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