23 #ifndef __CLRX_ASMFORMATS_H__ 24 #define __CLRX_ASMFORMATS_H__ 31 #include <unordered_set> 32 #include <unordered_map> 57 AMDCL2_RWDATA = LAST_COMMON+1,
64 AMDCL2_CONFIG_CTRL_DIRECTIVE,
67 GALLIUM_CONFIG_CTRL_DIRECTIVE,
70 ROCM_CONFIG_CTRL_DIRECTIVE,
73 EXTRA_PROGBITS = 0xfc,
89 ASMSECT_WRITEABLE = 1,
90 ASMSECT_ADDRESSABLE = 2,
91 ASMSECT_ABS_ADDRESSABLE = 4,
94 ASMELFSECT_ALLOCATABLE = 0x10,
95 ASMELFSECT_WRITEABLE = 0x20,
96 ASMELFSECT_EXECUTABLE = 0x40
142 virtual cxuint addKernel(
const char* kernelName) = 0;
151 virtual cxuint addSection(
const char* sectionName,
cxuint kernelId) = 0;
154 virtual cxuint getSectionId(
const char* sectionName)
const = 0;
157 virtual void setCurrentKernel(
cxuint kernel) = 0;
159 virtual void setCurrentSection(
cxuint sectionId) = 0;
164 virtual bool parsePseudoOp(
const CString& firstName,
165 const char* stmtPlace,
const char* linePtr) = 0;
167 virtual void handleLabel(
const CString& label);
169 virtual bool resolveSymbol(
const AsmSymbol& symbol,
170 uint64_t& value,
cxuint& sectionId);
173 uint64_t& value,
cxuint& sectionId);
175 virtual bool prepareBinary() = 0;
177 virtual void writeBinary(std::ostream& os)
const = 0;
191 cxuint addKernel(
const char* kernelName);
192 cxuint addSection(
const char* sectionName,
cxuint kernelId);
194 cxuint getSectionId(
const char* sectionName)
const;
196 void setCurrentKernel(
cxuint kernel);
197 void setCurrentSection(
cxuint sectionId);
200 bool parsePseudoOp(
const CString& firstName,
201 const char* stmtPlace,
const char* linePtr);
203 bool prepareBinary();
204 void writeBinary(std::ostream& os)
const;
212 typedef std::unordered_map<CString, cxuint> SectionMap;
213 friend struct AsmAmdPseudoOps;
230 std::vector<cxuint> calNoteSections;
231 SectionMap extraSectionMap;
234 std::unordered_set<CString> argNamesSet;
235 cxuint allocRegs[MAX_REGTYPES_NUM];
238 std::vector<Section> sections;
240 std::vector<Kernel*> kernelStates;
241 SectionMap extraSectionMap;
246 cxuint detectedDriverVersion;
248 void saveCurrentSection();
249 void restoreCurrentAllocRegs();
250 void saveCurrentAllocRegs();
252 cxuint determineDriverVersion()
const;
259 cxuint addKernel(
const char* kernelName);
260 cxuint addSection(
const char* sectionName,
cxuint kernelId);
262 cxuint getSectionId(
const char* sectionName)
const;
263 void setCurrentKernel(
cxuint kernel);
264 void setCurrentSection(
cxuint sectionId);
267 bool parsePseudoOp(
const CString& firstName,
268 const char* stmtPlace,
const char* linePtr);
270 bool prepareBinary();
271 void writeBinary(std::ostream& os)
const;
301 typedef std::unordered_map<CString, cxuint> SectionMap;
302 friend struct AsmAmdCL2PseudoOps;
319 typedef std::unordered_map<CString, Relocation> RelocMap;
325 cxuint isaMetadataSection;
331 std::unique_ptr<AsmAmdHsaKernelConfig> hsaConfig;
332 std::unordered_set<CString> argNamesSet;
333 cxuint allocRegs[MAX_REGTYPES_NUM];
336 void initializeKernelConfig();
338 std::vector<Section> sections;
340 std::vector<Kernel*> kernelStates;
342 SectionMap extraSectionMap;
343 SectionMap innerExtraSectionMap;
347 cxuint samplerInitSection;
351 cxuint innerExtraSectionCount;
353 cxuint detectedDriverVersion;
355 void saveCurrentSection();
356 void restoreCurrentAllocRegs();
357 void saveCurrentAllocRegs();
358 cxuint getDriverVersion()
const;
365 cxuint addKernel(
const char* kernelName);
366 cxuint addSection(
const char* sectionName,
cxuint kernelId);
368 cxuint getSectionId(
const char* sectionName)
const;
369 void setCurrentKernel(
cxuint kernel);
370 void setCurrentSection(
cxuint sectionId);
373 bool parsePseudoOp(
const CString& firstName,
374 const char* stmtPlace,
const char* linePtr);
376 bool resolveSymbol(
const AsmSymbol& symbol, uint64_t& value,
cxuint& sectionId);
378 bool prepareBinary();
379 void writeBinary(std::ostream& os)
const;
390 enum class Inside :
cxbyte {
391 MAINLAYOUT,
CONFIG, ARGS, PROGINFO
394 typedef std::unordered_map<CString, cxuint> SectionMap;
395 friend struct AsmGalliumPseudoOps;
407 std::unique_ptr<AsmAmdHsaKernelConfig> hsaConfig;
411 cxuint allocRegs[MAX_REGTYPES_NUM];
414 void initializeAmdHsaKernelConfig();
416 std::vector<Kernel*> kernelStates;
417 std::vector<Section> sections;
418 std::vector<cxuint> kcodeSelection;
419 std::stack<std::vector<cxuint> > kcodeSelStack;
420 cxuint currentKcodeKernel;
421 SectionMap extraSectionMap;
429 cxuint detectedDriverVersion;
430 cxuint detectedLLVMVersion;
433 uint32_t archStepping;
435 void restoreKcodeCurrentAllocRegs();
436 void saveKcodeCurrentAllocRegs();
438 cxuint determineDriverVersion()
const;
439 cxuint determineLLVMVersion()
const;
446 cxuint addKernel(
const char* kernelName);
447 cxuint addSection(
const char* sectionName,
cxuint kernelId);
449 cxuint getSectionId(
const char* sectionName)
const;
450 void setCurrentKernel(
cxuint kernel);
451 void setCurrentSection(
cxuint sectionId);
454 bool parsePseudoOp(
const CString& firstName,
455 const char* stmtPlace,
const char* linePtr);
456 void handleLabel(
const CString& label);
458 bool prepareBinary();
459 void writeBinary(std::ostream& os)
const;
472 typedef std::unordered_map<CString, cxuint> SectionMap;
473 friend struct AsmROCmPseudoOps;
485 std::unique_ptr<AsmROCmKernelConfig> config;
490 cxuint allocRegs[MAX_REGTYPES_NUM];
492 void initializeKernelConfig();
494 std::vector<Kernel*> kernelStates;
495 std::vector<Section> sections;
496 std::vector<cxuint> kcodeSelection;
497 std::stack<std::vector<cxuint> > kcodeSelStack;
498 cxuint currentKcodeKernel;
499 SectionMap extraSectionMap;
505 void restoreKcodeCurrentAllocRegs();
506 void saveKcodeCurrentAllocRegs();
514 cxuint addKernel(
const char* kernelName);
515 cxuint addSection(
const char* sectionName,
cxuint kernelId);
517 cxuint getSectionId(
const char* sectionName)
const;
518 void setCurrentKernel(
cxuint kernel);
519 void setCurrentSection(
cxuint sectionId);
522 bool parsePseudoOp(
const CString& firstName,
523 const char* stmtPlace,
const char* linePtr);
524 void handleLabel(
const CString& label);
526 bool prepareBinary();
527 void writeBinary(std::ostream& os)
const;
code of program or kernel
common definitions for assembler and disassembler
main class of assembler
Definition: Assembler.h:403
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: AsmDefs.h:289
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:97
cxbyte userDataNum
number of user data
Definition: AsmFormats.h:284
configuration (global or for kernel)
bool privilegedMode
prvileged mode
Definition: AsmFormats.h:291
AMD Catalyst kernel's metadata.
handles raw code format
Definition: AsmFormats.h:183
bool debugMode
debug mode
Definition: AsmFormats.h:290
AMD HSA kernel configuration structure.
Definition: Commons.h:64
an array class
Definition: Containers.h:38
bool ieeeMode
IEEE mode.
Definition: AsmFormats.h:285
cxbyte floatMode
float mode
Definition: AsmFormats.h:286
handles ROCM binary format
Definition: AsmFormats.h:469
cxuint RelocType
relocation type
Definition: Commons.h:33
bool tgSize
enable TG_SIZE_EN bit
Definition: AsmFormats.h:289
data object
Definition: ROCmBinaries.h:52
absolute section id
Definition: AsmFormats.h:81
GalliumCompute binaries handling (only with LLVM 3.6)
assembler relocation
Definition: AsmDefs.h:276
const AmdCL2Input * getOutput() const
get output structure pointer
Definition: AsmFormats.h:382
AsmSectionType
assembler section type
Definition: AsmFormats.h:46
none section id
Definition: AsmFormats.h:82
unsigned char cxbyte
unsigned byte
Definition: Config.h:215
AMD OpenCL2 binaries generator.
main namespace
Definition: AsmDefs.h:38
unsigned int cxuint
unsigned int
Definition: Config.h:223
const GalliumInput * getOutput() const
get output object (input for bingenerator)
Definition: AsmFormats.h:462
AMD Catalyst kernel's header.
utilities for other libraries and programs
exception class
Definition: Utilities.h:58
cxuint usedVGPRsNum
number of used VGPRs
Definition: AsmFormats.h:282
cxbyte priority
priority
Definition: AsmFormats.h:287
GPU identification utilities.
const AmdInput * getOutput() const
get output structure pointer
Definition: AsmFormats.h:274
bool dx10Clamp
DX10 CLAMP mode.
Definition: AsmFormats.h:292
const ROCmInput * getOutput() const
get output object (input for bingenerator)
Definition: AsmFormats.h:530
cxuint dimMask
mask of dimension (bits: 0 - X, 1 - Y, 2 - Z)
Definition: AsmFormats.h:281
handles GalliumCompute format
Definition: AsmFormats.h:387
cxuint usedSGPRsNum
number of used SGPRs
Definition: AsmFormats.h:283
assembler symbol structure
Definition: AsmDefs.h:159
cxbyte exceptions
enabled exceptions
Definition: AsmFormats.h:288
handles AMD Catalyst format
Definition: AsmFormats.h:209
handles AMD OpenCL 2.0 binary format
Definition: AsmFormats.h:298
Asm AMD HSA kernel configuration.
Definition: AsmFormats.h:279
section is unresolvable
Definition: AsmFormats.h:92
no kernel, inner global space
Definition: AsmFormats.h:84
simple C-string container
Definition: CString.h:38
no kernel, global space
Definition: AsmFormats.h:83