mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 17:24:48 +00:00
Simplify handling of variables with complex address (i.e. blocks variables)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@130339 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -192,16 +192,10 @@ void CompileUnit::addSourceLine(DIE *Die, DINameSpace NS) {
|
|||||||
addUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
|
addUInt(Die, dwarf::DW_AT_decl_line, 0, Line);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addFrameVariableAddress - Add DW_AT_location attribute for a
|
/// addVariableAddress - Add DW_AT_location attribute for a
|
||||||
/// DbgVariable based on provided frame index.
|
/// DbgVariable based on provided MachineLocation.
|
||||||
void CompileUnit::addFrameVariableAddress(DbgVariable *&DV, DIE *Die,
|
void CompileUnit::addVariableAddress(DbgVariable *&DV, DIE *Die,
|
||||||
int64_t FI) {
|
MachineLocation Location) {
|
||||||
MachineLocation Location;
|
|
||||||
unsigned FrameReg;
|
|
||||||
const TargetFrameLowering *TFI = Asm->TM.getFrameLowering();
|
|
||||||
int Offset = TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
|
||||||
Location.set(FrameReg, Offset);
|
|
||||||
|
|
||||||
if (DV->variableHasComplexAddress())
|
if (DV->variableHasComplexAddress())
|
||||||
addComplexAddress(DV, Die, dwarf::DW_AT_location, Location);
|
addComplexAddress(DV, Die, dwarf::DW_AT_location, Location);
|
||||||
else if (DV->isBlockByrefVariable())
|
else if (DV->isBlockByrefVariable())
|
||||||
@ -255,17 +249,6 @@ void CompileUnit::addAddress(DIE *Die, unsigned Attribute,
|
|||||||
addBlock(Die, Attribute, 0, Block);
|
addBlock(Die, Attribute, 0, Block);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// addRegisterAddress - Add register location entry in variable DIE.
|
|
||||||
bool CompileUnit::addRegisterAddress(DIE *Die, const MachineOperand &MO) {
|
|
||||||
assert (MO.isReg() && "Invalid machine operand!");
|
|
||||||
if (!MO.getReg())
|
|
||||||
return false;
|
|
||||||
MachineLocation Location;
|
|
||||||
Location.set(MO.getReg());
|
|
||||||
addAddress(Die, dwarf::DW_AT_location, Location);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// addComplexAddress - Start with the address based on the location provided,
|
/// addComplexAddress - Start with the address based on the location provided,
|
||||||
/// and generate the DWARF information necessary to find the actual variable
|
/// and generate the DWARF information necessary to find the actual variable
|
||||||
/// given the extra address information encoded in the DIVariable, starting from
|
/// given the extra address information encoded in the DIVariable, starting from
|
||||||
|
@ -181,9 +181,6 @@ public:
|
|||||||
void addAddress(DIE *Die, unsigned Attribute,
|
void addAddress(DIE *Die, unsigned Attribute,
|
||||||
const MachineLocation &Location);
|
const MachineLocation &Location);
|
||||||
|
|
||||||
/// addRegisterAddress - Add register location entry in variable DIE.
|
|
||||||
bool addRegisterAddress(DIE *Die, const MachineOperand &MO);
|
|
||||||
|
|
||||||
/// addConstantValue - Add constant value entry in variable DIE.
|
/// addConstantValue - Add constant value entry in variable DIE.
|
||||||
bool addConstantValue(DIE *Die, const MachineOperand &MO);
|
bool addConstantValue(DIE *Die, const MachineOperand &MO);
|
||||||
bool addConstantValue(DIE *Die, ConstantInt *CI, bool Unsigned);
|
bool addConstantValue(DIE *Die, ConstantInt *CI, bool Unsigned);
|
||||||
@ -218,9 +215,9 @@ public:
|
|||||||
void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
void addBlockByrefAddress(DbgVariable *&DV, DIE *Die, unsigned Attribute,
|
||||||
const MachineLocation &Location);
|
const MachineLocation &Location);
|
||||||
|
|
||||||
/// addFrameVariableAddress - Add DW_AT_location attribute for a DbgVariable
|
/// addVariableAddress - Add DW_AT_location attribute for a
|
||||||
/// based on provided frame index.
|
/// DbgVariable based on provided MachineLocation.
|
||||||
void addFrameVariableAddress(DbgVariable *&DV, DIE *Die, int64_t FI);
|
void addVariableAddress(DbgVariable *&DV, DIE *Die, MachineLocation Location);
|
||||||
|
|
||||||
/// addToContextOwner - Add Die into the list of its context owner's children.
|
/// addToContextOwner - Add Die into the list of its context owner's children.
|
||||||
void addToContextOwner(DIE *Die, DIDescriptor Context);
|
void addToContextOwner(DIE *Die, DIDescriptor Context);
|
||||||
|
@ -699,11 +699,19 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, DbgScope *Scope) {
|
|||||||
const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo();
|
const TargetRegisterInfo *TRI = Asm->TM.getRegisterInfo();
|
||||||
if (DVInsn->getOperand(1).isImm() &&
|
if (DVInsn->getOperand(1).isImm() &&
|
||||||
TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) {
|
TRI->getFrameRegister(*Asm->MF) == RegOp.getReg()) {
|
||||||
VariableCU->addFrameVariableAddress(DV, VariableDie,
|
unsigned FrameReg = 0;
|
||||||
DVInsn->getOperand(1).getImm());
|
const TargetFrameLowering *TFI = Asm->TM.getFrameLowering();
|
||||||
|
int Offset =
|
||||||
|
TFI->getFrameIndexReference(*Asm->MF,
|
||||||
|
DVInsn->getOperand(1).getImm(),
|
||||||
|
FrameReg);
|
||||||
|
MachineLocation Location(FrameReg, Offset);
|
||||||
|
VariableCU->addVariableAddress(DV, VariableDie, Location);
|
||||||
|
|
||||||
|
} else if (RegOp.getReg())
|
||||||
|
VariableCU->addVariableAddress(DV, VariableDie,
|
||||||
|
MachineLocation(RegOp.getReg()));
|
||||||
updated = true;
|
updated = true;
|
||||||
} else
|
|
||||||
updated = VariableCU->addRegisterAddress(VariableDie, RegOp);
|
|
||||||
}
|
}
|
||||||
else if (DVInsn->getOperand(0).isImm())
|
else if (DVInsn->getOperand(0).isImm())
|
||||||
updated = VariableCU->addConstantValue(VariableDie,
|
updated = VariableCU->addConstantValue(VariableDie,
|
||||||
@ -712,16 +720,10 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, DbgScope *Scope) {
|
|||||||
updated =
|
updated =
|
||||||
VariableCU->addConstantFPValue(VariableDie, DVInsn->getOperand(0));
|
VariableCU->addConstantFPValue(VariableDie, DVInsn->getOperand(0));
|
||||||
} else {
|
} else {
|
||||||
MachineLocation Location = Asm->getDebugValueLocation(DVInsn);
|
VariableCU->addVariableAddress(DV, VariableDie,
|
||||||
if (Location.getReg()) {
|
Asm->getDebugValueLocation(DVInsn));
|
||||||
if (DV->getVariable().hasComplexAddress())
|
|
||||||
VariableCU->addComplexAddress(DV, VariableDie, dwarf::DW_AT_location,
|
|
||||||
Location);
|
|
||||||
else
|
|
||||||
VariableCU->addAddress(VariableDie, dwarf::DW_AT_location, Location);
|
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!updated) {
|
if (!updated) {
|
||||||
// If variableDie is not updated then DBG_VALUE instruction does not
|
// If variableDie is not updated then DBG_VALUE instruction does not
|
||||||
// have valid variable info.
|
// have valid variable info.
|
||||||
@ -734,8 +736,14 @@ DIE *DwarfDebug::constructVariableDIE(DbgVariable *DV, DbgScope *Scope) {
|
|||||||
|
|
||||||
// .. else use frame index, if available.
|
// .. else use frame index, if available.
|
||||||
int FI = 0;
|
int FI = 0;
|
||||||
if (findVariableFrameIndex(DV, &FI))
|
if (findVariableFrameIndex(DV, &FI)) {
|
||||||
VariableCU->addFrameVariableAddress(DV, VariableDie, FI);
|
unsigned FrameReg = 0;
|
||||||
|
const TargetFrameLowering *TFI = Asm->TM.getFrameLowering();
|
||||||
|
int Offset =
|
||||||
|
TFI->getFrameIndexReference(*Asm->MF, FI, FrameReg);
|
||||||
|
MachineLocation Location(FrameReg, Offset);
|
||||||
|
VariableCU->addVariableAddress(DV, VariableDie, Location);
|
||||||
|
}
|
||||||
|
|
||||||
DV->setDIE(VariableDie);
|
DV->setDIE(VariableDie);
|
||||||
return VariableDie;
|
return VariableDie;
|
||||||
|
Reference in New Issue
Block a user