Remove MethodProtos/MethodBodies and allocation_order_begin/end.
[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/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 {
26   string Namespace = "";
27 }
28
29 // Register - You should define one instance of this class for each register
30 // in the target machine.  String n will become the "name" of the register.
31 class Register<string n> {
32   string Namespace = "";
33   string AsmName = n;
34
35   // Aliases - A list of registers that this register overlaps with.  A read or
36   // modification of this register can potentially read or modify the aliased
37   // registers.
38   list<Register> Aliases = [];
39
40   // SubRegs - A list of registers that are parts of this register. Note these
41   // are "immediate" sub-registers and the registers within the list do not
42   // themselves overlap. e.g. For X86, EAX's SubRegs list contains only [AX],
43   // not [AX, AH, AL].
44   list<Register> SubRegs = [];
45
46   // SubRegIndices - For each register in SubRegs, specify the SubRegIndex used
47   // to address it. Sub-sub-register indices are automatically inherited from
48   // SubRegs.
49   list<SubRegIndex> SubRegIndices = [];
50
51   // CompositeIndices - Specify subreg indices that don't correspond directly to
52   // a register in SubRegs and are not inherited. The following formats are
53   // supported:
54   //
55   // (a)     Identity  - Reg:a == Reg
56   // (a b)   Alias     - Reg:a == Reg:b
57   // (a b,c) Composite - Reg:a == (Reg:b):c
58   //
59   // This can be used to disambiguate a sub-sub-register that exists in more
60   // than one subregister and other weird stuff.
61   list<dag> CompositeIndices = [];
62
63   // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
64   // These values can be determined by locating the <target>.h file in the
65   // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES.  The
66   // order of these names correspond to the enumeration used by gcc.  A value of
67   // -1 indicates that the gcc number is undefined and -2 that register number
68   // is invalid for this mode/flavour.
69   list<int> DwarfNumbers = [];
70
71   // CostPerUse - Additional cost of instructions using this register compared
72   // to other registers in its class. The register allocator will try to
73   // minimize the number of instructions using a register with a CostPerUse.
74   // This is used by the x86-64 and ARM Thumb targets where some registers 
75   // require larger instruction encodings.
76   int CostPerUse = 0;
77 }
78
79 // RegisterWithSubRegs - This can be used to define instances of Register which
80 // need to specify sub-registers.
81 // List "subregs" specifies which registers are sub-registers to this one. This
82 // is used to populate the SubRegs and AliasSet fields of TargetRegisterDesc.
83 // This allows the code generator to be careful not to put two values with
84 // overlapping live ranges into registers which alias.
85 class RegisterWithSubRegs<string n, list<Register> subregs> : Register<n> {
86   let SubRegs = subregs;
87 }
88
89 // RegisterClass - Now that all of the registers are defined, and aliases
90 // between registers are defined, specify which registers belong to which
91 // register classes.  This also defines the default allocation order of
92 // registers by register allocators.
93 //
94 class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,
95                     dag regList> {
96   string Namespace = namespace;
97
98   // RegType - Specify the list ValueType of the registers in this register
99   // class.  Note that all registers in a register class must have the same
100   // ValueTypes.  This is a list because some targets permit storing different
101   // types in same register, for example vector values with 128-bit total size,
102   // but different count/size of items, like SSE on x86.
103   //
104   list<ValueType> RegTypes = regTypes;
105
106   // Size - Specify the spill size in bits of the registers.  A default value of
107   // zero lets tablgen pick an appropriate size.
108   int Size = 0;
109
110   // Alignment - Specify the alignment required of the registers when they are
111   // stored or loaded to memory.
112   //
113   int Alignment = alignment;
114
115   // CopyCost - This value is used to specify the cost of copying a value
116   // between two registers in this register class. The default value is one
117   // meaning it takes a single instruction to perform the copying. A negative
118   // value means copying is extremely expensive or impossible.
119   int CopyCost = 1;
120
121   // MemberList - Specify which registers are in this class.  If the
122   // allocation_order_* method are not specified, this also defines the order of
123   // allocation used by the register allocator.
124   //
125   dag MemberList = regList;
126
127   // SubRegClasses - Specify the register class of subregisters as a list of
128   // dags: (RegClass SubRegIndex, SubRegindex, ...)
129   list<dag> SubRegClasses = [];
130
131   // isAllocatable - Specify that the register class can be used for virtual
132   // registers and register allocation.  Some register classes are only used to
133   // model instruction operand constraints, and should have isAllocatable = 0.
134   bit isAllocatable = 1;
135
136   // AltOrders - List of alternative allocation orders. The default order is
137   // MemberList itself, and that is good enough for most targets since the
138   // register allocators automatically remove reserved registers and move
139   // callee-saved registers to the end.
140   list<dag> AltOrders = [];
141
142   // AltOrderSelect - The body of a function that selects the allocation order
143   // to use in a given machine function. The code will be inserted in a
144   // function like this:
145   //
146   //   static inline unsigned f(const MachineFunction &MF) { ... }
147   //
148   // The function should return 0 to select the default order defined by
149   // MemberList, 1 to select the first AltOrders entry and so on.
150   code AltOrderSelect = [{}];
151 }
152
153 // The memberList in a RegisterClass is a dag of set operations. TableGen
154 // evaluates these set operations and expand them into register lists. These
155 // are the most common operation, see test/TableGen/SetTheory.td for more
156 // examples of what is possible:
157 //
158 // (add R0, R1, R2) - Set Union. Each argument can be an individual register, a
159 // register class, or a sub-expression. This is also the way to simply list
160 // registers.
161 //
162 // (sub GPR, SP) - Set difference. Subtract the last arguments from the first.
163 //
164 // (and GPR, CSR) - Set intersection. All registers from the first set that are
165 // also in the second set.
166 //
167 // (sequence "R%u", 0, 15) -> [R0, R1, ..., R15]. Generate a sequence of
168 // numbered registers.
169 //
170 // (shl GPR, 4) - Remove the first N elements.
171 //
172 // (trunc GPR, 4) - Truncate after the first N elements.
173 //
174 // (rotl GPR, 1) - Rotate N places to the left.
175 //
176 // (rotr GPR, 1) - Rotate N places to the right.
177 //
178 // (decimate GPR, 2) - Pick every N'th element, starting with the first.
179 //
180 // All of these operators work on ordered sets, not lists. That means
181 // duplicates are removed from sub-expressions.
182
183 // Set operators. The rest is defined in TargetSelectionDAG.td.
184 def sequence;
185 def decimate;
186
187 //===----------------------------------------------------------------------===//
188 // DwarfRegNum - This class provides a mapping of the llvm register enumeration
189 // to the register numbering used by gcc and gdb.  These values are used by a
190 // debug information writer to describe where values may be located during
191 // execution.
192 class DwarfRegNum<list<int> Numbers> {
193   // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
194   // These values can be determined by locating the <target>.h file in the
195   // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES.  The
196   // order of these names correspond to the enumeration used by gcc.  A value of
197   // -1 indicates that the gcc number is undefined and -2 that register number
198   // is invalid for this mode/flavour.
199   list<int> DwarfNumbers = Numbers;
200 }
201
202 // DwarfRegAlias - This class declares that a given register uses the same dwarf
203 // numbers as another one. This is useful for making it clear that the two
204 // registers do have the same number. It also lets us build a mapping
205 // from dwarf register number to llvm register.
206 class DwarfRegAlias<Register reg> {
207       Register DwarfAlias = reg;
208 }
209
210 //===----------------------------------------------------------------------===//
211 // Pull in the common support for scheduling
212 //
213 include "llvm/Target/TargetSchedule.td"
214
215 class Predicate; // Forward def
216
217 //===----------------------------------------------------------------------===//
218 // Instruction set description - These classes correspond to the C++ classes in
219 // the Target/TargetInstrInfo.h file.
220 //
221 class Instruction {
222   string Namespace = "";
223
224   dag OutOperandList;       // An dag containing the MI def operand list.
225   dag InOperandList;        // An dag containing the MI use operand list.
226   string AsmString = "";    // The .s format to print the instruction with.
227
228   // Pattern - Set to the DAG pattern for this instruction, if we know of one,
229   // otherwise, uninitialized.
230   list<dag> Pattern;
231
232   // The follow state will eventually be inferred automatically from the
233   // instruction pattern.
234
235   list<Register> Uses = []; // Default to using no non-operand registers
236   list<Register> Defs = []; // Default to modifying no non-operand registers
237
238   // Predicates - List of predicates which will be turned into isel matching
239   // code.
240   list<Predicate> Predicates = [];
241
242   // Code size.
243   int CodeSize = 0;
244
245   // Added complexity passed onto matching pattern.
246   int AddedComplexity  = 0;
247
248   // These bits capture information about the high-level semantics of the
249   // instruction.
250   bit isReturn     = 0;     // Is this instruction a return instruction?
251   bit isBranch     = 0;     // Is this instruction a branch instruction?
252   bit isIndirectBranch = 0; // Is this instruction an indirect branch?
253   bit isCompare    = 0;     // Is this instruction a comparison instruction?
254   bit isMoveImm    = 0;     // Is this instruction a move immediate instruction?
255   bit isBitcast    = 0;     // Is this instruction a bitcast instruction?
256   bit isBarrier    = 0;     // Can control flow fall through this instruction?
257   bit isCall       = 0;     // Is this instruction a call instruction?
258   bit canFoldAsLoad = 0;    // Can this be folded as a simple memory operand?
259   bit mayLoad      = 0;     // Is it possible for this inst to read memory?
260   bit mayStore     = 0;     // Is it possible for this inst to write memory?
261   bit isConvertibleToThreeAddress = 0;  // Can this 2-addr instruction promote?
262   bit isCommutable = 0;     // Is this 3 operand instruction commutable?
263   bit isTerminator = 0;     // Is this part of the terminator for a basic block?
264   bit isReMaterializable = 0; // Is this instruction re-materializable?
265   bit isPredicable = 0;     // Is this instruction predicable?
266   bit hasDelaySlot = 0;     // Does this instruction have an delay slot?
267   bit usesCustomInserter = 0; // Pseudo instr needing special help.
268   bit hasCtrlDep   = 0;     // Does this instruction r/w ctrl-flow chains?
269   bit isNotDuplicable = 0;  // Is it unsafe to duplicate this instruction?
270   bit isAsCheapAsAMove = 0; // As cheap (or cheaper) than a move instruction.
271   bit hasExtraSrcRegAllocReq = 0; // Sources have special regalloc requirement?
272   bit hasExtraDefRegAllocReq = 0; // Defs have special regalloc requirement?
273
274   // Side effect flags - When set, the flags have these meanings:
275   //
276   //  hasSideEffects - The instruction has side effects that are not
277   //    captured by any operands of the instruction or other flags.
278   //
279   //  neverHasSideEffects - Set on an instruction with no pattern if it has no
280   //    side effects.
281   bit hasSideEffects = 0;
282   bit neverHasSideEffects = 0;
283
284   // Is this instruction a "real" instruction (with a distinct machine
285   // encoding), or is it a pseudo instruction used for codegen modeling
286   // purposes.
287   bit isCodeGenOnly = 0;
288
289   // Is this instruction a pseudo instruction for use by the assembler parser.
290   bit isAsmParserOnly = 0;
291
292   InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling.
293
294   string Constraints = "";  // OperandConstraint, e.g. $src = $dst.
295
296   /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not
297   /// be encoded into the output machineinstr.
298   string DisableEncoding = "";
299
300   string PostEncoderMethod = "";
301   string DecoderMethod = "";
302
303   /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
304   bits<64> TSFlags = 0;
305
306   ///@name Assembler Parser Support
307   ///@{
308
309   string AsmMatchConverter = "";
310
311   ///@}
312 }
313
314 /// Predicates - These are extra conditionals which are turned into instruction
315 /// selector matching code. Currently each predicate is just a string.
316 class Predicate<string cond> {
317   string CondString = cond;
318
319   /// AssemblerMatcherPredicate - If this feature can be used by the assembler
320   /// matcher, this is true.  Targets should set this by inheriting their
321   /// feature from the AssemblerPredicate class in addition to Predicate.
322   bit AssemblerMatcherPredicate = 0;
323 }
324
325 /// NoHonorSignDependentRounding - This predicate is true if support for
326 /// sign-dependent-rounding is not enabled.
327 def NoHonorSignDependentRounding
328  : Predicate<"!HonorSignDependentRoundingFPMath()">;
329
330 class Requires<list<Predicate> preds> {
331   list<Predicate> Predicates = preds;
332 }
333
334 /// ops definition - This is just a simple marker used to identify the operand
335 /// list for an instruction. outs and ins are identical both syntactically and
336 /// semanticallyr; they are used to define def operands and use operands to
337 /// improve readibility. This should be used like this:
338 ///     (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar.
339 def ops;
340 def outs;
341 def ins;
342
343 /// variable_ops definition - Mark this instruction as taking a variable number
344 /// of operands.
345 def variable_ops;
346
347
348 /// PointerLikeRegClass - Values that are designed to have pointer width are
349 /// derived from this.  TableGen treats the register class as having a symbolic
350 /// type that it doesn't know, and resolves the actual regclass to use by using
351 /// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
352 class PointerLikeRegClass<int Kind> {
353   int RegClassKind = Kind;
354 }
355
356
357 /// ptr_rc definition - Mark this operand as being a pointer value whose
358 /// register class is resolved dynamically via a callback to TargetInstrInfo.
359 /// FIXME: We should probably change this to a class which contain a list of
360 /// flags. But currently we have but one flag.
361 def ptr_rc : PointerLikeRegClass<0>;
362
363 /// unknown definition - Mark this operand as being of unknown type, causing
364 /// it to be resolved by inference in the context it is used.
365 def unknown;
366
367 /// AsmOperandClass - Representation for the kinds of operands which the target
368 /// specific parser can create and the assembly matcher may need to distinguish.
369 ///
370 /// Operand classes are used to define the order in which instructions are
371 /// matched, to ensure that the instruction which gets matched for any
372 /// particular list of operands is deterministic.
373 ///
374 /// The target specific parser must be able to classify a parsed operand into a
375 /// unique class which does not partially overlap with any other classes. It can
376 /// match a subset of some other class, in which case the super class field
377 /// should be defined.
378 class AsmOperandClass {
379   /// The name to use for this class, which should be usable as an enum value.
380   string Name = ?;
381
382   /// The super classes of this operand.
383   list<AsmOperandClass> SuperClasses = [];
384
385   /// The name of the method on the target specific operand to call to test
386   /// whether the operand is an instance of this class. If not set, this will
387   /// default to "isFoo", where Foo is the AsmOperandClass name. The method
388   /// signature should be:
389   ///   bool isFoo() const;
390   string PredicateMethod = ?;
391
392   /// The name of the method on the target specific operand to call to add the
393   /// target specific operand to an MCInst. If not set, this will default to
394   /// "addFooOperands", where Foo is the AsmOperandClass name. The method
395   /// signature should be:
396   ///   void addFooOperands(MCInst &Inst, unsigned N) const;
397   string RenderMethod = ?;
398
399   /// The name of the method on the target specific operand to call to custom
400   /// handle the operand parsing. This is useful when the operands do not relate
401   /// to immediates or registers and are very instruction specific (as flags to
402   /// set in a processor register, coprocessor number, ...).
403   string ParserMethod = ?;
404 }
405
406 def ImmAsmOperand : AsmOperandClass {
407   let Name = "Imm";
408 }
409
410 /// Operand Types - These provide the built-in operand types that may be used
411 /// by a target.  Targets can optionally provide their own operand types as
412 /// needed, though this should not be needed for RISC targets.
413 class Operand<ValueType ty> {
414   ValueType Type = ty;
415   string PrintMethod = "printOperand";
416   string EncoderMethod = "";
417   string DecoderMethod = "";
418   string AsmOperandLowerMethod = ?;
419   dag MIOperandInfo = (ops);
420
421   // ParserMatchClass - The "match class" that operands of this type fit
422   // in. Match classes are used to define the order in which instructions are
423   // match, to ensure that which instructions gets matched is deterministic.
424   //
425   // The target specific parser must be able to classify an parsed operand into
426   // a unique class, which does not partially overlap with any other classes. It
427   // can match a subset of some other class, in which case the AsmOperandClass
428   // should declare the other operand as one of its super classes.
429   AsmOperandClass ParserMatchClass = ImmAsmOperand;
430 }
431
432 def i1imm  : Operand<i1>;
433 def i8imm  : Operand<i8>;
434 def i16imm : Operand<i16>;
435 def i32imm : Operand<i32>;
436 def i64imm : Operand<i64>;
437
438 def f32imm : Operand<f32>;
439 def f64imm : Operand<f64>;
440
441 /// zero_reg definition - Special node to stand for the zero register.
442 ///
443 def zero_reg;
444
445 /// PredicateOperand - This can be used to define a predicate operand for an
446 /// instruction.  OpTypes specifies the MIOperandInfo for the operand, and
447 /// AlwaysVal specifies the value of this predicate when set to "always
448 /// execute".
449 class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal>
450   : Operand<ty> {
451   let MIOperandInfo = OpTypes;
452   dag DefaultOps = AlwaysVal;
453 }
454
455 /// OptionalDefOperand - This is used to define a optional definition operand
456 /// for an instruction. DefaultOps is the register the operand represents if
457 /// none is supplied, e.g. zero_reg.
458 class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>
459   : Operand<ty> {
460   let MIOperandInfo = OpTypes;
461   dag DefaultOps = defaultops;
462 }
463
464
465 // InstrInfo - This class should only be instantiated once to provide parameters
466 // which are global to the target machine.
467 //
468 class InstrInfo {
469   // Target can specify its instructions in either big or little-endian formats.
470   // For instance, while both Sparc and PowerPC are big-endian platforms, the
471   // Sparc manual specifies its instructions in the format [31..0] (big), while
472   // PowerPC specifies them using the format [0..31] (little).
473   bit isLittleEndianEncoding = 0;
474 }
475
476 // Standard Pseudo Instructions.
477 // This list must match TargetOpcodes.h and CodeGenTarget.cpp.
478 // Only these instructions are allowed in the TargetOpcode namespace.
479 let isCodeGenOnly = 1, Namespace = "TargetOpcode" in {
480 def PHI : Instruction {
481   let OutOperandList = (outs);
482   let InOperandList = (ins variable_ops);
483   let AsmString = "PHINODE";
484 }
485 def INLINEASM : Instruction {
486   let OutOperandList = (outs);
487   let InOperandList = (ins variable_ops);
488   let AsmString = "";
489   let neverHasSideEffects = 1;  // Note side effect is encoded in an operand.
490 }
491 def PROLOG_LABEL : Instruction {
492   let OutOperandList = (outs);
493   let InOperandList = (ins i32imm:$id);
494   let AsmString = "";
495   let hasCtrlDep = 1;
496   let isNotDuplicable = 1;
497 }
498 def EH_LABEL : Instruction {
499   let OutOperandList = (outs);
500   let InOperandList = (ins i32imm:$id);
501   let AsmString = "";
502   let hasCtrlDep = 1;
503   let isNotDuplicable = 1;
504 }
505 def GC_LABEL : Instruction {
506   let OutOperandList = (outs);
507   let InOperandList = (ins i32imm:$id);
508   let AsmString = "";
509   let hasCtrlDep = 1;
510   let isNotDuplicable = 1;
511 }
512 def KILL : Instruction {
513   let OutOperandList = (outs);
514   let InOperandList = (ins variable_ops);
515   let AsmString = "";
516   let neverHasSideEffects = 1;
517 }
518 def EXTRACT_SUBREG : Instruction {
519   let OutOperandList = (outs unknown:$dst);
520   let InOperandList = (ins unknown:$supersrc, i32imm:$subidx);
521   let AsmString = "";
522   let neverHasSideEffects = 1;
523 }
524 def INSERT_SUBREG : Instruction {
525   let OutOperandList = (outs unknown:$dst);
526   let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx);
527   let AsmString = "";
528   let neverHasSideEffects = 1;
529   let Constraints = "$supersrc = $dst";
530 }
531 def IMPLICIT_DEF : Instruction {
532   let OutOperandList = (outs unknown:$dst);
533   let InOperandList = (ins);
534   let AsmString = "";
535   let neverHasSideEffects = 1;
536   let isReMaterializable = 1;
537   let isAsCheapAsAMove = 1;
538 }
539 def SUBREG_TO_REG : Instruction {
540   let OutOperandList = (outs unknown:$dst);
541   let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx);
542   let AsmString = "";
543   let neverHasSideEffects = 1;
544 }
545 def COPY_TO_REGCLASS : Instruction {
546   let OutOperandList = (outs unknown:$dst);
547   let InOperandList = (ins unknown:$src, i32imm:$regclass);
548   let AsmString = "";
549   let neverHasSideEffects = 1;
550   let isAsCheapAsAMove = 1;
551 }
552 def DBG_VALUE : Instruction {
553   let OutOperandList = (outs);
554   let InOperandList = (ins variable_ops);
555   let AsmString = "DBG_VALUE";
556   let neverHasSideEffects = 1;
557 }
558 def REG_SEQUENCE : Instruction {
559   let OutOperandList = (outs unknown:$dst);
560   let InOperandList = (ins variable_ops);
561   let AsmString = "";
562   let neverHasSideEffects = 1;
563   let isAsCheapAsAMove = 1;
564 }
565 def COPY : Instruction {
566   let OutOperandList = (outs unknown:$dst);
567   let InOperandList = (ins unknown:$src);
568   let AsmString = "";
569   let neverHasSideEffects = 1;
570   let isAsCheapAsAMove = 1;
571 }
572 }
573
574 //===----------------------------------------------------------------------===//
575 // AsmParser - This class can be implemented by targets that wish to implement
576 // .s file parsing.
577 //
578 // Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel
579 // syntax on X86 for example).
580 //
581 class AsmParser {
582   // AsmParserClassName - This specifies the suffix to use for the asmparser
583   // class.  Generated AsmParser classes are always prefixed with the target
584   // name.
585   string AsmParserClassName  = "AsmParser";
586
587   // AsmParserInstCleanup - If non-empty, this is the name of a custom member
588   // function of the AsmParser class to call on every matched instruction.
589   // This can be used to perform target specific instruction post-processing.
590   string AsmParserInstCleanup  = "";
591
592   // Variant - AsmParsers can be of multiple different variants.  Variants are
593   // used to support targets that need to parser multiple formats for the
594   // assembly language.
595   int Variant = 0;
596
597   // CommentDelimiter - If given, the delimiter string used to recognize
598   // comments which are hard coded in the .td assembler strings for individual
599   // instructions.
600   string CommentDelimiter = "";
601
602   // RegisterPrefix - If given, the token prefix which indicates a register
603   // token. This is used by the matcher to automatically recognize hard coded
604   // register tokens as constrained registers, instead of tokens, for the
605   // purposes of matching.
606   string RegisterPrefix = "";
607 }
608 def DefaultAsmParser : AsmParser;
609
610 /// AssemblerPredicate - This is a Predicate that can be used when the assembler
611 /// matches instructions and aliases.
612 class AssemblerPredicate {
613   bit AssemblerMatcherPredicate = 1;
614 }
615
616
617
618 /// MnemonicAlias - This class allows targets to define assembler mnemonic
619 /// aliases.  This should be used when all forms of one mnemonic are accepted
620 /// with a different mnemonic.  For example, X86 allows:
621 ///   sal %al, 1    -> shl %al, 1
622 ///   sal %ax, %cl  -> shl %ax, %cl
623 ///   sal %eax, %cl -> shl %eax, %cl
624 /// etc.  Though "sal" is accepted with many forms, all of them are directly
625 /// translated to a shl, so it can be handled with (in the case of X86, it
626 /// actually has one for each suffix as well):
627 ///   def : MnemonicAlias<"sal", "shl">;
628 ///
629 /// Mnemonic aliases are mapped before any other translation in the match phase,
630 /// and do allow Requires predicates, e.g.:
631 ///
632 ///  def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>;
633 ///  def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>;
634 ///
635 class MnemonicAlias<string From, string To> {
636   string FromMnemonic = From;
637   string ToMnemonic = To;
638
639   // Predicates - Predicates that must be true for this remapping to happen.
640   list<Predicate> Predicates = [];
641 }
642
643 /// InstAlias - This defines an alternate assembly syntax that is allowed to
644 /// match an instruction that has a different (more canonical) assembly
645 /// representation.
646 class InstAlias<string Asm, dag Result, bit Emit = 0b1> {
647   string AsmString = Asm;      // The .s format to match the instruction with.
648   dag ResultInst = Result;     // The MCInst to generate.
649   bit EmitAlias = Emit;        // Emit the alias instead of what's aliased.
650
651   // Predicates - Predicates that must be true for this to match.
652   list<Predicate> Predicates = [];
653 }
654
655 //===----------------------------------------------------------------------===//
656 // AsmWriter - This class can be implemented by targets that need to customize
657 // the format of the .s file writer.
658 //
659 // Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax
660 // on X86 for example).
661 //
662 class AsmWriter {
663   // AsmWriterClassName - This specifies the suffix to use for the asmwriter
664   // class.  Generated AsmWriter classes are always prefixed with the target
665   // name.
666   string AsmWriterClassName  = "AsmPrinter";
667
668   // Variant - AsmWriters can be of multiple different variants.  Variants are
669   // used to support targets that need to emit assembly code in ways that are
670   // mostly the same for different targets, but have minor differences in
671   // syntax.  If the asmstring contains {|} characters in them, this integer
672   // will specify which alternative to use.  For example "{x|y|z}" with Variant
673   // == 1, will expand to "y".
674   int Variant = 0;
675
676
677   // FirstOperandColumn/OperandSpacing - If the assembler syntax uses a columnar
678   // layout, the asmwriter can actually generate output in this columns (in
679   // verbose-asm mode).  These two values indicate the width of the first column
680   // (the "opcode" area) and the width to reserve for subsequent operands.  When
681   // verbose asm mode is enabled, operands will be indented to respect this.
682   int FirstOperandColumn = -1;
683
684   // OperandSpacing - Space between operand columns.
685   int OperandSpacing = -1;
686
687   // isMCAsmWriter - Is this assembly writer for an MC emitter? This controls
688   // generation of the printInstruction() method. For MC printers, it takes
689   // an MCInstr* operand, otherwise it takes a MachineInstr*.
690   bit isMCAsmWriter = 0;
691 }
692 def DefaultAsmWriter : AsmWriter;
693
694
695 //===----------------------------------------------------------------------===//
696 // Target - This class contains the "global" target information
697 //
698 class Target {
699   // InstructionSet - Instruction set description for this target.
700   InstrInfo InstructionSet;
701
702   // AssemblyParsers - The AsmParser instances available for this target.
703   list<AsmParser> AssemblyParsers = [DefaultAsmParser];
704
705   // AssemblyWriters - The AsmWriter instances available for this target.
706   list<AsmWriter> AssemblyWriters = [DefaultAsmWriter];
707 }
708
709 //===----------------------------------------------------------------------===//
710 // SubtargetFeature - A characteristic of the chip set.
711 //
712 class SubtargetFeature<string n, string a,  string v, string d,
713                        list<SubtargetFeature> i = []> {
714   // Name - Feature name.  Used by command line (-mattr=) to determine the
715   // appropriate target chip.
716   //
717   string Name = n;
718
719   // Attribute - Attribute to be set by feature.
720   //
721   string Attribute = a;
722
723   // Value - Value the attribute to be set to by feature.
724   //
725   string Value = v;
726
727   // Desc - Feature description.  Used by command line (-mattr=) to display help
728   // information.
729   //
730   string Desc = d;
731
732   // Implies - Features that this feature implies are present. If one of those
733   // features isn't set, then this one shouldn't be set either.
734   //
735   list<SubtargetFeature> Implies = i;
736 }
737
738 //===----------------------------------------------------------------------===//
739 // Processor chip sets - These values represent each of the chip sets supported
740 // by the scheduler.  Each Processor definition requires corresponding
741 // instruction itineraries.
742 //
743 class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f> {
744   // Name - Chip set name.  Used by command line (-mcpu=) to determine the
745   // appropriate target chip.
746   //
747   string Name = n;
748
749   // ProcItin - The scheduling information for the target processor.
750   //
751   ProcessorItineraries ProcItin = pi;
752
753   // Features - list of
754   list<SubtargetFeature> Features = f;
755 }
756
757 //===----------------------------------------------------------------------===//
758 // Pull in the common support for calling conventions.
759 //
760 include "llvm/Target/TargetCallingConv.td"
761
762 //===----------------------------------------------------------------------===//
763 // Pull in the common support for DAG isel generation.
764 //
765 include "llvm/Target/TargetSelectionDAG.td"