summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/MachineFunction.cpp2
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp37
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp1
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp2
-rw-r--r--llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp8
-rw-r--r--llvm/lib/Target/PowerPC/PPCInstrInfo.td9
-rw-r--r--llvm/lib/Target/TargetSelectionDAG.td10
7 files changed, 64 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index f0ece6b3dbb..f51176ff210 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -108,7 +108,7 @@ void ilist_traits<MachineBasicBlock>::transferNodesFromList(
MachineFunction::MachineFunction(const Function *F,
const TargetMachine &TM)
- : Annotation(MF_AID), Fn(F), Target(TM), UsedPhysRegs(0) {
+ : Annotation(MF_AID), Fn(F), Target(TM), UsedPhysRegs(0), DebugInfo() {
SSARegMapping = new SSARegMap();
MFInfo = 0;
FrameInfo = new MachineFrameInfo();
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 15376216a51..c5b7bf9f541 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -611,9 +611,18 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
switch (TLI.getOperationAction(ISD::LOCATION, MVT::Other)) {
case TargetLowering::Promote:
default: assert(0 && "This action is not supported yet!");
- case TargetLowering::Expand:
- // If the target doesn't support line numbers, ignore this node.
- Result = Tmp1;
+ case TargetLowering::Expand: {
+ MachineDebugInfo &DebugInfo = DAG.getMachineFunction().getDebugInfo();
+ std::vector<SDOperand> Ops;
+ Ops.push_back(Tmp1); // chain
+ Ops.push_back(Node->getOperand(1)); // line #
+ Ops.push_back(Node->getOperand(2)); // col #
+ const std::string &fname = cast<StringSDNode>(Node->getOperand(3))->getValue();
+ const std::string &dirname=cast<StringSDNode>(Node->getOperand(4))->getValue();
+ unsigned id = DebugInfo.RecordSource(fname, dirname);
+ Ops.push_back(DAG.getConstant(id, MVT::i32)); // source file id
+ Result = DAG.getNode(ISD::DEBUG_LOC, MVT::Other, Ops);
+ }
break;
case TargetLowering::Legal:
if (Tmp1 != Node->getOperand(0) ||
@@ -635,6 +644,28 @@ SDOperand SelectionDAGLegalize::LegalizeOp(SDOperand Op) {
break;
}
break;
+
+ case ISD::DEBUG_LOC:
+ assert(Node->getNumOperands() == 4 && "Invalid DEBUG_LOC node!");
+ switch (TLI.getOperationAction(ISD::DEBUG_LOC, MVT::Other)) {
+ case TargetLowering::Promote:
+ case TargetLowering::Expand:
+ default: assert(0 && "This action is not supported yet!");
+ case TargetLowering::Legal:
+ Tmp1 = LegalizeOp(Node->getOperand(0)); // Legalize the chain.
+ Tmp2 = LegalizeOp(Node->getOperand(1)); // Legalize the line #.
+ Tmp3 = LegalizeOp(Node->getOperand(2)); // Legalize the col #.
+ Tmp4 = LegalizeOp(Node->getOperand(3)); // Legalize the source file id.
+
+ if (Tmp1 != Node->getOperand(0) ||
+ Tmp2 != Node->getOperand(1) ||
+ Tmp3 != Node->getOperand(2) ||
+ Tmp4 != Node->getOperand(3)) {
+ Result = DAG.getNode(ISD::DEBUG_LOC,MVT::Other, Tmp1, Tmp2, Tmp3, Tmp4);
+ }
+ break;
+ }
+ break;
case ISD::Constant:
// We know we don't need to expand constants here, constants only have one
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 30ebeb2b8e9..2fe1b0df0de 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -1961,6 +1961,7 @@ const char *SDNode::getOperationName(const SelectionDAG *G) const {
// Debug info
case ISD::LOCATION: return "location";
+ case ISD::DEBUG_LOC: return "debug_loc";
case ISD::CONDCODE:
switch (cast<CondCodeSDNode>(this)->get()) {
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index 20335fbaa47..e6a0913a9b5 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -918,8 +918,8 @@ SelectionDAGLowering::visitIntrinsicCall(CallInst &I, unsigned Intrinsic) {
if (ConstantStruct *CS =
dyn_cast<ConstantStruct>(cunit->getInitializer())) {
if (CS->getNumOperands() > 0) {
- Ops.push_back(DAG.getString(getStringValue(CS->getOperand(4))));
Ops.push_back(DAG.getString(getStringValue(CS->getOperand(3))));
+ Ops.push_back(DAG.getString(getStringValue(CS->getOperand(4))));
}
}
}
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 83e3b0519a9..cb27e1f3888 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -25,6 +25,7 @@
#include "llvm/Module.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/CodeGen/AsmPrinter.h"
+#include "llvm/CodeGen/MachineDebugInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Support/Mangler.h"
@@ -375,6 +376,13 @@ void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
SetupMachineFunction(MF);
O << "\n\n";
+
+ // Print out dwarf file info
+ MachineDebugInfo &DebugInfo = MF.getDebugInfo();
+ std::vector<std::string> Sources = DebugInfo.getSourceFiles();
+ for (unsigned i = 0, N = Sources.size(); i < N; i++) {
+ O << "\t; .file\t" << (i + 1) << "," << "\"" << Sources[i] << "\"" << "\n";
+ }
// Print out constants referenced by the function
EmitConstantPool(MF.getConstantPool());
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
index 225017cea78..af7560b648c 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -922,6 +922,15 @@ def V_SET0 : VXForm_setzero<1220, (ops VRRC:$vD),
//===----------------------------------------------------------------------===//
+// DWARF Pseudo Instructions
+//
+
+def DWARF_LOC : Pseudo<(ops i32imm:$line, i32imm:$col, i32imm:$file),
+ "; .loc $file, $line, $col",
+ [(dwarf_loc (i32 imm:$line), (i32 imm:$col),
+ (i32 imm:$file))]>;
+
+//===----------------------------------------------------------------------===//
// PowerPC Instruction Patterns
//
diff --git a/llvm/lib/Target/TargetSelectionDAG.td b/llvm/lib/Target/TargetSelectionDAG.td
index 36f83c168f0..0da445d5d14 100644
--- a/llvm/lib/Target/TargetSelectionDAG.td
+++ b/llvm/lib/Target/TargetSelectionDAG.td
@@ -415,3 +415,13 @@ class ComplexPattern<ValueType ty, int numops, string fn, list<SDNode> roots = [
string SelectFunc = fn;
list<SDNode> RootNodes = roots;
}
+
+//===----------------------------------------------------------------------===//
+// Dwarf support.
+//
+def SDT_dwarf_loc : SDTypeProfile<0, 3,
+ [SDTCisInt<0>, SDTCisInt<1>, SDTCisInt<2>]>;
+def dwarf_loc : SDNode<"ISD::DEBUG_LOC", SDT_dwarf_loc,[SDNPHasChain]>;
+
+
+
OpenPOWER on IntegriCloud