diff options
| author | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2014-07-10 10:52:51 +0000 | 
|---|---|---|
| committer | Richard Sandiford <rsandifo@linux.vnet.ibm.com> | 2014-07-10 10:52:51 +0000 | 
| commit | ca44614ac05f5364c3f8fdcb842e64845339295f (patch) | |
| tree | b2695ef09359851144ea81f554dfc0455fc92b35 /llvm/lib/Target | |
| parent | ac1dba0fdf9cd935de32f8ca0762beaa7a9e6998 (diff) | |
| download | bcm5719-llvm-ca44614ac05f5364c3f8fdcb842e64845339295f.tar.gz bcm5719-llvm-ca44614ac05f5364c3f8fdcb842e64845339295f.zip | |
[SystemZ] Avoid using i8 constants for immediate fields
Immediate fields that have no natural MVT type tended to use i8 if the
field was small enough.  This was a bit confusing since i8 isn't a legal
type for the target.  Fields for short immediates in a 32-bit or 64-bit
operation use i32 or i64 instead, so it would be better to do the same
for all fields.
No behavioral change intended.
llvm-svn: 212702
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZInstrFormats.td | 39 | ||||
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZInstrInfo.td | 24 | ||||
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZOperands.td | 29 | ||||
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZOperators.td | 12 | ||||
| -rw-r--r-- | llvm/lib/Target/SystemZ/SystemZPatterns.td | 8 | 
5 files changed, 54 insertions, 58 deletions
| diff --git a/llvm/lib/Target/SystemZ/SystemZInstrFormats.td b/llvm/lib/Target/SystemZ/SystemZInstrFormats.td index add675a22cc..a1ae802ce15 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrFormats.td +++ b/llvm/lib/Target/SystemZ/SystemZInstrFormats.td @@ -691,7 +691,7 @@ class CondStoreRSY<string mnemonic, bits<16> opcode,  class AsmCondStoreRSY<string mnemonic, bits<16> opcode,                        RegisterOperand cls, bits<5> bytes,                        AddressingMode mode = bdaddr20only> -  : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, uimm8zx4:$R3), +  : InstRSY<opcode, (outs), (ins cls:$R1, mode:$BD2, imm32zx4:$R3),              mnemonic#"\t$R1, $BD2, $R3", []>,      Requires<[FeatureLoadStoreOnCond]> {    let mayStore = 1; @@ -730,7 +730,7 @@ class UnaryRRE<string mnemonic, bits<16> opcode, SDPatternOperator operator,  class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,                 RegisterOperand cls2> -  : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2), +  : InstRRF<opcode, (outs cls1:$R1), (ins imm32zx4:$R3, cls2:$R2),              mnemonic#"r\t$R1, $R3, $R2", []> {    let OpKey = mnemonic ## cls1;    let OpType = "reg"; @@ -739,7 +739,7 @@ class UnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,  class UnaryRRF4<string mnemonic, bits<16> opcode, RegisterOperand cls1,                  RegisterOperand cls2> -  : InstRRF<opcode, (outs cls1:$R1), (ins uimm8zx4:$R3, cls2:$R2, uimm8zx4:$R4), +  : InstRRF<opcode, (outs cls1:$R1), (ins imm32zx4:$R3, cls2:$R2, imm32zx4:$R4),              mnemonic#"\t$R1, $R3, $R2, $R4", []>;  // These instructions are generated by if conversion.  The old value of R1 @@ -757,7 +757,7 @@ class CondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,  // mask is the third operand rather than being part of the mnemonic.  class AsmCondUnaryRRF<string mnemonic, bits<16> opcode, RegisterOperand cls1,                        RegisterOperand cls2> -  : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2, uimm8zx4:$R3), +  : InstRRF<opcode, (outs cls1:$R1), (ins cls1:$R1src, cls2:$R2, imm32zx4:$R3),              mnemonic#"r\t$R1, $R2, $R3", []>,      Requires<[FeatureLoadStoreOnCond]> {    let Constraints = "$R1 = $R1src"; @@ -823,7 +823,7 @@ class CondUnaryRSY<string mnemonic, bits<16> opcode,  class AsmCondUnaryRSY<string mnemonic, bits<16> opcode,                        RegisterOperand cls, bits<5> bytes,                        AddressingMode mode = bdaddr20only> -  : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, uimm8zx4:$R3), +  : InstRSY<opcode, (outs cls:$R1), (ins cls:$R1src, mode:$BD2, imm32zx4:$R3),              mnemonic#"\t$R1, $BD2, $R3", []>,      Requires<[FeatureLoadStoreOnCond]> {    let mayLoad = 1; @@ -1315,22 +1315,23 @@ multiclass CmpSwapRSPair<string mnemonic, bits<8> rsOpcode, bits<16> rsyOpcode,  class RotateSelectRIEf<string mnemonic, bits<16> opcode, RegisterOperand cls1,                         RegisterOperand cls2>    : InstRIEf<opcode, (outs cls1:$R1), -             (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5), +             (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4, +                  imm32zx6:$I5),               mnemonic#"\t$R1, $R2, $I3, $I4, $I5", []> {    let Constraints = "$R1 = $R1src";    let DisableEncoding = "$R1src";  }  class PrefetchRXY<string mnemonic, bits<16> opcode, SDPatternOperator operator> -  : InstRXY<opcode, (outs), (ins uimm8zx4:$R1, bdxaddr20only:$XBD2), +  : InstRXY<opcode, (outs), (ins imm32zx4:$R1, bdxaddr20only:$XBD2),              mnemonic##"\t$R1, $XBD2", -            [(operator uimm8zx4:$R1, bdxaddr20only:$XBD2)]>; +            [(operator imm32zx4:$R1, bdxaddr20only:$XBD2)]>;  class PrefetchRILPC<string mnemonic, bits<12> opcode,                      SDPatternOperator operator> -  : InstRIL<opcode, (outs), (ins uimm8zx4:$R1, pcrel32:$I2), +  : InstRIL<opcode, (outs), (ins imm32zx4:$R1, pcrel32:$I2),              mnemonic##"\t$R1, $I2", -            [(operator uimm8zx4:$R1, pcrel32:$I2)]> { +            [(operator imm32zx4:$R1, pcrel32:$I2)]> {    // We want PC-relative addresses to be tried ahead of BD and BDX addresses.    // However, BDXs have two extra operands and are therefore 6 units more    // complex. @@ -1450,7 +1451,8 @@ class StoreRXYPseudo<SDPatternOperator operator, RegisterOperand cls,  // of registers.  class RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>    : Pseudo<(outs cls1:$R1), -           (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5), +           (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4, +                imm32zx6:$I5),             []> {    let Constraints = "$R1 = $R1src";    let DisableEncoding = "$R1src"; @@ -1460,9 +1462,9 @@ class RotateSelectRIEfPseudo<RegisterOperand cls1, RegisterOperand cls2>  // the value of the PSW's 2-bit condition code field.  class SelectWrapper<RegisterOperand cls>    : Pseudo<(outs cls:$dst), -           (ins cls:$src1, cls:$src2, uimm8zx4:$valid, uimm8zx4:$cc), +           (ins cls:$src1, cls:$src2, imm32zx4:$valid, imm32zx4:$cc),             [(set cls:$dst, (z_select_ccmask cls:$src1, cls:$src2, -                                            uimm8zx4:$valid, uimm8zx4:$cc))]> { +                                            imm32zx4:$valid, imm32zx4:$cc))]> {    let usesCustomInserter = 1;    // Although the instructions used by these nodes do not in themselves    // change CC, the insertion requires new blocks, and CC cannot be live @@ -1476,14 +1478,14 @@ multiclass CondStores<RegisterOperand cls, SDPatternOperator store,                        SDPatternOperator load, AddressingMode mode> {    let Defs = [CC], Uses = [CC], usesCustomInserter = 1 in {      def "" : Pseudo<(outs), -                    (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc), +                    (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),                      [(store (z_select_ccmask cls:$new, (load mode:$addr), -                                             uimm8zx4:$valid, uimm8zx4:$cc), +                                             imm32zx4:$valid, imm32zx4:$cc),                              mode:$addr)]>;      def Inv : Pseudo<(outs), -                     (ins cls:$new, mode:$addr, uimm8zx4:$valid, uimm8zx4:$cc), +                     (ins cls:$new, mode:$addr, imm32zx4:$valid, imm32zx4:$cc),                       [(store (z_select_ccmask (load mode:$addr), cls:$new, -                                              uimm8zx4:$valid, uimm8zx4:$cc), +                                              imm32zx4:$valid, imm32zx4:$cc),                                mode:$addr)]>;    }  } @@ -1611,6 +1613,7 @@ class CompareAliasRI<SDPatternOperator operator, RegisterOperand cls,  // An alias of a RotateSelectRIEf, but with different register sizes.  class RotateSelectAliasRIEf<RegisterOperand cls1, RegisterOperand cls2>    : Alias<6, (outs cls1:$R1), -          (ins cls1:$R1src, cls2:$R2, uimm8:$I3, uimm8:$I4, uimm8zx6:$I5), []> { +          (ins cls1:$R1src, cls2:$R2, imm32zx8:$I3, imm32zx8:$I4, +               imm32zx6:$I5), []> {    let Constraints = "$R1 = $R1src";  } diff --git a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td index e70df92ffe8..3639c1abdb4 100644 --- a/llvm/lib/Target/SystemZ/SystemZInstrInfo.td +++ b/llvm/lib/Target/SystemZ/SystemZInstrInfo.td @@ -63,11 +63,11 @@ let isBranch = 1, isTerminator = 1, Uses = [CC] in {      def BRCL : InstRIL<0xC04, (outs), (ins cond4:$valid, cond4:$R1,                                             brtarget32:$I2), "jg$R1\t$I2", []>;    } -  def AsmBRC : InstRI<0xA74, (outs), (ins uimm8zx4:$R1, brtarget16:$I2), +  def AsmBRC : InstRI<0xA74, (outs), (ins imm32zx4:$R1, brtarget16:$I2),                        "brc\t$R1, $I2", []>; -  def AsmBRCL : InstRIL<0xC04, (outs), (ins uimm8zx4:$R1, brtarget32:$I2), +  def AsmBRCL : InstRIL<0xC04, (outs), (ins imm32zx4:$R1, brtarget32:$I2),                          "brcl\t$R1, $I2", []>; -  def AsmBCR : InstRR<0x07, (outs), (ins uimm8zx4:$R1, GR64:$R2), +  def AsmBCR : InstRR<0x07, (outs), (ins imm32zx4:$R1, GR64:$R2),                        "bcr\t$R1, $R2", []>;  } @@ -109,7 +109,7 @@ multiclass CompareBranches<Operand ccmask, string pos1, string pos2> {  }  let isCodeGenOnly = 1 in    defm C : CompareBranches<cond4, "$M3", "">; -defm AsmC : CompareBranches<uimm8zx4, "", "$M3, ">; +defm AsmC : CompareBranches<imm32zx4, "", "$M3, ">;  // Define AsmParser mnemonics for each general condition-code mask  // (integer or floating-point) @@ -855,7 +855,7 @@ let Defs = [CC] in {    }    // AND to memory -  defm NI : BinarySIPair<"ni", 0x94, 0xEB54, null_frag, uimm8>; +  defm NI : BinarySIPair<"ni", 0x94, 0xEB54, null_frag, imm32zx8>;    // Block AND.    let mayLoad = 1, mayStore = 1 in @@ -912,7 +912,7 @@ let Defs = [CC] in {    }    // OR to memory -  defm OI : BinarySIPair<"oi", 0x96, 0xEB56, null_frag, uimm8>; +  defm OI : BinarySIPair<"oi", 0x96, 0xEB56, null_frag, imm32zx8>;    // Block OR.    let mayLoad = 1, mayStore = 1 in @@ -952,7 +952,7 @@ let Defs = [CC] in {    }    // XOR to memory -  defm XI : BinarySIPair<"xi", 0x97, 0xEB57, null_frag, uimm8>; +  defm XI : BinarySIPair<"xi", 0x97, 0xEB57, null_frag, imm32zx8>;    // Block XOR.    let mayLoad = 1, mayStore = 1 in @@ -1403,15 +1403,15 @@ def  : Pat<(sub GR64:$src1, (azextloadi32 bdxaddr20only:$addr)),  // Optimize sign-extended 1/0 selects to -1/0 selects.  This is important  // for vector legalization. -def : Pat<(sra (shl (i32 (z_select_ccmask 1, 0, uimm8zx4:$valid, uimm8zx4:$cc)), +def : Pat<(sra (shl (i32 (z_select_ccmask 1, 0, imm32zx4:$valid, imm32zx4:$cc)),                           (i32 31)),                      (i32 31)), -          (Select32 (LHI -1), (LHI 0), uimm8zx4:$valid, uimm8zx4:$cc)>; -def : Pat<(sra (shl (i64 (anyext (i32 (z_select_ccmask 1, 0, uimm8zx4:$valid, -                                                       uimm8zx4:$cc)))), +          (Select32 (LHI -1), (LHI 0), imm32zx4:$valid, imm32zx4:$cc)>; +def : Pat<(sra (shl (i64 (anyext (i32 (z_select_ccmask 1, 0, imm32zx4:$valid, +                                                       imm32zx4:$cc)))),                      (i32 63)),                 (i32 63)), -          (Select64 (LGHI -1), (LGHI 0), uimm8zx4:$valid, uimm8zx4:$cc)>; +          (Select64 (LGHI -1), (LGHI 0), imm32zx4:$valid, imm32zx4:$cc)>;  // Peepholes for turning scalar operations into block operations.  defm : BlockLoadStore<anyextloadi8, i32, MVCSequence, NCSequence, OCSequence, diff --git a/llvm/lib/Target/SystemZ/SystemZOperands.td b/llvm/lib/Target/SystemZ/SystemZOperands.td index 3ad146c57d9..7be81dca727 100644 --- a/llvm/lib/Target/SystemZ/SystemZOperands.td +++ b/llvm/lib/Target/SystemZ/SystemZOperands.td @@ -202,21 +202,6 @@ def S32Imm : ImmediateAsmOperand<"S32Imm">;  def U32Imm : ImmediateAsmOperand<"U32Imm">;  //===----------------------------------------------------------------------===// -// 8-bit immediates -//===----------------------------------------------------------------------===// - -def uimm8zx4 : Immediate<i8, [{ -  return isUInt<4>(N->getZExtValue()); -}], NOOP_SDNodeXForm, "U4Imm">; - -def uimm8zx6 : Immediate<i8, [{ -  return isUInt<6>(N->getZExtValue()); -}], NOOP_SDNodeXForm, "U6Imm">; - -def simm8    : Immediate<i8, [{}], SIMM8, "S8Imm">; -def uimm8    : Immediate<i8, [{}], UIMM8, "U8Imm">; - -//===----------------------------------------------------------------------===//  // i32 immediates  //===----------------------------------------------------------------------===// @@ -241,6 +226,14 @@ def imm32lh16c : Immediate<i32, [{  }], LH16, "U16Imm">;  // Short immediates +def imm32zx4 : Immediate<i32, [{ +  return isUInt<4>(N->getZExtValue()); +}], NOOP_SDNodeXForm, "U4Imm">; + +def imm32zx6 : Immediate<i32, [{ +  return isUInt<6>(N->getZExtValue()); +}], NOOP_SDNodeXForm, "U6Imm">; +  def imm32sx8 : Immediate<i32, [{    return isInt<8>(N->getSExtValue());  }], SIMM8, "S8Imm">; @@ -470,13 +463,13 @@ def AccessReg : AsmOperandClass {    let Name = "AccessReg";    let ParserMethod = "parseAccessReg";  } -def access_reg : Immediate<i8, [{ return N->getZExtValue() < 16; }], +def access_reg : Immediate<i32, [{ return N->getZExtValue() < 16; }],                             NOOP_SDNodeXForm, "AccessReg"> {    let ParserMatchClass = AccessReg;  }  // A 4-bit condition-code mask. -def cond4 : PatLeaf<(i8 imm), [{ return (N->getZExtValue() < 16); }]>, -            Operand<i8> { +def cond4 : PatLeaf<(i32 imm), [{ return (N->getZExtValue() < 16); }]>, +            Operand<i32> {    let PrintMethod = "printCond4Operand";  } diff --git a/llvm/lib/Target/SystemZ/SystemZOperators.td b/llvm/lib/Target/SystemZ/SystemZOperators.td index a3919618f8f..c70e662db42 100644 --- a/llvm/lib/Target/SystemZ/SystemZOperators.td +++ b/llvm/lib/Target/SystemZ/SystemZOperators.td @@ -19,14 +19,14 @@ def SDT_ZICmp               : SDTypeProfile<0, 3,                                              [SDTCisSameAs<0, 1>,                                               SDTCisVT<2, i32>]>;  def SDT_ZBRCCMask           : SDTypeProfile<0, 3, -                                            [SDTCisVT<0, i8>, -                                             SDTCisVT<1, i8>, +                                            [SDTCisVT<0, i32>, +                                             SDTCisVT<1, i32>,                                               SDTCisVT<2, OtherVT>]>;  def SDT_ZSelectCCMask       : SDTypeProfile<1, 4,                                              [SDTCisSameAs<0, 1>,                                               SDTCisSameAs<1, 2>, -                                             SDTCisVT<3, i8>, -                                             SDTCisVT<4, i8>]>; +                                             SDTCisVT<3, i32>, +                                             SDTCisVT<4, i32>]>;  def SDT_ZWrapPtr            : SDTypeProfile<1, 1,                                              [SDTCisSameAs<0, 1>,                                               SDTCisPtrTy<0>]>; @@ -37,7 +37,7 @@ def SDT_ZWrapOffset         : SDTypeProfile<1, 2,  def SDT_ZAdjDynAlloc        : SDTypeProfile<1, 0, [SDTCisVT<0, i64>]>;  def SDT_ZExtractAccess      : SDTypeProfile<1, 1,                                              [SDTCisVT<0, i32>, -                                             SDTCisVT<1, i8>]>; +                                             SDTCisVT<1, i32>]>;  def SDT_ZGR128Binary32      : SDTypeProfile<1, 2,                                              [SDTCisVT<0, untyped>,                                               SDTCisVT<1, untyped>, @@ -77,7 +77,7 @@ def SDT_ZString             : SDTypeProfile<1, 3,                                               SDTCisVT<3, i32>]>;  def SDT_ZI32Intrinsic       : SDTypeProfile<1, 0, [SDTCisVT<0, i32>]>;  def SDT_ZPrefetch           : SDTypeProfile<0, 2, -                                            [SDTCisVT<0, i8>, +                                            [SDTCisVT<0, i32>,                                               SDTCisPtrTy<1>]>;  //===----------------------------------------------------------------------===// diff --git a/llvm/lib/Target/SystemZ/SystemZPatterns.td b/llvm/lib/Target/SystemZ/SystemZPatterns.td index c0f94ecbe2c..e307f8a888e 100644 --- a/llvm/lib/Target/SystemZ/SystemZPatterns.td +++ b/llvm/lib/Target/SystemZ/SystemZPatterns.td @@ -101,15 +101,15 @@ multiclass CondStores64<Instruction insn, Instruction insninv,                          SDPatternOperator store, SDPatternOperator load,                          AddressingMode mode> {    def : Pat<(store (z_select_ccmask GR64:$new, (load mode:$addr), -                                    uimm8zx4:$valid, uimm8zx4:$cc), +                                    imm32zx4:$valid, imm32zx4:$cc),                     mode:$addr),              (insn (EXTRACT_SUBREG GR64:$new, subreg_l32), mode:$addr, -                  uimm8zx4:$valid, uimm8zx4:$cc)>; +                  imm32zx4:$valid, imm32zx4:$cc)>;    def : Pat<(store (z_select_ccmask (load mode:$addr), GR64:$new, -                                    uimm8zx4:$valid, uimm8zx4:$cc), +                                    imm32zx4:$valid, imm32zx4:$cc),                     mode:$addr),              (insninv (EXTRACT_SUBREG GR64:$new, subreg_l32), mode:$addr, -                     uimm8zx4:$valid, uimm8zx4:$cc)>; +                     imm32zx4:$valid, imm32zx4:$cc)>;  }  // Try to use MVC instruction INSN for a load of type LOAD followed by a store | 

