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// SubtargetFeature - A characteristic of the chip set. 464// 465class SubtargetFeature<string n, string f, string v, string d, 466 list<SubtargetFeature> i = []> { 467 // Name - Feature name. Used by command line (-mattr=) to determine the 468 // appropriate target chip. 469 // 470 string Name = n; 471 472 // FieldName - Field in XXXSubtarget to be set by feature. 473 // 474 string FieldName = f; 475 476 // Value - Value the XXXSubtarget field to be set to by feature. 477 // 478 // A value of "true" or "false" implies the field is a bool. Otherwise, 479 // it is assumed to be an integer. the integer value may be the name of an 480 // enum constant. If multiple features use the same integer field, the 481 // field will be set to the maximum value of all enabled features that 482 // share the field. 483 // 484 string Value = v; 485 486 // Desc - Feature description. Used by command line (-mattr=) to display help 487 // information. 488 // 489 string Desc = d; 490 491 // Implies - Features that this feature implies are present. If one of those 492 // features isn't set, then this one shouldn't be set either. 493 // 494 list<SubtargetFeature> Implies = i; 495} 496 497/// Specifies a Subtarget feature that this instruction is deprecated on. 498class Deprecated<SubtargetFeature dep> { 499 SubtargetFeature DeprecatedFeatureMask = dep; 500} 501 502/// A custom predicate used to determine if an instruction is 503/// deprecated or not. 504class ComplexDeprecationPredicate<string dep> { 505 string ComplexDeprecationPredicate = dep; 506} 507 508//===----------------------------------------------------------------------===// 509// Pull in the common support for MCPredicate (portable scheduling predicates). 510// 511include "llvm/Target/TargetInstrPredicate.td" 512 513//===----------------------------------------------------------------------===// 514// Pull in the common support for scheduling 515// 516include "llvm/Target/TargetSchedule.td" 517 518class InstructionEncoding { 519 // Size of encoded instruction. 520 int Size; 521 522 // The "namespace" in which this instruction exists, on targets like ARM 523 // which multiple ISA namespaces exist. 524 string DecoderNamespace = ""; 525 526 // List of predicates which will be turned into isel matching code. 527 list<Predicate> Predicates = []; 528 529 string DecoderMethod = ""; 530 531 // Is the instruction decoder method able to completely determine if the 532 // given instruction is valid or not. If the TableGen definition of the 533 // instruction specifies bitpattern A??B where A and B are static bits, the 534 // hasCompleteDecoder flag says whether the decoder method fully handles the 535 // ?? space, i.e. if it is a final arbiter for the instruction validity. 536 // If not then the decoder attempts to continue decoding when the decoder 537 // method fails. 538 // 539 // This allows to handle situations where the encoding is not fully 540 // orthogonal. Example: 541 // * InstA with bitpattern 0b0000????, 542 // * InstB with bitpattern 0b000000?? but the associated decoder method 543 // DecodeInstB() returns Fail when ?? is 0b00 or 0b11. 544 // 545 // The decoder tries to decode a bitpattern that matches both InstA and 546 // InstB bitpatterns first as InstB (because it is the most specific 547 // encoding). In the default case (hasCompleteDecoder = 1), when 548 // DecodeInstB() returns Fail the bitpattern gets rejected. By setting 549 // hasCompleteDecoder = 0 in InstB, the decoder is informed that 550 // DecodeInstB() is not able to determine if all possible values of ?? are 551 // valid or not. If DecodeInstB() returns Fail the decoder will attempt to 552 // decode the bitpattern as InstA too. 553 bit hasCompleteDecoder = true; 554} 555 556// Allows specifying an InstructionEncoding by HwMode. If an Instruction specifies 557// an EncodingByHwMode, its Inst and Size members are ignored and Ts are used 558// to encode and decode based on HwMode. 559class EncodingByHwMode<list<HwMode> Ms = [], list<InstructionEncoding> Ts = []> 560 : HwModeSelect<Ms> { 561 // The length of this list must be the same as the length of Ms. 562 list<InstructionEncoding> Objects = Ts; 563} 564 565//===----------------------------------------------------------------------===// 566// Instruction set description - These classes correspond to the C++ classes in 567// the Target/TargetInstrInfo.h file. 568// 569class Instruction : InstructionEncoding { 570 string Namespace = ""; 571 572 dag OutOperandList; // An dag containing the MI def operand list. 573 dag InOperandList; // An dag containing the MI use operand list. 574 string AsmString = ""; // The .s format to print the instruction with. 575 576 // Allows specifying a canonical InstructionEncoding by HwMode. If non-empty, 577 // the Inst member of this Instruction is ignored. 578 EncodingByHwMode EncodingInfos; 579 580 // Pattern - Set to the DAG pattern for this instruction, if we know of one, 581 // otherwise, uninitialized. 582 list<dag> Pattern; 583 584 // The follow state will eventually be inferred automatically from the 585 // instruction pattern. 586 587 list<Register> Uses = []; // Default to using no non-operand registers 588 list<Register> Defs = []; // Default to modifying no non-operand registers 589 590 // Predicates - List of predicates which will be turned into isel matching 591 // code. 592 list<Predicate> Predicates = []; 593 594 // Size - Size of encoded instruction, or zero if the size cannot be determined 595 // from the opcode. 596 int Size = 0; 597 598 // Code size, for instruction selection. 599 // FIXME: What does this actually mean? 600 int CodeSize = 0; 601 602 // Added complexity passed onto matching pattern. 603 int AddedComplexity = 0; 604 605 // Indicates if this is a pre-isel opcode that should be 606 // legalized/regbankselected/selected. 607 bit isPreISelOpcode = false; 608 609 // These bits capture information about the high-level semantics of the 610 // instruction. 611 bit isReturn = false; // Is this instruction a return instruction? 612 bit isBranch = false; // Is this instruction a branch instruction? 613 bit isEHScopeReturn = false; // Does this instruction end an EH scope? 614 bit isIndirectBranch = false; // Is this instruction an indirect branch? 615 bit isCompare = false; // Is this instruction a comparison instruction? 616 bit isMoveImm = false; // Is this instruction a move immediate instruction? 617 bit isMoveReg = false; // Is this instruction a move register instruction? 618 bit isBitcast = false; // Is this instruction a bitcast instruction? 619 bit isSelect = false; // Is this instruction a select instruction? 620 bit isBarrier = false; // Can control flow fall through this instruction? 621 bit isCall = false; // Is this instruction a call instruction? 622 bit isAdd = false; // Is this instruction an add instruction? 623 bit isTrap = false; // Is this instruction a trap instruction? 624 bit canFoldAsLoad = false; // Can this be folded as a simple memory operand? 625 bit mayLoad = ?; // Is it possible for this inst to read memory? 626 bit mayStore = ?; // Is it possible for this inst to write memory? 627 bit mayRaiseFPException = false; // Can this raise a floating-point exception? 628 bit isConvertibleToThreeAddress = false; // Can this 2-addr instruction promote? 629 bit isCommutable = false; // Is this 3 operand instruction commutable? 630 bit isTerminator = false; // Is this part of the terminator for a basic block? 631 bit isReMaterializable = false; // Is this instruction re-materializable? 632 bit isPredicable = false; // 1 means this instruction is predicable 633 // even if it does not have any operand 634 // tablegen can identify as a predicate 635 bit isUnpredicable = false; // 1 means this instruction is not predicable 636 // even if it _does_ have a predicate operand 637 bit hasDelaySlot = false; // Does this instruction have an delay slot? 638 bit usesCustomInserter = false; // Pseudo instr needing special help. 639 bit hasPostISelHook = false; // To be *adjusted* after isel by target hook. 640 bit hasCtrlDep = false; // Does this instruction r/w ctrl-flow chains? 641 bit isNotDuplicable = false; // Is it unsafe to duplicate this instruction? 642 bit isConvergent = false; // Is this instruction convergent? 643 bit isAuthenticated = false; // Does this instruction authenticate a pointer? 644 bit isAsCheapAsAMove = false; // As cheap (or cheaper) than a move instruction. 645 bit hasExtraSrcRegAllocReq = false; // Sources have special regalloc requirement? 646 bit hasExtraDefRegAllocReq = false; // Defs have special regalloc requirement? 647 bit isRegSequence = false; // Is this instruction a kind of reg sequence? 648 // If so, make sure to override 649 // TargetInstrInfo::getRegSequenceLikeInputs. 650 bit isPseudo = false; // Is this instruction a pseudo-instruction? 651 // If so, won't have encoding information for 652 // the [MC]CodeEmitter stuff. 653 bit isMeta = false; // Is this instruction a meta-instruction? 654 // If so, won't produce any output in the form of 655 // executable instructions 656 bit isExtractSubreg = false; // Is this instruction a kind of extract subreg? 657 // If so, make sure to override 658 // TargetInstrInfo::getExtractSubregLikeInputs. 659 bit isInsertSubreg = false; // Is this instruction a kind of insert subreg? 660 // If so, make sure to override 661 // TargetInstrInfo::getInsertSubregLikeInputs. 662 bit variadicOpsAreDefs = false; // Are variadic operands definitions? 663 664 // Does the instruction have side effects that are not captured by any 665 // operands of the instruction or other flags? 666 bit hasSideEffects = ?; 667 668 // Is this instruction a "real" instruction (with a distinct machine 669 // encoding), or is it a pseudo instruction used for codegen modeling 670 // purposes. 671 // FIXME: For now this is distinct from isPseudo, above, as code-gen-only 672 // instructions can (and often do) still have encoding information 673 // associated with them. Once we've migrated all of them over to true 674 // pseudo-instructions that are lowered to real instructions prior to 675 // the printer/emitter, we can remove this attribute and just use isPseudo. 676 // 677 // The intended use is: 678 // isPseudo: Does not have encoding information and should be expanded, 679 // at the latest, during lowering to MCInst. 680 // 681 // isCodeGenOnly: Does have encoding information and can go through to the 682 // CodeEmitter unchanged, but duplicates a canonical instruction 683 // definition's encoding and should be ignored when constructing the 684 // assembler match tables. 685 bit isCodeGenOnly = false; 686 687 // Is this instruction a pseudo instruction for use by the assembler parser. 688 bit isAsmParserOnly = false; 689 690 // This instruction is not expected to be queried for scheduling latencies 691 // and therefore needs no scheduling information even for a complete 692 // scheduling model. 693 bit hasNoSchedulingInfo = false; 694 695 InstrItinClass Itinerary = NoItinerary;// Execution steps used for scheduling. 696 697 // Scheduling information from TargetSchedule.td. 698 list<SchedReadWrite> SchedRW; 699 700 string Constraints = ""; // OperandConstraint, e.g. $src = $dst. 701 702 /// DisableEncoding - List of operand names (e.g. "$op1,$op2") that should not 703 /// be encoded into the output machineinstr. 704 string DisableEncoding = ""; 705 706 string PostEncoderMethod = ""; 707 708 /// Target-specific flags. This becomes the TSFlags field in TargetInstrDesc. 709 bits<64> TSFlags = 0; 710 711 ///@name Assembler Parser Support 712 ///@{ 713 714 string AsmMatchConverter = ""; 715 716 /// TwoOperandAliasConstraint - Enable TableGen to auto-generate a 717 /// two-operand matcher inst-alias for a three operand instruction. 718 /// For example, the arm instruction "add r3, r3, r5" can be written 719 /// as "add r3, r5". The constraint is of the same form as a tied-operand 720 /// constraint. For example, "$Rn = $Rd". 721 string TwoOperandAliasConstraint = ""; 722 723 /// Assembler variant name to use for this instruction. If specified then 724 /// instruction will be presented only in MatchTable for this variant. If 725 /// not specified then assembler variants will be determined based on 726 /// AsmString 727 string AsmVariantName = ""; 728 729 ///@} 730 731 /// UseNamedOperandTable - If set, the operand indices of this instruction 732 /// can be queried via the getNamedOperandIdx() function which is generated 733 /// by TableGen. 734 bit UseNamedOperandTable = false; 735 736 /// Should generate helper functions that help you to map a logical operand's 737 /// index to the underlying MIOperand's index. 738 /// In most architectures logical operand indicies are equal to 739 /// MIOperand indicies, but for some CISC architectures, a logical operand 740 /// might be consist of multiple MIOperand (e.g. a logical operand that 741 /// uses complex address mode). 742 bit UseLogicalOperandMappings = false; 743 744 /// Should FastISel ignore this instruction. For certain ISAs, they have 745 /// instructions which map to the same ISD Opcode, value type operands and 746 /// instruction selection predicates. FastISel cannot handle such cases, but 747 /// SelectionDAG can. 748 bit FastISelShouldIgnore = false; 749 750 /// HasPositionOrder: Indicate tablegen to sort the instructions by record 751 /// ID, so that instruction that is defined earlier can be sorted earlier 752 /// in the assembly matching table. 753 bit HasPositionOrder = false; 754} 755 756/// Defines a Pat match between compressed and uncompressed instruction. 757/// The relationship and helper function generation are handled by 758/// CompressInstEmitter backend. 759class CompressPat<dag input, dag output, list<Predicate> predicates = []> { 760 /// Uncompressed instruction description. 761 dag Input = input; 762 /// Compressed instruction description. 763 dag Output = output; 764 /// Predicates that must be true for this to match. 765 list<Predicate> Predicates = predicates; 766 /// Duplicate match when tied operand is just different. 767 bit isCompressOnly = false; 768} 769 770/// Defines an additional encoding that disassembles to the given instruction 771/// Like Instruction, the Inst and SoftFail fields are omitted to allow targets 772// to specify their size. 773class AdditionalEncoding<Instruction I> : InstructionEncoding { 774 Instruction AliasOf = I; 775} 776 777/// PseudoInstExpansion - Expansion information for a pseudo-instruction. 778/// Which instruction it expands to and how the operands map from the 779/// pseudo. 780class PseudoInstExpansion<dag Result> { 781 dag ResultInst = Result; // The instruction to generate. 782 bit isPseudo = true; 783} 784 785/// Predicates - These are extra conditionals which are turned into instruction 786/// selector matching code. Currently each predicate is just a string. 787class Predicate<string cond> { 788 string CondString = cond; 789 790 /// AssemblerMatcherPredicate - If this feature can be used by the assembler 791 /// matcher, this is true. Targets should set this by inheriting their 792 /// feature from the AssemblerPredicate class in addition to Predicate. 793 bit AssemblerMatcherPredicate = false; 794 795 /// AssemblerCondDag - Set of subtarget features being tested used 796 /// as alternative condition string used for assembler matcher. Must be used 797 /// with (all_of) to indicate that all features must be present, or (any_of) 798 /// to indicate that at least one must be. The required lack of presence of 799 /// a feature can be tested using a (not) node including the feature. 800 /// e.g. "(all_of ModeThumb)" is translated to "(Bits & ModeThumb) != 0". 801 /// "(all_of (not ModeThumb))" is translated to 802 /// "(Bits & ModeThumb) == 0". 803 /// "(all_of ModeThumb, FeatureThumb2)" is translated to 804 /// "(Bits & ModeThumb) != 0 && (Bits & FeatureThumb2) != 0". 805 /// "(any_of ModeTumb, FeatureThumb2)" is translated to 806 /// "(Bits & ModeThumb) != 0 || (Bits & FeatureThumb2) != 0". 807 /// all_of and any_of cannot be combined in a single dag, instead multiple 808 /// predicates can be placed onto Instruction definitions. 809 dag AssemblerCondDag; 810 811 /// PredicateName - User-level name to use for the predicate. Mainly for use 812 /// in diagnostics such as missing feature errors in the asm matcher. 813 string PredicateName = ""; 814 815 /// Setting this to '1' indicates that the predicate must be recomputed on 816 /// every function change. Most predicates can leave this at '0'. 817 /// 818 /// Ignored by SelectionDAG, it always recomputes the predicate on every use. 819 bit RecomputePerFunction = false; 820} 821 822/// NoHonorSignDependentRounding - This predicate is true if support for 823/// sign-dependent-rounding is not enabled. 824def NoHonorSignDependentRounding 825 : Predicate<"!TM.Options.HonorSignDependentRoundingFPMath()">; 826 827class Requires<list<Predicate> preds> { 828 list<Predicate> Predicates = preds; 829} 830 831/// ops definition - This is just a simple marker used to identify the operand 832/// list for an instruction. outs and ins are identical both syntactically and 833/// semantically; they are used to define def operands and use operands to 834/// improve readability. This should be used like this: 835/// (outs R32:$dst), (ins R32:$src1, R32:$src2) or something similar. 836def ops; 837def outs; 838def ins; 839 840/// variable_ops definition - Mark this instruction as taking a variable number 841/// of operands. 842def variable_ops; 843 844/// variable-length instruction encoding utilities. 845/// The `ascend` operator should be used like this: 846/// (ascend 0b0010, 0b1101) 847/// Which represent a seqence of encoding fragments placing from LSB to MSB. 848/// Thus, in this case the final encoding will be 0b1101_0010. 849/// The arguments for `ascend` can either be `bits` or another DAG. 850def ascend; 851/// In addition, we can use `descend` to describe an encoding that places 852/// its arguments (i.e. encoding fragments) from MSB to LSB. For instance: 853/// (descend 0b0010, 0b1101) 854/// This results in an encoding of 0b0010_1101. 855def descend; 856/// The `operand` operator should be used like this: 857/// (operand "$src", 4) 858/// Which represents a 4-bit encoding for an instruction operand named `$src`. 859def operand; 860/// Similar to `operand`, we can reference only part of the operand's encoding: 861/// (slice "$src", 6, 8) 862/// (slice "$src", 8, 6) 863/// Both DAG represent bit 6 to 8 (total of 3 bits) in the encoding of operand 864/// `$src`. 865def slice; 866/// You can use `encoder` or `decoder` to specify a custom encoder or decoder 867/// function for a specific `operand` or `slice` directive. For example: 868/// (operand "$src", 4, (encoder "encodeMyImm")) 869/// (slice "$src", 8, 6, (encoder "encodeMyReg")) 870/// (operand "$src", 4, (encoder "encodeMyImm"), (decoder "decodeMyImm")) 871/// The ordering of `encoder` and `decoder` in the same `operand` or `slice` 872/// doesn't matter. 873/// Note that currently we cannot assign different decoders in the same 874/// (instruction) operand. 875def encoder; 876def decoder; 877 878/// PointerLikeRegClass - Values that are designed to have pointer width are 879/// derived from this. TableGen treats the register class as having a symbolic 880/// type that it doesn't know, and resolves the actual regclass to use by using 881/// the TargetRegisterInfo::getPointerRegClass() hook at codegen time. 882class PointerLikeRegClass<int Kind> { 883 int RegClassKind = Kind; 884} 885 886 887/// ptr_rc definition - Mark this operand as being a pointer value whose 888/// register class is resolved dynamically via a callback to TargetInstrInfo. 889/// FIXME: We should probably change this to a class which contain a list of 890/// flags. But currently we have but one flag. 891def ptr_rc : PointerLikeRegClass<0>; 892 893/// unknown definition - Mark this operand as being of unknown type, causing 894/// it to be resolved by inference in the context it is used. 895class unknown_class; 896def unknown : unknown_class; 897 898/// AsmOperandClass - Representation for the kinds of operands which the target 899/// specific parser can create and the assembly matcher may need to distinguish. 900/// 901/// Operand classes are used to define the order in which instructions are 902/// matched, to ensure that the instruction which gets matched for any 903/// particular list of operands is deterministic. 904/// 905/// The target specific parser must be able to classify a parsed operand into a 906/// unique class which does not partially overlap with any other classes. It can 907/// match a subset of some other class, in which case the super class field 908/// should be defined. 909class AsmOperandClass { 910 /// The name to use for this class, which should be usable as an enum value. 911 string Name = ?; 912 913 /// The super classes of this operand. 914 list<AsmOperandClass> SuperClasses = []; 915 916 /// The name of the method on the target specific operand to call to test 917 /// whether the operand is an instance of this class. If not set, this will 918 /// default to "isFoo", where Foo is the AsmOperandClass name. The method 919 /// signature should be: 920 /// bool isFoo() const; 921 string PredicateMethod = ?; 922 923 /// The name of the method on the target specific operand to call to add the 924 /// target specific operand to an MCInst. If not set, this will default to 925 /// "addFooOperands", where Foo is the AsmOperandClass name. The method 926 /// signature should be: 927 /// void addFooOperands(MCInst &Inst, unsigned N) const; 928 string RenderMethod = ?; 929 930 /// The name of the method on the target specific operand to call to custom 931 /// handle the operand parsing. This is useful when the operands do not relate 932 /// to immediates or registers and are very instruction specific (as flags to 933 /// set in a processor register, coprocessor number, ...). 934 string ParserMethod = ?; 935 936 // The diagnostic type to present when referencing this operand in a 937 // match failure error message. By default, use a generic "invalid operand" 938 // diagnostic. The target AsmParser maps these codes to text. 939 string DiagnosticType = ""; 940 941 /// A diagnostic message to emit when an invalid value is provided for this 942 /// operand. 943 string DiagnosticString = ""; 944 945 /// Set to 1 if this operand is optional and not always required. Typically, 946 /// the AsmParser will emit an error when it finishes parsing an 947 /// instruction if it hasn't matched all the operands yet. However, this 948 /// error will be suppressed if all of the remaining unmatched operands are 949 /// marked as IsOptional. 950 /// 951 /// Optional arguments must be at the end of the operand list. 952 bit IsOptional = false; 953 954 /// The name of the method on the target specific asm parser that returns the 955 /// default operand for this optional operand. This method is only used if 956 /// IsOptional == 1. If not set, this will default to "defaultFooOperands", 957 /// where Foo is the AsmOperandClass name. The method signature should be: 958 /// std::unique_ptr<MCParsedAsmOperand> defaultFooOperands() const; 959 string DefaultMethod = ?; 960} 961 962def ImmAsmOperand : AsmOperandClass { 963 let Name = "Imm"; 964} 965 966/// Operand Types - These provide the built-in operand types that may be used 967/// by a target. Targets can optionally provide their own operand types as 968/// needed, though this should not be needed for RISC targets. 969class Operand<ValueType ty> : DAGOperand { 970 ValueType Type = ty; 971 string PrintMethod = "printOperand"; 972 string EncoderMethod = ""; 973 bit hasCompleteDecoder = true; 974 string OperandType = "OPERAND_UNKNOWN"; 975 dag MIOperandInfo = (ops); 976 977 // MCOperandPredicate - Optionally, a code fragment operating on 978 // const MCOperand &MCOp, and returning a bool, to indicate if 979 // the value of MCOp is valid for the specific subclass of Operand 980 code MCOperandPredicate; 981 982 // ParserMatchClass - The "match class" that operands of this type fit 983 // in. Match classes are used to define the order in which instructions are 984 // match, to ensure that which instructions gets matched is deterministic. 985 // 986 // The target specific parser must be able to classify an parsed operand into 987 // a unique class, which does not partially overlap with any other classes. It 988 // can match a subset of some other class, in which case the AsmOperandClass 989 // should declare the other operand as one of its super classes. 990 AsmOperandClass ParserMatchClass = ImmAsmOperand; 991} 992 993class RegisterOperand<RegisterClass regclass, string pm = "printOperand"> 994 : DAGOperand { 995 // RegClass - The register class of the operand. 996 RegisterClass RegClass = regclass; 997 // PrintMethod - The target method to call to print register operands of 998 // this type. The method normally will just use an alt-name index to look 999 // up the name to print. Default to the generic printOperand(). 1000 string PrintMethod = pm; 1001 1002 // EncoderMethod - The target method name to call to encode this register 1003 // operand. 1004 string EncoderMethod = ""; 1005 1006 // ParserMatchClass - The "match class" that operands of this type fit 1007 // in. Match classes are used to define the order in which instructions are 1008 // match, to ensure that which instructions gets matched is deterministic. 1009 // 1010 // The target specific parser must be able to classify an parsed operand into 1011 // a unique class, which does not partially overlap with any other classes. It 1012 // can match a subset of some other class, in which case the AsmOperandClass 1013 // should declare the other operand as one of its super classes. 1014 AsmOperandClass ParserMatchClass; 1015 1016 string OperandType = "OPERAND_REGISTER"; 1017 1018 // When referenced in the result of a CodeGen pattern, GlobalISel will 1019 // normally copy the matched operand to the result. When this is set, it will 1020 // emit a special copy that will replace zero-immediates with the specified 1021 // zero-register. 1022 Register GIZeroRegister = ?; 1023} 1024 1025let OperandType = "OPERAND_IMMEDIATE" in { 1026def i1imm : Operand<i1>; 1027def i8imm : Operand<i8>; 1028def i16imm : Operand<i16>; 1029def i32imm : Operand<i32>; 1030def i64imm : Operand<i64>; 1031 1032def f32imm : Operand<f32>; 1033def f64imm : Operand<f64>; 1034} 1035 1036// Register operands for generic instructions don't have an MVT, but do have 1037// constraints linking the operands (e.g. all operands of a G_ADD must 1038// have the same LLT). 1039class TypedOperand<string Ty> : Operand<untyped> { 1040 let OperandType = Ty; 1041 bit IsPointer = false; 1042 bit IsImmediate = false; 1043} 1044 1045def type0 : TypedOperand<"OPERAND_GENERIC_0">; 1046def type1 : TypedOperand<"OPERAND_GENERIC_1">; 1047def type2 : TypedOperand<"OPERAND_GENERIC_2">; 1048def type3 : TypedOperand<"OPERAND_GENERIC_3">; 1049def type4 : TypedOperand<"OPERAND_GENERIC_4">; 1050def type5 : TypedOperand<"OPERAND_GENERIC_5">; 1051 1052let IsPointer = true in { 1053 def ptype0 : TypedOperand<"OPERAND_GENERIC_0">; 1054 def ptype1 : TypedOperand<"OPERAND_GENERIC_1">; 1055 def ptype2 : TypedOperand<"OPERAND_GENERIC_2">; 1056 def ptype3 : TypedOperand<"OPERAND_GENERIC_3">; 1057 def ptype4 : TypedOperand<"OPERAND_GENERIC_4">; 1058 def ptype5 : TypedOperand<"OPERAND_GENERIC_5">; 1059} 1060 1061// untyped_imm is for operands where isImm() will be true. It currently has no 1062// special behaviour and is only used for clarity. 1063def untyped_imm_0 : TypedOperand<"OPERAND_GENERIC_IMM_0"> { 1064 let IsImmediate = true; 1065} 1066 1067/// zero_reg definition - Special node to stand for the zero register. 1068/// 1069def zero_reg; 1070 1071/// undef_tied_input - Special node to indicate an input register tied 1072/// to an output which defaults to IMPLICIT_DEF. 1073def undef_tied_input; 1074 1075/// All operands which the MC layer classifies as predicates should inherit from 1076/// this class in some manner. This is already handled for the most commonly 1077/// used PredicateOperand, but may be useful in other circumstances. 1078class PredicateOp; 1079 1080/// OperandWithDefaultOps - This Operand class can be used as the parent class 1081/// for an Operand that needs to be initialized with a default value if 1082/// no value is supplied in a pattern. This class can be used to simplify the 1083/// pattern definitions for instructions that have target specific flags 1084/// encoded as immediate operands. 1085class OperandWithDefaultOps<ValueType ty, dag defaultops> 1086 : Operand<ty> { 1087 dag DefaultOps = defaultops; 1088} 1089 1090/// PredicateOperand - This can be used to define a predicate operand for an 1091/// instruction. OpTypes specifies the MIOperandInfo for the operand, and 1092/// AlwaysVal specifies the value of this predicate when set to "always 1093/// execute". 1094class PredicateOperand<ValueType ty, dag OpTypes, dag AlwaysVal> 1095 : OperandWithDefaultOps<ty, AlwaysVal>, PredicateOp { 1096 let MIOperandInfo = OpTypes; 1097} 1098 1099/// OptionalDefOperand - This is used to define a optional definition operand 1100/// for an instruction. DefaultOps is the register the operand represents if 1101/// none is supplied, e.g. zero_reg. 1102class OptionalDefOperand<ValueType ty, dag OpTypes, dag defaultops> 1103 : OperandWithDefaultOps<ty, defaultops> { 1104 let MIOperandInfo = OpTypes; 1105} 1106 1107 1108// InstrInfo - This class should only be instantiated once to provide parameters 1109// which are global to the target machine. 1110// 1111class InstrInfo { 1112 // Target can specify its instructions in either big or little-endian formats. 1113 // For instance, while both Sparc and PowerPC are big-endian platforms, the 1114 // Sparc manual specifies its instructions in the format [31..0] (big), while 1115 // PowerPC specifies them using the format [0..31] (little). 1116 bit isLittleEndianEncoding = false; 1117 1118 // The instruction properties mayLoad, mayStore, and hasSideEffects are unset 1119 // by default, and TableGen will infer their value from the instruction 1120 // pattern when possible. 1121 // 1122 // Normally, TableGen will issue an error if it can't infer the value of a 1123 // property that hasn't been set explicitly. When guessInstructionProperties 1124 // is set, it will guess a safe value instead. 1125 // 1126 // This option is a temporary migration help. It will go away. 1127 bit guessInstructionProperties = true; 1128} 1129 1130// Standard Pseudo Instructions. 1131// This list must match TargetOpcodes.def. 1132// Only these instructions are allowed in the TargetOpcode namespace. 1133// Ensure mayLoad and mayStore have a default value, so as not to break 1134// targets that set guessInstructionProperties=0. Any local definition of 1135// mayLoad/mayStore takes precedence over these default values. 1136class StandardPseudoInstruction : Instruction { 1137 let mayLoad = false; 1138 let mayStore = false; 1139 let isCodeGenOnly = true; 1140 let isPseudo = true; 1141 let hasNoSchedulingInfo = true; 1142 let Namespace = "TargetOpcode"; 1143} 1144def PHI : StandardPseudoInstruction { 1145 let OutOperandList = (outs unknown:$dst); 1146 let InOperandList = (ins variable_ops); 1147 let AsmString = "PHINODE"; 1148 let hasSideEffects = false; 1149} 1150def INLINEASM : StandardPseudoInstruction { 1151 let OutOperandList = (outs); 1152 let InOperandList = (ins variable_ops); 1153 let AsmString = ""; 1154 let hasSideEffects = false; // Note side effect is encoded in an operand. 1155} 1156def INLINEASM_BR : StandardPseudoInstruction { 1157 let OutOperandList = (outs); 1158 let InOperandList = (ins variable_ops); 1159 let AsmString = ""; 1160 // Unlike INLINEASM, this is always treated as having side-effects. 1161 let hasSideEffects = true; 1162 // Despite potentially branching, this instruction is intentionally _not_ 1163 // marked as a terminator or a branch. 1164} 1165def CFI_INSTRUCTION : StandardPseudoInstruction { 1166 let OutOperandList = (outs); 1167 let InOperandList = (ins i32imm:$id); 1168 let AsmString = ""; 1169 let hasCtrlDep = true; 1170 let hasSideEffects = false; 1171 let isNotDuplicable = true; 1172 let isMeta = true; 1173} 1174def EH_LABEL : StandardPseudoInstruction { 1175 let OutOperandList = (outs); 1176 let InOperandList = (ins i32imm:$id); 1177 let AsmString = ""; 1178 let hasCtrlDep = true; 1179 let hasSideEffects = false; 1180 let isNotDuplicable = true; 1181 let isMeta = true; 1182} 1183def GC_LABEL : StandardPseudoInstruction { 1184 let OutOperandList = (outs); 1185 let InOperandList = (ins i32imm:$id); 1186 let AsmString = ""; 1187 let hasCtrlDep = true; 1188 let hasSideEffects = false; 1189 let isNotDuplicable = true; 1190 let isMeta = true; 1191} 1192def ANNOTATION_LABEL : StandardPseudoInstruction { 1193 let OutOperandList = (outs); 1194 let InOperandList = (ins i32imm:$id); 1195 let AsmString = ""; 1196 let hasCtrlDep = true; 1197 let hasSideEffects = false; 1198 let isNotDuplicable = true; 1199} 1200def KILL : StandardPseudoInstruction { 1201 let OutOperandList = (outs); 1202 let InOperandList = (ins variable_ops); 1203 let AsmString = ""; 1204 let hasSideEffects = false; 1205 let isMeta = true; 1206} 1207def EXTRACT_SUBREG : StandardPseudoInstruction { 1208 let OutOperandList = (outs unknown:$dst); 1209 let InOperandList = (ins unknown:$supersrc, i32imm:$subidx); 1210 let AsmString = ""; 1211 let hasSideEffects = false; 1212} 1213def INSERT_SUBREG : StandardPseudoInstruction { 1214 let OutOperandList = (outs unknown:$dst); 1215 let InOperandList = (ins unknown:$supersrc, unknown:$subsrc, i32imm:$subidx); 1216 let AsmString = ""; 1217 let hasSideEffects = false; 1218 let Constraints = "$supersrc = $dst"; 1219} 1220def IMPLICIT_DEF : StandardPseudoInstruction { 1221 let OutOperandList = (outs unknown:$dst); 1222 let InOperandList = (ins); 1223 let AsmString = ""; 1224 let hasSideEffects = false; 1225 let isReMaterializable = true; 1226 let isAsCheapAsAMove = true; 1227 let isMeta = true; 1228} 1229def SUBREG_TO_REG : StandardPseudoInstruction { 1230 let OutOperandList = (outs unknown:$dst); 1231 let InOperandList = (ins unknown:$implsrc, unknown:$subsrc, i32imm:$subidx); 1232 let AsmString = ""; 1233 let hasSideEffects = false; 1234} 1235def COPY_TO_REGCLASS : StandardPseudoInstruction { 1236 let OutOperandList = (outs unknown:$dst); 1237 let InOperandList = (ins unknown:$src, i32imm:$regclass); 1238 let AsmString = ""; 1239 let hasSideEffects = false; 1240 let isAsCheapAsAMove = true; 1241} 1242def DBG_VALUE : StandardPseudoInstruction { 1243 let OutOperandList = (outs); 1244 let InOperandList = (ins variable_ops); 1245 let AsmString = "DBG_VALUE"; 1246 let hasSideEffects = false; 1247 let isMeta = true; 1248} 1249def DBG_VALUE_LIST : StandardPseudoInstruction { 1250 let OutOperandList = (outs); 1251 let InOperandList = (ins variable_ops); 1252 let AsmString = "DBG_VALUE_LIST"; 1253 let hasSideEffects = 0; 1254 let isMeta = true; 1255} 1256def DBG_INSTR_REF : StandardPseudoInstruction { 1257 let OutOperandList = (outs); 1258 let InOperandList = (ins variable_ops); 1259 let AsmString = "DBG_INSTR_REF"; 1260 let hasSideEffects = false; 1261 let isMeta = true; 1262} 1263def DBG_PHI : StandardPseudoInstruction { 1264 let OutOperandList = (outs); 1265 let InOperandList = (ins variable_ops); 1266 let AsmString = "DBG_PHI"; 1267 let hasSideEffects = 0; 1268 let isMeta = true; 1269} 1270def DBG_LABEL : StandardPseudoInstruction { 1271 let OutOperandList = (outs); 1272 let InOperandList = (ins unknown:$label); 1273 let AsmString = "DBG_LABEL"; 1274 let hasSideEffects = false; 1275 let isMeta = true; 1276} 1277def REG_SEQUENCE : StandardPseudoInstruction { 1278 let OutOperandList = (outs unknown:$dst); 1279 let InOperandList = (ins unknown:$supersrc, variable_ops); 1280 let AsmString = ""; 1281 let hasSideEffects = false; 1282 let isAsCheapAsAMove = true; 1283} 1284def COPY : StandardPseudoInstruction { 1285 let OutOperandList = (outs unknown:$dst); 1286 let InOperandList = (ins unknown:$src); 1287 let AsmString = ""; 1288 let hasSideEffects = false; 1289 let isAsCheapAsAMove = true; 1290 let hasNoSchedulingInfo = false; 1291} 1292def BUNDLE : StandardPseudoInstruction { 1293 let OutOperandList = (outs); 1294 let InOperandList = (ins variable_ops); 1295 let AsmString = "BUNDLE"; 1296 let hasSideEffects = false; 1297} 1298def LIFETIME_START : StandardPseudoInstruction { 1299 let OutOperandList = (outs); 1300 let InOperandList = (ins i32imm:$id); 1301 let AsmString = "LIFETIME_START"; 1302 let hasSideEffects = false; 1303 let isMeta = true; 1304} 1305def LIFETIME_END : StandardPseudoInstruction { 1306 let OutOperandList = (outs); 1307 let InOperandList = (ins i32imm:$id); 1308 let AsmString = "LIFETIME_END"; 1309 let hasSideEffects = false; 1310 let isMeta = true; 1311} 1312def PSEUDO_PROBE : StandardPseudoInstruction { 1313 let OutOperandList = (outs); 1314 let InOperandList = (ins i64imm:$guid, i64imm:$index, i8imm:$type, i32imm:$attr); 1315 let AsmString = "PSEUDO_PROBE"; 1316 let hasSideEffects = 1; 1317 let isMeta = true; 1318} 1319def ARITH_FENCE : StandardPseudoInstruction { 1320 let OutOperandList = (outs unknown:$dst); 1321 let InOperandList = (ins unknown:$src); 1322 let AsmString = ""; 1323 let hasSideEffects = false; 1324 let Constraints = "$src = $dst"; 1325 let isMeta = true; 1326} 1327 1328def STACKMAP : StandardPseudoInstruction { 1329 let OutOperandList = (outs); 1330 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, variable_ops); 1331 let hasSideEffects = true; 1332 let isCall = true; 1333 let mayLoad = true; 1334 let usesCustomInserter = true; 1335} 1336def PATCHPOINT : StandardPseudoInstruction { 1337 let OutOperandList = (outs unknown:$dst); 1338 let InOperandList = (ins i64imm:$id, i32imm:$nbytes, unknown:$callee, 1339 i32imm:$nargs, i32imm:$cc, variable_ops); 1340 let hasSideEffects = true; 1341 let isCall = true; 1342 let mayLoad = true; 1343 let usesCustomInserter = true; 1344} 1345def STATEPOINT : StandardPseudoInstruction { 1346 let OutOperandList = (outs variable_ops); 1347 let InOperandList = (ins variable_ops); 1348 let usesCustomInserter = true; 1349 let mayLoad = true; 1350 let mayStore = true; 1351 let hasSideEffects = true; 1352 let isCall = true; 1353} 1354def LOAD_STACK_GUARD : StandardPseudoInstruction { 1355 let OutOperandList = (outs ptr_rc:$dst); 1356 let InOperandList = (ins); 1357 let mayLoad = true; 1358 bit isReMaterializable = true; 1359 let hasSideEffects = false; 1360 bit isPseudo = true; 1361} 1362def PREALLOCATED_SETUP : StandardPseudoInstruction { 1363 let OutOperandList = (outs); 1364 let InOperandList = (ins i32imm:$a); 1365 let usesCustomInserter = true; 1366 let hasSideEffects = true; 1367} 1368def PREALLOCATED_ARG : StandardPseudoInstruction { 1369 let OutOperandList = (outs ptr_rc:$loc); 1370 let InOperandList = (ins i32imm:$a, i32imm:$b); 1371 let usesCustomInserter = true; 1372 let hasSideEffects = true; 1373} 1374def LOCAL_ESCAPE : StandardPseudoInstruction { 1375 // This instruction is really just a label. It has to be part of the chain so 1376 // that it doesn't get dropped from the DAG, but it produces nothing and has 1377 // no side effects. 1378 let OutOperandList = (outs); 1379 let InOperandList = (ins ptr_rc:$symbol, i32imm:$id); 1380 let hasSideEffects = false; 1381 let hasCtrlDep = true; 1382} 1383def FAULTING_OP : StandardPseudoInstruction { 1384 let OutOperandList = (outs unknown:$dst); 1385 let InOperandList = (ins variable_ops); 1386 let usesCustomInserter = true; 1387 let hasSideEffects = true; 1388 let mayLoad = true; 1389 let mayStore = true; 1390 let isTerminator = true; 1391 let isBranch = true; 1392} 1393def PATCHABLE_OP : StandardPseudoInstruction { 1394 let OutOperandList = (outs); 1395 let InOperandList = (ins variable_ops); 1396 let usesCustomInserter = true; 1397 let mayLoad = true; 1398 let mayStore = true; 1399 let hasSideEffects = true; 1400} 1401def PATCHABLE_FUNCTION_ENTER : StandardPseudoInstruction { 1402 let OutOperandList = (outs); 1403 let InOperandList = (ins); 1404 let AsmString = "# XRay Function Enter."; 1405 let usesCustomInserter = true; 1406 let hasSideEffects = true; 1407} 1408def PATCHABLE_RET : StandardPseudoInstruction { 1409 let OutOperandList = (outs); 1410 let InOperandList = (ins variable_ops); 1411 let AsmString = "# XRay Function Patchable RET."; 1412 let usesCustomInserter = true; 1413 let hasSideEffects = true; 1414 let isTerminator = true; 1415 let isReturn = true; 1416} 1417def PATCHABLE_FUNCTION_EXIT : StandardPseudoInstruction { 1418 let OutOperandList = (outs); 1419 let InOperandList = (ins); 1420 let AsmString = "# XRay Function Exit."; 1421 let usesCustomInserter = true; 1422 let hasSideEffects = true; 1423 let isReturn = false; // Original return instruction will follow 1424} 1425def PATCHABLE_TAIL_CALL : StandardPseudoInstruction { 1426 let OutOperandList = (outs); 1427 let InOperandList = (ins variable_ops); 1428 let AsmString = "# XRay Tail Call Exit."; 1429 let usesCustomInserter = true; 1430 let hasSideEffects = true; 1431 let isReturn = true; 1432} 1433def PATCHABLE_EVENT_CALL : StandardPseudoInstruction { 1434 let OutOperandList = (outs); 1435 let InOperandList = (ins ptr_rc:$event, unknown:$size); 1436 let AsmString = "# XRay Custom Event Log."; 1437 let usesCustomInserter = true; 1438 let isCall = true; 1439 let mayLoad = true; 1440 let mayStore = true; 1441 let hasSideEffects = true; 1442} 1443def PATCHABLE_TYPED_EVENT_CALL : StandardPseudoInstruction { 1444 let OutOperandList = (outs); 1445 let InOperandList = (ins unknown:$type, ptr_rc:$event, unknown:$size); 1446 let AsmString = "# XRay Typed Event Log."; 1447 let usesCustomInserter = true; 1448 let isCall = true; 1449 let mayLoad = true; 1450 let mayStore = true; 1451 let hasSideEffects = true; 1452} 1453def FENTRY_CALL : StandardPseudoInstruction { 1454 let OutOperandList = (outs); 1455 let InOperandList = (ins); 1456 let AsmString = "# FEntry call"; 1457 let usesCustomInserter = true; 1458 let isCall = true; 1459 let mayLoad = true; 1460 let mayStore = true; 1461 let hasSideEffects = true; 1462} 1463def ICALL_BRANCH_FUNNEL : StandardPseudoInstruction { 1464 let OutOperandList = (outs); 1465 let InOperandList = (ins variable_ops); 1466 let AsmString = ""; 1467 let hasSideEffects = true; 1468} 1469def MEMBARRIER : StandardPseudoInstruction { 1470 let OutOperandList = (outs); 1471 let InOperandList = (ins); 1472 let AsmString = ""; 1473 let hasSideEffects = true; 1474 let Size = 0; 1475 let isMeta = true; 1476} 1477def JUMP_TABLE_DEBUG_INFO : StandardPseudoInstruction { 1478 let OutOperandList = (outs); 1479 let InOperandList = (ins i64imm:$jti); 1480 let AsmString = ""; 1481 let hasSideEffects = false; 1482 let Size = 0; 1483 let isMeta = true; 1484} 1485 1486let hasSideEffects = false, isMeta = true, isConvergent = true in { 1487def CONVERGENCECTRL_ANCHOR : StandardPseudoInstruction { 1488 let OutOperandList = (outs unknown:$dst); 1489 let InOperandList = (ins); 1490} 1491def CONVERGENCECTRL_ENTRY : StandardPseudoInstruction { 1492 let OutOperandList = (outs unknown:$dst); 1493 let InOperandList = (ins); 1494} 1495def CONVERGENCECTRL_LOOP : StandardPseudoInstruction { 1496 let OutOperandList = (outs unknown:$dst); 1497 let InOperandList = (ins unknown:$src); 1498} 1499def CONVERGENCECTRL_GLUE : StandardPseudoInstruction { 1500 let OutOperandList = (outs); 1501 let InOperandList = (ins unknown:$src); 1502} 1503} 1504 1505// Generic opcodes used in GlobalISel. 1506include "llvm/Target/GenericOpcodes.td" 1507 1508//===----------------------------------------------------------------------===// 1509// AsmParser - This class can be implemented by targets that wish to implement 1510// .s file parsing. 1511// 1512// Subtargets can have multiple different assembly parsers (e.g. AT&T vs Intel 1513// syntax on X86 for example). 1514// 1515class AsmParser { 1516 // AsmParserClassName - This specifies the suffix to use for the asmparser 1517 // class. Generated AsmParser classes are always prefixed with the target 1518 // name. 1519 string AsmParserClassName = "AsmParser"; 1520 1521 // AsmParserInstCleanup - If non-empty, this is the name of a custom member 1522 // function of the AsmParser class to call on every matched instruction. 1523 // This can be used to perform target specific instruction post-processing. 1524 string AsmParserInstCleanup = ""; 1525 1526 // ShouldEmitMatchRegisterName - Set to false if the target needs a hand 1527 // written register name matcher 1528 bit ShouldEmitMatchRegisterName = true; 1529 1530 // Set to true if the target needs a generated 'alternative register name' 1531 // matcher. 1532 // 1533 // This generates a function which can be used to lookup registers from 1534 // their aliases. This function will fail when called on targets where 1535 // several registers share the same alias (i.e. not a 1:1 mapping). 1536 bit ShouldEmitMatchRegisterAltName = false; 1537 1538 // Set to true if MatchRegisterName and MatchRegisterAltName functions 1539 // should be generated even if there are duplicate register names. The 1540 // target is responsible for coercing aliased registers as necessary 1541 // (e.g. in validateTargetOperandClass), and there are no guarantees about 1542 // which numeric register identifier will be returned in the case of 1543 // multiple matches. 1544 bit AllowDuplicateRegisterNames = false; 1545 1546 // HasMnemonicFirst - Set to false if target instructions don't always 1547 // start with a mnemonic as the first token. 1548 bit HasMnemonicFirst = true; 1549 1550 // ReportMultipleNearMisses - 1551 // When 0, the assembly matcher reports an error for one encoding or operand 1552 // that did not match the parsed instruction. 1553 // When 1, the assembly matcher returns a list of encodings that were close 1554 // to matching the parsed instruction, so to allow more detailed error 1555 // messages. 1556 bit ReportMultipleNearMisses = false; 1557 1558 // OperandParserMethod - If non-empty, this is the name of a custom 1559 // member function of the AsmParser class to call for every instruction 1560 // operand to be parsed. 1561 string OperandParserMethod = ""; 1562 1563 // CallCustomParserForAllOperands - Set to true if the custom parser 1564 // method shall be called for all operands as opposed to only those 1565 // that have their own specified custom parsers. 1566 bit CallCustomParserForAllOperands = false; 1567} 1568def DefaultAsmParser : AsmParser; 1569 1570//===----------------------------------------------------------------------===// 1571// AsmParserVariant - Subtargets can have multiple different assembly parsers 1572// (e.g. AT&T vs Intel syntax on X86 for example). This class can be 1573// implemented by targets to describe such variants. 1574// 1575class AsmParserVariant { 1576 // Variant - AsmParsers can be of multiple different variants. Variants are 1577 // used to support targets that need to parse multiple formats for the 1578 // assembly language. 1579 int Variant = 0; 1580 1581 // Name - The AsmParser variant name (e.g., AT&T vs Intel). 1582 string Name = ""; 1583 1584 // CommentDelimiter - If given, the delimiter string used to recognize 1585 // comments which are hard coded in the .td assembler strings for individual 1586 // instructions. 1587 string CommentDelimiter = ""; 1588 1589 // RegisterPrefix - If given, the token prefix which indicates a register 1590 // token. This is used by the matcher to automatically recognize hard coded 1591 // register tokens as constrained registers, instead of tokens, for the 1592 // purposes of matching. 1593 string RegisterPrefix = ""; 1594 1595 // TokenizingCharacters - Characters that are standalone tokens 1596 string TokenizingCharacters = "[]*!"; 1597 1598 // SeparatorCharacters - Characters that are not tokens 1599 string SeparatorCharacters = " \t,"; 1600 1601 // BreakCharacters - Characters that start new identifiers 1602 string BreakCharacters = ""; 1603} 1604def DefaultAsmParserVariant : AsmParserVariant; 1605 1606// Operators for combining SubtargetFeatures in AssemblerPredicates 1607def any_of; 1608def all_of; 1609 1610/// AssemblerPredicate - This is a Predicate that can be used when the assembler 1611/// matches instructions and aliases. 1612class AssemblerPredicate<dag cond, string name = ""> { 1613 bit AssemblerMatcherPredicate = true; 1614 dag AssemblerCondDag = cond; 1615 string PredicateName = name; 1616} 1617 1618/// TokenAlias - This class allows targets to define assembler token 1619/// operand aliases. That is, a token literal operand which is equivalent 1620/// to another, canonical, token literal. For example, ARM allows: 1621/// vmov.u32 s4, #0 -> vmov.i32, #0 1622/// 'u32' is a more specific designator for the 32-bit integer type specifier 1623/// and is legal for any instruction which accepts 'i32' as a datatype suffix. 1624/// def : TokenAlias<".u32", ".i32">; 1625/// 1626/// This works by marking the match class of 'From' as a subclass of the 1627/// match class of 'To'. 1628class TokenAlias<string From, string To> { 1629 string FromToken = From; 1630 string ToToken = To; 1631} 1632 1633/// MnemonicAlias - This class allows targets to define assembler mnemonic 1634/// aliases. This should be used when all forms of one mnemonic are accepted 1635/// with a different mnemonic. For example, X86 allows: 1636/// sal %al, 1 -> shl %al, 1 1637/// sal %ax, %cl -> shl %ax, %cl 1638/// sal %eax, %cl -> shl %eax, %cl 1639/// etc. Though "sal" is accepted with many forms, all of them are directly 1640/// translated to a shl, so it can be handled with (in the case of X86, it 1641/// actually has one for each suffix as well): 1642/// def : MnemonicAlias<"sal", "shl">; 1643/// 1644/// Mnemonic aliases are mapped before any other translation in the match phase, 1645/// and do allow Requires predicates, e.g.: 1646/// 1647/// def : MnemonicAlias<"pushf", "pushfq">, Requires<[In64BitMode]>; 1648/// def : MnemonicAlias<"pushf", "pushfl">, Requires<[In32BitMode]>; 1649/// 1650/// Mnemonic aliases can also be constrained to specific variants, e.g.: 1651/// 1652/// def : MnemonicAlias<"pushf", "pushfq", "att">, Requires<[In64BitMode]>; 1653/// 1654/// If no variant (e.g., "att" or "intel") is specified then the alias is 1655/// applied unconditionally. 1656class MnemonicAlias<string From, string To, string VariantName = ""> { 1657 string FromMnemonic = From; 1658 string ToMnemonic = To; 1659 string AsmVariantName = VariantName; 1660 1661 // Predicates - Predicates that must be true for this remapping to happen. 1662 list<Predicate> Predicates = []; 1663} 1664 1665/// InstAlias - This defines an alternate assembly syntax that is allowed to 1666/// match an instruction that has a different (more canonical) assembly 1667/// representation. 1668class InstAlias<string Asm, dag Result, int Emit = 1, string VariantName = ""> { 1669 string AsmString = Asm; // The .s format to match the instruction with. 1670 dag ResultInst = Result; // The MCInst to generate. 1671 1672 // This determines which order the InstPrinter detects aliases for 1673 // printing. A larger value makes the alias more likely to be 1674 // emitted. The Instruction's own definition is notionally 0.5, so 0 1675 // disables printing and 1 enables it if there are no conflicting aliases. 1676 int EmitPriority = Emit; 1677 1678 // Predicates - Predicates that must be true for this to match. 1679 list<Predicate> Predicates = []; 1680 1681 // If the instruction specified in Result has defined an AsmMatchConverter 1682 // then setting this to 1 will cause the alias to use the AsmMatchConverter 1683 // function when converting the OperandVector into an MCInst instead of the 1684 // function that is generated by the dag Result. 1685 // Setting this to 0 will cause the alias to ignore the Result instruction's 1686 // defined AsmMatchConverter and instead use the function generated by the 1687 // dag Result. 1688 bit UseInstAsmMatchConverter = true; 1689 1690 // Assembler variant name to use for this alias. If not specified then 1691 // assembler variants will be determined based on AsmString 1692 string AsmVariantName = VariantName; 1693} 1694 1695//===----------------------------------------------------------------------===// 1696// AsmWriter - This class can be implemented by targets that need to customize 1697// the format of the .s file writer. 1698// 1699// Subtargets can have multiple different asmwriters (e.g. AT&T vs Intel syntax 1700// on X86 for example). 1701// 1702class AsmWriter { 1703 // AsmWriterClassName - This specifies the suffix to use for the asmwriter 1704 // class. Generated AsmWriter classes are always prefixed with the target 1705 // name. 1706 string AsmWriterClassName = "InstPrinter"; 1707 1708 // PassSubtarget - Determines whether MCSubtargetInfo should be passed to 1709 // the various print methods. 1710 // FIXME: Remove after all ports are updated. 1711 int PassSubtarget = 0; 1712 1713 // Variant - AsmWriters can be of multiple different variants. Variants are 1714 // used to support targets that need to emit assembly code in ways that are 1715 // mostly the same for different targets, but have minor differences in 1716 // syntax. If the asmstring contains {|} characters in them, this integer 1717 // will specify which alternative to use. For example "{x|y|z}" with Variant 1718 // == 1, will expand to "y". 1719 int Variant = 0; 1720} 1721def DefaultAsmWriter : AsmWriter; 1722 1723 1724//===----------------------------------------------------------------------===// 1725// Target - This class contains the "global" target information 1726// 1727class Target { 1728 // InstructionSet - Instruction set description for this target. 1729 InstrInfo InstructionSet; 1730 1731 // AssemblyParsers - The AsmParser instances available for this target. 1732 list<AsmParser> AssemblyParsers = [DefaultAsmParser]; 1733 1734 /// AssemblyParserVariants - The AsmParserVariant instances available for 1735 /// this target. 1736 list<AsmParserVariant> AssemblyParserVariants = [DefaultAsmParserVariant]; 1737 1738 // AssemblyWriters - The AsmWriter instances available for this target. 1739 list<AsmWriter> AssemblyWriters = [DefaultAsmWriter]; 1740 1741 // AllowRegisterRenaming - Controls whether this target allows 1742 // post-register-allocation renaming of registers. This is done by 1743 // setting hasExtraDefRegAllocReq and hasExtraSrcRegAllocReq to 1 1744 // for all opcodes if this flag is set to 0. 1745 int AllowRegisterRenaming = 0; 1746} 1747 1748//===----------------------------------------------------------------------===// 1749// Processor chip sets - These values represent each of the chip sets supported 1750// by the scheduler. Each Processor definition requires corresponding 1751// instruction itineraries. 1752// 1753class Processor<string n, ProcessorItineraries pi, list<SubtargetFeature> f, 1754 list<SubtargetFeature> tunef = []> { 1755 // Name - Chip set name. Used by command line (-mcpu=) to determine the 1756 // appropriate target chip. 1757 // 1758 string Name = n; 1759 1760 // SchedModel - The machine model for scheduling and instruction cost. 1761 // 1762 SchedMachineModel SchedModel = NoSchedModel; 1763 1764 // ProcItin - The scheduling information for the target processor. 1765 // 1766 ProcessorItineraries ProcItin = pi; 1767 1768 // Features - list of 1769 list<SubtargetFeature> Features = f; 1770 1771 // TuneFeatures - list of features for tuning for this CPU. If the target 1772 // supports -mtune, this should contain the list of features used to make 1773 // microarchitectural optimization decisions for a given processor. While 1774 // Features should contain the architectural features for the processor. 1775 list<SubtargetFeature> TuneFeatures = tunef; 1776} 1777 1778// ProcessorModel allows subtargets to specify the more general 1779// SchedMachineModel instead if a ProcessorItinerary. Subtargets will 1780// gradually move to this newer form. 1781// 1782// Although this class always passes NoItineraries to the Processor 1783// class, the SchedMachineModel may still define valid Itineraries. 1784class ProcessorModel<string n, SchedMachineModel m, list<SubtargetFeature> f, 1785 list<SubtargetFeature> tunef = []> 1786 : Processor<n, NoItineraries, f, tunef> { 1787 let SchedModel = m; 1788} 1789 1790//===----------------------------------------------------------------------===// 1791// InstrMapping - This class is used to create mapping tables to relate 1792// instructions with each other based on the values specified in RowFields, 1793// ColFields, KeyCol and ValueCols. 1794// 1795class InstrMapping { 1796 // FilterClass - Used to limit search space only to the instructions that 1797 // define the relationship modeled by this InstrMapping record. 1798 string FilterClass; 1799 1800 // RowFields - List of fields/attributes that should be same for all the 1801 // instructions in a row of the relation table. Think of this as a set of 1802 // properties shared by all the instructions related by this relationship 1803 // model and is used to categorize instructions into subgroups. For instance, 1804 // if we want to define a relation that maps 'Add' instruction to its 1805 // predicated forms, we can define RowFields like this: 1806 // 1807 // let RowFields = BaseOp 1808 // All add instruction predicated/non-predicated will have to set their BaseOp 1809 // to the same value. 1810 // 1811 // def Add: { let BaseOp = 'ADD'; let predSense = 'nopred' } 1812 // def Add_predtrue: { let BaseOp = 'ADD'; let predSense = 'true' } 1813 // def Add_predfalse: { let BaseOp = 'ADD'; let predSense = 'false' } 1814 list<string> RowFields = []; 1815 1816 // List of fields/attributes that are same for all the instructions 1817 // in a column of the relation table. 1818 // Ex: let ColFields = 'predSense' -- It means that the columns are arranged 1819 // based on the 'predSense' values. All the instruction in a specific 1820 // column have the same value and it is fixed for the column according 1821 // to the values set in 'ValueCols'. 1822 list<string> ColFields = []; 1823 1824 // Values for the fields/attributes listed in 'ColFields'. 1825 // Ex: let KeyCol = 'nopred' -- It means that the key instruction (instruction 1826 // that models this relation) should be non-predicated. 1827 // In the example above, 'Add' is the key instruction. 1828 list<string> KeyCol = []; 1829 1830 // List of values for the fields/attributes listed in 'ColFields', one for 1831 // each column in the relation table. 1832 // 1833 // Ex: let ValueCols = [['true'],['false']] -- It adds two columns in the 1834 // table. First column requires all the instructions to have predSense 1835 // set to 'true' and second column requires it to be 'false'. 1836 list<list<string> > ValueCols = []; 1837} 1838 1839//===----------------------------------------------------------------------===// 1840// Pull in the common support for calling conventions. 1841// 1842include "llvm/Target/TargetCallingConv.td" 1843 1844//===----------------------------------------------------------------------===// 1845// Pull in the common support for DAG isel generation. 1846// 1847include "llvm/Target/TargetSelectionDAG.td" 1848 1849//===----------------------------------------------------------------------===// 1850// Pull in the common support for Global ISel register bank info generation. 1851// 1852include "llvm/Target/GlobalISel/RegisterBank.td" 1853 1854//===----------------------------------------------------------------------===// 1855// Pull in the common support for DAG isel generation. 1856// 1857include "llvm/Target/GlobalISel/Target.td" 1858 1859//===----------------------------------------------------------------------===// 1860// Pull in the common support for the Global ISel DAG-based selector generation. 1861// 1862include "llvm/Target/GlobalISel/SelectionDAGCompat.td" 1863 1864//===----------------------------------------------------------------------===// 1865// Pull in the common support for Pfm Counters generation. 1866// 1867include "llvm/Target/TargetPfmCounters.td" 1868