1 /*========================== begin_copyright_notice ============================ 2 3 Copyright (C) 2019-2021 Intel Corporation 4 5 SPDX-License-Identifier: MIT 6 7 ============================= end_copyright_notice ===========================*/ 8 9 /* --------------------------------------------------------------------------- 10 ** 11 ** File Name : RelocationInfo.h 12 ** 13 ** Abastract : This file contains the definition of Relocation Table and 14 ** Symbol Table which are shared between Compiler and Driver 15 ** -------------------------------------------------------------------------- */ 16 #ifndef RELOCATION_INFO_H 17 #define RELOCATION_INFO_H 18 19 #include <string> 20 21 namespace vISA { 22 23 static const uint32_t MAX_SYMBOL_NAME_LENGTH = 1024; 24 25 /// GenSymType - Specify the symbol's type 26 enum GenSymType { 27 S_NOTYPE = 0, // The symbol's type is not specified 28 S_UNDEF = 1, // The symbol is undefined in this module 29 S_FUNC = 2, // The symbol is associated with a function 30 S_GLOBAL_VAR = 3, // The symbol is associated with a global variable in global address space 31 S_GLOBAL_VAR_CONST = 4, // The symbol is associated with a global variable in constant address space 32 S_CONST_SAMPLER = 5, // The symbol is associated with a constant sampler 33 S_KERNEL = 6 // The symbol is associated with a kernel function 34 }; 35 36 /// GenSymEntry - An symbol table entry 37 typedef struct { 38 uint32_t s_type; // The symbol's type 39 uint32_t s_offset; // The binary offset of this symbol. This field is ignored if s_type is S_UNDEF 40 uint32_t s_size; // The size in bytes of the function binary 41 char s_name[MAX_SYMBOL_NAME_LENGTH]; // The symbol's name 42 } GenSymEntry; 43 44 /// GenRelocType - Specify the relocation's type 45 enum GenRelocType { 46 R_NONE = 0, 47 R_SYM_ADDR = 1, // 64-bit type address 48 R_SYM_ADDR_32 = 2, // 32-bit address or lower 32-bit of a 64-bit address. 49 R_SYM_ADDR_32_HI = 3, // higher 32bits of 64-bit address 50 R_PER_THREAD_PAYLOAD_OFFSET_32 = 4, // 32-bit field of payload offset of per-thread data 51 R_GLOBAL_IMM_32 = 5 // 32-bit global immediate 52 }; 53 54 /// GenRelocEntry - An relocation table entry 55 typedef struct { 56 uint32_t r_type; // The relocation's type 57 uint32_t r_offset; // The binary offset of the relocated target 58 char r_symbol[MAX_SYMBOL_NAME_LENGTH]; // The relocation target symbol's name 59 } GenRelocEntry; 60 61 /// GenFuncAttribEntry - Per-function attribute entry 62 typedef struct { 63 uint8_t f_isKernel; // Is the function a kernel 64 uint8_t f_hasBarrier; // Does the function use barriers 65 uint32_t f_privateMemPerThread; // Total private memory (in bytes) used by this function per thread 66 uint32_t f_spillMemPerThread; // Spill mem used (in bytes) in scratch space for this function 67 char f_name[MAX_SYMBOL_NAME_LENGTH]; // The function's name 68 } GenFuncAttribEntry; 69 70 /// FIXME: ZE*Entry information should be moved to upper level (e.g. IGC or runtime interface) 71 72 /// ZESymEntry - An symbol entry that will later be transformed to ZE binary format 73 /// It contains the same information as GenSymEntry, and has the full symbol name with 74 /// no length limitation 75 /// FIXME: s_type should be standard ELF symbol type instead of GenSymType 76 struct ZESymEntry { 77 GenSymType s_type; // The symbol's type 78 uint32_t s_offset; // The binary offset of this symbol. This field is ignored if s_type is S_UNDEF 79 uint32_t s_size; // The size in bytes of the function binary 80 std::string s_name; // The symbol's name 81 82 ZESymEntry() = default; ZESymEntryZESymEntry83 ZESymEntry(GenSymType type, uint32_t offset, uint32_t size, std::string name) 84 : s_type(type), s_offset(offset), s_size(size), s_name(name) 85 {} 86 }; 87 88 /// ZERelocEntry - A relocation entry that will later be transformed to ZE binary format 89 /// It contains the same information as GenRelocEntry, and has the full symbol name with 90 /// no length limitation 91 /// FIXME: r_type should be standard ELF symbol type instead of GenRelocType 92 struct ZERelocEntry { 93 GenRelocType r_type; // The relocation's type 94 uint32_t r_offset; // The binary offset of the relocated target 95 std::string r_symbol; // The relocation target symbol's name 96 97 ZERelocEntry() = default; ZERelocEntryZERelocEntry98 ZERelocEntry(GenRelocType type, uint32_t offset, std::string targetSymName) 99 : r_type(type), r_offset(offset), r_symbol(targetSymName) 100 {} 101 }; 102 103 /// ZEFuncAttribEntry - A function attribute entry that will later be transformed to ZE binary format 104 struct ZEFuncAttribEntry { 105 uint8_t f_isKernel; // Is the function a kernel 106 uint8_t f_hasBarrier; // Does the function use barriers 107 uint32_t f_privateMemPerThread; // Total private memory (in bytes) used by this function per thread 108 uint32_t f_spillMemPerThread; // Spill mem used (in bytes) in scratch space for this function 109 std::string f_name; // The function's name 110 ZEFuncAttribEntryZEFuncAttribEntry111 ZEFuncAttribEntry(uint8_t isKernel, uint8_t hasBarrier, uint32_t privateMemPerThread, 112 uint32_t spillMemPerThread, std::string funcName) 113 : f_isKernel(isKernel), 114 f_hasBarrier(hasBarrier), 115 f_privateMemPerThread(privateMemPerThread), 116 f_spillMemPerThread(spillMemPerThread), 117 f_name(funcName) 118 {} 119 }; 120 121 } //namespace vISA 122 #endif 123