CLRX  1
An unofficial OpenCL extensions designed for Radeon GPUs
AsmDefs.h
Go to the documentation of this file.
1 /*
2  * CLRadeonExtender - Unofficial OpenCL Radeon Extensions Library
3  * Copyright (C) 2014-2017 Mateusz Szpakowski
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18  */
23 #ifndef __CLRX_ASMDEFS_H__
24 #define __CLRX_ASMDEFS_H__
25 
26 #include <CLRX/Config.h>
27 #include <cstdint>
28 #include <vector>
29 #include <utility>
30 #include <list>
31 #include <unordered_map>
32 #include <CLRX/utils/Utilities.h>
33 #include <CLRX/amdasm/Commons.h>
34 #include <CLRX/amdasm/AsmSource.h>
35 #include <CLRX/amdasm/AsmFormats.h>
36 
38 namespace CLRX
39 {
40 
42 class AsmException: public Exception
43 {
44 public:
46  AsmException() = default;
48  explicit AsmException(const std::string& message);
50  virtual ~AsmException() noexcept = default;
51 };
52 
53 enum: cxbyte {
54  WS_UNSIGNED = 0, // only unsigned
55  WS_BOTH = 1, // both signed and unsigned range checking
56 };
57 
60 
61 enum : AsmExprTargetType
62 {
69 
70  GCNTGT_LITIMM = 16,
71  GCNTGT_SOPKSIMM16,
72  GCNTGT_SOPJMP,
73  GCNTGT_SMRDOFFSET,
74  GCNTGT_DSOFFSET16,
75  GCNTGT_DSOFFSET8_0,
76  GCNTGT_DSOFFSET8_1,
77  GCNTGT_MXBUFOFFSET,
78  GCNTGT_SMEMOFFSET,
79  GCNTGT_SOPCIMM8,
80  GCNTGT_SMEMIMM,
81  GCNTGT_SMEMOFFSETVEGA,
82  GCNTGT_SMEMOFFSET2, // RXVEGA first soffset
83  GCNTGT_INSTOFFSET,
84  GCNTGT_INSTOFFSET_S
85 };
86 
87 /*
88  * assembler expressions
89  */
90 
92 enum class AsmExprOp : cxbyte
93 {
94  ARG_VALUE = 0,
95  ARG_SYMBOL = 1,
96  NEGATE = 2,
97  BIT_NOT,
98  LOGICAL_NOT,
99  PLUS,
100  ADDITION,
101  SUBTRACT,
102  MULTIPLY,
103  DIVISION,
105  MODULO,
106  SIGNED_MODULO,
107  BIT_AND,
108  BIT_OR, //< bitwise OR
109  BIT_XOR,
110  BIT_ORNOT,
111  SHIFT_LEFT,
112  SHIFT_RIGHT,
114  LOGICAL_AND,
115  LOGICAL_OR,
116  EQUAL,
117  NOT_EQUAL,
118  LESS,
119  LESS_EQ,
120  GREATER,
121  GREATER_EQ,
122  BELOW,
123  BELOW_EQ,
124  ABOVE,
125  ABOVE_EQ,
126  CHOICE,
127  CHOICE_START,
128  FIRST_ARG = ARG_VALUE,
129  LAST_ARG = ARG_SYMBOL,
130  FIRST_UNARY = NEGATE,
131  LAST_UNARY = PLUS,
134  NONE = 0xff
135 };
136 
137 struct AsmExprTarget;
138 
139 union AsmExprArg;
140 
141 class AsmExpression;
142 
145 {
147  size_t argIndex;
148  size_t opIndex;
149 
151  bool operator==(const AsmExprSymbolOccurrence& b) const
152  { return expression==b.expression && opIndex==b.opIndex && argIndex==b.argIndex; }
153 };
154 
155 struct AsmRegVar;
156 struct AsmScope;
157 
159 struct AsmSymbol
160 {
165  cxuint hasValue:1;
166  cxuint onceDefined:1;
167  cxuint resolving:1;
168  cxuint base:1;
169  cxuint snapshot:1;
170  cxuint regRange:1;
171  uint64_t value;
172  uint64_t size;
173  union {
175  const AsmRegVar* regVar;
176  };
177 
179  std::vector<AsmExprSymbolOccurrence> occurrencesInExprs;
180 
182  explicit AsmSymbol(bool _onceDefined = false) :
183  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
184  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
185  regRange(false), value(0), size(0), expression(nullptr)
186  { }
188  explicit AsmSymbol(AsmExpression* expr, bool _onceDefined = false, bool _base = false) :
189  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
190  onceDefined(_onceDefined), resolving(false), base(_base),
191  snapshot(false), regRange(false), value(0), size(0), expression(expr)
192  { }
194  explicit AsmSymbol(cxuint _sectionId, uint64_t _value, bool _onceDefined = false) :
195  refCount(1), sectionId(_sectionId), info(0), other(0), hasValue(true),
196  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
197  regRange(false), value(_value), size(0), expression(nullptr)
198  { }
200  ~AsmSymbol();
201 
203  void addOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex)
204  { occurrencesInExprs.push_back({expr, argIndex, opIndex}); }
206  void removeOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex);
208  void clearOccurrencesInExpr();
210  void undefine();
212  bool isDefined() const
213  { return hasValue || expression!=nullptr; }
214 };
215 
217 typedef std::unordered_map<CString, AsmSymbol> AsmSymbolMap;
219 typedef AsmSymbolMap::value_type AsmSymbolEntry;
220 
223 {
224  AsmExprTargetType type;
225  union
226  {
227  AsmSymbolEntry* symbol;
228  struct {
230  union {
231  size_t offset;
232  size_t cflowId;
233  };
234  };
235  };
238 
240  AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
241  : type(_type), sectionId(_sectionId), offset(_offset)
242  { }
243 
245  static AsmExprTarget symbolTarget(AsmSymbolEntry* entry)
246  {
247  AsmExprTarget target;
248  target.type = ASMXTGT_SYMBOL;
249  target.symbol = entry;
250  return target;
251  }
253  static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
254  {
255  AsmExprTarget target;
256  target.type = ASMXTGT_CODEFLOW;
257  target.sectionId = sectionId;
258  target.cflowId = cflowIndex;
259  return target;
260  }
261 
263  template<typename T>
264  static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
265  {
266  AsmExprTarget target;
267  target.type = (sizeof(T)==1) ? ASMXTGT_DATA8 : (sizeof(T)==2) ? ASMXTGT_DATA16 :
268  (sizeof(T)==4) ? ASMXTGT_DATA32 : ASMXTGT_DATA64;
269  target.sectionId = sectionId;
270  target.offset = offset;
271  return target;
272  }
273 };
274 
277 {
279  size_t offset;
281  union {
282  AsmSymbolEntry* symbol;
284  };
285  uint64_t addend;
286 };
287 
290 {
291 private:
292  class TempSymbolSnapshotMap;
293 
294  AsmExprTarget target;
295  AsmSourcePos sourcePos;
296  size_t symOccursNum;
297  bool relativeSymOccurs;
298  bool baseExpr;
299  Array<AsmExprOp> ops;
300  std::unique_ptr<LineCol[]> messagePositions;
301  std::unique_ptr<AsmExprArg[]> args;
302 
303  AsmSourcePos getSourcePos(size_t msgPosIndex) const
304  {
305  AsmSourcePos pos = sourcePos;
306  pos.lineNo = messagePositions[msgPosIndex].lineNo;
307  pos.colNo = messagePositions[msgPosIndex].colNo;
308  return pos;
309  }
310 
311  static bool makeSymbolSnapshot(Assembler& assembler,
312  TempSymbolSnapshotMap* snapshotMap, const AsmSymbolEntry& symEntry,
313  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* topParentSourcePos);
314 
315  AsmExpression();
316  void setParams(size_t symOccursNum, bool relativeSymOccurs,
317  size_t _opsNum, const AsmExprOp* ops, size_t opPosNum, const LineCol* opPos,
318  size_t argsNum, const AsmExprArg* args, bool baseExpr = false);
319 public:
321  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
322  size_t opsNum, size_t opPosNum, size_t argsNum, bool baseExpr = false);
324  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
325  size_t opsNum, const AsmExprOp* ops, size_t opPosNum,
326  const LineCol* opPos, size_t argsNum, const AsmExprArg* args,
327  bool baseExpr = false);
329  ~AsmExpression();
330 
332  bool isEmpty() const
333  { return ops.empty(); }
334 
336  AsmExpression* createForSnapshot(const AsmSourcePos* exprSourcePos) const;
337 
339  void setTarget(AsmExprTarget _target)
340  { target = _target; }
341 
343 
349  bool evaluate(Assembler& assembler, uint64_t& value, cxuint& sectionId) const
350  { return evaluate(assembler, 0, ops.size(), value, sectionId); }
351 
353 
361  bool evaluate(Assembler& assembler, size_t opStart, size_t opEnd,
362  uint64_t& value, cxuint& sectionId) const;
363 
365 
372  static AsmExpression* parse(Assembler& assembler, size_t& linePos,
373  bool makeBase = false, bool dontResolveSymbolsLater = false);
374 
376 
383  static AsmExpression* parse(Assembler& assembler, const char*& linePtr,
384  bool makeBase = false, bool dontResolveSymbolsLater = false);
385 
387  static bool isArg(AsmExprOp op)
388  { return (AsmExprOp::FIRST_ARG <= op && op <= AsmExprOp::LAST_ARG); }
390  static bool isUnaryOp(AsmExprOp op)
391  { return (AsmExprOp::FIRST_UNARY <= op && op <= AsmExprOp::LAST_UNARY); }
393  static bool isBinaryOp(AsmExprOp op)
394  { return (AsmExprOp::FIRST_BINARY <= op && op <= AsmExprOp::LAST_BINARY); }
396  const AsmExprTarget& getTarget() const
397  { return target; }
399  size_t getSymOccursNum() const
400  { return symOccursNum; }
402  size_t hasRelativeSymOccurs() const
403  { return relativeSymOccurs; }
406  { return --symOccursNum!=0; }
407 
409  void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value,
410  cxuint sectionId = ASMSECT_ABS);
412  const Array<AsmExprOp>& getOps() const
413  { return ops; }
415  const AsmExprArg* getArgs() const
416  { return args.get(); }
418  const AsmSourcePos& getSourcePos() const
419  { return sourcePos; }
420 
422  size_t toTop(size_t opIndex) const;
423 
425  static bool makeSymbolSnapshot(Assembler& assembler, const AsmSymbolEntry& symEntry,
426  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* parentExprSourcePos);
427 };
428 
430 {
431  if (base) delete expression; // if symbol with base expresion
432  clearOccurrencesInExpr();
433 }
434 
437 {
438  AsmSymbolEntry* symbol;
439  uint64_t value;
440  struct {
441  uint64_t value;
443  } relValue;
444 };
445 
447  uint64_t value, cxuint sectionId)
448 {
449  ops[occurrence.opIndex] = AsmExprOp::ARG_VALUE;
450  args[occurrence.argIndex].relValue.value = value;
451  args[occurrence.argIndex].relValue.sectionId = sectionId;
452  if (sectionId != ASMSECT_ABS)
453  relativeSymOccurs = true;
454 }
455 
458 
459 enum : AsmRegField
460 {
461  ASMFIELD_NONE = 0,
462  GCNFIELD_SSRC0,
463  GCNFIELD_SSRC1,
464  GCNFIELD_SDST,
465  GCNFIELD_SMRD_SBASE,
466  GCNFIELD_SMRD_SDST,
467  GCNFIELD_SMRD_SDSTH,
468  GCNFIELD_SMRD_SOFFSET,
469  GCNFIELD_VOP_SRC0,
470  GCNFIELD_VOP_VSRC1,
471  GCNFIELD_VOP_SSRC1,
472  GCNFIELD_VOP_VDST,
473  GCNFIELD_VOP_SDST,
474  GCNFIELD_VOP3_SRC0,
475  GCNFIELD_VOP3_SRC1,
476  GCNFIELD_VOP3_SRC2,
477  GCNFIELD_VOP3_VDST,
478  GCNFIELD_VOP3_SDST0,
479  GCNFIELD_VOP3_SSRC,
480  GCNFIELD_VOP3_SDST1,
481  GCNFIELD_VINTRP_VSRC0,
482  GCNFIELD_VINTRP_VDST,
483  GCNFIELD_DS_ADDR,
484  GCNFIELD_DS_DATA0,
485  GCNFIELD_DS_DATA1,
486  GCNFIELD_DS_VDST,
487  GCNFIELD_M_VADDR,
488  GCNFIELD_M_VDATA,
489  GCNFIELD_M_VDATAH,
490  GCNFIELD_M_VDATALAST,
491  GCNFIELD_M_SRSRC,
492  GCNFIELD_MIMG_SSAMP,
493  GCNFIELD_M_SOFFSET,
494  GCNFIELD_EXP_VSRC0,
495  GCNFIELD_EXP_VSRC1,
496  GCNFIELD_EXP_VSRC2,
497  GCNFIELD_EXP_VSRC3,
498  GCNFIELD_FLAT_ADDR,
499  GCNFIELD_FLAT_DATA,
500  GCNFIELD_FLAT_VDST,
501  GCNFIELD_FLAT_VDSTLAST,
502  GCNFIELD_DPPSDWA_SRC0,
503  GCNFIELD_DPPSDWA_SSRC0,
504  GCNFIELD_FLAT_SADDR
505 };
506 
507 struct AsmScope;
508 
510 struct AsmRegVar
511 {
513  uint16_t size;
514 };
515 
517 struct AsmSingleVReg // key for regvar
518 {
519  const AsmRegVar* regVar;
520  uint16_t index;
521 
523  bool operator==(const AsmSingleVReg& r2) const
524  { return regVar == r2.regVar && index == r2.index; }
526  bool operator!=(const AsmSingleVReg& r2) const
527  { return regVar == r2.regVar && index == r2.index; }
528 };
529 
531 typedef std::unordered_map<CString, AsmRegVar> AsmRegVarMap;
533 typedef AsmRegVarMap::value_type AsmRegVarEntry;
534 
535 enum : cxbyte {
542 };
543 
546 {
547  size_t offset;
548  const AsmRegVar* regVar;
549  uint16_t rstart;
550  uint16_t rend;
551  AsmRegField regField;
554  bool useRegMode;
555 };
556 
559 {
560  const AsmRegVar* regVar;
561  uint16_t rstart;
562  uint16_t rend;
563  AsmRegField regField;
566 };
567 
570 {
571  AsmRegField regField;
573 };
574 
577 {
578  uint16_t rstart;
579  uint16_t rend;
581 };
582 
585 {
586  JUMP = 0,
592 };
593 
596 {
597  size_t offset;
598  size_t target;
600 };
601 
603 typedef std::unordered_map<CString, RefPtr<const AsmMacro> > AsmMacroMap;
604 
605 struct AsmScope;
606 
608 typedef std::unordered_map<CString, AsmScope*> AsmScopeMap;
609 
611 struct AsmScope
612 {
614  AsmSymbolMap symbolMap;
615  AsmRegVarMap regVarMap;
616  AsmScopeMap scopeMap;
617  bool temporary;
618  std::list<AsmScope*> usedScopes;
619 
621  std::unordered_map<AsmScope*, std::list<AsmScope*>::iterator> usedScopesSet;
622 
624  AsmScope(AsmScope* _parent, const AsmSymbolMap& _symbolMap,
625  bool _temporary = false)
626  : parent(_parent), symbolMap(_symbolMap), temporary(_temporary)
627  { }
629  AsmScope(AsmScope* _parent = nullptr, bool _temporary= false)
630  : parent(_parent), temporary(_temporary)
631  { }
633  ~AsmScope();
634 
636  void startUsingScope(AsmScope* scope);
638  void stopUsingScope(AsmScope* scope);
641  {
642  usedScopes.clear();
643  usedScopesSet.clear();
644  }
646  void deleteSymbolsRecursively();
647 };
648 
649 class ISAUsageHandler;
650 
653 {
654  const char* name;
658  uint64_t alignment;
659  uint64_t size;
660  std::vector<cxbyte> content;
661 
662  std::unique_ptr<ISAUsageHandler> usageHandler;
663  std::vector<AsmCodeFlowEntry> codeFlow;
664 
666  AsmSection();
668  AsmSection(const char* _name, cxuint _kernelId, AsmSectionType _type,
669  Flags _flags, uint64_t _alignment, uint64_t _size = 0)
670  : name(_name), kernelId(_kernelId), type(_type), flags(_flags),
671  alignment(_alignment), size(_size)
672  { }
673 
675  AsmSection(const AsmSection& section);
677  AsmSection& operator=(const AsmSection& section);
678 
681  { codeFlow.push_back(entry); }
682 
684  size_t getSize() const
685  { return ((flags&ASMSECT_WRITEABLE) != 0) ? content.size() : size; }
686 };
687 
689 struct AsmKernel
690 {
691  const char* name;
693  std::vector<std::pair<size_t, size_t> > codeRegions;
694 
696  void openCodeRegion(size_t offset);
698  void closeCodeRegion(size_t offset);
699 };
700 
701 };
702 
703 namespace std
704 {
705 
707 template<>
708 struct hash<CLRX::AsmSingleVReg>
709 {
711  typedef std::size_t result_type;
712 
714  size_t operator()(const CLRX::AsmSingleVReg& r1) const
715  {
716  std::hash<const CLRX::AsmRegVar*> h1;
717  std::hash<uint16_t> h2;
718  return h1(r1.regVar) ^ (h2(r1.index)<<1);
719  }
720 };
721 
722 }
723 
724 #endif
AsmRegVarMap regVarMap
regvar map
Definition: AsmDefs.h:615
common definitions for assembler and disassembler
size_t target
target jump addreses
Definition: AsmDefs.h:598
main class of assembler
Definition: Assembler.h:403
AsmExprTargetType type
type of target
Definition: AsmDefs.h:224
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: AsmDefs.h:289
AsmSymbolEntry * symbol
symbol
Definition: AsmDefs.h:282
AsmSymbol(bool _onceDefined=false)
empty constructor
Definition: AsmDefs.h:182
kernel entry structure
Definition: AsmDefs.h:689
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:97
plus (nothing)
std::unordered_map< CString, AsmRegVar > AsmRegVarMap
regvar map
Definition: AsmDefs.h:531
AsmExpression * expression
expression of symbol (if not resolved)
Definition: AsmDefs.h:174
bool operator==(const AsmExprSymbolOccurrence &b) const
comparison operator
Definition: AsmDefs.h:151
cxuint kernelId
kernel id (optional)
Definition: AsmDefs.h:655
none operation
AsmRegVarMap::value_type AsmRegVarEntry
regvar entry
Definition: AsmDefs.h:533
target is 32-bit word
Definition: AsmDefs.h:66
target is 64-bit word
Definition: AsmDefs.h:67
AsmSymbolEntry * symbol
symbol entry (if ASMXTGT_SYMBOL)
Definition: AsmDefs.h:227
target for assembler expression
Definition: AsmDefs.h:222
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:564
~AsmSymbol()
destructor
Definition: AsmDefs.h:429
size_t operator()(const CLRX::AsmSingleVReg &r1) const
a calling operator
Definition: AsmDefs.h:714
AsmExprOp
assembler expression operator
Definition: AsmDefs.h:92
assembler section
Definition: AsmDefs.h:652
AsmExprTarget()
empty constructor
Definition: AsmDefs.h:237
for internal usage
Definition: AsmDefs.h:541
size_t offset
offset in section
Definition: AsmDefs.h:547
code flow entry
Definition: AsmDefs.h:68
static AsmExprTarget symbolTarget(AsmSymbolEntry *entry)
make symbol target for expression
Definition: AsmDefs.h:245
assembler scope for symbol, macros, regvars
Definition: AsmDefs.h:611
Regvar info structure.
Definition: AsmDefs.h:510
cxbyte info
ELF symbol info.
Definition: AsmDefs.h:163
cxuint type
scalar/vector/other
Definition: AsmDefs.h:512
std::vector< AsmCodeFlowEntry > codeFlow
code flow info
Definition: AsmDefs.h:663
const AsmExprTarget & getTarget() const
get targer of expression
Definition: AsmDefs.h:396
uint16_t rstart
register start
Definition: AsmDefs.h:561
signed (arithmetic) shift right
void addCodeFlowEntry(const AsmCodeFlowEntry &entry)
add code flow entry to this section
Definition: AsmDefs.h:680
STL namespace.
static bool isUnaryOp(AsmExprOp op)
return true if is unary op
Definition: AsmDefs.h:390
uint16_t index
index of regvar array
Definition: AsmDefs.h:520
AsmSourcePos sourcePos
source position of definition
Definition: AsmDefs.h:692
size_t getSymOccursNum() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:399
std::list< AsmScope * > usedScopes
list of used scope in this scope
Definition: AsmDefs.h:618
assembler symbol occurrence in expression
Definition: AsmDefs.h:144
regvar usage (internal)
Definition: AsmDefs.h:558
std::unordered_map< CString, AsmScope * > AsmScopeMap
type definition of scope&#39;s map
Definition: AsmDefs.h:605
cxuint sectionId
section id
Definition: AsmDefs.h:162
void addOccurrenceInExpr(AsmExpression *expr, size_t argIndex, size_t opIndex)
adds occurrence in expression
Definition: AsmDefs.h:203
ColNo colNo
column number
Definition: AsmSource.h:157
AsmSymbol(cxuint _sectionId, uint64_t _value, bool _onceDefined=false)
constructor with value and section id
Definition: AsmDefs.h:194
void stopUsingScopes()
remove all usings
Definition: AsmDefs.h:640
Configuration header.
cxuint RelocType
relocation type
Definition: Commons.h:33
less or equal than
unsigned modulo
void setTarget(AsmExprTarget _target)
set target of expression
Definition: AsmDefs.h:339
for internal usage
Definition: AsmDefs.h:540
std::unordered_map< AsmScope *, std::list< AsmScope * >::iterator > usedScopesSet
set of used scopes in this scope
Definition: AsmDefs.h:621
size_t cflowId
cflow index of destination
Definition: AsmDefs.h:232
return from procedure
Definition: AsmDefs.h:589
AsmScope * parent
parent scope
Definition: AsmDefs.h:613
line and column
Definition: AsmSource.h:44
bool isEmpty() const
return true if expression is empty
Definition: AsmDefs.h:332
std::unordered_map< CString, AsmSymbol > AsmSymbolMap
assembler symbol map
Definition: AsmDefs.h:217
AsmScope(AsmScope *_parent, const AsmSymbolMap &_symbolMap, bool _temporary=false)
constructor
Definition: AsmDefs.h:624
an assembler formats
cxuint sectionId
sectionId
Definition: AsmDefs.h:442
LineNo lineNo
line number of top-most source
Definition: AsmSource.h:156
size_t offset
offset of relocation
Definition: AsmDefs.h:279
AsmRegField regField
place in instruction
Definition: AsmDefs.h:563
absolute section id
Definition: AsmFormats.h:81
uint64_t value
value of symbol
Definition: AsmDefs.h:171
AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
constructor to create custom target
Definition: AsmDefs.h:240
single regvar id
Definition: AsmDefs.h:517
cxbyte rwFlags
1 - read, 2 - write, other flags
Definition: AsmDefs.h:572
uint16_t rend
register end
Definition: AsmDefs.h:562
assembler relocation
Definition: AsmDefs.h:276
logical shift irght
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:552
bool temporary
true if temporary
Definition: AsmDefs.h:617
AsmException()=default
empty constructor
size_t opIndex
operator index
Definition: AsmDefs.h:148
unsigned less or equal
const char * name
name of kernel
Definition: AsmDefs.h:691
AsmSectionType
assembler section type
Definition: AsmFormats.h:46
unsigned char cxbyte
unsigned byte
Definition: Config.h:215
cxbyte rwFlags
rw flags and others
Definition: AsmDefs.h:580
internal structure for regusage
Definition: AsmDefs.h:576
std::unordered_map< CString, RefPtr< const AsmMacro > > AsmMacroMap
assembler macro map
Definition: AsmDefs.h:603
greater or equal than
main namespace
Definition: AsmDefs.h:38
AsmSymbolEntry * symbol
if symbol
Definition: AsmDefs.h:438
absolute symbol without defined value
void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value, cxuint sectionId=ASMSECT_ABS)
substitute occurrence in expression by value
Definition: AsmDefs.h:446
const AsmRegVar * regVar
regvar
Definition: AsmDefs.h:519
uint16_t rstart
register start
Definition: AsmDefs.h:578
static bool isArg(AsmExprOp op)
return true if is argument op
Definition: AsmDefs.h:387
bool unrefSymOccursNum()
unreference symbol occurrences in expression (used internally)
Definition: AsmDefs.h:405
unsigned int cxuint
unsigned int
Definition: Config.h:223
bool operator!=(const AsmSingleVReg &r2) const
not equal operator
Definition: AsmDefs.h:526
internal structure for regusage
Definition: AsmDefs.h:569
static bool isBinaryOp(AsmExprOp op)
return true if is binary op
Definition: AsmDefs.h:393
code end
Definition: AsmDefs.h:591
target is byte
Definition: AsmDefs.h:64
uint64_t size
size of symbol
Definition: AsmDefs.h:172
size_t getSize() const
get section&#39;s size
Definition: AsmDefs.h:684
binary negation
AsmScope(AsmScope *_parent=nullptr, bool _temporary=false)
constructor
Definition: AsmDefs.h:629
cxbyte AsmExprTargetType
expression target type (one byte)
Definition: AsmDefs.h:59
AsmCodeFlowType type
type of code flow entry
Definition: AsmDefs.h:599
uint16_t rend
register end
Definition: AsmDefs.h:550
uint64_t size
section size
Definition: AsmDefs.h:659
std::vector< AsmExprSymbolOccurrence > occurrencesInExprs
Definition: AsmDefs.h:179
target is 16-bit word
Definition: AsmDefs.h:65
std::vector< cxbyte > content
content of section
Definition: AsmDefs.h:660
AsmSymbolMap::value_type AsmSymbolEntry
assembler symbol entry
Definition: AsmDefs.h:219
Flags flags
section flags
Definition: AsmDefs.h:657
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:560
target is symbol
Definition: AsmDefs.h:63
uint64_t value
value
Definition: AsmDefs.h:439
AsmRegField regField
place in instruction
Definition: AsmDefs.h:571
cxuint refCount
reference counter (for internal use only)
Definition: AsmDefs.h:161
uint16_t rend
register end
Definition: AsmDefs.h:579
size_t offset
offset of destination
Definition: AsmDefs.h:231
uint16_t size
in regs
Definition: AsmDefs.h:513
size_t offset
offset where is this entry
Definition: AsmDefs.h:597
size_t argIndex
argument index
Definition: AsmDefs.h:147
cxuint sectionId
section id where relocation is present
Definition: AsmDefs.h:278
cxuint sectionId
section id of destination
Definition: AsmDefs.h:229
utilities for other libraries and programs
const Array< AsmExprOp > & getOps() const
get operators list
Definition: AsmDefs.h:412
unsigned division
std::unique_ptr< ISAUsageHandler > usageHandler
usage handler
Definition: AsmDefs.h:662
AsmSection(const char *_name, cxuint _kernelId, AsmSectionType _type, Flags _flags, uint64_t _alignment, uint64_t _size=0)
constructor
Definition: AsmDefs.h:668
RelocType type
relocation type
Definition: AsmDefs.h:280
uint64_t alignment
section alignment
Definition: AsmDefs.h:658
static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
make n-bit word target for expression
Definition: AsmDefs.h:264
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:548
std::string message
message
Definition: Utilities.h:61
exception class
Definition: Utilities.h:58
AsmSymbolMap symbolMap
symbol map
Definition: AsmDefs.h:614
AsmScopeMap scopeMap
scope map
Definition: AsmDefs.h:616
code start
Definition: AsmDefs.h:590
AsmSectionType type
type of section
Definition: AsmDefs.h:656
regvar usage in code
Definition: AsmDefs.h:545
uint16_t rstart
register start
Definition: AsmDefs.h:549
call of procedure
Definition: AsmDefs.h:588
AsmSymbol(AsmExpression *expr, bool _onceDefined=false, bool _base=false)
constructor with expression
Definition: AsmDefs.h:188
for internal usage (regtype)
Definition: AsmDefs.h:539
static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
make code flow target for expression
Definition: AsmDefs.h:253
register will be read
Definition: AsmDefs.h:536
cxbyte align
register alignment
Definition: AsmDefs.h:565
code flow entry
Definition: AsmDefs.h:595
cxbyte other
ELF symbol other.
Definition: AsmDefs.h:164
jump
Definition: AsmDefs.h:586
std::vector< std::pair< size_t, size_t > > codeRegions
code regions
Definition: AsmDefs.h:693
const char * name
section name
Definition: AsmDefs.h:654
an assembler sources handling
virtual ~AsmException() noexcept=default
destructor
AsmCodeFlowType
code flow type
Definition: AsmDefs.h:584
Assembler exception class.
Definition: AsmDefs.h:42
cxuint relSectionId
section for which relocation is defined
Definition: AsmDefs.h:283
assembler symbol structure
Definition: AsmDefs.h:159
bool useRegMode
if RVU from useReg pseudo-ops
Definition: AsmDefs.h:554
bool isDefined() const
return true if symbol defined (have value or expression)
Definition: AsmDefs.h:212
register will be written
Definition: AsmDefs.h:537
cxbyte AsmRegField
type of register field
Definition: AsmDefs.h:457
const AsmExprArg * getArgs() const
get argument list
Definition: AsmDefs.h:415
ISA (register and regvar) Usage handler.
Definition: Assembler.h:64
unsigned less or equal
size_t hasRelativeSymOccurs() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:402
AsmRegField regField
place in instruction
Definition: AsmDefs.h:551
uint64_t addend
addend
Definition: AsmDefs.h:285
conditional jump
Definition: AsmDefs.h:587
AsmExpression * expression
target expression pointer
Definition: AsmDefs.h:146
bool evaluate(Assembler &assembler, uint64_t &value, cxuint &sectionId) const
try to evaluate expression
Definition: AsmDefs.h:349
assembler expression argument
Definition: AsmDefs.h:436
access mask
Definition: AsmDefs.h:538
cxbyte align
register alignment
Definition: AsmDefs.h:553
bool operator==(const AsmSingleVReg &r2) const
equal operator
Definition: AsmDefs.h:523
CLRX::AsmSingleVReg argument_type
argument type
Definition: AsmDefs.h:710
const AsmSourcePos & getSourcePos() const
get source position
Definition: AsmDefs.h:418
assembler source position
Definition: AsmSource.h:152
std::size_t result_type
result type
Definition: AsmDefs.h:711