23 #ifndef __CLRX_GALLIUMBINARIES_H__ 24 #define __CLRX_GALLIUMBINARIES_H__ 82 MAX_VALUE = IMAGE_FORMAT
120 TEXT_INTERMEDIATE_170 = 0,
127 MAX_VALUE = DATA_PRIVATE_170
162 template<
typename ElfBinary>
163 void loadFromElf(ElfBinary& elfBinary,
size_t kernelsNum);
172 {
return progInfosNum; }
175 uint32_t getProgramInfoEntriesNum(uint32_t index)
const;
178 uint32_t getProgramInfoEntryIndex(
const char* name)
const;
182 {
return progInfoEntries + getProgramInfoEntryIndex(name); }
186 {
return progInfoEntries + getProgramInfoEntryIndex(name); }
195 {
return disasmOffset != 0; }
199 {
return disasmSize; }
206 {
return scratchRelocs.
size(); }
210 {
return scratchRelocs[i]; }
214 {
return scratchRelocs; }
228 size_t textRelEntrySize;
245 {
return reinterpret_cast<const char*
>(binaryCode + disasmOffset); }
249 {
return textRelsNum; }
252 {
return *
reinterpret_cast<const Elf32_Rel*
>(textRel + textRelEntrySize*index); }
255 {
return *
reinterpret_cast<Elf32_Rel*
>(textRel + textRelEntrySize*index); }
263 size_t textRelEntrySize;
280 {
return reinterpret_cast<const char*
>(binaryCode + disasmOffset); }
283 {
return textRelsNum; }
286 {
return *
reinterpret_cast<const Elf64_Rel*
>(textRel + textRelEntrySize*index); }
289 {
return *
reinterpret_cast<Elf64_Rel*
>(textRel + textRelEntrySize*index); }
298 size_t binaryCodeSize;
301 uint32_t sectionsNum;
302 std::unique_ptr<GalliumKernel[]> kernels;
303 std::unique_ptr<GalliumSection[]> sections;
306 std::unique_ptr<GalliumElfBinaryBase> elfBinary;
317 {
return creationFlags; }
321 {
return binaryCodeSize; }
324 operator bool()
const 325 {
return binaryCode!=
nullptr; }
329 {
return binaryCode==
nullptr; }
333 {
return binaryCode; }
337 {
return binaryCode; }
340 {
return elf64BitBinary; }
360 {
return sectionsNum; }
364 {
return sections[index].size; }
368 {
return binaryCode + sections[index].offset; }
372 {
return binaryCode + sections[index].offset; }
376 {
return sections[index]; }
380 {
return kernelsNum;; }
383 uint32_t getKernelIndex(
const char* name)
const;
387 {
return kernels[index]; }
391 {
return kernels[getKernelIndex(name)]; }
398 GALLIUMSECTID_GPUCONFIG = ELFSECTID_OTHER_BUILTIN,
399 GALLIUMSECTID_NOTEGNUSTACK,
400 GALLIUMSECTID_RELTEXT,
401 GALLIUMSECTID_MAX = GALLIUMSECTID_RELTEXT
461 void addEmptyKernel(
const char* kernelName,
cxuint llvmVersion);
471 void generateInternal(std::ostream* osPtr, std::vector<char>* vPtr,
489 const cxbyte* code,
size_t globalDataSize,
const cxbyte* globalData,
490 const std::vector<GalliumKernelInput>& kernels);
493 const cxbyte* code,
size_t globalDataSize,
const cxbyte* globalData,
494 std::vector<GalliumKernelInput>&& kernels);
508 void generate(std::ostream& os)
const;
511 void generate(std::vector<char>& vector)
const;
uint32_t pgmRSRC2
pgmRSRC2 register value
Definition: GalliumBinaries.h:415
bool privilegedMode
prvileged mode
Definition: GalliumBinaries.h:423
GalliumElfBinary64 & getElfBinary64()
returns Gallium inner ELF 64-bit binary
Definition: GalliumBinaries.h:351
Flags getCreationFlags()
get creation flags
Definition: GalliumBinaries.h:316
create prinfomap for inner binaries
Definition: GalliumBinaries.h:51
kernel config
Definition: GalliumBinaries.h:409
non copyable and non movable base structure (class)
Definition: Utilities.h:43
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:97
uint32_t sectionId
section id
Definition: GalliumBinaries.h:107
size_t offset
offset
Definition: GalliumBinaries.h:142
const cxbyte * getSectionContent(uint32_t index) const
get content for section with specified index
Definition: GalliumBinaries.h:367
RelocType type
relocation type
Definition: GalliumBinaries.h:143
GalliumProgInfoEntry * getProgramInfo(const char *name)
returns program info entries for specified kernel name
Definition: GalliumBinaries.h:185
size_t localSize
used local size (not local defined in kernel arguments)
Definition: GalliumBinaries.h:425
Array< std::pair< const char *, size_t > > ProgInfoEntryIndexMap
program info entry index map
Definition: GalliumBinaries.h:151
uint32_t address
address
Definition: GalliumBinaries.h:88
all Gallium binaries flags
Definition: GalliumBinaries.h:55
Gallium binarie's Section.
Definition: GalliumBinaries.h:131
cxbyte priority
priority
Definition: GalliumBinaries.h:419
uint32_t value
value
Definition: GalliumBinaries.h:89
create map of sections for inner binaries
Definition: GalliumBinaries.h:47
GalliumProgInfoEntry * progInfoEntries
program info entries
Definition: GalliumBinaries.h:154
class ElfBinaryTemplate< Elf64Types > ElfBinary64
type for 64-bit ELF binary
Definition: ElfBinaries.h:483
uint32_t targetSize
target size
Definition: GalliumBinaries.h:99
ProgInfoEntryIndexMap progInfoEntryMap
program info map
Definition: GalliumBinaries.h:155
GalliumSectionType type
type of section
Definition: GalliumBinaries.h:134
kernel argument (Gallium binaries)
Definition: GalliumBinaries.h:93
common definitions for binaries
GalliumArgType type
type of argument
Definition: GalliumBinaries.h:95
bool debugMode
debug mode
Definition: GalliumBinaries.h:422
const GalliumKernel & getKernel(const char *name) const
get kernel with speciified name
Definition: GalliumBinaries.h:390
Definition: GalliumBinaries.h:294
const GalliumElfBinary64 & getElfBinary64() const
returns Gallium inner ELF 64-bit binary
Definition: GalliumBinaries.h:355
cxbyte * getBinaryCode()
returns binary code data
Definition: GalliumBinaries.h:336
an array class
Definition: Containers.h:38
uint32_t detectMesaDriverVersion()
detect driver version in the system
const GalliumProgInfoEntry * getProgramInfo(const char *name) const
returns program info entries for specified kernel name
Definition: GalliumBinaries.h:181
uint32_t getKernelsNum() const
returns kernels number
Definition: GalliumBinaries.h:379
size_t getSize() const
get size of binaries
Definition: GalliumBinaries.h:320
cxuint usedVGPRsNum
number of used VGPRs
Definition: GalliumBinaries.h:412
create map of kernels for inner binaries
Definition: GalliumBinaries.h:48
size_t getTextRelEntriesNum() const
get text rel entries number
Definition: GalliumBinaries.h:248
cxuint RelocType
relocation type
Definition: Commons.h:33
uint32_t getSectionsNum() const
get sections number
Definition: GalliumBinaries.h:359
size_t disasmOffset
disassembly offset
Definition: GalliumBinaries.h:157
size_t disasmSize
disassembly size
Definition: GalliumBinaries.h:156
shift for convert inner binary flags into elf binary flags
Definition: GalliumBinaries.h:56
cxbyte userDataNum
number of user data
Definition: GalliumBinaries.h:416
const Elf32_Rel & getTextRelEntry(size_t index) const
get text rel entry
Definition: GalliumBinaries.h:251
const GalliumInput * getInput() const
get input
Definition: GalliumBinaries.h:498
uint32_t size
size of argument
Definition: GalliumBinaries.h:98
bool ieeeMode
IEEE mode.
Definition: GalliumBinaries.h:417
cxuint usedSGPRsNum
number of used SGPRs
Definition: GalliumBinaries.h:413
uint32_t offset
offset in binary
Definition: GalliumBinaries.h:135
Array< GalliumArgInfo > argInfos
arguments
Definition: GalliumBinaries.h:109
unsigned char cxbyte
unsigned byte
Definition: Config.h:215
Elf64_Rel & getTextRelEntry(size_t index)
get text rel entry
Definition: GalliumBinaries.h:288
kernel program info entry for Gallium binaries
Definition: GalliumBinaries.h:86
main namespace
Definition: AsmDefs.h:38
cxbyte floatMode
float mode
Definition: GalliumBinaries.h:418
const GalliumElfBinary32 & getElfBinary32() const
returns Gallium inner ELF 32-bit binary
Definition: GalliumBinaries.h:347
unsigned int cxuint
unsigned int
Definition: Config.h:223
uint32_t sectionId
section id
Definition: GalliumBinaries.h:133
gallium code binary generator
Definition: GalliumBinaries.h:465
cxuint spilledVGPRs
number of spilled vector registers
Definition: GalliumBinaries.h:427
bool isMesa170() const
returns true if binary for >=Mesa3D 17.0
Definition: GalliumBinaries.h:393
uint32_t targetAlign
target alignment
Definition: GalliumBinaries.h:100
inlines for accessing memory words in LittleEndian and unaligned
bool operator!() const
returns true if object is uninitialized
Definition: GalliumBinaries.h:328
bool hasProgInfoMap() const
return true if binary has program info map
Definition: GalliumBinaries.h:275
section for text (binary code)
const char * getDisassembly() const
return disassembly content (without null-character)
Definition: GalliumBinaries.h:244
const GalliumScratchReloc & getScratchReloc(size_t i) const
return scratch buffer relocation by index
Definition: GalliumBinaries.h:209
create elf proginfomap
Definition: GalliumBinaries.h:53
GPUDeviceType
type of GPU device
Definition: GPUId.h:51
uint32_t detectLLVMCompilerVersion()
detect LLVM compiler version in the system
cxbyte exceptions
enabled exceptions
Definition: GalliumBinaries.h:420
32-bit Gallium ELF binary
Definition: GalliumBinaries.h:224
const GalliumKernel & getKernel(uint32_t index) const
get kernel by index
Definition: GalliumBinaries.h:386
GalliumSectionType
Gallium format section type.
Definition: GalliumBinaries.h:113
bool dx10Clamp
DX10 CLAMP mode.
Definition: GalliumBinaries.h:424
64-bit Gallium ELF binary
Definition: GalliumBinaries.h:259
utilities for other libraries and programs
uint32_t size
size of section
Definition: GalliumBinaries.h:136
size_t getScratchRelocsNum() const
return scratch buffer relocations number
Definition: GalliumBinaries.h:205
uint32_t scratchBufferSize
size of scratch buffer
Definition: GalliumBinaries.h:426
uint32_t getProgramInfosNum() const
returns program infos number
Definition: GalliumBinaries.h:171
CString kernelName
kernel's name
Definition: GalliumBinaries.h:106
bool is64BitElfBinary() const
return true if inner binary is 64-bit
Definition: GalliumBinaries.h:339
const char * getDisassembly() const
return disassembly content (without null-character)
Definition: GalliumBinaries.h:279
uint32_t progInfosNum
program info entries number
Definition: GalliumBinaries.h:153
const GalliumSection & getSection(uint32_t index) const
get section with specified index
Definition: GalliumBinaries.h:375
bool tgSize
enable TG_SIZE_EN bit
Definition: GalliumBinaries.h:421
size_t getTextRelEntriesNum() const
get text rel entries number
Definition: GalliumBinaries.h:282
uint32_t pgmRSRC1
pgmRSRC1 register value
Definition: GalliumBinaries.h:414
GPU identification utilities.
Definition: GalliumBinaries.h:140
uint32_t getSectionSize(uint32_t index) const
get size of section with specified index
Definition: GalliumBinaries.h:363
size_t size() const
returns number of elements
Definition: Containers.h:169
const Array< GalliumScratchReloc > & getScratchRelocs() const
return all scratch buffer relocations
Definition: GalliumBinaries.h:213
creation flags for ELF binaries
Definition: ElfBinaries.h:73
class ElfBinaryTemplate< Elf32Types > ElfBinary32
type for 32-bit ELF binary
Definition: ElfBinaries.h:481
GalliumArgSemantic semantic
semantic of array
Definition: GalliumBinaries.h:97
kernel info structure (Gallium binaries)
Definition: GalliumBinaries.h:104
Elf32_Rel & getTextRelEntry(size_t index)
get text rel entry
Definition: GalliumBinaries.h:254
GalliumArgType
GalliumCompute Kernel Arg type.
Definition: GalliumBinaries.h:60
bool isLLVM390() const
returns true binary for if >=LLVM 3.9
Definition: GalliumBinaries.h:201
GalliumArgSemantic
Gallium semantic field type.
Definition: GalliumBinaries.h:75
bool llvm390
true if >= LLVM 3.9
Definition: GalliumBinaries.h:158
bool hasProgInfoMap() const
return true if binary has program info map
Definition: GalliumBinaries.h:240
uint32_t offset
offset in ElfBinary
Definition: GalliumBinaries.h:108
size_t getDisassemblySize() const
returns size of disassembly
Definition: GalliumBinaries.h:198
const Elf64_Rel & getTextRelEntry(size_t index) const
get text rel entry
Definition: GalliumBinaries.h:285
cxbyte * getSectionContent(uint32_t index)
get content for section with specified index
Definition: GalliumBinaries.h:371
cxuint dimMask
mask of dimension (bits: 0 - X, 1 - Y, 2 - Z)
Definition: GalliumBinaries.h:411
GalliumElfBinary32 & getElfBinary32()
returns Gallium inner ELF 32-bit binary
Definition: GalliumBinaries.h:343
bool hasDisassembly() const
returns true if disassembly available
Definition: GalliumBinaries.h:194
const cxbyte * getBinaryCode() const
returns binary code data
Definition: GalliumBinaries.h:332
Definition: GalliumBinaries.h:50
bool signExtended
is signed extended
Definition: GalliumBinaries.h:96
simple C-string container
Definition: CString.h:38
containers and other utils for other libraries and programs
Gallium elf binary base (for 32-bit and 64-bit)
Definition: GalliumBinaries.h:147
cxuint spilledSGPRs
number of spilled scalar registers
Definition: GalliumBinaries.h:428
pointer to constant memory