Target.td 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. //===- Target.td - Target Independent TableGen interface ---*- tablegen -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This file defines the target-independent interfaces which should be
  11. // implemented by each target which is using a TableGen based code generator.
  12. //
  13. //===----------------------------------------------------------------------===//
  14. include "llvm/IR/Intrinsics.td"
  15. //===----------------------------------------------------------------------===//
  16. // Register file description - These classes are used to fill in the target
  17. // description classes.
  18. class RegisterClass; // Forward def
  19. // SubRegIndex - Use instances of SubRegIndex to identify subregisters.
  20. class SubRegIndex<int size, int offset = 0> {
  21. string Namespace = "";
  22. // Size - Size (in bits) of the sub-registers represented by this index.
  23. int Size = size;
  24. // Offset - Offset of the first bit that is part of this sub-register index.
  25. // Set it to -1 if the same index is used to represent sub-registers that can
  26. // be at different offsets (for example when using an index to access an
  27. // element in a register tuple).
  28. int Offset = offset;
  29. // ComposedOf - A list of two SubRegIndex instances, [A, B].
  30. // This indicates that this SubRegIndex is the result of composing A and B.
  31. // See ComposedSubRegIndex.
  32. list<SubRegIndex> ComposedOf = [];
  33. // CoveringSubRegIndices - A list of two or more sub-register indexes that
  34. // cover this sub-register.
  35. //
  36. // This field should normally be left blank as TableGen can infer it.
  37. //
  38. // TableGen automatically detects sub-registers that straddle the registers
  39. // in the SubRegs field of a Register definition. For example:
  40. //
  41. // Q0 = dsub_0 -> D0, dsub_1 -> D1
  42. // Q1 = dsub_0 -> D2, dsub_1 -> D3
  43. // D1_D2 = dsub_0 -> D1, dsub_1 -> D2
  44. // QQ0 = qsub_0 -> Q0, qsub_1 -> Q1
  45. //
  46. // TableGen will infer that D1_D2 is a sub-register of QQ0. It will be given
  47. // the synthetic index dsub_1_dsub_2 unless some SubRegIndex is defined with
  48. // CoveringSubRegIndices = [dsub_1, dsub_2].
  49. list<SubRegIndex> CoveringSubRegIndices = [];
  50. }
  51. // ComposedSubRegIndex - A sub-register that is the result of composing A and B.
  52. // Offset is set to the sum of A and B's Offsets. Size is set to B's Size.
  53. class ComposedSubRegIndex<SubRegIndex A, SubRegIndex B>
  54. : SubRegIndex<B.Size, !if(!eq(A.Offset, -1), -1,
  55. !if(!eq(B.Offset, -1), -1,
  56. !add(A.Offset, B.Offset)))> {
  57. // See SubRegIndex.
  58. let ComposedOf = [A, B];
  59. }
  60. // RegAltNameIndex - The alternate name set to use for register operands of
  61. // this register class when printing.
  62. class RegAltNameIndex {
  63. string Namespace = "";
  64. }
  65. def NoRegAltName : RegAltNameIndex;
  66. // Register - You should define one instance of this class for each register
  67. // in the target machine. String n will become the "name" of the register.
  68. class Register<string n, list<string> altNames = []> {
  69. string Namespace = "";
  70. string AsmName = n;
  71. list<string> AltNames = altNames;
  72. // Aliases - A list of registers that this register overlaps with. A read or
  73. // modification of this register can potentially read or modify the aliased
  74. // registers.
  75. list<Register> Aliases = [];
  76. // SubRegs - A list of registers that are parts of this register. Note these
  77. // are "immediate" sub-registers and the registers within the list do not
  78. // themselves overlap. e.g. For X86, EAX's SubRegs list contains only [AX],
  79. // not [AX, AH, AL].
  80. list<Register> SubRegs = [];
  81. // SubRegIndices - For each register in SubRegs, specify the SubRegIndex used
  82. // to address it. Sub-sub-register indices are automatically inherited from
  83. // SubRegs.
  84. list<SubRegIndex> SubRegIndices = [];
  85. // RegAltNameIndices - The alternate name indices which are valid for this
  86. // register.
  87. list<RegAltNameIndex> RegAltNameIndices = [];
  88. // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
  89. // These values can be determined by locating the <target>.h file in the
  90. // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
  91. // order of these names correspond to the enumeration used by gcc. A value of
  92. // -1 indicates that the gcc number is undefined and -2 that register number
  93. // is invalid for this mode/flavour.
  94. list<int> DwarfNumbers = [];
  95. // CostPerUse - Additional cost of instructions using this register compared
  96. // to other registers in its class. The register allocator will try to
  97. // minimize the number of instructions using a register with a CostPerUse.
  98. // This is used by the x86-64 and ARM Thumb targets where some registers
  99. // require larger instruction encodings.
  100. int CostPerUse = 0;
  101. // CoveredBySubRegs - When this bit is set, the value of this register is
  102. // completely determined by the value of its sub-registers. For example, the
  103. // x86 register AX is covered by its sub-registers AL and AH, but EAX is not
  104. // covered by its sub-register AX.
  105. bit CoveredBySubRegs = 0;
  106. // HWEncoding - The target specific hardware encoding for this register.
  107. bits<16> HWEncoding = 0;
  108. }
  109. // RegisterWithSubRegs - This can be used to define instances of Register which
  110. // need to specify sub-registers.
  111. // List "subregs" specifies which registers are sub-registers to this one. This
  112. // is used to populate the SubRegs and AliasSet fields of TargetRegisterDesc.
  113. // This allows the code generator to be careful not to put two values with
  114. // overlapping live ranges into registers which alias.
  115. class RegisterWithSubRegs<string n, list<Register> subregs> : Register<n> {
  116. let SubRegs = subregs;
  117. }
  118. // DAGOperand - An empty base class that unifies RegisterClass's and other forms
  119. // of Operand's that are legal as type qualifiers in DAG patterns. This should
  120. // only ever be used for defining multiclasses that are polymorphic over both
  121. // RegisterClass's and other Operand's.
  122. class DAGOperand { }
  123. // RegisterClass - Now that all of the registers are defined, and aliases
  124. // between registers are defined, specify which registers belong to which
  125. // register classes. This also defines the default allocation order of
  126. // registers by register allocators.
  127. //
  128. class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,
  129. dag regList, RegAltNameIndex idx = NoRegAltName>
  130. : DAGOperand {
  131. string Namespace = namespace;
  132. // RegType - Specify the list ValueType of the registers in this register
  133. // class. Note that all registers in a register class must have the same
  134. // ValueTypes. This is a list because some targets permit storing different
  135. // types in same register, for example vector values with 128-bit total size,
  136. // but different count/size of items, like SSE on x86.
  137. //
  138. list<ValueType> RegTypes = regTypes;
  139. // Size - Specify the spill size in bits of the registers. A default value of
  140. // zero lets tablgen pick an appropriate size.
  141. int Size = 0;
  142. // Alignment - Specify the alignment required of the registers when they are
  143. // stored or loaded to memory.
  144. //
  145. int Alignment = alignment;
  146. // CopyCost - This value is used to specify the cost of copying a value
  147. // between two registers in this register class. The default value is one
  148. // meaning it takes a single instruction to perform the copying. A negative
  149. // value means copying is extremely expensive or impossible.
  150. int CopyCost = 1;
  151. // MemberList - Specify which registers are in this class. If the
  152. // allocation_order_* method are not specified, this also defines the order of
  153. // allocation used by the register allocator.
  154. //
  155. dag MemberList = regList;
  156. // AltNameIndex - The alternate register name to use when printing operands
  157. // of this register class. Every register in the register class must have
  158. // a valid alternate name for the given index.
  159. RegAltNameIndex altNameIndex = idx;
  160. // isAllocatable - Specify that the register class can be used for virtual
  161. // registers and register allocation. Some register classes are only used to
  162. // model instruction operand constraints, and should have isAllocatable = 0.
  163. bit isAllocatable = 1;
  164. // AltOrders - List of alternative allocation orders. The default order is
  165. // MemberList itself, and that is good enough for most targets since the
  166. // register allocators automatically remove reserved registers and move
  167. // callee-saved registers to the end.
  168. list<dag> AltOrders = [];
  169. // AltOrderSelect - The body of a function that selects the allocation order
  170. // to use in a given machine function. The code will be inserted in a
  171. // function like this:
  172. //
  173. // static inline unsigned f(const MachineFunction &MF) { ... }
  174. //
  175. // The function should return 0 to select the default order defined by
  176. // MemberList, 1 to select the first AltOrders entry and so on.
  177. code AltOrderSelect = [{}];
  178. // Specify allocation priority for register allocators using a greedy
  179. // heuristic. Classes with higher priority values are assigned first. This is
  180. // useful as it is sometimes beneficial to assign registers to highly
  181. // constrained classes first. The value has to be in the range [0,63].
  182. int AllocationPriority = 0;
  183. }
  184. // The memberList in a RegisterClass is a dag of set operations. TableGen
  185. // evaluates these set operations and expand them into register lists. These
  186. // are the most common operation, see test/TableGen/SetTheory.td for more
  187. // examples of what is possible:
  188. //
  189. // (add R0, R1, R2) - Set Union. Each argument can be an individual register, a
  190. // register class, or a sub-expression. This is also the way to simply list
  191. // registers.
  192. //
  193. // (sub GPR, SP) - Set difference. Subtract the last arguments from the first.
  194. //
  195. // (and GPR, CSR) - Set intersection. All registers from the first set that are
  196. // also in the second set.
  197. //
  198. // (sequence "R%u", 0, 15) -> [R0, R1, ..., R15]. Generate a sequence of
  199. // numbered registers. Takes an optional 4th operand which is a stride to use
  200. // when generating the sequence.
  201. //
  202. // (shl GPR, 4) - Remove the first N elements.
  203. //
  204. // (trunc GPR, 4) - Truncate after the first N elements.
  205. //
  206. // (rotl GPR, 1) - Rotate N places to the left.
  207. //
  208. // (rotr GPR, 1) - Rotate N places to the right.
  209. //
  210. // (decimate GPR, 2) - Pick every N'th element, starting with the first.
  211. //
  212. // (interleave A, B, ...) - Interleave the elements from each argument list.
  213. //
  214. // All of these operators work on ordered sets, not lists. That means
  215. // duplicates are removed from sub-expressions.
  216. // Set operators. The rest is defined in TargetSelectionDAG.td.
  217. def sequence;
  218. def decimate;
  219. def interleave;
  220. // RegisterTuples - Automatically generate super-registers by forming tuples of
  221. // sub-registers. This is useful for modeling register sequence constraints
  222. // with pseudo-registers that are larger than the architectural registers.
  223. //
  224. // The sub-register lists are zipped together:
  225. //
  226. // def EvenOdd : RegisterTuples<[sube, subo], [(add R0, R2), (add R1, R3)]>;
  227. //
  228. // Generates the same registers as:
  229. //
  230. // let SubRegIndices = [sube, subo] in {
  231. // def R0_R1 : RegisterWithSubRegs<"", [R0, R1]>;
  232. // def R2_R3 : RegisterWithSubRegs<"", [R2, R3]>;
  233. // }
  234. //
  235. // The generated pseudo-registers inherit super-classes and fields from their
  236. // first sub-register. Most fields from the Register class are inferred, and
  237. // the AsmName and Dwarf numbers are cleared.
  238. //
  239. // RegisterTuples instances can be used in other set operations to form
  240. // register classes and so on. This is the only way of using the generated
  241. // registers.
  242. class RegisterTuples<list<SubRegIndex> Indices, list<dag> Regs> {
  243. // SubRegs - N lists of registers to be zipped up. Super-registers are
  244. // synthesized from the first element of each SubRegs list, the second
  245. // element and so on.
  246. list<dag> SubRegs = Regs;
  247. // SubRegIndices - N SubRegIndex instances. This provides the names of the
  248. // sub-registers in the synthesized super-registers.
  249. list<SubRegIndex> SubRegIndices = Indices;
  250. }
  251. //===----------------------------------------------------------------------===//
  252. // DwarfRegNum - This class provides a mapping of the llvm register enumeration
  253. // to the register numbering used by gcc and gdb. These values are used by a
  254. // debug information writer to describe where values may be located during
  255. // execution.
  256. class DwarfRegNum<list<int> Numbers> {
  257. // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
  258. // These values can be determined by locating the <target>.h file in the
  259. // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
  260. // order of these names correspond to the enumeration used by gcc. A value of
  261. // -1 indicates that the gcc number is undefined and -2 that register number
  262. // is invalid for this mode/flavour.
  263. list<int> DwarfNumbers = Numbers;
  264. }
  265. // DwarfRegAlias - This class declares that a given register uses the same dwarf
  266. // numbers as another one. This is useful for making it clear that the two
  267. // registers do have the same number. It also lets us build a mapping
  268. // from dwarf register number to llvm register.
  269. class DwarfRegAlias<Register reg> {
  270. Register DwarfAlias = reg;
  271. }
  272. //===----------------------------------------------------------------------===//
  273. // Pull in the common support for scheduling
  274. //
  275. include "llvm/Target/TargetSchedule.td"
  276. class Predicate; // Forward def
  277. //===----------------------------------------------------------------------===//
  278. // Instruction set description - These classes correspond to the C++ classes in
  279. // the Target/TargetInstrInfo.h file.
  280. //
  281. class Instruction {
  282. string Namespace = "";
  283. dag OutOperandList; // An dag containing the MI def operand list.
  284. dag InOperandList; // An dag containing the MI use operand list.
  285. string AsmString = ""; // The .s format to print the instruction with.
  286. // Pattern - Set to the DAG pattern for this instruction, if we know of one,
  287. // otherwise, uninitialized.
  288. list<dag> Pattern;
  289. // The follow state will eventually be inferred automatically from the
  290. // instruction pattern.
  291. list<Register> Uses = []; // Default to using no non-operand registers
  292. list<Register> Defs = []; // Default to modifying no non-operand registers
  293. // Predicates - List of predicates which will be turned into isel matching
  294. // code.
  295. list<Predicate> Predicates = [];
  296. // Size - Size of encoded instruction, or zero if the size cannot be determined
  297. // from the opcode.
  298. int Size = 0;
  299. // DecoderNamespace - The "namespace" in which this instruction exists, on
  300. // targets like ARM which multiple ISA namespaces exist.
  301. string DecoderNamespace = "";
  302. // Code size, for instruction selection.
  303. // FIXME: What does this actually mean?
  304. int CodeSize = 0;
  305. // Added complexity passed onto matching pattern.
  306. int AddedComplexity = 0;
  307. // These bits capture information about the high-level semantics of the
  308. // instruction.
  309. bit isReturn = 0; // Is this instruction a return instruction?
  310. bit isBranch = 0; // Is this instruction a branch instruction?
  311. bit isIndirectBranch = 0; // Is this instruction an indirect branch?
  312. bit isCompare = 0; // Is this instruction a comparison instruction?
  313. bit isMoveImm = 0; // Is this instruction a move immediate instruction?
  314. bit isBitcast = 0; // Is this instruction a bitcast instruction?
  315. bit isSelect = 0; // Is this instruction a select instruction?
  316. bit isBarrier = 0; // Can control flow fall through this instruction?
  317. bit isCall = 0; // Is this instruction a call instruction?
  318. bit canFoldAsLoad = 0; // Can this be folded as a simple memory operand?
  319. bit mayLoad = ?; // Is it possible for this inst to read memory?
  320. bit mayStore = ?; // Is it possible for this inst to write memory?
  321. bit isConvertibleToThreeAddress = 0; // Can this 2-addr instruction promote?
  322. bit isCommutable = 0; // Is this 3 operand instruction commutable?
  323. bit isTerminator = 0; // Is this part of the terminator for a basic block?
  324. bit isReMaterializable = 0; // Is this instruction re-materializable?
  325. bit isPredicable = 0; // Is this instruction predicable?
  326. bit hasDelaySlot = 0; // Does this instruction have an delay slot?
  327. bit usesCustomInserter = 0; // Pseudo instr needing special help.
  328. bit hasPostISelHook = 0; // To be *adjusted* after isel by target hook.
  329. bit hasCtrlDep = 0; // Does this instruction r/w ctrl-flow chains?
  330. bit isNotDuplicable = 0; // Is it unsafe to duplicate this instruction?
  331. bit isConvergent = 0; // Is this instruction convergent?
  332. bit isAsCheapAsAMove = 0; // As cheap (or cheaper) than a move instruction.
  333. bit hasExtraSrcRegAllocReq = 0; // Sources have special regalloc requirement?
  334. bit hasExtraDefRegAllocReq = 0; // Defs have special regalloc requirement?
  335. bit isRegSequence = 0; // Is this instruction a kind of reg sequence?
  336. // If so, make sure to override
  337. // TargetInstrInfo::getRegSequenceLikeInputs.
  338. bit isPseudo = 0; // Is this instruction a pseudo-instruction?
  339. // If so, won't have encoding information for
  340. // the [MC]CodeEmitter stuff.
  341. bit isExtractSubreg = 0; // Is this instruction a kind of extract subreg?
  342. // If so, make sure to override
  343. // TargetInstrInfo::getExtractSubregLikeInputs.
  344. bit isInsertSubreg = 0; // Is this instruction a kind of insert subreg?
  345. // If so, make sure to override
  346. // TargetInstrInfo::getInsertSubregLikeInputs.
  347. // Side effect flags - When set, the flags have these meanings:
  348. //
  349. // hasSideEffects - The instruction has side effects that are not
  350. // captured by any operands of the instruction or other flags.
  351. //
  352. bit hasSideEffects = ?;
  353. // Is this instruction a "real" instruction (with a distinct machine
  354. // encoding), or is it a pseudo instruction used for codegen modeling
  355. // purposes.
  356. // FIXME: For now this is distinct from isPseudo, above, as code-gen-only
  357. // instructions can (and often do) still have encoding information
  358. // associated with them. Once we've migrated all of them over to true
  359. // pseudo-instructions that are lowered to real instructions prior to
  360. // the printer/emitter, we can remove this attribute and just use isPseudo.
  361. //
  362. // The intended use is:
  363. // isPseudo: Does not have encoding information and should be expanded,
  364. // at the latest, during lowering to MCInst.
  365. //
  366. // isCodeGenOnly: Does have encoding information and can go through to the
  367. // CodeEmitter unchanged, but duplicates a canonical instruction
  368. // definition's encoding and should be ignored when constructing the
  369. // assembler match tables.
  370. bit isCodeGenOnly = 0;
  371. // Is this instruction a pseudo instruction for use by the assembler parser.
  372. bit isAsmParserOnly = 0;
  373. InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling.
  374. // Scheduling information from TargetSchedule.td.
  375. list<SchedReadWrite> SchedRW;
  376. string Constraints = ""; // OperandConstraint, e.g. $src = $dst.
  377. /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not
  378. /// be encoded into the output machineinstr.
  379. string DisableEncoding = "";
  380. string PostEncoderMethod = "";
  381. string DecoderMethod = "";
  382. /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
  383. bits<64> TSFlags = 0;
  384. ///@name Assembler Parser Support
  385. ///@{
  386. string AsmMatchConverter = "";
  387. /// TwoOperandAliasConstraint - Enable TableGen to auto-generate a
  388. /// two-operand matcher inst-alias for a three operand instruction.
  389. /// For example, the arm instruction "add r3, r3, r5" can be written
  390. /// as "add r3, r5". The constraint is of the same form as a tied-operand
  391. /// constraint. For example, "$Rn = $Rd".
  392. string TwoOperandAliasConstraint = "";
  393. ///@}
  394. /// UseNamedOperandTable - If set, the operand indices of this instruction
  395. /// can be queried via the getNamedOperandIdx() function which is generated
  396. /// by TableGen.
  397. bit UseNamedOperandTable = 0;
  398. }
  399. /// PseudoInstExpansion - Expansion information for a pseudo-instruction.
  400. /// Which instruction it expands to and how the operands map from the
  401. /// pseudo.
  402. class PseudoInstExpansion<dag Result> {
  403. dag ResultInst = Result; // The instruction to generate.
  404. bit isPseudo = 1;
  405. }
  406. /// Predicates - These are extra conditionals which are turned into instruction
  407. /// selector matching code. Currently each predicate is just a string.
  408. class Predicate<string cond> {
  409. string CondString = cond;
  410. /// AssemblerMatcherPredicate - If this feature can be used by the assembler
  411. /// matcher, this is true. Targets should set this by inheriting their
  412. /// feature from the AssemblerPredicate class in addition to Predicate.
  413. bit AssemblerMatcherPredicate = 0;
  414. /// AssemblerCondString - Name of the subtarget feature being tested used
  415. /// as alternative condition string used for assembler matcher.
  416. /// e.g. "ModeThumb" is translated to "(Bits & ModeThumb) != 0".
  417. /// "!ModeThumb" is translated to "(Bits & ModeThumb) == 0".
  418. /// It can also list multiple features separated by ",".
  419. /// e.g. "ModeThumb,FeatureThumb2" is translated to
  420. /// "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0".
  421. string AssemblerCondString = "";
  422. /// PredicateName - User-level name to use for the predicate. Mainly for use
  423. /// in diagnostics such as missing feature errors in the asm matcher.
  424. string PredicateName = "";
  425. }
  426. /// NoHonorSignDependentRounding - This predicate is true if support for
  427. /// sign-dependent-rounding is not enabled.
  428. def NoHonorSignDependentRounding
  429. : Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">;
  430. class Requires<list<Predicate> preds> {
  431. list<Predicate> Predicates = preds;
  432. }
  433. /// ops definition - This is just a simple marker used to identify the operand
  434. /// list for an instruction. outs and ins are identical both syntactically and
  435. /// semantically; they are used to define def operands and use operands to
  436. /// improve readibility. This should be used like this:
  437. /// (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar.
  438. def ops;
  439. def outs;
  440. def ins;
  441. /// variable_ops definition - Mark this instruction as taking a variable number
  442. /// of operands.
  443. def variable_ops;
  444. /// PointerLikeRegClass - Values that are designed to have pointer width are
  445. /// derived from this. TableGen treats the register class as having a symbolic
  446. /// type that it doesn't know, and resolves the actual regclass to use by using
  447. /// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
  448. class PointerLikeRegClass<int Kind> {
  449. int RegClassKind = Kind;
  450. }
  451. /// ptr_rc definition - Mark this operand as being a pointer value whose
  452. /// register class is resolved dynamically via a callback to TargetInstrInfo.
  453. /// FIXME: We should probably change this to a class which contain a list of
  454. /// flags. But currently we have but one flag.
  455. def ptr_rc : PointerLikeRegClass<0>;
  456. /// unknown definition - Mark this operand as being of unknown type, causing
  457. /// it to be resolved by inference in the context it is used.
  458. class unknown_class;
  459. def unknown : unknown_class;
  460. /// AsmOperandClass - Representation for the kinds of operands which the target
  461. /// specific parser can create and the assembly matcher may need to distinguish.
  462. ///
  463. /// Operand classes are used to define the order in which instructions are
  464. /// matched, to ensure that the instruction which gets matched for any
  465. /// particular list of operands is deterministic.
  466. ///
  467. /// The target specific parser must be able to classify a parsed operand into a
  468. /// unique class which does not partially overlap with any other classes. It can
  469. /// match a subset of some other class, in which case the super class field
  470. /// should be defined.
  471. class AsmOperandClass {
  472. /// The name to use for this class, which should be usable as an enum value.
  473. string Name = ?;
  474. /// The super classes of this operand.
  475. list<AsmOperandClass> SuperClasses = [];
  476. /// The name of the method on the target specific operand to call to test
  477. /// whether the operand is an instance of this class. If not set, this will
  478. /// default to "isFoo", where Foo is the AsmOperandClass name. The method
  479. /// signature should be:
  480. /// bool isFoo() const;
  481. string PredicateMethod = ?;
  482. /// The name of the method on the target specific operand to call to add the
  483. /// target specific operand to an MCInst. If not set, this will default to
  484. /// "addFooOperands", where Foo is the AsmOperandClass name. The method
  485. /// signature should be:
  486. /// void addFooOperands(MCInst &Inst, unsigned N) const;
  487. string RenderMethod = ?;
  488. /// The name of the method on the target specific operand to call to custom
  489. /// handle the operand parsing. This is useful when the operands do not relate
  490. /// to immediates or registers and are very instruction specific (as flags to
  491. /// set in a processor register, coprocessor number, ...).
  492. string ParserMethod = ?;
  493. // The diagnostic type to present when referencing this operand in a
  494. // match failure error message. By default, use a generic "invalid operand"
  495. // diagnostic. The target AsmParser maps these codes to text.
  496. string DiagnosticType = "";
  497. }
  498. def ImmAsmOperand : AsmOperandClass {
  499. let Name = "Imm";
  500. }
  501. /// Operand Types - These provide the built-in operand types that may be used
  502. /// by a target. Targets can optionally provide their own operand types as
  503. /// needed, though this should not be needed for RISC targets.
  504. class Operand<ValueType ty> : DAGOperand {
  505. ValueType Type = ty;
  506. string PrintMethod = "printOperand";
  507. string EncoderMethod = "";
  508. string DecoderMethod = "";
  509. string OperandType = "OPERAND_UNKNOWN";
  510. dag MIOperandInfo = (ops);
  511. // MCOperandPredicate - Optionally, a code fragment operating on
  512. // const MCOperand &MCOp, and returning a bool, to indicate if
  513. // the value of MCOp is valid for the specific subclass of Operand
  514. code MCOperandPredicate;
  515. // ParserMatchClass - The "match class" that operands of this type fit
  516. // in. Match classes are used to define the order in which instructions are
  517. // match, to ensure that which instructions gets matched is deterministic.
  518. //
  519. // The target specific parser must be able to classify an parsed operand into
  520. // a unique class, which does not partially overlap with any other classes. It
  521. // can match a subset of some other class, in which case the AsmOperandClass
  522. // should declare the other operand as one of its super classes.
  523. AsmOperandClass ParserMatchClass = ImmAsmOperand;
  524. }
  525. class RegisterOperand<RegisterClass regclass, string pm = "printOperand">
  526. : DAGOperand {
  527. // RegClass - The register class of the operand.
  528. RegisterClass RegClass = regclass;
  529. // PrintMethod - The target method to call to print register operands of
  530. // this type. The method normally will just use an alt-name index to look
  531. // up the name to print. Default to the generic printOperand().
  532. string PrintMethod = pm;
  533. // ParserMatchClass - The "match class" that operands of this type fit
  534. // in. Match classes are used to define the order in which instructions are
  535. // match, to ensure that which instructions gets matched is deterministic.
  536. //
  537. // The target specific parser must be able to classify an parsed operand into
  538. // a unique class, which does not partially overlap with any other classes. It
  539. // can match a subset of some other class, in which case the AsmOperandClass
  540. // should declare the other operand as one of its super classes.
  541. AsmOperandClass ParserMatchClass;
  542. string OperandNamespace = "MCOI";
  543. string OperandType = "OPERAND_REGISTER";
  544. }
  545. let OperandType = "OPERAND_IMMEDIATE" in {
  546. def i1imm : Operand<i1>;
  547. def i8imm : Operand<i8>;
  548. def i16imm : Operand<i16>;
  549. def i32imm : Operand<i32>;
  550. def i64imm : Operand<i64>;
  551. def f32imm : Operand<f32>;
  552. def f64imm : Operand<f64>;
  553. }
  554. /// zero_reg definition - Special node to stand for the zero register.
  555. ///
  556. def zero_reg;
  557. /// All operands which the MC layer classifies as predicates should inherit from
  558. /// this class in some manner. This is already handled for the most commonly
  559. /// used PredicateOperand, but may be useful in other circumstances.
  560. class PredicateOp;
  561. /// OperandWithDefaultOps - This Operand class can be used as the parent class
  562. /// for an Operand that needs to be initialized with a default value if
  563. /// no value is supplied in a pattern. This class can be used to simplify the
  564. /// pattern definitions for instructions that have target specific flags
  565. /// encoded as immediate operands.
  566. class OperandWithDefaultOps<ValueType ty, dag defaultops>
  567. : Operand<ty> {
  568. dag DefaultOps = defaultops;
  569. }
  570. /// PredicateOperand - This can be used to define a predicate operand for an
  571. /// instruction. OpTypes specifies the MIOperandInfo for the operand, and
  572. /// AlwaysVal specifies the value of this predicate when set to "always
  573. /// execute".
  574. class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal>
  575. : OperandWithDefaultOps<ty, AlwaysVal>, PredicateOp {
  576. let MIOperandInfo = OpTypes;
  577. }
  578. /// OptionalDefOperand - This is used to define a optional definition operand
  579. /// for an instruction. DefaultOps is the register the operand represents if
  580. /// none is supplied, e.g. zero_reg.
  581. class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>
  582. : OperandWithDefaultOps<ty, defaultops> {
  583. let MIOperandInfo = OpTypes;
  584. }
  585. // InstrInfo - This class should only be instantiated once to provide parameters
  586. // which are global to the target machine.
  587. //
  588. class InstrInfo {
  589. // Target can specify its instructions in either big or little-endian formats.
  590. // For instance, while both Sparc and PowerPC are big-endian platforms, the
  591. // Sparc manual specifies its instructions in the format [31..0] (big), while
  592. // PowerPC specifies them using the format [0..31] (little).
  593. bit isLittleEndianEncoding = 0;
  594. // The instruction properties mayLoad, mayStore, and hasSideEffects are unset
  595. // by default, and TableGen will infer their value from the instruction
  596. // pattern when possible.
  597. //
  598. // Normally, TableGen will issue an error it it can't infer the value of a
  599. // property that hasn't been set explicitly. When guessInstructionProperties
  600. // is set, it will guess a safe value instead.
  601. //
  602. // This option is a temporary migration help. It will go away.
  603. bit guessInstructionProperties = 1;
  604. // TableGen's instruction encoder generator has support for matching operands
  605. // to bit-field variables both by name and by position. While matching by
  606. // name is preferred, this is currently not possible for complex operands,
  607. // and some targets still reply on the positional encoding rules. When
  608. // generating a decoder for such targets, the positional encoding rules must
  609. // be used by the decoder generator as well.
  610. //
  611. // This option is temporary; it will go away once the TableGen decoder
  612. // generator has better support for complex operands and targets have
  613. // migrated away from using positionally encoded operands.
  614. bit decodePositionallyEncodedOperands = 0;
  615. // When set, this indicates that there will be no overlap between those
  616. // operands that are matched by ordering (positional operands) and those
  617. // matched by name.
  618. //
  619. // This option is temporary; it will go away once the TableGen decoder
  620. // generator has better support for complex operands and targets have
  621. // migrated away from using positionally encoded operands.
  622. bit noNamedPositionallyEncodedOperands = 0;
  623. }
  624. // Standard Pseudo Instructions.
  625. // This list must match TargetOpcodes.h and CodeGenTarget.cpp.
  626. // Only these instructions are allowed in the TargetOpcode namespace.
  627. let isCodeGenOnly = 1, isPseudo = 1, Namespace = "TargetOpcode" in {
  628. def PHI : Instruction {
  629. let OutOperandList = (outs);
  630. let InOperandList = (ins variable_ops);
  631. let AsmString = "PHINODE";
  632. }
  633. def INLINEASM : Instruction {
  634. let OutOperandList = (outs);
  635. let InOperandList = (ins variable_ops);
  636. let AsmString = "";
  637. let hasSideEffects = 0; // Note side effect is encoded in an operand.
  638. }
  639. def CFI_INSTRUCTION : Instruction {
  640. let OutOperandList = (outs);
  641. let InOperandList = (ins i32imm:$id);
  642. let AsmString = "";
  643. let hasCtrlDep = 1;
  644. let isNotDuplicable = 1;
  645. }
  646. def EH_LABEL : Instruction {
  647. let OutOperandList = (outs);
  648. let InOperandList = (ins i32imm:$id);
  649. let AsmString = "";
  650. let hasCtrlDep = 1;
  651. let isNotDuplicable = 1;
  652. }
  653. def GC_LABEL : Instruction {
  654. let OutOperandList = (outs);
  655. let InOperandList = (ins i32imm:$id);
  656. let AsmString = "";
  657. let hasCtrlDep = 1;
  658. let isNotDuplicable = 1;
  659. }
  660. def KILL : Instruction {
  661. let OutOperandList = (outs);
  662. let InOperandList = (ins variable_ops);
  663. let AsmString = "";
  664. let hasSideEffects = 0;
  665. }
  666. def EXTRACT_SUBREG : Instruction {
  667. let OutOperandList = (outs unknown:$dst);
  668. let InOperandList = (ins unknown:$supersrc, i32imm:$subidx);
  669. let AsmString = "";
  670. let hasSideEffects = 0;
  671. }
  672. def INSERT_SUBREG : Instruction {
  673. let OutOperandList = (outs unknown:$dst);
  674. let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx);
  675. let AsmString = "";
  676. let hasSideEffects = 0;
  677. let Constraints = "$supersrc = $dst";
  678. }
  679. def IMPLICIT_DEF : Instruction {
  680. let OutOperandList = (outs unknown:$dst);
  681. let InOperandList = (ins);
  682. let AsmString = "";
  683. let hasSideEffects = 0;
  684. let isReMaterializable = 1;
  685. let isAsCheapAsAMove = 1;
  686. }
  687. def SUBREG_TO_REG : Instruction {
  688. let OutOperandList = (outs unknown:$dst);
  689. let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx);
  690. let AsmString = "";
  691. let hasSideEffects = 0;
  692. }
  693. def COPY_TO_REGCLASS : Instruction {
  694. let OutOperandList = (outs unknown:$dst);
  695. let InOperandList = (ins unknown:$src, i32imm:$regclass);
  696. let AsmString = "";
  697. let hasSideEffects = 0;
  698. let isAsCheapAsAMove = 1;
  699. }
  700. def DBG_VALUE : Instruction {
  701. let OutOperandList = (outs);
  702. let InOperandList = (ins variable_ops);
  703. let AsmString = "DBG_VALUE";
  704. let hasSideEffects = 0;
  705. }
  706. def REG_SEQUENCE : Instruction {
  707. let OutOperandList = (outs unknown:$dst);
  708. let InOperandList = (ins unknown:$supersrc, variable_ops);
  709. let AsmString = "";
  710. let hasSideEffects = 0;
  711. let isAsCheapAsAMove = 1;
  712. }
  713. def COPY : Instruction {
  714. let OutOperandList = (outs unknown:$dst);
  715. let InOperandList = (ins unknown:$src);
  716. let AsmString = "";
  717. let hasSideEffects = 0;
  718. let isAsCheapAsAMove = 1;
  719. }
  720. def BUNDLE : Instruction {
  721. let OutOperandList = (outs);
  722. let InOperandList = (ins variable_ops);
  723. let AsmString = "BUNDLE";
  724. }
  725. def LIFETIME_START : Instruction {
  726. let OutOperandList = (outs);
  727. let InOperandList = (ins i32imm:$id);
  728. let AsmString = "LIFETIME_START";
  729. let hasSideEffects = 0;
  730. }
  731. def LIFETIME_END : Instruction {
  732. let OutOperandList = (outs);
  733. let InOperandList = (ins i32imm:$id);
  734. let AsmString = "LIFETIME_END";
  735. let hasSideEffects = 0;
  736. }
  737. def STACKMAP : Instruction {
  738. let OutOperandList = (outs);
  739. let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops);
  740. let isCall = 1;
  741. let mayLoad = 1;
  742. let usesCustomInserter = 1;
  743. }
  744. def PATCHPOINT : Instruction {
  745. let OutOperandList = (outs unknown:$dst);
  746. let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee,
  747. i32imm:$nargs, i32imm:$cc, variable_ops);
  748. let isCall = 1;
  749. let mayLoad = 1;
  750. let usesCustomInserter = 1;
  751. }
  752. def STATEPOINT : Instruction {
  753. let OutOperandList = (outs);
  754. let InOperandList = (ins variable_ops);
  755. let usesCustomInserter = 1;
  756. let mayLoad = 1;
  757. let mayStore = 1;
  758. let hasSideEffects = 1;
  759. let isCall = 1;
  760. }
  761. def LOAD_STACK_GUARD : Instruction {
  762. let OutOperandList = (outs ptr_rc:$dst);
  763. let InOperandList = (ins);
  764. let mayLoad = 1;
  765. bit isReMaterializable = 1;
  766. let hasSideEffects = 0;
  767. bit isPseudo = 1;
  768. }
  769. def LOCAL_ESCAPE : Instruction {
  770. // This instruction is really just a label. It has to be part of the chain so
  771. // that it doesn't get dropped from the DAG, but it produces nothing and has
  772. // no side effects.
  773. let OutOperandList = (outs);
  774. let InOperandList = (ins ptr_rc:$symbol, i32imm:$id);
  775. let hasSideEffects = 0;
  776. let hasCtrlDep = 1;
  777. }
  778. def FAULTING_LOAD_OP : Instruction {
  779. let OutOperandList = (outs unknown:$dst);
  780. let InOperandList = (ins variable_ops);
  781. let usesCustomInserter = 1;
  782. let mayLoad = 1;
  783. }
  784. }
  785. //===----------------------------------------------------------------------===//
  786. // AsmParser - This class can be implemented by targets that wish to implement
  787. // .s file parsing.
  788. //
  789. // Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel
  790. // syntax on X86 for example).
  791. //
  792. class AsmParser {
  793. // AsmParserClassName - This specifies the suffix to use for the asmparser
  794. // class. Generated AsmParser classes are always prefixed with the target
  795. // name.
  796. string AsmParserClassName = "AsmParser";
  797. // AsmParserInstCleanup - If non-empty, this is the name of a custom member
  798. // function of the AsmParser class to call on every matched instruction.
  799. // This can be used to perform target specific instruction post-processing.
  800. string AsmParserInstCleanup = "";
  801. // ShouldEmitMatchRegisterName - Set to false if the target needs a hand
  802. // written register name matcher
  803. bit ShouldEmitMatchRegisterName = 1;
  804. /// Does the instruction mnemonic allow '.'
  805. bit MnemonicContainsDot = 0;
  806. }
  807. def DefaultAsmParser : AsmParser;
  808. //===----------------------------------------------------------------------===//
  809. // AsmParserVariant - Subtargets can have multiple different assembly parsers
  810. // (e.g. AT&T vs Intel syntax on X86 for example). This class can be
  811. // implemented by targets to describe such variants.
  812. //
  813. class AsmParserVariant {
  814. // Variant - AsmParsers can be of multiple different variants. Variants are
  815. // used to support targets that need to parser multiple formats for the
  816. // assembly language.
  817. int Variant = 0;
  818. // Name - The AsmParser variant name (e.g., AT&T vs Intel).
  819. string Name = "";
  820. // CommentDelimiter - If given, the delimiter string used to recognize
  821. // comments which are hard coded in the .td assembler strings for individual
  822. // instructions.
  823. string CommentDelimiter = "";
  824. // RegisterPrefix - If given, the token prefix which indicates a register
  825. // token. This is used by the matcher to automatically recognize hard coded
  826. // register tokens as constrained registers, instead of tokens, for the
  827. // purposes of matching.
  828. string RegisterPrefix = "";
  829. }
  830. def DefaultAsmParserVariant : AsmParserVariant;
  831. /// AssemblerPredicate - This is a Predicate that can be used when the assembler
  832. /// matches instructions and aliases.
  833. class AssemblerPredicate<string cond, string name = ""> {
  834. bit AssemblerMatcherPredicate = 1;
  835. string AssemblerCondString = cond;
  836. string PredicateName = name;
  837. }
  838. /// TokenAlias - This class allows targets to define assembler token
  839. /// operand aliases. That is, a token literal operand which is equivalent
  840. /// to another, canonical, token literal. For example, ARM allows:
  841. /// vmov.u32 s4, #0 -> vmov.i32, #0
  842. /// 'u32' is a more specific designator for the 32-bit integer type specifier
  843. /// and is legal for any instruction which accepts 'i32' as a datatype suffix.
  844. /// def : TokenAlias<".u32", ".i32">;
  845. ///
  846. /// This works by marking the match class of 'From' as a subclass of the
  847. /// match class of 'To'.
  848. class TokenAlias<string From, string To> {
  849. string FromToken = From;
  850. string ToToken = To;
  851. }
  852. /// MnemonicAlias - This class allows targets to define assembler mnemonic
  853. /// aliases. This should be used when all forms of one mnemonic are accepted
  854. /// with a different mnemonic. For example, X86 allows:
  855. /// sal %al, 1 -> shl %al, 1
  856. /// sal %ax, %cl -> shl %ax, %cl
  857. /// sal %eax, %cl -> shl %eax, %cl
  858. /// etc. Though "sal" is accepted with many forms, all of them are directly
  859. /// translated to a shl, so it can be handled with (in the case of X86, it
  860. /// actually has one for each suffix as well):
  861. /// def : MnemonicAlias<"sal", "shl">;
  862. ///
  863. /// Mnemonic aliases are mapped before any other translation in the match phase,
  864. /// and do allow Requires predicates, e.g.:
  865. ///
  866. /// def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>;
  867. /// def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>;
  868. ///
  869. /// Mnemonic aliases can also be constrained to specific variants, e.g.:
  870. ///
  871. /// def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>;
  872. ///
  873. /// If no variant (e.g., "att" or "intel") is specified then the alias is
  874. /// applied unconditionally.
  875. class MnemonicAlias<string From, string To, string VariantName = ""> {
  876. string FromMnemonic = From;
  877. string ToMnemonic = To;
  878. string AsmVariantName = VariantName;
  879. // Predicates - Predicates that must be true for this remapping to happen.
  880. list<Predicate> Predicates = [];
  881. }
  882. /// InstAlias - This defines an alternate assembly syntax that is allowed to
  883. /// match an instruction that has a different (more canonical) assembly
  884. /// representation.
  885. class InstAlias<string Asm, dag Result, int Emit = 1> {
  886. string AsmString = Asm; // The .s format to match the instruction with.
  887. dag ResultInst = Result; // The MCInst to generate.
  888. // This determines which order the InstPrinter detects aliases for
  889. // printing. A larger value makes the alias more likely to be
  890. // emitted. The Instruction's own definition is notionally 0.5, so 0
  891. // disables printing and 1 enables it if there are no conflicting aliases.
  892. int EmitPriority = Emit;
  893. // Predicates - Predicates that must be true for this to match.
  894. list<Predicate> Predicates = [];
  895. // If the instruction specified in Result has defined an AsmMatchConverter
  896. // then setting this to 1 will cause the alias to use the AsmMatchConverter
  897. // function when converting the OperandVector into an MCInst instead of the
  898. // function that is generated by the dag Result.
  899. // Setting this to 0 will cause the alias to ignore the Result instruction's
  900. // defined AsmMatchConverter and instead use the function generated by the
  901. // dag Result.
  902. bit UseInstAsmMatchConverter = 1;
  903. }
  904. //===----------------------------------------------------------------------===//
  905. // AsmWriter - This class can be implemented by targets that need to customize
  906. // the format of the .s file writer.
  907. //
  908. // Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax
  909. // on X86 for example).
  910. //
  911. class AsmWriter {
  912. // AsmWriterClassName - This specifies the suffix to use for the asmwriter
  913. // class. Generated AsmWriter classes are always prefixed with the target
  914. // name.
  915. string AsmWriterClassName = "InstPrinter";
  916. // PassSubtarget - Determines whether MCSubtargetInfo should be passed to
  917. // the various print methods.
  918. // FIXME: Remove after all ports are updated.
  919. int PassSubtarget = 0;
  920. // Variant - AsmWriters can be of multiple different variants. Variants are
  921. // used to support targets that need to emit assembly code in ways that are
  922. // mostly the same for different targets, but have minor differences in
  923. // syntax. If the asmstring contains {|} characters in them, this integer
  924. // will specify which alternative to use. For example "{x|y|z}" with Variant
  925. // == 1, will expand to "y".
  926. int Variant = 0;
  927. }
  928. def DefaultAsmWriter : AsmWriter;
  929. //===----------------------------------------------------------------------===//
  930. // Target - This class contains the "global" target information
  931. //
  932. class Target {
  933. // InstructionSet - Instruction set description for this target.
  934. InstrInfo InstructionSet;
  935. // AssemblyParsers - The AsmParser instances available for this target.
  936. list<AsmParser> AssemblyParsers = [DefaultAsmParser];
  937. /// AssemblyParserVariants - The AsmParserVariant instances available for
  938. /// this target.
  939. list<AsmParserVariant> AssemblyParserVariants = [DefaultAsmParserVariant];
  940. // AssemblyWriters - The AsmWriter instances available for this target.
  941. list<AsmWriter> AssemblyWriters = [DefaultAsmWriter];
  942. }
  943. //===----------------------------------------------------------------------===//
  944. // SubtargetFeature - A characteristic of the chip set.
  945. //
  946. class SubtargetFeature<string n, string a, string v, string d,
  947. list<SubtargetFeature> i = []> {
  948. // Name - Feature name. Used by command line (-mattr=) to determine the
  949. // appropriate target chip.
  950. //
  951. string Name = n;
  952. // Attribute - Attribute to be set by feature.
  953. //
  954. string Attribute = a;
  955. // Value - Value the attribute to be set to by feature.
  956. //
  957. string Value = v;
  958. // Desc - Feature description. Used by command line (-mattr=) to display help
  959. // information.
  960. //
  961. string Desc = d;
  962. // Implies - Features that this feature implies are present. If one of those
  963. // features isn't set, then this one shouldn't be set either.
  964. //
  965. list<SubtargetFeature> Implies = i;
  966. }
  967. /// Specifies a Subtarget feature that this instruction is deprecated on.
  968. class Deprecated<SubtargetFeature dep> {
  969. SubtargetFeature DeprecatedFeatureMask = dep;
  970. }
  971. /// A custom predicate used to determine if an instruction is
  972. /// deprecated or not.
  973. class ComplexDeprecationPredicate<string dep> {
  974. string ComplexDeprecationPredicate = dep;
  975. }
  976. //===----------------------------------------------------------------------===//
  977. // Processor chip sets - These values represent each of the chip sets supported
  978. // by the scheduler. Each Processor definition requires corresponding
  979. // instruction itineraries.
  980. //
  981. class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f> {
  982. // Name - Chip set name. Used by command line (-mcpu=) to determine the
  983. // appropriate target chip.
  984. //
  985. string Name = n;
  986. // SchedModel - The machine model for scheduling and instruction cost.
  987. //
  988. SchedMachineModel SchedModel = NoSchedModel;
  989. // ProcItin - The scheduling information for the target processor.
  990. //
  991. ProcessorItineraries ProcItin = pi;
  992. // Features - list of
  993. list<SubtargetFeature> Features = f;
  994. }
  995. // ProcessorModel allows subtargets to specify the more general
  996. // SchedMachineModel instead if a ProcessorItinerary. Subtargets will
  997. // gradually move to this newer form.
  998. //
  999. // Although this class always passes NoItineraries to the Processor
  1000. // class, the SchedMachineModel may still define valid Itineraries.
  1001. class ProcessorModel<string n, SchedMachineModel m, list<SubtargetFeature> f>
  1002. : Processor<n, NoItineraries, f> {
  1003. let SchedModel = m;
  1004. }
  1005. //===----------------------------------------------------------------------===//
  1006. // InstrMapping - This class is used to create mapping tables to relate
  1007. // instructions with each other based on the values specified in RowFields,
  1008. // ColFields, KeyCol and ValueCols.
  1009. //
  1010. class InstrMapping {
  1011. // FilterClass - Used to limit search space only to the instructions that
  1012. // define the relationship modeled by this InstrMapping record.
  1013. string FilterClass;
  1014. // RowFields - List of fields/attributes that should be same for all the
  1015. // instructions in a row of the relation table. Think of this as a set of
  1016. // properties shared by all the instructions related by this relationship
  1017. // model and is used to categorize instructions into subgroups. For instance,
  1018. // if we want to define a relation that maps 'Add' instruction to its
  1019. // predicated forms, we can define RowFields like this:
  1020. //
  1021. // let RowFields = BaseOp
  1022. // All add instruction predicated/non-predicated will have to set their BaseOp
  1023. // to the same value.
  1024. //
  1025. // def Add: { let BaseOp = 'ADD'; let predSense = 'nopred' }
  1026. // def Add_predtrue: { let BaseOp = 'ADD'; let predSense = 'true' }
  1027. // def Add_predfalse: { let BaseOp = 'ADD'; let predSense = 'false' }
  1028. list<string> RowFields = [];
  1029. // List of fields/attributes that are same for all the instructions
  1030. // in a column of the relation table.
  1031. // Ex: let ColFields = 'predSense' -- It means that the columns are arranged
  1032. // based on the 'predSense' values. All the instruction in a specific
  1033. // column have the same value and it is fixed for the column according
  1034. // to the values set in 'ValueCols'.
  1035. list<string> ColFields = [];
  1036. // Values for the fields/attributes listed in 'ColFields'.
  1037. // Ex: let KeyCol = 'nopred' -- It means that the key instruction (instruction
  1038. // that models this relation) should be non-predicated.
  1039. // In the example above, 'Add' is the key instruction.
  1040. list<string> KeyCol = [];
  1041. // List of values for the fields/attributes listed in 'ColFields', one for
  1042. // each column in the relation table.
  1043. //
  1044. // Ex: let ValueCols = [['true'],['false']] -- It adds two columns in the
  1045. // table. First column requires all the instructions to have predSense
  1046. // set to 'true' and second column requires it to be 'false'.
  1047. list<list<string> > ValueCols = [];
  1048. }
  1049. //===----------------------------------------------------------------------===//
  1050. // Pull in the common support for calling conventions.
  1051. //
  1052. include "llvm/Target/TargetCallingConv.td"
  1053. //===----------------------------------------------------------------------===//
  1054. // Pull in the common support for DAG isel generation.
  1055. //
  1056. include "llvm/Target/TargetSelectionDAG.td"