]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/llvm/Target/Target.td
Vendor import of llvm trunk r300422:
[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
535 /// NoHonorSignDependentRounding - This predicate is true if support for
536 /// sign-dependent-rounding is not enabled.
537 def NoHonorSignDependentRounding
538  : Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">;
539
540 class Requires<list<Predicate> preds> {
541   list<Predicate> Predicates = preds;
542 }
543
544 /// ops definition - This is just a simple marker used to identify the operand
545 /// list for an instruction. outs and ins are identical both syntactically and
546 /// semantically; they are used to define def operands and use operands to
547 /// improve readibility. This should be used like this:
548 ///     (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar.
549 def ops;
550 def outs;
551 def ins;
552
553 /// variable_ops definition - Mark this instruction as taking a variable number
554 /// of operands.
555 def variable_ops;
556
557
558 /// PointerLikeRegClass - Values that are designed to have pointer width are
559 /// derived from this.  TableGen treats the register class as having a symbolic
560 /// type that it doesn't know, and resolves the actual regclass to use by using
561 /// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
562 class PointerLikeRegClass<int Kind> {
563   int RegClassKind = Kind;
564 }
565
566
567 /// ptr_rc definition - Mark this operand as being a pointer value whose
568 /// register class is resolved dynamically via a callback to TargetInstrInfo.
569 /// FIXME: We should probably change this to a class which contain a list of
570 /// flags. But currently we have but one flag.
571 def ptr_rc : PointerLikeRegClass<0>;
572
573 /// unknown definition - Mark this operand as being of unknown type, causing
574 /// it to be resolved by inference in the context it is used.
575 class unknown_class;
576 def unknown : unknown_class;
577
578 /// AsmOperandClass - Representation for the kinds of operands which the target
579 /// specific parser can create and the assembly matcher may need to distinguish.
580 ///
581 /// Operand classes are used to define the order in which instructions are
582 /// matched, to ensure that the instruction which gets matched for any
583 /// particular list of operands is deterministic.
584 ///
585 /// The target specific parser must be able to classify a parsed operand into a
586 /// unique class which does not partially overlap with any other classes. It can
587 /// match a subset of some other class, in which case the super class field
588 /// should be defined.
589 class AsmOperandClass {
590   /// The name to use for this class, which should be usable as an enum value.
591   string Name = ?;
592
593   /// The super classes of this operand.
594   list<AsmOperandClass> SuperClasses = [];
595
596   /// The name of the method on the target specific operand to call to test
597   /// whether the operand is an instance of this class. If not set, this will
598   /// default to "isFoo", where Foo is the AsmOperandClass name. The method
599   /// signature should be:
600   ///   bool isFoo() const;
601   string PredicateMethod = ?;
602
603   /// The name of the method on the target specific operand to call to add the
604   /// target specific operand to an MCInst. If not set, this will default to
605   /// "addFooOperands", where Foo is the AsmOperandClass name. The method
606   /// signature should be:
607   ///   void addFooOperands(MCInst &Inst, unsigned N) const;
608   string RenderMethod = ?;
609
610   /// The name of the method on the target specific operand to call to custom
611   /// handle the operand parsing. This is useful when the operands do not relate
612   /// to immediates or registers and are very instruction specific (as flags to
613   /// set in a processor register, coprocessor number, ...).
614   string ParserMethod = ?;
615
616   // The diagnostic type to present when referencing this operand in a
617   // match failure error message. By default, use a generic "invalid operand"
618   // diagnostic. The target AsmParser maps these codes to text.
619   string DiagnosticType = "";
620
621   /// Set to 1 if this operand is optional and not always required. Typically,
622   /// the AsmParser will emit an error when it finishes parsing an
623   /// instruction if it hasn't matched all the operands yet.  However, this
624   /// error will be suppressed if all of the remaining unmatched operands are
625   /// marked as IsOptional.
626   ///
627   /// Optional arguments must be at the end of the operand list.
628   bit IsOptional = 0;
629
630   /// The name of the method on the target specific asm parser that returns the
631   /// default operand for this optional operand. This method is only used if
632   /// IsOptional == 1. If not set, this will default to "defaultFooOperands",
633   /// where Foo is the AsmOperandClass name. The method signature should be:
634   ///   std::unique_ptr<MCParsedAsmOperand> defaultFooOperands() const;
635   string DefaultMethod = ?;
636 }
637
638 def ImmAsmOperand : AsmOperandClass {
639   let Name = "Imm";
640 }
641
642 /// Operand Types - These provide the built-in operand types that may be used
643 /// by a target.  Targets can optionally provide their own operand types as
644 /// needed, though this should not be needed for RISC targets.
645 class Operand<ValueType ty> : DAGOperand {
646   ValueType Type = ty;
647   string PrintMethod = "printOperand";
648   string EncoderMethod = "";
649   bit hasCompleteDecoder = 1;
650   string OperandType = "OPERAND_UNKNOWN";
651   dag MIOperandInfo = (ops);
652
653   // MCOperandPredicate - Optionally, a code fragment operating on
654   // const MCOperand &MCOp, and returning a bool, to indicate if
655   // the value of MCOp is valid for the specific subclass of Operand
656   code MCOperandPredicate;
657
658   // ParserMatchClass - The "match class" that operands of this type fit
659   // in. Match classes are used to define the order in which instructions are
660   // match, to ensure that which instructions gets matched is deterministic.
661   //
662   // The target specific parser must be able to classify an parsed operand into
663   // a unique class, which does not partially overlap with any other classes. It
664   // can match a subset of some other class, in which case the AsmOperandClass
665   // should declare the other operand as one of its super classes.
666   AsmOperandClass ParserMatchClass = ImmAsmOperand;
667 }
668
669 class RegisterOperand<RegisterClass regclass, string pm = "printOperand">
670   : DAGOperand {
671   // RegClass - The register class of the operand.
672   RegisterClass RegClass = regclass;
673   // PrintMethod - The target method to call to print register operands of
674   // this type. The method normally will just use an alt-name index to look
675   // up the name to print. Default to the generic printOperand().
676   string PrintMethod = pm;
677   // ParserMatchClass - The "match class" that operands of this type fit
678   // in. Match classes are used to define the order in which instructions are
679   // match, to ensure that which instructions gets matched is deterministic.
680   //
681   // The target specific parser must be able to classify an parsed operand into
682   // a unique class, which does not partially overlap with any other classes. It
683   // can match a subset of some other class, in which case the AsmOperandClass
684   // should declare the other operand as one of its super classes.
685   AsmOperandClass ParserMatchClass;
686
687   string OperandType = "OPERAND_REGISTER";
688 }
689
690 let OperandType = "OPERAND_IMMEDIATE" in {
691 def i1imm  : Operand<i1>;
692 def i8imm  : Operand<i8>;
693 def i16imm : Operand<i16>;
694 def i32imm : Operand<i32>;
695 def i64imm : Operand<i64>;
696
697 def f32imm : Operand<f32>;
698 def f64imm : Operand<f64>;
699 }
700
701 // Register operands for generic instructions don't have an MVT, but do have
702 // constraints linking the operands (e.g. all operands of a G_ADD must
703 // have the same LLT).
704 class TypedOperand<string Ty> : Operand<untyped> {
705   let OperandType = Ty;
706 }
707
708 def type0 : TypedOperand<"OPERAND_GENERIC_0">;
709 def type1 : TypedOperand<"OPERAND_GENERIC_1">;
710 def type2 : TypedOperand<"OPERAND_GENERIC_2">;
711 def type3 : TypedOperand<"OPERAND_GENERIC_3">;
712 def type4 : TypedOperand<"OPERAND_GENERIC_4">;
713 def type5 : TypedOperand<"OPERAND_GENERIC_5">;
714
715 /// zero_reg definition - Special node to stand for the zero register.
716 ///
717 def zero_reg;
718
719 /// All operands which the MC layer classifies as predicates should inherit from
720 /// this class in some manner. This is already handled for the most commonly
721 /// used PredicateOperand, but may be useful in other circumstances.
722 class PredicateOp;
723
724 /// OperandWithDefaultOps - This Operand class can be used as the parent class
725 /// for an Operand that needs to be initialized with a default value if
726 /// no value is supplied in a pattern.  This class can be used to simplify the
727 /// pattern definitions for instructions that have target specific flags
728 /// encoded as immediate operands.
729 class OperandWithDefaultOps<ValueType ty, dag defaultops>
730   : Operand<ty> {
731   dag DefaultOps = defaultops;
732 }
733
734 /// PredicateOperand - This can be used to define a predicate operand for an
735 /// instruction.  OpTypes specifies the MIOperandInfo for the operand, and
736 /// AlwaysVal specifies the value of this predicate when set to "always
737 /// execute".
738 class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal>
739   : OperandWithDefaultOps<ty, AlwaysVal>, PredicateOp {
740   let MIOperandInfo = OpTypes;
741 }
742
743 /// OptionalDefOperand - This is used to define a optional definition operand
744 /// for an instruction. DefaultOps is the register the operand represents if
745 /// none is supplied, e.g. zero_reg.
746 class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>
747   : OperandWithDefaultOps<ty, defaultops> {
748   let MIOperandInfo = OpTypes;
749 }
750
751
752 // InstrInfo - This class should only be instantiated once to provide parameters
753 // which are global to the target machine.
754 //
755 class InstrInfo {
756   // Target can specify its instructions in either big or little-endian formats.
757   // For instance, while both Sparc and PowerPC are big-endian platforms, the
758   // Sparc manual specifies its instructions in the format [31..0] (big), while
759   // PowerPC specifies them using the format [0..31] (little).
760   bit isLittleEndianEncoding = 0;
761
762   // The instruction properties mayLoad, mayStore, and hasSideEffects are unset
763   // by default, and TableGen will infer their value from the instruction
764   // pattern when possible.
765   //
766   // Normally, TableGen will issue an error it it can't infer the value of a
767   // property that hasn't been set explicitly. When guessInstructionProperties
768   // is set, it will guess a safe value instead.
769   //
770   // This option is a temporary migration help. It will go away.
771   bit guessInstructionProperties = 1;
772
773   // TableGen's instruction encoder generator has support for matching operands
774   // to bit-field variables both by name and by position. While matching by
775   // name is preferred, this is currently not possible for complex operands,
776   // and some targets still reply on the positional encoding rules. When
777   // generating a decoder for such targets, the positional encoding rules must
778   // be used by the decoder generator as well.
779   //
780   // This option is temporary; it will go away once the TableGen decoder
781   // generator has better support for complex operands and targets have
782   // migrated away from using positionally encoded operands.
783   bit decodePositionallyEncodedOperands = 0;
784
785   // When set, this indicates that there will be no overlap between those
786   // operands that are matched by ordering (positional operands) and those
787   // matched by name.
788   //
789   // This option is temporary; it will go away once the TableGen decoder
790   // generator has better support for complex operands and targets have
791   // migrated away from using positionally encoded operands.
792   bit noNamedPositionallyEncodedOperands = 0;
793 }
794
795 // Standard Pseudo Instructions.
796 // This list must match TargetOpcodes.h and CodeGenTarget.cpp.
797 // Only these instructions are allowed in the TargetOpcode namespace.
798 let isCodeGenOnly = 1, isPseudo = 1, hasNoSchedulingInfo = 1,
799     Namespace = "TargetOpcode" in {
800 def PHI : Instruction {
801   let OutOperandList = (outs unknown:$dst);
802   let InOperandList = (ins variable_ops);
803   let AsmString = "PHINODE";
804 }
805 def INLINEASM : Instruction {
806   let OutOperandList = (outs);
807   let InOperandList = (ins variable_ops);
808   let AsmString = "";
809   let hasSideEffects = 0;  // Note side effect is encoded in an operand.
810 }
811 def CFI_INSTRUCTION : Instruction {
812   let OutOperandList = (outs);
813   let InOperandList = (ins i32imm:$id);
814   let AsmString = "";
815   let hasCtrlDep = 1;
816   let isNotDuplicable = 1;
817 }
818 def EH_LABEL : Instruction {
819   let OutOperandList = (outs);
820   let InOperandList = (ins i32imm:$id);
821   let AsmString = "";
822   let hasCtrlDep = 1;
823   let isNotDuplicable = 1;
824 }
825 def GC_LABEL : Instruction {
826   let OutOperandList = (outs);
827   let InOperandList = (ins i32imm:$id);
828   let AsmString = "";
829   let hasCtrlDep = 1;
830   let isNotDuplicable = 1;
831 }
832 def KILL : Instruction {
833   let OutOperandList = (outs);
834   let InOperandList = (ins variable_ops);
835   let AsmString = "";
836   let hasSideEffects = 0;
837 }
838 def EXTRACT_SUBREG : Instruction {
839   let OutOperandList = (outs unknown:$dst);
840   let InOperandList = (ins unknown:$supersrc, i32imm:$subidx);
841   let AsmString = "";
842   let hasSideEffects = 0;
843 }
844 def INSERT_SUBREG : Instruction {
845   let OutOperandList = (outs unknown:$dst);
846   let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx);
847   let AsmString = "";
848   let hasSideEffects = 0;
849   let Constraints = "$supersrc = $dst";
850 }
851 def IMPLICIT_DEF : Instruction {
852   let OutOperandList = (outs unknown:$dst);
853   let InOperandList = (ins);
854   let AsmString = "";
855   let hasSideEffects = 0;
856   let isReMaterializable = 1;
857   let isAsCheapAsAMove = 1;
858 }
859 def SUBREG_TO_REG : Instruction {
860   let OutOperandList = (outs unknown:$dst);
861   let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx);
862   let AsmString = "";
863   let hasSideEffects = 0;
864 }
865 def COPY_TO_REGCLASS : Instruction {
866   let OutOperandList = (outs unknown:$dst);
867   let InOperandList = (ins unknown:$src, i32imm:$regclass);
868   let AsmString = "";
869   let hasSideEffects = 0;
870   let isAsCheapAsAMove = 1;
871 }
872 def DBG_VALUE : Instruction {
873   let OutOperandList = (outs);
874   let InOperandList = (ins variable_ops);
875   let AsmString = "DBG_VALUE";
876   let hasSideEffects = 0;
877 }
878 def REG_SEQUENCE : Instruction {
879   let OutOperandList = (outs unknown:$dst);
880   let InOperandList = (ins unknown:$supersrc, variable_ops);
881   let AsmString = "";
882   let hasSideEffects = 0;
883   let isAsCheapAsAMove = 1;
884 }
885 def COPY : Instruction {
886   let OutOperandList = (outs unknown:$dst);
887   let InOperandList = (ins unknown:$src);
888   let AsmString = "";
889   let hasSideEffects = 0;
890   let isAsCheapAsAMove = 1;
891   let hasNoSchedulingInfo = 0;
892 }
893 def BUNDLE : Instruction {
894   let OutOperandList = (outs);
895   let InOperandList = (ins variable_ops);
896   let AsmString = "BUNDLE";
897 }
898 def LIFETIME_START : Instruction {
899   let OutOperandList = (outs);
900   let InOperandList = (ins i32imm:$id);
901   let AsmString = "LIFETIME_START";
902   let hasSideEffects = 0;
903 }
904 def LIFETIME_END : Instruction {
905   let OutOperandList = (outs);
906   let InOperandList = (ins i32imm:$id);
907   let AsmString = "LIFETIME_END";
908   let hasSideEffects = 0;
909 }
910 def STACKMAP : Instruction {
911   let OutOperandList = (outs);
912   let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops);
913   let isCall = 1;
914   let mayLoad = 1;
915   let usesCustomInserter = 1;
916 }
917 def PATCHPOINT : Instruction {
918   let OutOperandList = (outs unknown:$dst);
919   let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee,
920                        i32imm:$nargs, i32imm:$cc, variable_ops);
921   let isCall = 1;
922   let mayLoad = 1;
923   let usesCustomInserter = 1;
924 }
925 def STATEPOINT : Instruction {
926   let OutOperandList = (outs);
927   let InOperandList = (ins variable_ops);
928   let usesCustomInserter = 1;
929   let mayLoad = 1;
930   let mayStore = 1;
931   let hasSideEffects = 1;
932   let isCall = 1;
933 }
934 def LOAD_STACK_GUARD : Instruction {
935   let OutOperandList = (outs ptr_rc:$dst);
936   let InOperandList = (ins);
937   let mayLoad = 1;
938   bit isReMaterializable = 1;
939   let hasSideEffects = 0;
940   bit isPseudo = 1;
941 }
942 def LOCAL_ESCAPE : Instruction {
943   // This instruction is really just a label. It has to be part of the chain so
944   // that it doesn't get dropped from the DAG, but it produces nothing and has
945   // no side effects.
946   let OutOperandList = (outs);
947   let InOperandList = (ins ptr_rc:$symbol, i32imm:$id);
948   let hasSideEffects = 0;
949   let hasCtrlDep = 1;
950 }
951 def FAULTING_OP : Instruction {
952   let OutOperandList = (outs unknown:$dst);
953   let InOperandList = (ins variable_ops);
954   let usesCustomInserter = 1;
955   let mayLoad = 1;
956   let mayStore = 1;
957   let isTerminator = 1;
958   let isBranch = 1;
959 }
960 def PATCHABLE_OP : Instruction {
961   let OutOperandList = (outs unknown:$dst);
962   let InOperandList = (ins variable_ops);
963   let usesCustomInserter = 1;
964   let mayLoad = 1;
965   let mayStore = 1;
966   let hasSideEffects = 1;
967 }
968 def PATCHABLE_FUNCTION_ENTER : Instruction {
969   let OutOperandList = (outs);
970   let InOperandList = (ins);
971   let AsmString = "# XRay Function Enter.";
972   let usesCustomInserter = 1;
973   let hasSideEffects = 0;
974 }
975 def PATCHABLE_RET : Instruction {
976   let OutOperandList = (outs unknown:$dst);
977   let InOperandList = (ins variable_ops);
978   let AsmString = "# XRay Function Patchable RET.";
979   let usesCustomInserter = 1;
980   let hasSideEffects = 1;
981   let isReturn = 1;
982 }
983 def PATCHABLE_FUNCTION_EXIT : Instruction {
984   let OutOperandList = (outs);
985   let InOperandList = (ins);
986   let AsmString = "# XRay Function Exit.";
987   let usesCustomInserter = 1;
988   let hasSideEffects = 0; // FIXME: is this correct?
989   let isReturn = 0; // Original return instruction will follow
990 }
991 def PATCHABLE_TAIL_CALL : Instruction {
992   let OutOperandList = (outs unknown:$dst);
993   let InOperandList = (ins variable_ops);
994   let AsmString = "# XRay Tail Call Exit.";
995   let usesCustomInserter = 1;
996   let hasSideEffects = 1;
997   let isReturn = 1;
998 }
999 def FENTRY_CALL : Instruction {
1000   let OutOperandList = (outs unknown:$dst);
1001   let InOperandList = (ins variable_ops);
1002   let AsmString = "# FEntry call";
1003   let usesCustomInserter = 1;
1004   let mayLoad = 1;
1005   let mayStore = 1;
1006   let hasSideEffects = 1;
1007 }
1008
1009 // Generic opcodes used in GlobalISel.
1010 include "llvm/Target/GenericOpcodes.td"
1011
1012 }
1013
1014 //===----------------------------------------------------------------------===//
1015 // AsmParser - This class can be implemented by targets that wish to implement
1016 // .s file parsing.
1017 //
1018 // Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel
1019 // syntax on X86 for example).
1020 //
1021 class AsmParser {
1022   // AsmParserClassName - This specifies the suffix to use for the asmparser
1023   // class.  Generated AsmParser classes are always prefixed with the target
1024   // name.
1025   string AsmParserClassName  = "AsmParser";
1026
1027   // AsmParserInstCleanup - If non-empty, this is the name of a custom member
1028   // function of the AsmParser class to call on every matched instruction.
1029   // This can be used to perform target specific instruction post-processing.
1030   string AsmParserInstCleanup  = "";
1031
1032   // ShouldEmitMatchRegisterName - Set to false if the target needs a hand
1033   // written register name matcher
1034   bit ShouldEmitMatchRegisterName = 1;
1035
1036   // Set to true if the target needs a generated 'alternative register name'
1037   // matcher.
1038   //
1039   // This generates a function which can be used to lookup registers from
1040   // their aliases. This function will fail when called on targets where
1041   // several registers share the same alias (i.e. not a 1:1 mapping).
1042   bit ShouldEmitMatchRegisterAltName = 0;
1043
1044   // HasMnemonicFirst - Set to false if target instructions don't always
1045   // start with a mnemonic as the first token.
1046   bit HasMnemonicFirst = 1;
1047 }
1048 def DefaultAsmParser : AsmParser;
1049
1050 //===----------------------------------------------------------------------===//
1051 // AsmParserVariant - Subtargets can have multiple different assembly parsers
1052 // (e.g. AT&T vs Intel syntax on X86 for example). This class can be
1053 // implemented by targets to describe such variants.
1054 //
1055 class AsmParserVariant {
1056   // Variant - AsmParsers can be of multiple different variants.  Variants are
1057   // used to support targets that need to parser multiple formats for the
1058   // assembly language.
1059   int Variant = 0;
1060
1061   // Name - The AsmParser variant name (e.g., AT&T vs Intel).
1062   string Name = "";
1063
1064   // CommentDelimiter - If given, the delimiter string used to recognize
1065   // comments which are hard coded in the .td assembler strings for individual
1066   // instructions.
1067   string CommentDelimiter = "";
1068
1069   // RegisterPrefix - If given, the token prefix which indicates a register
1070   // token. This is used by the matcher to automatically recognize hard coded
1071   // register tokens as constrained registers, instead of tokens, for the
1072   // purposes of matching.
1073   string RegisterPrefix = "";
1074
1075   // TokenizingCharacters - Characters that are standalone tokens
1076   string TokenizingCharacters = "[]*!";
1077
1078   // SeparatorCharacters - Characters that are not tokens
1079   string SeparatorCharacters = " \t,";
1080
1081   // BreakCharacters - Characters that start new identifiers
1082   string BreakCharacters = "";
1083 }
1084 def DefaultAsmParserVariant : AsmParserVariant;
1085
1086 /// AssemblerPredicate - This is a Predicate that can be used when the assembler
1087 /// matches instructions and aliases.
1088 class AssemblerPredicate<string cond, string name = ""> {
1089   bit AssemblerMatcherPredicate = 1;
1090   string AssemblerCondString = cond;
1091   string PredicateName = name;
1092 }
1093
1094 /// TokenAlias - This class allows targets to define assembler token
1095 /// operand aliases. That is, a token literal operand which is equivalent
1096 /// to another, canonical, token literal. For example, ARM allows:
1097 ///   vmov.u32 s4, #0  -> vmov.i32, #0
1098 /// 'u32' is a more specific designator for the 32-bit integer type specifier
1099 /// and is legal for any instruction which accepts 'i32' as a datatype suffix.
1100 ///   def : TokenAlias<".u32", ".i32">;
1101 ///
1102 /// This works by marking the match class of 'From' as a subclass of the
1103 /// match class of 'To'.
1104 class TokenAlias<string From, string To> {
1105   string FromToken = From;
1106   string ToToken = To;
1107 }
1108
1109 /// MnemonicAlias - This class allows targets to define assembler mnemonic
1110 /// aliases.  This should be used when all forms of one mnemonic are accepted
1111 /// with a different mnemonic.  For example, X86 allows:
1112 ///   sal %al, 1    -> shl %al, 1
1113 ///   sal %ax, %cl  -> shl %ax, %cl
1114 ///   sal %eax, %cl -> shl %eax, %cl
1115 /// etc.  Though "sal" is accepted with many forms, all of them are directly
1116 /// translated to a shl, so it can be handled with (in the case of X86, it
1117 /// actually has one for each suffix as well):
1118 ///   def : MnemonicAlias<"sal", "shl">;
1119 ///
1120 /// Mnemonic aliases are mapped before any other translation in the match phase,
1121 /// and do allow Requires predicates, e.g.:
1122 ///
1123 ///  def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>;
1124 ///  def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>;
1125 ///
1126 /// Mnemonic aliases can also be constrained to specific variants, e.g.:
1127 ///
1128 ///  def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>;
1129 ///
1130 /// If no variant (e.g., "att" or "intel") is specified then the alias is
1131 /// applied unconditionally.
1132 class MnemonicAlias<string From, string To, string VariantName = ""> {
1133   string FromMnemonic = From;
1134   string ToMnemonic = To;
1135   string AsmVariantName = VariantName;
1136
1137   // Predicates - Predicates that must be true for this remapping to happen.
1138   list<Predicate> Predicates = [];
1139 }
1140
1141 /// InstAlias - This defines an alternate assembly syntax that is allowed to
1142 /// match an instruction that has a different (more canonical) assembly
1143 /// representation.
1144 class InstAlias<string Asm, dag Result, int Emit = 1> {
1145   string AsmString = Asm;      // The .s format to match the instruction with.
1146   dag ResultInst = Result;     // The MCInst to generate.
1147
1148   // This determines which order the InstPrinter detects aliases for
1149   // printing. A larger value makes the alias more likely to be
1150   // emitted. The Instruction's own definition is notionally 0.5, so 0
1151   // disables printing and 1 enables it if there are no conflicting aliases.
1152   int EmitPriority = Emit;
1153
1154   // Predicates - Predicates that must be true for this to match.
1155   list<Predicate> Predicates = [];
1156
1157   // If the instruction specified in Result has defined an AsmMatchConverter
1158   // then setting this to 1 will cause the alias to use the AsmMatchConverter
1159   // function when converting the OperandVector into an MCInst instead of the
1160   // function that is generated by the dag Result.
1161   // Setting this to 0 will cause the alias to ignore the Result instruction's
1162   // defined AsmMatchConverter and instead use the function generated by the
1163   // dag Result.
1164   bit UseInstAsmMatchConverter = 1;
1165
1166   // Assembler variant name to use for this alias. If not specified then
1167   // assembler variants will be determined based on AsmString
1168   string AsmVariantName = "";
1169 }
1170
1171 //===----------------------------------------------------------------------===//
1172 // AsmWriter - This class can be implemented by targets that need to customize
1173 // the format of the .s file writer.
1174 //
1175 // Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax
1176 // on X86 for example).
1177 //
1178 class AsmWriter {
1179   // AsmWriterClassName - This specifies the suffix to use for the asmwriter
1180   // class.  Generated AsmWriter classes are always prefixed with the target
1181   // name.
1182   string AsmWriterClassName  = "InstPrinter";
1183
1184   // PassSubtarget - Determines whether MCSubtargetInfo should be passed to
1185   // the various print methods.
1186   // FIXME: Remove after all ports are updated.
1187   int PassSubtarget = 0;
1188
1189   // Variant - AsmWriters can be of multiple different variants.  Variants are
1190   // used to support targets that need to emit assembly code in ways that are
1191   // mostly the same for different targets, but have minor differences in
1192   // syntax.  If the asmstring contains {|} characters in them, this integer
1193   // will specify which alternative to use.  For example "{x|y|z}" with Variant
1194   // == 1, will expand to "y".
1195   int Variant = 0;
1196 }
1197 def DefaultAsmWriter : AsmWriter;
1198
1199
1200 //===----------------------------------------------------------------------===//
1201 // Target - This class contains the "global" target information
1202 //
1203 class Target {
1204   // InstructionSet - Instruction set description for this target.
1205   InstrInfo InstructionSet;
1206
1207   // AssemblyParsers - The AsmParser instances available for this target.
1208   list<AsmParser> AssemblyParsers = [DefaultAsmParser];
1209
1210   /// AssemblyParserVariants - The AsmParserVariant instances available for
1211   /// this target.
1212   list<AsmParserVariant> AssemblyParserVariants = [DefaultAsmParserVariant];
1213
1214   // AssemblyWriters - The AsmWriter instances available for this target.
1215   list<AsmWriter> AssemblyWriters = [DefaultAsmWriter];
1216 }
1217
1218 //===----------------------------------------------------------------------===//
1219 // SubtargetFeature - A characteristic of the chip set.
1220 //
1221 class SubtargetFeature<string n, string a,  string v, string d,
1222                        list<SubtargetFeature> i = []> {
1223   // Name - Feature name.  Used by command line (-mattr=) to determine the
1224   // appropriate target chip.
1225   //
1226   string Name = n;
1227
1228   // Attribute - Attribute to be set by feature.
1229   //
1230   string Attribute = a;
1231
1232   // Value - Value the attribute to be set to by feature.
1233   //
1234   string Value = v;
1235
1236   // Desc - Feature description.  Used by command line (-mattr=) to display help
1237   // information.
1238   //
1239   string Desc = d;
1240
1241   // Implies - Features that this feature implies are present. If one of those
1242   // features isn't set, then this one shouldn't be set either.
1243   //
1244   list<SubtargetFeature> Implies = i;
1245 }
1246
1247 /// Specifies a Subtarget feature that this instruction is deprecated on.
1248 class Deprecated<SubtargetFeature dep> {
1249   SubtargetFeature DeprecatedFeatureMask = dep;
1250 }
1251
1252 /// A custom predicate used to determine if an instruction is
1253 /// deprecated or not.
1254 class ComplexDeprecationPredicate<string dep> {
1255   string ComplexDeprecationPredicate = dep;
1256 }
1257
1258 //===----------------------------------------------------------------------===//
1259 // Processor chip sets - These values represent each of the chip sets supported
1260 // by the scheduler.  Each Processor definition requires corresponding
1261 // instruction itineraries.
1262 //
1263 class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f> {
1264   // Name - Chip set name.  Used by command line (-mcpu=) to determine the
1265   // appropriate target chip.
1266   //
1267   string Name = n;
1268
1269   // SchedModel - The machine model for scheduling and instruction cost.
1270   //
1271   SchedMachineModel SchedModel = NoSchedModel;
1272
1273   // ProcItin - The scheduling information for the target processor.
1274   //
1275   ProcessorItineraries ProcItin = pi;
1276
1277   // Features - list of
1278   list<SubtargetFeature> Features = f;
1279 }
1280
1281 // ProcessorModel allows subtargets to specify the more general
1282 // SchedMachineModel instead if a ProcessorItinerary. Subtargets will
1283 // gradually move to this newer form.
1284 //
1285 // Although this class always passes NoItineraries to the Processor
1286 // class, the SchedMachineModel may still define valid Itineraries.
1287 class ProcessorModel<string n, SchedMachineModel m, list<SubtargetFeature> f>
1288   : Processor<n, NoItineraries, f> {
1289   let SchedModel = m;
1290 }
1291
1292 //===----------------------------------------------------------------------===//
1293 // InstrMapping - This class is used to create mapping tables to relate
1294 // instructions with each other based on the values specified in RowFields,
1295 // ColFields, KeyCol and ValueCols.
1296 //
1297 class InstrMapping {
1298   // FilterClass - Used to limit search space only to the instructions that
1299   // define the relationship modeled by this InstrMapping record.
1300   string FilterClass;
1301
1302   // RowFields - List of fields/attributes that should be same for all the
1303   // instructions in a row of the relation table. Think of this as a set of
1304   // properties shared by all the instructions related by this relationship
1305   // model and is used to categorize instructions into subgroups. For instance,
1306   // if we want to define a relation that maps 'Add' instruction to its
1307   // predicated forms, we can define RowFields like this:
1308   //
1309   // let RowFields = BaseOp
1310   // All add instruction predicated/non-predicated will have to set their BaseOp
1311   // to the same value.
1312   //
1313   // def Add: { let BaseOp = 'ADD'; let predSense = 'nopred' }
1314   // def Add_predtrue: { let BaseOp = 'ADD'; let predSense = 'true' }
1315   // def Add_predfalse: { let BaseOp = 'ADD'; let predSense = 'false'  }
1316   list<string> RowFields = [];
1317
1318   // List of fields/attributes that are same for all the instructions
1319   // in a column of the relation table.
1320   // Ex: let ColFields = 'predSense' -- It means that the columns are arranged
1321   // based on the 'predSense' values. All the instruction in a specific
1322   // column have the same value and it is fixed for the column according
1323   // to the values set in 'ValueCols'.
1324   list<string> ColFields = [];
1325
1326   // Values for the fields/attributes listed in 'ColFields'.
1327   // Ex: let KeyCol = 'nopred' -- It means that the key instruction (instruction
1328   // that models this relation) should be non-predicated.
1329   // In the example above, 'Add' is the key instruction.
1330   list<string> KeyCol = [];
1331
1332   // List of values for the fields/attributes listed in 'ColFields', one for
1333   // each column in the relation table.
1334   //
1335   // Ex: let ValueCols = [['true'],['false']] -- It adds two columns in the
1336   // table. First column requires all the instructions to have predSense
1337   // set to 'true' and second column requires it to be 'false'.
1338   list<list<string> > ValueCols = [];
1339 }
1340
1341 //===----------------------------------------------------------------------===//
1342 // Pull in the common support for calling conventions.
1343 //
1344 include "llvm/Target/TargetCallingConv.td"
1345
1346 //===----------------------------------------------------------------------===//
1347 // Pull in the common support for DAG isel generation.
1348 //
1349 include "llvm/Target/TargetSelectionDAG.td"
1350
1351 //===----------------------------------------------------------------------===//
1352 // Pull in the common support for Global ISel register bank info generation.
1353 //
1354 include "llvm/Target/GlobalISel/RegisterBank.td"
1355
1356 //===----------------------------------------------------------------------===//
1357 // Pull in the common support for DAG isel generation.
1358 //
1359 include "llvm/Target/GlobalISel/Target.td"
1360
1361 //===----------------------------------------------------------------------===//
1362 // Pull in the common support for the Global ISel DAG-based selector generation.
1363 //
1364 include "llvm/Target/GlobalISel/SelectionDAGCompat.td"