diff options
author | Oliver Stannard <oliver.stannard@arm.com> | 2016-01-28 13:19:47 +0000 |
---|---|---|
committer | Oliver Stannard <oliver.stannard@arm.com> | 2016-01-28 13:19:47 +0000 |
commit | 02fa1c80c4648655c352705265d8f1c0cebd53ea (patch) | |
tree | 73d73d4c7f53ef582092f21ad42bf80eb8e08953 /llvm/lib/Target/BPF/BPFISelLowering.cpp | |
parent | fca0a34398fda3966ad930d9ec18af12a54c2f23 (diff) | |
download | bcm5719-llvm-02fa1c80c4648655c352705265d8f1c0cebd53ea.tar.gz bcm5719-llvm-02fa1c80c4648655c352705265d8f1c0cebd53ea.zip |
Revert r259035, it introduces a cyclic library dependency
llvm-svn: 259045
Diffstat (limited to 'llvm/lib/Target/BPF/BPFISelLowering.cpp')
-rw-r--r-- | llvm/lib/Target/BPF/BPFISelLowering.cpp | 81 |
1 files changed, 68 insertions, 13 deletions
diff --git a/llvm/lib/Target/BPF/BPFISelLowering.cpp b/llvm/lib/Target/BPF/BPFISelLowering.cpp index 61261c2f14c..6a5b37e153d 100644 --- a/llvm/lib/Target/BPF/BPFISelLowering.cpp +++ b/llvm/lib/Target/BPF/BPFISelLowering.cpp @@ -17,7 +17,6 @@ #include "BPFTargetMachine.h" #include "BPFSubtarget.h" #include "llvm/CodeGen/CallingConvLower.h" -#include "llvm/CodeGen/DiagnosticInfoCodeGen.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" @@ -29,10 +28,66 @@ #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/IR/DiagnosticInfo.h" +#include "llvm/IR/DiagnosticPrinter.h" using namespace llvm; #define DEBUG_TYPE "bpf-lower" +namespace { + +// Diagnostic information for unimplemented or unsupported feature reporting. +class DiagnosticInfoUnsupported : public DiagnosticInfo { +private: + // Debug location where this diagnostic is triggered. + DebugLoc DLoc; + const Twine &Description; + const Function &Fn; + SDValue Value; + + static int KindID; + + static int getKindID() { + if (KindID == 0) + KindID = llvm::getNextAvailablePluginDiagnosticKind(); + return KindID; + } + +public: + DiagnosticInfoUnsupported(SDLoc DLoc, const Function &Fn, const Twine &Desc, + SDValue Value) + : DiagnosticInfo(getKindID(), DS_Error), DLoc(DLoc.getDebugLoc()), + Description(Desc), Fn(Fn), Value(Value) {} + + void print(DiagnosticPrinter &DP) const override { + std::string Str; + raw_string_ostream OS(Str); + + if (DLoc) { + auto DIL = DLoc.get(); + StringRef Filename = DIL->getFilename(); + unsigned Line = DIL->getLine(); + unsigned Column = DIL->getColumn(); + OS << Filename << ':' << Line << ':' << Column << ' '; + } + + OS << "in function " << Fn.getName() << ' ' << *Fn.getFunctionType() << '\n' + << Description; + if (Value) + Value->print(OS); + OS << '\n'; + OS.flush(); + DP << Str; + } + + static bool classof(const DiagnosticInfo *DI) { + return DI->getKind() == getKindID(); + } +}; + +int DiagnosticInfoUnsupported::KindID = 0; +} + BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM, const BPFSubtarget &STI) : TargetLowering(TM) { @@ -181,16 +236,16 @@ SDValue BPFTargetLowering::LowerFormalArguments( InVals.push_back(ArgValue); } } else { - DiagnosticInfoUnsupported Err( - *MF.getFunction(), "defined with too many args", DL); + DiagnosticInfoUnsupported Err(DL, *MF.getFunction(), + "defined with too many args", SDValue()); DAG.getContext()->diagnose(Err); } } if (IsVarArg || MF.getFunction()->hasStructRetAttr()) { DiagnosticInfoUnsupported Err( - *MF.getFunction(), - "functions with VarArgs or StructRet are not supported", DL); + DL, *MF.getFunction(), + "functions with VarArgs or StructRet are not supported", SDValue()); DAG.getContext()->diagnose(Err); } @@ -230,8 +285,8 @@ SDValue BPFTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, unsigned NumBytes = CCInfo.getNextStackOffset(); if (Outs.size() >= 6) { - DiagnosticInfoUnsupported Err(*MF.getFunction(), "too many args to ", - CLI.DL, Callee); + DiagnosticInfoUnsupported Err(CLI.DL, *MF.getFunction(), + "too many args to ", Callee); DAG.getContext()->diagnose(Err); } @@ -240,8 +295,8 @@ SDValue BPFTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI, if (!Flags.isByVal()) continue; - DiagnosticInfoUnsupported Err( - *MF.getFunction(), "pass by value not supported ", CLI.DL, Callee); + DiagnosticInfoUnsupported Err(CLI.DL, *MF.getFunction(), + "pass by value not supported ", Callee); DAG.getContext()->diagnose(Err); } @@ -343,8 +398,8 @@ BPFTargetLowering::LowerReturn(SDValue Chain, CallingConv::ID CallConv, CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.getContext()); if (MF.getFunction()->getReturnType()->isAggregateType()) { - DiagnosticInfoUnsupported Err( - *MF.getFunction(), "only integer returns supported", DL); + DiagnosticInfoUnsupported Err(DL, *MF.getFunction(), + "only integer returns supported", SDValue()); DAG.getContext()->diagnose(Err); } @@ -388,8 +443,8 @@ SDValue BPFTargetLowering::LowerCallResult( CCState CCInfo(CallConv, IsVarArg, MF, RVLocs, *DAG.getContext()); if (Ins.size() >= 2) { - DiagnosticInfoUnsupported Err(*MF.getFunction(), - "only small returns supported", DL); + DiagnosticInfoUnsupported Err(DL, *MF.getFunction(), + "only small returns supported", SDValue()); DAG.getContext()->diagnose(Err); } |