Target.td 69 KB

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