class MachineLocation {
private:
- bool IsRegister = false; // True if location is a register.
- unsigned Register = 0; // gcc/gdb register number.
- int Offset = 0; // Displacement if not register.
+ bool IsRegister = false; ///< True if location is a register.
+ unsigned Register = 0; ///< gcc/gdb register number.
public:
enum : uint32_t {
MachineLocation() = default;
/// Create a direct register location.
- explicit MachineLocation(unsigned R) : IsRegister(true), Register(R) {}
- /// Create a register-indirect location with an offset.
- MachineLocation(unsigned R, int O) : Register(R), Offset(O) {
- assert(O == 0 && "offset is expected to always be zero");
- }
+ explicit MachineLocation(unsigned R, bool Indirect = false)
+ : IsRegister(!Indirect), Register(R) {}
bool operator==(const MachineLocation &Other) const {
- return IsRegister == Other.IsRegister && Register == Other.Register &&
- Offset == Other.Offset;
+ return IsRegister == Other.IsRegister && Register == Other.Register;
}
// Accessors.
bool isIndirect() const { return !IsRegister; }
bool isReg() const { return IsRegister; }
unsigned getReg() const { return Register; }
- int getOffset() const { return Offset; }
void setIsRegister(bool Is) { IsRegister = Is; }
void setRegister(unsigned R) { Register = R; }
-
- /// Make this location a direct register location.
- void set(unsigned R) {
- IsRegister = true;
- Register = R;
- Offset = 0;
- }
-
- /// Make this location a register-indirect+offset location.
- void set(unsigned R, int O) {
- IsRegister = false;
- Register = R;
- Offset = O;
- assert(O == 0 && "offset is expected to always be zero");
- }
};
inline bool operator!=(const MachineLocation &LHS, const MachineLocation &RHS) {
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()));
+ MachineLocation Location(RegOp.getReg(), DVInsn->getOperand(1).isImm());
+ addVariableAddress(DV, *VariableDie, Location);
} else if (DVInsn->getOperand(0).isImm()) {
// This variable is described by a single constant.
// Check whether it has a DIExpression.
assert(MI->getNumOperands() == 4);
if (MI->getOperand(0).isReg()) {
- MachineLocation MLoc;
// If the second operand is an immediate, this is a
// register-indirect address.
- if (!MI->getOperand(1).isImm())
- MLoc.set(MI->getOperand(0).getReg());
- else
- MLoc.set(MI->getOperand(0).getReg(), MI->getOperand(1).getImm());
+ MachineLocation MLoc(MI->getOperand(0).getReg(), MI->getOperand(1).isImm());
return DebugLocEntry::Value(Expr, MLoc);
}
if (MI->getOperand(0).isImm())