llvm.org GIT mirror llvm / edfb72c
simplify PseudoSourceValue printing a bit. Unnest all of PseudoSourceValue.cpp from the llvm namespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55293 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
3 changed file(s) with 47 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
2727 public:
2828 PseudoSourceValue();
2929
30 virtual void print(std::ostream &OS) const;
31 virtual void print(raw_ostream &OS) const;
30 void print(raw_ostream &OS) const;
3231
3332 /// isConstant - Test whether this PseudoSourceValue has a constant value.
3433 ///
6059 /// A SV referencing the jump table
6160 static const PseudoSourceValue *getJumpTable();
6261 };
63
64 inline std::ostream &operator<<(std::ostream &OS,const PseudoSourceValue &PSV) {
65 PSV.print(OS);
66 return OS;
67 }
68 inline raw_ostream &operator<<(raw_ostream &OS, const PseudoSourceValue &PSV) {
69 PSV.print(OS);
70 return OS;
71 }
72
7362 } // End llvm namespace
7463
7564 #endif
2323 #include "llvm/Support/LeakDetector.h"
2424 #include "llvm/Support/MathExtras.h"
2525 #include "llvm/Support/Streams.h"
26 #include "llvm/Support/raw_ostream.h"
2627 #include "llvm/ADT/FoldingSet.h"
2728 #include
2829 using namespace llvm;
755756 OS << "";
756757 else if (!V->getName().empty())
757758 OS << V->getName();
758 else if (const PseudoSourceValue *PSV = dyn_cast(V))
759 OS << *PSV;
760 else
759 else if (const PseudoSourceValue *PSV = dyn_cast(V)) {
760 raw_os_ostream OSS(OS);
761 PSV->print(OSS);
762 } else
761763 OS << V;
762764
763765 OS << " + " << MRO.getOffset() << "]";
1717 #include "llvm/Support/ManagedStatic.h"
1818 #include "llvm/Support/raw_ostream.h"
1919 #include
20 using namespace llvm;
2021
21 namespace llvm {
22 static ManagedStatic PSVs;
22 static ManagedStatic PSVs;
2323
24 const PseudoSourceValue *PseudoSourceValue::getStack()
25 { return &(*PSVs)[0]; }
26 const PseudoSourceValue *PseudoSourceValue::getGOT()
27 { return &(*PSVs)[1]; }
28 const PseudoSourceValue *PseudoSourceValue::getJumpTable()
29 { return &(*PSVs)[2]; }
30 const PseudoSourceValue *PseudoSourceValue::getConstantPool()
31 { return &(*PSVs)[3]; }
24 const PseudoSourceValue *PseudoSourceValue::getStack()
25 { return &(*PSVs)[0]; }
26 const PseudoSourceValue *PseudoSourceValue::getGOT()
27 { return &(*PSVs)[1]; }
28 const PseudoSourceValue *PseudoSourceValue::getJumpTable()
29 { return &(*PSVs)[2]; }
30 const PseudoSourceValue *PseudoSourceValue::getConstantPool()
31 { return &(*PSVs)[3]; }
3232
33 static const char *const PSVNames[] = {
34 "Stack",
35 "GOT",
36 "JumpTable",
37 "ConstantPool"
38 };
33 static const char *const PSVNames[] = {
34 "Stack",
35 "GOT",
36 "JumpTable",
37 "ConstantPool"
38 };
3939
40 PseudoSourceValue::PseudoSourceValue() :
41 Value(PointerType::getUnqual(Type::Int8Ty), PseudoSourceValueVal) {}
40 PseudoSourceValue::PseudoSourceValue() :
41 Value(PointerType::getUnqual(Type::Int8Ty), PseudoSourceValueVal) {}
4242
43 void PseudoSourceValue::print(std::ostream &OS) const {
44 OS << PSVNames[this - *PSVs];
45 }
46 void PseudoSourceValue::print(raw_ostream &OS) const {
47 OS << PSVNames[this - *PSVs];
48 }
43 void PseudoSourceValue::print(raw_ostream &OS) const {
44 OS << PSVNames[this - *PSVs];
45 }
4946
47 namespace {
5048 /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
5149 /// for holding FixedStack values, which must include a frame
5250 /// index.
6563 OS << "FixedStack" << FI;
6664 }
6765 };
66 }
6867
69 static ManagedStatic > FSValues;
68 static ManagedStatic > FSValues;
7069
71 const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
72 const PseudoSourceValue *&V = (*FSValues)[FI];
73 if (!V)
74 V = new FixedStackPseudoSourceValue(FI);
75 return V;
76 }
70 const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
71 const PseudoSourceValue *&V = (*FSValues)[FI];
72 if (!V)
73 V = new FixedStackPseudoSourceValue(FI);
74 return V;
75 }
7776
78 bool PseudoSourceValue::isConstant(const MachineFrameInfo *) const {
79 if (this == getStack())
80 return false;
81 if (this == getGOT() ||
82 this == getConstantPool() ||
83 this == getJumpTable())
84 return true;
85 assert(0 && "Unknown PseudoSourceValue!");
77 bool PseudoSourceValue::isConstant(const MachineFrameInfo *) const {
78 if (this == getStack())
8679 return false;
87 }
80 if (this == getGOT() ||
81 this == getConstantPool() ||
82 this == getJumpTable())
83 return true;
84 assert(0 && "Unknown PseudoSourceValue!");
85 return false;
86 }
8887
89 bool
90 FixedStackPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const {
91 return MFI && MFI->isImmutableObjectIndex(FI);
92 }
88 bool FixedStackPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const{
89 return MFI && MFI->isImmutableObjectIndex(FI);
9390 }