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 
71 /*
72  * assembler expressions
73  */
74 
76 enum class AsmExprOp : cxbyte
77 {
78  ARG_VALUE = 0,
79  ARG_SYMBOL = 1,
80  NEGATE = 2,
81  BIT_NOT,
82  LOGICAL_NOT,
83  PLUS,
84  ADDITION,
85  SUBTRACT,
86  MULTIPLY,
87  DIVISION,
89  MODULO,
91  BIT_AND,
92  BIT_OR, //< bitwise OR
93  BIT_XOR,
94  BIT_ORNOT,
95  SHIFT_LEFT,
96  SHIFT_RIGHT,
98  LOGICAL_AND,
99  LOGICAL_OR,
100  EQUAL,
101  NOT_EQUAL,
102  LESS,
103  LESS_EQ,
104  GREATER,
105  GREATER_EQ,
106  BELOW,
107  BELOW_EQ,
108  ABOVE,
109  ABOVE_EQ,
110  CHOICE,
111  CHOICE_START,
112  FIRST_ARG = ARG_VALUE,
113  LAST_ARG = ARG_SYMBOL,
114  FIRST_UNARY = NEGATE,
115  LAST_UNARY = PLUS,
118  NONE = 0xff
119 };
120 
121 struct AsmExprTarget;
122 
123 union AsmExprArg;
124 
125 class AsmExpression;
126 
129 {
131  size_t argIndex;
132  size_t opIndex;
133 
135  bool operator==(const AsmExprSymbolOccurrence& b) const
136  { return expression==b.expression && opIndex==b.opIndex && argIndex==b.argIndex; }
137 };
138 
139 struct AsmRegVar;
140 struct AsmScope;
141 
143 struct AsmSymbol
144 {
149  cxuint hasValue:1;
150  cxuint onceDefined:1;
151  cxuint resolving:1;
152  cxuint base:1;
153  cxuint snapshot:1;
154  cxuint regRange:1;
155  cxuint detached:1;
156  cxuint withUnevalExpr:1;
157  uint64_t value;
158  uint64_t size;
159  union {
161  const AsmRegVar* regVar;
162  };
163 
165  std::vector<AsmExprSymbolOccurrence> occurrencesInExprs;
166 
168  explicit AsmSymbol(bool _onceDefined = false) :
169  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
170  onceDefined(_onceDefined), resolving(false), base(false), snapshot(false),
171  regRange(false), detached(false), withUnevalExpr(false),
172  value(0), size(0), expression(nullptr)
173  { }
175  explicit AsmSymbol(AsmExpression* expr, bool _onceDefined = false, bool _base = false) :
176  refCount(1), sectionId(ASMSECT_ABS), info(0), other(0), hasValue(false),
177  onceDefined(_onceDefined), resolving(false), base(_base),
178  snapshot(false), regRange(false), detached(false), withUnevalExpr(false),
179  value(0), size(0), expression(expr)
180  { }
182  explicit AsmSymbol(AsmSectionId _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), detached(false), withUnevalExpr(false),
186  value(_value), size(0), expression(nullptr)
187  { }
189  ~AsmSymbol();
190 
192  void addOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex)
193  { occurrencesInExprs.push_back({expr, argIndex, opIndex}); }
195  void removeOccurrenceInExpr(AsmExpression* expr, size_t argIndex, size_t opIndex);
197  void clearOccurrencesInExpr();
199  void undefine();
201  bool isDefined() const
202  { return hasValue || expression!=nullptr; }
203 };
204 
206 typedef std::unordered_map<CString, AsmSymbol> AsmSymbolMap;
208 typedef AsmSymbolMap::value_type AsmSymbolEntry;
209 
212 {
213  AsmExprTargetType type;
214  union
215  {
216  AsmSymbolEntry* symbol;
217  struct {
219  union {
220  size_t offset;
221  size_t cflowId;
222  };
223  };
224  };
227 
229  AsmExprTarget(AsmExprTargetType _type, AsmSectionId _sectionId, size_t _offset)
230  : type(_type), sectionId(_sectionId), offset(_offset)
231  { }
232 
234  static AsmExprTarget symbolTarget(AsmSymbolEntry* entry)
235  {
236  AsmExprTarget target;
237  target.type = ASMXTGT_SYMBOL;
238  target.symbol = entry;
239  return target;
240  }
242  static AsmExprTarget codeFlowTarget(AsmSectionId sectionId, size_t cflowIndex)
243  {
244  AsmExprTarget target;
245  target.type = ASMXTGT_CODEFLOW;
246  target.sectionId = sectionId;
247  target.cflowId = cflowIndex;
248  return target;
249  }
250 
252  template<typename T>
253  static AsmExprTarget dataTarget(AsmSectionId sectionId, size_t offset)
254  {
255  AsmExprTarget target;
256  target.type = (sizeof(T)==1) ? ASMXTGT_DATA8 : (sizeof(T)==2) ? ASMXTGT_DATA16 :
257  (sizeof(T)==4) ? ASMXTGT_DATA32 : ASMXTGT_DATA64;
258  target.sectionId = sectionId;
259  target.offset = offset;
260  return target;
261  }
262 };
263 
266 {
268  size_t offset;
270  union {
271  AsmSymbolEntry* symbol;
273  };
274  uint64_t addend;
275 };
276 
278 enum class AsmTryStatus
279 {
280  FAILED = 0,
281  TRY_LATER,
282  SUCCESS
283 };
284 
287 {
288 private:
289  class TempSymbolSnapshotMap;
290 
291  AsmExprTarget target;
292  AsmSourcePos sourcePos;
293  size_t symOccursNum;
294  bool relativeSymOccurs;
295  bool baseExpr;
296  Array<AsmExprOp> ops;
297  std::unique_ptr<LineCol[]> messagePositions;
298  std::unique_ptr<AsmExprArg[]> args;
299 
300  AsmSourcePos getSourcePos(size_t msgPosIndex) const
301  {
302  AsmSourcePos pos = sourcePos;
303  pos.lineNo = messagePositions[msgPosIndex].lineNo;
304  pos.colNo = messagePositions[msgPosIndex].colNo;
305  return pos;
306  }
307 
308  static bool makeSymbolSnapshot(Assembler& assembler,
309  TempSymbolSnapshotMap* snapshotMap, const AsmSymbolEntry& symEntry,
310  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* topParentSourcePos);
311 
312  AsmExpression();
313  void setParams(size_t symOccursNum, bool relativeSymOccurs,
314  size_t _opsNum, const AsmExprOp* ops, size_t opPosNum, const LineCol* opPos,
315  size_t argsNum, const AsmExprArg* args, bool baseExpr = false);
316 public:
318  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
319  size_t opsNum, size_t opPosNum, size_t argsNum, bool baseExpr = false);
321  AsmExpression(const AsmSourcePos& pos, size_t symOccursNum, bool relativeSymOccurs,
322  size_t opsNum, const AsmExprOp* ops, size_t opPosNum,
323  const LineCol* opPos, size_t argsNum, const AsmExprArg* args,
324  bool baseExpr = false);
326  ~AsmExpression();
327 
329  bool isEmpty() const
330  { return ops.empty(); }
331 
333  AsmExpression* createForSnapshot(const AsmSourcePos* exprSourcePos) const;
334 
336  void setTarget(AsmExprTarget _target)
337  { target = _target; }
338 
340 
349  AsmTryStatus tryEvaluate(Assembler& assembler, size_t opStart, size_t opEnd,
350  uint64_t& value, AsmSectionId& sectionId, bool withSectionDiffs = false) const;
351 
353 
360  AsmTryStatus tryEvaluate(Assembler& assembler, uint64_t& value, AsmSectionId& sectionId,
361  bool withSectionDiffs = false) const
362  { return tryEvaluate(assembler, 0, ops.size(), value, sectionId, withSectionDiffs); }
363 
365 
371  bool evaluate(Assembler& assembler, uint64_t& value, AsmSectionId& sectionId) const
372  { return tryEvaluate(assembler, 0, ops.size(), value, sectionId) !=
374 
376 
384  bool evaluate(Assembler& assembler, size_t opStart, size_t opEnd,
385  uint64_t& value, AsmSectionId& sectionId) const
386  { return tryEvaluate(assembler, opStart, opEnd, value, sectionId) !=
388 
390 
397  static AsmExpression* parse(Assembler& assembler, size_t& linePos,
398  bool makeBase = false, bool dontResolveSymbolsLater = false);
399 
401 
408  static AsmExpression* parse(Assembler& assembler, const char*& linePtr,
409  bool makeBase = false, bool dontResolveSymbolsLater = false);
410 
412  static bool isArg(AsmExprOp op)
413  { return (AsmExprOp::FIRST_ARG <= op && op <= AsmExprOp::LAST_ARG); }
415  static bool isUnaryOp(AsmExprOp op)
416  { return (AsmExprOp::FIRST_UNARY <= op && op <= AsmExprOp::LAST_UNARY); }
418  static bool isBinaryOp(AsmExprOp op)
419  { return (AsmExprOp::FIRST_BINARY <= op && op <= AsmExprOp::LAST_BINARY); }
421  const AsmExprTarget& getTarget() const
422  { return target; }
424  size_t getSymOccursNum() const
425  { return symOccursNum; }
427  size_t hasRelativeSymOccurs() const
428  { return relativeSymOccurs; }
431  { return --symOccursNum!=0; }
432 
434  void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value,
435  AsmSectionId sectionId = ASMSECT_ABS);
437  void replaceOccurrenceSymbol(AsmExprSymbolOccurrence occurrence,
438  AsmSymbolEntry* newSymEntry);
440  const Array<AsmExprOp>& getOps() const
441  { return ops; }
443  const AsmExprArg* getArgs() const
444  { return args.get(); }
446  const AsmSourcePos& getSourcePos() const
447  { return sourcePos; }
448 
450  size_t toTop(size_t opIndex) const;
451 
453  AsmExpression* createExprToEvaluate(Assembler& assembler) const;
454 
456  static bool makeSymbolSnapshot(Assembler& assembler, const AsmSymbolEntry& symEntry,
457  AsmSymbolEntry*& outSymEntry, const AsmSourcePos* parentExprSourcePos);
458 
460  static bool fastExprEvaluate(Assembler& assembler, const char*& linePtr,
461  uint64_t& value);
462  static bool fastExprEvaluate(Assembler& assembler, size_t& linePos,
463  uint64_t& value);
464 };
465 
467 {
468  if (base) delete expression; // if symbol with base expresion
469  clearOccurrencesInExpr();
470 }
471 
474 {
475  AsmSymbolEntry* symbol;
476  uint64_t value;
477  struct {
478  uint64_t value;
480  } relValue;
481 };
482 
484  uint64_t value, AsmSectionId sectionId)
485 {
486  ops[occurrence.opIndex] = AsmExprOp::ARG_VALUE;
487  args[occurrence.argIndex].relValue.value = value;
488  args[occurrence.argIndex].relValue.sectionId = sectionId;
489  if (sectionId != ASMSECT_ABS)
490  relativeSymOccurs = true;
491 }
492 
494  AsmSymbolEntry* newSymEntry)
495 {
496  args[occurrence.argIndex].symbol = newSymEntry;
497 }
498 
501 
502 enum : AsmRegField
503 {
504  ASMFIELD_NONE = 0
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 
530  bool operator<(const AsmSingleVReg& r2) const
531  { return regVar < r2.regVar || (regVar == r2.regVar && index < r2.index); }
532 };
533 
535 typedef std::unordered_map<CString, AsmRegVar> AsmRegVarMap;
537 typedef AsmRegVarMap::value_type AsmRegVarEntry;
538 
539 enum : cxbyte {
546 };
547 
550 {
551  size_t offset;
552  const AsmRegVar* regVar;
553  uint16_t rstart;
554  uint16_t rend;
555  AsmRegField regField;
558  bool useRegMode;
559 };
560 
563 {
564  size_t offset;
565  const AsmRegVar* regVar;
566  uint16_t rstart;
567  uint16_t rend;
568 };
569 
570 enum {
571  ASM_DELAYED_OP_MAX_TYPES_NUM = 8,
572  ASM_WAIT_MAX_TYPES_NUM = 4
573 };
574 
577 {
578  cxbyte waitType;
579  bool ordered;
583 };
584 
587 {
588  cxuint delayedOpTypesNum;
589  cxuint waitQueuesNum;
590  AsmDelayedOpTypeEntry delayOpTypes[ASM_DELAYED_OP_MAX_TYPES_NUM];
591  uint16_t waitQueueSizes[ASM_WAIT_MAX_TYPES_NUM];
592 };
593 
594 enum : cxbyte
595 {
596  ASMDELOP_NONE = 255
597 };
598 
601 {
602  size_t offset;
603  const AsmRegVar* regVar;
604  uint16_t rstart;
605  uint16_t rend;
606  cxbyte count;
607  cxbyte delayedOpType;
608  cxbyte delayedOpType2;
609  cxbyte rwFlags:2;
610  cxbyte rwFlags2:2;
611 };
612 
615 {
616  size_t offset;
617  uint16_t waits[ASM_WAIT_MAX_TYPES_NUM];
618 };
619 
622 {
623  JUMP = 0,
629 };
630 
633 {
634  size_t offset;
635  size_t target;
637 };
638 
640 typedef std::unordered_map<CString, RefPtr<const AsmMacro> > AsmMacroMap;
641 
642 struct AsmScope;
643 
645 typedef std::unordered_map<CString, AsmScope*> AsmScopeMap;
646 
648 struct AsmScope
649 {
651  AsmSymbolMap symbolMap;
652  AsmRegVarMap regVarMap;
653  AsmScopeMap scopeMap;
654  bool temporary;
655  std::list<AsmScope*> usedScopes;
656  uint64_t enumCount;
657 
659  std::unordered_map<AsmScope*, std::list<AsmScope*>::iterator> usedScopesSet;
660 
662  AsmScope(AsmScope* _parent, const AsmSymbolMap& _symbolMap,
663  bool _temporary = false)
664  : parent(_parent), symbolMap(_symbolMap), temporary(_temporary), enumCount(0)
665  { }
667  AsmScope(AsmScope* _parent = nullptr, bool _temporary= false)
668  : parent(_parent), temporary(_temporary), enumCount(0)
669  { }
671  ~AsmScope();
672 
674  void startUsingScope(AsmScope* scope);
676  void stopUsingScope(AsmScope* scope);
679  {
680  usedScopes.clear();
681  usedScopesSet.clear();
682  }
684  void deleteSymbolsRecursively();
685 };
686 
687 class ISAUsageHandler;
688 class ISALinearDepHandler;
689 class ISAWaitHandler;
690 
693 {
694  const char* name;
698  uint64_t alignment;
699  uint64_t size;
701  uint64_t relAddress;
702  std::vector<cxbyte> content;
703 
704  std::unique_ptr<ISAUsageHandler> usageHandler;
705  std::unique_ptr<ISALinearDepHandler> linearDepHandler;
706  std::unique_ptr<ISAWaitHandler> waitHandler;
707  std::vector<AsmCodeFlowEntry> codeFlow;
708  AsmSourcePosHandler sourcePosHandler;
709 
711  AsmSection();
713  AsmSection(const char* _name, AsmKernelId _kernelId, AsmSectionType _type, Flags _flags,
714  uint64_t _alignment, uint64_t _size = 0, cxuint _relSpace = UINT_MAX,
715  uint64_t _relAddress = UINT64_MAX)
716  : name(_name), kernelId(_kernelId), type(_type), flags(_flags),
717  alignment(_alignment), size(_size), relSpace(_relSpace),
718  relAddress(_relAddress)
719  { }
720 
722  AsmSection(const AsmSection& section);
724  AsmSection& operator=(const AsmSection& section);
725 
728  { codeFlow.push_back(entry); }
729 
731  size_t getSize() const
732  { return ((flags&ASMSECT_WRITEABLE) != 0) ? content.size() : size; }
733 };
734 
736 struct AsmKernel
737 {
738  const char* name;
740  std::vector<std::pair<size_t, size_t> > codeRegions;
741 
743  void openCodeRegion(size_t offset);
745  void closeCodeRegion(size_t offset);
746 };
747 
749 class AsmRegVarLinears: std::vector<std::pair<uint16_t, uint16_t> >
750 {
751 public:
754 
756  void insertRegion(const std::pair<uint16_t, uint16_t>& p)
757  {
758  const_iterator it;
759  for (it = begin(); it != end(); ++it)
760  if (it->first <= p.first && it->second >= p.second)
761  break;
762  if (it == end())
763  push_back(p);
764  }
765 };
766 
767 };
768 
769 namespace std
770 {
771 
773 template<>
774 struct hash<CLRX::AsmSingleVReg>
775 {
777  typedef std::size_t result_type;
778 
780  size_t operator()(const CLRX::AsmSingleVReg& r1) const
781  {
782  std::hash<const CLRX::AsmRegVar*> h1;
783  std::hash<uint16_t> h2;
784  return h1(r1.regVar) ^ (h2(r1.index)<<1);
785  }
786 };
787 
788 }
789 
790 #endif
AsmRegVarMap regVarMap
regvar map
Definition: AsmDefs.h:652
bool evaluate(Assembler &assembler, uint64_t &value, AsmSectionId &sectionId) const
try to evaluate expression
Definition: AsmDefs.h:371
common definitions for assembler and disassembler
size_t target
target jump addreses
Definition: AsmDefs.h:635
main class of assembler
Definition: Assembler.h:529
AsmExprTargetType type
type of target
Definition: AsmDefs.h:213
non copyable and non movable base structure (class)
Definition: Utilities.h:46
assembler expression class
Definition: AsmDefs.h:286
AsmSymbolEntry * symbol
symbol
Definition: AsmDefs.h:271
AsmSymbol(bool _onceDefined=false)
empty constructor
Definition: AsmDefs.h:168
AsmSectionId sectionId
section id of destination
Definition: AsmDefs.h:218
kernel entry structure
Definition: AsmDefs.h:736
uint32_t Flags
type for declaring various flags
Definition: Utilities.h:100
plus (nothing)
std::unordered_map< CString, AsmRegVar > AsmRegVarMap
regvar map
Definition: AsmDefs.h:535
AsmExpression * expression
expression of symbol (if not resolved)
Definition: AsmDefs.h:160
bool operator==(const AsmExprSymbolOccurrence &b) const
comparison operator
Definition: AsmDefs.h:135
none operation
AsmRegVarMap::value_type AsmRegVarEntry
regvar entry
Definition: AsmDefs.h:537
target is 32-bit word
Definition: AsmDefs.h:66
AsmExprTarget(AsmExprTargetType _type, AsmSectionId _sectionId, size_t _offset)
constructor to create custom target
Definition: AsmDefs.h:229
target is 64-bit word
Definition: AsmDefs.h:67
AsmSymbolEntry * symbol
symbol entry (if ASMXTGT_SYMBOL)
Definition: AsmDefs.h:216
static AsmExprTarget codeFlowTarget(AsmSectionId sectionId, size_t cflowIndex)
make code flow target for expression
Definition: AsmDefs.h:242
target for assembler expression
Definition: AsmDefs.h:211
~AsmSymbol()
destructor
Definition: AsmDefs.h:466
size_t operator()(const CLRX::AsmSingleVReg &r1) const
a calling operator
Definition: AsmDefs.h:780
AsmExprOp
assembler expression operator
Definition: AsmDefs.h:76
delayed result for register for instruction with delayed results
Definition: AsmDefs.h:600
assembler section
Definition: AsmDefs.h:692
AsmSectionId relSectionId
section for which relocation is defined
Definition: AsmDefs.h:272
AsmExprTarget()
empty constructor
Definition: AsmDefs.h:226
for internal usage
Definition: AsmDefs.h:545
size_t offset
offset in section
Definition: AsmDefs.h:551
code flow entry
Definition: AsmDefs.h:68
static AsmExprTarget symbolTarget(AsmSymbolEntry *entry)
make symbol target for expression
Definition: AsmDefs.h:234
assembler scope for symbol, macros, regvars
Definition: AsmDefs.h:648
Regvar info structure.
Definition: AsmDefs.h:510
std::unique_ptr< ISAWaitHandler > waitHandler
wait handler
Definition: AsmDefs.h:706
cxbyte info
ELF symbol info.
Definition: AsmDefs.h:147
asm delay instr type entry
Definition: AsmDefs.h:576
cxuint type
scalar/vector/other
Definition: AsmDefs.h:512
std::vector< AsmCodeFlowEntry > codeFlow
code flow info
Definition: AsmDefs.h:707
const AsmExprTarget & getTarget() const
get targer of expression
Definition: AsmDefs.h:421
signed (arithmetic) shift right
void addCodeFlowEntry(const AsmCodeFlowEntry &entry)
add code flow entry to this section
Definition: AsmDefs.h:727
STL namespace.
static bool isUnaryOp(AsmExprOp op)
return true if is unary op
Definition: AsmDefs.h:415
uint16_t index
index of regvar array
Definition: AsmDefs.h:520
AsmSourcePos sourcePos
source position of definition
Definition: AsmDefs.h:739
size_t getSymOccursNum() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:424
std::list< AsmScope * > usedScopes
list of used scope in this scope
Definition: AsmDefs.h:655
assembler symbol occurrence in expression
Definition: AsmDefs.h:128
uint16_t rstart
register start
Definition: AsmDefs.h:566
std::unordered_map< CString, AsmScope * > AsmScopeMap
type definition of scope&#39;s map
Definition: AsmDefs.h:642
void addOccurrenceInExpr(AsmExpression *expr, size_t argIndex, size_t opIndex)
adds occurrence in expression
Definition: AsmDefs.h:192
try later (after some)
ColNo colNo
column number
Definition: AsmSource.h:155
void stopUsingScopes()
remove all usings
Definition: AsmDefs.h:678
Configuration header.
cxuint AsmSectionId
type for Asm section id (index)
Definition: Commons.h:35
cxuint RelocType
relocation type
Definition: Commons.h:33
less or equal than
AsmTryStatus
class of return value for a trying routines
Definition: AsmDefs.h:278
unsigned modulo
void setTarget(AsmExprTarget _target)
set target of expression
Definition: AsmDefs.h:336
for internal usage
Definition: AsmDefs.h:544
uint16_t rend
register end
Definition: AsmDefs.h:567
std::unordered_map< AsmScope *, std::list< AsmScope * >::iterator > usedScopesSet
set of used scopes in this scope
Definition: AsmDefs.h:659
size_t cflowId
cflow index of destination
Definition: AsmDefs.h:221
return from procedure
Definition: AsmDefs.h:626
AsmScope * parent
parent scope
Definition: AsmDefs.h:650
line and column
Definition: AsmSource.h:45
bool isEmpty() const
return true if expression is empty
Definition: AsmDefs.h:329
std::unordered_map< CString, AsmSymbol > AsmSymbolMap
assembler symbol map
Definition: AsmDefs.h:206
internal structure for regvar linear dependencies
Definition: AsmDefs.h:562
AsmScope(AsmScope *_parent, const AsmSymbolMap &_symbolMap, bool _temporary=false)
constructor
Definition: AsmDefs.h:662
const AsmRegVar * regVar
regvar
Definition: AsmDefs.h:565
an assembler formats
LineNo lineNo
line number of top-most source
Definition: AsmSource.h:154
size_t offset
offset of relocation
Definition: AsmDefs.h:268
uint64_t value
value of symbol
Definition: AsmDefs.h:157
single regvar id
Definition: AsmDefs.h:517
assembler relocation
Definition: AsmDefs.h:265
logical shift irght
cxbyte rwFlags
1 - read, 2 - write
Definition: AsmDefs.h:556
bool temporary
true if temporary
Definition: AsmDefs.h:654
AsmException()=default
empty constructor
wait handler
Definition: Assembler.h:182
void replaceOccurrenceSymbol(AsmExprSymbolOccurrence occurrence, AsmSymbolEntry *newSymEntry)
replace symbol in expression
Definition: AsmDefs.h:493
size_t opIndex
operator index
Definition: AsmDefs.h:132
if failed now, no later trial
unsigned less or equal
const char * name
name of kernel
Definition: AsmDefs.h:738
AsmSectionType
assembler section type
Definition: AsmFormats.h:47
unsigned char cxbyte
unsigned byte
Definition: Config.h:229
std::unordered_map< CString, RefPtr< const AsmMacro > > AsmMacroMap
assembler macro map
Definition: AsmDefs.h:640
greater or equal than
main namespace
Definition: AsmDefs.h:38
AsmSymbolEntry * symbol
if symbol
Definition: AsmDefs.h:475
symbol without defined value
AsmKernelId kernelId
kernel id (optional)
Definition: AsmDefs.h:695
const AsmRegVar * regVar
regvar
Definition: AsmDefs.h:519
AsmSymbol(AsmSectionId _sectionId, uint64_t _value, bool _onceDefined=false)
constructor with value and section id
Definition: AsmDefs.h:182
bool finishOnRegReadOut
waiting finished on register read out (true) or on operation
Definition: AsmDefs.h:581
static bool isArg(AsmExprOp op)
return true if is argument op
Definition: AsmDefs.h:412
bool unrefSymOccursNum()
unreference symbol occurrences in expression (used internally)
Definition: AsmDefs.h:430
void substituteOccurrence(AsmExprSymbolOccurrence occurrence, uint64_t value, AsmSectionId sectionId=ASMSECT_ABS)
substitute occurrence in expression by value
Definition: AsmDefs.h:483
unsigned int cxuint
unsigned int
Definition: Config.h:237
bool operator!=(const AsmSingleVReg &r2) const
not equal operator
Definition: AsmDefs.h:526
static bool isBinaryOp(AsmExprOp op)
return true if is binary op
Definition: AsmDefs.h:418
code end
Definition: AsmDefs.h:628
target is byte
Definition: AsmDefs.h:64
uint64_t size
size of symbol
Definition: AsmDefs.h:158
size_t getSize() const
get section&#39;s size
Definition: AsmDefs.h:731
cxuint relSpace
relative space where is section
Definition: AsmDefs.h:700
binary negation
AsmScope(AsmScope *_parent=nullptr, bool _temporary=false)
constructor
Definition: AsmDefs.h:667
AsmSection(const char *_name, AsmKernelId _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:713
static AsmExprTarget dataTarget(AsmSectionId sectionId, size_t offset)
make n-bit word target for expression
Definition: AsmDefs.h:253
uint64_t relAddress
relative address
Definition: AsmDefs.h:701
cxbyte AsmExprTargetType
expression target type (one byte)
Definition: AsmDefs.h:59
AsmCodeFlowType type
type of code flow entry
Definition: AsmDefs.h:636
uint16_t rend
register end
Definition: AsmDefs.h:554
uint64_t size
section size
Definition: AsmDefs.h:699
std::vector< AsmExprSymbolOccurrence > occurrencesInExprs
Definition: AsmDefs.h:165
target is 16-bit word
Definition: AsmDefs.h:65
AsmSectionId sectionId
sectionId
Definition: AsmDefs.h:479
std::vector< cxbyte > content
content of section
Definition: AsmDefs.h:702
AsmSymbolMap::value_type AsmSymbolEntry
assembler symbol entry
Definition: AsmDefs.h:208
Flags flags
section flags
Definition: AsmDefs.h:697
cxuint AsmKernelId
type for Asm kernel id (index)
Definition: Commons.h:33
target is symbol
Definition: AsmDefs.h:63
uint64_t value
value
Definition: AsmDefs.h:476
cxuint refCount
reference counter (for internal use only)
Definition: AsmDefs.h:145
size_t offset
offset of destination
Definition: AsmDefs.h:220
uint16_t size
in regs
Definition: AsmDefs.h:513
size_t offset
offset where is this entry
Definition: AsmDefs.h:634
size_t argIndex
argument index
Definition: AsmDefs.h:131
utilities for other libraries and programs
const Array< AsmExprOp > & getOps() const
get operators list
Definition: AsmDefs.h:440
unsigned division
std::unique_ptr< ISAUsageHandler > usageHandler
usage handler
Definition: AsmDefs.h:704
class holds source position for section offset
Definition: AsmSource.h:530
RelocType type
relocation type
Definition: AsmDefs.h:269
uint64_t alignment
section alignment
Definition: AsmDefs.h:698
bool operator<(const AsmSingleVReg &r2) const
less operator
Definition: AsmDefs.h:530
const AsmRegVar * regVar
if null, then usage of called register
Definition: AsmDefs.h:552
std::string message
message
Definition: Utilities.h:64
exception class
Definition: Utilities.h:61
AsmSymbolMap symbolMap
symbol map
Definition: AsmDefs.h:651
AsmSectionId sectionId
section id
Definition: AsmDefs.h:146
AsmScopeMap scopeMap
scope map
Definition: AsmDefs.h:653
code start
Definition: AsmDefs.h:627
AsmSectionType type
type of section
Definition: AsmDefs.h:696
regvar usage in code
Definition: AsmDefs.h:549
linears for regvars
Definition: AsmDefs.h:749
uint16_t rstart
register start
Definition: AsmDefs.h:553
AsmTryStatus tryEvaluate(Assembler &assembler, uint64_t &value, AsmSectionId &sectionId, bool withSectionDiffs=false) const
try to evaluate expression with/without section differences
Definition: AsmDefs.h:360
AsmRegVarLinears()
constructor
Definition: AsmDefs.h:753
call of procedure
Definition: AsmDefs.h:625
AsmSymbol(AsmExpression *expr, bool _onceDefined=false, bool _base=false)
constructor with expression
Definition: AsmDefs.h:175
for internal usage (regtype)
Definition: AsmDefs.h:543
register will be read
Definition: AsmDefs.h:540
std::unique_ptr< ISALinearDepHandler > linearDepHandler
linear dep handler
Definition: AsmDefs.h:705
void insertRegion(const std::pair< uint16_t, uint16_t > &p)
insert new region if whole region is not some already region
Definition: AsmDefs.h:756
code flow entry
Definition: AsmDefs.h:632
cxbyte other
ELF symbol other.
Definition: AsmDefs.h:148
jump
Definition: AsmDefs.h:623
description of the WAIT instruction (for waiting for results)
Definition: AsmDefs.h:614
std::vector< std::pair< size_t, size_t > > codeRegions
code regions
Definition: AsmDefs.h:740
const char * name
section name
Definition: AsmDefs.h:694
absolute section id
Definition: AsmFormats.h:86
an assembler sources handling
virtual ~AsmException() noexcept=default
destructor
AsmCodeFlowType
code flow type
Definition: AsmDefs.h:621
Assembler exception class.
Definition: AsmDefs.h:42
assembler symbol structure
Definition: AsmDefs.h:143
bool useRegMode
if RVU from useReg pseudo-ops
Definition: AsmDefs.h:558
asm wait system configuration
Definition: AsmDefs.h:586
bool isDefined() const
return true if symbol defined (have value or expression)
Definition: AsmDefs.h:201
cxbyte counting
counting (255 - per instr), 1-254 - per element size
Definition: AsmDefs.h:582
register will be written
Definition: AsmDefs.h:541
cxbyte AsmRegField
type of register field
Definition: AsmDefs.h:500
const AsmExprArg * getArgs() const
get argument list
Definition: AsmDefs.h:443
ISA regvar linear handler.
Definition: Assembler.h:136
ISA (register and regvar) Usage handler.
Definition: Assembler.h:80
unsigned less or equal
size_t hasRelativeSymOccurs() const
get number of symbol occurrences in expression
Definition: AsmDefs.h:427
AsmRegField regField
place in instruction
Definition: AsmDefs.h:555
uint64_t addend
addend
Definition: AsmDefs.h:274
succeed, no trial needed
conditional jump
Definition: AsmDefs.h:624
AsmExpression * expression
target expression pointer
Definition: AsmDefs.h:130
assembler expression argument
Definition: AsmDefs.h:473
access mask
Definition: AsmDefs.h:542
cxbyte align
register alignment
Definition: AsmDefs.h:557
bool operator==(const AsmSingleVReg &r2) const
equal operator
Definition: AsmDefs.h:523
CLRX::AsmSingleVReg argument_type
argument type
Definition: AsmDefs.h:776
const AsmSourcePos & getSourcePos() const
get source position
Definition: AsmDefs.h:446
bool evaluate(Assembler &assembler, size_t opStart, size_t opEnd, uint64_t &value, AsmSectionId &sectionId) const
try to evaluate expression
Definition: AsmDefs.h:384
assembler source position
Definition: AsmSource.h:150
std::size_t result_type
result type
Definition: AsmDefs.h:777
AsmSectionId sectionId
section id where relocation is present
Definition: AsmDefs.h:267