llvm.org GIT mirror llvm / 60ae8c8
Reformat PseudoSourceValue.cpp and PseudoSourceValue.h. NFC. This commit reformats the files lib/CodeGen/PseudoSourceValue.cpp and include/llvm/CodeGen/PseudoSourceValue.h using clang-format. This change is done in preparation for the changes to the pseudo source value object management and to the PseudoSourceValue's class hierarchy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244685 91177308-0d34-0410-b5e6-96231b3b80d8 Alex Lorenz 4 years ago
2 changed file(s) with 92 addition(s) and 94 deletion(s). Raw diff Collapse all Expand all
1616 #include "llvm/IR/Value.h"
1717
1818 namespace llvm {
19 class MachineFrameInfo;
20 class MachineMemOperand;
21 class raw_ostream;
19 class MachineFrameInfo;
20 class MachineMemOperand;
21 class raw_ostream;
2222
23 raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
23 raw_ostream &operator<<(raw_ostream &OS, const MachineMemOperand &MMO);
2424
25 /// PseudoSourceValue - Special value supplied for machine level alias
26 /// analysis. It indicates that a memory access references the functions
27 /// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
28 /// space), or constant pool.
29 class PseudoSourceValue {
30 private:
31 friend class MachineMemOperand; // For printCustom().
25 /// PseudoSourceValue - Special value supplied for machine level alias
26 /// analysis. It indicates that a memory access references the functions
27 /// stack frame (e.g., a spill slot), below the stack frame (e.g., argument
28 /// space), or constant pool.
29 class PseudoSourceValue {
30 private:
31 friend class MachineMemOperand; // For printCustom().
3232
33 /// printCustom - Implement printing for PseudoSourceValue. This is called
34 /// from Value::print or Value's operator<<.
35 ///
36 virtual void printCustom(raw_ostream &O) const;
33 /// printCustom - Implement printing for PseudoSourceValue. This is called
34 /// from Value::print or Value's operator<<.
35 ///
36 virtual void printCustom(raw_ostream &O) const;
3737
38 public:
39 /// isFixed - Whether this is a FixedStackPseudoSourceValue.
40 bool isFixed;
38 public:
39 /// isFixed - Whether this is a FixedStackPseudoSourceValue.
40 bool isFixed;
4141
42 explicit PseudoSourceValue(bool isFixed = false);
42 explicit PseudoSourceValue(bool isFixed = false);
4343
44 virtual ~PseudoSourceValue();
44 virtual ~PseudoSourceValue();
4545
46 /// isConstant - Test whether the memory pointed to by this
47 /// PseudoSourceValue has a constant value.
48 ///
49 virtual bool isConstant(const MachineFrameInfo *) const;
46 /// isConstant - Test whether the memory pointed to by this
47 /// PseudoSourceValue has a constant value.
48 ///
49 virtual bool isConstant(const MachineFrameInfo *) const;
5050
51 /// isAliased - Test whether the memory pointed to by this
52 /// PseudoSourceValue may also be pointed to by an LLVM IR Value.
53 virtual bool isAliased(const MachineFrameInfo *) const;
51 /// isAliased - Test whether the memory pointed to by this
52 /// PseudoSourceValue may also be pointed to by an LLVM IR Value.
53 virtual bool isAliased(const MachineFrameInfo *) const;
5454
55 /// mayAlias - Return true if the memory pointed to by this
56 /// PseudoSourceValue can ever alias an LLVM IR Value.
57 virtual bool mayAlias(const MachineFrameInfo *) const;
55 /// mayAlias - Return true if the memory pointed to by this
56 /// PseudoSourceValue can ever alias an LLVM IR Value.
57 virtual bool mayAlias(const MachineFrameInfo *) const;
5858
59 /// A pseudo source value referencing a fixed stack frame entry,
60 /// e.g., a spill slot.
61 static const PseudoSourceValue *getFixedStack(int FI);
59 /// A pseudo source value referencing a fixed stack frame entry,
60 /// e.g., a spill slot.
61 static const PseudoSourceValue *getFixedStack(int FI);
6262
63 /// A pseudo source value referencing the area below the stack frame of
64 /// a function, e.g., the argument space.
65 static const PseudoSourceValue *getStack();
63 /// A pseudo source value referencing the area below the stack frame of
64 /// a function, e.g., the argument space.
65 static const PseudoSourceValue *getStack();
6666
67 /// A pseudo source value referencing the global offset table
68 /// (or something the like).
69 static const PseudoSourceValue *getGOT();
67 /// A pseudo source value referencing the global offset table
68 /// (or something the like).
69 static const PseudoSourceValue *getGOT();
7070
71 /// A pseudo source value referencing the constant pool. Since constant
72 /// pools are constant, this doesn't need to identify a specific constant
73 /// pool entry.
74 static const PseudoSourceValue *getConstantPool();
71 /// A pseudo source value referencing the constant pool. Since constant
72 /// pools are constant, this doesn't need to identify a specific constant
73 /// pool entry.
74 static const PseudoSourceValue *getConstantPool();
7575
76 /// A pseudo source value referencing a jump table. Since jump tables are
77 /// constant, this doesn't need to identify a specific jump table.
78 static const PseudoSourceValue *getJumpTable();
79 };
76 /// A pseudo source value referencing a jump table. Since jump tables are
77 /// constant, this doesn't need to identify a specific jump table.
78 static const PseudoSourceValue *getJumpTable();
79 };
8080
81 /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
82 /// for holding FixedStack values, which must include a frame
83 /// index.
84 class FixedStackPseudoSourceValue : public PseudoSourceValue {
85 const int FI;
86 public:
87 explicit FixedStackPseudoSourceValue(int fi) :
88 PseudoSourceValue(true), FI(fi) {}
81 /// FixedStackPseudoSourceValue - A specialized PseudoSourceValue
82 /// for holding FixedStack values, which must include a frame
83 /// index.
84 class FixedStackPseudoSourceValue : public PseudoSourceValue {
85 const int FI;
8986
90 /// classof - Methods for support type inquiry through isa, cast, and
91 /// dyn_cast:
92 ///
93 static inline bool classof(const PseudoSourceValue *V) {
94 return V->isFixed == true;
95 }
87 public:
88 explicit FixedStackPseudoSourceValue(int fi)
89 : PseudoSourceValue(true), FI(fi) {}
9690
97 bool isConstant(const MachineFrameInfo *MFI) const override;
91 /// classof - Methods for support type inquiry through isa, cast, and
92 /// dyn_cast:
93 ///
94 static inline bool classof(const PseudoSourceValue *V) {
95 return V->isFixed == true;
96 }
9897
99 bool isAliased(const MachineFrameInfo *MFI) const override;
98 bool isConstant(const MachineFrameInfo *MFI) const override;
10099
101 bool mayAlias(const MachineFrameInfo *) const override;
100 bool isAliased(const MachineFrameInfo *MFI) const override;
102101
103 void printCustom(raw_ostream &OS) const override;
102 bool mayAlias(const MachineFrameInfo *) const override;
104103
105 int getFrameIndex() const { return FI; }
106 };
104 void printCustom(raw_ostream &OS) const override;
105
106 int getFrameIndex() const { return FI; }
107 };
107108 } // End llvm namespace
108109
109110 #endif
2525 struct PSVGlobalsTy {
2626 // PseudoSourceValues are immutable so don't need locking.
2727 const PseudoSourceValue PSVs[4];
28 sys::Mutex Lock; // Guards FSValues, but not the values inside it.
28 sys::Mutex Lock; // Guards FSValues, but not the values inside it.
2929 std::map FSValues;
3030
3131 PSVGlobalsTy() : PSVs() {}
3232 ~PSVGlobalsTy() {
3333 for (std::map::iterator
34 I = FSValues.begin(), E = FSValues.end(); I != E; ++I) {
34 I = FSValues.begin(),
35 E = FSValues.end();
36 I != E; ++I) {
3537 delete I->second;
3638 }
3739 }
3941
4042 static ManagedStatic PSVGlobals;
4143
42 } // anonymous namespace
44 } // anonymous namespace
4345
44 const PseudoSourceValue *PseudoSourceValue::getStack()
45 { return &PSVGlobals->PSVs[0]; }
46 const PseudoSourceValue *PseudoSourceValue::getGOT()
47 { return &PSVGlobals->PSVs[1]; }
48 const PseudoSourceValue *PseudoSourceValue::getJumpTable()
49 { return &PSVGlobals->PSVs[2]; }
50 const PseudoSourceValue *PseudoSourceValue::getConstantPool()
51 { return &PSVGlobals->PSVs[3]; }
46 const PseudoSourceValue *PseudoSourceValue::getStack() {
47 return &PSVGlobals->PSVs[0];
48 }
49 const PseudoSourceValue *PseudoSourceValue::getGOT() {
50 return &PSVGlobals->PSVs[1];
51 }
52 const PseudoSourceValue *PseudoSourceValue::getJumpTable() {
53 return &PSVGlobals->PSVs[2];
54 }
55 const PseudoSourceValue *PseudoSourceValue::getConstantPool() {
56 return &PSVGlobals->PSVs[3];
57 }
5258
53 static const char *const PSVNames[] = {
54 "Stack",
55 "GOT",
56 "JumpTable",
57 "ConstantPool"
58 };
59 static const char *const PSVNames[] = {"Stack", "GOT", "JumpTable",
60 "ConstantPool"};
5961
6062 PseudoSourceValue::PseudoSourceValue(bool isFixed) : isFixed(isFixed) {}
6163
7779 bool PseudoSourceValue::isConstant(const MachineFrameInfo *) const {
7880 if (this == getStack())
7981 return false;
80 if (this == getGOT() ||
81 this == getConstantPool() ||
82 this == getJumpTable())
82 if (this == getGOT() || this == getConstantPool() || this == getJumpTable())
8383 return true;
8484 llvm_unreachable("Unknown PseudoSourceValue!");
8585 }
8686
8787 bool PseudoSourceValue::isAliased(const MachineFrameInfo *MFI) const {
88 if (this == getStack() ||
89 this == getGOT() ||
90 this == getConstantPool() ||
88 if (this == getStack() || this == getGOT() || this == getConstantPool() ||
9189 this == getJumpTable())
9290 return false;
9391 llvm_unreachable("Unknown PseudoSourceValue!");
9492 }
9593
9694 bool PseudoSourceValue::mayAlias(const MachineFrameInfo *MFI) const {
97 if (this == getGOT() ||
98 this == getConstantPool() ||
99 this == getJumpTable())
95 if (this == getGOT() || this == getConstantPool() || this == getJumpTable())
10096 return false;
10197 return true;
10298 }
10399
104 bool FixedStackPseudoSourceValue::isConstant(const MachineFrameInfo *MFI) const{
100 bool FixedStackPseudoSourceValue::isConstant(
101 const MachineFrameInfo *MFI) const {
105102 return MFI && MFI->isImmutableObjectIndex(FI);
106103 }
107104