1 //===-- SystemZOperands.td - SystemZ instruction operands ----*- tblgen-*--===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 //===----------------------------------------------------------------------===// 11 // Class definitions 12 //===----------------------------------------------------------------------===// 13 14 class ImmediateAsmOperand<string name> 15 : AsmOperandClass { 16 let Name = name; 17 let RenderMethod = "addImmOperands"; 18 } 19 class ImmediateTLSAsmOperand<string name> 20 : AsmOperandClass { 21 let Name = name; 22 let RenderMethod = "addImmTLSOperands"; 23 } 24 25 // Constructs both a DAG pattern and instruction operand for an immediate 26 // of type VT. PRED returns true if a node is acceptable and XFORM returns 27 // the operand value associated with the node. ASMOP is the name of the 28 // associated asm operand, and also forms the basis of the asm print method. 29 class Immediate<ValueType vt, code pred, SDNodeXForm xform, string asmop> 30 : PatLeaf<(vt imm), pred, xform>, Operand<vt> { 31 let PrintMethod = "print"##asmop##"Operand"; 32 let DecoderMethod = "decode"##asmop##"Operand"; 33 let ParserMatchClass = !cast<AsmOperandClass>(asmop); 34 } 35 36 // Constructs an asm operand for a PC-relative address. SIZE says how 37 // many bits there are. 38 class PCRelAsmOperand<string size> : ImmediateAsmOperand<"PCRel"##size> { 39 let PredicateMethod = "isImm"; 40 let ParserMethod = "parsePCRel"##size; 41 } 42 class PCRelTLSAsmOperand<string size> 43 : ImmediateTLSAsmOperand<"PCRelTLS"##size> { 44 let PredicateMethod = "isImmTLS"; 45 let ParserMethod = "parsePCRelTLS"##size; 46 } 47 48 // Constructs an operand for a PC-relative address with address type VT. 49 // ASMOP is the associated asm operand. 50 class PCRelOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> { 51 let PrintMethod = "printPCRelOperand"; 52 let ParserMatchClass = asmop; 53 } 54 class PCRelTLSOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> { 55 let PrintMethod = "printPCRelTLSOperand"; 56 let ParserMatchClass = asmop; 57 } 58 59 // Constructs both a DAG pattern and instruction operand for a PC-relative 60 // address with address size VT. SELF is the name of the operand and 61 // ASMOP is the associated asm operand. 62 class PCRelAddress<ValueType vt, string self, AsmOperandClass asmop> 63 : ComplexPattern<vt, 1, "selectPCRelAddress", 64 [z_pcrel_wrapper, z_pcrel_offset]>, 65 PCRelOperand<vt, asmop> { 66 let MIOperandInfo = (ops !cast<Operand>(self)); 67 } 68 69 // Constructs an AsmOperandClass for addressing mode FORMAT, treating the 70 // registers as having BITSIZE bits and displacements as having DISPSIZE bits. 71 // LENGTH is "LenN" for addresses with an N-bit length field, otherwise it 72 // is "". 73 class AddressAsmOperand<string format, string bitsize, string dispsize, 74 string length = ""> 75 : AsmOperandClass { 76 let Name = format##bitsize##"Disp"##dispsize##length; 77 let ParserMethod = "parse"##format##bitsize; 78 let RenderMethod = "add"##format##"Operands"; 79 } 80 81 // Constructs an instruction operand for an addressing mode. FORMAT, 82 // BITSIZE, DISPSIZE and LENGTH are the parameters to an associated 83 // AddressAsmOperand. OPERANDS is a list of individual operands 84 // (base register, displacement, etc.). 85 class AddressOperand<string bitsize, string dispsize, string length, 86 string format, dag operands> 87 : Operand<!cast<ValueType>("i"##bitsize)> { 88 let PrintMethod = "print"##format##"Operand"; 89 let EncoderMethod = "get"##format##dispsize##length##"Encoding"; 90 let DecoderMethod = 91 "decode"##format##bitsize##"Disp"##dispsize##length##"Operand"; 92 let MIOperandInfo = operands; 93 let ParserMatchClass = 94 !cast<AddressAsmOperand>(format##bitsize##"Disp"##dispsize##length); 95 } 96 97 // Constructs both a DAG pattern and instruction operand for an addressing mode. 98 // FORMAT, BITSIZE, DISPSIZE and LENGTH are the parameters to an associated 99 // AddressAsmOperand. OPERANDS is a list of NUMOPS individual operands 100 // (base register, displacement, etc.). SELTYPE is the type of the memory 101 // operand for selection purposes; sometimes we want different selection 102 // choices for the same underlying addressing mode. SUFFIX is similarly 103 // a suffix appended to the displacement for selection purposes; 104 // e.g. we want to reject small 20-bit displacements if a 12-bit form 105 // also exists, but we want to accept them otherwise. 106 class AddressingMode<string seltype, string bitsize, string dispsize, 107 string suffix, string length, int numops, string format, 108 dag operands> 109 : ComplexPattern<!cast<ValueType>("i"##bitsize), numops, 110 "select"##seltype##dispsize##suffix##length, 111 [add, sub, or, frameindex, z_adjdynalloc]>, 112 AddressOperand<bitsize, dispsize, length, format, operands>; 113 114 // An addressing mode with a base and displacement but no index. 115 class BDMode<string type, string bitsize, string dispsize, string suffix> 116 : AddressingMode<type, bitsize, dispsize, suffix, "", 2, "BDAddr", 117 (ops !cast<RegisterOperand>("ADDR"##bitsize), 118 !cast<Operand>("disp"##dispsize##"imm"##bitsize))>; 119 120 // An addressing mode with a base, displacement and index. 121 class BDXMode<string type, string bitsize, string dispsize, string suffix> 122 : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDXAddr", 123 (ops !cast<RegisterOperand>("ADDR"##bitsize), 124 !cast<Operand>("disp"##dispsize##"imm"##bitsize), 125 !cast<RegisterOperand>("ADDR"##bitsize))>; 126 127 // A BDMode paired with an immediate length operand of LENSIZE bits. 128 class BDLMode<string type, string bitsize, string dispsize, string suffix, 129 string lensize> 130 : AddressingMode<type, bitsize, dispsize, suffix, "Len"##lensize, 3, 131 "BDLAddr", 132 (ops !cast<RegisterOperand>("ADDR"##bitsize), 133 !cast<Operand>("disp"##dispsize##"imm"##bitsize), 134 !cast<Operand>("imm"##bitsize))>; 135 136 // A BDMode paired with a register length operand. 137 class BDRMode<string type, string bitsize, string dispsize, string suffix> 138 : AddressingMode<type, bitsize, dispsize, suffix, "", 3, "BDRAddr", 139 (ops !cast<RegisterOperand>("ADDR"##bitsize), 140 !cast<Operand>("disp"##dispsize##"imm"##bitsize), 141 !cast<RegisterOperand>("GR"##bitsize))>; 142 143 // An addressing mode with a base, displacement and a vector index. 144 class BDVMode<string bitsize, string dispsize> 145 : AddressOperand<bitsize, dispsize, "", "BDVAddr", 146 (ops !cast<RegisterOperand>("ADDR"##bitsize), 147 !cast<Operand>("disp"##dispsize##"imm"##bitsize), 148 !cast<RegisterOperand>("VR128"))>; 149 150 //===----------------------------------------------------------------------===// 151 // Extracting immediate operands from nodes 152 // These all create MVT::i64 nodes to ensure the value is not sign-extended 153 // when converted from an SDNode to a MachineOperand later on. 154 //===----------------------------------------------------------------------===// 155 156 // Bits 0-15 (counting from the lsb). 157 def LL16 : SDNodeXForm<imm, [{ 158 uint64_t Value = N->getZExtValue() & 0x000000000000FFFFULL; 159 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64); 160 }]>; 161 162 // Bits 16-31 (counting from the lsb). 163 def LH16 : SDNodeXForm<imm, [{ 164 uint64_t Value = (N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16; 165 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64); 166 }]>; 167 168 // Bits 32-47 (counting from the lsb). 169 def HL16 : SDNodeXForm<imm, [{ 170 uint64_t Value = (N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32; 171 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64); 172 }]>; 173 174 // Bits 48-63 (counting from the lsb). 175 def HH16 : SDNodeXForm<imm, [{ 176 uint64_t Value = (N->getZExtValue() & 0xFFFF000000000000ULL) >> 48; 177 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64); 178 }]>; 179 180 // Low 32 bits. 181 def LF32 : SDNodeXForm<imm, [{ 182 uint64_t Value = N->getZExtValue() & 0x00000000FFFFFFFFULL; 183 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64); 184 }]>; 185 186 // High 32 bits. 187 def HF32 : SDNodeXForm<imm, [{ 188 uint64_t Value = N->getZExtValue() >> 32; 189 return CurDAG->getTargetConstant(Value, SDLoc(N), MVT::i64); 190 }]>; 191 192 // Truncate an immediate to a 8-bit signed quantity. 193 def SIMM8 : SDNodeXForm<imm, [{ 194 return CurDAG->getTargetConstant(int8_t(N->getZExtValue()), SDLoc(N), 195 MVT::i64); 196 }]>; 197 198 // Truncate an immediate to a 8-bit unsigned quantity. 199 def UIMM8 : SDNodeXForm<imm, [{ 200 return CurDAG->getTargetConstant(uint8_t(N->getZExtValue()), SDLoc(N), 201 MVT::i64); 202 }]>; 203 204 // Truncate an immediate to a 8-bit unsigned quantity and mask off low bit. 205 def UIMM8EVEN : SDNodeXForm<imm, [{ 206 return CurDAG->getTargetConstant(N->getZExtValue() & 0xfe, SDLoc(N), 207 MVT::i64); 208 }]>; 209 210 // Truncate an immediate to a 12-bit unsigned quantity. 211 def UIMM12 : SDNodeXForm<imm, [{ 212 return CurDAG->getTargetConstant(N->getZExtValue() & 0xfff, SDLoc(N), 213 MVT::i64); 214 }]>; 215 216 // Truncate an immediate to a 16-bit signed quantity. 217 def SIMM16 : SDNodeXForm<imm, [{ 218 return CurDAG->getTargetConstant(int16_t(N->getZExtValue()), SDLoc(N), 219 MVT::i64); 220 }]>; 221 222 // Negate and then truncate an immediate to a 16-bit signed quantity. 223 def NEGSIMM16 : SDNodeXForm<imm, [{ 224 return CurDAG->getTargetConstant(int16_t(-N->getZExtValue()), SDLoc(N), 225 MVT::i64); 226 }]>; 227 228 // Truncate an immediate to a 16-bit unsigned quantity. 229 def UIMM16 : SDNodeXForm<imm, [{ 230 return CurDAG->getTargetConstant(uint16_t(N->getZExtValue()), SDLoc(N), 231 MVT::i64); 232 }]>; 233 234 // Truncate an immediate to a 32-bit signed quantity. 235 def SIMM32 : SDNodeXForm<imm, [{ 236 return CurDAG->getTargetConstant(int32_t(N->getZExtValue()), SDLoc(N), 237 MVT::i64); 238 }]>; 239 240 // Negate and then truncate an immediate to a 32-bit unsigned quantity. 241 def NEGSIMM32 : SDNodeXForm<imm, [{ 242 return CurDAG->getTargetConstant(int32_t(-N->getZExtValue()), SDLoc(N), 243 MVT::i64); 244 }]>; 245 246 // Truncate an immediate to a 32-bit unsigned quantity. 247 def UIMM32 : SDNodeXForm<imm, [{ 248 return CurDAG->getTargetConstant(uint32_t(N->getZExtValue()), SDLoc(N), 249 MVT::i64); 250 }]>; 251 252 // Negate and then truncate an immediate to a 32-bit unsigned quantity. 253 def NEGUIMM32 : SDNodeXForm<imm, [{ 254 return CurDAG->getTargetConstant(uint32_t(-N->getZExtValue()), SDLoc(N), 255 MVT::i64); 256 }]>; 257 258 // Truncate an immediate to a 48-bit unsigned quantity. 259 def UIMM48 : SDNodeXForm<imm, [{ 260 return CurDAG->getTargetConstant(uint64_t(N->getZExtValue()) & 0xffffffffffff, 261 SDLoc(N), MVT::i64); 262 }]>; 263 264 //===----------------------------------------------------------------------===// 265 // Immediate asm operands. 266 //===----------------------------------------------------------------------===// 267 268 def U1Imm : ImmediateAsmOperand<"U1Imm">; 269 def U2Imm : ImmediateAsmOperand<"U2Imm">; 270 def U3Imm : ImmediateAsmOperand<"U3Imm">; 271 def U4Imm : ImmediateAsmOperand<"U4Imm">; 272 def U6Imm : ImmediateAsmOperand<"U6Imm">; 273 def S8Imm : ImmediateAsmOperand<"S8Imm">; 274 def U8Imm : ImmediateAsmOperand<"U8Imm">; 275 def U12Imm : ImmediateAsmOperand<"U12Imm">; 276 def S16Imm : ImmediateAsmOperand<"S16Imm">; 277 def U16Imm : ImmediateAsmOperand<"U16Imm">; 278 def S32Imm : ImmediateAsmOperand<"S32Imm">; 279 def U32Imm : ImmediateAsmOperand<"U32Imm">; 280 def U48Imm : ImmediateAsmOperand<"U48Imm">; 281 282 //===----------------------------------------------------------------------===// 283 // i32 immediates 284 //===----------------------------------------------------------------------===// 285 286 // Immediates for the lower and upper 16 bits of an i32, with the other 287 // bits of the i32 being zero. 288 def imm32ll16 : Immediate<i32, [{ 289 return SystemZ::isImmLL(N->getZExtValue()); 290 }], LL16, "U16Imm">; 291 292 def imm32lh16 : Immediate<i32, [{ 293 return SystemZ::isImmLH(N->getZExtValue()); 294 }], LH16, "U16Imm">; 295 296 // Immediates for the lower and upper 16 bits of an i32, with the other 297 // bits of the i32 being one. 298 def imm32ll16c : Immediate<i32, [{ 299 return SystemZ::isImmLL(uint32_t(~N->getZExtValue())); 300 }], LL16, "U16Imm">; 301 302 def imm32lh16c : Immediate<i32, [{ 303 return SystemZ::isImmLH(uint32_t(~N->getZExtValue())); 304 }], LH16, "U16Imm">; 305 306 // Short immediates 307 def imm32zx1 : Immediate<i32, [{ 308 return isUInt<1>(N->getZExtValue()); 309 }], NOOP_SDNodeXForm, "U1Imm">; 310 311 def imm32zx2 : Immediate<i32, [{ 312 return isUInt<2>(N->getZExtValue()); 313 }], NOOP_SDNodeXForm, "U2Imm">; 314 315 def imm32zx3 : Immediate<i32, [{ 316 return isUInt<3>(N->getZExtValue()); 317 }], NOOP_SDNodeXForm, "U3Imm">; 318 319 def imm32zx4 : Immediate<i32, [{ 320 return isUInt<4>(N->getZExtValue()); 321 }], NOOP_SDNodeXForm, "U4Imm">; 322 323 // Note: this enforces an even value during code generation only. 324 // When used from the assembler, any 4-bit value is allowed. 325 def imm32zx4even : Immediate<i32, [{ 326 return isUInt<4>(N->getZExtValue()); 327 }], UIMM8EVEN, "U4Imm">; 328 329 def imm32zx6 : Immediate<i32, [{ 330 return isUInt<6>(N->getZExtValue()); 331 }], NOOP_SDNodeXForm, "U6Imm">; 332 333 def imm32sx8 : Immediate<i32, [{ 334 return isInt<8>(N->getSExtValue()); 335 }], SIMM8, "S8Imm">; 336 337 def imm32zx8 : Immediate<i32, [{ 338 return isUInt<8>(N->getZExtValue()); 339 }], UIMM8, "U8Imm">; 340 341 def imm32zx8trunc : Immediate<i32, [{}], UIMM8, "U8Imm">; 342 343 def imm32zx12 : Immediate<i32, [{ 344 return isUInt<12>(N->getZExtValue()); 345 }], UIMM12, "U12Imm">; 346 347 def imm32sx16 : Immediate<i32, [{ 348 return isInt<16>(N->getSExtValue()); 349 }], SIMM16, "S16Imm">; 350 351 def imm32sx16n : Immediate<i32, [{ 352 return isInt<16>(-N->getSExtValue()); 353 }], NEGSIMM16, "S16Imm">; 354 355 def imm32zx16 : Immediate<i32, [{ 356 return isUInt<16>(N->getZExtValue()); 357 }], UIMM16, "U16Imm">; 358 359 def imm32sx16trunc : Immediate<i32, [{}], SIMM16, "S16Imm">; 360 def imm32zx16trunc : Immediate<i32, [{}], UIMM16, "U16Imm">; 361 362 // Full 32-bit immediates. we need both signed and unsigned versions 363 // because the assembler is picky. E.g. AFI requires signed operands 364 // while NILF requires unsigned ones. 365 def simm32 : Immediate<i32, [{}], SIMM32, "S32Imm">; 366 def uimm32 : Immediate<i32, [{}], UIMM32, "U32Imm">; 367 368 def simm32n : Immediate<i32, [{ 369 return isInt<32>(-N->getSExtValue()); 370 }], NEGSIMM32, "S32Imm">; 371 372 def imm32 : ImmLeaf<i32, [{}]>; 373 374 //===----------------------------------------------------------------------===// 375 // 64-bit immediates 376 //===----------------------------------------------------------------------===// 377 378 // Immediates for 16-bit chunks of an i64, with the other bits of the 379 // i32 being zero. 380 def imm64ll16 : Immediate<i64, [{ 381 return SystemZ::isImmLL(N->getZExtValue()); 382 }], LL16, "U16Imm">; 383 384 def imm64lh16 : Immediate<i64, [{ 385 return SystemZ::isImmLH(N->getZExtValue()); 386 }], LH16, "U16Imm">; 387 388 def imm64hl16 : Immediate<i64, [{ 389 return SystemZ::isImmHL(N->getZExtValue()); 390 }], HL16, "U16Imm">; 391 392 def imm64hh16 : Immediate<i64, [{ 393 return SystemZ::isImmHH(N->getZExtValue()); 394 }], HH16, "U16Imm">; 395 396 // Immediates for 16-bit chunks of an i64, with the other bits of the 397 // i32 being one. 398 def imm64ll16c : Immediate<i64, [{ 399 return SystemZ::isImmLL(uint64_t(~N->getZExtValue())); 400 }], LL16, "U16Imm">; 401 402 def imm64lh16c : Immediate<i64, [{ 403 return SystemZ::isImmLH(uint64_t(~N->getZExtValue())); 404 }], LH16, "U16Imm">; 405 406 def imm64hl16c : Immediate<i64, [{ 407 return SystemZ::isImmHL(uint64_t(~N->getZExtValue())); 408 }], HL16, "U16Imm">; 409 410 def imm64hh16c : Immediate<i64, [{ 411 return SystemZ::isImmHH(uint64_t(~N->getZExtValue())); 412 }], HH16, "U16Imm">; 413 414 // Immediates for the lower and upper 32 bits of an i64, with the other 415 // bits of the i32 being zero. 416 def imm64lf32 : Immediate<i64, [{ 417 return SystemZ::isImmLF(N->getZExtValue()); 418 }], LF32, "U32Imm">; 419 420 def imm64hf32 : Immediate<i64, [{ 421 return SystemZ::isImmHF(N->getZExtValue()); 422 }], HF32, "U32Imm">; 423 424 // Immediates for the lower and upper 32 bits of an i64, with the other 425 // bits of the i32 being one. 426 def imm64lf32c : Immediate<i64, [{ 427 return SystemZ::isImmLF(uint64_t(~N->getZExtValue())); 428 }], LF32, "U32Imm">; 429 430 def imm64hf32c : Immediate<i64, [{ 431 return SystemZ::isImmHF(uint64_t(~N->getZExtValue())); 432 }], HF32, "U32Imm">; 433 434 // Short immediates. 435 def imm64sx8 : Immediate<i64, [{ 436 return isInt<8>(N->getSExtValue()); 437 }], SIMM8, "S8Imm">; 438 439 def imm64zx8 : Immediate<i64, [{ 440 return isUInt<8>(N->getSExtValue()); 441 }], UIMM8, "U8Imm">; 442 443 def imm64sx16 : Immediate<i64, [{ 444 return isInt<16>(N->getSExtValue()); 445 }], SIMM16, "S16Imm">; 446 447 def imm64sx16n : Immediate<i64, [{ 448 return isInt<16>(-N->getSExtValue()); 449 }], NEGSIMM16, "S16Imm">; 450 451 def imm64zx16 : Immediate<i64, [{ 452 return isUInt<16>(N->getZExtValue()); 453 }], UIMM16, "U16Imm">; 454 455 def imm64sx32 : Immediate<i64, [{ 456 return isInt<32>(N->getSExtValue()); 457 }], SIMM32, "S32Imm">; 458 459 def imm64sx32n : Immediate<i64, [{ 460 return isInt<32>(-N->getSExtValue()); 461 }], NEGSIMM32, "S32Imm">; 462 463 def imm64zx32 : Immediate<i64, [{ 464 return isUInt<32>(N->getZExtValue()); 465 }], UIMM32, "U32Imm">; 466 467 def imm64zx32n : Immediate<i64, [{ 468 return isUInt<32>(-N->getSExtValue()); 469 }], NEGUIMM32, "U32Imm">; 470 471 def imm64zx48 : Immediate<i64, [{ 472 return isUInt<64>(N->getZExtValue()); 473 }], UIMM48, "U48Imm">; 474 475 def imm64 : ImmLeaf<i64, [{}]>, Operand<i64>; 476 477 //===----------------------------------------------------------------------===// 478 // Floating-point immediates 479 //===----------------------------------------------------------------------===// 480 481 // Floating-point zero. 482 def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>; 483 484 // Floating point negative zero. 485 def fpimmneg0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(-0.0); }]>; 486 487 //===----------------------------------------------------------------------===// 488 // Symbolic address operands 489 //===----------------------------------------------------------------------===// 490 491 // PC-relative asm operands. 492 def PCRel12 : PCRelAsmOperand<"12">; 493 def PCRel16 : PCRelAsmOperand<"16">; 494 def PCRel24 : PCRelAsmOperand<"24">; 495 def PCRel32 : PCRelAsmOperand<"32">; 496 def PCRelTLS16 : PCRelTLSAsmOperand<"16">; 497 def PCRelTLS32 : PCRelTLSAsmOperand<"32">; 498 499 // PC-relative offsets of a basic block. The offset is sign-extended 500 // and multiplied by 2. 501 def brtarget16 : PCRelOperand<OtherVT, PCRel16> { 502 let EncoderMethod = "getPC16DBLEncoding"; 503 let DecoderMethod = "decodePC16DBLBranchOperand"; 504 } 505 def brtarget32 : PCRelOperand<OtherVT, PCRel32> { 506 let EncoderMethod = "getPC32DBLEncoding"; 507 let DecoderMethod = "decodePC32DBLBranchOperand"; 508 } 509 510 // Variants of brtarget for use with branch prediction preload. 511 def brtarget12bpp : PCRelOperand<OtherVT, PCRel12> { 512 let EncoderMethod = "getPC12DBLBPPEncoding"; 513 let DecoderMethod = "decodePC12DBLBranchOperand"; 514 } 515 def brtarget16bpp : PCRelOperand<OtherVT, PCRel16> { 516 let EncoderMethod = "getPC16DBLBPPEncoding"; 517 let DecoderMethod = "decodePC16DBLBranchOperand"; 518 } 519 def brtarget24bpp : PCRelOperand<OtherVT, PCRel24> { 520 let EncoderMethod = "getPC24DBLBPPEncoding"; 521 let DecoderMethod = "decodePC24DBLBranchOperand"; 522 } 523 524 // Variants of brtarget16/32 with an optional additional TLS symbol. 525 // These are used to annotate calls to __tls_get_offset. 526 def tlssym : Operand<i64> { } 527 def brtarget16tls : PCRelTLSOperand<OtherVT, PCRelTLS16> { 528 let MIOperandInfo = (ops brtarget16:$func, tlssym:$sym); 529 let EncoderMethod = "getPC16DBLTLSEncoding"; 530 let DecoderMethod = "decodePC16DBLBranchOperand"; 531 } 532 def brtarget32tls : PCRelTLSOperand<OtherVT, PCRelTLS32> { 533 let MIOperandInfo = (ops brtarget32:$func, tlssym:$sym); 534 let EncoderMethod = "getPC32DBLTLSEncoding"; 535 let DecoderMethod = "decodePC32DBLBranchOperand"; 536 } 537 538 // A PC-relative offset of a global value. The offset is sign-extended 539 // and multiplied by 2. 540 def pcrel32 : PCRelAddress<i64, "pcrel32", PCRel32> { 541 let EncoderMethod = "getPC32DBLEncoding"; 542 let DecoderMethod = "decodePC32DBLOperand"; 543 } 544 545 //===----------------------------------------------------------------------===// 546 // Addressing modes 547 //===----------------------------------------------------------------------===// 548 549 // 12-bit displacement operands. 550 def disp12imm32 : Operand<i32>; 551 def disp12imm64 : Operand<i64>; 552 553 // 20-bit displacement operands. 554 def disp20imm32 : Operand<i32>; 555 def disp20imm64 : Operand<i64>; 556 557 def BDAddr32Disp12 : AddressAsmOperand<"BDAddr", "32", "12">; 558 def BDAddr32Disp20 : AddressAsmOperand<"BDAddr", "32", "20">; 559 def BDAddr64Disp12 : AddressAsmOperand<"BDAddr", "64", "12">; 560 def BDAddr64Disp20 : AddressAsmOperand<"BDAddr", "64", "20">; 561 def BDXAddr64Disp12 : AddressAsmOperand<"BDXAddr", "64", "12">; 562 def BDXAddr64Disp20 : AddressAsmOperand<"BDXAddr", "64", "20">; 563 def BDLAddr64Disp12Len4 : AddressAsmOperand<"BDLAddr", "64", "12", "Len4">; 564 def BDLAddr64Disp12Len8 : AddressAsmOperand<"BDLAddr", "64", "12", "Len8">; 565 def BDRAddr64Disp12 : AddressAsmOperand<"BDRAddr", "64", "12">; 566 def BDVAddr64Disp12 : AddressAsmOperand<"BDVAddr", "64", "12">; 567 568 // DAG patterns and operands for addressing modes. Each mode has 569 // the form <type><range><group>[<len>] where: 570 // 571 // <type> is one of: 572 // shift : base + displacement (32-bit) 573 // bdaddr : base + displacement 574 // mviaddr : like bdaddr, but reject cases with a natural index 575 // bdxaddr : base + displacement + index 576 // laaddr : like bdxaddr, but used for Load Address operations 577 // dynalloc : base + displacement + index + ADJDYNALLOC 578 // bdladdr : base + displacement with a length field 579 // bdvaddr : base + displacement with a vector index 580 // 581 // <range> is one of: 582 // 12 : the displacement is an unsigned 12-bit value 583 // 20 : the displacement is a signed 20-bit value 584 // 585 // <group> is one of: 586 // pair : used when there is an equivalent instruction with the opposite 587 // range value (12 or 20) 588 // only : used when there is no equivalent instruction with the opposite 589 // range value 590 // 591 // <len> is one of: 592 // 593 // <empty> : there is no length field 594 // len8 : the length field is 8 bits, with a range of [1, 0x100]. 595 def shift12only : BDMode <"BDAddr", "32", "12", "Only">; 596 def shift20only : BDMode <"BDAddr", "32", "20", "Only">; 597 def bdaddr12only : BDMode <"BDAddr", "64", "12", "Only">; 598 def bdaddr12pair : BDMode <"BDAddr", "64", "12", "Pair">; 599 def bdaddr20only : BDMode <"BDAddr", "64", "20", "Only">; 600 def bdaddr20pair : BDMode <"BDAddr", "64", "20", "Pair">; 601 def mviaddr12pair : BDMode <"MVIAddr", "64", "12", "Pair">; 602 def mviaddr20pair : BDMode <"MVIAddr", "64", "20", "Pair">; 603 def bdxaddr12only : BDXMode<"BDXAddr", "64", "12", "Only">; 604 def bdxaddr12pair : BDXMode<"BDXAddr", "64", "12", "Pair">; 605 def bdxaddr20only : BDXMode<"BDXAddr", "64", "20", "Only">; 606 def bdxaddr20only128 : BDXMode<"BDXAddr", "64", "20", "Only128">; 607 def bdxaddr20pair : BDXMode<"BDXAddr", "64", "20", "Pair">; 608 def dynalloc12only : BDXMode<"DynAlloc", "64", "12", "Only">; 609 def laaddr12pair : BDXMode<"LAAddr", "64", "12", "Pair">; 610 def laaddr20pair : BDXMode<"LAAddr", "64", "20", "Pair">; 611 def bdladdr12onlylen4 : BDLMode<"BDLAddr", "64", "12", "Only", "4">; 612 def bdladdr12onlylen8 : BDLMode<"BDLAddr", "64", "12", "Only", "8">; 613 def bdraddr12only : BDRMode<"BDRAddr", "64", "12", "Only">; 614 def bdvaddr12only : BDVMode< "64", "12">; 615 616 //===----------------------------------------------------------------------===// 617 // Miscellaneous 618 //===----------------------------------------------------------------------===// 619 620 // A 4-bit condition-code mask. 621 def cond4 : PatLeaf<(i32 imm), [{ return (N->getZExtValue() < 16); }]>, 622 Operand<i32> { 623 let PrintMethod = "printCond4Operand"; 624 } 625