mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
Cleanup and document MachineLocation.
Clarify documentation and API to make the difference between register and register-indirect addressed locations more explicit. Put in a comment to point out that with the current implementation we cannot specify a register-indirect location with offset 0 (a breg 0 in DWARF). No functionality change intended. rdar://problem/13658587 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180641 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f1d9fe9d04
commit
13131e62fc
@ -9,7 +9,7 @@
|
|||||||
// The MachineLocation class is used to represent a simple location in a machine
|
// The MachineLocation class is used to represent a simple location in a machine
|
||||||
// frame. Locations will be one of two forms; a register or an address formed
|
// frame. Locations will be one of two forms; a register or an address formed
|
||||||
// from a base address plus an offset. Register indirection can be specified by
|
// from a base address plus an offset. Register indirection can be specified by
|
||||||
// using an offset of zero.
|
// explicitly passing an offset to the constructor.
|
||||||
//
|
//
|
||||||
// The MachineMove class is used to represent abstract move operations in the
|
// The MachineMove class is used to represent abstract move operations in the
|
||||||
// prolog/epilog of a compiled function. A collection of these objects can be
|
// prolog/epilog of a compiled function. A collection of these objects can be
|
||||||
@ -37,8 +37,10 @@ public:
|
|||||||
};
|
};
|
||||||
MachineLocation()
|
MachineLocation()
|
||||||
: IsRegister(false), Register(0), Offset(0) {}
|
: IsRegister(false), Register(0), Offset(0) {}
|
||||||
|
/// Create a direct register location.
|
||||||
explicit MachineLocation(unsigned R)
|
explicit MachineLocation(unsigned R)
|
||||||
: IsRegister(true), Register(R), Offset(0) {}
|
: IsRegister(true), Register(R), Offset(0) {}
|
||||||
|
/// Create a register-indirect location with an offset.
|
||||||
MachineLocation(unsigned R, int O)
|
MachineLocation(unsigned R, int O)
|
||||||
: IsRegister(false), Register(R), Offset(O) {}
|
: IsRegister(false), Register(R), Offset(O) {}
|
||||||
|
|
||||||
@ -48,17 +50,20 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accessors
|
// Accessors
|
||||||
|
bool isIndirect() const { return !IsRegister; }
|
||||||
bool isReg() const { return IsRegister; }
|
bool isReg() const { return IsRegister; }
|
||||||
unsigned getReg() const { return Register; }
|
unsigned getReg() const { return Register; }
|
||||||
int getOffset() const { return Offset; }
|
int getOffset() const { return Offset; }
|
||||||
void setIsRegister(bool Is) { IsRegister = Is; }
|
void setIsRegister(bool Is) { IsRegister = Is; }
|
||||||
void setRegister(unsigned R) { Register = R; }
|
void setRegister(unsigned R) { Register = R; }
|
||||||
void setOffset(int O) { Offset = O; }
|
void setOffset(int O) { Offset = O; }
|
||||||
|
/// Make this location a direct register location.
|
||||||
void set(unsigned R) {
|
void set(unsigned R) {
|
||||||
IsRegister = true;
|
IsRegister = true;
|
||||||
Register = R;
|
Register = R;
|
||||||
Offset = 0;
|
Offset = 0;
|
||||||
}
|
}
|
||||||
|
/// Make this location a register-indirect+offset location.
|
||||||
void set(unsigned R, int O) {
|
void set(unsigned R, int O) {
|
||||||
IsRegister = false;
|
IsRegister = false;
|
||||||
Register = R;
|
Register = R;
|
||||||
|
@ -813,7 +813,7 @@ void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const {
|
|||||||
// caller might be in the middle of an dwarf expression. We should
|
// caller might be in the middle of an dwarf expression. We should
|
||||||
// probably assert that Reg >= 0 once debug info generation is more mature.
|
// probably assert that Reg >= 0 once debug info generation is more mature.
|
||||||
|
|
||||||
if (int Offset = MLoc.getOffset()) {
|
if (MLoc.isIndirect()) {
|
||||||
if (Reg < 32) {
|
if (Reg < 32) {
|
||||||
OutStreamer.AddComment(
|
OutStreamer.AddComment(
|
||||||
dwarf::OperationEncodingString(dwarf::DW_OP_breg0 + Reg));
|
dwarf::OperationEncodingString(dwarf::DW_OP_breg0 + Reg));
|
||||||
@ -824,7 +824,7 @@ void AsmPrinter::EmitDwarfRegOp(const MachineLocation &MLoc) const {
|
|||||||
OutStreamer.AddComment(Twine(Reg));
|
OutStreamer.AddComment(Twine(Reg));
|
||||||
EmitULEB128(Reg);
|
EmitULEB128(Reg);
|
||||||
}
|
}
|
||||||
EmitSLEB128(Offset);
|
EmitSLEB128(MLoc.getOffset());
|
||||||
} else {
|
} else {
|
||||||
if (Reg < 32) {
|
if (Reg < 32) {
|
||||||
OutStreamer.AddComment(
|
OutStreamer.AddComment(
|
||||||
|
@ -1131,6 +1131,12 @@ static DotDebugLocEntry getDebugLocEntry(AsmPrinter *Asm,
|
|||||||
}
|
}
|
||||||
if (MI->getOperand(0).isReg() && MI->getOperand(1).isImm()) {
|
if (MI->getOperand(0).isReg() && MI->getOperand(1).isImm()) {
|
||||||
MachineLocation MLoc;
|
MachineLocation MLoc;
|
||||||
|
// TODO: Currently an offset of 0 in a DBG_VALUE means
|
||||||
|
// we need to generate a direct register value.
|
||||||
|
// There is no way to specify an indirect value with offset 0.
|
||||||
|
if (MI->getOperand(1).getImm() == 0)
|
||||||
|
MLoc.set(MI->getOperand(0).getReg());
|
||||||
|
else
|
||||||
MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
|
MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
|
||||||
return DotDebugLocEntry(FLabel, SLabel, MLoc, Var);
|
return DotDebugLocEntry(FLabel, SLabel, MLoc, Var);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user