Warning, /include/llvm/Target/Target.td is written in an unsupported language. File is not indexed.
0001 //===- Target.td - Target Independent TableGen interface ---*- tablegen -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the target-independent interfaces which should be
0010 // implemented by each target which is using a TableGen based code generator.
0011 //
0012 //===----------------------------------------------------------------------===//
0013
0014 // Include all information about LLVM intrinsics.
0015 include "llvm/IR/Intrinsics.td"
0016
0017 class Predicate; // Forward def
0018
0019 //===----------------------------------------------------------------------===//
0020 // Register file description - These classes are used to fill in the target
0021 // description classes.
0022
0023 class HwMode<string FS, list<Predicate> Ps> {
0024 // A string representing subtarget features that turn on this HW mode.
0025 // For example, "+feat1,-feat2" will indicate that the mode is active
0026 // when "feat1" is enabled and "feat2" is disabled at the same time.
0027 // Any other features are not checked.
0028 // When multiple modes are used, they should be mutually exclusive,
0029 // otherwise the results are unpredictable.
0030 string Features = FS;
0031
0032 // A list of predicates that turn on this HW mode.
0033 list<Predicate> Predicates = Ps;
0034 }
0035
0036 // A special mode recognized by tablegen. This mode is considered active
0037 // when no other mode is active. For targets that do not use specific hw
0038 // modes, this is the only mode.
0039 def DefaultMode : HwMode<"", []>;
0040
0041 // A class used to associate objects with HW modes. It is only intended to
0042 // be used as a base class, where the derived class should contain a member
0043 // "Objects", which is a list of the same length as the list of modes.
0044 // The n-th element on the Objects list will be associated with the n-th
0045 // element on the Modes list.
0046 class HwModeSelect<list<HwMode> Ms, int ObjectsLength> {
0047 list<HwMode> Modes = Ms;
0048
0049 assert !eq(ObjectsLength, !size(Modes)),
0050 "The Objects and Modes lists must be the same length";
0051 }
0052
0053 // A common class that implements a counterpart of ValueType, which is
0054 // dependent on a HW mode. This class inherits from ValueType itself,
0055 // which makes it possible to use objects of this class where ValueType
0056 // objects could be used. This is specifically applicable to selection
0057 // patterns.
0058 class ValueTypeByHwMode<list<HwMode> Ms, list<ValueType> Ts>
0059 : HwModeSelect<Ms, !size(Ts)>, ValueType<0, 0> {
0060 // The length of this list must be the same as the length of Ms.
0061 list<ValueType> Objects = Ts;
0062 }
0063
0064 // A class that implements a counterpart of PtrValueType, which is
0065 // dependent on a HW mode. This class inherits from PtrValueType itself,
0066 // which makes it possible to use objects of this class where PtrValueType
0067 // or ValueType could be used. This is specifically applicable to selection
0068 // patterns.
0069 class PtrValueTypeByHwMode<ValueTypeByHwMode scalar, int addrspace>
0070 : HwModeSelect<scalar.Modes, !size(scalar.Objects)>,
0071 PtrValueType<ValueType<0, 0>, addrspace> {
0072 // The length of this list must be the same as the length of Ms.
0073 list<ValueType> Objects = scalar.Objects;
0074 }
0075
0076 // A class representing the register size, spill size and spill alignment
0077 // in bits of a register.
0078 class RegInfo<int RS, int SS, int SA> {
0079 int RegSize = RS; // Register size in bits.
0080 int SpillSize = SS; // Spill slot size in bits.
0081 int SpillAlignment = SA; // Spill slot alignment in bits.
0082 }
0083
0084 // The register size/alignment information, parameterized by a HW mode.
0085 class RegInfoByHwMode<list<HwMode> Ms = [], list<RegInfo> Ts = []>
0086 : HwModeSelect<Ms, !size(Ts)> {
0087 // The length of this list must be the same as the length of Ms.
0088 list<RegInfo> Objects = Ts;
0089 }
0090
0091 class SubRegRange<int size, int offset = 0> {
0092 int Size = size; // Sub register size in bits.
0093 int Offset = offset; // Offset of the first bit of the sub-reg index.
0094 }
0095
0096 class SubRegRangeByHwMode<list<HwMode> Ms = [], list<SubRegRange> Ts = []>
0097 : HwModeSelect<Ms, !size(Ts)> {
0098 // The length of this list must be the same as the length of Ms.
0099 list<SubRegRange> Objects = Ts;
0100 }
0101
0102 // SubRegIndex - Use instances of SubRegIndex to identify subregisters.
0103 class SubRegIndex<int size, int offset = 0> {
0104 string Namespace = "";
0105
0106 // The size/offset information, parameterized by a HW mode.
0107 // If the HwModes provided for SubRegRanges does not include the DefaultMode,
0108 // the Size and Offset fields below will be used for the default. Otherwise,
0109 // the Size and Offset fields are ignored.
0110 SubRegRangeByHwMode SubRegRanges;
0111
0112 // Size - Size (in bits) of the sub-registers represented by this index.
0113 int Size = size;
0114
0115 // Offset - Offset of the first bit that is part of this sub-register index.
0116 // Set it to -1 if the same index is used to represent sub-registers that can
0117 // be at different offsets (for example when using an index to access an
0118 // element in a register tuple).
0119 int Offset = offset;
0120
0121 // ComposedOf - A list of two SubRegIndex instances, [A, B].
0122 // This indicates that this SubRegIndex is the result of composing A and B.
0123 // See ComposedSubRegIndex.
0124 list<SubRegIndex> ComposedOf = [];
0125
0126 // CoveringSubRegIndices - A list of two or more sub-register indexes that
0127 // cover this sub-register.
0128 //
0129 // This field should normally be left blank as TableGen can infer it.
0130 //
0131 // TableGen automatically detects sub-registers that straddle the registers
0132 // in the SubRegs field of a Register definition. For example:
0133 //
0134 // Q0 = dsub_0 -> D0, dsub_1 -> D1
0135 // Q1 = dsub_0 -> D2, dsub_1 -> D3
0136 // D1_D2 = dsub_0 -> D1, dsub_1 -> D2
0137 // QQ0 = qsub_0 -> Q0, qsub_1 -> Q1
0138 //
0139 // TableGen will infer that D1_D2 is a sub-register of QQ0. It will be given
0140 // the synthetic index dsub_1_dsub_2 unless some SubRegIndex is defined with
0141 // CoveringSubRegIndices = [dsub_1, dsub_2].
0142 list<SubRegIndex> CoveringSubRegIndices = [];
0143 }
0144
0145 // ComposedSubRegIndex - A sub-register that is the result of composing A and B.
0146 // Offset is set to the sum of A and B's Offsets. Size is set to B's Size.
0147 class ComposedSubRegIndex<SubRegIndex A, SubRegIndex B>
0148 : SubRegIndex<B.Size, !cond(!eq(A.Offset, -1): -1,
0149 !eq(B.Offset, -1): -1,
0150 true: !add(A.Offset, B.Offset))> {
0151 // See SubRegIndex.
0152 let ComposedOf = [A, B];
0153 }
0154
0155 // RegAltNameIndex - The alternate name set to use for register operands of
0156 // this register class when printing.
0157 class RegAltNameIndex {
0158 string Namespace = "";
0159
0160 // A set to be used if the name for a register is not defined in this set.
0161 // This allows creating name sets with only a few alternative names.
0162 RegAltNameIndex FallbackRegAltNameIndex = ?;
0163 }
0164 def NoRegAltName : RegAltNameIndex;
0165
0166 // Register - You should define one instance of this class for each register
0167 // in the target machine. String n will become the "name" of the register.
0168 class Register<string n, list<string> altNames = []> {
0169 string Namespace = "";
0170 string AsmName = n;
0171 list<string> AltNames = altNames;
0172
0173 // Aliases - A list of registers that this register overlaps with. A read or
0174 // modification of this register can potentially read or modify the aliased
0175 // registers.
0176 list<Register> Aliases = [];
0177
0178 // SubRegs - A list of registers that are parts of this register. Note these
0179 // are "immediate" sub-registers and the registers within the list do not
0180 // themselves overlap. e.g. For X86, EAX's SubRegs list contains only [AX],
0181 // not [AX, AH, AL].
0182 list<Register> SubRegs = [];
0183
0184 // SubRegIndices - For each register in SubRegs, specify the SubRegIndex used
0185 // to address it. Sub-sub-register indices are automatically inherited from
0186 // SubRegs.
0187 list<SubRegIndex> SubRegIndices = [];
0188
0189 // RegAltNameIndices - The alternate name indices which are valid for this
0190 // register.
0191 list<RegAltNameIndex> RegAltNameIndices = [];
0192
0193 // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
0194 // These values can be determined by locating the <target>.h file in the
0195 // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
0196 // order of these names correspond to the enumeration used by gcc. A value of
0197 // -1 indicates that the gcc number is undefined and -2 that register number
0198 // is invalid for this mode/flavour.
0199 list<int> DwarfNumbers = [];
0200
0201 // CostPerUse - Additional cost of instructions using this register compared
0202 // to other registers in its class. The register allocator will try to
0203 // minimize the number of instructions using a register with a CostPerUse.
0204 // This is used by the ARC target, by the ARM Thumb and x86-64 targets, where
0205 // some registers require larger instruction encodings, by the RISC-V target,
0206 // where some registers preclude using some C instructions. By making it a
0207 // list, targets can have multiple cost models associated with each register
0208 // and can choose one specific cost model per Machine Function by overriding
0209 // TargetRegisterInfo::getRegisterCostTableIndex. Every target register will
0210 // finally have an equal number of cost values which is the max of costPerUse
0211 // values specified. Any mismatch in the cost values for a register will be
0212 // filled with zeros. Restricted the cost type to uint8_t in the
0213 // generated table. It will considerably reduce the table size.
0214 list<int> CostPerUse = [0];
0215
0216 // CoveredBySubRegs - When this bit is set, the value of this register is
0217 // completely determined by the value of its sub-registers. For example, the
0218 // x86 register AX is covered by its sub-registers AL and AH, but EAX is not
0219 // covered by its sub-register AX.
0220 bit CoveredBySubRegs = false;
0221
0222 // HWEncoding - The target specific hardware encoding for this register.
0223 bits<16> HWEncoding = 0;
0224
0225 bit isArtificial = false;
0226
0227 // isConstant - This register always holds a constant value (e.g. the zero
0228 // register in architectures such as MIPS)
0229 bit isConstant = false;
0230
0231 /// PositionOrder - Indicate tablegen to place the newly added register at a later
0232 /// position to avoid iterations on them on unsupported target.
0233 int PositionOrder = 0;
0234 }
0235
0236 // RegisterWithSubRegs - This can be used to define instances of Register which
0237 // need to specify sub-registers.
0238 // List "subregs" specifies which registers are sub-registers to this one. This
0239 // is used to populate the SubRegs and AliasSet fields of TargetRegisterDesc.
0240 // This allows the code generator to be careful not to put two values with
0241 // overlapping live ranges into registers which alias.
0242 class RegisterWithSubRegs<string n, list<Register> subregs> : Register<n> {
0243 let SubRegs = subregs;
0244 }
0245
0246 // DAGOperand - An empty base class that unifies RegisterClass's and other forms
0247 // of Operand's that are legal as type qualifiers in DAG patterns. This should
0248 // only ever be used for defining multiclasses that are polymorphic over both
0249 // RegisterClass's and other Operand's.
0250 class DAGOperand {
0251 string OperandNamespace = "MCOI";
0252 string DecoderMethod = "";
0253 }
0254
0255 // RegisterClass - Now that all of the registers are defined, and aliases
0256 // between registers are defined, specify which registers belong to which
0257 // register classes. This also defines the default allocation order of
0258 // registers by register allocators.
0259 //
0260 class RegisterClass<string namespace, list<ValueType> regTypes, int alignment,
0261 dag regList, RegAltNameIndex idx = NoRegAltName>
0262 : DAGOperand {
0263 string Namespace = namespace;
0264
0265 // The register size/alignment information, parameterized by a HW mode.
0266 RegInfoByHwMode RegInfos;
0267
0268 // RegType - Specify the list ValueType of the registers in this register
0269 // class. Note that all registers in a register class must have the same
0270 // ValueTypes. This is a list because some targets permit storing different
0271 // types in same register, for example vector values with 128-bit total size,
0272 // but different count/size of items, like SSE on x86.
0273 //
0274 list<ValueType> RegTypes = regTypes;
0275
0276 // Size - Specify the spill size in bits of the registers. A default value of
0277 // zero lets tablegen pick an appropriate size.
0278 int Size = 0;
0279
0280 // Alignment - Specify the alignment required of the registers when they are
0281 // stored or loaded to memory.
0282 //
0283 int Alignment = alignment;
0284
0285 // CopyCost - This value is used to specify the cost of copying a value
0286 // between two registers in this register class. The default value is one
0287 // meaning it takes a single instruction to perform the copying. A negative
0288 // value means copying is extremely expensive or impossible.
0289 int CopyCost = 1;
0290
0291 // MemberList - Specify which registers are in this class. If the
0292 // allocation_order_* method are not specified, this also defines the order of
0293 // allocation used by the register allocator.
0294 //
0295 dag MemberList = regList;
0296
0297 // AltNameIndex - The alternate register name to use when printing operands
0298 // of this register class. Every register in the register class must have
0299 // a valid alternate name for the given index.
0300 RegAltNameIndex altNameIndex = idx;
0301
0302 // isAllocatable - Specify that the register class can be used for virtual
0303 // registers and register allocation. Some register classes are only used to
0304 // model instruction operand constraints, and should have isAllocatable = 0.
0305 bit isAllocatable = true;
0306
0307 // AltOrders - List of alternative allocation orders. The default order is
0308 // MemberList itself, and that is good enough for most targets since the
0309 // register allocators automatically remove reserved registers and move
0310 // callee-saved registers to the end.
0311 list<dag> AltOrders = [];
0312
0313 // AltOrderSelect - The body of a function that selects the allocation order
0314 // to use in a given machine function. The code will be inserted in a
0315 // function like this:
0316 //
0317 // static inline unsigned f(const MachineFunction &MF) { ... }
0318 //
0319 // The function should return 0 to select the default order defined by
0320 // MemberList, 1 to select the first AltOrders entry and so on.
0321 code AltOrderSelect = [{}];
0322
0323 // Specify allocation priority for register allocators using a greedy
0324 // heuristic. Classes with higher priority values are assigned first. This is
0325 // useful as it is sometimes beneficial to assign registers to highly
0326 // constrained classes first. The value has to be in the range [0,31].
0327 int AllocationPriority = 0;
0328
0329 // Force register class to use greedy's global heuristic for all
0330 // registers in this class. This should more aggressively try to
0331 // avoid spilling in pathological cases.
0332 bit GlobalPriority = false;
0333
0334 // Generate register pressure set for this register class and any class
0335 // synthesized from it. Set to 0 to inhibit unneeded pressure sets.
0336 bit GeneratePressureSet = true;
0337
0338 // Weight override for register pressure calculation. This is the value
0339 // TargetRegisterClass::getRegClassWeight() will return. The weight is in
0340 // units of pressure for this register class. If unset tablegen will
0341 // calculate a weight based on a number of register units in this register
0342 // class registers. The weight is per register.
0343 int Weight = ?;
0344
0345 // The diagnostic type to present when referencing this operand in a match
0346 // failure error message. If this is empty, the default Match_InvalidOperand
0347 // diagnostic type will be used. If this is "<name>", a Match_<name> enum
0348 // value will be generated and used for this operand type. The target
0349 // assembly parser is responsible for converting this into a user-facing
0350 // diagnostic message.
0351 string DiagnosticType = "";
0352
0353 // A diagnostic message to emit when an invalid value is provided for this
0354 // register class when it is being used as an assembly operand. If this is
0355 // non-empty, an anonymous diagnostic type enum value will be generated, and
0356 // the assembly matcher will provide a function to map from diagnostic types
0357 // to message strings.
0358 string DiagnosticString = "";
0359
0360 // Target-specific flags. This becomes the TSFlags field in TargetRegisterClass.
0361 bits<8> TSFlags = 0;
0362
0363 // If set then consider this register class to be the base class for registers in
0364 // its MemberList. The base class for registers present in multiple base register
0365 // classes will be resolved in the order defined by this value, with lower values
0366 // taking precedence over higher ones. Ties are resolved by enumeration order.
0367 int BaseClassOrder = ?;
0368 }
0369
0370 // The memberList in a RegisterClass is a dag of set operations. TableGen
0371 // evaluates these set operations and expand them into register lists. These
0372 // are the most common operation, see test/TableGen/SetTheory.td for more
0373 // examples of what is possible:
0374 //
0375 // (add R0, R1, R2) - Set Union. Each argument can be an individual register, a
0376 // register class, or a sub-expression. This is also the way to simply list
0377 // registers.
0378 //
0379 // (sub GPR, SP) - Set difference. Subtract the last arguments from the first.
0380 //
0381 // (and GPR, CSR) - Set intersection. All registers from the first set that are
0382 // also in the second set.
0383 //
0384 // (sequence "R%u", 0, 15) -> [R0, R1, ..., R15]. Generate a sequence of
0385 // numbered registers. Takes an optional 4th operand which is a stride to use
0386 // when generating the sequence.
0387 //
0388 // (shl GPR, 4) - Remove the first N elements.
0389 //
0390 // (trunc GPR, 4) - Truncate after the first N elements.
0391 //
0392 // (rotl GPR, 1) - Rotate N places to the left.
0393 //
0394 // (rotr GPR, 1) - Rotate N places to the right.
0395 //
0396 // (decimate GPR, 2) - Pick every N'th element, starting with the first.
0397 //
0398 // (interleave A, B, ...) - Interleave the elements from each argument list.
0399 //
0400 // All of these operators work on ordered sets, not lists. That means
0401 // duplicates are removed from sub-expressions.
0402
0403 // Set operators. The rest is defined in TargetSelectionDAG.td.
0404 def sequence;
0405 def decimate;
0406 def interleave;
0407
0408 // RegisterTuples - Automatically generate super-registers by forming tuples of
0409 // sub-registers. This is useful for modeling register sequence constraints
0410 // with pseudo-registers that are larger than the architectural registers.
0411 //
0412 // The sub-register lists are zipped together:
0413 //
0414 // def EvenOdd : RegisterTuples<[sube, subo], [(add R0, R2), (add R1, R3)]>;
0415 //
0416 // Generates the same registers as:
0417 //
0418 // let SubRegIndices = [sube, subo] in {
0419 // def R0_R1 : RegisterWithSubRegs<"", [R0, R1]>;
0420 // def R2_R3 : RegisterWithSubRegs<"", [R2, R3]>;
0421 // }
0422 //
0423 // The generated pseudo-registers inherit super-classes and fields from their
0424 // first sub-register. Most fields from the Register class are inferred, and
0425 // the AsmName and Dwarf numbers are cleared.
0426 //
0427 // RegisterTuples instances can be used in other set operations to form
0428 // register classes and so on. This is the only way of using the generated
0429 // registers.
0430 //
0431 // RegNames may be specified to supply asm names for the generated tuples.
0432 // If used must have the same size as the list of produced registers.
0433 class RegisterTuples<list<SubRegIndex> Indices, list<dag> Regs,
0434 list<string> RegNames = []> {
0435 // SubRegs - N lists of registers to be zipped up. Super-registers are
0436 // synthesized from the first element of each SubRegs list, the second
0437 // element and so on.
0438 list<dag> SubRegs = Regs;
0439
0440 // SubRegIndices - N SubRegIndex instances. This provides the names of the
0441 // sub-registers in the synthesized super-registers.
0442 list<SubRegIndex> SubRegIndices = Indices;
0443
0444 // List of asm names for the generated tuple registers.
0445 list<string> RegAsmNames = RegNames;
0446
0447 // PositionOrder - Indicate tablegen to place the newly added register at a later
0448 // position to avoid iterations on them on unsupported target.
0449 int PositionOrder = 0;
0450 }
0451
0452 // RegisterCategory - This class is a list of RegisterClasses that belong to a
0453 // general cateogry --- e.g. "general purpose" or "fixed" registers. This is
0454 // useful for identifying registers in a generic way instead of having
0455 // information about a specific target's registers.
0456 class RegisterCategory<list<RegisterClass> classes> {
0457 // Classes - A list of register classes that fall within the category.
0458 list<RegisterClass> Classes = classes;
0459 }
0460
0461 //===----------------------------------------------------------------------===//
0462 // DwarfRegNum - This class provides a mapping of the llvm register enumeration
0463 // to the register numbering used by gcc and gdb. These values are used by a
0464 // debug information writer to describe where values may be located during
0465 // execution.
0466 class DwarfRegNum<list<int> Numbers> {
0467 // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register.
0468 // These values can be determined by locating the <target>.h file in the
0469 // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The
0470 // order of these names correspond to the enumeration used by gcc. A value of
0471 // -1 indicates that the gcc number is undefined and -2 that register number
0472 // is invalid for this mode/flavour.
0473 list<int> DwarfNumbers = Numbers;
0474 }
0475
0476 // DwarfRegAlias - This class declares that a given register uses the same dwarf
0477 // numbers as another one. This is useful for making it clear that the two
0478 // registers do have the same number. It also lets us build a mapping
0479 // from dwarf register number to llvm register.
0480 class DwarfRegAlias<Register reg> {
0481 Register DwarfAlias = reg;
0482 }
0483
0484 //===----------------------------------------------------------------------===//
0485 // SubtargetFeature - A characteristic of the chip set.
0486 //
0487 class SubtargetFeature<string n, string f, string v, string d,
0488 list<SubtargetFeature> i = []> {
0489 // Name - Feature name. Used by command line (-mattr=) to determine the
0490 // appropriate target chip.
0491 //
0492 string Name = n;
0493
0494 // FieldName - Field in XXXSubtarget to be set by feature.
0495 //
0496 string FieldName = f;
0497
0498 // Value - Value the XXXSubtarget field to be set to by feature.
0499 //
0500 // A value of "true" or "false" implies the field is a bool. Otherwise,
0501 // it is assumed to be an integer. the integer value may be the name of an
0502 // enum constant. If multiple features use the same integer field, the
0503 // field will be set to the maximum value of all enabled features that
0504 // share the field.
0505 //
0506 string Value = v;
0507
0508 // Desc - Feature description. Used by command line (-mattr=) to display help
0509 // information.
0510 //
0511 string Desc = d;
0512
0513 // Implies - Features that this feature implies are present. If one of those
0514 // features isn't set, then this one shouldn't be set either.
0515 //
0516 list<SubtargetFeature> Implies = i;
0517 }
0518
0519 /// Specifies a Subtarget feature that this instruction is deprecated on.
0520 class Deprecated<SubtargetFeature dep> {
0521 SubtargetFeature DeprecatedFeatureMask = dep;
0522 }
0523
0524 /// A custom predicate used to determine if an instruction is
0525 /// deprecated or not.
0526 class ComplexDeprecationPredicate<string dep> {
0527 string ComplexDeprecationPredicate = dep;
0528 }
0529
0530 //===----------------------------------------------------------------------===//
0531 // Pull in the common support for MCPredicate (portable scheduling predicates).
0532 //
0533 include "llvm/Target/TargetInstrPredicate.td"
0534
0535 //===----------------------------------------------------------------------===//
0536 // Pull in the common support for scheduling
0537 //
0538 include "llvm/Target/TargetSchedule.td"
0539
0540 class InstructionEncoding {
0541 // Size of encoded instruction.
0542 int Size;
0543
0544 // The "namespace" in which this instruction exists, on targets like ARM
0545 // which multiple ISA namespaces exist.
0546 string DecoderNamespace = "";
0547
0548 // List of predicates which will be turned into isel matching code.
0549 list<Predicate> Predicates = [];
0550
0551 string DecoderMethod = "";
0552
0553 // Is the instruction decoder method able to completely determine if the
0554 // given instruction is valid or not. If the TableGen definition of the
0555 // instruction specifies bitpattern A??B where A and B are static bits, the
0556 // hasCompleteDecoder flag says whether the decoder method fully handles the
0557 // ?? space, i.e. if it is a final arbiter for the instruction validity.
0558 // If not then the decoder attempts to continue decoding when the decoder
0559 // method fails.
0560 //
0561 // This allows to handle situations where the encoding is not fully
0562 // orthogonal. Example:
0563 // * InstA with bitpattern 0b0000????,
0564 // * InstB with bitpattern 0b000000?? but the associated decoder method
0565 // DecodeInstB() returns Fail when ?? is 0b00 or 0b11.
0566 //
0567 // The decoder tries to decode a bitpattern that matches both InstA and
0568 // InstB bitpatterns first as InstB (because it is the most specific
0569 // encoding). In the default case (hasCompleteDecoder = 1), when
0570 // DecodeInstB() returns Fail the bitpattern gets rejected. By setting
0571 // hasCompleteDecoder = 0 in InstB, the decoder is informed that
0572 // DecodeInstB() is not able to determine if all possible values of ?? are
0573 // valid or not. If DecodeInstB() returns Fail the decoder will attempt to
0574 // decode the bitpattern as InstA too.
0575 bit hasCompleteDecoder = true;
0576 }
0577
0578 // Allows specifying an InstructionEncoding by HwMode. If an Instruction specifies
0579 // an EncodingByHwMode, its Inst and Size members are ignored and Ts are used
0580 // to encode and decode based on HwMode.
0581 class EncodingByHwMode<list<HwMode> Ms = [], list<InstructionEncoding> Ts = []>
0582 : HwModeSelect<Ms, !size(Ts)> {
0583 // The length of this list must be the same as the length of Ms.
0584 list<InstructionEncoding> Objects = Ts;
0585 }
0586
0587 //===----------------------------------------------------------------------===//
0588 // Instruction set description - These classes correspond to the C++ classes in
0589 // the Target/TargetInstrInfo.h file.
0590 //
0591 class Instruction : InstructionEncoding {
0592 string Namespace = "";
0593
0594 dag OutOperandList; // An dag containing the MI def operand list.
0595 dag InOperandList; // An dag containing the MI use operand list.
0596 string AsmString = ""; // The .s format to print the instruction with.
0597
0598 // Allows specifying a canonical InstructionEncoding by HwMode. If non-empty,
0599 // the Inst member of this Instruction is ignored.
0600 EncodingByHwMode EncodingInfos;
0601
0602 // Pattern - Set to the DAG pattern for this instruction, if we know of one,
0603 // otherwise, uninitialized.
0604 list<dag> Pattern;
0605
0606 // The follow state will eventually be inferred automatically from the
0607 // instruction pattern.
0608
0609 list<Register> Uses = []; // Default to using no non-operand registers
0610 list<Register> Defs = []; // Default to modifying no non-operand registers
0611
0612 // Predicates - List of predicates which will be turned into isel matching
0613 // code.
0614 list<Predicate> Predicates = [];
0615
0616 // Size - Size of encoded instruction, or zero if the size cannot be determined
0617 // from the opcode.
0618 int Size = 0;
0619
0620 // Code size, for instruction selection.
0621 // FIXME: What does this actually mean?
0622 int CodeSize = 0;
0623
0624 // Added complexity passed onto matching pattern.
0625 int AddedComplexity = 0;
0626
0627 // Indicates if this is a pre-isel opcode that should be
0628 // legalized/regbankselected/selected.
0629 bit isPreISelOpcode = false;
0630
0631 // These bits capture information about the high-level semantics of the
0632 // instruction.
0633 bit isReturn = false; // Is this instruction a return instruction?
0634 bit isBranch = false; // Is this instruction a branch instruction?
0635 bit isEHScopeReturn = false; // Does this instruction end an EH scope?
0636 bit isIndirectBranch = false; // Is this instruction an indirect branch?
0637 bit isCompare = false; // Is this instruction a comparison instruction?
0638 bit isMoveImm = false; // Is this instruction a move immediate instruction?
0639 bit isMoveReg = false; // Is this instruction a move register instruction?
0640 bit isBitcast = false; // Is this instruction a bitcast instruction?
0641 bit isSelect = false; // Is this instruction a select instruction?
0642 bit isBarrier = false; // Can control flow fall through this instruction?
0643 bit isCall = false; // Is this instruction a call instruction?
0644 bit isAdd = false; // Is this instruction an add instruction?
0645 bit isTrap = false; // Is this instruction a trap instruction?
0646 bit canFoldAsLoad = false; // Can this be folded as a simple memory operand?
0647 bit mayLoad = ?; // Is it possible for this inst to read memory?
0648 bit mayStore = ?; // Is it possible for this inst to write memory?
0649 bit mayRaiseFPException = false; // Can this raise a floating-point exception?
0650 bit isConvertibleToThreeAddress = false; // Can this 2-addr instruction promote?
0651 bit isCommutable = false; // Is this 3 operand instruction commutable?
0652 bit isTerminator = false; // Is this part of the terminator for a basic block?
0653 bit isReMaterializable = false; // Is this instruction re-materializable?
0654 bit isPredicable = false; // 1 means this instruction is predicable
0655 // even if it does not have any operand
0656 // tablegen can identify as a predicate
0657 bit isUnpredicable = false; // 1 means this instruction is not predicable
0658 // even if it _does_ have a predicate operand
0659 bit hasDelaySlot = false; // Does this instruction have an delay slot?
0660 bit usesCustomInserter = false; // Pseudo instr needing special help.
0661 bit hasPostISelHook = false; // To be *adjusted* after isel by target hook.
0662 bit hasCtrlDep = false; // Does this instruction r/w ctrl-flow chains?
0663 bit isNotDuplicable = false; // Is it unsafe to duplicate this instruction?
0664 bit isConvergent = false; // Is this instruction convergent?
0665 bit isAuthenticated = false; // Does this instruction authenticate a pointer?
0666 bit isAsCheapAsAMove = false; // As cheap (or cheaper) than a move instruction.
0667 bit hasExtraSrcRegAllocReq = false; // Sources have special regalloc requirement?
0668 bit hasExtraDefRegAllocReq = false; // Defs have special regalloc requirement?
0669 bit isRegSequence = false; // Is this instruction a kind of reg sequence?
0670 // If so, make sure to override
0671 // TargetInstrInfo::getRegSequenceLikeInputs.
0672 bit isPseudo = false; // Is this instruction a pseudo-instruction?
0673 // If so, won't have encoding information for
0674 // the [MC]CodeEmitter stuff.
0675 bit isMeta = false; // Is this instruction a meta-instruction?
0676 // If so, won't produce any output in the form of
0677 // executable instructions
0678 bit isExtractSubreg = false; // Is this instruction a kind of extract subreg?
0679 // If so, make sure to override
0680 // TargetInstrInfo::getExtractSubregLikeInputs.
0681 bit isInsertSubreg = false; // Is this instruction a kind of insert subreg?
0682 // If so, make sure to override
0683 // TargetInstrInfo::getInsertSubregLikeInputs.
0684 bit variadicOpsAreDefs = false; // Are variadic operands definitions?
0685
0686 // Does the instruction have side effects that are not captured by any
0687 // operands of the instruction or other flags?
0688 bit hasSideEffects = ?;
0689
0690 // Is this instruction a "real" instruction (with a distinct machine
0691 // encoding), or is it a pseudo instruction used for codegen modeling
0692 // purposes.
0693 // FIXME: For now this is distinct from isPseudo, above, as code-gen-only
0694 // instructions can (and often do) still have encoding information
0695 // associated with them. Once we've migrated all of them over to true
0696 // pseudo-instructions that are lowered to real instructions prior to
0697 // the printer/emitter, we can remove this attribute and just use isPseudo.
0698 //
0699 // The intended use is:
0700 // isPseudo: Does not have encoding information and should be expanded,
0701 // at the latest, during lowering to MCInst.
0702 //
0703 // isCodeGenOnly: Does have encoding information and can go through to the
0704 // CodeEmitter unchanged, but duplicates a canonical instruction
0705 // definition's encoding and should be ignored when constructing the
0706 // assembler match tables.
0707 bit isCodeGenOnly = false;
0708
0709 // Is this instruction a pseudo instruction for use by the assembler parser.
0710 bit isAsmParserOnly = false;
0711
0712 // This instruction is not expected to be queried for scheduling latencies
0713 // and therefore needs no scheduling information even for a complete
0714 // scheduling model.
0715 bit hasNoSchedulingInfo = false;
0716
0717 InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling.
0718
0719 // Scheduling information from TargetSchedule.td.
0720 list<SchedReadWrite> SchedRW;
0721
0722 /// Support for operand constraints. There are currently two kinds:
0723 /// "$src = $dst"
0724 /// Ensures that the operands are allocated to the same register.
0725 ///
0726 /// "@earlyclobber $rd"
0727 /// Ensures that LLVM will not use the same register for any inputs (other
0728 /// than an input tied to this output).
0729 ///
0730 /// See also:
0731 /// - MC/MCInstrDesc.h:OperandConstraint::{TIED_TO, EARLY_CLOBBER}.
0732 /// - CodeGen/MachineOperand.h:MachineOperand::{TiedTo, IsEarlyClobber}.
0733 /// - The LLVM IR specification: Section `Output constraints` in the
0734 /// discussion of inline assembly constraint strings.
0735 string Constraints = "";
0736
0737 /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not
0738 /// be encoded into the output machineinstr.
0739 string DisableEncoding = "";
0740
0741 string PostEncoderMethod = "";
0742
0743 /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc.
0744 bits<64> TSFlags = 0;
0745
0746 ///@name Assembler Parser Support
0747 ///@{
0748
0749 string AsmMatchConverter = "";
0750
0751 /// TwoOperandAliasConstraint - Enable TableGen to auto-generate a
0752 /// two-operand matcher inst-alias for a three operand instruction.
0753 /// For example, the arm instruction "add r3, r3, r5" can be written
0754 /// as "add r3, r5". The constraint is of the same form as a tied-operand
0755 /// constraint. For example, "$Rn = $Rd".
0756 string TwoOperandAliasConstraint = "";
0757
0758 /// Assembler variant name to use for this instruction. If specified then
0759 /// instruction will be presented only in MatchTable for this variant. If
0760 /// not specified then assembler variants will be determined based on
0761 /// AsmString
0762 string AsmVariantName = "";
0763
0764 ///@}
0765
0766 /// UseNamedOperandTable - If set, the operand indices of this instruction
0767 /// can be queried via the getNamedOperandIdx() function which is generated
0768 /// by TableGen.
0769 bit UseNamedOperandTable = false;
0770
0771 /// Should generate helper functions that help you to map a logical operand's
0772 /// index to the underlying MIOperand's index.
0773 /// In most architectures logical operand indices are equal to
0774 /// MIOperand indices, but for some CISC architectures, a logical operand
0775 /// might be consist of multiple MIOperand (e.g. a logical operand that
0776 /// uses complex address mode).
0777 bit UseLogicalOperandMappings = false;
0778
0779 /// Should FastISel ignore this instruction. For certain ISAs, they have
0780 /// instructions which map to the same ISD Opcode, value type operands and
0781 /// instruction selection predicates. FastISel cannot handle such cases, but
0782 /// SelectionDAG can.
0783 bit FastISelShouldIgnore = false;
0784
0785 /// HasPositionOrder: Indicate tablegen to sort the instructions by record
0786 /// ID, so that instruction that is defined earlier can be sorted earlier
0787 /// in the assembly matching table.
0788 bit HasPositionOrder = false;
0789 }
0790
0791 /// Defines a Pat match between compressed and uncompressed instruction.
0792 /// The relationship and helper function generation are handled by
0793 /// CompressInstEmitter backend.
0794 class CompressPat<dag input, dag output, list<Predicate> predicates = []> {
0795 /// Uncompressed instruction description.
0796 dag Input = input;
0797 /// Compressed instruction description.
0798 dag Output = output;
0799 /// Predicates that must be true for this to match.
0800 list<Predicate> Predicates = predicates;
0801 /// Duplicate match when tied operand is just different.
0802 bit isCompressOnly = false;
0803 }
0804
0805 /// Defines an additional encoding that disassembles to the given instruction
0806 /// Like Instruction, the Inst and SoftFail fields are omitted to allow targets
0807 // to specify their size.
0808 class AdditionalEncoding<Instruction I> : InstructionEncoding {
0809 Instruction AliasOf = I;
0810 }
0811
0812 /// PseudoInstExpansion - Expansion information for a pseudo-instruction.
0813 /// Which instruction it expands to and how the operands map from the
0814 /// pseudo.
0815 class PseudoInstExpansion<dag Result> {
0816 dag ResultInst = Result; // The instruction to generate.
0817 bit isPseudo = true;
0818 }
0819
0820 /// Predicates - These are extra conditionals which are turned into instruction
0821 /// selector matching code. Currently each predicate is just a string.
0822 class Predicate<string cond> {
0823 string CondString = cond;
0824
0825 /// AssemblerMatcherPredicate - If this feature can be used by the assembler
0826 /// matcher, this is true. Targets should set this by inheriting their
0827 /// feature from the AssemblerPredicate class in addition to Predicate.
0828 bit AssemblerMatcherPredicate = false;
0829
0830 /// AssemblerCondDag - Set of subtarget features being tested used
0831 /// as alternative condition string used for assembler matcher. Must be used
0832 /// with (all_of) to indicate that all features must be present, or (any_of)
0833 /// to indicate that at least one must be. The required lack of presence of
0834 /// a feature can be tested using a (not) node including the feature.
0835 /// e.g. "(all_of ModeThumb)" is translated to "(Bits & ModeThumb) != 0".
0836 /// "(all_of (not ModeThumb))" is translated to
0837 /// "(Bits & ModeThumb) == 0".
0838 /// "(all_of ModeThumb, FeatureThumb2)" is translated to
0839 /// "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0".
0840 /// "(any_of ModeTumb, FeatureThumb2)" is translated to
0841 /// "(Bits & ModeThumb) != 0 || (Bits & FeatureThumb2) != 0".
0842 /// all_of and any_of cannot be combined in a single dag, instead multiple
0843 /// predicates can be placed onto Instruction definitions.
0844 dag AssemblerCondDag;
0845
0846 /// PredicateName - User-level name to use for the predicate. Mainly for use
0847 /// in diagnostics such as missing feature errors in the asm matcher.
0848 string PredicateName = "";
0849
0850 /// Setting this to '1' indicates that the predicate must be recomputed on
0851 /// every function change. Most predicates can leave this at '0'.
0852 ///
0853 /// Ignored by SelectionDAG, it always recomputes the predicate on every use.
0854 bit RecomputePerFunction = false;
0855 }
0856
0857 /// NoHonorSignDependentRounding - This predicate is true if support for
0858 /// sign-dependent-rounding is not enabled.
0859 def NoHonorSignDependentRounding
0860 : Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">;
0861
0862 class Requires<list<Predicate> preds> {
0863 list<Predicate> Predicates = preds;
0864 }
0865
0866 /// ops definition - This is just a simple marker used to identify the operand
0867 /// list for an instruction. outs and ins are identical both syntactically and
0868 /// semantically; they are used to define def operands and use operands to
0869 /// improve readability. This should be used like this:
0870 /// (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar.
0871 def ops;
0872 def outs;
0873 def ins;
0874
0875 /// variable_ops definition - Mark this instruction as taking a variable number
0876 /// of operands.
0877 def variable_ops;
0878
0879 /// variable-length instruction encoding utilities.
0880 /// The `ascend` operator should be used like this:
0881 /// (ascend 0b0010, 0b1101)
0882 /// Which represent a seqence of encoding fragments placing from LSB to MSB.
0883 /// Thus, in this case the final encoding will be 0b1101_0010.
0884 /// The arguments for `ascend` can either be `bits` or another DAG.
0885 def ascend;
0886 /// In addition, we can use `descend` to describe an encoding that places
0887 /// its arguments (i.e. encoding fragments) from MSB to LSB. For instance:
0888 /// (descend 0b0010, 0b1101)
0889 /// This results in an encoding of 0b0010_1101.
0890 def descend;
0891 /// The `operand` operator should be used like this:
0892 /// (operand "$src", 4)
0893 /// Which represents a 4-bit encoding for an instruction operand named `$src`.
0894 def operand;
0895 /// Similar to `operand`, we can reference only part of the operand's encoding:
0896 /// (slice "$src", 6, 8)
0897 /// (slice "$src", 8, 6)
0898 /// Both DAG represent bit 6 to 8 (total of 3 bits) in the encoding of operand
0899 /// `$src`.
0900 def slice;
0901 /// You can use `encoder` or `decoder` to specify a custom encoder or decoder
0902 /// function for a specific `operand` or `slice` directive. For example:
0903 /// (operand "$src", 4, (encoder "encodeMyImm"))
0904 /// (slice "$src", 8, 6, (encoder "encodeMyReg"))
0905 /// (operand "$src", 4, (encoder "encodeMyImm"), (decoder "decodeMyImm"))
0906 /// The ordering of `encoder` and `decoder` in the same `operand` or `slice`
0907 /// doesn't matter.
0908 /// Note that currently we cannot assign different decoders in the same
0909 /// (instruction) operand.
0910 def encoder;
0911 def decoder;
0912
0913 /// PointerLikeRegClass - Values that are designed to have pointer width are
0914 /// derived from this. TableGen treats the register class as having a symbolic
0915 /// type that it doesn't know, and resolves the actual regclass to use by using
0916 /// the TargetRegisterInfo::getPointerRegClass() hook at codegen time.
0917 class PointerLikeRegClass<int Kind> {
0918 int RegClassKind = Kind;
0919 }
0920
0921
0922 /// ptr_rc definition - Mark this operand as being a pointer value whose
0923 /// register class is resolved dynamically via a callback to TargetInstrInfo.
0924 /// FIXME: We should probably change this to a class which contain a list of
0925 /// flags. But currently we have but one flag.
0926 def ptr_rc : PointerLikeRegClass<0>;
0927
0928 /// unknown definition - Mark this operand as being of unknown type, causing
0929 /// it to be resolved by inference in the context it is used.
0930 class unknown_class;
0931 def unknown : unknown_class;
0932
0933 /// AsmOperandClass - Representation for the kinds of operands which the target
0934 /// specific parser can create and the assembly matcher may need to distinguish.
0935 ///
0936 /// Operand classes are used to define the order in which instructions are
0937 /// matched, to ensure that the instruction which gets matched for any
0938 /// particular list of operands is deterministic.
0939 ///
0940 /// The target specific parser must be able to classify a parsed operand into a
0941 /// unique class which does not partially overlap with any other classes. It can
0942 /// match a subset of some other class, in which case the super class field
0943 /// should be defined.
0944 class AsmOperandClass {
0945 /// The name to use for this class, which should be usable as an enum value.
0946 string Name = ?;
0947
0948 /// The super classes of this operand.
0949 list<AsmOperandClass> SuperClasses = [];
0950
0951 /// The name of the method on the target specific operand to call to test
0952 /// whether the operand is an instance of this class. If not set, this will
0953 /// default to "isFoo", where Foo is the AsmOperandClass name. The method
0954 /// signature should be:
0955 /// bool isFoo() const;
0956 string PredicateMethod = ?;
0957
0958 /// The name of the method on the target specific operand to call to add the
0959 /// target specific operand to an MCInst. If not set, this will default to
0960 /// "addFooOperands", where Foo is the AsmOperandClass name. The method
0961 /// signature should be:
0962 /// void addFooOperands(MCInst &Inst, unsigned N) const;
0963 string RenderMethod = ?;
0964
0965 /// The name of the method on the target specific operand to call to custom
0966 /// handle the operand parsing. This is useful when the operands do not relate
0967 /// to immediates or registers and are very instruction specific (as flags to
0968 /// set in a processor register, coprocessor number, ...).
0969 string ParserMethod = ?;
0970
0971 // The diagnostic type to present when referencing this operand in a
0972 // match failure error message. By default, use a generic "invalid operand"
0973 // diagnostic. The target AsmParser maps these codes to text.
0974 string DiagnosticType = "";
0975
0976 /// A diagnostic message to emit when an invalid value is provided for this
0977 /// operand.
0978 string DiagnosticString = "";
0979
0980 /// Set to 1 if this operand is optional and not always required. Typically,
0981 /// the AsmParser will emit an error when it finishes parsing an
0982 /// instruction if it hasn't matched all the operands yet. However, this
0983 /// error will be suppressed if all of the remaining unmatched operands are
0984 /// marked as IsOptional.
0985 bit IsOptional = false;
0986
0987 /// The name of the method on the target specific asm parser that returns the
0988 /// default operand for this optional operand. This method is only used if
0989 /// IsOptional == 1. If not set, this will default to "defaultFooOperands",
0990 /// where Foo is the AsmOperandClass name. The method signature should be:
0991 /// std::unique_ptr<MCParsedAsmOperand> defaultFooOperands() const;
0992 string DefaultMethod = ?;
0993 }
0994
0995 def ImmAsmOperand : AsmOperandClass {
0996 let Name = "Imm";
0997 }
0998
0999 /// Operand Types - These provide the built-in operand types that may be used
1000 /// by a target. Targets can optionally provide their own operand types as
1001 /// needed, though this should not be needed for RISC targets.
1002 class Operand<ValueType ty> : DAGOperand {
1003 ValueType Type = ty;
1004 string PrintMethod = "printOperand";
1005 string EncoderMethod = "";
1006 bit hasCompleteDecoder = true;
1007 string OperandType = "OPERAND_UNKNOWN";
1008 dag MIOperandInfo = (ops);
1009
1010 // MCOperandPredicate - Optionally, a code fragment operating on
1011 // const MCOperand &MCOp, and returning a bool, to indicate if
1012 // the value of MCOp is valid for the specific subclass of Operand
1013 code MCOperandPredicate;
1014
1015 // ParserMatchClass - The "match class" that operands of this type fit
1016 // in. Match classes are used to define the order in which instructions are
1017 // match, to ensure that which instructions gets matched is deterministic.
1018 //
1019 // The target specific parser must be able to classify an parsed operand into
1020 // a unique class, which does not partially overlap with any other classes. It
1021 // can match a subset of some other class, in which case the AsmOperandClass
1022 // should declare the other operand as one of its super classes.
1023 AsmOperandClass ParserMatchClass = ImmAsmOperand;
1024 }
1025
1026 class RegisterOperand<RegisterClass regclass, string pm = "printOperand">
1027 : DAGOperand {
1028 // RegClass - The register class of the operand.
1029 RegisterClass RegClass = regclass;
1030 // PrintMethod - The target method to call to print register operands of
1031 // this type. The method normally will just use an alt-name index to look
1032 // up the name to print. Default to the generic printOperand().
1033 string PrintMethod = pm;
1034
1035 // EncoderMethod - The target method name to call to encode this register
1036 // operand.
1037 string EncoderMethod = "";
1038
1039 // ParserMatchClass - The "match class" that operands of this type fit
1040 // in. Match classes are used to define the order in which instructions are
1041 // match, to ensure that which instructions gets matched is deterministic.
1042 //
1043 // The target specific parser must be able to classify an parsed operand into
1044 // a unique class, which does not partially overlap with any other classes. It
1045 // can match a subset of some other class, in which case the AsmOperandClass
1046 // should declare the other operand as one of its super classes.
1047 AsmOperandClass ParserMatchClass;
1048
1049 string OperandType = "OPERAND_REGISTER";
1050
1051 // When referenced in the result of a CodeGen pattern, GlobalISel will
1052 // normally copy the matched operand to the result. When this is set, it will
1053 // emit a special copy that will replace zero-immediates with the specified
1054 // zero-register.
1055 Register GIZeroRegister = ?;
1056 }
1057
1058 let OperandType = "OPERAND_IMMEDIATE" in {
1059 def i1imm : Operand<i1>;
1060 def i8imm : Operand<i8>;
1061 def i16imm : Operand<i16>;
1062 def i32imm : Operand<i32>;
1063 def i64imm : Operand<i64>;
1064
1065 def f32imm : Operand<f32>;
1066 def f64imm : Operand<f64>;
1067 }
1068
1069 // Register operands for generic instructions don't have an MVT, but do have
1070 // constraints linking the operands (e.g. all operands of a G_ADD must
1071 // have the same LLT).
1072 class TypedOperand<string Ty> : Operand<untyped> {
1073 let OperandType = Ty;
1074 bit IsPointer = false;
1075 bit IsImmediate = false;
1076 }
1077
1078 def type0 : TypedOperand<"OPERAND_GENERIC_0">;
1079 def type1 : TypedOperand<"OPERAND_GENERIC_1">;
1080 def type2 : TypedOperand<"OPERAND_GENERIC_2">;
1081 def type3 : TypedOperand<"OPERAND_GENERIC_3">;
1082 def type4 : TypedOperand<"OPERAND_GENERIC_4">;
1083 def type5 : TypedOperand<"OPERAND_GENERIC_5">;
1084
1085 let IsPointer = true in {
1086 def ptype0 : TypedOperand<"OPERAND_GENERIC_0">;
1087 def ptype1 : TypedOperand<"OPERAND_GENERIC_1">;
1088 def ptype2 : TypedOperand<"OPERAND_GENERIC_2">;
1089 def ptype3 : TypedOperand<"OPERAND_GENERIC_3">;
1090 def ptype4 : TypedOperand<"OPERAND_GENERIC_4">;
1091 def ptype5 : TypedOperand<"OPERAND_GENERIC_5">;
1092 }
1093
1094 // untyped_imm is for operands where isImm() will be true. It currently has no
1095 // special behaviour and is only used for clarity.
1096 def untyped_imm_0 : TypedOperand<"OPERAND_GENERIC_IMM_0"> {
1097 let IsImmediate = true;
1098 }
1099
1100 /// zero_reg definition - Special node to stand for the zero register.
1101 ///
1102 def zero_reg;
1103
1104 /// undef_tied_input - Special node to indicate an input register tied
1105 /// to an output which defaults to IMPLICIT_DEF.
1106 def undef_tied_input;
1107
1108 /// All operands which the MC layer classifies as predicates should inherit from
1109 /// this class in some manner. This is already handled for the most commonly
1110 /// used PredicateOperand, but may be useful in other circumstances.
1111 class PredicateOp;
1112
1113 /// OperandWithDefaultOps - This Operand class can be used as the parent class
1114 /// for an Operand that needs to be initialized with a default value if
1115 /// no value is supplied in a pattern. This class can be used to simplify the
1116 /// pattern definitions for instructions that have target specific flags
1117 /// encoded as immediate operands.
1118 class OperandWithDefaultOps<ValueType ty, dag defaultops>
1119 : Operand<ty> {
1120 dag DefaultOps = defaultops;
1121 }
1122
1123 /// PredicateOperand - This can be used to define a predicate operand for an
1124 /// instruction. OpTypes specifies the MIOperandInfo for the operand, and
1125 /// AlwaysVal specifies the value of this predicate when set to "always
1126 /// execute".
1127 class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal>
1128 : OperandWithDefaultOps<ty, AlwaysVal>, PredicateOp {
1129 let MIOperandInfo = OpTypes;
1130 }
1131
1132 /// OptionalDefOperand - This is used to define a optional definition operand
1133 /// for an instruction. DefaultOps is the register the operand represents if
1134 /// none is supplied, e.g. zero_reg.
1135 class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops>
1136 : OperandWithDefaultOps<ty, defaultops> {
1137 let MIOperandInfo = OpTypes;
1138 }
1139
1140
1141 // InstrInfo - This class should only be instantiated once to provide parameters
1142 // which are global to the target machine.
1143 //
1144 class InstrInfo {
1145 // Target can specify its instructions in either big or little-endian formats.
1146 // For instance, while both Sparc and PowerPC are big-endian platforms, the
1147 // Sparc manual specifies its instructions in the format [31..0] (big), while
1148 // PowerPC specifies them using the format [0..31] (little).
1149 bit isLittleEndianEncoding = false;
1150
1151 // The instruction properties mayLoad, mayStore, and hasSideEffects are unset
1152 // by default, and TableGen will infer their value from the instruction
1153 // pattern when possible.
1154 //
1155 // Normally, TableGen will issue an error if it can't infer the value of a
1156 // property that hasn't been set explicitly. When guessInstructionProperties
1157 // is set, it will guess a safe value instead.
1158 //
1159 // This option is a temporary migration help. It will go away.
1160 bit guessInstructionProperties = true;
1161 }
1162
1163 // Standard Pseudo Instructions.
1164 // This list must match TargetOpcodes.def.
1165 // Only these instructions are allowed in the TargetOpcode namespace.
1166 // Ensure mayLoad and mayStore have a default value, so as not to break
1167 // targets that set guessInstructionProperties=0. Any local definition of
1168 // mayLoad/mayStore takes precedence over these default values.
1169 class StandardPseudoInstruction : Instruction {
1170 let mayLoad = false;
1171 let mayStore = false;
1172 let isCodeGenOnly = true;
1173 let isPseudo = true;
1174 let hasNoSchedulingInfo = true;
1175 let Namespace = "TargetOpcode";
1176 }
1177 def PHI : StandardPseudoInstruction {
1178 let OutOperandList = (outs unknown:$dst);
1179 let InOperandList = (ins variable_ops);
1180 let AsmString = "PHINODE";
1181 let hasSideEffects = false;
1182 }
1183 def INLINEASM : StandardPseudoInstruction {
1184 let OutOperandList = (outs);
1185 let InOperandList = (ins variable_ops);
1186 let AsmString = "";
1187 let hasSideEffects = false; // Note side effect is encoded in an operand.
1188 }
1189 def INLINEASM_BR : StandardPseudoInstruction {
1190 let OutOperandList = (outs);
1191 let InOperandList = (ins variable_ops);
1192 let AsmString = "";
1193 // Unlike INLINEASM, this is always treated as having side-effects.
1194 let hasSideEffects = true;
1195 // Despite potentially branching, this instruction is intentionally _not_
1196 // marked as a terminator or a branch.
1197 }
1198 def CFI_INSTRUCTION : StandardPseudoInstruction {
1199 let OutOperandList = (outs);
1200 let InOperandList = (ins i32imm:$id);
1201 let AsmString = "";
1202 let hasCtrlDep = true;
1203 let hasSideEffects = false;
1204 let isNotDuplicable = true;
1205 let isMeta = true;
1206 }
1207 def EH_LABEL : StandardPseudoInstruction {
1208 let OutOperandList = (outs);
1209 let InOperandList = (ins i32imm:$id);
1210 let AsmString = "";
1211 let hasCtrlDep = true;
1212 let hasSideEffects = false;
1213 let isNotDuplicable = true;
1214 let isMeta = true;
1215 }
1216 def GC_LABEL : StandardPseudoInstruction {
1217 let OutOperandList = (outs);
1218 let InOperandList = (ins i32imm:$id);
1219 let AsmString = "";
1220 let hasCtrlDep = true;
1221 let hasSideEffects = false;
1222 let isNotDuplicable = true;
1223 let isMeta = true;
1224 }
1225 def ANNOTATION_LABEL : StandardPseudoInstruction {
1226 let OutOperandList = (outs);
1227 let InOperandList = (ins i32imm:$id);
1228 let AsmString = "";
1229 let hasCtrlDep = true;
1230 let hasSideEffects = false;
1231 let isNotDuplicable = true;
1232 }
1233 def KILL : StandardPseudoInstruction {
1234 let OutOperandList = (outs);
1235 let InOperandList = (ins variable_ops);
1236 let AsmString = "";
1237 let hasSideEffects = false;
1238 let isMeta = true;
1239 }
1240 def EXTRACT_SUBREG : StandardPseudoInstruction {
1241 let OutOperandList = (outs unknown:$dst);
1242 let InOperandList = (ins unknown:$supersrc, i32imm:$subidx);
1243 let AsmString = "";
1244 let hasSideEffects = false;
1245 }
1246 def INSERT_SUBREG : StandardPseudoInstruction {
1247 let OutOperandList = (outs unknown:$dst);
1248 let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx);
1249 let AsmString = "";
1250 let hasSideEffects = false;
1251 let Constraints = "$supersrc = $dst";
1252 }
1253 def IMPLICIT_DEF : StandardPseudoInstruction {
1254 let OutOperandList = (outs unknown:$dst);
1255 let InOperandList = (ins);
1256 let AsmString = "";
1257 let hasSideEffects = false;
1258 let isReMaterializable = true;
1259 let isAsCheapAsAMove = true;
1260 let isMeta = true;
1261 }
1262 def INIT_UNDEF : StandardPseudoInstruction {
1263 let OutOperandList = (outs unknown:$dst);
1264 let InOperandList = (ins);
1265 let AsmString = "";
1266 let hasSideEffects = false;
1267 let Size = 0;
1268 }
1269 def SUBREG_TO_REG : StandardPseudoInstruction {
1270 let OutOperandList = (outs unknown:$dst);
1271 let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx);
1272 let AsmString = "";
1273 let hasSideEffects = false;
1274 }
1275 def COPY_TO_REGCLASS : StandardPseudoInstruction {
1276 let OutOperandList = (outs unknown:$dst);
1277 let InOperandList = (ins unknown:$src, i32imm:$regclass);
1278 let AsmString = "";
1279 let hasSideEffects = false;
1280 let isAsCheapAsAMove = true;
1281 }
1282 def DBG_VALUE : StandardPseudoInstruction {
1283 let OutOperandList = (outs);
1284 let InOperandList = (ins variable_ops);
1285 let AsmString = "DBG_VALUE";
1286 let hasSideEffects = false;
1287 let isMeta = true;
1288 }
1289 def DBG_VALUE_LIST : StandardPseudoInstruction {
1290 let OutOperandList = (outs);
1291 let InOperandList = (ins variable_ops);
1292 let AsmString = "DBG_VALUE_LIST";
1293 let hasSideEffects = 0;
1294 let isMeta = true;
1295 }
1296 def DBG_INSTR_REF : StandardPseudoInstruction {
1297 let OutOperandList = (outs);
1298 let InOperandList = (ins variable_ops);
1299 let AsmString = "DBG_INSTR_REF";
1300 let hasSideEffects = false;
1301 let isMeta = true;
1302 }
1303 def DBG_PHI : StandardPseudoInstruction {
1304 let OutOperandList = (outs);
1305 let InOperandList = (ins variable_ops);
1306 let AsmString = "DBG_PHI";
1307 let hasSideEffects = 0;
1308 let isMeta = true;
1309 }
1310 def DBG_LABEL : StandardPseudoInstruction {
1311 let OutOperandList = (outs);
1312 let InOperandList = (ins unknown:$label);
1313 let AsmString = "DBG_LABEL";
1314 let hasSideEffects = false;
1315 let isMeta = true;
1316 }
1317 def REG_SEQUENCE : StandardPseudoInstruction {
1318 let OutOperandList = (outs unknown:$dst);
1319 let InOperandList = (ins unknown:$supersrc, variable_ops);
1320 let AsmString = "";
1321 let hasSideEffects = false;
1322 let isAsCheapAsAMove = true;
1323 }
1324 def COPY : StandardPseudoInstruction {
1325 let OutOperandList = (outs unknown:$dst);
1326 let InOperandList = (ins unknown:$src);
1327 let AsmString = "";
1328 let hasSideEffects = false;
1329 let isAsCheapAsAMove = true;
1330 let hasNoSchedulingInfo = false;
1331 }
1332 def BUNDLE : StandardPseudoInstruction {
1333 let OutOperandList = (outs);
1334 let InOperandList = (ins variable_ops);
1335 let AsmString = "BUNDLE";
1336 let hasSideEffects = false;
1337 }
1338 def LIFETIME_START : StandardPseudoInstruction {
1339 let OutOperandList = (outs);
1340 let InOperandList = (ins i32imm:$id);
1341 let AsmString = "LIFETIME_START";
1342 let hasSideEffects = false;
1343 let isMeta = true;
1344 }
1345 def LIFETIME_END : StandardPseudoInstruction {
1346 let OutOperandList = (outs);
1347 let InOperandList = (ins i32imm:$id);
1348 let AsmString = "LIFETIME_END";
1349 let hasSideEffects = false;
1350 let isMeta = true;
1351 }
1352 def PSEUDO_PROBE : StandardPseudoInstruction {
1353 let OutOperandList = (outs);
1354 let InOperandList = (ins i64imm:$guid, i64imm:$index, i8imm:$type, i32imm:$attr);
1355 let AsmString = "PSEUDO_PROBE";
1356 let hasSideEffects = 1;
1357 let isMeta = true;
1358 }
1359 def ARITH_FENCE : StandardPseudoInstruction {
1360 let OutOperandList = (outs unknown:$dst);
1361 let InOperandList = (ins unknown:$src);
1362 let AsmString = "";
1363 let hasSideEffects = false;
1364 let Constraints = "$src = $dst";
1365 let isMeta = true;
1366 }
1367
1368 def STACKMAP : StandardPseudoInstruction {
1369 let OutOperandList = (outs);
1370 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops);
1371 let hasSideEffects = true;
1372 let isCall = true;
1373 let mayLoad = true;
1374 let usesCustomInserter = true;
1375 }
1376 def PATCHPOINT : StandardPseudoInstruction {
1377 let OutOperandList = (outs unknown:$dst);
1378 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee,
1379 i32imm:$nargs, i32imm:$cc, variable_ops);
1380 let hasSideEffects = true;
1381 let isCall = true;
1382 let mayLoad = true;
1383 let usesCustomInserter = true;
1384 }
1385 def STATEPOINT : StandardPseudoInstruction {
1386 let OutOperandList = (outs variable_ops);
1387 let InOperandList = (ins variable_ops);
1388 let usesCustomInserter = true;
1389 let mayLoad = true;
1390 let mayStore = true;
1391 let hasSideEffects = true;
1392 let isCall = true;
1393 }
1394 def LOAD_STACK_GUARD : StandardPseudoInstruction {
1395 let OutOperandList = (outs ptr_rc:$dst);
1396 let InOperandList = (ins);
1397 let mayLoad = true;
1398 bit isReMaterializable = true;
1399 let hasSideEffects = false;
1400 bit isPseudo = true;
1401 }
1402 def PREALLOCATED_SETUP : StandardPseudoInstruction {
1403 let OutOperandList = (outs);
1404 let InOperandList = (ins i32imm:$a);
1405 let usesCustomInserter = true;
1406 let hasSideEffects = true;
1407 }
1408 def PREALLOCATED_ARG : StandardPseudoInstruction {
1409 let OutOperandList = (outs ptr_rc:$loc);
1410 let InOperandList = (ins i32imm:$a, i32imm:$b);
1411 let usesCustomInserter = true;
1412 let hasSideEffects = true;
1413 }
1414 def LOCAL_ESCAPE : StandardPseudoInstruction {
1415 // This instruction is really just a label. It has to be part of the chain so
1416 // that it doesn't get dropped from the DAG, but it produces nothing and has
1417 // no side effects.
1418 let OutOperandList = (outs);
1419 let InOperandList = (ins ptr_rc:$symbol, i32imm:$id);
1420 let hasSideEffects = false;
1421 let hasCtrlDep = true;
1422 }
1423 def FAULTING_OP : StandardPseudoInstruction {
1424 let OutOperandList = (outs unknown:$dst);
1425 let InOperandList = (ins variable_ops);
1426 let usesCustomInserter = true;
1427 let hasSideEffects = true;
1428 let mayLoad = true;
1429 let mayStore = true;
1430 let isTerminator = true;
1431 let isBranch = true;
1432 }
1433 def FAKE_USE : StandardPseudoInstruction {
1434 // An instruction that uses its operands but does nothing; this instruction
1435 // will be treated specially by CodeGen passes, distinguishing it from any
1436 // otherwise equivalent instructions.
1437 let OutOperandList = (outs);
1438 let InOperandList = (ins variable_ops);
1439 let AsmString = "FAKE_USE";
1440 let hasSideEffects = 0;
1441 let isMeta = true;
1442 }
1443 def PATCHABLE_OP : StandardPseudoInstruction {
1444 let OutOperandList = (outs);
1445 let InOperandList = (ins variable_ops);
1446 let usesCustomInserter = true;
1447 let mayLoad = true;
1448 let mayStore = true;
1449 let hasSideEffects = true;
1450 }
1451 def PATCHABLE_FUNCTION_ENTER : StandardPseudoInstruction {
1452 let OutOperandList = (outs);
1453 let InOperandList = (ins);
1454 let AsmString = "# XRay Function Enter.";
1455 let usesCustomInserter = true;
1456 let hasSideEffects = true;
1457 }
1458 def PATCHABLE_RET : StandardPseudoInstruction {
1459 let OutOperandList = (outs);
1460 let InOperandList = (ins variable_ops);
1461 let AsmString = "# XRay Function Patchable RET.";
1462 let usesCustomInserter = true;
1463 let hasSideEffects = true;
1464 let isTerminator = true;
1465 let isReturn = true;
1466 }
1467 def PATCHABLE_FUNCTION_EXIT : StandardPseudoInstruction {
1468 let OutOperandList = (outs);
1469 let InOperandList = (ins);
1470 let AsmString = "# XRay Function Exit.";
1471 let usesCustomInserter = true;
1472 let hasSideEffects = true;
1473 let isReturn = false; // Original return instruction will follow
1474 }
1475 def PATCHABLE_TAIL_CALL : StandardPseudoInstruction {
1476 let OutOperandList = (outs);
1477 let InOperandList = (ins variable_ops);
1478 let AsmString = "# XRay Tail Call Exit.";
1479 let usesCustomInserter = true;
1480 let hasSideEffects = true;
1481 let isReturn = true;
1482 }
1483 def PATCHABLE_EVENT_CALL : StandardPseudoInstruction {
1484 let OutOperandList = (outs);
1485 let InOperandList = (ins ptr_rc:$event, unknown:$size);
1486 let AsmString = "# XRay Custom Event Log.";
1487 let usesCustomInserter = true;
1488 let isCall = true;
1489 let mayLoad = true;
1490 let mayStore = true;
1491 let hasSideEffects = true;
1492 }
1493 def PATCHABLE_TYPED_EVENT_CALL : StandardPseudoInstruction {
1494 let OutOperandList = (outs);
1495 let InOperandList = (ins unknown:$type, ptr_rc:$event, unknown:$size);
1496 let AsmString = "# XRay Typed Event Log.";
1497 let usesCustomInserter = true;
1498 let isCall = true;
1499 let mayLoad = true;
1500 let mayStore = true;
1501 let hasSideEffects = true;
1502 }
1503 def FENTRY_CALL : StandardPseudoInstruction {
1504 let OutOperandList = (outs);
1505 let InOperandList = (ins);
1506 let AsmString = "# FEntry call";
1507 let usesCustomInserter = true;
1508 let isCall = true;
1509 let mayLoad = true;
1510 let mayStore = true;
1511 let hasSideEffects = true;
1512 }
1513 def ICALL_BRANCH_FUNNEL : StandardPseudoInstruction {
1514 let OutOperandList = (outs);
1515 let InOperandList = (ins variable_ops);
1516 let AsmString = "";
1517 let hasSideEffects = true;
1518 }
1519 def MEMBARRIER : StandardPseudoInstruction {
1520 let OutOperandList = (outs);
1521 let InOperandList = (ins);
1522 let AsmString = "";
1523 let hasSideEffects = true;
1524 let Size = 0;
1525 let isMeta = true;
1526 }
1527 def JUMP_TABLE_DEBUG_INFO : StandardPseudoInstruction {
1528 let OutOperandList = (outs);
1529 let InOperandList = (ins i64imm:$jti);
1530 let AsmString = "";
1531 let hasSideEffects = false;
1532 let Size = 0;
1533 let isMeta = true;
1534 }
1535
1536 let hasSideEffects = false, isMeta = true, isConvergent = true in {
1537 def CONVERGENCECTRL_ANCHOR : StandardPseudoInstruction {
1538 let OutOperandList = (outs unknown:$dst);
1539 let InOperandList = (ins);
1540 }
1541 def CONVERGENCECTRL_ENTRY : StandardPseudoInstruction {
1542 let OutOperandList = (outs unknown:$dst);
1543 let InOperandList = (ins);
1544 }
1545 def CONVERGENCECTRL_LOOP : StandardPseudoInstruction {
1546 let OutOperandList = (outs unknown:$dst);
1547 let InOperandList = (ins unknown:$src);
1548 }
1549 def CONVERGENCECTRL_GLUE : StandardPseudoInstruction {
1550 let OutOperandList = (outs);
1551 let InOperandList = (ins unknown:$src);
1552 }
1553 }
1554
1555 // Generic opcodes used in GlobalISel.
1556 include "llvm/Target/GenericOpcodes.td"
1557
1558 //===----------------------------------------------------------------------===//
1559 // AsmParser - This class can be implemented by targets that wish to implement
1560 // .s file parsing.
1561 //
1562 // Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel
1563 // syntax on X86 for example).
1564 //
1565 class AsmParser {
1566 // AsmParserClassName - This specifies the suffix to use for the asmparser
1567 // class. Generated AsmParser classes are always prefixed with the target
1568 // name.
1569 string AsmParserClassName = "AsmParser";
1570
1571 // AsmParserInstCleanup - If non-empty, this is the name of a custom member
1572 // function of the AsmParser class to call on every matched instruction.
1573 // This can be used to perform target specific instruction post-processing.
1574 string AsmParserInstCleanup = "";
1575
1576 // ShouldEmitMatchRegisterName - Set to false if the target needs a hand
1577 // written register name matcher
1578 bit ShouldEmitMatchRegisterName = true;
1579
1580 // Set to true if the target needs a generated 'alternative register name'
1581 // matcher.
1582 //
1583 // This generates a function which can be used to lookup registers from
1584 // their aliases. This function will fail when called on targets where
1585 // several registers share the same alias (i.e. not a 1:1 mapping).
1586 bit ShouldEmitMatchRegisterAltName = false;
1587
1588 // Set to true if MatchRegisterName and MatchRegisterAltName functions
1589 // should be generated even if there are duplicate register names. The
1590 // target is responsible for coercing aliased registers as necessary
1591 // (e.g. in validateTargetOperandClass), and there are no guarantees about
1592 // which numeric register identifier will be returned in the case of
1593 // multiple matches.
1594 bit AllowDuplicateRegisterNames = false;
1595
1596 // HasMnemonicFirst - Set to false if target instructions don't always
1597 // start with a mnemonic as the first token.
1598 bit HasMnemonicFirst = true;
1599
1600 // ReportMultipleNearMisses -
1601 // When 0, the assembly matcher reports an error for one encoding or operand
1602 // that did not match the parsed instruction.
1603 // When 1, the assembly matcher returns a list of encodings that were close
1604 // to matching the parsed instruction, so to allow more detailed error
1605 // messages.
1606 bit ReportMultipleNearMisses = false;
1607
1608 // OperandParserMethod - If non-empty, this is the name of a custom
1609 // member function of the AsmParser class to call for every instruction
1610 // operand to be parsed.
1611 string OperandParserMethod = "";
1612
1613 // CallCustomParserForAllOperands - Set to true if the custom parser
1614 // method shall be called for all operands as opposed to only those
1615 // that have their own specified custom parsers.
1616 bit CallCustomParserForAllOperands = false;
1617
1618 // PreferSmallerInstructions - Should the assembly matcher prefer the smaller
1619 // instructions.
1620 //
1621 // This is useful for the ARM instructions set where smaller encodings must
1622 // be preferentially selected.
1623 //
1624 // The preference order is:
1625 // Instrution size (if this option is enabled, smallest first)
1626 // Number of Operands (least first),
1627 // Operand Classes (lexicographically by operand),
1628 // (Optional) Instruction id (see AsmMatcherEmitter.cpp for details),
1629 // Number of required features (least first)
1630 bit PreferSmallerInstructions = false;
1631 }
1632 def DefaultAsmParser : AsmParser;
1633
1634 //===----------------------------------------------------------------------===//
1635 // AsmParserVariant - Subtargets can have multiple different assembly parsers
1636 // (e.g. AT&T vs Intel syntax on X86 for example). This class can be
1637 // implemented by targets to describe such variants.
1638 //
1639 class AsmParserVariant {
1640 // Variant - AsmParsers can be of multiple different variants. Variants are
1641 // used to support targets that need to parse multiple formats for the
1642 // assembly language.
1643 int Variant = 0;
1644
1645 // Name - The AsmParser variant name (e.g., AT&T vs Intel).
1646 string Name = "";
1647
1648 // CommentDelimiter - If given, the delimiter string used to recognize
1649 // comments which are hard coded in the .td assembler strings for individual
1650 // instructions.
1651 string CommentDelimiter = "";
1652
1653 // RegisterPrefix - If given, the token prefix which indicates a register
1654 // token. This is used by the matcher to automatically recognize hard coded
1655 // register tokens as constrained registers, instead of tokens, for the
1656 // purposes of matching.
1657 string RegisterPrefix = "";
1658
1659 // TokenizingCharacters - Characters that are standalone tokens
1660 string TokenizingCharacters = "[]*!";
1661
1662 // SeparatorCharacters - Characters that are not tokens
1663 string SeparatorCharacters = " \t,";
1664
1665 // BreakCharacters - Characters that start new identifiers
1666 string BreakCharacters = "";
1667 }
1668 def DefaultAsmParserVariant : AsmParserVariant;
1669
1670 // Operators for combining SubtargetFeatures in AssemblerPredicates
1671 def any_of;
1672 def all_of;
1673
1674 /// AssemblerPredicate - This is a Predicate that can be used when the assembler
1675 /// matches instructions and aliases.
1676 class AssemblerPredicate<dag cond, string name = ""> {
1677 bit AssemblerMatcherPredicate = true;
1678 dag AssemblerCondDag = cond;
1679 string PredicateName = name;
1680 }
1681
1682 /// TokenAlias - This class allows targets to define assembler token
1683 /// operand aliases. That is, a token literal operand which is equivalent
1684 /// to another, canonical, token literal. For example, ARM allows:
1685 /// vmov.u32 s4, #0 -> vmov.i32, #0
1686 /// 'u32' is a more specific designator for the 32-bit integer type specifier
1687 /// and is legal for any instruction which accepts 'i32' as a datatype suffix.
1688 /// def : TokenAlias<".u32", ".i32">;
1689 ///
1690 /// This works by marking the match class of 'From' as a subclass of the
1691 /// match class of 'To'.
1692 class TokenAlias<string From, string To> {
1693 string FromToken = From;
1694 string ToToken = To;
1695 }
1696
1697 /// MnemonicAlias - This class allows targets to define assembler mnemonic
1698 /// aliases. This should be used when all forms of one mnemonic are accepted
1699 /// with a different mnemonic. For example, X86 allows:
1700 /// sal %al, 1 -> shl %al, 1
1701 /// sal %ax, %cl -> shl %ax, %cl
1702 /// sal %eax, %cl -> shl %eax, %cl
1703 /// etc. Though "sal" is accepted with many forms, all of them are directly
1704 /// translated to a shl, so it can be handled with (in the case of X86, it
1705 /// actually has one for each suffix as well):
1706 /// def : MnemonicAlias<"sal", "shl">;
1707 ///
1708 /// Mnemonic aliases are mapped before any other translation in the match phase,
1709 /// and do allow Requires predicates, e.g.:
1710 ///
1711 /// def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>;
1712 /// def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>;
1713 ///
1714 /// Mnemonic aliases can also be constrained to specific variants, e.g.:
1715 ///
1716 /// def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>;
1717 ///
1718 /// If no variant (e.g., "att" or "intel") is specified then the alias is
1719 /// applied unconditionally.
1720 class MnemonicAlias<string From, string To, string VariantName = ""> {
1721 string FromMnemonic = From;
1722 string ToMnemonic = To;
1723 string AsmVariantName = VariantName;
1724
1725 // Predicates - Predicates that must be true for this remapping to happen.
1726 list<Predicate> Predicates = [];
1727 }
1728
1729 /// InstAlias - This defines an alternate assembly syntax that is allowed to
1730 /// match an instruction that has a different (more canonical) assembly
1731 /// representation.
1732 class InstAlias<string Asm, dag Result, int Emit = 1, string VariantName = ""> {
1733 string AsmString = Asm; // The .s format to match the instruction with.
1734 dag ResultInst = Result; // The MCInst to generate.
1735
1736 // This determines which order the InstPrinter detects aliases for
1737 // printing. A larger value makes the alias more likely to be
1738 // emitted. The Instruction's own definition is notionally 0.5, so 0
1739 // disables printing and 1 enables it if there are no conflicting aliases.
1740 int EmitPriority = Emit;
1741
1742 // Predicates - Predicates that must be true for this to match.
1743 list<Predicate> Predicates = [];
1744
1745 // If the instruction specified in Result has defined an AsmMatchConverter
1746 // then setting this to 1 will cause the alias to use the AsmMatchConverter
1747 // function when converting the OperandVector into an MCInst instead of the
1748 // function that is generated by the dag Result.
1749 // Setting this to 0 will cause the alias to ignore the Result instruction's
1750 // defined AsmMatchConverter and instead use the function generated by the
1751 // dag Result.
1752 bit UseInstAsmMatchConverter = true;
1753
1754 // Assembler variant name to use for this alias. If not specified then
1755 // assembler variants will be determined based on AsmString
1756 string AsmVariantName = VariantName;
1757 }
1758
1759 //===----------------------------------------------------------------------===//
1760 // AsmWriter - This class can be implemented by targets that need to customize
1761 // the format of the .s file writer.
1762 //
1763 // Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax
1764 // on X86 for example).
1765 //
1766 class AsmWriter {
1767 // AsmWriterClassName - This specifies the suffix to use for the asmwriter
1768 // class. Generated AsmWriter classes are always prefixed with the target
1769 // name.
1770 string AsmWriterClassName = "InstPrinter";
1771
1772 // PassSubtarget - Determines whether MCSubtargetInfo should be passed to
1773 // the various print methods.
1774 // FIXME: Remove after all ports are updated.
1775 int PassSubtarget = 0;
1776
1777 // Variant - AsmWriters can be of multiple different variants. Variants are
1778 // used to support targets that need to emit assembly code in ways that are
1779 // mostly the same for different targets, but have minor differences in
1780 // syntax. If the asmstring contains {|} characters in them, this integer
1781 // will specify which alternative to use. For example "{x|y|z}" with Variant
1782 // == 1, will expand to "y".
1783 int Variant = 0;
1784 }
1785 def DefaultAsmWriter : AsmWriter;
1786
1787
1788 //===----------------------------------------------------------------------===//
1789 // Target - This class contains the "global" target information
1790 //
1791 class Target {
1792 // InstructionSet - Instruction set description for this target.
1793 InstrInfo InstructionSet;
1794
1795 // AssemblyParsers - The AsmParser instances available for this target.
1796 list<AsmParser> AssemblyParsers = [DefaultAsmParser];
1797
1798 /// AssemblyParserVariants - The AsmParserVariant instances available for
1799 /// this target.
1800 list<AsmParserVariant> AssemblyParserVariants = [DefaultAsmParserVariant];
1801
1802 // AssemblyWriters - The AsmWriter instances available for this target.
1803 list<AsmWriter> AssemblyWriters = [DefaultAsmWriter];
1804
1805 // AllowRegisterRenaming - Controls whether this target allows
1806 // post-register-allocation renaming of registers. This is done by
1807 // setting hasExtraDefRegAllocReq and hasExtraSrcRegAllocReq to 1
1808 // for all opcodes if this flag is set to 0.
1809 int AllowRegisterRenaming = 0;
1810 }
1811
1812 //===----------------------------------------------------------------------===//
1813 // Processor chip sets - These values represent each of the chip sets supported
1814 // by the scheduler. Each Processor definition requires corresponding
1815 // instruction itineraries.
1816 //
1817 class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f,
1818 list<SubtargetFeature> tunef = []> {
1819 // Name - Chip set name. Used by command line (-mcpu=) to determine the
1820 // appropriate target chip.
1821 //
1822 string Name = n;
1823
1824 // SchedModel - The machine model for scheduling and instruction cost.
1825 //
1826 SchedMachineModel SchedModel = NoSchedModel;
1827
1828 // ProcItin - The scheduling information for the target processor.
1829 //
1830 ProcessorItineraries ProcItin = pi;
1831
1832 // Features - list of
1833 list<SubtargetFeature> Features = f;
1834
1835 // TuneFeatures - list of features for tuning for this CPU. If the target
1836 // supports -mtune, this should contain the list of features used to make
1837 // microarchitectural optimization decisions for a given processor. While
1838 // Features should contain the architectural features for the processor.
1839 list<SubtargetFeature> TuneFeatures = tunef;
1840 }
1841
1842 // ProcessorModel allows subtargets to specify the more general
1843 // SchedMachineModel instead if a ProcessorItinerary. Subtargets will
1844 // gradually move to this newer form.
1845 //
1846 // Although this class always passes NoItineraries to the Processor
1847 // class, the SchedMachineModel may still define valid Itineraries.
1848 class ProcessorModel<string n, SchedMachineModel m, list<SubtargetFeature> f,
1849 list<SubtargetFeature> tunef = []>
1850 : Processor<n, NoItineraries, f, tunef> {
1851 let SchedModel = m;
1852 }
1853
1854 //===----------------------------------------------------------------------===//
1855 // InstrMapping - This class is used to create mapping tables to relate
1856 // instructions with each other based on the values specified in RowFields,
1857 // ColFields, KeyCol and ValueCols.
1858 //
1859 class InstrMapping {
1860 // FilterClass - Used to limit search space only to the instructions that
1861 // define the relationship modeled by this InstrMapping record.
1862 string FilterClass;
1863
1864 // RowFields - List of fields/attributes that should be same for all the
1865 // instructions in a row of the relation table. Think of this as a set of
1866 // properties shared by all the instructions related by this relationship
1867 // model and is used to categorize instructions into subgroups. For instance,
1868 // if we want to define a relation that maps 'Add' instruction to its
1869 // predicated forms, we can define RowFields like this:
1870 //
1871 // let RowFields = BaseOp
1872 // All add instruction predicated/non-predicated will have to set their BaseOp
1873 // to the same value.
1874 //
1875 // def Add: { let BaseOp = 'ADD'; let predSense = 'nopred' }
1876 // def Add_predtrue: { let BaseOp = 'ADD'; let predSense = 'true' }
1877 // def Add_predfalse: { let BaseOp = 'ADD'; let predSense = 'false' }
1878 list<string> RowFields = [];
1879
1880 // List of fields/attributes that are same for all the instructions
1881 // in a column of the relation table.
1882 // Ex: let ColFields = 'predSense' -- It means that the columns are arranged
1883 // based on the 'predSense' values. All the instruction in a specific
1884 // column have the same value and it is fixed for the column according
1885 // to the values set in 'ValueCols'.
1886 list<string> ColFields = [];
1887
1888 // Values for the fields/attributes listed in 'ColFields'.
1889 // Ex: let KeyCol = 'nopred' -- It means that the key instruction (instruction
1890 // that models this relation) should be non-predicated.
1891 // In the example above, 'Add' is the key instruction.
1892 list<string> KeyCol = [];
1893
1894 // List of values for the fields/attributes listed in 'ColFields', one for
1895 // each column in the relation table.
1896 //
1897 // Ex: let ValueCols = [['true'],['false']] -- It adds two columns in the
1898 // table. First column requires all the instructions to have predSense
1899 // set to 'true' and second column requires it to be 'false'.
1900 list<list<string> > ValueCols = [];
1901 }
1902
1903 //===----------------------------------------------------------------------===//
1904 // Pull in the common support for calling conventions.
1905 //
1906 include "llvm/Target/TargetCallingConv.td"
1907
1908 //===----------------------------------------------------------------------===//
1909 // Pull in the common support for DAG isel generation.
1910 //
1911 include "llvm/Target/TargetSelectionDAG.td"
1912
1913 //===----------------------------------------------------------------------===//
1914 // Pull in the common support for Global ISel register bank info generation.
1915 //
1916 include "llvm/Target/GlobalISel/RegisterBank.td"
1917
1918 //===----------------------------------------------------------------------===//
1919 // Pull in the common support for DAG isel generation.
1920 //
1921 include "llvm/Target/GlobalISel/Target.td"
1922
1923 //===----------------------------------------------------------------------===//
1924 // Pull in the common support for the Global ISel DAG-based selector generation.
1925 //
1926 include "llvm/Target/GlobalISel/SelectionDAGCompat.td"
1927
1928 //===----------------------------------------------------------------------===//
1929 // Pull in the common support for Pfm Counters generation.
1930 //
1931 include "llvm/Target/TargetPfmCounters.td"
1932
1933 //===----------------------------------------------------------------------===//
1934 // Pull in the common support for macro fusion.
1935 //
1936 include "llvm/Target/TargetMacroFusion.td"