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 
41 enum: cxbyte {
42  WS_UNSIGNED = 0, // only unsigned
43  WS_BOTH = 1, // both signed and unsigned range checking
44 };
45 
48 
49 enum : AsmExprTargetType
50 {
57 
58  GCNTGT_LITIMM = 16,
59  GCNTGT_SOPKSIMM16,
60  GCNTGT_SOPJMP,
61  GCNTGT_SMRDOFFSET,
62  GCNTGT_DSOFFSET16,
63  GCNTGT_DSOFFSET8_0,
64  GCNTGT_DSOFFSET8_1,
65  GCNTGT_MXBUFOFFSET,
66  GCNTGT_SMEMOFFSET,
67  GCNTGT_SOPCIMM8,
68  GCNTGT_SMEMIMM,
69  GCNTGT_SMEMOFFSETVEGA,
70  GCNTGT_SMEMOFFSET2, // RXVEGA first soffset
71  GCNTGT_INSTOFFSET,
72  GCNTGT_INSTOFFSET_S
73 };
74 
75 /*
76  * assembler expressions
77  */
78 
80 enum class AsmExprOp : cxbyte
81 {
82  ARG_VALUE = 0,
83  ARG_SYMBOL = 1,
84  NEGATE = 2,
85  BIT_NOT,
86  LOGICAL_NOT,
87  PLUS,
88  ADDITION,
89  SUBTRACT,
90  MULTIPLY,
91  DIVISION,
93  MODULO,
95  BIT_AND,
96  BIT_OR, //< bitwise OR
97  BIT_XOR,
98  BIT_ORNOT,
99  SHIFT_LEFT,
100  SHIFT_RIGHT,
102  LOGICAL_AND,
103  LOGICAL_OR,
104  EQUAL,
105  NOT_EQUAL,
106  LESS,
107  LESS_EQ,
108  GREATER,
109  GREATER_EQ,
110  BELOW,
111  BELOW_EQ,
112  ABOVE,
113  ABOVE_EQ,
114  CHOICE,
115  CHOICE_START,
116  FIRST_ARG = ARG_VALUE,
117  LAST_ARG = ARG_SYMBOL,
118  FIRST_UNARY = NEGATE,
119  LAST_UNARY = PLUS,
122  NONE = 0xff
123 };
124 
125 struct AsmExprTarget;
126 
127 union AsmExprArg;
128 
129 class AsmExpression;
130 
133 {
135  size_t argIndex;
136  size_t opIndex;
137 
139  bool operator==(const AsmExprSymbolOccurrence& b) const
140  { return expression==b.expression && opIndex==b.opIndex && argIndex==b.argIndex; }
141 };
142 
143 struct AsmRegVar;
144 struct AsmScope;
145 
147 struct AsmSymbol
148 {
153  cxuint hasValue:1;
154  cxuint onceDefined:1;
155  cxuint resolving:1;
156  cxuint base:1;
157  cxuint snapshot:1;
158  cxuint regRange:1;
159  uint64_t value;
160  uint64_t size;
161  union {
163  const AsmRegVar* regVar;
164  };
165 
167  std::vector<AsmExprSymbolOccurrence> occurrencesInExprs;
168 
170  explicit AsmSymbol(bool _onceDefined = false) :
171  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
172  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
173  regRange(false), value(0), size(0), expression(nullptr)
174  { }
176  explicit AsmSymbol(AsmExpression* expr, bool _onceDefined = false, bool _base = false) :
177  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
178  onceDefined(_onceDefined), resolving(false), base(_base),
179  snapshot(false), regRange(false), value(0), size(0), expression(expr)
180  { }
182  explicit AsmSymbol(cxuint _sectionId, uint64_t _value, bool _onceDefined = false) :
183  refCount(1), sectionId(_sectionId), info(0), other(0), hasValue(true),
184  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
185  regRange(false), value(_value), size(0), expression(nullptr)
186  { }
188  ~AsmSymbol();
189 
191  void addOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex)
192  { occurrencesInExprs.push_back({expr, argIndex, opIndex}); }
194  void removeOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex);
196  void clearOccurrencesInExpr();
198  void undefine();
200  bool isDefined() const
201  { return hasValue || expression!=nullptr; }
202 };
203 
205 typedef std::unordered_map<CString, AsmSymbol> AsmSymbolMap;
207 typedef AsmSymbolMap::value_type AsmSymbolEntry;
208 
211 {
212  AsmExprTargetType type;
213  union
214  {
215  AsmSymbolEntry* symbol;
216  struct {
218  union {
219  size_t offset;
220  size_t cflowId;
221  };
222  };
223  };
226 
228  AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
229  : type(_type), sectionId(_sectionId), offset(_offset)
230  { }
231 
233  static AsmExprTarget symbolTarget(AsmSymbolEntry* entry)
234  {
235  AsmExprTarget target;
236  target.type = ASMXTGT_SYMBOL;
237  target.symbol = entry;
238  return target;
239  }
241  static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
242  {
243  AsmExprTarget target;
244  target.type = ASMXTGT_CODEFLOW;
245  target.sectionId = sectionId;
246  target.cflowId = cflowIndex;
247  return target;
248  }
249 
251  template<typename T>
252  static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
253  {
254  AsmExprTarget target;
255  target.type = (sizeof(T)==1) ? ASMXTGT_DATA8 : (sizeof(T)==2) ? ASMXTGT_DATA16 :
256  (sizeof(T)==4) ? ASMXTGT_DATA32 : ASMXTGT_DATA64;
257  target.sectionId = sectionId;
258  target.offset = offset;
259  return target;
260  }
261 };
262 
265 {
267  size_t offset;
269  union {
270  AsmSymbolEntry* symbol;
272  };
273  uint64_t addend;
274 };
275 
278 {
279 private:
280  class TempSymbolSnapshotMap;
281 
282  AsmExprTarget target;
283  AsmSourcePos sourcePos;
284  size_t symOccursNum;
285  bool relativeSymOccurs;
286  bool baseExpr;
287  Array<AsmExprOp> ops;
288  std::unique_ptr<LineCol[]> messagePositions;
289  std::unique_ptr<AsmExprArg[]> args;
290 
291  AsmSourcePos getSourcePos(size_t msgPosIndex) const
292  {
293  AsmSourcePos pos = sourcePos;
294  pos.lineNo = messagePositions[msgPosIndex].lineNo;
295  pos.colNo = messagePositions[msgPosIndex].colNo;
296  return pos;
297  }
298 
299  static bool makeSymbolSnapshot(Assembler& assembler,
300  TempSymbolSnapshotMap* snapshotMap, const AsmSymbolEntry& symEntry,
301  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* topParentSourcePos);
302 
303  AsmExpression();
304  void setParams(size_t symOccursNum, bool relativeSymOccurs,
305  size_t _opsNum, const AsmExprOp* ops, size_t opPosNum, const LineCol* opPos,
306  size_t argsNum, const AsmExprArg* args, bool baseExpr = false);
307 public:
309  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
310  size_t opsNum, size_t opPosNum, size_t argsNum, bool baseExpr = false);
312  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
313  size_t opsNum, const AsmExprOp* ops, size_t opPosNum,
314  const LineCol* opPos, size_t argsNum, const AsmExprArg* args,
315  bool baseExpr = false);
317  ~AsmExpression();
318 
320  bool isEmpty() const
321  { return ops.empty(); }
322 
324  AsmExpression* createForSnapshot(const AsmSourcePos* exprSourcePos) const;
325 
327  void setTarget(AsmExprTarget _target)
328  { target = _target; }
329 
331 
337  bool evaluate(Assembler& assembler, uint64_t& value, cxuint& sectionId) const
338  { return evaluate(assembler, 0, ops.size(), value, sectionId); }
339 
341 
349  bool evaluate(Assembler& assembler, size_t opStart, size_t opEnd,
350  uint64_t& value, cxuint& sectionId) const;
351 
353 
360  static AsmExpression* parse(Assembler& assembler, size_t& linePos,
361  bool makeBase = false, bool dontResolveSymbolsLater = false);
362 
364 
371  static AsmExpression* parse(Assembler& assembler, const char*& linePtr,
372  bool makeBase = false, bool dontResolveSymbolsLater = false);
373 
375  static bool isArg(AsmExprOp op)
376  { return (AsmExprOp::FIRST_ARG <= op && op <= AsmExprOp::LAST_ARG); }
378  static bool isUnaryOp(AsmExprOp op)
379  { return (AsmExprOp::FIRST_UNARY <= op && op <= AsmExprOp::LAST_UNARY); }
381  static bool isBinaryOp(AsmExprOp op)
382  { return (AsmExprOp::FIRST_BINARY <= op && op <= AsmExprOp::LAST_BINARY); }
384  const AsmExprTarget& getTarget() const
385  { return target; }
387  size_t getSymOccursNum() const
388  { return symOccursNum; }
390  size_t hasRelativeSymOccurs() const
391  { return relativeSymOccurs; }
394  { return --symOccursNum!=0; }
395 
397  void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value,
398  cxuint sectionId = ASMSECT_ABS);
400  const Array<AsmExprOp>& getOps() const
401  { return ops; }
403  const AsmExprArg* getArgs() const
404  { return args.get(); }
406  const AsmSourcePos& getSourcePos() const
407  { return sourcePos; }
408 
410  size_t toTop(size_t opIndex) const;
411 
413  static bool makeSymbolSnapshot(Assembler& assembler, const AsmSymbolEntry& symEntry,
414  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* parentExprSourcePos);
415 };
416 
418 {
419  if (base) delete expression; // if symbol with base expresion
420  clearOccurrencesInExpr();
421 }
422 
425 {
426  AsmSymbolEntry* symbol;
427  uint64_t value;
428  struct {
429  uint64_t value;
431  } relValue;
432 };
433 
435  uint64_t value, cxuint sectionId)
436 {
437  ops[occurrence.opIndex] = AsmExprOp::ARG_VALUE;
438  args[occurrence.argIndex].relValue.value = value;
439  args[occurrence.argIndex].relValue.sectionId = sectionId;
440  if (sectionId != ASMSECT_ABS)
441  relativeSymOccurs = true;
442 }
443 
446 
447 enum : AsmRegField
448 {
449  ASMFIELD_NONE = 0,
450  GCNFIELD_SSRC0,
451  GCNFIELD_SSRC1,
452  GCNFIELD_SDST,
453  GCNFIELD_SMRD_SBASE,
454  GCNFIELD_SMRD_SDST,
455  GCNFIELD_SMRD_SDSTH,
456  GCNFIELD_SMRD_SOFFSET,
457  GCNFIELD_VOP_SRC0,
458  GCNFIELD_VOP_VSRC1,
459  GCNFIELD_VOP_SSRC1,
460  GCNFIELD_VOP_VDST,
461  GCNFIELD_VOP_SDST,
462  GCNFIELD_VOP3_SRC0,
463  GCNFIELD_VOP3_SRC1,
464  GCNFIELD_VOP3_SRC2,
465  GCNFIELD_VOP3_VDST,
466  GCNFIELD_VOP3_SDST0,
467  GCNFIELD_VOP3_SSRC,
468  GCNFIELD_VOP3_SDST1,
469  GCNFIELD_VINTRP_VSRC0,
470  GCNFIELD_VINTRP_VDST,
471  GCNFIELD_DS_ADDR,
472  GCNFIELD_DS_DATA0,
473  GCNFIELD_DS_DATA1,
474  GCNFIELD_DS_VDST,
475  GCNFIELD_M_VADDR,
476  GCNFIELD_M_VDATA,
477  GCNFIELD_M_VDATAH,
478  GCNFIELD_M_VDATALAST,
479  GCNFIELD_M_SRSRC,
480  GCNFIELD_MIMG_SSAMP,
481  GCNFIELD_M_SOFFSET,
482  GCNFIELD_EXP_VSRC0,
483  GCNFIELD_EXP_VSRC1,
484  GCNFIELD_EXP_VSRC2,
485  GCNFIELD_EXP_VSRC3,
486  GCNFIELD_FLAT_ADDR,
487  GCNFIELD_FLAT_DATA,
488  GCNFIELD_FLAT_VDST,
489  GCNFIELD_FLAT_VDSTLAST,
490  GCNFIELD_DPPSDWA_SRC0,
491  GCNFIELD_DPPSDWA_SSRC0,
492  GCNFIELD_FLAT_SADDR
493 };
494 
495 struct AsmScope;
496 
498 struct AsmRegVar
499 {
501  uint16_t size;
502 };
503 
505 struct AsmSingleVReg // key for regvar
506 {
507  const AsmRegVar* regVar;
508  uint16_t index;
509 
511  bool operator==(const AsmSingleVReg& r2) const
512  { return regVar == r2.regVar && index == r2.index; }
514  bool operator!=(const AsmSingleVReg& r2) const
515  { return regVar == r2.regVar && index == r2.index; }
516 };
517 
519 typedef std::unordered_map<CString, AsmRegVar> AsmRegVarMap;
521 typedef AsmRegVarMap::value_type AsmRegVarEntry;
522 
523 enum : cxbyte {
530 };
531 
534 {
535  size_t offset;
536  const AsmRegVar* regVar;
537  uint16_t rstart;
538  uint16_t rend;
539  AsmRegField regField;
542  bool useRegMode;
543 };
544 
547 {
548  const AsmRegVar* regVar;
549  uint16_t rstart;
550  uint16_t rend;
551  AsmRegField regField;
554 };
555 
558 {
559  AsmRegField regField;
561 };
562 
565 {
566  uint16_t rstart;
567  uint16_t rend;
569 };
570 
573 {
574  JUMP = 0,
580 };
581 
584 {
585  size_t offset;
586  size_t target;
588 };
589 
591 typedef std::unordered_map<CString, RefPtr<const AsmMacro> > AsmMacroMap;
592 
593 struct AsmScope;
594 
596 typedef std::unordered_map<CString, AsmScope*> AsmScopeMap;
597 
599 struct AsmScope
600 {
602  AsmSymbolMap symbolMap;
603  AsmRegVarMap regVarMap;
604  AsmScopeMap scopeMap;
605  bool temporary;
606  std::list<AsmScope*> usedScopes;
607 
609  std::unordered_map<AsmScope*, std::list<AsmScope*>::iterator> usedScopesSet;
610 
612  AsmScope(AsmScope* _parent, const AsmSymbolMap& _symbolMap,
613  bool _temporary = false)
614  : parent(_parent), symbolMap(_symbolMap), temporary(_temporary)
615  { }
617  AsmScope(AsmScope* _parent = nullptr, bool _temporary= false)
618  : parent(_parent), temporary(_temporary)
619  { }
621  ~AsmScope();
622 
624  void startUsingScope(AsmScope* scope);
626  void stopUsingScope(AsmScope* scope);
629  {
630  usedScopes.clear();
631  usedScopesSet.clear();
632  }
634  void deleteSymbolsRecursively();
635 };
636 
637 class ISAUsageHandler;
638 
641 {
642  const char* name;
646  uint64_t alignment;
647  uint64_t size;
648  std::vector<cxbyte> content;
649 
650  std::unique_ptr<ISAUsageHandler> usageHandler;
651  std::vector<AsmCodeFlowEntry> codeFlow;
652 
654  AsmSection();
656  AsmSection(const char* _name, cxuint _kernelId, AsmSectionType _type,
657  Flags _flags, uint64_t _alignment, uint64_t _size = 0)
658  : name(_name), kernelId(_kernelId), type(_type), flags(_flags),
659  alignment(_alignment), size(_size)
660  { }
661 
663  AsmSection(const AsmSection& section);
665  AsmSection& operator=(const AsmSection& section);
666 
669  { codeFlow.push_back(entry); }
670 
672  size_t getSize() const
673  { return ((flags&ASMSECT_WRITEABLE) != 0) ? content.size() : size; }
674 };
675 
677 struct AsmKernel
678 {
679  const char* name;
681  std::vector<std::pair<size_t, size_t> > codeRegions;
682 
684  void openCodeRegion(size_t offset);
686  void closeCodeRegion(size_t offset);
687 };
688 
689 };
690 
691 namespace std
692 {
693 
695 template<>
696 struct hash<CLRX::AsmSingleVReg>
697 {
699  typedef std::size_t result_type;
700 
702  size_t operator()(const CLRX::AsmSingleVReg& r1) const
703  {
704  std::hash<const CLRX::AsmRegVar*> h1;
705  std::hash<uint16_t> h2;
706  return h1(r1.regVar) ^ (h2(r1.index)<<1);
707  }
708 };
709 
710 }
711 
712 #endif
AsmRegVarMap regVarMap
regvar map
Definition: AsmDefs.h:603
common definitions for assembler and disassembler
size_t target
target jump addreses
Definition: AsmDefs.h:586
main class of assembler
Definition: Assembler.h:401
AsmExprTargetType type
type of target
Definition: AsmDefs.h:212
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: AsmDefs.h:277
AsmSymbolEntry * symbol
symbol
Definition: AsmDefs.h:270
AsmSymbol(bool _onceDefined=false)
empty constructor
Definition: AsmDefs.h:170
kernel entry structure
Definition: AsmDefs.h:677
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:519
AsmExpression * expression
expression of symbol (if not resolved)
Definition: AsmDefs.h:162
bool operator==(const AsmExprSymbolOccurrence &b) const
comparison operator
Definition: AsmDefs.h:139
cxuint kernelId
kernel id (optional)
Definition: AsmDefs.h:643
none operation
AsmRegVarMap::value_type AsmRegVarEntry
regvar entry
Definition: AsmDefs.h:521
target is 32-bit word
Definition: AsmDefs.h:54
target is 64-bit word
Definition: AsmDefs.h:55
AsmSymbolEntry * symbol
symbol entry (if ASMXTGT_SYMBOL)
Definition: AsmDefs.h:215
target for assembler expression
Definition: AsmDefs.h:210
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:552
~AsmSymbol()
destructor
Definition: AsmDefs.h:417
size_t operator()(const CLRX::AsmSingleVReg &r1) const
a calling operator
Definition: AsmDefs.h:702
AsmExprOp
assembler expression operator
Definition: AsmDefs.h:80
assembler section
Definition: AsmDefs.h:640
AsmExprTarget()
empty constructor
Definition: AsmDefs.h:225
for internal usage
Definition: AsmDefs.h:529
size_t offset
offset in section
Definition: AsmDefs.h:535
code flow entry
Definition: AsmDefs.h:56
static AsmExprTarget symbolTarget(AsmSymbolEntry *entry)
make symbol target for expression
Definition: AsmDefs.h:233
assembler scope for symbol, macros, regvars
Definition: AsmDefs.h:599
Regvar info structure.
Definition: AsmDefs.h:498
cxbyte info
ELF symbol info.
Definition: AsmDefs.h:151
cxuint type
scalar/vector/other
Definition: AsmDefs.h:500
std::vector< AsmCodeFlowEntry > codeFlow
code flow info
Definition: AsmDefs.h:651
const AsmExprTarget & getTarget() const
get targer of expression
Definition: AsmDefs.h:384
uint16_t rstart
register start
Definition: AsmDefs.h:549
signed (arithmetic) shift right
void addCodeFlowEntry(const AsmCodeFlowEntry &entry)
add code flow entry to this section
Definition: AsmDefs.h:668
STL namespace.
static bool isUnaryOp(AsmExprOp op)
return true if is unary op
Definition: AsmDefs.h:378
uint16_t index
index of regvar array
Definition: AsmDefs.h:508
AsmSourcePos sourcePos
source position of definition
Definition: AsmDefs.h:680
size_t getSymOccursNum() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:387
std::list< AsmScope * > usedScopes
list of used scope in this scope
Definition: AsmDefs.h:606
assembler symbol occurrence in expression
Definition: AsmDefs.h:132
regvar usage (internal)
Definition: AsmDefs.h:546
std::unordered_map< CString, AsmScope * > AsmScopeMap
type definition of scope&#39;s map
Definition: AsmDefs.h:593
cxuint sectionId
section id
Definition: AsmDefs.h:150
void addOccurrenceInExpr(AsmExpression *expr, size_t argIndex, size_t opIndex)
adds occurrence in expression
Definition: AsmDefs.h:191
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:182
void stopUsingScopes()
remove all usings
Definition: AsmDefs.h:628
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:327
for internal usage
Definition: AsmDefs.h:528
std::unordered_map< AsmScope *, std::list< AsmScope * >::iterator > usedScopesSet
set of used scopes in this scope
Definition: AsmDefs.h:609
size_t cflowId
cflow index of destination
Definition: AsmDefs.h:220
return from procedure
Definition: AsmDefs.h:577
AsmScope * parent
parent scope
Definition: AsmDefs.h:601
line and column
Definition: AsmSource.h:44
bool isEmpty() const
return true if expression is empty
Definition: AsmDefs.h:320
std::unordered_map< CString, AsmSymbol > AsmSymbolMap
assembler symbol map
Definition: AsmDefs.h:205
AsmScope(AsmScope *_parent, const AsmSymbolMap &_symbolMap, bool _temporary=false)
constructor
Definition: AsmDefs.h:612
an assembler formats
cxuint sectionId
sectionId
Definition: AsmDefs.h:430
LineNo lineNo
line number of top-most source
Definition: AsmSource.h:156
size_t offset
offset of relocation
Definition: AsmDefs.h:267
AsmRegField regField
place in instruction
Definition: AsmDefs.h:551
absolute section id
Definition: AsmFormats.h:81
uint64_t value
value of symbol
Definition: AsmDefs.h:159
AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
constructor to create custom target
Definition: AsmDefs.h:228
single regvar id
Definition: AsmDefs.h:505
cxbyte rwFlags
1 - read, 2 - write, other flags
Definition: AsmDefs.h:560
uint16_t rend
register end
Definition: AsmDefs.h:550
assembler relocation
Definition: AsmDefs.h:264
logical shift irght
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:540
bool temporary
true if temporary
Definition: AsmDefs.h:605
size_t opIndex
operator index
Definition: AsmDefs.h:136
unsigned less or equal
const char * name
name of kernel
Definition: AsmDefs.h:679
AsmSectionType
assembler section type
Definition: AsmFormats.h:46
unsigned char cxbyte
unsigned byte
Definition: Config.h:213
cxbyte rwFlags
rw flags and others
Definition: AsmDefs.h:568
internal structure for regusage
Definition: AsmDefs.h:564
std::unordered_map< CString, RefPtr< const AsmMacro > > AsmMacroMap
assembler macro map
Definition: AsmDefs.h:591
greater or equal than
main namespace
Definition: AsmDefs.h:38
AsmSymbolEntry * symbol
if symbol
Definition: AsmDefs.h:426
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:434
const AsmRegVar * regVar
regvar
Definition: AsmDefs.h:507
uint16_t rstart
register start
Definition: AsmDefs.h:566
static bool isArg(AsmExprOp op)
return true if is argument op
Definition: AsmDefs.h:375
bool unrefSymOccursNum()
unreference symbol occurrences in expression (used internally)
Definition: AsmDefs.h:393
unsigned int cxuint
unsigned int
Definition: Config.h:221
bool operator!=(const AsmSingleVReg &r2) const
not equal operator
Definition: AsmDefs.h:514
internal structure for regusage
Definition: AsmDefs.h:557
static bool isBinaryOp(AsmExprOp op)
return true if is binary op
Definition: AsmDefs.h:381
code end
Definition: AsmDefs.h:579
target is byte
Definition: AsmDefs.h:52
uint64_t size
size of symbol
Definition: AsmDefs.h:160
size_t getSize() const
get section&#39;s size
Definition: AsmDefs.h:672
binary negation
AsmScope(AsmScope *_parent=nullptr, bool _temporary=false)
constructor
Definition: AsmDefs.h:617
cxbyte AsmExprTargetType
expression target type (one byte)
Definition: AsmDefs.h:47
AsmCodeFlowType type
type of code flow entry
Definition: AsmDefs.h:587
uint16_t rend
register end
Definition: AsmDefs.h:538
uint64_t size
section size
Definition: AsmDefs.h:647
std::vector< AsmExprSymbolOccurrence > occurrencesInExprs
Definition: AsmDefs.h:167
target is 16-bit word
Definition: AsmDefs.h:53
std::vector< cxbyte > content
content of section
Definition: AsmDefs.h:648
AsmSymbolMap::value_type AsmSymbolEntry
assembler symbol entry
Definition: AsmDefs.h:207
Flags flags
section flags
Definition: AsmDefs.h:645
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:548
target is symbol
Definition: AsmDefs.h:51
uint64_t value
value
Definition: AsmDefs.h:427
AsmRegField regField
place in instruction
Definition: AsmDefs.h:559
cxuint refCount
reference counter (for internal use only)
Definition: AsmDefs.h:149
uint16_t rend
register end
Definition: AsmDefs.h:567
size_t offset
offset of destination
Definition: AsmDefs.h:219
uint16_t size
in regs
Definition: AsmDefs.h:501
size_t offset
offset where is this entry
Definition: AsmDefs.h:585
size_t argIndex
argument index
Definition: AsmDefs.h:135
cxuint sectionId
section id where relocation is present
Definition: AsmDefs.h:266
cxuint sectionId
section id of destination
Definition: AsmDefs.h:217
utilities for other libraries and programs
const Array< AsmExprOp > & getOps() const
get operators list
Definition: AsmDefs.h:400
unsigned division
std::unique_ptr< ISAUsageHandler > usageHandler
usage handler
Definition: AsmDefs.h:650
AsmSection(const char *_name, cxuint _kernelId, AsmSectionType _type, Flags _flags, uint64_t _alignment, uint64_t _size=0)
constructor
Definition: AsmDefs.h:656
RelocType type
relocation type
Definition: AsmDefs.h:268
uint64_t alignment
section alignment
Definition: AsmDefs.h:646
static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
make n-bit word target for expression
Definition: AsmDefs.h:252
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:536
AsmSymbolMap symbolMap
symbol map
Definition: AsmDefs.h:602
AsmScopeMap scopeMap
scope map
Definition: AsmDefs.h:604
code start
Definition: AsmDefs.h:578
AsmSectionType type
type of section
Definition: AsmDefs.h:644
regvar usage in code
Definition: AsmDefs.h:533
uint16_t rstart
register start
Definition: AsmDefs.h:537
call of procedure
Definition: AsmDefs.h:576
AsmSymbol(AsmExpression *expr, bool _onceDefined=false, bool _base=false)
constructor with expression
Definition: AsmDefs.h:176
for internal usage (regtype)
Definition: AsmDefs.h:527
static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
make code flow target for expression
Definition: AsmDefs.h:241
register will be read
Definition: AsmDefs.h:524
cxbyte align
register alignment
Definition: AsmDefs.h:553
code flow entry
Definition: AsmDefs.h:583
cxbyte other
ELF symbol other.
Definition: AsmDefs.h:152
jump
Definition: AsmDefs.h:574
std::vector< std::pair< size_t, size_t > > codeRegions
code regions
Definition: AsmDefs.h:681
const char * name
section name
Definition: AsmDefs.h:642
an assembler sources handling
AsmCodeFlowType
code flow type
Definition: AsmDefs.h:572
cxuint relSectionId
section for which relocation is defined
Definition: AsmDefs.h:271
assembler symbol structure
Definition: AsmDefs.h:147
bool useRegMode
if RVU from useReg pseudo-ops
Definition: AsmDefs.h:542
bool isDefined() const
return true if symbol defined (have value or expression)
Definition: AsmDefs.h:200
register will be written
Definition: AsmDefs.h:525
cxbyte AsmRegField
type of register field
Definition: AsmDefs.h:445
const AsmExprArg * getArgs() const
get argument list
Definition: AsmDefs.h:403
ISA (register and regvar) Usage handler.
Definition: Assembler.h:62
unsigned less or equal
size_t hasRelativeSymOccurs() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:390
AsmRegField regField
place in instruction
Definition: AsmDefs.h:539
uint64_t addend
addend
Definition: AsmDefs.h:273
conditional jump
Definition: AsmDefs.h:575
AsmExpression * expression
target expression pointer
Definition: AsmDefs.h:134
bool evaluate(Assembler &assembler, uint64_t &value, cxuint &sectionId) const
try to evaluate expression
Definition: AsmDefs.h:337
assembler expression argument
Definition: AsmDefs.h:424
access mask
Definition: AsmDefs.h:526
cxbyte align
register alignment
Definition: AsmDefs.h:541
bool operator==(const AsmSingleVReg &r2) const
equal operator
Definition: AsmDefs.h:511
CLRX::AsmSingleVReg argument_type
argument type
Definition: AsmDefs.h:698
const AsmSourcePos & getSourcePos() const
get source position
Definition: AsmDefs.h:406
assembler source position
Definition: AsmSource.h:152
std::size_t result_type
result type
Definition: AsmDefs.h:699