diff options
| -rw-r--r-- | llvm/include/llvm/MC/MachineLocation.h | 31 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 6 |
3 files changed, 8 insertions, 37 deletions
diff --git a/llvm/include/llvm/MC/MachineLocation.h b/llvm/include/llvm/MC/MachineLocation.h index 94d752fc998..91ed661ebea 100644 --- a/llvm/include/llvm/MC/MachineLocation.h +++ b/llvm/include/llvm/MC/MachineLocation.h @@ -22,9 +22,8 @@ namespace llvm { 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 { @@ -35,15 +34,11 @@ public: 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. @@ -51,24 +46,8 @@ public: 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) { diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 6c5aa966786..8820d21dd14 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -483,12 +483,8 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV, 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. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 6e9afde0f28..b4bd470fe85 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -831,13 +831,9 @@ static DebugLocEntry::Value getDebugLocValue(const MachineInstr *MI) { 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()) |

