X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FSystemZ%2FSystemZOperands.td;h=66d9c5fceba52606cec731a460b01407f10d1064;hb=98017a015bb862afce4f90d432eded4e28fe1d26;hp=0ee48c3ebafbc13c1922303013e3ef406a475a6a;hpb=e50ed30282bb5b4a9ed952580523f2dda16215ac;p=oota-llvm.git diff --git a/lib/Target/SystemZ/SystemZOperands.td b/lib/Target/SystemZ/SystemZOperands.td index 0ee48c3ebaf..66d9c5fceba 100644 --- a/lib/Target/SystemZ/SystemZOperands.td +++ b/lib/Target/SystemZ/SystemZOperands.td @@ -1,306 +1,465 @@ -//=====- SystemZOperands.td - SystemZ Operands defs ---------*- tblgen-*-=====// +//===-- SystemZOperands.td - SystemZ instruction operands ----*- tblgen-*--===// // // The LLVM Compiler Infrastructure // -// This file is distributed under the University of Illinois Open Source +// This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -// -// This file describes the various SystemZ instruction operands. -// -//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===// -// Instruction Pattern Stuff. +// Class definitions //===----------------------------------------------------------------------===// -// SystemZ specific condition code. These correspond to CondCode in -// SystemZ.h. They must be kept in synch. -def SYSTEMZ_COND_O : PatLeaf<(i8 0)>; -def SYSTEMZ_COND_H : PatLeaf<(i8 1)>; -def SYSTEMZ_COND_NLE : PatLeaf<(i8 2)>; -def SYSTEMZ_COND_L : PatLeaf<(i8 3)>; -def SYSTEMZ_COND_NHE : PatLeaf<(i8 4)>; -def SYSTEMZ_COND_LH : PatLeaf<(i8 5)>; -def SYSTEMZ_COND_NE : PatLeaf<(i8 6)>; -def SYSTEMZ_COND_E : PatLeaf<(i8 7)>; -def SYSTEMZ_COND_NLH : PatLeaf<(i8 8)>; -def SYSTEMZ_COND_HE : PatLeaf<(i8 9)>; -def SYSTEMZ_COND_NL : PatLeaf<(i8 10)>; -def SYSTEMZ_COND_LE : PatLeaf<(i8 11)>; -def SYSTEMZ_COND_NH : PatLeaf<(i8 12)>; -def SYSTEMZ_COND_NO : PatLeaf<(i8 13)>; - -def LO8 : SDNodeXFormgetZExtValue() & 0x00000000000000FFULL); -}]>; +class ImmediateAsmOperand + : AsmOperandClass { + let Name = name; + let RenderMethod = "addImmOperands"; +} + +// Constructs both a DAG pattern and instruction operand for an immediate +// of type VT. PRED returns true if a node is acceptable and XFORM returns +// the operand value associated with the node. ASMOP is the name of the +// associated asm operand, and also forms the basis of the asm print method. +class Immediate + : PatLeaf<(vt imm), pred, xform>, Operand { + let PrintMethod = "print"##asmop##"Operand"; + let DecoderMethod = "decode"##asmop##"Operand"; + let ParserMatchClass = !cast(asmop); +} + +// Constructs an asm operand for a PC-relative address. SIZE says how +// many bits there are. +class PCRelAsmOperand : ImmediateAsmOperand<"PCRel"##size> { + let PredicateMethod = "isImm"; + let ParserMethod = "parsePCRel"##size; +} + +// Constructs an operand for a PC-relative address with address type VT. +// ASMOP is the associated asm operand. +class PCRelOperand : Operand { + let PrintMethod = "printPCRelOperand"; + let ParserMatchClass = asmop; +} + +// Constructs both a DAG pattern and instruction operand for a PC-relative +// address with address size VT. SELF is the name of the operand and +// ASMOP is the associated asm operand. +class PCRelAddress + : ComplexPattern, + PCRelOperand { + let MIOperandInfo = (ops !cast(self)); +} + +// Constructs an AsmOperandClass for addressing mode FORMAT, treating the +// registers as having BITSIZE bits and displacements as having DISPSIZE bits. +class AddressAsmOperand + : AsmOperandClass { + let Name = format##bitsize##"Disp"##dispsize; + let ParserMethod = "parse"##format##bitsize; + let RenderMethod = "add"##format##"Operands"; +} + +// Constructs both a DAG pattern and instruction operand for an addressing mode. +// The mode is selected by custom code in select(), +// encoded by custom code in getEncoding() and decoded +// by custom code in decodeDispOperand(). +// The address registers have BITSIZE bits and displacements have +// DISPSIZE bits. NUMOPS is the number of operands that make up an +// address and OPERANDS lists the types of those operands using (ops ...). +// FORMAT is the type of addressing mode, which needs to match the names +// used in AddressAsmOperand. +class AddressingMode + : ComplexPattern("i"##bitsize), numops, + "select"##type##dispsize##suffix, + [add, sub, or, frameindex, z_adjdynalloc]>, + Operand("i"##bitsize)> { + let PrintMethod = "print"##format##"Operand"; + let EncoderMethod = "get"##format##dispsize##"Encoding"; + let DecoderMethod = "decode"##format##bitsize##"Disp"##dispsize##"Operand"; + let MIOperandInfo = operands; + let ParserMatchClass = + !cast(format##bitsize##"Disp"##dispsize); +} + +// An addressing mode with a base and displacement but no index. +class BDMode + : AddressingMode("ADDR"##bitsize), + !cast("disp"##dispsize##"imm"##bitsize))>; + +// An addressing mode with a base, displacement and index. +class BDXMode + : AddressingMode("ADDR"##bitsize), + !cast("disp"##dispsize##"imm"##bitsize), + !cast("ADDR"##bitsize))>; + +//===----------------------------------------------------------------------===// +// Extracting immediate operands from nodes +// These all create MVT::i64 nodes to ensure the value is not sign-extended +// when converted from an SDNode to a MachineOperand later on. +//===----------------------------------------------------------------------===// +// Bits 0-15 (counting from the lsb). def LL16 : SDNodeXFormgetZExtValue() & 0x000000000000FFFFULL); + uint64_t Value = N->getZExtValue() & 0x000000000000FFFFULL; + return CurDAG->getTargetConstant(Value, MVT::i64); }]>; +// Bits 16-31 (counting from the lsb). def LH16 : SDNodeXFormgetZExtValue() & 0x00000000FFFF0000ULL) >> 16); + uint64_t Value = (N->getZExtValue() & 0x00000000FFFF0000ULL) >> 16; + return CurDAG->getTargetConstant(Value, MVT::i64); }]>; +// Bits 32-47 (counting from the lsb). def HL16 : SDNodeXFormgetZExtValue() & 0x0000FFFF00000000ULL) >> 32); + uint64_t Value = (N->getZExtValue() & 0x0000FFFF00000000ULL) >> 32; + return CurDAG->getTargetConstant(Value, MVT::i64); }]>; +// Bits 48-63 (counting from the lsb). def HH16 : SDNodeXFormgetZExtValue() & 0xFFFF000000000000ULL) >> 48); + uint64_t Value = (N->getZExtValue() & 0xFFFF000000000000ULL) >> 48; + return CurDAG->getTargetConstant(Value, MVT::i64); }]>; -def LO32 : SDNodeXFormgetZExtValue() & 0x00000000FFFFFFFFULL); +// Low 32 bits. +def LF32 : SDNodeXFormgetZExtValue() & 0x00000000FFFFFFFFULL; + return CurDAG->getTargetConstant(Value, MVT::i64); }]>; -def HI32 : SDNodeXFormgetZExtValue() >> 32); +// High 32 bits. +def HF32 : SDNodeXFormgetZExtValue() >> 32; + return CurDAG->getTargetConstant(Value, MVT::i64); }]>; -def i32ll16 : PatLeaf<(i32 imm), [{ - // i32ll16 predicate - true if the 32-bit immediate has only rightmost 16 - // bits set. - return ((N->getZExtValue() & 0x000000000000FFFFULL) == N->getZExtValue()); -}], LL16>; - -def i32lh16 : PatLeaf<(i32 imm), [{ - // i32lh16 predicate - true if the 32-bit immediate has only bits 16-31 set. - return ((N->getZExtValue() & 0x00000000FFFF0000ULL) == N->getZExtValue()); -}], LH16>; - -def i32ll16c : PatLeaf<(i32 imm), [{ - // i32ll16c predicate - true if the 32-bit immediate has all bits 16-31 set. - return ((N->getZExtValue() | 0x00000000FFFF0000ULL) == N->getZExtValue()); -}], LL16>; - -def i32lh16c : PatLeaf<(i32 imm), [{ - // i32lh16c predicate - true if the 32-bit immediate has all rightmost 16 - // bits set. - return ((N->getZExtValue() | 0x000000000000FFFFULL) == N->getZExtValue()); -}], LH16>; - -def i64ll16 : PatLeaf<(i64 imm), [{ - // i64ll16 predicate - true if the 64-bit immediate has only rightmost 16 - // bits set. - return ((N->getZExtValue() & 0x000000000000FFFFULL) == N->getZExtValue()); -}], LL16>; - -def i64lh16 : PatLeaf<(i64 imm), [{ - // i64lh16 predicate - true if the 64-bit immediate has only bits 16-31 set. - return ((N->getZExtValue() & 0x00000000FFFF0000ULL) == N->getZExtValue()); -}], LH16>; - -def i64hl16 : PatLeaf<(i64 imm), [{ - // i64hl16 predicate - true if the 64-bit immediate has only bits 32-47 set. - return ((N->getZExtValue() & 0x0000FFFF00000000ULL) == N->getZExtValue()); -}], HL16>; - -def i64hh16 : PatLeaf<(i64 imm), [{ - // i64hh16 predicate - true if the 64-bit immediate has only bits 48-63 set. - return ((N->getZExtValue() & 0xFFFF000000000000ULL) == N->getZExtValue()); -}], HH16>; - -def i64ll16c : PatLeaf<(i64 imm), [{ - // i64ll16c predicate - true if the 64-bit immediate has only rightmost 16 - // bits set. - return ((N->getZExtValue() | 0xFFFFFFFFFFFF0000ULL) == N->getZExtValue()); -}], LL16>; - -def i64lh16c : PatLeaf<(i64 imm), [{ - // i64lh16c predicate - true if the 64-bit immediate has only bits 16-31 set. - return ((N->getZExtValue() | 0xFFFFFFFF0000FFFFULL) == N->getZExtValue()); -}], LH16>; - -def i64hl16c : PatLeaf<(i64 imm), [{ - // i64hl16c predicate - true if the 64-bit immediate has only bits 32-47 set. - return ((N->getZExtValue() | 0xFFFF0000FFFFFFFFULL) == N->getZExtValue()); -}], HL16>; - -def i64hh16c : PatLeaf<(i64 imm), [{ - // i64hh16c predicate - true if the 64-bit immediate has only bits 48-63 set. - return ((N->getZExtValue() | 0x0000FFFFFFFFFFFFULL) == N->getZExtValue()); -}], HH16>; - -def immSExt16 : PatLeaf<(imm), [{ - // immSExt16 predicate - true if the immediate fits in a 16-bit sign extended - // field. - if (N->getValueType(0) == EVT::i64) { - uint64_t val = N->getZExtValue(); - return ((int64_t)val == (int16_t)val); - } else if (N->getValueType(0) == EVT::i32) { - uint32_t val = N->getZExtValue(); - return ((int32_t)val == (int16_t)val); - } - - return false; -}], LL16>; - -def immSExt32 : PatLeaf<(i64 imm), [{ - // immSExt32 predicate - true if the immediate fits in a 32-bit sign extended - // field. - uint64_t val = N->getZExtValue(); - return ((int64_t)val == (int32_t)val); -}], LO32>; - -def i64lo32 : PatLeaf<(i64 imm), [{ - // i64lo32 predicate - true if the 64-bit immediate has only rightmost 32 - // bits set. - return ((N->getZExtValue() & 0x00000000FFFFFFFFULL) == N->getZExtValue()); -}], LO32>; - -def i64hi32 : PatLeaf<(i64 imm), [{ - // i64hi32 predicate - true if the 64-bit immediate has only bits 32-63 set. - return ((N->getZExtValue() & 0xFFFFFFFF00000000ULL) == N->getZExtValue()); -}], HI32>; - -def i64lo32c : PatLeaf<(i64 imm), [{ - // i64lo32 predicate - true if the 64-bit immediate has only rightmost 32 - // bits set. - return ((N->getZExtValue() | 0xFFFFFFFF00000000ULL) == N->getZExtValue()); -}], LO32>; - -def i64hi32c : PatLeaf<(i64 imm), [{ - // i64hi32 predicate - true if the 64-bit immediate has only bits 32-63 set. - return ((N->getZExtValue() | 0x00000000FFFFFFFFULL) == N->getZExtValue()); -}], HI32>; - -def i32immSExt8 : PatLeaf<(i32 imm), [{ - // i32immSExt8 predicate - True if the 32-bit immediate fits in a 8-bit - // sign extended field. - return (int32_t)N->getZExtValue() == (int8_t)N->getZExtValue(); -}], LO8>; - -def i32immSExt16 : PatLeaf<(i32 imm), [{ - // i32immSExt16 predicate - True if the 32-bit immediate fits in a 16-bit - // sign extended field. - return (int32_t)N->getZExtValue() == (int16_t)N->getZExtValue(); -}], LL16>; - -def i64immSExt32 : PatLeaf<(i64 imm), [{ - // i64immSExt32 predicate - True if the 64-bit immediate fits in a 32-bit - // sign extended field. - return (int64_t)N->getZExtValue() == (int32_t)N->getZExtValue(); -}], LO32>; - -def i64immZExt32 : PatLeaf<(i64 imm), [{ - // i64immZExt32 predicate - True if the 64-bit immediate fits in a 32-bit - // zero extended field. - return (uint64_t)N->getZExtValue() == (uint32_t)N->getZExtValue(); -}], LO32>; - -// extloads -def extloadi32i8 : PatFrag<(ops node:$ptr), (i32 (extloadi8 node:$ptr))>; -def extloadi32i16 : PatFrag<(ops node:$ptr), (i32 (extloadi16 node:$ptr))>; -def extloadi64i8 : PatFrag<(ops node:$ptr), (i64 (extloadi8 node:$ptr))>; -def extloadi64i16 : PatFrag<(ops node:$ptr), (i64 (extloadi16 node:$ptr))>; -def extloadi64i32 : PatFrag<(ops node:$ptr), (i64 (extloadi32 node:$ptr))>; - -def sextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (sextloadi8 node:$ptr))>; -def sextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (sextloadi16 node:$ptr))>; -def sextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (sextloadi8 node:$ptr))>; -def sextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (sextloadi16 node:$ptr))>; -def sextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (sextloadi32 node:$ptr))>; - -def zextloadi32i8 : PatFrag<(ops node:$ptr), (i32 (zextloadi8 node:$ptr))>; -def zextloadi32i16 : PatFrag<(ops node:$ptr), (i32 (zextloadi16 node:$ptr))>; -def zextloadi64i8 : PatFrag<(ops node:$ptr), (i64 (zextloadi8 node:$ptr))>; -def zextloadi64i16 : PatFrag<(ops node:$ptr), (i64 (zextloadi16 node:$ptr))>; -def zextloadi64i32 : PatFrag<(ops node:$ptr), (i64 (zextloadi32 node:$ptr))>; - -// A couple of more descriptive operand definitions. -// 32-bits but only 8 bits are significant. -def i32i8imm : Operand; -// 32-bits but only 16 bits are significant. -def i32i16imm : Operand; -// 64-bits but only 32 bits are significant. -def i64i32imm : Operand; -// Branch targets have OtherVT type. -def brtarget : Operand; - -// Unsigned i12 -def u12imm : Operand { - let PrintMethod = "printU12ImmOperand"; -} -def u12imm64 : Operand { - let PrintMethod = "printU12ImmOperand"; -} +// Truncate an immediate to a 8-bit signed quantity. +def SIMM8 : SDNodeXFormgetTargetConstant(int8_t(N->getZExtValue()), MVT::i64); +}]>; -// Signed i16 -def s16imm : Operand { - let PrintMethod = "printS16ImmOperand"; -} -def s16imm64 : Operand { - let PrintMethod = "printS16ImmOperand"; -} -// Signed i20 -def s20imm : Operand { - let PrintMethod = "printS20ImmOperand"; -} -def s20imm64 : Operand { - let PrintMethod = "printS20ImmOperand"; +// Truncate an immediate to a 8-bit unsigned quantity. +def UIMM8 : SDNodeXFormgetTargetConstant(uint8_t(N->getZExtValue()), MVT::i64); +}]>; + +// Truncate an immediate to a 16-bit signed quantity. +def SIMM16 : SDNodeXFormgetTargetConstant(int16_t(N->getZExtValue()), MVT::i64); +}]>; + +// Truncate an immediate to a 16-bit unsigned quantity. +def UIMM16 : SDNodeXFormgetTargetConstant(uint16_t(N->getZExtValue()), MVT::i64); +}]>; + +// Truncate an immediate to a 32-bit signed quantity. +def SIMM32 : SDNodeXFormgetTargetConstant(int32_t(N->getZExtValue()), MVT::i64); +}]>; + +// Truncate an immediate to a 32-bit unsigned quantity. +def UIMM32 : SDNodeXFormgetTargetConstant(uint32_t(N->getZExtValue()), MVT::i64); +}]>; + +// Negate and then truncate an immediate to a 32-bit unsigned quantity. +def NEGIMM32 : SDNodeXFormgetTargetConstant(uint32_t(-N->getZExtValue()), MVT::i64); +}]>; + +//===----------------------------------------------------------------------===// +// Immediate asm operands. +//===----------------------------------------------------------------------===// + +def U4Imm : ImmediateAsmOperand<"U4Imm">; +def U6Imm : ImmediateAsmOperand<"U6Imm">; +def S8Imm : ImmediateAsmOperand<"S8Imm">; +def U8Imm : ImmediateAsmOperand<"U8Imm">; +def S16Imm : ImmediateAsmOperand<"S16Imm">; +def U16Imm : ImmediateAsmOperand<"U16Imm">; +def S32Imm : ImmediateAsmOperand<"S32Imm">; +def U32Imm : ImmediateAsmOperand<"U32Imm">; + +//===----------------------------------------------------------------------===// +// 8-bit immediates +//===----------------------------------------------------------------------===// + +def uimm8zx4 : Immediate(N->getZExtValue()); +}], NOOP_SDNodeXForm, "U4Imm">; + +def uimm8zx6 : Immediate(N->getZExtValue()); +}], NOOP_SDNodeXForm, "U6Imm">; + +def simm8 : Immediate; +def uimm8 : Immediate; + +//===----------------------------------------------------------------------===// +// i32 immediates +//===----------------------------------------------------------------------===// + +// Immediates for the lower and upper 16 bits of an i32, with the other +// bits of the i32 being zero. +def imm32ll16 : ImmediategetZExtValue()); +}], LL16, "U16Imm">; + +def imm32lh16 : ImmediategetZExtValue()); +}], LH16, "U16Imm">; + +// Immediates for the lower and upper 16 bits of an i32, with the other +// bits of the i32 being one. +def imm32ll16c : ImmediategetZExtValue())); +}], LL16, "U16Imm">; + +def imm32lh16c : ImmediategetZExtValue())); +}], LH16, "U16Imm">; + +// Short immediates +def imm32sx8 : Immediate(N->getSExtValue()); +}], SIMM8, "S8Imm">; + +def imm32zx8 : Immediate(N->getZExtValue()); +}], UIMM8, "U8Imm">; + +def imm32zx8trunc : Immediate; + +def imm32sx16 : Immediate(N->getSExtValue()); +}], SIMM16, "S16Imm">; + +def imm32zx16 : Immediate(N->getZExtValue()); +}], UIMM16, "U16Imm">; + +def imm32sx16trunc : Immediate; + +// Full 32-bit immediates. we need both signed and unsigned versions +// because the assembler is picky. E.g. AFI requires signed operands +// while NILF requires unsigned ones. +def simm32 : Immediate; +def uimm32 : Immediate; + +def imm32 : ImmLeaf; + +//===----------------------------------------------------------------------===// +// 64-bit immediates +//===----------------------------------------------------------------------===// + +// Immediates for 16-bit chunks of an i64, with the other bits of the +// i32 being zero. +def imm64ll16 : ImmediategetZExtValue()); +}], LL16, "U16Imm">; + +def imm64lh16 : ImmediategetZExtValue()); +}], LH16, "U16Imm">; + +def imm64hl16 : ImmediategetZExtValue()); +}], HL16, "U16Imm">; + +def imm64hh16 : ImmediategetZExtValue()); +}], HH16, "U16Imm">; + +// Immediates for 16-bit chunks of an i64, with the other bits of the +// i32 being one. +def imm64ll16c : ImmediategetZExtValue())); +}], LL16, "U16Imm">; + +def imm64lh16c : ImmediategetZExtValue())); +}], LH16, "U16Imm">; + +def imm64hl16c : ImmediategetZExtValue())); +}], HL16, "U16Imm">; + +def imm64hh16c : ImmediategetZExtValue())); +}], HH16, "U16Imm">; + +// Immediates for the lower and upper 32 bits of an i64, with the other +// bits of the i32 being zero. +def imm64lf32 : ImmediategetZExtValue()); +}], LF32, "U32Imm">; + +def imm64hf32 : ImmediategetZExtValue()); +}], HF32, "U32Imm">; + +// Immediates for the lower and upper 32 bits of an i64, with the other +// bits of the i32 being one. +def imm64lf32c : ImmediategetZExtValue())); +}], LF32, "U32Imm">; + +def imm64hf32c : ImmediategetZExtValue())); +}], HF32, "U32Imm">; + +// Short immediates. +def imm64sx8 : Immediate(N->getSExtValue()); +}], SIMM8, "S8Imm">; + +def imm64sx16 : Immediate(N->getSExtValue()); +}], SIMM16, "S16Imm">; + +def imm64zx16 : Immediate(N->getZExtValue()); +}], UIMM16, "U16Imm">; + +def imm64sx32 : Immediate(N->getSExtValue()); +}], SIMM32, "S32Imm">; + +def imm64zx32 : Immediate(N->getZExtValue()); +}], UIMM32, "U32Imm">; + +def imm64zx32n : Immediate(-N->getSExtValue()); +}], NEGIMM32, "U32Imm">; + +def imm64 : ImmLeaf; + +//===----------------------------------------------------------------------===// +// Floating-point immediates +//===----------------------------------------------------------------------===// + +// Floating-point zero. +def fpimm0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(+0.0); }]>; + +// Floating point negative zero. +def fpimmneg0 : PatLeaf<(fpimm), [{ return N->isExactlyValue(-0.0); }]>; + +//===----------------------------------------------------------------------===// +// Symbolic address operands +//===----------------------------------------------------------------------===// + +// PC-relative asm operands. +def PCRel16 : PCRelAsmOperand<"16">; +def PCRel32 : PCRelAsmOperand<"32">; + +// PC-relative offsets of a basic block. The offset is sign-extended +// and multiplied by 2. +def brtarget16 : PCRelOperand { + let EncoderMethod = "getPC16DBLEncoding"; + let DecoderMethod = "decodePC16DBLOperand"; } -// Signed i32 -def s32imm : Operand { - let PrintMethod = "printS32ImmOperand"; +def brtarget32 : PCRelOperand { + let EncoderMethod = "getPC32DBLEncoding"; + let DecoderMethod = "decodePC32DBLOperand"; } -def s32imm64 : Operand { - let PrintMethod = "printS32ImmOperand"; + +// A PC-relative offset of a global value. The offset is sign-extended +// and multiplied by 2. +def pcrel32 : PCRelAddress { + let EncoderMethod = "getPC32DBLEncoding"; + let DecoderMethod = "decodePC32DBLOperand"; } -def imm_pcrel : Operand { - let PrintMethod = "printPCRelImmOperand"; +// A PC-relative offset of a global value when the value is used as a +// call target. The offset is sign-extended and multiplied by 2. +def pcrel16call : PCRelAddress { + let PrintMethod = "printCallOperand"; + let EncoderMethod = "getPLT16DBLEncoding"; + let DecoderMethod = "decodePC16DBLOperand"; +} +def pcrel32call : PCRelAddress { + let PrintMethod = "printCallOperand"; + let EncoderMethod = "getPLT32DBLEncoding"; + let DecoderMethod = "decodePC32DBLOperand"; } //===----------------------------------------------------------------------===// -// SystemZ Operand Definitions. +// Addressing modes //===----------------------------------------------------------------------===// -// Address operands +// 12-bit displacement operands. +def disp12imm32 : Operand; +def disp12imm64 : Operand; -// riaddr := reg + imm -def riaddr32 : Operand, - ComplexPattern { - let PrintMethod = "printRIAddrOperand"; - let MIOperandInfo = (ops ADDR64:$base, u12imm:$disp); -} +// 20-bit displacement operands. +def disp20imm32 : Operand; +def disp20imm64 : Operand; -def riaddr12 : Operand, - ComplexPattern { - let PrintMethod = "printRIAddrOperand"; - let MIOperandInfo = (ops ADDR64:$base, u12imm64:$disp); -} +def BDAddr32Disp12 : AddressAsmOperand<"BDAddr", "32", "12">; +def BDAddr32Disp20 : AddressAsmOperand<"BDAddr", "32", "20">; +def BDAddr64Disp12 : AddressAsmOperand<"BDAddr", "64", "12">; +def BDAddr64Disp20 : AddressAsmOperand<"BDAddr", "64", "20">; +def BDXAddr64Disp12 : AddressAsmOperand<"BDXAddr", "64", "12">; +def BDXAddr64Disp20 : AddressAsmOperand<"BDXAddr", "64", "20">; -def riaddr : Operand, - ComplexPattern { - let PrintMethod = "printRIAddrOperand"; - let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp); -} +// DAG patterns and operands for addressing modes. Each mode has +// the form where: +// +// is one of: +// shift : base + displacement (32-bit) +// bdaddr : base + displacement +// bdxaddr : base + displacement + index +// laaddr : like bdxaddr, but used for Load Address operations +// dynalloc : base + displacement + index + ADJDYNALLOC +// +// is one of: +// 12 : the displacement is an unsigned 12-bit value +// 20 : the displacement is a signed 20-bit value +// +// is one of: +// pair : used when there is an equivalent instruction with the opposite +// range value (12 or 20) +// only : used when there is no equivalent instruction with the opposite +// range value +def shift12only : BDMode <"BDAddr", "32", "12", "Only">; +def shift20only : BDMode <"BDAddr", "32", "20", "Only">; +def bdaddr12only : BDMode <"BDAddr", "64", "12", "Only">; +def bdaddr12pair : BDMode <"BDAddr", "64", "12", "Pair">; +def bdaddr20only : BDMode <"BDAddr", "64", "20", "Only">; +def bdaddr20pair : BDMode <"BDAddr", "64", "20", "Pair">; +def bdxaddr12only : BDXMode<"BDXAddr", "64", "12", "Only">; +def bdxaddr12pair : BDXMode<"BDXAddr", "64", "12", "Pair">; +def bdxaddr20only : BDXMode<"BDXAddr", "64", "20", "Only">; +def bdxaddr20only128 : BDXMode<"BDXAddr", "64", "20", "Only128">; +def bdxaddr20pair : BDXMode<"BDXAddr", "64", "20", "Pair">; +def dynalloc12only : BDXMode<"DynAlloc", "64", "12", "Only">; +def laaddr12pair : BDXMode<"LAAddr", "64", "12", "Pair">; +def laaddr20pair : BDXMode<"LAAddr", "64", "20", "Pair">; +//===----------------------------------------------------------------------===// +// Miscellaneous //===----------------------------------------------------------------------===// -// rriaddr := reg + reg + imm -def rriaddr12 : Operand, - ComplexPattern { - let PrintMethod = "printRRIAddrOperand"; - let MIOperandInfo = (ops ADDR64:$base, u12imm64:$disp, ADDR64:$index); +// Access registers. At present we just use them for accessing the thread +// pointer, so we don't expose them as register to LLVM. +def AccessReg : AsmOperandClass { + let Name = "AccessReg"; + let ParserMethod = "parseAccessReg"; } -def rriaddr : Operand, - ComplexPattern { - let PrintMethod = "printRRIAddrOperand"; - let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp, ADDR64:$index); +def access_reg : ImmediategetZExtValue() < 16; }], + NOOP_SDNodeXForm, "AccessReg"> { + let ParserMatchClass = AccessReg; } -def laaddr : Operand, - ComplexPattern { - let PrintMethod = "printRRIAddrOperand"; - let MIOperandInfo = (ops ADDR64:$base, s20imm64:$disp, ADDR64:$index); + +// A 4-bit condition-code mask. +def cond4 : PatLeaf<(i8 imm), [{ return (N->getZExtValue() < 16); }]>, + Operand { + let PrintMethod = "printCond4Operand"; }