X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FTarget%2FCellSPU%2FSPUOperands.td;h=6f8deef5530f54fa9bd25205d67b590cec41c852;hb=fef904d0e824a2c587f8c1063b6c4fbf47fec898;hp=79d1a7a348ac93a739243bf0b58159d0d584509b;hpb=0fec975a183002d9bf59a4c224c048ef9dfd0ba2;p=oota-llvm.git diff --git a/lib/Target/CellSPU/SPUOperands.td b/lib/Target/CellSPU/SPUOperands.td index 79d1a7a348a..6f8deef5530 100644 --- a/lib/Target/CellSPU/SPUOperands.td +++ b/lib/Target/CellSPU/SPUOperands.td @@ -1,22 +1,33 @@ -//===- SPUOperands.td - Cell SPU Instruction Operands ------*- tablegen -*-===// -// +//===-- SPUOperands.td - Cell SPU Instruction Operands -----*- tablegen -*-===// +// // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // Cell SPU Instruction Operands: //===----------------------------------------------------------------------===// +// TO_IMM32 - Convert an i8/i16 to i32. +def TO_IMM32 : SDNodeXFormgetZExtValue()); +}]>; + +// TO_IMM16 - Convert an i8/i32 to i16. +def TO_IMM16 : SDNodeXFormgetTargetConstant(N->getZExtValue(), MVT::i16); +}]>; + + def LO16 : SDNodeXFormgetValue(); + unsigned val = N->getZExtValue(); // Transformation function: get the low 16 bits. return getI32Imm(val & 0xffff); }]>; def LO16_vec : SDNodeXFormgetNumOperands(); OpVal.Val == 0 && i != e; ++i) { + for (unsigned i = 0, e = N->getNumOperands(); + OpVal.getNode() == 0 && i != e; ++i) { if (N->getOperand(i).getOpcode() == ISD::UNDEF) continue; - if (OpVal.Val == 0) + if (OpVal.getNode() == 0) OpVal = N->getOperand(i); } - assert(OpVal.Val != 0 && "LO16_vec did not locate a node"); - ConstantSDNode *CN = dyn_cast(OpVal); - return getI32Imm((unsigned)CN->getValue() & 0xffff); + assert(OpVal.getNode() != 0 && "LO16_vec did not locate a node"); + ConstantSDNode *CN = cast(OpVal); + return getI32Imm((unsigned)CN->getZExtValue() & 0xffff); }]>; // Transform an immediate, returning the high 16 bits shifted down: def HI16 : SDNodeXFormgetValue() >> 16); + return getI32Imm((unsigned)N->getZExtValue() >> 16); }]>; // Transformation function: shift the high 16 bit immediate from a build_vector // node into the low 16 bits, and return a 16-bit constant. def HI16_vec : SDNodeXFormgetOpcode() == ISD::BUILD_VECTOR && "HI16_vec got something other than a BUILD_VECTOR"); // Get first constant operand... - for (unsigned i = 0, e = N->getNumOperands(); OpVal.Val == 0 && i != e; ++i) { + for (unsigned i = 0, e = N->getNumOperands(); + OpVal.getNode() == 0 && i != e; ++i) { if (N->getOperand(i).getOpcode() == ISD::UNDEF) continue; - if (OpVal.Val == 0) + if (OpVal.getNode() == 0) OpVal = N->getOperand(i); } - assert(OpVal.Val != 0 && "HI16_vec did not locate a node"); - ConstantSDNode *CN = dyn_cast(OpVal); - return getI32Imm((unsigned)CN->getValue() >> 16); + assert(OpVal.getNode() != 0 && "HI16_vec did not locate a node"); + ConstantSDNode *CN = cast(OpVal); + return getI32Imm((unsigned)CN->getZExtValue() >> 16); }]>; // simm7 predicate - True if the immediate fits in an 7-bit signed // field. def simm7: PatLeaf<(imm), [{ - int sextVal = ((((int) N->getValue()) << 25) >> 25); + int sextVal = int(N->getSExtValue()); return (sextVal >= -64 && sextVal <= 63); }]>; // uimm7 predicate - True if the immediate fits in an 7-bit unsigned // field. def uimm7: PatLeaf<(imm), [{ - return (N->getValue() <= 0x7f); + return (N->getZExtValue() <= 0x7f); }]>; // immSExt8 predicate - True if the immediate fits in an 8-bit sign extended // field. def immSExt8 : PatLeaf<(imm), [{ - int Value = (int) N->getValue(); - int Value8 = (Value << 24) >> 24; - return (Value < 0xff && (Value8 >= -128 && Value8 < 127)); + int Value = int(N->getSExtValue()); + return (Value >= -(1 << 8) && Value <= (1 << 8) - 1); }]>; // immU8: immediate, unsigned 8-bit quantity def immU8 : PatLeaf<(imm), [{ - return (N->getValue() <= 0xff); -}]>; - -// i64ImmSExt10 predicate - True if the i64 immediate fits in a 10-bit sign -// extended field. Used by RI10Form instructions like 'ldq'. -def i64ImmSExt10 : PatLeaf<(imm), [{ - return isI64IntS10Immediate(N); + return (N->getZExtValue() <= 0xff); }]>; // i32ImmSExt10 predicate - True if the i32 immediate fits in a 10-bit sign @@ -126,25 +132,25 @@ def immSExt16 : PatLeaf<(imm), [{ def immZExt16 : PatLeaf<(imm), [{ // immZExt16 predicate - True if the immediate fits in a 16-bit zero extended // field. - return (uint64_t)N->getValue() == (unsigned short)N->getValue(); + return (uint64_t)N->getZExtValue() == (unsigned short)N->getZExtValue(); }], LO16>; def immU16 : PatLeaf<(imm), [{ // immU16 predicate- True if the immediate fits into a 16-bit unsigned field. - return (uint64_t)N->getValue() == (N->getValue() & 0xffff); + return (uint64_t)N->getZExtValue() == (N->getZExtValue() & 0xffff); }]>; def imm18 : PatLeaf<(imm), [{ // imm18 predicate: True if the immediate fits into an 18-bit unsigned field. - int Value = (int) N->getValue(); - return ((Value & ((1 << 19) - 1)) == Value); + int Value = (int) N->getZExtValue(); + return isUInt<18>(Value); }]>; def lo16 : PatLeaf<(imm), [{ - // hi16 predicate - returns true if the immediate has all zeros in the + // lo16 predicate - returns true if the immediate has all zeros in the // low order bits and is a 32-bit constant: if (N->getValueType(0) == MVT::i32) { - uint32_t val = N->getValue(); + uint32_t val = N->getZExtValue(); return ((val & 0x0000ffff) == val); } @@ -155,13 +161,23 @@ def hi16 : PatLeaf<(imm), [{ // hi16 predicate - returns true if the immediate has all zeros in the // low order bits and is a 32-bit constant: if (N->getValueType(0) == MVT::i32) { - uint32_t val = N->getValue(); + uint32_t val = uint32_t(N->getZExtValue()); return ((val & 0xffff0000) == val); + } else if (N->getValueType(0) == MVT::i64) { + uint64_t val = N->getZExtValue(); + return ((val & 0xffff0000ULL) == val); } return false; }], HI16>; +def bitshift : PatLeaf<(imm), [{ + // bitshift predicate - returns true if 0 < imm <= 7 for SHLQBII + // (shift left quadword by bits immediate) + int64_t Val = N->getZExtValue(); + return (Val > 0 && Val <= 7); +}]>; + //===----------------------------------------------------------------------===// // Floating point operands: //===----------------------------------------------------------------------===// @@ -187,7 +203,7 @@ def FPimm_sext16 : SDNodeXFormgetValueAPF().convertToFloat(); - return getI32Imm(FloatToBits(fval) & ((1 << 19) - 1)); + return getI32Imm(FloatToBits(fval) & ((1 << 18) - 1)); }]>; def fpimmSExt16 : PatLeaf<(fpimm), [{ @@ -209,7 +225,7 @@ def hi16_f32 : PatLeaf<(fpimm), [{ def fpimm18 : PatLeaf<(fpimm), [{ if (N->getValueType(0) == MVT::f32) { uint32_t Value = FloatToBits(N->getValueAPF().convertToFloat()); - return ((Value & ((1 << 19) - 1)) == Value); + return isUInt<18>(Value); } return false; @@ -235,7 +251,7 @@ def v16i8SExt8Imm_xform: SDNodeXForm; // v16i8U8Imm_xform function: convert build_vector to unsigned 8-bit @@ -250,7 +266,7 @@ def v16i8U8Imm_xform: SDNodeXForm; // v8i16SExt8Imm_xform function: convert build_vector to 8-bit sign extended @@ -262,7 +278,7 @@ def v8i16SExt8Imm_xform: SDNodeXForm; // v8i16SExt10Imm_xform function: convert build_vector to 16-bit sign extended @@ -274,7 +290,7 @@ def v8i16SExt10Imm_xform: SDNodeXForm; // v8i16Uns10Imm_xform function: convert build_vector to 16-bit unsigned @@ -286,7 +302,7 @@ def v8i16Uns10Imm_xform: SDNodeXForm; // v8i16SExt16Imm_xform function: convert build_vector to 16-bit sign extended @@ -298,7 +314,7 @@ def v8i16Uns16Imm_xform: SDNodeXForm; // v4i32SExt10Imm_xform function: convert build_vector to 10-bit sign extended @@ -310,7 +326,7 @@ def v4i32SExt10Imm_xform: SDNodeXForm; // v4i32Uns10Imm_xform function: convert build_vector to 10-bit unsigned @@ -322,7 +338,7 @@ def v4i32Uns10Imm_xform: SDNodeXForm; // v4i32SExt16Imm_xform function: convert build_vector to 16-bit sign extended @@ -334,7 +350,7 @@ def v4i32SExt16Imm_xform: SDNodeXForm; // v4i32Uns18Imm_xform function: convert build_vector to 18-bit unsigned @@ -346,7 +362,7 @@ def v4i32Uns18Imm_xform: SDNodeXForm; // ILHUvec_get_imm xform function: convert build_vector to ILHUvec imm constant @@ -357,7 +373,7 @@ def ILHUvec_get_imm: SDNodeXForm; // Catch-all for any other i32 vector constants @@ -366,7 +382,7 @@ def v4i32_get_imm: SDNodeXForm; def v4i32Imm: PatLeaf<(build_vector), [{ - return SPU::get_v4i32_imm(N, *CurDAG).Val != 0; + return SPU::get_v4i32_imm(N, *CurDAG).getNode() != 0; }], v4i32_get_imm>; // v2i64SExt10Imm_xform function: convert build_vector to 10-bit sign extended @@ -378,7 +394,7 @@ def v2i64SExt10Imm_xform: SDNodeXForm; // v2i64SExt16Imm_xform function: convert build_vector to 16-bit sign extended @@ -390,7 +406,7 @@ def v2i64SExt16Imm_xform: SDNodeXForm; // v2i64Uns18Imm_xform function: convert build_vector to 18-bit unsigned @@ -402,12 +418,12 @@ def v2i64Uns18Imm_xform: SDNodeXForm; /// immILHUvec: Predicate test for a ILHU constant vector. def immILHUvec_i64: PatLeaf<(build_vector), [{ - return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i64).Val != 0; + return SPU::get_ILHUvec_imm(N, *CurDAG, MVT::i64).getNode() != 0; }], ILHUvec_get_imm>; // Catch-all for any other i32 vector constants @@ -416,7 +432,7 @@ def v2i64_get_imm: SDNodeXForm; def v2i64Imm: PatLeaf<(build_vector), [{ - return SPU::get_v2i64_imm(N, *CurDAG).Val != 0; + return SPU::get_v2i64_imm(N, *CurDAG).getNode() != 0; }], v2i64_get_imm>; //===----------------------------------------------------------------------===// @@ -447,6 +463,10 @@ def s10imm : Operand { let PrintMethod = "printS10ImmOperand"; } +def s10imm_i8: Operand { + let PrintMethod = "printS10ImmOperand"; +} + def s10imm_i32: Operand { let PrintMethod = "printS10ImmOperand"; } @@ -492,7 +512,15 @@ def s16imm_f64: Operand { let PrintMethod = "printS16ImmOperand"; } -def u16imm : Operand { +def u16imm_i64 : Operand { + let PrintMethod = "printU16ImmOperand"; +} + +def u16imm_i32 : Operand { + let PrintMethod = "printU16ImmOperand"; +} + +def u16imm : Operand { let PrintMethod = "printU16ImmOperand"; } @@ -538,6 +566,10 @@ def rotNeg7imm_i16 : Operand { let PrintMethod = "printROTNeg7Imm"; } +def rotNeg7imm_i8 : Operand { + let PrintMethod = "printROTNeg7Imm"; +} + def target : Operand { let PrintMethod = "printBranchOperand"; } @@ -548,7 +580,7 @@ def calltarget : Operand { let MIOperandInfo = (ops u18imm:$calldest); } -// Relative call target +// PC relative call target def relcalltarget : Operand { let PrintMethod = "printPCRelativeOperand"; let MIOperandInfo = (ops s16imm:$calldest); @@ -559,6 +591,11 @@ def brtarget : Operand { let PrintMethod = "printPCRelativeOperand"; } +// Hint for branch target +def hbrtarget : Operand { + let PrintMethod = "printHBROperand"; +} + // Indirect call target def indcalltarget : Operand { let PrintMethod = "printCallOperand"; @@ -577,15 +614,15 @@ def symbolLSA: Operand { let PrintMethod = "printSymbolLSA"; } -// memory s7imm(reg) operaand -def memri7 : Operand { - let PrintMethod = "printMemRegImmS7"; +// Shuffle address memory operaand [s7imm(reg) d-format] +def shufaddr : Operand { + let PrintMethod = "printShufAddr"; let MIOperandInfo = (ops s7imm:$imm, ptr_rc:$reg); } // memory s10imm(reg) operand -def memri10 : Operand { - let PrintMethod = "printMemRegImmS10"; +def dformaddr : Operand { + let PrintMethod = "printDFormAddr"; let MIOperandInfo = (ops s10imm:$imm, ptr_rc:$reg); } @@ -617,7 +654,11 @@ def memrr : Operand { // A-form : abs (256K LSA offset) // D-form(2): [r+I7] (7-bit signed offset + reg) -def dform_addr : ComplexPattern; -def xform_addr : ComplexPattern; -def aform_addr : ComplexPattern; -def dform2_addr : ComplexPattern; +def dform_addr : ComplexPattern; +def xform_addr : ComplexPattern; +def aform_addr : ComplexPattern; +def dform2_addr : ComplexPattern;