OpenASIP  2.0
TDGen.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2020 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file TDGen.hh
26  *
27  * Declaration of TDGen class.
28  *
29  * @author Veli-Pekka Jääskeläinen 2008 (vjaaskel-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2010
31  * @author Heikki Kultala 2012
32  */
33 
34 #ifndef TTA_TDGEN_HH
35 #define TTA_TDGEN_HH
36 
37 #include <iostream>
38 #include <map>
39 #include <set>
40 #include <string>
41 #include <vector>
42 
43 #include "Exception.hh"
44 #include "ImmInfo.hh"
45 #include "MachinePart.hh"
46 #include "Operand.hh"
47 #include "OperationDAGSelector.hh"
48 #include "TCEString.hh"
49 
50 class Operation;
51 class Operand;
52 class OperationDAG;
53 class OperationNode;
54 class OperationDAGNode;
55 class TerminalNode;
56 class ConstantNode;
57 
58 namespace TTAMachine {
59  class Machine;
60  class RegisterFile;
61 }
62 
63 namespace TDGenerator {
64 struct RegisterInfo;
65 struct InstructionInfo;
66 class ValueType;
67 class RegisterClass;
68 } // namespace TDGenerator
69 
70 /**
71  * TCE Backend plugin source code and .td definition generator.
72  *
73  * Generates files for building target architecture plugin for LLVM-TCE
74  * backend. This version generates the backend files for the "RISC
75  * instruction set style" output and provides useful methods.
76  */
77 class TDGen {
78 public:
79  TDGen(const TTAMachine::Machine& mach);
80  virtual ~TDGen();
81  void generateBackend(std::string& path);
82  // todo clear out virtual functions. they are a remaind of removed
83  // TDGenSIMD.
84 protected:
85  bool writeRegisterInfo(std::ostream& o);
86  void writeStartOfRegisterInfo(std::ostream& o);
87  void writeOperandDefs(std::ostream& o);
88  void writeIntegerImmediateDefs(std::ostream& o, const ImmInfo& iivis);
89  void writeMoveImmediateDefs(std::ostream& o);
90 
91  void writeInstrInfo(std::ostream& o);
92  void writeBackendCode(std::ostream& o);
93  void writeTopLevelTD(std::ostream& o);
94  void writeInstrFormats(std::ostream& o);
95 
96  enum RegType {
97  GPR = 0,
101  };
102 
103  struct TerminalDef {
104  std::string registerPat;
105  std::string registerDag;
106  std::string immPat;
107  std::string immDag;
108  };
109 
110  struct RegInfo {
111  std::string rf;
112  unsigned idx;
113 
114  // Comparison operator for ordering in set.
115  bool operator<(const RegInfo& other) const {
116  if (rf < other.rf ||
117  (rf == other.rf && idx < other.idx)) {
118 
119  return true;
120  }
121 
122  return false;
123  }
124  };
125 
131  };
132  // Gather & associate machine information
133  // TODO maybe remove this comment, because in TDGenSIMD made sense, but
134  // here is more confusing
135  bool checkRequiredRegisters();
136  void analyzeRegisters();
138  void analyzeRegisters(RegsToProcess regsToProcess);
144 
145  void verbose(const TCEString& msg) const;
146 
147  // Helper functions.
148  bool isVectorLoadOperation(const Operation& op) const;
149  bool isVectorStoreOperation(const Operation& op) const;
150  bool isWrongEndianessVectorOp(const Operation& op) const;
151  bool isVectorBitwiseOperation(const Operation& op) const;
152  bool hasRawOperands(const Operation& op) const;
153  int subwordWidthOfRawData(const Operation& op) const;
154  bool hasRegisterClassSupport(const Operation& op) const;
155  bool hasRegisterClassSupport(const TDGenerator::ValueType& vt) const;
156  TCEString associatedVectorRegisterClass(const Operand& operand) const;
158  std::ostream& o, const TCEString& origPat,
159  const TCEString& replacerPat) const;
161  std::ostream& o, Operation& op, bool skipPattern,
162  std::vector<TDGenerator::ValueType> inputs,
163  std::vector<TDGenerator::ValueType> outputs,
164  TCEString instrSuffix = "");
165 
166  void writeRegisterDef(
167  std::ostream& o,
168  const RegInfo& reg,
169  const std::string regName,
170  const std::string regTemplate,
171  const std::string aliases,
172  RegType type);
173 
174  void write64bitRegisterInfo(std::ostream& o);
175  void write32bitRegisterInfo(std::ostream& o);
176  void write16bitRegisterInfo(std::ostream& o);
177  void write8bitRegisterInfo(std::ostream& o);
178  void write1bitRegisterInfo(std::ostream& o);
179  void writeRARegisterInfo(std::ostream& o);
180 // void writeVectorRegisterInfo(std::ostream& o);
181 // void writeVectorRegisterInfo(std::ostream& o, int width);
182  void writeGuardRegisterClassInfo(std::ostream& o);
183 
184  // these generate vectorregister info in the GenRegisterInfo.td
185  // definitions
186  void writeVectorRegisterBaseClasses(std::ostream& o) const;
187  void writeVectorRegisterNames(std::ostream& o);
188  void writeVectorRegisterClasses(std::ostream& o) const;
189 
190  // These generate vector GenInstrInfo.td definitions.
192  std::ostream& o, Operation& op, bool skipPattern);
194  std::ostream& o, Operation& op, TCEString valueTypes,
195  const TCEString& attributes, bool skipPattern);
197  const Operation& op, const TCEString& valueTypes, bool isRegisterOp);
199  std::ostream& o, Operation& op, bool skipPattern);
201  std::ostream& o, Operation& op, bool skipPattern);
202 
203  void writeVectorRegisterMoveDefs(std::ostream& o);
204  void writeVectorTruncStoreDefs(std::ostream& o) const;
205  void writeScalarToVectorDefs(std::ostream& o) const;
206  void writeVectorBitConversions(std::ostream& o) const;
207  void writeScalarOperationExploitations(std::ostream& o);
208  void writeVectorLoadStoreOperationExploitations(std::ostream& o);
209  void writeWiderVectorOperationExploitations(std::ostream& o);
210 
211  // These generate vector Backend.inc definitions.
212  void genGeneratedTCEPlugin_getStore(std::ostream& o) const;
213  void genGeneratedTCEPlugin_getLoad(std::ostream& o) const;
214  void genGeneratedTCEPlugin_isVectorRegisterMove(std::ostream& o) const;
215  void genGeneratedTCEPlugin_getVectorValueType(std::ostream& o) const;
217  std::ostream& o) const;
218  void genGeneratedTCEPlugin_getVectorPackOpcode(std::ostream& o) const;
219  void genGeneratedTCEPlugin_getVectorSelectOpcode(std::ostream& o) const;
220  void genGeneratedTCEPlugin_getVectorShuffle1Opcode(std::ostream& o) const;
221  void genGeneratedTCEPlugin_getVectorShuffle2Opcode(std::ostream& o) const;
223  std::ostream& o) const;
224  void genGeneratedTCEPlugin_getExtractElemOpcode(std::ostream& o) const;
225  void genGeneratedTCEPlugin_getVectorShlSameOpcode(std::ostream& o) const;
226  void genGeneratedTCEPlugin_getVectorShrSameOpcode(std::ostream& o) const;
227  void genGeneratedTCEPlugin_getVectorShruSameOpcode(std::ostream& o) const;
228  void genGeneratedTCEPlugin_getVectorAndSameOpcode(std::ostream& o) const;
229  void genGeneratedTCEPlugin_getVectorIorSameOpcode(std::ostream& o) const;
230  void genGeneratedTCEPlugin_getVectorXorSameOpcode(std::ostream& o) const;
232  std::ostream& o) const;
234  std::ostream& o) const;
235  void genTCETargetLoweringSIMD_getSetCCResultVT(std::ostream& o) const;
236  void genTCEInstrInfoSIMD_copyPhysVectorReg(std::ostream& o) const;
237 
239  std::ostream& o) const;
240  void genGeneratedTCEPlugin_getGatherOpcode(std::ostream& o) const;
241  void genGeneratedTCEPlugin_getLoadOpcode(std::ostream& o) const;
242  void genGeneratedTCEPlugin_getAddOpcode(std::ostream& o) const;
243  void genGeneratedTCEPlugin_getShlOpcode(std::ostream& o) const;
244  void genGeneratedTCEPlugin_getIorOpcode(std::ostream& o) const;
245 
246  void writeVectorImmediateWriteDefs(std::ostream& instrInfoTD);
247 
248  void createMinMaxDef(
249  const TCEString& opName, const TCEString& valueName, std::ostream&os);
250 
252  const TCEString& opName,
253  int bits,
254  char llvmTypeChar,
255  const TCEString& postFix,
256  std::ostream& os);
257 
258  void writeOperationDefs(std::ostream& o, Operation& op, bool skipPattern);
259 
260  void writeOperationDef(
261  std::ostream& o, Operation& op, const std::string& operandTypes,
262  const std::string& attrs, bool skipPattern,
263  std::string backendPrefix = "");
264 
265  std::string emulatingOpNodeLLVMName(
266  const Operation& op, const OperationDAG& dag, const OperationNode& node,
267  const std::string& operandTypes);
268 
270  std::ostream& o, const Operation& op, const OperationDAG& dag);
271 
272  void write64bitMoveDefs(std::ostream& o);
273 
274  void writeControlFlowInstrDefs(std::ostream& os);
275  void writeCondBranchDefs(std::ostream& os);
276  void writeCallDef(std::ostream& o);
277  void writeHWLoopDef(std::ostream& o);
278  virtual void writeCallDefRegs(std::ostream& o);
279 
280  void writeRegisterClasses(std::ostream& o);
281 
283  const Operation& op, char operandType = ' ') const;
284 
285  virtual TCEString
286  llvmOperationName(const TCEString& opName) const;
287 
289  const Operation& op,
290  std::set<std::string>* recursionCycleCheck = NULL,
291  bool recursionHasStore = false);
293  const OperationDAG& op,
294  std::set<std::string>* recursionCycleCheck = NULL,
295  bool recursionHasStore = false);
297  const Operation& op);
298 
299  std::string tceOperationPattern(const Operation& op);
300 
301  std::string patOutputs(const Operation& op, const std::string& oprTypes);
302  std::string patInputs(const Operation& op, const std::string& oprTypes);
303 
304  virtual std::string operandToString(
305  const Operand& operand,
306  bool match,
307  char operandType,
308  const std::string& immDefName = "");
309 
310  std::string operationNodeToString(
311  const Operation& op, const OperationDAG& dag,
312  const OperationNode& node, bool emulationPattern,
313  const std::string& operandTypes);
314 
315  std::string constantNodeString(
316  const Operation& op,
317  const OperationDAG& dag,
318  const ConstantNode& node,
319  const std::string& operandTypes,
320  const OperationDAGNode* successor = nullptr);
321 
322  std::string dagNodeToString(
323  const Operation& op, const OperationDAG& dag,
324  const OperationDAGNode& node, bool emulationPattern,
325  const std::string& operandTypes, const Operation* emulatingOp = nullptr,
326  const OperationDAGNode* successor = nullptr);
327 
328  std::string operationPattern(
329  const Operation& op, const OperationDAG& dag,
330  const std::string& operandTypes);
331 
332  virtual char operandChar(Operand& operand);
333 
334  std::string createDefaultOperandTypeString(const Operation& op);
335 
337  std::ostream& o,
338  const TCEString& opName,
339  const TCEString& opNameSuffix,
340  bool addrImm,
341  const TCEString& dataType,
342  bool writePredicatedVersions);
343 
344  void genTCEInstrInfo_copyPhys64bitReg(std::ostream&o) const;
345 
346  void writeArgRegsArray(std::ostream& os);
347  virtual void createSelectPatterns(std::ostream& os);
348  void writeAddressingModeDefs(std::ostream& o);
349 
350  void createByteExtLoadPatterns(std::ostream& os);
351  void createShortExtLoadPatterns(std::ostream& os);
352  void create32BitExtLoadPatterns(std::ostream& os);
353 
354  void createEndiannesQuery(std::ostream& os);
355  void createConstantMaterializationQuery(std::ostream& os);
356  void createConstShiftPatterns(std::ostream& os);
357 
358  void writeOperationDefs(
359  std::ostream& o, Operation& op, const std::string& operandTypes,
360  const std::string& attrs, bool skipPattern,
361  std::string backendPrefix = "");
362 
363  void writeVectorStoreDefs(std::ostream& o, Operation& op, int vectorLen);
364 
366  std::ostream& o, Operation& op, int bitsize, int vectorLen);
367 
368  void createGetMaxMemoryAlignment(std::ostream& os) const;
369 
371  std::ostream& o, Operation& op, const TCEString& loadPatternName,
372  int vectorLen);
373 
374  void writeVectorLoadDefs(
375  std::ostream& o, const TCEString& opName, const TCEString& opNameSuffix,
376  bool addrImm, const TCEString& resultType,
377  const TCEString& loadPatternName, bool writePredicatedVersions);
378 
379  virtual void writeImmediateDef(
380  std::ostream& o, const std::string& defName,
381  const std::string& operandType, const std::string& predicate);
382  void writeInstrDef(
383  std::ostream& o, const std::string& instrDefName,
384  const std::string& outs, const std::string& ins,
385  const std::string& asmString, const std::string& pattern);
386 
387  void writeVectorLoadDefs(
388  std::ostream& o, Operation& op, const TCEString& loadPatternName,
389  int vectorLen);
390 
391  void writeBooleanStorePatterns(std::ostream& os);
392 
393  std::string immediatePredicate(
394  int64_t lowerBoundInclusive,
395  uint64_t upperBoundInclusive);
397  const OperationDAG&,
398  const Operand& operand);
400  const Operation& operation,
401  const std::string& operandTypes) const;
402 
403  void writeBroadcastDefs(std::ostream& o, Operation& op, int vectorLen);
404 
406  std::ostream& os, const TCEString& tceop1, const TCEString& tceop2,
407  bool fp = false);
408 
409  std::string subPattern(const Operation& op, const OperationDAG& dag);
410 
412  bool canBeImmediate(const OperationDAG& dag, const TerminalNode& node);
413 
414  virtual void createMinMaxGenerator(std::ostream& os);
415 
416  void writeCallSeqStart(std::ostream& os);
417  void writeMiscPatterns(std::ostream& o);
418  void generateLoadStoreCopyGenerator(std::ostream& os);
419 
420  void createParamDRegNums(std::ostream& os);
421  virtual void createVectorRVDRegNums(std::ostream& os);
422 
423  void writeCallingConv(std::ostream& os);
424  void writeCallingConvLicenceText(std::ostream& os);
425 
426  void writeConstShiftPat(
427  std::ostream& os, const TCEString& nodeName,
428  const TCEString& opNameBase, int i);
429 
430  ImmInfo* immInfo_ = nullptr;
431  /// Maps (operation, operand) pairs to i32 immediate operand definition
432  /// names.
433  std::map<ImmInfoKey, std::string> immOperandDefs_;
434 
435  void createBoolAndHalfLoadPatterns(std::ostream& os);
436 
437  virtual void createConstantMaterializationPatterns(std::ostream& os);
438 
439  void createBranchAnalysis(std::ostream& os);
440 
441  void genTCERegisterInfo_setReservedVectorRegs(std::ostream& os) const;
442 
443  void writeGetPointerAdjustmentQuery(std::ostream& os) const;
444 
445  bool canBePredicated(Operation& op, const std::string& operandTypes);
446  static std::vector<std::string> supportedStackAccessOperations(
447  const TTAMachine::Machine& mach);
448 
450  const Operation& op, const std::string& operandTypes,
451  const std::string& operand0, const std::string& operand1) const;
452 
453  std::string operandTypesToRegisters(const std::string& opdTypes) const;
454  char operandTypeToRegister(const char& opdType) const;
455 
457  const char& opdType, const std::string& inputPattern) const;
458 
460 
461  // Current dwarf register number.
462  unsigned dregNum_;
463 
464  /// Float type subword width.
465  static const int FP_SUBW_WIDTH;
466  /// Half float type subword width.
467  static const int HFP_SUBW_WIDTH;
468  /// Bool type subword width.
469  static const int BOOL_SUBW_WIDTH;
470  /// Distincts wide vs scalar registers.
471  static const int MAX_SCALAR_WIDTH;
472  /// Maximum number of subwords that any SIMD operation can have.
473  static const int MAX_SUBW_COUNT;
474 
475  /// If set to true, smaller vector value types can be stored to larger
476  /// register files, e.g. v4i8 vectors can be stored to registers that
477  /// are over 32 bits in size.
478  static const bool EXPLOIT_BIGGER_REGISTERS;
479 
480 public:
481  // Characters for differend operand types.
482  static const char OT_REG_BOOL;
483  static const char OT_REG_INT;
484  static const char OT_REG_LONG;
485  static const char OT_REG_FP;
486  static const char OT_REG_HFP;
487  static const char OT_REG_DOUBLE;
488  static const char OT_IMM_BOOL;
489  static const char OT_IMM_INT;
490  static const char OT_IMM_FP;
491  static const char OT_IMM_HFP;
492  static const char OT_IMM_LONG;
493  static const char OT_VREG_BOOL;
494  static const char OT_VREG_INT8;
495  static const char OT_VREG_INT16;
496  static const char OT_VREG_INT32;
497  static const char OT_VREG_FP;
498  static const char OT_VREG_HFP;
499 
500 protected:
501  /// Contains <BaseOpName, OpPattern> key-value pairs.
502  static const std::map<TCEString, TCEString> OPERATION_PATTERNS_;
503 
504  /// Contains all operation names in upper case.
506 
507  /// Contains all scalar operations (<Name, Operation>).
508  std::map<TCEString, Operation*> scalarOps_;
509 
510  /// Contains all vector operations (<Name, Operation>).
511  std::map<TCEString, Operation*> vectorOps_;
512 
513  /// Contains vector base classes for register files (<Width, Name>).
514  std::map<int, TCEString> baseClasses_;
515 
516  /// Contains registers fit for being vector registers (<Width, Registers>).
517  std::map<int, std::vector<TDGenerator::RegisterInfo> > registers_;
518 
519  /// Contains required vector register classes (<ValueType, RegClass>).
520  std::map<TCEString, TDGenerator::RegisterClass> vRegClasses_;
521 
522  /// All register store operations (<ValueType, InstrInfo>).
523  std::map<TCEString, TDGenerator::InstructionInfo> registerStores_;
524  /// All register load operations (<ValueType, InstrInfo>).
525  std::map<TCEString, TDGenerator::InstructionInfo> registerLoads_;
526  /// All immediate store operations (<ValueType, InstrInfo>).
527  std::map<TCEString, TDGenerator::InstructionInfo> immediateStores_;
528  /// All immediate load operations (<ValueType, InstrInfo>).
529  std::map<TCEString, TDGenerator::InstructionInfo> immediateLoads_;
530 
531  /// Contains machine's PACK instructions (<ValueType, InstrName>).
532  std::map<TCEString, TCEString> packOperations_;
533  /// Contains machine's VBCAST instructions (<ValueType, InstrName>).
534  std::map<TCEString, TCEString> vbcastOperations_;
535  /// Contains machine's TRUNCxx/CFH instructions (<ValueType, InstrName>).
536  std::vector<std::pair<const Operation*, TCEString> > truncOperations_;
537  /// Contains machine's VSELECT instructions (<instrName, ValueType>).
538  std::map<TCEString, TCEString> vselectOperations_;
539  /// Contains machine's VSHUFFLE1 instructions (<ValueType, InstrName>).
540  std::map<TCEString, TCEString> vshuffle1Operations_;
541  /// Contains machine's VSHUFFLE2 instructions (<ValueType, InstrName>).
542  std::map<TCEString, TCEString> vshuffle2Operations_;
543  /// Contains machine's VCSHUFFLE instructions
544  /// (<<ValueType, ConstantSelects>, InstrName>).
545  std::map<std::pair<TCEString, std::vector<int>>, TCEString>
547  /// Contains machine's EXTRACTELEM instructions (<ValueType, InstrName>).
548  std::map<TCEString, TCEString> extractElemOperations_;
549  /// Contains machine's SHLSAME instructions (<ValueType, InstrName>).
550  std::map<TCEString, TCEString> shlSameOperations_;
551  /// Contains machine's SHRSAME instructions (<ValueType, InstrName>).
552  std::map<TCEString, TCEString> shrSameOperations_;
553  /// Contains machine's SHRUSAME instructions (<ValueType, InstrName>).
554  std::map<TCEString, TCEString> shruSameOperations_;
555  /// Contains machine's ANDSAME instructions (<ValueType, InstrName>).
556  std::map<TCEString, TCEString> andSameOperations_;
557  /// Contains machine's IORSAME instructions (<ValueType, InstrName>).
558  std::map<TCEString, TCEString> iorSameOperations_;
559  /// Contains machine's XORSAME instructions (<ValueType, InstrName>).
560  std::map<TCEString, TCEString> xorSameOperations_;
561  /// Contains machine's GATHER instructions (<ValueType, InstrName>).
562  std::map<TCEString, TCEString> gatherOperations_;
563  /// Contains machine's add instructions (<ValueType, InstrName>).
564  std::map<TCEString, TCEString> addOperations_;
565  /// Contains machine's shl instructions (<ValueType, InstrName>).
566  std::map<TCEString, TCEString> shlOperations_;
567  /// Contains machine's shl instructions (<ValueType, InstrName>).
568  std::map<TCEString, TCEString> iorOperations_;
569 
570  /// Contains all moves between register classes (<InstrName>).
571  std::set<TCEString> movOperations_;
572 
573  // List of all 1-bit registers in the target machine.
574  std::vector<RegInfo> regs1bit_;
575  // List of 8-bit registers in the target machine.
576  std::vector<RegInfo> regs8bit_;
577  // List of 16-bit registers in the target machine.
578  std::vector<RegInfo> regs16bit_;
579  // List of 32-bit registers in the target machine.
580  std::vector<RegInfo> regs32bit_;
581  // List of 64-bit registers in the target machine.
582  std::vector<RegInfo> regs64bit_;
583  /// The LLVM register defs used as guards.
584  std::vector<std::string> llvmGuardRegs_;
585 
586  /// Map of generated llvm register names to
587  /// physical register in the machine.
588  std::map<std::string, RegInfo> regs_;
589 
590  std::vector<std::string> argRegNames_;
591  std::vector<std::string> resRegNames_;
592  std::vector<std::string> gprRegNames_;
593 
594  std::map<std::string, std::string> opNames_;
595 
596  std::map<std::string, std::string> truePredOps_;
597  std::map<std::string, std::string> falsePredOps_;
598 
600 
603 
607 
609 
611 
613  unsigned int argRegCount_;
614  /// Minimum number of 32 bit registers.
615  unsigned int requiredI32Regs_;
616  unsigned int requiredI64Regs_;
619 
620  /// List of register that are associated with a guard on a bus.
621  std::set<RegInfo> guardedRegs_;
622 
623  /// Register files whose last reg reserved for temp reg copies.
624  std::set<
627 
628  typedef std::map<std::string, std::vector<std::string> > RegClassMap;
629  /// All registers in certain group
631  // Registers grouped by corresponding RFs
633  /// All predicates used in constant materialization patterns.
634  std::vector<std::string> constantMaterializationPredicates_;
635 
636  static const std::string guardRegTemplateName;
637 };
638 
639 namespace TDGenerator {
640 
641 /**
642  * Class to represent info of a single register in a register file.
643  */
644 struct RegisterInfo {
646  const TCEString& regName, const TCEString& regFileName,
647  unsigned regIndex, unsigned regWidth)
648  : regName_(regName),
649  regFileName_(regFileName),
650  regIndex_(regIndex),
651  regWidth_(regWidth) {}
652 
653  /// Register name in GenRegisterInfo.td, e.g. "KLUDGE_REGISTER".
655  /// Name of the register file the register belongs to, e.g. "RF".
657  /// Register index in the register file.
658  unsigned regIndex_;
659  /// Register width in bits.
660  unsigned regWidth_;
661 };
662 
663 /**
664  * Class to represent information of an instruction record.
665  */
667  InstructionInfo(const TCEString& osalOpName, const TCEString& instrName)
668  : osalOpName_(osalOpName), instrName_(instrName) {}
669 
670  /// The OSAL operation used to create the record, e.g. "ADD32X4".
672  /// The instruction record name, e.g. "ADD32X4uuu"
674 };
675 
676 /**
677  * Represents an LLVM value type to express different value types.
678  */
679 class ValueType {
680 public:
681  ValueType(int subwWidth, int subwCount, bool isFloat);
682  ValueType(const TCEString& vtStr);
683  ValueType(const Operand& opnd);
684 
685  ValueType(const ValueType& other);
686  ValueType& operator=(const ValueType& other);
687 
688  bool isSupportedByLLVM() const;
689  int width() const;
690  int subwordWidth() const;
691  int subwordCount() const;
692  bool isFloat() const;
693  bool isVector() const;
695  TCEString valueTypeStr() const;
696 
697  static TCEString valueTypeStr(const Operand& operand);
698  static ValueType valueType(const TCEString& vtStr);
699  static ValueType valueType(const Operand& operand);
700  static std::vector<ValueType> vectorTypesOfWidth(
701  int width, bool onlyInts = false);
702  static std::vector<ValueType> vectorTypesOfSubwordWidth(
703  int subwordWidth, bool onlyInt = false);
704 
705  // Public for faster access.
706 
707  /// Subword width of the value type.
709  /// Subword count of the value type.
711  /// If true, the value type is a floating point type.
712  bool isFloat_;
713 
714  /// Contains all supported LLVM value types (<ValueType>).
715  static const std::set<TCEString> SUPPORTED_LLVM_VALUE_TYPES;
716 };
717 
718 /**
719  * Represents TableGen RegisterClass class.
720  */
722 public:
723  RegisterClass(const ValueType& vt, const TCEString& name);
724 
725  RegisterClass(const RegisterClass& other);
726  RegisterClass& operator=(const RegisterClass& other);
727 
728  TCEString name() const;
729  ValueType valueType() const;
730  int alignment() const;
731  std::vector<RegisterInfo> registers() const;
732  RegisterInfo registerInfo(int index) const;
733  size_t numberOfRegisters() const;
734 
735  void addRegisters(const std::vector<RegisterInfo>& registers);
736 
737 private:
738  /// RegisterClass name.
740  /// Value type that is supported by this RegisterClass, e.g. v4i32.
742  /// RegisterClass alignment in bits, at least 8.
744  /// Register file registers that this RegisterClass uses.
745  std::vector<RegisterInfo> registers_;
746 };
747 } // namespace TDGenerator
748 
749 #endif
Operand
Definition: Operand.hh:52
TDGen::requiredI64Regs_
unsigned int requiredI64Regs_
Definition: TDGen.hh:616
TDGen::gprRegNames_
std::vector< std::string > gprRegNames_
Definition: TDGen.hh:592
TDGenerator::RegisterInfo::regWidth_
unsigned regWidth_
Register width in bits.
Definition: TDGen.hh:660
TDGen::createEndiannesQuery
void createEndiannesQuery(std::ostream &os)
Definition: TDGen.cc:6413
TDGenerator::RegisterInfo::regFileName_
TCEString regFileName_
Name of the register file the register belongs to, e.g. "RF".
Definition: TDGen.hh:656
TDGen::writePortGuardedJumpDefPair
bool writePortGuardedJumpDefPair(std::ostream &os, const TCEString &tceop1, const TCEString &tceop2, bool fp=false)
Definition: TDGen.cc:3841
TDGenerator::RegisterClass
Definition: TDGen.hh:721
TDGen::genGeneratedTCEPlugin_getVectorShuffle2Opcode
void genGeneratedTCEPlugin_getVectorShuffle2Opcode(std::ostream &o) const
TDGen::RegsToProcess
RegsToProcess
Definition: TDGen.hh:126
TDGen::OT_REG_FP
static const char OT_REG_FP
Definition: TDGen.hh:485
TDGen::write16bitRegisterInfo
void write16bitRegisterInfo(std::ostream &o)
Definition: TDGen.cc:1155
TDGen::RESULT
@ RESULT
Definition: TDGen.hh:100
TDGen::genTCETargetLoweringSIMD_associatedVectorRegClass
void genTCETargetLoweringSIMD_associatedVectorRegClass(std::ostream &o) const
Definition: TDGen.cc:3042
TDGen::genGeneratedTCEPlugin_getExtractElemOpcode
void genGeneratedTCEPlugin_getExtractElemOpcode(std::ostream &o) const
TDGen::OT_REG_INT
static const char OT_REG_INT
Definition: TDGen.hh:483
TDGen::getMatchableOperationDAG
const OperationDAG * getMatchableOperationDAG(const Operation &op)
Definition: TDGen.cc:5320
TDGen::maxScalarWidth_
int maxScalarWidth_
Definition: TDGen.hh:610
TDGen::writeVectorStoreDefs
void writeVectorStoreDefs(std::ostream &o, const TCEString &opName, const TCEString &opNameSuffix, bool addrImm, const TCEString &dataType, bool writePredicatedVersions)
TDGen::writeHWLoopDef
void writeHWLoopDef(std::ostream &o)
Definition: TDGen.cc:3571
TDGen::vshuffle2Operations_
std::map< TCEString, TCEString > vshuffle2Operations_
Contains machine's VSHUFFLE2 instructions (<ValueType, InstrName>).
Definition: TDGen.hh:542
TDGen::writeBooleanStorePatterns
void writeBooleanStorePatterns(std::ostream &os)
Definition: TDGen.cc:4527
TDGenerator::RegisterInfo::regIndex_
unsigned regIndex_
Register index in the register file.
Definition: TDGen.hh:658
TDGen::iorSameOperations_
std::map< TCEString, TCEString > iorSameOperations_
Contains machine's IORSAME instructions (<ValueType, InstrName>).
Definition: TDGen.hh:558
TDGen::checkRequiredRegisters
bool checkRequiredRegisters()
Definition: TDGen.cc:3280
TDGen::resRegNames_
std::vector< std::string > resRegNames_
Definition: TDGen.hh:591
TDGen::createConstantMaterializationQuery
void createConstantMaterializationQuery(std::ostream &os)
Definition: TDGen.cc:6427
TDGen::writeConstShiftPat
void writeConstShiftPat(std::ostream &os, const TCEString &nodeName, const TCEString &opNameBase, int i)
Definition: TDGen.cc:8503
TDGenerator::InstructionInfo::instrName_
TCEString instrName_
The instruction record name, e.g. "ADD32X4uuu".
Definition: TDGen.hh:673
TDGen::writeVectorRegisterClasses
void writeVectorRegisterClasses(std::ostream &o) const
Definition: TDGen.cc:2046
TDGen::OT_IMM_HFP
static const char OT_IMM_HFP
Definition: TDGen.hh:491
TDGen::OT_VREG_INT32
static const char OT_VREG_INT32
Definition: TDGen.hh:496
TDGenerator::RegisterClass::RegisterClass
RegisterClass(const ValueType &vt, const TCEString &name)
Definition: TDGen.cc:8939
TDGen::canBeImmediate
bool canBeImmediate(const OperationDAG &dag, const TerminalNode &node)
Definition: TDGen.cc:6049
TDGen::immediateStores_
std::map< TCEString, TDGenerator::InstructionInfo > immediateStores_
All immediate store operations (<ValueType, InstrInfo>).
Definition: TDGen.hh:527
TDGen::write64bitRegisterInfo
void write64bitRegisterInfo(std::ostream &o)
Definition: TDGen.cc:1307
Operand::OperandType
OperandType
Definition: Operand.hh:58
TDGenerator::RegisterClass::registerInfo
RegisterInfo registerInfo(int index) const
Definition: TDGen.cc:9010
TDGenerator::RegisterClass::valueType
ValueType valueType() const
Definition: TDGen.cc:8990
TDGen::requiredI32Regs_
unsigned int requiredI32Regs_
Minimum number of 32 bit registers.
Definition: TDGen.hh:615
Exception.hh
TDGen::RegInfo::operator<
bool operator<(const RegInfo &other) const
Definition: TDGen.hh:115
TDGen::immInfo_
ImmInfo * immInfo_
Definition: TDGen.hh:430
TDGen::OT_VREG_BOOL
static const char OT_VREG_BOOL
Definition: TDGen.hh:493
TDGen::writeVectorBitConversions
void writeVectorBitConversions(std::ostream &o) const
Definition: TDGen.cc:2362
TDGen::OT_IMM_INT
static const char OT_IMM_INT
Definition: TDGen.hh:489
TDGenerator::ValueType::SUPPORTED_LLVM_VALUE_TYPES
static const std::set< TCEString > SUPPORTED_LLVM_VALUE_TYPES
Contains all supported LLVM value types (<ValueType>).
Definition: TDGen.hh:715
TDGen::tceOperationPattern
std::string tceOperationPattern(const Operation &op)
Definition: TDGen.cc:5225
TDGenerator::RegisterClass::registers
std::vector< RegisterInfo > registers() const
TDGen::operationPattern
std::string operationPattern(const Operation &op, const OperationDAG &dag, const std::string &operandTypes)
Definition: TDGen.cc:5351
TDGen::createDefaultOperandTypeString
std::string createDefaultOperandTypeString(const Operation &op)
Definition: TDGen.cc:5369
TDGen::genGeneratedTCEPlugin_getVectorXorSameOpcode
void genGeneratedTCEPlugin_getVectorXorSameOpcode(std::ostream &o) const
TDGen::createByteExtLoadPatterns
void createByteExtLoadPatterns(std::ostream &os)
Definition: TDGen.cc:6457
TDGen::writeVectorRegisterNames
void writeVectorRegisterNames(std::ostream &o)
Definition: TDGen.cc:2014
TDGen::writeCallDef
void writeCallDef(std::ostream &o)
Definition: TDGen.cc:3899
TDGen::genGeneratedTCEPlugin_getVectorShrSameOpcode
void genGeneratedTCEPlugin_getVectorShrSameOpcode(std::ostream &o) const
TDGen::genGeneratedTCEPlugin_getIorOpcode
void genGeneratedTCEPlugin_getIorOpcode(std::ostream &o) const
Definition: TDGen.cc:3259
TDGenerator::ValueType::subwCount_
int subwCount_
Subword count of the value type.
Definition: TDGen.hh:710
TDGen::genGeneratedTCEPlugin_getVectorValueType
void genGeneratedTCEPlugin_getVectorValueType(std::ostream &o) const
TDGen::TerminalDef::registerDag
std::string registerDag
Definition: TDGen.hh:105
TDGen::regs16bit_
std::vector< RegInfo > regs16bit_
Definition: TDGen.hh:578
TDGen::highestLaneInt_
int highestLaneInt_
Definition: TDGen.hh:601
TDGen::associatedVectorRegisterClass
TCEString associatedVectorRegisterClass(const Operand &operand) const
Definition: TDGen.cc:1786
TDGenerator::RegisterClass::addRegisters
void addRegisters(const std::vector< RegisterInfo > &registers)
Definition: TDGen.cc:9033
TDGen::truePredOps_
std::map< std::string, std::string > truePredOps_
Definition: TDGen.hh:596
TDGen::subwordWidthOfRawData
int subwordWidthOfRawData(const Operation &op) const
Definition: TDGen.cc:1722
TDGen::BOOL_SUBW_WIDTH
static const int BOOL_SUBW_WIDTH
Bool type subword width.
Definition: TDGen.hh:469
TDGen::writeOperationDefs
void writeOperationDefs(std::ostream &o, Operation &op, bool skipPattern)
Definition: TDGen.cc:4271
TDGen::writeCallSeqStart
void writeCallSeqStart(std::ostream &os)
Definition: TDGen.cc:7870
TDGen::writeInstrInfo
void writeInstrInfo(std::ostream &o)
Definition: TDGen.cc:3328
TerminalNode
Definition: TerminalNode.hh:47
TDGen::writeVectorImmediateWriteDefs
void writeVectorImmediateWriteDefs(std::ostream &instrInfoTD)
Definition: TDGen.cc:3160
TDGen::analyzeMachineRegisters
void analyzeMachineRegisters()
Definition: TDGen.cc:1422
TDGenerator::RegisterClass::name
TCEString name() const
Definition: TDGen.cc:8980
TDGen::falsePredOps_
std::map< std::string, std::string > falsePredOps_
Definition: TDGen.hh:597
TDGen::RegClassMap
std::map< std::string, std::vector< std::string > > RegClassMap
Definition: TDGen.hh:628
TDGen::argRegCount_
unsigned int argRegCount_
Definition: TDGen.hh:613
TDGen::createVectorRVDRegNums
virtual void createVectorRVDRegNums(std::ostream &os)
Definition: TDGen.cc:6948
TDGen::scalarOps_
std::map< TCEString, Operation * > scalarOps_
Contains all scalar operations (<Name, Operation>).
Definition: TDGen.hh:508
TDGen::genGeneratedTCEPlugin_getVectorSelectOpcode
void genGeneratedTCEPlugin_getVectorSelectOpcode(std::ostream &o) const
TDGenerator::RegisterInfo
Definition: TDGen.hh:644
TDGen::llvmOperationPattern
virtual TCEString llvmOperationPattern(const Operation &op, char operandType=' ') const
Definition: TDGen.cc:4854
TDGen::OT_REG_BOOL
static const char OT_REG_BOOL
Definition: TDGen.hh:482
TDGen::supportedStackAccessOperations
static std::vector< std::string > supportedStackAccessOperations(const TTAMachine::Machine &mach)
Definition: TDGen.cc:7611
TDGen::OT_VREG_HFP
static const char OT_VREG_HFP
Definition: TDGen.hh:498
TDGen::genGeneratedTCEPlugin_getVectorShuffle1Opcode
void genGeneratedTCEPlugin_getVectorShuffle1Opcode(std::ostream &o) const
TDGen::write32bitRegisterInfo
void write32bitRegisterInfo(std::ostream &o)
Definition: TDGen.cc:965
TDGen::genGeneratedTCEPlugin_getVectorShlSameOpcode
void genGeneratedTCEPlugin_getVectorShlSameOpcode(std::ostream &o) const
TDGen::ONLY_EXTRAS
@ ONLY_EXTRAS
Definition: TDGen.hh:128
OperationNode
Definition: OperationNode.hh:47
TDGen::orderEqualWidthRegistersToRoundRobin
void orderEqualWidthRegistersToRoundRobin()
Definition: TDGen.cc:1618
TDGen::guardedRegs_
std::set< RegInfo > guardedRegs_
List of register that are associated with a guard on a bus.
Definition: TDGen.hh:621
TDGen::OT_REG_LONG
static const char OT_REG_LONG
Definition: TDGen.hh:484
TDGen::writeScalarToVectorDefs
void writeScalarToVectorDefs(std::ostream &o) const
Definition: TDGen.cc:2332
TDGen::writeVectorRegisterMoveDefs
void writeVectorRegisterMoveDefs(std::ostream &o)
Definition: TDGen.cc:2214
TDGen::writeVectorOperationDefs
void writeVectorOperationDefs(std::ostream &o, Operation &op, bool skipPattern)
Definition: TDGen.cc:2108
TDGen::xorSameOperations_
std::map< TCEString, TCEString > xorSameOperations_
Contains machine's XORSAME instructions (<ValueType, InstrName>).
Definition: TDGen.hh:560
TDGen::OT_VREG_INT8
static const char OT_VREG_INT8
Definition: TDGen.hh:494
MachinePart.hh
TDGen::genGeneratedTCEPlugin_getLoad
void genGeneratedTCEPlugin_getLoad(std::ostream &o) const
Definition: TDGen.cc:2883
TDGen::writeInstrDef
void writeInstrDef(std::ostream &o, const std::string &instrDefName, const std::string &outs, const std::string &ins, const std::string &asmString, const std::string &pattern)
Definition: TDGen.cc:4585
TDGen::writeVectorMemoryOperationDefs
void writeVectorMemoryOperationDefs(std::ostream &o, Operation &op, bool skipPattern)
Definition: TDGen.cc:2205
TDGen::write64bitMoveDefs
void write64bitMoveDefs(std::ostream &o)
Definition: TDGen.cc:8304
TDGen::regs8bit_
std::vector< RegInfo > regs8bit_
Definition: TDGen.hh:576
TDGen::RegInfo::idx
unsigned idx
Definition: TDGen.hh:112
TDGen
Definition: TDGen.hh:77
TDGen::vbcastOperations_
std::map< TCEString, TCEString > vbcastOperations_
Contains machine's VBCAST instructions (<ValueType, InstrName>).
Definition: TDGen.hh:534
TDGen::isVectorStoreOperation
bool isVectorStoreOperation(const Operation &op) const
Definition: TDGen.cc:1921
TDGen::shlOperations_
std::map< TCEString, TCEString > shlOperations_
Contains machine's shl instructions (<ValueType, InstrName>).
Definition: TDGen.hh:566
TDGen::generateBackend
void generateBackend(std::string &path)
Definition: TDGen.cc:388
TDGen::areImmediateOperandsLegal
bool areImmediateOperandsLegal(const Operation &operation, const std::string &operandTypes) const
Definition: TDGen.cc:7543
TDGen::isVectorLoadOperation
bool isVectorLoadOperation(const Operation &op) const
Definition: TDGen.cc:1909
TDGen::writeGetPointerAdjustmentQuery
void writeGetPointerAdjustmentQuery(std::ostream &os) const
Definition: TDGen.cc:7448
TDGen::genGeneratedTCEPlugin_getVectorShruSameOpcode
void genGeneratedTCEPlugin_getVectorShruSameOpcode(std::ostream &o) const
TDGenerator::RegisterClass::alignment_
int alignment_
RegisterClass alignment in bits, at least 8.
Definition: TDGen.hh:743
TDGenerator::ValueType
Definition: TDGen.hh:679
TDGen::allOpNames_
OperationDAGSelector::OperationSet allOpNames_
Contains all operation names in upper case.
Definition: TDGen.hh:505
TDGen::TerminalDef::registerPat
std::string registerPat
Definition: TDGen.hh:104
TCEString.hh
TDGen::OT_VREG_INT16
static const char OT_VREG_INT16
Definition: TDGen.hh:495
TDGenerator::ValueType::valueType
static ValueType valueType(const TCEString &vtStr)
Definition: TDGen.cc:8817
ImmInfo.hh
TDGen::writeBroadcastDefs
void writeBroadcastDefs(std::ostream &o, Operation &op, int vectorLen)
TDGen::writeOperandDefs
void writeOperandDefs(std::ostream &o)
Definition: TDGen.cc:566
TDGen::hasRegisterClassSupport
bool hasRegisterClassSupport(const Operation &op) const
Definition: TDGen.cc:1749
TDGen::ONLY_NORMAL
@ ONLY_NORMAL
Definition: TDGen.hh:130
TDGen::writeVectorLoadDefs
void writeVectorLoadDefs(std::ostream &o, const TCEString &opName, const TCEString &opNameSuffix, bool addrImm, const TCEString &resultType, const TCEString &loadPatternName, bool writePredicatedVersions)
TDGen::ARGUMENT
@ ARGUMENT
Definition: TDGen.hh:99
TDGen::writeVectorAnyextPattern
void writeVectorAnyextPattern(std::ostream &o, Operation &op, const TCEString &loadPatternName, int vectorLen)
TDGen::hasConditionalMoves_
bool hasConditionalMoves_
Definition: TDGen.hh:608
TDGen::genGeneratedTCEPlugin_getVectorIorSameOpcode
void genGeneratedTCEPlugin_getVectorIorSameOpcode(std::ostream &o) const
TDGen::genTCETargetLoweringSIMD_addVectorRegisterClasses
void genTCETargetLoweringSIMD_addVectorRegisterClasses(std::ostream &o) const
Definition: TDGen.cc:2997
TDGen::createTrivialDAG
OperationDAG * createTrivialDAG(Operation &op)
Definition: TDGen.cc:6019
TDGen::vRegClasses_
std::map< TCEString, TDGenerator::RegisterClass > vRegClasses_
Contains required vector register classes (<ValueType, RegClass>).
Definition: TDGen.hh:520
TDGen::writeStartOfRegisterInfo
void writeStartOfRegisterInfo(std::ostream &o)
Definition: TDGen.cc:539
TDGen::writeTopLevelTD
void writeTopLevelTD(std::ostream &o)
Definition: TDGen.cc:4190
TDGen::registerStores_
std::map< TCEString, TDGenerator::InstructionInfo > registerStores_
All register store operations (<ValueType, InstrInfo>).
Definition: TDGen.hh:523
TDGenerator::ValueType::vectorTypesOfSubwordWidth
static std::vector< ValueType > vectorTypesOfSubwordWidth(int subwordWidth, bool onlyInt=false)
Definition: TDGen.cc:8903
TDGen::dregNum_
unsigned dregNum_
Definition: TDGen.hh:462
TDGen::writeCallingConvLicenceText
void writeCallingConvLicenceText(std::ostream &os)
Definition: TDGen.cc:6901
TDGen::TerminalDef::immDag
std::string immDag
Definition: TDGen.hh:107
TDGen::createMinMaxGenerator
virtual void createMinMaxGenerator(std::ostream &os)
Definition: TDGen.cc:6324
TDGen::immediateLoads_
std::map< TCEString, TDGenerator::InstructionInfo > immediateLoads_
All immediate load operations (<ValueType, InstrInfo>).
Definition: TDGen.hh:529
TDGen::tempRegFiles_
std::set< const TTAMachine::RegisterFile *, TTAMachine::MachinePart::Comparator > tempRegFiles_
Register files whose last reg reserved for temp reg copies.
Definition: TDGen.hh:626
TDGenerator::RegisterClass::alignment
int alignment() const
Definition: TDGen.cc:9000
TDGen::immediatePredicate
std::string immediatePredicate(int64_t lowerBoundInclusive, uint64_t upperBoundInclusive)
Definition: TDGen.cc:7486
TDGen::writeIntegerImmediateDefs
void writeIntegerImmediateDefs(std::ostream &o, const ImmInfo &iivis)
Definition: TDGen.cc:594
TDGen::regsInRFClasses_
RegClassMap regsInRFClasses_
Definition: TDGen.hh:632
TDGen::getLLVMPatternWithConstants
TCEString getLLVMPatternWithConstants(const Operation &op, const std::string &operandTypes, const std::string &operand0, const std::string &operand1) const
Definition: TDGen.cc:7682
TDGen::hasExBoolRegs_
bool hasExBoolRegs_
Definition: TDGen.hh:604
TDGen::extractElemOperations_
std::map< TCEString, TCEString > extractElemOperations_
Contains machine's EXTRACTELEM instructions (<ValueType, InstrName>).
Definition: TDGen.hh:548
TDGen::addOperations_
std::map< TCEString, TCEString > addOperations_
Contains machine's add instructions (<ValueType, InstrName>).
Definition: TDGen.hh:564
TDGen::hasSelect_
bool hasSelect_
Definition: TDGen.hh:606
TDGen::analyzeRegisterFileClasses
void analyzeRegisterFileClasses()
TDGen::writeAddressingModeDefs
void writeAddressingModeDefs(std::ostream &o)
Definition: TDGen.cc:8345
OperationDAGNode
Definition: OperationDAGNode.hh:45
TDGen::operationNodeToString
std::string operationNodeToString(const Operation &op, const OperationDAG &dag, const OperationNode &node, bool emulationPattern, const std::string &operandTypes)
Definition: TDGen.cc:5711
TDGenerator::ValueType::operator=
ValueType & operator=(const ValueType &other)
Definition: TDGen.cc:8675
TDGen::genGeneratedTCEPlugin_getVectorPackOpcode
void genGeneratedTCEPlugin_getVectorPackOpcode(std::ostream &o) const
TDGenerator::ValueType::subwordWidth
int subwordWidth() const
Definition: TDGen.cc:8712
TDGen::saveAdditionalVectorOperationInfo
void saveAdditionalVectorOperationInfo(const Operation &op, const TCEString &valueTypes, bool isRegisterOp)
Definition: TDGen.cc:2190
TDGenerator::ValueType::subwWidth_
int subwWidth_
Subword width of the value type.
Definition: TDGen.hh:708
TDGen::writeGuardRegisterClassInfo
void writeGuardRegisterClassInfo(std::ostream &o)
Definition: TDGen.cc:1952
TDGen::TerminalDef
Definition: TDGen.hh:103
TDGenerator::InstructionInfo::osalOpName_
TCEString osalOpName_
The OSAL operation used to create the record, e.g. "ADD32X4".
Definition: TDGen.hh:671
TDGen::highestLaneBool_
int highestLaneBool_
Definition: TDGen.hh:602
TDGen::canBePredicated
bool canBePredicated(Operation &op, const std::string &operandTypes)
Definition: TDGen.cc:7591
TDGen::writeVectorLoadStoreOperationExploitations
void writeVectorLoadStoreOperationExploitations(std::ostream &o)
Definition: TDGen.cc:2648
TDGen::isWrongEndianessVectorOp
bool isWrongEndianessVectorOp(const Operation &op) const
Definition: TDGen.cc:1927
TDGen::operandToString
virtual std::string operandToString(const Operand &operand, bool match, char operandType, const std::string &immDefName="")
Definition: TDGen.cc:5796
TDGen::writeOperationDef
void writeOperationDef(std::ostream &o, Operation &op, const std::string &operandTypes, const std::string &attrs, bool skipPattern, std::string backendPrefix="")
Definition: TDGen.cc:4608
TDGen::hasExIntRegs_
bool hasExIntRegs_
Definition: TDGen.hh:605
TDGen::FP_SUBW_WIDTH
static const int FP_SUBW_WIDTH
Float type subword width.
Definition: TDGen.hh:465
TDGen::baseClasses_
std::map< int, TCEString > baseClasses_
Contains vector base classes for register files (<Width, Name>).
Definition: TDGen.hh:514
TDGen::genTCERegisterInfo_setReservedVectorRegs
void genTCERegisterInfo_setReservedVectorRegs(std::ostream &os) const
Definition: TDGen.cc:4162
OperationDAG
Definition: OperationDAG.hh:43
TDGenerator::RegisterClass::registers_
std::vector< RegisterInfo > registers_
Register file registers that this RegisterClass uses.
Definition: TDGen.hh:745
TDGenerator::ValueType::width
int width() const
Definition: TDGen.cc:8702
TDGenerator::RegisterClass::operator=
RegisterClass & operator=(const RegisterClass &other)
Definition: TDGen.cc:8966
TDGen::writeArgRegsArray
void writeArgRegsArray(std::ostream &os)
Definition: TDGen.cc:6922
TDGen::vshuffle1Operations_
std::map< TCEString, TCEString > vshuffle1Operations_
Contains machine's VSHUFFLE1 instructions (<ValueType, InstrName>).
Definition: TDGen.hh:540
TDGen::subPattern
std::string subPattern(const Operation &op, const OperationDAG &dag)
Definition: TDGen.cc:5398
TDGen::OPERATION_PATTERNS_
static const std::map< TCEString, TCEString > OPERATION_PATTERNS_
Contains <BaseOpName, OpPattern> key-value pairs.
Definition: TDGen.hh:502
TDGen::gatherOperations_
std::map< TCEString, TCEString > gatherOperations_
Contains machine's GATHER instructions (<ValueType, InstrName>).
Definition: TDGen.hh:562
TDGen::genGeneratedTCEPlugin_getLoadOpcode
void genGeneratedTCEPlugin_getLoadOpcode(std::ostream &o) const
Definition: TDGen.cc:3215
TDGen::registers_
std::map< int, std::vector< TDGenerator::RegisterInfo > > registers_
Contains registers fit for being vector registers (<Width, Registers>).
Definition: TDGen.hh:517
TDGenerator::ValueType::isSupportedByLLVM
bool isSupportedByLLVM() const
Definition: TDGen.cc:8688
ConstantNode
Definition: ConstantNode.hh:43
TDGen::genGeneratedTCEPlugin_getStore
void genGeneratedTCEPlugin_getStore(std::ostream &o) const
Definition: TDGen.cc:2783
TDGen::mach_
const TTAMachine::Machine & mach_
Definition: TDGen.hh:459
TDGenerator::RegisterInfo::regName_
TCEString regName_
Register name in GenRegisterInfo.td, e.g. "KLUDGE_REGISTER".
Definition: TDGen.hh:654
TDGen::write8bitRegisterInfo
void write8bitRegisterInfo(std::ostream &o)
TDGen::writeOperationDefUsingGivenOperandTypes
void writeOperationDefUsingGivenOperandTypes(std::ostream &o, Operation &op, bool skipPattern, std::vector< TDGenerator::ValueType > inputs, std::vector< TDGenerator::ValueType > outputs, TCEString instrSuffix="")
Definition: TDGen.cc:1840
TDGen::shlSameOperations_
std::map< TCEString, TCEString > shlSameOperations_
Contains machine's SHLSAME instructions (<ValueType, InstrName>).
Definition: TDGen.hh:550
OperationDAGSelector.hh
TDGen::hasRawOperands
bool hasRawOperands(const Operation &op) const
Definition: TDGen.cc:1699
TDGen::opNames_
std::map< std::string, std::string > opNames_
Definition: TDGen.hh:594
TDGen::createBranchAnalysis
void createBranchAnalysis(std::ostream &os)
Definition: TDGen.cc:7896
TDGenerator::ValueType::isFloat_
bool isFloat_
If true, the value type is a floating point type.
Definition: TDGen.hh:712
TDGen::writeWiderVectorOperationExploitations
void writeWiderVectorOperationExploitations(std::ostream &o)
Definition: TDGen.cc:2775
TDGen::MAX_SCALAR_WIDTH
static const int MAX_SCALAR_WIDTH
Distincts wide vs scalar registers.
Definition: TDGen.hh:471
TDGenerator::ValueType::isFloat
bool isFloat() const
Definition: TDGen.cc:8732
TDGen::EXPLOIT_BIGGER_REGISTERS
static const bool EXPLOIT_BIGGER_REGISTERS
If set to true, smaller vector value types can be stored to larger register files,...
Definition: TDGen.hh:478
TDGen::guardRegTemplateName
static const std::string guardRegTemplateName
Definition: TDGen.hh:636
OperationDAGSelector::OperationSet
TCETools::CIStringSet OperationSet
Definition: OperationDAGSelector.hh:88
TDGen::writeRegisterDef
void writeRegisterDef(std::ostream &o, const RegInfo &reg, const std::string regName, const std::string regTemplate, const std::string aliases, RegType type)
Definition: TDGen.cc:448
TDGen::prebypassStackIndeces_
bool prebypassStackIndeces_
Definition: TDGen.hh:617
TDGen::RegInfo
Definition: TDGen.hh:110
TDGen::operandChar
virtual char operandChar(Operand &operand)
Definition: TDGen.cc:4714
TDGenerator::ValueType::ValueType
ValueType(int subwWidth, int subwCount, bool isFloat)
Definition: TDGen.cc:8628
TDGen::genGeneratedTCEPlugin_isVectorRegisterMove
void genGeneratedTCEPlugin_isVectorRegisterMove(std::ostream &o) const
TDGen::TDGen
TDGen(const TTAMachine::Machine &mach)
Definition: TDGen.cc:341
TDGen::writeImmediateDef
virtual void writeImmediateDef(std::ostream &o, const std::string &defName, const std::string &operandType, const std::string &predicate)
Definition: TDGen.cc:4569
Operation
Definition: Operation.hh:59
TDGen::regsInClasses_
RegClassMap regsInClasses_
All registers in certain group.
Definition: TDGen.hh:630
TDGen::regs32bit_
std::vector< RegInfo > regs32bit_
Definition: TDGen.hh:580
TDGen::HFP_SUBW_WIDTH
static const int HFP_SUBW_WIDTH
Half float type subword width.
Definition: TDGen.hh:467
TDGen::getMovePattern
TCEString getMovePattern(const char &opdType, const std::string &inputPattern) const
Definition: TDGen.cc:7835
TDGen::create32BitExtLoadPatterns
void create32BitExtLoadPatterns(std::ostream &os)
Definition: TDGen.cc:6734
TDGen::writeControlFlowInstrDefs
void writeControlFlowInstrDefs(std::ostream &os)
Definition: TDGen.cc:3560
TDGen::createGetMaxMemoryAlignment
void createGetMaxMemoryAlignment(std::ostream &os) const
Definition: TDGen.cc:6974
TDGen::writeRARegisterInfo
void writeRARegisterInfo(std::ostream &o)
Definition: TDGen.cc:3101
TDGen::genGeneratedTCEPlugin_getVectorAndSameOpcode
void genGeneratedTCEPlugin_getVectorAndSameOpcode(std::ostream &o) const
TDGen::writeRegisterInfo
bool writeRegisterInfo(std::ostream &o)
Definition: TDGen.cc:496
TDGen::writePatternReplacement
void writePatternReplacement(std::ostream &o, const TCEString &origPat, const TCEString &replacerPat) const
Definition: TDGen.cc:1819
TDGen::createMinMaxDef
void createMinMaxDef(const TCEString &opName, const TCEString &valueName, std::ostream &os)
Definition: TDGen.cc:6296
Operand.hh
TDGen::vectorOps_
std::map< TCEString, Operation * > vectorOps_
Contains all vector operations (<Name, Operation>).
Definition: TDGen.hh:511
TDGen::analyzeRegisters
void analyzeRegisters()
Definition: TDGen.cc:783
TDGen::OT_IMM_LONG
static const char OT_IMM_LONG
Definition: TDGen.hh:492
TDGen::writeVectorRegisterBaseClasses
void writeVectorRegisterBaseClasses(std::ostream &o) const
Definition: TDGen.cc:1991
TDGen::writeCallingConv
void writeCallingConv(std::ostream &os)
Definition: TDGen.cc:6796
TDGenerator::InstructionInfo::InstructionInfo
InstructionInfo(const TCEString &osalOpName, const TCEString &instrName)
Definition: TDGen.hh:667
TDGen::writeVectorTruncStoreDefs
void writeVectorTruncStoreDefs(std::ostream &o) const
Definition: TDGen.cc:2262
TDGen::analyzeMachineVectorRegisterClasses
void analyzeMachineVectorRegisterClasses()
Definition: TDGen.cc:1226
TDGen::RegInfo::rf
std::string rf
Definition: TDGen.hh:111
TDGen::verbose
void verbose(const TCEString &msg) const
Definition: TDGen.cc:1806
TDGen::shrSameOperations_
std::map< TCEString, TCEString > shrSameOperations_
Contains machine's SHRSAME instructions (<ValueType, InstrName>).
Definition: TDGen.hh:552
TDGen::~TDGen
virtual ~TDGen()
Definition: TDGen.cc:379
TDGen::OT_REG_DOUBLE
static const char OT_REG_DOUBLE
Definition: TDGen.hh:487
TDGen::writeBackendCode
void writeBackendCode(std::ostream &o)
Definition: TDGen.cc:3941
TDGen::ONLY_LANES
@ ONLY_LANES
Definition: TDGen.hh:129
TDGen::writeCondBranchDefs
void writeCondBranchDefs(std::ostream &os)
Definition: TDGen.cc:3605
TDGen::writeMoveImmediateDefs
void writeMoveImmediateDefs(std::ostream &o)
Definition: TDGen.cc:701
TDGen::immediateOperandNameForEmulatedOperation
std::string immediateOperandNameForEmulatedOperation(const OperationDAG &, const Operand &operand)
Definition: TDGen.cc:7510
TDGen::OT_VREG_FP
static const char OT_VREG_FP
Definition: TDGen.hh:497
TDGen::writeVectorOperationDef
void writeVectorOperationDef(std::ostream &o, Operation &op, TCEString valueTypes, const TCEString &attributes, bool skipPattern)
Definition: TDGen.cc:2125
TDGen::writeRegisterClasses
void writeRegisterClasses(std::ostream &o)
Definition: TDGen.cc:761
TDGen::createConstantMaterializationPatterns
virtual void createConstantMaterializationPatterns(std::ostream &os)
Definition: TDGen.cc:7384
TDGen::regs1bit_
std::vector< RegInfo > regs1bit_
Definition: TDGen.hh:574
TDGen::regs_
std::map< std::string, RegInfo > regs_
Map of generated llvm register names to physical register in the machine.
Definition: TDGen.hh:588
TDGen::dagNodeToString
std::string dagNodeToString(const Operation &op, const OperationDAG &dag, const OperationDAGNode &node, bool emulationPattern, const std::string &operandTypes, const Operation *emulatingOp=nullptr, const OperationDAGNode *successor=nullptr)
Definition: TDGen.cc:5436
TDGen::maxVectorSize_
int maxVectorSize_
Definition: TDGen.hh:599
TDGenerator::RegisterClass::vt_
ValueType vt_
Value type that is supported by this RegisterClass, e.g. v4i32.
Definition: TDGen.hh:741
TDGenerator::RegisterClass::numberOfRegisters
size_t numberOfRegisters() const
Definition: TDGen.cc:9023
TDGen::packOperations_
std::map< TCEString, TCEString > packOperations_
Contains machine's PACK instructions (<ValueType, InstrName>).
Definition: TDGen.hh:532
TCEString
Definition: TCEString.hh:53
TDGenerator::ValueType::vectorTypesOfWidth
static std::vector< ValueType > vectorTypesOfWidth(int width, bool onlyInts=false)
Definition: TDGen.cc:8867
TDGenerator::InstructionInfo
Definition: TDGen.hh:666
TDGen::andSameOperations_
std::map< TCEString, TCEString > andSameOperations_
Contains machine's ANDSAME instructions (<ValueType, InstrName>).
Definition: TDGen.hh:556
TDGen::isVectorBitwiseOperation
bool isVectorBitwiseOperation(const Operation &op) const
Definition: TDGen.cc:1939
TDGen::genGeneratedTCEPlugin_getShlOpcode
void genGeneratedTCEPlugin_getShlOpcode(std::ostream &o) const
Definition: TDGen.cc:3244
TDGen::RegType
RegType
Definition: TDGen.hh:96
TDGen::patOutputs
std::string patOutputs(const Operation &op, const std::string &oprTypes)
Definition: TDGen.cc:6000
TDGen::writeInstrFormats
void writeInstrFormats(std::ostream &o)
Definition: TDGen.cc:4214
TDGen::createVectorMinMaxDef
void createVectorMinMaxDef(const TCEString &opName, int bits, char llvmTypeChar, const TCEString &postFix, std::ostream &os)
Definition: TDGen.cc:6306
TDGen::writeCallDefRegs
virtual void writeCallDefRegs(std::ostream &o)
Definition: TDGen.cc:3524
TDGenerator::ValueType::subwordCount
int subwordCount() const
Definition: TDGen.cc:8722
TDGen::shruSameOperations_
std::map< TCEString, TCEString > shruSameOperations_
Contains machine's SHRUSAME instructions (<ValueType, InstrName>).
Definition: TDGen.hh:554
TDGen::RESERVED
@ RESERVED
Definition: TDGen.hh:98
TDGen::gatherAllMachineOperations
void gatherAllMachineOperations()
Definition: TDGen.cc:941
TDGen::createShortExtLoadPatterns
void createShortExtLoadPatterns(std::ostream &os)
Definition: TDGen.cc:6617
TDGen::constantNodeString
std::string constantNodeString(const Operation &op, const OperationDAG &dag, const ConstantNode &node, const std::string &operandTypes, const OperationDAGNode *successor=nullptr)
Definition: TDGen.cc:5541
TDGen::constantMaterializationPredicates_
std::vector< std::string > constantMaterializationPredicates_
All predicates used in constant materialization patterns.
Definition: TDGen.hh:634
TDGen::genGeneratedTCEPlugin_getGatherOpcode
void genGeneratedTCEPlugin_getGatherOpcode(std::ostream &o) const
Definition: TDGen.cc:3199
TDGen::writeScalarOperationExploitations
void writeScalarOperationExploitations(std::ostream &o)
Definition: TDGen.cc:2419
TDGen::registerLoads_
std::map< TCEString, TDGenerator::InstructionInfo > registerLoads_
All register load operations (<ValueType, InstrInfo>).
Definition: TDGen.hh:525
TDGen::argRegNames_
std::vector< std::string > argRegNames_
Definition: TDGen.hh:590
TDGen::genGeneratedTCEPlugin_getVectorBroadcastOpcode
void genGeneratedTCEPlugin_getVectorBroadcastOpcode(std::ostream &o) const
TDGen::patInputs
std::string patInputs(const Operation &op, const std::string &oprTypes)
Definition: TDGen.cc:5969
TDGen::operationDAGCanBeMatched
bool operationDAGCanBeMatched(const OperationDAG &op, std::set< std::string > *recursionCycleCheck=NULL, bool recursionHasStore=false)
Definition: TDGen.cc:5274
TDGen::iorOperations_
std::map< TCEString, TCEString > iorOperations_
Contains machine's shl instructions (<ValueType, InstrName>).
Definition: TDGen.hh:568
TTAMachine::RegisterFile
Definition: RegisterFile.hh:47
TDGen::createParamDRegNums
void createParamDRegNums(std::ostream &os)
Definition: TDGen.cc:6936
TDGenerator::ValueType::isVector
bool isVector() const
Definition: TDGen.cc:8742
TDGenerator::ValueType::valueTypeStr
TCEString valueTypeStr() const
Definition: TDGen.cc:8772
TDGen::genGeneratedTCEPlugin_getVectorImmediateOpcode
void genGeneratedTCEPlugin_getVectorImmediateOpcode(std::ostream &o) const
Definition: TDGen.cc:3179
TDGen::TerminalDef::immPat
std::string immPat
Definition: TDGen.hh:106
TDGen::writeVectorBitwiseOperationDefs
void writeVectorBitwiseOperationDefs(std::ostream &o, Operation &op, bool skipPattern)
Definition: TDGen.cc:2601
TDGen::truncOperations_
std::vector< std::pair< const Operation *, TCEString > > truncOperations_
Contains machine's TRUNCxx/CFH instructions (<ValueType, InstrName>).
Definition: TDGen.hh:536
TDGen::llvmGuardRegs_
std::vector< std::string > llvmGuardRegs_
The LLVM register defs used as guards.
Definition: TDGen.hh:584
TDGen::createBoolAndHalfLoadPatterns
void createBoolAndHalfLoadPatterns(std::ostream &os)
Definition: TDGen.cc:8534
TDGen::emulatingOpNodeLLVMName
std::string emulatingOpNodeLLVMName(const Operation &op, const OperationDAG &dag, const OperationNode &node, const std::string &operandTypes)
Definition: TDGen.cc:5600
TDGen::operandTypeToRegister
char operandTypeToRegister(const char &opdType) const
Definition: TDGen.cc:7820
TDGen::immOperandDefs_
std::map< ImmInfoKey, std::string > immOperandDefs_
Maps (operation, operand) pairs to i32 immediate operand definition names.
Definition: TDGen.hh:433
TDGen::associateRegistersWithVectorRegisterClasses
void associateRegistersWithVectorRegisterClasses()
Definition: TDGen.cc:1653
TDGenerator::ValueType::operandType
Operand::OperandType operandType() const
Definition: TDGen.cc:8752
TTAMachine
Definition: Assembler.hh:48
TDGen::writeMiscPatterns
void writeMiscPatterns(std::ostream &o)
Definition: TDGen.cc:8391
TDGen::operationCanBeMatched
bool operationCanBeMatched(const Operation &op, std::set< std::string > *recursionCycleCheck=NULL, bool recursionHasStore=false)
Definition: TDGen.cc:5240
TDGenerator::RegisterInfo::RegisterInfo
RegisterInfo(const TCEString &regName, const TCEString &regFileName, unsigned regIndex, unsigned regWidth)
Definition: TDGen.hh:645
TDGen::createConstShiftPatterns
void createConstShiftPatterns(std::ostream &os)
Definition: TDGen.cc:8525
TDGen::vcshuffleOperations_
std::map< std::pair< TCEString, std::vector< int > >, TCEString > vcshuffleOperations_
Contains machine's VCSHUFFLE instructions (<<ValueType, ConstantSelects>, InstrName>).
Definition: TDGen.hh:546
TTAMachine::MachinePart::Comparator
Definition: MachinePart.hh:59
TDGen::genTCEInstrInfoSIMD_copyPhysVectorReg
void genTCEInstrInfoSIMD_copyPhysVectorReg(std::ostream &o) const
Definition: TDGen.cc:3131
TDGen::llvmOperationName
virtual TCEString llvmOperationName(const TCEString &opName) const
Definition: TDGen.cc:5068
ImmInfo
Definition: ImmInfo.hh:82
TDGen::GPR
@ GPR
Definition: TDGen.hh:97
TDGen::writeEmulationPattern
void writeEmulationPattern(std::ostream &o, const Operation &op, const OperationDAG &dag)
Definition: TDGen.cc:4759
TDGen::write1bitRegisterInfo
void write1bitRegisterInfo(std::ostream &o)
Definition: TDGen.cc:905
TDGen::ALL_REGISTERS
@ ALL_REGISTERS
Definition: TDGen.hh:127
TDGen::genTCEInstrInfo_copyPhys64bitReg
void genTCEInstrInfo_copyPhys64bitReg(std::ostream &o) const
Definition: TDGen.cc:8322
TDGenerator::RegisterClass::name_
TCEString name_
RegisterClass name.
Definition: TDGen.hh:739
TDGen::movOperations_
std::set< TCEString > movOperations_
Contains all moves between register classes (<InstrName>).
Definition: TDGen.hh:571
TDGen::genGeneratedTCEPlugin_getAddOpcode
void genGeneratedTCEPlugin_getAddOpcode(std::ostream &o) const
Definition: TDGen.cc:3229
TDGen::regs64bit_
std::vector< RegInfo > regs64bit_
Definition: TDGen.hh:582
TDGen::generateLoadStoreCopyGenerator
void generateLoadStoreCopyGenerator(std::ostream &os)
Definition: TDGen.cc:6291
TDGen::createSelectPatterns
virtual void createSelectPatterns(std::ostream &os)
Definition: TDGen.cc:6991
TDGen::operandTypesToRegisters
std::string operandTypesToRegisters(const std::string &opdTypes) const
Definition: TDGen.cc:7811
TDGen::vselectOperations_
std::map< TCEString, TCEString > vselectOperations_
Contains machine's VSELECT instructions (<instrName, ValueType>).
Definition: TDGen.hh:538
TTAMachine::Machine
Definition: Machine.hh:73
TDGen::OT_IMM_BOOL
static const char OT_IMM_BOOL
Definition: TDGen.hh:488
TDGen::littleEndian_
bool littleEndian_
Definition: TDGen.hh:612
TDGen::use64bitForFP_
bool use64bitForFP_
Definition: TDGen.hh:618
TDGen::OT_IMM_FP
static const char OT_IMM_FP
Definition: TDGen.hh:490
TDGen::genGeneratedTCEPlugin_getConstantVectorShuffleOpcode
void genGeneratedTCEPlugin_getConstantVectorShuffleOpcode(std::ostream &o) const
TDGen::MAX_SUBW_COUNT
static const int MAX_SUBW_COUNT
Maximum number of subwords that any SIMD operation can have.
Definition: TDGen.hh:473
TDGen::OT_REG_HFP
static const char OT_REG_HFP
Definition: TDGen.hh:486
TDGen::genTCETargetLoweringSIMD_getSetCCResultVT
void genTCETargetLoweringSIMD_getSetCCResultVT(std::ostream &o) const
Definition: TDGen.cc:3072
TDGenerator
Definition: TDGen.hh:63