23 #ifndef __CLRX_ASMFORMATS_H__ 24 #define __CLRX_ASMFORMATS_H__ 26 #include <CLRX/Config.h> 31 #include <unordered_set> 32 #include <unordered_map> 57 AMDCL2_RWDATA = LAST_COMMON+1,
68 ROCM_CONFIG_CTRL_DIRECTIVE,
71 EXTRA_PROGBITS = 0xfc,
87 ASMSECT_WRITEABLE = 1,
88 ASMSECT_ADDRESSABLE = 2,
89 ASMSECT_ABS_ADDRESSABLE = 4,
92 ASMELFSECT_ALLOCATABLE = 0x10,
93 ASMELFSECT_WRITEABLE = 0x20,
94 ASMELFSECT_EXECUTABLE = 0x40
140 virtual cxuint addKernel(
const char* kernelName) = 0;
149 virtual cxuint addSection(
const char* sectionName, cxuint kernelId) = 0;
152 virtual cxuint getSectionId(
const char* sectionName)
const = 0;
155 virtual void setCurrentKernel(cxuint kernel) = 0;
157 virtual void setCurrentSection(cxuint sectionId) = 0;
160 virtual SectionInfo getSectionInfo(cxuint sectionId)
const = 0;
162 virtual bool parsePseudoOp(
const CString& firstName,
163 const char* stmtPlace,
const char* linePtr) = 0;
165 virtual void handleLabel(
const CString& label);
167 virtual bool resolveSymbol(
const AsmSymbol& symbol,
168 uint64_t& value, cxuint& sectionId);
171 uint64_t& value, cxuint& sectionId);
173 virtual bool prepareBinary() = 0;
175 virtual void writeBinary(std::ostream& os)
const = 0;
189 cxuint addKernel(
const char* kernelName);
190 cxuint addSection(
const char* sectionName, cxuint kernelId);
192 cxuint getSectionId(
const char* sectionName)
const;
194 void setCurrentKernel(cxuint kernel);
195 void setCurrentSection(cxuint sectionId);
197 SectionInfo getSectionInfo(cxuint sectionId)
const;
198 bool parsePseudoOp(
const CString& firstName,
199 const char* stmtPlace,
const char* linePtr);
201 bool prepareBinary();
202 void writeBinary(std::ostream& os)
const;
210 typedef std::unordered_map<CString, cxuint> SectionMap;
211 friend struct AsmAmdPseudoOps;
223 cxuint headerSection;
224 cxuint metadataSection;
225 cxuint configSection;
228 std::vector<cxuint> calNoteSections;
229 SectionMap extraSectionMap;
230 cxuint extraSectionCount;
232 std::unordered_set<CString> argNamesSet;
233 cxuint allocRegs[MAX_REGTYPES_NUM];
236 std::vector<Section> sections;
238 std::vector<Kernel*> kernelStates;
239 SectionMap extraSectionMap;
242 cxuint extraSectionCount;
244 void saveCurrentSection();
245 void restoreCurrentAllocRegs();
246 void saveCurrentAllocRegs();
253 cxuint addKernel(
const char* kernelName);
254 cxuint addSection(
const char* sectionName, cxuint kernelId);
256 cxuint getSectionId(
const char* sectionName)
const;
257 void setCurrentKernel(cxuint kernel);
258 void setCurrentSection(cxuint sectionId);
260 SectionInfo getSectionInfo(cxuint sectionId)
const;
261 bool parsePseudoOp(
const CString& firstName,
262 const char* stmtPlace,
const char* linePtr);
264 bool prepareBinary();
265 void writeBinary(std::ostream& os)
const;
276 typedef std::unordered_map<CString, cxuint> SectionMap;
277 friend struct AsmAmdCL2PseudoOps;
294 typedef std::unordered_map<CString, Relocation> RelocMap;
299 cxuint metadataSection;
300 cxuint isaMetadataSection;
301 cxuint configSection;
304 std::unordered_set<CString> argNamesSet;
305 cxuint allocRegs[MAX_REGTYPES_NUM];
308 std::vector<Section> sections;
310 std::vector<Kernel*> kernelStates;
312 SectionMap extraSectionMap;
313 SectionMap innerExtraSectionMap;
314 cxuint rodataSection;
317 cxuint samplerInitSection;
319 cxuint innerSavedSection;
320 cxuint extraSectionCount;
321 cxuint innerExtraSectionCount;
323 void saveCurrentSection();
324 void restoreCurrentAllocRegs();
325 void saveCurrentAllocRegs();
326 cxuint getDriverVersion()
const;
333 cxuint addKernel(
const char* kernelName);
334 cxuint addSection(
const char* sectionName, cxuint kernelId);
336 cxuint getSectionId(
const char* sectionName)
const;
337 void setCurrentKernel(cxuint kernel);
338 void setCurrentSection(cxuint sectionId);
340 SectionInfo getSectionInfo(cxuint sectionId)
const;
341 bool parsePseudoOp(
const CString& firstName,
342 const char* stmtPlace,
const char* linePtr);
344 bool resolveSymbol(
const AsmSymbol& symbol, uint64_t& value, cxuint& sectionId);
345 bool resolveRelocation(
const AsmExpression* expr, uint64_t& value, cxuint& sectionId);
346 bool prepareBinary();
347 void writeBinary(std::ostream& os)
const;
358 enum class Inside : cxbyte {
359 MAINLAYOUT,
CONFIG, ARGS, PROGINFO
362 typedef std::unordered_map<CString, cxuint> SectionMap;
363 friend struct AsmGalliumPseudoOps;
374 cxuint defaultSection;
376 cxbyte progInfoEntries;
377 cxuint allocRegs[MAX_REGTYPES_NUM];
380 std::vector<Kernel> kernelStates;
381 std::vector<Section> sections;
382 std::vector<cxuint> kcodeSelection;
383 std::stack<std::vector<cxuint> > kcodeSelStack;
384 cxuint currentKcodeKernel;
385 SectionMap extraSectionMap;
388 cxuint commentSection;
391 cxuint extraSectionCount;
393 void restoreKcodeCurrentAllocRegs();
394 void saveKcodeCurrentAllocRegs();
401 cxuint addKernel(
const char* kernelName);
402 cxuint addSection(
const char* sectionName, cxuint kernelId);
404 cxuint getSectionId(
const char* sectionName)
const;
405 void setCurrentKernel(cxuint kernel);
406 void setCurrentSection(cxuint sectionId);
408 SectionInfo getSectionInfo(cxuint sectionId)
const;
409 bool parsePseudoOp(
const CString& firstName,
410 const char* stmtPlace,
const char* linePtr);
411 void handleLabel(
const CString& label);
413 bool prepareBinary();
414 void writeBinary(std::ostream& os)
const;
442 typedef std::unordered_map<CString, cxuint> SectionMap;
443 friend struct AsmROCmPseudoOps;
454 cxuint configSection;
455 std::unique_ptr<AsmROCmKernelConfig> config;
457 cxuint ctrlDirSection;
460 cxuint allocRegs[MAX_REGTYPES_NUM];
462 void initializeKernelConfig();
464 std::vector<Kernel*> kernelStates;
465 std::vector<Section> sections;
466 std::vector<cxuint> kcodeSelection;
467 std::stack<std::vector<cxuint> > kcodeSelStack;
468 cxuint currentKcodeKernel;
469 SectionMap extraSectionMap;
471 cxuint commentSection;
473 cxuint extraSectionCount;
475 void restoreKcodeCurrentAllocRegs();
476 void saveKcodeCurrentAllocRegs();
484 cxuint addKernel(
const char* kernelName);
485 cxuint addSection(
const char* sectionName, cxuint kernelId);
487 cxuint getSectionId(
const char* sectionName)
const;
488 void setCurrentKernel(cxuint kernel);
489 void setCurrentSection(cxuint sectionId);
491 SectionInfo getSectionInfo(cxuint sectionId)
const;
492 bool parsePseudoOp(
const CString& firstName,
493 const char* stmtPlace,
const char* linePtr);
494 void handleLabel(
const CString& label);
496 bool prepareBinary();
497 void writeBinary(std::ostream& os)
const;
cxbyte userDataNum
number of user data
Definition: AsmFormats.h:427
code of program or kernel
bool dx10Clamp
DX10 CLAMP mode.
Definition: AsmFormats.h:435
common definitions for assembler and disassembler
main class of assembler
Definition: Assembler.h:401
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: AsmDefs.h:277
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:97
cxuint usedSGPRsNum
number of used SGPRs
Definition: AsmFormats.h:426
configuration (global or for kernel)
AMD Catalyst kernel's metadata.
bool tgSize
enable TG_SIZE_EN bit
Definition: AsmFormats.h:432
handles raw code format
Definition: AsmFormats.h:181
cxuint dimMask
mask of dimension (bits: 0 - X, 1 - Y, 2 - Z)
Definition: AsmFormats.h:424
cxbyte priority
priority
Definition: AsmFormats.h:430
AMD HSA kernel configuration structure.
Definition: Commons.h:63
an array class
Definition: Containers.h:38
bool debugMode
debug mode
Definition: AsmFormats.h:433
handles ROCM binary format
Definition: AsmFormats.h:439
cxuint RelocType
relocation type
Definition: Commons.h:32
cxbyte exceptions
enabled exceptions
Definition: AsmFormats.h:431
data object
Definition: ROCmBinaries.h:52
absolute section id
Definition: AsmFormats.h:79
GalliumCompute binaries handling (only with LLVM 3.6)
assembler relocation
Definition: AsmDefs.h:264
const AmdCL2Input * getOutput() const
get output structure pointer
Definition: AsmFormats.h:350
AsmSectionType
assembler section type
Definition: AsmFormats.h:46
none section id
Definition: AsmFormats.h:80
AMD OpenCL2 binaries generator.
main namespace
Definition: AsmDefs.h:38
const GalliumInput * getOutput() const
get output object (input for bingenerator)
Definition: AsmFormats.h:417
bool ieeeMode
IEEE mode.
Definition: AsmFormats.h:428
cxbyte floatMode
float mode
Definition: AsmFormats.h:429
AMD Catalyst kernel's header.
utilities for other libraries and programs
exception class
Definition: Utilities.h:58
GPU identification utilities.
const AmdInput * getOutput() const
get output structure pointer
Definition: AsmFormats.h:268
const ROCmInput * getOutput() const
get output object (input for bingenerator)
Definition: AsmFormats.h:500
handles GalliumCompute format
Definition: AsmFormats.h:355
assembler symbol structure
Definition: AsmDefs.h:147
ROCm kernel configuration.
Definition: AsmFormats.h:422
cxuint usedVGPRsNum
number of used VGPRs
Definition: AsmFormats.h:425
handles AMD Catalyst format
Definition: AsmFormats.h:207
handles AMD OpenCL 2.0 binary format
Definition: AsmFormats.h:273
section is unresolvable
Definition: AsmFormats.h:90
no kernel, inner global space
Definition: AsmFormats.h:82
simple C-string container
Definition: CString.h:38
bool privilegedMode
prvileged mode
Definition: AsmFormats.h:434
no kernel, global space
Definition: AsmFormats.h:81