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