diff options
| author | Nadav Rotem <nadav.rotem@intel.com> | 2011-06-01 19:47:10 +0000 | 
|---|---|---|
| committer | Nadav Rotem <nadav.rotem@intel.com> | 2011-06-01 19:47:10 +0000 | 
| commit | 22ad9bb7d93f09962d47045d6c932df5bb1077bc (patch) | |
| tree | ad63f7f93a3976a019d554cc654dd1bca102ae60 /llvm/lib/CodeGen/SelectionDAG | |
| parent | 755faf7744a04d81d5e9df76b917c3819b60c574 (diff) | |
| download | bcm5719-llvm-22ad9bb7d93f09962d47045d6c932df5bb1077bc.tar.gz bcm5719-llvm-22ad9bb7d93f09962d47045d6c932df5bb1077bc.zip | |
Refactor LegalizeTypes: Erase LegalizeAction and make the type legalizer use
the TargetLowering enum.
llvm-svn: 132418
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 34 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp | 32 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h | 33 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp | 16 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp | 52 | 
5 files changed, 71 insertions, 96 deletions
| diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 935aab0e59a..882ad7e639f 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -174,24 +174,24 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BITCAST(SDNode *N) {    default:      assert(false && "Unknown type action!");      break; -  case Legal: +  case TargetLowering::TypeLegal:      break; -  case PromoteInteger: +  case TargetLowering::TypePromoteInteger:      if (NOutVT.bitsEq(NInVT))        // The input promotes to the same size.  Convert the promoted value.        return DAG.getNode(ISD::BITCAST, dl, NOutVT, GetPromotedInteger(InOp));      break; -  case SoftenFloat: +  case TargetLowering::TypeSoftenFloat:      // Promote the integer operand by hand.      return DAG.getNode(ISD::ANY_EXTEND, dl, NOutVT, GetSoftenedFloat(InOp)); -  case ExpandInteger: -  case ExpandFloat: +  case TargetLowering::TypeExpandInteger: +  case TargetLowering::TypeExpandFloat:      break; -  case ScalarizeVector: +  case TargetLowering::TypeScalarizeVector:      // Convert the element to an integer and promote it by hand.      return DAG.getNode(ISD::ANY_EXTEND, dl, NOutVT,                         BitConvertToInteger(GetScalarizedVector(InOp))); -  case SplitVector: { +  case TargetLowering::TypeSplitVector: {      // For example, i32 = BITCAST v2i16 on alpha.  Convert the split      // pieces of the input into integers and reassemble in the final type.      SDValue Lo, Hi; @@ -208,7 +208,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BITCAST(SDNode *N) {                         JoinIntegers(Lo, Hi));      return DAG.getNode(ISD::BITCAST, dl, NOutVT, InOp);    } -  case WidenVector: +  case TargetLowering::TypeWidenVector:      if (OutVT.bitsEq(NInVT))        // The input is widened to the same size.  Convert to the widened value.        return DAG.getNode(ISD::BITCAST, dl, OutVT, GetWidenedVector(InOp)); @@ -342,7 +342,8 @@ SDValue DAGTypeLegalizer::PromoteIntRes_INT_EXTEND(SDNode *N) {    EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), N->getValueType(0));    DebugLoc dl = N->getDebugLoc(); -  if (getTypeAction(N->getOperand(0).getValueType()) == PromoteInteger) { +  if (getTypeAction(N->getOperand(0).getValueType()) +      == TargetLowering::TypePromoteInteger) {      SDValue Res = GetPromotedInteger(N->getOperand(0));      assert(Res.getValueType().bitsLE(NVT) && "Extension doesn't make sense!"); @@ -507,11 +508,11 @@ SDValue DAGTypeLegalizer::PromoteIntRes_TRUNCATE(SDNode *N) {    switch (getTypeAction(N->getOperand(0).getValueType())) {    default: llvm_unreachable("Unknown type action!"); -  case Legal: -  case ExpandInteger: +  case TargetLowering::TypeLegal: +  case TargetLowering::TypeExpandInteger:      Res = N->getOperand(0);      break; -  case PromoteInteger: +  case TargetLowering::TypePromoteInteger:      Res = GetPromotedInteger(N->getOperand(0));      break;    } @@ -1513,7 +1514,8 @@ void DAGTypeLegalizer::ExpandIntRes_ANY_EXTEND(SDNode *N,    } else {      // For example, extension of an i48 to an i64.  The operand type necessarily      // promotes to the result type, so will end up being expanded too. -    assert(getTypeAction(Op.getValueType()) == PromoteInteger && +    assert(getTypeAction(Op.getValueType()) == +           TargetLowering::TypePromoteInteger &&             "Only know how to promote this result!");      SDValue Res = GetPromotedInteger(Op);      assert(Res.getValueType() == N->getValueType(0) && @@ -2030,7 +2032,8 @@ void DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(SDNode *N,    } else {      // For example, extension of an i48 to an i64.  The operand type necessarily      // promotes to the result type, so will end up being expanded too. -    assert(getTypeAction(Op.getValueType()) == PromoteInteger && +    assert(getTypeAction(Op.getValueType()) == +           TargetLowering::TypePromoteInteger &&             "Only know how to promote this result!");      SDValue Res = GetPromotedInteger(Op);      assert(Res.getValueType() == N->getValueType(0) && @@ -2178,7 +2181,8 @@ void DAGTypeLegalizer::ExpandIntRes_ZERO_EXTEND(SDNode *N,    } else {      // For example, extension of an i48 to an i64.  The operand type necessarily      // promotes to the result type, so will end up being expanded too. -    assert(getTypeAction(Op.getValueType()) == PromoteInteger && +    assert(getTypeAction(Op.getValueType()) == +           TargetLowering::TypePromoteInteger &&             "Only know how to promote this result!");      SDValue Res = GetPromotedInteger(Op);      assert(Res.getValueType() == N->getValueType(0) && diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp index cedda7e7075..ba658b02205 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.cpp @@ -224,38 +224,38 @@ bool DAGTypeLegalizer::run() {        switch (getTypeAction(ResultVT)) {        default:          assert(false && "Unknown action!"); -      case Legal: +      case TargetLowering::TypeLegal:          break;        // The following calls must take care of *all* of the node's results,        // not just the illegal result they were passed (this includes results        // with a legal type).  Results can be remapped using ReplaceValueWith,        // or their promoted/expanded/etc values registered in PromotedIntegers,        // ExpandedIntegers etc. -      case PromoteInteger: +      case TargetLowering::TypePromoteInteger:          PromoteIntegerResult(N, i);          Changed = true;          goto NodeDone; -      case ExpandInteger: +      case TargetLowering::TypeExpandInteger:          ExpandIntegerResult(N, i);          Changed = true;          goto NodeDone; -      case SoftenFloat: +      case TargetLowering::TypeSoftenFloat:          SoftenFloatResult(N, i);          Changed = true;          goto NodeDone; -      case ExpandFloat: +      case TargetLowering::TypeExpandFloat:          ExpandFloatResult(N, i);          Changed = true;          goto NodeDone; -      case ScalarizeVector: +      case TargetLowering::TypeScalarizeVector:          ScalarizeVectorResult(N, i);          Changed = true;          goto NodeDone; -      case SplitVector: +      case TargetLowering::TypeSplitVector:          SplitVectorResult(N, i);          Changed = true;          goto NodeDone; -      case WidenVector: +      case TargetLowering::TypeWidenVector:          WidenVectorResult(N, i);          Changed = true;          goto NodeDone; @@ -277,36 +277,36 @@ ScanOperands:        switch (getTypeAction(OpVT)) {        default:          assert(false && "Unknown action!"); -      case Legal: +      case TargetLowering::TypeLegal:          continue;        // The following calls must either replace all of the node's results        // using ReplaceValueWith, and return "false"; or update the node's        // operands in place, and return "true". -      case PromoteInteger: +      case TargetLowering::TypePromoteInteger:          NeedsReanalyzing = PromoteIntegerOperand(N, i);          Changed = true;          break; -      case ExpandInteger: +      case TargetLowering::TypeExpandInteger:          NeedsReanalyzing = ExpandIntegerOperand(N, i);          Changed = true;          break; -      case SoftenFloat: +      case TargetLowering::TypeSoftenFloat:          NeedsReanalyzing = SoftenFloatOperand(N, i);          Changed = true;          break; -      case ExpandFloat: +      case TargetLowering::TypeExpandFloat:          NeedsReanalyzing = ExpandFloatOperand(N, i);          Changed = true;          break; -      case ScalarizeVector: +      case TargetLowering::TypeScalarizeVector:          NeedsReanalyzing = ScalarizeVectorOperand(N, i);          Changed = true;          break; -      case SplitVector: +      case TargetLowering::TypeSplitVector:          NeedsReanalyzing = SplitVectorOperand(N, i);          Changed = true;          break; -      case WidenVector: +      case TargetLowering::TypeWidenVector:          NeedsReanalyzing = WidenVectorOperand(N, i);          Changed = true;          break; diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h index b2daf8519b1..3713f94bea8 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h @@ -57,16 +57,6 @@ public:      // 1+ - This is a node which has this many unprocessed operands.    };  private: -  enum LegalizeAction { -    Legal,           // The target natively supports this type. -    PromoteInteger,  // Replace this integer type with a larger one. -    ExpandInteger,   // Split this integer type into two of half the size. -    SoftenFloat,     // Convert this float type to a same size integer type. -    ExpandFloat,     // Split this float type into two of half the size. -    ScalarizeVector, // Replace this one-element vector with its element type. -    SplitVector,     // Split this vector type into two of half the size. -    WidenVector      // This vector type should be widened into a larger vector. -  };    /// ValueTypeActions - This is a bitvector that contains two bits for each    /// simple value type, where the two bits correspond to the LegalizeAction @@ -74,27 +64,8 @@ private:    TargetLowering::ValueTypeActionImpl ValueTypeActions;    /// getTypeAction - Return how we should legalize values of this type. -  LegalizeAction getTypeAction(EVT VT) const { -    switch (TLI.getTypeAction(*DAG.getContext(), VT)) { -    default: -      assert(false && "Unknown legalize action!"); -    case TargetLowering::Legal: -      return Legal; -    case TargetLowering::TypePromoteInteger: -      return PromoteInteger; -    case TargetLowering::TypeExpandInteger: -      return ExpandInteger; -    case TargetLowering::TypeExpandFloat: -      return ExpandFloat; -    case TargetLowering::TypeSoftenFloat: -        return SoftenFloat; -    case TargetLowering::TypeWidenVector: -      return WidenVector; -    case TargetLowering::TypeScalarizeVector: -      return ScalarizeVector; -    case TargetLowering::TypeSplitVector: -       return SplitVector; -    } +  TargetLowering::LegalizeTypeAction getTypeAction(EVT VT) const { +    return TLI.getTypeAction(*DAG.getContext(), VT);    }    /// isTypeLegal - Return true if this type is legal on this target. diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp index a75ae87f3cb..85ea6b66204 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp @@ -43,36 +43,36 @@ void DAGTypeLegalizer::ExpandRes_BITCAST(SDNode *N, SDValue &Lo, SDValue &Hi) {    switch (getTypeAction(InVT)) {      default:        assert(false && "Unknown type action!"); -    case Legal: -    case PromoteInteger: +    case TargetLowering::TypeLegal: +    case TargetLowering::TypePromoteInteger:        break; -    case SoftenFloat: +    case TargetLowering::TypeSoftenFloat:        // Convert the integer operand instead.        SplitInteger(GetSoftenedFloat(InOp), Lo, Hi);        Lo = DAG.getNode(ISD::BITCAST, dl, NOutVT, Lo);        Hi = DAG.getNode(ISD::BITCAST, dl, NOutVT, Hi);        return; -    case ExpandInteger: -    case ExpandFloat: +    case TargetLowering::TypeExpandInteger: +    case TargetLowering::TypeExpandFloat:        // Convert the expanded pieces of the input.        GetExpandedOp(InOp, Lo, Hi);        Lo = DAG.getNode(ISD::BITCAST, dl, NOutVT, Lo);        Hi = DAG.getNode(ISD::BITCAST, dl, NOutVT, Hi);        return; -    case SplitVector: +    case TargetLowering::TypeSplitVector:        GetSplitVector(InOp, Lo, Hi);        if (TLI.isBigEndian())          std::swap(Lo, Hi);        Lo = DAG.getNode(ISD::BITCAST, dl, NOutVT, Lo);        Hi = DAG.getNode(ISD::BITCAST, dl, NOutVT, Hi);        return; -    case ScalarizeVector: +    case TargetLowering::TypeScalarizeVector:        // Convert the element instead.        SplitInteger(BitConvertToInteger(GetScalarizedVector(InOp)), Lo, Hi);        Lo = DAG.getNode(ISD::BITCAST, dl, NOutVT, Lo);        Hi = DAG.getNode(ISD::BITCAST, dl, NOutVT, Hi);        return; -    case WidenVector: { +    case TargetLowering::TypeWidenVector: {        assert(!(InVT.getVectorNumElements() & 1) && "Unsupported BITCAST");        InOp = GetWidenedVector(InOp);        EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(), diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp index 0b4dd357c39..e27017d7760 100644 --- a/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp @@ -526,13 +526,13 @@ void DAGTypeLegalizer::SplitVecRes_BITCAST(SDNode *N, SDValue &Lo,    switch (getTypeAction(InVT)) {    default:      assert(false && "Unknown type action!"); -  case Legal: -  case PromoteInteger: -  case SoftenFloat: -  case ScalarizeVector: +  case TargetLowering::TypeLegal: +  case TargetLowering::TypePromoteInteger: +  case TargetLowering::TypeSoftenFloat: +  case TargetLowering::TypeScalarizeVector:      break; -  case ExpandInteger: -  case ExpandFloat: +  case TargetLowering::TypeExpandInteger: +  case TargetLowering::TypeExpandFloat:      // A scalar to vector conversion, where the scalar needs expansion.      // If the vector is being split in two then we can just convert the      // expanded pieces. @@ -545,7 +545,7 @@ void DAGTypeLegalizer::SplitVecRes_BITCAST(SDNode *N, SDValue &Lo,        return;      }      break; -  case SplitVector: +  case TargetLowering::TypeSplitVector:      // If the input is a vector that needs to be split, convert each split      // piece of the input now.      GetSplitVector(InOp, Lo, Hi); @@ -774,7 +774,7 @@ void DAGTypeLegalizer::SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo,    EVT InVT = N->getOperand(0).getValueType();    switch (getTypeAction(InVT)) {    default: llvm_unreachable("Unexpected type action!"); -  case Legal: { +  case TargetLowering::TypeLegal: {      EVT InNVT = EVT::getVectorVT(*DAG.getContext(), InVT.getVectorElementType(),                                   LoVT.getVectorNumElements());      Lo = DAG.getNode(ISD::EXTRACT_SUBVECTOR, dl, InNVT, N->getOperand(0), @@ -783,10 +783,10 @@ void DAGTypeLegalizer::SplitVecRes_UnaryOp(SDNode *N, SDValue &Lo,                       DAG.getIntPtrConstant(InNVT.getVectorNumElements()));      break;    } -  case SplitVector: +  case TargetLowering::TypeSplitVector:      GetSplitVector(N->getOperand(0), Lo, Hi);      break; -  case WidenVector: { +  case TargetLowering::TypeWidenVector: {      // If the result needs to be split and the input needs to be widened,      // the two types must have different lengths. Use the widened result      // and extract from it to do the split. @@ -1439,7 +1439,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_Convert(SDNode *N) {    unsigned Opcode = N->getOpcode();    unsigned InVTNumElts = InVT.getVectorNumElements(); -  if (getTypeAction(InVT) == WidenVector) { +  if (getTypeAction(InVT) == TargetLowering::TypeWidenVector) {      InOp = GetWidenedVector(N->getOperand(0));      InVT = InOp.getValueType();      InVTNumElts = InVT.getVectorNumElements(); @@ -1515,7 +1515,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_Shift(SDNode *N) {    SDValue ShOp = N->getOperand(1);    EVT ShVT = ShOp.getValueType(); -  if (getTypeAction(ShVT) == WidenVector) { +  if (getTypeAction(ShVT) == TargetLowering::TypeWidenVector) {      ShOp = GetWidenedVector(ShOp);      ShVT = ShOp.getValueType();    } @@ -1557,9 +1557,9 @@ SDValue DAGTypeLegalizer::WidenVecRes_BITCAST(SDNode *N) {    default:      assert(false && "Unknown type action!");      break; -  case Legal: +  case TargetLowering::TypeLegal:      break; -  case PromoteInteger: +  case TargetLowering::TypePromoteInteger:      // If the InOp is promoted to the same size, convert it.  Otherwise,      // fall out of the switch and widen the promoted input.      InOp = GetPromotedInteger(InOp); @@ -1567,13 +1567,13 @@ SDValue DAGTypeLegalizer::WidenVecRes_BITCAST(SDNode *N) {      if (WidenVT.bitsEq(InVT))        return DAG.getNode(ISD::BITCAST, dl, WidenVT, InOp);      break; -  case SoftenFloat: -  case ExpandInteger: -  case ExpandFloat: -  case ScalarizeVector: -  case SplitVector: +  case TargetLowering::TypeSoftenFloat: +  case TargetLowering::TypeExpandInteger: +  case TargetLowering::TypeExpandFloat: +  case TargetLowering::TypeScalarizeVector: +  case TargetLowering::TypeSplitVector:      break; -  case WidenVector: +  case TargetLowering::TypeWidenVector:      // If the InOp is widened to the same size, convert it.  Otherwise, fall      // out of the switch and widen the widened input.      InOp = GetWidenedVector(InOp); @@ -1653,7 +1653,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_CONCAT_VECTORS(SDNode *N) {    unsigned NumOperands = N->getNumOperands();    bool InputWidened = false; // Indicates we need to widen the input. -  if (getTypeAction(InVT) != WidenVector) { +  if (getTypeAction(InVT) != TargetLowering::TypeWidenVector) {      if (WidenVT.getVectorNumElements() % InVT.getVectorNumElements() == 0) {        // Add undef vectors to widen to correct length.        unsigned NumConcat = WidenVT.getVectorNumElements() / @@ -1732,7 +1732,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_CONVERT_RNDSAT(SDNode *N) {    ISD::CvtCode CvtCode = cast<CvtRndSatSDNode>(N)->getCvtCode();    unsigned InVTNumElts = InVT.getVectorNumElements(); -  if (getTypeAction(InVT) == WidenVector) { +  if (getTypeAction(InVT) == TargetLowering::TypeWidenVector) {      InOp = GetWidenedVector(InOp);      InVT = InOp.getValueType();      InVTNumElts = InVT.getVectorNumElements(); @@ -1800,7 +1800,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_EXTRACT_SUBVECTOR(SDNode *N) {    SDValue  Idx  = N->getOperand(1);    DebugLoc dl = N->getDebugLoc(); -  if (getTypeAction(InOp.getValueType()) == WidenVector) +  if (getTypeAction(InOp.getValueType()) == TargetLowering::TypeWidenVector)      InOp = GetWidenedVector(InOp);    EVT InVT = InOp.getValueType(); @@ -1882,7 +1882,7 @@ SDValue DAGTypeLegalizer::WidenVecRes_SELECT(SDNode *N) {      EVT CondEltVT = CondVT.getVectorElementType();      EVT CondWidenVT =  EVT::getVectorVT(*DAG.getContext(),                                          CondEltVT, WidenNumElts); -    if (getTypeAction(CondVT) == WidenVector) +    if (getTypeAction(CondVT) == TargetLowering::TypeWidenVector)        Cond1 = GetWidenedVector(Cond1);      if (Cond1.getValueType() != CondWidenVT) @@ -2026,7 +2026,7 @@ SDValue DAGTypeLegalizer::WidenVecOp_Convert(SDNode *N) {    DebugLoc dl = N->getDebugLoc();    unsigned NumElts = VT.getVectorNumElements();    SDValue InOp = N->getOperand(0); -  if (getTypeAction(InOp.getValueType()) == WidenVector) +  if (getTypeAction(InOp.getValueType()) == TargetLowering::TypeWidenVector)      InOp = GetWidenedVector(InOp);    EVT InVT = InOp.getValueType();    EVT InEltVT = InVT.getVectorElementType(); @@ -2081,7 +2081,7 @@ SDValue DAGTypeLegalizer::WidenVecOp_CONCAT_VECTORS(SDNode *N) {    unsigned NumOperands = N->getNumOperands();    for (unsigned i=0; i < NumOperands; ++i) {      SDValue InOp = N->getOperand(i); -    if (getTypeAction(InOp.getValueType()) == WidenVector) +    if (getTypeAction(InOp.getValueType()) == TargetLowering::TypeWidenVector)        InOp = GetWidenedVector(InOp);      for (unsigned j=0; j < NumInElts; ++j)        Ops[Idx++] = DAG.getNode(ISD::EXTRACT_VECTOR_ELT, dl, EltVT, InOp, | 

