mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
Give MachineMemOperand an operator<<, factoring out code from
two different places for printing MachineMemOperands. Drop the virtual from Value::dump and instead give Value a protected virtual hook that can be overridden by subclasses to implement custom printing. This lets printing be more consistent, and simplifies printing of PseudoSourceValue values. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82599 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -22,6 +22,7 @@ namespace llvm {
|
|||||||
|
|
||||||
class Value;
|
class Value;
|
||||||
class FoldingSetNodeID;
|
class FoldingSetNodeID;
|
||||||
|
class raw_ostream;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
/// MachineMemOperand - A description of a memory reference used in the backend.
|
/// MachineMemOperand - A description of a memory reference used in the backend.
|
||||||
@ -92,6 +93,8 @@ public:
|
|||||||
void Profile(FoldingSetNodeID &ID) const;
|
void Profile(FoldingSetNodeID &ID) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MRO);
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -25,17 +25,15 @@ namespace llvm {
|
|||||||
/// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
|
/// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
|
||||||
/// space), or constant pool.
|
/// space), or constant pool.
|
||||||
class PseudoSourceValue : public Value {
|
class PseudoSourceValue : public Value {
|
||||||
|
private:
|
||||||
|
/// printCustom - Implement printing for PseudoSourceValue. This is called
|
||||||
|
/// from Value::print or Value's operator<<.
|
||||||
|
///
|
||||||
|
virtual void printCustom(raw_ostream &O) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PseudoSourceValue();
|
PseudoSourceValue();
|
||||||
|
|
||||||
/// dump - Support for debugging, callable in GDB: V->dump()
|
|
||||||
//
|
|
||||||
virtual void dump() const;
|
|
||||||
|
|
||||||
/// print - Implement operator<< on PseudoSourceValue.
|
|
||||||
///
|
|
||||||
virtual void print(raw_ostream &OS) const;
|
|
||||||
|
|
||||||
/// isConstant - Test whether this PseudoSourceValue has a constant value.
|
/// isConstant - Test whether this PseudoSourceValue has a constant value.
|
||||||
///
|
///
|
||||||
virtual bool isConstant(const MachineFrameInfo *) const;
|
virtual bool isConstant(const MachineFrameInfo *) const;
|
||||||
|
@ -90,13 +90,18 @@ private:
|
|||||||
void operator=(const Value &); // Do not implement
|
void operator=(const Value &); // Do not implement
|
||||||
Value(const Value &); // Do not implement
|
Value(const Value &); // Do not implement
|
||||||
|
|
||||||
|
protected:
|
||||||
|
/// printCustom - Value subclasses can override this to implement custom
|
||||||
|
/// printing behavior.
|
||||||
|
virtual void printCustom(raw_ostream &O) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Value(const Type *Ty, unsigned scid);
|
Value(const Type *Ty, unsigned scid);
|
||||||
virtual ~Value();
|
virtual ~Value();
|
||||||
|
|
||||||
/// dump - Support for debugging, callable in GDB: V->dump()
|
/// dump - Support for debugging, callable in GDB: V->dump()
|
||||||
//
|
//
|
||||||
virtual void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
/// print - Implement operator<< on Value.
|
/// print - Implement operator<< on Value.
|
||||||
///
|
///
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/InlineAsm.h"
|
#include "llvm/InlineAsm.h"
|
||||||
#include "llvm/Value.h"
|
#include "llvm/Value.h"
|
||||||
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "llvm/CodeGen/MachineFunction.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
||||||
#include "llvm/CodeGen/PseudoSourceValue.h"
|
#include "llvm/CodeGen/PseudoSourceValue.h"
|
||||||
@ -297,6 +298,44 @@ void MachineMemOperand::Profile(FoldingSetNodeID &ID) const {
|
|||||||
ID.AddInteger(Flags);
|
ID.AddInteger(Flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
raw_ostream &llvm::operator<<(raw_ostream &OS, const MachineMemOperand &MRO) {
|
||||||
|
assert((MRO.isLoad() || MRO.isStore()) &&
|
||||||
|
"SV has to be a load, store or both.");
|
||||||
|
|
||||||
|
if (MRO.isVolatile())
|
||||||
|
OS << "Volatile ";
|
||||||
|
|
||||||
|
if (MRO.isLoad())
|
||||||
|
OS << "LD";
|
||||||
|
if (MRO.isStore())
|
||||||
|
OS << "ST";
|
||||||
|
OS << MRO.getSize();
|
||||||
|
|
||||||
|
// Print the address information.
|
||||||
|
OS << "[";
|
||||||
|
if (!MRO.getValue())
|
||||||
|
OS << "<unknown>";
|
||||||
|
else
|
||||||
|
WriteAsOperand(OS, MRO.getValue(), /*PrintType=*/false);
|
||||||
|
|
||||||
|
// If the alignment of the memory reference itself differs from the alignment
|
||||||
|
// of the base pointer, print the base alignment explicitly, next to the base
|
||||||
|
// pointer.
|
||||||
|
if (MRO.getBaseAlignment() != MRO.getAlignment())
|
||||||
|
OS << "(align=" << MRO.getBaseAlignment() << ")";
|
||||||
|
|
||||||
|
if (MRO.getOffset() != 0)
|
||||||
|
OS << "+" << MRO.getOffset();
|
||||||
|
OS << "]";
|
||||||
|
|
||||||
|
// Print the alignment of the reference.
|
||||||
|
if (MRO.getBaseAlignment() != MRO.getAlignment() ||
|
||||||
|
MRO.getBaseAlignment() != MRO.getSize())
|
||||||
|
OS << "(align=" << MRO.getAlignment() << ")";
|
||||||
|
|
||||||
|
return OS;
|
||||||
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// MachineInstr Implementation
|
// MachineInstr Implementation
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
@ -967,32 +1006,9 @@ void MachineInstr::print(raw_ostream &OS, const TargetMachine *TM) const {
|
|||||||
OS << ", Mem:";
|
OS << ", Mem:";
|
||||||
for (std::list<MachineMemOperand>::const_iterator i = memoperands_begin(),
|
for (std::list<MachineMemOperand>::const_iterator i = memoperands_begin(),
|
||||||
e = memoperands_end(); i != e; ++i) {
|
e = memoperands_end(); i != e; ++i) {
|
||||||
const MachineMemOperand &MRO = *i;
|
OS << *i;
|
||||||
const Value *V = MRO.getValue();
|
if (next(i) != e)
|
||||||
|
OS << " ";
|
||||||
assert((MRO.isLoad() || MRO.isStore()) &&
|
|
||||||
"SV has to be a load, store or both.");
|
|
||||||
|
|
||||||
if (MRO.isVolatile())
|
|
||||||
OS << "Volatile ";
|
|
||||||
|
|
||||||
if (MRO.isLoad())
|
|
||||||
OS << "LD";
|
|
||||||
if (MRO.isStore())
|
|
||||||
OS << "ST";
|
|
||||||
|
|
||||||
OS << "(" << MRO.getSize() << "," << MRO.getAlignment() << ") [";
|
|
||||||
|
|
||||||
if (!V)
|
|
||||||
OS << "<unknown>";
|
|
||||||
else if (!V->getName().empty())
|
|
||||||
OS << V->getName();
|
|
||||||
else if (const PseudoSourceValue *PSV = dyn_cast<PseudoSourceValue>(V)) {
|
|
||||||
PSV->print(OS);
|
|
||||||
} else
|
|
||||||
OS << V;
|
|
||||||
|
|
||||||
OS << " + " << MRO.getOffset() << "]";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,12 +47,8 @@ PseudoSourceValue::PseudoSourceValue() :
|
|||||||
Value(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())),
|
Value(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())),
|
||||||
PseudoSourceValueVal) {}
|
PseudoSourceValueVal) {}
|
||||||
|
|
||||||
void PseudoSourceValue::dump() const {
|
void PseudoSourceValue::printCustom(raw_ostream &O) const {
|
||||||
print(errs()); errs() << '\n';
|
O << PSVNames[this - *PSVs];
|
||||||
}
|
|
||||||
|
|
||||||
void PseudoSourceValue::print(raw_ostream &OS) const {
|
|
||||||
OS << PSVNames[this - *PSVs];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -67,7 +63,7 @@ namespace {
|
|||||||
|
|
||||||
virtual bool isConstant(const MachineFrameInfo *MFI) const;
|
virtual bool isConstant(const MachineFrameInfo *MFI) const;
|
||||||
|
|
||||||
virtual void print(raw_ostream &OS) const {
|
virtual void printCustom(raw_ostream &OS) const {
|
||||||
OS << "FixedStack" << FI;
|
OS << "FixedStack" << FI;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -5580,10 +5580,7 @@ void SDNode::print_details(raw_ostream &OS, const SelectionDAG *G) const {
|
|||||||
else
|
else
|
||||||
OS << "<null>";
|
OS << "<null>";
|
||||||
} else if (const MemOperandSDNode *M = dyn_cast<MemOperandSDNode>(this)) {
|
} else if (const MemOperandSDNode *M = dyn_cast<MemOperandSDNode>(this)) {
|
||||||
if (M->MO.getValue())
|
OS << ": " << M->MO;
|
||||||
OS << "<" << M->MO.getValue() << ":" << M->MO.getOffset() << ">";
|
|
||||||
else
|
|
||||||
OS << "<null:" << M->MO.getOffset() << ">";
|
|
||||||
} else if (const VTSDNode *N = dyn_cast<VTSDNode>(this)) {
|
} else if (const VTSDNode *N = dyn_cast<VTSDNode>(this)) {
|
||||||
OS << ":" << N->getVT().getEVTString();
|
OS << ":" << N->getVT().getEVTString();
|
||||||
}
|
}
|
||||||
|
@ -1198,6 +1198,11 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Value *V,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (V->getValueID() == Value::PseudoSourceValueVal) {
|
||||||
|
V->print(Out);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char Prefix = '%';
|
char Prefix = '%';
|
||||||
int Slot;
|
int Slot;
|
||||||
if (Machine) {
|
if (Machine) {
|
||||||
@ -2076,10 +2081,17 @@ void Value::print(raw_ostream &ROS, AssemblyAnnotationWriter *AAW) const {
|
|||||||
} else if (isa<InlineAsm>(this)) {
|
} else if (isa<InlineAsm>(this)) {
|
||||||
WriteAsOperand(OS, this, true, 0);
|
WriteAsOperand(OS, this, true, 0);
|
||||||
} else {
|
} else {
|
||||||
llvm_unreachable("Unknown value to print out!");
|
// Otherwise we don't know what it is. Call the virtual function to
|
||||||
|
// allow a subclass to print itself.
|
||||||
|
printCustom(OS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Value::printCustom - subclasses should override this to implement printing.
|
||||||
|
void Value::printCustom(raw_ostream &OS) const {
|
||||||
|
llvm_unreachable("Unknown value to print out!");
|
||||||
|
}
|
||||||
|
|
||||||
// Value::dump - allow easy printing of Values from the debugger.
|
// Value::dump - allow easy printing of Values from the debugger.
|
||||||
void Value::dump() const { print(errs()); errs() << '\n'; }
|
void Value::dump() const { print(errs()); errs() << '\n'; }
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user