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-2018 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_INSTOFFSET,
83  GCNTGT_INSTOFFSET_S
84 };
85 
86 /*
87  * assembler expressions
88  */
89 
91 enum class AsmExprOp : cxbyte
92 {
93  ARG_VALUE = 0,
94  ARG_SYMBOL = 1,
95  NEGATE = 2,
96  BIT_NOT,
97  LOGICAL_NOT,
98  PLUS,
99  ADDITION,
100  SUBTRACT,
101  MULTIPLY,
102  DIVISION,
104  MODULO,
105  SIGNED_MODULO,
106  BIT_AND,
107  BIT_OR, //< bitwise OR
108  BIT_XOR,
109  BIT_ORNOT,
110  SHIFT_LEFT,
111  SHIFT_RIGHT,
113  LOGICAL_AND,
114  LOGICAL_OR,
115  EQUAL,
116  NOT_EQUAL,
117  LESS,
118  LESS_EQ,
119  GREATER,
120  GREATER_EQ,
121  BELOW,
122  BELOW_EQ,
123  ABOVE,
124  ABOVE_EQ,
125  CHOICE,
126  CHOICE_START,
127  FIRST_ARG = ARG_VALUE,
128  LAST_ARG = ARG_SYMBOL,
129  FIRST_UNARY = NEGATE,
130  LAST_UNARY = PLUS,
133  NONE = 0xff
134 };
135 
136 struct AsmExprTarget;
137 
138 union AsmExprArg;
139 
140 class AsmExpression;
141 
144 {
146  size_t argIndex;
147  size_t opIndex;
148 
150  bool operator==(const AsmExprSymbolOccurrence& b) const
151  { return expression==b.expression && opIndex==b.opIndex && argIndex==b.argIndex; }
152 };
153 
154 struct AsmRegVar;
155 struct AsmScope;
156 
158 struct AsmSymbol
159 {
164  cxuint hasValue:1;
165  cxuint onceDefined:1;
166  cxuint resolving:1;
167  cxuint base:1;
168  cxuint snapshot:1;
169  cxuint regRange:1;
170  cxuint detached:1;
171  cxuint withUnevalExpr:1;
172  uint64_t value;
173  uint64_t size;
174  union {
176  const AsmRegVar* regVar;
177  };
178 
180  std::vector<AsmExprSymbolOccurrence> occurrencesInExprs;
181 
183  explicit AsmSymbol(bool _onceDefined = false) :
184  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
185  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
186  regRange(false), detached(false), withUnevalExpr(false),
187  value(0), size(0), expression(nullptr)
188  { }
190  explicit AsmSymbol(AsmExpression* expr, bool _onceDefined = false, bool _base = false) :
191  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
192  onceDefined(_onceDefined), resolving(false), base(_base),
193  snapshot(false), regRange(false), detached(false), withUnevalExpr(false),
194  value(0), size(0), expression(expr)
195  { }
197  explicit AsmSymbol(cxuint _sectionId, uint64_t _value, bool _onceDefined = false) :
198  refCount(1), sectionId(_sectionId), info(0), other(0), hasValue(true),
199  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
200  regRange(false), detached(false), withUnevalExpr(false),
201  value(_value), size(0), expression(nullptr)
202  { }
204  ~AsmSymbol();
205 
207  void addOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex)
208  { occurrencesInExprs.push_back({expr, argIndex, opIndex}); }
210  void removeOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex);
212  void clearOccurrencesInExpr();
214  void undefine();
216  bool isDefined() const
217  { return hasValue || expression!=nullptr; }
218 };
219 
221 typedef std::unordered_map<CString, AsmSymbol> AsmSymbolMap;
223 typedef AsmSymbolMap::value_type AsmSymbolEntry;
224 
227 {
228  AsmExprTargetType type;
229  union
230  {
231  AsmSymbolEntry* symbol;
232  struct {
234  union {
235  size_t offset;
236  size_t cflowId;
237  };
238  };
239  };
242 
244  AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
245  : type(_type), sectionId(_sectionId), offset(_offset)
246  { }
247 
249  static AsmExprTarget symbolTarget(AsmSymbolEntry* entry)
250  {
251  AsmExprTarget target;
252  target.type = ASMXTGT_SYMBOL;
253  target.symbol = entry;
254  return target;
255  }
257  static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
258  {
259  AsmExprTarget target;
260  target.type = ASMXTGT_CODEFLOW;
261  target.sectionId = sectionId;
262  target.cflowId = cflowIndex;
263  return target;
264  }
265 
267  template<typename T>
268  static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
269  {
270  AsmExprTarget target;
271  target.type = (sizeof(T)==1) ? ASMXTGT_DATA8 : (sizeof(T)==2) ? ASMXTGT_DATA16 :
272  (sizeof(T)==4) ? ASMXTGT_DATA32 : ASMXTGT_DATA64;
273  target.sectionId = sectionId;
274  target.offset = offset;
275  return target;
276  }
277 };
278 
281 {
283  size_t offset;
285  union {
286  AsmSymbolEntry* symbol;
288  };
289  uint64_t addend;
290 };
291 
293 enum class AsmTryStatus
294 {
295  FAILED = 0,
296  TRY_LATER,
297  SUCCESS
298 };
299 
302 {
303 private:
304  class TempSymbolSnapshotMap;
305 
306  AsmExprTarget target;
307  AsmSourcePos sourcePos;
308  size_t symOccursNum;
309  bool relativeSymOccurs;
310  bool baseExpr;
311  Array<AsmExprOp> ops;
312  std::unique_ptr<LineCol[]> messagePositions;
313  std::unique_ptr<AsmExprArg[]> args;
314 
315  AsmSourcePos getSourcePos(size_t msgPosIndex) const
316  {
317  AsmSourcePos pos = sourcePos;
318  pos.lineNo = messagePositions[msgPosIndex].lineNo;
319  pos.colNo = messagePositions[msgPosIndex].colNo;
320  return pos;
321  }
322 
323  static bool makeSymbolSnapshot(Assembler& assembler,
324  TempSymbolSnapshotMap* snapshotMap, const AsmSymbolEntry& symEntry,
325  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* topParentSourcePos);
326 
327  AsmExpression();
328  void setParams(size_t symOccursNum, bool relativeSymOccurs,
329  size_t _opsNum, const AsmExprOp* ops, size_t opPosNum, const LineCol* opPos,
330  size_t argsNum, const AsmExprArg* args, bool baseExpr = false);
331 public:
333  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
334  size_t opsNum, size_t opPosNum, size_t argsNum, bool baseExpr = false);
336  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
337  size_t opsNum, const AsmExprOp* ops, size_t opPosNum,
338  const LineCol* opPos, size_t argsNum, const AsmExprArg* args,
339  bool baseExpr = false);
341  ~AsmExpression();
342 
344  bool isEmpty() const
345  { return ops.empty(); }
346 
348  AsmExpression* createForSnapshot(const AsmSourcePos* exprSourcePos) const;
349 
351  void setTarget(AsmExprTarget _target)
352  { target = _target; }
353 
355 
364  AsmTryStatus tryEvaluate(Assembler& assembler, size_t opStart, size_t opEnd,
365  uint64_t& value, cxuint& sectionId, bool withSectionDiffs = false) const;
366 
368 
375  AsmTryStatus tryEvaluate(Assembler& assembler, uint64_t& value, cxuint& sectionId,
376  bool withSectionDiffs = false) const
377  { return tryEvaluate(assembler, 0, ops.size(), value, sectionId, withSectionDiffs); }
378 
380 
386  bool evaluate(Assembler& assembler, uint64_t& value, cxuint& sectionId) const
387  { return tryEvaluate(assembler, 0, ops.size(), value, sectionId) !=
389 
391 
399  bool evaluate(Assembler& assembler, size_t opStart, size_t opEnd,
400  uint64_t& value, cxuint& sectionId) const
401  { return tryEvaluate(assembler, opStart, opEnd, value, sectionId) !=
403 
405 
412  static AsmExpression* parse(Assembler& assembler, size_t& linePos,
413  bool makeBase = false, bool dontResolveSymbolsLater = false);
414 
416 
423  static AsmExpression* parse(Assembler& assembler, const char*& linePtr,
424  bool makeBase = false, bool dontResolveSymbolsLater = false);
425 
427  static bool isArg(AsmExprOp op)
428  { return (AsmExprOp::FIRST_ARG <= op && op <= AsmExprOp::LAST_ARG); }
430  static bool isUnaryOp(AsmExprOp op)
431  { return (AsmExprOp::FIRST_UNARY <= op && op <= AsmExprOp::LAST_UNARY); }
433  static bool isBinaryOp(AsmExprOp op)
434  { return (AsmExprOp::FIRST_BINARY <= op && op <= AsmExprOp::LAST_BINARY); }
436  const AsmExprTarget& getTarget() const
437  { return target; }
439  size_t getSymOccursNum() const
440  { return symOccursNum; }
442  size_t hasRelativeSymOccurs() const
443  { return relativeSymOccurs; }
446  { return --symOccursNum!=0; }
447 
449  void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value,
450  cxuint sectionId = ASMSECT_ABS);
452  void replaceOccurrenceSymbol(AsmExprSymbolOccurrence occurrence,
453  AsmSymbolEntry* newSymEntry);
455  const Array<AsmExprOp>& getOps() const
456  { return ops; }
458  const AsmExprArg* getArgs() const
459  { return args.get(); }
461  const AsmSourcePos& getSourcePos() const
462  { return sourcePos; }
463 
465  size_t toTop(size_t opIndex) const;
466 
468  AsmExpression* createExprToEvaluate(Assembler& assembler) const;
469 
471  static bool makeSymbolSnapshot(Assembler& assembler, const AsmSymbolEntry& symEntry,
472  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* parentExprSourcePos);
473 
475  static bool fastExprEvaluate(Assembler& assembler, const char*& linePtr,
476  uint64_t& value);
477  static bool fastExprEvaluate(Assembler& assembler, size_t& linePos,
478  uint64_t& value);
479 };
480 
482 {
483  if (base) delete expression; // if symbol with base expresion
484  clearOccurrencesInExpr();
485 }
486 
489 {
490  AsmSymbolEntry* symbol;
491  uint64_t value;
492  struct {
493  uint64_t value;
495  } relValue;
496 };
497 
499  uint64_t value, cxuint sectionId)
500 {
501  ops[occurrence.opIndex] = AsmExprOp::ARG_VALUE;
502  args[occurrence.argIndex].relValue.value = value;
503  args[occurrence.argIndex].relValue.sectionId = sectionId;
504  if (sectionId != ASMSECT_ABS)
505  relativeSymOccurs = true;
506 }
507 
509  AsmSymbolEntry* newSymEntry)
510 {
511  args[occurrence.argIndex].symbol = newSymEntry;
512 }
513 
516 
517 enum : AsmRegField
518 {
519  ASMFIELD_NONE = 0,
520  GCNFIELD_SSRC0,
521  GCNFIELD_SSRC1,
522  GCNFIELD_SDST,
523  GCNFIELD_SMRD_SBASE,
524  GCNFIELD_SMRD_SDST,
525  GCNFIELD_SMRD_SDSTH,
526  GCNFIELD_SMRD_SOFFSET,
527  GCNFIELD_VOP_SRC0,
528  GCNFIELD_VOP_VSRC1,
529  GCNFIELD_VOP_SSRC1,
530  GCNFIELD_VOP_VDST,
531  GCNFIELD_VOP_SDST,
532  GCNFIELD_VOP3_SRC0,
533  GCNFIELD_VOP3_SRC1,
534  GCNFIELD_VOP3_SRC2,
535  GCNFIELD_VOP3_VDST,
536  GCNFIELD_VOP3_SDST0,
537  GCNFIELD_VOP3_SSRC,
538  GCNFIELD_VOP3_SDST1,
539  GCNFIELD_VINTRP_VSRC0,
540  GCNFIELD_VINTRP_VDST,
541  GCNFIELD_DS_ADDR,
542  GCNFIELD_DS_DATA0,
543  GCNFIELD_DS_DATA1,
544  GCNFIELD_DS_VDST,
545  GCNFIELD_M_VADDR,
546  GCNFIELD_M_VDATA,
547  GCNFIELD_M_VDATAH,
548  GCNFIELD_M_VDATALAST,
549  GCNFIELD_M_SRSRC,
550  GCNFIELD_MIMG_SSAMP,
551  GCNFIELD_M_SOFFSET,
552  GCNFIELD_EXP_VSRC0,
553  GCNFIELD_EXP_VSRC1,
554  GCNFIELD_EXP_VSRC2,
555  GCNFIELD_EXP_VSRC3,
556  GCNFIELD_FLAT_ADDR,
557  GCNFIELD_FLAT_DATA,
558  GCNFIELD_FLAT_VDST,
559  GCNFIELD_FLAT_VDSTLAST,
560  GCNFIELD_DPPSDWA_SRC0,
561  GCNFIELD_DPPSDWA_SSRC0,
562  GCNFIELD_FLAT_SADDR,
563  GCNFIELD_SDWAB_SDST
564 };
565 
566 struct AsmScope;
567 
569 struct AsmRegVar
570 {
572  uint16_t size;
573 };
574 
576 struct AsmSingleVReg // key for regvar
577 {
578  const AsmRegVar* regVar;
579  uint16_t index;
580 
582  bool operator==(const AsmSingleVReg& r2) const
583  { return regVar == r2.regVar && index == r2.index; }
585  bool operator!=(const AsmSingleVReg& r2) const
586  { return regVar == r2.regVar && index == r2.index; }
587 };
588 
590 typedef std::unordered_map<CString, AsmRegVar> AsmRegVarMap;
592 typedef AsmRegVarMap::value_type AsmRegVarEntry;
593 
594 enum : cxbyte {
601 };
602 
605 {
606  size_t offset;
607  const AsmRegVar* regVar;
608  uint16_t rstart;
609  uint16_t rend;
610  AsmRegField regField;
613  bool useRegMode;
614 };
615 
618 {
619  const AsmRegVar* regVar;
620  uint16_t rstart;
621  uint16_t rend;
622  AsmRegField regField;
625 };
626 
629 {
630  AsmRegField regField;
632 };
633 
636 {
637  uint16_t rstart;
638  uint16_t rend;
640 };
641 
644 {
645  JUMP = 0,
651 };
652 
655 {
656  size_t offset;
657  size_t target;
659 };
660 
662 typedef std::unordered_map<CString, RefPtr<const AsmMacro> > AsmMacroMap;
663 
664 struct AsmScope;
665 
667 typedef std::unordered_map<CString, AsmScope*> AsmScopeMap;
668 
670 struct AsmScope
671 {
673  AsmSymbolMap symbolMap;
674  AsmRegVarMap regVarMap;
675  AsmScopeMap scopeMap;
676  bool temporary;
677  std::list<AsmScope*> usedScopes;
678 
680  std::unordered_map<AsmScope*, std::list<AsmScope*>::iterator> usedScopesSet;
681 
683  AsmScope(AsmScope* _parent, const AsmSymbolMap& _symbolMap,
684  bool _temporary = false)
685  : parent(_parent), symbolMap(_symbolMap), temporary(_temporary)
686  { }
688  AsmScope(AsmScope* _parent = nullptr, bool _temporary= false)
689  : parent(_parent), temporary(_temporary)
690  { }
692  ~AsmScope();
693 
695  void startUsingScope(AsmScope* scope);
697  void stopUsingScope(AsmScope* scope);
700  {
701  usedScopes.clear();
702  usedScopesSet.clear();
703  }
705  void deleteSymbolsRecursively();
706 };
707 
708 class ISAUsageHandler;
709 
712 {
713  const char* name;
717  uint64_t alignment;
718  uint64_t size;
720  uint64_t relAddress;
721  std::vector<cxbyte> content;
722 
723  std::unique_ptr<ISAUsageHandler> usageHandler;
724  std::vector<AsmCodeFlowEntry> codeFlow;
725 
727  AsmSection();
729  AsmSection(const char* _name, cxuint _kernelId, AsmSectionType _type, Flags _flags,
730  uint64_t _alignment, uint64_t _size = 0, cxuint _relSpace = UINT_MAX,
731  uint64_t _relAddress = UINT64_MAX)
732  : name(_name), kernelId(_kernelId), type(_type), flags(_flags),
733  alignment(_alignment), size(_size), relSpace(_relSpace),
734  relAddress(_relAddress)
735  { }
736 
738  AsmSection(const AsmSection& section);
740  AsmSection& operator=(const AsmSection& section);
741 
744  { codeFlow.push_back(entry); }
745 
747  size_t getSize() const
748  { return ((flags&ASMSECT_WRITEABLE) != 0) ? content.size() : size; }
749 };
750 
752 struct AsmKernel
753 {
754  const char* name;
756  std::vector<std::pair<size_t, size_t> > codeRegions;
757 
759  void openCodeRegion(size_t offset);
761  void closeCodeRegion(size_t offset);
762 };
763 
764 };
765 
766 namespace std
767 {
768 
770 template<>
771 struct hash<CLRX::AsmSingleVReg>
772 {
774  typedef std::size_t result_type;
775 
777  size_t operator()(const CLRX::AsmSingleVReg& r1) const
778  {
779  std::hash<const CLRX::AsmRegVar*> h1;
780  std::hash<uint16_t> h2;
781  return h1(r1.regVar) ^ (h2(r1.index)<<1);
782  }
783 };
784 
785 }
786 
787 #endif
AsmRegVarMap regVarMap
regvar map
Definition: AsmDefs.h:674
common definitions for assembler and disassembler
size_t target
target jump addreses
Definition: AsmDefs.h:657
main class of assembler
Definition: Assembler.h:404
AsmExprTargetType type
type of target
Definition: AsmDefs.h:228
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: AsmDefs.h:301
AsmSymbolEntry * symbol
symbol
Definition: AsmDefs.h:286
AsmSymbol(bool _onceDefined=false)
empty constructor
Definition: AsmDefs.h:183
kernel entry structure
Definition: AsmDefs.h:752
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:590
AsmExpression * expression
expression of symbol (if not resolved)
Definition: AsmDefs.h:175
bool operator==(const AsmExprSymbolOccurrence &b) const
comparison operator
Definition: AsmDefs.h:150
cxuint kernelId
kernel id (optional)
Definition: AsmDefs.h:714
none operation
AsmRegVarMap::value_type AsmRegVarEntry
regvar entry
Definition: AsmDefs.h:592
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:231
target for assembler expression
Definition: AsmDefs.h:226
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:623
~AsmSymbol()
destructor
Definition: AsmDefs.h:481
size_t operator()(const CLRX::AsmSingleVReg &r1) const
a calling operator
Definition: AsmDefs.h:777
AsmExprOp
assembler expression operator
Definition: AsmDefs.h:91
assembler section
Definition: AsmDefs.h:711
AsmExprTarget()
empty constructor
Definition: AsmDefs.h:241
for internal usage
Definition: AsmDefs.h:600
size_t offset
offset in section
Definition: AsmDefs.h:606
code flow entry
Definition: AsmDefs.h:68
static AsmExprTarget symbolTarget(AsmSymbolEntry *entry)
make symbol target for expression
Definition: AsmDefs.h:249
assembler scope for symbol, macros, regvars
Definition: AsmDefs.h:670
Regvar info structure.
Definition: AsmDefs.h:569
cxbyte info
ELF symbol info.
Definition: AsmDefs.h:162
cxuint type
scalar/vector/other
Definition: AsmDefs.h:571
std::vector< AsmCodeFlowEntry > codeFlow
code flow info
Definition: AsmDefs.h:724
const AsmExprTarget & getTarget() const
get targer of expression
Definition: AsmDefs.h:436
uint16_t rstart
register start
Definition: AsmDefs.h:620
signed (arithmetic) shift right
void addCodeFlowEntry(const AsmCodeFlowEntry &entry)
add code flow entry to this section
Definition: AsmDefs.h:743
STL namespace.
static bool isUnaryOp(AsmExprOp op)
return true if is unary op
Definition: AsmDefs.h:430
uint16_t index
index of regvar array
Definition: AsmDefs.h:579
AsmSourcePos sourcePos
source position of definition
Definition: AsmDefs.h:755
size_t getSymOccursNum() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:439
std::list< AsmScope * > usedScopes
list of used scope in this scope
Definition: AsmDefs.h:677
assembler symbol occurrence in expression
Definition: AsmDefs.h:143
regvar usage (internal)
Definition: AsmDefs.h:617
bool evaluate(Assembler &assembler, size_t opStart, size_t opEnd, uint64_t &value, cxuint &sectionId) const
try to evaluate expression
Definition: AsmDefs.h:399
std::unordered_map< CString, AsmScope * > AsmScopeMap
type definition of scope&#39;s map
Definition: AsmDefs.h:664
cxuint sectionId
section id
Definition: AsmDefs.h:161
void addOccurrenceInExpr(AsmExpression *expr, size_t argIndex, size_t opIndex)
adds occurrence in expression
Definition: AsmDefs.h:207
try later (after some)
ColNo colNo
column number
Definition: AsmSource.h:158
AsmSymbol(cxuint _sectionId, uint64_t _value, bool _onceDefined=false)
constructor with value and section id
Definition: AsmDefs.h:197
void stopUsingScopes()
remove all usings
Definition: AsmDefs.h:699
Configuration header.
cxuint RelocType
relocation type
Definition: Commons.h:33
less or equal than
AsmTryStatus
class of return value for a trying routines
Definition: AsmDefs.h:293
unsigned modulo
void setTarget(AsmExprTarget _target)
set target of expression
Definition: AsmDefs.h:351
for internal usage
Definition: AsmDefs.h:599
std::unordered_map< AsmScope *, std::list< AsmScope * >::iterator > usedScopesSet
set of used scopes in this scope
Definition: AsmDefs.h:680
size_t cflowId
cflow index of destination
Definition: AsmDefs.h:236
return from procedure
Definition: AsmDefs.h:648
AsmScope * parent
parent scope
Definition: AsmDefs.h:672
line and column
Definition: AsmSource.h:45
bool isEmpty() const
return true if expression is empty
Definition: AsmDefs.h:344
std::unordered_map< CString, AsmSymbol > AsmSymbolMap
assembler symbol map
Definition: AsmDefs.h:221
AsmScope(AsmScope *_parent, const AsmSymbolMap &_symbolMap, bool _temporary=false)
constructor
Definition: AsmDefs.h:683
an assembler formats
cxuint sectionId
sectionId
Definition: AsmDefs.h:494
LineNo lineNo
line number of top-most source
Definition: AsmSource.h:157
size_t offset
offset of relocation
Definition: AsmDefs.h:283
AsmRegField regField
place in instruction
Definition: AsmDefs.h:622
absolute section id
Definition: AsmFormats.h:85
uint64_t value
value of symbol
Definition: AsmDefs.h:172
AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
constructor to create custom target
Definition: AsmDefs.h:244
single regvar id
Definition: AsmDefs.h:576
cxbyte rwFlags
1 - read, 2 - write, other flags
Definition: AsmDefs.h:631
uint16_t rend
register end
Definition: AsmDefs.h:621
assembler relocation
Definition: AsmDefs.h:280
logical shift irght
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:611
bool temporary
true if temporary
Definition: AsmDefs.h:676
AsmException()=default
empty constructor
void replaceOccurrenceSymbol(AsmExprSymbolOccurrence occurrence, AsmSymbolEntry *newSymEntry)
replace symbol in expression
Definition: AsmDefs.h:508
size_t opIndex
operator index
Definition: AsmDefs.h:147
if failed now, no later trial
unsigned less or equal
const char * name
name of kernel
Definition: AsmDefs.h:754
AsmSectionType
assembler section type
Definition: AsmFormats.h:47
unsigned char cxbyte
unsigned byte
Definition: Config.h:215
cxbyte rwFlags
rw flags and others
Definition: AsmDefs.h:639
internal structure for regusage
Definition: AsmDefs.h:635
std::unordered_map< CString, RefPtr< const AsmMacro > > AsmMacroMap
assembler macro map
Definition: AsmDefs.h:662
greater or equal than
main namespace
Definition: AsmDefs.h:38
AsmSymbolEntry * symbol
if symbol
Definition: AsmDefs.h:490
symbol without defined value
void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value, cxuint sectionId=ASMSECT_ABS)
substitute occurrence in expression by value
Definition: AsmDefs.h:498
const AsmRegVar * regVar
regvar
Definition: AsmDefs.h:578
uint16_t rstart
register start
Definition: AsmDefs.h:637
static bool isArg(AsmExprOp op)
return true if is argument op
Definition: AsmDefs.h:427
bool unrefSymOccursNum()
unreference symbol occurrences in expression (used internally)
Definition: AsmDefs.h:445
unsigned int cxuint
unsigned int
Definition: Config.h:223
bool operator!=(const AsmSingleVReg &r2) const
not equal operator
Definition: AsmDefs.h:585
internal structure for regusage
Definition: AsmDefs.h:628
static bool isBinaryOp(AsmExprOp op)
return true if is binary op
Definition: AsmDefs.h:433
code end
Definition: AsmDefs.h:650
target is byte
Definition: AsmDefs.h:64
uint64_t size
size of symbol
Definition: AsmDefs.h:173
size_t getSize() const
get section&#39;s size
Definition: AsmDefs.h:747
cxuint relSpace
relative space where is section
Definition: AsmDefs.h:719
binary negation
AsmScope(AsmScope *_parent=nullptr, bool _temporary=false)
constructor
Definition: AsmDefs.h:688
uint64_t relAddress
relative address
Definition: AsmDefs.h:720
cxbyte AsmExprTargetType
expression target type (one byte)
Definition: AsmDefs.h:59
AsmCodeFlowType type
type of code flow entry
Definition: AsmDefs.h:658
uint16_t rend
register end
Definition: AsmDefs.h:609
uint64_t size
section size
Definition: AsmDefs.h:718
std::vector< AsmExprSymbolOccurrence > occurrencesInExprs
Definition: AsmDefs.h:180
target is 16-bit word
Definition: AsmDefs.h:65
std::vector< cxbyte > content
content of section
Definition: AsmDefs.h:721
AsmSymbolMap::value_type AsmSymbolEntry
assembler symbol entry
Definition: AsmDefs.h:223
Flags flags
section flags
Definition: AsmDefs.h:716
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:619
target is symbol
Definition: AsmDefs.h:63
uint64_t value
value
Definition: AsmDefs.h:491
AsmRegField regField
place in instruction
Definition: AsmDefs.h:630
cxuint refCount
reference counter (for internal use only)
Definition: AsmDefs.h:160
uint16_t rend
register end
Definition: AsmDefs.h:638
size_t offset
offset of destination
Definition: AsmDefs.h:235
uint16_t size
in regs
Definition: AsmDefs.h:572
size_t offset
offset where is this entry
Definition: AsmDefs.h:656
size_t argIndex
argument index
Definition: AsmDefs.h:146
cxuint sectionId
section id where relocation is present
Definition: AsmDefs.h:282
cxuint sectionId
section id of destination
Definition: AsmDefs.h:233
utilities for other libraries and programs
const Array< AsmExprOp > & getOps() const
get operators list
Definition: AsmDefs.h:455
unsigned division
std::unique_ptr< ISAUsageHandler > usageHandler
usage handler
Definition: AsmDefs.h:723
RelocType type
relocation type
Definition: AsmDefs.h:284
uint64_t alignment
section alignment
Definition: AsmDefs.h:717
static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
make n-bit word target for expression
Definition: AsmDefs.h:268
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:607
std::string message
message
Definition: Utilities.h:61
AsmTryStatus tryEvaluate(Assembler &assembler, uint64_t &value, cxuint &sectionId, bool withSectionDiffs=false) const
try to evaluate expression with/without section differences
Definition: AsmDefs.h:375
exception class
Definition: Utilities.h:58
AsmSymbolMap symbolMap
symbol map
Definition: AsmDefs.h:673
AsmScopeMap scopeMap
scope map
Definition: AsmDefs.h:675
code start
Definition: AsmDefs.h:649
AsmSectionType type
type of section
Definition: AsmDefs.h:715
regvar usage in code
Definition: AsmDefs.h:604
uint16_t rstart
register start
Definition: AsmDefs.h:608
call of procedure
Definition: AsmDefs.h:647
AsmSymbol(AsmExpression *expr, bool _onceDefined=false, bool _base=false)
constructor with expression
Definition: AsmDefs.h:190
for internal usage (regtype)
Definition: AsmDefs.h:598
static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
make code flow target for expression
Definition: AsmDefs.h:257
register will be read
Definition: AsmDefs.h:595
cxbyte align
register alignment
Definition: AsmDefs.h:624
code flow entry
Definition: AsmDefs.h:654
cxbyte other
ELF symbol other.
Definition: AsmDefs.h:163
jump
Definition: AsmDefs.h:645
std::vector< std::pair< size_t, size_t > > codeRegions
code regions
Definition: AsmDefs.h:756
const char * name
section name
Definition: AsmDefs.h:713
an assembler sources handling
virtual ~AsmException() noexcept=default
destructor
AsmCodeFlowType
code flow type
Definition: AsmDefs.h:643
Assembler exception class.
Definition: AsmDefs.h:42
cxuint relSectionId
section for which relocation is defined
Definition: AsmDefs.h:287
assembler symbol structure
Definition: AsmDefs.h:158
bool useRegMode
if RVU from useReg pseudo-ops
Definition: AsmDefs.h:613
bool isDefined() const
return true if symbol defined (have value or expression)
Definition: AsmDefs.h:216
register will be written
Definition: AsmDefs.h:596
cxbyte AsmRegField
type of register field
Definition: AsmDefs.h:515
const AsmExprArg * getArgs() const
get argument list
Definition: AsmDefs.h:458
ISA (register and regvar) Usage handler.
Definition: Assembler.h:65
unsigned less or equal
size_t hasRelativeSymOccurs() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:442
AsmRegField regField
place in instruction
Definition: AsmDefs.h:610
AsmSection(const char *_name, cxuint _kernelId, AsmSectionType _type, Flags _flags, uint64_t _alignment, uint64_t _size=0, cxuint _relSpace=UINT_MAX, uint64_t _relAddress=UINT64_MAX)
constructor
Definition: AsmDefs.h:729
uint64_t addend
addend
Definition: AsmDefs.h:289
succeed, no trial needed
conditional jump
Definition: AsmDefs.h:646
AsmExpression * expression
target expression pointer
Definition: AsmDefs.h:145
bool evaluate(Assembler &assembler, uint64_t &value, cxuint &sectionId) const
try to evaluate expression
Definition: AsmDefs.h:386
assembler expression argument
Definition: AsmDefs.h:488
access mask
Definition: AsmDefs.h:597
cxbyte align
register alignment
Definition: AsmDefs.h:612
bool operator==(const AsmSingleVReg &r2) const
equal operator
Definition: AsmDefs.h:582
CLRX::AsmSingleVReg argument_type
argument type
Definition: AsmDefs.h:773
const AsmSourcePos & getSourcePos() const
get source position
Definition: AsmDefs.h:461
assembler source position
Definition: AsmSource.h:153
std::size_t result_type
result type
Definition: AsmDefs.h:774