mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-11 15:08:16 +00:00
Move DwarfUnit::constructVariableDIE down to DwarfCompileUnit, since it's only needed there.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219418 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c307b3034a
commit
4710301da5
@ -7,6 +7,7 @@
|
||||
#include "llvm/IR/Instruction.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCStreamer.h"
|
||||
#include "llvm/Target/TargetFrameLowering.h"
|
||||
#include "llvm/Target/TargetLoweringObjectFile.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
@ -477,4 +478,68 @@ DwarfCompileUnit::constructLexicalScopeDIE(LexicalScope *Scope) {
|
||||
return ScopeDIE;
|
||||
}
|
||||
|
||||
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
|
||||
std::unique_ptr<DIE> DwarfCompileUnit::constructVariableDIE(DbgVariable &DV,
|
||||
bool Abstract) {
|
||||
auto D = constructVariableDIEImpl(DV, Abstract);
|
||||
DV.setDIE(*D);
|
||||
return D;
|
||||
}
|
||||
|
||||
std::unique_ptr<DIE>
|
||||
DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV,
|
||||
bool Abstract) {
|
||||
// Define variable debug information entry.
|
||||
auto VariableDie = make_unique<DIE>(DV.getTag());
|
||||
|
||||
if (Abstract) {
|
||||
applyVariableAttributes(DV, *VariableDie);
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
// Add variable address.
|
||||
|
||||
unsigned Offset = DV.getDotDebugLocOffset();
|
||||
if (Offset != ~0U) {
|
||||
addLocationList(*VariableDie, dwarf::DW_AT_location, Offset);
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
// Check if variable is described by a DBG_VALUE instruction.
|
||||
if (const MachineInstr *DVInsn = DV.getMInsn()) {
|
||||
assert(DVInsn->getNumOperands() == 4);
|
||||
if (DVInsn->getOperand(0).isReg()) {
|
||||
const MachineOperand RegOp = DVInsn->getOperand(0);
|
||||
// If the second operand is an immediate, this is an indirect value.
|
||||
if (DVInsn->getOperand(1).isImm()) {
|
||||
MachineLocation Location(RegOp.getReg(),
|
||||
DVInsn->getOperand(1).getImm());
|
||||
addVariableAddress(DV, *VariableDie, Location);
|
||||
} else if (RegOp.getReg())
|
||||
addVariableAddress(DV, *VariableDie, MachineLocation(RegOp.getReg()));
|
||||
} else if (DVInsn->getOperand(0).isImm())
|
||||
addConstantValue(*VariableDie, DVInsn->getOperand(0), DV.getType());
|
||||
else if (DVInsn->getOperand(0).isFPImm())
|
||||
addConstantFPValue(*VariableDie, DVInsn->getOperand(0));
|
||||
else if (DVInsn->getOperand(0).isCImm())
|
||||
addConstantValue(*VariableDie, DVInsn->getOperand(0).getCImm(),
|
||||
DV.getType());
|
||||
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
// .. else use frame index.
|
||||
int FI = DV.getFrameIndex();
|
||||
if (FI != ~0) {
|
||||
unsigned FrameReg = 0;
|
||||
const TargetFrameLowering *TFI =
|
||||
Asm->TM.getSubtargetImpl()->getFrameLowering();
|
||||
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||
MachineLocation Location(FrameReg, Offset);
|
||||
addVariableAddress(DV, *VariableDie, Location);
|
||||
}
|
||||
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
} // end llvm namespace
|
||||
|
@ -33,6 +33,11 @@ class DwarfCompileUnit : public DwarfUnit {
|
||||
/// the need to search for it in applyStmtList.
|
||||
unsigned stmtListIndex;
|
||||
|
||||
/// \brief Construct a DIE for the given DbgVariable without initializing the
|
||||
/// DbgVariable's DIE reference.
|
||||
std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
|
||||
bool Abstract);
|
||||
|
||||
public:
|
||||
DwarfCompileUnit(unsigned UID, DICompileUnit Node, AsmPrinter *A,
|
||||
DwarfDebug *DW, DwarfFile *DWU);
|
||||
@ -97,6 +102,10 @@ public:
|
||||
/// \brief Construct new DW_TAG_lexical_block for this scope and
|
||||
/// attach DW_AT_low_pc/DW_AT_high_pc labels.
|
||||
std::unique_ptr<DIE> constructLexicalScopeDIE(LexicalScope *Scope);
|
||||
|
||||
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
|
||||
std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
|
||||
bool Abstract = false);
|
||||
};
|
||||
|
||||
} // end llvm namespace
|
||||
|
@ -1625,69 +1625,6 @@ void DwarfUnit::constructContainingTypeDIEs() {
|
||||
}
|
||||
}
|
||||
|
||||
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
|
||||
std::unique_ptr<DIE> DwarfUnit::constructVariableDIE(DbgVariable &DV,
|
||||
bool Abstract) {
|
||||
auto D = constructVariableDIEImpl(DV, Abstract);
|
||||
DV.setDIE(*D);
|
||||
return D;
|
||||
}
|
||||
|
||||
std::unique_ptr<DIE> DwarfUnit::constructVariableDIEImpl(const DbgVariable &DV,
|
||||
bool Abstract) {
|
||||
// Define variable debug information entry.
|
||||
auto VariableDie = make_unique<DIE>(DV.getTag());
|
||||
|
||||
if (Abstract) {
|
||||
applyVariableAttributes(DV, *VariableDie);
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
// Add variable address.
|
||||
|
||||
unsigned Offset = DV.getDotDebugLocOffset();
|
||||
if (Offset != ~0U) {
|
||||
addLocationList(*VariableDie, dwarf::DW_AT_location, Offset);
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
// Check if variable is described by a DBG_VALUE instruction.
|
||||
if (const MachineInstr *DVInsn = DV.getMInsn()) {
|
||||
assert(DVInsn->getNumOperands() == 4);
|
||||
if (DVInsn->getOperand(0).isReg()) {
|
||||
const MachineOperand RegOp = DVInsn->getOperand(0);
|
||||
// If the second operand is an immediate, this is an indirect value.
|
||||
if (DVInsn->getOperand(1).isImm()) {
|
||||
MachineLocation Location(RegOp.getReg(),
|
||||
DVInsn->getOperand(1).getImm());
|
||||
addVariableAddress(DV, *VariableDie, Location);
|
||||
} else if (RegOp.getReg())
|
||||
addVariableAddress(DV, *VariableDie, MachineLocation(RegOp.getReg()));
|
||||
} else if (DVInsn->getOperand(0).isImm())
|
||||
addConstantValue(*VariableDie, DVInsn->getOperand(0), DV.getType());
|
||||
else if (DVInsn->getOperand(0).isFPImm())
|
||||
addConstantFPValue(*VariableDie, DVInsn->getOperand(0));
|
||||
else if (DVInsn->getOperand(0).isCImm())
|
||||
addConstantValue(*VariableDie, DVInsn->getOperand(0).getCImm(),
|
||||
DV.getType());
|
||||
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
// .. else use frame index.
|
||||
int FI = DV.getFrameIndex();
|
||||
if (FI != ~0) {
|
||||
unsigned FrameReg = 0;
|
||||
const TargetFrameLowering *TFI =
|
||||
Asm->TM.getSubtargetImpl()->getFrameLowering();
|
||||
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||
MachineLocation Location(FrameReg, Offset);
|
||||
addVariableAddress(DV, *VariableDie, Location);
|
||||
}
|
||||
|
||||
return VariableDie;
|
||||
}
|
||||
|
||||
/// constructMemberDIE - Construct member DIE from DIDerivedType.
|
||||
void DwarfUnit::constructMemberDIE(DIE &Buffer, DIDerivedType DT) {
|
||||
DIE &MemberDie = createAndAddDIE(DT.getTag(), Buffer);
|
||||
|
@ -408,10 +408,6 @@ public:
|
||||
/// vtables.
|
||||
void constructContainingTypeDIEs();
|
||||
|
||||
/// constructVariableDIE - Construct a DIE for the given DbgVariable.
|
||||
std::unique_ptr<DIE> constructVariableDIE(DbgVariable &DV,
|
||||
bool Abstract = false);
|
||||
|
||||
/// constructSubprogramArguments - Construct function argument DIEs.
|
||||
void constructSubprogramArguments(DIE &Buffer, DITypeArray Args);
|
||||
|
||||
@ -449,11 +445,6 @@ protected:
|
||||
virtual unsigned getOrCreateSourceID(StringRef File, StringRef Directory) = 0;
|
||||
|
||||
private:
|
||||
/// \brief Construct a DIE for the given DbgVariable without initializing the
|
||||
/// DbgVariable's DIE reference.
|
||||
std::unique_ptr<DIE> constructVariableDIEImpl(const DbgVariable &DV,
|
||||
bool Abstract);
|
||||
|
||||
/// constructTypeDIE - Construct basic type die from DIBasicType.
|
||||
void constructTypeDIE(DIE &Buffer, DIBasicType BTy);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user