1 //===- Target.td - Target Independent TableGen interface ---*- tablegen -*-===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 // This file defines the target-independent interfaces which should be
10 // implemented by each target which is using a TableGen based code generator.
12 //===----------------------------------------------------------------------===//
14 // Include all information about LLVM intrinsics.
15 include "llvm/IR/Intrinsics.td"
17 //===----------------------------------------------------------------------===//
18 // Register file description - These classes are used to fill in the target
19 // description classes.
21 class RegisterClass; // Forward def
23 class HwMode<string FS> {
24 // A string representing subtarget features that turn on this HW mode.
25 // For example, "+feat1,-feat2" will indicate that the mode is active
26 // when "feat1" is enabled and "feat2" is disabled at the same time.
27 // Any other features are not checked.
28 // When multiple modes are used, they should be mutually exclusive,
29 // otherwise the results are unpredictable.
33 // A special mode recognized by tablegen. This mode is considered active
34 // when no other mode is active. For targets that do not use specific hw
35 // modes, this is the only mode.
36 def DefaultMode : HwMode<"">;
38 // A class used to associate objects with HW modes. It is only intended to
39 // be used as a base class, where the derived class should contain a member
40 // "Objects", which is a list of the same length as the list of modes.
41 // The n-th element on the Objects list will be associated with the n-th
42 // element on the Modes list.
43 class HwModeSelect<list<HwMode> Ms> {
44 list<HwMode> Modes = Ms;
47 // A common class that implements a counterpart of ValueType, which is
48 // dependent on a HW mode. This class inherits from ValueType itself,
49 // which makes it possible to use objects of this class where ValueType
50 // objects could be used. This is specifically applicable to selection
52 class ValueTypeByHwMode<list<HwMode> Ms, list<ValueType> Ts>
53 : HwModeSelect<Ms>, ValueType<0, 0> {
54 // The length of this list must be the same as the length of Ms.
55 list<ValueType> Objects = Ts;
58 // A class representing the register size, spill size and spill alignment
59 // in bits of a register.
60 class RegInfo<int RS, int SS, int SA> {
61 int RegSize = RS; // Register size in bits.
62 int SpillSize = SS; // Spill slot size in bits.
63 int SpillAlignment = SA; // Spill slot alignment in bits.
66 // The register size/alignment information, parameterized by a HW mode.
67 class RegInfoByHwMode<list<HwMode> Ms = [], list<RegInfo> Ts = []>
69 // The length of this list must be the same as the length of Ms.
70 list<RegInfo> Objects = Ts;
73 // SubRegIndex - Use instances of SubRegIndex to identify subregisters.
74 class SubRegIndex<int size, int offset = 0> {
75 string Namespace = "";
77 // Size - Size (in bits) of the sub-registers represented by this index.
80 // Offset - Offset of the first bit that is part of this sub-register index.
81 // Set it to -1 if the same index is used to represent sub-registers that can
82 // be at different offsets (for example when using an index to access an
83 // element in a register tuple).
86 // ComposedOf - A list of two SubRegIndex instances, [A, B].
87 // This indicates that this SubRegIndex is the result of composing A and B.
88 // See ComposedSubRegIndex.
89 list<SubRegIndex> ComposedOf = [];
91 // CoveringSubRegIndices - A list of two or more sub-register indexes that
92 // cover this sub-register.
94 // This field should normally be left blank as TableGen can infer it.
96 // TableGen automatically detects sub-registers that straddle the registers
97 // in the SubRegs field of a Register definition. For example:
99 // Q0 = dsub_0 -> D0, dsub_1 -> D1
100 // Q1 = dsub_0 -> D2, dsub_1 -> D3
101 // D1_D2 = dsub_0 -> D1, dsub_1 -> D2
102 // QQ0 = qsub_0 -> Q0, qsub_1 -> Q1
104 // TableGen will infer that D1_D2 is a sub-register of QQ0. It will be given
105 // the synthetic index dsub_1_dsub_2 unless some SubRegIndex is defined with
106 // CoveringSubRegIndices = [dsub_1, dsub_2].
107 list<SubRegIndex> CoveringSubRegIndices = [];
110 // ComposedSubRegIndex - A sub-register that is the result of composing A and B.
111 // Offset is set to the sum of A and B's Offsets. Size is set to B's Size.
112 class ComposedSubRegIndex<SubRegIndex A, SubRegIndex B>
113 : SubRegIndex<B.Size, !if(!eq(A.Offset, -1), -1,
114 !if(!eq(B.Offset, -1), -1,
115 !add(A.Offset, B.Offset)))> {
117 let ComposedOf = [A, B];
120 // RegAltNameIndex - The alternate name set to use for register operands of
121 // this register class when printing.
122 class RegAltNameIndex {
123 string Namespace = "";
125 def NoRegAltName : RegAltNameIndex;
127 // Register - You should define one instance of this class for each register
128 // in the target machine. String n will become the "name" of the register.
129 class Register<string n, list<string> altNames = []> {
130 string Namespace = "";
132 list<string> AltNames = altNames;
134 // Aliases - A list of registers that this register overlaps with. A read or
135 // modification of this register can potentially read or modify the aliased
137 list<Register> Aliases = [];
139 // SubRegs - A list of registers that are parts of this register. Note these
140 // are "immediate" sub-registers and the registers within the list do not
141 // themselves overlap. e.g. For X86, EAX's SubRegs list contains only [AX],
143 list<Register> SubRegs = [];
145 // SubRegIndices - For each register in SubRegs, specify the SubRegIndex used
146 // to address it. Sub-sub-register indices are automatically inherited from
148 list<SubRegIndex> SubRegIndices = [];
150 // RegAltNameIndices - The alternate name indices which are valid for this
152 list<RegAltNameIndex> RegAltNameIndices = [];
154 // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
155 // These values can be determined by locating the <target>.h file in the
156 // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
157 // order of these names correspond to the enumeration used by gcc. A value of
158 // -1 indicates that the gcc number is undefined and -2 that register number
159 // is invalid for this mode/flavour.
160 list<int> DwarfNumbers = [];
162 // CostPerUse - Additional cost of instructions using this register compared
163 // to other registers in its class. The register allocator will try to
164 // minimize the number of instructions using a register with a CostPerUse.
165 // This is used by the x86-64 and ARM Thumb targets where some registers
166 // require larger instruction encodings.
169 // CoveredBySubRegs - When this bit is set, the value of this register is
170 // completely determined by the value of its sub-registers. For example, the
171 // x86 register AX is covered by its sub-registers AL and AH, but EAX is not
172 // covered by its sub-register AX.
173 bit CoveredBySubRegs = 0;
175 // HWEncoding - The target specific hardware encoding for this register.
176 bits<16> HWEncoding = 0;
178 bit isArtificial = 0;
181 // RegisterWithSubRegs - This can be used to define instances of Register which
182 // need to specify sub-registers.
183 // List "subregs" specifies which registers are sub-registers to this one. This
184 // is used to populate the SubRegs and AliasSet fields of TargetRegisterDesc.
185 // This allows the code generator to be careful not to put two values with
186 // overlapping live ranges into registers which alias.
187 class RegisterWithSubRegs<string n, list<Register> subregs> : Register<n> {
188 let SubRegs = subregs;
191 // DAGOperand - An empty base class that unifies RegisterClass's and other forms
192 // of Operand's that are legal as type qualifiers in DAG patterns. This should
193 // only ever be used for defining multiclasses that are polymorphic over both
194 // RegisterClass's and other Operand's.
196 string OperandNamespace = "MCOI";
197 string DecoderMethod = "";
200 // RegisterClass - Now that all of the registers are defined, and aliases
201 // between registers are defined, specify which registers belong to which
202 // register classes. This also defines the default allocation order of
203 // registers by register allocators.
205 class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,
206 dag regList, RegAltNameIndex idx = NoRegAltName>
208 string Namespace = namespace;
210 // The register size/alignment information, parameterized by a HW mode.
211 RegInfoByHwMode RegInfos;
213 // RegType - Specify the list ValueType of the registers in this register
214 // class. Note that all registers in a register class must have the same
215 // ValueTypes. This is a list because some targets permit storing different
216 // types in same register, for example vector values with 128-bit total size,
217 // but different count/size of items, like SSE on x86.
219 list<ValueType> RegTypes = regTypes;
221 // Size - Specify the spill size in bits of the registers. A default value of
222 // zero lets tablgen pick an appropriate size.
225 // Alignment - Specify the alignment required of the registers when they are
226 // stored or loaded to memory.
228 int Alignment = alignment;
230 // CopyCost - This value is used to specify the cost of copying a value
231 // between two registers in this register class. The default value is one
232 // meaning it takes a single instruction to perform the copying. A negative
233 // value means copying is extremely expensive or impossible.
236 // MemberList - Specify which registers are in this class. If the
237 // allocation_order_* method are not specified, this also defines the order of
238 // allocation used by the register allocator.
240 dag MemberList = regList;
242 // AltNameIndex - The alternate register name to use when printing operands
243 // of this register class. Every register in the register class must have
244 // a valid alternate name for the given index.
245 RegAltNameIndex altNameIndex = idx;
247 // isAllocatable - Specify that the register class can be used for virtual
248 // registers and register allocation. Some register classes are only used to
249 // model instruction operand constraints, and should have isAllocatable = 0.
250 bit isAllocatable = 1;
252 // AltOrders - List of alternative allocation orders. The default order is
253 // MemberList itself, and that is good enough for most targets since the
254 // register allocators automatically remove reserved registers and move
255 // callee-saved registers to the end.
256 list<dag> AltOrders = [];
258 // AltOrderSelect - The body of a function that selects the allocation order
259 // to use in a given machine function. The code will be inserted in a
260 // function like this:
262 // static inline unsigned f(const MachineFunction &MF) { ... }
264 // The function should return 0 to select the default order defined by
265 // MemberList, 1 to select the first AltOrders entry and so on.
266 code AltOrderSelect = [{}];
268 // Specify allocation priority for register allocators using a greedy
269 // heuristic. Classes with higher priority values are assigned first. This is
270 // useful as it is sometimes beneficial to assign registers to highly
271 // constrained classes first. The value has to be in the range [0,63].
272 int AllocationPriority = 0;
274 // The diagnostic type to present when referencing this operand in a match
275 // failure error message. If this is empty, the default Match_InvalidOperand
276 // diagnostic type will be used. If this is "<name>", a Match_<name> enum
277 // value will be generated and used for this operand type. The target
278 // assembly parser is responsible for converting this into a user-facing
279 // diagnostic message.
280 string DiagnosticType = "";
282 // A diagnostic message to emit when an invalid value is provided for this
283 // register class when it is being used an an assembly operand. If this is
284 // non-empty, an anonymous diagnostic type enum value will be generated, and
285 // the assembly matcher will provide a function to map from diagnostic types
286 // to message strings.
287 string DiagnosticString = "";
290 // The memberList in a RegisterClass is a dag of set operations. TableGen
291 // evaluates these set operations and expand them into register lists. These
292 // are the most common operation, see test/TableGen/SetTheory.td for more
293 // examples of what is possible:
295 // (add R0, R1, R2) - Set Union. Each argument can be an individual register, a
296 // register class, or a sub-expression. This is also the way to simply list
299 // (sub GPR, SP) - Set difference. Subtract the last arguments from the first.
301 // (and GPR, CSR) - Set intersection. All registers from the first set that are
302 // also in the second set.
304 // (sequence "R%u", 0, 15) -> [R0, R1, ..., R15]. Generate a sequence of
305 // numbered registers. Takes an optional 4th operand which is a stride to use
306 // when generating the sequence.
308 // (shl GPR, 4) - Remove the first N elements.
310 // (trunc GPR, 4) - Truncate after the first N elements.
312 // (rotl GPR, 1) - Rotate N places to the left.
314 // (rotr GPR, 1) - Rotate N places to the right.
316 // (decimate GPR, 2) - Pick every N'th element, starting with the first.
318 // (interleave A, B, ...) - Interleave the elements from each argument list.
320 // All of these operators work on ordered sets, not lists. That means
321 // duplicates are removed from sub-expressions.
323 // Set operators. The rest is defined in TargetSelectionDAG.td.
328 // RegisterTuples - Automatically generate super-registers by forming tuples of
329 // sub-registers. This is useful for modeling register sequence constraints
330 // with pseudo-registers that are larger than the architectural registers.
332 // The sub-register lists are zipped together:
334 // def EvenOdd : RegisterTuples<[sube, subo], [(add R0, R2), (add R1, R3)]>;
336 // Generates the same registers as:
338 // let SubRegIndices = [sube, subo] in {
339 // def R0_R1 : RegisterWithSubRegs<"", [R0, R1]>;
340 // def R2_R3 : RegisterWithSubRegs<"", [R2, R3]>;
343 // The generated pseudo-registers inherit super-classes and fields from their
344 // first sub-register. Most fields from the Register class are inferred, and
345 // the AsmName and Dwarf numbers are cleared.
347 // RegisterTuples instances can be used in other set operations to form
348 // register classes and so on. This is the only way of using the generated
350 class RegisterTuples<list<SubRegIndex> Indices, list<dag> Regs> {
351 // SubRegs - N lists of registers to be zipped up. Super-registers are
352 // synthesized from the first element of each SubRegs list, the second
353 // element and so on.
354 list<dag> SubRegs = Regs;
356 // SubRegIndices - N SubRegIndex instances. This provides the names of the
357 // sub-registers in the synthesized super-registers.
358 list<SubRegIndex> SubRegIndices = Indices;
362 //===----------------------------------------------------------------------===//
363 // DwarfRegNum - This class provides a mapping of the llvm register enumeration
364 // to the register numbering used by gcc and gdb. These values are used by a
365 // debug information writer to describe where values may be located during
367 class DwarfRegNum<list<int> Numbers> {
368 // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
369 // These values can be determined by locating the <target>.h file in the
370 // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
371 // order of these names correspond to the enumeration used by gcc. A value of
372 // -1 indicates that the gcc number is undefined and -2 that register number
373 // is invalid for this mode/flavour.
374 list<int> DwarfNumbers = Numbers;
377 // DwarfRegAlias - This class declares that a given register uses the same dwarf
378 // numbers as another one. This is useful for making it clear that the two
379 // registers do have the same number. It also lets us build a mapping
380 // from dwarf register number to llvm register.
381 class DwarfRegAlias<Register reg> {
382 Register DwarfAlias = reg;
385 //===----------------------------------------------------------------------===//
386 // Pull in the common support for MCPredicate (portable scheduling predicates).
388 include "llvm/Target/TargetInstrPredicate.td"
390 //===----------------------------------------------------------------------===//
391 // Pull in the common support for scheduling
393 include "llvm/Target/TargetSchedule.td"
395 class Predicate; // Forward def
397 //===----------------------------------------------------------------------===//
398 // Instruction set description - These classes correspond to the C++ classes in
399 // the Target/TargetInstrInfo.h file.
402 string Namespace = "";
404 dag OutOperandList; // An dag containing the MI def operand list.
405 dag InOperandList; // An dag containing the MI use operand list.
406 string AsmString = ""; // The .s format to print the instruction with.
408 // Pattern - Set to the DAG pattern for this instruction, if we know of one,
409 // otherwise, uninitialized.
412 // The follow state will eventually be inferred automatically from the
413 // instruction pattern.
415 list<Register> Uses = []; // Default to using no non-operand registers
416 list<Register> Defs = []; // Default to modifying no non-operand registers
418 // Predicates - List of predicates which will be turned into isel matching
420 list<Predicate> Predicates = [];
422 // Size - Size of encoded instruction, or zero if the size cannot be determined
426 // DecoderNamespace - The "namespace" in which this instruction exists, on
427 // targets like ARM which multiple ISA namespaces exist.
428 string DecoderNamespace = "";
430 // Code size, for instruction selection.
431 // FIXME: What does this actually mean?
434 // Added complexity passed onto matching pattern.
435 int AddedComplexity = 0;
437 // These bits capture information about the high-level semantics of the
439 bit isReturn = 0; // Is this instruction a return instruction?
440 bit isBranch = 0; // Is this instruction a branch instruction?
441 bit isEHScopeReturn = 0; // Does this instruction end an EH scope?
442 bit isIndirectBranch = 0; // Is this instruction an indirect branch?
443 bit isCompare = 0; // Is this instruction a comparison instruction?
444 bit isMoveImm = 0; // Is this instruction a move immediate instruction?
445 bit isMoveReg = 0; // Is this instruction a move register instruction?
446 bit isBitcast = 0; // Is this instruction a bitcast instruction?
447 bit isSelect = 0; // Is this instruction a select instruction?
448 bit isBarrier = 0; // Can control flow fall through this instruction?
449 bit isCall = 0; // Is this instruction a call instruction?
450 bit isAdd = 0; // Is this instruction an add instruction?
451 bit isTrap = 0; // Is this instruction a trap instruction?
452 bit canFoldAsLoad = 0; // Can this be folded as a simple memory operand?
453 bit mayLoad = ?; // Is it possible for this inst to read memory?
454 bit mayStore = ?; // Is it possible for this inst to write memory?
455 bit isConvertibleToThreeAddress = 0; // Can this 2-addr instruction promote?
456 bit isCommutable = 0; // Is this 3 operand instruction commutable?
457 bit isTerminator = 0; // Is this part of the terminator for a basic block?
458 bit isReMaterializable = 0; // Is this instruction re-materializable?
459 bit isPredicable = 0; // Is this instruction predicable?
460 bit hasDelaySlot = 0; // Does this instruction have an delay slot?
461 bit usesCustomInserter = 0; // Pseudo instr needing special help.
462 bit hasPostISelHook = 0; // To be *adjusted* after isel by target hook.
463 bit hasCtrlDep = 0; // Does this instruction r/w ctrl-flow chains?
464 bit isNotDuplicable = 0; // Is it unsafe to duplicate this instruction?
465 bit isConvergent = 0; // Is this instruction convergent?
466 bit isAsCheapAsAMove = 0; // As cheap (or cheaper) than a move instruction.
467 bit hasExtraSrcRegAllocReq = 0; // Sources have special regalloc requirement?
468 bit hasExtraDefRegAllocReq = 0; // Defs have special regalloc requirement?
469 bit isRegSequence = 0; // Is this instruction a kind of reg sequence?
470 // If so, make sure to override
471 // TargetInstrInfo::getRegSequenceLikeInputs.
472 bit isPseudo = 0; // Is this instruction a pseudo-instruction?
473 // If so, won't have encoding information for
474 // the [MC]CodeEmitter stuff.
475 bit isExtractSubreg = 0; // Is this instruction a kind of extract subreg?
476 // If so, make sure to override
477 // TargetInstrInfo::getExtractSubregLikeInputs.
478 bit isInsertSubreg = 0; // Is this instruction a kind of insert subreg?
479 // If so, make sure to override
480 // TargetInstrInfo::getInsertSubregLikeInputs.
481 bit variadicOpsAreDefs = 0; // Are variadic operands definitions?
483 // Does the instruction have side effects that are not captured by any
484 // operands of the instruction or other flags?
485 bit hasSideEffects = ?;
487 // Is this instruction a "real" instruction (with a distinct machine
488 // encoding), or is it a pseudo instruction used for codegen modeling
490 // FIXME: For now this is distinct from isPseudo, above, as code-gen-only
491 // instructions can (and often do) still have encoding information
492 // associated with them. Once we've migrated all of them over to true
493 // pseudo-instructions that are lowered to real instructions prior to
494 // the printer/emitter, we can remove this attribute and just use isPseudo.
496 // The intended use is:
497 // isPseudo: Does not have encoding information and should be expanded,
498 // at the latest, during lowering to MCInst.
500 // isCodeGenOnly: Does have encoding information and can go through to the
501 // CodeEmitter unchanged, but duplicates a canonical instruction
502 // definition's encoding and should be ignored when constructing the
503 // assembler match tables.
504 bit isCodeGenOnly = 0;
506 // Is this instruction a pseudo instruction for use by the assembler parser.
507 bit isAsmParserOnly = 0;
509 // This instruction is not expected to be queried for scheduling latencies
510 // and therefore needs no scheduling information even for a complete
512 bit hasNoSchedulingInfo = 0;
514 InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling.
516 // Scheduling information from TargetSchedule.td.
517 list<SchedReadWrite> SchedRW;
519 string Constraints = ""; // OperandConstraint, e.g. $src = $dst.
521 /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not
522 /// be encoded into the output machineinstr.
523 string DisableEncoding = "";
525 string PostEncoderMethod = "";
526 string DecoderMethod = "";
528 // Is the instruction decoder method able to completely determine if the
529 // given instruction is valid or not. If the TableGen definition of the
530 // instruction specifies bitpattern A??B where A and B are static bits, the
531 // hasCompleteDecoder flag says whether the decoder method fully handles the
532 // ?? space, i.e. if it is a final arbiter for the instruction validity.
533 // If not then the decoder attempts to continue decoding when the decoder
536 // This allows to handle situations where the encoding is not fully
537 // orthogonal. Example:
538 // * InstA with bitpattern 0b0000????,
539 // * InstB with bitpattern 0b000000?? but the associated decoder method
540 // DecodeInstB() returns Fail when ?? is 0b00 or 0b11.
542 // The decoder tries to decode a bitpattern that matches both InstA and
543 // InstB bitpatterns first as InstB (because it is the most specific
544 // encoding). In the default case (hasCompleteDecoder = 1), when
545 // DecodeInstB() returns Fail the bitpattern gets rejected. By setting
546 // hasCompleteDecoder = 0 in InstB, the decoder is informed that
547 // DecodeInstB() is not able to determine if all possible values of ?? are
548 // valid or not. If DecodeInstB() returns Fail the decoder will attempt to
549 // decode the bitpattern as InstA too.
550 bit hasCompleteDecoder = 1;
552 /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
553 bits<64> TSFlags = 0;
555 ///@name Assembler Parser Support
558 string AsmMatchConverter = "";
560 /// TwoOperandAliasConstraint - Enable TableGen to auto-generate a
561 /// two-operand matcher inst-alias for a three operand instruction.
562 /// For example, the arm instruction "add r3, r3, r5" can be written
563 /// as "add r3, r5". The constraint is of the same form as a tied-operand
564 /// constraint. For example, "$Rn = $Rd".
565 string TwoOperandAliasConstraint = "";
567 /// Assembler variant name to use for this instruction. If specified then
568 /// instruction will be presented only in MatchTable for this variant. If
569 /// not specified then assembler variants will be determined based on
571 string AsmVariantName = "";
575 /// UseNamedOperandTable - If set, the operand indices of this instruction
576 /// can be queried via the getNamedOperandIdx() function which is generated
578 bit UseNamedOperandTable = 0;
580 /// Should FastISel ignore this instruction. For certain ISAs, they have
581 /// instructions which map to the same ISD Opcode, value type operands and
582 /// instruction selection predicates. FastISel cannot handle such cases, but
583 /// SelectionDAG can.
584 bit FastISelShouldIgnore = 0;
587 /// PseudoInstExpansion - Expansion information for a pseudo-instruction.
588 /// Which instruction it expands to and how the operands map from the
590 class PseudoInstExpansion<dag Result> {
591 dag ResultInst = Result; // The instruction to generate.
595 /// Predicates - These are extra conditionals which are turned into instruction
596 /// selector matching code. Currently each predicate is just a string.
597 class Predicate<string cond> {
598 string CondString = cond;
600 /// AssemblerMatcherPredicate - If this feature can be used by the assembler
601 /// matcher, this is true. Targets should set this by inheriting their
602 /// feature from the AssemblerPredicate class in addition to Predicate.
603 bit AssemblerMatcherPredicate = 0;
605 /// AssemblerCondString - Name of the subtarget feature being tested used
606 /// as alternative condition string used for assembler matcher.
607 /// e.g. "ModeThumb" is translated to "(Bits & ModeThumb) != 0".
608 /// "!ModeThumb" is translated to "(Bits & ModeThumb) == 0".
609 /// It can also list multiple features separated by ",".
610 /// e.g. "ModeThumb,FeatureThumb2" is translated to
611 /// "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0".
612 string AssemblerCondString = "";
614 /// PredicateName - User-level name to use for the predicate. Mainly for use
615 /// in diagnostics such as missing feature errors in the asm matcher.
616 string PredicateName = "";
618 /// Setting this to '1' indicates that the predicate must be recomputed on
619 /// every function change. Most predicates can leave this at '0'.
621 /// Ignored by SelectionDAG, it always recomputes the predicate on every use.
622 bit RecomputePerFunction = 0;
625 /// NoHonorSignDependentRounding - This predicate is true if support for
626 /// sign-dependent-rounding is not enabled.
627 def NoHonorSignDependentRounding
628 : Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">;
630 class Requires<list<Predicate> preds> {
631 list<Predicate> Predicates = preds;
634 /// ops definition - This is just a simple marker used to identify the operand
635 /// list for an instruction. outs and ins are identical both syntactically and
636 /// semantically; they are used to define def operands and use operands to
637 /// improve readibility. This should be used like this:
638 /// (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar.
643 /// variable_ops definition - Mark this instruction as taking a variable number
648 /// PointerLikeRegClass - Values that are designed to have pointer width are
649 /// derived from this. TableGen treats the register class as having a symbolic
650 /// type that it doesn't know, and resolves the actual regclass to use by using
651 /// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
652 class PointerLikeRegClass<int Kind> {
653 int RegClassKind = Kind;
657 /// ptr_rc definition - Mark this operand as being a pointer value whose
658 /// register class is resolved dynamically via a callback to TargetInstrInfo.
659 /// FIXME: We should probably change this to a class which contain a list of
660 /// flags. But currently we have but one flag.
661 def ptr_rc : PointerLikeRegClass<0>;
663 /// unknown definition - Mark this operand as being of unknown type, causing
664 /// it to be resolved by inference in the context it is used.
666 def unknown : unknown_class;
668 /// AsmOperandClass - Representation for the kinds of operands which the target
669 /// specific parser can create and the assembly matcher may need to distinguish.
671 /// Operand classes are used to define the order in which instructions are
672 /// matched, to ensure that the instruction which gets matched for any
673 /// particular list of operands is deterministic.
675 /// The target specific parser must be able to classify a parsed operand into a
676 /// unique class which does not partially overlap with any other classes. It can
677 /// match a subset of some other class, in which case the super class field
678 /// should be defined.
679 class AsmOperandClass {
680 /// The name to use for this class, which should be usable as an enum value.
683 /// The super classes of this operand.
684 list<AsmOperandClass> SuperClasses = [];
686 /// The name of the method on the target specific operand to call to test
687 /// whether the operand is an instance of this class. If not set, this will
688 /// default to "isFoo", where Foo is the AsmOperandClass name. The method
689 /// signature should be:
690 /// bool isFoo() const;
691 string PredicateMethod = ?;
693 /// The name of the method on the target specific operand to call to add the
694 /// target specific operand to an MCInst. If not set, this will default to
695 /// "addFooOperands", where Foo is the AsmOperandClass name. The method
696 /// signature should be:
697 /// void addFooOperands(MCInst &Inst, unsigned N) const;
698 string RenderMethod = ?;
700 /// The name of the method on the target specific operand to call to custom
701 /// handle the operand parsing. This is useful when the operands do not relate
702 /// to immediates or registers and are very instruction specific (as flags to
703 /// set in a processor register, coprocessor number, ...).
704 string ParserMethod = ?;
706 // The diagnostic type to present when referencing this operand in a
707 // match failure error message. By default, use a generic "invalid operand"
708 // diagnostic. The target AsmParser maps these codes to text.
709 string DiagnosticType = "";
711 /// A diagnostic message to emit when an invalid value is provided for this
713 string DiagnosticString = "";
715 /// Set to 1 if this operand is optional and not always required. Typically,
716 /// the AsmParser will emit an error when it finishes parsing an
717 /// instruction if it hasn't matched all the operands yet. However, this
718 /// error will be suppressed if all of the remaining unmatched operands are
719 /// marked as IsOptional.
721 /// Optional arguments must be at the end of the operand list.
724 /// The name of the method on the target specific asm parser that returns the
725 /// default operand for this optional operand. This method is only used if
726 /// IsOptional == 1. If not set, this will default to "defaultFooOperands",
727 /// where Foo is the AsmOperandClass name. The method signature should be:
728 /// std::unique_ptr<MCParsedAsmOperand> defaultFooOperands() const;
729 string DefaultMethod = ?;
732 def ImmAsmOperand : AsmOperandClass {
736 /// Operand Types - These provide the built-in operand types that may be used
737 /// by a target. Targets can optionally provide their own operand types as
738 /// needed, though this should not be needed for RISC targets.
739 class Operand<ValueType ty> : DAGOperand {
741 string PrintMethod = "printOperand";
742 string EncoderMethod = "";
743 bit hasCompleteDecoder = 1;
744 string OperandType = "OPERAND_UNKNOWN";
745 dag MIOperandInfo = (ops);
747 // MCOperandPredicate - Optionally, a code fragment operating on
748 // const MCOperand &MCOp, and returning a bool, to indicate if
749 // the value of MCOp is valid for the specific subclass of Operand
750 code MCOperandPredicate;
752 // ParserMatchClass - The "match class" that operands of this type fit
753 // in. Match classes are used to define the order in which instructions are
754 // match, to ensure that which instructions gets matched is deterministic.
756 // The target specific parser must be able to classify an parsed operand into
757 // a unique class, which does not partially overlap with any other classes. It
758 // can match a subset of some other class, in which case the AsmOperandClass
759 // should declare the other operand as one of its super classes.
760 AsmOperandClass ParserMatchClass = ImmAsmOperand;
763 class RegisterOperand<RegisterClass regclass, string pm = "printOperand">
765 // RegClass - The register class of the operand.
766 RegisterClass RegClass = regclass;
767 // PrintMethod - The target method to call to print register operands of
768 // this type. The method normally will just use an alt-name index to look
769 // up the name to print. Default to the generic printOperand().
770 string PrintMethod = pm;
772 // EncoderMethod - The target method name to call to encode this register
774 string EncoderMethod = "";
776 // ParserMatchClass - The "match class" that operands of this type fit
777 // in. Match classes are used to define the order in which instructions are
778 // match, to ensure that which instructions gets matched is deterministic.
780 // The target specific parser must be able to classify an parsed operand into
781 // a unique class, which does not partially overlap with any other classes. It
782 // can match a subset of some other class, in which case the AsmOperandClass
783 // should declare the other operand as one of its super classes.
784 AsmOperandClass ParserMatchClass;
786 string OperandType = "OPERAND_REGISTER";
788 // When referenced in the result of a CodeGen pattern, GlobalISel will
789 // normally copy the matched operand to the result. When this is set, it will
790 // emit a special copy that will replace zero-immediates with the specified
792 Register GIZeroRegister = ?;
795 let OperandType = "OPERAND_IMMEDIATE" in {
796 def i1imm : Operand<i1>;
797 def i8imm : Operand<i8>;
798 def i16imm : Operand<i16>;
799 def i32imm : Operand<i32>;
800 def i64imm : Operand<i64>;
802 def f32imm : Operand<f32>;
803 def f64imm : Operand<f64>;
806 // Register operands for generic instructions don't have an MVT, but do have
807 // constraints linking the operands (e.g. all operands of a G_ADD must
808 // have the same LLT).
809 class TypedOperand<string Ty> : Operand<untyped> {
810 let OperandType = Ty;
814 def type0 : TypedOperand<"OPERAND_GENERIC_0">;
815 def type1 : TypedOperand<"OPERAND_GENERIC_1">;
816 def type2 : TypedOperand<"OPERAND_GENERIC_2">;
817 def type3 : TypedOperand<"OPERAND_GENERIC_3">;
818 def type4 : TypedOperand<"OPERAND_GENERIC_4">;
819 def type5 : TypedOperand<"OPERAND_GENERIC_5">;
821 let IsPointer = 1 in {
822 def ptype0 : TypedOperand<"OPERAND_GENERIC_0">;
823 def ptype1 : TypedOperand<"OPERAND_GENERIC_1">;
824 def ptype2 : TypedOperand<"OPERAND_GENERIC_2">;
825 def ptype3 : TypedOperand<"OPERAND_GENERIC_3">;
826 def ptype4 : TypedOperand<"OPERAND_GENERIC_4">;
827 def ptype5 : TypedOperand<"OPERAND_GENERIC_5">;
830 /// zero_reg definition - Special node to stand for the zero register.
834 /// All operands which the MC layer classifies as predicates should inherit from
835 /// this class in some manner. This is already handled for the most commonly
836 /// used PredicateOperand, but may be useful in other circumstances.
839 /// OperandWithDefaultOps - This Operand class can be used as the parent class
840 /// for an Operand that needs to be initialized with a default value if
841 /// no value is supplied in a pattern. This class can be used to simplify the
842 /// pattern definitions for instructions that have target specific flags
843 /// encoded as immediate operands.
844 class OperandWithDefaultOps<ValueType ty, dag defaultops>
846 dag DefaultOps = defaultops;
849 /// PredicateOperand - This can be used to define a predicate operand for an
850 /// instruction. OpTypes specifies the MIOperandInfo for the operand, and
851 /// AlwaysVal specifies the value of this predicate when set to "always
853 class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal>
854 : OperandWithDefaultOps<ty, AlwaysVal>, PredicateOp {
855 let MIOperandInfo = OpTypes;
858 /// OptionalDefOperand - This is used to define a optional definition operand
859 /// for an instruction. DefaultOps is the register the operand represents if
860 /// none is supplied, e.g. zero_reg.
861 class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>
862 : OperandWithDefaultOps<ty, defaultops> {
863 let MIOperandInfo = OpTypes;
867 // InstrInfo - This class should only be instantiated once to provide parameters
868 // which are global to the target machine.
871 // Target can specify its instructions in either big or little-endian formats.
872 // For instance, while both Sparc and PowerPC are big-endian platforms, the
873 // Sparc manual specifies its instructions in the format [31..0] (big), while
874 // PowerPC specifies them using the format [0..31] (little).
875 bit isLittleEndianEncoding = 0;
877 // The instruction properties mayLoad, mayStore, and hasSideEffects are unset
878 // by default, and TableGen will infer their value from the instruction
879 // pattern when possible.
881 // Normally, TableGen will issue an error it it can't infer the value of a
882 // property that hasn't been set explicitly. When guessInstructionProperties
883 // is set, it will guess a safe value instead.
885 // This option is a temporary migration help. It will go away.
886 bit guessInstructionProperties = 1;
888 // TableGen's instruction encoder generator has support for matching operands
889 // to bit-field variables both by name and by position. While matching by
890 // name is preferred, this is currently not possible for complex operands,
891 // and some targets still reply on the positional encoding rules. When
892 // generating a decoder for such targets, the positional encoding rules must
893 // be used by the decoder generator as well.
895 // This option is temporary; it will go away once the TableGen decoder
896 // generator has better support for complex operands and targets have
897 // migrated away from using positionally encoded operands.
898 bit decodePositionallyEncodedOperands = 0;
900 // When set, this indicates that there will be no overlap between those
901 // operands that are matched by ordering (positional operands) and those
904 // This option is temporary; it will go away once the TableGen decoder
905 // generator has better support for complex operands and targets have
906 // migrated away from using positionally encoded operands.
907 bit noNamedPositionallyEncodedOperands = 0;
910 // Standard Pseudo Instructions.
911 // This list must match TargetOpcodes.h and CodeGenTarget.cpp.
912 // Only these instructions are allowed in the TargetOpcode namespace.
913 // Ensure mayLoad and mayStore have a default value, so as not to break
914 // targets that set guessInstructionProperties=0. Any local definition of
915 // mayLoad/mayStore takes precedence over these default values.
916 class StandardPseudoInstruction : Instruction {
919 let isCodeGenOnly = 1;
921 let hasNoSchedulingInfo = 1;
922 let Namespace = "TargetOpcode";
924 def PHI : StandardPseudoInstruction {
925 let OutOperandList = (outs unknown:$dst);
926 let InOperandList = (ins variable_ops);
927 let AsmString = "PHINODE";
928 let hasSideEffects = 0;
930 def INLINEASM : StandardPseudoInstruction {
931 let OutOperandList = (outs);
932 let InOperandList = (ins variable_ops);
934 let hasSideEffects = 0; // Note side effect is encoded in an operand.
936 def INLINEASM_BR : StandardPseudoInstruction {
937 let OutOperandList = (outs);
938 let InOperandList = (ins variable_ops);
940 let hasSideEffects = 0; // Note side effect is encoded in an operand.
941 let isTerminator = 1;
943 let isIndirectBranch = 1;
945 def CFI_INSTRUCTION : StandardPseudoInstruction {
946 let OutOperandList = (outs);
947 let InOperandList = (ins i32imm:$id);
950 let hasSideEffects = 0;
951 let isNotDuplicable = 1;
953 def EH_LABEL : StandardPseudoInstruction {
954 let OutOperandList = (outs);
955 let InOperandList = (ins i32imm:$id);
958 let hasSideEffects = 0;
959 let isNotDuplicable = 1;
961 def GC_LABEL : StandardPseudoInstruction {
962 let OutOperandList = (outs);
963 let InOperandList = (ins i32imm:$id);
966 let hasSideEffects = 0;
967 let isNotDuplicable = 1;
969 def ANNOTATION_LABEL : StandardPseudoInstruction {
970 let OutOperandList = (outs);
971 let InOperandList = (ins i32imm:$id);
974 let hasSideEffects = 0;
975 let isNotDuplicable = 1;
977 def KILL : StandardPseudoInstruction {
978 let OutOperandList = (outs);
979 let InOperandList = (ins variable_ops);
981 let hasSideEffects = 0;
983 def EXTRACT_SUBREG : StandardPseudoInstruction {
984 let OutOperandList = (outs unknown:$dst);
985 let InOperandList = (ins unknown:$supersrc, i32imm:$subidx);
987 let hasSideEffects = 0;
989 def INSERT_SUBREG : StandardPseudoInstruction {
990 let OutOperandList = (outs unknown:$dst);
991 let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx);
993 let hasSideEffects = 0;
994 let Constraints = "$supersrc = $dst";
996 def IMPLICIT_DEF : StandardPseudoInstruction {
997 let OutOperandList = (outs unknown:$dst);
998 let InOperandList = (ins);
1000 let hasSideEffects = 0;
1001 let isReMaterializable = 1;
1002 let isAsCheapAsAMove = 1;
1004 def SUBREG_TO_REG : StandardPseudoInstruction {
1005 let OutOperandList = (outs unknown:$dst);
1006 let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx);
1008 let hasSideEffects = 0;
1010 def COPY_TO_REGCLASS : StandardPseudoInstruction {
1011 let OutOperandList = (outs unknown:$dst);
1012 let InOperandList = (ins unknown:$src, i32imm:$regclass);
1014 let hasSideEffects = 0;
1015 let isAsCheapAsAMove = 1;
1017 def DBG_VALUE : StandardPseudoInstruction {
1018 let OutOperandList = (outs);
1019 let InOperandList = (ins variable_ops);
1020 let AsmString = "DBG_VALUE";
1021 let hasSideEffects = 0;
1023 def DBG_LABEL : StandardPseudoInstruction {
1024 let OutOperandList = (outs);
1025 let InOperandList = (ins unknown:$label);
1026 let AsmString = "DBG_LABEL";
1027 let hasSideEffects = 0;
1029 def REG_SEQUENCE : StandardPseudoInstruction {
1030 let OutOperandList = (outs unknown:$dst);
1031 let InOperandList = (ins unknown:$supersrc, variable_ops);
1033 let hasSideEffects = 0;
1034 let isAsCheapAsAMove = 1;
1036 def COPY : StandardPseudoInstruction {
1037 let OutOperandList = (outs unknown:$dst);
1038 let InOperandList = (ins unknown:$src);
1040 let hasSideEffects = 0;
1041 let isAsCheapAsAMove = 1;
1042 let hasNoSchedulingInfo = 0;
1044 def BUNDLE : StandardPseudoInstruction {
1045 let OutOperandList = (outs);
1046 let InOperandList = (ins variable_ops);
1047 let AsmString = "BUNDLE";
1048 let hasSideEffects = 1;
1050 def LIFETIME_START : StandardPseudoInstruction {
1051 let OutOperandList = (outs);
1052 let InOperandList = (ins i32imm:$id);
1053 let AsmString = "LIFETIME_START";
1054 let hasSideEffects = 0;
1056 def LIFETIME_END : StandardPseudoInstruction {
1057 let OutOperandList = (outs);
1058 let InOperandList = (ins i32imm:$id);
1059 let AsmString = "LIFETIME_END";
1060 let hasSideEffects = 0;
1062 def STACKMAP : StandardPseudoInstruction {
1063 let OutOperandList = (outs);
1064 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops);
1065 let hasSideEffects = 1;
1068 let usesCustomInserter = 1;
1070 def PATCHPOINT : StandardPseudoInstruction {
1071 let OutOperandList = (outs unknown:$dst);
1072 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee,
1073 i32imm:$nargs, i32imm:$cc, variable_ops);
1074 let hasSideEffects = 1;
1077 let usesCustomInserter = 1;
1079 def STATEPOINT : StandardPseudoInstruction {
1080 let OutOperandList = (outs);
1081 let InOperandList = (ins variable_ops);
1082 let usesCustomInserter = 1;
1085 let hasSideEffects = 1;
1088 def LOAD_STACK_GUARD : StandardPseudoInstruction {
1089 let OutOperandList = (outs ptr_rc:$dst);
1090 let InOperandList = (ins);
1092 bit isReMaterializable = 1;
1093 let hasSideEffects = 0;
1096 def LOCAL_ESCAPE : StandardPseudoInstruction {
1097 // This instruction is really just a label. It has to be part of the chain so
1098 // that it doesn't get dropped from the DAG, but it produces nothing and has
1100 let OutOperandList = (outs);
1101 let InOperandList = (ins ptr_rc:$symbol, i32imm:$id);
1102 let hasSideEffects = 0;
1105 def FAULTING_OP : StandardPseudoInstruction {
1106 let OutOperandList = (outs unknown:$dst);
1107 let InOperandList = (ins variable_ops);
1108 let usesCustomInserter = 1;
1109 let hasSideEffects = 1;
1112 let isTerminator = 1;
1115 def PATCHABLE_OP : StandardPseudoInstruction {
1116 let OutOperandList = (outs);
1117 let InOperandList = (ins variable_ops);
1118 let usesCustomInserter = 1;
1121 let hasSideEffects = 1;
1123 def PATCHABLE_FUNCTION_ENTER : StandardPseudoInstruction {
1124 let OutOperandList = (outs);
1125 let InOperandList = (ins);
1126 let AsmString = "# XRay Function Enter.";
1127 let usesCustomInserter = 1;
1128 let hasSideEffects = 0;
1130 def PATCHABLE_RET : StandardPseudoInstruction {
1131 let OutOperandList = (outs);
1132 let InOperandList = (ins variable_ops);
1133 let AsmString = "# XRay Function Patchable RET.";
1134 let usesCustomInserter = 1;
1135 let hasSideEffects = 1;
1136 let isTerminator = 1;
1139 def PATCHABLE_FUNCTION_EXIT : StandardPseudoInstruction {
1140 let OutOperandList = (outs);
1141 let InOperandList = (ins);
1142 let AsmString = "# XRay Function Exit.";
1143 let usesCustomInserter = 1;
1144 let hasSideEffects = 0; // FIXME: is this correct?
1145 let isReturn = 0; // Original return instruction will follow
1147 def PATCHABLE_TAIL_CALL : StandardPseudoInstruction {
1148 let OutOperandList = (outs);
1149 let InOperandList = (ins variable_ops);
1150 let AsmString = "# XRay Tail Call Exit.";
1151 let usesCustomInserter = 1;
1152 let hasSideEffects = 1;
1155 def PATCHABLE_EVENT_CALL : StandardPseudoInstruction {
1156 let OutOperandList = (outs);
1157 let InOperandList = (ins ptr_rc:$event, i8imm:$size);
1158 let AsmString = "# XRay Custom Event Log.";
1159 let usesCustomInserter = 1;
1163 let hasSideEffects = 1;
1165 def PATCHABLE_TYPED_EVENT_CALL : StandardPseudoInstruction {
1166 let OutOperandList = (outs);
1167 let InOperandList = (ins i16imm:$type, ptr_rc:$event, i32imm:$size);
1168 let AsmString = "# XRay Typed Event Log.";
1169 let usesCustomInserter = 1;
1173 let hasSideEffects = 1;
1175 def FENTRY_CALL : StandardPseudoInstruction {
1176 let OutOperandList = (outs);
1177 let InOperandList = (ins);
1178 let AsmString = "# FEntry call";
1179 let usesCustomInserter = 1;
1182 let hasSideEffects = 1;
1184 def ICALL_BRANCH_FUNNEL : StandardPseudoInstruction {
1185 let OutOperandList = (outs unknown:$dst);
1186 let InOperandList = (ins variable_ops);
1188 let hasSideEffects = 1;
1191 // Generic opcodes used in GlobalISel.
1192 include "llvm/Target/GenericOpcodes.td"
1194 //===----------------------------------------------------------------------===//
1195 // AsmParser - This class can be implemented by targets that wish to implement
1198 // Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel
1199 // syntax on X86 for example).
1202 // AsmParserClassName - This specifies the suffix to use for the asmparser
1203 // class. Generated AsmParser classes are always prefixed with the target
1205 string AsmParserClassName = "AsmParser";
1207 // AsmParserInstCleanup - If non-empty, this is the name of a custom member
1208 // function of the AsmParser class to call on every matched instruction.
1209 // This can be used to perform target specific instruction post-processing.
1210 string AsmParserInstCleanup = "";
1212 // ShouldEmitMatchRegisterName - Set to false if the target needs a hand
1213 // written register name matcher
1214 bit ShouldEmitMatchRegisterName = 1;
1216 // Set to true if the target needs a generated 'alternative register name'
1219 // This generates a function which can be used to lookup registers from
1220 // their aliases. This function will fail when called on targets where
1221 // several registers share the same alias (i.e. not a 1:1 mapping).
1222 bit ShouldEmitMatchRegisterAltName = 0;
1224 // Set to true if MatchRegisterName and MatchRegisterAltName functions
1225 // should be generated even if there are duplicate register names. The
1226 // target is responsible for coercing aliased registers as necessary
1227 // (e.g. in validateTargetOperandClass), and there are no guarantees about
1228 // which numeric register identifier will be returned in the case of
1229 // multiple matches.
1230 bit AllowDuplicateRegisterNames = 0;
1232 // HasMnemonicFirst - Set to false if target instructions don't always
1233 // start with a mnemonic as the first token.
1234 bit HasMnemonicFirst = 1;
1236 // ReportMultipleNearMisses -
1237 // When 0, the assembly matcher reports an error for one encoding or operand
1238 // that did not match the parsed instruction.
1239 // When 1, the assmebly matcher returns a list of encodings that were close
1240 // to matching the parsed instruction, so to allow more detailed error
1242 bit ReportMultipleNearMisses = 0;
1244 def DefaultAsmParser : AsmParser;
1246 //===----------------------------------------------------------------------===//
1247 // AsmParserVariant - Subtargets can have multiple different assembly parsers
1248 // (e.g. AT&T vs Intel syntax on X86 for example). This class can be
1249 // implemented by targets to describe such variants.
1251 class AsmParserVariant {
1252 // Variant - AsmParsers can be of multiple different variants. Variants are
1253 // used to support targets that need to parser multiple formats for the
1254 // assembly language.
1257 // Name - The AsmParser variant name (e.g., AT&T vs Intel).
1260 // CommentDelimiter - If given, the delimiter string used to recognize
1261 // comments which are hard coded in the .td assembler strings for individual
1263 string CommentDelimiter = "";
1265 // RegisterPrefix - If given, the token prefix which indicates a register
1266 // token. This is used by the matcher to automatically recognize hard coded
1267 // register tokens as constrained registers, instead of tokens, for the
1268 // purposes of matching.
1269 string RegisterPrefix = "";
1271 // TokenizingCharacters - Characters that are standalone tokens
1272 string TokenizingCharacters = "[]*!";
1274 // SeparatorCharacters - Characters that are not tokens
1275 string SeparatorCharacters = " \t,";
1277 // BreakCharacters - Characters that start new identifiers
1278 string BreakCharacters = "";
1280 def DefaultAsmParserVariant : AsmParserVariant;
1282 /// AssemblerPredicate - This is a Predicate that can be used when the assembler
1283 /// matches instructions and aliases.
1284 class AssemblerPredicate<string cond, string name = ""> {
1285 bit AssemblerMatcherPredicate = 1;
1286 string AssemblerCondString = cond;
1287 string PredicateName = name;
1290 /// TokenAlias - This class allows targets to define assembler token
1291 /// operand aliases. That is, a token literal operand which is equivalent
1292 /// to another, canonical, token literal. For example, ARM allows:
1293 /// vmov.u32 s4, #0 -> vmov.i32, #0
1294 /// 'u32' is a more specific designator for the 32-bit integer type specifier
1295 /// and is legal for any instruction which accepts 'i32' as a datatype suffix.
1296 /// def : TokenAlias<".u32", ".i32">;
1298 /// This works by marking the match class of 'From' as a subclass of the
1299 /// match class of 'To'.
1300 class TokenAlias<string From, string To> {
1301 string FromToken = From;
1302 string ToToken = To;
1305 /// MnemonicAlias - This class allows targets to define assembler mnemonic
1306 /// aliases. This should be used when all forms of one mnemonic are accepted
1307 /// with a different mnemonic. For example, X86 allows:
1308 /// sal %al, 1 -> shl %al, 1
1309 /// sal %ax, %cl -> shl %ax, %cl
1310 /// sal %eax, %cl -> shl %eax, %cl
1311 /// etc. Though "sal" is accepted with many forms, all of them are directly
1312 /// translated to a shl, so it can be handled with (in the case of X86, it
1313 /// actually has one for each suffix as well):
1314 /// def : MnemonicAlias<"sal", "shl">;
1316 /// Mnemonic aliases are mapped before any other translation in the match phase,
1317 /// and do allow Requires predicates, e.g.:
1319 /// def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>;
1320 /// def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>;
1322 /// Mnemonic aliases can also be constrained to specific variants, e.g.:
1324 /// def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>;
1326 /// If no variant (e.g., "att" or "intel") is specified then the alias is
1327 /// applied unconditionally.
1328 class MnemonicAlias<string From, string To, string VariantName = ""> {
1329 string FromMnemonic = From;
1330 string ToMnemonic = To;
1331 string AsmVariantName = VariantName;
1333 // Predicates - Predicates that must be true for this remapping to happen.
1334 list<Predicate> Predicates = [];
1337 /// InstAlias - This defines an alternate assembly syntax that is allowed to
1338 /// match an instruction that has a different (more canonical) assembly
1340 class InstAlias<string Asm, dag Result, int Emit = 1, string VariantName = ""> {
1341 string AsmString = Asm; // The .s format to match the instruction with.
1342 dag ResultInst = Result; // The MCInst to generate.
1344 // This determines which order the InstPrinter detects aliases for
1345 // printing. A larger value makes the alias more likely to be
1346 // emitted. The Instruction's own definition is notionally 0.5, so 0
1347 // disables printing and 1 enables it if there are no conflicting aliases.
1348 int EmitPriority = Emit;
1350 // Predicates - Predicates that must be true for this to match.
1351 list<Predicate> Predicates = [];
1353 // If the instruction specified in Result has defined an AsmMatchConverter
1354 // then setting this to 1 will cause the alias to use the AsmMatchConverter
1355 // function when converting the OperandVector into an MCInst instead of the
1356 // function that is generated by the dag Result.
1357 // Setting this to 0 will cause the alias to ignore the Result instruction's
1358 // defined AsmMatchConverter and instead use the function generated by the
1360 bit UseInstAsmMatchConverter = 1;
1362 // Assembler variant name to use for this alias. If not specified then
1363 // assembler variants will be determined based on AsmString
1364 string AsmVariantName = VariantName;
1367 //===----------------------------------------------------------------------===//
1368 // AsmWriter - This class can be implemented by targets that need to customize
1369 // the format of the .s file writer.
1371 // Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax
1372 // on X86 for example).
1375 // AsmWriterClassName - This specifies the suffix to use for the asmwriter
1376 // class. Generated AsmWriter classes are always prefixed with the target
1378 string AsmWriterClassName = "InstPrinter";
1380 // PassSubtarget - Determines whether MCSubtargetInfo should be passed to
1381 // the various print methods.
1382 // FIXME: Remove after all ports are updated.
1383 int PassSubtarget = 0;
1385 // Variant - AsmWriters can be of multiple different variants. Variants are
1386 // used to support targets that need to emit assembly code in ways that are
1387 // mostly the same for different targets, but have minor differences in
1388 // syntax. If the asmstring contains {|} characters in them, this integer
1389 // will specify which alternative to use. For example "{x|y|z}" with Variant
1390 // == 1, will expand to "y".
1393 def DefaultAsmWriter : AsmWriter;
1396 //===----------------------------------------------------------------------===//
1397 // Target - This class contains the "global" target information
1400 // InstructionSet - Instruction set description for this target.
1401 InstrInfo InstructionSet;
1403 // AssemblyParsers - The AsmParser instances available for this target.
1404 list<AsmParser> AssemblyParsers = [DefaultAsmParser];
1406 /// AssemblyParserVariants - The AsmParserVariant instances available for
1408 list<AsmParserVariant> AssemblyParserVariants = [DefaultAsmParserVariant];
1410 // AssemblyWriters - The AsmWriter instances available for this target.
1411 list<AsmWriter> AssemblyWriters = [DefaultAsmWriter];
1413 // AllowRegisterRenaming - Controls whether this target allows
1414 // post-register-allocation renaming of registers. This is done by
1415 // setting hasExtraDefRegAllocReq and hasExtraSrcRegAllocReq to 1
1416 // for all opcodes if this flag is set to 0.
1417 int AllowRegisterRenaming = 0;
1420 //===----------------------------------------------------------------------===//
1421 // SubtargetFeature - A characteristic of the chip set.
1423 class SubtargetFeature<string n, string a, string v, string d,
1424 list<SubtargetFeature> i = []> {
1425 // Name - Feature name. Used by command line (-mattr=) to determine the
1426 // appropriate target chip.
1430 // Attribute - Attribute to be set by feature.
1432 string Attribute = a;
1434 // Value - Value the attribute to be set to by feature.
1438 // Desc - Feature description. Used by command line (-mattr=) to display help
1443 // Implies - Features that this feature implies are present. If one of those
1444 // features isn't set, then this one shouldn't be set either.
1446 list<SubtargetFeature> Implies = i;
1449 /// Specifies a Subtarget feature that this instruction is deprecated on.
1450 class Deprecated<SubtargetFeature dep> {
1451 SubtargetFeature DeprecatedFeatureMask = dep;
1454 /// A custom predicate used to determine if an instruction is
1455 /// deprecated or not.
1456 class ComplexDeprecationPredicate<string dep> {
1457 string ComplexDeprecationPredicate = dep;
1460 //===----------------------------------------------------------------------===//
1461 // Processor chip sets - These values represent each of the chip sets supported
1462 // by the scheduler. Each Processor definition requires corresponding
1463 // instruction itineraries.
1465 class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f> {
1466 // Name - Chip set name. Used by command line (-mcpu=) to determine the
1467 // appropriate target chip.
1471 // SchedModel - The machine model for scheduling and instruction cost.
1473 SchedMachineModel SchedModel = NoSchedModel;
1475 // ProcItin - The scheduling information for the target processor.
1477 ProcessorItineraries ProcItin = pi;
1479 // Features - list of
1480 list<SubtargetFeature> Features = f;
1483 // ProcessorModel allows subtargets to specify the more general
1484 // SchedMachineModel instead if a ProcessorItinerary. Subtargets will
1485 // gradually move to this newer form.
1487 // Although this class always passes NoItineraries to the Processor
1488 // class, the SchedMachineModel may still define valid Itineraries.
1489 class ProcessorModel<string n, SchedMachineModel m, list<SubtargetFeature> f>
1490 : Processor<n, NoItineraries, f> {
1494 //===----------------------------------------------------------------------===//
1495 // InstrMapping - This class is used to create mapping tables to relate
1496 // instructions with each other based on the values specified in RowFields,
1497 // ColFields, KeyCol and ValueCols.
1499 class InstrMapping {
1500 // FilterClass - Used to limit search space only to the instructions that
1501 // define the relationship modeled by this InstrMapping record.
1504 // RowFields - List of fields/attributes that should be same for all the
1505 // instructions in a row of the relation table. Think of this as a set of
1506 // properties shared by all the instructions related by this relationship
1507 // model and is used to categorize instructions into subgroups. For instance,
1508 // if we want to define a relation that maps 'Add' instruction to its
1509 // predicated forms, we can define RowFields like this:
1511 // let RowFields = BaseOp
1512 // All add instruction predicated/non-predicated will have to set their BaseOp
1513 // to the same value.
1515 // def Add: { let BaseOp = 'ADD'; let predSense = 'nopred' }
1516 // def Add_predtrue: { let BaseOp = 'ADD'; let predSense = 'true' }
1517 // def Add_predfalse: { let BaseOp = 'ADD'; let predSense = 'false' }
1518 list<string> RowFields = [];
1520 // List of fields/attributes that are same for all the instructions
1521 // in a column of the relation table.
1522 // Ex: let ColFields = 'predSense' -- It means that the columns are arranged
1523 // based on the 'predSense' values. All the instruction in a specific
1524 // column have the same value and it is fixed for the column according
1525 // to the values set in 'ValueCols'.
1526 list<string> ColFields = [];
1528 // Values for the fields/attributes listed in 'ColFields'.
1529 // Ex: let KeyCol = 'nopred' -- It means that the key instruction (instruction
1530 // that models this relation) should be non-predicated.
1531 // In the example above, 'Add' is the key instruction.
1532 list<string> KeyCol = [];
1534 // List of values for the fields/attributes listed in 'ColFields', one for
1535 // each column in the relation table.
1537 // Ex: let ValueCols = [['true'],['false']] -- It adds two columns in the
1538 // table. First column requires all the instructions to have predSense
1539 // set to 'true' and second column requires it to be 'false'.
1540 list<list<string> > ValueCols = [];
1543 //===----------------------------------------------------------------------===//
1544 // Pull in the common support for calling conventions.
1546 include "llvm/Target/TargetCallingConv.td"
1548 //===----------------------------------------------------------------------===//
1549 // Pull in the common support for DAG isel generation.
1551 include "llvm/Target/TargetSelectionDAG.td"
1553 //===----------------------------------------------------------------------===//
1554 // Pull in the common support for Global ISel register bank info generation.
1556 include "llvm/Target/GlobalISel/RegisterBank.td"
1558 //===----------------------------------------------------------------------===//
1559 // Pull in the common support for DAG isel generation.
1561 include "llvm/Target/GlobalISel/Target.td"
1563 //===----------------------------------------------------------------------===//
1564 // Pull in the common support for the Global ISel DAG-based selector generation.
1566 include "llvm/Target/GlobalISel/SelectionDAGCompat.td"
1568 //===----------------------------------------------------------------------===//
1569 // Pull in the common support for Pfm Counters generation.
1571 include "llvm/Target/TargetPfmCounters.td"