mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-03 12:18:00 +00:00
Add some new bits of debug info handling. No
functional change yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97855 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1027,11 +1027,15 @@ private:
|
|||||||
/// then they will be delete[]'d when the node is destroyed.
|
/// then they will be delete[]'d when the node is destroyed.
|
||||||
uint16_t OperandsNeedDelete : 1;
|
uint16_t OperandsNeedDelete : 1;
|
||||||
|
|
||||||
|
/// HasDebugValue - This tracks whether this node has one or more dbg_value
|
||||||
|
/// nodes corresponding to it.
|
||||||
|
uint16_t HasDebugValue : 1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// SubclassData - This member is defined by this class, but is not used for
|
/// SubclassData - This member is defined by this class, but is not used for
|
||||||
/// anything. Subclasses can use it to hold whatever state they find useful.
|
/// anything. Subclasses can use it to hold whatever state they find useful.
|
||||||
/// This field is initialized to zero by the ctor.
|
/// This field is initialized to zero by the ctor.
|
||||||
uint16_t SubclassData : 15;
|
uint16_t SubclassData : 14;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/// NodeId - Unique id per SDNode in the DAG.
|
/// NodeId - Unique id per SDNode in the DAG.
|
||||||
@@ -1094,6 +1098,12 @@ public:
|
|||||||
return ~NodeType;
|
return ~NodeType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// getHasDebugValue - get this bit.
|
||||||
|
bool getHasDebugValue() const { return HasDebugValue; }
|
||||||
|
|
||||||
|
/// setHasDebugValue - set this bit.
|
||||||
|
void setHasDebugValue(bool b) { HasDebugValue = b; }
|
||||||
|
|
||||||
/// use_empty - Return true if there are no uses of this node.
|
/// use_empty - Return true if there are no uses of this node.
|
||||||
///
|
///
|
||||||
bool use_empty() const { return UseList == NULL; }
|
bool use_empty() const { return UseList == NULL; }
|
||||||
@@ -1357,8 +1367,8 @@ protected:
|
|||||||
|
|
||||||
SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs, const SDValue *Ops,
|
SDNode(unsigned Opc, const DebugLoc dl, SDVTList VTs, const SDValue *Ops,
|
||||||
unsigned NumOps)
|
unsigned NumOps)
|
||||||
: NodeType(Opc), OperandsNeedDelete(true), SubclassData(0),
|
: NodeType(Opc), OperandsNeedDelete(true), HasDebugValue(false),
|
||||||
NodeId(-1),
|
SubclassData(0), NodeId(-1),
|
||||||
OperandList(NumOps ? new SDUse[NumOps] : 0),
|
OperandList(NumOps ? new SDUse[NumOps] : 0),
|
||||||
ValueList(VTs.VTs), UseList(NULL),
|
ValueList(VTs.VTs), UseList(NULL),
|
||||||
NumOperands(NumOps), NumValues(VTs.NumVTs),
|
NumOperands(NumOps), NumValues(VTs.NumVTs),
|
||||||
|
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#define DEBUG_TYPE "instr-emitter"
|
#define DEBUG_TYPE "instr-emitter"
|
||||||
#include "InstrEmitter.h"
|
#include "InstrEmitter.h"
|
||||||
|
#include "SDDbgValue.h"
|
||||||
#include "llvm/CodeGen/MachineConstantPool.h"
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||||
@@ -497,6 +498,56 @@ InstrEmitter::EmitCopyToRegClassNode(SDNode *Node,
|
|||||||
assert(isNew && "Node emitted out of order - early");
|
assert(isNew && "Node emitted out of order - early");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// EmitDbgValue - Generate any debug info that refers to this Node. Constant
|
||||||
|
/// dbg_value is not handled here.
|
||||||
|
void
|
||||||
|
InstrEmitter::EmitDbgValue(SDNode *Node,
|
||||||
|
DenseMap<SDValue, unsigned> &VRBaseMap,
|
||||||
|
SDDbgValue *sd) {
|
||||||
|
if (!Node->getHasDebugValue())
|
||||||
|
return;
|
||||||
|
if (!sd)
|
||||||
|
return;
|
||||||
|
unsigned VReg = getVR(SDValue(sd->getSDNode(), sd->getResNo()), VRBaseMap);
|
||||||
|
const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE);
|
||||||
|
DebugLoc DL = sd->getDebugLoc();
|
||||||
|
MachineInstr *MI;
|
||||||
|
if (VReg) {
|
||||||
|
MI = BuildMI(*MF, DL, II).addReg(VReg, RegState::Debug).
|
||||||
|
addImm(sd->getOffset()).
|
||||||
|
addMetadata(sd->getMDPtr());
|
||||||
|
} else {
|
||||||
|
// Insert an Undef so we can see what we dropped.
|
||||||
|
MI = BuildMI(*MF, DL, II).addReg(0U).addImm(sd->getOffset()).
|
||||||
|
addMetadata(sd->getMDPtr());
|
||||||
|
}
|
||||||
|
MBB->insert(InsertPos, MI);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// EmitDbgValue - Generate constant debug info. No SDNode is involved.
|
||||||
|
void
|
||||||
|
InstrEmitter::EmitDbgValue(SDDbgValue *sd) {
|
||||||
|
if (!sd)
|
||||||
|
return;
|
||||||
|
const TargetInstrDesc &II = TII->get(TargetOpcode::DBG_VALUE);
|
||||||
|
DebugLoc DL = sd->getDebugLoc();
|
||||||
|
MachineInstr *MI;
|
||||||
|
Value *V = sd->getConst();
|
||||||
|
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
|
||||||
|
MI = BuildMI(*MF, DL, II).addImm(CI->getZExtValue()).
|
||||||
|
addImm(sd->getOffset()).
|
||||||
|
addMetadata(sd->getMDPtr());
|
||||||
|
} else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
|
||||||
|
MI = BuildMI(*MF, DL, II).addFPImm(CF).addImm(sd->getOffset()).
|
||||||
|
addMetadata(sd->getMDPtr());
|
||||||
|
} else {
|
||||||
|
// Insert an Undef so we can see what we dropped.
|
||||||
|
MI = BuildMI(*MF, DL, II).addReg(0U).addImm(sd->getOffset()).
|
||||||
|
addMetadata(sd->getMDPtr());
|
||||||
|
}
|
||||||
|
MBB->insert(InsertPos, MI);
|
||||||
|
}
|
||||||
|
|
||||||
/// EmitNode - Generate machine code for a node and needed dependencies.
|
/// EmitNode - Generate machine code for a node and needed dependencies.
|
||||||
///
|
///
|
||||||
void InstrEmitter::EmitNode(SDNode *Node, bool IsClone, bool IsCloned,
|
void InstrEmitter::EmitNode(SDNode *Node, bool IsClone, bool IsCloned,
|
||||||
|
@@ -23,6 +23,7 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class TargetInstrDesc;
|
class TargetInstrDesc;
|
||||||
|
class SDDbgValue;
|
||||||
|
|
||||||
class InstrEmitter {
|
class InstrEmitter {
|
||||||
MachineFunction *MF;
|
MachineFunction *MF;
|
||||||
@@ -97,6 +98,16 @@ public:
|
|||||||
/// MachineInstr.
|
/// MachineInstr.
|
||||||
static unsigned CountOperands(SDNode *Node);
|
static unsigned CountOperands(SDNode *Node);
|
||||||
|
|
||||||
|
/// EmitDbgValue - Generate any debug info that refers to this Node. Constant
|
||||||
|
/// dbg_value is not handled here.
|
||||||
|
void EmitDbgValue(SDNode *Node,
|
||||||
|
DenseMap<SDValue, unsigned> &VRBaseMap,
|
||||||
|
SDDbgValue* sd);
|
||||||
|
|
||||||
|
|
||||||
|
/// EmitDbgValue - Generate a constant DBG_VALUE. No node is involved.
|
||||||
|
void EmitDbgValue(SDDbgValue* sd);
|
||||||
|
|
||||||
/// EmitNode - Generate machine code for a node and needed dependencies.
|
/// EmitNode - Generate machine code for a node and needed dependencies.
|
||||||
///
|
///
|
||||||
void EmitNode(SDNode *Node, bool IsClone, bool IsCloned,
|
void EmitNode(SDNode *Node, bool IsClone, bool IsCloned,
|
||||||
|
67
lib/CodeGen/SelectionDAG/SDDbgValue.h
Normal file
67
lib/CodeGen/SelectionDAG/SDDbgValue.h
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
//===-- llvm/CodeGen/SDDbgValue.h - SD dbg_value handling--------*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// The LLVM Compiler Infrastructure
|
||||||
|
//
|
||||||
|
// This file is distributed under the University of Illinois Open Source
|
||||||
|
// License. See LICENSE.TXT for details.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file declares the SDDbgValue class.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_CODEGEN_SDDBGVALUE_H
|
||||||
|
#define LLVM_CODEGEN_SDDBGVALUE_H
|
||||||
|
|
||||||
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
#include "llvm/Support/DebugLoc.h"
|
||||||
|
|
||||||
|
namespace llvm {
|
||||||
|
|
||||||
|
class MDNode;
|
||||||
|
class SDNode;
|
||||||
|
class Value;
|
||||||
|
|
||||||
|
/// SDDbgValue - Holds the information from a dbg_value node through SDISel.
|
||||||
|
/// Either Const or Node is nonzero, but not both.
|
||||||
|
/// We do not use SDValue here to avoid including its header.
|
||||||
|
|
||||||
|
class SDDbgValue {
|
||||||
|
SDNode *Node; // valid for non-constants
|
||||||
|
unsigned ResNo; // valid for non-constants
|
||||||
|
Value *Const; // valid for constants
|
||||||
|
MDNode *mdPtr;
|
||||||
|
uint64_t Offset;
|
||||||
|
DebugLoc DL;
|
||||||
|
public:
|
||||||
|
// Constructor for non-constants.
|
||||||
|
SDDbgValue(MDNode *mdP, SDNode *N, unsigned R, uint64_t off, DebugLoc dl) :
|
||||||
|
Node(N), ResNo(R), Const(0), mdPtr(mdP), Offset(off), DL(dl) {}
|
||||||
|
|
||||||
|
// Constructor for constants.
|
||||||
|
SDDbgValue(MDNode *mdP, Value *C, uint64_t off, DebugLoc dl) : Node(0),
|
||||||
|
ResNo(0), Const(C), mdPtr(mdP), Offset(off), DL(dl) {}
|
||||||
|
|
||||||
|
// Returns the MDNode pointer.
|
||||||
|
MDNode *getMDPtr() { return mdPtr; }
|
||||||
|
|
||||||
|
// Returns the SDNode* (valid for non-constants only).
|
||||||
|
SDNode *getSDNode() { assert (!Const); return Node; }
|
||||||
|
|
||||||
|
// Returns the ResNo (valid for non-constants only).
|
||||||
|
unsigned getResNo() { assert (!Const); return ResNo; }
|
||||||
|
|
||||||
|
// Returns the Value* for a constant (invalid for non-constants).
|
||||||
|
Value *getConst() { assert (!Node); return Const; }
|
||||||
|
|
||||||
|
// Returns the offset.
|
||||||
|
uint64_t getOffset() { return Offset; }
|
||||||
|
|
||||||
|
// Returns the DebugLoc.
|
||||||
|
DebugLoc getDebugLoc() { return DL; }
|
||||||
|
};
|
||||||
|
|
||||||
|
} // end llvm namespace
|
||||||
|
|
||||||
|
#endif
|
Reference in New Issue
Block a user