Target.td 70 KB

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