1//===- Target.td - Target Independent TableGen interface ---*- tablegen -*-===// 2// 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 6// 7//===----------------------------------------------------------------------===// 8// 9// This file defines the target-independent interfaces which should be 10// implemented by each target which is using a TableGen based code generator. 11// 12//===----------------------------------------------------------------------===// 13 14// Include all information about LLVM intrinsics. 15include "llvm/IR/Intrinsics.td" 16 17class Predicate; // Forward def 18 19//===----------------------------------------------------------------------===// 20// Register file description - These classes are used to fill in the target 21// description classes. 22 23class HwMode<string FS, list<Predicate> Ps> { 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. 30 string Features = FS; 31 32 // A list of predicates that turn on this HW mode. 33 list<Predicate> Predicates = Ps; 34} 35 36// A special mode recognized by tablegen. This mode is considered active 37// when no other mode is active. For targets that do not use specific hw 38// modes, this is the only mode. 39def DefaultMode : HwMode<"", []>; 40 41// A class used to associate objects with HW modes. It is only intended to 42// be used as a base class, where the derived class should contain a member 43// "Objects", which is a list of the same length as the list of modes. 44// The n-th element on the Objects list will be associated with the n-th 45// element on the Modes list. 46class HwModeSelect<list<HwMode> Ms> { 47 list<HwMode> Modes = Ms; 48} 49 50// A common class that implements a counterpart of ValueType, which is 51// dependent on a HW mode. This class inherits from ValueType itself, 52// which makes it possible to use objects of this class where ValueType 53// objects could be used. This is specifically applicable to selection 54// patterns. 55class ValueTypeByHwMode<list<HwMode> Ms, list<ValueType> Ts> 56 : HwModeSelect<Ms>, ValueType<0, 0> { 57 // The length of this list must be the same as the length of Ms. 58 list<ValueType> Objects = Ts; 59} 60 61// A class that implements a counterpart of PtrValueType, which is 62// dependent on a HW mode. This class inherits from PtrValueType itself, 63// which makes it possible to use objects of this class where PtrValueType 64// or ValueType could be used. This is specifically applicable to selection 65// patterns. 66class PtrValueTypeByHwMode<ValueTypeByHwMode scalar, int addrspace> 67 : HwModeSelect<scalar.Modes>, PtrValueType<ValueType<0, 0>, addrspace> { 68 list<ValueType> Objects = scalar.Objects; 69} 70 71// A class representing the register size, spill size and spill alignment 72// in bits of a register. 73class RegInfo<int RS, int SS, int SA> { 74 int RegSize = RS; // Register size in bits. 75 int SpillSize = SS; // Spill slot size in bits. 76 int SpillAlignment = SA; // Spill slot alignment in bits. 77} 78 79// The register size/alignment information, parameterized by a HW mode. 80class RegInfoByHwMode<list<HwMode> Ms = [], list<RegInfo> Ts = []> 81 : HwModeSelect<Ms> { 82 // The length of this list must be the same as the length of Ms. 83 list<RegInfo> Objects = Ts; 84} 85 86// SubRegIndex - Use instances of SubRegIndex to identify subregisters. 87class SubRegIndex<int size, int offset = 0> { 88 string Namespace = ""; 89 90 // Size - Size (in bits) of the sub-registers represented by this index. 91 int Size = size; 92 93 // Offset - Offset of the first bit that is part of this sub-register index. 94 // Set it to -1 if the same index is used to represent sub-registers that can 95 // be at different offsets (for example when using an index to access an 96 // element in a register tuple). 97 int Offset = offset; 98 99 // ComposedOf - A list of two SubRegIndex instances, [A, B]. 100 // This indicates that this SubRegIndex is the result of composing A and B. 101 // See ComposedSubRegIndex. 102 list<SubRegIndex> ComposedOf = []; 103 104 // CoveringSubRegIndices - A list of two or more sub-register indexes that 105 // cover this sub-register. 106 // 107 // This field should normally be left blank as TableGen can infer it. 108 // 109 // TableGen automatically detects sub-registers that straddle the registers 110 // in the SubRegs field of a Register definition. For example: 111 // 112 // Q0 = dsub_0 -> D0, dsub_1 -> D1 113 // Q1 = dsub_0 -> D2, dsub_1 -> D3 114 // D1_D2 = dsub_0 -> D1, dsub_1 -> D2 115 // QQ0 = qsub_0 -> Q0, qsub_1 -> Q1 116 // 117 // TableGen will infer that D1_D2 is a sub-register of QQ0. It will be given 118 // the synthetic index dsub_1_dsub_2 unless some SubRegIndex is defined with 119 // CoveringSubRegIndices = [dsub_1, dsub_2]. 120 list<SubRegIndex> CoveringSubRegIndices = []; 121} 122 123// ComposedSubRegIndex - A sub-register that is the result of composing A and B. 124// Offset is set to the sum of A and B's Offsets. Size is set to B's Size. 125class ComposedSubRegIndex<SubRegIndex A, SubRegIndex B> 126 : SubRegIndex<B.Size, !cond(!eq(A.Offset, -1): -1, 127 !eq(B.Offset, -1): -1, 128 true: !add(A.Offset, B.Offset))> { 129 // See SubRegIndex. 130 let ComposedOf = [A, B]; 131} 132 133// RegAltNameIndex - The alternate name set to use for register operands of 134// this register class when printing. 135class RegAltNameIndex { 136 string Namespace = ""; 137 138 // A set to be used if the name for a register is not defined in this set. 139 // This allows creating name sets with only a few alternative names. 140 RegAltNameIndex FallbackRegAltNameIndex = ?; 141} 142def NoRegAltName : RegAltNameIndex; 143 144// Register - You should define one instance of this class for each register 145// in the target machine. String n will become the "name" of the register. 146class Register<string n, list<string> altNames = []> { 147 string Namespace = ""; 148 string AsmName = n; 149 list<string> AltNames = altNames; 150 151 // Aliases - A list of registers that this register overlaps with. A read or 152 // modification of this register can potentially read or modify the aliased 153 // registers. 154 list<Register> Aliases = []; 155 156 // SubRegs - A list of registers that are parts of this register. Note these 157 // are "immediate" sub-registers and the registers within the list do not 158 // themselves overlap. e.g. For X86, EAX's SubRegs list contains only [AX], 159 // not [AX, AH, AL]. 160 list<Register> SubRegs = []; 161 162 // SubRegIndices - For each register in SubRegs, specify the SubRegIndex used 163 // to address it. Sub-sub-register indices are automatically inherited from 164 // SubRegs. 165 list<SubRegIndex> SubRegIndices = []; 166 167 // RegAltNameIndices - The alternate name indices which are valid for this 168 // register. 169 list<RegAltNameIndex> RegAltNameIndices = []; 170 171 // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register. 172 // These values can be determined by locating the <target>.h file in the 173 // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The 174 // order of these names correspond to the enumeration used by gcc. A value of 175 // -1 indicates that the gcc number is undefined and -2 that register number 176 // is invalid for this mode/flavour. 177 list<int> DwarfNumbers = []; 178 179 // CostPerUse - Additional cost of instructions using this register compared 180 // to other registers in its class. The register allocator will try to 181 // minimize the number of instructions using a register with a CostPerUse. 182 // This is used by the ARC target, by the ARM Thumb and x86-64 targets, where 183 // some registers require larger instruction encodings, by the RISC-V target, 184 // where some registers preclude using some C instructions. By making it a 185 // list, targets can have multiple cost models associated with each register 186 // and can choose one specific cost model per Machine Function by overriding 187 // TargetRegisterInfo::getRegisterCostTableIndex. Every target register will 188 // finally have an equal number of cost values which is the max of costPerUse 189 // values specified. Any mismatch in the cost values for a register will be 190 // filled with zeros. Restricted the cost type to uint8_t in the 191 // generated table. It will considerably reduce the table size. 192 list<int> CostPerUse = [0]; 193 194 // CoveredBySubRegs - When this bit is set, the value of this register is 195 // completely determined by the value of its sub-registers. For example, the 196 // x86 register AX is covered by its sub-registers AL and AH, but EAX is not 197 // covered by its sub-register AX. 198 bit CoveredBySubRegs = false; 199 200 // HWEncoding - The target specific hardware encoding for this register. 201 bits<16> HWEncoding = 0; 202 203 bit isArtificial = false; 204 205 // isConstant - This register always holds a constant value (e.g. the zero 206 // register in architectures such as MIPS) 207 bit isConstant = false; 208 209 /// PositionOrder - Indicate tablegen to place the newly added register at a later 210 /// position to avoid iterations on them on unsupported target. 211 int PositionOrder = 0; 212} 213 214// RegisterWithSubRegs - This can be used to define instances of Register which 215// need to specify sub-registers. 216// List "subregs" specifies which registers are sub-registers to this one. This 217// is used to populate the SubRegs and AliasSet fields of TargetRegisterDesc. 218// This allows the code generator to be careful not to put two values with 219// overlapping live ranges into registers which alias. 220class RegisterWithSubRegs<string n, list<Register> subregs> : Register<n> { 221 let SubRegs = subregs; 222} 223 224// DAGOperand - An empty base class that unifies RegisterClass's and other forms 225// of Operand's that are legal as type qualifiers in DAG patterns. This should 226// only ever be used for defining multiclasses that are polymorphic over both 227// RegisterClass's and other Operand's. 228class DAGOperand { 229 string OperandNamespace = "MCOI"; 230 string DecoderMethod = ""; 231} 232 233// RegisterClass - Now that all of the registers are defined, and aliases 234// between registers are defined, specify which registers belong to which 235// register classes. This also defines the default allocation order of 236// registers by register allocators. 237// 238class RegisterClass<string namespace, list<ValueType> regTypes, int alignment, 239 dag regList, RegAltNameIndex idx = NoRegAltName> 240 : DAGOperand { 241 string Namespace = namespace; 242 243 // The register size/alignment information, parameterized by a HW mode. 244 RegInfoByHwMode RegInfos; 245 246 // RegType - Specify the list ValueType of the registers in this register 247 // class. Note that all registers in a register class must have the same 248 // ValueTypes. This is a list because some targets permit storing different 249 // types in same register, for example vector values with 128-bit total size, 250 // but different count/size of items, like SSE on x86. 251 // 252 list<ValueType> RegTypes = regTypes; 253 254 // Size - Specify the spill size in bits of the registers. A default value of 255 // zero lets tablegen pick an appropriate size. 256 int Size = 0; 257 258 // Alignment - Specify the alignment required of the registers when they are 259 // stored or loaded to memory. 260 // 261 int Alignment = alignment; 262 263 // CopyCost - This value is used to specify the cost of copying a value 264 // between two registers in this register class. The default value is one 265 // meaning it takes a single instruction to perform the copying. A negative 266 // value means copying is extremely expensive or impossible. 267 int CopyCost = 1; 268 269 // MemberList - Specify which registers are in this class. If the 270 // allocation_order_* method are not specified, this also defines the order of 271 // allocation used by the register allocator. 272 // 273 dag MemberList = regList; 274 275 // AltNameIndex - The alternate register name to use when printing operands 276 // of this register class. Every register in the register class must have 277 // a valid alternate name for the given index. 278 RegAltNameIndex altNameIndex = idx; 279 280 // isAllocatable - Specify that the register class can be used for virtual 281 // registers and register allocation. Some register classes are only used to 282 // model instruction operand constraints, and should have isAllocatable = 0. 283 bit isAllocatable = true; 284 285 // AltOrders - List of alternative allocation orders. The default order is 286 // MemberList itself, and that is good enough for most targets since the 287 // register allocators automatically remove reserved registers and move 288 // callee-saved registers to the end. 289 list<dag> AltOrders = []; 290 291 // AltOrderSelect - The body of a function that selects the allocation order 292 // to use in a given machine function. The code will be inserted in a 293 // function like this: 294 // 295 // static inline unsigned f(const MachineFunction &MF) { ... } 296 // 297 // The function should return 0 to select the default order defined by 298 // MemberList, 1 to select the first AltOrders entry and so on. 299 code AltOrderSelect = [{}]; 300 301 // Specify allocation priority for register allocators using a greedy 302 // heuristic. Classes with higher priority values are assigned first. This is 303 // useful as it is sometimes beneficial to assign registers to highly 304 // constrained classes first. The value has to be in the range [0,31]. 305 int AllocationPriority = 0; 306 307 // Force register class to use greedy's global heuristic for all 308 // registers in this class. This should more aggressively try to 309 // avoid spilling in pathological cases. 310 bit GlobalPriority = false; 311 312 // Generate register pressure set for this register class and any class 313 // synthesized from it. Set to 0 to inhibit unneeded pressure sets. 314 bit GeneratePressureSet = true; 315 316 // Weight override for register pressure calculation. This is the value 317 // TargetRegisterClass::getRegClassWeight() will return. The weight is in 318 // units of pressure for this register class. If unset tablegen will 319 // calculate a weight based on a number of register units in this register 320 // class registers. The weight is per register. 321 int Weight = ?; 322 323 // The diagnostic type to present when referencing this operand in a match 324 // failure error message. If this is empty, the default Match_InvalidOperand 325 // diagnostic type will be used. If this is "<name>", a Match_<name> enum 326 // value will be generated and used for this operand type. The target 327 // assembly parser is responsible for converting this into a user-facing 328 // diagnostic message. 329 string DiagnosticType = ""; 330 331 // A diagnostic message to emit when an invalid value is provided for this 332 // register class when it is being used as an assembly operand. If this is 333 // non-empty, an anonymous diagnostic type enum value will be generated, and 334 // the assembly matcher will provide a function to map from diagnostic types 335 // to message strings. 336 string DiagnosticString = ""; 337 338 // Target-specific flags. This becomes the TSFlags field in TargetRegisterClass. 339 bits<8> TSFlags = 0; 340 341 // If set then consider this register class to be the base class for registers in 342 // its MemberList. The base class for registers present in multiple base register 343 // classes will be resolved in the order defined by this value, with lower values 344 // taking precedence over higher ones. Ties are resolved by enumeration order. 345 int BaseClassOrder = ?; 346} 347 348// The memberList in a RegisterClass is a dag of set operations. TableGen 349// evaluates these set operations and expand them into register lists. These 350// are the most common operation, see test/TableGen/SetTheory.td for more 351// examples of what is possible: 352// 353// (add R0, R1, R2) - Set Union. Each argument can be an individual register, a 354// register class, or a sub-expression. This is also the way to simply list 355// registers. 356// 357// (sub GPR, SP) - Set difference. Subtract the last arguments from the first. 358// 359// (and GPR, CSR) - Set intersection. All registers from the first set that are 360// also in the second set. 361// 362// (sequence "R%u", 0, 15) -> [R0, R1, ..., R15]. Generate a sequence of 363// numbered registers. Takes an optional 4th operand which is a stride to use 364// when generating the sequence. 365// 366// (shl GPR, 4) - Remove the first N elements. 367// 368// (trunc GPR, 4) - Truncate after the first N elements. 369// 370// (rotl GPR, 1) - Rotate N places to the left. 371// 372// (rotr GPR, 1) - Rotate N places to the right. 373// 374// (decimate GPR, 2) - Pick every N'th element, starting with the first. 375// 376// (interleave A, B, ...) - Interleave the elements from each argument list. 377// 378// All of these operators work on ordered sets, not lists. That means 379// duplicates are removed from sub-expressions. 380 381// Set operators. The rest is defined in TargetSelectionDAG.td. 382def sequence; 383def decimate; 384def interleave; 385 386// RegisterTuples - Automatically generate super-registers by forming tuples of 387// sub-registers. This is useful for modeling register sequence constraints 388// with pseudo-registers that are larger than the architectural registers. 389// 390// The sub-register lists are zipped together: 391// 392// def EvenOdd : RegisterTuples<[sube, subo], [(add R0, R2), (add R1, R3)]>; 393// 394// Generates the same registers as: 395// 396// let SubRegIndices = [sube, subo] in { 397// def R0_R1 : RegisterWithSubRegs<"", [R0, R1]>; 398// def R2_R3 : RegisterWithSubRegs<"", [R2, R3]>; 399// } 400// 401// The generated pseudo-registers inherit super-classes and fields from their 402// first sub-register. Most fields from the Register class are inferred, and 403// the AsmName and Dwarf numbers are cleared. 404// 405// RegisterTuples instances can be used in other set operations to form 406// register classes and so on. This is the only way of using the generated 407// registers. 408// 409// RegNames may be specified to supply asm names for the generated tuples. 410// If used must have the same size as the list of produced registers. 411class RegisterTuples<list<SubRegIndex> Indices, list<dag> Regs, 412 list<string> RegNames = []> { 413 // SubRegs - N lists of registers to be zipped up. Super-registers are 414 // synthesized from the first element of each SubRegs list, the second 415 // element and so on. 416 list<dag> SubRegs = Regs; 417 418 // SubRegIndices - N SubRegIndex instances. This provides the names of the 419 // sub-registers in the synthesized super-registers. 420 list<SubRegIndex> SubRegIndices = Indices; 421 422 // List of asm names for the generated tuple registers. 423 list<string> RegAsmNames = RegNames; 424 425 // PositionOrder - Indicate tablegen to place the newly added register at a later 426 // position to avoid iterations on them on unsupported target. 427 int PositionOrder = 0; 428} 429 430// RegisterCategory - This class is a list of RegisterClasses that belong to a 431// general cateogry --- e.g. "general purpose" or "fixed" registers. This is 432// useful for identifying registers in a generic way instead of having 433// information about a specific target's registers. 434class RegisterCategory<list<RegisterClass> classes> { 435 // Classes - A list of register classes that fall within the category. 436 list<RegisterClass> Classes = classes; 437} 438 439//===----------------------------------------------------------------------===// 440// DwarfRegNum - This class provides a mapping of the llvm register enumeration 441// to the register numbering used by gcc and gdb. These values are used by a 442// debug information writer to describe where values may be located during 443// execution. 444class DwarfRegNum<list<int> Numbers> { 445 // DwarfNumbers - Numbers used internally by gcc/gdb to identify the register. 446 // These values can be determined by locating the <target>.h file in the 447 // directory llvmgcc/gcc/config/<target>/ and looking for REGISTER_NAMES. The 448 // order of these names correspond to the enumeration used by gcc. A value of 449 // -1 indicates that the gcc number is undefined and -2 that register number 450 // is invalid for this mode/flavour. 451 list<int> DwarfNumbers = Numbers; 452} 453 454// DwarfRegAlias - This class declares that a given register uses the same dwarf 455// numbers as another one. This is useful for making it clear that the two 456// registers do have the same number. It also lets us build a mapping 457// from dwarf register number to llvm register. 458class DwarfRegAlias<Register reg> { 459 Register DwarfAlias = reg; 460} 461 462//===----------------------------------------------------------------------===// 463// Pull in the common support for MCPredicate (portable scheduling predicates). 464// 465include "llvm/Target/TargetInstrPredicate.td" 466 467//===----------------------------------------------------------------------===// 468// Pull in the common support for scheduling 469// 470include "llvm/Target/TargetSchedule.td" 471 472class InstructionEncoding { 473 // Size of encoded instruction. 474 int Size; 475 476 // The "namespace" in which this instruction exists, on targets like ARM 477 // which multiple ISA namespaces exist. 478 string DecoderNamespace = ""; 479 480 // List of predicates which will be turned into isel matching code. 481 list<Predicate> Predicates = []; 482 483 string DecoderMethod = ""; 484 485 // Is the instruction decoder method able to completely determine if the 486 // given instruction is valid or not. If the TableGen definition of the 487 // instruction specifies bitpattern A??B where A and B are static bits, the 488 // hasCompleteDecoder flag says whether the decoder method fully handles the 489 // ?? space, i.e. if it is a final arbiter for the instruction validity. 490 // If not then the decoder attempts to continue decoding when the decoder 491 // method fails. 492 // 493 // This allows to handle situations where the encoding is not fully 494 // orthogonal. Example: 495 // * InstA with bitpattern 0b0000????, 496 // * InstB with bitpattern 0b000000?? but the associated decoder method 497 // DecodeInstB() returns Fail when ?? is 0b00 or 0b11. 498 // 499 // The decoder tries to decode a bitpattern that matches both InstA and 500 // InstB bitpatterns first as InstB (because it is the most specific 501 // encoding). In the default case (hasCompleteDecoder = 1), when 502 // DecodeInstB() returns Fail the bitpattern gets rejected. By setting 503 // hasCompleteDecoder = 0 in InstB, the decoder is informed that 504 // DecodeInstB() is not able to determine if all possible values of ?? are 505 // valid or not. If DecodeInstB() returns Fail the decoder will attempt to 506 // decode the bitpattern as InstA too. 507 bit hasCompleteDecoder = true; 508} 509 510// Allows specifying an InstructionEncoding by HwMode. If an Instruction specifies 511// an EncodingByHwMode, its Inst and Size members are ignored and Ts are used 512// to encode and decode based on HwMode. 513class EncodingByHwMode<list<HwMode> Ms = [], list<InstructionEncoding> Ts = []> 514 : HwModeSelect<Ms> { 515 // The length of this list must be the same as the length of Ms. 516 list<InstructionEncoding> Objects = Ts; 517} 518 519//===----------------------------------------------------------------------===// 520// Instruction set description - These classes correspond to the C++ classes in 521// the Target/TargetInstrInfo.h file. 522// 523class Instruction : InstructionEncoding { 524 string Namespace = ""; 525 526 dag OutOperandList; // An dag containing the MI def operand list. 527 dag InOperandList; // An dag containing the MI use operand list. 528 string AsmString = ""; // The .s format to print the instruction with. 529 530 // Allows specifying a canonical InstructionEncoding by HwMode. If non-empty, 531 // the Inst member of this Instruction is ignored. 532 EncodingByHwMode EncodingInfos; 533 534 // Pattern - Set to the DAG pattern for this instruction, if we know of one, 535 // otherwise, uninitialized. 536 list<dag> Pattern; 537 538 // The follow state will eventually be inferred automatically from the 539 // instruction pattern. 540 541 list<Register> Uses = []; // Default to using no non-operand registers 542 list<Register> Defs = []; // Default to modifying no non-operand registers 543 544 // Predicates - List of predicates which will be turned into isel matching 545 // code. 546 list<Predicate> Predicates = []; 547 548 // Size - Size of encoded instruction, or zero if the size cannot be determined 549 // from the opcode. 550 int Size = 0; 551 552 // Code size, for instruction selection. 553 // FIXME: What does this actually mean? 554 int CodeSize = 0; 555 556 // Added complexity passed onto matching pattern. 557 int AddedComplexity = 0; 558 559 // Indicates if this is a pre-isel opcode that should be 560 // legalized/regbankselected/selected. 561 bit isPreISelOpcode = false; 562 563 // These bits capture information about the high-level semantics of the 564 // instruction. 565 bit isReturn = false; // Is this instruction a return instruction? 566 bit isBranch = false; // Is this instruction a branch instruction? 567 bit isEHScopeReturn = false; // Does this instruction end an EH scope? 568 bit isIndirectBranch = false; // Is this instruction an indirect branch? 569 bit isCompare = false; // Is this instruction a comparison instruction? 570 bit isMoveImm = false; // Is this instruction a move immediate instruction? 571 bit isMoveReg = false; // Is this instruction a move register instruction? 572 bit isBitcast = false; // Is this instruction a bitcast instruction? 573 bit isSelect = false; // Is this instruction a select instruction? 574 bit isBarrier = false; // Can control flow fall through this instruction? 575 bit isCall = false; // Is this instruction a call instruction? 576 bit isAdd = false; // Is this instruction an add instruction? 577 bit isTrap = false; // Is this instruction a trap instruction? 578 bit canFoldAsLoad = false; // Can this be folded as a simple memory operand? 579 bit mayLoad = ?; // Is it possible for this inst to read memory? 580 bit mayStore = ?; // Is it possible for this inst to write memory? 581 bit mayRaiseFPException = false; // Can this raise a floating-point exception? 582 bit isConvertibleToThreeAddress = false; // Can this 2-addr instruction promote? 583 bit isCommutable = false; // Is this 3 operand instruction commutable? 584 bit isTerminator = false; // Is this part of the terminator for a basic block? 585 bit isReMaterializable = false; // Is this instruction re-materializable? 586 bit isPredicable = false; // 1 means this instruction is predicable 587 // even if it does not have any operand 588 // tablegen can identify as a predicate 589 bit isUnpredicable = false; // 1 means this instruction is not predicable 590 // even if it _does_ have a predicate operand 591 bit hasDelaySlot = false; // Does this instruction have an delay slot? 592 bit usesCustomInserter = false; // Pseudo instr needing special help. 593 bit hasPostISelHook = false; // To be *adjusted* after isel by target hook. 594 bit hasCtrlDep = false; // Does this instruction r/w ctrl-flow chains? 595 bit isNotDuplicable = false; // Is it unsafe to duplicate this instruction? 596 bit isConvergent = false; // Is this instruction convergent? 597 bit isAuthenticated = false; // Does this instruction authenticate a pointer? 598 bit isAsCheapAsAMove = false; // As cheap (or cheaper) than a move instruction. 599 bit hasExtraSrcRegAllocReq = false; // Sources have special regalloc requirement? 600 bit hasExtraDefRegAllocReq = false; // Defs have special regalloc requirement? 601 bit isRegSequence = false; // Is this instruction a kind of reg sequence? 602 // If so, make sure to override 603 // TargetInstrInfo::getRegSequenceLikeInputs. 604 bit isPseudo = false; // Is this instruction a pseudo-instruction? 605 // If so, won't have encoding information for 606 // the [MC]CodeEmitter stuff. 607 bit isMeta = false; // Is this instruction a meta-instruction? 608 // If so, won't produce any output in the form of 609 // executable instructions 610 bit isExtractSubreg = false; // Is this instruction a kind of extract subreg? 611 // If so, make sure to override 612 // TargetInstrInfo::getExtractSubregLikeInputs. 613 bit isInsertSubreg = false; // Is this instruction a kind of insert subreg? 614 // If so, make sure to override 615 // TargetInstrInfo::getInsertSubregLikeInputs. 616 bit variadicOpsAreDefs = false; // Are variadic operands definitions? 617 618 // Does the instruction have side effects that are not captured by any 619 // operands of the instruction or other flags? 620 bit hasSideEffects = ?; 621 622 // Is this instruction a "real" instruction (with a distinct machine 623 // encoding), or is it a pseudo instruction used for codegen modeling 624 // purposes. 625 // FIXME: For now this is distinct from isPseudo, above, as code-gen-only 626 // instructions can (and often do) still have encoding information 627 // associated with them. Once we've migrated all of them over to true 628 // pseudo-instructions that are lowered to real instructions prior to 629 // the printer/emitter, we can remove this attribute and just use isPseudo. 630 // 631 // The intended use is: 632 // isPseudo: Does not have encoding information and should be expanded, 633 // at the latest, during lowering to MCInst. 634 // 635 // isCodeGenOnly: Does have encoding information and can go through to the 636 // CodeEmitter unchanged, but duplicates a canonical instruction 637 // definition's encoding and should be ignored when constructing the 638 // assembler match tables. 639 bit isCodeGenOnly = false; 640 641 // Is this instruction a pseudo instruction for use by the assembler parser. 642 bit isAsmParserOnly = false; 643 644 // This instruction is not expected to be queried for scheduling latencies 645 // and therefore needs no scheduling information even for a complete 646 // scheduling model. 647 bit hasNoSchedulingInfo = false; 648 649 InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling. 650 651 // Scheduling information from TargetSchedule.td. 652 list<SchedReadWrite> SchedRW; 653 654 string Constraints = ""; // OperandConstraint, e.g. $src = $dst. 655 656 /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not 657 /// be encoded into the output machineinstr. 658 string DisableEncoding = ""; 659 660 string PostEncoderMethod = ""; 661 662 /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc. 663 bits<64> TSFlags = 0; 664 665 ///@name Assembler Parser Support 666 ///@{ 667 668 string AsmMatchConverter = ""; 669 670 /// TwoOperandAliasConstraint - Enable TableGen to auto-generate a 671 /// two-operand matcher inst-alias for a three operand instruction. 672 /// For example, the arm instruction "add r3, r3, r5" can be written 673 /// as "add r3, r5". The constraint is of the same form as a tied-operand 674 /// constraint. For example, "$Rn = $Rd". 675 string TwoOperandAliasConstraint = ""; 676 677 /// Assembler variant name to use for this instruction. If specified then 678 /// instruction will be presented only in MatchTable for this variant. If 679 /// not specified then assembler variants will be determined based on 680 /// AsmString 681 string AsmVariantName = ""; 682 683 ///@} 684 685 /// UseNamedOperandTable - If set, the operand indices of this instruction 686 /// can be queried via the getNamedOperandIdx() function which is generated 687 /// by TableGen. 688 bit UseNamedOperandTable = false; 689 690 /// Should generate helper functions that help you to map a logical operand's 691 /// index to the underlying MIOperand's index. 692 /// In most architectures logical operand indicies are equal to 693 /// MIOperand indicies, but for some CISC architectures, a logical operand 694 /// might be consist of multiple MIOperand (e.g. a logical operand that 695 /// uses complex address mode). 696 bit UseLogicalOperandMappings = false; 697 698 /// Should FastISel ignore this instruction. For certain ISAs, they have 699 /// instructions which map to the same ISD Opcode, value type operands and 700 /// instruction selection predicates. FastISel cannot handle such cases, but 701 /// SelectionDAG can. 702 bit FastISelShouldIgnore = false; 703 704 /// HasPositionOrder: Indicate tablegen to sort the instructions by record 705 /// ID, so that instruction that is defined earlier can be sorted earlier 706 /// in the assembly matching table. 707 bit HasPositionOrder = false; 708} 709 710/// Defines a Pat match between compressed and uncompressed instruction. 711/// The relationship and helper function generation are handled by 712/// CompressInstEmitter backend. 713class CompressPat<dag input, dag output, list<Predicate> predicates = []> { 714 /// Uncompressed instruction description. 715 dag Input = input; 716 /// Compressed instruction description. 717 dag Output = output; 718 /// Predicates that must be true for this to match. 719 list<Predicate> Predicates = predicates; 720 /// Duplicate match when tied operand is just different. 721 bit isCompressOnly = false; 722} 723 724/// Defines an additional encoding that disassembles to the given instruction 725/// Like Instruction, the Inst and SoftFail fields are omitted to allow targets 726// to specify their size. 727class AdditionalEncoding<Instruction I> : InstructionEncoding { 728 Instruction AliasOf = I; 729} 730 731/// PseudoInstExpansion - Expansion information for a pseudo-instruction. 732/// Which instruction it expands to and how the operands map from the 733/// pseudo. 734class PseudoInstExpansion<dag Result> { 735 dag ResultInst = Result; // The instruction to generate. 736 bit isPseudo = true; 737} 738 739/// Predicates - These are extra conditionals which are turned into instruction 740/// selector matching code. Currently each predicate is just a string. 741class Predicate<string cond> { 742 string CondString = cond; 743 744 /// AssemblerMatcherPredicate - If this feature can be used by the assembler 745 /// matcher, this is true. Targets should set this by inheriting their 746 /// feature from the AssemblerPredicate class in addition to Predicate. 747 bit AssemblerMatcherPredicate = false; 748 749 /// AssemblerCondDag - Set of subtarget features being tested used 750 /// as alternative condition string used for assembler matcher. Must be used 751 /// with (all_of) to indicate that all features must be present, or (any_of) 752 /// to indicate that at least one must be. The required lack of presence of 753 /// a feature can be tested using a (not) node including the feature. 754 /// e.g. "(all_of ModeThumb)" is translated to "(Bits & ModeThumb) != 0". 755 /// "(all_of (not ModeThumb))" is translated to 756 /// "(Bits & ModeThumb) == 0". 757 /// "(all_of ModeThumb, FeatureThumb2)" is translated to 758 /// "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0". 759 /// "(any_of ModeTumb, FeatureThumb2)" is translated to 760 /// "(Bits & ModeThumb) != 0 || (Bits & FeatureThumb2) != 0". 761 /// all_of and any_of cannot be combined in a single dag, instead multiple 762 /// predicates can be placed onto Instruction definitions. 763 dag AssemblerCondDag; 764 765 /// PredicateName - User-level name to use for the predicate. Mainly for use 766 /// in diagnostics such as missing feature errors in the asm matcher. 767 string PredicateName = ""; 768 769 /// Setting this to '1' indicates that the predicate must be recomputed on 770 /// every function change. Most predicates can leave this at '0'. 771 /// 772 /// Ignored by SelectionDAG, it always recomputes the predicate on every use. 773 bit RecomputePerFunction = false; 774} 775 776/// NoHonorSignDependentRounding - This predicate is true if support for 777/// sign-dependent-rounding is not enabled. 778def NoHonorSignDependentRounding 779 : Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">; 780 781class Requires<list<Predicate> preds> { 782 list<Predicate> Predicates = preds; 783} 784 785/// ops definition - This is just a simple marker used to identify the operand 786/// list for an instruction. outs and ins are identical both syntactically and 787/// semantically; they are used to define def operands and use operands to 788/// improve readability. This should be used like this: 789/// (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar. 790def ops; 791def outs; 792def ins; 793 794/// variable_ops definition - Mark this instruction as taking a variable number 795/// of operands. 796def variable_ops; 797 798/// variable-length instruction encoding utilities. 799/// The `ascend` operator should be used like this: 800/// (ascend 0b0010, 0b1101) 801/// Which represent a seqence of encoding fragments placing from LSB to MSB. 802/// Thus, in this case the final encoding will be 0b1101_0010. 803/// The arguments for `ascend` can either be `bits` or another DAG. 804def ascend; 805/// In addition, we can use `descend` to describe an encoding that places 806/// its arguments (i.e. encoding fragments) from MSB to LSB. For instance: 807/// (descend 0b0010, 0b1101) 808/// This results in an encoding of 0b0010_1101. 809def descend; 810/// The `operand` operator should be used like this: 811/// (operand "$src", 4) 812/// Which represents a 4-bit encoding for an instruction operand named `$src`. 813def operand; 814/// Similar to `operand`, we can reference only part of the operand's encoding: 815/// (slice "$src", 6, 8) 816/// (slice "$src", 8, 6) 817/// Both DAG represent bit 6 to 8 (total of 3 bits) in the encoding of operand 818/// `$src`. 819def slice; 820/// You can use `encoder` or `decoder` to specify a custom encoder or decoder 821/// function for a specific `operand` or `slice` directive. For example: 822/// (operand "$src", 4, (encoder "encodeMyImm")) 823/// (slice "$src", 8, 6, (encoder "encodeMyReg")) 824/// (operand "$src", 4, (encoder "encodeMyImm"), (decoder "decodeMyImm")) 825/// The ordering of `encoder` and `decoder` in the same `operand` or `slice` 826/// doesn't matter. 827/// Note that currently we cannot assign different decoders in the same 828/// (instruction) operand. 829def encoder; 830def decoder; 831 832/// PointerLikeRegClass - Values that are designed to have pointer width are 833/// derived from this. TableGen treats the register class as having a symbolic 834/// type that it doesn't know, and resolves the actual regclass to use by using 835/// the TargetRegisterInfo::getPointerRegClass() hook at codegen time. 836class PointerLikeRegClass<int Kind> { 837 int RegClassKind = Kind; 838} 839 840 841/// ptr_rc definition - Mark this operand as being a pointer value whose 842/// register class is resolved dynamically via a callback to TargetInstrInfo. 843/// FIXME: We should probably change this to a class which contain a list of 844/// flags. But currently we have but one flag. 845def ptr_rc : PointerLikeRegClass<0>; 846 847/// unknown definition - Mark this operand as being of unknown type, causing 848/// it to be resolved by inference in the context it is used. 849class unknown_class; 850def unknown : unknown_class; 851 852/// AsmOperandClass - Representation for the kinds of operands which the target 853/// specific parser can create and the assembly matcher may need to distinguish. 854/// 855/// Operand classes are used to define the order in which instructions are 856/// matched, to ensure that the instruction which gets matched for any 857/// particular list of operands is deterministic. 858/// 859/// The target specific parser must be able to classify a parsed operand into a 860/// unique class which does not partially overlap with any other classes. It can 861/// match a subset of some other class, in which case the super class field 862/// should be defined. 863class AsmOperandClass { 864 /// The name to use for this class, which should be usable as an enum value. 865 string Name = ?; 866 867 /// The super classes of this operand. 868 list<AsmOperandClass> SuperClasses = []; 869 870 /// The name of the method on the target specific operand to call to test 871 /// whether the operand is an instance of this class. If not set, this will 872 /// default to "isFoo", where Foo is the AsmOperandClass name. The method 873 /// signature should be: 874 /// bool isFoo() const; 875 string PredicateMethod = ?; 876 877 /// The name of the method on the target specific operand to call to add the 878 /// target specific operand to an MCInst. If not set, this will default to 879 /// "addFooOperands", where Foo is the AsmOperandClass name. The method 880 /// signature should be: 881 /// void addFooOperands(MCInst &Inst, unsigned N) const; 882 string RenderMethod = ?; 883 884 /// The name of the method on the target specific operand to call to custom 885 /// handle the operand parsing. This is useful when the operands do not relate 886 /// to immediates or registers and are very instruction specific (as flags to 887 /// set in a processor register, coprocessor number, ...). 888 string ParserMethod = ?; 889 890 // The diagnostic type to present when referencing this operand in a 891 // match failure error message. By default, use a generic "invalid operand" 892 // diagnostic. The target AsmParser maps these codes to text. 893 string DiagnosticType = ""; 894 895 /// A diagnostic message to emit when an invalid value is provided for this 896 /// operand. 897 string DiagnosticString = ""; 898 899 /// Set to 1 if this operand is optional and not always required. Typically, 900 /// the AsmParser will emit an error when it finishes parsing an 901 /// instruction if it hasn't matched all the operands yet. However, this 902 /// error will be suppressed if all of the remaining unmatched operands are 903 /// marked as IsOptional. 904 /// 905 /// Optional arguments must be at the end of the operand list. 906 bit IsOptional = false; 907 908 /// The name of the method on the target specific asm parser that returns the 909 /// default operand for this optional operand. This method is only used if 910 /// IsOptional == 1. If not set, this will default to "defaultFooOperands", 911 /// where Foo is the AsmOperandClass name. The method signature should be: 912 /// std::unique_ptr<MCParsedAsmOperand> defaultFooOperands() const; 913 string DefaultMethod = ?; 914} 915 916def ImmAsmOperand : AsmOperandClass { 917 let Name = "Imm"; 918} 919 920/// Operand Types - These provide the built-in operand types that may be used 921/// by a target. Targets can optionally provide their own operand types as 922/// needed, though this should not be needed for RISC targets. 923class Operand<ValueType ty> : DAGOperand { 924 ValueType Type = ty; 925 string PrintMethod = "printOperand"; 926 string EncoderMethod = ""; 927 bit hasCompleteDecoder = true; 928 string OperandType = "OPERAND_UNKNOWN"; 929 dag MIOperandInfo = (ops); 930 931 // MCOperandPredicate - Optionally, a code fragment operating on 932 // const MCOperand &MCOp, and returning a bool, to indicate if 933 // the value of MCOp is valid for the specific subclass of Operand 934 code MCOperandPredicate; 935 936 // ParserMatchClass - The "match class" that operands of this type fit 937 // in. Match classes are used to define the order in which instructions are 938 // match, to ensure that which instructions gets matched is deterministic. 939 // 940 // The target specific parser must be able to classify an parsed operand into 941 // a unique class, which does not partially overlap with any other classes. It 942 // can match a subset of some other class, in which case the AsmOperandClass 943 // should declare the other operand as one of its super classes. 944 AsmOperandClass ParserMatchClass = ImmAsmOperand; 945} 946 947class RegisterOperand<RegisterClass regclass, string pm = "printOperand"> 948 : DAGOperand { 949 // RegClass - The register class of the operand. 950 RegisterClass RegClass = regclass; 951 // PrintMethod - The target method to call to print register operands of 952 // this type. The method normally will just use an alt-name index to look 953 // up the name to print. Default to the generic printOperand(). 954 string PrintMethod = pm; 955 956 // EncoderMethod - The target method name to call to encode this register 957 // operand. 958 string EncoderMethod = ""; 959 960 // ParserMatchClass - The "match class" that operands of this type fit 961 // in. Match classes are used to define the order in which instructions are 962 // match, to ensure that which instructions gets matched is deterministic. 963 // 964 // The target specific parser must be able to classify an parsed operand into 965 // a unique class, which does not partially overlap with any other classes. It 966 // can match a subset of some other class, in which case the AsmOperandClass 967 // should declare the other operand as one of its super classes. 968 AsmOperandClass ParserMatchClass; 969 970 string OperandType = "OPERAND_REGISTER"; 971 972 // When referenced in the result of a CodeGen pattern, GlobalISel will 973 // normally copy the matched operand to the result. When this is set, it will 974 // emit a special copy that will replace zero-immediates with the specified 975 // zero-register. 976 Register GIZeroRegister = ?; 977} 978 979let OperandType = "OPERAND_IMMEDIATE" in { 980def i1imm : Operand<i1>; 981def i8imm : Operand<i8>; 982def i16imm : Operand<i16>; 983def i32imm : Operand<i32>; 984def i64imm : Operand<i64>; 985 986def f32imm : Operand<f32>; 987def f64imm : Operand<f64>; 988} 989 990// Register operands for generic instructions don't have an MVT, but do have 991// constraints linking the operands (e.g. all operands of a G_ADD must 992// have the same LLT). 993class TypedOperand<string Ty> : Operand<untyped> { 994 let OperandType = Ty; 995 bit IsPointer = false; 996 bit IsImmediate = false; 997} 998 999def type0 : TypedOperand<"OPERAND_GENERIC_0">; 1000def type1 : TypedOperand<"OPERAND_GENERIC_1">; 1001def type2 : TypedOperand<"OPERAND_GENERIC_2">; 1002def type3 : TypedOperand<"OPERAND_GENERIC_3">; 1003def type4 : TypedOperand<"OPERAND_GENERIC_4">; 1004def type5 : TypedOperand<"OPERAND_GENERIC_5">; 1005 1006let IsPointer = true in { 1007 def ptype0 : TypedOperand<"OPERAND_GENERIC_0">; 1008 def ptype1 : TypedOperand<"OPERAND_GENERIC_1">; 1009 def ptype2 : TypedOperand<"OPERAND_GENERIC_2">; 1010 def ptype3 : TypedOperand<"OPERAND_GENERIC_3">; 1011 def ptype4 : TypedOperand<"OPERAND_GENERIC_4">; 1012 def ptype5 : TypedOperand<"OPERAND_GENERIC_5">; 1013} 1014 1015// untyped_imm is for operands where isImm() will be true. It currently has no 1016// special behaviour and is only used for clarity. 1017def untyped_imm_0 : TypedOperand<"OPERAND_GENERIC_IMM_0"> { 1018 let IsImmediate = true; 1019} 1020 1021/// zero_reg definition - Special node to stand for the zero register. 1022/// 1023def zero_reg; 1024 1025/// undef_tied_input - Special node to indicate an input register tied 1026/// to an output which defaults to IMPLICIT_DEF. 1027def undef_tied_input; 1028 1029/// All operands which the MC layer classifies as predicates should inherit from 1030/// this class in some manner. This is already handled for the most commonly 1031/// used PredicateOperand, but may be useful in other circumstances. 1032class PredicateOp; 1033 1034/// OperandWithDefaultOps - This Operand class can be used as the parent class 1035/// for an Operand that needs to be initialized with a default value if 1036/// no value is supplied in a pattern. This class can be used to simplify the 1037/// pattern definitions for instructions that have target specific flags 1038/// encoded as immediate operands. 1039class OperandWithDefaultOps<ValueType ty, dag defaultops> 1040 : Operand<ty> { 1041 dag DefaultOps = defaultops; 1042} 1043 1044/// PredicateOperand - This can be used to define a predicate operand for an 1045/// instruction. OpTypes specifies the MIOperandInfo for the operand, and 1046/// AlwaysVal specifies the value of this predicate when set to "always 1047/// execute". 1048class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal> 1049 : OperandWithDefaultOps<ty, AlwaysVal>, PredicateOp { 1050 let MIOperandInfo = OpTypes; 1051} 1052 1053/// OptionalDefOperand - This is used to define a optional definition operand 1054/// for an instruction. DefaultOps is the register the operand represents if 1055/// none is supplied, e.g. zero_reg. 1056class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops> 1057 : OperandWithDefaultOps<ty, defaultops> { 1058 let MIOperandInfo = OpTypes; 1059} 1060 1061 1062// InstrInfo - This class should only be instantiated once to provide parameters 1063// which are global to the target machine. 1064// 1065class InstrInfo { 1066 // Target can specify its instructions in either big or little-endian formats. 1067 // For instance, while both Sparc and PowerPC are big-endian platforms, the 1068 // Sparc manual specifies its instructions in the format [31..0] (big), while 1069 // PowerPC specifies them using the format [0..31] (little). 1070 bit isLittleEndianEncoding = false; 1071 1072 // The instruction properties mayLoad, mayStore, and hasSideEffects are unset 1073 // by default, and TableGen will infer their value from the instruction 1074 // pattern when possible. 1075 // 1076 // Normally, TableGen will issue an error if it can't infer the value of a 1077 // property that hasn't been set explicitly. When guessInstructionProperties 1078 // is set, it will guess a safe value instead. 1079 // 1080 // This option is a temporary migration help. It will go away. 1081 bit guessInstructionProperties = true; 1082} 1083 1084// Standard Pseudo Instructions. 1085// This list must match TargetOpcodes.def. 1086// Only these instructions are allowed in the TargetOpcode namespace. 1087// Ensure mayLoad and mayStore have a default value, so as not to break 1088// targets that set guessInstructionProperties=0. Any local definition of 1089// mayLoad/mayStore takes precedence over these default values. 1090class StandardPseudoInstruction : Instruction { 1091 let mayLoad = false; 1092 let mayStore = false; 1093 let isCodeGenOnly = true; 1094 let isPseudo = true; 1095 let hasNoSchedulingInfo = true; 1096 let Namespace = "TargetOpcode"; 1097} 1098def PHI : StandardPseudoInstruction { 1099 let OutOperandList = (outs unknown:$dst); 1100 let InOperandList = (ins variable_ops); 1101 let AsmString = "PHINODE"; 1102 let hasSideEffects = false; 1103} 1104def INLINEASM : StandardPseudoInstruction { 1105 let OutOperandList = (outs); 1106 let InOperandList = (ins variable_ops); 1107 let AsmString = ""; 1108 let hasSideEffects = false; // Note side effect is encoded in an operand. 1109} 1110def INLINEASM_BR : StandardPseudoInstruction { 1111 let OutOperandList = (outs); 1112 let InOperandList = (ins variable_ops); 1113 let AsmString = ""; 1114 // Unlike INLINEASM, this is always treated as having side-effects. 1115 let hasSideEffects = true; 1116 // Despite potentially branching, this instruction is intentionally _not_ 1117 // marked as a terminator or a branch. 1118} 1119def CFI_INSTRUCTION : StandardPseudoInstruction { 1120 let OutOperandList = (outs); 1121 let InOperandList = (ins i32imm:$id); 1122 let AsmString = ""; 1123 let hasCtrlDep = true; 1124 let hasSideEffects = false; 1125 let isNotDuplicable = true; 1126 let isMeta = true; 1127} 1128def EH_LABEL : StandardPseudoInstruction { 1129 let OutOperandList = (outs); 1130 let InOperandList = (ins i32imm:$id); 1131 let AsmString = ""; 1132 let hasCtrlDep = true; 1133 let hasSideEffects = false; 1134 let isNotDuplicable = true; 1135 let isMeta = true; 1136} 1137def GC_LABEL : StandardPseudoInstruction { 1138 let OutOperandList = (outs); 1139 let InOperandList = (ins i32imm:$id); 1140 let AsmString = ""; 1141 let hasCtrlDep = true; 1142 let hasSideEffects = false; 1143 let isNotDuplicable = true; 1144 let isMeta = true; 1145} 1146def ANNOTATION_LABEL : StandardPseudoInstruction { 1147 let OutOperandList = (outs); 1148 let InOperandList = (ins i32imm:$id); 1149 let AsmString = ""; 1150 let hasCtrlDep = true; 1151 let hasSideEffects = false; 1152 let isNotDuplicable = true; 1153} 1154def KILL : StandardPseudoInstruction { 1155 let OutOperandList = (outs); 1156 let InOperandList = (ins variable_ops); 1157 let AsmString = ""; 1158 let hasSideEffects = false; 1159 let isMeta = true; 1160} 1161def EXTRACT_SUBREG : StandardPseudoInstruction { 1162 let OutOperandList = (outs unknown:$dst); 1163 let InOperandList = (ins unknown:$supersrc, i32imm:$subidx); 1164 let AsmString = ""; 1165 let hasSideEffects = false; 1166} 1167def INSERT_SUBREG : StandardPseudoInstruction { 1168 let OutOperandList = (outs unknown:$dst); 1169 let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx); 1170 let AsmString = ""; 1171 let hasSideEffects = false; 1172 let Constraints = "$supersrc = $dst"; 1173} 1174def IMPLICIT_DEF : StandardPseudoInstruction { 1175 let OutOperandList = (outs unknown:$dst); 1176 let InOperandList = (ins); 1177 let AsmString = ""; 1178 let hasSideEffects = false; 1179 let isReMaterializable = true; 1180 let isAsCheapAsAMove = true; 1181 let isMeta = true; 1182} 1183def SUBREG_TO_REG : StandardPseudoInstruction { 1184 let OutOperandList = (outs unknown:$dst); 1185 let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx); 1186 let AsmString = ""; 1187 let hasSideEffects = false; 1188} 1189def COPY_TO_REGCLASS : StandardPseudoInstruction { 1190 let OutOperandList = (outs unknown:$dst); 1191 let InOperandList = (ins unknown:$src, i32imm:$regclass); 1192 let AsmString = ""; 1193 let hasSideEffects = false; 1194 let isAsCheapAsAMove = true; 1195} 1196def DBG_VALUE : StandardPseudoInstruction { 1197 let OutOperandList = (outs); 1198 let InOperandList = (ins variable_ops); 1199 let AsmString = "DBG_VALUE"; 1200 let hasSideEffects = false; 1201 let isMeta = true; 1202} 1203def DBG_VALUE_LIST : StandardPseudoInstruction { 1204 let OutOperandList = (outs); 1205 let InOperandList = (ins variable_ops); 1206 let AsmString = "DBG_VALUE_LIST"; 1207 let hasSideEffects = 0; 1208 let isMeta = true; 1209} 1210def DBG_INSTR_REF : StandardPseudoInstruction { 1211 let OutOperandList = (outs); 1212 let InOperandList = (ins variable_ops); 1213 let AsmString = "DBG_INSTR_REF"; 1214 let hasSideEffects = false; 1215 let isMeta = true; 1216} 1217def DBG_PHI : StandardPseudoInstruction { 1218 let OutOperandList = (outs); 1219 let InOperandList = (ins variable_ops); 1220 let AsmString = "DBG_PHI"; 1221 let hasSideEffects = 0; 1222 let isMeta = true; 1223} 1224def DBG_LABEL : StandardPseudoInstruction { 1225 let OutOperandList = (outs); 1226 let InOperandList = (ins unknown:$label); 1227 let AsmString = "DBG_LABEL"; 1228 let hasSideEffects = false; 1229 let isMeta = true; 1230} 1231def REG_SEQUENCE : StandardPseudoInstruction { 1232 let OutOperandList = (outs unknown:$dst); 1233 let InOperandList = (ins unknown:$supersrc, variable_ops); 1234 let AsmString = ""; 1235 let hasSideEffects = false; 1236 let isAsCheapAsAMove = true; 1237} 1238def COPY : StandardPseudoInstruction { 1239 let OutOperandList = (outs unknown:$dst); 1240 let InOperandList = (ins unknown:$src); 1241 let AsmString = ""; 1242 let hasSideEffects = false; 1243 let isAsCheapAsAMove = true; 1244 let hasNoSchedulingInfo = false; 1245} 1246def BUNDLE : StandardPseudoInstruction { 1247 let OutOperandList = (outs); 1248 let InOperandList = (ins variable_ops); 1249 let AsmString = "BUNDLE"; 1250 let hasSideEffects = false; 1251} 1252def LIFETIME_START : StandardPseudoInstruction { 1253 let OutOperandList = (outs); 1254 let InOperandList = (ins i32imm:$id); 1255 let AsmString = "LIFETIME_START"; 1256 let hasSideEffects = false; 1257 let isMeta = true; 1258} 1259def LIFETIME_END : StandardPseudoInstruction { 1260 let OutOperandList = (outs); 1261 let InOperandList = (ins i32imm:$id); 1262 let AsmString = "LIFETIME_END"; 1263 let hasSideEffects = false; 1264 let isMeta = true; 1265} 1266def PSEUDO_PROBE : StandardPseudoInstruction { 1267 let OutOperandList = (outs); 1268 let InOperandList = (ins i64imm:$guid, i64imm:$index, i8imm:$type, i32imm:$attr); 1269 let AsmString = "PSEUDO_PROBE"; 1270 let hasSideEffects = 1; 1271 let isMeta = true; 1272} 1273def ARITH_FENCE : StandardPseudoInstruction { 1274 let OutOperandList = (outs unknown:$dst); 1275 let InOperandList = (ins unknown:$src); 1276 let AsmString = ""; 1277 let hasSideEffects = false; 1278 let Constraints = "$src = $dst"; 1279 let isMeta = true; 1280} 1281 1282def STACKMAP : StandardPseudoInstruction { 1283 let OutOperandList = (outs); 1284 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops); 1285 let hasSideEffects = true; 1286 let isCall = true; 1287 let mayLoad = true; 1288 let usesCustomInserter = true; 1289} 1290def PATCHPOINT : StandardPseudoInstruction { 1291 let OutOperandList = (outs unknown:$dst); 1292 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee, 1293 i32imm:$nargs, i32imm:$cc, variable_ops); 1294 let hasSideEffects = true; 1295 let isCall = true; 1296 let mayLoad = true; 1297 let usesCustomInserter = true; 1298} 1299def STATEPOINT : StandardPseudoInstruction { 1300 let OutOperandList = (outs variable_ops); 1301 let InOperandList = (ins variable_ops); 1302 let usesCustomInserter = true; 1303 let mayLoad = true; 1304 let mayStore = true; 1305 let hasSideEffects = true; 1306 let isCall = true; 1307} 1308def LOAD_STACK_GUARD : StandardPseudoInstruction { 1309 let OutOperandList = (outs ptr_rc:$dst); 1310 let InOperandList = (ins); 1311 let mayLoad = true; 1312 bit isReMaterializable = true; 1313 let hasSideEffects = false; 1314 bit isPseudo = true; 1315} 1316def PREALLOCATED_SETUP : StandardPseudoInstruction { 1317 let OutOperandList = (outs); 1318 let InOperandList = (ins i32imm:$a); 1319 let usesCustomInserter = true; 1320 let hasSideEffects = true; 1321} 1322def PREALLOCATED_ARG : StandardPseudoInstruction { 1323 let OutOperandList = (outs ptr_rc:$loc); 1324 let InOperandList = (ins i32imm:$a, i32imm:$b); 1325 let usesCustomInserter = true; 1326 let hasSideEffects = true; 1327} 1328def LOCAL_ESCAPE : StandardPseudoInstruction { 1329 // This instruction is really just a label. It has to be part of the chain so 1330 // that it doesn't get dropped from the DAG, but it produces nothing and has 1331 // no side effects. 1332 let OutOperandList = (outs); 1333 let InOperandList = (ins ptr_rc:$symbol, i32imm:$id); 1334 let hasSideEffects = false; 1335 let hasCtrlDep = true; 1336} 1337def FAULTING_OP : StandardPseudoInstruction { 1338 let OutOperandList = (outs unknown:$dst); 1339 let InOperandList = (ins variable_ops); 1340 let usesCustomInserter = true; 1341 let hasSideEffects = true; 1342 let mayLoad = true; 1343 let mayStore = true; 1344 let isTerminator = true; 1345 let isBranch = true; 1346} 1347def PATCHABLE_OP : StandardPseudoInstruction { 1348 let OutOperandList = (outs); 1349 let InOperandList = (ins variable_ops); 1350 let usesCustomInserter = true; 1351 let mayLoad = true; 1352 let mayStore = true; 1353 let hasSideEffects = true; 1354} 1355def PATCHABLE_FUNCTION_ENTER : StandardPseudoInstruction { 1356 let OutOperandList = (outs); 1357 let InOperandList = (ins); 1358 let AsmString = "# XRay Function Enter."; 1359 let usesCustomInserter = true; 1360 let hasSideEffects = true; 1361} 1362def PATCHABLE_RET : StandardPseudoInstruction { 1363 let OutOperandList = (outs); 1364 let InOperandList = (ins variable_ops); 1365 let AsmString = "# XRay Function Patchable RET."; 1366 let usesCustomInserter = true; 1367 let hasSideEffects = true; 1368 let isTerminator = true; 1369 let isReturn = true; 1370} 1371def PATCHABLE_FUNCTION_EXIT : StandardPseudoInstruction { 1372 let OutOperandList = (outs); 1373 let InOperandList = (ins); 1374 let AsmString = "# XRay Function Exit."; 1375 let usesCustomInserter = true; 1376 let hasSideEffects = true; 1377 let isReturn = false; // Original return instruction will follow 1378} 1379def PATCHABLE_TAIL_CALL : StandardPseudoInstruction { 1380 let OutOperandList = (outs); 1381 let InOperandList = (ins variable_ops); 1382 let AsmString = "# XRay Tail Call Exit."; 1383 let usesCustomInserter = true; 1384 let hasSideEffects = true; 1385 let isReturn = true; 1386} 1387def PATCHABLE_EVENT_CALL : StandardPseudoInstruction { 1388 let OutOperandList = (outs); 1389 let InOperandList = (ins ptr_rc:$event, unknown:$size); 1390 let AsmString = "# XRay Custom Event Log."; 1391 let usesCustomInserter = true; 1392 let isCall = true; 1393 let mayLoad = true; 1394 let mayStore = true; 1395 let hasSideEffects = true; 1396} 1397def PATCHABLE_TYPED_EVENT_CALL : StandardPseudoInstruction { 1398 let OutOperandList = (outs); 1399 let InOperandList = (ins unknown:$type, ptr_rc:$event, unknown:$size); 1400 let AsmString = "# XRay Typed Event Log."; 1401 let usesCustomInserter = true; 1402 let isCall = true; 1403 let mayLoad = true; 1404 let mayStore = true; 1405 let hasSideEffects = true; 1406} 1407def FENTRY_CALL : StandardPseudoInstruction { 1408 let OutOperandList = (outs); 1409 let InOperandList = (ins); 1410 let AsmString = "# FEntry call"; 1411 let usesCustomInserter = true; 1412 let isCall = true; 1413 let mayLoad = true; 1414 let mayStore = true; 1415 let hasSideEffects = true; 1416} 1417def ICALL_BRANCH_FUNNEL : StandardPseudoInstruction { 1418 let OutOperandList = (outs); 1419 let InOperandList = (ins variable_ops); 1420 let AsmString = ""; 1421 let hasSideEffects = true; 1422} 1423def MEMBARRIER : StandardPseudoInstruction { 1424 let OutOperandList = (outs); 1425 let InOperandList = (ins); 1426 let AsmString = ""; 1427 let hasSideEffects = true; 1428 let Size = 0; 1429 let isMeta = true; 1430} 1431def JUMP_TABLE_DEBUG_INFO : StandardPseudoInstruction { 1432 let OutOperandList = (outs); 1433 let InOperandList = (ins i64imm:$jti); 1434 let AsmString = ""; 1435 let hasSideEffects = false; 1436 let Size = 0; 1437 let isMeta = true; 1438} 1439 1440// Generic opcodes used in GlobalISel. 1441include "llvm/Target/GenericOpcodes.td" 1442 1443//===----------------------------------------------------------------------===// 1444// AsmParser - This class can be implemented by targets that wish to implement 1445// .s file parsing. 1446// 1447// Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel 1448// syntax on X86 for example). 1449// 1450class AsmParser { 1451 // AsmParserClassName - This specifies the suffix to use for the asmparser 1452 // class. Generated AsmParser classes are always prefixed with the target 1453 // name. 1454 string AsmParserClassName = "AsmParser"; 1455 1456 // AsmParserInstCleanup - If non-empty, this is the name of a custom member 1457 // function of the AsmParser class to call on every matched instruction. 1458 // This can be used to perform target specific instruction post-processing. 1459 string AsmParserInstCleanup = ""; 1460 1461 // ShouldEmitMatchRegisterName - Set to false if the target needs a hand 1462 // written register name matcher 1463 bit ShouldEmitMatchRegisterName = true; 1464 1465 // Set to true if the target needs a generated 'alternative register name' 1466 // matcher. 1467 // 1468 // This generates a function which can be used to lookup registers from 1469 // their aliases. This function will fail when called on targets where 1470 // several registers share the same alias (i.e. not a 1:1 mapping). 1471 bit ShouldEmitMatchRegisterAltName = false; 1472 1473 // Set to true if MatchRegisterName and MatchRegisterAltName functions 1474 // should be generated even if there are duplicate register names. The 1475 // target is responsible for coercing aliased registers as necessary 1476 // (e.g. in validateTargetOperandClass), and there are no guarantees about 1477 // which numeric register identifier will be returned in the case of 1478 // multiple matches. 1479 bit AllowDuplicateRegisterNames = false; 1480 1481 // HasMnemonicFirst - Set to false if target instructions don't always 1482 // start with a mnemonic as the first token. 1483 bit HasMnemonicFirst = true; 1484 1485 // ReportMultipleNearMisses - 1486 // When 0, the assembly matcher reports an error for one encoding or operand 1487 // that did not match the parsed instruction. 1488 // When 1, the assembly matcher returns a list of encodings that were close 1489 // to matching the parsed instruction, so to allow more detailed error 1490 // messages. 1491 bit ReportMultipleNearMisses = false; 1492 1493 // OperandParserMethod - If non-empty, this is the name of a custom 1494 // member function of the AsmParser class to call for every instruction 1495 // operand to be parsed. 1496 string OperandParserMethod = ""; 1497 1498 // CallCustomParserForAllOperands - Set to true if the custom parser 1499 // method shall be called for all operands as opposed to only those 1500 // that have their own specified custom parsers. 1501 bit CallCustomParserForAllOperands = false; 1502} 1503def DefaultAsmParser : AsmParser; 1504 1505//===----------------------------------------------------------------------===// 1506// AsmParserVariant - Subtargets can have multiple different assembly parsers 1507// (e.g. AT&T vs Intel syntax on X86 for example). This class can be 1508// implemented by targets to describe such variants. 1509// 1510class AsmParserVariant { 1511 // Variant - AsmParsers can be of multiple different variants. Variants are 1512 // used to support targets that need to parse multiple formats for the 1513 // assembly language. 1514 int Variant = 0; 1515 1516 // Name - The AsmParser variant name (e.g., AT&T vs Intel). 1517 string Name = ""; 1518 1519 // CommentDelimiter - If given, the delimiter string used to recognize 1520 // comments which are hard coded in the .td assembler strings for individual 1521 // instructions. 1522 string CommentDelimiter = ""; 1523 1524 // RegisterPrefix - If given, the token prefix which indicates a register 1525 // token. This is used by the matcher to automatically recognize hard coded 1526 // register tokens as constrained registers, instead of tokens, for the 1527 // purposes of matching. 1528 string RegisterPrefix = ""; 1529 1530 // TokenizingCharacters - Characters that are standalone tokens 1531 string TokenizingCharacters = "[]*!"; 1532 1533 // SeparatorCharacters - Characters that are not tokens 1534 string SeparatorCharacters = " \t,"; 1535 1536 // BreakCharacters - Characters that start new identifiers 1537 string BreakCharacters = ""; 1538} 1539def DefaultAsmParserVariant : AsmParserVariant; 1540 1541// Operators for combining SubtargetFeatures in AssemblerPredicates 1542def any_of; 1543def all_of; 1544 1545/// AssemblerPredicate - This is a Predicate that can be used when the assembler 1546/// matches instructions and aliases. 1547class AssemblerPredicate<dag cond, string name = ""> { 1548 bit AssemblerMatcherPredicate = true; 1549 dag AssemblerCondDag = cond; 1550 string PredicateName = name; 1551} 1552 1553/// TokenAlias - This class allows targets to define assembler token 1554/// operand aliases. That is, a token literal operand which is equivalent 1555/// to another, canonical, token literal. For example, ARM allows: 1556/// vmov.u32 s4, #0 -> vmov.i32, #0 1557/// 'u32' is a more specific designator for the 32-bit integer type specifier 1558/// and is legal for any instruction which accepts 'i32' as a datatype suffix. 1559/// def : TokenAlias<".u32", ".i32">; 1560/// 1561/// This works by marking the match class of 'From' as a subclass of the 1562/// match class of 'To'. 1563class TokenAlias<string From, string To> { 1564 string FromToken = From; 1565 string ToToken = To; 1566} 1567 1568/// MnemonicAlias - This class allows targets to define assembler mnemonic 1569/// aliases. This should be used when all forms of one mnemonic are accepted 1570/// with a different mnemonic. For example, X86 allows: 1571/// sal %al, 1 -> shl %al, 1 1572/// sal %ax, %cl -> shl %ax, %cl 1573/// sal %eax, %cl -> shl %eax, %cl 1574/// etc. Though "sal" is accepted with many forms, all of them are directly 1575/// translated to a shl, so it can be handled with (in the case of X86, it 1576/// actually has one for each suffix as well): 1577/// def : MnemonicAlias<"sal", "shl">; 1578/// 1579/// Mnemonic aliases are mapped before any other translation in the match phase, 1580/// and do allow Requires predicates, e.g.: 1581/// 1582/// def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>; 1583/// def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>; 1584/// 1585/// Mnemonic aliases can also be constrained to specific variants, e.g.: 1586/// 1587/// def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>; 1588/// 1589/// If no variant (e.g., "att" or "intel") is specified then the alias is 1590/// applied unconditionally. 1591class MnemonicAlias<string From, string To, string VariantName = ""> { 1592 string FromMnemonic = From; 1593 string ToMnemonic = To; 1594 string AsmVariantName = VariantName; 1595 1596 // Predicates - Predicates that must be true for this remapping to happen. 1597 list<Predicate> Predicates = []; 1598} 1599 1600/// InstAlias - This defines an alternate assembly syntax that is allowed to 1601/// match an instruction that has a different (more canonical) assembly 1602/// representation. 1603class InstAlias<string Asm, dag Result, int Emit = 1, string VariantName = ""> { 1604 string AsmString = Asm; // The .s format to match the instruction with. 1605 dag ResultInst = Result; // The MCInst to generate. 1606 1607 // This determines which order the InstPrinter detects aliases for 1608 // printing. A larger value makes the alias more likely to be 1609 // emitted. The Instruction's own definition is notionally 0.5, so 0 1610 // disables printing and 1 enables it if there are no conflicting aliases. 1611 int EmitPriority = Emit; 1612 1613 // Predicates - Predicates that must be true for this to match. 1614 list<Predicate> Predicates = []; 1615 1616 // If the instruction specified in Result has defined an AsmMatchConverter 1617 // then setting this to 1 will cause the alias to use the AsmMatchConverter 1618 // function when converting the OperandVector into an MCInst instead of the 1619 // function that is generated by the dag Result. 1620 // Setting this to 0 will cause the alias to ignore the Result instruction's 1621 // defined AsmMatchConverter and instead use the function generated by the 1622 // dag Result. 1623 bit UseInstAsmMatchConverter = true; 1624 1625 // Assembler variant name to use for this alias. If not specified then 1626 // assembler variants will be determined based on AsmString 1627 string AsmVariantName = VariantName; 1628} 1629 1630//===----------------------------------------------------------------------===// 1631// AsmWriter - This class can be implemented by targets that need to customize 1632// the format of the .s file writer. 1633// 1634// Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax 1635// on X86 for example). 1636// 1637class AsmWriter { 1638 // AsmWriterClassName - This specifies the suffix to use for the asmwriter 1639 // class. Generated AsmWriter classes are always prefixed with the target 1640 // name. 1641 string AsmWriterClassName = "InstPrinter"; 1642 1643 // PassSubtarget - Determines whether MCSubtargetInfo should be passed to 1644 // the various print methods. 1645 // FIXME: Remove after all ports are updated. 1646 int PassSubtarget = 0; 1647 1648 // Variant - AsmWriters can be of multiple different variants. Variants are 1649 // used to support targets that need to emit assembly code in ways that are 1650 // mostly the same for different targets, but have minor differences in 1651 // syntax. If the asmstring contains {|} characters in them, this integer 1652 // will specify which alternative to use. For example "{x|y|z}" with Variant 1653 // == 1, will expand to "y". 1654 int Variant = 0; 1655} 1656def DefaultAsmWriter : AsmWriter; 1657 1658 1659//===----------------------------------------------------------------------===// 1660// Target - This class contains the "global" target information 1661// 1662class Target { 1663 // InstructionSet - Instruction set description for this target. 1664 InstrInfo InstructionSet; 1665 1666 // AssemblyParsers - The AsmParser instances available for this target. 1667 list<AsmParser> AssemblyParsers = [DefaultAsmParser]; 1668 1669 /// AssemblyParserVariants - The AsmParserVariant instances available for 1670 /// this target. 1671 list<AsmParserVariant> AssemblyParserVariants = [DefaultAsmParserVariant]; 1672 1673 // AssemblyWriters - The AsmWriter instances available for this target. 1674 list<AsmWriter> AssemblyWriters = [DefaultAsmWriter]; 1675 1676 // AllowRegisterRenaming - Controls whether this target allows 1677 // post-register-allocation renaming of registers. This is done by 1678 // setting hasExtraDefRegAllocReq and hasExtraSrcRegAllocReq to 1 1679 // for all opcodes if this flag is set to 0. 1680 int AllowRegisterRenaming = 0; 1681} 1682 1683//===----------------------------------------------------------------------===// 1684// SubtargetFeature - A characteristic of the chip set. 1685// 1686class SubtargetFeature<string n, string f, string v, string d, 1687 list<SubtargetFeature> i = []> { 1688 // Name - Feature name. Used by command line (-mattr=) to determine the 1689 // appropriate target chip. 1690 // 1691 string Name = n; 1692 1693 // FieldName - Field in XXXSubtarget to be set by feature. 1694 // 1695 string FieldName = f; 1696 1697 // Value - Value the XXXSubtarget field to be set to by feature. 1698 // 1699 // A value of "true" or "false" implies the field is a bool. Otherwise, 1700 // it is assumed to be an integer. the integer value may be the name of an 1701 // enum constant. If multiple features use the same integer field, the 1702 // field will be set to the maximum value of all enabled features that 1703 // share the field. 1704 // 1705 string Value = v; 1706 1707 // Desc - Feature description. Used by command line (-mattr=) to display help 1708 // information. 1709 // 1710 string Desc = d; 1711 1712 // Implies - Features that this feature implies are present. If one of those 1713 // features isn't set, then this one shouldn't be set either. 1714 // 1715 list<SubtargetFeature> Implies = i; 1716} 1717 1718/// Specifies a Subtarget feature that this instruction is deprecated on. 1719class Deprecated<SubtargetFeature dep> { 1720 SubtargetFeature DeprecatedFeatureMask = dep; 1721} 1722 1723/// A custom predicate used to determine if an instruction is 1724/// deprecated or not. 1725class ComplexDeprecationPredicate<string dep> { 1726 string ComplexDeprecationPredicate = dep; 1727} 1728 1729//===----------------------------------------------------------------------===// 1730// Processor chip sets - These values represent each of the chip sets supported 1731// by the scheduler. Each Processor definition requires corresponding 1732// instruction itineraries. 1733// 1734class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f, 1735 list<SubtargetFeature> tunef = []> { 1736 // Name - Chip set name. Used by command line (-mcpu=) to determine the 1737 // appropriate target chip. 1738 // 1739 string Name = n; 1740 1741 // SchedModel - The machine model for scheduling and instruction cost. 1742 // 1743 SchedMachineModel SchedModel = NoSchedModel; 1744 1745 // ProcItin - The scheduling information for the target processor. 1746 // 1747 ProcessorItineraries ProcItin = pi; 1748 1749 // Features - list of 1750 list<SubtargetFeature> Features = f; 1751 1752 // TuneFeatures - list of features for tuning for this CPU. If the target 1753 // supports -mtune, this should contain the list of features used to make 1754 // microarchitectural optimization decisions for a given processor. While 1755 // Features should contain the architectural features for the processor. 1756 list<SubtargetFeature> TuneFeatures = tunef; 1757} 1758 1759// ProcessorModel allows subtargets to specify the more general 1760// SchedMachineModel instead if a ProcessorItinerary. Subtargets will 1761// gradually move to this newer form. 1762// 1763// Although this class always passes NoItineraries to the Processor 1764// class, the SchedMachineModel may still define valid Itineraries. 1765class ProcessorModel<string n, SchedMachineModel m, list<SubtargetFeature> f, 1766 list<SubtargetFeature> tunef = []> 1767 : Processor<n, NoItineraries, f, tunef> { 1768 let SchedModel = m; 1769} 1770 1771//===----------------------------------------------------------------------===// 1772// InstrMapping - This class is used to create mapping tables to relate 1773// instructions with each other based on the values specified in RowFields, 1774// ColFields, KeyCol and ValueCols. 1775// 1776class InstrMapping { 1777 // FilterClass - Used to limit search space only to the instructions that 1778 // define the relationship modeled by this InstrMapping record. 1779 string FilterClass; 1780 1781 // RowFields - List of fields/attributes that should be same for all the 1782 // instructions in a row of the relation table. Think of this as a set of 1783 // properties shared by all the instructions related by this relationship 1784 // model and is used to categorize instructions into subgroups. For instance, 1785 // if we want to define a relation that maps 'Add' instruction to its 1786 // predicated forms, we can define RowFields like this: 1787 // 1788 // let RowFields = BaseOp 1789 // All add instruction predicated/non-predicated will have to set their BaseOp 1790 // to the same value. 1791 // 1792 // def Add: { let BaseOp = 'ADD'; let predSense = 'nopred' } 1793 // def Add_predtrue: { let BaseOp = 'ADD'; let predSense = 'true' } 1794 // def Add_predfalse: { let BaseOp = 'ADD'; let predSense = 'false' } 1795 list<string> RowFields = []; 1796 1797 // List of fields/attributes that are same for all the instructions 1798 // in a column of the relation table. 1799 // Ex: let ColFields = 'predSense' -- It means that the columns are arranged 1800 // based on the 'predSense' values. All the instruction in a specific 1801 // column have the same value and it is fixed for the column according 1802 // to the values set in 'ValueCols'. 1803 list<string> ColFields = []; 1804 1805 // Values for the fields/attributes listed in 'ColFields'. 1806 // Ex: let KeyCol = 'nopred' -- It means that the key instruction (instruction 1807 // that models this relation) should be non-predicated. 1808 // In the example above, 'Add' is the key instruction. 1809 list<string> KeyCol = []; 1810 1811 // List of values for the fields/attributes listed in 'ColFields', one for 1812 // each column in the relation table. 1813 // 1814 // Ex: let ValueCols = [['true'],['false']] -- It adds two columns in the 1815 // table. First column requires all the instructions to have predSense 1816 // set to 'true' and second column requires it to be 'false'. 1817 list<list<string> > ValueCols = []; 1818} 1819 1820//===----------------------------------------------------------------------===// 1821// Pull in the common support for calling conventions. 1822// 1823include "llvm/Target/TargetCallingConv.td" 1824 1825//===----------------------------------------------------------------------===// 1826// Pull in the common support for DAG isel generation. 1827// 1828include "llvm/Target/TargetSelectionDAG.td" 1829 1830//===----------------------------------------------------------------------===// 1831// Pull in the common support for Global ISel register bank info generation. 1832// 1833include "llvm/Target/GlobalISel/RegisterBank.td" 1834 1835//===----------------------------------------------------------------------===// 1836// Pull in the common support for DAG isel generation. 1837// 1838include "llvm/Target/GlobalISel/Target.td" 1839 1840//===----------------------------------------------------------------------===// 1841// Pull in the common support for the Global ISel DAG-based selector generation. 1842// 1843include "llvm/Target/GlobalISel/SelectionDAGCompat.td" 1844 1845//===----------------------------------------------------------------------===// 1846// Pull in the common support for Pfm Counters generation. 1847// 1848include "llvm/Target/TargetPfmCounters.td" 1849