Target.td 71 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743
  1. //===- Target.td - Target Independent TableGen interface ---*- tablegen -*-===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file defines the target-independent interfaces which should be
  10. // implemented by each target which is using a TableGen based code generator.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. // Include all information about LLVM intrinsics.
  14. include "llvm/IR/Intrinsics.td"
  15. //===----------------------------------------------------------------------===//
  16. // Register file description - These classes are used to fill in the target
  17. // description classes.
  18. class HwMode<string FS> {
  19. // A string representing subtarget features that turn on this HW mode.
  20. // For example, "+feat1,-feat2" will indicate that the mode is active
  21. // when "feat1" is enabled and "feat2" is disabled at the same time.
  22. // Any other features are not checked.
  23. // When multiple modes are used, they should be mutually exclusive,
  24. // otherwise the results are unpredictable.
  25. string Features = FS;
  26. }
  27. // A special mode recognized by tablegen. This mode is considered active
  28. // when no other mode is active. For targets that do not use specific hw
  29. // modes, this is the only mode.
  30. def DefaultMode : HwMode<"">;
  31. // A class used to associate objects with HW modes. It is only intended to
  32. // be used as a base class, where the derived class should contain a member
  33. // "Objects", which is a list of the same length as the list of modes.
  34. // The n-th element on the Objects list will be associated with the n-th
  35. // element on the Modes list.
  36. class HwModeSelect<list<HwMode> Ms> {
  37. list<HwMode> Modes = Ms;
  38. }
  39. // A common class that implements a counterpart of ValueType, which is
  40. // dependent on a HW mode. This class inherits from ValueType itself,
  41. // which makes it possible to use objects of this class where ValueType
  42. // objects could be used. This is specifically applicable to selection
  43. // patterns.
  44. class ValueTypeByHwMode<list<HwMode> Ms, list<ValueType> Ts>
  45. : HwModeSelect<Ms>, ValueType<0, 0> {
  46. // The length of this list must be the same as the length of Ms.
  47. list<ValueType> Objects = Ts;
  48. }
  49. // A class representing the register size, spill size and spill alignment
  50. // in bits of a register.
  51. class RegInfo<int RS, int SS, int SA> {
  52. int RegSize = RS; // Register size in bits.
  53. int SpillSize = SS; // Spill slot size in bits.
  54. int SpillAlignment = SA; // Spill slot alignment in bits.
  55. }
  56. // The register size/alignment information, parameterized by a HW mode.
  57. class RegInfoByHwMode<list<HwMode> Ms = [], list<RegInfo> Ts = []>
  58. : HwModeSelect<Ms> {
  59. // The length of this list must be the same as the length of Ms.
  60. list<RegInfo> Objects = Ts;
  61. }
  62. // SubRegIndex - Use instances of SubRegIndex to identify subregisters.
  63. class SubRegIndex<int size, int offset = 0> {
  64. string Namespace = "";
  65. // Size - Size (in bits) of the sub-registers represented by this index.
  66. int Size = size;
  67. // Offset - Offset of the first bit that is part of this sub-register index.
  68. // Set it to -1 if the same index is used to represent sub-registers that can
  69. // be at different offsets (for example when using an index to access an
  70. // element in a register tuple).
  71. int Offset = offset;
  72. // ComposedOf - A list of two SubRegIndex instances, [A, B].
  73. // This indicates that this SubRegIndex is the result of composing A and B.
  74. // See ComposedSubRegIndex.
  75. list<SubRegIndex> ComposedOf = [];
  76. // CoveringSubRegIndices - A list of two or more sub-register indexes that
  77. // cover this sub-register.
  78. //
  79. // This field should normally be left blank as TableGen can infer it.
  80. //
  81. // TableGen automatically detects sub-registers that straddle the registers
  82. // in the SubRegs field of a Register definition. For example:
  83. //
  84. // Q0 = dsub_0 -> D0, dsub_1 -> D1
  85. // Q1 = dsub_0 -> D2, dsub_1 -> D3
  86. // D1_D2 = dsub_0 -> D1, dsub_1 -> D2
  87. // QQ0 = qsub_0 -> Q0, qsub_1 -> Q1
  88. //
  89. // TableGen will infer that D1_D2 is a sub-register of QQ0. It will be given
  90. // the synthetic index dsub_1_dsub_2 unless some SubRegIndex is defined with
  91. // CoveringSubRegIndices = [dsub_1, dsub_2].
  92. list<SubRegIndex> CoveringSubRegIndices = [];
  93. }
  94. // ComposedSubRegIndex - A sub-register that is the result of composing A and B.
  95. // Offset is set to the sum of A and B's Offsets. Size is set to B's Size.
  96. class ComposedSubRegIndex<SubRegIndex A, SubRegIndex B>
  97. : SubRegIndex<B.Size, !cond(!eq(A.Offset, -1): -1,
  98. !eq(B.Offset, -1): -1,
  99. true: !add(A.Offset, B.Offset))> {
  100. // See SubRegIndex.
  101. let ComposedOf = [A, B];
  102. }
  103. // RegAltNameIndex - The alternate name set to use for register operands of
  104. // this register class when printing.
  105. class RegAltNameIndex {
  106. string Namespace = "";
  107. // A set to be used if the name for a register is not defined in this set.
  108. // This allows creating name sets with only a few alternative names.
  109. RegAltNameIndex FallbackRegAltNameIndex = ?;
  110. }
  111. def NoRegAltName : RegAltNameIndex;
  112. // Register - You should define one instance of this class for each register
  113. // in the target machine. String n will become the "name" of the register.
  114. class Register<string n, list<string> altNames = []> {
  115. string Namespace = "";
  116. string AsmName = n;
  117. list<string> AltNames = altNames;
  118. // Aliases - A list of registers that this register overlaps with. A read or
  119. // modification of this register can potentially read or modify the aliased
  120. // registers.
  121. list<Register> Aliases = [];
  122. // SubRegs - A list of registers that are parts of this register. Note these
  123. // are "immediate" sub-registers and the registers within the list do not
  124. // themselves overlap. e.g. For X86, EAX's SubRegs list contains only [AX],
  125. // not [AX, AH, AL].
  126. list<Register> SubRegs = [];
  127. // SubRegIndices - For each register in SubRegs, specify the SubRegIndex used
  128. // to address it. Sub-sub-register indices are automatically inherited from
  129. // SubRegs.
  130. list<SubRegIndex> SubRegIndices = [];
  131. // RegAltNameIndices - The alternate name indices which are valid for this
  132. // register.
  133. list<RegAltNameIndex> RegAltNameIndices = [];
  134. // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
  135. // These values can be determined by locating the <target>.h file in the
  136. // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
  137. // order of these names correspond to the enumeration used by gcc. A value of
  138. // -1 indicates that the gcc number is undefined and -2 that register number
  139. // is invalid for this mode/flavour.
  140. list<int> DwarfNumbers = [];
  141. // CostPerUse - Additional cost of instructions using this register compared
  142. // to other registers in its class. The register allocator will try to
  143. // minimize the number of instructions using a register with a CostPerUse.
  144. // This is used by the ARC target, by the ARM Thumb and x86-64 targets, where
  145. // some registers require larger instruction encodings, by the RISC-V target,
  146. // where some registers preclude using some C instructions. By making it a
  147. // list, targets can have multiple cost models associated with each register
  148. // and can choose one specific cost model per Machine Function by overriding
  149. // TargetRegisterInfo::getRegisterCostTableIndex. Every target register will
  150. // finally have an equal number of cost values which is the max of costPerUse
  151. // values specified. Any mismatch in the cost values for a register will be
  152. // filled with zeros. Restricted the cost type to uint8_t in the
  153. // generated table. It will considerably reduce the table size.
  154. list<int> CostPerUse = [0];
  155. // CoveredBySubRegs - When this bit is set, the value of this register is
  156. // completely determined by the value of its sub-registers. For example, the
  157. // x86 register AX is covered by its sub-registers AL and AH, but EAX is not
  158. // covered by its sub-register AX.
  159. bit CoveredBySubRegs = false;
  160. // HWEncoding - The target specific hardware encoding for this register.
  161. bits<16> HWEncoding = 0;
  162. bit isArtificial = false;
  163. }
  164. // RegisterWithSubRegs - This can be used to define instances of Register which
  165. // need to specify sub-registers.
  166. // List "subregs" specifies which registers are sub-registers to this one. This
  167. // is used to populate the SubRegs and AliasSet fields of TargetRegisterDesc.
  168. // This allows the code generator to be careful not to put two values with
  169. // overlapping live ranges into registers which alias.
  170. class RegisterWithSubRegs<string n, list<Register> subregs> : Register<n> {
  171. let SubRegs = subregs;
  172. }
  173. // DAGOperand - An empty base class that unifies RegisterClass's and other forms
  174. // of Operand's that are legal as type qualifiers in DAG patterns. This should
  175. // only ever be used for defining multiclasses that are polymorphic over both
  176. // RegisterClass's and other Operand's.
  177. class DAGOperand {
  178. string OperandNamespace = "MCOI";
  179. string DecoderMethod = "";
  180. }
  181. // RegisterClass - Now that all of the registers are defined, and aliases
  182. // between registers are defined, specify which registers belong to which
  183. // register classes. This also defines the default allocation order of
  184. // registers by register allocators.
  185. //
  186. class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,
  187. dag regList, RegAltNameIndex idx = NoRegAltName>
  188. : DAGOperand {
  189. string Namespace = namespace;
  190. // The register size/alignment information, parameterized by a HW mode.
  191. RegInfoByHwMode RegInfos;
  192. // RegType - Specify the list ValueType of the registers in this register
  193. // class. Note that all registers in a register class must have the same
  194. // ValueTypes. This is a list because some targets permit storing different
  195. // types in same register, for example vector values with 128-bit total size,
  196. // but different count/size of items, like SSE on x86.
  197. //
  198. list<ValueType> RegTypes = regTypes;
  199. // Size - Specify the spill size in bits of the registers. A default value of
  200. // zero lets tablegen pick an appropriate size.
  201. int Size = 0;
  202. // Alignment - Specify the alignment required of the registers when they are
  203. // stored or loaded to memory.
  204. //
  205. int Alignment = alignment;
  206. // CopyCost - This value is used to specify the cost of copying a value
  207. // between two registers in this register class. The default value is one
  208. // meaning it takes a single instruction to perform the copying. A negative
  209. // value means copying is extremely expensive or impossible.
  210. int CopyCost = 1;
  211. // MemberList - Specify which registers are in this class. If the
  212. // allocation_order_* method are not specified, this also defines the order of
  213. // allocation used by the register allocator.
  214. //
  215. dag MemberList = regList;
  216. // AltNameIndex - The alternate register name to use when printing operands
  217. // of this register class. Every register in the register class must have
  218. // a valid alternate name for the given index.
  219. RegAltNameIndex altNameIndex = idx;
  220. // isAllocatable - Specify that the register class can be used for virtual
  221. // registers and register allocation. Some register classes are only used to
  222. // model instruction operand constraints, and should have isAllocatable = 0.
  223. bit isAllocatable = true;
  224. // AltOrders - List of alternative allocation orders. The default order is
  225. // MemberList itself, and that is good enough for most targets since the
  226. // register allocators automatically remove reserved registers and move
  227. // callee-saved registers to the end.
  228. list<dag> AltOrders = [];
  229. // AltOrderSelect - The body of a function that selects the allocation order
  230. // to use in a given machine function. The code will be inserted in a
  231. // function like this:
  232. //
  233. // static inline unsigned f(const MachineFunction &MF) { ... }
  234. //
  235. // The function should return 0 to select the default order defined by
  236. // MemberList, 1 to select the first AltOrders entry and so on.
  237. code AltOrderSelect = [{}];
  238. // Specify allocation priority for register allocators using a greedy
  239. // heuristic. Classes with higher priority values are assigned first. This is
  240. // useful as it is sometimes beneficial to assign registers to highly
  241. // constrained classes first. The value has to be in the range [0,63].
  242. int AllocationPriority = 0;
  243. // Generate register pressure set for this register class and any class
  244. // synthesized from it. Set to 0 to inhibit unneeded pressure sets.
  245. bit GeneratePressureSet = true;
  246. // Weight override for register pressure calculation. This is the value
  247. // TargetRegisterClass::getRegClassWeight() will return. The weight is in
  248. // units of pressure for this register class. If unset tablegen will
  249. // calculate a weight based on a number of register units in this register
  250. // class registers. The weight is per register.
  251. int Weight = ?;
  252. // The diagnostic type to present when referencing this operand in a match
  253. // failure error message. If this is empty, the default Match_InvalidOperand
  254. // diagnostic type will be used. If this is "<name>", a Match_<name> enum
  255. // value will be generated and used for this operand type. The target
  256. // assembly parser is responsible for converting this into a user-facing
  257. // diagnostic message.
  258. string DiagnosticType = "";
  259. // A diagnostic message to emit when an invalid value is provided for this
  260. // register class when it is being used an an assembly operand. If this is
  261. // non-empty, an anonymous diagnostic type enum value will be generated, and
  262. // the assembly matcher will provide a function to map from diagnostic types
  263. // to message strings.
  264. string DiagnosticString = "";
  265. // Target-specific flags. This becomes the TSFlags field in TargetRegisterClass.
  266. bits<8> TSFlags = 0;
  267. }
  268. // The memberList in a RegisterClass is a dag of set operations. TableGen
  269. // evaluates these set operations and expand them into register lists. These
  270. // are the most common operation, see test/TableGen/SetTheory.td for more
  271. // examples of what is possible:
  272. //
  273. // (add R0, R1, R2) - Set Union. Each argument can be an individual register, a
  274. // register class, or a sub-expression. This is also the way to simply list
  275. // registers.
  276. //
  277. // (sub GPR, SP) - Set difference. Subtract the last arguments from the first.
  278. //
  279. // (and GPR, CSR) - Set intersection. All registers from the first set that are
  280. // also in the second set.
  281. //
  282. // (sequence "R%u", 0, 15) -> [R0, R1, ..., R15]. Generate a sequence of
  283. // numbered registers. Takes an optional 4th operand which is a stride to use
  284. // when generating the sequence.
  285. //
  286. // (shl GPR, 4) - Remove the first N elements.
  287. //
  288. // (trunc GPR, 4) - Truncate after the first N elements.
  289. //
  290. // (rotl GPR, 1) - Rotate N places to the left.
  291. //
  292. // (rotr GPR, 1) - Rotate N places to the right.
  293. //
  294. // (decimate GPR, 2) - Pick every N'th element, starting with the first.
  295. //
  296. // (interleave A, B, ...) - Interleave the elements from each argument list.
  297. //
  298. // All of these operators work on ordered sets, not lists. That means
  299. // duplicates are removed from sub-expressions.
  300. // Set operators. The rest is defined in TargetSelectionDAG.td.
  301. def sequence;
  302. def decimate;
  303. def interleave;
  304. // RegisterTuples - Automatically generate super-registers by forming tuples of
  305. // sub-registers. This is useful for modeling register sequence constraints
  306. // with pseudo-registers that are larger than the architectural registers.
  307. //
  308. // The sub-register lists are zipped together:
  309. //
  310. // def EvenOdd : RegisterTuples<[sube, subo], [(add R0, R2), (add R1, R3)]>;
  311. //
  312. // Generates the same registers as:
  313. //
  314. // let SubRegIndices = [sube, subo] in {
  315. // def R0_R1 : RegisterWithSubRegs<"", [R0, R1]>;
  316. // def R2_R3 : RegisterWithSubRegs<"", [R2, R3]>;
  317. // }
  318. //
  319. // The generated pseudo-registers inherit super-classes and fields from their
  320. // first sub-register. Most fields from the Register class are inferred, and
  321. // the AsmName and Dwarf numbers are cleared.
  322. //
  323. // RegisterTuples instances can be used in other set operations to form
  324. // register classes and so on. This is the only way of using the generated
  325. // registers.
  326. //
  327. // RegNames may be specified to supply asm names for the generated tuples.
  328. // If used must have the same size as the list of produced registers.
  329. class RegisterTuples<list<SubRegIndex> Indices, list<dag> Regs,
  330. list<string> RegNames = []> {
  331. // SubRegs - N lists of registers to be zipped up. Super-registers are
  332. // synthesized from the first element of each SubRegs list, the second
  333. // element and so on.
  334. list<dag> SubRegs = Regs;
  335. // SubRegIndices - N SubRegIndex instances. This provides the names of the
  336. // sub-registers in the synthesized super-registers.
  337. list<SubRegIndex> SubRegIndices = Indices;
  338. // List of asm names for the generated tuple registers.
  339. list<string> RegAsmNames = RegNames;
  340. }
  341. //===----------------------------------------------------------------------===//
  342. // DwarfRegNum - This class provides a mapping of the llvm register enumeration
  343. // to the register numbering used by gcc and gdb. These values are used by a
  344. // debug information writer to describe where values may be located during
  345. // execution.
  346. class DwarfRegNum<list<int> Numbers> {
  347. // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
  348. // These values can be determined by locating the <target>.h file in the
  349. // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
  350. // order of these names correspond to the enumeration used by gcc. A value of
  351. // -1 indicates that the gcc number is undefined and -2 that register number
  352. // is invalid for this mode/flavour.
  353. list<int> DwarfNumbers = Numbers;
  354. }
  355. // DwarfRegAlias - This class declares that a given register uses the same dwarf
  356. // numbers as another one. This is useful for making it clear that the two
  357. // registers do have the same number. It also lets us build a mapping
  358. // from dwarf register number to llvm register.
  359. class DwarfRegAlias<Register reg> {
  360. Register DwarfAlias = reg;
  361. }
  362. //===----------------------------------------------------------------------===//
  363. // Pull in the common support for MCPredicate (portable scheduling predicates).
  364. //
  365. include "llvm/Target/TargetInstrPredicate.td"
  366. //===----------------------------------------------------------------------===//
  367. // Pull in the common support for scheduling
  368. //
  369. include "llvm/Target/TargetSchedule.td"
  370. class Predicate; // Forward def
  371. class InstructionEncoding {
  372. // Size of encoded instruction.
  373. int Size;
  374. // The "namespace" in which this instruction exists, on targets like ARM
  375. // which multiple ISA namespaces exist.
  376. string DecoderNamespace = "";
  377. // List of predicates which will be turned into isel matching code.
  378. list<Predicate> Predicates = [];
  379. string DecoderMethod = "";
  380. // Is the instruction decoder method able to completely determine if the
  381. // given instruction is valid or not. If the TableGen definition of the
  382. // instruction specifies bitpattern A??B where A and B are static bits, the
  383. // hasCompleteDecoder flag says whether the decoder method fully handles the
  384. // ?? space, i.e. if it is a final arbiter for the instruction validity.
  385. // If not then the decoder attempts to continue decoding when the decoder
  386. // method fails.
  387. //
  388. // This allows to handle situations where the encoding is not fully
  389. // orthogonal. Example:
  390. // * InstA with bitpattern 0b0000????,
  391. // * InstB with bitpattern 0b000000?? but the associated decoder method
  392. // DecodeInstB() returns Fail when ?? is 0b00 or 0b11.
  393. //
  394. // The decoder tries to decode a bitpattern that matches both InstA and
  395. // InstB bitpatterns first as InstB (because it is the most specific
  396. // encoding). In the default case (hasCompleteDecoder = 1), when
  397. // DecodeInstB() returns Fail the bitpattern gets rejected. By setting
  398. // hasCompleteDecoder = 0 in InstB, the decoder is informed that
  399. // DecodeInstB() is not able to determine if all possible values of ?? are
  400. // valid or not. If DecodeInstB() returns Fail the decoder will attempt to
  401. // decode the bitpattern as InstA too.
  402. bit hasCompleteDecoder = true;
  403. }
  404. // Allows specifying an InstructionEncoding by HwMode. If an Instruction specifies
  405. // an EncodingByHwMode, its Inst and Size members are ignored and Ts are used
  406. // to encode and decode based on HwMode.
  407. class EncodingByHwMode<list<HwMode> Ms = [], list<InstructionEncoding> Ts = []>
  408. : HwModeSelect<Ms> {
  409. // The length of this list must be the same as the length of Ms.
  410. list<InstructionEncoding> Objects = Ts;
  411. }
  412. //===----------------------------------------------------------------------===//
  413. // Instruction set description - These classes correspond to the C++ classes in
  414. // the Target/TargetInstrInfo.h file.
  415. //
  416. class Instruction : InstructionEncoding {
  417. string Namespace = "";
  418. dag OutOperandList; // An dag containing the MI def operand list.
  419. dag InOperandList; // An dag containing the MI use operand list.
  420. string AsmString = ""; // The .s format to print the instruction with.
  421. // Allows specifying a canonical InstructionEncoding by HwMode. If non-empty,
  422. // the Inst member of this Instruction is ignored.
  423. EncodingByHwMode EncodingInfos;
  424. // Pattern - Set to the DAG pattern for this instruction, if we know of one,
  425. // otherwise, uninitialized.
  426. list<dag> Pattern;
  427. // The follow state will eventually be inferred automatically from the
  428. // instruction pattern.
  429. list<Register> Uses = []; // Default to using no non-operand registers
  430. list<Register> Defs = []; // Default to modifying no non-operand registers
  431. // Predicates - List of predicates which will be turned into isel matching
  432. // code.
  433. list<Predicate> Predicates = [];
  434. // Size - Size of encoded instruction, or zero if the size cannot be determined
  435. // from the opcode.
  436. int Size = 0;
  437. // Code size, for instruction selection.
  438. // FIXME: What does this actually mean?
  439. int CodeSize = 0;
  440. // Added complexity passed onto matching pattern.
  441. int AddedComplexity = 0;
  442. // Indicates if this is a pre-isel opcode that should be
  443. // legalized/regbankselected/selected.
  444. bit isPreISelOpcode = false;
  445. // These bits capture information about the high-level semantics of the
  446. // instruction.
  447. bit isReturn = false; // Is this instruction a return instruction?
  448. bit isBranch = false; // Is this instruction a branch instruction?
  449. bit isEHScopeReturn = false; // Does this instruction end an EH scope?
  450. bit isIndirectBranch = false; // Is this instruction an indirect branch?
  451. bit isCompare = false; // Is this instruction a comparison instruction?
  452. bit isMoveImm = false; // Is this instruction a move immediate instruction?
  453. bit isMoveReg = false; // Is this instruction a move register instruction?
  454. bit isBitcast = false; // Is this instruction a bitcast instruction?
  455. bit isSelect = false; // Is this instruction a select instruction?
  456. bit isBarrier = false; // Can control flow fall through this instruction?
  457. bit isCall = false; // Is this instruction a call instruction?
  458. bit isAdd = false; // Is this instruction an add instruction?
  459. bit isTrap = false; // Is this instruction a trap instruction?
  460. bit canFoldAsLoad = false; // Can this be folded as a simple memory operand?
  461. bit mayLoad = ?; // Is it possible for this inst to read memory?
  462. bit mayStore = ?; // Is it possible for this inst to write memory?
  463. bit mayRaiseFPException = false; // Can this raise a floating-point exception?
  464. bit isConvertibleToThreeAddress = false; // Can this 2-addr instruction promote?
  465. bit isCommutable = false; // Is this 3 operand instruction commutable?
  466. bit isTerminator = false; // Is this part of the terminator for a basic block?
  467. bit isReMaterializable = false; // Is this instruction re-materializable?
  468. bit isPredicable = false; // 1 means this instruction is predicable
  469. // even if it does not have any operand
  470. // tablegen can identify as a predicate
  471. bit isUnpredicable = false; // 1 means this instruction is not predicable
  472. // even if it _does_ have a predicate operand
  473. bit hasDelaySlot = false; // Does this instruction have an delay slot?
  474. bit usesCustomInserter = false; // Pseudo instr needing special help.
  475. bit hasPostISelHook = false; // To be *adjusted* after isel by target hook.
  476. bit hasCtrlDep = false; // Does this instruction r/w ctrl-flow chains?
  477. bit isNotDuplicable = false; // Is it unsafe to duplicate this instruction?
  478. bit isConvergent = false; // Is this instruction convergent?
  479. bit isAuthenticated = false; // Does this instruction authenticate a pointer?
  480. bit isAsCheapAsAMove = false; // As cheap (or cheaper) than a move instruction.
  481. bit hasExtraSrcRegAllocReq = false; // Sources have special regalloc requirement?
  482. bit hasExtraDefRegAllocReq = false; // Defs have special regalloc requirement?
  483. bit isRegSequence = false; // Is this instruction a kind of reg sequence?
  484. // If so, make sure to override
  485. // TargetInstrInfo::getRegSequenceLikeInputs.
  486. bit isPseudo = false; // Is this instruction a pseudo-instruction?
  487. // If so, won't have encoding information for
  488. // the [MC]CodeEmitter stuff.
  489. bit isExtractSubreg = false; // Is this instruction a kind of extract subreg?
  490. // If so, make sure to override
  491. // TargetInstrInfo::getExtractSubregLikeInputs.
  492. bit isInsertSubreg = false; // Is this instruction a kind of insert subreg?
  493. // If so, make sure to override
  494. // TargetInstrInfo::getInsertSubregLikeInputs.
  495. bit variadicOpsAreDefs = false; // Are variadic operands definitions?
  496. // Does the instruction have side effects that are not captured by any
  497. // operands of the instruction or other flags?
  498. bit hasSideEffects = ?;
  499. // Is this instruction a "real" instruction (with a distinct machine
  500. // encoding), or is it a pseudo instruction used for codegen modeling
  501. // purposes.
  502. // FIXME: For now this is distinct from isPseudo, above, as code-gen-only
  503. // instructions can (and often do) still have encoding information
  504. // associated with them. Once we've migrated all of them over to true
  505. // pseudo-instructions that are lowered to real instructions prior to
  506. // the printer/emitter, we can remove this attribute and just use isPseudo.
  507. //
  508. // The intended use is:
  509. // isPseudo: Does not have encoding information and should be expanded,
  510. // at the latest, during lowering to MCInst.
  511. //
  512. // isCodeGenOnly: Does have encoding information and can go through to the
  513. // CodeEmitter unchanged, but duplicates a canonical instruction
  514. // definition's encoding and should be ignored when constructing the
  515. // assembler match tables.
  516. bit isCodeGenOnly = false;
  517. // Is this instruction a pseudo instruction for use by the assembler parser.
  518. bit isAsmParserOnly = false;
  519. // This instruction is not expected to be queried for scheduling latencies
  520. // and therefore needs no scheduling information even for a complete
  521. // scheduling model.
  522. bit hasNoSchedulingInfo = false;
  523. InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling.
  524. // Scheduling information from TargetSchedule.td.
  525. list<SchedReadWrite> SchedRW;
  526. string Constraints = ""; // OperandConstraint, e.g. $src = $dst.
  527. /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not
  528. /// be encoded into the output machineinstr.
  529. string DisableEncoding = "";
  530. string PostEncoderMethod = "";
  531. /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
  532. bits<64> TSFlags = 0;
  533. ///@name Assembler Parser Support
  534. ///@{
  535. string AsmMatchConverter = "";
  536. /// TwoOperandAliasConstraint - Enable TableGen to auto-generate a
  537. /// two-operand matcher inst-alias for a three operand instruction.
  538. /// For example, the arm instruction "add r3, r3, r5" can be written
  539. /// as "add r3, r5". The constraint is of the same form as a tied-operand
  540. /// constraint. For example, "$Rn = $Rd".
  541. string TwoOperandAliasConstraint = "";
  542. /// Assembler variant name to use for this instruction. If specified then
  543. /// instruction will be presented only in MatchTable for this variant. If
  544. /// not specified then assembler variants will be determined based on
  545. /// AsmString
  546. string AsmVariantName = "";
  547. ///@}
  548. /// UseNamedOperandTable - If set, the operand indices of this instruction
  549. /// can be queried via the getNamedOperandIdx() function which is generated
  550. /// by TableGen.
  551. bit UseNamedOperandTable = false;
  552. /// Should generate helper functions that help you to map a logical operand's
  553. /// index to the underlying MIOperand's index.
  554. /// In most architectures logical operand indicies are equal to
  555. /// MIOperand indicies, but for some CISC architectures, a logical operand
  556. /// might be consist of multiple MIOperand (e.g. a logical operand that
  557. /// uses complex address mode).
  558. bit UseLogicalOperandMappings = false;
  559. /// Should FastISel ignore this instruction. For certain ISAs, they have
  560. /// instructions which map to the same ISD Opcode, value type operands and
  561. /// instruction selection predicates. FastISel cannot handle such cases, but
  562. /// SelectionDAG can.
  563. bit FastISelShouldIgnore = false;
  564. /// HasPositionOrder: Indicate tablegen to sort the instructions by record
  565. /// ID, so that instruction that is defined earlier can be sorted earlier
  566. /// in the assembly matching table.
  567. bit HasPositionOrder = false;
  568. }
  569. /// Defines a Pat match between compressed and uncompressed instruction.
  570. /// The relationship and helper function generation are handled by
  571. /// CompressInstEmitter backend.
  572. class CompressPat<dag input, dag output, list<Predicate> predicates = []> {
  573. /// Uncompressed instruction description.
  574. dag Input = input;
  575. /// Compressed instruction description.
  576. dag Output = output;
  577. /// Predicates that must be true for this to match.
  578. list<Predicate> Predicates = predicates;
  579. /// Duplicate match when tied operand is just different.
  580. bit isCompressOnly = false;
  581. }
  582. /// Defines an additional encoding that disassembles to the given instruction
  583. /// Like Instruction, the Inst and SoftFail fields are omitted to allow targets
  584. // to specify their size.
  585. class AdditionalEncoding<Instruction I> : InstructionEncoding {
  586. Instruction AliasOf = I;
  587. }
  588. /// PseudoInstExpansion - Expansion information for a pseudo-instruction.
  589. /// Which instruction it expands to and how the operands map from the
  590. /// pseudo.
  591. class PseudoInstExpansion<dag Result> {
  592. dag ResultInst = Result; // The instruction to generate.
  593. bit isPseudo = true;
  594. }
  595. /// Predicates - These are extra conditionals which are turned into instruction
  596. /// selector matching code. Currently each predicate is just a string.
  597. class Predicate<string cond> {
  598. string CondString = cond;
  599. /// AssemblerMatcherPredicate - If this feature can be used by the assembler
  600. /// matcher, this is true. Targets should set this by inheriting their
  601. /// feature from the AssemblerPredicate class in addition to Predicate.
  602. bit AssemblerMatcherPredicate = false;
  603. /// AssemblerCondDag - Set of subtarget features being tested used
  604. /// as alternative condition string used for assembler matcher. Must be used
  605. /// with (all_of) to indicate that all features must be present, or (any_of)
  606. /// to indicate that at least one must be. The required lack of presence of
  607. /// a feature can be tested using a (not) node including the feature.
  608. /// e.g. "(all_of ModeThumb)" is translated to "(Bits & ModeThumb) != 0".
  609. /// "(all_of (not ModeThumb))" is translated to
  610. /// "(Bits & ModeThumb) == 0".
  611. /// "(all_of ModeThumb, FeatureThumb2)" is translated to
  612. /// "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0".
  613. /// "(any_of ModeTumb, FeatureThumb2)" is translated to
  614. /// "(Bits & ModeThumb) != 0 || (Bits & FeatureThumb2) != 0".
  615. /// all_of and any_of cannot be combined in a single dag, instead multiple
  616. /// predicates can be placed onto Instruction definitions.
  617. dag AssemblerCondDag;
  618. /// PredicateName - User-level name to use for the predicate. Mainly for use
  619. /// in diagnostics such as missing feature errors in the asm matcher.
  620. string PredicateName = "";
  621. /// Setting this to '1' indicates that the predicate must be recomputed on
  622. /// every function change. Most predicates can leave this at '0'.
  623. ///
  624. /// Ignored by SelectionDAG, it always recomputes the predicate on every use.
  625. bit RecomputePerFunction = false;
  626. }
  627. /// NoHonorSignDependentRounding - This predicate is true if support for
  628. /// sign-dependent-rounding is not enabled.
  629. def NoHonorSignDependentRounding
  630. : Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">;
  631. class Requires<list<Predicate> preds> {
  632. list<Predicate> Predicates = preds;
  633. }
  634. /// ops definition - This is just a simple marker used to identify the operand
  635. /// list for an instruction. outs and ins are identical both syntactically and
  636. /// semantically; they are used to define def operands and use operands to
  637. /// improve readability. This should be used like this:
  638. /// (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar.
  639. def ops;
  640. def outs;
  641. def ins;
  642. /// variable_ops definition - Mark this instruction as taking a variable number
  643. /// of operands.
  644. def variable_ops;
  645. /// PointerLikeRegClass - Values that are designed to have pointer width are
  646. /// derived from this. TableGen treats the register class as having a symbolic
  647. /// type that it doesn't know, and resolves the actual regclass to use by using
  648. /// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
  649. class PointerLikeRegClass<int Kind> {
  650. int RegClassKind = Kind;
  651. }
  652. /// ptr_rc definition - Mark this operand as being a pointer value whose
  653. /// register class is resolved dynamically via a callback to TargetInstrInfo.
  654. /// FIXME: We should probably change this to a class which contain a list of
  655. /// flags. But currently we have but one flag.
  656. def ptr_rc : PointerLikeRegClass<0>;
  657. /// unknown definition - Mark this operand as being of unknown type, causing
  658. /// it to be resolved by inference in the context it is used.
  659. class unknown_class;
  660. def unknown : unknown_class;
  661. /// AsmOperandClass - Representation for the kinds of operands which the target
  662. /// specific parser can create and the assembly matcher may need to distinguish.
  663. ///
  664. /// Operand classes are used to define the order in which instructions are
  665. /// matched, to ensure that the instruction which gets matched for any
  666. /// particular list of operands is deterministic.
  667. ///
  668. /// The target specific parser must be able to classify a parsed operand into a
  669. /// unique class which does not partially overlap with any other classes. It can
  670. /// match a subset of some other class, in which case the super class field
  671. /// should be defined.
  672. class AsmOperandClass {
  673. /// The name to use for this class, which should be usable as an enum value.
  674. string Name = ?;
  675. /// The super classes of this operand.
  676. list<AsmOperandClass> SuperClasses = [];
  677. /// The name of the method on the target specific operand to call to test
  678. /// whether the operand is an instance of this class. If not set, this will
  679. /// default to "isFoo", where Foo is the AsmOperandClass name. The method
  680. /// signature should be:
  681. /// bool isFoo() const;
  682. string PredicateMethod = ?;
  683. /// The name of the method on the target specific operand to call to add the
  684. /// target specific operand to an MCInst. If not set, this will default to
  685. /// "addFooOperands", where Foo is the AsmOperandClass name. The method
  686. /// signature should be:
  687. /// void addFooOperands(MCInst &Inst, unsigned N) const;
  688. string RenderMethod = ?;
  689. /// The name of the method on the target specific operand to call to custom
  690. /// handle the operand parsing. This is useful when the operands do not relate
  691. /// to immediates or registers and are very instruction specific (as flags to
  692. /// set in a processor register, coprocessor number, ...).
  693. string ParserMethod = ?;
  694. // The diagnostic type to present when referencing this operand in a
  695. // match failure error message. By default, use a generic "invalid operand"
  696. // diagnostic. The target AsmParser maps these codes to text.
  697. string DiagnosticType = "";
  698. /// A diagnostic message to emit when an invalid value is provided for this
  699. /// operand.
  700. string DiagnosticString = "";
  701. /// Set to 1 if this operand is optional and not always required. Typically,
  702. /// the AsmParser will emit an error when it finishes parsing an
  703. /// instruction if it hasn't matched all the operands yet. However, this
  704. /// error will be suppressed if all of the remaining unmatched operands are
  705. /// marked as IsOptional.
  706. ///
  707. /// Optional arguments must be at the end of the operand list.
  708. bit IsOptional = false;
  709. /// The name of the method on the target specific asm parser that returns the
  710. /// default operand for this optional operand. This method is only used if
  711. /// IsOptional == 1. If not set, this will default to "defaultFooOperands",
  712. /// where Foo is the AsmOperandClass name. The method signature should be:
  713. /// std::unique_ptr<MCParsedAsmOperand> defaultFooOperands() const;
  714. string DefaultMethod = ?;
  715. }
  716. def ImmAsmOperand : AsmOperandClass {
  717. let Name = "Imm";
  718. }
  719. /// Operand Types - These provide the built-in operand types that may be used
  720. /// by a target. Targets can optionally provide their own operand types as
  721. /// needed, though this should not be needed for RISC targets.
  722. class Operand<ValueType ty> : DAGOperand {
  723. ValueType Type = ty;
  724. string PrintMethod = "printOperand";
  725. string EncoderMethod = "";
  726. bit hasCompleteDecoder = true;
  727. string OperandType = "OPERAND_UNKNOWN";
  728. dag MIOperandInfo = (ops);
  729. // MCOperandPredicate - Optionally, a code fragment operating on
  730. // const MCOperand &MCOp, and returning a bool, to indicate if
  731. // the value of MCOp is valid for the specific subclass of Operand
  732. code MCOperandPredicate;
  733. // ParserMatchClass - The "match class" that operands of this type fit
  734. // in. Match classes are used to define the order in which instructions are
  735. // match, to ensure that which instructions gets matched is deterministic.
  736. //
  737. // The target specific parser must be able to classify an parsed operand into
  738. // a unique class, which does not partially overlap with any other classes. It
  739. // can match a subset of some other class, in which case the AsmOperandClass
  740. // should declare the other operand as one of its super classes.
  741. AsmOperandClass ParserMatchClass = ImmAsmOperand;
  742. }
  743. class RegisterOperand<RegisterClass regclass, string pm = "printOperand">
  744. : DAGOperand {
  745. // RegClass - The register class of the operand.
  746. RegisterClass RegClass = regclass;
  747. // PrintMethod - The target method to call to print register operands of
  748. // this type. The method normally will just use an alt-name index to look
  749. // up the name to print. Default to the generic printOperand().
  750. string PrintMethod = pm;
  751. // EncoderMethod - The target method name to call to encode this register
  752. // operand.
  753. string EncoderMethod = "";
  754. // ParserMatchClass - The "match class" that operands of this type fit
  755. // in. Match classes are used to define the order in which instructions are
  756. // match, to ensure that which instructions gets matched is deterministic.
  757. //
  758. // The target specific parser must be able to classify an parsed operand into
  759. // a unique class, which does not partially overlap with any other classes. It
  760. // can match a subset of some other class, in which case the AsmOperandClass
  761. // should declare the other operand as one of its super classes.
  762. AsmOperandClass ParserMatchClass;
  763. string OperandType = "OPERAND_REGISTER";
  764. // When referenced in the result of a CodeGen pattern, GlobalISel will
  765. // normally copy the matched operand to the result. When this is set, it will
  766. // emit a special copy that will replace zero-immediates with the specified
  767. // zero-register.
  768. Register GIZeroRegister = ?;
  769. }
  770. let OperandType = "OPERAND_IMMEDIATE" in {
  771. def i1imm : Operand<i1>;
  772. def i8imm : Operand<i8>;
  773. def i16imm : Operand<i16>;
  774. def i32imm : Operand<i32>;
  775. def i64imm : Operand<i64>;
  776. def f32imm : Operand<f32>;
  777. def f64imm : Operand<f64>;
  778. }
  779. // Register operands for generic instructions don't have an MVT, but do have
  780. // constraints linking the operands (e.g. all operands of a G_ADD must
  781. // have the same LLT).
  782. class TypedOperand<string Ty> : Operand<untyped> {
  783. let OperandType = Ty;
  784. bit IsPointer = false;
  785. bit IsImmediate = false;
  786. }
  787. def type0 : TypedOperand<"OPERAND_GENERIC_0">;
  788. def type1 : TypedOperand<"OPERAND_GENERIC_1">;
  789. def type2 : TypedOperand<"OPERAND_GENERIC_2">;
  790. def type3 : TypedOperand<"OPERAND_GENERIC_3">;
  791. def type4 : TypedOperand<"OPERAND_GENERIC_4">;
  792. def type5 : TypedOperand<"OPERAND_GENERIC_5">;
  793. let IsPointer = true in {
  794. def ptype0 : TypedOperand<"OPERAND_GENERIC_0">;
  795. def ptype1 : TypedOperand<"OPERAND_GENERIC_1">;
  796. def ptype2 : TypedOperand<"OPERAND_GENERIC_2">;
  797. def ptype3 : TypedOperand<"OPERAND_GENERIC_3">;
  798. def ptype4 : TypedOperand<"OPERAND_GENERIC_4">;
  799. def ptype5 : TypedOperand<"OPERAND_GENERIC_5">;
  800. }
  801. // untyped_imm is for operands where isImm() will be true. It currently has no
  802. // special behaviour and is only used for clarity.
  803. def untyped_imm_0 : TypedOperand<"OPERAND_GENERIC_IMM_0"> {
  804. let IsImmediate = true;
  805. }
  806. /// zero_reg definition - Special node to stand for the zero register.
  807. ///
  808. def zero_reg;
  809. /// undef_tied_input - Special node to indicate an input register tied
  810. /// to an output which defaults to IMPLICIT_DEF.
  811. def undef_tied_input;
  812. /// All operands which the MC layer classifies as predicates should inherit from
  813. /// this class in some manner. This is already handled for the most commonly
  814. /// used PredicateOperand, but may be useful in other circumstances.
  815. class PredicateOp;
  816. /// OperandWithDefaultOps - This Operand class can be used as the parent class
  817. /// for an Operand that needs to be initialized with a default value if
  818. /// no value is supplied in a pattern. This class can be used to simplify the
  819. /// pattern definitions for instructions that have target specific flags
  820. /// encoded as immediate operands.
  821. class OperandWithDefaultOps<ValueType ty, dag defaultops>
  822. : Operand<ty> {
  823. dag DefaultOps = defaultops;
  824. }
  825. /// PredicateOperand - This can be used to define a predicate operand for an
  826. /// instruction. OpTypes specifies the MIOperandInfo for the operand, and
  827. /// AlwaysVal specifies the value of this predicate when set to "always
  828. /// execute".
  829. class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal>
  830. : OperandWithDefaultOps<ty, AlwaysVal>, PredicateOp {
  831. let MIOperandInfo = OpTypes;
  832. }
  833. /// OptionalDefOperand - This is used to define a optional definition operand
  834. /// for an instruction. DefaultOps is the register the operand represents if
  835. /// none is supplied, e.g. zero_reg.
  836. class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>
  837. : OperandWithDefaultOps<ty, defaultops> {
  838. let MIOperandInfo = OpTypes;
  839. }
  840. // InstrInfo - This class should only be instantiated once to provide parameters
  841. // which are global to the target machine.
  842. //
  843. class InstrInfo {
  844. // Target can specify its instructions in either big or little-endian formats.
  845. // For instance, while both Sparc and PowerPC are big-endian platforms, the
  846. // Sparc manual specifies its instructions in the format [31..0] (big), while
  847. // PowerPC specifies them using the format [0..31] (little).
  848. bit isLittleEndianEncoding = false;
  849. // The instruction properties mayLoad, mayStore, and hasSideEffects are unset
  850. // by default, and TableGen will infer their value from the instruction
  851. // pattern when possible.
  852. //
  853. // Normally, TableGen will issue an error if it can't infer the value of a
  854. // property that hasn't been set explicitly. When guessInstructionProperties
  855. // is set, it will guess a safe value instead.
  856. //
  857. // This option is a temporary migration help. It will go away.
  858. bit guessInstructionProperties = true;
  859. // TableGen's instruction encoder generator has support for matching operands
  860. // to bit-field variables both by name and by position. While matching by
  861. // name is preferred, this is currently not possible for complex operands,
  862. // and some targets still reply on the positional encoding rules. When
  863. // generating a decoder for such targets, the positional encoding rules must
  864. // be used by the decoder generator as well.
  865. //
  866. // This option is temporary; it will go away once the TableGen decoder
  867. // generator has better support for complex operands and targets have
  868. // migrated away from using positionally encoded operands.
  869. bit decodePositionallyEncodedOperands = false;
  870. // When set, this indicates that there will be no overlap between those
  871. // operands that are matched by ordering (positional operands) and those
  872. // matched by name.
  873. //
  874. // This option is temporary; it will go away once the TableGen decoder
  875. // generator has better support for complex operands and targets have
  876. // migrated away from using positionally encoded operands.
  877. bit noNamedPositionallyEncodedOperands = false;
  878. }
  879. // Standard Pseudo Instructions.
  880. // This list must match TargetOpcodes.def.
  881. // Only these instructions are allowed in the TargetOpcode namespace.
  882. // Ensure mayLoad and mayStore have a default value, so as not to break
  883. // targets that set guessInstructionProperties=0. Any local definition of
  884. // mayLoad/mayStore takes precedence over these default values.
  885. class StandardPseudoInstruction : Instruction {
  886. let mayLoad = false;
  887. let mayStore = false;
  888. let isCodeGenOnly = true;
  889. let isPseudo = true;
  890. let hasNoSchedulingInfo = true;
  891. let Namespace = "TargetOpcode";
  892. }
  893. def PHI : StandardPseudoInstruction {
  894. let OutOperandList = (outs unknown:$dst);
  895. let InOperandList = (ins variable_ops);
  896. let AsmString = "PHINODE";
  897. let hasSideEffects = false;
  898. }
  899. def INLINEASM : StandardPseudoInstruction {
  900. let OutOperandList = (outs);
  901. let InOperandList = (ins variable_ops);
  902. let AsmString = "";
  903. let hasSideEffects = false; // Note side effect is encoded in an operand.
  904. }
  905. def INLINEASM_BR : StandardPseudoInstruction {
  906. let OutOperandList = (outs);
  907. let InOperandList = (ins variable_ops);
  908. let AsmString = "";
  909. // Unlike INLINEASM, this is always treated as having side-effects.
  910. let hasSideEffects = true;
  911. // Despite potentially branching, this instruction is intentionally _not_
  912. // marked as a terminator or a branch.
  913. }
  914. def CFI_INSTRUCTION : StandardPseudoInstruction {
  915. let OutOperandList = (outs);
  916. let InOperandList = (ins i32imm:$id);
  917. let AsmString = "";
  918. let hasCtrlDep = true;
  919. let hasSideEffects = false;
  920. let isNotDuplicable = true;
  921. }
  922. def EH_LABEL : StandardPseudoInstruction {
  923. let OutOperandList = (outs);
  924. let InOperandList = (ins i32imm:$id);
  925. let AsmString = "";
  926. let hasCtrlDep = true;
  927. let hasSideEffects = false;
  928. let isNotDuplicable = true;
  929. }
  930. def GC_LABEL : StandardPseudoInstruction {
  931. let OutOperandList = (outs);
  932. let InOperandList = (ins i32imm:$id);
  933. let AsmString = "";
  934. let hasCtrlDep = true;
  935. let hasSideEffects = false;
  936. let isNotDuplicable = true;
  937. }
  938. def ANNOTATION_LABEL : StandardPseudoInstruction {
  939. let OutOperandList = (outs);
  940. let InOperandList = (ins i32imm:$id);
  941. let AsmString = "";
  942. let hasCtrlDep = true;
  943. let hasSideEffects = false;
  944. let isNotDuplicable = true;
  945. }
  946. def KILL : StandardPseudoInstruction {
  947. let OutOperandList = (outs);
  948. let InOperandList = (ins variable_ops);
  949. let AsmString = "";
  950. let hasSideEffects = false;
  951. }
  952. def EXTRACT_SUBREG : StandardPseudoInstruction {
  953. let OutOperandList = (outs unknown:$dst);
  954. let InOperandList = (ins unknown:$supersrc, i32imm:$subidx);
  955. let AsmString = "";
  956. let hasSideEffects = false;
  957. }
  958. def INSERT_SUBREG : StandardPseudoInstruction {
  959. let OutOperandList = (outs unknown:$dst);
  960. let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx);
  961. let AsmString = "";
  962. let hasSideEffects = false;
  963. let Constraints = "$supersrc = $dst";
  964. }
  965. def IMPLICIT_DEF : StandardPseudoInstruction {
  966. let OutOperandList = (outs unknown:$dst);
  967. let InOperandList = (ins);
  968. let AsmString = "";
  969. let hasSideEffects = false;
  970. let isReMaterializable = true;
  971. let isAsCheapAsAMove = true;
  972. }
  973. def SUBREG_TO_REG : StandardPseudoInstruction {
  974. let OutOperandList = (outs unknown:$dst);
  975. let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx);
  976. let AsmString = "";
  977. let hasSideEffects = false;
  978. }
  979. def COPY_TO_REGCLASS : StandardPseudoInstruction {
  980. let OutOperandList = (outs unknown:$dst);
  981. let InOperandList = (ins unknown:$src, i32imm:$regclass);
  982. let AsmString = "";
  983. let hasSideEffects = false;
  984. let isAsCheapAsAMove = true;
  985. }
  986. def DBG_VALUE : StandardPseudoInstruction {
  987. let OutOperandList = (outs);
  988. let InOperandList = (ins variable_ops);
  989. let AsmString = "DBG_VALUE";
  990. let hasSideEffects = false;
  991. }
  992. def DBG_VALUE_LIST : StandardPseudoInstruction {
  993. let OutOperandList = (outs);
  994. let InOperandList = (ins variable_ops);
  995. let AsmString = "DBG_VALUE_LIST";
  996. let hasSideEffects = 0;
  997. }
  998. def DBG_INSTR_REF : StandardPseudoInstruction {
  999. let OutOperandList = (outs);
  1000. let InOperandList = (ins variable_ops);
  1001. let AsmString = "DBG_INSTR_REF";
  1002. let hasSideEffects = false;
  1003. }
  1004. def DBG_PHI : StandardPseudoInstruction {
  1005. let OutOperandList = (outs);
  1006. let InOperandList = (ins variable_ops);
  1007. let AsmString = "DBG_PHI";
  1008. let hasSideEffects = 0;
  1009. }
  1010. def DBG_LABEL : StandardPseudoInstruction {
  1011. let OutOperandList = (outs);
  1012. let InOperandList = (ins unknown:$label);
  1013. let AsmString = "DBG_LABEL";
  1014. let hasSideEffects = false;
  1015. }
  1016. def REG_SEQUENCE : StandardPseudoInstruction {
  1017. let OutOperandList = (outs unknown:$dst);
  1018. let InOperandList = (ins unknown:$supersrc, variable_ops);
  1019. let AsmString = "";
  1020. let hasSideEffects = false;
  1021. let isAsCheapAsAMove = true;
  1022. }
  1023. def COPY : StandardPseudoInstruction {
  1024. let OutOperandList = (outs unknown:$dst);
  1025. let InOperandList = (ins unknown:$src);
  1026. let AsmString = "";
  1027. let hasSideEffects = false;
  1028. let isAsCheapAsAMove = true;
  1029. let hasNoSchedulingInfo = false;
  1030. }
  1031. def BUNDLE : StandardPseudoInstruction {
  1032. let OutOperandList = (outs);
  1033. let InOperandList = (ins variable_ops);
  1034. let AsmString = "BUNDLE";
  1035. let hasSideEffects = false;
  1036. }
  1037. def LIFETIME_START : StandardPseudoInstruction {
  1038. let OutOperandList = (outs);
  1039. let InOperandList = (ins i32imm:$id);
  1040. let AsmString = "LIFETIME_START";
  1041. let hasSideEffects = false;
  1042. }
  1043. def LIFETIME_END : StandardPseudoInstruction {
  1044. let OutOperandList = (outs);
  1045. let InOperandList = (ins i32imm:$id);
  1046. let AsmString = "LIFETIME_END";
  1047. let hasSideEffects = false;
  1048. }
  1049. def PSEUDO_PROBE : StandardPseudoInstruction {
  1050. let OutOperandList = (outs);
  1051. let InOperandList = (ins i64imm:$guid, i64imm:$index, i8imm:$type, i32imm:$attr);
  1052. let AsmString = "PSEUDO_PROBE";
  1053. let hasSideEffects = 1;
  1054. }
  1055. def ARITH_FENCE : StandardPseudoInstruction {
  1056. let OutOperandList = (outs unknown:$dst);
  1057. let InOperandList = (ins unknown:$src);
  1058. let AsmString = "";
  1059. let hasSideEffects = false;
  1060. let Constraints = "$src = $dst";
  1061. }
  1062. def STACKMAP : StandardPseudoInstruction {
  1063. let OutOperandList = (outs);
  1064. let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops);
  1065. let hasSideEffects = true;
  1066. let isCall = true;
  1067. let mayLoad = true;
  1068. let usesCustomInserter = true;
  1069. }
  1070. def PATCHPOINT : StandardPseudoInstruction {
  1071. let OutOperandList = (outs unknown:$dst);
  1072. let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee,
  1073. i32imm:$nargs, i32imm:$cc, variable_ops);
  1074. let hasSideEffects = true;
  1075. let isCall = true;
  1076. let mayLoad = true;
  1077. let usesCustomInserter = true;
  1078. }
  1079. def STATEPOINT : StandardPseudoInstruction {
  1080. let OutOperandList = (outs variable_ops);
  1081. let InOperandList = (ins variable_ops);
  1082. let usesCustomInserter = true;
  1083. let mayLoad = true;
  1084. let mayStore = true;
  1085. let hasSideEffects = true;
  1086. let isCall = true;
  1087. }
  1088. def LOAD_STACK_GUARD : StandardPseudoInstruction {
  1089. let OutOperandList = (outs ptr_rc:$dst);
  1090. let InOperandList = (ins);
  1091. let mayLoad = true;
  1092. bit isReMaterializable = true;
  1093. let hasSideEffects = false;
  1094. bit isPseudo = true;
  1095. }
  1096. def PREALLOCATED_SETUP : StandardPseudoInstruction {
  1097. let OutOperandList = (outs);
  1098. let InOperandList = (ins i32imm:$a);
  1099. let usesCustomInserter = true;
  1100. let hasSideEffects = true;
  1101. }
  1102. def PREALLOCATED_ARG : StandardPseudoInstruction {
  1103. let OutOperandList = (outs ptr_rc:$loc);
  1104. let InOperandList = (ins i32imm:$a, i32imm:$b);
  1105. let usesCustomInserter = true;
  1106. let hasSideEffects = true;
  1107. }
  1108. def LOCAL_ESCAPE : StandardPseudoInstruction {
  1109. // This instruction is really just a label. It has to be part of the chain so
  1110. // that it doesn't get dropped from the DAG, but it produces nothing and has
  1111. // no side effects.
  1112. let OutOperandList = (outs);
  1113. let InOperandList = (ins ptr_rc:$symbol, i32imm:$id);
  1114. let hasSideEffects = false;
  1115. let hasCtrlDep = true;
  1116. }
  1117. def FAULTING_OP : StandardPseudoInstruction {
  1118. let OutOperandList = (outs unknown:$dst);
  1119. let InOperandList = (ins variable_ops);
  1120. let usesCustomInserter = true;
  1121. let hasSideEffects = true;
  1122. let mayLoad = true;
  1123. let mayStore = true;
  1124. let isTerminator = true;
  1125. let isBranch = true;
  1126. }
  1127. def PATCHABLE_OP : StandardPseudoInstruction {
  1128. let OutOperandList = (outs);
  1129. let InOperandList = (ins variable_ops);
  1130. let usesCustomInserter = true;
  1131. let mayLoad = true;
  1132. let mayStore = true;
  1133. let hasSideEffects = true;
  1134. }
  1135. def PATCHABLE_FUNCTION_ENTER : StandardPseudoInstruction {
  1136. let OutOperandList = (outs);
  1137. let InOperandList = (ins);
  1138. let AsmString = "# XRay Function Enter.";
  1139. let usesCustomInserter = true;
  1140. let hasSideEffects = true;
  1141. }
  1142. def PATCHABLE_RET : StandardPseudoInstruction {
  1143. let OutOperandList = (outs);
  1144. let InOperandList = (ins variable_ops);
  1145. let AsmString = "# XRay Function Patchable RET.";
  1146. let usesCustomInserter = true;
  1147. let hasSideEffects = true;
  1148. let isTerminator = true;
  1149. let isReturn = true;
  1150. }
  1151. def PATCHABLE_FUNCTION_EXIT : StandardPseudoInstruction {
  1152. let OutOperandList = (outs);
  1153. let InOperandList = (ins);
  1154. let AsmString = "# XRay Function Exit.";
  1155. let usesCustomInserter = true;
  1156. let hasSideEffects = true;
  1157. let isReturn = false; // Original return instruction will follow
  1158. }
  1159. def PATCHABLE_TAIL_CALL : StandardPseudoInstruction {
  1160. let OutOperandList = (outs);
  1161. let InOperandList = (ins variable_ops);
  1162. let AsmString = "# XRay Tail Call Exit.";
  1163. let usesCustomInserter = true;
  1164. let hasSideEffects = true;
  1165. let isReturn = true;
  1166. }
  1167. def PATCHABLE_EVENT_CALL : StandardPseudoInstruction {
  1168. let OutOperandList = (outs);
  1169. let InOperandList = (ins ptr_rc:$event, unknown:$size);
  1170. let AsmString = "# XRay Custom Event Log.";
  1171. let usesCustomInserter = true;
  1172. let isCall = true;
  1173. let mayLoad = true;
  1174. let mayStore = true;
  1175. let hasSideEffects = true;
  1176. }
  1177. def PATCHABLE_TYPED_EVENT_CALL : StandardPseudoInstruction {
  1178. let OutOperandList = (outs);
  1179. let InOperandList = (ins unknown:$type, ptr_rc:$event, unknown:$size);
  1180. let AsmString = "# XRay Typed Event Log.";
  1181. let usesCustomInserter = true;
  1182. let isCall = true;
  1183. let mayLoad = true;
  1184. let mayStore = true;
  1185. let hasSideEffects = true;
  1186. }
  1187. def FENTRY_CALL : StandardPseudoInstruction {
  1188. let OutOperandList = (outs);
  1189. let InOperandList = (ins);
  1190. let AsmString = "# FEntry call";
  1191. let usesCustomInserter = true;
  1192. let isCall = true;
  1193. let mayLoad = true;
  1194. let mayStore = true;
  1195. let hasSideEffects = true;
  1196. }
  1197. def ICALL_BRANCH_FUNNEL : StandardPseudoInstruction {
  1198. let OutOperandList = (outs);
  1199. let InOperandList = (ins variable_ops);
  1200. let AsmString = "";
  1201. let hasSideEffects = true;
  1202. }
  1203. // Generic opcodes used in GlobalISel.
  1204. include "llvm/Target/GenericOpcodes.td"
  1205. //===----------------------------------------------------------------------===//
  1206. // AsmParser - This class can be implemented by targets that wish to implement
  1207. // .s file parsing.
  1208. //
  1209. // Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel
  1210. // syntax on X86 for example).
  1211. //
  1212. class AsmParser {
  1213. // AsmParserClassName - This specifies the suffix to use for the asmparser
  1214. // class. Generated AsmParser classes are always prefixed with the target
  1215. // name.
  1216. string AsmParserClassName = "AsmParser";
  1217. // AsmParserInstCleanup - If non-empty, this is the name of a custom member
  1218. // function of the AsmParser class to call on every matched instruction.
  1219. // This can be used to perform target specific instruction post-processing.
  1220. string AsmParserInstCleanup = "";
  1221. // ShouldEmitMatchRegisterName - Set to false if the target needs a hand
  1222. // written register name matcher
  1223. bit ShouldEmitMatchRegisterName = true;
  1224. // Set to true if the target needs a generated 'alternative register name'
  1225. // matcher.
  1226. //
  1227. // This generates a function which can be used to lookup registers from
  1228. // their aliases. This function will fail when called on targets where
  1229. // several registers share the same alias (i.e. not a 1:1 mapping).
  1230. bit ShouldEmitMatchRegisterAltName = false;
  1231. // Set to true if MatchRegisterName and MatchRegisterAltName functions
  1232. // should be generated even if there are duplicate register names. The
  1233. // target is responsible for coercing aliased registers as necessary
  1234. // (e.g. in validateTargetOperandClass), and there are no guarantees about
  1235. // which numeric register identifier will be returned in the case of
  1236. // multiple matches.
  1237. bit AllowDuplicateRegisterNames = false;
  1238. // HasMnemonicFirst - Set to false if target instructions don't always
  1239. // start with a mnemonic as the first token.
  1240. bit HasMnemonicFirst = true;
  1241. // ReportMultipleNearMisses -
  1242. // When 0, the assembly matcher reports an error for one encoding or operand
  1243. // that did not match the parsed instruction.
  1244. // When 1, the assembly matcher returns a list of encodings that were close
  1245. // to matching the parsed instruction, so to allow more detailed error
  1246. // messages.
  1247. bit ReportMultipleNearMisses = false;
  1248. }
  1249. def DefaultAsmParser : AsmParser;
  1250. //===----------------------------------------------------------------------===//
  1251. // AsmParserVariant - Subtargets can have multiple different assembly parsers
  1252. // (e.g. AT&T vs Intel syntax on X86 for example). This class can be
  1253. // implemented by targets to describe such variants.
  1254. //
  1255. class AsmParserVariant {
  1256. // Variant - AsmParsers can be of multiple different variants. Variants are
  1257. // used to support targets that need to parse multiple formats for the
  1258. // assembly language.
  1259. int Variant = 0;
  1260. // Name - The AsmParser variant name (e.g., AT&T vs Intel).
  1261. string Name = "";
  1262. // CommentDelimiter - If given, the delimiter string used to recognize
  1263. // comments which are hard coded in the .td assembler strings for individual
  1264. // instructions.
  1265. string CommentDelimiter = "";
  1266. // RegisterPrefix - If given, the token prefix which indicates a register
  1267. // token. This is used by the matcher to automatically recognize hard coded
  1268. // register tokens as constrained registers, instead of tokens, for the
  1269. // purposes of matching.
  1270. string RegisterPrefix = "";
  1271. // TokenizingCharacters - Characters that are standalone tokens
  1272. string TokenizingCharacters = "[]*!";
  1273. // SeparatorCharacters - Characters that are not tokens
  1274. string SeparatorCharacters = " \t,";
  1275. // BreakCharacters - Characters that start new identifiers
  1276. string BreakCharacters = "";
  1277. }
  1278. def DefaultAsmParserVariant : AsmParserVariant;
  1279. // Operators for combining SubtargetFeatures in AssemblerPredicates
  1280. def any_of;
  1281. def all_of;
  1282. /// AssemblerPredicate - This is a Predicate that can be used when the assembler
  1283. /// matches instructions and aliases.
  1284. class AssemblerPredicate<dag cond, string name = ""> {
  1285. bit AssemblerMatcherPredicate = true;
  1286. dag AssemblerCondDag = cond;
  1287. string PredicateName = name;
  1288. }
  1289. /// TokenAlias - This class allows targets to define assembler token
  1290. /// operand aliases. That is, a token literal operand which is equivalent
  1291. /// to another, canonical, token literal. For example, ARM allows:
  1292. /// vmov.u32 s4, #0 -> vmov.i32, #0
  1293. /// 'u32' is a more specific designator for the 32-bit integer type specifier
  1294. /// and is legal for any instruction which accepts 'i32' as a datatype suffix.
  1295. /// def : TokenAlias<".u32", ".i32">;
  1296. ///
  1297. /// This works by marking the match class of 'From' as a subclass of the
  1298. /// match class of 'To'.
  1299. class TokenAlias<string From, string To> {
  1300. string FromToken = From;
  1301. string ToToken = To;
  1302. }
  1303. /// MnemonicAlias - This class allows targets to define assembler mnemonic
  1304. /// aliases. This should be used when all forms of one mnemonic are accepted
  1305. /// with a different mnemonic. For example, X86 allows:
  1306. /// sal %al, 1 -> shl %al, 1
  1307. /// sal %ax, %cl -> shl %ax, %cl
  1308. /// sal %eax, %cl -> shl %eax, %cl
  1309. /// etc. Though "sal" is accepted with many forms, all of them are directly
  1310. /// translated to a shl, so it can be handled with (in the case of X86, it
  1311. /// actually has one for each suffix as well):
  1312. /// def : MnemonicAlias<"sal", "shl">;
  1313. ///
  1314. /// Mnemonic aliases are mapped before any other translation in the match phase,
  1315. /// and do allow Requires predicates, e.g.:
  1316. ///
  1317. /// def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>;
  1318. /// def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>;
  1319. ///
  1320. /// Mnemonic aliases can also be constrained to specific variants, e.g.:
  1321. ///
  1322. /// def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>;
  1323. ///
  1324. /// If no variant (e.g., "att" or "intel") is specified then the alias is
  1325. /// applied unconditionally.
  1326. class MnemonicAlias<string From, string To, string VariantName = ""> {
  1327. string FromMnemonic = From;
  1328. string ToMnemonic = To;
  1329. string AsmVariantName = VariantName;
  1330. // Predicates - Predicates that must be true for this remapping to happen.
  1331. list<Predicate> Predicates = [];
  1332. }
  1333. /// InstAlias - This defines an alternate assembly syntax that is allowed to
  1334. /// match an instruction that has a different (more canonical) assembly
  1335. /// representation.
  1336. class InstAlias<string Asm, dag Result, int Emit = 1, string VariantName = ""> {
  1337. string AsmString = Asm; // The .s format to match the instruction with.
  1338. dag ResultInst = Result; // The MCInst to generate.
  1339. // This determines which order the InstPrinter detects aliases for
  1340. // printing. A larger value makes the alias more likely to be
  1341. // emitted. The Instruction's own definition is notionally 0.5, so 0
  1342. // disables printing and 1 enables it if there are no conflicting aliases.
  1343. int EmitPriority = Emit;
  1344. // Predicates - Predicates that must be true for this to match.
  1345. list<Predicate> Predicates = [];
  1346. // If the instruction specified in Result has defined an AsmMatchConverter
  1347. // then setting this to 1 will cause the alias to use the AsmMatchConverter
  1348. // function when converting the OperandVector into an MCInst instead of the
  1349. // function that is generated by the dag Result.
  1350. // Setting this to 0 will cause the alias to ignore the Result instruction's
  1351. // defined AsmMatchConverter and instead use the function generated by the
  1352. // dag Result.
  1353. bit UseInstAsmMatchConverter = true;
  1354. // Assembler variant name to use for this alias. If not specified then
  1355. // assembler variants will be determined based on AsmString
  1356. string AsmVariantName = VariantName;
  1357. }
  1358. //===----------------------------------------------------------------------===//
  1359. // AsmWriter - This class can be implemented by targets that need to customize
  1360. // the format of the .s file writer.
  1361. //
  1362. // Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax
  1363. // on X86 for example).
  1364. //
  1365. class AsmWriter {
  1366. // AsmWriterClassName - This specifies the suffix to use for the asmwriter
  1367. // class. Generated AsmWriter classes are always prefixed with the target
  1368. // name.
  1369. string AsmWriterClassName = "InstPrinter";
  1370. // PassSubtarget - Determines whether MCSubtargetInfo should be passed to
  1371. // the various print methods.
  1372. // FIXME: Remove after all ports are updated.
  1373. int PassSubtarget = 0;
  1374. // Variant - AsmWriters can be of multiple different variants. Variants are
  1375. // used to support targets that need to emit assembly code in ways that are
  1376. // mostly the same for different targets, but have minor differences in
  1377. // syntax. If the asmstring contains {|} characters in them, this integer
  1378. // will specify which alternative to use. For example "{x|y|z}" with Variant
  1379. // == 1, will expand to "y".
  1380. int Variant = 0;
  1381. }
  1382. def DefaultAsmWriter : AsmWriter;
  1383. //===----------------------------------------------------------------------===//
  1384. // Target - This class contains the "global" target information
  1385. //
  1386. class Target {
  1387. // InstructionSet - Instruction set description for this target.
  1388. InstrInfo InstructionSet;
  1389. // AssemblyParsers - The AsmParser instances available for this target.
  1390. list<AsmParser> AssemblyParsers = [DefaultAsmParser];
  1391. /// AssemblyParserVariants - The AsmParserVariant instances available for
  1392. /// this target.
  1393. list<AsmParserVariant> AssemblyParserVariants = [DefaultAsmParserVariant];
  1394. // AssemblyWriters - The AsmWriter instances available for this target.
  1395. list<AsmWriter> AssemblyWriters = [DefaultAsmWriter];
  1396. // AllowRegisterRenaming - Controls whether this target allows
  1397. // post-register-allocation renaming of registers. This is done by
  1398. // setting hasExtraDefRegAllocReq and hasExtraSrcRegAllocReq to 1
  1399. // for all opcodes if this flag is set to 0.
  1400. int AllowRegisterRenaming = 0;
  1401. }
  1402. //===----------------------------------------------------------------------===//
  1403. // SubtargetFeature - A characteristic of the chip set.
  1404. //
  1405. class SubtargetFeature<string n, string a, string v, string d,
  1406. list<SubtargetFeature> i = []> {
  1407. // Name - Feature name. Used by command line (-mattr=) to determine the
  1408. // appropriate target chip.
  1409. //
  1410. string Name = n;
  1411. // Attribute - Attribute to be set by feature.
  1412. //
  1413. string Attribute = a;
  1414. // Value - Value the attribute to be set to by feature.
  1415. //
  1416. string Value = v;
  1417. // Desc - Feature description. Used by command line (-mattr=) to display help
  1418. // information.
  1419. //
  1420. string Desc = d;
  1421. // Implies - Features that this feature implies are present. If one of those
  1422. // features isn't set, then this one shouldn't be set either.
  1423. //
  1424. list<SubtargetFeature> Implies = i;
  1425. }
  1426. /// Specifies a Subtarget feature that this instruction is deprecated on.
  1427. class Deprecated<SubtargetFeature dep> {
  1428. SubtargetFeature DeprecatedFeatureMask = dep;
  1429. }
  1430. /// A custom predicate used to determine if an instruction is
  1431. /// deprecated or not.
  1432. class ComplexDeprecationPredicate<string dep> {
  1433. string ComplexDeprecationPredicate = dep;
  1434. }
  1435. //===----------------------------------------------------------------------===//
  1436. // Processor chip sets - These values represent each of the chip sets supported
  1437. // by the scheduler. Each Processor definition requires corresponding
  1438. // instruction itineraries.
  1439. //
  1440. class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f,
  1441. list<SubtargetFeature> tunef = []> {
  1442. // Name - Chip set name. Used by command line (-mcpu=) to determine the
  1443. // appropriate target chip.
  1444. //
  1445. string Name = n;
  1446. // SchedModel - The machine model for scheduling and instruction cost.
  1447. //
  1448. SchedMachineModel SchedModel = NoSchedModel;
  1449. // ProcItin - The scheduling information for the target processor.
  1450. //
  1451. ProcessorItineraries ProcItin = pi;
  1452. // Features - list of
  1453. list<SubtargetFeature> Features = f;
  1454. // TuneFeatures - list of features for tuning for this CPU. If the target
  1455. // supports -mtune, this should contain the list of features used to make
  1456. // microarchitectural optimization decisions for a given processor. While
  1457. // Features should contain the architectural features for the processor.
  1458. list<SubtargetFeature> TuneFeatures = tunef;
  1459. }
  1460. // ProcessorModel allows subtargets to specify the more general
  1461. // SchedMachineModel instead if a ProcessorItinerary. Subtargets will
  1462. // gradually move to this newer form.
  1463. //
  1464. // Although this class always passes NoItineraries to the Processor
  1465. // class, the SchedMachineModel may still define valid Itineraries.
  1466. class ProcessorModel<string n, SchedMachineModel m, list<SubtargetFeature> f,
  1467. list<SubtargetFeature> tunef = []>
  1468. : Processor<n, NoItineraries, f, tunef> {
  1469. let SchedModel = m;
  1470. }
  1471. //===----------------------------------------------------------------------===//
  1472. // InstrMapping - This class is used to create mapping tables to relate
  1473. // instructions with each other based on the values specified in RowFields,
  1474. // ColFields, KeyCol and ValueCols.
  1475. //
  1476. class InstrMapping {
  1477. // FilterClass - Used to limit search space only to the instructions that
  1478. // define the relationship modeled by this InstrMapping record.
  1479. string FilterClass;
  1480. // RowFields - List of fields/attributes that should be same for all the
  1481. // instructions in a row of the relation table. Think of this as a set of
  1482. // properties shared by all the instructions related by this relationship
  1483. // model and is used to categorize instructions into subgroups. For instance,
  1484. // if we want to define a relation that maps 'Add' instruction to its
  1485. // predicated forms, we can define RowFields like this:
  1486. //
  1487. // let RowFields = BaseOp
  1488. // All add instruction predicated/non-predicated will have to set their BaseOp
  1489. // to the same value.
  1490. //
  1491. // def Add: { let BaseOp = 'ADD'; let predSense = 'nopred' }
  1492. // def Add_predtrue: { let BaseOp = 'ADD'; let predSense = 'true' }
  1493. // def Add_predfalse: { let BaseOp = 'ADD'; let predSense = 'false' }
  1494. list<string> RowFields = [];
  1495. // List of fields/attributes that are same for all the instructions
  1496. // in a column of the relation table.
  1497. // Ex: let ColFields = 'predSense' -- It means that the columns are arranged
  1498. // based on the 'predSense' values. All the instruction in a specific
  1499. // column have the same value and it is fixed for the column according
  1500. // to the values set in 'ValueCols'.
  1501. list<string> ColFields = [];
  1502. // Values for the fields/attributes listed in 'ColFields'.
  1503. // Ex: let KeyCol = 'nopred' -- It means that the key instruction (instruction
  1504. // that models this relation) should be non-predicated.
  1505. // In the example above, 'Add' is the key instruction.
  1506. list<string> KeyCol = [];
  1507. // List of values for the fields/attributes listed in 'ColFields', one for
  1508. // each column in the relation table.
  1509. //
  1510. // Ex: let ValueCols = [['true'],['false']] -- It adds two columns in the
  1511. // table. First column requires all the instructions to have predSense
  1512. // set to 'true' and second column requires it to be 'false'.
  1513. list<list<string> > ValueCols = [];
  1514. }
  1515. //===----------------------------------------------------------------------===//
  1516. // Pull in the common support for calling conventions.
  1517. //
  1518. include "llvm/Target/TargetCallingConv.td"
  1519. //===----------------------------------------------------------------------===//
  1520. // Pull in the common support for DAG isel generation.
  1521. //
  1522. include "llvm/Target/TargetSelectionDAG.td"
  1523. //===----------------------------------------------------------------------===//
  1524. // Pull in the common support for Global ISel register bank info generation.
  1525. //
  1526. include "llvm/Target/GlobalISel/RegisterBank.td"
  1527. //===----------------------------------------------------------------------===//
  1528. // Pull in the common support for DAG isel generation.
  1529. //
  1530. include "llvm/Target/GlobalISel/Target.td"
  1531. //===----------------------------------------------------------------------===//
  1532. // Pull in the common support for the Global ISel DAG-based selector generation.
  1533. //
  1534. include "llvm/Target/GlobalISel/SelectionDAGCompat.td"
  1535. //===----------------------------------------------------------------------===//
  1536. // Pull in the common support for Pfm Counters generation.
  1537. //
  1538. include "llvm/Target/TargetPfmCounters.td"