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