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