llvm.org GIT mirror llvm / 697954c
Changes to build successfully with GCC 3.02 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1503 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 18 years ago
230 changed file(s) with 2455 addition(s) and 2527 deletion(s). Raw diff Collapse all Expand all
5151 #Prof = -pg
5252
5353 # TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti
54 CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
54 CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused-parameter -Wno-missing-braces -I$(LEVEL)/include
5555
5656 # Compile a file, don't link...
5757 Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
5151 #Prof = -pg
5252
5353 # TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti
54 CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
54 CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused-parameter -Wno-missing-braces -I$(LEVEL)/include
5555
5656 # Compile a file, don't link...
5757 Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
165165 //===--------------------------------------------------------------------===//
166166 // Basic ID <-> Name map functionality
167167
168 static AnnotationID getID (const string &Name); // Name -> ID
169 static const string &getName(AnnotationID ID); // ID -> Name
168 static AnnotationID getID(const std::string &Name); // Name -> ID
169 static const std::string &getName(AnnotationID ID); // ID -> Name
170170
171171 // getID - Name -> ID + registration of a factory function for demand driven
172172 // annotation support.
173 static AnnotationID getID (const string &Name, Factory Fact, void *Data=0);
173 static AnnotationID getID(const std::string &Name, Factory Fact,
174 void *Data = 0);
174175
175176 //===--------------------------------------------------------------------===//
176177 // Annotation creation on demand support...
9999 // an argument. Should return true if there was an error processing the
100100 // argument and the program should exit.
101101 //
102 virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0;
102 virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0;
103103
104104 virtual enum NumOccurances getNumOccurancesFlagDefault() const {
105105 return Optional;
145145
146146 // addOccurance - Wrapper around handleOccurance that enforces Flags
147147 //
148 bool addOccurance(const char *ArgName, const string &Value);
148 bool addOccurance(const char *ArgName, const std::string &Value);
149149
150150 // Prints option name followed by message. Always returns true.
151 bool error(string Message, const char *ArgName = 0);
151 bool error(std::string Message, const char *ArgName = 0);
152152
153153 public:
154154 inline int getNumOccurances() const { return NumOccurances; }
161161 //
162162 class Alias : public Option {
163163 Option &AliasFor;
164 virtual bool handleOccurance(const char *ArgName, const string &Arg) {
164 virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
165165 return AliasFor.handleOccurance(AliasFor.ArgStr, Arg);
166166 }
167167 virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
176176 //
177177 class Flag : public Option {
178178 bool Value;
179 virtual bool handleOccurance(const char *ArgName, const string &Arg);
179 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
180180 public:
181181 inline Flag(const char *ArgStr, const char *Message, int Flags = 0,
182182 bool DefaultVal = 0) : Option(ArgStr, Message, Flags),
192192 //
193193 class Int : public Option {
194194 int Value;
195 virtual bool handleOccurance(const char *ArgName, const string &Arg);
195 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
196196 virtual enum ValueExpected getValueExpectedFlagDefault() const {
197197 return ValueRequired;
198198 }
208208 //===----------------------------------------------------------------------===//
209209 // String valued command line option
210210 //
211 class String : public Option, public string {
212 virtual bool handleOccurance(const char *ArgName, const string &Arg);
211 class String : public Option, public std::string {
212 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
213213 virtual enum ValueExpected getValueExpectedFlagDefault() const {
214214 return ValueRequired;
215215 }
216216 public:
217217 inline String(const char *ArgStr, const char *Help, int Flags = 0,
218218 const char *DefaultVal = "")
219 : Option(ArgStr, Help, Flags), string(DefaultVal) {}
220
221 inline const string &operator=(const string &Val) {
222 return string::operator=(Val);
219 : Option(ArgStr, Help, Flags), std::string(DefaultVal) {}
220
221 inline const std::string &operator=(const std::string &Val) {
222 return std::string::operator=(Val);
223223 }
224224 };
225225
227227 //===----------------------------------------------------------------------===//
228228 // String list command line option
229229 //
230 class StringList : public Option, public vector<string> {
230 class StringList : public Option, public std::vectorstring> {
231231
232232 virtual enum NumOccurances getNumOccurancesFlagDefault() const {
233233 return ZeroOrMore;
235235 virtual enum ValueExpected getValueExpectedFlagDefault() const {
236236 return ValueRequired;
237237 }
238 virtual bool handleOccurance(const char *ArgName, const string &Arg);
238 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
239239
240240 public:
241241 inline StringList(const char *ArgStr, const char *Help, int Flags = 0)
255255 // Use a vector instead of a map, because the lists should be short,
256256 // the overhead is less, and most importantly, it keeps them in the order
257257 // inserted so we can print our option out nicely.
258 vectorpair > > ValueMap;
258 std::vectorpair > > ValueMap;
259259
260260 inline EnumBase(const char *ArgStr, const char *Help, int Flags)
261261 : Option(ArgStr, Help, Flags) {}
283283 inline EnumValueBase(int Flags) : EnumBase(Flags) {}
284284
285285 // handleOccurance - Set Value to the enum value specified by Arg
286 virtual bool handleOccurance(const char *ArgName, const string &Arg);
286 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
287287
288288 // Return the width of the option tag for printing...
289289 virtual unsigned getOptionWidth() const;
322322 return ValueDisallowed;
323323 }
324324 protected:
325 virtual bool handleOccurance(const char *ArgName, const string &Arg);
325 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
326326 inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {}
327327
328328 // Return the width of the option tag for printing...
362362 return ValueDisallowed;
363363 }
364364 protected:
365 vector Values; // The options specified so far.
365 std::vector Values; // The options specified so far.
366366
367367 inline EnumListBase(int Flags)
368368 : EnumBase(Flags) {}
369 virtual bool handleOccurance(const char *ArgName, const string &Arg);
369 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
370370
371371 // Return the width of the option tag for printing...
372372 virtual unsigned getOptionWidth() const;
1919 typedef typename GT::NodeType NodeType;
2020 typedef typename GT::ChildIteratorType ChildItTy;
2121
22 set Visited; // All of the blocks visited so far...
22 std::set Visited; // All of the blocks visited so far...
2323 // VisitStack - Used to maintain the ordering. Top = current block
2424 // First element is node pointer, second is the 'next child' to visit
25 stack<pair > VisitStack;
25 std::stackpair > VisitStack;
2626 const bool Reverse; // Iterate over children before self?
2727 private:
2828 void reverseEnterNode() {
29 pair &Top = VisitStack.top();
29 std::pair &Top = VisitStack.top();
3030 NodeType *Node = Top.first;
3131 ChildItTy &It = Top.second;
3232 for (; It != GT::child_end(Node); ++It) {
3333 NodeType *Child = *It;
3434 if (!Visited.count(Child)) {
3535 Visited.insert(Child);
36 VisitStack.push(make_pair(Child, GT::child_begin(Child)));
36 VisitStack.push(std::make_pair(Child, GT::child_begin(Child)));
3737 reverseEnterNode();
3838 return;
3939 }
4242
4343 inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) {
4444 Visited.insert(Node);
45 VisitStack.push(make_pair(Node, GT::child_begin(Node)));
45 VisitStack.push(std::make_pair(Node, GT::child_begin(Node)));
4646 if (Reverse) reverseEnterNode();
4747 }
4848 inline df_iterator() { /* End is when stack is empty */ }
8080 reverseEnterNode();
8181 } else { // Normal Depth First Iterator
8282 do {
83 pair &Top = VisitStack.top();
83 std::pair &Top = VisitStack.top();
8484 NodeType *Node = Top.first;
8585 ChildItTy &It = Top.second;
8686
8989 if (!Visited.count(Next)) { // Has our next sibling been visited?
9090 // No, do it now.
9191 Visited.insert(Next);
92 VisitStack.push(make_pair(Next, GT::child_begin(Next)));
92 VisitStack.push(std::make_pair(Next, GT::child_begin(Next)));
9393 return *this;
9494 }
9595 }
1010 #define LLVM_SUPPORT_HASHEXTRAS_H
1111
1212 #include
13 #include <hash_map>
13 #include <ext/hash_map>
14
15 // Cannot specialize hash template from outside of the std namespace.
16 namespace std {
1417
1518 template <> struct hash {
1619 size_t operator()(string const &str) const {
2326 inline size_t operator()(const T *Val) const { return (size_t)Val; }
2427 };
2528
29 } // End namespace std
30
2631 #endif
1919 typedef typename GT::NodeType NodeType;
2020 typedef typename GT::ChildIteratorType ChildItTy;
2121
22 set Visited; // All of the blocks visited so far...
22 std::set Visited; // All of the blocks visited so far...
2323 // VisitStack - Used to maintain the ordering. Top = current block
2424 // First element is basic block pointer, second is the 'next child' to visit
25 stack<pair > VisitStack;
25 std::stackpair > VisitStack;
2626
2727 void traverseChild() {
2828 while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
121121 // }
122122 //
123123
124 typedef reverse_iterator::iterator> rpo_iterator;
124 typedef std::vector::reverse_iterator rpo_iterator;
125125 // TODO: FIXME: ReversePostOrderTraversal is not generic!
126126 class ReversePostOrderTraversal {
127 vector Blocks; // Block list in normal PO order
127 std::vector Blocks; // Block list in normal PO order
128128 inline void Initialize(BasicBlock *BB) {
129129 copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
130130 }
3535 // arguments to get a boolean result.
3636 //
3737 template
38 struct bitwise_or : public binary_function {
38 struct bitwise_or : public std::binary_function {
3939 bool operator()(const Ty& left, const Ty& right) const {
4040 return left | right;
4141 }
6969 RootIt current;
7070 UnaryFunc Fn;
7171 public:
72 typedef typename iterator_traits::iterator_category
72 typedef typename std::iterator_traits::iterator_category
7373 iterator_category;
74 typedef typename iterator_traits::difference_type
74 typedef typename std::iterator_traits::difference_type
7575 difference_type;
7676 typedef typename UnaryFunc::result_type value_type;
7777 typedef typename UnaryFunc::result_type *pointer;
101101 _Self& operator-= (difference_type n) { current -= n; return *this; }
102102 reference operator[](difference_type n) const { return *(*this + n); }
103103
104 inline bool operator!=(const _Self &X) const { return !operator==(X); }
104105 inline bool operator==(const _Self &X) const { return current == X.current; }
105106 inline bool operator< (const _Self &X) const { return current < X.current; }
106107
1010 #include
1111 #include
1212
13 static inline string utostr(uint64_t X, bool isNeg = false) {
13 static inline std::string utostr(uint64_t X, bool isNeg = false) {
1414 char Buffer[40];
1515 char *BufPtr = Buffer+39;
1616
2424
2525 if (isNeg) *--BufPtr = '-'; // Add negative sign...
2626
27 return string(BufPtr);
27 return std::string(BufPtr);
2828 }
2929
30 static inline string itostr(int64_t X) {
30 static inline std::string itostr(int64_t X) {
3131 if (X < 0)
3232 return utostr((uint64_t)-X, true);
3333 else
3535 }
3636
3737
38 static inline string utostr(unsigned X, bool isNeg = false) {
38 static inline std::string utostr(unsigned X, bool isNeg = false) {
3939 char Buffer[20];
4040 char *BufPtr = Buffer+19;
4141
4949
5050 if (isNeg) *--BufPtr = '-'; // Add negative sign...
5151
52 return string(BufPtr);
52 return std::string(BufPtr);
5353 }
5454
55 static inline string itostr(int X) {
55 static inline std::string itostr(int X) {
5656 if (X < 0)
5757 return utostr((unsigned)-X, true);
5858 else
5959 return utostr((unsigned)X);
6060 }
6161
62 static inline string ftostr(double V) {
62 static inline std::string ftostr(double V) {
6363 char Buffer[200];
6464 snprintf(Buffer, 200, "%e", V);
6565 return Buffer;
1111
1212 template
1313 class Tree {
14 vector Children; // This nodes children, if any
15 ConcreteTreeNode *Parent; // Parent of this node...
16 Payload Data; // Data held in this node...
14 std::vector Children; // This nodes children, if any
15 ConcreteTreeNode *Parent; // Parent of this node...
16 Payload Data; // Data held in this node...
1717
1818 protected:
19 void setChildren(const vector &children) {
19 void setChildren(const std::vector &children) {
2020 Children = children;
2121 }
2222 public:
2323 inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
24 inline Tree(const vector &children, ConcreteTreeNode *par)
25 : Children(children), Parent(par) {}
24 inline Tree(const std::vector &children,
25 ConcreteTreeNode *par) : Children(children), Parent(par) {}
2626
27 inline Tree(const vector &children, ConcreteTreeNode *par,
28 const Payload &data)
27 inline Tree(const std::vector &children,
28 ConcreteTreeNode *par, const Payload &data)
2929 : Children(children), Parent(parent), Data(data) {}
3030
3131 // Tree dtor - Free all children
1919 typedef typename GT::NodeType NodeType;
2020 typedef typename GT::ChildIteratorType ChildItTy;
2121
22 set Visited; // All of the blocks visited so far...
22 std::set Visited; // All of the blocks visited so far...
2323 // VisitStack - Used to maintain the ordering. Top = current block
2424 // First element is node pointer, second is the 'next child' to visit
25 stack<pair > VisitStack;
25 std::stackpair > VisitStack;
2626 const bool Reverse; // Iterate over children before self?
2727 private:
2828 void reverseEnterNode() {
29 pair &Top = VisitStack.top();
29 std::pair &Top = VisitStack.top();
3030 NodeType *Node = Top.first;
3131 ChildItTy &It = Top.second;
3232 for (; It != GT::child_end(Node); ++It) {
3333 NodeType *Child = *It;
3434 if (!Visited.count(Child)) {
3535 Visited.insert(Child);
36 VisitStack.push(make_pair(Child, GT::child_begin(Child)));
36 VisitStack.push(std::make_pair(Child, GT::child_begin(Child)));
3737 reverseEnterNode();
3838 return;
3939 }
4242
4343 inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) {
4444 Visited.insert(Node);
45 VisitStack.push(make_pair(Node, GT::child_begin(Node)));
45 VisitStack.push(std::make_pair(Node, GT::child_begin(Node)));
4646 if (Reverse) reverseEnterNode();
4747 }
4848 inline df_iterator() { /* End is when stack is empty */ }
8080 reverseEnterNode();
8181 } else { // Normal Depth First Iterator
8282 do {
83 pair &Top = VisitStack.top();
83 std::pair &Top = VisitStack.top();
8484 NodeType *Node = Top.first;
8585 ChildItTy &It = Top.second;
8686
8989 if (!Visited.count(Next)) { // Has our next sibling been visited?
9090 // No, do it now.
9191 Visited.insert(Next);
92 VisitStack.push(make_pair(Next, GT::child_begin(Next)));
92 VisitStack.push(std::make_pair(Next, GT::child_begin(Next)));
9393 return *this;
9494 }
9595 }
1010 #define LLVM_SUPPORT_HASHEXTRAS_H
1111
1212 #include
13 #include <hash_map>
13 #include <ext/hash_map>
14
15 // Cannot specialize hash template from outside of the std namespace.
16 namespace std {
1417
1518 template <> struct hash {
1619 size_t operator()(string const &str) const {
2326 inline size_t operator()(const T *Val) const { return (size_t)Val; }
2427 };
2528
29 } // End namespace std
30
2631 #endif
1919 typedef typename GT::NodeType NodeType;
2020 typedef typename GT::ChildIteratorType ChildItTy;
2121
22 set Visited; // All of the blocks visited so far...
22 std::set Visited; // All of the blocks visited so far...
2323 // VisitStack - Used to maintain the ordering. Top = current block
2424 // First element is basic block pointer, second is the 'next child' to visit
25 stack<pair > VisitStack;
25 std::stackpair > VisitStack;
2626
2727 void traverseChild() {
2828 while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
121121 // }
122122 //
123123
124 typedef reverse_iterator::iterator> rpo_iterator;
124 typedef std::vector::reverse_iterator rpo_iterator;
125125 // TODO: FIXME: ReversePostOrderTraversal is not generic!
126126 class ReversePostOrderTraversal {
127 vector Blocks; // Block list in normal PO order
127 std::vector Blocks; // Block list in normal PO order
128128 inline void Initialize(BasicBlock *BB) {
129129 copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
130130 }
3535 // arguments to get a boolean result.
3636 //
3737 template
38 struct bitwise_or : public binary_function {
38 struct bitwise_or : public std::binary_function {
3939 bool operator()(const Ty& left, const Ty& right) const {
4040 return left | right;
4141 }
6969 RootIt current;
7070 UnaryFunc Fn;
7171 public:
72 typedef typename iterator_traits::iterator_category
72 typedef typename std::iterator_traits::iterator_category
7373 iterator_category;
74 typedef typename iterator_traits::difference_type
74 typedef typename std::iterator_traits::difference_type
7575 difference_type;
7676 typedef typename UnaryFunc::result_type value_type;
7777 typedef typename UnaryFunc::result_type *pointer;
101101 _Self& operator-= (difference_type n) { current -= n; return *this; }
102102 reference operator[](difference_type n) const { return *(*this + n); }
103103
104 inline bool operator!=(const _Self &X) const { return !operator==(X); }
104105 inline bool operator==(const _Self &X) const { return current == X.current; }
105106 inline bool operator< (const _Self &X) const { return current < X.current; }
106107
1010 #include
1111 #include
1212
13 static inline string utostr(uint64_t X, bool isNeg = false) {
13 static inline std::string utostr(uint64_t X, bool isNeg = false) {
1414 char Buffer[40];
1515 char *BufPtr = Buffer+39;
1616
2424
2525 if (isNeg) *--BufPtr = '-'; // Add negative sign...
2626
27 return string(BufPtr);
27 return std::string(BufPtr);
2828 }
2929
30 static inline string itostr(int64_t X) {
30 static inline std::string itostr(int64_t X) {
3131 if (X < 0)
3232 return utostr((uint64_t)-X, true);
3333 else
3535 }
3636
3737
38 static inline string utostr(unsigned X, bool isNeg = false) {
38 static inline std::string utostr(unsigned X, bool isNeg = false) {
3939 char Buffer[20];
4040 char *BufPtr = Buffer+19;
4141
4949
5050 if (isNeg) *--BufPtr = '-'; // Add negative sign...
5151
52 return string(BufPtr);
52 return std::string(BufPtr);
5353 }
5454
55 static inline string itostr(int X) {
55 static inline std::string itostr(int X) {
5656 if (X < 0)
5757 return utostr((unsigned)-X, true);
5858 else
5959 return utostr((unsigned)X);
6060 }
6161
62 static inline string ftostr(double V) {
62 static inline std::string ftostr(double V) {
6363 char Buffer[200];
6464 snprintf(Buffer, 200, "%e", V);
6565 return Buffer;
1111
1212 template
1313 class Tree {
14 vector Children; // This nodes children, if any
15 ConcreteTreeNode *Parent; // Parent of this node...
16 Payload Data; // Data held in this node...
14 std::vector Children; // This nodes children, if any
15 ConcreteTreeNode *Parent; // Parent of this node...
16 Payload Data; // Data held in this node...
1717
1818 protected:
19 void setChildren(const vector &children) {
19 void setChildren(const std::vector &children) {
2020 Children = children;
2121 }
2222 public:
2323 inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
24 inline Tree(const vector &children, ConcreteTreeNode *par)
25 : Children(children), Parent(par) {}
24 inline Tree(const std::vector &children,
25 ConcreteTreeNode *par) : Children(children), Parent(par) {}
2626
27 inline Tree(const vector &children, ConcreteTreeNode *par,
28 const Payload &data)
27 inline Tree(const std::vector &children,
28 ConcreteTreeNode *par, const Payload &data)
2929 : Children(children), Parent(parent), Data(data) {}
3030
3131 // Tree dtor - Free all children
2626 class CallGraph;
2727 class CallGraphNode {
2828 Method *Meth;
29 vector CalledMethods;
29 std::vector CalledMethods;
3030
3131 CallGraphNode(const CallGraphNode &); // Do not implement
3232 public:
33 typedef vector::iterator iterator;
34 typedef vector::const_iterator const_iterator;
33 typedef std::vector::iterator iterator;
34 typedef std::vector::const_iterator const_iterator;
3535
3636 // getMethod - Return the method that this call graph node represents...
3737 Method *getMethod() const { return Meth; }
6464 class CallGraph {
6565 Module *Mod; // The module this call graph represents
6666
67 typedef map MethodMapTy;
67 typedef std::map MethodMapTy;
6868 MethodMapTy MethodMap; // Map from a method to its node
6969
7070 CallGraphNode *Root;
4646 //
4747 class DominatorSet : public DominatorBase {
4848 public:
49 typedef set DomSetType; // Dom set for a bb
50 typedef map DomSetMapType; // Map of dom sets
49 typedef std::set DomSetType; // Dom set for a bb
50 // Map of dom sets
51 typedef std::map DomSetMapType;
5152 private:
5253 DomSetMapType Doms;
5354
9091 // method.
9192 //
9293 class ImmediateDominators : public DominatorBase {
93 map IDoms;
94 std::map IDoms;
9495 void calcIDoms(const DominatorSet &DS);
9596 public:
9697
103104 }
104105
105106 // Accessor interface:
106 typedef map IDomMapType;
107 typedef std::map IDomMapType;
107108 typedef IDomMapType::const_iterator const_iterator;
108109 inline const_iterator begin() const { return IDoms.begin(); }
109110 inline const_iterator end() const { return IDoms.end(); }
113114 // node returns null, because it does not have an immediate dominator.
114115 //
115116 inline const BasicBlock *operator[](const BasicBlock *BB) const {
116 map::const_iterator I =
117 std::map::const_iterator I =
117118 IDoms.find(BB);
118119 return I != IDoms.end() ? I->second : 0;
119120 }
129130 public:
130131 typedef Node2 Node;
131132 private:
132 map Nodes;
133 std::map Nodes;
133134 void calculate(const DominatorSet &DS);
134 typedef map NodeMapType;
135 public:
136 class Node2 : public vector {
135 typedef std::map NodeMapType;
136 public:
137 class Node2 : public std::vector {
137138 friend class DominatorTree;
138139 const BasicBlock *TheNode;
139140 Node2 * const IDom;
140141 public:
141142 inline const BasicBlock *getNode() const { return TheNode; }
142143 inline Node2 *getIDom() const { return IDom; }
143 inline const vector &getChildren() const { return *this; }
144 inline const std::vector &getChildren() const { return *this; }
144145
145146 // dominates - Returns true iff this dominates N. Note that this is not a
146147 // constant time operation!
180181 //
181182 class DominanceFrontier : public DominatorBase {
182183 public:
183 typedef set DomSetType; // Dom set for a bb
184 typedef map DomSetMapType; // Map of dom sets
184 typedef std::set DomSetType; // Dom set for a bb
185 typedef std::map DomSetMapType; // Dom set map
185186 private:
186187 DomSetMapType Frontiers;
187188 const DomSetType &calcDomFrontier(const DominatorTree &DT,
2323
2424 struct FindUnsafePointerTypes : public Pass {
2525 // UnsafeTypes - Set of types that are not safe to transform.
26 set UnsafeTypes;
26 std::set UnsafeTypes;
2727 public:
2828
2929 // Accessor for underlying type set...
30 inline const set &getUnsafeTypes() const {
30 inline const std::set &getUnsafeTypes() const {
3131 return UnsafeTypes;
3232 }
3333
4040 // printResults - Loop over the results of the analysis, printing out unsafe
4141 // types.
4242 //
43 void printResults(const Module *Mod, ostream &o);
43 void printResults(const Module *Mod, std::ostream &o);
4444 };
4545
4646 #endif
1111 class SymbolTable;
1212
1313 class FindUsedTypes : public Pass {
14 set UsedTypes;
14 std::set UsedTypes;
1515
1616 bool IncludeSymbolTables;
1717 public:
2424 // getTypes - After the pass has been run, return the set containing all of
2525 // the types used in the module.
2626 //
27 inline const set &getTypes() const { return UsedTypes; }
27 inline const std::set &getTypes() const { return UsedTypes; }
2828
2929 // Print the types found in the module. If the optional Module parameter is
3030 // passed in, then the types are printed symbolically if possible, using the
3131 // symbol table from the module.
3232 //
33 void printTypes(ostream &o, const Module *M = 0) const;
33 void printTypes(std::ostream &o, const Module *M = 0) const;
3434
3535 private:
3636 // IncorporateType - Incorporate one type and all of its subtypes into the
3434 //
3535 template
3636 class InstTreeNode :
37 public Tree, pair, Payload> > {
37 public Tree,
38 std::pair, Payload> > {
3839
3940 friend class InstForest;
40 typedef Tree, pair, Payload> > super;
41 typedef Tree,
42 std::pair, Payload> > super;
4143
4244 // Constants used for the node type value
4345 enum NodeTypeTy {
103105
104106 public:
105107 // print - Called by operator<< below...
106 void print(ostream &o, unsigned Indent) const {
107 o << string(Indent*2, ' ');
108 void print(std::ostream &o, unsigned Indent) const {
109 o << std::string(Indent*2, ' ');
108110 switch (getNodeType()) {
109111 case ConstNode : o << "Constant : "; break;
110 case BasicBlockNode : o << "BasicBlock : " << getValue()->getName() << endl;
112 case BasicBlockNode : o << "BasicBlock : " << getValue()->getName() << "\n";
111113 return;
112114 case InstructionNode: o << "Instruction: "; break;
113115 case TemporaryNode : o << "Temporary : "; break;
114 default: o << "UNKNOWN NODE TYPE: " << getNodeType() << endl; abort();
116 default: o << "UNKNOWN NODE TYPE: " << getNodeType() << "\n"; abort();
115117 }
116118
117119 o << getValue();
123125 };
124126
125127 template
126 inline ostream &operator<<(ostream &o, const InstTreeNode *N) {
128 inline std::ostream &operator<<(std::ostream &o,
129 const InstTreeNode *N) {
127130 N->print(o, 0); return o;
128131 }
129132
136139 // guaranteed to be an instruction node. The constructor builds the forest.
137140 //
138141 template
139 class InstForest : public vector *> {
142 class InstForest : public std::vector *> {
140143 friend class InstTreeNode;
141144
142145 // InstMap - Map contains entries for ALL instructions in the method and the
143146 // InstTreeNode that they correspond to.
144147 //
145 map *> InstMap;
148 std::map *> InstMap;
146149
147150 void addInstMapping(Instruction *I, InstTreeNode *IN) {
148 InstMap.insert(make_pair(I, IN));
151 InstMap.insert(std::make_pair(I, IN));
149152 }
150153
151154 void removeInstFromRootList(Instruction *I) {
179182 // the parent pointer can be used to find the root of the tree.
180183 //
181184 inline InstTreeNode *getInstNode(Instruction *Inst) {
182 map *>::iterator I = InstMap.find(Inst);
183 if (I != InstMap.end()) return I->second;
184 return 0;
185 }
186 inline const InstTreeNode *getInstNode(const Instruction *Inst)const{
187 map*>::const_iterator I =
185 std::map *>::iterator I =
188186 InstMap.find(Inst);
189187 if (I != InstMap.end()) return I->second;
190188 return 0;
191189 }
190 inline const InstTreeNode *getInstNode(const Instruction *Inst)const{
191 std::map*>::const_iterator I =
192 InstMap.find(Inst);
193 if (I != InstMap.end()) return I->second;
194 return 0;
195 }
192196
193197 // print - Called by operator<< below...
194 void print(ostream &out) const {
198 void print(std::ostream &out) const {
195199 for (const_iterator I = begin(), E = end(); I != E; ++I)
196200 out << *I;
197201 }
198202 };
199203
200204 template
201 inline ostream &operator<<(ostream &o, const InstForest &IF) {
205 inline std::ostream &operator<<(std::ostream &o, const InstForest &IF){
202206 IF.print(o); return o;
203207 }
204208
253257 // Otherwise, we are an internal instruction node. We must process our
254258 // uses and add them as children of this node.
255259 //
256 vector Children;
260 std::vector Children;
257261
258262 // Make sure that the forest knows about us!
259263 IF.addInstMapping(I, this);
3030 //
3131 BasicBlock *HeaderNode;
3232 public:
33 typedef vector::iterator succ_iterator;
34 typedef vector::iterator pred_iterator;
35 typedef vector::iterator node_iterator;
33 typedef std::vector::iterator succ_iterator;
34 typedef std::vector::iterator pred_iterator;
35 typedef std::vector::iterator node_iterator;
3636
3737 inline Interval(BasicBlock *Header) : HeaderNode(Header) {
3838 Nodes.push_back(Header);
4545
4646 // Nodes - The basic blocks in this interval.
4747 //
48 vector Nodes;
48 std::vector Nodes;
4949
5050 // Successors - List of BasicBlocks that are reachable directly from nodes in
5151 // this interval, but are not in the interval themselves.
5252 // These nodes neccesarily must be header nodes for other intervals.
5353 //
54 vector Successors;
54 std::vector Successors;
5555
5656 // Predecessors - List of BasicBlocks that have this Interval's header block
5757 // as one of their successors.
5858 //
59 vector Predecessors;
59 std::vector Predecessors;
6060
6161 // contains - Find out if a basic block is in this interval
6262 inline bool contains(BasicBlock *BB) const {
7878
7979 template
8080 class IntervalIterator {
81 stack > IntStack;
82 set Visited;
81 std::stack > IntStack;
82 std::set Visited;
8383 OrigContainer_t *OrigContainer;
8484 bool IOwnMem; // If True, delete intervals when done with them
8585 // See file header for conditions of use
8787 typedef BasicBlock* _BB;
8888
8989 typedef IntervalIterator _Self;
90 typedef forward_iterator_tag iterator_category;
90 typedef std::forward_iterator_tag iterator_category;
9191
9292 IntervalIterator() {} // End iterator, empty stack
9393 IntervalIterator(Method *M, bool OwnMemory) : IOwnMem(OwnMemory) {
3030 // BasicBlock is a (possibly nonexistent) loop with a "tail" of non looping
3131 // nodes following it.
3232 //
33 class IntervalPartition : public vector {
34 typedef map IntervalMapTy;
33 class IntervalPartition : public std::vector {
34 typedef std::map IntervalMapTy;
3535 IntervalMapTy IntervalMap;
3636
37 typedef vector IntervalListTy;
37 typedef std::vector IntervalListTy;
3838 Interval *RootInterval;
3939
4040 public:
1111 #ifndef LIVE_VAR_MAP_H
1212 #define LIVE_VAR_MAP_H
1313
14 #include <hash_map>
14 #include <ext/hash_map>
1515
1616 class BasicBlock;
1717 class BBLiveVar;
3333
3434
3535
36 typedef hash_map
37 BBLiveVar *, hashFuncBB > BBToBBLiveVarMapType;
36 typedef std::hash_map
37 BBLiveVar *, hashFuncBB > BBToBBLiveVarMapType;
3838
39 typedef hash_map
40 hashFuncMInst> MInstToLiveVarSetMapType;
39 typedef std::hash_map
40 hashFuncMInst> MInstToLiveVarSetMapType;
4141
4242
4343 #endif
77 #ifndef LIVE_VAR_SET_H
88 #define LIVE_VAR_SET_H
99
10 #include "ValueSet.h"
10 #include "llvm/Analysis/LiveVar/ValueSet.h"
1111 #include "llvm/Instruction.h"
1212 #include "llvm/Type.h"
1313
None /* Title: ValueSet.h
0 /* Title: ValueSet.h -*- C++ -*-
11 Author: Ruchira Sasanka
22 Date: Jun 30, 01
33 Purpose: Contains a mathematical set of Values. LiveVarSet is derived from
77 #ifndef VALUE_SET_H
88 #define VALUE_SET_H
99
10 #include
11
12 #include
13 #include
14 //#include
15 #include
16
17 #include "llvm/Value.h"
18
19
20 //------------------------ Support functions ---------------------------------
21
22 struct hashFuncValue { // sturcture containing the hash func
23 inline size_t operator () (const Value *const val) const
24 { return (size_t) val; }
25 };
26
27
10 class Value;
11 #include "Support/HashExtras.h"
12 #include
2813
2914 //------------------- Class Definition for ValueSet --------------------------
3015
3217
3318
3419
35 class ValueSet : public hash_set
36 {
37
20 class ValueSet : public std::hash_set {
3821 public:
39 ValueSet(); // constructor
40
4122 inline void add(const Value *const val)
4223 { assert( val ); insert(val);} // for adding a live variable to set
4324
1313 namespace cfg {class Interval; }
1414
1515 class LoopDepthCalculator {
16 map LoopDepth;
16 std::map LoopDepth;
1717 inline void AddBB(const BasicBlock *BB); // Increment count for this block
1818 inline void ProcessInterval(cfg::Interval *I);
1919 public:
2020 LoopDepthCalculator(Method *M);
2121
2222 inline unsigned getLoopDepth(const BasicBlock *BB) const {
23 mapunsigned>::const_iterator I = LoopDepth.find(BB);
23 std::mapunsigned>::const_iterator I = LoopDepth.find(BB);
2424 return I != LoopDepth.end() ? I->second : 0;
2525 }
2626 };
2424 //
2525 class Loop {
2626 Loop *ParentLoop;
27 vector Blocks; // First entry is the header node
28 vector SubLoops; // Loops contained entirely within this one
27 std::vector Blocks; // First entry is the header node
28 std::vector SubLoops; // Loops contained entirely within this one
2929 unsigned LoopDepth; // Nesting depth of this loop
3030
3131 Loop(const Loop &); // DO NOT IMPLEMENT
3939 bool contains(const BasicBlock *BB) const;
4040
4141 // getSubLoops - Return the loops contained entirely within this loop
42 inline const vector &getSubLoops() const { return SubLoops; }
43 inline const vector &getBlocks() const { return Blocks; }
42 inline const std::vector &getSubLoops() const { return SubLoops; }
43 inline const std::vector &getBlocks() const {
44 return Blocks;
45 }
4446
4547 private:
4648 friend class LoopInfo;
6163 //
6264 class LoopInfo {
6365 // BBMap - Mapping of basic blocks to the inner most loop they occur in
64 map BBMap;
65 vector TopLevelLoops;
66 std::map BBMap;
67 std::vector TopLevelLoops;
6668 public:
6769 // LoopInfo ctor - Calculate the natural loop information for a CFG
6870 LoopInfo(const DominatorSet &DS);
6971
70 const vector &getTopLevelLoops() const { return TopLevelLoops; }
72 const std::vector &getTopLevelLoops() const { return TopLevelLoops; }
7173
7274 // getLoopFor - Return the inner most loop that BB lives in. If a basic block
7375 // is in no loop (for example the entry node), null is returned.
7476 //
7577 const Loop *getLoopFor(const BasicBlock *BB) const {
76 map::const_iterator I = BBMap.find(BB);
78 std::map::const_iterator I = BBMap.find(BB);
7779 return I != BBMap.end() ? I->second : 0;
7880 }
7981 inline const Loop *operator[](const BasicBlock *BB) const {
7777 virtual bool processInstruction(const Instruction *I) { return false; }
7878
7979 private:
80 bool handleType(set &TypeSet, const Type *T);
80 bool handleType(std::set &TypeSet, const Type *T);
8181 };
8282
8383 #endif
2222 const Module *TheModule;
2323 bool IgnoreNamedNodes; // Shall we not count named nodes?
2424
25 typedef vector TypePlane;
26 vector Table;
27 map NodeMap;
25 typedef std::vector TypePlane;
26 std::vector Table;
27 std::map NodeMap;
2828
2929 // ModuleLevel - Used to keep track of which values belong to the module,
3030 // and which values belong to the currently incorporated method.
3131 //
32 vector ModuleLevel;
32 std::vector ModuleLevel;
3333
3434 public:
3535 SlotCalculator(const Module *M, bool IgnoreNamed);
2121 // error messages corresponding to the problem are added to the errorMsgs
2222 // vectors, and a value of true is returned.
2323 //
24 bool verify(const Module *M, vector &ErrorMsgs);
25 bool verify(const Method *M, vector<string> &ErrorMsgs);
24 bool verify(const Module *M, std::vectorstring> &ErrorMsgs);
25 bool verify(const Method *M, std::vector &ErrorMsgs);
2626
2727 #endif
1515 class Interval;
1616 class IntervalPartition;
1717
18 void WriteToOutput(const Interval *I, ostream &o);
19 inline ostream &operator <<(ostream &o, const Interval *I) {
18 void WriteToOutput(const Interval *I, std::ostream &o);
19 inline std::ostream &operator <<(std::ostream &o, const Interval *I) {
2020 WriteToOutput(I, o); return o;
2121 }
2222
23 void WriteToOutput(const IntervalPartition &IP, ostream &o);
24 inline ostream &operator <<(ostream &o, const IntervalPartition &IP) {
23 void WriteToOutput(const IntervalPartition &IP, std::ostream &o);
24 inline std::ostream &operator <<(std::ostream &o,
25 const IntervalPartition &IP) {
2526 WriteToOutput(IP, o); return o;
2627 }
2728
3132 class DominatorTree;
3233 class DominanceFrontier;
3334
34 void WriteToOutput(const DominatorSet &, ostream &o);
35 inline ostream &operator <<(ostream &o, const DominatorSet &DS) {
35 void WriteToOutput(const DominatorSet &, std::ostream &o);
36 inline std::ostream &operator <<(std::ostream &o, const DominatorSet &DS) {
3637 WriteToOutput(DS, o); return o;
3738 }
3839
39 void WriteToOutput(const ImmediateDominators &, ostream &o);
40 inline ostream &operator <<(ostream &o, const ImmediateDominators &ID) {
40 void WriteToOutput(const ImmediateDominators &, std::ostream &o);
41 inline std::ostream &operator <<(std::ostream &o,
42 const ImmediateDominators &ID) {
4143 WriteToOutput(ID, o); return o;
4244 }
4345
44 void WriteToOutput(const DominatorTree &, ostream &o);
45 inline ostream &operator <<(ostream &o, const DominatorTree &DT) {
46 void WriteToOutput(const DominatorTree &, std::ostream &o);
47 inline std::ostream &operator <<(std::ostream &o, const DominatorTree &DT) {
4648 WriteToOutput(DT, o); return o;
4749 }
4850
49 void WriteToOutput(const DominanceFrontier &, ostream &o);
50 inline ostream &operator <<(ostream &o, const DominanceFrontier &DF) {
51 void WriteToOutput(const DominanceFrontier &, std::ostream &o);
52 inline std::ostream &operator <<(std::ostream &o,
53 const DominanceFrontier &DF) {
5154 WriteToOutput(DF, o); return o;
5255 }
5356
5558 class CallGraph;
5659 class CallGraphNode;
5760
58 void WriteToOutput(const CallGraph &, ostream &o);
59 inline ostream &operator <<(ostream &o, const CallGraph &CG) {
61 void WriteToOutput(const CallGraph &, std::ostream &o);
62 inline std::ostream &operator <<(std::ostream &o, const CallGraph &CG) {
6063 WriteToOutput(CG, o); return o;
6164 }
6265
63 void WriteToOutput(const CallGraphNode *, ostream &o);
64 inline ostream &operator <<(ostream &o, const CallGraphNode *CGN) {
66 void WriteToOutput(const CallGraphNode *, std::ostream &o);
67 inline std::ostream &operator <<(std::ostream &o, const CallGraphNode *CGN) {
6568 WriteToOutput(CGN, o); return o;
6669 }
6770
6972 class Loop;
7073 class LoopInfo;
7174
72 void WriteToOutput(const LoopInfo &, ostream &o);
73 inline ostream &operator <<(ostream &o, const LoopInfo &LI) {
75 void WriteToOutput(const LoopInfo &, std::ostream &o);
76 inline std::ostream &operator <<(std::ostream &o, const LoopInfo &LI) {
7477 WriteToOutput(LI, o); return o;
7578 }
7679
77 void WriteToOutput(const Loop *, ostream &o);
78 inline ostream &operator <<(ostream &o, const Loop *L) {
80 void WriteToOutput(const Loop *, std::ostream &o);
81 inline std::ostream &operator <<(std::ostream &o, const Loop *L) {
7982 WriteToOutput(L, o); return o;
8083 }
8184
8285 } // End namespace CFG
8386
8487 class InductionVariable;
85 void WriteToOutput(const InductionVariable &, ostream &o);
86 inline ostream &operator <<(ostream &o, const InductionVariable &IV) {
88 void WriteToOutput(const InductionVariable &, std::ostream &o);
89 inline std::ostream &operator <<(std::ostream &o, const InductionVariable &IV) {
8790 WriteToOutput(IV, o); return o;
8891 }
8992
165165 //===--------------------------------------------------------------------===//
166166 // Basic ID <-> Name map functionality
167167
168 static AnnotationID getID (const string &Name); // Name -> ID
169 static const string &getName(AnnotationID ID); // ID -> Name
168 static AnnotationID getID(const std::string &Name); // Name -> ID
169 static const std::string &getName(AnnotationID ID); // ID -> Name
170170
171171 // getID - Name -> ID + registration of a factory function for demand driven
172172 // annotation support.
173 static AnnotationID getID (const string &Name, Factory Fact, void *Data=0);
173 static AnnotationID getID(const std::string &Name, Factory Fact,
174 void *Data = 0);
174175
175176 //===--------------------------------------------------------------------===//
176177 // Annotation creation on demand support...
1010 #define LLVM_ASSEMBLY_CACHED_WRITER_H
1111
1212 #include "llvm/Assembly/Writer.h"
13 #include
1314
1415 class AssemblyWriter; // Internal private class
1516 class SlotCalculator;
1819 AssemblyWriter *AW;
1920 SlotCalculator *SC;
2021 public:
21 ostream &Out;
22 std::ostream &Out;
2223 public:
23 CachedWriter(ostream &O = cout) : AW(0), SC(0), Out(O) { }
24 CachedWriter(const Module *M, ostream &O = cout) : AW(0), SC(0), Out(O) {
24 CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { }
25 CachedWriter(const Module *M, std::ostream &O = std::cout)
26 : AW(0), SC(0), Out(O) {
2527 setModule(M);
2628 }
2729 ~CachedWriter();
6264 return *this << (const Value*)X;
6365 }
6466
65 inline CachedWriter &operator<<(ostream &(&Manip)(ostream &)) {
67 inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
6668 Out << Manip; return *this;
6769 }
6870
1515 // The useful interface defined by this file... Parse an ascii file, and return
1616 // the internal representation in a nice slice'n'dice'able representation.
1717 //
18 Module *ParseAssemblyFile(const string &Filename);// throw (ParseException);
18 Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException)
1919
2020 //===------------------------------------------------------------------------===
2121 // Helper Classes
2626 //
2727 class ParseException {
2828 public:
29 ParseException(const string &filename, const string &message,
29 ParseException(const std::string &filename, const std::string &message,
3030 int LineNo = -1, int ColNo = -1);
3131
3232 ParseException(const ParseException &E);
3434 // getMessage - Return the message passed in at construction time plus extra
3535 // information extracted from the options used to parse with...
3636 //
37 const string getMessage() const;
37 const std::string getMessage() const;
3838
39 inline const string getRawMessage() const { // Just the raw message...
39 inline const std::string &getRawMessage() const { // Just the raw message...
4040 return Message;
4141 }
4242
43 inline const string &getFilename() const {
43 inline const std::string &getFilename() const {
4444 return Filename;
4545 }
4646
5454 }
5555
5656 private :
57 string Filename;
58 string Message;
57 std::string Filename;
58 std::string Message;
5959 int LineNo, ColumnNo; // -1 if not relevant
6060
6161 ParseException &operator=(const ParseException &E); // objects by reference
99
1010 #include "llvm/Pass.h"
1111 #include "llvm/Assembly/Writer.h"
12 #include
1213
1314 class PrintModulePass : public Pass {
14 string Banner; // String to print before each method
15 ostream *Out; // ostream to print on
15 std::string Banner; // String to print before each method
16 std::ostream *Out; // ostream to print on
1617 bool DeleteStream; // Delete the ostream in our dtor?
1718 bool PrintPerMethod; // Print one method at a time rather than the whole?
1819 public:
19 inline PrintModulePass(const string &B, ostream *o = &cout,
20 inline PrintModulePass(const std::string &B, std::ostream *o = &std::cout,
2021 bool DS = false,
2122 bool printPerMethod = true)
2223 : Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
2929 // representation of an object into an ascii bytestream that the parser can
3030 // understand later... (the parser only understands whole classes though)
3131 //
32 void WriteToAssembly(const Module *Module, ostream &o);
33 void WriteToAssembly(const GlobalVariable *G, ostream &o);
34 void WriteToAssembly(const Method *Method, ostream &o);
35 void WriteToAssembly(const BasicBlock *BB, ostream &o);
36 void WriteToAssembly(const Instruction *In, ostream &o);
37 void WriteToAssembly(const Constant *V, ostream &o);
32 void WriteToAssembly(const Module *Module, std::ostream &o);
33 void WriteToAssembly(const GlobalVariable *G, std::ostream &o);
34 void WriteToAssembly(const Method *Method, std::ostream &o);
35 void WriteToAssembly(const BasicBlock *BB, std::ostream &o);
36 void WriteToAssembly(const Instruction *In, std::ostream &o);
37 void WriteToAssembly(const Constant *V, std::ostream &o);
3838
3939 // WriteTypeSymbolic - This attempts to write the specified type as a symbolic
4040 // type, iff there is an entry in the modules symbol table for the specified
4141 // type or one of it's component types. This is slower than a simple x << Type;
4242 //
43 ostream &WriteTypeSymbolic(ostream &o, const Type *Ty, const Module *Module);
43 std::ostream &WriteTypeSymbolic(std::ostream &, const Type *, const Module *M);
4444
4545
4646 // WriteAsOperand - Write the name of the specified value out to the specified
4747 // ostream. This can be useful when you just want to print int %reg126, not the
4848 // whole instruction that generated it.
4949 //
50 ostream &WriteAsOperand(ostream &o, const Value *V, bool PrintType = true,
51 bool PrintName = true, SlotCalculator *Table = 0);
50 std::ostream &WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true,
51 bool PrintName = true, SlotCalculator *Table = 0);
5252
5353
5454 // WriteToVCG - Dump the specified structure to a VCG file. If method is
5656 // family of files with a common base name is created, with a method name
5757 // suffix.
5858 //
59 void WriteToVCG(const Module *Module, const string &Filename);
60 void WriteToVCG(const Method *Method, const string &Filename);
59 void WriteToVCG(const Module *Module, const std::string &Filename);
60 void WriteToVCG(const Method *Method, const std::string &Filename);
6161
6262
6363
6565 // Define operator<< to work on the various classes that we can send to an
6666 // ostream...
6767 //
68 inline ostream &operator<<(ostream &o, const Module *C) {
68 inline std::ostream &operator<<(std::ostream &o, const Module *C) {
6969 WriteToAssembly(C, o); return o;
7070 }
7171
72 inline ostream &operator<<(ostream &o, const GlobalVariable *G) {
72 inline std::ostream &operator<<(std::ostream &o, const GlobalVariable *G) {
7373 WriteToAssembly(G, o); return o;
7474 }
7575
76 inline ostream &operator<<(ostream &o, const Method *M) {
76 inline std::ostream &operator<<(std::ostream &o, const Method *M) {
7777 WriteToAssembly(M, o); return o;
7878 }
7979
80 inline ostream &operator<<(ostream &o, const BasicBlock *B) {
80 inline std::ostream &operator<<(std::ostream &o, const BasicBlock *B) {
8181 WriteToAssembly(B, o); return o;
8282 }
8383
84 inline ostream &operator<<(ostream &o, const Instruction *I) {
84 inline std::ostream &operator<<(std::ostream &o, const Instruction *I) {
8585 WriteToAssembly(I, o); return o;
8686 }
8787
88 inline ostream &operator<<(ostream &o, const Constant *I) {
88 inline std::ostream &operator<<(std::ostream &o, const Constant *I) {
8989 WriteToAssembly(I, o); return o;
9090 }
9191
9292
93 inline ostream &operator<<(ostream &o, const Type *T) {
93 inline std::ostream &operator<<(std::ostream &o, const Type *T) {
9494 if (!T) return o << "";
9595 return o << T->getDescription();
9696 }
9797
98 inline ostream &operator<<(ostream &o, const Value *I) {
98 inline std::ostream &operator<<(std::ostream &o, const Value *I) {
9999 switch (I->getValueType()) {
100100 case Value::TypeVal: return o << cast(I);
101101 case Value::ConstantVal: WriteToAssembly(cast(I) , o); break;
4848 // Instruction iterators...
4949 typedef InstListType::iterator iterator;
5050 typedef InstListType::const_iterator const_iterator;
51 typedef reverse_iterator const_reverse_iterator;
52 typedef reverse_iterator reverse_iterator;
51 typedef std::reverse_iterator const_reverse_iterator;
52 typedef std::reverse_iterator reverse_iterator;
5353
5454 // Predecessor and successor iterators...
5555 typedef PredIterator pred_iterator;
6060 const BasicBlock> succ_const_iterator;
6161
6262 // Ctor, dtor
63 BasicBlock(const string &Name = "", Method *Parent = 0);
63 BasicBlock(const std::string &Name = "", Method *Parent = 0);
6464 ~BasicBlock();
6565
6666 // Specialize setName to take care of symbol table majik
67 virtual void setName(const string &name, SymbolTable *ST = 0);
67 virtual void setName(const std::string &name, SymbolTable *ST = 0);
6868
6969 // getParent - Return the enclosing method, or null if none
7070 const Method *getParent() const { return InstList.getParent(); }
115115 }
116116
117117 static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
118 string &Result, bool Aligned = true) {
118 std::string &Result, bool Aligned = true) {
119119 unsigned Size;
120120 if (read_vbr(Buf, EndBuf, Size)) return true; // Failure reading size?
121121 if (Buf+Size > EndBuf) return true; // Size invalid?
122122
123 Result = string((char*)Buf, Size);
123 Result = std::string((char*)Buf, Size);
124124 Buf += Size;
125125
126126 if (Aligned) // If we should stay aligned do so...
156156 // string... note that this should be inlined always so only the relevant IF
157157 // body should be included...
158158 //
159 static inline void output(unsigned i, deque &Out, int pos = -1){
159 static inline void output(unsigned i, std::deque &Out,
160 int pos = -1) {
160161 #ifdef LITTLE_ENDIAN
161162 if (pos == -1)
162163 Out.insert(Out.end(), (unsigned char*)&i, (unsigned char*)&i+4);
177178 #endif
178179 }
179180
180 static inline void output(int i, deque &Out) {
181 static inline void output(int i, std::deque &Out) {
181182 output((unsigned)i, Out);
182183 }
183184
190191 //
191192 // Note that using this may cause the output buffer to become unaligned...
192193 //
193 static inline void output_vbr(uint64_t i, deque &out) {
194 static inline void output_vbr(uint64_t i, std::deque &out) {
194195 while (1) {
195196 if (i < 0x80) { // done?
196197 out.push_back((unsigned char)i); // We know the high bit is clear...
204205 }
205206 }
206207
207 static inline void output_vbr(unsigned i, deque &out) {
208 static inline void output_vbr(unsigned i, std::deque &out) {
208209 while (1) {
209210 if (i < 0x80) { // done?
210211 out.push_back((unsigned char)i); // We know the high bit is clear...
218219 }
219220 }
220221
221 static inline void output_vbr(int64_t i, deque &out) {
222 static inline void output_vbr(int64_t i, std::deque &out) {
222223 if (i < 0)
223224 output_vbr(((uint64_t)(-i) << 1) | 1, out); // Set low order sign bit...
224225 else
226227 }
227228
228229
229 static inline void output_vbr(int i, deque &out) {
230 static inline void output_vbr(int i, std::deque &out) {
230231 if (i < 0)
231232 output_vbr(((unsigned)(-i) << 1) | 1, out); // Set low order sign bit...
232233 else
236237 // align32 - emit the minimal number of bytes that will bring us to 32 bit
237238 // alignment...
238239 //
239 static inline void align32(deque &Out) {
240 static inline void align32(std::deque &Out) {
240241 int NumPads = (4-(Out.size() & 3)) & 3; // Bytes to get padding to 32 bits
241242 while (NumPads--) Out.push_back((unsigned char)0xAB);
242243 }
243244
244 static inline void output(const string &s, deque &Out,
245 static inline void output(const std::string &s, std::deque &Out,
245246 bool Aligned = true) {
246247 unsigned Len = s.length();
247248 output_vbr(Len, Out); // Strings may have an arbitrary length...
252253 }
253254
254255 static inline void output_data(void *Ptr, void *End,
255 deque &Out, bool Align = false) {
256 std::deque &Out,
257 bool Align = false) {
256258 #ifdef LITTLE_ENDIAN
257259 Out.insert(Out.end(), (unsigned char*)Ptr, (unsigned char*)End);
258260 #else
1717
1818 // Parse and return a class...
1919 //
20 Module *ParseBytecodeFile(const string &Filename, string *ErrorStr = 0);
20 Module *ParseBytecodeFile(const std::string &Filename,
21 std::string *ErrorStr = 0);
2122 Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize,
22 string *ErrorStr = 0);
23 std::string *ErrorStr = 0);
2324
2425 #endif
2626 #include "llvm/Instruction.h"
2727 #include "Support/NonCopyable.h"
2828 #include "Support/HashExtras.h"
29 #include
30 #include <hash_set>
29 #include <ext/hash_set>
3130
3231 class Constant;
3332 class BasicBlock;
238237 //
239238 //------------------------------------------------------------------------
240239
241 class InstrForest : private hash_map {
240 class InstrForest : private std::hash_map {
242241 private:
243 hash_set treeRoots;
242 std::hash_set treeRoots;
244243
245244 public:
246245 /*ctor*/ InstrForest (Method *M);
250249 return (*this)[instr];
251250 }
252251
253 inline const hash_set &getRootSet() const {
252 inline const std::hash_set &getRootSet() const {
254253 return treeRoots;
255254 }
256255
8383 public:
8484 // Constructor that uses the type of S1 as the type of the temporary.
8585 // s1 must be a valid value. s2 may be NULL.
86 TmpInstruction(OtherOps opcode, Value *s1, Value* s2, const string &name="")
86 TmpInstruction(OtherOps opcode, Value *s1, Value* s2,
87 const std::string &name = "")
8788 : Instruction(s1->getType(), opcode, name)
8889 {
8990 assert(s1 != NULL && "Use different constructor if both operands are 0");
9394 // Constructor that allows the type of the temporary to be specified.
9495 // Both S1 and S2 may be NULL.
9596 TmpInstruction(OtherOps opcode, const Type* tmpType,
96 Value *s1, Value* s2, const string &name = "")
97 Value *s1, Value* s2, const std::string &name = "")
9798 : Instruction(tmpType, opcode, name)
9899 {
99100 Initialize(opcode, s1, s2);
2222 class TmpInstruction;
2323 class Constant;
2424 class TargetMachine;
25
26 //************************ Exported Functions ******************************/
2725
2826
2927 //---------------------------------------------------------------------------
5351 //---------------------------------------------------------------------------
5452
5553 Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
56 vector& chainIdxVec);
54 std::vector& chainIdxVec);
5755
5856
5957 //------------------------------------------------------------------------
129127 // fall under case 3; these must be inserted before `minstr'.
130128 //---------------------------------------------------------------------------
131129
132 vector FixConstantOperandsForInstr (Instruction* vmInstr,
133 MachineInstr* minstr,
134 TargetMachine& target);
135
136
137 //**************************************************************************/
130 std::vector FixConstantOperandsForInstr (Instruction* vmInstr,
131 MachineInstr* minstr,
132 TargetMachine& target);
138133
139134 #endif
None /* Title: InterferenceGraph.h
0 /* Title: InterferenceGraph.h -*- C++ -*-
11 Author: Ruchira Sasanka
22 Date: July 20, 01
33 Purpose: Interference Graph used for register coloring.
2323
2424 #include "llvm/CodeGen/IGNode.h"
2525
26 typedef vector IGNodeListType;
26 typedef std::vector IGNodeListType;
2727
2828
2929 class InterferenceGraph
4646 // to create it after adding all IGNodes to the IGNodeList
4747
4848 InterferenceGraph(RegClass *const RC);
49 ~InterferenceGraph();
50
4951 void createGraph();
5052
5153 void addLRToIG(LiveRange *const LR);
6466
6567 void printIG() const;
6668 void printIGNodeList() const;
67
68 ~InterferenceGraph();
69
70
7169 };
7270
73
7471 #endif
75
2121 #include "llvm/Annotation.h"
2222 #include "llvm/Method.h"
2323 #include
24 #include
25 #include
2624 #include
2725
2826 template class ValOpIterator;
130128 }
131129
132130 public:
133 friend ostream& operator<<(ostream& os, const MachineOperand& mop);
131 friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
134132
135133
136134 private:
261259 private:
262260 MachineOpCode opCode;
263261 OpCodeMask opCodeMask; // extra bits for variants of an opcode
264 vector operands;
265 vector implicitRefs; // values implicitly referenced by this
266 vector implicitIsDef; // machine instruction (eg, call args)
262 std::vector operands;
263 std::vector implicitRefs; // values implicitly referenced by this
264 std::vector implicitIsDef; // machine instruction (eg, call args)
267265
268266 public:
269267 typedef ValOpIterator val_const_op_iterator;
305303
306304
307305 public:
308 friend ostream& operator<<(ostream& os, const MachineInstr& minstr);
309 friend val_const_op_iterator;
310 friend val_op_iterator;
306 friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr);
307 friend class val_const_op_iterator;
308 friend class val_op_iterator;
311309
312310 public:
313311 // Access to set the operands when building the machine instruction
448446 //
449447 //---------------------------------------------------------------------------
450448
451 class MachineCodeForVMInstr: public vector
452 {
453 private:
454 vector tempVec; // used by m/c instr but not VM instr
449 class MachineCodeForVMInstr: public std::vector
450 {
451 private:
452 std::vector tempVec; // used by m/c instr but not VM instr
455453
456454 public:
457455 /*ctor*/ MachineCodeForVMInstr () {}
458456 /*ctor*/ ~MachineCodeForVMInstr ();
459457
460 const vector& getTempValues () const { return tempVec; }
461 vector& getTempValues () { return tempVec; }
458 const std::vector& getTempValues () const { return tempVec; }
459 std::vector& getTempValues () { return tempVec; }
462460
463461 void addTempValue (Value* val) { tempVec.push_back(val); }
464462
498496 //---------------------------------------------------------------------------
499497
500498
501 class MachineCodeForBasicBlock: public vector {
502 public:
503 typedef vector::iterator iterator;
504 typedef vector::const_iterator const_iterator;
499 class MachineCodeForBasicBlock: public std::vector {
500 public:
501 typedef std::vector::iterator iterator;
502 typedef std::vector::const_iterator const_iterator;
505503 };
506504
507505
528526 unsigned currentOptionalArgsSize;
529527 unsigned maxOptionalArgsSize;
530528 unsigned currentTmpValuesSize;
531 hash_set constantsForConstPool;
532 hash_map offsets;
529 std::hash_set constantsForConstPool;
530 std::hash_map offsets;
533531 // hash_map offsetsFromSP;
534532
535533 public:
571569 inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
572570 inline unsigned getCurrentOptionalArgsSize() const
573571 { return currentOptionalArgsSize;}
574 inline const hash_set&
572 inline const std::hash_set&
575573 getConstantPoolValues() const {return constantsForConstPool;}
576574
577575 //
627625 //---------------------------------------------------------------------------
628626
629627
630 ostream& operator<< (ostream& os, const MachineInstr& minstr);
631
632
633 ostream& operator<< (ostream& os, const MachineOperand& mop);
628 std::ostream& operator<< (std::ostream& os, const MachineInstr& minstr);
629
630
631 std::ostream& operator<< (std::ostream& os, const MachineOperand& mop);
634632
635633
636634 void PrintMachineInstructions(const Method *method);
1212 #include "llvm/Target/TargetMachine.h"
1313 #include "llvm/Target/MachineRegInfo.h"
1414 #include
15 #include
1516
16 typedef vector ReservedColorListType;
17 typedef std::vector ReservedColorListType;
1718
1819
1920 //-----------------------------------------------------------------------------
4546
4647 InterferenceGraph IG; // Interference graph - constructed by
4748 // buildInterferenceGraph
48 stack IGNodeStack; // the stack used for coloring
49 std::stack IGNodeStack; // the stack used for coloring
4950
5051 const ReservedColorListType *const ReservedColorList;
5152 //
116117
117118
118119 inline void printIGNodeList() const {
119 cerr << "IG Nodes for Register Class " << RegClassID << ":" << endl;
120 std::cerr << "IG Nodes for Register Class " << RegClassID << ":" << "\n";
120121 IG.printIGNodeList();
121122 }
122123
123124 inline void printIG() {
124 cerr << "IG for Register Class " << RegClassID << ":" << endl;
125 std::cerr << "IG for Register Class " << RegClassID << ":" << "\n";
125126 IG.printIG();
126127 }
127
128128 };
129129
130
131
132
133
134
135
136130 #endif
None /* Title: ValueSet.h
0 /* Title: ValueSet.h -*- C++ -*-
11 Author: Ruchira Sasanka
22 Date: Jun 30, 01
33 Purpose: Contains a mathematical set of Values. LiveVarSet is derived from
77 #ifndef VALUE_SET_H
88 #define VALUE_SET_H
99
10 #include
11
12 #include
13 #include
14 //#include
15 #include
16
17 #include "llvm/Value.h"
18
19
20 //------------------------ Support functions ---------------------------------
21
22 struct hashFuncValue { // sturcture containing the hash func
23 inline size_t operator () (const Value *const val) const
24 { return (size_t) val; }
25 };
26
27
10 class Value;
11 #include "Support/HashExtras.h"
12 #include
2813
2914 //------------------- Class Definition for ValueSet --------------------------
3015
3217
3318
3419
35 class ValueSet : public hash_set
36 {
37
20 class ValueSet : public std::hash_set {
3821 public:
39 ValueSet(); // constructor
40
4122 inline void add(const Value *const val)
4223 { assert( val ); insert(val);} // for adding a live variable to set
4324
3535 void destroyConstantImpl();
3636 public:
3737 // Specialize setName to handle symbol table majik...
38 virtual void setName(const string &name, SymbolTable *ST = 0);
39
40 virtual string getStrValue() const = 0;
38 virtual void setName(const std::string &name, SymbolTable *ST = 0);
39
40 virtual std::string getStrValue() const = 0;
4141
4242 // Static constructor to get a '0' constant of arbitrary type...
4343 static Constant *getNullConstant(const Type *Ty);
7777 // inverted - Return the opposite value of the current value.
7878 inline ConstantBool *inverted() const { return (this==True) ? False : True; }
7979
80 virtual string getStrValue() const;
80 virtual std::string getStrValue() const;
8181 inline bool getValue() const { return Val; }
8282
8383 // isNullValue - Return true if this is the value that would be returned by
148148 public:
149149 static ConstantSInt *get(const Type *Ty, int64_t V);
150150
151 virtual string getStrValue() const;
151 virtual std::string getStrValue() const;
152152
153153 static bool isValueValidForType(const Type *Ty, int64_t V);
154154 inline int64_t getValue() const { return Val.Signed; }
172172 public:
173173 static ConstantUInt *get(const Type *Ty, uint64_t V);
174174
175 virtual string getStrValue() const;
175 virtual std::string getStrValue() const;
176176
177177 static bool isValueValidForType(const Type *Ty, uint64_t V);
178178 inline uint64_t getValue() const { return Val.Unsigned; }
198198 public:
199199 static ConstantFP *get(const Type *Ty, double V);
200200
201 virtual string getStrValue() const;
201 virtual std::string getStrValue() const;
202202
203203 static bool isValueValidForType(const Type *Ty, double V);
204204 inline double getValue() const { return Val; }
222222 class ConstantArray : public Constant {
223223 ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
224224 protected:
225 ConstantArray(const ArrayType *T, const vector &Val);
225 ConstantArray(const ArrayType *T, const std::vector &Val);
226226 ~ConstantArray() {}
227227
228228 virtual void destroyConstant();
229229 public:
230 static ConstantArray *get(const ArrayType *T, const vector &);
231 static ConstantArray *get(const string &Initializer);
230 static ConstantArray *get(const ArrayType *T, const std::vector &);
231 static ConstantArray *get(const std::string &Initializer);
232232
233 virtual string getStrValue() const;
233 virtual std::string getStrValue() const;
234234 inline const ArrayType *getType() const {
235235 return (ArrayType*)Value::getType();
236236 }
237237
238 inline const vector &getValues() const { return Operands; }
238 inline const std::vector &getValues() const { return Operands; }
239239
240240 // isNullValue - Return true if this is the value that would be returned by
241241 // getNullConstant.
256256 class ConstantStruct : public Constant {
257257 ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
258258 protected:
259 ConstantStruct(const StructType *T, const vector &Val);
259 ConstantStruct(const StructType *T, const std::vector &Val);
260260 ~ConstantStruct() {}
261261
262262 virtual void destroyConstant();
263263 public:
264264 static ConstantStruct *get(const StructType *T,
265 const vector &V);
266
267 virtual string getStrValue() const;
265 const std::vector &V);
266
267 virtual std::string getStrValue() const;
268268 inline const StructType *getType() const {
269269 return (StructType*)Value::getType();
270270 }
271271
272 inline const vector &getValues() const { return Operands; }
272 inline const std::vector &getValues() const { return Operands; }
273273
274274 // isNullValue - Return true if this is the value that would be returned by
275275 // getNullConstant.
296296 inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){}
297297 ~ConstantPointer() {}
298298 public:
299 virtual string getStrValue() const = 0;
299 virtual std::string getStrValue() const = 0;
300300 inline const PointerType *getType() const {
301301 return (PointerType*)Value::getType();
302302 }
321321 inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
322322 inline ~ConstantPointerNull() {}
323323 public:
324 virtual string getStrValue() const;
324 virtual std::string getStrValue() const;
325325
326326 static ConstantPointerNull *get(const PointerType *T);
327327
358358 public:
359359 static ConstantPointerRef *get(GlobalValue *GV);
360360
361 virtual string getStrValue() const;
361 virtual std::string getStrValue() const;
362362
363363 const GlobalValue *getValue() const {
364364 return cast(Operands[0].get());
1717 // if I am a type, and I get resolved into a more concrete type.
1818 //
1919 ///// FIXME: kill mutable nonsense when Type's are not const
20 mutable vector AbstractTypeUsers;
20 mutable std::vector AbstractTypeUsers;
2121
2222 char isRefining; // Used for recursive types
2323
9393
9494 class MethodType : public DerivedType {
9595 public:
96 typedef vector > ParamTypes;
96 typedef std::vector > ParamTypes;
9797 private:
9898 PATypeHandle ResultType;
9999 ParamTypes ParamTys;
107107 // defines private constructors and has no friends
108108
109109 // Private ctor - Only can be created by a static member...
110 MethodType(const Type *Result, const vector &Params,
110 MethodType(const Type *Result, const std::vector &Params,
111111 bool IsVarArgs);
112112
113113 public:
129129 //
130130 virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
131131
132 static MethodType *get(const Type *Result, const vector &Params,
132 static MethodType *get(const Type *Result,
133 const std::vector &Params,
133134 bool isVarArg);
134135
135136
179180
180181 class StructType : public CompositeType {
181182 public:
182 typedef vector > ElementTypes;
183 typedef std::vector > ElementTypes;
183184
184185 private:
185186 ElementTypes ETypes; // Element types of struct
193194 // defines private constructors and has no friends
194195
195196 // Private ctor - Only can be created by a static member...
196 StructType(const vector &Types);
197 StructType(const std::vector &Types);
197198
198199 public:
199200 inline const ElementTypes &getElementTypes() const { return ETypes; }
220221 //
221222 virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
222223
223 static StructType *get(const vector &Params);
224 static StructType *get(const std::vector &Params);
224225
225226 // Methods for support type inquiry through isa, cast, and dyn_cast:
226227 static inline bool classof(const StructType *T) { return true; }
2828 // BasicBlock iterators...
2929 typedef BasicBlocksType::iterator iterator;
3030 typedef BasicBlocksType::const_iterator const_iterator;
31 typedef reverse_iterator const_reverse_iterator;
32 typedef reverse_iterator reverse_iterator;
31 typedef std::reverse_iterator const_reverse_iterator;
32 typedef std::reverse_iterator reverse_iterator;
3333
3434 private:
3535
4141 void setParent(Module *parent);
4242
4343 public:
44 Method(const MethodType *Ty, bool isInternal, const string &Name = "");
44 Method(const MethodType *Ty, bool isInternal, const std::string &Name = "");
4545 ~Method();
4646
4747 // Specialize setName to handle symbol table majik...
48 virtual void setName(const string &name, SymbolTable *ST = 0);
48 virtual void setName(const std::string &name, SymbolTable *ST = 0);
4949
5050 const Type *getReturnType() const; // Return the return type of method
5151 const MethodType *getMethodType() const; // Return the MethodType for me
128128 _BB_i_t BB; // BasicBlocksType::iterator
129129 _BI_t BI; // BasicBlock::iterator
130130 public:
131 typedef bidirectional_iterator_tag iterator_category;
132 typedef IIty value_type;
133 typedef unsigned difference_type;
134 typedef BIty pointer;
135 typedef IIty reference;
131 typedef std::bidirectional_iterator_tag iterator_category;
132 typedef IIty value_type;
133 typedef unsigned difference_type;
134 typedef BIty pointer;
135 typedef IIty reference;
136136
137137 template InstIterator(M &m)
138138 : BBs(m.getBasicBlocks()), BB(BBs.begin()) { // begin ctor
1616 GlobalValue(const GlobalValue &); // do not implement
1717 protected:
1818 GlobalValue(const Type *Ty, ValueTy vty, bool hasInternalLinkage,
19 const string &name = "")
19 const std::string &name = "")
2020 : User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {}
2121
2222 bool HasInternalLinkage; // Is this value accessable externally?
2424 bool isConstantGlobal; // Is this a global constant?
2525 public:
2626 GlobalVariable(const Type *Ty, bool isConstant, bool isInternal,
27 Constant *Initializer = 0, const string &Name = "");
27 Constant *Initializer = 0, const std::string &Name = "");
2828 ~GlobalVariable() {}
2929
3030 // Specialize setName to handle symbol table majik...
31 virtual void setName(const string &name, SymbolTable *ST = 0);
31 virtual void setName(const std::string &name, SymbolTable *ST = 0);
3232
3333 // The initializer for the global variable/constant is held by Operands[0] if
3434 // an initializer is specified.
2424 public:
2525 TerminatorInst(Instruction::TermOps iType);
2626 TerminatorInst(const Type *Ty, Instruction::TermOps iType,
27 const string &Name = "");
27 const std::string &Name = "");
2828 inline ~TerminatorInst() {}
2929
3030 // Terminators must implement the methods required by Instruction...
6565 //
6666 static UnaryOperator *create(UnaryOps Op, Value *Source);
6767
68 UnaryOperator(Value *S, UnaryOps iType, const string &Name = "")
68 UnaryOperator(Value *S, UnaryOps iType, const std::string &Name = "")
6969 : Instruction(S->getType(), iType, Name) {
7070 Operands.reserve(1);
7171 Operands.push_back(Use(S, this));
104104 // and the two operands.
105105 //
106106 static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2,
107 const string &Name = "");
107 const std::string &Name = "");
108108
109109 BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
110 const string &Name = "")
110 const std::string &Name = "")
111111 : Instruction(S1->getType(), iType, Name) {
112112 Operands.reserve(2);
113113 Operands.push_back(Use(S1, this));
2424 protected:
2525 unsigned iType; // InstructionType
2626 public:
27 Instruction(const Type *Ty, unsigned iType, const string &Name = "");
27 Instruction(const Type *Ty, unsigned iType, const std::string &Name = "");
2828 virtual ~Instruction(); // Virtual dtor == good.
2929
3030 // Specialize setName to handle symbol table majik...
31 virtual void setName(const string &name, SymbolTable *ST = 0);
31 virtual void setName(const std::string &name, SymbolTable *ST = 0);
3232
3333 // clone() - Create a copy of 'this' instruction that is identical in all ways
3434 // except the following:
1515 // error occurs, true is returned and ErrorMsg (if not null) is set to indicate
1616 // the problem.
1717 //
18 bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0);
18 bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0);
1919
2020 #endif
2121
2525 typedef ValueHolder MethodListType;
2626
2727 // Global Variable iterators...
28 typedef GlobalListType::iterator giterator;
29 typedef GlobalListType::const_iterator const_giterator;
30 typedef reverse_iterator reverse_giterator;
31 typedef reverse_iterator const_reverse_giterator;
28 typedef GlobalListType::iterator giterator;
29 typedef GlobalListType::const_iterator const_giterator;
30 typedef std::reverse_iterator reverse_giterator;
31 typedef std::reverse_iterator const_reverse_giterator;
3232
3333 // Method iterators...
34 typedef MethodListType::iterator iterator;
35 typedef MethodListType::const_iterator const_iterator;
36 typedef reverse_iterator const_reverse_iterator;
37 typedef reverse_iterator reverse_iterator;
34 typedef MethodListType::iterator iterator;
35 typedef MethodListType::const_iterator const_iterator;
36 typedef std::reverse_iterator reverse_iterator;
37 typedef std::reverse_iterator const_reverse_iterator;
3838
3939 private:
4040 GlobalListType GlobalList; // The Global Variables
4444 //
4545
4646 // runAllPasses - Run a bunch of passes on the specified module, efficiently.
47 static bool runAllPasses(Module *M, vector &Passes) {
47 static bool runAllPasses(Module *M, std::vector &Passes) {
4848 bool MadeChanges = false;
4949 // Run all of the pass initializers
5050 for (unsigned i = 0; i < Passes.size(); ++i)
6464 // runAllPassesAndFree - Run a bunch of passes on the specified module,
6565 // efficiently. When done, delete all of the passes.
6666 //
67 static bool runAllPassesAndFree(Module *M, vector &Passes) {
67 static bool runAllPassesAndFree(Module *M, std::vector &Passes) {
6868 // First run all of the passes
6969 bool MadeChanges = runAllPasses(M, Passes);
7070
2222 const Module *TheModule;
2323 bool IgnoreNamedNodes; // Shall we not count named nodes?
2424
25 typedef vector TypePlane;
26 vector Table;
27 map NodeMap;
25 typedef std::vector TypePlane;
26 std::vector Table;
27 std::map NodeMap;
2828
2929 // ModuleLevel - Used to keep track of which values belong to the module,
3030 // and which values belong to the currently incorporated method.
3131 //
32 vector ModuleLevel;
32 std::vector ModuleLevel;
3333
3434 public:
3535 SlotCalculator(const Module *M, bool IgnoreNamed);
165165 //===--------------------------------------------------------------------===//
166166 // Basic ID <-> Name map functionality
167167
168 static AnnotationID getID (const string &Name); // Name -> ID
169 static const string &getName(AnnotationID ID); // ID -> Name
168 static AnnotationID getID(const std::string &Name); // Name -> ID
169 static const std::string &getName(AnnotationID ID); // ID -> Name
170170
171171 // getID - Name -> ID + registration of a factory function for demand driven
172172 // annotation support.
173 static AnnotationID getID (const string &Name, Factory Fact, void *Data=0);
173 static AnnotationID getID(const std::string &Name, Factory Fact,
174 void *Data = 0);
174175
175176 //===--------------------------------------------------------------------===//
176177 // Annotation creation on demand support...
9999 // an argument. Should return true if there was an error processing the
100100 // argument and the program should exit.
101101 //
102 virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0;
102 virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0;
103103
104104 virtual enum NumOccurances getNumOccurancesFlagDefault() const {
105105 return Optional;
145145
146146 // addOccurance - Wrapper around handleOccurance that enforces Flags
147147 //
148 bool addOccurance(const char *ArgName, const string &Value);
148 bool addOccurance(const char *ArgName, const std::string &Value);
149149
150150 // Prints option name followed by message. Always returns true.
151 bool error(string Message, const char *ArgName = 0);
151 bool error(std::string Message, const char *ArgName = 0);
152152
153153 public:
154154 inline int getNumOccurances() const { return NumOccurances; }
161161 //
162162 class Alias : public Option {
163163 Option &AliasFor;
164 virtual bool handleOccurance(const char *ArgName, const string &Arg) {
164 virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
165165 return AliasFor.handleOccurance(AliasFor.ArgStr, Arg);
166166 }
167167 virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
176176 //
177177 class Flag : public Option {
178178 bool Value;
179 virtual bool handleOccurance(const char *ArgName, const string &Arg);
179 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
180180 public:
181181 inline Flag(const char *ArgStr, const char *Message, int Flags = 0,
182182 bool DefaultVal = 0) : Option(ArgStr, Message, Flags),
192192 //
193193 class Int : public Option {
194194 int Value;
195 virtual bool handleOccurance(const char *ArgName, const string &Arg);
195 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
196196 virtual enum ValueExpected getValueExpectedFlagDefault() const {
197197 return ValueRequired;
198198 }
208208 //===----------------------------------------------------------------------===//
209209 // String valued command line option
210210 //
211 class String : public Option, public string {
212 virtual bool handleOccurance(const char *ArgName, const string &Arg);
211 class String : public Option, public std::string {
212 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
213213 virtual enum ValueExpected getValueExpectedFlagDefault() const {
214214 return ValueRequired;
215215 }
216216 public:
217217 inline String(const char *ArgStr, const char *Help, int Flags = 0,
218218 const char *DefaultVal = "")
219 : Option(ArgStr, Help, Flags), string(DefaultVal) {}
220
221 inline const string &operator=(const string &Val) {
222 return string::operator=(Val);
219 : Option(ArgStr, Help, Flags), std::string(DefaultVal) {}
220
221 inline const std::string &operator=(const std::string &Val) {
222 return std::string::operator=(Val);
223223 }
224224 };
225225
227227 //===----------------------------------------------------------------------===//
228228 // String list command line option
229229 //
230 class StringList : public Option, public vector<string> {
230 class StringList : public Option, public std::vectorstring> {
231231
232232 virtual enum NumOccurances getNumOccurancesFlagDefault() const {
233233 return ZeroOrMore;
235235 virtual enum ValueExpected getValueExpectedFlagDefault() const {
236236 return ValueRequired;
237237 }
238 virtual bool handleOccurance(const char *ArgName, const string &Arg);
238 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
239239
240240 public:
241241 inline StringList(const char *ArgStr, const char *Help, int Flags = 0)
255255 // Use a vector instead of a map, because the lists should be short,
256256 // the overhead is less, and most importantly, it keeps them in the order
257257 // inserted so we can print our option out nicely.
258 vectorpair > > ValueMap;
258 std::vectorpair > > ValueMap;
259259
260260 inline EnumBase(const char *ArgStr, const char *Help, int Flags)
261261 : Option(ArgStr, Help, Flags) {}
283283 inline EnumValueBase(int Flags) : EnumBase(Flags) {}
284284
285285 // handleOccurance - Set Value to the enum value specified by Arg
286 virtual bool handleOccurance(const char *ArgName, const string &Arg);
286 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
287287
288288 // Return the width of the option tag for printing...
289289 virtual unsigned getOptionWidth() const;
322322 return ValueDisallowed;
323323 }
324324 protected:
325 virtual bool handleOccurance(const char *ArgName, const string &Arg);
325 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
326326 inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {}
327327
328328 // Return the width of the option tag for printing...
362362 return ValueDisallowed;
363363 }
364364 protected:
365 vector Values; // The options specified so far.
365 std::vector Values; // The options specified so far.
366366
367367 inline EnumListBase(int Flags)
368368 : EnumBase(Flags) {}
369 virtual bool handleOccurance(const char *ArgName, const string &Arg);
369 virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
370370
371371 // Return the width of the option tag for printing...
372372 virtual unsigned getOptionWidth() const;
1515 // error occurs, true is returned and ErrorMsg (if not null) is set to indicate
1616 // the problem.
1717 //
18 bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0);
18 bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0);
1919
2020 #endif
2121
1313 // MangleTypeName - Implement a consistent name-mangling scheme for
1414 // a given type.
1515 //
16 string MangleTypeName(const Type *type);
16 std::string MangleTypeName(const Type *type);
1717
1818 // MangleName - implement a consistent name-mangling scheme for all
1919 // externally visible (i.e., global) objects.
2020 //
2121 // privateName should be unique within the module.
2222 //
23 string MangleName(const string &privateName, const Value *V);
23 std::string MangleName(const std::string &privateName, const Value *V);
2424
2525 #endif
2626
2626 class Type;
2727
2828 class SymbolTable : public AbstractTypeUser,
29 public map > {
29 public std::map
30 std::map > {
3031 public:
31 typedef map VarMap;
32 typedef map super;
32 typedef std::map VarMap;
33 typedef std::map super;
3334 private:
3435
3536 SymbolTable *ParentSymTab;
5051 SymbolTable *getParentSymTab() { return ParentSymTab; }
5152
5253 // lookup - Returns null on failure...
53 Value *lookup(const Type *Ty, const string &name);
54 Value *lookup(const Type *Ty, const std::string &name);
5455
5556 // insert - Add named definition to the symbol table...
5657 inline void insert(Value *N) {
6263 // name... There can be a many to one mapping between names and
6364 // (constant/type)s.
6465 //
65 inline void insert(const string &Name, Value *V) {
66 inline void insert(const std::string &Name, Value *V) {
6667 assert((isa(V) || isa(V)) &&
6768 "Can only insert types and constants here!");
6869 insertEntry(Name, V->getType(), V);
7778 // it (or derived from it) that does not already occur in the symbol table for
7879 // the specified type.
7980 //
80 string getUniqueName(const Type *Ty, const string &BaseName);
81 std::string getUniqueName(const Type *Ty, const std::string &BaseName);
8182
8283 inline unsigned type_size(const Type *TypeID) const {
8384 return find(TypeID)->second.size();
120121 // insertEntry - Insert a value into the symbol table with the specified
121122 // name...
122123 //
123 void insertEntry(const string &Name, const Type *Ty, Value *V);
124 void insertEntry(const std::string &Name, const Type *Ty, Value *V);
124125
125126 // removeEntry - Remove a value from the symbol table...
126127 //
5858
5959
6060 struct MachineInstrDescriptor {
61 string opCodeString; // Assembly language mnemonic for the opcode.
62 int numOperands; // Number of args; -1 if variable #args
63 int resultPos; // Position of the result; -1 if no result
61 std::string opCodeString; // Assembly language mnemonic for the opcode.
62 int numOperands; // Number of args; -1 if variable #args
63 int resultPos; // Position of the result; -1 if no result
6464 unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0.
65 bool immedIsSignExtended; // Is IMMED field sign-extended? If so,
65 bool immedIsSignExtended; // Is IMMED field sign-extended? If so,
6666 // smallest -ve value is -(maxImmedConst+1).
6767 unsigned int numDelaySlots; // Number of delay slots after instruction
6868 unsigned int latency; // Latency in machine cycles
245245 //
246246 virtual void CreateCodeToLoadConst(Value* val,
247247 Instruction* dest,
248 vector& minstrVec,
249 vector& temps) const =0;
248 std::vector& minstrVec,
249 std::vector &) const = 0;
250250
251251 // Create an instruction sequence to copy an integer value `val'
252252 // to a floating point value `dest' by copying to memory and back.
257257 virtual void CreateCodeToCopyIntToFloat(Method* method,
258258 Value* val,
259259 Instruction* dest,
260 vector& minstrVec,
261 vector& tempVec,
260 std::vector& minstVec,
261 std::vector& tmpVec,
262262 TargetMachine& target) const = 0;
263263
264264 // Similarly, create an instruction sequence to copy an FP value
268268 virtual void CreateCodeToCopyFloatToInt(Method* method,
269269 Value* val,
270270 Instruction* dest,
271 vector& minstrVec,
272 vector& tempVec,
271 std::vector& minstVec,
272 std::vector& tmpVec,
273273 TargetMachine& target) const = 0;
274274
275275
278278 CreateCopyInstructionsByType(const TargetMachine& target,
279279 Value* src,
280280 Instruction* dest,
281 vector& minstrVec) const = 0;
282
283
284
281 std::vector& minstrVec) const = 0;
285282 };
286283
287284 #endif
2727
2828 protected:
2929 unsigned int numLevels;
30 vector cacheLineSizes;
31 vector cacheSizes;
32 vector cacheAssoc;
30 std::vector cacheLineSizes;
31 std::vector cacheSizes;
32 std::vector cacheAssoc;
3333
3434 public:
3535 /*ctor*/ MachineCacheInfo (const TargetMachine& tgt);
3030
3131 static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *);
3232 public:
33 TargetData(const string &TargetName, unsigned char PtrSize = 8,
33 TargetData(const std::string &TargetName, unsigned char PtrSize = 8,
3434 unsigned char PtrAl = 8, unsigned char DoubleAl = 8,
3535 unsigned char FloatAl = 4, unsigned char LongAl = 8,
3636 unsigned char IntAl = 4, unsigned char ShortAl = 2,
6060 // stores that include the implicit form of getelementptr.
6161 //
6262 unsigned getIndexedOffset(const Type *Ty,
63 const vector &Indices) const;
63 const std::vector &Indices) const;
6464
6565 inline const StructLayout *getStructLayout(const StructType *Ty) const {
6666 return (const StructLayout*)((const Type*)Ty)->getOrCreateAnnotation(AID);
7272 // TargetData structure.
7373 //
7474 struct StructLayout : public Annotation {
75 vector MemberOffsets;
75 std::vector MemberOffsets;
7676 unsigned StructSize;
7777 unsigned StructAlignment;
7878 private:
5858
5959
6060 struct MachineInstrDescriptor {
61 string opCodeString; // Assembly language mnemonic for the opcode.
62 int numOperands; // Number of args; -1 if variable #args
63 int resultPos; // Position of the result; -1 if no result
61 std::string opCodeString; // Assembly language mnemonic for the opcode.
62 int numOperands; // Number of args; -1 if variable #args
63 int resultPos; // Position of the result; -1 if no result
6464 unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0.
65 bool immedIsSignExtended; // Is IMMED field sign-extended? If so,
65 bool immedIsSignExtended; // Is IMMED field sign-extended? If so,
6666 // smallest -ve value is -(maxImmedConst+1).
6767 unsigned int numDelaySlots; // Number of delay slots after instruction
6868 unsigned int latency; // Latency in machine cycles
245245 //
246246 virtual void CreateCodeToLoadConst(Value* val,
247247 Instruction* dest,
248 vector& minstrVec,
249 vector& temps) const =0;
248 std::vector& minstrVec,
249 std::vector &) const = 0;
250250
251251 // Create an instruction sequence to copy an integer value `val'
252252 // to a floating point value `dest' by copying to memory and back.
257257 virtual void CreateCodeToCopyIntToFloat(Method* method,
258258 Value* val,
259259 Instruction* dest,
260 vector& minstrVec,
261 vector& tempVec,
260 std::vector& minstVec,
261 std::vector& tmpVec,
262262 TargetMachine& target) const = 0;
263263
264264 // Similarly, create an instruction sequence to copy an FP value
268268 virtual void CreateCodeToCopyFloatToInt(Method* method,
269269 Value* val,
270270 Instruction* dest,
271 vector& minstrVec,
272 vector& tempVec,
271 std::vector& minstVec,
272 std::vector& tmpVec,
273273 TargetMachine& target) const = 0;
274274
275275
278278 CreateCopyInstructionsByType(const TargetMachine& target,
279279 Value* src,
280280 Instruction* dest,
281 vector& minstrVec) const = 0;
282
283
284
281 std::vector& minstrVec) const = 0;
285282 };
286283
287284 #endif
3737
3838 class TargetMachine : public NonCopyableV {
3939 public:
40 const string TargetName;
40 const std::string TargetName;
4141 const TargetData DataLayout; // Calculates type size & alignment
4242 int optSizeForSubWordData;
4343 int minMemOpWordSize;
4444 int maxAtomicMemOpWordSize;
4545
4646 protected:
47 TargetMachine(const string &targetname, // Can only create subclasses...
47 TargetMachine(const std::string &targetname, // Can only create subclasses...
4848 unsigned char PtrSize = 8, unsigned char PtrAl = 8,
4949 unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
5050 unsigned char LongAl = 8, unsigned char IntAl = 4,
8585 // method. The specified method must have been compiled before this may be
8686 // used.
8787 //
88 virtual void emitAssembly(const Module *M, ostream &OutStr) const = 0;
88 virtual void emitAssembly(const Module *M, std::ostream &OutStr) const = 0;
8989 };
9090
9191 #endif
88 #define LLVM_TARGET_MACHINEREGINFO_H
99
1010 #include "Support/NonCopyable.h"
11 #include <hash_map>
11 #include <ext/hash_map>
1212 #include
1313
1414 class TargetMachine;
7575
7676
7777
78 typedef hash_map AddedInstrMapType;
78 typedef std::hash_map AddedInstrMapType;
7979
8080 // A vector of all machine register classes
8181 //
82 typedef vector MachineRegClassArrayType;
82 typedef std::vector MachineRegClassArrayType;
8383
8484
8585 class MachineRegInfo : public NonCopyableV {
127127 LiveRangeInfo & LRI) const = 0;
128128
129129 virtual void suggestRegs4CallArgs(const MachineInstr *const CallI,
130 LiveRangeInfo& LRI, vector RCL) const = 0;
130 LiveRangeInfo& LRI, std::vector RCL) const = 0;
131131
132132 virtual void suggestReg4RetValue(const MachineInstr *const RetI,
133133 LiveRangeInfo& LRI) const = 0;
185185 //
186186 virtual int getUnifiedRegNum(int RegClassID, int reg) const = 0;
187187
188 virtual const string getUnifiedRegName(int UnifiedRegNum) const = 0;
188 virtual const std::string getUnifiedRegName(int UnifiedRegNum) const = 0;
189189
190190
191191 // Gives the type of a register based on the type of the LR
77 #define LLVM_TARGET_MACHINESCHEDINFO_H
88
99 #include "llvm/Target/MachineInstrInfo.h"
10 #include <hash_map>
10 #include <ext/hash_map>
1111
1212 typedef long long cycles_t;
13 const cycles_t HUGE_LATENCY = ~((unsigned long long) 1 << sizeof(cycles_t)-1);
13 const cycles_t HUGE_LATENCY = ~((unsigned long long) 1 << sizeof(cycles_t)-2);
1414 const cycles_t INVALID_LATENCY = -HUGE_LATENCY;
1515 static const unsigned MAX_OPCODE_SIZE = 16;
1616
2727 OpCodePair(); // disable for now
2828 };
2929
30
30 namespace std {
3131 template <> struct hash {
3232 size_t operator()(const OpCodePair& pair) const {
3333 return hash()(pair.val);
3434 }
3535 };
36
36 }
3737
3838 //---------------------------------------------------------------------------
3939 // class MachineResource
4949
5050 class MachineResource {
5151 public:
52 const string rname;
52 const std::string rname;
5353 resourceId_t rid;
5454
55 /*ctor*/ MachineResource(const string& resourceName)
55 /*ctor*/ MachineResource(const std::string& resourceName)
5656 : rname(resourceName), rid(nextId++) {}
5757
5858 private:
6565 public:
6666 int maxNumUsers; // MAXINT if no restriction
6767
68 /*ctor*/ CPUResource(const string& rname, int maxUsers)
68 /*ctor*/ CPUResource(const std::string& rname, int maxUsers)
6969 : MachineResource(rname), maxNumUsers(maxUsers) {}
7070 };
7171
146146 cycles_t numBubbles;
147147
148148 // Feasible slots to use for this instruction.
149 vector feasibleSlots;
149 std::vector feasibleSlots;
150150
151151 // Resource usages for this instruction, with one resource vector per cycle.
152152 cycles_t numCycles;
153 vector<vector > resourcesByCycle;
153 std::vectorvector > resourcesByCycle;
154154
155155 private:
156156 // Conveniences for initializing this structure
242242
243243 // resize the resources vector if more cycles are specified
244244 unsigned maxCycles = this->numCycles;
245 maxCycles = max(maxCycles, delta.startCycle + abs(NC) - 1);
245 maxCycles = std::max(maxCycles, delta.startCycle + abs(NC) - 1);
246246 if (maxCycles > this->numCycles)
247247 {
248248 this->resourcesByCycle.resize(maxCycles);
258258 {
259259 // Look for the resource backwards so we remove the last entry
260260 // for that resource in each cycle.
261 vector& rvec = this->resourcesByCycle[c];
261 std::vector& rvec = this->resourcesByCycle[c];
262262 int r;
263263 for (r = (int) rvec.size(); r >= 0; r--)
264264 if (rvec[r] == delta.resourceId)
348348
349349 inline int getMinIssueGap (MachineOpCode fromOp,
350350 MachineOpCode toOp) const {
351 hash_map::const_iterator
351 std::hash_map::const_iterator
352352 I = issueGaps.find(OpCodePair(fromOp, toOp));
353353 return (I == issueGaps.end())? 0 : (*I).second;
354354 }
355355
356 inline const vector*
356 inline const std::vector*
357357 getConflictList(MachineOpCode opCode) const {
358 hash_mapvector >::const_iterator
358 std::hash_mapvector >::const_iterator
359359 I = conflictLists.find(opCode);
360360 return (I == conflictLists.end())? NULL : & (*I).second;
361361 }
376376 virtual void initializeResources ();
377377
378378 private:
379 void computeInstrResources(const vector& instrRUForClasses);
380 void computeIssueGaps(const vector& instrRUForClasses);
379 void computeInstrResources(const std::vector& instrRUForClasses);
380 void computeIssueGaps(const std::vector& instrRUForClasses);
381381
382382 protected:
383383 int numSchedClasses;
384384 const MachineInstrInfo* mii;
385 const InstrClassRUsage* classRUsages; // raw array by sclass
386 const InstrRUsageDelta* usageDeltas; // raw array [1:numUsageDeltas]
387 const InstrIssueDelta* issueDeltas; // raw array [1:numIssueDeltas]
385 const InstrClassRUsage* classRUsages; // raw array by sclass
386 const InstrRUsageDelta* usageDeltas; // raw array [1:numUsageDeltas]
387 const InstrIssueDelta* issueDeltas; // raw array [1:numIssueDeltas]
388388 unsigned int numUsageDeltas;
389389 unsigned int numIssueDeltas;
390390
391 vector instrRUsages; // indexed by opcode
392 hash_map issueGaps; // indexed by opcode pair
393 hash_map >
394 conflictLists; // indexed by opcode
391 std::vector instrRUsages; // indexed by opcode
392 std::hash_map issueGaps; // indexed by opcode pair
393 std::hash_map >
394 conflictLists; // indexed by opcode
395395 };
396396
397397 #endif
2323
2424 class ConstantMerge : public Pass {
2525 protected:
26 map Constants;
26 std::map Constants;
2727 unsigned LastConstantSeen;
2828 public:
2929 inline ConstantMerge() : LastConstantSeen(0) {}
2727 // incoming slot [or negative if the specified incoming slot should be
2828 // removed].
2929 //
30 typedef pairvector > TransformType;
30 typedef std::pairvector > TransformType;
3131
3232 // Transforms to do for each structure type...
33 map Transforms;
33 std::map Transforms;
3434
3535 // Mapping of old type to new types...
36 map > TypeMap;
36 std::map > TypeMap;
3737
3838 // Mapping from global value of old type, to a global value of the new type...
39 map GlobalMap;
39 std::map GlobalMap;
4040
4141 // Mapping from intra method value to intra method value
42 map LocalValueMap;
42 std::map LocalValueMap;
4343
4444 public:
4545 // Ctor - Take a map that specifies what transformation to do for each field
4848 // the destination structure the field should end up in. A negative value
4949 // indicates that the field should be deleted entirely.
5050 //
51 typedef mapvector > TransformsType;
51 typedef std::mapvector > TransformsType;
5252
5353 MutateStructTypes(const TransformsType &Transforms);
5454
8282 // AdjustIndices - Convert the indexes specifed by Idx to the new changed form
8383 // using the specified OldTy as the base type being indexed into.
8484 //
85 void AdjustIndices(const CompositeType *OldTy, vector &Idx,
85 void AdjustIndices(const CompositeType *OldTy, std::vector &Idx,
8686 unsigned idx = 0);
8787 };
8888
1515 // error occurs, true is returned and ErrorMsg (if not null) is set to indicate
1616 // the problem.
1717 //
18 bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0);
18 bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0);
1919
2020 #endif
2121
7070 private:
7171 PrimitiveID ID; // The current base type of this type...
7272 unsigned UID; // The unique ID number for this class
73 string Desc; // The printed name of the string...
73 std::string Desc; // The printed name of the string...
7474 bool Abstract; // True if type contains an OpaqueType
7575 bool Recursive; // True if the type is recursive
7676
7777 protected:
7878 // ctor is protected, so only subclasses can create Type objects...
79 Type(const string &Name, PrimitiveID id);
79 Type(const std::string &Name, PrimitiveID id);
8080 virtual ~Type() {}
8181
8282 // When types are refined, they update their description to be more concrete.
8383 //
84 inline void setDescription(const string &D) { Desc = D; }
84 inline void setDescription(const std::string &D) { Desc = D; }
8585
8686 // setName - Associate the name with this type in the symbol table, but don't
8787 // set the local name to be equal specified name.
8888 //
89 virtual void setName(const string &Name, SymbolTable *ST = 0);
89 virtual void setName(const std::string &Name, SymbolTable *ST = 0);
9090
9191 // Types can become nonabstract later, if they are refined.
9292 //
115115 inline unsigned getUniqueID() const { return UID; }
116116
117117 // getDescription - Return the string representation of the type...
118 inline const string &getDescription() const { return Desc; }
118 inline const std::string &getDescription() const { return Desc; }
119119
120120 // isSigned - Return whether a numeric type is signed.
121121 virtual bool isSigned() const { return 0; }
1616 class User : public Value {
1717 User(const User &); // Do not implement
1818 protected:
19 vector Operands;
19 std::vector Operands;
2020 public:
21 User(const Type *Ty, ValueTy vty, const string &name = "");
21 User(const Type *Ty, ValueTy vty, const std::string &name = "");
2222 virtual ~User() { dropAllReferences(); }
2323
2424 inline Value *getOperand(unsigned i) {
3838 // ---------------------------------------------------------------------------
3939 // Operand Iterator interface...
4040 //
41 typedef vector::iterator op_iterator;
42 typedef vector::const_iterator const_op_iterator;
41 typedef std::vector::iterator op_iterator;
42 typedef std::vector::const_iterator const_op_iterator;
4343
4444 inline op_iterator op_begin() { return Operands.begin(); }
4545 inline const_op_iterator op_begin() const { return Operands.begin(); }
4848 };
4949
5050 private:
51 vector Uses;
52 string Name;
51 std::vector Uses;
52 std::string Name;
5353 PATypeHandle Ty;
5454 ValueTy VTy;
5555
5757 protected:
5858 inline void setType(const Type *ty) { Ty = ty; }
5959 public:
60 Value(const Type *Ty, ValueTy vty, const string &name = "");
60 Value(const Type *Ty, ValueTy vty, const std::string &name = "");
6161 virtual ~Value();
6262
6363 // Support for debugging
6767 inline const Type *getType() const { return Ty; }
6868
6969 // All values can potentially be named...
70 inline bool hasName() const { return Name != ""; }
71 inline const string &getName() const { return Name; }
72
73 virtual void setName(const string &name, SymbolTable * = 0) {
70 inline bool hasName() const { return Name != ""; }
71 inline const std::string &getName() const { return Name; }
72
73 virtual void setName(const std::string &name, SymbolTable * = 0) {
7474 Name = name;
7575 }
7676
100100 //----------------------------------------------------------------------
101101 // Methods for handling the vector of uses of this Value.
102102 //
103 typedef vector::iterator use_iterator;
104 typedef vector::const_iterator use_const_iterator;
103 typedef std::vector::iterator use_iterator;
104 typedef std::vector::const_iterator use_const_iterator;
105105
106106 inline unsigned use_size() const { return Uses.size(); }
107107 inline bool use_empty() const { return Uses.empty(); }
2424 //
2525 template
2626 class ValueHolder {
27 vector ValueList;
27 std::vector ValueList;
2828
2929 ItemParentType *ItemParent;
3030 SymTabType *Parent;
6565 // sub-Definition iterator code
6666 //===--------------------------------------------------------------------===//
6767 //
68 typedef vector::iterator iterator;
69 typedef vector::const_iterator const_iterator;
70 typedef reverse_iterator const_reverse_iterator;
71 typedef reverse_iterator reverse_iterator;
68 typedef std::vector::iterator iterator;
69 typedef std::vector::const_iterator const_iterator;
70 typedef std::reverse_iterator const_reverse_iterator;
71 typedef std::reverse_iterator reverse_iterator;
7272
7373 inline iterator begin() { return ValueList.begin(); }
7474 inline const_iterator begin() const { return ValueList.begin(); }
2020 class AllocationInst : public Instruction {
2121 public:
2222 AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
23 const string &Name = "")
23 const std::string &Name = "")
2424 : Instruction(Ty, iTy, Name) {
2525 assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
2626
6666
6767 class MallocInst : public AllocationInst {
6868 public:
69 MallocInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "")
69 MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "")
7070 : AllocationInst(Ty, ArraySize, Malloc, Name) {}
7171
7272 virtual Instruction *clone() const {
9393
9494 class AllocaInst : public AllocationInst {
9595 public:
96 AllocaInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "")
96 AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "")
9797 : AllocationInst(Ty, ArraySize, Alloca, Name) {}
9898
9999 virtual Instruction *clone() const {
153153 class MemAccessInst : public Instruction {
154154 protected:
155155 inline MemAccessInst(const Type *Ty, unsigned Opcode,
156 const string &Nam = "")
156 const std::string &Nam = "")
157157 : Instruction(Ty, Opcode, Nam) {}
158158 public:
159159 // getIndexedType - Returns the type of the element that would be loaded with
163163 // pointer type.
164164 //
165165 static const Type *getIndexedType(const Type *Ptr,
166 const vector &Indices,
166 const std::vector &Indices,
167167 bool AllowStructLeaf = false);
168168
169169 inline op_iterator idx_begin() {
176176 inline const_op_iterator idx_end() const { return op_end(); }
177177
178178
179 vector copyIndices() const {
180 return vector(idx_begin(), idx_end());
179 std::vector copyIndices() const {
180 return std::vector(idx_begin(), idx_end());
181181 }
182182
183183 Value *getPointerOperand() {
216216 Operands.push_back(Use(LI.Operands[i], this));
217217 }
218218 public:
219 LoadInst(Value *Ptr, const vector &Idx, const string &Name = "");
220 LoadInst(Value *Ptr, const string &Name = "");
219 LoadInst(Value *Ptr, const std::vector &Ix, const std::string & = "");
220 LoadInst(Value *Ptr, const std::string &Name = "");
221221
222222 virtual Instruction *clone() const { return new LoadInst(*this); }
223223 virtual const char *getOpcodeName() const { return "load"; }
246246 Operands.push_back(Use(SI.Operands[i], this));
247247 }
248248 public:
249 StoreInst(Value *Val, Value *Ptr, const vector &Idx,
250 const string &Name = "");
251 StoreInst(Value *Val, Value *Ptr, const string &Name = "");
249 StoreInst(Value *Val, Value *Ptr, const std::vector &Idx,
250 const std::string &Name = "");
251 StoreInst(Value *Val, Value *Ptr, const std::string &Name = "");
252252 virtual Instruction *clone() const { return new StoreInst(*this); }
253253
254254 virtual const char *getOpcodeName() const { return "store"; }
279279 Operands.push_back(Use(EPI.Operands[i], this));
280280 }
281281 public:
282 GetElementPtrInst(Value *Ptr, const vector &Idx,
283 const string &Name = "");
282 GetElementPtrInst(Value *Ptr, const std::vector &Idx,
283 const std::string &Name = "");
284284 virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
285285 virtual const char *getOpcodeName() const { return "getelementptr"; }
286286 virtual unsigned getFirstIndexOperandNumber() const { return 1; }
1414 //
1515 class GenericUnaryInst : public UnaryOperator {
1616 public:
17 GenericUnaryInst(UnaryOps Opcode, Value *S1, const string &Name = "")
17 GenericUnaryInst(UnaryOps Opcode, Value *S1, const std::string &Name = "")
1818 : UnaryOperator(S1, Opcode, Name) {
1919 }
2020
3131 class GenericBinaryInst : public BinaryOperator {
3232 public:
3333 GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2,
34 const string &Name = "")
34 const std::string &Name = "")
3535 : BinaryOperator(Opcode, S1, S2, Name) {
3636 }
3737
4242 BinaryOps OpType;
4343 public:
4444 SetCondInst(BinaryOps opType, Value *S1, Value *S2,
45 const string &Name = "");
45 const std::string &Name = "");
4646
4747 virtual const char *getOpcodeName() const;
4848 };
2323 Operands.push_back(Use(CI.Operands[0], this));
2424 }
2525 public:
26 CastInst(Value *S, const Type *Ty, const string &Name = "")
26 CastInst(Value *S, const Type *Ty, const std::string &Name = "")
2727 : Instruction(Ty, Cast, Name) {
2828 Operands.reserve(1);
2929 Operands.push_back(Use(S, this));
5454 inline void setParent(Method *parent) { Parent = parent; }
5555
5656 public:
57 MethodArgument(const Type *Ty, const string &Name = "")
57 MethodArgument(const Type *Ty, const std::string &Name = "")
5858 : Value(Ty, Value::MethodArgumentVal, Name) {
5959 Parent = 0;
6060 }
6161
6262 // Specialize setName to handle symbol table majik...
63 virtual void setName(const string &name, SymbolTable *ST = 0);
63 virtual void setName(const std::string &name, SymbolTable *ST = 0);
6464
6565 inline const Method *getParent() const { return Parent; }
6666 inline Method *getParent() { return Parent; }
8080