23 #ifndef __CLRX_ASMFORMATS_H__ 24 #define __CLRX_ASMFORMATS_H__ 26 #include <CLRX/Config.h> 31 #include <unordered_set> 32 #include <unordered_map> 56 AMDCL2_RWDATA = LAST_COMMON+1,
67 ROCM_CONFIG_CTRL_DIRECTIVE,
70 EXTRA_PROGBITS = 0xfc,
86 ASMSECT_WRITEABLE = 1,
87 ASMSECT_ADDRESSABLE = 2,
88 ASMSECT_ABS_ADDRESSABLE = 4,
91 ASMELFSECT_ALLOCATABLE = 0x10,
92 ASMELFSECT_WRITEABLE = 0x20,
93 ASMELFSECT_EXECUTABLE = 0x40
139 virtual cxuint addKernel(
const char* kernelName) = 0;
148 virtual cxuint addSection(
const char* sectionName, cxuint kernelId) = 0;
151 virtual cxuint getSectionId(
const char* sectionName)
const = 0;
154 virtual void setCurrentKernel(cxuint kernel) = 0;
156 virtual void setCurrentSection(cxuint sectionId) = 0;
159 virtual SectionInfo getSectionInfo(cxuint sectionId)
const = 0;
161 virtual bool parsePseudoOp(
const CString& firstName,
162 const char* stmtPlace,
const char* linePtr) = 0;
164 virtual void handleLabel(
const CString& label);
166 virtual bool resolveSymbol(
const AsmSymbol& symbol,
167 uint64_t& value, cxuint& sectionId);
170 uint64_t& value, cxuint& sectionId);
172 virtual bool prepareBinary() = 0;
174 virtual void writeBinary(std::ostream& os)
const = 0;
188 cxuint addKernel(
const char* kernelName);
189 cxuint addSection(
const char* sectionName, cxuint kernelId);
191 cxuint getSectionId(
const char* sectionName)
const;
193 void setCurrentKernel(cxuint kernel);
194 void setCurrentSection(cxuint sectionId);
196 SectionInfo getSectionInfo(cxuint sectionId)
const;
197 bool parsePseudoOp(
const CString& firstName,
198 const char* stmtPlace,
const char* linePtr);
200 bool prepareBinary();
201 void writeBinary(std::ostream& os)
const;
209 typedef std::unordered_map<CString, cxuint> SectionMap;
210 friend struct AsmAmdPseudoOps;
222 cxuint headerSection;
223 cxuint metadataSection;
224 cxuint configSection;
227 std::vector<cxuint> calNoteSections;
228 SectionMap extraSectionMap;
229 cxuint extraSectionCount;
231 std::unordered_set<CString> argNamesSet;
235 std::vector<Section> sections;
237 std::vector<Kernel*> kernelStates;
238 SectionMap extraSectionMap;
241 cxuint extraSectionCount;
243 void saveCurrentSection();
244 void restoreCurrentAllocRegs();
245 void saveCurrentAllocRegs();
252 cxuint addKernel(
const char* kernelName);
253 cxuint addSection(
const char* sectionName, cxuint kernelId);
255 cxuint getSectionId(
const char* sectionName)
const;
256 void setCurrentKernel(cxuint kernel);
257 void setCurrentSection(cxuint sectionId);
259 SectionInfo getSectionInfo(cxuint sectionId)
const;
260 bool parsePseudoOp(
const CString& firstName,
261 const char* stmtPlace,
const char* linePtr);
263 bool prepareBinary();
264 void writeBinary(std::ostream& os)
const;
275 typedef std::unordered_map<CString, cxuint> SectionMap;
276 friend struct AsmAmdCL2PseudoOps;
293 typedef std::unordered_map<CString, Relocation> RelocMap;
298 cxuint metadataSection;
299 cxuint isaMetadataSection;
300 cxuint configSection;
303 std::unordered_set<CString> argNamesSet;
307 std::vector<Section> sections;
309 std::vector<Kernel*> kernelStates;
311 SectionMap extraSectionMap;
312 SectionMap innerExtraSectionMap;
313 cxuint rodataSection;
316 cxuint samplerInitSection;
318 cxuint innerSavedSection;
319 cxuint extraSectionCount;
320 cxuint innerExtraSectionCount;
322 void saveCurrentSection();
323 void restoreCurrentAllocRegs();
324 void saveCurrentAllocRegs();
325 cxuint getDriverVersion()
const;
332 cxuint addKernel(
const char* kernelName);
333 cxuint addSection(
const char* sectionName, cxuint kernelId);
335 cxuint getSectionId(
const char* sectionName)
const;
336 void setCurrentKernel(cxuint kernel);
337 void setCurrentSection(cxuint sectionId);
339 SectionInfo getSectionInfo(cxuint sectionId)
const;
340 bool parsePseudoOp(
const CString& firstName,
341 const char* stmtPlace,
const char* linePtr);
343 bool resolveSymbol(
const AsmSymbol& symbol, uint64_t& value, cxuint& sectionId);
344 bool resolveRelocation(
const AsmExpression* expr, uint64_t& value, cxuint& sectionId);
345 bool prepareBinary();
346 void writeBinary(std::ostream& os)
const;
357 enum class Inside : cxbyte {
358 MAINLAYOUT,
CONFIG, ARGS, PROGINFO
361 typedef std::unordered_map<CString, cxuint> SectionMap;
362 friend struct AsmGalliumPseudoOps;
373 cxuint defaultSection;
375 cxbyte progInfoEntries;
379 std::vector<Kernel> kernelStates;
380 std::vector<Section> sections;
381 std::vector<cxuint> kcodeSelection;
382 std::stack<std::vector<cxuint> > kcodeSelStack;
383 cxuint currentKcodeKernel;
384 SectionMap extraSectionMap;
387 cxuint commentSection;
390 cxuint extraSectionCount;
392 void restoreKcodeCurrentAllocRegs();
393 void saveKcodeCurrentAllocRegs();
400 cxuint addKernel(
const char* kernelName);
401 cxuint addSection(
const char* sectionName, cxuint kernelId);
403 cxuint getSectionId(
const char* sectionName)
const;
404 void setCurrentKernel(cxuint kernel);
405 void setCurrentSection(cxuint sectionId);
407 SectionInfo getSectionInfo(cxuint sectionId)
const;
408 bool parsePseudoOp(
const CString& firstName,
409 const char* stmtPlace,
const char* linePtr);
410 void handleLabel(
const CString& label);
412 bool prepareBinary();
413 void writeBinary(std::ostream& os)
const;
440 typedef std::unordered_map<CString, cxuint> SectionMap;
441 friend struct AsmROCmPseudoOps;
452 cxuint configSection;
453 std::unique_ptr<AsmROCmKernelConfig> config;
455 cxuint ctrlDirSection;
460 void initializeKernelConfig();
462 std::vector<Kernel*> kernelStates;
463 std::vector<Section> sections;
464 std::vector<cxuint> kcodeSelection;
465 std::stack<std::vector<cxuint> > kcodeSelStack;
466 cxuint currentKcodeKernel;
467 SectionMap extraSectionMap;
469 cxuint commentSection;
471 cxuint extraSectionCount;
473 void restoreKcodeCurrentAllocRegs();
474 void saveKcodeCurrentAllocRegs();
483 cxuint addKernel(
const char* kernelName);
484 cxuint addSection(
const char* sectionName, cxuint kernelId);
486 cxuint getSectionId(
const char* sectionName)
const;
487 void setCurrentKernel(cxuint kernel);
488 void setCurrentSection(cxuint sectionId);
490 SectionInfo getSectionInfo(cxuint sectionId)
const;
491 bool parsePseudoOp(
const CString& firstName,
492 const char* stmtPlace,
const char* linePtr);
493 void handleLabel(
const CString& label);
495 bool prepareBinary();
496 void writeBinary(std::ostream& os)
const;
cxbyte userDataNum
number of user data
Definition: AsmFormats.h:425
code of program or kernel
bool dx10Clamp
DX10 CLAMP mode.
Definition: AsmFormats.h:433
common definitions for assembler and disassembler
main class of assembler
Definition: Assembler.h:650
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: Assembler.h:363
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:97
cxuint usedSGPRsNum
number of used SGPRs
Definition: AsmFormats.h:424
configuration (global or for kernel)
AMD Catalyst kernel's metadata.
bool tgSize
enable TG_SIZE_EN bit
Definition: AsmFormats.h:430
handles raw code format
Definition: AsmFormats.h:180
cxuint dimMask
mask of dimension (bits: 0 - X, 1 - Y, 2 - Z)
Definition: AsmFormats.h:422
cxbyte priority
priority
Definition: AsmFormats.h:428
an array class
Definition: Containers.h:38
bool debugMode
debug mode
Definition: AsmFormats.h:431
handles ROCM binary format
Definition: AsmFormats.h:437
cxuint RelocType
relocation type
Definition: Commons.h:32
cxbyte exceptions
enabled exceptions
Definition: AsmFormats.h:429
data object
Definition: ROCmBinaries.h:52
GalliumCompute binaries handling (only with LLVM 3.6)
assembler relocation
Definition: Assembler.h:350
const AmdCL2Input * getOutput() const
get output structure pointer
Definition: AsmFormats.h:349
AsmSectionType
assembler section type
Definition: AsmFormats.h:45
absolute section id
Definition: AsmFormats.h:78
AMD OpenCL2 binaries generator.
main namespace
Definition: AsmFormats.h:41
ROCm kernel configuration structure.
Definition: ROCmBinaries.h:130
const GalliumInput * getOutput() const
get output object (input for bingenerator)
Definition: AsmFormats.h:416
bool ieeeMode
IEEE mode.
Definition: AsmFormats.h:426
no kernel, inner global space
Definition: AsmFormats.h:81
cxbyte floatMode
float mode
Definition: AsmFormats.h:427
none section id
Definition: AsmFormats.h:79
AMD Catalyst kernel's header.
utilities for other libraries and programs
no kernel, global space
Definition: AsmFormats.h:80
exception class
Definition: Utilities.h:58
const AmdInput * getOutput() const
get output structure pointer
Definition: AsmFormats.h:267
const ROCmInput * getOutput() const
get output object (input for bingenerator)
Definition: AsmFormats.h:499
handles GalliumCompute format
Definition: AsmFormats.h:354
assembler symbol structure
Definition: Assembler.h:245
Definition: AsmFormats.h:420
cxuint usedVGPRsNum
number of used VGPRs
Definition: AsmFormats.h:423
handles AMD Catalyst format
Definition: AsmFormats.h:206
handles AMD OpenCL 2.0 binary format
Definition: AsmFormats.h:272
section is unresolvable
Definition: AsmFormats.h:89
simple C-string container
Definition: CString.h:38
bool privilegedMode
prvileged mode
Definition: AsmFormats.h:432