23 #ifndef __CLRX_ASMFORMATS_H__
24 #define __CLRX_ASMFORMATS_H__
26 #include <CLRX/Config.h>
31 #include <unordered_set>
32 #include <unordered_map>
65 EXTRA_PROGBITS = 0xfc,
81 ASMSECT_WRITEABLE = 1,
82 ASMSECT_ADDRESSABLE = 2,
83 ASMSECT_ABS_ADDRESSABLE = 4,
86 ASMELFSECT_ALLOCATABLE = 0x10,
87 ASMELFSECT_WRITEABLE = 0x20,
88 ASMELFSECT_EXECUTABLE = 0x40
134 virtual cxuint
addKernel(
const char* kernelName) = 0;
143 virtual cxuint
addSection(
const char* sectionName, cxuint kernelId) = 0;
146 virtual cxuint
getSectionId(
const char* sectionName)
const = 0;
157 const char* stmtPlace,
const char* linePtr) = 0;
162 uint64_t& value, cxuint& sectionId);
165 uint64_t& value, cxuint& sectionId);
169 virtual void writeBinary(std::ostream& os)
const = 0;
183 cxuint
addKernel(
const char* kernelName);
184 cxuint
addSection(
const char* sectionName, cxuint kernelId);
193 const char* stmtPlace,
const char* linePtr);
204 typedef std::unordered_map<CString, cxuint> SectionMap;
205 friend struct AsmAmdPseudoOps;
217 cxuint headerSection;
218 cxuint metadataSection;
219 cxuint configSection;
222 std::vector<cxuint> calNoteSections;
223 SectionMap extraSectionMap;
224 cxuint extraSectionCount;
226 std::unordered_set<CString> argNamesSet;
230 std::vector<Section> sections;
232 std::vector<Kernel*> kernelStates;
233 SectionMap extraSectionMap;
236 cxuint extraSectionCount;
238 void saveCurrentSection();
239 void restoreCurrentAllocRegs();
240 void saveCurrentAllocRegs();
247 cxuint
addKernel(
const char* kernelName);
248 cxuint
addSection(
const char* sectionName, cxuint kernelId);
256 const char* stmtPlace,
const char* linePtr);
270 typedef std::unordered_map<CString, cxuint> SectionMap;
271 friend struct AsmAmdCL2PseudoOps;
288 typedef std::unordered_map<CString, Relocation> RelocMap;
293 cxuint metadataSection;
294 cxuint isaMetadataSection;
295 cxuint configSection;
298 std::unordered_set<CString> argNamesSet;
302 std::vector<Section> sections;
304 std::vector<Kernel*> kernelStates;
306 SectionMap extraSectionMap;
307 SectionMap innerExtraSectionMap;
308 cxuint rodataSection;
311 cxuint samplerInitSection;
313 cxuint innerSavedSection;
314 cxuint extraSectionCount;
315 cxuint innerExtraSectionCount;
317 void saveCurrentSection();
318 void restoreCurrentAllocRegs();
319 void saveCurrentAllocRegs();
320 cxuint getDriverVersion()
const;
327 cxuint
addKernel(
const char* kernelName);
328 cxuint
addSection(
const char* sectionName, cxuint kernelId);
336 const char* stmtPlace,
const char* linePtr);
352 enum class Inside : cxbyte {
353 MAINLAYOUT,
CONFIG, ARGS, PROGINFO
356 typedef std::unordered_map<CString, cxuint> SectionMap;
357 friend struct AsmGalliumPseudoOps;
368 cxuint defaultSection;
370 cxbyte progInfoEntries;
374 std::vector<Kernel> kernelStates;
375 std::vector<Section> sections;
376 std::vector<cxuint> kcodeSelection;
377 std::stack<std::vector<cxuint> > kcodeSelStack;
378 cxuint currentKcodeKernel;
379 SectionMap extraSectionMap;
382 cxuint commentSection;
385 cxuint extraSectionCount;
387 void restoreKcodeCurrentAllocRegs();
388 void saveKcodeCurrentAllocRegs();
395 cxuint
addKernel(
const char* kernelName);
396 cxuint
addSection(
const char* sectionName, cxuint kernelId);
404 const char* stmtPlace,
const char* linePtr);
void writeBinary(std::ostream &os) const
write binary to output stream
code of program or kernel
~AsmRawCodeHandler()=default
destructor
common definitions for assembler and disassembler
main class of assembler
Definition: Assembler.h:559
cxuint addKernel(const char *kernelName)
add/set kernel
cxuint addSection(const char *sectionName, cxuint kernelId)
add section
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: Assembler.h:350
cxuint getSectionId(const char *sectionName) const
get section id if exists in current context, otherwise returns ASMSECT_NONE
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:97
void writeBinary(std::ostream &os) const
write binary to output stream
bool prepareBinary()
prepare binary for use
~AsmAmdCL2Handler()
destructor
configuration (global or for kernel)
AMD Catalyst kernel's metadata.
void setCurrentSection(cxuint sectionId)
set current section, this method can change current kernel if that required
handles raw code format
Definition: AsmFormats.h:175
AsmAmdCL2Handler(Assembler &assembler)
constructor
cxuint addKernel(const char *kernelName)
add/set kernel
void writeBinary(std::ostream &os) const
write binary to output stream
an array class
Definition: Containers.h:38
SectionInfo getSectionInfo(cxuint sectionId) const
get current section flags and type
SectionInfo getSectionInfo(cxuint sectionId) const
get current section flags and type
cxuint RelocType
relocation type
Definition: Commons.h:32
bool resolveSymbol(const AsmSymbol &symbol, uint64_t &value, cxuint §ionId)
resolve symbol if needed (for example that comes from unresolvable sections)
cxuint addSection(const char *sectionName, cxuint kernelId)
add section
void setCurrentKernel(cxuint kernel)
set current kernel
~AsmAmdHandler()
destructor
cxuint getSectionId(const char *sectionName) const
get section id if exists in current context, otherwise returns ASMSECT_NONE
GalliumCompute binaries handling (only with LLVM 3.6)
void setCurrentKernel(cxuint kernel)
set current kernel
const AmdCL2Input * getOutput() const
get output structure pointer
Definition: AsmFormats.h:344
AsmSectionType
assembler section type
Definition: AsmFormats.h:44
absolute section id
Definition: AsmFormats.h:73
cxuint addSection(const char *sectionName, cxuint kernelId)
add section
bool prepareBinary()
prepare binary for use
AMD OpenCL2 binaries generator.
void setCurrentSection(cxuint sectionId)
set current section, this method can change current kernel if that required
bool parsePseudoOp(const CString &firstName, const char *stmtPlace, const char *linePtr)
parse pseudo-op (return true if recognized pseudo-op)
bool resolveRelocation(const AsmExpression *expr, uint64_t &value, cxuint §ionId)
resolve relocation for specified expression
cxuint addSection(const char *sectionName, cxuint kernelId)
add section
const GalliumInput * getOutput() const
get output object (input for bingenerator)
Definition: AsmFormats.h:411
no kernel, inner global space
Definition: AsmFormats.h:76
cxuint addKernel(const char *kernelName)
add/set kernel
void setCurrentKernel(cxuint kernel)
set current kernel
cxuint getSectionId(const char *sectionName) const
get section id if exists in current context, otherwise returns ASMSECT_NONE
bool parsePseudoOp(const CString &firstName, const char *stmtPlace, const char *linePtr)
parse pseudo-op (return true if recognized pseudo-op)
void handleLabel(const CString &label)
handle labels
none section id
Definition: AsmFormats.h:74
bool parsePseudoOp(const CString &firstName, const char *stmtPlace, const char *linePtr)
parse pseudo-op (return true if recognized pseudo-op)
AMD Catalyst kernel's header.
AsmRawCodeHandler(Assembler &assembler)
constructor
utilities for other libraries and programs
AsmGalliumHandler(Assembler &assembler)
construcror
std::string message
message
Definition: Utilities.h:61
bool prepareBinary()
prepare binary for use
AsmAmdHandler(Assembler &assembler)
constructor
no kernel, global space
Definition: AsmFormats.h:75
~AsmGalliumHandler()=default
destructor
exception class
Definition: Utilities.h:58
cxuint addKernel(const char *kernelName)
add/set kernel
bool prepareBinary()
prepare binary for use
SectionInfo getSectionInfo(cxuint sectionId) const
get current section flags and type
const AmdInput * getOutput() const
get output structure pointer
Definition: AsmFormats.h:262
void setCurrentSection(cxuint sectionId)
set current section, this method can change current kernel if that required
void setCurrentSection(cxuint sectionId)
set current section, this method can change current kernel if that required
handles GalliumCompute format
Definition: AsmFormats.h:349
void writeBinary(std::ostream &os) const
write binary to output stream
cxuint getSectionId(const char *sectionName) const
get section id if exists in current context, otherwise returns ASMSECT_NONE
assembler symbol structure
Definition: Assembler.h:235
SectionInfo getSectionInfo(cxuint sectionId) const
get current section flags and type
void setCurrentKernel(cxuint kernel)
set current kernel
handles AMD Catalyst format
Definition: AsmFormats.h:201
handles AMD OpenCL 2.0 binary format
Definition: AsmFormats.h:267
bool parsePseudoOp(const CString &firstName, const char *stmtPlace, const char *linePtr)
parse pseudo-op (return true if recognized pseudo-op)
section is unresolvable
Definition: AsmFormats.h:84
simple C-string container
Definition: CString.h:38