llvm.org GIT mirror llvm / c18bd9d
PseudoSourceValue: Introduce a 'PSVKind' enumerator. This commit introduces a new enumerator named 'PSVKind' in the 'PseudoSourceValue' class. This enumerator is now used to distinguish between the various kinds of pseudo source values. This change is done in preparation for the changes to the pseudo source value object management and to the PseudoSourceValue's class hierarchy - the next two PseudoSourceValue commits will get rid of the global variable that manages the pseudo source values and the mips specific MipsCallEntry subclass. Reviewers: Akira Hatanaka git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244687 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Lorenz 4 years ago
3 changed file(s) with 37 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
2727 /// a memory access references the functions stack frame (e.g., a spill slot),
2828 /// below the stack frame (e.g., argument space), or constant pool.
2929 class PseudoSourceValue {
30 public:
31 enum PSVKind { Stack, GOT, JumpTable, ConstantPool, FixedStack, MipsPSV };
32
3033 private:
34 PSVKind Kind;
35
3136 friend class MachineMemOperand; // For printCustom().
3237
3338 /// Implement printing for PseudoSourceValue. This is called from
3540 virtual void printCustom(raw_ostream &O) const;
3641
3742 public:
38 /// Whether this is a FixedStackPseudoSourceValue.
39 bool IsFixed;
40
41 explicit PseudoSourceValue(bool IsFixed = false);
43 explicit PseudoSourceValue(PSVKind Kind);
4244
4345 virtual ~PseudoSourceValue();
46
47 PSVKind kind() const { return Kind; }
48
49 bool isStack() const { return Kind == Stack; }
50 bool isGOT() const { return Kind == GOT; }
51 bool isConstantPool() const { return Kind == ConstantPool; }
52 bool isJumpTable() const { return Kind == JumpTable; }
4453
4554 /// Test whether the memory pointed to by this PseudoSourceValue has a
4655 /// constant value.
8392
8493 public:
8594 explicit FixedStackPseudoSourceValue(int FI)
86 : PseudoSourceValue(true), FI(FI) {}
95 : PseudoSourceValue(FixedStack), FI(FI) {}
8796
8897 static inline bool classof(const PseudoSourceValue *V) {
89 return V->IsFixed == true;
98 return V->kind() == FixedStack;
9099 }
91100
92101 bool isConstant(const MachineFrameInfo *MFI) const override;
2424 namespace {
2525 struct PSVGlobalsTy {
2626 // PseudoSourceValues are immutable so don't need locking.
27 const PseudoSourceValue PSVs[4];
27 const PseudoSourceValue StackPSV, GOTPSV, JumpTablePSV, ConstantPoolPSV;
2828 sys::Mutex Lock; // Guards FSValues, but not the values inside it.
2929 std::map FSValues;
3030
31 PSVGlobalsTy() : PSVs() {}
31 PSVGlobalsTy()
32 : StackPSV(PseudoSourceValue::Stack), GOTPSV(PseudoSourceValue::GOT),
33 JumpTablePSV(PseudoSourceValue::JumpTable),
34 ConstantPoolPSV(PseudoSourceValue::ConstantPool) {}
3235 ~PSVGlobalsTy() {
3336 for (std::map::iterator
3437 I = FSValues.begin(),
4447 } // anonymous namespace
4548
4649 const PseudoSourceValue *PseudoSourceValue::getStack() {
47 return &PSVGlobals->PSVs[0];
50 return &PSVGlobals->StackPSV;
4851 }
4952 const PseudoSourceValue *PseudoSourceValue::getGOT() {
50 return &PSVGlobals->PSVs[1];
53 return &PSVGlobals->GOTPSV;
5154 }
5255 const PseudoSourceValue *PseudoSourceValue::getJumpTable() {
53 return &PSVGlobals->PSVs[2];
56 return &PSVGlobals->JumpTablePSV;
5457 }
5558 const PseudoSourceValue *PseudoSourceValue::getConstantPool() {
56 return &PSVGlobals->PSVs[3];
59 return &PSVGlobals->ConstantPoolPSV;
5760 }
5861
59 static const char *const PSVNames[] = {"Stack", "GOT", "JumpTable",
60 "ConstantPool"};
62 static const char *const PSVNames[] = {
63 "Stack", "GOT", "JumpTable", "ConstantPool", "FixedStack", "MipsCallEntry"};
6164
62 PseudoSourceValue::PseudoSourceValue(bool IsFixed) : IsFixed(IsFixed) {}
65 PseudoSourceValue::PseudoSourceValue(PSVKind Kind) : Kind(Kind) {}
6366
6467 PseudoSourceValue::~PseudoSourceValue() {}
6568
6669 void PseudoSourceValue::printCustom(raw_ostream &O) const {
67 O << PSVNames[this - PSVGlobals->PSVs];
70 O << PSVNames[Kind];
6871 }
6972
7073 const PseudoSourceValue *PseudoSourceValue::getFixedStack(int FI) {
7780 }
7881
7982 bool PseudoSourceValue::isConstant(const MachineFrameInfo *) const {
80 if (this == getStack())
83 if (isStack())
8184 return false;
82 if (this == getGOT() || this == getConstantPool() || this == getJumpTable())
85 if (isGOT() || isConstantPool() || isJumpTable())
8386 return true;
8487 llvm_unreachable("Unknown PseudoSourceValue!");
8588 }
8689
87 bool PseudoSourceValue::isAliased(const MachineFrameInfo *MFI) const {
88 if (this == getStack() || this == getGOT() || this == getConstantPool() ||
89 this == getJumpTable())
90 bool PseudoSourceValue::isAliased(const MachineFrameInfo *) const {
91 if (isStack() || isGOT() || isConstantPool() || isJumpTable())
9092 return false;
9193 llvm_unreachable("Unknown PseudoSourceValue!");
9294 }
9395
94 bool PseudoSourceValue::mayAlias(const MachineFrameInfo *MFI) const {
95 if (this == getGOT() || this == getConstantPool() || this == getJumpTable())
96 bool PseudoSourceValue::mayAlias(const MachineFrameInfo *) const {
97 if (isGOT() || isConstantPool() || isJumpTable())
9698 return false;
9799 return true;
98100 }
2424 cl::desc("Always use $gp as the global base register."));
2525
2626 // class MipsCallEntry.
27 MipsCallEntry::MipsCallEntry(StringRef N) {
27 MipsCallEntry::MipsCallEntry(StringRef N) : PseudoSourceValue(MipsPSV) {
2828 #ifndef NDEBUG
2929 Name = N;
3030 Val = nullptr;
3131 #endif
3232 }
3333
34 MipsCallEntry::MipsCallEntry(const GlobalValue *V) {
34 MipsCallEntry::MipsCallEntry(const GlobalValue *V)
35 : PseudoSourceValue(MipsPSV) {
3536 #ifndef NDEBUG
3637 Val = V;
3738 #endif