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_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  uint64_t value;
171  uint64_t size;
172  union {
174  const AsmRegVar* regVar;
175  };
176 
178  std::vector<AsmExprSymbolOccurrence> occurrencesInExprs;
179 
181  explicit AsmSymbol(bool _onceDefined = false) :
182  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
183  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
184  regRange(false), value(0), size(0), expression(nullptr)
185  { }
187  explicit AsmSymbol(AsmExpression* expr, bool _onceDefined = false, bool _base = false) :
188  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
189  onceDefined(_onceDefined), resolving(false), base(_base),
190  snapshot(false), regRange(false), value(0), size(0), expression(expr)
191  { }
193  explicit AsmSymbol(cxuint _sectionId, uint64_t _value, bool _onceDefined = false) :
194  refCount(1), sectionId(_sectionId), info(0), other(0), hasValue(true),
195  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
196  regRange(false), value(_value), size(0), expression(nullptr)
197  { }
199  ~AsmSymbol();
200 
202  void addOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex)
203  { occurrencesInExprs.push_back({expr, argIndex, opIndex}); }
205  void removeOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex);
207  void clearOccurrencesInExpr();
209  void undefine();
211  bool isDefined() const
212  { return hasValue || expression!=nullptr; }
213 };
214 
216 typedef std::unordered_map<CString, AsmSymbol> AsmSymbolMap;
218 typedef AsmSymbolMap::value_type AsmSymbolEntry;
219 
222 {
223  AsmExprTargetType type;
224  union
225  {
226  AsmSymbolEntry* symbol;
227  struct {
229  union {
230  size_t offset;
231  size_t cflowId;
232  };
233  };
234  };
237 
239  AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
240  : type(_type), sectionId(_sectionId), offset(_offset)
241  { }
242 
244  static AsmExprTarget symbolTarget(AsmSymbolEntry* entry)
245  {
246  AsmExprTarget target;
247  target.type = ASMXTGT_SYMBOL;
248  target.symbol = entry;
249  return target;
250  }
252  static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
253  {
254  AsmExprTarget target;
255  target.type = ASMXTGT_CODEFLOW;
256  target.sectionId = sectionId;
257  target.cflowId = cflowIndex;
258  return target;
259  }
260 
262  template<typename T>
263  static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
264  {
265  AsmExprTarget target;
266  target.type = (sizeof(T)==1) ? ASMXTGT_DATA8 : (sizeof(T)==2) ? ASMXTGT_DATA16 :
267  (sizeof(T)==4) ? ASMXTGT_DATA32 : ASMXTGT_DATA64;
268  target.sectionId = sectionId;
269  target.offset = offset;
270  return target;
271  }
272 };
273 
276 {
278  size_t offset;
280  union {
281  AsmSymbolEntry* symbol;
283  };
284  uint64_t addend;
285 };
286 
289 {
290 private:
291  class TempSymbolSnapshotMap;
292 
293  AsmExprTarget target;
294  AsmSourcePos sourcePos;
295  size_t symOccursNum;
296  bool relativeSymOccurs;
297  bool baseExpr;
298  Array<AsmExprOp> ops;
299  std::unique_ptr<LineCol[]> messagePositions;
300  std::unique_ptr<AsmExprArg[]> args;
301 
302  AsmSourcePos getSourcePos(size_t msgPosIndex) const
303  {
304  AsmSourcePos pos = sourcePos;
305  pos.lineNo = messagePositions[msgPosIndex].lineNo;
306  pos.colNo = messagePositions[msgPosIndex].colNo;
307  return pos;
308  }
309 
310  static bool makeSymbolSnapshot(Assembler& assembler,
311  TempSymbolSnapshotMap* snapshotMap, const AsmSymbolEntry& symEntry,
312  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* topParentSourcePos);
313 
314  AsmExpression();
315  void setParams(size_t symOccursNum, bool relativeSymOccurs,
316  size_t _opsNum, const AsmExprOp* ops, size_t opPosNum, const LineCol* opPos,
317  size_t argsNum, const AsmExprArg* args, bool baseExpr = false);
318 public:
320  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
321  size_t opsNum, size_t opPosNum, size_t argsNum, bool baseExpr = false);
323  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
324  size_t opsNum, const AsmExprOp* ops, size_t opPosNum,
325  const LineCol* opPos, size_t argsNum, const AsmExprArg* args,
326  bool baseExpr = false);
328  ~AsmExpression();
329 
331  bool isEmpty() const
332  { return ops.empty(); }
333 
335  AsmExpression* createForSnapshot(const AsmSourcePos* exprSourcePos) const;
336 
338  void setTarget(AsmExprTarget _target)
339  { target = _target; }
340 
342 
348  bool evaluate(Assembler& assembler, uint64_t& value, cxuint& sectionId) const
349  { return evaluate(assembler, 0, ops.size(), value, sectionId); }
350 
352 
360  bool evaluate(Assembler& assembler, size_t opStart, size_t opEnd,
361  uint64_t& value, cxuint& sectionId) const;
362 
364 
371  static AsmExpression* parse(Assembler& assembler, size_t& linePos,
372  bool makeBase = false, bool dontResolveSymbolsLater = false);
373 
375 
382  static AsmExpression* parse(Assembler& assembler, const char*& linePtr,
383  bool makeBase = false, bool dontResolveSymbolsLater = false);
384 
386  static bool isArg(AsmExprOp op)
387  { return (AsmExprOp::FIRST_ARG <= op && op <= AsmExprOp::LAST_ARG); }
389  static bool isUnaryOp(AsmExprOp op)
390  { return (AsmExprOp::FIRST_UNARY <= op && op <= AsmExprOp::LAST_UNARY); }
392  static bool isBinaryOp(AsmExprOp op)
393  { return (AsmExprOp::FIRST_BINARY <= op && op <= AsmExprOp::LAST_BINARY); }
395  const AsmExprTarget& getTarget() const
396  { return target; }
398  size_t getSymOccursNum() const
399  { return symOccursNum; }
401  size_t hasRelativeSymOccurs() const
402  { return relativeSymOccurs; }
405  { return --symOccursNum!=0; }
406 
408  void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value,
409  cxuint sectionId = ASMSECT_ABS);
411  const Array<AsmExprOp>& getOps() const
412  { return ops; }
414  const AsmExprArg* getArgs() const
415  { return args.get(); }
417  const AsmSourcePos& getSourcePos() const
418  { return sourcePos; }
419 
421  size_t toTop(size_t opIndex) const;
422 
424  static bool makeSymbolSnapshot(Assembler& assembler, const AsmSymbolEntry& symEntry,
425  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* parentExprSourcePos);
426 };
427 
429 {
430  if (base) delete expression; // if symbol with base expresion
431  clearOccurrencesInExpr();
432 }
433 
436 {
437  AsmSymbolEntry* symbol;
438  uint64_t value;
439  struct {
440  uint64_t value;
442  } relValue;
443 };
444 
446  uint64_t value, cxuint sectionId)
447 {
448  ops[occurrence.opIndex] = AsmExprOp::ARG_VALUE;
449  args[occurrence.argIndex].relValue.value = value;
450  args[occurrence.argIndex].relValue.sectionId = sectionId;
451  if (sectionId != ASMSECT_ABS)
452  relativeSymOccurs = true;
453 }
454 
457 
458 enum : AsmRegField
459 {
460  ASMFIELD_NONE = 0,
461  GCNFIELD_SSRC0,
462  GCNFIELD_SSRC1,
463  GCNFIELD_SDST,
464  GCNFIELD_SMRD_SBASE,
465  GCNFIELD_SMRD_SDST,
466  GCNFIELD_SMRD_SDSTH,
467  GCNFIELD_SMRD_SOFFSET,
468  GCNFIELD_VOP_SRC0,
469  GCNFIELD_VOP_VSRC1,
470  GCNFIELD_VOP_SSRC1,
471  GCNFIELD_VOP_VDST,
472  GCNFIELD_VOP_SDST,
473  GCNFIELD_VOP3_SRC0,
474  GCNFIELD_VOP3_SRC1,
475  GCNFIELD_VOP3_SRC2,
476  GCNFIELD_VOP3_VDST,
477  GCNFIELD_VOP3_SDST0,
478  GCNFIELD_VOP3_SSRC,
479  GCNFIELD_VOP3_SDST1,
480  GCNFIELD_VINTRP_VSRC0,
481  GCNFIELD_VINTRP_VDST,
482  GCNFIELD_DS_ADDR,
483  GCNFIELD_DS_DATA0,
484  GCNFIELD_DS_DATA1,
485  GCNFIELD_DS_VDST,
486  GCNFIELD_M_VADDR,
487  GCNFIELD_M_VDATA,
488  GCNFIELD_M_VDATAH,
489  GCNFIELD_M_VDATALAST,
490  GCNFIELD_M_SRSRC,
491  GCNFIELD_MIMG_SSAMP,
492  GCNFIELD_M_SOFFSET,
493  GCNFIELD_EXP_VSRC0,
494  GCNFIELD_EXP_VSRC1,
495  GCNFIELD_EXP_VSRC2,
496  GCNFIELD_EXP_VSRC3,
497  GCNFIELD_FLAT_ADDR,
498  GCNFIELD_FLAT_DATA,
499  GCNFIELD_FLAT_VDST,
500  GCNFIELD_FLAT_VDSTLAST,
501  GCNFIELD_DPPSDWA_SRC0,
502  GCNFIELD_DPPSDWA_SSRC0,
503  GCNFIELD_FLAT_SADDR
504 };
505 
506 struct AsmScope;
507 
509 struct AsmRegVar
510 {
512  uint16_t size;
513 };
514 
516 struct AsmSingleVReg // key for regvar
517 {
518  const AsmRegVar* regVar;
519  uint16_t index;
520 
522  bool operator==(const AsmSingleVReg& r2) const
523  { return regVar == r2.regVar && index == r2.index; }
525  bool operator!=(const AsmSingleVReg& r2) const
526  { return regVar == r2.regVar && index == r2.index; }
527 };
528 
530 typedef std::unordered_map<CString, AsmRegVar> AsmRegVarMap;
532 typedef AsmRegVarMap::value_type AsmRegVarEntry;
533 
534 enum : cxbyte {
541 };
542 
545 {
546  size_t offset;
547  const AsmRegVar* regVar;
548  uint16_t rstart;
549  uint16_t rend;
550  AsmRegField regField;
553  bool useRegMode;
554 };
555 
558 {
559  const AsmRegVar* regVar;
560  uint16_t rstart;
561  uint16_t rend;
562  AsmRegField regField;
565 };
566 
569 {
570  AsmRegField regField;
572 };
573 
576 {
577  uint16_t rstart;
578  uint16_t rend;
580 };
581 
584 {
585  JUMP = 0,
591 };
592 
595 {
596  size_t offset;
597  size_t target;
599 };
600 
602 typedef std::unordered_map<CString, RefPtr<const AsmMacro> > AsmMacroMap;
603 
604 struct AsmScope;
605 
607 typedef std::unordered_map<CString, AsmScope*> AsmScopeMap;
608 
610 struct AsmScope
611 {
613  AsmSymbolMap symbolMap;
614  AsmRegVarMap regVarMap;
615  AsmScopeMap scopeMap;
616  bool temporary;
617  std::list<AsmScope*> usedScopes;
618 
620  std::unordered_map<AsmScope*, std::list<AsmScope*>::iterator> usedScopesSet;
621 
623  AsmScope(AsmScope* _parent, const AsmSymbolMap& _symbolMap,
624  bool _temporary = false)
625  : parent(_parent), symbolMap(_symbolMap), temporary(_temporary)
626  { }
628  AsmScope(AsmScope* _parent = nullptr, bool _temporary= false)
629  : parent(_parent), temporary(_temporary)
630  { }
632  ~AsmScope();
633 
635  void startUsingScope(AsmScope* scope);
637  void stopUsingScope(AsmScope* scope);
640  {
641  usedScopes.clear();
642  usedScopesSet.clear();
643  }
645  void deleteSymbolsRecursively();
646 };
647 
648 class ISAUsageHandler;
649 
652 {
653  const char* name;
657  uint64_t alignment;
658  uint64_t size;
659  std::vector<cxbyte> content;
660 
661  std::unique_ptr<ISAUsageHandler> usageHandler;
662  std::vector<AsmCodeFlowEntry> codeFlow;
663 
665  AsmSection();
667  AsmSection(const char* _name, cxuint _kernelId, AsmSectionType _type,
668  Flags _flags, uint64_t _alignment, uint64_t _size = 0)
669  : name(_name), kernelId(_kernelId), type(_type), flags(_flags),
670  alignment(_alignment), size(_size)
671  { }
672 
674  AsmSection(const AsmSection& section);
676  AsmSection& operator=(const AsmSection& section);
677 
680  { codeFlow.push_back(entry); }
681 
683  size_t getSize() const
684  { return ((flags&ASMSECT_WRITEABLE) != 0) ? content.size() : size; }
685 };
686 
688 struct AsmKernel
689 {
690  const char* name;
692  std::vector<std::pair<size_t, size_t> > codeRegions;
693 
695  void openCodeRegion(size_t offset);
697  void closeCodeRegion(size_t offset);
698 };
699 
700 };
701 
702 namespace std
703 {
704 
706 template<>
707 struct hash<CLRX::AsmSingleVReg>
708 {
710  typedef std::size_t result_type;
711 
713  size_t operator()(const CLRX::AsmSingleVReg& r1) const
714  {
715  std::hash<const CLRX::AsmRegVar*> h1;
716  std::hash<uint16_t> h2;
717  return h1(r1.regVar) ^ (h2(r1.index)<<1);
718  }
719 };
720 
721 }
722 
723 #endif
AsmRegVarMap regVarMap
regvar map
Definition: AsmDefs.h:614
common definitions for assembler and disassembler
size_t target
target jump addreses
Definition: AsmDefs.h:597
main class of assembler
Definition: Assembler.h:403
AsmExprTargetType type
type of target
Definition: AsmDefs.h:223
non copyable and non movable base structure (class)
Definition: Utilities.h:43
assembler expression class
Definition: AsmDefs.h:288
AsmSymbolEntry * symbol
symbol
Definition: AsmDefs.h:281
AsmSymbol(bool _onceDefined=false)
empty constructor
Definition: AsmDefs.h:181
kernel entry structure
Definition: AsmDefs.h:688
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:530
AsmExpression * expression
expression of symbol (if not resolved)
Definition: AsmDefs.h:173
bool operator==(const AsmExprSymbolOccurrence &b) const
comparison operator
Definition: AsmDefs.h:150
cxuint kernelId
kernel id (optional)
Definition: AsmDefs.h:654
none operation
AsmRegVarMap::value_type AsmRegVarEntry
regvar entry
Definition: AsmDefs.h:532
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:226
target for assembler expression
Definition: AsmDefs.h:221
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:563
~AsmSymbol()
destructor
Definition: AsmDefs.h:428
size_t operator()(const CLRX::AsmSingleVReg &r1) const
a calling operator
Definition: AsmDefs.h:713
AsmExprOp
assembler expression operator
Definition: AsmDefs.h:91
assembler section
Definition: AsmDefs.h:651
AsmExprTarget()
empty constructor
Definition: AsmDefs.h:236
for internal usage
Definition: AsmDefs.h:540
size_t offset
offset in section
Definition: AsmDefs.h:546
code flow entry
Definition: AsmDefs.h:68
static AsmExprTarget symbolTarget(AsmSymbolEntry *entry)
make symbol target for expression
Definition: AsmDefs.h:244
assembler scope for symbol, macros, regvars
Definition: AsmDefs.h:610
Regvar info structure.
Definition: AsmDefs.h:509
cxbyte info
ELF symbol info.
Definition: AsmDefs.h:162
cxuint type
scalar/vector/other
Definition: AsmDefs.h:511
std::vector< AsmCodeFlowEntry > codeFlow
code flow info
Definition: AsmDefs.h:662
const AsmExprTarget & getTarget() const
get targer of expression
Definition: AsmDefs.h:395
uint16_t rstart
register start
Definition: AsmDefs.h:560
signed (arithmetic) shift right
void addCodeFlowEntry(const AsmCodeFlowEntry &entry)
add code flow entry to this section
Definition: AsmDefs.h:679
STL namespace.
static bool isUnaryOp(AsmExprOp op)
return true if is unary op
Definition: AsmDefs.h:389
uint16_t index
index of regvar array
Definition: AsmDefs.h:519
AsmSourcePos sourcePos
source position of definition
Definition: AsmDefs.h:691
size_t getSymOccursNum() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:398
std::list< AsmScope * > usedScopes
list of used scope in this scope
Definition: AsmDefs.h:617
assembler symbol occurrence in expression
Definition: AsmDefs.h:143
regvar usage (internal)
Definition: AsmDefs.h:557
std::unordered_map< CString, AsmScope * > AsmScopeMap
type definition of scope&#39;s map
Definition: AsmDefs.h:604
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:202
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:193
void stopUsingScopes()
remove all usings
Definition: AsmDefs.h:639
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:338
for internal usage
Definition: AsmDefs.h:539
std::unordered_map< AsmScope *, std::list< AsmScope * >::iterator > usedScopesSet
set of used scopes in this scope
Definition: AsmDefs.h:620
size_t cflowId
cflow index of destination
Definition: AsmDefs.h:231
return from procedure
Definition: AsmDefs.h:588
AsmScope * parent
parent scope
Definition: AsmDefs.h:612
line and column
Definition: AsmSource.h:44
bool isEmpty() const
return true if expression is empty
Definition: AsmDefs.h:331
std::unordered_map< CString, AsmSymbol > AsmSymbolMap
assembler symbol map
Definition: AsmDefs.h:216
AsmScope(AsmScope *_parent, const AsmSymbolMap &_symbolMap, bool _temporary=false)
constructor
Definition: AsmDefs.h:623
an assembler formats
cxuint sectionId
sectionId
Definition: AsmDefs.h:441
LineNo lineNo
line number of top-most source
Definition: AsmSource.h:156
size_t offset
offset of relocation
Definition: AsmDefs.h:278
AsmRegField regField
place in instruction
Definition: AsmDefs.h:562
absolute section id
Definition: AsmFormats.h:81
uint64_t value
value of symbol
Definition: AsmDefs.h:170
AsmExprTarget(AsmExprTargetType _type, cxuint _sectionId, size_t _offset)
constructor to create custom target
Definition: AsmDefs.h:239
single regvar id
Definition: AsmDefs.h:516
cxbyte rwFlags
1 - read, 2 - write, other flags
Definition: AsmDefs.h:571
uint16_t rend
register end
Definition: AsmDefs.h:561
assembler relocation
Definition: AsmDefs.h:275
logical shift irght
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:551
bool temporary
true if temporary
Definition: AsmDefs.h:616
AsmException()=default
empty constructor
size_t opIndex
operator index
Definition: AsmDefs.h:147
unsigned less or equal
const char * name
name of kernel
Definition: AsmDefs.h:690
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:579
internal structure for regusage
Definition: AsmDefs.h:575
std::unordered_map< CString, RefPtr< const AsmMacro > > AsmMacroMap
assembler macro map
Definition: AsmDefs.h:602
greater or equal than
main namespace
Definition: AsmDefs.h:38
AsmSymbolEntry * symbol
if symbol
Definition: AsmDefs.h:437
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:445
const AsmRegVar * regVar
regvar
Definition: AsmDefs.h:518
uint16_t rstart
register start
Definition: AsmDefs.h:577
static bool isArg(AsmExprOp op)
return true if is argument op
Definition: AsmDefs.h:386
bool unrefSymOccursNum()
unreference symbol occurrences in expression (used internally)
Definition: AsmDefs.h:404
unsigned int cxuint
unsigned int
Definition: Config.h:223
bool operator!=(const AsmSingleVReg &r2) const
not equal operator
Definition: AsmDefs.h:525
internal structure for regusage
Definition: AsmDefs.h:568
static bool isBinaryOp(AsmExprOp op)
return true if is binary op
Definition: AsmDefs.h:392
code end
Definition: AsmDefs.h:590
target is byte
Definition: AsmDefs.h:64
uint64_t size
size of symbol
Definition: AsmDefs.h:171
size_t getSize() const
get section&#39;s size
Definition: AsmDefs.h:683
binary negation
AsmScope(AsmScope *_parent=nullptr, bool _temporary=false)
constructor
Definition: AsmDefs.h:628
cxbyte AsmExprTargetType
expression target type (one byte)
Definition: AsmDefs.h:59
AsmCodeFlowType type
type of code flow entry
Definition: AsmDefs.h:598
uint16_t rend
register end
Definition: AsmDefs.h:549
uint64_t size
section size
Definition: AsmDefs.h:658
std::vector< AsmExprSymbolOccurrence > occurrencesInExprs
Definition: AsmDefs.h:178
target is 16-bit word
Definition: AsmDefs.h:65
std::vector< cxbyte > content
content of section
Definition: AsmDefs.h:659
AsmSymbolMap::value_type AsmSymbolEntry
assembler symbol entry
Definition: AsmDefs.h:218
Flags flags
section flags
Definition: AsmDefs.h:656
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:559
target is symbol
Definition: AsmDefs.h:63
uint64_t value
value
Definition: AsmDefs.h:438
AsmRegField regField
place in instruction
Definition: AsmDefs.h:570
cxuint refCount
reference counter (for internal use only)
Definition: AsmDefs.h:160
uint16_t rend
register end
Definition: AsmDefs.h:578
size_t offset
offset of destination
Definition: AsmDefs.h:230
uint16_t size
in regs
Definition: AsmDefs.h:512
size_t offset
offset where is this entry
Definition: AsmDefs.h:596
size_t argIndex
argument index
Definition: AsmDefs.h:146
cxuint sectionId
section id where relocation is present
Definition: AsmDefs.h:277
cxuint sectionId
section id of destination
Definition: AsmDefs.h:228
utilities for other libraries and programs
const Array< AsmExprOp > & getOps() const
get operators list
Definition: AsmDefs.h:411
unsigned division
std::unique_ptr< ISAUsageHandler > usageHandler
usage handler
Definition: AsmDefs.h:661
AsmSection(const char *_name, cxuint _kernelId, AsmSectionType _type, Flags _flags, uint64_t _alignment, uint64_t _size=0)
constructor
Definition: AsmDefs.h:667
RelocType type
relocation type
Definition: AsmDefs.h:279
uint64_t alignment
section alignment
Definition: AsmDefs.h:657
static AsmExprTarget dataTarget(cxuint sectionId, size_t offset)
make n-bit word target for expression
Definition: AsmDefs.h:263
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:547
std::string message
message
Definition: Utilities.h:61
exception class
Definition: Utilities.h:58
AsmSymbolMap symbolMap
symbol map
Definition: AsmDefs.h:613
AsmScopeMap scopeMap
scope map
Definition: AsmDefs.h:615
code start
Definition: AsmDefs.h:589
AsmSectionType type
type of section
Definition: AsmDefs.h:655
regvar usage in code
Definition: AsmDefs.h:544
uint16_t rstart
register start
Definition: AsmDefs.h:548
call of procedure
Definition: AsmDefs.h:587
AsmSymbol(AsmExpression *expr, bool _onceDefined=false, bool _base=false)
constructor with expression
Definition: AsmDefs.h:187
for internal usage (regtype)
Definition: AsmDefs.h:538
static AsmExprTarget codeFlowTarget(cxuint sectionId, size_t cflowIndex)
make code flow target for expression
Definition: AsmDefs.h:252
register will be read
Definition: AsmDefs.h:535
cxbyte align
register alignment
Definition: AsmDefs.h:564
code flow entry
Definition: AsmDefs.h:594
cxbyte other
ELF symbol other.
Definition: AsmDefs.h:163
jump
Definition: AsmDefs.h:585
std::vector< std::pair< size_t, size_t > > codeRegions
code regions
Definition: AsmDefs.h:692
const char * name
section name
Definition: AsmDefs.h:653
an assembler sources handling
virtual ~AsmException() noexcept=default
destructor
AsmCodeFlowType
code flow type
Definition: AsmDefs.h:583
Assembler exception class.
Definition: AsmDefs.h:42
cxuint relSectionId
section for which relocation is defined
Definition: AsmDefs.h:282
assembler symbol structure
Definition: AsmDefs.h:158
bool useRegMode
if RVU from useReg pseudo-ops
Definition: AsmDefs.h:553
bool isDefined() const
return true if symbol defined (have value or expression)
Definition: AsmDefs.h:211
register will be written
Definition: AsmDefs.h:536
cxbyte AsmRegField
type of register field
Definition: AsmDefs.h:456
const AsmExprArg * getArgs() const
get argument list
Definition: AsmDefs.h:414
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:401
AsmRegField regField
place in instruction
Definition: AsmDefs.h:550
uint64_t addend
addend
Definition: AsmDefs.h:284
conditional jump
Definition: AsmDefs.h:586
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:348
assembler expression argument
Definition: AsmDefs.h:435
access mask
Definition: AsmDefs.h:537
cxbyte align
register alignment
Definition: AsmDefs.h:552
bool operator==(const AsmSingleVReg &r2) const
equal operator
Definition: AsmDefs.h:522
CLRX::AsmSingleVReg argument_type
argument type
Definition: AsmDefs.h:709
const AsmSourcePos & getSourcePos() const
get source position
Definition: AsmDefs.h:417
assembler source position
Definition: AsmSource.h:152
std::size_t result_type
result type
Definition: AsmDefs.h:710