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 14class ImmediateAsmOperand<string name> 15 : AsmOperandClass { 16 let Name = name; 17 let RenderMethod = "addImmOperands"; 18} 19class 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. 29class 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. 38class PCRelAsmOperand<string size> : ImmediateAsmOperand<"PCRel"##size> { 39 let PredicateMethod = "isImm"; 40 let ParserMethod = "parsePCRel"##size; 41} 42class 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. 50class PCRelOperand<ValueType vt, AsmOperandClass asmop> : Operand<vt> { 51 let PrintMethod = "printPCRelOperand"; 52 let ParserMatchClass = asmop; 53} 54class 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. 62class 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 "". 73class 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.). 85class 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. 106class 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. 115class 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. 121class 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. 128class 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. 137class 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. 144class 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). 157def 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). 163def 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). 169def 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). 175def 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. 181def 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. 187def 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. 193def 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. 199def 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. 205def 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. 211def 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. 217def 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. 223def 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. 229def 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. 235def 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. 241def 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. 247def 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. 253def 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. 259def 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 268def U1Imm : ImmediateAsmOperand<"U1Imm">; 269def U2Imm : ImmediateAsmOperand<"U2Imm">; 270def U3Imm : ImmediateAsmOperand<"U3Imm">; 271def U4Imm : ImmediateAsmOperand<"U4Imm">; 272def U6Imm : ImmediateAsmOperand<"U6Imm">; 273def S8Imm : ImmediateAsmOperand<"S8Imm">; 274def U8Imm : ImmediateAsmOperand<"U8Imm">; 275def U12Imm : ImmediateAsmOperand<"U12Imm">; 276def S16Imm : ImmediateAsmOperand<"S16Imm">; 277def U16Imm : ImmediateAsmOperand<"U16Imm">; 278def S32Imm : ImmediateAsmOperand<"S32Imm">; 279def U32Imm : ImmediateAsmOperand<"U32Imm">; 280def 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. 288def imm32ll16 : Immediate<i32, [{ 289 return SystemZ::isImmLL(N->getZExtValue()); 290}], LL16, "U16Imm">; 291 292def 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. 298def imm32ll16c : Immediate<i32, [{ 299 return SystemZ::isImmLL(uint32_t(~N->getZExtValue())); 300}], LL16, "U16Imm">; 301 302def imm32lh16c : Immediate<i32, [{ 303 return SystemZ::isImmLH(uint32_t(~N->getZExtValue())); 304}], LH16, "U16Imm">; 305 306// Short immediates 307def imm32zx1 : Immediate<i32, [{ 308 return isUInt<1>(N->getZExtValue()); 309}], NOOP_SDNodeXForm, "U1Imm">; 310 311def imm32zx2 : Immediate<i32, [{ 312 return isUInt<2>(N->getZExtValue()); 313}], NOOP_SDNodeXForm, "U2Imm">; 314 315def imm32zx3 : Immediate<i32, [{ 316 return isUInt<3>(N->getZExtValue()); 317}], NOOP_SDNodeXForm, "U3Imm">; 318 319def 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. 325def imm32zx4even : Immediate<i32, [{ 326 return isUInt<4>(N->getZExtValue()); 327}], UIMM8EVEN, "U4Imm">; 328 329def imm32zx6 : Immediate<i32, [{ 330 return isUInt<6>(N->getZExtValue()); 331}], NOOP_SDNodeXForm, "U6Imm">; 332 333def imm32sx8 : Immediate<i32, [{ 334 return isInt<8>(N->getSExtValue()); 335}], SIMM8, "S8Imm">; 336 337def imm32zx8 : Immediate<i32, [{ 338 return isUInt<8>(N->getZExtValue()); 339}], UIMM8, "U8Imm">; 340 341def imm32zx8trunc : Immediate<i32, [{}], UIMM8, "U8Imm">; 342 343def imm32zx12 : Immediate<i32, [{ 344 return isUInt<12>(N->getZExtValue()); 345}], UIMM12, "U12Imm">; 346 347def imm32sx16 : Immediate<i32, [{ 348 return isInt<16>(N->getSExtValue()); 349}], SIMM16, "S16Imm">; 350 351def imm32sx16n : Immediate<i32, [{ 352 return isInt<16>(-N->getSExtValue()); 353}], NEGSIMM16, "S16Imm">; 354 355def imm32zx16 : Immediate<i32, [{ 356 return isUInt<16>(N->getZExtValue()); 357}], UIMM16, "U16Imm">; 358 359def imm32sx16trunc : Immediate<i32, [{}], SIMM16, "S16Imm">; 360 361// Full 32-bit immediates. we need both signed and unsigned versions 362// because the assembler is picky. E.g. AFI requires signed operands 363// while NILF requires unsigned ones. 364def simm32 : Immediate<i32, [{}], SIMM32, "S32Imm">; 365def uimm32 : Immediate<i32, [{}], UIMM32, "U32Imm">; 366 367def simm32n : Immediate<i32, [{ 368 return isInt<32>(-N->getSExtValue()); 369}], NEGSIMM32, "S32Imm">; 370 371def imm32 : ImmLeaf<i32, [{}]>; 372 373//===----------------------------------------------------------------------===// 374// 64-bit immediates 375//===----------------------------------------------------------------------===// 376 377// Immediates for 16-bit chunks of an i64, with the other bits of the 378// i32 being zero. 379def imm64ll16 : Immediate<i64, [{ 380 return SystemZ::isImmLL(N->getZExtValue()); 381}], LL16, "U16Imm">; 382 383def imm64lh16 : Immediate<i64, [{ 384 return SystemZ::isImmLH(N->getZExtValue()); 385}], LH16, "U16Imm">; 386 387def imm64hl16 : Immediate<i64, [{ 388 return SystemZ::isImmHL(N->getZExtValue()); 389}], HL16, "U16Imm">; 390 391def imm64hh16 : Immediate<i64, [{ 392 return SystemZ::isImmHH(N->getZExtValue()); 393}], HH16, "U16Imm">; 394 395// Immediates for 16-bit chunks of an i64, with the other bits of the 396// i32 being one. 397def imm64ll16c : Immediate<i64, [{ 398 return SystemZ::isImmLL(uint64_t(~N->getZExtValue())); 399}], LL16, "U16Imm">; 400 401def imm64lh16c : Immediate<i64, [{ 402 return SystemZ::isImmLH(uint64_t(~N->getZExtValue())); 403}], LH16, "U16Imm">; 404 405def imm64hl16c : Immediate<i64, [{ 406 return SystemZ::isImmHL(uint64_t(~N->getZExtValue())); 407}], HL16, "U16Imm">; 408 409def imm64hh16c : Immediate<i64, [{ 410 return SystemZ::isImmHH(uint64_t(~N->getZExtValue())); 411}], HH16, "U16Imm">; 412 413// Immediates for the lower and upper 32 bits of an i64, with the other 414// bits of the i32 being zero. 415def imm64lf32 : Immediate<i64, [{ 416 return SystemZ::isImmLF(N->getZExtValue()); 417}], LF32, "U32Imm">; 418 419def imm64hf32 : Immediate<i64, [{ 420 return SystemZ::isImmHF(N->getZExtValue()); 421}], HF32, "U32Imm">; 422 423// Immediates for the lower and upper 32 bits of an i64, with the other 424// bits of the i32 being one. 425def imm64lf32c : Immediate<i64, [{ 426 return SystemZ::isImmLF(uint64_t(~N->getZExtValue())); 427}], LF32, "U32Imm">; 428 429def imm64hf32c : Immediate<i64, [{ 430 return SystemZ::isImmHF(uint64_t(~N->getZExtValue())); 431}], HF32, "U32Imm">; 432 433// Short immediates. 434def imm64sx8 : Immediate<i64, [{ 435 return isInt<8>(N->getSExtValue()); 436}], SIMM8, "S8Imm">; 437 438def imm64zx8 : Immediate<i64, [{ 439 return isUInt<8>(N->getSExtValue()); 440}], UIMM8, "U8Imm">; 441 442def imm64sx16 : Immediate<i64, [{ 443 return isInt<16>(N->getSExtValue()); 444}], SIMM16, "S16Imm">; 445 446def imm64sx16n : Immediate<i64, [{ 447 return isInt<16>(-N->getSExtValue()); 448}], NEGSIMM16, "S16Imm">; 449 450def imm64zx16 : Immediate<i64, [{ 451 return isUInt<16>(N->getZExtValue()); 452}], UIMM16, "U16Imm">; 453 454def imm64sx32 : Immediate<i64, [{ 455 return isInt<32>(N->getSExtValue()); 456}], SIMM32, "S32Imm">; 457 458def imm64sx32n : Immediate<i64, [{ 459 return isInt<32>(-N->getSExtValue()); 460}], NEGSIMM32, "S32Imm">; 461 462def imm64zx32 : Immediate<i64, [{ 463 return isUInt<32>(N->getZExtValue()); 464}], UIMM32, "U32Imm">; 465 466def imm64zx32n : Immediate<i64, [{ 467 return isUInt<32>(-N->getSExtValue()); 468}], NEGUIMM32, "U32Imm">; 469 470def imm64zx48 : Immediate<i64, [{ 471 return isUInt<64>(N->getZExtValue()); 472}], UIMM48, "U48Imm">; 473 474def imm64 : ImmLeaf<i64, [{}]>, Operand<i64>; 475 476//===----------------------------------------------------------------------===// 477// Floating-point immediates 478//===----------------------------------------------------------------------===// 479 480// Floating-point zero. 481def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>; 482 483// Floating point negative zero. 484def fpimmneg0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(-0.0); }]>; 485 486//===----------------------------------------------------------------------===// 487// Symbolic address operands 488//===----------------------------------------------------------------------===// 489 490// PC-relative asm operands. 491def PCRel12 : PCRelAsmOperand<"12">; 492def PCRel16 : PCRelAsmOperand<"16">; 493def PCRel24 : PCRelAsmOperand<"24">; 494def PCRel32 : PCRelAsmOperand<"32">; 495def PCRelTLS16 : PCRelTLSAsmOperand<"16">; 496def PCRelTLS32 : PCRelTLSAsmOperand<"32">; 497 498// PC-relative offsets of a basic block. The offset is sign-extended 499// and multiplied by 2. 500def brtarget16 : PCRelOperand<OtherVT, PCRel16> { 501 let EncoderMethod = "getPC16DBLEncoding"; 502 let DecoderMethod = "decodePC16DBLBranchOperand"; 503} 504def brtarget32 : PCRelOperand<OtherVT, PCRel32> { 505 let EncoderMethod = "getPC32DBLEncoding"; 506 let DecoderMethod = "decodePC32DBLBranchOperand"; 507} 508 509// Variants of brtarget for use with branch prediction preload. 510def brtarget12bpp : PCRelOperand<OtherVT, PCRel12> { 511 let EncoderMethod = "getPC12DBLBPPEncoding"; 512 let DecoderMethod = "decodePC12DBLBranchOperand"; 513} 514def brtarget16bpp : PCRelOperand<OtherVT, PCRel16> { 515 let EncoderMethod = "getPC16DBLBPPEncoding"; 516 let DecoderMethod = "decodePC16DBLBranchOperand"; 517} 518def brtarget24bpp : PCRelOperand<OtherVT, PCRel24> { 519 let EncoderMethod = "getPC24DBLBPPEncoding"; 520 let DecoderMethod = "decodePC24DBLBranchOperand"; 521} 522 523// Variants of brtarget16/32 with an optional additional TLS symbol. 524// These are used to annotate calls to __tls_get_offset. 525def tlssym : Operand<i64> { } 526def brtarget16tls : PCRelTLSOperand<OtherVT, PCRelTLS16> { 527 let MIOperandInfo = (ops brtarget16:$func, tlssym:$sym); 528 let EncoderMethod = "getPC16DBLTLSEncoding"; 529 let DecoderMethod = "decodePC16DBLBranchOperand"; 530} 531def brtarget32tls : PCRelTLSOperand<OtherVT, PCRelTLS32> { 532 let MIOperandInfo = (ops brtarget32:$func, tlssym:$sym); 533 let EncoderMethod = "getPC32DBLTLSEncoding"; 534 let DecoderMethod = "decodePC32DBLBranchOperand"; 535} 536 537// A PC-relative offset of a global value. The offset is sign-extended 538// and multiplied by 2. 539def pcrel32 : PCRelAddress<i64, "pcrel32", PCRel32> { 540 let EncoderMethod = "getPC32DBLEncoding"; 541 let DecoderMethod = "decodePC32DBLOperand"; 542} 543 544//===----------------------------------------------------------------------===// 545// Addressing modes 546//===----------------------------------------------------------------------===// 547 548// 12-bit displacement operands. 549def disp12imm32 : Operand<i32>; 550def disp12imm64 : Operand<i64>; 551 552// 20-bit displacement operands. 553def disp20imm32 : Operand<i32>; 554def disp20imm64 : Operand<i64>; 555 556def BDAddr32Disp12 : AddressAsmOperand<"BDAddr", "32", "12">; 557def BDAddr32Disp20 : AddressAsmOperand<"BDAddr", "32", "20">; 558def BDAddr64Disp12 : AddressAsmOperand<"BDAddr", "64", "12">; 559def BDAddr64Disp20 : AddressAsmOperand<"BDAddr", "64", "20">; 560def BDXAddr64Disp12 : AddressAsmOperand<"BDXAddr", "64", "12">; 561def BDXAddr64Disp20 : AddressAsmOperand<"BDXAddr", "64", "20">; 562def BDLAddr64Disp12Len4 : AddressAsmOperand<"BDLAddr", "64", "12", "Len4">; 563def BDLAddr64Disp12Len8 : AddressAsmOperand<"BDLAddr", "64", "12", "Len8">; 564def BDRAddr64Disp12 : AddressAsmOperand<"BDRAddr", "64", "12">; 565def BDVAddr64Disp12 : AddressAsmOperand<"BDVAddr", "64", "12">; 566 567// DAG patterns and operands for addressing modes. Each mode has 568// the form <type><range><group>[<len>] where: 569// 570// <type> is one of: 571// shift : base + displacement (32-bit) 572// bdaddr : base + displacement 573// mviaddr : like bdaddr, but reject cases with a natural index 574// bdxaddr : base + displacement + index 575// laaddr : like bdxaddr, but used for Load Address operations 576// dynalloc : base + displacement + index + ADJDYNALLOC 577// bdladdr : base + displacement with a length field 578// bdvaddr : base + displacement with a vector index 579// 580// <range> is one of: 581// 12 : the displacement is an unsigned 12-bit value 582// 20 : the displacement is a signed 20-bit value 583// 584// <group> is one of: 585// pair : used when there is an equivalent instruction with the opposite 586// range value (12 or 20) 587// only : used when there is no equivalent instruction with the opposite 588// range value 589// 590// <len> is one of: 591// 592// <empty> : there is no length field 593// len8 : the length field is 8 bits, with a range of [1, 0x100]. 594def shift12only : BDMode <"BDAddr", "32", "12", "Only">; 595def shift20only : BDMode <"BDAddr", "32", "20", "Only">; 596def bdaddr12only : BDMode <"BDAddr", "64", "12", "Only">; 597def bdaddr12pair : BDMode <"BDAddr", "64", "12", "Pair">; 598def bdaddr20only : BDMode <"BDAddr", "64", "20", "Only">; 599def bdaddr20pair : BDMode <"BDAddr", "64", "20", "Pair">; 600def mviaddr12pair : BDMode <"MVIAddr", "64", "12", "Pair">; 601def mviaddr20pair : BDMode <"MVIAddr", "64", "20", "Pair">; 602def bdxaddr12only : BDXMode<"BDXAddr", "64", "12", "Only">; 603def bdxaddr12pair : BDXMode<"BDXAddr", "64", "12", "Pair">; 604def bdxaddr20only : BDXMode<"BDXAddr", "64", "20", "Only">; 605def bdxaddr20only128 : BDXMode<"BDXAddr", "64", "20", "Only128">; 606def bdxaddr20pair : BDXMode<"BDXAddr", "64", "20", "Pair">; 607def dynalloc12only : BDXMode<"DynAlloc", "64", "12", "Only">; 608def laaddr12pair : BDXMode<"LAAddr", "64", "12", "Pair">; 609def laaddr20pair : BDXMode<"LAAddr", "64", "20", "Pair">; 610def bdladdr12onlylen4 : BDLMode<"BDLAddr", "64", "12", "Only", "4">; 611def bdladdr12onlylen8 : BDLMode<"BDLAddr", "64", "12", "Only", "8">; 612def bdraddr12only : BDRMode<"BDRAddr", "64", "12", "Only">; 613def bdvaddr12only : BDVMode< "64", "12">; 614 615//===----------------------------------------------------------------------===// 616// Miscellaneous 617//===----------------------------------------------------------------------===// 618 619// A 4-bit condition-code mask. 620def cond4 : PatLeaf<(i32 imm), [{ return (N->getZExtValue() < 16); }]>, 621 Operand<i32> { 622 let PrintMethod = "printCond4Operand"; 623} 624