diff options
author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-15 16:33:45 +0000 |
---|---|---|
committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2017-12-15 16:33:45 +0000 |
commit | 0b5bdceabfeaf67c91e5ccfed0320a82781f555c (patch) | |
tree | a69055b06a17fc2cbebac494e14e7852e1cefca0 /llvm/lib/CodeGen | |
parent | b952e639d9dc0cf9c7d46231d080e436fae5f9e4 (diff) | |
download | llvm-0b5bdceabfeaf67c91e5ccfed0320a82781f555c.zip llvm-0b5bdceabfeaf67c91e5ccfed0320a82781f555c.tar.gz llvm-0b5bdceabfeaf67c91e5ccfed0320a82781f555c.tar.bz2 |
[CodeGen] Print stack object references as %(fixed-)stack.0 in both MIR and debug output
Work towards the unification of MIR and debug output by printing
`%stack.0` instead of `<fi#0>`, and `%fixed-stack.0` instead of
`<fi#-4>` (supposing there are 4 fixed stack objects).
Only debug syntax is affected.
Differential Revision: https://reviews.llvm.org/D41027
llvm-svn: 320827
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r-- | llvm/lib/CodeGen/MIRPrinter.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/CodeGen/MachineOperand.cpp | 31 |
2 files changed, 31 insertions, 9 deletions
diff --git a/llvm/lib/CodeGen/MIRPrinter.cpp b/llvm/lib/CodeGen/MIRPrinter.cpp index 8cc9ad2..7c4e098 100644 --- a/llvm/lib/CodeGen/MIRPrinter.cpp +++ b/llvm/lib/CodeGen/MIRPrinter.cpp @@ -758,13 +758,8 @@ void MIPrinter::printStackObjectReference(int FrameIndex) { assert(ObjectInfo != StackObjectOperandMapping.end() && "Invalid frame index"); const FrameIndexOperand &Operand = ObjectInfo->second; - if (Operand.IsFixed) { - OS << "%fixed-stack." << Operand.ID; - return; - } - OS << "%stack." << Operand.ID; - if (!Operand.Name.empty()) - OS << '.' << Operand.Name; + MachineOperand::printStackObjectReference(OS, Operand.ID, Operand.IsFixed, + Operand.Name); } void MIPrinter::printOffset(int64_t Offset) { diff --git a/llvm/lib/CodeGen/MachineOperand.cpp b/llvm/lib/CodeGen/MachineOperand.cpp index c95fb12..d17c481 100644 --- a/llvm/lib/CodeGen/MachineOperand.cpp +++ b/llvm/lib/CodeGen/MachineOperand.cpp @@ -14,6 +14,7 @@ #include "llvm/CodeGen/MachineOperand.h" #include "llvm/Analysis/Loads.h" #include "llvm/CodeGen/MIRPrinter.h" +#include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/TargetInstrInfo.h" @@ -476,6 +477,19 @@ void MachineOperand::printSymbol(raw_ostream &OS, MCSymbol &Sym) { OS << "<mcsymbol " << Sym << ">"; } +void MachineOperand::printStackObjectReference(raw_ostream &OS, + unsigned FrameIndex, + bool IsFixed, StringRef Name) { + if (IsFixed) { + OS << "%fixed-stack." << FrameIndex; + return; + } + + OS << "%stack." << FrameIndex; + if (!Name.empty()) + OS << '.' << Name; +} + void MachineOperand::print(raw_ostream &OS, const TargetRegisterInfo *TRI, const TargetIntrinsicInfo *IntrinsicInfo) const { tryToGetTargetInfo(*this, TRI, IntrinsicInfo); @@ -574,9 +588,22 @@ void MachineOperand::print(raw_ostream &OS, ModuleSlotTracker &MST, case MachineOperand::MO_MachineBasicBlock: OS << printMBBReference(*getMBB()); break; - case MachineOperand::MO_FrameIndex: - OS << "<fi#" << getIndex() << '>'; + case MachineOperand::MO_FrameIndex: { + int FrameIndex = getIndex(); + bool IsFixed = false; + StringRef Name; + if (const MachineFunction *MF = getMFIfAvailable(*this)) { + const MachineFrameInfo &MFI = MF->getFrameInfo(); + IsFixed = MFI.isFixedObjectIndex(FrameIndex); + if (const AllocaInst *Alloca = MFI.getObjectAllocation(FrameIndex)) + if (Alloca->hasName()) + Name = Alloca->getName(); + if (IsFixed) + FrameIndex -= MFI.getObjectIndexBegin(); + } + printStackObjectReference(OS, FrameIndex, IsFixed, Name); break; + } case MachineOperand::MO_ConstantPoolIndex: OS << "%const." << getIndex(); printOffset(OS, getOffset()); |