1 /*========================== begin_copyright_notice ============================ 2 3 Copyright (C) 2017-2021 Intel Corporation 4 5 SPDX-License-Identifier: MIT 6 7 ============================= end_copyright_notice ===========================*/ 8 9 #ifndef VISA_KERNEL_H 10 #define VISA_KERNEL_H 11 #include "VISABuilderAPIDefinition.h" 12 #include "Common_ISA_util.h" 13 #include "BuildCISAIR.h" 14 #include "visa_wa.h" 15 #include "Mem_Manager.h" 16 #include "JitterDataStruct.h" 17 #include "KernelInfo.h" 18 //#include "G4_IR.hpp" // for PhyRegPool 19 #include "Attributes.hpp" 20 #include "CompilerStats.h" 21 22 #include <list> 23 #include <map> 24 #include <string> 25 #include <vector> 26 #include <unordered_set> 27 28 #define MAX_ERROR_MSG_LEN 511 29 #define vISA_NUMBER_OF_OPNDS_IN_POOL 47 30 31 //forward declaration 32 namespace vISA 33 { 34 class G4_Kernel; 35 class DebugInfoFormat; 36 class BinaryEncodingBase; 37 } 38 39 // Class hierarchy is as follows: 40 // VISAKernel -> Abstract class that declares virtual functions to build a kernel object 41 // VISAFunction : VISAKernel -> Abstract class that declares function specific APIs 42 // VISAKernelImpl : VISAFunction -> Implementation for all APIs in VISAKernel and VISAFunction 43 class VISAKernelImpl : public VISAFunction 44 { 45 friend class VISAKernel_format_provider; 46 47 public: VISAKernelImpl(enum VISA_BUILD_TYPE type,CISA_IR_Builder * cisaBuilder,const char * name)48 VISAKernelImpl(enum VISA_BUILD_TYPE type, CISA_IR_Builder* cisaBuilder, const char* name) 49 : m_mem(4096), m_CISABuilder(cisaBuilder), m_options(cisaBuilder->getOptions()) 50 { 51 mBuildOption = m_CISABuilder->getBuilderOption(); 52 m_magic_number = COMMON_ISA_MAGIC_NUM; 53 m_major_version = m_CISABuilder->getMajorVersion(); 54 m_minor_version = m_CISABuilder->getMinorVersion(); 55 m_var_info_count = 0; 56 m_addr_info_count = 0; 57 m_pred_info_count = 0; 58 m_sampler_count = 0; 59 m_surface_count = 0; 60 m_input_count = 0; 61 m_attribute_count = 0; 62 m_label_count = 0; 63 64 m_string_pool_size = 0; 65 m_address_info_size = 0; 66 m_predicate_info_size = 0; 67 m_label_info_size = 0; 68 m_input_info_size = 0; 69 m_attribute_info_size = 0; 70 m_instruction_size = 0; 71 m_genx_binary_size = 0; 72 m_kernel_data_size = 0; 73 m_genx_binary_buffer = NULL; 74 m_genx_debug_info_size = 0; 75 m_genx_debug_info_buffer = NULL; 76 m_bytes_written_cisa_buffer = 0; 77 m_input_offset = 0; 78 m_num_pred_vars = 0; 79 m_sampler_info_size = 0; 80 m_type = type; 81 82 memset(&m_cisa_kernel, 0, sizeof(kernel_format_t)); 83 m_jitInfo = NULL; 84 m_kernelInfo = NULL; 85 m_kernel = NULL; 86 m_builder = NULL; 87 88 m_inputSize = 0; 89 m_opndCounter = 0; 90 91 varNameCount = COMMON_ISA_NUM_PREDEFINED_VAR_VER_3; 92 addressNameCount = 0; 93 predicateNameCount = COMMON_ISA_NUM_PREDEFINED_PRED; 94 surfaceNameCount = COMMON_ISA_NUM_PREDEFINED_SURF_VER_3_1; 95 samplerNameCount = 0; 96 unknownNameCount = 0; 97 m_functionId = 0; 98 m_vISAInstCount = -1; 99 100 mIsFCCallableKernel = false; 101 mIsFCCallerKernel = false; 102 mIsFCComposableKernel = false; 103 104 // Initialize first level scope of the map 105 m_GenNamedVarMap.emplace_back(); 106 107 createKernelAttributes(); 108 createReservedKeywordSet(); 109 110 InitializeKernel(name); 111 SetGTPinInit(m_CISABuilder->getGtpinInit()); 112 } 113 alloc(size_t sz)114 void* alloc(size_t sz) { return m_mem.alloc(sz); } 115 116 virtual ~VISAKernelImpl(); 117 new(size_t sz,vISA::Mem_Manager & m)118 void *operator new(size_t sz, vISA::Mem_Manager& m) { return m.alloc(sz); }; 119 getKernelAttributes()120 vISA::Attributes* getKernelAttributes() { return m_kernelAttrs; } 121 // Temporary function to move options to attributes! 122 void finalizeAttributes(); 123 void finalizeKernel(); 124 unsigned long writeInToCisaBinaryBuffer(const void * value, int size); getBytesWritten()125 unsigned long getBytesWritten() { return m_bytes_written_cisa_buffer; } 126 127 void setName(const char* n); getName()128 const char* getName() const { return m_name.c_str(); } 129 string_pool_entry** new_string_pool(); 130 unsigned short get_hash_key(const char* str); 131 getKernelFormat()132 const kernel_format_t* getKernelFormat() const { return &m_cisa_kernel; } 133 /***************** START HELPER FUNCTIONS ********************/ 134 int CreateStateInstUse(VISA_StateOpndHandle *&cisa_opnd, unsigned int index); 135 int CreateStateInstUseFastPath(VISA_StateOpndHandle *&cisa_opnd, CISA_GEN_VAR *decl); 136 Common_ISA_Input_Class GetInputClass(Common_ISA_Var_Class var_class); 137 138 void addVarInfoToList(CISA_GEN_VAR * t); 139 140 void addAddrToList(CISA_GEN_VAR * addr); 141 142 void addPredToList(CISA_GEN_VAR * pred); 143 144 void addSampler(CISA_GEN_VAR * state); 145 146 void addSurface(CISA_GEN_VAR * state); 147 148 void addAttribute(const char *input_name, attribute_info_t *attr_temp); 149 150 int addLabel(label_info_t * lbl, char * label_name); 151 152 uint32_t addStringPool(std::string strng); 153 154 void addInstructionToEnd(CisaFramework::CisaInst * inst); 155 int addFunctionDirective(char * func_name); 156 157 // The user of CreateVISALabelVar should be responsible for the management 158 // of the created labels. The following are the example APIs to manage vISA 159 // labels that assumes every block/subroutine/function in kernel has an 160 // unique name. 161 VISA_LabelOpnd * getLabelOperandFromFunctionName(const std::string &name); 162 VISA_LabelOpnd * getLabelOpndFromLabelName(const std::string &label_name); 163 bool setLabelOpndNameMap(const std::string &label_name, VISA_LabelOpnd * lbl, VISA_Label_Kind kind); 164 165 void setGenxDebugInfoBuffer(char * buffer, unsigned long size); 166 VISA_opnd* CreateOtherOpndHelper(int num_pred_desc_operands, int num_operands, VISA_INST_Desc *inst_desc, unsigned int value, bool hasSubOpcode = false, uint8_t subOpcode = 0); 167 VISA_opnd* CreateOtherOpnd(unsigned int value, VISA_Type opndType); 168 169 vISA::G4_Operand* CommonISABuildPreDefinedSrc(int index, uint16_t vStride, uint16_t width, 170 uint16_t hStride, uint8_t rowOffset, uint8_t colOffset, VISA_Modifier modifier); 171 /***************** END HELPER FUNCTIONS **********************/ getInstructionListBegin()172 std::list<CisaFramework::CisaInst *>::iterator getInstructionListBegin() { return m_instruction_list.begin(); } getInstructionListEnd()173 std::list<CisaFramework::CisaInst *>::iterator getInstructionListEnd() { return m_instruction_list.end(); } getInstructionListBegin()174 std::list<CisaFramework::CisaInst *>::const_iterator getInstructionListBegin() const { return m_instruction_list.cbegin(); } getInstructionListEnd()175 std::list<CisaFramework::CisaInst *>::const_iterator getInstructionListEnd() const { return m_instruction_list.cend(); } 176 getGenxBinarySize()177 unsigned long getGenxBinarySize() { return m_genx_binary_size; } 178 getGenxBinaryBuffer()179 char * getGenxBinaryBuffer() { return m_genx_binary_buffer; } 180 getCisaBinarySize()181 unsigned long getCisaBinarySize() { return m_cisa_binary_size; } 182 getCisaBinaryBuffer()183 char * getCisaBinaryBuffer() { return m_cisa_binary_buffer; } 184 getInputOffset()185 unsigned long getInputOffset() { return m_input_offset; } getNumPredVars()186 unsigned int getNumPredVars() { return m_num_pred_vars; } 187 getKernelDataSize()188 unsigned long getKernelDataSize() { return m_kernel_data_size; } getIsKernel()189 bool getIsKernel() const { return m_type == VISA_BUILD_TYPE::KERNEL; } getIsFunction()190 bool getIsFunction() const { return m_type == VISA_BUILD_TYPE::FUNCTION; } getIsPayload()191 bool getIsPayload() const { return m_type == VISA_BUILD_TYPE::PAYLOAD; } getType()192 enum VISA_BUILD_TYPE getType() const { return m_type; } setType(enum VISA_BUILD_TYPE _type)193 void setType(enum VISA_BUILD_TYPE _type) { m_type = _type; } getCodeOffset()194 unsigned long getCodeOffset() { return m_cisa_kernel.entry; } 195 196 CISA_GEN_VAR * getDeclFromName(const std::string &name); 197 bool declExistsInCurrentScope(const std::string &name) const; 198 bool setNameIndexMap(const std::string &name, CISA_GEN_VAR *, bool unique = false); 199 void pushIndexMapScopeLevel(); 200 void popIndexMapScopeLevel(); 201 getKernel()202 vISA::G4_Kernel* getKernel() const { return m_kernel; } getIRBuilder()203 vISA::IR_Builder* getIRBuilder() const { return m_builder; } getCISABuilder()204 CISA_IR_Builder* getCISABuilder() const { return m_CISABuilder; } 205 206 int getVISAOffset() const; 207 void CopyVars(VISAKernelImpl* from); 208 209 210 /***************** START EXPOSED APIS *************************/ 211 VISA_BUILDER_API int CreateVISAGenVar(VISA_GenVar *& decl, const char *varName, int numberElements, VISA_Type dataType, 212 VISA_Align varAlign, VISA_GenVar *parentDecl = NULL, int aliasOffset = 0) override; 213 214 VISA_BUILDER_API int CreateVISAAddrVar(VISA_AddrVar *& decl, const char *varName, unsigned int numberElements) override; 215 216 VISA_BUILDER_API int AddKernelAttribute(const char* name, int size, const void *value) override; 217 218 VISA_BUILDER_API int CreateVISAPredVar(VISA_PredVar *& decl, const char* varName, unsigned short numberElements) override; 219 220 VISA_BUILDER_API int AddAttributeToVar(VISA_PredVar *decl, const char* varName, unsigned int size, void *val) override; 221 222 VISA_BUILDER_API int AddAttributeToVar(VISA_SurfaceVar *decl, const char* varName, unsigned int size, void *val) override; 223 224 VISA_BUILDER_API int AddAttributeToVar(VISA_GenVar *decl, const char* name, unsigned int size, void *val) override; 225 226 VISA_BUILDER_API int AddAttributeToVar(VISA_AddrVar *decl, const char* name, unsigned int size, void *val) override; 227 228 VISA_BUILDER_API int CreateVISASamplerVar(VISA_SamplerVar *&decl, const char* name, unsigned int numberElements) override; 229 230 VISA_BUILDER_API int CreateVISASurfaceVar(VISA_SurfaceVar *&decl, const char* name, unsigned int numberElements) override; 231 232 VISA_BUILDER_API int CreateVISALabelVar(VISA_LabelOpnd *& opnd, const char* name, VISA_Label_Kind kind) override; 233 234 VISA_BUILDER_API int CreateVISAImplicitInputVar(VISA_GenVar *decl, unsigned short offset, unsigned short size, unsigned short kind) override; 235 236 VISA_BUILDER_API int CreateVISAInputVar(VISA_GenVar *decl, unsigned short offset, unsigned short size) override; 237 238 VISA_BUILDER_API int CreateVISAInputVar(VISA_SamplerVar *decl, unsigned short offset, unsigned short size) override; 239 240 VISA_BUILDER_API int CreateVISAInputVar(VISA_SurfaceVar *decl, unsigned short offset, unsigned short size) override; 241 242 VISA_BUILDER_API int CreateVISAAddressSrcOperand(VISA_VectorOpnd *&opnd, VISA_AddrVar *decl, unsigned int offset, unsigned int width) override; 243 244 VISA_BUILDER_API int CreateVISAAddressDstOperand(VISA_VectorOpnd *&opnd, VISA_AddrVar *decl, unsigned int offset) override; 245 246 VISA_BUILDER_API int CreateVISAAddressOfOperand(VISA_VectorOpnd *&cisa_opnd, VISA_GenVar *decl, unsigned int offset) override; 247 248 VISA_BUILDER_API int CreateVISAAddressOfOperand(VISA_VectorOpnd *&cisa_opnd, VISA_SurfaceVar *decl, unsigned int offset) override; 249 250 VISA_BUILDER_API int CreateVISAIndirectSrcOperand(VISA_VectorOpnd *& opnd, VISA_AddrVar *cisa_decl, VISA_Modifier mod, unsigned int addrOffset, short immediateOffset, 251 unsigned short verticalStride, unsigned short width, unsigned short horizontalStride, VISA_Type type) override; 252 253 VISA_BUILDER_API int CreateVISAIndirectDstOperand(VISA_VectorOpnd *& opnd, VISA_AddrVar *decl, unsigned int addrOffset, short immediateOffset, 254 unsigned short horizontalStride, VISA_Type type) override; 255 256 VISA_BUILDER_API int CreateVISAIndirectOperandVxH(VISA_VectorOpnd *& cisa_opnd, VISA_AddrVar *decl, unsigned int addrOffset, short immediateOffset, VISA_Type type) override; 257 258 VISA_BUILDER_API int CreateVISAPredicateOperand(VISA_PredOpnd *& opnd, VISA_PredVar *decl, VISA_PREDICATE_STATE state, VISA_PREDICATE_CONTROL cntrl) override; 259 260 VISA_BUILDER_API int CreateVISASrcOperand(VISA_VectorOpnd *& opnd, VISA_GenVar *cisa_decl, VISA_Modifier mod, unsigned short vStride, unsigned short width, unsigned short hStride, 261 unsigned char rowOffset, unsigned char colOffset) override; 262 263 VISA_BUILDER_API int CreateVISADstOperand(VISA_VectorOpnd *&opnd, VISA_GenVar *decl, unsigned short hStride, unsigned char rowOffset, unsigned char colOffset) override; 264 265 VISA_BUILDER_API int CreateVISAImmediate(VISA_VectorOpnd *&opnd, const void *val, VISA_Type type) override; 266 267 VISA_BUILDER_API int CreateVISAStateOperand(VISA_VectorOpnd *&opnd, VISA_SurfaceVar *decl, unsigned char offset, bool useAsDst) override; 268 269 VISA_BUILDER_API int CreateVISAStateOperand(VISA_VectorOpnd *&opnd, VISA_SurfaceVar *decl, uint8_t size, unsigned char offset, bool useAsDst) override; 270 271 VISA_BUILDER_API int CreateVISAStateOperand(VISA_VectorOpnd *&opnd, VISA_SamplerVar *decl, unsigned char offset, bool useAsDst) override; 272 273 VISA_BUILDER_API int CreateVISAStateOperand(VISA_VectorOpnd *&opnd, VISA_SamplerVar *decl, uint8_t size, unsigned char offset, bool useAsDst) override; 274 275 VISA_BUILDER_API int CreateVISAStateOperandHandle(VISA_StateOpndHandle *&opnd, VISA_SurfaceVar *decl) override; 276 277 VISA_BUILDER_API int CreateVISAStateOperandHandle(VISA_StateOpndHandle *&opnd, VISA_SamplerVar *decl) override; 278 279 VISA_BUILDER_API int CreateVISARawOperand(VISA_RawOpnd *& opnd, VISA_GenVar *decl, unsigned short offset) override; 280 281 VISA_BUILDER_API int CreateVISANullRawOperand(VISA_RawOpnd *& opnd, bool isDst) override; 282 283 VISA_BUILDER_API int GetPredefinedVar(VISA_GenVar *&predDcl, PreDefined_Vars varName) override; 284 285 VISA_BUILDER_API int GetPredefinedSurface(VISA_SurfaceVar *&surfDcl, PreDefined_Surface surfaceName) override; 286 287 VISA_BUILDER_API int GetBindlessSampler(VISA_SamplerVar *&samplerDcl) override; 288 289 VISA_BUILDER_API int SetFunctionInputSize(unsigned int size) override; 290 291 VISA_BUILDER_API int SetFunctionReturnSize(unsigned int size) override; 292 293 /********** APPEND INSTRUCTION APIS START ******************/ 294 VISA_BUILDER_API int AppendVISAArithmeticInst(ISA_Opcode opcode, VISA_PredOpnd *pred, bool satMode, VISA_EMask_Ctrl emask, 295 VISA_Exec_Size executionSize, VISA_VectorOpnd *tmpDst, VISA_VectorOpnd *src0) override; 296 297 VISA_BUILDER_API int AppendVISAArithmeticInst(ISA_Opcode opcode, VISA_PredOpnd *pred, bool satMode, VISA_EMask_Ctrl emask, 298 VISA_Exec_Size executionSize, VISA_VectorOpnd *tmpDst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1) override; 299 300 VISA_BUILDER_API int AppendVISAArithmeticInst(ISA_Opcode opcode, VISA_PredOpnd *pred, bool satMode, VISA_EMask_Ctrl emask, 301 VISA_Exec_Size executionSize, VISA_VectorOpnd *tmpDst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1, VISA_VectorOpnd *src2) override; 302 303 VISA_BUILDER_API int AppendVISATwoDstArithmeticInst(ISA_Opcode opcode, VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, 304 VISA_Exec_Size executionSize, VISA_VectorOpnd *dst1, VISA_VectorOpnd *carry_borrow, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1) override; 305 306 VISA_BUILDER_API int AppendVISALogicOrShiftInst(ISA_Opcode opcode, VISA_PredOpnd *pred, bool satMode, VISA_EMask_Ctrl emask, 307 VISA_Exec_Size executionSize, VISA_VectorOpnd *dst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1, VISA_VectorOpnd *src2 = NULL, 308 VISA_VectorOpnd *src3 = NULL) override; 309 310 VISA_BUILDER_API int AppendVISALogicOrShiftInst(ISA_Opcode opcode, VISA_EMask_Ctrl emask, 311 VISA_Exec_Size executionSize, VISA_PredVar *dst, VISA_PredVar *src0, VISA_PredVar *src1) override; 312 313 VISA_BUILDER_API int AppendVISAAddrAddInst(VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_VectorOpnd *dst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1) override; 314 315 VISA_BUILDER_API int AppendVISADataMovementInst(ISA_Opcode opcode, VISA_PredOpnd *pred, bool satMod, VISA_EMask_Ctrl emask, 316 VISA_Exec_Size executionSize, VISA_VectorOpnd *dst, VISA_VectorOpnd *src0) override; 317 318 VISA_BUILDER_API int AppendVISADataMovementInst(ISA_Opcode opcode, VISA_PredOpnd *pred, bool satMod, VISA_EMask_Ctrl emask, 319 VISA_Exec_Size executionSize, VISA_VectorOpnd *dst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1) override; 320 321 VISA_BUILDER_API int AppendVISAPredicateMove(VISA_VectorOpnd *dst, VISA_PredVar *src0) override; 322 323 VISA_BUILDER_API int AppendVISASetP(VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_PredVar *dst, VISA_VectorOpnd *src0) override; 324 325 VISA_BUILDER_API int AppendVISAMinMaxInst(CISA_MIN_MAX_SUB_OPCODE subOpcode, bool satMod, VISA_EMask_Ctrl emask, 326 VISA_Exec_Size executionSize, VISA_VectorOpnd *dst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1) override; 327 328 VISA_BUILDER_API int AppendVISAComparisonInst(VISA_Cond_Mod sub_op, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_PredVar *dst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1) override; 329 330 VISA_BUILDER_API int AppendVISAComparisonInst(VISA_Cond_Mod sub_op, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_VectorOpnd *dst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1) override; 331 332 VISA_BUILDER_API int AppendVISACFGotoInst(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_LabelOpnd *label) override; 333 334 VISA_BUILDER_API int AppendVISACFLabelInst(VISA_LabelOpnd *label) override; 335 336 VISA_BUILDER_API int AppendVISACFJmpInst(VISA_PredOpnd *pred, VISA_LabelOpnd *label) override; 337 338 VISA_BUILDER_API int AppendVISACFCallInst(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_LabelOpnd *label) override; 339 340 VISA_BUILDER_API int AppendVISACFRetInst(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize) override; 341 342 VISA_BUILDER_API int AppendVISACFFunctionCallInst(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, 343 VISA_Exec_Size executionSize, std::string funcName, unsigned char argSize, unsigned char returnSize) override; 344 345 VISA_BUILDER_API int AppendVISACFIndirectFuncCallInst(VISA_PredOpnd *pred, 346 VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 347 VISA_VectorOpnd* funcAddr, uint8_t argSize, uint8_t returnSize) override; 348 349 VISA_BUILDER_API int AppendVISACFSymbolInst(std::string symbolName, VISA_VectorOpnd* dst) override; 350 351 VISA_BUILDER_API int AppendVISACFFunctionRetInst(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize) override; 352 353 VISA_BUILDER_API int AppendVISACFSwitchJMPInst(VISA_VectorOpnd *index, unsigned char labelCount, VISA_LabelOpnd **labels) override; 354 355 VISA_BUILDER_API int AppendVISASurfAccessDwordAtomicInst( 356 VISA_PredOpnd *pred, VISAAtomicOps subOpc, bool is16Bit, 357 VISA_EMask_Ctrl eMask, VISA_Exec_Size execSize, 358 VISA_StateOpndHandle *surface, VISA_RawOpnd *offsets, 359 VISA_RawOpnd *src0, VISA_RawOpnd *src1, VISA_RawOpnd *dst) override; 360 361 VISA_BUILDER_API int AppendVISASurfAccessGatherScatterInst(ISA_Opcode opcode, VISA_EMask_Ctrl emask, GATHER_SCATTER_ELEMENT_SIZE elementSize, 362 VISA_Exec_Size executionSize, VISA_StateOpndHandle *surface, VISA_VectorOpnd *globalOffset, VISA_RawOpnd *elementOffset, VISA_RawOpnd *srcDst) override; 363 364 VISA_BUILDER_API int AppendVISASurfAccessGather4Scatter4TypedInst(ISA_Opcode opcode, 365 VISA_PredOpnd *pred, 366 VISAChannelMask chMask, 367 VISA_EMask_Ctrl emask, 368 VISA_Exec_Size executionSize, 369 VISA_StateOpndHandle *surface, 370 VISA_RawOpnd *uOffset, 371 VISA_RawOpnd *vOffset, 372 VISA_RawOpnd *rOffset, 373 VISA_RawOpnd *lod, 374 VISA_RawOpnd *dst) override; 375 376 VISA_BUILDER_API int AppendVISASurfAccessGather4Scatter4ScaledInst(ISA_Opcode opcode, 377 VISA_PredOpnd *pred, 378 VISA_EMask_Ctrl eMask, 379 VISA_Exec_Size execSize, 380 VISAChannelMask chMask, 381 VISA_StateOpndHandle *surface, 382 VISA_VectorOpnd *globalOffset, 383 VISA_RawOpnd *offsets, 384 VISA_RawOpnd *dstSrc) override; 385 386 VISA_BUILDER_API int AppendVISASurfAccessScatterScaledInst(ISA_Opcode opcode, 387 VISA_PredOpnd *pred, 388 VISA_EMask_Ctrl eMask, 389 VISA_Exec_Size execSize, 390 VISA_SVM_Block_Num numBlocks, 391 VISA_StateOpndHandle *surface, 392 VISA_VectorOpnd *globalOffset, 393 VISA_RawOpnd *offsets, 394 VISA_RawOpnd *dstSrc) override; 395 396 VISA_BUILDER_API int AppendVISASurfAccessMediaLoadStoreInst(ISA_Opcode opcode, MEDIA_LD_mod modifier, VISA_StateOpndHandle *surface, unsigned char blockWidth, 397 unsigned char blockHeight, VISA_VectorOpnd *xOffset, VISA_VectorOpnd *yOffset, VISA_RawOpnd *srcDst, 398 CISA_PLANE_ID plane = CISA_PLANE_Y) override; 399 400 VISA_BUILDER_API int AppendVISASurfAccessOwordLoadStoreInst(ISA_Opcode opcode, VISA_EMask_Ctrl emask, VISA_StateOpndHandle *surface, VISA_Oword_Num size, VISA_VectorOpnd *offset, VISA_RawOpnd *srcDst) override; 401 402 VISA_BUILDER_API int AppendVISASvmBlockStoreInst(VISA_Oword_Num size, bool unaligned, VISA_VectorOpnd* address, VISA_RawOpnd *srcDst) override; 403 404 VISA_BUILDER_API int AppendVISASvmBlockLoadInst(VISA_Oword_Num size, bool unaligned, VISA_VectorOpnd* address, VISA_RawOpnd *srcDst) override; 405 406 VISA_BUILDER_API int AppendVISASvmScatterInst(VISA_PredOpnd *pred, 407 VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 408 VISA_SVM_Block_Type blockType, VISA_SVM_Block_Num numBlocks, 409 VISA_RawOpnd* address, VISA_RawOpnd *srcDst) override; 410 411 VISA_BUILDER_API int AppendVISASvmGatherInst(VISA_PredOpnd *pred, 412 VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 413 VISA_SVM_Block_Type blockType, VISA_SVM_Block_Num numBlocks, 414 VISA_RawOpnd* address, VISA_RawOpnd *srcDst) override; 415 416 VISA_BUILDER_API int 417 AppendVISASvmAtomicInst(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, 418 VISA_Exec_Size executionSize, 419 VISAAtomicOps op, unsigned short bitwidth, 420 VISA_RawOpnd *addresses, VISA_RawOpnd *src0, 421 VISA_RawOpnd *src1, VISA_RawOpnd *dst) override; 422 423 VISA_BUILDER_API int AppendVISASvmGather4ScaledInst(VISA_PredOpnd *pred, 424 VISA_EMask_Ctrl eMask, 425 VISA_Exec_Size execSize, 426 VISAChannelMask channelMask, 427 VISA_VectorOpnd *address, 428 VISA_RawOpnd *offsets, 429 VISA_RawOpnd *dst) override; 430 431 VISA_BUILDER_API int AppendVISASvmScatter4ScaledInst(VISA_PredOpnd *pred, 432 VISA_EMask_Ctrl eMask, 433 VISA_Exec_Size execSize, 434 VISAChannelMask channelMask, 435 VISA_VectorOpnd *address, 436 VISA_RawOpnd *offsets, 437 VISA_RawOpnd *src) override; 438 439 VISA_BUILDER_API int AppendVISASILoad(VISA_StateOpndHandle *surface, VISAChannelMask channel, bool isSIMD16, 440 VISA_RawOpnd *uOffset, VISA_RawOpnd *vOffset, VISA_RawOpnd *rOffset, VISA_RawOpnd *dst) override; 441 442 VISA_BUILDER_API int AppendVISASISample(VISA_EMask_Ctrl emask, VISA_StateOpndHandle *surface, VISA_StateOpndHandle *sampler, VISAChannelMask channel, bool isSIMD16, 443 VISA_RawOpnd *uOffset, VISA_RawOpnd *vOffset, VISA_RawOpnd *rOffset, VISA_RawOpnd *dst) override; 444 445 VISA_BUILDER_API int AppendVISASISampleUnorm(VISA_StateOpndHandle *surface, VISA_StateOpndHandle *sampler, VISAChannelMask channel, 446 VISA_VectorOpnd *uOffset, VISA_VectorOpnd *vOffset, VISA_VectorOpnd *deltaU, VISA_VectorOpnd *deltaV, VISA_RawOpnd *dst, CHANNEL_OUTPUT_FORMAT out) override; 447 448 VISA_BUILDER_API int AppendVISASyncInst(ISA_Opcode opcode, unsigned char mask = 0) override; 449 VISA_BUILDER_API int AppendVISAWaitInst(VISA_VectorOpnd* mask) override; 450 451 VISA_BUILDER_API int AppendVISASplitBarrierInst(bool isSignal) override; 452 453 VISA_BUILDER_API int AppendVISAMiscFileInst(const char *fileName) override; 454 455 VISA_BUILDER_API int AppendVISAMiscLOC(unsigned int lineNumber) override; 456 457 VISA_BUILDER_API int AppendVISADebugLinePlaceholder() override; 458 459 VISA_BUILDER_API int AppendVISAMiscRawSend(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, unsigned char modifiers, 460 unsigned int exMsgDesc, unsigned char srcSize, unsigned char dstSize, VISA_VectorOpnd *desc, 461 VISA_RawOpnd *src, VISA_RawOpnd *dst) override; 462 VISA_BUILDER_API int AppendVISAMiscRawSends(VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, unsigned char modifiers, 463 unsigned ffid, VISA_VectorOpnd *exMsgDesc, unsigned char src0Size, unsigned char src1Size, unsigned char dstSize, VISA_VectorOpnd *desc, 464 VISA_RawOpnd *src0, VISA_RawOpnd *src1, VISA_RawOpnd *dst, bool hasEOT) override; 465 466 VISA_BUILDER_API int AppendVISAMiscVME_FBR(VISA_StateOpndHandle *surface, VISA_RawOpnd *UNIInput, VISA_RawOpnd *FBRInput, VISA_VectorOpnd* FBRMbMode, VISA_VectorOpnd *FBRSubMbShape, 467 VISA_VectorOpnd *FBRSubPredMode, VISA_RawOpnd *output) override; 468 469 VISA_BUILDER_API int AppendVISAMiscVME_IME(VISA_StateOpndHandle *surface, unsigned char streamMode, unsigned char searchControlMode, VISA_RawOpnd *UNIInput, 470 VISA_RawOpnd *IMEInput, VISA_RawOpnd *ref0, VISA_RawOpnd *ref1, VISA_RawOpnd *costCenter, VISA_RawOpnd *output) override; 471 472 VISA_BUILDER_API int AppendVISAMiscVME_SIC(VISA_StateOpndHandle *surface, VISA_RawOpnd *UNIInput, VISA_RawOpnd *SICInput, VISA_RawOpnd *output) override; 473 474 VISA_BUILDER_API int AppendVISAMiscVME_IDM(VISA_StateOpndHandle *surface, VISA_RawOpnd *UNIInput, VISA_RawOpnd *IDMInput, VISA_RawOpnd *output) override; 475 476 VISA_BUILDER_API int AppendVISAMEAVS(VISA_StateOpndHandle *surface, VISA_StateOpndHandle *sampler, VISAChannelMask channel, VISA_VectorOpnd *uOffset, 477 VISA_VectorOpnd *vOffset, VISA_VectorOpnd *deltaU, VISA_VectorOpnd *deltaV, VISA_VectorOpnd *u2d, 478 VISA_VectorOpnd *v2d, VISA_VectorOpnd *groupID, VISA_VectorOpnd *verticalBlockNumber, OutputFormatControl cntrl, 479 AVSExecMode execMode, VISA_VectorOpnd *iefBypass, VISA_RawOpnd *dst) override; 480 481 VISA_BUILDER_API int AppendVISAVABooleanCentroid(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 482 VISA_VectorOpnd *vOffset, VISA_VectorOpnd *vSize, VISA_VectorOpnd *hSize, VISA_RawOpnd *dst) override; 483 VISA_BUILDER_API int AppendVISAVACentroid(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 484 VISA_VectorOpnd *vOffset, VISA_VectorOpnd *vSize, VISA_RawOpnd *dst) override; 485 486 VISA_BUILDER_API int AppendVISAVAConvolve(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 487 VISA_VectorOpnd *vOffset, CONVExecMode execMode, bool isBigKernel, VISA_RawOpnd *dst) override; 488 489 VISA_BUILDER_API int AppendVISAVAErodeDilate(EDMode subOp, VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 490 VISA_VectorOpnd *vOffset, EDExecMode execMode, VISA_RawOpnd *dst) override; 491 492 VISA_BUILDER_API int AppendVISAVAMinMax(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 493 VISA_VectorOpnd *vOffset, VISA_VectorOpnd *mmMode, VISA_RawOpnd *dst) override; 494 495 VISA_BUILDER_API int AppendVISAVAMinMaxFilter(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 496 VISA_VectorOpnd *vOffset, OutputFormatControl cntrl, MMFExecMode execMode, VISA_VectorOpnd *mmfMode, VISA_RawOpnd *dst) override; 497 498 VISA_BUILDER_API int AppendVISAVACorrelationSearch(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 499 VISA_VectorOpnd *vOffset, VISA_VectorOpnd *vOrigin, VISA_VectorOpnd *hOrigin, 500 VISA_VectorOpnd *xDirectionSize, VISA_VectorOpnd *yDirectionSize, 501 VISA_VectorOpnd *xDirectionSearchSize, VISA_VectorOpnd *yDirectionSearchSize, 502 VISA_RawOpnd *dst) override; 503 504 VISA_BUILDER_API int AppendVISAVAFloodFill(bool is8Connect, VISA_RawOpnd *pixelMaskHDirection, 505 VISA_VectorOpnd *pixelMaskVDirectionLeft, VISA_VectorOpnd *pixelMaskVDirectionRight, 506 VISA_VectorOpnd *loopCount, VISA_RawOpnd *dst) override; 507 508 VISA_BUILDER_API int AppendVISAVALBPCorrelation(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 509 VISA_VectorOpnd *vOffset, VISA_VectorOpnd *disparity, 510 VISA_RawOpnd *dst) override; 511 512 VISA_BUILDER_API int AppendVISAVALBPCreation(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 513 VISA_VectorOpnd *vOffset, LBPCreationMode mode, 514 VISA_RawOpnd *dst) override; 515 516 VISA_BUILDER_API int AppendVISAVAConvolve1D(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 517 VISA_VectorOpnd *vOffset, CONVExecMode mode, Convolve1DDirection direction, VISA_RawOpnd *dst) override; 518 519 VISA_BUILDER_API int AppendVISAVAConvolve1Pixel(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 520 VISA_VectorOpnd *vOffset, CONV1PixelExecMode mode, VISA_RawOpnd *offsets, VISA_RawOpnd *dst) override; 521 522 VISA_BUILDER_API int AppendVISAVAHDCConvolve(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 523 VISA_VectorOpnd *vOffset, HDCReturnFormat returnFormat, CONVHDCRegionSize regionSize, 524 VISA_StateOpndHandle *dstSurface, VISA_VectorOpnd *xOffset, VISA_VectorOpnd *yOffset) override; 525 526 VISA_BUILDER_API int AppendVISAVAHDCErodeDilate(EDMode subOp, VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 527 VISA_VectorOpnd *vOffset, VISA_StateOpndHandle *dstSurface, VISA_VectorOpnd *xOffset, 528 VISA_VectorOpnd *yOffset) override; 529 530 VISA_BUILDER_API int AppendVISAVAHDCMinMaxFilter(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 531 VISA_VectorOpnd *vOffset, HDCReturnFormat returnFormat, MMFEnableMode mmfMode, 532 VISA_StateOpndHandle *dstSurface, VISA_VectorOpnd *xOffset, VISA_VectorOpnd *yOffset) override; 533 534 VISA_BUILDER_API int AppendVISAVAHDCLBPCorrelation(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 535 VISA_VectorOpnd *vOffset, VISA_VectorOpnd *disparity, 536 VISA_StateOpndHandle *dstSurface, VISA_VectorOpnd *xOffset, VISA_VectorOpnd *yOffset) override; 537 538 VISA_BUILDER_API int AppendVISAVAHDCLBPCreation(VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 539 VISA_VectorOpnd *vOffset, LBPCreationMode mode, 540 VISA_StateOpndHandle *dstSurface, VISA_VectorOpnd *xOffset, VISA_VectorOpnd *yOffset) override; 541 542 VISA_BUILDER_API int AppendVISAVAHDCConvolve1D(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 543 VISA_VectorOpnd *vOffset, HDCReturnFormat returnFormat, Convolve1DDirection direction, 544 VISA_StateOpndHandle *dstSurface, VISA_VectorOpnd *xOffset, VISA_VectorOpnd *yOffset) override; 545 546 VISA_BUILDER_API int AppendVISAVAHDCConvolve1Pixel(VISA_StateOpndHandle *sampler, VISA_StateOpndHandle *surface, VISA_VectorOpnd * uOffset, 547 VISA_VectorOpnd *vOffset, HDCReturnFormat returnFormat, VISA_RawOpnd *offsets, 548 VISA_StateOpndHandle *dstSurface, VISA_VectorOpnd *xOffset, VISA_VectorOpnd *yOffset) override; 549 550 VISA_BUILDER_API int AppendVISALifetime(VISAVarLifetime startOrEnd, VISA_VectorOpnd *varId) override; 551 552 VISA_BUILDER_API int AppendVISADpasInst( 553 ISA_Opcode opcode, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 554 VISA_RawOpnd *tmpDst, VISA_RawOpnd *src0, VISA_RawOpnd *src1, VISA_VectorOpnd *src2, 555 GenPrecision src2Precision, GenPrecision src1Precision, 556 uint8_t Depth, uint8_t Count) override; 557 558 VISA_BUILDER_API int AppendVISABfnInst( 559 uint8_t booleanFuncCtrl, VISA_PredOpnd *pred, bool satMode, VISA_EMask_Ctrl emask, 560 VISA_Exec_Size executionSize, VISA_VectorOpnd *tmpDst, VISA_VectorOpnd *src0, VISA_VectorOpnd *src1, VISA_VectorOpnd *src2) override; 561 562 VISA_BUILDER_API int AppendVISAQwordGatherInst(VISA_PredOpnd *pred, 563 VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 564 VISA_SVM_Block_Num numBlocks, VISA_StateOpndHandle *surface, 565 VISA_RawOpnd* address, VISA_RawOpnd *src) override; 566 567 VISA_BUILDER_API int AppendVISAQwordScatterInst(VISA_PredOpnd *pred, 568 VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 569 VISA_SVM_Block_Num numBlocks, VISA_StateOpndHandle *surface, 570 VISA_RawOpnd* address, VISA_RawOpnd *dst) override; 571 572 VISA_BUILDER_API int AppendVISALscUntypedLoad( 573 LSC_OP op, 574 LSC_SFID sfid, 575 VISA_PredOpnd *pred, 576 VISA_Exec_Size execSize, 577 VISA_EMask_Ctrl emask, 578 LSC_CACHE_OPTS cacheOpts, 579 LSC_ADDR addr, 580 LSC_DATA_SHAPE data, 581 VISA_VectorOpnd *surface, 582 VISA_RawOpnd *dstData, 583 VISA_RawOpnd *src0Addr 584 ) override; 585 VISA_BUILDER_API int AppendVISALscUntypedStore( 586 LSC_OP op, 587 LSC_SFID sfid, 588 VISA_PredOpnd *pred, 589 VISA_Exec_Size execSize, 590 VISA_EMask_Ctrl emask, 591 LSC_CACHE_OPTS cacheOpts, 592 LSC_ADDR addr, 593 LSC_DATA_SHAPE data, 594 VISA_VectorOpnd *surface, 595 VISA_RawOpnd *src0Addr, 596 VISA_RawOpnd *src1Data 597 ) override; 598 VISA_BUILDER_API int AppendVISALscUntypedAtomic( 599 LSC_OP op, 600 LSC_SFID sfid, 601 VISA_PredOpnd *pred, 602 VISA_Exec_Size execSize, 603 VISA_EMask_Ctrl emask, 604 LSC_CACHE_OPTS cacheOpts, 605 LSC_ADDR addr, 606 LSC_DATA_SHAPE data, 607 VISA_VectorOpnd *surface, 608 VISA_RawOpnd *dstReadBack, 609 VISA_RawOpnd *src0Addr, 610 VISA_RawOpnd *src1AtomOpnd1, 611 VISA_RawOpnd *src2AtomOpnd2) override; 612 VISA_BUILDER_API int AppendVISALscUntypedInst( 613 LSC_OP op, 614 LSC_SFID sfid, 615 VISA_PredOpnd *pred, 616 VISA_Exec_Size execSize, 617 VISA_EMask_Ctrl emask, 618 LSC_CACHE_OPTS cacheOpts, 619 LSC_ADDR addr, 620 LSC_DATA_SHAPE data, 621 VISA_VectorOpnd *surface, 622 VISA_RawOpnd *dst, 623 VISA_RawOpnd *src0, 624 VISA_RawOpnd *src1, 625 VISA_RawOpnd *src2) override; 626 VISA_BUILDER_API int AppendVISALscUntypedStridedInst( 627 LSC_OP subOpcode, 628 LSC_SFID sfid, 629 VISA_PredOpnd *pred, 630 VISA_Exec_Size execSize, 631 VISA_EMask_Ctrl emask, 632 LSC_CACHE_OPTS cacheOpts, 633 LSC_ADDR addrInfo, 634 LSC_DATA_SHAPE dataShape, 635 VISA_VectorOpnd *surface, 636 VISA_RawOpnd *dstData, 637 VISA_RawOpnd *src0AddrBase, 638 VISA_VectorOpnd *src0AddrPitch, 639 VISA_RawOpnd *src1Data) override; 640 VISA_BUILDER_API int AppendVISALscUntypedBlock2DInst( 641 LSC_OP op, 642 LSC_SFID lscSfid, 643 VISA_PredOpnd *pred, 644 VISA_Exec_Size execSize, 645 VISA_EMask_Ctrl emask, 646 LSC_CACHE_OPTS cacheOpts, 647 LSC_DATA_SHAPE_BLOCK2D dataShape, 648 VISA_RawOpnd *dstData, 649 VISA_VectorOpnd *src0Addrs[LSC_BLOCK2D_ADDR_PARAMS], 650 VISA_RawOpnd *src1Data) override; 651 652 VISA_BUILDER_API int AppendVISALscTypedLoad( 653 LSC_OP op, 654 VISA_PredOpnd *pred, 655 VISA_Exec_Size execSize, 656 VISA_EMask_Ctrl emask, 657 LSC_CACHE_OPTS cacheOpts, 658 LSC_ADDR_TYPE addrModel, 659 LSC_ADDR_SIZE addrSize, 660 LSC_DATA_SHAPE data, 661 VISA_VectorOpnd *surface, 662 VISA_RawOpnd *dstData, 663 VISA_RawOpnd *Us, 664 VISA_RawOpnd *Vs, 665 VISA_RawOpnd *Rs, 666 VISA_RawOpnd *LODs) override; 667 VISA_BUILDER_API int AppendVISALscTypedStore( 668 LSC_OP op, 669 VISA_PredOpnd *pred, 670 VISA_Exec_Size execSize, 671 VISA_EMask_Ctrl emask, 672 LSC_CACHE_OPTS cacheOpts, 673 LSC_ADDR_TYPE addrType, 674 LSC_ADDR_SIZE addrSize, 675 LSC_DATA_SHAPE data, 676 VISA_VectorOpnd *surface, 677 VISA_RawOpnd *Us, 678 VISA_RawOpnd *Vs, 679 VISA_RawOpnd *Rs, 680 VISA_RawOpnd *LODs, 681 VISA_RawOpnd *src1Data) override; 682 VISA_BUILDER_API int AppendVISALscTypedAtomic( 683 LSC_OP op, 684 VISA_PredOpnd *pred, 685 VISA_Exec_Size execSize, 686 VISA_EMask_Ctrl emask, 687 LSC_CACHE_OPTS cacheOpts, 688 LSC_ADDR_TYPE addrType, 689 LSC_ADDR_SIZE addrSize, 690 LSC_DATA_SHAPE data, 691 VISA_VectorOpnd *surface, 692 VISA_RawOpnd *dst, 693 VISA_RawOpnd *Us, 694 VISA_RawOpnd *Vs, 695 VISA_RawOpnd *Rs, 696 VISA_RawOpnd *LODs, 697 VISA_RawOpnd *src1AtomicOpnd1, 698 VISA_RawOpnd *src2AtomicOpnd2) override; 699 700 VISA_BUILDER_API int AppendVISALscTypedInst( 701 LSC_OP op, 702 VISA_PredOpnd* pred, 703 VISA_Exec_Size execSize, 704 VISA_EMask_Ctrl emask, 705 LSC_CACHE_OPTS cacheOpts, 706 LSC_ADDR_TYPE addrType, 707 LSC_ADDR_SIZE addrSize, 708 LSC_DATA_SHAPE data, 709 VISA_VectorOpnd* surface, 710 VISA_RawOpnd* dst, 711 VISA_RawOpnd* Us, 712 VISA_RawOpnd* Vs, 713 VISA_RawOpnd* Rs, 714 VISA_RawOpnd* LODs, 715 VISA_RawOpnd* src1, 716 VISA_RawOpnd* src2) override; 717 718 VISA_BUILDER_API int AppendVISALscFence( 719 LSC_SFID lscSfid, 720 LSC_FENCE_OP fenceOp, 721 LSC_SCOPE scope) override; 722 723 724 725 VISA_BUILDER_API int AppendVISANamedBarrierWait( 726 VISA_VectorOpnd* barrierId) override; 727 728 VISA_BUILDER_API int AppendVISANamedBarrierSignal( 729 VISA_VectorOpnd* barrierId, 730 VISA_VectorOpnd* barrierCount) override; 731 732 /********** APPEND INSTRUCTION APIS END ******************/ 733 734 /********** APPEND 3D Instructions START ******************/ 735 736 VISA_BUILDER_API int AppendVISA3dSampler(VISASampler3DSubOpCode subOpcode, 737 bool pixelNullMask, 738 bool cpsEnable, 739 bool uniformSampler, 740 VISA_PredOpnd *pred, 741 VISA_EMask_Ctrl emask, 742 VISA_Exec_Size executionSize, 743 VISAChannelMask srcChannel, 744 VISA_VectorOpnd *aoffimmi, 745 VISA_StateOpndHandle *sampler, 746 VISA_StateOpndHandle *surface, 747 VISA_RawOpnd *dst, 748 int numMsgSpecificOpnds, 749 VISA_RawOpnd **opndArray) override; 750 751 VISA_BUILDER_API int AppendVISA3dLoad( 752 VISASampler3DSubOpCode subOpcode, 753 bool pixelNullMask, 754 VISA_PredOpnd *pred, 755 VISA_EMask_Ctrl emask, 756 VISA_Exec_Size executionSize, 757 VISAChannelMask srcChannel, 758 VISA_VectorOpnd *aoffimmi, 759 VISA_StateOpndHandle *surface, 760 VISA_RawOpnd *dst, 761 int numMsgSpecificOpnds, 762 VISA_RawOpnd ** opndArray) override; 763 764 VISA_BUILDER_API int AppendVISA3dGather4( 765 VISASampler3DSubOpCode subOpcode, 766 bool pixelNullMask, 767 VISA_PredOpnd *pred, 768 VISA_EMask_Ctrl emask, 769 VISA_Exec_Size executionSize, 770 VISASourceSingleChannel srcChannel, 771 VISA_VectorOpnd *aoffimmi, 772 VISA_StateOpndHandle *sampler, 773 VISA_StateOpndHandle *surface, 774 VISA_RawOpnd *dst, 775 int numMsgSpecificOpnds, 776 VISA_RawOpnd ** opndArray) override; 777 778 VISA_BUILDER_API int AppendVISA3dInfo(VISASampler3DSubOpCode subOpcode, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISAChannelMask srcChannel, VISA_StateOpndHandle *surface, VISA_RawOpnd *lod, VISA_RawOpnd *dst) override; 779 780 VISA_BUILDER_API int AppendVISA3dRTWrite( 781 VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_VectorOpnd* renderTargetIndex, vISA_RT_CONTROLS cntrls, 782 VISA_StateOpndHandle *surface, VISA_RawOpnd *r1HeaderOpnd, VISA_VectorOpnd *sampleIndex, 783 uint8_t numMsgSpecificOpnds, VISA_RawOpnd **opndArray) override; 784 785 VISA_BUILDER_API int AppendVISA3dRTWriteCPS( 786 VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, VISA_VectorOpnd* renderTargetIndex, vISA_RT_CONTROLS cntrls, 787 VISA_StateOpndHandle *surface, VISA_RawOpnd *r1HeaderOpnd, VISA_VectorOpnd *sampleIndex, 788 VISA_VectorOpnd *cPSCounter, uint8_t numMsgSpecificOpnds, VISA_RawOpnd **opndArray) override; 789 790 VISA_BUILDER_API int AppendVISA3dURBWrite( 791 VISA_PredOpnd *pred, VISA_EMask_Ctrl emask, 792 VISA_Exec_Size executionSize, unsigned char numberOutputParams, 793 VISA_RawOpnd *channelMask, unsigned short globalOffset, VISA_RawOpnd *URBHandle, 794 VISA_RawOpnd *perSLotOffset, VISA_RawOpnd *vertexData) override; 795 796 VISA_BUILDER_API int AppendVISA3dTypedAtomic( 797 VISAAtomicOps subOp, bool is16Bit, VISA_PredOpnd *pred, 798 VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 799 VISA_StateOpndHandle *surface, VISA_RawOpnd *u, VISA_RawOpnd *v, 800 VISA_RawOpnd *r, VISA_RawOpnd *lod, VISA_RawOpnd *src0, 801 VISA_RawOpnd *src1, VISA_RawOpnd *dst) override; 802 803 /********** APPEND 3D Instructions END ******************/ 804 805 /********** MISC APIs START *************************/ 806 VISA_BUILDER_API int GetGenxBinary(void *&buffer, int &size) const override; 807 VISA_BUILDER_API int GetJitInfo(FINALIZER_INFO *&jitInfo) const override; 808 VISA_BUILDER_API int GetKernelInfo(KERNEL_INFO*& kernelInfo) const override; 809 VISA_BUILDER_API int GetCompilerStats(CompilerStats &compilerStats) override; 810 VISA_BUILDER_API int GetErrorMessage(const char *&errorMsg) const override; 811 VISA_BUILDER_API virtual int GetGenxDebugInfo(void *&buffer, unsigned int &size) const override; 812 /// GetGenRelocEntryBuffer -- allocate and return a buffer of all GenRelocEntry that are created by vISA 813 VISA_BUILDER_API int GetGenRelocEntryBuffer(void *&buffer, unsigned int &byteSize, unsigned int &numEntries) override; 814 /// GetRelocations -- add vISA created relocations into given relocation list 815 /// This get the same information as GetGenRelocEntryBuffer, but in different foramt 816 VISA_BUILDER_API int GetRelocations(RelocListType &relocs) override; 817 VISA_BUILDER_API int GetGTPinBuffer(void*& buffer, unsigned int& size) override; 818 VISA_BUILDER_API int SetGTPinInit(void* buffer) override; 819 VISA_BUILDER_API int GetFreeGRFInfo(void*& buffer, unsigned int& size) override; 820 821 VISA_BUILDER_API int GetFunctionId(unsigned int& id) const override; 822 823 ///Gets declaration id GenVar 824 VISA_BUILDER_API int getDeclarationID(VISA_GenVar *decl) const override; 825 826 ///Gets declaration id VISA_AddrVar 827 VISA_BUILDER_API int getDeclarationID(VISA_AddrVar *decl) const override; 828 829 ///Gets declaration id VISA_PredVar 830 VISA_BUILDER_API int getDeclarationID(VISA_PredVar *decl) const override; 831 832 ///Gets declaration id VISA_SamplerVar 833 VISA_BUILDER_API int getDeclarationID(VISA_SamplerVar *decl) const override; 834 835 ///Gets declaration id VISA_SurfaceVar 836 VISA_BUILDER_API int getDeclarationID(VISA_SurfaceVar *decl) const override; 837 838 ///Gets declaration id VISA_LabelVar 839 VISA_BUILDER_API int getDeclarationID(VISA_LabelVar *decl) const override; 840 841 ///Gets gen binary offset 842 VISA_BUILDER_API int64_t getGenOffset() const override; 843 844 ///Gets gen binary size within instruction heap 845 VISA_BUILDER_API int64_t getGenSize() const override; 846 847 ///Gets num of total regs 848 VISA_BUILDER_API virtual unsigned getNumRegTotal() const override; 849 850 /// Get global function name 851 VISA_BUILDER_API const char* getFunctionName() const override; 852 853 /// Get vISA asm of the kernel function 854 VISA_BUILDER_API std::string getVISAAsm() const override; 855 856 //Gets the VISA string format for the variable 857 VISA_BUILDER_API std::string getVarName(VISA_GenVar* decl) const override; 858 VISA_BUILDER_API std::string getVarName(VISA_PredVar* decl) const override; 859 VISA_BUILDER_API std::string getVarName(VISA_AddrVar* decl) const override; 860 VISA_BUILDER_API std::string getVarName(VISA_SurfaceVar* decl) const override; 861 VISA_BUILDER_API std::string getVarName(VISA_SamplerVar* decl) const override; 862 863 //Gets the VISA string format for the operand 864 VISA_BUILDER_API std::string getVectorOperandName(VISA_VectorOpnd *opnd, bool showRegion) const override; 865 VISA_BUILDER_API std::string getPredicateOperandName(VISA_PredOpnd* opnd) const override; 866 867 /********** MISC APIs END *************************/ 868 int CreateVISAPredicateSrcOperand(VISA_VectorOpnd *& opnd, VISA_PredVar *decl, unsigned int size); 869 870 int CreateVISAPredicateDstOperand(VISA_VectorOpnd *& opnd, VISA_PredVar *decl, uint32_t size); 871 872 int CreateVISAAddressOperand(VISA_VectorOpnd *&opnd, VISA_AddrVar *decl, unsigned int offset, unsigned int width, bool isDst); 873 874 int CreateVISAPredicateOperandvISA(VISA_PredOpnd *& opnd, VISA_PredVar *decl, VISA_PREDICATE_STATE state, VISA_PREDICATE_CONTROL cntrl); 875 876 int CreateGenNullRawOperand(VISA_RawOpnd *& opnd, bool isDst); 877 878 int CreateGenRawSrcOperand(VISA_RawOpnd *& cisa_opnd); 879 int CreateGenRawDstOperand(VISA_RawOpnd *& cisa_opnd); 880 881 int CreateVISAIndirectGeneralOperand(VISA_VectorOpnd *& opnd, VISA_AddrVar *cisa_decl, VISA_Modifier mod, unsigned int addrOffset, unsigned short immediateOffset, 882 unsigned short verticalStride, unsigned short width, unsigned short horizontalStride, VISA_Type type, bool isDst); 883 884 int AppendVISA3dSamplerMsgGeneric(ISA_Opcode opcode, 885 VISASampler3DSubOpCode subOpcode, 886 bool pixelNullMask, 887 bool cpsEnable, 888 bool uniformSampler, 889 VISA_PredOpnd *pred, 890 VISA_EMask_Ctrl emask, 891 VISA_Exec_Size executionSize, 892 ChannelMask srcChannel, 893 VISA_VectorOpnd *aoffimmi, 894 VISA_StateOpndHandle *sampler, 895 VISA_StateOpndHandle *surface, 896 VISA_RawOpnd *dst, 897 unsigned int numMsgSpecificOpnds, 898 VISA_RawOpnd **opndArray); 899 allocAttribute(CISA_GEN_VAR * Dcl)900 attribute_info_t* allocAttribute(CISA_GEN_VAR* Dcl) 901 { 902 return allocAttributeImpl(Dcl, 0); 903 } resizeAttribute(CISA_GEN_VAR * Dcl,uint32_t AllocMaxNum)904 attribute_info_t* resizeAttribute(CISA_GEN_VAR* Dcl, uint32_t AllocMaxNum) 905 { 906 return allocAttributeImpl(Dcl, AllocMaxNum); 907 } 908 909 int AddAttributeToVarGeneric(CISA_GEN_VAR *decl, const char* varName, unsigned int size, const void *val); 910 911 int CreateStateVar(CISA_GEN_VAR *&decl, Common_ISA_Var_Class type, const char* name, unsigned int numberElements); 912 913 int CreateVISAInputVar(CISA_GEN_VAR *decl, uint16_t offset, uint16_t size, uint8_t implicitKind); 914 915 int CreateVISAAddressOfOperandGeneric(VISA_VectorOpnd *&cisa_opnd, CISA_GEN_VAR *decl, unsigned int offset); 916 917 int CreateVISAStateOperand(VISA_VectorOpnd *& opnd, CISA_GEN_VAR *decl, Common_ISA_State_Opnd_Class opnd_class, uint8_t size, unsigned char offset, bool useAsDst); 918 setGenxBinaryBuffer(void * buffer,int size)919 void setGenxBinaryBuffer(void *buffer, int size) { m_genx_binary_buffer = static_cast<char *>(buffer); m_genx_binary_size = size; } setJitInfo(FINALIZER_INFO * jitInfo)920 void setJitInfo(FINALIZER_INFO* jitInfo) { m_jitInfo = jitInfo; } 921 getOutputAsmPath()922 std::string getOutputAsmPath() const { return m_asmName; } setOutputAsmPath(std::string val)923 void setOutputAsmPath(std::string val) { m_asmName = val; } 924 925 int compileFastPath(); 926 927 unsigned int m_magic_number; 928 unsigned char m_major_version; 929 unsigned char m_minor_version; 930 931 void compilePostOptimize(); 932 void* encodeAndEmit(unsigned int& binarySize); 933 934 void setInputSize(uint8_t size); 935 void setReturnSize(unsigned int size); 936 getIsGenBothPath()937 bool getIsGenBothPath() const { 938 return (mBuildOption == VISA_BUILDER_GEN || 939 mBuildOption == VISA_BUILDER_BOTH); 940 } 941 942 // This member holds symbolic index of function when invoked via 943 // API path. Builder client can use this id when invoking this 944 // stack call function. For a kernel instance, this is not useful. 945 unsigned int m_functionId; 946 getvIsaInstCount()947 unsigned getvIsaInstCount() const override { return m_vISAInstCount; }; 948 949 isFCCallableKernel()950 bool isFCCallableKernel() const { return mIsFCCallableKernel; } setFCCallableKernel(bool value)951 void setFCCallableKernel(bool value) { mIsFCCallableKernel = value; } 952 isFCCallerKernel()953 bool isFCCallerKernel() const { return mIsFCCallerKernel; } setFCCallerKernel(bool value)954 void setFCCallerKernel(bool value) { mIsFCCallerKernel = value; } 955 isFCComposableKernel()956 bool isFCComposableKernel() const { return mIsFCComposableKernel; } setFCComposableKernel(bool value)957 void setFCComposableKernel(bool value) { mIsFCComposableKernel = value; } 958 getGenVarCount()959 unsigned int getGenVarCount() const 960 { 961 return (uint32_t)m_var_info_list.size(); 962 } 963 getGenVar(unsigned int index)964 CISA_GEN_VAR* getGenVar(unsigned int index) const 965 { 966 return m_var_info_list[index]; 967 } 968 getAddrVarCount()969 unsigned int getAddrVarCount() const 970 { 971 return (uint32_t)m_addr_info_list.size(); 972 } 973 getAddrVar(unsigned int index)974 CISA_GEN_VAR* getAddrVar(unsigned int index) 975 { 976 return m_addr_info_list[index]; 977 } 978 getPredVarCount()979 unsigned int getPredVarCount() const 980 { 981 return (uint32_t)m_pred_info_list.size(); 982 } 983 getPredVar(unsigned int index)984 CISA_GEN_VAR* getPredVar(unsigned int index) 985 { 986 auto it = m_pred_info_list.begin(); 987 std::advance(it, index); 988 989 return (*it); 990 } 991 getSamplerVarCount()992 unsigned int getSamplerVarCount() const 993 { 994 return (uint32_t)m_sampler_info_list.size(); 995 } 996 getSamplerVar(unsigned int index)997 CISA_GEN_VAR* getSamplerVar(unsigned int index) 998 { 999 auto it = m_sampler_info_list.begin(); 1000 std::advance(it, index); 1001 1002 return (*it); 1003 } 1004 getSurfaceVarCount()1005 unsigned int getSurfaceVarCount() const 1006 { 1007 return (uint32_t)m_surface_info_list.size(); 1008 } 1009 getSurfaceVar(unsigned int index)1010 CISA_GEN_VAR* getSurfaceVar(unsigned int index) 1011 { 1012 auto it = m_surface_info_list.begin(); 1013 std::advance(it, index); 1014 1015 return (*it); 1016 } 1017 getVarName(CISA_GEN_VAR * decl)1018 std::string getVarName(CISA_GEN_VAR* decl) const 1019 { 1020 assert(m_GenVarToNameMap.count(decl) && "Can't find the decl's name"); 1021 return m_GenVarToNameMap.find(decl)->second; 1022 } 1023 getOptions()1024 const Options * getOptions() const { return m_options; } 1025 IsAsmWriterMode()1026 bool IsAsmWriterMode() const { return m_CISABuilder->getBuilderMode() == vISA_ASM_WRITER; } 1027 1028 typedef std::list<VISAKernelImpl*> VISAKernelImplListTy; 1029 void computeAndEmitDebugInfo(VISAKernelImplListTy& functions); 1030 1031 private: 1032 1033 int InitializeKernel(const char* kernel_name); 1034 int CISABuildPreDefinedDecls(); 1035 void createReservedKeywordSet(); 1036 bool isReservedName(const std::string &nm) const; 1037 void ensureVariableNameUnique(const char *&varName); 1038 void generateVariableName(Common_ISA_Var_Class Ty, const char *&varName); 1039 1040 void dumpDebugFormatFile(std::vector<vISA::DebugInfoFormat>& debugSymbols, std::string filename); 1041 int InitializeFastPath(); 1042 void initCompilerStats(); 1043 int predefinedVarRegAssignment(); 1044 int calculateTotalInputSize(); 1045 int compileTillOptimize(); 1046 void recordFinalizerInfo(); 1047 1048 // Re-adjust indirect call target after swsb 1049 void adjustIndirectCallOffset(); 1050 1051 CisaFramework::CisaInst* AppendVISASvmGeneralScatterInst(VISA_PredOpnd* pred, 1052 VISA_EMask_Ctrl emask, VISA_Exec_Size execSize, unsigned char blockSize, 1053 unsigned char numBlocks, VISA_RawOpnd* address, VISA_RawOpnd *srcDst, bool isRead); 1054 1055 CisaFramework::CisaInst * 1056 PackCisaInsnForSVMGather4Scatter4Scaled(unsigned subOpc, 1057 VISA_PredOpnd *pred, 1058 VISA_EMask_Ctrl eMask, 1059 VISA_Exec_Size executionSize, 1060 ChannelMask chMask, 1061 VISA_VectorOpnd *address, 1062 VISA_RawOpnd *offsets, 1063 VISA_RawOpnd *srcOrDst); 1064 1065 VISA_opnd * getOpndFromPool(); 1066 1067 void AppendVISAInstCommon(); 1068 int AppendVISADpasInstCommon( 1069 ISA_Opcode opcode, VISA_EMask_Ctrl emask, VISA_Exec_Size executionSize, 1070 VISA_RawOpnd* tmpDst, VISA_RawOpnd* src0, VISA_RawOpnd* src1, 1071 VISA_VectorOpnd* src2, VISA_VectorOpnd* src3, 1072 GenPrecision src2Precision, GenPrecision src1Precision, 1073 uint8_t Depth, uint8_t Count); 1074 1075 void createBindlessSampler(); 1076 1077 kernel_format_t m_cisa_kernel; 1078 1079 unsigned int m_num_pred_vars; 1080 //size of various arrays in kernel header. 1081 //used for buffer size allocation. 1082 unsigned int m_string_pool_size; 1083 unsigned int m_address_info_size; 1084 unsigned int m_predicate_info_size; 1085 unsigned int m_label_info_size; 1086 unsigned int m_input_info_size; 1087 unsigned int m_attribute_info_size; 1088 unsigned int m_instruction_size; 1089 unsigned int m_sampler_info_size; 1090 1091 unsigned long m_genx_binary_size; 1092 char * m_genx_binary_buffer; 1093 unsigned long m_genx_debug_info_size; 1094 char * m_genx_debug_info_buffer; 1095 FINALIZER_INFO* m_jitInfo; 1096 KERNEL_INFO* m_kernelInfo; 1097 CompilerStats m_compilerStats; 1098 1099 unsigned long m_cisa_binary_size; 1100 char * m_cisa_binary_buffer; 1101 1102 unsigned long m_kernel_data_size; 1103 1104 unsigned long m_bytes_written_cisa_buffer; 1105 1106 unsigned long m_input_offset; 1107 1108 std::vector<std::string> m_string_pool; 1109 enum VISA_BUILD_TYPE m_type; 1110 unsigned int m_resolvedIndex; 1111 1112 vISA::Mem_Manager m_mem; 1113 std::string m_name; 1114 std::string m_asmName; 1115 std::string m_sanitizedName; 1116 1117 std::list<CisaFramework::CisaInst *> m_instruction_list; 1118 1119 unsigned int m_var_info_count; 1120 std::vector<CISA_GEN_VAR*> m_var_info_list; 1121 1122 unsigned int m_addr_info_count; 1123 std::vector<CISA_GEN_VAR *> m_addr_info_list; 1124 1125 unsigned int m_pred_info_count; 1126 std::vector<CISA_GEN_VAR *> m_pred_info_list; 1127 1128 unsigned int m_sampler_count; 1129 std::vector<CISA_GEN_VAR*> m_sampler_info_list; 1130 1131 unsigned int m_surface_count; 1132 std::vector<CISA_GEN_VAR*> m_surface_info_list; 1133 1134 VISA_SamplerVar* m_bindlessSampler; 1135 1136 std::map<unsigned int, unsigned int> m_declID_to_PredefinedSurfaceID_map; 1137 1138 unsigned int m_input_count; 1139 std::vector<input_info_t *> m_input_info_list; 1140 // std::map<unsigned int, unsigned int> m_declID_to_inputID_map; 1141 1142 unsigned int m_attribute_count; 1143 std::list<attribute_info_t *> m_attribute_info_list; 1144 1145 unsigned int m_label_count; 1146 std::vector<label_info_t *> m_label_info_list; 1147 1148 // maps a variable name to the var pointer 1149 // unique vars are unique to the entire program 1150 // general vars must be unique within the same scope, but can be redefined across scopes 1151 typedef std::map<std::string, CISA_GEN_VAR *> GenDeclNameToVarMap; 1152 std::vector<GenDeclNameToVarMap> m_GenNamedVarMap; 1153 GenDeclNameToVarMap m_UniqueNamedVarMap; 1154 1155 // reverse map from a GenVar to its declared name, used in inline assembly 1156 // Note that name is only unique within the same scope 1157 std::map<CISA_GEN_VAR*, std::string> m_GenVarToNameMap; 1158 1159 std::unordered_map<std::string, VISA_LabelOpnd *> m_label_name_to_index_map; 1160 std::unordered_map<std::string, VISA_LabelOpnd *> m_funcName_to_labelID_map; 1161 1162 VISA_BUILDER_OPTION mBuildOption; 1163 vISA::G4_Kernel* m_kernel; 1164 CISA_IR_Builder* const m_CISABuilder; 1165 vISA::IR_Builder* m_builder; 1166 vISA::Mem_Manager *m_kernelMem; 1167 //customized allocator for allocating 1168 //It is very important that the same allocator is used by all instruction lists 1169 //that might be joined/spliced. 1170 INST_LIST_NODE_ALLOCATOR m_instListNodeAllocator; 1171 unsigned int m_inputSize; 1172 VISA_opnd m_fastPathOpndPool[vISA_NUMBER_OF_OPNDS_IN_POOL]; 1173 unsigned int m_opndCounter; 1174 1175 unsigned int varNameCount; 1176 unsigned int addressNameCount; 1177 unsigned int predicateNameCount; 1178 unsigned int surfaceNameCount; 1179 unsigned int samplerNameCount; 1180 unsigned int unknownNameCount; 1181 1182 // TODO: this should be merged and re-worked to fit into the symbol table 1183 // scheme 1184 std::unordered_set<std::string> varNames; 1185 std::unordered_set<std::string> reservedNames; 1186 1187 int m_vISAInstCount; 1188 print_decl_index_t m_printDeclIndex; 1189 1190 bool mIsFCCallableKernel; 1191 bool mIsFCCallerKernel; 1192 bool mIsFCComposableKernel; 1193 1194 void computeFCInfo(vISA::BinaryEncodingBase* binEncodingInstance); 1195 void computeFCInfo(); 1196 //memory managed by the entity that creates vISA Kernel object 1197 Options * const m_options; 1198 createKernelAttributes()1199 void createKernelAttributes() { 1200 void* pmem = m_mem.alloc(sizeof(vISA::Attributes)); 1201 m_kernelAttrs = new (pmem) vISA::Attributes(); 1202 } destroyKernelAttributes()1203 void destroyKernelAttributes() { 1204 // Even though attributes is allocated from m_mem, need to invoke dtor. 1205 if (m_kernelAttrs) { 1206 m_kernelAttrs->~Attributes(); 1207 m_kernelAttrs = nullptr; 1208 } 1209 } 1210 attribute_info_t* allocAttributeImpl(CISA_GEN_VAR* Dcl, uint32_t AllocNum); 1211 1212 // Shared with G4_kernel 1213 vISA::Attributes* m_kernelAttrs; 1214 }; 1215 1216 class VISAKernel_format_provider : public print_format_provider_t 1217 { 1218 protected: 1219 const VISAKernelImpl* const m_kernel; 1220 1221 public: VISAKernel_format_provider(const VISAKernelImpl * kernel)1222 VISAKernel_format_provider(const VISAKernelImpl* kernel) 1223 : m_kernel(kernel) { } 1224 getNameIndex()1225 uint32_t getNameIndex() const 1226 { 1227 return m_kernel->m_cisa_kernel.name_index; 1228 } getString(uint32_t str_id)1229 const char* getString(uint32_t str_id) const 1230 { 1231 assert(str_id < m_kernel->m_string_pool.size()); 1232 return m_kernel->m_string_pool[str_id].c_str(); 1233 } getStringCount()1234 uint32_t getStringCount() const 1235 { 1236 return m_kernel->m_string_pool.size(); 1237 } getLabel(uint16_t label_id)1238 const label_info_t* getLabel(uint16_t label_id) const 1239 { 1240 assert(label_id < m_kernel->m_label_info_list.size()); 1241 return m_kernel->m_label_info_list[label_id]; 1242 } getLabelCount()1243 unsigned short getLabelCount() const 1244 { 1245 return m_kernel->m_label_count; 1246 } getPredefVar(unsigned var_id)1247 const var_info_t* getPredefVar(unsigned var_id) const 1248 { 1249 assert(var_id < m_kernel->m_num_pred_vars); 1250 return &m_kernel->m_var_info_list[var_id]->genVar; 1251 } getVar(unsigned var_id)1252 const var_info_t* getVar(unsigned var_id) const 1253 { 1254 assert(var_id + m_kernel->m_num_pred_vars < m_kernel->m_var_info_list.size()); 1255 return &m_kernel->m_var_info_list[var_id + m_kernel->m_num_pred_vars]->genVar; 1256 } getVarCount()1257 uint32_t getVarCount() const 1258 { 1259 return m_kernel->m_var_info_count - m_kernel->m_num_pred_vars; 1260 } getAttr(unsigned id)1261 const attribute_info_t* getAttr(unsigned id) const 1262 { 1263 auto it = m_kernel->m_attribute_info_list.begin(); 1264 std::advance(it, id); 1265 return *it; 1266 } getAttrCount()1267 unsigned getAttrCount() const 1268 { 1269 return m_kernel->m_attribute_count; 1270 } getAddr(unsigned id)1271 const addr_info_t* getAddr(unsigned id) const 1272 { 1273 assert(id < m_kernel->m_addr_info_list.size()); 1274 return &m_kernel->m_addr_info_list[id]->addrVar; 1275 } getAddrCount()1276 unsigned short getAddrCount() const 1277 { 1278 return m_kernel->m_addr_info_count; 1279 } getPred(unsigned id)1280 const pred_info_t* getPred(unsigned id) const 1281 { 1282 assert(id < m_kernel->m_pred_info_list.size()); 1283 return &m_kernel->m_pred_info_list[id]->predVar; 1284 } getPredCount()1285 unsigned short getPredCount() const 1286 { 1287 return m_kernel->m_pred_info_count; 1288 } getPredefSurface(unsigned id)1289 const state_info_t* getPredefSurface(unsigned id) const 1290 { 1291 assert(id < Get_CISA_PreDefined_Surf_Count()); 1292 return &m_kernel->m_surface_info_list[id]->stateVar; 1293 } getSurface(unsigned id)1294 const state_info_t* getSurface(unsigned id) const 1295 { 1296 assert(id + Get_CISA_PreDefined_Surf_Count() < m_kernel->m_surface_info_list.size()); 1297 return &m_kernel->m_surface_info_list[id + Get_CISA_PreDefined_Surf_Count()]->stateVar; 1298 } getSurfaceCount()1299 unsigned char getSurfaceCount() const 1300 { 1301 return m_kernel->m_surface_count - Get_CISA_PreDefined_Surf_Count(); 1302 } getSampler(unsigned id)1303 const state_info_t* getSampler(unsigned id) const 1304 { 1305 assert(id < m_kernel->m_sampler_info_list.size()); 1306 return &m_kernel->m_sampler_info_list[id]->stateVar; 1307 } getSamplerCount()1308 unsigned char getSamplerCount() const 1309 { 1310 return m_kernel->m_sampler_count; 1311 } getInput(unsigned id)1312 const input_info_t* getInput(unsigned id) const 1313 { 1314 assert(id < m_kernel->m_input_info_list.size()); 1315 return m_kernel->m_input_info_list[id]; 1316 } getInputCount()1317 uint32_t getInputCount() const 1318 { 1319 return m_kernel->m_input_count; 1320 } 1321 1322 std::string printKernelHeader(const common_isa_header& isaHeader); 1323 }; 1324 1325 #endif //VISA_KERNEL_H 1326