diff options
Diffstat (limited to 'compute_kernel_writer/include')
-rw-r--r-- | compute_kernel_writer/include/ckw/KernelWriter.h | 24 | ||||
-rw-r--r-- | compute_kernel_writer/include/ckw/TileOperand.h | 24 |
2 files changed, 33 insertions, 15 deletions
diff --git a/compute_kernel_writer/include/ckw/KernelWriter.h b/compute_kernel_writer/include/ckw/KernelWriter.h index 85ae47f686..cfd24d35a3 100644 --- a/compute_kernel_writer/include/ckw/KernelWriter.h +++ b/compute_kernel_writer/include/ckw/KernelWriter.h @@ -28,7 +28,6 @@ #include "ckw/TileOperand.h" #include <memory> -#include <set> #include <string> namespace ckw @@ -103,23 +102,30 @@ public: * * @returns The created tile operand */ - virtual TileOperand &declare_tile(const std::string &name, const TileInfo &tile_info) = 0; + virtual TileOperand declare_tile(const std::string &name, const TileInfo &tile_info) = 0; protected: int32_t id_space() const; - /** Pure virtual function to be overridden by language specific subclasses to add a tile operand to the kernel */ - virtual TileOperand &add_operand(const std::string &name, const TileInfo &tile_info) = 0; - - /** Add a tile operand to the operand list */ - TileOperand &add_operand(std::unique_ptr<TileOperand> &operand_ptr); - /** Generate full variable name by prefixing it with id space */ std::string generate_full_name(const std::string &name) const; + /** Create a new tile operand referring to the specified tile object. + * + * This class has friendship relationship with @ref TileOperand which allows it + * to access the private constructor. + */ + static TileOperand create_tile_operand(ITile &tile); + + /** Get the reference to tile object from the tile operand. + * + * This class has friendship relationship with @ref TileOperand which allows it + * to access the private reference to the private tile field. + */ + static ITile &get_tile(const TileOperand &operand); + private: int32_t _id_space{ 0 }; - std::set<std::unique_ptr<TileOperand>> _operands {}; }; } // namespace ckw diff --git a/compute_kernel_writer/include/ckw/TileOperand.h b/compute_kernel_writer/include/ckw/TileOperand.h index abd3e0ac97..fe44b73e82 100644 --- a/compute_kernel_writer/include/ckw/TileOperand.h +++ b/compute_kernel_writer/include/ckw/TileOperand.h @@ -22,20 +22,32 @@ * SOFTWARE. */ -#ifndef CKW_INCLUDE_CKW_TILEOPERAND -#define CKW_INCLUDE_CKW_TILEOPERAND +#ifndef CKW_INCLUDE_CKW_TILEOPERAND_H +#define CKW_INCLUDE_CKW_TILEOPERAND_H namespace ckw { -/** Tile operand which can be either scalar, vector or 2D tile. */ +class KernelWriter; +class ITile; + +/** A tile operand refers to a tile object that can be used for kernel writing. */ class TileOperand { public: - /* Destructor */ - virtual ~TileOperand(); + // The constructor and _tile field is completely hidden from the public API to avoid any misuse. + // Only kernel writer class interacts with tile operand hence we allow it to access this field. + friend class KernelWriter; + +private: + // These are hidden from the public API to avoid any misuse. + + /** Initialize a new instance of @ref TileOperand class for the given tile. */ + TileOperand(ITile &tile); + + ITile &_tile; }; } // namespace ckw -#endif /* COMPUTE_KERNEL_WRITER_INCLUDE_CKW_TILEOPERAND */ +#endif // CKW_INCLUDE_CKW_TILEOPERAND_H |