diff options
Diffstat (limited to 'lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
| -rw-r--r-- | lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 53 | 
1 files changed, 45 insertions, 8 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index e6df742bc336..38bf68b8539f 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -15,6 +15,7 @@  #include "SDNodeOrdering.h"  #include "SDNodeDbgValue.h"  #include "llvm/Constants.h" +#include "llvm/Analysis/DebugInfo.h"  #include "llvm/Analysis/ValueTracking.h"  #include "llvm/Function.h"  #include "llvm/GlobalAlias.h" @@ -32,6 +33,7 @@  #include "llvm/Target/TargetData.h"  #include "llvm/Target/TargetFrameInfo.h"  #include "llvm/Target/TargetLowering.h" +#include "llvm/Target/TargetSelectionDAGInfo.h"  #include "llvm/Target/TargetOptions.h"  #include "llvm/Target/TargetInstrInfo.h"  #include "llvm/Target/TargetIntrinsicInfo.h" @@ -789,7 +791,8 @@ unsigned SelectionDAG::getEVTAlignment(EVT VT) const {  // EntryNode could meaningfully have debug info if we can find it...  SelectionDAG::SelectionDAG(const TargetMachine &tm, FunctionLoweringInfo &fli) -  : TM(tm), TLI(*tm.getTargetLowering()), FLI(fli), +  : TM(tm), TLI(*tm.getTargetLowering()), TSI(*tm.getSelectionDAGInfo()), +    FLI(fli),      EntryNode(ISD::EntryToken, DebugLoc(), getVTList(MVT::Other)),      Root(getEntryNode()), Ordering(0) {    AllNodes.push_back(&EntryNode); @@ -963,8 +966,18 @@ SDValue SelectionDAG::getConstantFP(double Val, EVT VT, bool isTarget) {    EVT EltVT = VT.getScalarType();    if (EltVT==MVT::f32)      return getConstantFP(APFloat((float)Val), VT, isTarget); -  else +  else if (EltVT==MVT::f64)      return getConstantFP(APFloat(Val), VT, isTarget); +  else if (EltVT==MVT::f80 || EltVT==MVT::f128) { +    bool ignored; +    APFloat apf = APFloat(Val); +    apf.convert(*EVTToAPFloatSemantics(EltVT), APFloat::rmNearestTiesToEven, +                &ignored); +    return getConstantFP(apf, VT, isTarget); +  } else { +    assert(0 && "Unsupported type in getConstantFP"); +    return SDValue(); +  }  }  SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV, @@ -2614,7 +2627,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL, EVT VT,      }      break;    case ISD::AND: -    assert(VT.isInteger() && N1.getValueType() == N2.getValueType() && +    assert(VT.isInteger() && "This operator does not apply to FP types!"); +    assert(N1.getValueType() == N2.getValueType() &&             N1.getValueType() == VT && "Binary operator types must match!");      // (X & 0) -> 0.  This commonly occurs when legalizing i64 values, so it's      // worth handling here. @@ -2627,7 +2641,8 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL, EVT VT,    case ISD::XOR:    case ISD::ADD:    case ISD::SUB: -    assert(VT.isInteger() && N1.getValueType() == N2.getValueType() && +    assert(VT.isInteger() && "This operator does not apply to FP types!"); +    assert(N1.getValueType() == N2.getValueType() &&             N1.getValueType() == VT && "Binary operator types must match!");      // (X ^|+- 0) -> X.  This commonly occurs when legalizing i64 values, so      // it's worth handling here. @@ -2642,7 +2657,9 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL, EVT VT,    case ISD::SDIV:    case ISD::SREM:      assert(VT.isInteger() && "This operator does not apply to FP types!"); -    // fall through +    assert(N1.getValueType() == N2.getValueType() && +           N1.getValueType() == VT && "Binary operator types must match!"); +    break;    case ISD::FADD:    case ISD::FSUB:    case ISD::FMUL: @@ -2665,6 +2682,7 @@ SDValue SelectionDAG::getNode(unsigned Opcode, DebugLoc DL, EVT VT,              return N1;        }      } +    assert(VT.isFloatingPoint() && "This operator only applies to FP types!");      assert(N1.getValueType() == N2.getValueType() &&             N1.getValueType() == VT && "Binary operator types must match!");      break; @@ -3525,7 +3543,7 @@ SDValue SelectionDAG::getMemcpy(SDValue Chain, DebugLoc dl, SDValue Dst,    // Then check to see if we should lower the memcpy with target-specific    // code. If the target chooses to do this, this is the next best.    SDValue Result = -    TLI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align, +    TSI.EmitTargetCodeForMemcpy(*this, dl, Chain, Dst, Src, Size, Align,                                  isVol, AlwaysInline,                                  DstSV, DstSVOff, SrcSV, SrcSVOff);    if (Result.getNode()) @@ -3590,7 +3608,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, DebugLoc dl, SDValue Dst,    // Then check to see if we should lower the memmove with target-specific    // code. If the target chooses to do this, this is the next best.    SDValue Result = -    TLI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol, +    TSI.EmitTargetCodeForMemmove(*this, dl, Chain, Dst, Src, Size, Align, isVol,                                   DstSV, DstSVOff, SrcSV, SrcSVOff);    if (Result.getNode())      return Result; @@ -3641,7 +3659,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, DebugLoc dl, SDValue Dst,    // Then check to see if we should lower the memset with target-specific    // code. If the target chooses to do this, this is the next best.    SDValue Result = -    TLI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol, +    TSI.EmitTargetCodeForMemset(*this, dl, Chain, Dst, Src, Size, Align, isVol,                                  DstSV, DstSVOff);    if (Result.getNode())      return Result; @@ -5417,6 +5435,8 @@ const EVT *SDNode::getValueTypeList(EVT VT) {      sys::SmartScopedLock<true> Lock(*VTMutex);      return &(*EVTs->insert(VT).first);    } else { +    assert(VT.getSimpleVT().SimpleTy < MVT::LAST_VALUETYPE && +           "Value type out of range!");      return &SimpleVTArray->VTs[VT.getSimpleVT().SimpleTy];    }  } @@ -5607,6 +5627,8 @@ std::string SDNode::getOperationName(const SelectionDAG *G) const {    case ISD::LSDAADDR: return "LSDAADDR";    case ISD::EHSELECTION: return "EHSELECTION";    case ISD::EH_RETURN: return "EH_RETURN"; +  case ISD::EH_SJLJ_SETJMP: return "EH_SJLJ_SETJMP"; +  case ISD::EH_SJLJ_LONGJMP: return "EH_SJLJ_LONGJMP";    case ISD::ConstantPool:  return "ConstantPool";    case ISD::ExternalSymbol: return "ExternalSymbol";    case ISD::BlockAddress:  return "BlockAddress"; @@ -6008,6 +6030,21 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {    if (getNodeId() != -1)      OS << " [ID=" << getNodeId() << ']'; + +  DebugLoc dl = getDebugLoc(); +  if (G && !dl.isUnknown()) { +    DIScope +      Scope(dl.getScope(G->getMachineFunction().getFunction()->getContext())); +    OS << " dbg:"; +    // Omit the directory, since it's usually long and uninteresting. +    if (Scope.Verify()) +      OS << Scope.getFilename(); +    else +      OS << "<unknown>"; +    OS << ':' << dl.getLine(); +    if (dl.getCol() != 0) +      OS << ':' << dl.getCol(); +  }  }  void SDNode::print(raw_ostream &OS, const SelectionDAG *G) const {  | 
