Target.td 75 KB

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