mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-24 12:19:53 +00:00
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
This commit is contained in:
parent
13c4659220
commit
697954c15d
@ -52,7 +52,7 @@ RunBurg = $(BURG) $(BURG_OPTS)
|
|||||||
#Prof = -pg
|
#Prof = -pg
|
||||||
|
|
||||||
# TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti
|
# TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti
|
||||||
CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
|
CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused-parameter -Wno-missing-braces -I$(LEVEL)/include
|
||||||
|
|
||||||
# Compile a file, don't link...
|
# Compile a file, don't link...
|
||||||
Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
|
Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
|
||||||
|
@ -52,7 +52,7 @@ RunBurg = $(BURG) $(BURG_OPTS)
|
|||||||
#Prof = -pg
|
#Prof = -pg
|
||||||
|
|
||||||
# TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti
|
# TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti
|
||||||
CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include
|
CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused-parameter -Wno-missing-braces -I$(LEVEL)/include
|
||||||
|
|
||||||
# Compile a file, don't link...
|
# Compile a file, don't link...
|
||||||
Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
|
Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts)
|
||||||
|
@ -166,12 +166,13 @@ struct AnnotationManager {
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Basic ID <-> Name map functionality
|
// Basic ID <-> Name map functionality
|
||||||
|
|
||||||
static AnnotationID getID (const string &Name); // Name -> ID
|
static AnnotationID getID(const std::string &Name); // Name -> ID
|
||||||
static const string &getName(AnnotationID ID); // ID -> Name
|
static const std::string &getName(AnnotationID ID); // ID -> Name
|
||||||
|
|
||||||
// getID - Name -> ID + registration of a factory function for demand driven
|
// getID - Name -> ID + registration of a factory function for demand driven
|
||||||
// annotation support.
|
// annotation support.
|
||||||
static AnnotationID getID (const string &Name, Factory Fact, void *Data=0);
|
static AnnotationID getID(const std::string &Name, Factory Fact,
|
||||||
|
void *Data = 0);
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Annotation creation on demand support...
|
// Annotation creation on demand support...
|
||||||
|
@ -100,7 +100,7 @@ class Option {
|
|||||||
// an argument. Should return true if there was an error processing the
|
// an argument. Should return true if there was an error processing the
|
||||||
// argument and the program should exit.
|
// argument and the program should exit.
|
||||||
//
|
//
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0;
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0;
|
||||||
|
|
||||||
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
||||||
return Optional;
|
return Optional;
|
||||||
@ -146,10 +146,10 @@ public:
|
|||||||
|
|
||||||
// addOccurance - Wrapper around handleOccurance that enforces Flags
|
// addOccurance - Wrapper around handleOccurance that enforces Flags
|
||||||
//
|
//
|
||||||
bool addOccurance(const char *ArgName, const string &Value);
|
bool addOccurance(const char *ArgName, const std::string &Value);
|
||||||
|
|
||||||
// Prints option name followed by message. Always returns true.
|
// Prints option name followed by message. Always returns true.
|
||||||
bool error(string Message, const char *ArgName = 0);
|
bool error(std::string Message, const char *ArgName = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline int getNumOccurances() const { return NumOccurances; }
|
inline int getNumOccurances() const { return NumOccurances; }
|
||||||
@ -162,7 +162,7 @@ public:
|
|||||||
//
|
//
|
||||||
class Alias : public Option {
|
class Alias : public Option {
|
||||||
Option &AliasFor;
|
Option &AliasFor;
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg) {
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
|
||||||
return AliasFor.handleOccurance(AliasFor.ArgStr, Arg);
|
return AliasFor.handleOccurance(AliasFor.ArgStr, Arg);
|
||||||
}
|
}
|
||||||
virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
|
virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
|
||||||
@ -177,7 +177,7 @@ public:
|
|||||||
//
|
//
|
||||||
class Flag : public Option {
|
class Flag : public Option {
|
||||||
bool Value;
|
bool Value;
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
public:
|
public:
|
||||||
inline Flag(const char *ArgStr, const char *Message, int Flags = 0,
|
inline Flag(const char *ArgStr, const char *Message, int Flags = 0,
|
||||||
bool DefaultVal = 0) : Option(ArgStr, Message, Flags),
|
bool DefaultVal = 0) : Option(ArgStr, Message, Flags),
|
||||||
@ -193,7 +193,7 @@ public:
|
|||||||
//
|
//
|
||||||
class Int : public Option {
|
class Int : public Option {
|
||||||
int Value;
|
int Value;
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
return ValueRequired;
|
return ValueRequired;
|
||||||
}
|
}
|
||||||
@ -209,18 +209,18 @@ public:
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// String valued command line option
|
// String valued command line option
|
||||||
//
|
//
|
||||||
class String : public Option, public string {
|
class String : public Option, public std::string {
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
return ValueRequired;
|
return ValueRequired;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
inline String(const char *ArgStr, const char *Help, int Flags = 0,
|
inline String(const char *ArgStr, const char *Help, int Flags = 0,
|
||||||
const char *DefaultVal = "")
|
const char *DefaultVal = "")
|
||||||
: Option(ArgStr, Help, Flags), string(DefaultVal) {}
|
: Option(ArgStr, Help, Flags), std::string(DefaultVal) {}
|
||||||
|
|
||||||
inline const string &operator=(const string &Val) {
|
inline const std::string &operator=(const std::string &Val) {
|
||||||
return string::operator=(Val);
|
return std::string::operator=(Val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public:
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// String list command line option
|
// String list command line option
|
||||||
//
|
//
|
||||||
class StringList : public Option, public vector<string> {
|
class StringList : public Option, public std::vector<std::string> {
|
||||||
|
|
||||||
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
||||||
return ZeroOrMore;
|
return ZeroOrMore;
|
||||||
@ -236,7 +236,7 @@ class StringList : public Option, public vector<string> {
|
|||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
return ValueRequired;
|
return ValueRequired;
|
||||||
}
|
}
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline StringList(const char *ArgStr, const char *Help, int Flags = 0)
|
inline StringList(const char *ArgStr, const char *Help, int Flags = 0)
|
||||||
@ -256,7 +256,7 @@ protected:
|
|||||||
// Use a vector instead of a map, because the lists should be short,
|
// Use a vector instead of a map, because the lists should be short,
|
||||||
// the overhead is less, and most importantly, it keeps them in the order
|
// the overhead is less, and most importantly, it keeps them in the order
|
||||||
// inserted so we can print our option out nicely.
|
// inserted so we can print our option out nicely.
|
||||||
vector<pair<const char *, pair<int, const char *> > > ValueMap;
|
std::vector<std::pair<const char *, std::pair<int, const char *> > > ValueMap;
|
||||||
|
|
||||||
inline EnumBase(const char *ArgStr, const char *Help, int Flags)
|
inline EnumBase(const char *ArgStr, const char *Help, int Flags)
|
||||||
: Option(ArgStr, Help, Flags) {}
|
: Option(ArgStr, Help, Flags) {}
|
||||||
@ -284,7 +284,7 @@ protected:
|
|||||||
inline EnumValueBase(int Flags) : EnumBase(Flags) {}
|
inline EnumValueBase(int Flags) : EnumBase(Flags) {}
|
||||||
|
|
||||||
// handleOccurance - Set Value to the enum value specified by Arg
|
// handleOccurance - Set Value to the enum value specified by Arg
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
|
|
||||||
// Return the width of the option tag for printing...
|
// Return the width of the option tag for printing...
|
||||||
virtual unsigned getOptionWidth() const;
|
virtual unsigned getOptionWidth() const;
|
||||||
@ -323,7 +323,7 @@ class EnumFlagsBase : public EnumValueBase {
|
|||||||
return ValueDisallowed;
|
return ValueDisallowed;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {}
|
inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {}
|
||||||
|
|
||||||
// Return the width of the option tag for printing...
|
// Return the width of the option tag for printing...
|
||||||
@ -363,11 +363,11 @@ class EnumListBase : public EnumBase {
|
|||||||
return ValueDisallowed;
|
return ValueDisallowed;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
vector<int> Values; // The options specified so far.
|
std::vector<int> Values; // The options specified so far.
|
||||||
|
|
||||||
inline EnumListBase(int Flags)
|
inline EnumListBase(int Flags)
|
||||||
: EnumBase(Flags) {}
|
: EnumBase(Flags) {}
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
|
|
||||||
// Return the width of the option tag for printing...
|
// Return the width of the option tag for printing...
|
||||||
virtual unsigned getOptionWidth() const;
|
virtual unsigned getOptionWidth() const;
|
||||||
|
@ -20,21 +20,21 @@ class df_iterator : public std::forward_iterator<typename GT::NodeType,
|
|||||||
typedef typename GT::NodeType NodeType;
|
typedef typename GT::NodeType NodeType;
|
||||||
typedef typename GT::ChildIteratorType ChildItTy;
|
typedef typename GT::ChildIteratorType ChildItTy;
|
||||||
|
|
||||||
set<NodeType *> Visited; // All of the blocks visited so far...
|
std::set<NodeType *> Visited; // All of the blocks visited so far...
|
||||||
// VisitStack - Used to maintain the ordering. Top = current block
|
// VisitStack - Used to maintain the ordering. Top = current block
|
||||||
// First element is node pointer, second is the 'next child' to visit
|
// First element is node pointer, second is the 'next child' to visit
|
||||||
stack<pair<NodeType *, ChildItTy> > VisitStack;
|
std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;
|
||||||
const bool Reverse; // Iterate over children before self?
|
const bool Reverse; // Iterate over children before self?
|
||||||
private:
|
private:
|
||||||
void reverseEnterNode() {
|
void reverseEnterNode() {
|
||||||
pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
std::pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
||||||
NodeType *Node = Top.first;
|
NodeType *Node = Top.first;
|
||||||
ChildItTy &It = Top.second;
|
ChildItTy &It = Top.second;
|
||||||
for (; It != GT::child_end(Node); ++It) {
|
for (; It != GT::child_end(Node); ++It) {
|
||||||
NodeType *Child = *It;
|
NodeType *Child = *It;
|
||||||
if (!Visited.count(Child)) {
|
if (!Visited.count(Child)) {
|
||||||
Visited.insert(Child);
|
Visited.insert(Child);
|
||||||
VisitStack.push(make_pair(Child, GT::child_begin(Child)));
|
VisitStack.push(std::make_pair(Child, GT::child_begin(Child)));
|
||||||
reverseEnterNode();
|
reverseEnterNode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ private:
|
|||||||
|
|
||||||
inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) {
|
inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) {
|
||||||
Visited.insert(Node);
|
Visited.insert(Node);
|
||||||
VisitStack.push(make_pair(Node, GT::child_begin(Node)));
|
VisitStack.push(std::make_pair(Node, GT::child_begin(Node)));
|
||||||
if (Reverse) reverseEnterNode();
|
if (Reverse) reverseEnterNode();
|
||||||
}
|
}
|
||||||
inline df_iterator() { /* End is when stack is empty */ }
|
inline df_iterator() { /* End is when stack is empty */ }
|
||||||
@ -81,7 +81,7 @@ public:
|
|||||||
reverseEnterNode();
|
reverseEnterNode();
|
||||||
} else { // Normal Depth First Iterator
|
} else { // Normal Depth First Iterator
|
||||||
do {
|
do {
|
||||||
pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
std::pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
||||||
NodeType *Node = Top.first;
|
NodeType *Node = Top.first;
|
||||||
ChildItTy &It = Top.second;
|
ChildItTy &It = Top.second;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public:
|
|||||||
if (!Visited.count(Next)) { // Has our next sibling been visited?
|
if (!Visited.count(Next)) { // Has our next sibling been visited?
|
||||||
// No, do it now.
|
// No, do it now.
|
||||||
Visited.insert(Next);
|
Visited.insert(Next);
|
||||||
VisitStack.push(make_pair(Next, GT::child_begin(Next)));
|
VisitStack.push(std::make_pair(Next, GT::child_begin(Next)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
#define LLVM_SUPPORT_HASHEXTRAS_H
|
#define LLVM_SUPPORT_HASHEXTRAS_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <hash_map>
|
#include <ext/hash_map>
|
||||||
|
|
||||||
|
// Cannot specialize hash template from outside of the std namespace.
|
||||||
|
namespace std {
|
||||||
|
|
||||||
template <> struct hash<string> {
|
template <> struct hash<string> {
|
||||||
size_t operator()(string const &str) const {
|
size_t operator()(string const &str) const {
|
||||||
@ -24,4 +27,6 @@ template <class T> struct hash<T *> {
|
|||||||
inline size_t operator()(const T *Val) const { return (size_t)Val; }
|
inline size_t operator()(const T *Val) const { return (size_t)Val; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // End namespace std
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,10 +20,10 @@ class po_iterator : public std::forward_iterator<typename GT::NodeType,
|
|||||||
typedef typename GT::NodeType NodeType;
|
typedef typename GT::NodeType NodeType;
|
||||||
typedef typename GT::ChildIteratorType ChildItTy;
|
typedef typename GT::ChildIteratorType ChildItTy;
|
||||||
|
|
||||||
set<NodeType *> Visited; // All of the blocks visited so far...
|
std::set<NodeType *> Visited; // All of the blocks visited so far...
|
||||||
// VisitStack - Used to maintain the ordering. Top = current block
|
// VisitStack - Used to maintain the ordering. Top = current block
|
||||||
// First element is basic block pointer, second is the 'next child' to visit
|
// First element is basic block pointer, second is the 'next child' to visit
|
||||||
stack<pair<NodeType *, ChildItTy> > VisitStack;
|
std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;
|
||||||
|
|
||||||
void traverseChild() {
|
void traverseChild() {
|
||||||
while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
|
while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
|
||||||
@ -122,10 +122,10 @@ ipo_iterator<T> ipo_end(T G){
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
||||||
typedef reverse_iterator<vector<BasicBlock*>::iterator> rpo_iterator;
|
typedef std::vector<BasicBlock*>::reverse_iterator rpo_iterator;
|
||||||
// TODO: FIXME: ReversePostOrderTraversal is not generic!
|
// TODO: FIXME: ReversePostOrderTraversal is not generic!
|
||||||
class ReversePostOrderTraversal {
|
class ReversePostOrderTraversal {
|
||||||
vector<BasicBlock*> Blocks; // Block list in normal PO order
|
std::vector<BasicBlock*> Blocks; // Block list in normal PO order
|
||||||
inline void Initialize(BasicBlock *BB) {
|
inline void Initialize(BasicBlock *BB) {
|
||||||
copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
|
copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
// arguments to get a boolean result.
|
// arguments to get a boolean result.
|
||||||
//
|
//
|
||||||
template<class Ty>
|
template<class Ty>
|
||||||
struct bitwise_or : public binary_function<Ty, Ty, bool> {
|
struct bitwise_or : public std::binary_function<Ty, Ty, bool> {
|
||||||
bool operator()(const Ty& left, const Ty& right) const {
|
bool operator()(const Ty& left, const Ty& right) const {
|
||||||
return left | right;
|
return left | right;
|
||||||
}
|
}
|
||||||
@ -70,9 +70,9 @@ class mapped_iterator {
|
|||||||
RootIt current;
|
RootIt current;
|
||||||
UnaryFunc Fn;
|
UnaryFunc Fn;
|
||||||
public:
|
public:
|
||||||
typedef typename iterator_traits<RootIt>::iterator_category
|
typedef typename std::iterator_traits<RootIt>::iterator_category
|
||||||
iterator_category;
|
iterator_category;
|
||||||
typedef typename iterator_traits<RootIt>::difference_type
|
typedef typename std::iterator_traits<RootIt>::difference_type
|
||||||
difference_type;
|
difference_type;
|
||||||
typedef typename UnaryFunc::result_type value_type;
|
typedef typename UnaryFunc::result_type value_type;
|
||||||
typedef typename UnaryFunc::result_type *pointer;
|
typedef typename UnaryFunc::result_type *pointer;
|
||||||
@ -102,6 +102,7 @@ public:
|
|||||||
_Self& operator-= (difference_type n) { current -= n; return *this; }
|
_Self& operator-= (difference_type n) { current -= n; return *this; }
|
||||||
reference operator[](difference_type n) const { return *(*this + n); }
|
reference operator[](difference_type n) const { return *(*this + n); }
|
||||||
|
|
||||||
|
inline bool operator!=(const _Self &X) const { return !operator==(X); }
|
||||||
inline bool operator==(const _Self &X) const { return current == X.current; }
|
inline bool operator==(const _Self &X) const { return current == X.current; }
|
||||||
inline bool operator< (const _Self &X) const { return current < X.current; }
|
inline bool operator< (const _Self &X) const { return current < X.current; }
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static inline string utostr(uint64_t X, bool isNeg = false) {
|
static inline std::string utostr(uint64_t X, bool isNeg = false) {
|
||||||
char Buffer[40];
|
char Buffer[40];
|
||||||
char *BufPtr = Buffer+39;
|
char *BufPtr = Buffer+39;
|
||||||
|
|
||||||
@ -25,10 +25,10 @@ static inline string utostr(uint64_t X, bool isNeg = false) {
|
|||||||
|
|
||||||
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
||||||
|
|
||||||
return string(BufPtr);
|
return std::string(BufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline string itostr(int64_t X) {
|
static inline std::string itostr(int64_t X) {
|
||||||
if (X < 0)
|
if (X < 0)
|
||||||
return utostr((uint64_t)-X, true);
|
return utostr((uint64_t)-X, true);
|
||||||
else
|
else
|
||||||
@ -36,7 +36,7 @@ static inline string itostr(int64_t X) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline string utostr(unsigned X, bool isNeg = false) {
|
static inline std::string utostr(unsigned X, bool isNeg = false) {
|
||||||
char Buffer[20];
|
char Buffer[20];
|
||||||
char *BufPtr = Buffer+19;
|
char *BufPtr = Buffer+19;
|
||||||
|
|
||||||
@ -50,17 +50,17 @@ static inline string utostr(unsigned X, bool isNeg = false) {
|
|||||||
|
|
||||||
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
||||||
|
|
||||||
return string(BufPtr);
|
return std::string(BufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline string itostr(int X) {
|
static inline std::string itostr(int X) {
|
||||||
if (X < 0)
|
if (X < 0)
|
||||||
return utostr((unsigned)-X, true);
|
return utostr((unsigned)-X, true);
|
||||||
else
|
else
|
||||||
return utostr((unsigned)X);
|
return utostr((unsigned)X);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline string ftostr(double V) {
|
static inline std::string ftostr(double V) {
|
||||||
char Buffer[200];
|
char Buffer[200];
|
||||||
snprintf(Buffer, 200, "%e", V);
|
snprintf(Buffer, 200, "%e", V);
|
||||||
return Buffer;
|
return Buffer;
|
||||||
|
@ -12,21 +12,21 @@
|
|||||||
|
|
||||||
template<class ConcreteTreeNode, class Payload>
|
template<class ConcreteTreeNode, class Payload>
|
||||||
class Tree {
|
class Tree {
|
||||||
vector<ConcreteTreeNode*> Children; // This nodes children, if any
|
std::vector<ConcreteTreeNode*> Children; // This nodes children, if any
|
||||||
ConcreteTreeNode *Parent; // Parent of this node...
|
ConcreteTreeNode *Parent; // Parent of this node...
|
||||||
Payload Data; // Data held in this node...
|
Payload Data; // Data held in this node...
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setChildren(const vector<ConcreteTreeNode*> &children) {
|
void setChildren(const std::vector<ConcreteTreeNode*> &children) {
|
||||||
Children = children;
|
Children = children;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
|
inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
|
||||||
inline Tree(const vector<ConcreteTreeNode*> &children, ConcreteTreeNode *par)
|
inline Tree(const std::vector<ConcreteTreeNode*> &children,
|
||||||
: Children(children), Parent(par) {}
|
ConcreteTreeNode *par) : Children(children), Parent(par) {}
|
||||||
|
|
||||||
inline Tree(const vector<ConcreteTreeNode*> &children, ConcreteTreeNode *par,
|
inline Tree(const std::vector<ConcreteTreeNode*> &children,
|
||||||
const Payload &data)
|
ConcreteTreeNode *par, const Payload &data)
|
||||||
: Children(children), Parent(parent), Data(data) {}
|
: Children(children), Parent(parent), Data(data) {}
|
||||||
|
|
||||||
// Tree dtor - Free all children
|
// Tree dtor - Free all children
|
||||||
|
@ -20,21 +20,21 @@ class df_iterator : public std::forward_iterator<typename GT::NodeType,
|
|||||||
typedef typename GT::NodeType NodeType;
|
typedef typename GT::NodeType NodeType;
|
||||||
typedef typename GT::ChildIteratorType ChildItTy;
|
typedef typename GT::ChildIteratorType ChildItTy;
|
||||||
|
|
||||||
set<NodeType *> Visited; // All of the blocks visited so far...
|
std::set<NodeType *> Visited; // All of the blocks visited so far...
|
||||||
// VisitStack - Used to maintain the ordering. Top = current block
|
// VisitStack - Used to maintain the ordering. Top = current block
|
||||||
// First element is node pointer, second is the 'next child' to visit
|
// First element is node pointer, second is the 'next child' to visit
|
||||||
stack<pair<NodeType *, ChildItTy> > VisitStack;
|
std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;
|
||||||
const bool Reverse; // Iterate over children before self?
|
const bool Reverse; // Iterate over children before self?
|
||||||
private:
|
private:
|
||||||
void reverseEnterNode() {
|
void reverseEnterNode() {
|
||||||
pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
std::pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
||||||
NodeType *Node = Top.first;
|
NodeType *Node = Top.first;
|
||||||
ChildItTy &It = Top.second;
|
ChildItTy &It = Top.second;
|
||||||
for (; It != GT::child_end(Node); ++It) {
|
for (; It != GT::child_end(Node); ++It) {
|
||||||
NodeType *Child = *It;
|
NodeType *Child = *It;
|
||||||
if (!Visited.count(Child)) {
|
if (!Visited.count(Child)) {
|
||||||
Visited.insert(Child);
|
Visited.insert(Child);
|
||||||
VisitStack.push(make_pair(Child, GT::child_begin(Child)));
|
VisitStack.push(std::make_pair(Child, GT::child_begin(Child)));
|
||||||
reverseEnterNode();
|
reverseEnterNode();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ private:
|
|||||||
|
|
||||||
inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) {
|
inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) {
|
||||||
Visited.insert(Node);
|
Visited.insert(Node);
|
||||||
VisitStack.push(make_pair(Node, GT::child_begin(Node)));
|
VisitStack.push(std::make_pair(Node, GT::child_begin(Node)));
|
||||||
if (Reverse) reverseEnterNode();
|
if (Reverse) reverseEnterNode();
|
||||||
}
|
}
|
||||||
inline df_iterator() { /* End is when stack is empty */ }
|
inline df_iterator() { /* End is when stack is empty */ }
|
||||||
@ -81,7 +81,7 @@ public:
|
|||||||
reverseEnterNode();
|
reverseEnterNode();
|
||||||
} else { // Normal Depth First Iterator
|
} else { // Normal Depth First Iterator
|
||||||
do {
|
do {
|
||||||
pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
std::pair<NodeType *, ChildItTy> &Top = VisitStack.top();
|
||||||
NodeType *Node = Top.first;
|
NodeType *Node = Top.first;
|
||||||
ChildItTy &It = Top.second;
|
ChildItTy &It = Top.second;
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ public:
|
|||||||
if (!Visited.count(Next)) { // Has our next sibling been visited?
|
if (!Visited.count(Next)) { // Has our next sibling been visited?
|
||||||
// No, do it now.
|
// No, do it now.
|
||||||
Visited.insert(Next);
|
Visited.insert(Next);
|
||||||
VisitStack.push(make_pair(Next, GT::child_begin(Next)));
|
VisitStack.push(std::make_pair(Next, GT::child_begin(Next)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,10 @@
|
|||||||
#define LLVM_SUPPORT_HASHEXTRAS_H
|
#define LLVM_SUPPORT_HASHEXTRAS_H
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <hash_map>
|
#include <ext/hash_map>
|
||||||
|
|
||||||
|
// Cannot specialize hash template from outside of the std namespace.
|
||||||
|
namespace std {
|
||||||
|
|
||||||
template <> struct hash<string> {
|
template <> struct hash<string> {
|
||||||
size_t operator()(string const &str) const {
|
size_t operator()(string const &str) const {
|
||||||
@ -24,4 +27,6 @@ template <class T> struct hash<T *> {
|
|||||||
inline size_t operator()(const T *Val) const { return (size_t)Val; }
|
inline size_t operator()(const T *Val) const { return (size_t)Val; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
} // End namespace std
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -20,10 +20,10 @@ class po_iterator : public std::forward_iterator<typename GT::NodeType,
|
|||||||
typedef typename GT::NodeType NodeType;
|
typedef typename GT::NodeType NodeType;
|
||||||
typedef typename GT::ChildIteratorType ChildItTy;
|
typedef typename GT::ChildIteratorType ChildItTy;
|
||||||
|
|
||||||
set<NodeType *> Visited; // All of the blocks visited so far...
|
std::set<NodeType *> Visited; // All of the blocks visited so far...
|
||||||
// VisitStack - Used to maintain the ordering. Top = current block
|
// VisitStack - Used to maintain the ordering. Top = current block
|
||||||
// First element is basic block pointer, second is the 'next child' to visit
|
// First element is basic block pointer, second is the 'next child' to visit
|
||||||
stack<pair<NodeType *, ChildItTy> > VisitStack;
|
std::stack<std::pair<NodeType *, ChildItTy> > VisitStack;
|
||||||
|
|
||||||
void traverseChild() {
|
void traverseChild() {
|
||||||
while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
|
while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) {
|
||||||
@ -122,10 +122,10 @@ ipo_iterator<T> ipo_end(T G){
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
|
||||||
typedef reverse_iterator<vector<BasicBlock*>::iterator> rpo_iterator;
|
typedef std::vector<BasicBlock*>::reverse_iterator rpo_iterator;
|
||||||
// TODO: FIXME: ReversePostOrderTraversal is not generic!
|
// TODO: FIXME: ReversePostOrderTraversal is not generic!
|
||||||
class ReversePostOrderTraversal {
|
class ReversePostOrderTraversal {
|
||||||
vector<BasicBlock*> Blocks; // Block list in normal PO order
|
std::vector<BasicBlock*> Blocks; // Block list in normal PO order
|
||||||
inline void Initialize(BasicBlock *BB) {
|
inline void Initialize(BasicBlock *BB) {
|
||||||
copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
|
copy(po_begin(BB), po_end(BB), back_inserter(Blocks));
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
// arguments to get a boolean result.
|
// arguments to get a boolean result.
|
||||||
//
|
//
|
||||||
template<class Ty>
|
template<class Ty>
|
||||||
struct bitwise_or : public binary_function<Ty, Ty, bool> {
|
struct bitwise_or : public std::binary_function<Ty, Ty, bool> {
|
||||||
bool operator()(const Ty& left, const Ty& right) const {
|
bool operator()(const Ty& left, const Ty& right) const {
|
||||||
return left | right;
|
return left | right;
|
||||||
}
|
}
|
||||||
@ -70,9 +70,9 @@ class mapped_iterator {
|
|||||||
RootIt current;
|
RootIt current;
|
||||||
UnaryFunc Fn;
|
UnaryFunc Fn;
|
||||||
public:
|
public:
|
||||||
typedef typename iterator_traits<RootIt>::iterator_category
|
typedef typename std::iterator_traits<RootIt>::iterator_category
|
||||||
iterator_category;
|
iterator_category;
|
||||||
typedef typename iterator_traits<RootIt>::difference_type
|
typedef typename std::iterator_traits<RootIt>::difference_type
|
||||||
difference_type;
|
difference_type;
|
||||||
typedef typename UnaryFunc::result_type value_type;
|
typedef typename UnaryFunc::result_type value_type;
|
||||||
typedef typename UnaryFunc::result_type *pointer;
|
typedef typename UnaryFunc::result_type *pointer;
|
||||||
@ -102,6 +102,7 @@ public:
|
|||||||
_Self& operator-= (difference_type n) { current -= n; return *this; }
|
_Self& operator-= (difference_type n) { current -= n; return *this; }
|
||||||
reference operator[](difference_type n) const { return *(*this + n); }
|
reference operator[](difference_type n) const { return *(*this + n); }
|
||||||
|
|
||||||
|
inline bool operator!=(const _Self &X) const { return !operator==(X); }
|
||||||
inline bool operator==(const _Self &X) const { return current == X.current; }
|
inline bool operator==(const _Self &X) const { return current == X.current; }
|
||||||
inline bool operator< (const _Self &X) const { return current < X.current; }
|
inline bool operator< (const _Self &X) const { return current < X.current; }
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
static inline string utostr(uint64_t X, bool isNeg = false) {
|
static inline std::string utostr(uint64_t X, bool isNeg = false) {
|
||||||
char Buffer[40];
|
char Buffer[40];
|
||||||
char *BufPtr = Buffer+39;
|
char *BufPtr = Buffer+39;
|
||||||
|
|
||||||
@ -25,10 +25,10 @@ static inline string utostr(uint64_t X, bool isNeg = false) {
|
|||||||
|
|
||||||
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
||||||
|
|
||||||
return string(BufPtr);
|
return std::string(BufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline string itostr(int64_t X) {
|
static inline std::string itostr(int64_t X) {
|
||||||
if (X < 0)
|
if (X < 0)
|
||||||
return utostr((uint64_t)-X, true);
|
return utostr((uint64_t)-X, true);
|
||||||
else
|
else
|
||||||
@ -36,7 +36,7 @@ static inline string itostr(int64_t X) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline string utostr(unsigned X, bool isNeg = false) {
|
static inline std::string utostr(unsigned X, bool isNeg = false) {
|
||||||
char Buffer[20];
|
char Buffer[20];
|
||||||
char *BufPtr = Buffer+19;
|
char *BufPtr = Buffer+19;
|
||||||
|
|
||||||
@ -50,17 +50,17 @@ static inline string utostr(unsigned X, bool isNeg = false) {
|
|||||||
|
|
||||||
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
if (isNeg) *--BufPtr = '-'; // Add negative sign...
|
||||||
|
|
||||||
return string(BufPtr);
|
return std::string(BufPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline string itostr(int X) {
|
static inline std::string itostr(int X) {
|
||||||
if (X < 0)
|
if (X < 0)
|
||||||
return utostr((unsigned)-X, true);
|
return utostr((unsigned)-X, true);
|
||||||
else
|
else
|
||||||
return utostr((unsigned)X);
|
return utostr((unsigned)X);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline string ftostr(double V) {
|
static inline std::string ftostr(double V) {
|
||||||
char Buffer[200];
|
char Buffer[200];
|
||||||
snprintf(Buffer, 200, "%e", V);
|
snprintf(Buffer, 200, "%e", V);
|
||||||
return Buffer;
|
return Buffer;
|
||||||
|
@ -12,21 +12,21 @@
|
|||||||
|
|
||||||
template<class ConcreteTreeNode, class Payload>
|
template<class ConcreteTreeNode, class Payload>
|
||||||
class Tree {
|
class Tree {
|
||||||
vector<ConcreteTreeNode*> Children; // This nodes children, if any
|
std::vector<ConcreteTreeNode*> Children; // This nodes children, if any
|
||||||
ConcreteTreeNode *Parent; // Parent of this node...
|
ConcreteTreeNode *Parent; // Parent of this node...
|
||||||
Payload Data; // Data held in this node...
|
Payload Data; // Data held in this node...
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setChildren(const vector<ConcreteTreeNode*> &children) {
|
void setChildren(const std::vector<ConcreteTreeNode*> &children) {
|
||||||
Children = children;
|
Children = children;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
|
inline Tree(ConcreteTreeNode *parent) : Parent(parent) {}
|
||||||
inline Tree(const vector<ConcreteTreeNode*> &children, ConcreteTreeNode *par)
|
inline Tree(const std::vector<ConcreteTreeNode*> &children,
|
||||||
: Children(children), Parent(par) {}
|
ConcreteTreeNode *par) : Children(children), Parent(par) {}
|
||||||
|
|
||||||
inline Tree(const vector<ConcreteTreeNode*> &children, ConcreteTreeNode *par,
|
inline Tree(const std::vector<ConcreteTreeNode*> &children,
|
||||||
const Payload &data)
|
ConcreteTreeNode *par, const Payload &data)
|
||||||
: Children(children), Parent(parent), Data(data) {}
|
: Children(children), Parent(parent), Data(data) {}
|
||||||
|
|
||||||
// Tree dtor - Free all children
|
// Tree dtor - Free all children
|
||||||
|
@ -27,12 +27,12 @@ namespace cfg {
|
|||||||
class CallGraph;
|
class CallGraph;
|
||||||
class CallGraphNode {
|
class CallGraphNode {
|
||||||
Method *Meth;
|
Method *Meth;
|
||||||
vector<CallGraphNode*> CalledMethods;
|
std::vector<CallGraphNode*> CalledMethods;
|
||||||
|
|
||||||
CallGraphNode(const CallGraphNode &); // Do not implement
|
CallGraphNode(const CallGraphNode &); // Do not implement
|
||||||
public:
|
public:
|
||||||
typedef vector<CallGraphNode*>::iterator iterator;
|
typedef std::vector<CallGraphNode*>::iterator iterator;
|
||||||
typedef vector<CallGraphNode*>::const_iterator const_iterator;
|
typedef std::vector<CallGraphNode*>::const_iterator const_iterator;
|
||||||
|
|
||||||
// getMethod - Return the method that this call graph node represents...
|
// getMethod - Return the method that this call graph node represents...
|
||||||
Method *getMethod() const { return Meth; }
|
Method *getMethod() const { return Meth; }
|
||||||
@ -65,7 +65,7 @@ private: // Stuff to construct the node, used by CallGraph
|
|||||||
class CallGraph {
|
class CallGraph {
|
||||||
Module *Mod; // The module this call graph represents
|
Module *Mod; // The module this call graph represents
|
||||||
|
|
||||||
typedef map<const Method *, CallGraphNode *> MethodMapTy;
|
typedef std::map<const Method *, CallGraphNode *> MethodMapTy;
|
||||||
MethodMapTy MethodMap; // Map from a method to its node
|
MethodMapTy MethodMap; // Map from a method to its node
|
||||||
|
|
||||||
CallGraphNode *Root;
|
CallGraphNode *Root;
|
||||||
|
@ -47,8 +47,9 @@ public:
|
|||||||
//
|
//
|
||||||
class DominatorSet : public DominatorBase {
|
class DominatorSet : public DominatorBase {
|
||||||
public:
|
public:
|
||||||
typedef set<const BasicBlock*> DomSetType; // Dom set for a bb
|
typedef std::set<const BasicBlock*> DomSetType; // Dom set for a bb
|
||||||
typedef map<const BasicBlock *, DomSetType> DomSetMapType; // Map of dom sets
|
// Map of dom sets
|
||||||
|
typedef std::map<const BasicBlock*, DomSetType> DomSetMapType;
|
||||||
private:
|
private:
|
||||||
DomSetMapType Doms;
|
DomSetMapType Doms;
|
||||||
|
|
||||||
@ -91,7 +92,7 @@ public:
|
|||||||
// method.
|
// method.
|
||||||
//
|
//
|
||||||
class ImmediateDominators : public DominatorBase {
|
class ImmediateDominators : public DominatorBase {
|
||||||
map<const BasicBlock*, const BasicBlock*> IDoms;
|
std::map<const BasicBlock*, const BasicBlock*> IDoms;
|
||||||
void calcIDoms(const DominatorSet &DS);
|
void calcIDoms(const DominatorSet &DS);
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -104,7 +105,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Accessor interface:
|
// Accessor interface:
|
||||||
typedef map<const BasicBlock*, const BasicBlock*> IDomMapType;
|
typedef std::map<const BasicBlock*, const BasicBlock*> IDomMapType;
|
||||||
typedef IDomMapType::const_iterator const_iterator;
|
typedef IDomMapType::const_iterator const_iterator;
|
||||||
inline const_iterator begin() const { return IDoms.begin(); }
|
inline const_iterator begin() const { return IDoms.begin(); }
|
||||||
inline const_iterator end() const { return IDoms.end(); }
|
inline const_iterator end() const { return IDoms.end(); }
|
||||||
@ -114,7 +115,7 @@ public:
|
|||||||
// node returns null, because it does not have an immediate dominator.
|
// node returns null, because it does not have an immediate dominator.
|
||||||
//
|
//
|
||||||
inline const BasicBlock *operator[](const BasicBlock *BB) const {
|
inline const BasicBlock *operator[](const BasicBlock *BB) const {
|
||||||
map<const BasicBlock*, const BasicBlock*>::const_iterator I =
|
std::map<const BasicBlock*, const BasicBlock*>::const_iterator I =
|
||||||
IDoms.find(BB);
|
IDoms.find(BB);
|
||||||
return I != IDoms.end() ? I->second : 0;
|
return I != IDoms.end() ? I->second : 0;
|
||||||
}
|
}
|
||||||
@ -130,18 +131,18 @@ class DominatorTree : public DominatorBase {
|
|||||||
public:
|
public:
|
||||||
typedef Node2 Node;
|
typedef Node2 Node;
|
||||||
private:
|
private:
|
||||||
map<const BasicBlock*, Node*> Nodes;
|
std::map<const BasicBlock*, Node*> Nodes;
|
||||||
void calculate(const DominatorSet &DS);
|
void calculate(const DominatorSet &DS);
|
||||||
typedef map<const BasicBlock*, Node*> NodeMapType;
|
typedef std::map<const BasicBlock*, Node*> NodeMapType;
|
||||||
public:
|
public:
|
||||||
class Node2 : public vector<Node*> {
|
class Node2 : public std::vector<Node*> {
|
||||||
friend class DominatorTree;
|
friend class DominatorTree;
|
||||||
const BasicBlock *TheNode;
|
const BasicBlock *TheNode;
|
||||||
Node2 * const IDom;
|
Node2 * const IDom;
|
||||||
public:
|
public:
|
||||||
inline const BasicBlock *getNode() const { return TheNode; }
|
inline const BasicBlock *getNode() const { return TheNode; }
|
||||||
inline Node2 *getIDom() const { return IDom; }
|
inline Node2 *getIDom() const { return IDom; }
|
||||||
inline const vector<Node*> &getChildren() const { return *this; }
|
inline const std::vector<Node*> &getChildren() const { return *this; }
|
||||||
|
|
||||||
// dominates - Returns true iff this dominates N. Note that this is not a
|
// dominates - Returns true iff this dominates N. Note that this is not a
|
||||||
// constant time operation!
|
// constant time operation!
|
||||||
@ -181,8 +182,8 @@ public:
|
|||||||
//
|
//
|
||||||
class DominanceFrontier : public DominatorBase {
|
class DominanceFrontier : public DominatorBase {
|
||||||
public:
|
public:
|
||||||
typedef set<const BasicBlock*> DomSetType; // Dom set for a bb
|
typedef std::set<const BasicBlock*> DomSetType; // Dom set for a bb
|
||||||
typedef map<const BasicBlock *, DomSetType> DomSetMapType; // Map of dom sets
|
typedef std::map<const BasicBlock*, DomSetType> DomSetMapType; // Dom set map
|
||||||
private:
|
private:
|
||||||
DomSetMapType Frontiers;
|
DomSetMapType Frontiers;
|
||||||
const DomSetType &calcDomFrontier(const DominatorTree &DT,
|
const DomSetType &calcDomFrontier(const DominatorTree &DT,
|
||||||
|
@ -24,11 +24,11 @@ class PointerType;
|
|||||||
|
|
||||||
struct FindUnsafePointerTypes : public Pass {
|
struct FindUnsafePointerTypes : public Pass {
|
||||||
// UnsafeTypes - Set of types that are not safe to transform.
|
// UnsafeTypes - Set of types that are not safe to transform.
|
||||||
set<PointerType*> UnsafeTypes;
|
std::set<PointerType*> UnsafeTypes;
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// Accessor for underlying type set...
|
// Accessor for underlying type set...
|
||||||
inline const set<PointerType*> &getUnsafeTypes() const {
|
inline const std::set<PointerType*> &getUnsafeTypes() const {
|
||||||
return UnsafeTypes;
|
return UnsafeTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ public:
|
|||||||
// printResults - Loop over the results of the analysis, printing out unsafe
|
// printResults - Loop over the results of the analysis, printing out unsafe
|
||||||
// types.
|
// types.
|
||||||
//
|
//
|
||||||
void printResults(const Module *Mod, ostream &o);
|
void printResults(const Module *Mod, std::ostream &o);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
class SymbolTable;
|
class SymbolTable;
|
||||||
|
|
||||||
class FindUsedTypes : public Pass {
|
class FindUsedTypes : public Pass {
|
||||||
set<const Type *> UsedTypes;
|
std::set<const Type *> UsedTypes;
|
||||||
|
|
||||||
bool IncludeSymbolTables;
|
bool IncludeSymbolTables;
|
||||||
public:
|
public:
|
||||||
@ -25,13 +25,13 @@ public:
|
|||||||
// getTypes - After the pass has been run, return the set containing all of
|
// getTypes - After the pass has been run, return the set containing all of
|
||||||
// the types used in the module.
|
// the types used in the module.
|
||||||
//
|
//
|
||||||
inline const set<const Type *> &getTypes() const { return UsedTypes; }
|
inline const std::set<const Type *> &getTypes() const { return UsedTypes; }
|
||||||
|
|
||||||
// Print the types found in the module. If the optional Module parameter is
|
// Print the types found in the module. If the optional Module parameter is
|
||||||
// passed in, then the types are printed symbolically if possible, using the
|
// passed in, then the types are printed symbolically if possible, using the
|
||||||
// symbol table from the module.
|
// symbol table from the module.
|
||||||
//
|
//
|
||||||
void printTypes(ostream &o, const Module *M = 0) const;
|
void printTypes(std::ostream &o, const Module *M = 0) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// IncorporateType - Incorporate one type and all of its subtypes into the
|
// IncorporateType - Incorporate one type and all of its subtypes into the
|
||||||
|
@ -35,10 +35,12 @@ template<class Payload> class InstForest;
|
|||||||
//
|
//
|
||||||
template<class Payload>
|
template<class Payload>
|
||||||
class InstTreeNode :
|
class InstTreeNode :
|
||||||
public Tree<InstTreeNode<Payload>, pair<pair<Value*, char>, Payload> > {
|
public Tree<InstTreeNode<Payload>,
|
||||||
|
std::pair<std::pair<Value*, char>, Payload> > {
|
||||||
|
|
||||||
friend class InstForest<Payload>;
|
friend class InstForest<Payload>;
|
||||||
typedef Tree<InstTreeNode<Payload>, pair<pair<Value*, char>, Payload> > super;
|
typedef Tree<InstTreeNode<Payload>,
|
||||||
|
std::pair<std::pair<Value*, char>, Payload> > super;
|
||||||
|
|
||||||
// Constants used for the node type value
|
// Constants used for the node type value
|
||||||
enum NodeTypeTy {
|
enum NodeTypeTy {
|
||||||
@ -104,15 +106,15 @@ public:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// print - Called by operator<< below...
|
// print - Called by operator<< below...
|
||||||
void print(ostream &o, unsigned Indent) const {
|
void print(std::ostream &o, unsigned Indent) const {
|
||||||
o << string(Indent*2, ' ');
|
o << std::string(Indent*2, ' ');
|
||||||
switch (getNodeType()) {
|
switch (getNodeType()) {
|
||||||
case ConstNode : o << "Constant : "; break;
|
case ConstNode : o << "Constant : "; break;
|
||||||
case BasicBlockNode : o << "BasicBlock : " << getValue()->getName() << endl;
|
case BasicBlockNode : o << "BasicBlock : " << getValue()->getName() << "\n";
|
||||||
return;
|
return;
|
||||||
case InstructionNode: o << "Instruction: "; break;
|
case InstructionNode: o << "Instruction: "; break;
|
||||||
case TemporaryNode : o << "Temporary : "; break;
|
case TemporaryNode : o << "Temporary : "; break;
|
||||||
default: o << "UNKNOWN NODE TYPE: " << getNodeType() << endl; abort();
|
default: o << "UNKNOWN NODE TYPE: " << getNodeType() << "\n"; abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
o << getValue();
|
o << getValue();
|
||||||
@ -124,7 +126,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
template<class Payload>
|
template<class Payload>
|
||||||
inline ostream &operator<<(ostream &o, const InstTreeNode<Payload> *N) {
|
inline std::ostream &operator<<(std::ostream &o,
|
||||||
|
const InstTreeNode<Payload> *N) {
|
||||||
N->print(o, 0); return o;
|
N->print(o, 0); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,16 +140,16 @@ inline ostream &operator<<(ostream &o, const InstTreeNode<Payload> *N) {
|
|||||||
// guaranteed to be an instruction node. The constructor builds the forest.
|
// guaranteed to be an instruction node. The constructor builds the forest.
|
||||||
//
|
//
|
||||||
template<class Payload>
|
template<class Payload>
|
||||||
class InstForest : public vector<InstTreeNode<Payload> *> {
|
class InstForest : public std::vector<InstTreeNode<Payload> *> {
|
||||||
friend class InstTreeNode<Payload>;
|
friend class InstTreeNode<Payload>;
|
||||||
|
|
||||||
// InstMap - Map contains entries for ALL instructions in the method and the
|
// InstMap - Map contains entries for ALL instructions in the method and the
|
||||||
// InstTreeNode that they correspond to.
|
// InstTreeNode that they correspond to.
|
||||||
//
|
//
|
||||||
map<Instruction*, InstTreeNode<Payload> *> InstMap;
|
std::map<Instruction*, InstTreeNode<Payload> *> InstMap;
|
||||||
|
|
||||||
void addInstMapping(Instruction *I, InstTreeNode<Payload> *IN) {
|
void addInstMapping(Instruction *I, InstTreeNode<Payload> *IN) {
|
||||||
InstMap.insert(make_pair(I, IN));
|
InstMap.insert(std::make_pair(I, IN));
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeInstFromRootList(Instruction *I) {
|
void removeInstFromRootList(Instruction *I) {
|
||||||
@ -180,26 +183,27 @@ public:
|
|||||||
// the parent pointer can be used to find the root of the tree.
|
// the parent pointer can be used to find the root of the tree.
|
||||||
//
|
//
|
||||||
inline InstTreeNode<Payload> *getInstNode(Instruction *Inst) {
|
inline InstTreeNode<Payload> *getInstNode(Instruction *Inst) {
|
||||||
map<Instruction*, InstTreeNode<Payload> *>::iterator I = InstMap.find(Inst);
|
std::map<Instruction*, InstTreeNode<Payload> *>::iterator I =
|
||||||
|
InstMap.find(Inst);
|
||||||
if (I != InstMap.end()) return I->second;
|
if (I != InstMap.end()) return I->second;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
inline const InstTreeNode<Payload> *getInstNode(const Instruction *Inst)const{
|
inline const InstTreeNode<Payload> *getInstNode(const Instruction *Inst)const{
|
||||||
map<Instruction*, InstTreeNode<Payload>*>::const_iterator I =
|
std::map<Instruction*, InstTreeNode<Payload>*>::const_iterator I =
|
||||||
InstMap.find(Inst);
|
InstMap.find(Inst);
|
||||||
if (I != InstMap.end()) return I->second;
|
if (I != InstMap.end()) return I->second;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// print - Called by operator<< below...
|
// print - Called by operator<< below...
|
||||||
void print(ostream &out) const {
|
void print(std::ostream &out) const {
|
||||||
for (const_iterator I = begin(), E = end(); I != E; ++I)
|
for (const_iterator I = begin(), E = end(); I != E; ++I)
|
||||||
out << *I;
|
out << *I;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<class Payload>
|
template<class Payload>
|
||||||
inline ostream &operator<<(ostream &o, const InstForest<Payload> &IF) {
|
inline std::ostream &operator<<(std::ostream &o, const InstForest<Payload> &IF){
|
||||||
IF.print(o); return o;
|
IF.print(o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +258,7 @@ InstTreeNode<Payload>::InstTreeNode(InstForest<Payload> &IF, Value *V,
|
|||||||
// Otherwise, we are an internal instruction node. We must process our
|
// Otherwise, we are an internal instruction node. We must process our
|
||||||
// uses and add them as children of this node.
|
// uses and add them as children of this node.
|
||||||
//
|
//
|
||||||
vector<InstTreeNode*> Children;
|
std::vector<InstTreeNode*> Children;
|
||||||
|
|
||||||
// Make sure that the forest knows about us!
|
// Make sure that the forest knows about us!
|
||||||
IF.addInstMapping(I, this);
|
IF.addInstMapping(I, this);
|
||||||
|
@ -31,9 +31,9 @@ class Interval {
|
|||||||
//
|
//
|
||||||
BasicBlock *HeaderNode;
|
BasicBlock *HeaderNode;
|
||||||
public:
|
public:
|
||||||
typedef vector<BasicBlock*>::iterator succ_iterator;
|
typedef std::vector<BasicBlock*>::iterator succ_iterator;
|
||||||
typedef vector<BasicBlock*>::iterator pred_iterator;
|
typedef std::vector<BasicBlock*>::iterator pred_iterator;
|
||||||
typedef vector<BasicBlock*>::iterator node_iterator;
|
typedef std::vector<BasicBlock*>::iterator node_iterator;
|
||||||
|
|
||||||
inline Interval(BasicBlock *Header) : HeaderNode(Header) {
|
inline Interval(BasicBlock *Header) : HeaderNode(Header) {
|
||||||
Nodes.push_back(Header);
|
Nodes.push_back(Header);
|
||||||
@ -46,18 +46,18 @@ public:
|
|||||||
|
|
||||||
// Nodes - The basic blocks in this interval.
|
// Nodes - The basic blocks in this interval.
|
||||||
//
|
//
|
||||||
vector<BasicBlock*> Nodes;
|
std::vector<BasicBlock*> Nodes;
|
||||||
|
|
||||||
// Successors - List of BasicBlocks that are reachable directly from nodes in
|
// Successors - List of BasicBlocks that are reachable directly from nodes in
|
||||||
// this interval, but are not in the interval themselves.
|
// this interval, but are not in the interval themselves.
|
||||||
// These nodes neccesarily must be header nodes for other intervals.
|
// These nodes neccesarily must be header nodes for other intervals.
|
||||||
//
|
//
|
||||||
vector<BasicBlock*> Successors;
|
std::vector<BasicBlock*> Successors;
|
||||||
|
|
||||||
// Predecessors - List of BasicBlocks that have this Interval's header block
|
// Predecessors - List of BasicBlocks that have this Interval's header block
|
||||||
// as one of their successors.
|
// as one of their successors.
|
||||||
//
|
//
|
||||||
vector<BasicBlock*> Predecessors;
|
std::vector<BasicBlock*> Predecessors;
|
||||||
|
|
||||||
// contains - Find out if a basic block is in this interval
|
// contains - Find out if a basic block is in this interval
|
||||||
inline bool contains(BasicBlock *BB) const {
|
inline bool contains(BasicBlock *BB) const {
|
||||||
|
@ -79,8 +79,8 @@ inline void addNodeToInterval(Interval *Int, Interval *I) {
|
|||||||
|
|
||||||
template<class NodeTy, class OrigContainer_t>
|
template<class NodeTy, class OrigContainer_t>
|
||||||
class IntervalIterator {
|
class IntervalIterator {
|
||||||
stack<pair<Interval*, typename Interval::succ_iterator> > IntStack;
|
std::stack<std::pair<Interval*, typename Interval::succ_iterator> > IntStack;
|
||||||
set<BasicBlock*> Visited;
|
std::set<BasicBlock*> Visited;
|
||||||
OrigContainer_t *OrigContainer;
|
OrigContainer_t *OrigContainer;
|
||||||
bool IOwnMem; // If True, delete intervals when done with them
|
bool IOwnMem; // If True, delete intervals when done with them
|
||||||
// See file header for conditions of use
|
// See file header for conditions of use
|
||||||
@ -88,7 +88,7 @@ public:
|
|||||||
typedef BasicBlock* _BB;
|
typedef BasicBlock* _BB;
|
||||||
|
|
||||||
typedef IntervalIterator<NodeTy, OrigContainer_t> _Self;
|
typedef IntervalIterator<NodeTy, OrigContainer_t> _Self;
|
||||||
typedef forward_iterator_tag iterator_category;
|
typedef std::forward_iterator_tag iterator_category;
|
||||||
|
|
||||||
IntervalIterator() {} // End iterator, empty stack
|
IntervalIterator() {} // End iterator, empty stack
|
||||||
IntervalIterator(Method *M, bool OwnMemory) : IOwnMem(OwnMemory) {
|
IntervalIterator(Method *M, bool OwnMemory) : IOwnMem(OwnMemory) {
|
||||||
|
@ -31,11 +31,11 @@ namespace cfg {
|
|||||||
// BasicBlock is a (possibly nonexistent) loop with a "tail" of non looping
|
// BasicBlock is a (possibly nonexistent) loop with a "tail" of non looping
|
||||||
// nodes following it.
|
// nodes following it.
|
||||||
//
|
//
|
||||||
class IntervalPartition : public vector<Interval*> {
|
class IntervalPartition : public std::vector<Interval*> {
|
||||||
typedef map<BasicBlock*, Interval*> IntervalMapTy;
|
typedef std::map<BasicBlock*, Interval*> IntervalMapTy;
|
||||||
IntervalMapTy IntervalMap;
|
IntervalMapTy IntervalMap;
|
||||||
|
|
||||||
typedef vector<Interval*> IntervalListTy;
|
typedef std::vector<Interval*> IntervalListTy;
|
||||||
Interval *RootInterval;
|
Interval *RootInterval;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
#ifndef LIVE_VAR_MAP_H
|
#ifndef LIVE_VAR_MAP_H
|
||||||
#define LIVE_VAR_MAP_H
|
#define LIVE_VAR_MAP_H
|
||||||
|
|
||||||
#include <hash_map>
|
#include <ext/hash_map>
|
||||||
|
|
||||||
class BasicBlock;
|
class BasicBlock;
|
||||||
class BBLiveVar;
|
class BBLiveVar;
|
||||||
@ -34,10 +34,10 @@ struct hashFuncBB { // sturcture containing the hash function for BB
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef hash_map<const BasicBlock *,
|
typedef std::hash_map<const BasicBlock *,
|
||||||
BBLiveVar *, hashFuncBB > BBToBBLiveVarMapType;
|
BBLiveVar *, hashFuncBB > BBToBBLiveVarMapType;
|
||||||
|
|
||||||
typedef hash_map<const MachineInstr *, const LiveVarSet *,
|
typedef std::hash_map<const MachineInstr *, const LiveVarSet *,
|
||||||
hashFuncMInst> MInstToLiveVarSetMapType;
|
hashFuncMInst> MInstToLiveVarSetMapType;
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#ifndef LIVE_VAR_SET_H
|
#ifndef LIVE_VAR_SET_H
|
||||||
#define LIVE_VAR_SET_H
|
#define LIVE_VAR_SET_H
|
||||||
|
|
||||||
#include "ValueSet.h"
|
#include "llvm/Analysis/LiveVar/ValueSet.h"
|
||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Title: ValueSet.h
|
/* Title: ValueSet.h -*- C++ -*-
|
||||||
Author: Ruchira Sasanka
|
Author: Ruchira Sasanka
|
||||||
Date: Jun 30, 01
|
Date: Jun 30, 01
|
||||||
Purpose: Contains a mathematical set of Values. LiveVarSet is derived from
|
Purpose: Contains a mathematical set of Values. LiveVarSet is derived from
|
||||||
@ -8,24 +8,9 @@
|
|||||||
#ifndef VALUE_SET_H
|
#ifndef VALUE_SET_H
|
||||||
#define VALUE_SET_H
|
#define VALUE_SET_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
class Value;
|
||||||
|
#include "Support/HashExtras.h"
|
||||||
#include <hash_set>
|
#include <ext/hash_set>
|
||||||
#include <algorithm>
|
|
||||||
//#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "llvm/Value.h"
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------ Support functions ---------------------------------
|
|
||||||
|
|
||||||
struct hashFuncValue { // sturcture containing the hash func
|
|
||||||
inline size_t operator () (const Value *const val) const
|
|
||||||
{ return (size_t) val; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------- Class Definition for ValueSet --------------------------
|
//------------------- Class Definition for ValueSet --------------------------
|
||||||
|
|
||||||
@ -33,12 +18,8 @@ void printValue( const Value *const v); // func to print a Value
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ValueSet : public hash_set<const Value *, hashFuncValue >
|
class ValueSet : public std::hash_set<const Value *> {
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueSet(); // constructor
|
|
||||||
|
|
||||||
inline void add(const Value *const val)
|
inline void add(const Value *const val)
|
||||||
{ assert( val ); insert(val);} // for adding a live variable to set
|
{ assert( val ); insert(val);} // for adding a live variable to set
|
||||||
|
|
||||||
|
@ -14,14 +14,14 @@ class Method;
|
|||||||
namespace cfg {class Interval; }
|
namespace cfg {class Interval; }
|
||||||
|
|
||||||
class LoopDepthCalculator {
|
class LoopDepthCalculator {
|
||||||
map<const BasicBlock*, unsigned> LoopDepth;
|
std::map<const BasicBlock*, unsigned> LoopDepth;
|
||||||
inline void AddBB(const BasicBlock *BB); // Increment count for this block
|
inline void AddBB(const BasicBlock *BB); // Increment count for this block
|
||||||
inline void ProcessInterval(cfg::Interval *I);
|
inline void ProcessInterval(cfg::Interval *I);
|
||||||
public:
|
public:
|
||||||
LoopDepthCalculator(Method *M);
|
LoopDepthCalculator(Method *M);
|
||||||
|
|
||||||
inline unsigned getLoopDepth(const BasicBlock *BB) const {
|
inline unsigned getLoopDepth(const BasicBlock *BB) const {
|
||||||
map<const BasicBlock*, unsigned>::const_iterator I = LoopDepth.find(BB);
|
std::map<const BasicBlock*,unsigned>::const_iterator I = LoopDepth.find(BB);
|
||||||
return I != LoopDepth.end() ? I->second : 0;
|
return I != LoopDepth.end() ? I->second : 0;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -25,8 +25,8 @@ namespace cfg {
|
|||||||
//
|
//
|
||||||
class Loop {
|
class Loop {
|
||||||
Loop *ParentLoop;
|
Loop *ParentLoop;
|
||||||
vector<const BasicBlock *> Blocks; // First entry is the header node
|
std::vector<const BasicBlock *> Blocks; // First entry is the header node
|
||||||
vector<Loop*> SubLoops; // Loops contained entirely within this one
|
std::vector<Loop*> SubLoops; // Loops contained entirely within this one
|
||||||
unsigned LoopDepth; // Nesting depth of this loop
|
unsigned LoopDepth; // Nesting depth of this loop
|
||||||
|
|
||||||
Loop(const Loop &); // DO NOT IMPLEMENT
|
Loop(const Loop &); // DO NOT IMPLEMENT
|
||||||
@ -40,8 +40,10 @@ public:
|
|||||||
bool contains(const BasicBlock *BB) const;
|
bool contains(const BasicBlock *BB) const;
|
||||||
|
|
||||||
// getSubLoops - Return the loops contained entirely within this loop
|
// getSubLoops - Return the loops contained entirely within this loop
|
||||||
inline const vector<Loop*> &getSubLoops() const { return SubLoops; }
|
inline const std::vector<Loop*> &getSubLoops() const { return SubLoops; }
|
||||||
inline const vector<const BasicBlock*> &getBlocks() const { return Blocks; }
|
inline const std::vector<const BasicBlock*> &getBlocks() const {
|
||||||
|
return Blocks;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class LoopInfo;
|
friend class LoopInfo;
|
||||||
@ -62,19 +64,19 @@ private:
|
|||||||
//
|
//
|
||||||
class LoopInfo {
|
class LoopInfo {
|
||||||
// BBMap - Mapping of basic blocks to the inner most loop they occur in
|
// BBMap - Mapping of basic blocks to the inner most loop they occur in
|
||||||
map<const BasicBlock *, Loop*> BBMap;
|
std::map<const BasicBlock *, Loop*> BBMap;
|
||||||
vector<Loop*> TopLevelLoops;
|
std::vector<Loop*> TopLevelLoops;
|
||||||
public:
|
public:
|
||||||
// LoopInfo ctor - Calculate the natural loop information for a CFG
|
// LoopInfo ctor - Calculate the natural loop information for a CFG
|
||||||
LoopInfo(const DominatorSet &DS);
|
LoopInfo(const DominatorSet &DS);
|
||||||
|
|
||||||
const vector<Loop*> &getTopLevelLoops() const { return TopLevelLoops; }
|
const std::vector<Loop*> &getTopLevelLoops() const { return TopLevelLoops; }
|
||||||
|
|
||||||
// getLoopFor - Return the inner most loop that BB lives in. If a basic block
|
// getLoopFor - Return the inner most loop that BB lives in. If a basic block
|
||||||
// is in no loop (for example the entry node), null is returned.
|
// is in no loop (for example the entry node), null is returned.
|
||||||
//
|
//
|
||||||
const Loop *getLoopFor(const BasicBlock *BB) const {
|
const Loop *getLoopFor(const BasicBlock *BB) const {
|
||||||
map<const BasicBlock *, Loop*>::const_iterator I = BBMap.find(BB);
|
std::map<const BasicBlock *, Loop*>::const_iterator I = BBMap.find(BB);
|
||||||
return I != BBMap.end() ? I->second : 0;
|
return I != BBMap.end() ? I->second : 0;
|
||||||
}
|
}
|
||||||
inline const Loop *operator[](const BasicBlock *BB) const {
|
inline const Loop *operator[](const BasicBlock *BB) const {
|
||||||
|
@ -78,7 +78,7 @@ protected:
|
|||||||
virtual bool processInstruction(const Instruction *I) { return false; }
|
virtual bool processInstruction(const Instruction *I) { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool handleType(set<const Type *> &TypeSet, const Type *T);
|
bool handleType(std::set<const Type *> &TypeSet, const Type *T);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -23,14 +23,14 @@ class SlotCalculator {
|
|||||||
const Module *TheModule;
|
const Module *TheModule;
|
||||||
bool IgnoreNamedNodes; // Shall we not count named nodes?
|
bool IgnoreNamedNodes; // Shall we not count named nodes?
|
||||||
|
|
||||||
typedef vector<const Value*> TypePlane;
|
typedef std::vector<const Value*> TypePlane;
|
||||||
vector<TypePlane> Table;
|
std::vector<TypePlane> Table;
|
||||||
map<const Value *, unsigned> NodeMap;
|
std::map<const Value *, unsigned> NodeMap;
|
||||||
|
|
||||||
// ModuleLevel - Used to keep track of which values belong to the module,
|
// ModuleLevel - Used to keep track of which values belong to the module,
|
||||||
// and which values belong to the currently incorporated method.
|
// and which values belong to the currently incorporated method.
|
||||||
//
|
//
|
||||||
vector<unsigned> ModuleLevel;
|
std::vector<unsigned> ModuleLevel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SlotCalculator(const Module *M, bool IgnoreNamed);
|
SlotCalculator(const Module *M, bool IgnoreNamed);
|
||||||
|
@ -22,7 +22,7 @@ class Method;
|
|||||||
// error messages corresponding to the problem are added to the errorMsgs
|
// error messages corresponding to the problem are added to the errorMsgs
|
||||||
// vectors, and a value of true is returned.
|
// vectors, and a value of true is returned.
|
||||||
//
|
//
|
||||||
bool verify(const Module *M, vector<string> &ErrorMsgs);
|
bool verify(const Module *M, std::vector<std::string> &ErrorMsgs);
|
||||||
bool verify(const Method *M, vector<string> &ErrorMsgs);
|
bool verify(const Method *M, std::vector<std::string> &ErrorMsgs);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -16,13 +16,14 @@ namespace cfg {
|
|||||||
class Interval;
|
class Interval;
|
||||||
class IntervalPartition;
|
class IntervalPartition;
|
||||||
|
|
||||||
void WriteToOutput(const Interval *I, ostream &o);
|
void WriteToOutput(const Interval *I, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const Interval *I) {
|
inline std::ostream &operator <<(std::ostream &o, const Interval *I) {
|
||||||
WriteToOutput(I, o); return o;
|
WriteToOutput(I, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToOutput(const IntervalPartition &IP, ostream &o);
|
void WriteToOutput(const IntervalPartition &IP, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const IntervalPartition &IP) {
|
inline std::ostream &operator <<(std::ostream &o,
|
||||||
|
const IntervalPartition &IP) {
|
||||||
WriteToOutput(IP, o); return o;
|
WriteToOutput(IP, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,23 +33,25 @@ namespace cfg {
|
|||||||
class DominatorTree;
|
class DominatorTree;
|
||||||
class DominanceFrontier;
|
class DominanceFrontier;
|
||||||
|
|
||||||
void WriteToOutput(const DominatorSet &, ostream &o);
|
void WriteToOutput(const DominatorSet &, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const DominatorSet &DS) {
|
inline std::ostream &operator <<(std::ostream &o, const DominatorSet &DS) {
|
||||||
WriteToOutput(DS, o); return o;
|
WriteToOutput(DS, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToOutput(const ImmediateDominators &, ostream &o);
|
void WriteToOutput(const ImmediateDominators &, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const ImmediateDominators &ID) {
|
inline std::ostream &operator <<(std::ostream &o,
|
||||||
|
const ImmediateDominators &ID) {
|
||||||
WriteToOutput(ID, o); return o;
|
WriteToOutput(ID, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToOutput(const DominatorTree &, ostream &o);
|
void WriteToOutput(const DominatorTree &, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const DominatorTree &DT) {
|
inline std::ostream &operator <<(std::ostream &o, const DominatorTree &DT) {
|
||||||
WriteToOutput(DT, o); return o;
|
WriteToOutput(DT, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToOutput(const DominanceFrontier &, ostream &o);
|
void WriteToOutput(const DominanceFrontier &, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const DominanceFrontier &DF) {
|
inline std::ostream &operator <<(std::ostream &o,
|
||||||
|
const DominanceFrontier &DF) {
|
||||||
WriteToOutput(DF, o); return o;
|
WriteToOutput(DF, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +59,13 @@ namespace cfg {
|
|||||||
class CallGraph;
|
class CallGraph;
|
||||||
class CallGraphNode;
|
class CallGraphNode;
|
||||||
|
|
||||||
void WriteToOutput(const CallGraph &, ostream &o);
|
void WriteToOutput(const CallGraph &, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const CallGraph &CG) {
|
inline std::ostream &operator <<(std::ostream &o, const CallGraph &CG) {
|
||||||
WriteToOutput(CG, o); return o;
|
WriteToOutput(CG, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToOutput(const CallGraphNode *, ostream &o);
|
void WriteToOutput(const CallGraphNode *, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const CallGraphNode *CGN) {
|
inline std::ostream &operator <<(std::ostream &o, const CallGraphNode *CGN) {
|
||||||
WriteToOutput(CGN, o); return o;
|
WriteToOutput(CGN, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,21 +73,21 @@ namespace cfg {
|
|||||||
class Loop;
|
class Loop;
|
||||||
class LoopInfo;
|
class LoopInfo;
|
||||||
|
|
||||||
void WriteToOutput(const LoopInfo &, ostream &o);
|
void WriteToOutput(const LoopInfo &, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const LoopInfo &LI) {
|
inline std::ostream &operator <<(std::ostream &o, const LoopInfo &LI) {
|
||||||
WriteToOutput(LI, o); return o;
|
WriteToOutput(LI, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WriteToOutput(const Loop *, ostream &o);
|
void WriteToOutput(const Loop *, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const Loop *L) {
|
inline std::ostream &operator <<(std::ostream &o, const Loop *L) {
|
||||||
WriteToOutput(L, o); return o;
|
WriteToOutput(L, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End namespace CFG
|
} // End namespace CFG
|
||||||
|
|
||||||
class InductionVariable;
|
class InductionVariable;
|
||||||
void WriteToOutput(const InductionVariable &, ostream &o);
|
void WriteToOutput(const InductionVariable &, std::ostream &o);
|
||||||
inline ostream &operator <<(ostream &o, const InductionVariable &IV) {
|
inline std::ostream &operator <<(std::ostream &o, const InductionVariable &IV) {
|
||||||
WriteToOutput(IV, o); return o;
|
WriteToOutput(IV, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -166,12 +166,13 @@ struct AnnotationManager {
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Basic ID <-> Name map functionality
|
// Basic ID <-> Name map functionality
|
||||||
|
|
||||||
static AnnotationID getID (const string &Name); // Name -> ID
|
static AnnotationID getID(const std::string &Name); // Name -> ID
|
||||||
static const string &getName(AnnotationID ID); // ID -> Name
|
static const std::string &getName(AnnotationID ID); // ID -> Name
|
||||||
|
|
||||||
// getID - Name -> ID + registration of a factory function for demand driven
|
// getID - Name -> ID + registration of a factory function for demand driven
|
||||||
// annotation support.
|
// annotation support.
|
||||||
static AnnotationID getID (const string &Name, Factory Fact, void *Data=0);
|
static AnnotationID getID(const std::string &Name, Factory Fact,
|
||||||
|
void *Data = 0);
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Annotation creation on demand support...
|
// Annotation creation on demand support...
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#define LLVM_ASSEMBLY_CACHED_WRITER_H
|
#define LLVM_ASSEMBLY_CACHED_WRITER_H
|
||||||
|
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
class AssemblyWriter; // Internal private class
|
class AssemblyWriter; // Internal private class
|
||||||
class SlotCalculator;
|
class SlotCalculator;
|
||||||
@ -19,10 +20,11 @@ class CachedWriter {
|
|||||||
AssemblyWriter *AW;
|
AssemblyWriter *AW;
|
||||||
SlotCalculator *SC;
|
SlotCalculator *SC;
|
||||||
public:
|
public:
|
||||||
ostream &Out;
|
std::ostream &Out;
|
||||||
public:
|
public:
|
||||||
CachedWriter(ostream &O = cout) : AW(0), SC(0), Out(O) { }
|
CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { }
|
||||||
CachedWriter(const Module *M, ostream &O = cout) : AW(0), SC(0), Out(O) {
|
CachedWriter(const Module *M, std::ostream &O = std::cout)
|
||||||
|
: AW(0), SC(0), Out(O) {
|
||||||
setModule(M);
|
setModule(M);
|
||||||
}
|
}
|
||||||
~CachedWriter();
|
~CachedWriter();
|
||||||
@ -63,7 +65,7 @@ public:
|
|||||||
return *this << (const Value*)X;
|
return *this << (const Value*)X;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline CachedWriter &operator<<(ostream &(&Manip)(ostream &)) {
|
inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) {
|
||||||
Out << Manip; return *this;
|
Out << Manip; return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class ParseException;
|
|||||||
// The useful interface defined by this file... Parse an ascii file, and return
|
// The useful interface defined by this file... Parse an ascii file, and return
|
||||||
// the internal representation in a nice slice'n'dice'able representation.
|
// the internal representation in a nice slice'n'dice'able representation.
|
||||||
//
|
//
|
||||||
Module *ParseAssemblyFile(const string &Filename);// throw (ParseException);
|
Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException)
|
||||||
|
|
||||||
//===------------------------------------------------------------------------===
|
//===------------------------------------------------------------------------===
|
||||||
// Helper Classes
|
// Helper Classes
|
||||||
@ -27,7 +27,7 @@ Module *ParseAssemblyFile(const string &Filename);// throw (ParseException);
|
|||||||
//
|
//
|
||||||
class ParseException {
|
class ParseException {
|
||||||
public:
|
public:
|
||||||
ParseException(const string &filename, const string &message,
|
ParseException(const std::string &filename, const std::string &message,
|
||||||
int LineNo = -1, int ColNo = -1);
|
int LineNo = -1, int ColNo = -1);
|
||||||
|
|
||||||
ParseException(const ParseException &E);
|
ParseException(const ParseException &E);
|
||||||
@ -35,13 +35,13 @@ public:
|
|||||||
// getMessage - Return the message passed in at construction time plus extra
|
// getMessage - Return the message passed in at construction time plus extra
|
||||||
// information extracted from the options used to parse with...
|
// information extracted from the options used to parse with...
|
||||||
//
|
//
|
||||||
const string getMessage() const;
|
const std::string getMessage() const;
|
||||||
|
|
||||||
inline const string getRawMessage() const { // Just the raw message...
|
inline const std::string &getRawMessage() const { // Just the raw message...
|
||||||
return Message;
|
return Message;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const string &getFilename() const {
|
inline const std::string &getFilename() const {
|
||||||
return Filename;
|
return Filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +55,8 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private :
|
private :
|
||||||
string Filename;
|
std::string Filename;
|
||||||
string Message;
|
std::string Message;
|
||||||
int LineNo, ColumnNo; // -1 if not relevant
|
int LineNo, ColumnNo; // -1 if not relevant
|
||||||
|
|
||||||
ParseException &operator=(const ParseException &E); // objects by reference
|
ParseException &operator=(const ParseException &E); // objects by reference
|
||||||
|
@ -10,14 +10,15 @@
|
|||||||
|
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Assembly/Writer.h"
|
#include "llvm/Assembly/Writer.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
class PrintModulePass : public Pass {
|
class PrintModulePass : public Pass {
|
||||||
string Banner; // String to print before each method
|
std::string Banner; // String to print before each method
|
||||||
ostream *Out; // ostream to print on
|
std::ostream *Out; // ostream to print on
|
||||||
bool DeleteStream; // Delete the ostream in our dtor?
|
bool DeleteStream; // Delete the ostream in our dtor?
|
||||||
bool PrintPerMethod; // Print one method at a time rather than the whole?
|
bool PrintPerMethod; // Print one method at a time rather than the whole?
|
||||||
public:
|
public:
|
||||||
inline PrintModulePass(const string &B, ostream *o = &cout,
|
inline PrintModulePass(const std::string &B, std::ostream *o = &std::cout,
|
||||||
bool DS = false,
|
bool DS = false,
|
||||||
bool printPerMethod = true)
|
bool printPerMethod = true)
|
||||||
: Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
|
: Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) {
|
||||||
|
@ -30,25 +30,25 @@ class SlotCalculator;
|
|||||||
// representation of an object into an ascii bytestream that the parser can
|
// representation of an object into an ascii bytestream that the parser can
|
||||||
// understand later... (the parser only understands whole classes though)
|
// understand later... (the parser only understands whole classes though)
|
||||||
//
|
//
|
||||||
void WriteToAssembly(const Module *Module, ostream &o);
|
void WriteToAssembly(const Module *Module, std::ostream &o);
|
||||||
void WriteToAssembly(const GlobalVariable *G, ostream &o);
|
void WriteToAssembly(const GlobalVariable *G, std::ostream &o);
|
||||||
void WriteToAssembly(const Method *Method, ostream &o);
|
void WriteToAssembly(const Method *Method, std::ostream &o);
|
||||||
void WriteToAssembly(const BasicBlock *BB, ostream &o);
|
void WriteToAssembly(const BasicBlock *BB, std::ostream &o);
|
||||||
void WriteToAssembly(const Instruction *In, ostream &o);
|
void WriteToAssembly(const Instruction *In, std::ostream &o);
|
||||||
void WriteToAssembly(const Constant *V, ostream &o);
|
void WriteToAssembly(const Constant *V, std::ostream &o);
|
||||||
|
|
||||||
// WriteTypeSymbolic - This attempts to write the specified type as a symbolic
|
// WriteTypeSymbolic - This attempts to write the specified type as a symbolic
|
||||||
// type, iff there is an entry in the modules symbol table for the specified
|
// type, iff there is an entry in the modules symbol table for the specified
|
||||||
// type or one of it's component types. This is slower than a simple x << Type;
|
// type or one of it's component types. This is slower than a simple x << Type;
|
||||||
//
|
//
|
||||||
ostream &WriteTypeSymbolic(ostream &o, const Type *Ty, const Module *Module);
|
std::ostream &WriteTypeSymbolic(std::ostream &, const Type *, const Module *M);
|
||||||
|
|
||||||
|
|
||||||
// WriteAsOperand - Write the name of the specified value out to the specified
|
// WriteAsOperand - Write the name of the specified value out to the specified
|
||||||
// ostream. This can be useful when you just want to print int %reg126, not the
|
// ostream. This can be useful when you just want to print int %reg126, not the
|
||||||
// whole instruction that generated it.
|
// whole instruction that generated it.
|
||||||
//
|
//
|
||||||
ostream &WriteAsOperand(ostream &o, const Value *V, bool PrintType = true,
|
std::ostream &WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true,
|
||||||
bool PrintName = true, SlotCalculator *Table = 0);
|
bool PrintName = true, SlotCalculator *Table = 0);
|
||||||
|
|
||||||
|
|
||||||
@ -57,8 +57,8 @@ ostream &WriteAsOperand(ostream &o, const Value *V, bool PrintType = true,
|
|||||||
// family of files with a common base name is created, with a method name
|
// family of files with a common base name is created, with a method name
|
||||||
// suffix.
|
// suffix.
|
||||||
//
|
//
|
||||||
void WriteToVCG(const Module *Module, const string &Filename);
|
void WriteToVCG(const Module *Module, const std::string &Filename);
|
||||||
void WriteToVCG(const Method *Method, const string &Filename);
|
void WriteToVCG(const Method *Method, const std::string &Filename);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -66,37 +66,37 @@ void WriteToVCG(const Method *Method, const string &Filename);
|
|||||||
// Define operator<< to work on the various classes that we can send to an
|
// Define operator<< to work on the various classes that we can send to an
|
||||||
// ostream...
|
// ostream...
|
||||||
//
|
//
|
||||||
inline ostream &operator<<(ostream &o, const Module *C) {
|
inline std::ostream &operator<<(std::ostream &o, const Module *C) {
|
||||||
WriteToAssembly(C, o); return o;
|
WriteToAssembly(C, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostream &operator<<(ostream &o, const GlobalVariable *G) {
|
inline std::ostream &operator<<(std::ostream &o, const GlobalVariable *G) {
|
||||||
WriteToAssembly(G, o); return o;
|
WriteToAssembly(G, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostream &operator<<(ostream &o, const Method *M) {
|
inline std::ostream &operator<<(std::ostream &o, const Method *M) {
|
||||||
WriteToAssembly(M, o); return o;
|
WriteToAssembly(M, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostream &operator<<(ostream &o, const BasicBlock *B) {
|
inline std::ostream &operator<<(std::ostream &o, const BasicBlock *B) {
|
||||||
WriteToAssembly(B, o); return o;
|
WriteToAssembly(B, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostream &operator<<(ostream &o, const Instruction *I) {
|
inline std::ostream &operator<<(std::ostream &o, const Instruction *I) {
|
||||||
WriteToAssembly(I, o); return o;
|
WriteToAssembly(I, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostream &operator<<(ostream &o, const Constant *I) {
|
inline std::ostream &operator<<(std::ostream &o, const Constant *I) {
|
||||||
WriteToAssembly(I, o); return o;
|
WriteToAssembly(I, o); return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline ostream &operator<<(ostream &o, const Type *T) {
|
inline std::ostream &operator<<(std::ostream &o, const Type *T) {
|
||||||
if (!T) return o << "<null Type>";
|
if (!T) return o << "<null Type>";
|
||||||
return o << T->getDescription();
|
return o << T->getDescription();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ostream &operator<<(ostream &o, const Value *I) {
|
inline std::ostream &operator<<(std::ostream &o, const Value *I) {
|
||||||
switch (I->getValueType()) {
|
switch (I->getValueType()) {
|
||||||
case Value::TypeVal: return o << cast<const Type>(I);
|
case Value::TypeVal: return o << cast<const Type>(I);
|
||||||
case Value::ConstantVal: WriteToAssembly(cast<Constant>(I) , o); break;
|
case Value::ConstantVal: WriteToAssembly(cast<Constant>(I) , o); break;
|
||||||
|
@ -49,8 +49,8 @@ public:
|
|||||||
// Instruction iterators...
|
// Instruction iterators...
|
||||||
typedef InstListType::iterator iterator;
|
typedef InstListType::iterator iterator;
|
||||||
typedef InstListType::const_iterator const_iterator;
|
typedef InstListType::const_iterator const_iterator;
|
||||||
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
typedef reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
|
||||||
// Predecessor and successor iterators...
|
// Predecessor and successor iterators...
|
||||||
typedef PredIterator<BasicBlock, Value::use_iterator> pred_iterator;
|
typedef PredIterator<BasicBlock, Value::use_iterator> pred_iterator;
|
||||||
@ -61,11 +61,11 @@ public:
|
|||||||
const BasicBlock> succ_const_iterator;
|
const BasicBlock> succ_const_iterator;
|
||||||
|
|
||||||
// Ctor, dtor
|
// Ctor, dtor
|
||||||
BasicBlock(const string &Name = "", Method *Parent = 0);
|
BasicBlock(const std::string &Name = "", Method *Parent = 0);
|
||||||
~BasicBlock();
|
~BasicBlock();
|
||||||
|
|
||||||
// Specialize setName to take care of symbol table majik
|
// Specialize setName to take care of symbol table majik
|
||||||
virtual void setName(const string &name, SymbolTable *ST = 0);
|
virtual void setName(const std::string &name, SymbolTable *ST = 0);
|
||||||
|
|
||||||
// getParent - Return the enclosing method, or null if none
|
// getParent - Return the enclosing method, or null if none
|
||||||
const Method *getParent() const { return InstList.getParent(); }
|
const Method *getParent() const { return InstList.getParent(); }
|
||||||
|
@ -116,12 +116,12 @@ static inline bool align32(const unsigned char *&Buf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
|
static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf,
|
||||||
string &Result, bool Aligned = true) {
|
std::string &Result, bool Aligned = true) {
|
||||||
unsigned Size;
|
unsigned Size;
|
||||||
if (read_vbr(Buf, EndBuf, Size)) return true; // Failure reading size?
|
if (read_vbr(Buf, EndBuf, Size)) return true; // Failure reading size?
|
||||||
if (Buf+Size > EndBuf) return true; // Size invalid?
|
if (Buf+Size > EndBuf) return true; // Size invalid?
|
||||||
|
|
||||||
Result = string((char*)Buf, Size);
|
Result = std::string((char*)Buf, Size);
|
||||||
Buf += Size;
|
Buf += Size;
|
||||||
|
|
||||||
if (Aligned) // If we should stay aligned do so...
|
if (Aligned) // If we should stay aligned do so...
|
||||||
@ -157,7 +157,8 @@ static inline bool input_data(const unsigned char *&Buf,
|
|||||||
// string... note that this should be inlined always so only the relevant IF
|
// string... note that this should be inlined always so only the relevant IF
|
||||||
// body should be included...
|
// body should be included...
|
||||||
//
|
//
|
||||||
static inline void output(unsigned i, deque<unsigned char> &Out, int pos = -1){
|
static inline void output(unsigned i, std::deque<unsigned char> &Out,
|
||||||
|
int pos = -1) {
|
||||||
#ifdef LITTLE_ENDIAN
|
#ifdef LITTLE_ENDIAN
|
||||||
if (pos == -1)
|
if (pos == -1)
|
||||||
Out.insert(Out.end(), (unsigned char*)&i, (unsigned char*)&i+4);
|
Out.insert(Out.end(), (unsigned char*)&i, (unsigned char*)&i+4);
|
||||||
@ -178,7 +179,7 @@ static inline void output(unsigned i, deque<unsigned char> &Out, int pos = -1){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void output(int i, deque<unsigned char> &Out) {
|
static inline void output(int i, std::deque<unsigned char> &Out) {
|
||||||
output((unsigned)i, Out);
|
output((unsigned)i, Out);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +192,7 @@ static inline void output(int i, deque<unsigned char> &Out) {
|
|||||||
//
|
//
|
||||||
// Note that using this may cause the output buffer to become unaligned...
|
// Note that using this may cause the output buffer to become unaligned...
|
||||||
//
|
//
|
||||||
static inline void output_vbr(uint64_t i, deque<unsigned char> &out) {
|
static inline void output_vbr(uint64_t i, std::deque<unsigned char> &out) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (i < 0x80) { // done?
|
if (i < 0x80) { // done?
|
||||||
out.push_back((unsigned char)i); // We know the high bit is clear...
|
out.push_back((unsigned char)i); // We know the high bit is clear...
|
||||||
@ -205,7 +206,7 @@ static inline void output_vbr(uint64_t i, deque<unsigned char> &out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void output_vbr(unsigned i, deque<unsigned char> &out) {
|
static inline void output_vbr(unsigned i, std::deque<unsigned char> &out) {
|
||||||
while (1) {
|
while (1) {
|
||||||
if (i < 0x80) { // done?
|
if (i < 0x80) { // done?
|
||||||
out.push_back((unsigned char)i); // We know the high bit is clear...
|
out.push_back((unsigned char)i); // We know the high bit is clear...
|
||||||
@ -219,7 +220,7 @@ static inline void output_vbr(unsigned i, deque<unsigned char> &out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void output_vbr(int64_t i, deque<unsigned char> &out) {
|
static inline void output_vbr(int64_t i, std::deque<unsigned char> &out) {
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
output_vbr(((uint64_t)(-i) << 1) | 1, out); // Set low order sign bit...
|
output_vbr(((uint64_t)(-i) << 1) | 1, out); // Set low order sign bit...
|
||||||
else
|
else
|
||||||
@ -227,7 +228,7 @@ static inline void output_vbr(int64_t i, deque<unsigned char> &out) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static inline void output_vbr(int i, deque<unsigned char> &out) {
|
static inline void output_vbr(int i, std::deque<unsigned char> &out) {
|
||||||
if (i < 0)
|
if (i < 0)
|
||||||
output_vbr(((unsigned)(-i) << 1) | 1, out); // Set low order sign bit...
|
output_vbr(((unsigned)(-i) << 1) | 1, out); // Set low order sign bit...
|
||||||
else
|
else
|
||||||
@ -237,12 +238,12 @@ static inline void output_vbr(int i, deque<unsigned char> &out) {
|
|||||||
// align32 - emit the minimal number of bytes that will bring us to 32 bit
|
// align32 - emit the minimal number of bytes that will bring us to 32 bit
|
||||||
// alignment...
|
// alignment...
|
||||||
//
|
//
|
||||||
static inline void align32(deque<unsigned char> &Out) {
|
static inline void align32(std::deque<unsigned char> &Out) {
|
||||||
int NumPads = (4-(Out.size() & 3)) & 3; // Bytes to get padding to 32 bits
|
int NumPads = (4-(Out.size() & 3)) & 3; // Bytes to get padding to 32 bits
|
||||||
while (NumPads--) Out.push_back((unsigned char)0xAB);
|
while (NumPads--) Out.push_back((unsigned char)0xAB);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void output(const string &s, deque<unsigned char> &Out,
|
static inline void output(const std::string &s, std::deque<unsigned char> &Out,
|
||||||
bool Aligned = true) {
|
bool Aligned = true) {
|
||||||
unsigned Len = s.length();
|
unsigned Len = s.length();
|
||||||
output_vbr(Len, Out); // Strings may have an arbitrary length...
|
output_vbr(Len, Out); // Strings may have an arbitrary length...
|
||||||
@ -253,7 +254,8 @@ static inline void output(const string &s, deque<unsigned char> &Out,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline void output_data(void *Ptr, void *End,
|
static inline void output_data(void *Ptr, void *End,
|
||||||
deque<unsigned char> &Out, bool Align = false) {
|
std::deque<unsigned char> &Out,
|
||||||
|
bool Align = false) {
|
||||||
#ifdef LITTLE_ENDIAN
|
#ifdef LITTLE_ENDIAN
|
||||||
Out.insert(Out.end(), (unsigned char*)Ptr, (unsigned char*)End);
|
Out.insert(Out.end(), (unsigned char*)Ptr, (unsigned char*)End);
|
||||||
#else
|
#else
|
||||||
|
@ -18,8 +18,9 @@ class Module;
|
|||||||
|
|
||||||
// Parse and return a class...
|
// Parse and return a class...
|
||||||
//
|
//
|
||||||
Module *ParseBytecodeFile(const string &Filename, string *ErrorStr = 0);
|
Module *ParseBytecodeFile(const std::string &Filename,
|
||||||
|
std::string *ErrorStr = 0);
|
||||||
Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize,
|
Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize,
|
||||||
string *ErrorStr = 0);
|
std::string *ErrorStr = 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -27,8 +27,7 @@
|
|||||||
#include "llvm/Instruction.h"
|
#include "llvm/Instruction.h"
|
||||||
#include "Support/NonCopyable.h"
|
#include "Support/NonCopyable.h"
|
||||||
#include "Support/HashExtras.h"
|
#include "Support/HashExtras.h"
|
||||||
#include <hash_map>
|
#include <ext/hash_set>
|
||||||
#include <hash_set>
|
|
||||||
|
|
||||||
class Constant;
|
class Constant;
|
||||||
class BasicBlock;
|
class BasicBlock;
|
||||||
@ -239,9 +238,9 @@ protected:
|
|||||||
//
|
//
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
|
|
||||||
class InstrForest : private hash_map<const Instruction *, InstructionNode*> {
|
class InstrForest : private std::hash_map<const Instruction *, InstructionNode*> {
|
||||||
private:
|
private:
|
||||||
hash_set<InstructionNode*> treeRoots;
|
std::hash_set<InstructionNode*> treeRoots;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*ctor*/ InstrForest (Method *M);
|
/*ctor*/ InstrForest (Method *M);
|
||||||
@ -251,7 +250,7 @@ public:
|
|||||||
return (*this)[instr];
|
return (*this)[instr];
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const hash_set<InstructionNode*> &getRootSet() const {
|
inline const std::hash_set<InstructionNode*> &getRootSet() const {
|
||||||
return treeRoots;
|
return treeRoots;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ class TmpInstruction : public Instruction {
|
|||||||
public:
|
public:
|
||||||
// Constructor that uses the type of S1 as the type of the temporary.
|
// Constructor that uses the type of S1 as the type of the temporary.
|
||||||
// s1 must be a valid value. s2 may be NULL.
|
// s1 must be a valid value. s2 may be NULL.
|
||||||
TmpInstruction(OtherOps opcode, Value *s1, Value* s2, const string &name="")
|
TmpInstruction(OtherOps opcode, Value *s1, Value* s2,
|
||||||
|
const std::string &name = "")
|
||||||
: Instruction(s1->getType(), opcode, name)
|
: Instruction(s1->getType(), opcode, name)
|
||||||
{
|
{
|
||||||
assert(s1 != NULL && "Use different constructor if both operands are 0");
|
assert(s1 != NULL && "Use different constructor if both operands are 0");
|
||||||
@ -94,7 +95,7 @@ public:
|
|||||||
// Constructor that allows the type of the temporary to be specified.
|
// Constructor that allows the type of the temporary to be specified.
|
||||||
// Both S1 and S2 may be NULL.
|
// Both S1 and S2 may be NULL.
|
||||||
TmpInstruction(OtherOps opcode, const Type* tmpType,
|
TmpInstruction(OtherOps opcode, const Type* tmpType,
|
||||||
Value *s1, Value* s2, const string &name = "")
|
Value *s1, Value* s2, const std::string &name = "")
|
||||||
: Instruction(tmpType, opcode, name)
|
: Instruction(tmpType, opcode, name)
|
||||||
{
|
{
|
||||||
Initialize(opcode, s1, s2);
|
Initialize(opcode, s1, s2);
|
||||||
|
@ -24,8 +24,6 @@ class TmpInstruction;
|
|||||||
class Constant;
|
class Constant;
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
|
|
||||||
//************************ Exported Functions ******************************/
|
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// Function GetConstantValueAsSignedInt
|
// Function GetConstantValueAsSignedInt
|
||||||
@ -54,7 +52,7 @@ int64_t GetConstantValueAsSignedInt (const Value *V,
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
|
Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
|
||||||
vector<Value*>& chainIdxVec);
|
std::vector<Value*>& chainIdxVec);
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------
|
//------------------------------------------------------------------------
|
||||||
@ -130,11 +128,8 @@ MachineOperand::MachineOperandType
|
|||||||
// fall under case 3; these must be inserted before `minstr'.
|
// fall under case 3; these must be inserted before `minstr'.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
vector<MachineInstr*> FixConstantOperandsForInstr (Instruction* vmInstr,
|
std::vector<MachineInstr*> FixConstantOperandsForInstr (Instruction* vmInstr,
|
||||||
MachineInstr* minstr,
|
MachineInstr* minstr,
|
||||||
TargetMachine& target);
|
TargetMachine& target);
|
||||||
|
|
||||||
|
|
||||||
//**************************************************************************/
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Title: InterferenceGraph.h
|
/* Title: InterferenceGraph.h -*- C++ -*-
|
||||||
Author: Ruchira Sasanka
|
Author: Ruchira Sasanka
|
||||||
Date: July 20, 01
|
Date: July 20, 01
|
||||||
Purpose: Interference Graph used for register coloring.
|
Purpose: Interference Graph used for register coloring.
|
||||||
@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
#include "llvm/CodeGen/IGNode.h"
|
#include "llvm/CodeGen/IGNode.h"
|
||||||
|
|
||||||
typedef vector <IGNode *> IGNodeListType;
|
typedef std::vector <IGNode *> IGNodeListType;
|
||||||
|
|
||||||
|
|
||||||
class InterferenceGraph
|
class InterferenceGraph
|
||||||
@ -47,6 +47,8 @@ class InterferenceGraph
|
|||||||
// to create it after adding all IGNodes to the IGNodeList
|
// to create it after adding all IGNodes to the IGNodeList
|
||||||
|
|
||||||
InterferenceGraph(RegClass *const RC);
|
InterferenceGraph(RegClass *const RC);
|
||||||
|
~InterferenceGraph();
|
||||||
|
|
||||||
void createGraph();
|
void createGraph();
|
||||||
|
|
||||||
void addLRToIG(LiveRange *const LR);
|
void addLRToIG(LiveRange *const LR);
|
||||||
@ -65,12 +67,6 @@ class InterferenceGraph
|
|||||||
|
|
||||||
void printIG() const;
|
void printIG() const;
|
||||||
void printIGNodeList() const;
|
void printIGNodeList() const;
|
||||||
|
|
||||||
~InterferenceGraph();
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -22,8 +22,6 @@
|
|||||||
#include "llvm/Annotation.h"
|
#include "llvm/Annotation.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Method.h"
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <hash_map>
|
|
||||||
#include <hash_set>
|
|
||||||
#include <values.h>
|
#include <values.h>
|
||||||
|
|
||||||
template<class _MI, class _V> class ValOpIterator;
|
template<class _MI, class _V> class ValOpIterator;
|
||||||
@ -131,7 +129,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend ostream& operator<<(ostream& os, const MachineOperand& mop);
|
friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -262,9 +260,9 @@ class MachineInstr : public NonCopyable {
|
|||||||
private:
|
private:
|
||||||
MachineOpCode opCode;
|
MachineOpCode opCode;
|
||||||
OpCodeMask opCodeMask; // extra bits for variants of an opcode
|
OpCodeMask opCodeMask; // extra bits for variants of an opcode
|
||||||
vector<MachineOperand> operands;
|
std::vector<MachineOperand> operands;
|
||||||
vector<Value*> implicitRefs; // values implicitly referenced by this
|
std::vector<Value*> implicitRefs; // values implicitly referenced by this
|
||||||
vector<bool> implicitIsDef; // machine instruction (eg, call args)
|
std::vector<bool> implicitIsDef; // machine instruction (eg, call args)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef ValOpIterator<const MachineInstr, const Value> val_const_op_iterator;
|
typedef ValOpIterator<const MachineInstr, const Value> val_const_op_iterator;
|
||||||
@ -306,9 +304,9 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
friend ostream& operator<<(ostream& os, const MachineInstr& minstr);
|
friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr);
|
||||||
friend val_const_op_iterator;
|
friend class val_const_op_iterator;
|
||||||
friend val_op_iterator;
|
friend class val_op_iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Access to set the operands when building the machine instruction
|
// Access to set the operands when building the machine instruction
|
||||||
@ -449,17 +447,17 @@ public:
|
|||||||
//
|
//
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
class MachineCodeForVMInstr: public vector<MachineInstr*>
|
class MachineCodeForVMInstr: public std::vector<MachineInstr*>
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
vector<Value*> tempVec; // used by m/c instr but not VM instr
|
std::vector<Value*> tempVec; // used by m/c instr but not VM instr
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*ctor*/ MachineCodeForVMInstr () {}
|
/*ctor*/ MachineCodeForVMInstr () {}
|
||||||
/*ctor*/ ~MachineCodeForVMInstr ();
|
/*ctor*/ ~MachineCodeForVMInstr ();
|
||||||
|
|
||||||
const vector<Value*>& getTempValues () const { return tempVec; }
|
const std::vector<Value*>& getTempValues () const { return tempVec; }
|
||||||
vector<Value*>& getTempValues () { return tempVec; }
|
std::vector<Value*>& getTempValues () { return tempVec; }
|
||||||
|
|
||||||
void addTempValue (Value* val) { tempVec.push_back(val); }
|
void addTempValue (Value* val) { tempVec.push_back(val); }
|
||||||
|
|
||||||
@ -499,10 +497,10 @@ MachineCodeForVMInstr::~MachineCodeForVMInstr()
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
class MachineCodeForBasicBlock: public vector<MachineInstr*> {
|
class MachineCodeForBasicBlock: public std::vector<MachineInstr*> {
|
||||||
public:
|
public:
|
||||||
typedef vector<MachineInstr*>::iterator iterator;
|
typedef std::vector<MachineInstr*>::iterator iterator;
|
||||||
typedef vector<const MachineInstr*>::const_iterator const_iterator;
|
typedef std::vector<MachineInstr*>::const_iterator const_iterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -529,8 +527,8 @@ private:
|
|||||||
unsigned currentOptionalArgsSize;
|
unsigned currentOptionalArgsSize;
|
||||||
unsigned maxOptionalArgsSize;
|
unsigned maxOptionalArgsSize;
|
||||||
unsigned currentTmpValuesSize;
|
unsigned currentTmpValuesSize;
|
||||||
hash_set<const Constant*> constantsForConstPool;
|
std::hash_set<const Constant*> constantsForConstPool;
|
||||||
hash_map<const Value*, int> offsets;
|
std::hash_map<const Value*, int> offsets;
|
||||||
// hash_map<const Value*, int> offsetsFromSP;
|
// hash_map<const Value*, int> offsetsFromSP;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -572,7 +570,7 @@ public:
|
|||||||
inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
|
inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
|
||||||
inline unsigned getCurrentOptionalArgsSize() const
|
inline unsigned getCurrentOptionalArgsSize() const
|
||||||
{ return currentOptionalArgsSize;}
|
{ return currentOptionalArgsSize;}
|
||||||
inline const hash_set<const Constant*>&
|
inline const std::hash_set<const Constant*>&
|
||||||
getConstantPoolValues() const {return constantsForConstPool;}
|
getConstantPoolValues() const {return constantsForConstPool;}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -628,10 +626,10 @@ private:
|
|||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
ostream& operator<< (ostream& os, const MachineInstr& minstr);
|
std::ostream& operator<< (std::ostream& os, const MachineInstr& minstr);
|
||||||
|
|
||||||
|
|
||||||
ostream& operator<< (ostream& os, const MachineOperand& mop);
|
std::ostream& operator<< (std::ostream& os, const MachineOperand& mop);
|
||||||
|
|
||||||
|
|
||||||
void PrintMachineInstructions(const Method *method);
|
void PrintMachineInstructions(const Method *method);
|
||||||
|
@ -13,8 +13,9 @@
|
|||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/MachineRegInfo.h"
|
#include "llvm/Target/MachineRegInfo.h"
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
typedef vector<unsigned int> ReservedColorListType;
|
typedef std::vector<unsigned int> ReservedColorListType;
|
||||||
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -46,7 +47,7 @@ class RegClass
|
|||||||
|
|
||||||
InterferenceGraph IG; // Interference graph - constructed by
|
InterferenceGraph IG; // Interference graph - constructed by
|
||||||
// buildInterferenceGraph
|
// buildInterferenceGraph
|
||||||
stack <IGNode *> IGNodeStack; // the stack used for coloring
|
std::stack<IGNode *> IGNodeStack; // the stack used for coloring
|
||||||
|
|
||||||
const ReservedColorListType *const ReservedColorList;
|
const ReservedColorListType *const ReservedColorList;
|
||||||
//
|
//
|
||||||
@ -117,21 +118,14 @@ class RegClass
|
|||||||
|
|
||||||
|
|
||||||
inline void printIGNodeList() const {
|
inline void printIGNodeList() const {
|
||||||
cerr << "IG Nodes for Register Class " << RegClassID << ":" << endl;
|
std::cerr << "IG Nodes for Register Class " << RegClassID << ":" << "\n";
|
||||||
IG.printIGNodeList();
|
IG.printIGNodeList();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void printIG() {
|
inline void printIG() {
|
||||||
cerr << "IG for Register Class " << RegClassID << ":" << endl;
|
std::cerr << "IG for Register Class " << RegClassID << ":" << "\n";
|
||||||
IG.printIG();
|
IG.printIG();
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Title: ValueSet.h
|
/* Title: ValueSet.h -*- C++ -*-
|
||||||
Author: Ruchira Sasanka
|
Author: Ruchira Sasanka
|
||||||
Date: Jun 30, 01
|
Date: Jun 30, 01
|
||||||
Purpose: Contains a mathematical set of Values. LiveVarSet is derived from
|
Purpose: Contains a mathematical set of Values. LiveVarSet is derived from
|
||||||
@ -8,24 +8,9 @@
|
|||||||
#ifndef VALUE_SET_H
|
#ifndef VALUE_SET_H
|
||||||
#define VALUE_SET_H
|
#define VALUE_SET_H
|
||||||
|
|
||||||
#include <stdlib.h>
|
class Value;
|
||||||
|
#include "Support/HashExtras.h"
|
||||||
#include <hash_set>
|
#include <ext/hash_set>
|
||||||
#include <algorithm>
|
|
||||||
//#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
|
|
||||||
#include "llvm/Value.h"
|
|
||||||
|
|
||||||
|
|
||||||
//------------------------ Support functions ---------------------------------
|
|
||||||
|
|
||||||
struct hashFuncValue { // sturcture containing the hash func
|
|
||||||
inline size_t operator () (const Value *const val) const
|
|
||||||
{ return (size_t) val; }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//------------------- Class Definition for ValueSet --------------------------
|
//------------------- Class Definition for ValueSet --------------------------
|
||||||
|
|
||||||
@ -33,12 +18,8 @@ void printValue( const Value *const v); // func to print a Value
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ValueSet : public hash_set<const Value *, hashFuncValue >
|
class ValueSet : public std::hash_set<const Value *> {
|
||||||
{
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ValueSet(); // constructor
|
|
||||||
|
|
||||||
inline void add(const Value *const val)
|
inline void add(const Value *const val)
|
||||||
{ assert( val ); insert(val);} // for adding a live variable to set
|
{ assert( val ); insert(val);} // for adding a live variable to set
|
||||||
|
|
||||||
|
@ -36,9 +36,9 @@ protected:
|
|||||||
void destroyConstantImpl();
|
void destroyConstantImpl();
|
||||||
public:
|
public:
|
||||||
// Specialize setName to handle symbol table majik...
|
// Specialize setName to handle symbol table majik...
|
||||||
virtual void setName(const string &name, SymbolTable *ST = 0);
|
virtual void setName(const std::string &name, SymbolTable *ST = 0);
|
||||||
|
|
||||||
virtual string getStrValue() const = 0;
|
virtual std::string getStrValue() const = 0;
|
||||||
|
|
||||||
// Static constructor to get a '0' constant of arbitrary type...
|
// Static constructor to get a '0' constant of arbitrary type...
|
||||||
static Constant *getNullConstant(const Type *Ty);
|
static Constant *getNullConstant(const Type *Ty);
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
// inverted - Return the opposite value of the current value.
|
// inverted - Return the opposite value of the current value.
|
||||||
inline ConstantBool *inverted() const { return (this==True) ? False : True; }
|
inline ConstantBool *inverted() const { return (this==True) ? False : True; }
|
||||||
|
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
inline bool getValue() const { return Val; }
|
inline bool getValue() const { return Val; }
|
||||||
|
|
||||||
// isNullValue - Return true if this is the value that would be returned by
|
// isNullValue - Return true if this is the value that would be returned by
|
||||||
@ -149,7 +149,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static ConstantSInt *get(const Type *Ty, int64_t V);
|
static ConstantSInt *get(const Type *Ty, int64_t V);
|
||||||
|
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
|
|
||||||
static bool isValueValidForType(const Type *Ty, int64_t V);
|
static bool isValueValidForType(const Type *Ty, int64_t V);
|
||||||
inline int64_t getValue() const { return Val.Signed; }
|
inline int64_t getValue() const { return Val.Signed; }
|
||||||
@ -173,7 +173,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static ConstantUInt *get(const Type *Ty, uint64_t V);
|
static ConstantUInt *get(const Type *Ty, uint64_t V);
|
||||||
|
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
|
|
||||||
static bool isValueValidForType(const Type *Ty, uint64_t V);
|
static bool isValueValidForType(const Type *Ty, uint64_t V);
|
||||||
inline uint64_t getValue() const { return Val.Unsigned; }
|
inline uint64_t getValue() const { return Val.Unsigned; }
|
||||||
@ -199,7 +199,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static ConstantFP *get(const Type *Ty, double V);
|
static ConstantFP *get(const Type *Ty, double V);
|
||||||
|
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
|
|
||||||
static bool isValueValidForType(const Type *Ty, double V);
|
static bool isValueValidForType(const Type *Ty, double V);
|
||||||
inline double getValue() const { return Val; }
|
inline double getValue() const { return Val; }
|
||||||
@ -223,20 +223,20 @@ public:
|
|||||||
class ConstantArray : public Constant {
|
class ConstantArray : public Constant {
|
||||||
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
|
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
|
||||||
protected:
|
protected:
|
||||||
ConstantArray(const ArrayType *T, const vector<Constant*> &Val);
|
ConstantArray(const ArrayType *T, const std::vector<Constant*> &Val);
|
||||||
~ConstantArray() {}
|
~ConstantArray() {}
|
||||||
|
|
||||||
virtual void destroyConstant();
|
virtual void destroyConstant();
|
||||||
public:
|
public:
|
||||||
static ConstantArray *get(const ArrayType *T, const vector<Constant*> &);
|
static ConstantArray *get(const ArrayType *T, const std::vector<Constant*> &);
|
||||||
static ConstantArray *get(const string &Initializer);
|
static ConstantArray *get(const std::string &Initializer);
|
||||||
|
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
inline const ArrayType *getType() const {
|
inline const ArrayType *getType() const {
|
||||||
return (ArrayType*)Value::getType();
|
return (ArrayType*)Value::getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const vector<Use> &getValues() const { return Operands; }
|
inline const std::vector<Use> &getValues() const { return Operands; }
|
||||||
|
|
||||||
// isNullValue - Return true if this is the value that would be returned by
|
// isNullValue - Return true if this is the value that would be returned by
|
||||||
// getNullConstant.
|
// getNullConstant.
|
||||||
@ -257,20 +257,20 @@ public:
|
|||||||
class ConstantStruct : public Constant {
|
class ConstantStruct : public Constant {
|
||||||
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
|
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
|
||||||
protected:
|
protected:
|
||||||
ConstantStruct(const StructType *T, const vector<Constant*> &Val);
|
ConstantStruct(const StructType *T, const std::vector<Constant*> &Val);
|
||||||
~ConstantStruct() {}
|
~ConstantStruct() {}
|
||||||
|
|
||||||
virtual void destroyConstant();
|
virtual void destroyConstant();
|
||||||
public:
|
public:
|
||||||
static ConstantStruct *get(const StructType *T,
|
static ConstantStruct *get(const StructType *T,
|
||||||
const vector<Constant*> &V);
|
const std::vector<Constant*> &V);
|
||||||
|
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
inline const StructType *getType() const {
|
inline const StructType *getType() const {
|
||||||
return (StructType*)Value::getType();
|
return (StructType*)Value::getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const vector<Use> &getValues() const { return Operands; }
|
inline const std::vector<Use> &getValues() const { return Operands; }
|
||||||
|
|
||||||
// isNullValue - Return true if this is the value that would be returned by
|
// isNullValue - Return true if this is the value that would be returned by
|
||||||
// getNullConstant.
|
// getNullConstant.
|
||||||
@ -297,7 +297,7 @@ protected:
|
|||||||
inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){}
|
inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){}
|
||||||
~ConstantPointer() {}
|
~ConstantPointer() {}
|
||||||
public:
|
public:
|
||||||
virtual string getStrValue() const = 0;
|
virtual std::string getStrValue() const = 0;
|
||||||
inline const PointerType *getType() const {
|
inline const PointerType *getType() const {
|
||||||
return (PointerType*)Value::getType();
|
return (PointerType*)Value::getType();
|
||||||
}
|
}
|
||||||
@ -322,7 +322,7 @@ protected:
|
|||||||
inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
|
inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
|
||||||
inline ~ConstantPointerNull() {}
|
inline ~ConstantPointerNull() {}
|
||||||
public:
|
public:
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
|
|
||||||
static ConstantPointerNull *get(const PointerType *T);
|
static ConstantPointerNull *get(const PointerType *T);
|
||||||
|
|
||||||
@ -359,7 +359,7 @@ protected:
|
|||||||
public:
|
public:
|
||||||
static ConstantPointerRef *get(GlobalValue *GV);
|
static ConstantPointerRef *get(GlobalValue *GV);
|
||||||
|
|
||||||
virtual string getStrValue() const;
|
virtual std::string getStrValue() const;
|
||||||
|
|
||||||
const GlobalValue *getValue() const {
|
const GlobalValue *getValue() const {
|
||||||
return cast<GlobalValue>(Operands[0].get());
|
return cast<GlobalValue>(Operands[0].get());
|
||||||
|
@ -18,7 +18,7 @@ class DerivedType : public Type {
|
|||||||
// if I am a type, and I get resolved into a more concrete type.
|
// if I am a type, and I get resolved into a more concrete type.
|
||||||
//
|
//
|
||||||
///// FIXME: kill mutable nonsense when Type's are not const
|
///// FIXME: kill mutable nonsense when Type's are not const
|
||||||
mutable vector<AbstractTypeUser *> AbstractTypeUsers;
|
mutable std::vector<AbstractTypeUser *> AbstractTypeUsers;
|
||||||
|
|
||||||
char isRefining; // Used for recursive types
|
char isRefining; // Used for recursive types
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
class MethodType : public DerivedType {
|
class MethodType : public DerivedType {
|
||||||
public:
|
public:
|
||||||
typedef vector<PATypeHandle<Type> > ParamTypes;
|
typedef std::vector<PATypeHandle<Type> > ParamTypes;
|
||||||
private:
|
private:
|
||||||
PATypeHandle<Type> ResultType;
|
PATypeHandle<Type> ResultType;
|
||||||
ParamTypes ParamTys;
|
ParamTypes ParamTys;
|
||||||
@ -108,7 +108,7 @@ protected:
|
|||||||
// defines private constructors and has no friends
|
// defines private constructors and has no friends
|
||||||
|
|
||||||
// Private ctor - Only can be created by a static member...
|
// Private ctor - Only can be created by a static member...
|
||||||
MethodType(const Type *Result, const vector<const Type*> &Params,
|
MethodType(const Type *Result, const std::vector<const Type*> &Params,
|
||||||
bool IsVarArgs);
|
bool IsVarArgs);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -130,7 +130,8 @@ public:
|
|||||||
//
|
//
|
||||||
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
||||||
|
|
||||||
static MethodType *get(const Type *Result, const vector<const Type*> &Params,
|
static MethodType *get(const Type *Result,
|
||||||
|
const std::vector<const Type*> &Params,
|
||||||
bool isVarArg);
|
bool isVarArg);
|
||||||
|
|
||||||
|
|
||||||
@ -180,7 +181,7 @@ public:
|
|||||||
|
|
||||||
class StructType : public CompositeType {
|
class StructType : public CompositeType {
|
||||||
public:
|
public:
|
||||||
typedef vector<PATypeHandle<Type> > ElementTypes;
|
typedef std::vector<PATypeHandle<Type> > ElementTypes;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ElementTypes ETypes; // Element types of struct
|
ElementTypes ETypes; // Element types of struct
|
||||||
@ -194,7 +195,7 @@ protected:
|
|||||||
// defines private constructors and has no friends
|
// defines private constructors and has no friends
|
||||||
|
|
||||||
// Private ctor - Only can be created by a static member...
|
// Private ctor - Only can be created by a static member...
|
||||||
StructType(const vector<const Type*> &Types);
|
StructType(const std::vector<const Type*> &Types);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline const ElementTypes &getElementTypes() const { return ETypes; }
|
inline const ElementTypes &getElementTypes() const { return ETypes; }
|
||||||
@ -221,7 +222,7 @@ public:
|
|||||||
//
|
//
|
||||||
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
||||||
|
|
||||||
static StructType *get(const vector<const Type*> &Params);
|
static StructType *get(const std::vector<const Type*> &Params);
|
||||||
|
|
||||||
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
// Methods for support type inquiry through isa, cast, and dyn_cast:
|
||||||
static inline bool classof(const StructType *T) { return true; }
|
static inline bool classof(const StructType *T) { return true; }
|
||||||
|
@ -29,8 +29,8 @@ public:
|
|||||||
// BasicBlock iterators...
|
// BasicBlock iterators...
|
||||||
typedef BasicBlocksType::iterator iterator;
|
typedef BasicBlocksType::iterator iterator;
|
||||||
typedef BasicBlocksType::const_iterator const_iterator;
|
typedef BasicBlocksType::const_iterator const_iterator;
|
||||||
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
typedef reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -42,11 +42,11 @@ private:
|
|||||||
void setParent(Module *parent);
|
void setParent(Module *parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Method(const MethodType *Ty, bool isInternal, const string &Name = "");
|
Method(const MethodType *Ty, bool isInternal, const std::string &Name = "");
|
||||||
~Method();
|
~Method();
|
||||||
|
|
||||||
// Specialize setName to handle symbol table majik...
|
// Specialize setName to handle symbol table majik...
|
||||||
virtual void setName(const string &name, SymbolTable *ST = 0);
|
virtual void setName(const std::string &name, SymbolTable *ST = 0);
|
||||||
|
|
||||||
const Type *getReturnType() const; // Return the return type of method
|
const Type *getReturnType() const; // Return the return type of method
|
||||||
const MethodType *getMethodType() const; // Return the MethodType for me
|
const MethodType *getMethodType() const; // Return the MethodType for me
|
||||||
@ -129,7 +129,7 @@ public:
|
|||||||
_BB_i_t BB; // BasicBlocksType::iterator
|
_BB_i_t BB; // BasicBlocksType::iterator
|
||||||
_BI_t BI; // BasicBlock::iterator
|
_BI_t BI; // BasicBlock::iterator
|
||||||
public:
|
public:
|
||||||
typedef bidirectional_iterator_tag iterator_category;
|
typedef std::bidirectional_iterator_tag iterator_category;
|
||||||
typedef IIty value_type;
|
typedef IIty value_type;
|
||||||
typedef unsigned difference_type;
|
typedef unsigned difference_type;
|
||||||
typedef BIty pointer;
|
typedef BIty pointer;
|
||||||
|
@ -17,7 +17,7 @@ class GlobalValue : public User {
|
|||||||
GlobalValue(const GlobalValue &); // do not implement
|
GlobalValue(const GlobalValue &); // do not implement
|
||||||
protected:
|
protected:
|
||||||
GlobalValue(const Type *Ty, ValueTy vty, bool hasInternalLinkage,
|
GlobalValue(const Type *Ty, ValueTy vty, bool hasInternalLinkage,
|
||||||
const string &name = "")
|
const std::string &name = "")
|
||||||
: User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {}
|
: User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {}
|
||||||
|
|
||||||
bool HasInternalLinkage; // Is this value accessable externally?
|
bool HasInternalLinkage; // Is this value accessable externally?
|
||||||
|
@ -25,11 +25,11 @@ class GlobalVariable : public GlobalValue {
|
|||||||
bool isConstantGlobal; // Is this a global constant?
|
bool isConstantGlobal; // Is this a global constant?
|
||||||
public:
|
public:
|
||||||
GlobalVariable(const Type *Ty, bool isConstant, bool isInternal,
|
GlobalVariable(const Type *Ty, bool isConstant, bool isInternal,
|
||||||
Constant *Initializer = 0, const string &Name = "");
|
Constant *Initializer = 0, const std::string &Name = "");
|
||||||
~GlobalVariable() {}
|
~GlobalVariable() {}
|
||||||
|
|
||||||
// Specialize setName to handle symbol table majik...
|
// Specialize setName to handle symbol table majik...
|
||||||
virtual void setName(const string &name, SymbolTable *ST = 0);
|
virtual void setName(const std::string &name, SymbolTable *ST = 0);
|
||||||
|
|
||||||
// The initializer for the global variable/constant is held by Operands[0] if
|
// The initializer for the global variable/constant is held by Operands[0] if
|
||||||
// an initializer is specified.
|
// an initializer is specified.
|
||||||
|
@ -25,7 +25,7 @@ class TerminatorInst : public Instruction {
|
|||||||
public:
|
public:
|
||||||
TerminatorInst(Instruction::TermOps iType);
|
TerminatorInst(Instruction::TermOps iType);
|
||||||
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
|
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
|
||||||
const string &Name = "");
|
const std::string &Name = "");
|
||||||
inline ~TerminatorInst() {}
|
inline ~TerminatorInst() {}
|
||||||
|
|
||||||
// Terminators must implement the methods required by Instruction...
|
// Terminators must implement the methods required by Instruction...
|
||||||
@ -66,7 +66,7 @@ public:
|
|||||||
//
|
//
|
||||||
static UnaryOperator *create(UnaryOps Op, Value *Source);
|
static UnaryOperator *create(UnaryOps Op, Value *Source);
|
||||||
|
|
||||||
UnaryOperator(Value *S, UnaryOps iType, const string &Name = "")
|
UnaryOperator(Value *S, UnaryOps iType, const std::string &Name = "")
|
||||||
: Instruction(S->getType(), iType, Name) {
|
: Instruction(S->getType(), iType, Name) {
|
||||||
Operands.reserve(1);
|
Operands.reserve(1);
|
||||||
Operands.push_back(Use(S, this));
|
Operands.push_back(Use(S, this));
|
||||||
@ -105,10 +105,10 @@ public:
|
|||||||
// and the two operands.
|
// and the two operands.
|
||||||
//
|
//
|
||||||
static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2,
|
static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2,
|
||||||
const string &Name = "");
|
const std::string &Name = "");
|
||||||
|
|
||||||
BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
|
||||||
const string &Name = "")
|
const std::string &Name = "")
|
||||||
: Instruction(S1->getType(), iType, Name) {
|
: Instruction(S1->getType(), iType, Name) {
|
||||||
Operands.reserve(2);
|
Operands.reserve(2);
|
||||||
Operands.push_back(Use(S1, this));
|
Operands.push_back(Use(S1, this));
|
||||||
|
@ -25,11 +25,11 @@ class Instruction : public User {
|
|||||||
protected:
|
protected:
|
||||||
unsigned iType; // InstructionType
|
unsigned iType; // InstructionType
|
||||||
public:
|
public:
|
||||||
Instruction(const Type *Ty, unsigned iType, const string &Name = "");
|
Instruction(const Type *Ty, unsigned iType, const std::string &Name = "");
|
||||||
virtual ~Instruction(); // Virtual dtor == good.
|
virtual ~Instruction(); // Virtual dtor == good.
|
||||||
|
|
||||||
// Specialize setName to handle symbol table majik...
|
// Specialize setName to handle symbol table majik...
|
||||||
virtual void setName(const string &name, SymbolTable *ST = 0);
|
virtual void setName(const std::string &name, SymbolTable *ST = 0);
|
||||||
|
|
||||||
// clone() - Create a copy of 'this' instruction that is identical in all ways
|
// clone() - Create a copy of 'this' instruction that is identical in all ways
|
||||||
// except the following:
|
// except the following:
|
||||||
|
@ -16,7 +16,7 @@ class Module;
|
|||||||
// error occurs, true is returned and ErrorMsg (if not null) is set to indicate
|
// error occurs, true is returned and ErrorMsg (if not null) is set to indicate
|
||||||
// the problem.
|
// the problem.
|
||||||
//
|
//
|
||||||
bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0);
|
bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -28,14 +28,14 @@ public:
|
|||||||
// Global Variable iterators...
|
// Global Variable iterators...
|
||||||
typedef GlobalListType::iterator giterator;
|
typedef GlobalListType::iterator giterator;
|
||||||
typedef GlobalListType::const_iterator const_giterator;
|
typedef GlobalListType::const_iterator const_giterator;
|
||||||
typedef reverse_iterator<giterator> reverse_giterator;
|
typedef std::reverse_iterator<giterator> reverse_giterator;
|
||||||
typedef reverse_iterator<const_giterator> const_reverse_giterator;
|
typedef std::reverse_iterator<const_giterator> const_reverse_giterator;
|
||||||
|
|
||||||
// Method iterators...
|
// Method iterators...
|
||||||
typedef MethodListType::iterator iterator;
|
typedef MethodListType::iterator iterator;
|
||||||
typedef MethodListType::const_iterator const_iterator;
|
typedef MethodListType::const_iterator const_iterator;
|
||||||
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
typedef reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GlobalListType GlobalList; // The Global Variables
|
GlobalListType GlobalList; // The Global Variables
|
||||||
|
@ -45,7 +45,7 @@ struct Pass {
|
|||||||
//
|
//
|
||||||
|
|
||||||
// runAllPasses - Run a bunch of passes on the specified module, efficiently.
|
// runAllPasses - Run a bunch of passes on the specified module, efficiently.
|
||||||
static bool runAllPasses(Module *M, vector<Pass*> &Passes) {
|
static bool runAllPasses(Module *M, std::vector<Pass*> &Passes) {
|
||||||
bool MadeChanges = false;
|
bool MadeChanges = false;
|
||||||
// Run all of the pass initializers
|
// Run all of the pass initializers
|
||||||
for (unsigned i = 0; i < Passes.size(); ++i)
|
for (unsigned i = 0; i < Passes.size(); ++i)
|
||||||
@ -65,7 +65,7 @@ struct Pass {
|
|||||||
// runAllPassesAndFree - Run a bunch of passes on the specified module,
|
// runAllPassesAndFree - Run a bunch of passes on the specified module,
|
||||||
// efficiently. When done, delete all of the passes.
|
// efficiently. When done, delete all of the passes.
|
||||||
//
|
//
|
||||||
static bool runAllPassesAndFree(Module *M, vector<Pass*> &Passes) {
|
static bool runAllPassesAndFree(Module *M, std::vector<Pass*> &Passes) {
|
||||||
// First run all of the passes
|
// First run all of the passes
|
||||||
bool MadeChanges = runAllPasses(M, Passes);
|
bool MadeChanges = runAllPasses(M, Passes);
|
||||||
|
|
||||||
|
@ -23,14 +23,14 @@ class SlotCalculator {
|
|||||||
const Module *TheModule;
|
const Module *TheModule;
|
||||||
bool IgnoreNamedNodes; // Shall we not count named nodes?
|
bool IgnoreNamedNodes; // Shall we not count named nodes?
|
||||||
|
|
||||||
typedef vector<const Value*> TypePlane;
|
typedef std::vector<const Value*> TypePlane;
|
||||||
vector<TypePlane> Table;
|
std::vector<TypePlane> Table;
|
||||||
map<const Value *, unsigned> NodeMap;
|
std::map<const Value *, unsigned> NodeMap;
|
||||||
|
|
||||||
// ModuleLevel - Used to keep track of which values belong to the module,
|
// ModuleLevel - Used to keep track of which values belong to the module,
|
||||||
// and which values belong to the currently incorporated method.
|
// and which values belong to the currently incorporated method.
|
||||||
//
|
//
|
||||||
vector<unsigned> ModuleLevel;
|
std::vector<unsigned> ModuleLevel;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SlotCalculator(const Module *M, bool IgnoreNamed);
|
SlotCalculator(const Module *M, bool IgnoreNamed);
|
||||||
|
@ -166,12 +166,13 @@ struct AnnotationManager {
|
|||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Basic ID <-> Name map functionality
|
// Basic ID <-> Name map functionality
|
||||||
|
|
||||||
static AnnotationID getID (const string &Name); // Name -> ID
|
static AnnotationID getID(const std::string &Name); // Name -> ID
|
||||||
static const string &getName(AnnotationID ID); // ID -> Name
|
static const std::string &getName(AnnotationID ID); // ID -> Name
|
||||||
|
|
||||||
// getID - Name -> ID + registration of a factory function for demand driven
|
// getID - Name -> ID + registration of a factory function for demand driven
|
||||||
// annotation support.
|
// annotation support.
|
||||||
static AnnotationID getID (const string &Name, Factory Fact, void *Data=0);
|
static AnnotationID getID(const std::string &Name, Factory Fact,
|
||||||
|
void *Data = 0);
|
||||||
|
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
// Annotation creation on demand support...
|
// Annotation creation on demand support...
|
||||||
|
@ -100,7 +100,7 @@ class Option {
|
|||||||
// an argument. Should return true if there was an error processing the
|
// an argument. Should return true if there was an error processing the
|
||||||
// argument and the program should exit.
|
// argument and the program should exit.
|
||||||
//
|
//
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0;
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0;
|
||||||
|
|
||||||
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
||||||
return Optional;
|
return Optional;
|
||||||
@ -146,10 +146,10 @@ public:
|
|||||||
|
|
||||||
// addOccurance - Wrapper around handleOccurance that enforces Flags
|
// addOccurance - Wrapper around handleOccurance that enforces Flags
|
||||||
//
|
//
|
||||||
bool addOccurance(const char *ArgName, const string &Value);
|
bool addOccurance(const char *ArgName, const std::string &Value);
|
||||||
|
|
||||||
// Prints option name followed by message. Always returns true.
|
// Prints option name followed by message. Always returns true.
|
||||||
bool error(string Message, const char *ArgName = 0);
|
bool error(std::string Message, const char *ArgName = 0);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline int getNumOccurances() const { return NumOccurances; }
|
inline int getNumOccurances() const { return NumOccurances; }
|
||||||
@ -162,7 +162,7 @@ public:
|
|||||||
//
|
//
|
||||||
class Alias : public Option {
|
class Alias : public Option {
|
||||||
Option &AliasFor;
|
Option &AliasFor;
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg) {
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg) {
|
||||||
return AliasFor.handleOccurance(AliasFor.ArgStr, Arg);
|
return AliasFor.handleOccurance(AliasFor.ArgStr, Arg);
|
||||||
}
|
}
|
||||||
virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
|
virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;}
|
||||||
@ -177,7 +177,7 @@ public:
|
|||||||
//
|
//
|
||||||
class Flag : public Option {
|
class Flag : public Option {
|
||||||
bool Value;
|
bool Value;
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
public:
|
public:
|
||||||
inline Flag(const char *ArgStr, const char *Message, int Flags = 0,
|
inline Flag(const char *ArgStr, const char *Message, int Flags = 0,
|
||||||
bool DefaultVal = 0) : Option(ArgStr, Message, Flags),
|
bool DefaultVal = 0) : Option(ArgStr, Message, Flags),
|
||||||
@ -193,7 +193,7 @@ public:
|
|||||||
//
|
//
|
||||||
class Int : public Option {
|
class Int : public Option {
|
||||||
int Value;
|
int Value;
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
return ValueRequired;
|
return ValueRequired;
|
||||||
}
|
}
|
||||||
@ -209,18 +209,18 @@ public:
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// String valued command line option
|
// String valued command line option
|
||||||
//
|
//
|
||||||
class String : public Option, public string {
|
class String : public Option, public std::string {
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
return ValueRequired;
|
return ValueRequired;
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
inline String(const char *ArgStr, const char *Help, int Flags = 0,
|
inline String(const char *ArgStr, const char *Help, int Flags = 0,
|
||||||
const char *DefaultVal = "")
|
const char *DefaultVal = "")
|
||||||
: Option(ArgStr, Help, Flags), string(DefaultVal) {}
|
: Option(ArgStr, Help, Flags), std::string(DefaultVal) {}
|
||||||
|
|
||||||
inline const string &operator=(const string &Val) {
|
inline const std::string &operator=(const std::string &Val) {
|
||||||
return string::operator=(Val);
|
return std::string::operator=(Val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ public:
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// String list command line option
|
// String list command line option
|
||||||
//
|
//
|
||||||
class StringList : public Option, public vector<string> {
|
class StringList : public Option, public std::vector<std::string> {
|
||||||
|
|
||||||
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
virtual enum NumOccurances getNumOccurancesFlagDefault() const {
|
||||||
return ZeroOrMore;
|
return ZeroOrMore;
|
||||||
@ -236,7 +236,7 @@ class StringList : public Option, public vector<string> {
|
|||||||
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
virtual enum ValueExpected getValueExpectedFlagDefault() const {
|
||||||
return ValueRequired;
|
return ValueRequired;
|
||||||
}
|
}
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
inline StringList(const char *ArgStr, const char *Help, int Flags = 0)
|
inline StringList(const char *ArgStr, const char *Help, int Flags = 0)
|
||||||
@ -256,7 +256,7 @@ protected:
|
|||||||
// Use a vector instead of a map, because the lists should be short,
|
// Use a vector instead of a map, because the lists should be short,
|
||||||
// the overhead is less, and most importantly, it keeps them in the order
|
// the overhead is less, and most importantly, it keeps them in the order
|
||||||
// inserted so we can print our option out nicely.
|
// inserted so we can print our option out nicely.
|
||||||
vector<pair<const char *, pair<int, const char *> > > ValueMap;
|
std::vector<std::pair<const char *, std::pair<int, const char *> > > ValueMap;
|
||||||
|
|
||||||
inline EnumBase(const char *ArgStr, const char *Help, int Flags)
|
inline EnumBase(const char *ArgStr, const char *Help, int Flags)
|
||||||
: Option(ArgStr, Help, Flags) {}
|
: Option(ArgStr, Help, Flags) {}
|
||||||
@ -284,7 +284,7 @@ protected:
|
|||||||
inline EnumValueBase(int Flags) : EnumBase(Flags) {}
|
inline EnumValueBase(int Flags) : EnumBase(Flags) {}
|
||||||
|
|
||||||
// handleOccurance - Set Value to the enum value specified by Arg
|
// handleOccurance - Set Value to the enum value specified by Arg
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
|
|
||||||
// Return the width of the option tag for printing...
|
// Return the width of the option tag for printing...
|
||||||
virtual unsigned getOptionWidth() const;
|
virtual unsigned getOptionWidth() const;
|
||||||
@ -323,7 +323,7 @@ class EnumFlagsBase : public EnumValueBase {
|
|||||||
return ValueDisallowed;
|
return ValueDisallowed;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {}
|
inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {}
|
||||||
|
|
||||||
// Return the width of the option tag for printing...
|
// Return the width of the option tag for printing...
|
||||||
@ -363,11 +363,11 @@ class EnumListBase : public EnumBase {
|
|||||||
return ValueDisallowed;
|
return ValueDisallowed;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
vector<int> Values; // The options specified so far.
|
std::vector<int> Values; // The options specified so far.
|
||||||
|
|
||||||
inline EnumListBase(int Flags)
|
inline EnumListBase(int Flags)
|
||||||
: EnumBase(Flags) {}
|
: EnumBase(Flags) {}
|
||||||
virtual bool handleOccurance(const char *ArgName, const string &Arg);
|
virtual bool handleOccurance(const char *ArgName, const std::string &Arg);
|
||||||
|
|
||||||
// Return the width of the option tag for printing...
|
// Return the width of the option tag for printing...
|
||||||
virtual unsigned getOptionWidth() const;
|
virtual unsigned getOptionWidth() const;
|
||||||
|
@ -16,7 +16,7 @@ class Module;
|
|||||||
// error occurs, true is returned and ErrorMsg (if not null) is set to indicate
|
// error occurs, true is returned and ErrorMsg (if not null) is set to indicate
|
||||||
// the problem.
|
// the problem.
|
||||||
//
|
//
|
||||||
bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0);
|
bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -14,14 +14,14 @@ class Value;
|
|||||||
// MangleTypeName - Implement a consistent name-mangling scheme for
|
// MangleTypeName - Implement a consistent name-mangling scheme for
|
||||||
// a given type.
|
// a given type.
|
||||||
//
|
//
|
||||||
string MangleTypeName(const Type *type);
|
std::string MangleTypeName(const Type *type);
|
||||||
|
|
||||||
// MangleName - implement a consistent name-mangling scheme for all
|
// MangleName - implement a consistent name-mangling scheme for all
|
||||||
// externally visible (i.e., global) objects.
|
// externally visible (i.e., global) objects.
|
||||||
//
|
//
|
||||||
// privateName should be unique within the module.
|
// privateName should be unique within the module.
|
||||||
//
|
//
|
||||||
string MangleName(const string &privateName, const Value *V);
|
std::string MangleName(const std::string &privateName, const Value *V);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -27,10 +27,11 @@
|
|||||||
class Type;
|
class Type;
|
||||||
|
|
||||||
class SymbolTable : public AbstractTypeUser,
|
class SymbolTable : public AbstractTypeUser,
|
||||||
public map<const Type *, map<const string, Value *> > {
|
public std::map<const Type *,
|
||||||
|
std::map<const std::string, Value *> > {
|
||||||
public:
|
public:
|
||||||
typedef map<const string, Value *> VarMap;
|
typedef std::map<const std::string, Value *> VarMap;
|
||||||
typedef map<const Type *, VarMap> super;
|
typedef std::map<const Type *, VarMap> super;
|
||||||
private:
|
private:
|
||||||
|
|
||||||
SymbolTable *ParentSymTab;
|
SymbolTable *ParentSymTab;
|
||||||
@ -51,7 +52,7 @@ public:
|
|||||||
SymbolTable *getParentSymTab() { return ParentSymTab; }
|
SymbolTable *getParentSymTab() { return ParentSymTab; }
|
||||||
|
|
||||||
// lookup - Returns null on failure...
|
// lookup - Returns null on failure...
|
||||||
Value *lookup(const Type *Ty, const string &name);
|
Value *lookup(const Type *Ty, const std::string &name);
|
||||||
|
|
||||||
// insert - Add named definition to the symbol table...
|
// insert - Add named definition to the symbol table...
|
||||||
inline void insert(Value *N) {
|
inline void insert(Value *N) {
|
||||||
@ -63,7 +64,7 @@ public:
|
|||||||
// name... There can be a many to one mapping between names and
|
// name... There can be a many to one mapping between names and
|
||||||
// (constant/type)s.
|
// (constant/type)s.
|
||||||
//
|
//
|
||||||
inline void insert(const string &Name, Value *V) {
|
inline void insert(const std::string &Name, Value *V) {
|
||||||
assert((isa<Type>(V) || isa<Constant>(V)) &&
|
assert((isa<Type>(V) || isa<Constant>(V)) &&
|
||||||
"Can only insert types and constants here!");
|
"Can only insert types and constants here!");
|
||||||
insertEntry(Name, V->getType(), V);
|
insertEntry(Name, V->getType(), V);
|
||||||
@ -78,7 +79,7 @@ public:
|
|||||||
// it (or derived from it) that does not already occur in the symbol table for
|
// it (or derived from it) that does not already occur in the symbol table for
|
||||||
// the specified type.
|
// the specified type.
|
||||||
//
|
//
|
||||||
string getUniqueName(const Type *Ty, const string &BaseName);
|
std::string getUniqueName(const Type *Ty, const std::string &BaseName);
|
||||||
|
|
||||||
inline unsigned type_size(const Type *TypeID) const {
|
inline unsigned type_size(const Type *TypeID) const {
|
||||||
return find(TypeID)->second.size();
|
return find(TypeID)->second.size();
|
||||||
@ -121,7 +122,7 @@ private:
|
|||||||
// insertEntry - Insert a value into the symbol table with the specified
|
// insertEntry - Insert a value into the symbol table with the specified
|
||||||
// name...
|
// name...
|
||||||
//
|
//
|
||||||
void insertEntry(const string &Name, const Type *Ty, Value *V);
|
void insertEntry(const std::string &Name, const Type *Ty, Value *V);
|
||||||
|
|
||||||
// removeEntry - Remove a value from the symbol table...
|
// removeEntry - Remove a value from the symbol table...
|
||||||
//
|
//
|
||||||
|
@ -59,7 +59,7 @@ const unsigned int M_PSEUDO_FLAG = 1 << 14;
|
|||||||
|
|
||||||
|
|
||||||
struct MachineInstrDescriptor {
|
struct MachineInstrDescriptor {
|
||||||
string opCodeString; // Assembly language mnemonic for the opcode.
|
std::string opCodeString; // Assembly language mnemonic for the opcode.
|
||||||
int numOperands; // Number of args; -1 if variable #args
|
int numOperands; // Number of args; -1 if variable #args
|
||||||
int resultPos; // Position of the result; -1 if no result
|
int resultPos; // Position of the result; -1 if no result
|
||||||
unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0.
|
unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0.
|
||||||
@ -246,8 +246,8 @@ public:
|
|||||||
//
|
//
|
||||||
virtual void CreateCodeToLoadConst(Value* val,
|
virtual void CreateCodeToLoadConst(Value* val,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec,
|
std::vector<MachineInstr*>& minstrVec,
|
||||||
vector<TmpInstruction*>& temps) const =0;
|
std::vector<TmpInstruction*> &) const = 0;
|
||||||
|
|
||||||
// Create an instruction sequence to copy an integer value `val'
|
// Create an instruction sequence to copy an integer value `val'
|
||||||
// to a floating point value `dest' by copying to memory and back.
|
// to a floating point value `dest' by copying to memory and back.
|
||||||
@ -258,8 +258,8 @@ public:
|
|||||||
virtual void CreateCodeToCopyIntToFloat(Method* method,
|
virtual void CreateCodeToCopyIntToFloat(Method* method,
|
||||||
Value* val,
|
Value* val,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec,
|
std::vector<MachineInstr*>& minstVec,
|
||||||
vector<TmpInstruction*>& tempVec,
|
std::vector<TmpInstruction*>& tmpVec,
|
||||||
TargetMachine& target) const = 0;
|
TargetMachine& target) const = 0;
|
||||||
|
|
||||||
// Similarly, create an instruction sequence to copy an FP value
|
// Similarly, create an instruction sequence to copy an FP value
|
||||||
@ -269,8 +269,8 @@ public:
|
|||||||
virtual void CreateCodeToCopyFloatToInt(Method* method,
|
virtual void CreateCodeToCopyFloatToInt(Method* method,
|
||||||
Value* val,
|
Value* val,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec,
|
std::vector<MachineInstr*>& minstVec,
|
||||||
vector<TmpInstruction*>& tempVec,
|
std::vector<TmpInstruction*>& tmpVec,
|
||||||
TargetMachine& target) const = 0;
|
TargetMachine& target) const = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -279,10 +279,7 @@ public:
|
|||||||
CreateCopyInstructionsByType(const TargetMachine& target,
|
CreateCopyInstructionsByType(const TargetMachine& target,
|
||||||
Value* src,
|
Value* src,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec) const = 0;
|
std::vector<MachineInstr*>& minstrVec) const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -28,9 +28,9 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
unsigned int numLevels;
|
unsigned int numLevels;
|
||||||
vector<unsigned short> cacheLineSizes;
|
std::vector<unsigned short> cacheLineSizes;
|
||||||
vector<unsigned int> cacheSizes;
|
std::vector<unsigned int> cacheSizes;
|
||||||
vector<unsigned short> cacheAssoc;
|
std::vector<unsigned short> cacheAssoc;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/*ctor*/ MachineCacheInfo (const TargetMachine& tgt);
|
/*ctor*/ MachineCacheInfo (const TargetMachine& tgt);
|
||||||
|
@ -31,7 +31,7 @@ class TargetData {
|
|||||||
|
|
||||||
static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *);
|
static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *);
|
||||||
public:
|
public:
|
||||||
TargetData(const string &TargetName, unsigned char PtrSize = 8,
|
TargetData(const std::string &TargetName, unsigned char PtrSize = 8,
|
||||||
unsigned char PtrAl = 8, unsigned char DoubleAl = 8,
|
unsigned char PtrAl = 8, unsigned char DoubleAl = 8,
|
||||||
unsigned char FloatAl = 4, unsigned char LongAl = 8,
|
unsigned char FloatAl = 4, unsigned char LongAl = 8,
|
||||||
unsigned char IntAl = 4, unsigned char ShortAl = 2,
|
unsigned char IntAl = 4, unsigned char ShortAl = 2,
|
||||||
@ -61,7 +61,7 @@ public:
|
|||||||
// stores that include the implicit form of getelementptr.
|
// stores that include the implicit form of getelementptr.
|
||||||
//
|
//
|
||||||
unsigned getIndexedOffset(const Type *Ty,
|
unsigned getIndexedOffset(const Type *Ty,
|
||||||
const vector<Value*> &Indices) const;
|
const std::vector<Value*> &Indices) const;
|
||||||
|
|
||||||
inline const StructLayout *getStructLayout(const StructType *Ty) const {
|
inline const StructLayout *getStructLayout(const StructType *Ty) const {
|
||||||
return (const StructLayout*)((const Type*)Ty)->getOrCreateAnnotation(AID);
|
return (const StructLayout*)((const Type*)Ty)->getOrCreateAnnotation(AID);
|
||||||
@ -73,7 +73,7 @@ public:
|
|||||||
// TargetData structure.
|
// TargetData structure.
|
||||||
//
|
//
|
||||||
struct StructLayout : public Annotation {
|
struct StructLayout : public Annotation {
|
||||||
vector<unsigned> MemberOffsets;
|
std::vector<unsigned> MemberOffsets;
|
||||||
unsigned StructSize;
|
unsigned StructSize;
|
||||||
unsigned StructAlignment;
|
unsigned StructAlignment;
|
||||||
private:
|
private:
|
||||||
|
@ -59,7 +59,7 @@ const unsigned int M_PSEUDO_FLAG = 1 << 14;
|
|||||||
|
|
||||||
|
|
||||||
struct MachineInstrDescriptor {
|
struct MachineInstrDescriptor {
|
||||||
string opCodeString; // Assembly language mnemonic for the opcode.
|
std::string opCodeString; // Assembly language mnemonic for the opcode.
|
||||||
int numOperands; // Number of args; -1 if variable #args
|
int numOperands; // Number of args; -1 if variable #args
|
||||||
int resultPos; // Position of the result; -1 if no result
|
int resultPos; // Position of the result; -1 if no result
|
||||||
unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0.
|
unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0.
|
||||||
@ -246,8 +246,8 @@ public:
|
|||||||
//
|
//
|
||||||
virtual void CreateCodeToLoadConst(Value* val,
|
virtual void CreateCodeToLoadConst(Value* val,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec,
|
std::vector<MachineInstr*>& minstrVec,
|
||||||
vector<TmpInstruction*>& temps) const =0;
|
std::vector<TmpInstruction*> &) const = 0;
|
||||||
|
|
||||||
// Create an instruction sequence to copy an integer value `val'
|
// Create an instruction sequence to copy an integer value `val'
|
||||||
// to a floating point value `dest' by copying to memory and back.
|
// to a floating point value `dest' by copying to memory and back.
|
||||||
@ -258,8 +258,8 @@ public:
|
|||||||
virtual void CreateCodeToCopyIntToFloat(Method* method,
|
virtual void CreateCodeToCopyIntToFloat(Method* method,
|
||||||
Value* val,
|
Value* val,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec,
|
std::vector<MachineInstr*>& minstVec,
|
||||||
vector<TmpInstruction*>& tempVec,
|
std::vector<TmpInstruction*>& tmpVec,
|
||||||
TargetMachine& target) const = 0;
|
TargetMachine& target) const = 0;
|
||||||
|
|
||||||
// Similarly, create an instruction sequence to copy an FP value
|
// Similarly, create an instruction sequence to copy an FP value
|
||||||
@ -269,8 +269,8 @@ public:
|
|||||||
virtual void CreateCodeToCopyFloatToInt(Method* method,
|
virtual void CreateCodeToCopyFloatToInt(Method* method,
|
||||||
Value* val,
|
Value* val,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec,
|
std::vector<MachineInstr*>& minstVec,
|
||||||
vector<TmpInstruction*>& tempVec,
|
std::vector<TmpInstruction*>& tmpVec,
|
||||||
TargetMachine& target) const = 0;
|
TargetMachine& target) const = 0;
|
||||||
|
|
||||||
|
|
||||||
@ -279,10 +279,7 @@ public:
|
|||||||
CreateCopyInstructionsByType(const TargetMachine& target,
|
CreateCopyInstructionsByType(const TargetMachine& target,
|
||||||
Value* src,
|
Value* src,
|
||||||
Instruction* dest,
|
Instruction* dest,
|
||||||
vector<MachineInstr*>& minstrVec) const = 0;
|
std::vector<MachineInstr*>& minstrVec) const = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -38,14 +38,14 @@ typedef int OpCodeMask;
|
|||||||
|
|
||||||
class TargetMachine : public NonCopyableV {
|
class TargetMachine : public NonCopyableV {
|
||||||
public:
|
public:
|
||||||
const string TargetName;
|
const std::string TargetName;
|
||||||
const TargetData DataLayout; // Calculates type size & alignment
|
const TargetData DataLayout; // Calculates type size & alignment
|
||||||
int optSizeForSubWordData;
|
int optSizeForSubWordData;
|
||||||
int minMemOpWordSize;
|
int minMemOpWordSize;
|
||||||
int maxAtomicMemOpWordSize;
|
int maxAtomicMemOpWordSize;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TargetMachine(const string &targetname, // Can only create subclasses...
|
TargetMachine(const std::string &targetname, // Can only create subclasses...
|
||||||
unsigned char PtrSize = 8, unsigned char PtrAl = 8,
|
unsigned char PtrSize = 8, unsigned char PtrAl = 8,
|
||||||
unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
|
unsigned char DoubleAl = 8, unsigned char FloatAl = 4,
|
||||||
unsigned char LongAl = 8, unsigned char IntAl = 4,
|
unsigned char LongAl = 8, unsigned char IntAl = 4,
|
||||||
@ -86,7 +86,7 @@ public:
|
|||||||
// method. The specified method must have been compiled before this may be
|
// method. The specified method must have been compiled before this may be
|
||||||
// used.
|
// used.
|
||||||
//
|
//
|
||||||
virtual void emitAssembly(const Module *M, ostream &OutStr) const = 0;
|
virtual void emitAssembly(const Module *M, std::ostream &OutStr) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#define LLVM_TARGET_MACHINEREGINFO_H
|
#define LLVM_TARGET_MACHINEREGINFO_H
|
||||||
|
|
||||||
#include "Support/NonCopyable.h"
|
#include "Support/NonCopyable.h"
|
||||||
#include <hash_map>
|
#include <ext/hash_map>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
class TargetMachine;
|
class TargetMachine;
|
||||||
@ -76,11 +76,11 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
typedef hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
|
typedef std::hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
|
||||||
|
|
||||||
// A vector of all machine register classes
|
// A vector of all machine register classes
|
||||||
//
|
//
|
||||||
typedef vector<const MachineRegClassInfo *> MachineRegClassArrayType;
|
typedef std::vector<const MachineRegClassInfo *> MachineRegClassArrayType;
|
||||||
|
|
||||||
|
|
||||||
class MachineRegInfo : public NonCopyableV {
|
class MachineRegInfo : public NonCopyableV {
|
||||||
@ -128,7 +128,7 @@ public:
|
|||||||
LiveRangeInfo & LRI) const = 0;
|
LiveRangeInfo & LRI) const = 0;
|
||||||
|
|
||||||
virtual void suggestRegs4CallArgs(const MachineInstr *const CallI,
|
virtual void suggestRegs4CallArgs(const MachineInstr *const CallI,
|
||||||
LiveRangeInfo& LRI, vector<RegClass *> RCL) const = 0;
|
LiveRangeInfo& LRI, std::vector<RegClass *> RCL) const = 0;
|
||||||
|
|
||||||
virtual void suggestReg4RetValue(const MachineInstr *const RetI,
|
virtual void suggestReg4RetValue(const MachineInstr *const RetI,
|
||||||
LiveRangeInfo& LRI) const = 0;
|
LiveRangeInfo& LRI) const = 0;
|
||||||
@ -186,7 +186,7 @@ public:
|
|||||||
//
|
//
|
||||||
virtual int getUnifiedRegNum(int RegClassID, int reg) const = 0;
|
virtual int getUnifiedRegNum(int RegClassID, int reg) const = 0;
|
||||||
|
|
||||||
virtual const string getUnifiedRegName(int UnifiedRegNum) const = 0;
|
virtual const std::string getUnifiedRegName(int UnifiedRegNum) const = 0;
|
||||||
|
|
||||||
|
|
||||||
// Gives the type of a register based on the type of the LR
|
// Gives the type of a register based on the type of the LR
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
#define LLVM_TARGET_MACHINESCHEDINFO_H
|
#define LLVM_TARGET_MACHINESCHEDINFO_H
|
||||||
|
|
||||||
#include "llvm/Target/MachineInstrInfo.h"
|
#include "llvm/Target/MachineInstrInfo.h"
|
||||||
#include <hash_map>
|
#include <ext/hash_map>
|
||||||
|
|
||||||
typedef long long cycles_t;
|
typedef long long cycles_t;
|
||||||
const cycles_t HUGE_LATENCY = ~((unsigned long long) 1 << sizeof(cycles_t)-1);
|
const cycles_t HUGE_LATENCY = ~((unsigned long long) 1 << sizeof(cycles_t)-2);
|
||||||
const cycles_t INVALID_LATENCY = -HUGE_LATENCY;
|
const cycles_t INVALID_LATENCY = -HUGE_LATENCY;
|
||||||
static const unsigned MAX_OPCODE_SIZE = 16;
|
static const unsigned MAX_OPCODE_SIZE = 16;
|
||||||
|
|
||||||
@ -28,13 +28,13 @@ private:
|
|||||||
OpCodePair(); // disable for now
|
OpCodePair(); // disable for now
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace std {
|
||||||
template <> struct hash<OpCodePair> {
|
template <> struct hash<OpCodePair> {
|
||||||
size_t operator()(const OpCodePair& pair) const {
|
size_t operator()(const OpCodePair& pair) const {
|
||||||
return hash<long>()(pair.val);
|
return hash<long>()(pair.val);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// class MachineResource
|
// class MachineResource
|
||||||
@ -50,10 +50,10 @@ typedef unsigned int resourceId_t;
|
|||||||
|
|
||||||
class MachineResource {
|
class MachineResource {
|
||||||
public:
|
public:
|
||||||
const string rname;
|
const std::string rname;
|
||||||
resourceId_t rid;
|
resourceId_t rid;
|
||||||
|
|
||||||
/*ctor*/ MachineResource(const string& resourceName)
|
/*ctor*/ MachineResource(const std::string& resourceName)
|
||||||
: rname(resourceName), rid(nextId++) {}
|
: rname(resourceName), rid(nextId++) {}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -66,7 +66,7 @@ class CPUResource : public MachineResource {
|
|||||||
public:
|
public:
|
||||||
int maxNumUsers; // MAXINT if no restriction
|
int maxNumUsers; // MAXINT if no restriction
|
||||||
|
|
||||||
/*ctor*/ CPUResource(const string& rname, int maxUsers)
|
/*ctor*/ CPUResource(const std::string& rname, int maxUsers)
|
||||||
: MachineResource(rname), maxNumUsers(maxUsers) {}
|
: MachineResource(rname), maxNumUsers(maxUsers) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -147,11 +147,11 @@ struct InstrRUsage {
|
|||||||
cycles_t numBubbles;
|
cycles_t numBubbles;
|
||||||
|
|
||||||
// Feasible slots to use for this instruction.
|
// Feasible slots to use for this instruction.
|
||||||
vector<bool> feasibleSlots;
|
std::vector<bool> feasibleSlots;
|
||||||
|
|
||||||
// Resource usages for this instruction, with one resource vector per cycle.
|
// Resource usages for this instruction, with one resource vector per cycle.
|
||||||
cycles_t numCycles;
|
cycles_t numCycles;
|
||||||
vector<vector<resourceId_t> > resourcesByCycle;
|
std::vector<std::vector<resourceId_t> > resourcesByCycle;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Conveniences for initializing this structure
|
// Conveniences for initializing this structure
|
||||||
@ -243,7 +243,7 @@ InstrRUsage::addUsageDelta(const InstrRUsageDelta& delta)
|
|||||||
|
|
||||||
// resize the resources vector if more cycles are specified
|
// resize the resources vector if more cycles are specified
|
||||||
unsigned maxCycles = this->numCycles;
|
unsigned maxCycles = this->numCycles;
|
||||||
maxCycles = max(maxCycles, delta.startCycle + abs(NC) - 1);
|
maxCycles = std::max(maxCycles, delta.startCycle + abs(NC) - 1);
|
||||||
if (maxCycles > this->numCycles)
|
if (maxCycles > this->numCycles)
|
||||||
{
|
{
|
||||||
this->resourcesByCycle.resize(maxCycles);
|
this->resourcesByCycle.resize(maxCycles);
|
||||||
@ -259,7 +259,7 @@ InstrRUsage::addUsageDelta(const InstrRUsageDelta& delta)
|
|||||||
{
|
{
|
||||||
// Look for the resource backwards so we remove the last entry
|
// Look for the resource backwards so we remove the last entry
|
||||||
// for that resource in each cycle.
|
// for that resource in each cycle.
|
||||||
vector<resourceId_t>& rvec = this->resourcesByCycle[c];
|
std::vector<resourceId_t>& rvec = this->resourcesByCycle[c];
|
||||||
int r;
|
int r;
|
||||||
for (r = (int) rvec.size(); r >= 0; r--)
|
for (r = (int) rvec.size(); r >= 0; r--)
|
||||||
if (rvec[r] == delta.resourceId)
|
if (rvec[r] == delta.resourceId)
|
||||||
@ -349,14 +349,14 @@ public:
|
|||||||
|
|
||||||
inline int getMinIssueGap (MachineOpCode fromOp,
|
inline int getMinIssueGap (MachineOpCode fromOp,
|
||||||
MachineOpCode toOp) const {
|
MachineOpCode toOp) const {
|
||||||
hash_map<OpCodePair,int>::const_iterator
|
std::hash_map<OpCodePair,int>::const_iterator
|
||||||
I = issueGaps.find(OpCodePair(fromOp, toOp));
|
I = issueGaps.find(OpCodePair(fromOp, toOp));
|
||||||
return (I == issueGaps.end())? 0 : (*I).second;
|
return (I == issueGaps.end())? 0 : (*I).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const vector<MachineOpCode>*
|
inline const std::vector<MachineOpCode>*
|
||||||
getConflictList(MachineOpCode opCode) const {
|
getConflictList(MachineOpCode opCode) const {
|
||||||
hash_map<MachineOpCode,vector<MachineOpCode> >::const_iterator
|
std::hash_map<MachineOpCode, std::vector<MachineOpCode> >::const_iterator
|
||||||
I = conflictLists.find(opCode);
|
I = conflictLists.find(opCode);
|
||||||
return (I == conflictLists.end())? NULL : & (*I).second;
|
return (I == conflictLists.end())? NULL : & (*I).second;
|
||||||
}
|
}
|
||||||
@ -377,8 +377,8 @@ protected:
|
|||||||
virtual void initializeResources ();
|
virtual void initializeResources ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void computeInstrResources(const vector<InstrRUsage>& instrRUForClasses);
|
void computeInstrResources(const std::vector<InstrRUsage>& instrRUForClasses);
|
||||||
void computeIssueGaps(const vector<InstrRUsage>& instrRUForClasses);
|
void computeIssueGaps(const std::vector<InstrRUsage>& instrRUForClasses);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int numSchedClasses;
|
int numSchedClasses;
|
||||||
@ -389,9 +389,9 @@ protected:
|
|||||||
unsigned int numUsageDeltas;
|
unsigned int numUsageDeltas;
|
||||||
unsigned int numIssueDeltas;
|
unsigned int numIssueDeltas;
|
||||||
|
|
||||||
vector<InstrRUsage> instrRUsages; // indexed by opcode
|
std::vector<InstrRUsage> instrRUsages; // indexed by opcode
|
||||||
hash_map<OpCodePair,int> issueGaps; // indexed by opcode pair
|
std::hash_map<OpCodePair,int> issueGaps; // indexed by opcode pair
|
||||||
hash_map<MachineOpCode,vector<MachineOpCode> >
|
std::hash_map<MachineOpCode, std::vector<MachineOpCode> >
|
||||||
conflictLists; // indexed by opcode
|
conflictLists; // indexed by opcode
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ class GlobalVariable;
|
|||||||
|
|
||||||
class ConstantMerge : public Pass {
|
class ConstantMerge : public Pass {
|
||||||
protected:
|
protected:
|
||||||
map<Constant*, GlobalVariable*> Constants;
|
std::map<Constant*, GlobalVariable*> Constants;
|
||||||
unsigned LastConstantSeen;
|
unsigned LastConstantSeen;
|
||||||
public:
|
public:
|
||||||
inline ConstantMerge() : LastConstantSeen(0) {}
|
inline ConstantMerge() : LastConstantSeen(0) {}
|
||||||
|
@ -28,19 +28,19 @@ class MutateStructTypes : public Pass {
|
|||||||
// incoming slot [or negative if the specified incoming slot should be
|
// incoming slot [or negative if the specified incoming slot should be
|
||||||
// removed].
|
// removed].
|
||||||
//
|
//
|
||||||
typedef pair<const StructType*, vector<int> > TransformType;
|
typedef std::pair<const StructType*, std::vector<int> > TransformType;
|
||||||
|
|
||||||
// Transforms to do for each structure type...
|
// Transforms to do for each structure type...
|
||||||
map<const StructType*, TransformType> Transforms;
|
std::map<const StructType*, TransformType> Transforms;
|
||||||
|
|
||||||
// Mapping of old type to new types...
|
// Mapping of old type to new types...
|
||||||
map<const Type *, PATypeHolder<Type> > TypeMap;
|
std::map<const Type *, PATypeHolder<Type> > TypeMap;
|
||||||
|
|
||||||
// Mapping from global value of old type, to a global value of the new type...
|
// Mapping from global value of old type, to a global value of the new type...
|
||||||
map<const GlobalValue*, GlobalValue*> GlobalMap;
|
std::map<const GlobalValue*, GlobalValue*> GlobalMap;
|
||||||
|
|
||||||
// Mapping from intra method value to intra method value
|
// Mapping from intra method value to intra method value
|
||||||
map<const Value*, Value*> LocalValueMap;
|
std::map<const Value*, Value*> LocalValueMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Ctor - Take a map that specifies what transformation to do for each field
|
// Ctor - Take a map that specifies what transformation to do for each field
|
||||||
@ -49,7 +49,7 @@ public:
|
|||||||
// the destination structure the field should end up in. A negative value
|
// the destination structure the field should end up in. A negative value
|
||||||
// indicates that the field should be deleted entirely.
|
// indicates that the field should be deleted entirely.
|
||||||
//
|
//
|
||||||
typedef map<const StructType*, vector<int> > TransformsType;
|
typedef std::map<const StructType*, std::vector<int> > TransformsType;
|
||||||
|
|
||||||
MutateStructTypes(const TransformsType &Transforms);
|
MutateStructTypes(const TransformsType &Transforms);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ private:
|
|||||||
// AdjustIndices - Convert the indexes specifed by Idx to the new changed form
|
// AdjustIndices - Convert the indexes specifed by Idx to the new changed form
|
||||||
// using the specified OldTy as the base type being indexed into.
|
// using the specified OldTy as the base type being indexed into.
|
||||||
//
|
//
|
||||||
void AdjustIndices(const CompositeType *OldTy, vector<Value*> &Idx,
|
void AdjustIndices(const CompositeType *OldTy, std::vector<Value*> &Idx,
|
||||||
unsigned idx = 0);
|
unsigned idx = 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ class Module;
|
|||||||
// error occurs, true is returned and ErrorMsg (if not null) is set to indicate
|
// error occurs, true is returned and ErrorMsg (if not null) is set to indicate
|
||||||
// the problem.
|
// the problem.
|
||||||
//
|
//
|
||||||
bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0);
|
bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -71,23 +71,23 @@ public:
|
|||||||
private:
|
private:
|
||||||
PrimitiveID ID; // The current base type of this type...
|
PrimitiveID ID; // The current base type of this type...
|
||||||
unsigned UID; // The unique ID number for this class
|
unsigned UID; // The unique ID number for this class
|
||||||
string Desc; // The printed name of the string...
|
std::string Desc; // The printed name of the string...
|
||||||
bool Abstract; // True if type contains an OpaqueType
|
bool Abstract; // True if type contains an OpaqueType
|
||||||
bool Recursive; // True if the type is recursive
|
bool Recursive; // True if the type is recursive
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// ctor is protected, so only subclasses can create Type objects...
|
// ctor is protected, so only subclasses can create Type objects...
|
||||||
Type(const string &Name, PrimitiveID id);
|
Type(const std::string &Name, PrimitiveID id);
|
||||||
virtual ~Type() {}
|
virtual ~Type() {}
|
||||||
|
|
||||||
// When types are refined, they update their description to be more concrete.
|
// When types are refined, they update their description to be more concrete.
|
||||||
//
|
//
|
||||||
inline void setDescription(const string &D) { Desc = D; }
|
inline void setDescription(const std::string &D) { Desc = D; }
|
||||||
|
|
||||||
// setName - Associate the name with this type in the symbol table, but don't
|
// setName - Associate the name with this type in the symbol table, but don't
|
||||||
// set the local name to be equal specified name.
|
// set the local name to be equal specified name.
|
||||||
//
|
//
|
||||||
virtual void setName(const string &Name, SymbolTable *ST = 0);
|
virtual void setName(const std::string &Name, SymbolTable *ST = 0);
|
||||||
|
|
||||||
// Types can become nonabstract later, if they are refined.
|
// Types can become nonabstract later, if they are refined.
|
||||||
//
|
//
|
||||||
@ -116,7 +116,7 @@ public:
|
|||||||
inline unsigned getUniqueID() const { return UID; }
|
inline unsigned getUniqueID() const { return UID; }
|
||||||
|
|
||||||
// getDescription - Return the string representation of the type...
|
// getDescription - Return the string representation of the type...
|
||||||
inline const string &getDescription() const { return Desc; }
|
inline const std::string &getDescription() const { return Desc; }
|
||||||
|
|
||||||
// isSigned - Return whether a numeric type is signed.
|
// isSigned - Return whether a numeric type is signed.
|
||||||
virtual bool isSigned() const { return 0; }
|
virtual bool isSigned() const { return 0; }
|
||||||
|
@ -17,9 +17,9 @@
|
|||||||
class User : public Value {
|
class User : public Value {
|
||||||
User(const User &); // Do not implement
|
User(const User &); // Do not implement
|
||||||
protected:
|
protected:
|
||||||
vector<Use> Operands;
|
std::vector<Use> Operands;
|
||||||
public:
|
public:
|
||||||
User(const Type *Ty, ValueTy vty, const string &name = "");
|
User(const Type *Ty, ValueTy vty, const std::string &name = "");
|
||||||
virtual ~User() { dropAllReferences(); }
|
virtual ~User() { dropAllReferences(); }
|
||||||
|
|
||||||
inline Value *getOperand(unsigned i) {
|
inline Value *getOperand(unsigned i) {
|
||||||
@ -39,8 +39,8 @@ public:
|
|||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Operand Iterator interface...
|
// Operand Iterator interface...
|
||||||
//
|
//
|
||||||
typedef vector<Use>::iterator op_iterator;
|
typedef std::vector<Use>::iterator op_iterator;
|
||||||
typedef vector<Use>::const_iterator const_op_iterator;
|
typedef std::vector<Use>::const_iterator const_op_iterator;
|
||||||
|
|
||||||
inline op_iterator op_begin() { return Operands.begin(); }
|
inline op_iterator op_begin() { return Operands.begin(); }
|
||||||
inline const_op_iterator op_begin() const { return Operands.begin(); }
|
inline const_op_iterator op_begin() const { return Operands.begin(); }
|
||||||
|
@ -49,8 +49,8 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vector<User *> Uses;
|
std::vector<User *> Uses;
|
||||||
string Name;
|
std::string Name;
|
||||||
PATypeHandle<Type> Ty;
|
PATypeHandle<Type> Ty;
|
||||||
ValueTy VTy;
|
ValueTy VTy;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ private:
|
|||||||
protected:
|
protected:
|
||||||
inline void setType(const Type *ty) { Ty = ty; }
|
inline void setType(const Type *ty) { Ty = ty; }
|
||||||
public:
|
public:
|
||||||
Value(const Type *Ty, ValueTy vty, const string &name = "");
|
Value(const Type *Ty, ValueTy vty, const std::string &name = "");
|
||||||
virtual ~Value();
|
virtual ~Value();
|
||||||
|
|
||||||
// Support for debugging
|
// Support for debugging
|
||||||
@ -69,9 +69,9 @@ public:
|
|||||||
|
|
||||||
// All values can potentially be named...
|
// All values can potentially be named...
|
||||||
inline bool hasName() const { return Name != ""; }
|
inline bool hasName() const { return Name != ""; }
|
||||||
inline const string &getName() const { return Name; }
|
inline const std::string &getName() const { return Name; }
|
||||||
|
|
||||||
virtual void setName(const string &name, SymbolTable * = 0) {
|
virtual void setName(const std::string &name, SymbolTable * = 0) {
|
||||||
Name = name;
|
Name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,8 +101,8 @@ public:
|
|||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
// Methods for handling the vector of uses of this Value.
|
// Methods for handling the vector of uses of this Value.
|
||||||
//
|
//
|
||||||
typedef vector<User*>::iterator use_iterator;
|
typedef std::vector<User*>::iterator use_iterator;
|
||||||
typedef vector<User*>::const_iterator use_const_iterator;
|
typedef std::vector<User*>::const_iterator use_const_iterator;
|
||||||
|
|
||||||
inline unsigned use_size() const { return Uses.size(); }
|
inline unsigned use_size() const { return Uses.size(); }
|
||||||
inline bool use_empty() const { return Uses.empty(); }
|
inline bool use_empty() const { return Uses.empty(); }
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
//
|
//
|
||||||
template<class ValueSubclass, class ItemParentType, class SymTabType>
|
template<class ValueSubclass, class ItemParentType, class SymTabType>
|
||||||
class ValueHolder {
|
class ValueHolder {
|
||||||
vector<ValueSubclass*> ValueList;
|
std::vector<ValueSubclass*> ValueList;
|
||||||
|
|
||||||
ItemParentType *ItemParent;
|
ItemParentType *ItemParent;
|
||||||
SymTabType *Parent;
|
SymTabType *Parent;
|
||||||
@ -66,10 +66,10 @@ public:
|
|||||||
// sub-Definition iterator code
|
// sub-Definition iterator code
|
||||||
//===--------------------------------------------------------------------===//
|
//===--------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
typedef vector<ValueSubclass*>::iterator iterator;
|
typedef std::vector<ValueSubclass*>::iterator iterator;
|
||||||
typedef vector<ValueSubclass*>::const_iterator const_iterator;
|
typedef std::vector<ValueSubclass*>::const_iterator const_iterator;
|
||||||
typedef reverse_iterator<const_iterator> const_reverse_iterator;
|
typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
|
||||||
typedef reverse_iterator<iterator> reverse_iterator;
|
typedef std::reverse_iterator<iterator> reverse_iterator;
|
||||||
|
|
||||||
inline iterator begin() { return ValueList.begin(); }
|
inline iterator begin() { return ValueList.begin(); }
|
||||||
inline const_iterator begin() const { return ValueList.begin(); }
|
inline const_iterator begin() const { return ValueList.begin(); }
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
class AllocationInst : public Instruction {
|
class AllocationInst : public Instruction {
|
||||||
public:
|
public:
|
||||||
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
|
||||||
const string &Name = "")
|
const std::string &Name = "")
|
||||||
: Instruction(Ty, iTy, Name) {
|
: Instruction(Ty, iTy, Name) {
|
||||||
assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
|
assert(Ty->isPointerType() && "Can't allocate a non pointer type!");
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public:
|
|||||||
|
|
||||||
class MallocInst : public AllocationInst {
|
class MallocInst : public AllocationInst {
|
||||||
public:
|
public:
|
||||||
MallocInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "")
|
MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "")
|
||||||
: AllocationInst(Ty, ArraySize, Malloc, Name) {}
|
: AllocationInst(Ty, ArraySize, Malloc, Name) {}
|
||||||
|
|
||||||
virtual Instruction *clone() const {
|
virtual Instruction *clone() const {
|
||||||
@ -94,7 +94,7 @@ public:
|
|||||||
|
|
||||||
class AllocaInst : public AllocationInst {
|
class AllocaInst : public AllocationInst {
|
||||||
public:
|
public:
|
||||||
AllocaInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "")
|
AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "")
|
||||||
: AllocationInst(Ty, ArraySize, Alloca, Name) {}
|
: AllocationInst(Ty, ArraySize, Alloca, Name) {}
|
||||||
|
|
||||||
virtual Instruction *clone() const {
|
virtual Instruction *clone() const {
|
||||||
@ -154,7 +154,7 @@ public:
|
|||||||
class MemAccessInst : public Instruction {
|
class MemAccessInst : public Instruction {
|
||||||
protected:
|
protected:
|
||||||
inline MemAccessInst(const Type *Ty, unsigned Opcode,
|
inline MemAccessInst(const Type *Ty, unsigned Opcode,
|
||||||
const string &Nam = "")
|
const std::string &Nam = "")
|
||||||
: Instruction(Ty, Opcode, Nam) {}
|
: Instruction(Ty, Opcode, Nam) {}
|
||||||
public:
|
public:
|
||||||
// getIndexedType - Returns the type of the element that would be loaded with
|
// getIndexedType - Returns the type of the element that would be loaded with
|
||||||
@ -164,7 +164,7 @@ public:
|
|||||||
// pointer type.
|
// pointer type.
|
||||||
//
|
//
|
||||||
static const Type *getIndexedType(const Type *Ptr,
|
static const Type *getIndexedType(const Type *Ptr,
|
||||||
const vector<Value*> &Indices,
|
const std::vector<Value*> &Indices,
|
||||||
bool AllowStructLeaf = false);
|
bool AllowStructLeaf = false);
|
||||||
|
|
||||||
inline op_iterator idx_begin() {
|
inline op_iterator idx_begin() {
|
||||||
@ -177,8 +177,8 @@ public:
|
|||||||
inline const_op_iterator idx_end() const { return op_end(); }
|
inline const_op_iterator idx_end() const { return op_end(); }
|
||||||
|
|
||||||
|
|
||||||
vector<Value*> copyIndices() const {
|
std::vector<Value*> copyIndices() const {
|
||||||
return vector<Value*>(idx_begin(), idx_end());
|
return std::vector<Value*>(idx_begin(), idx_end());
|
||||||
}
|
}
|
||||||
|
|
||||||
Value *getPointerOperand() {
|
Value *getPointerOperand() {
|
||||||
@ -217,8 +217,8 @@ class LoadInst : public MemAccessInst {
|
|||||||
Operands.push_back(Use(LI.Operands[i], this));
|
Operands.push_back(Use(LI.Operands[i], this));
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
LoadInst(Value *Ptr, const vector<Value*> &Idx, const string &Name = "");
|
LoadInst(Value *Ptr, const std::vector<Value*> &Ix, const std::string & = "");
|
||||||
LoadInst(Value *Ptr, const string &Name = "");
|
LoadInst(Value *Ptr, const std::string &Name = "");
|
||||||
|
|
||||||
virtual Instruction *clone() const { return new LoadInst(*this); }
|
virtual Instruction *clone() const { return new LoadInst(*this); }
|
||||||
virtual const char *getOpcodeName() const { return "load"; }
|
virtual const char *getOpcodeName() const { return "load"; }
|
||||||
@ -247,9 +247,9 @@ class StoreInst : public MemAccessInst {
|
|||||||
Operands.push_back(Use(SI.Operands[i], this));
|
Operands.push_back(Use(SI.Operands[i], this));
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
StoreInst(Value *Val, Value *Ptr, const vector<Value*> &Idx,
|
StoreInst(Value *Val, Value *Ptr, const std::vector<Value*> &Idx,
|
||||||
const string &Name = "");
|
const std::string &Name = "");
|
||||||
StoreInst(Value *Val, Value *Ptr, const string &Name = "");
|
StoreInst(Value *Val, Value *Ptr, const std::string &Name = "");
|
||||||
virtual Instruction *clone() const { return new StoreInst(*this); }
|
virtual Instruction *clone() const { return new StoreInst(*this); }
|
||||||
|
|
||||||
virtual const char *getOpcodeName() const { return "store"; }
|
virtual const char *getOpcodeName() const { return "store"; }
|
||||||
@ -280,8 +280,8 @@ class GetElementPtrInst : public MemAccessInst {
|
|||||||
Operands.push_back(Use(EPI.Operands[i], this));
|
Operands.push_back(Use(EPI.Operands[i], this));
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
GetElementPtrInst(Value *Ptr, const vector<Value*> &Idx,
|
GetElementPtrInst(Value *Ptr, const std::vector<Value*> &Idx,
|
||||||
const string &Name = "");
|
const std::string &Name = "");
|
||||||
virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
|
virtual Instruction *clone() const { return new GetElementPtrInst(*this); }
|
||||||
virtual const char *getOpcodeName() const { return "getelementptr"; }
|
virtual const char *getOpcodeName() const { return "getelementptr"; }
|
||||||
virtual unsigned getFirstIndexOperandNumber() const { return 1; }
|
virtual unsigned getFirstIndexOperandNumber() const { return 1; }
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
//
|
//
|
||||||
class GenericUnaryInst : public UnaryOperator {
|
class GenericUnaryInst : public UnaryOperator {
|
||||||
public:
|
public:
|
||||||
GenericUnaryInst(UnaryOps Opcode, Value *S1, const string &Name = "")
|
GenericUnaryInst(UnaryOps Opcode, Value *S1, const std::string &Name = "")
|
||||||
: UnaryOperator(S1, Opcode, Name) {
|
: UnaryOperator(S1, Opcode, Name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public:
|
|||||||
class GenericBinaryInst : public BinaryOperator {
|
class GenericBinaryInst : public BinaryOperator {
|
||||||
public:
|
public:
|
||||||
GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2,
|
GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2,
|
||||||
const string &Name = "")
|
const std::string &Name = "")
|
||||||
: BinaryOperator(Opcode, S1, S2, Name) {
|
: BinaryOperator(Opcode, S1, S2, Name) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ class SetCondInst : public BinaryOperator {
|
|||||||
BinaryOps OpType;
|
BinaryOps OpType;
|
||||||
public:
|
public:
|
||||||
SetCondInst(BinaryOps opType, Value *S1, Value *S2,
|
SetCondInst(BinaryOps opType, Value *S1, Value *S2,
|
||||||
const string &Name = "");
|
const std::string &Name = "");
|
||||||
|
|
||||||
virtual const char *getOpcodeName() const;
|
virtual const char *getOpcodeName() const;
|
||||||
};
|
};
|
||||||
|
@ -24,7 +24,7 @@ class CastInst : public Instruction {
|
|||||||
Operands.push_back(Use(CI.Operands[0], this));
|
Operands.push_back(Use(CI.Operands[0], this));
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
CastInst(Value *S, const Type *Ty, const string &Name = "")
|
CastInst(Value *S, const Type *Ty, const std::string &Name = "")
|
||||||
: Instruction(Ty, Cast, Name) {
|
: Instruction(Ty, Cast, Name) {
|
||||||
Operands.reserve(1);
|
Operands.reserve(1);
|
||||||
Operands.push_back(Use(S, this));
|
Operands.push_back(Use(S, this));
|
||||||
@ -55,13 +55,13 @@ class MethodArgument : public Value { // Defined in the InstrType.cpp file
|
|||||||
inline void setParent(Method *parent) { Parent = parent; }
|
inline void setParent(Method *parent) { Parent = parent; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MethodArgument(const Type *Ty, const string &Name = "")
|
MethodArgument(const Type *Ty, const std::string &Name = "")
|
||||||
: Value(Ty, Value::MethodArgumentVal, Name) {
|
: Value(Ty, Value::MethodArgumentVal, Name) {
|
||||||
Parent = 0;
|
Parent = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Specialize setName to handle symbol table majik...
|
// Specialize setName to handle symbol table majik...
|
||||||
virtual void setName(const string &name, SymbolTable *ST = 0);
|
virtual void setName(const std::string &name, SymbolTable *ST = 0);
|
||||||
|
|
||||||
inline const Method *getParent() const { return Parent; }
|
inline const Method *getParent() const { return Parent; }
|
||||||
inline Method *getParent() { return Parent; }
|
inline Method *getParent() { return Parent; }
|
||||||
@ -81,7 +81,7 @@ public:
|
|||||||
class CallInst : public Instruction {
|
class CallInst : public Instruction {
|
||||||
CallInst(const CallInst &CI);
|
CallInst(const CallInst &CI);
|
||||||
public:
|
public:
|
||||||
CallInst(Value *Meth, const vector<Value*> ¶ms, const string &Name = "");
|
CallInst(Value *M, const std::vector<Value*> &Par, const std::string & = "");
|
||||||
|
|
||||||
virtual const char *getOpcodeName() const { return "call"; }
|
virtual const char *getOpcodeName() const { return "call"; }
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ class ShiftInst : public Instruction {
|
|||||||
Operands.push_back(Use(SI.Operands[1], this));
|
Operands.push_back(Use(SI.Operands[1], this));
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
ShiftInst(OtherOps Opcode, Value *S, Value *SA, const string &Name = "")
|
ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "")
|
||||||
: Instruction(S->getType(), Opcode, Name) {
|
: Instruction(S->getType(), Opcode, Name) {
|
||||||
assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
|
assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!");
|
||||||
Operands.reserve(2);
|
Operands.reserve(2);
|
||||||
|
@ -21,7 +21,7 @@ class BasicBlock;
|
|||||||
class PHINode : public Instruction {
|
class PHINode : public Instruction {
|
||||||
PHINode(const PHINode &PN);
|
PHINode(const PHINode &PN);
|
||||||
public:
|
public:
|
||||||
PHINode(const Type *Ty, const string &Name = "");
|
PHINode(const Type *Ty, const std::string &Name = "");
|
||||||
|
|
||||||
virtual Instruction *clone() const { return new PHINode(*this); }
|
virtual Instruction *clone() const { return new PHINode(*this); }
|
||||||
virtual const char *getOpcodeName() const { return "phi"; }
|
virtual const char *getOpcodeName() const { return "phi"; }
|
||||||
|
@ -198,7 +198,7 @@ class InvokeInst : public TerminatorInst {
|
|||||||
InvokeInst(const InvokeInst &BI);
|
InvokeInst(const InvokeInst &BI);
|
||||||
public:
|
public:
|
||||||
InvokeInst(Value *Meth, BasicBlock *IfNormal, BasicBlock *IfException,
|
InvokeInst(Value *Meth, BasicBlock *IfNormal, BasicBlock *IfException,
|
||||||
const vector<Value*> &Params, const string &Name = "");
|
const std::vector<Value*> &Params, const std::string &Name = "");
|
||||||
|
|
||||||
virtual Instruction *clone() const { return new InvokeInst(*this); }
|
virtual Instruction *clone() const { return new InvokeInst(*this); }
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "llvm/Optimizations/ConstantHandling.h"
|
#include "llvm/Optimizations/ConstantHandling.h"
|
||||||
#include "llvm/Method.h"
|
#include "llvm/Method.h"
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
using namespace opt; // Get all the constant handling stuff
|
using namespace opt; // Get all the constant handling stuff
|
||||||
using namespace analysis;
|
using namespace analysis;
|
||||||
@ -178,7 +179,7 @@ inline const ConstantInt *operator*(const DefZero &L, const DefOne &R) {
|
|||||||
static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) {
|
static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) {
|
||||||
const Type *Ty = V->getType();
|
const Type *Ty = V->getType();
|
||||||
if (Left.ExprTy > Right.ExprTy)
|
if (Left.ExprTy > Right.ExprTy)
|
||||||
swap(Left, Right); // Make left be simpler than right
|
std::swap(Left, Right); // Make left be simpler than right
|
||||||
|
|
||||||
switch (Left.ExprTy) {
|
switch (Left.ExprTy) {
|
||||||
case ExprType::Constant:
|
case ExprType::Constant:
|
||||||
@ -229,7 +230,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
|
|||||||
case Value::TypeVal: case Value::BasicBlockVal:
|
case Value::TypeVal: case Value::BasicBlockVal:
|
||||||
case Value::MethodVal: case Value::ModuleVal: default:
|
case Value::MethodVal: case Value::ModuleVal: default:
|
||||||
//assert(0 && "Unexpected expression type to classify!");
|
//assert(0 && "Unexpected expression type to classify!");
|
||||||
cerr << "Bizarre thing to expr classify: " << Expr << endl;
|
std::cerr << "Bizarre thing to expr classify: " << Expr << "\n";
|
||||||
return Expr;
|
return Expr;
|
||||||
case Value::GlobalVariableVal: // Global Variable & Method argument:
|
case Value::GlobalVariableVal: // Global Variable & Method argument:
|
||||||
case Value::MethodArgumentVal: // nothing known, return variable itself
|
case Value::MethodArgumentVal: // nothing known, return variable itself
|
||||||
@ -280,7 +281,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
|
|||||||
ExprType Left (ClassifyExpression(I->getOperand(0)));
|
ExprType Left (ClassifyExpression(I->getOperand(0)));
|
||||||
ExprType Right(ClassifyExpression(I->getOperand(1)));
|
ExprType Right(ClassifyExpression(I->getOperand(1)));
|
||||||
if (Left.ExprTy > Right.ExprTy)
|
if (Left.ExprTy > Right.ExprTy)
|
||||||
swap(Left, Right); // Make left be simpler than right
|
std::swap(Left, Right); // Make left be simpler than right
|
||||||
|
|
||||||
if (Left.ExprTy != ExprType::Constant) // RHS must be > constant
|
if (Left.ExprTy != ExprType::Constant) // RHS must be > constant
|
||||||
return I; // Quadratic eqn! :(
|
return I; // Quadratic eqn! :(
|
||||||
|
@ -29,7 +29,7 @@ cfg::CallGraphNode *cfg::CallGraph::getNodeFor(Method *M) {
|
|||||||
assert(M->getParent() == Mod && "Method not in current module!");
|
assert(M->getParent() == Mod && "Method not in current module!");
|
||||||
CallGraphNode *New = new CallGraphNode(M);
|
CallGraphNode *New = new CallGraphNode(M);
|
||||||
|
|
||||||
MethodMap.insert(pair<const Method*, CallGraphNode*>(M, New));
|
MethodMap.insert(std::make_pair(M, New));
|
||||||
return New;
|
return New;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ cfg::CallGraph::~CallGraph() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cfg::WriteToOutput(const CallGraphNode *CGN, ostream &o) {
|
void cfg::WriteToOutput(const CallGraphNode *CGN, std::ostream &o) {
|
||||||
if (CGN->getMethod())
|
if (CGN->getMethod())
|
||||||
o << "Call graph node for method: '" << CGN->getMethod()->getName() <<"'\n";
|
o << "Call graph node for method: '" << CGN->getMethod()->getName() <<"'\n";
|
||||||
else
|
else
|
||||||
@ -79,10 +79,10 @@ void cfg::WriteToOutput(const CallGraphNode *CGN, ostream &o) {
|
|||||||
|
|
||||||
for (unsigned i = 0; i < CGN->size(); ++i)
|
for (unsigned i = 0; i < CGN->size(); ++i)
|
||||||
o << " Calls method '" << (*CGN)[i]->getMethod()->getName() << "'\n";
|
o << " Calls method '" << (*CGN)[i]->getMethod()->getName() << "'\n";
|
||||||
o << endl;
|
o << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfg::WriteToOutput(const CallGraph &CG, ostream &o) {
|
void cfg::WriteToOutput(const CallGraph &CG, std::ostream &o) {
|
||||||
WriteToOutput(CG.getRoot(), o);
|
WriteToOutput(CG.getRoot(), o);
|
||||||
for (CallGraph::const_iterator I = CG.begin(), E = CG.end(); I != E; ++I)
|
for (CallGraph::const_iterator I = CG.begin(), E = CG.end(); I != E; ++I)
|
||||||
o << I->second;
|
o << I->second;
|
||||||
|
@ -60,7 +60,7 @@ bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) {
|
|||||||
UnsafeTypes.insert((PointerType*)ITy);
|
UnsafeTypes.insert((PointerType*)ITy);
|
||||||
|
|
||||||
if (PrintFailures) {
|
if (PrintFailures) {
|
||||||
CachedWriter CW(M->getParent(), cerr);
|
CachedWriter CW(M->getParent(), std::cerr);
|
||||||
CW << "FindUnsafePointerTypes: Type '" << ITy
|
CW << "FindUnsafePointerTypes: Type '" << ITy
|
||||||
<< "' marked unsafe in '" << Meth->getName() << "' by:\n" << Inst;
|
<< "' marked unsafe in '" << Meth->getName() << "' by:\n" << Inst;
|
||||||
}
|
}
|
||||||
@ -74,7 +74,7 @@ bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) {
|
|||||||
// printResults - Loop over the results of the analysis, printing out unsafe
|
// printResults - Loop over the results of the analysis, printing out unsafe
|
||||||
// types.
|
// types.
|
||||||
//
|
//
|
||||||
void FindUnsafePointerTypes::printResults(const Module *M, ostream &o) {
|
void FindUnsafePointerTypes::printResults(const Module *M, std::ostream &o) {
|
||||||
if (UnsafeTypes.empty()) {
|
if (UnsafeTypes.empty()) {
|
||||||
o << "SafePointerAccess Analysis: No unsafe types found!\n";
|
o << "SafePointerAccess Analysis: No unsafe types found!\n";
|
||||||
return;
|
return;
|
||||||
@ -84,9 +84,9 @@ void FindUnsafePointerTypes::printResults(const Module *M, ostream &o) {
|
|||||||
|
|
||||||
CW << "SafePointerAccess Analysis: Found these unsafe types:\n";
|
CW << "SafePointerAccess Analysis: Found these unsafe types:\n";
|
||||||
unsigned Counter = 1;
|
unsigned Counter = 1;
|
||||||
for (set<PointerType*>::const_iterator I = getUnsafeTypes().begin(),
|
for (std::set<PointerType*>::const_iterator I = getUnsafeTypes().begin(),
|
||||||
E = getUnsafeTypes().end(); I != E; ++I, ++Counter) {
|
E = getUnsafeTypes().end(); I != E; ++I, ++Counter) {
|
||||||
|
|
||||||
CW << " #" << Counter << ". " << (Value*)*I << endl;
|
CW << " #" << Counter << ". " << (Value*)*I << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,15 +78,15 @@ bool FindUsedTypes::doPerMethodWork(Method *m) {
|
|||||||
// passed in, then the types are printed symbolically if possible, using the
|
// passed in, then the types are printed symbolically if possible, using the
|
||||||
// symbol table from the module.
|
// symbol table from the module.
|
||||||
//
|
//
|
||||||
void FindUsedTypes::printTypes(ostream &o, const Module *M = 0) const {
|
void FindUsedTypes::printTypes(std::ostream &o, const Module *M = 0) const {
|
||||||
o << "Types in use by this module:\n";
|
o << "Types in use by this module:\n";
|
||||||
if (M) {
|
if (M) {
|
||||||
CachedWriter CW(M, o);
|
CachedWriter CW(M, o);
|
||||||
for (set<const Type *>::const_iterator I = UsedTypes.begin(),
|
for (std::set<const Type *>::const_iterator I = UsedTypes.begin(),
|
||||||
E = UsedTypes.end(); I != E; ++I)
|
E = UsedTypes.end(); I != E; ++I)
|
||||||
CW << " " << *I << endl;
|
CW << " " << *I << "\n";
|
||||||
} else
|
} else
|
||||||
for (set<const Type *>::const_iterator I = UsedTypes.begin(),
|
for (std::set<const Type *>::const_iterator I = UsedTypes.begin(),
|
||||||
E = UsedTypes.end(); I != E; ++I)
|
E = UsedTypes.end(); I != E; ++I)
|
||||||
o << " " << *I << endl;
|
o << " " << *I << "\n";
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
|
|||||||
ExprType E2 = analysis::ClassifyExpression(V2);
|
ExprType E2 = analysis::ClassifyExpression(V2);
|
||||||
|
|
||||||
if (E1.ExprTy > E2.ExprTy) // Make E1 be the simpler expression
|
if (E1.ExprTy > E2.ExprTy) // Make E1 be the simpler expression
|
||||||
swap(E1, E2);
|
std::swap(E1, E2);
|
||||||
|
|
||||||
// E1 must be a constant incoming value, and E2 must be a linear expression
|
// E1 must be a constant incoming value, and E2 must be a linear expression
|
||||||
// with respect to the PHI node.
|
// with respect to the PHI node.
|
||||||
@ -109,7 +109,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
|
|||||||
// Make sure that V1 is the incoming value, and V2 is from the backedge of
|
// Make sure that V1 is the incoming value, and V2 is from the backedge of
|
||||||
// the loop.
|
// the loop.
|
||||||
if (L->contains(Phi->getIncomingBlock(0))) // Wrong order. Swap now.
|
if (L->contains(Phi->getIncomingBlock(0))) // Wrong order. Swap now.
|
||||||
swap(V1, V2);
|
std::swap(V1, V2);
|
||||||
|
|
||||||
Start = V1; // We know that Start has to be loop invariant...
|
Start = V1; // We know that Start has to be loop invariant...
|
||||||
Step = 0;
|
Step = 0;
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
|
|
||||||
using namespace cfg;
|
using namespace cfg;
|
||||||
|
using std::make_pair;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// IntervalPartition Implementation
|
// IntervalPartition Implementation
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
#include "llvm/Analysis/LiveVar/BBLiveVar.h"
|
#include "llvm/Analysis/LiveVar/BBLiveVar.h"
|
||||||
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
|
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
|
|
||||||
|
/// BROKEN: Should not include sparc stuff directly into here
|
||||||
#include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn
|
#include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn
|
||||||
|
|
||||||
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
using std::pair;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Constructor
|
// Constructor
|
||||||
@ -39,7 +44,7 @@ void BBLiveVar::calcDefUseSets()
|
|||||||
if( DEBUG_LV > 1) { // debug msg
|
if( DEBUG_LV > 1) { // debug msg
|
||||||
cerr << " *Iterating over machine instr ";
|
cerr << " *Iterating over machine instr ";
|
||||||
MInst->dump();
|
MInst->dump();
|
||||||
cerr << endl;
|
cerr << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
// iterate over MI operands to find defs
|
// iterate over MI operands to find defs
|
||||||
@ -87,7 +92,7 @@ void BBLiveVar::calcDefUseSets()
|
|||||||
printValue( ArgVal );
|
printValue( ArgVal );
|
||||||
cerr << " came from BB ";
|
cerr << " came from BB ";
|
||||||
printValue( PhiArgMap[ ArgVal ]);
|
printValue( PhiArgMap[ ArgVal ]);
|
||||||
cerr<<endl;
|
cerr << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} // if( IsPhi )
|
} // if( IsPhi )
|
||||||
@ -123,7 +128,7 @@ void BBLiveVar::addDef(const Value *Op)
|
|||||||
InSetChanged = true;
|
InSetChanged = true;
|
||||||
|
|
||||||
if( DEBUG_LV > 1) {
|
if( DEBUG_LV > 1) {
|
||||||
cerr << " +Def: "; printValue( Op ); cerr << endl;
|
cerr << " +Def: "; printValue( Op ); cerr << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class BBLiveVar
|
|||||||
|
|
||||||
// map that contains phi args->BB they came
|
// map that contains phi args->BB they came
|
||||||
// set by calcDefUseSets & used by setPropagate
|
// set by calcDefUseSets & used by setPropagate
|
||||||
hash_map<const Value *, const BasicBlock *, hashFuncValue> PhiArgMap;
|
std::hash_map<const Value *, const BasicBlock *> PhiArgMap;
|
||||||
|
|
||||||
// method to propogate an InSet to OutSet of a predecessor
|
// method to propogate an InSet to OutSet of a predecessor
|
||||||
bool setPropagate( LiveVarSet *const OutSetOfPred,
|
bool setPropagate( LiveVarSet *const OutSetOfPred,
|
||||||
|
@ -12,15 +12,15 @@
|
|||||||
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
|
#include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "Support/PostOrderIterator.h"
|
#include "Support/PostOrderIterator.h"
|
||||||
|
#include <iostream>
|
||||||
|
using std::cout;
|
||||||
|
using std::endl;
|
||||||
|
|
||||||
//************************** Constructor/Destructor ***************************
|
//************************** Constructor/Destructor ***************************
|
||||||
|
|
||||||
|
|
||||||
MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M),
|
MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M) {
|
||||||
BB2BBLVMap()
|
assert(!M->isExternal() && "Cannot be a prototype declaration");
|
||||||
{
|
|
||||||
assert(! M->isExternal() ); // cannot be a prototype decleration
|
|
||||||
HasAnalyzed = false; // still we haven't called analyze()
|
HasAnalyzed = false; // still we haven't called analyze()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,8 +55,6 @@ MethodLiveVarInfo:: ~MethodLiveVarInfo()
|
|||||||
if( (*MI).first ) // delete all LiveVarSets in MInst2LVSetBI
|
if( (*MI).first ) // delete all LiveVarSets in MInst2LVSetBI
|
||||||
delete (*MI).second;
|
delete (*MI).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,14 @@
|
|||||||
|
|
||||||
#include "llvm/Analysis/LiveVar/ValueSet.h"
|
#include "llvm/Analysis/LiveVar/ValueSet.h"
|
||||||
#include "llvm/ConstantVals.h"
|
#include "llvm/ConstantVals.h"
|
||||||
|
#include <iostream>
|
||||||
|
using std::cerr;
|
||||||
|
using std::endl;
|
||||||
|
using std::pair;
|
||||||
|
using std::hash_set;
|
||||||
|
|
||||||
void printValue( const Value *const v) // func to print a Value
|
void printValue( const Value *const v) // func to print a Value
|
||||||
{
|
{
|
||||||
|
|
||||||
if (v->hasName())
|
if (v->hasName())
|
||||||
cerr << v << "(" << ((*v).getName()) << ") ";
|
cerr << v << "(" << ((*v).getName()) << ") ";
|
||||||
else if (Constant *C = dyn_cast<Constant>(v))
|
else if (Constant *C = dyn_cast<Constant>(v))
|
||||||
@ -16,17 +19,13 @@ void printValue( const Value *const v) // func to print a Value
|
|||||||
|
|
||||||
|
|
||||||
//---------------- Method implementations --------------------------
|
//---------------- Method implementations --------------------------
|
||||||
|
|
||||||
|
|
||||||
ValueSet:: ValueSet() : hash_set<const Value *, hashFuncValue> () { }
|
|
||||||
|
|
||||||
// for performing two set unions
|
// for performing two set unions
|
||||||
bool ValueSet::setUnion( const ValueSet *const set1) {
|
bool ValueSet::setUnion( const ValueSet *const set1) {
|
||||||
const_iterator set1it;
|
const_iterator set1it;
|
||||||
pair<iterator, bool> result;
|
pair<iterator, bool> result;
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|
||||||
for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {
|
for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
|
||||||
// for all all elements in set1
|
// for all all elements in set1
|
||||||
result = insert( *set1it ); // insert to this set
|
result = insert( *set1it ); // insert to this set
|
||||||
if( result.second == true) changed = true;
|
if( result.second == true) changed = true;
|
||||||
@ -41,7 +40,7 @@ void ValueSet::setDifference( const ValueSet *const set1,
|
|||||||
const ValueSet *const set2) {
|
const ValueSet *const set2) {
|
||||||
|
|
||||||
const_iterator set1it, set2it;
|
const_iterator set1it, set2it;
|
||||||
for( set1it = set1->begin() ; set1it != set1->end(); set1it++) {
|
for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) {
|
||||||
// for all elements in set1
|
// for all elements in set1
|
||||||
iterator set2it = set2->find( *set1it ); // find wether the elem is in set2
|
iterator set2it = set2->find( *set1it ); // find wether the elem is in set2
|
||||||
if( set2it == set2->end() ) // if the element is not in set2
|
if( set2it == set2->end() ) // if the element is not in set2
|
||||||
@ -53,7 +52,7 @@ void ValueSet::setDifference( const ValueSet *const set1,
|
|||||||
// for performing set subtraction
|
// for performing set subtraction
|
||||||
void ValueSet::setSubtract( const ValueSet *const set1) {
|
void ValueSet::setSubtract( const ValueSet *const set1) {
|
||||||
const_iterator set1it;
|
const_iterator set1it;
|
||||||
for( set1it = set1->begin() ; set1it != set1->end(); set1it++)
|
for( set1it = set1->begin() ; set1it != set1->end(); ++set1it)
|
||||||
// for all elements in set1
|
// for all elements in set1
|
||||||
erase( *set1it ); // erase that element from this set
|
erase( *set1it ); // erase that element from this set
|
||||||
}
|
}
|
||||||
@ -62,7 +61,5 @@ void ValueSet::setSubtract( const ValueSet *const set1) {
|
|||||||
|
|
||||||
|
|
||||||
void ValueSet::printSet() const { // for printing a live variable set
|
void ValueSet::printSet() const { // for printing a live variable set
|
||||||
const_iterator it;
|
for_each(begin(), end(), printValue);
|
||||||
for( it = begin() ; it != end(); it++)
|
|
||||||
printValue( *it );
|
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,6 @@ inline void LoopDepthCalculator::ProcessInterval(cfg::Interval *I) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LoopDepthCalculator::LoopDepthCalculator(Method *M) {
|
LoopDepthCalculator::LoopDepthCalculator(Method *M) {
|
||||||
//map<const BasicBlock*, unsigned> LoopDepth;
|
|
||||||
|
|
||||||
cfg::IntervalPartition *IP = new cfg::IntervalPartition(M);
|
cfg::IntervalPartition *IP = new cfg::IntervalPartition(M);
|
||||||
while (!IP->isDegeneratePartition()) {
|
while (!IP->isDegeneratePartition()) {
|
||||||
for_each(IP->begin(), IP->end(),
|
for_each(IP->begin(), IP->end(),
|
||||||
@ -34,7 +32,7 @@ LoopDepthCalculator::LoopDepthCalculator(Method *M) {
|
|||||||
//
|
//
|
||||||
cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, true);
|
cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, true);
|
||||||
if (NewIP->size() == IP->size()) {
|
if (NewIP->size() == IP->size()) {
|
||||||
cerr << "IRREDUCIBLE GRAPH FOUND!!!\n";
|
assert(0 && "IRREDUCIBLE GRAPH FOUND!!!\n");
|
||||||
// TODO: fix irreducible graph
|
// TODO: fix irreducible graph
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB,
|
|||||||
const DominatorSet &DS) {
|
const DominatorSet &DS) {
|
||||||
if (BBMap.find(BB) != BBMap.end()) return 0; // Havn't processed this node?
|
if (BBMap.find(BB) != BBMap.end()) return 0; // Havn't processed this node?
|
||||||
|
|
||||||
vector<const BasicBlock *> TodoStack;
|
std::vector<const BasicBlock *> TodoStack;
|
||||||
|
|
||||||
// Scan the predecessors of BB, checking to see if BB dominates any of
|
// Scan the predecessors of BB, checking to see if BB dominates any of
|
||||||
// them.
|
// them.
|
||||||
@ -64,7 +64,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB,
|
|||||||
// loop can be found for them. Also check subsidary basic blocks to see if
|
// loop can be found for them. Also check subsidary basic blocks to see if
|
||||||
// they start subloops of their own.
|
// they start subloops of their own.
|
||||||
//
|
//
|
||||||
for (vector<const BasicBlock*>::reverse_iterator I = L->Blocks.rbegin(),
|
for (std::vector<const BasicBlock*>::reverse_iterator I = L->Blocks.rbegin(),
|
||||||
E = L->Blocks.rend(); I != E; ++I) {
|
E = L->Blocks.rend(); I != E; ++I) {
|
||||||
|
|
||||||
// Check to see if this block starts a new loop
|
// Check to see if this block starts a new loop
|
||||||
@ -74,7 +74,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (BBMap.find(*I) == BBMap.end())
|
if (BBMap.find(*I) == BBMap.end())
|
||||||
BBMap.insert(make_pair(*I, L));
|
BBMap.insert(std::make_pair(*I, L));
|
||||||
}
|
}
|
||||||
|
|
||||||
return L;
|
return L;
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
#include <iostream>
|
||||||
|
using std::set;
|
||||||
|
|
||||||
// processModule - Driver function to call all of my subclasses virtual methods.
|
// processModule - Driver function to call all of my subclasses virtual methods.
|
||||||
//
|
//
|
||||||
@ -59,7 +61,7 @@ inline bool ModuleAnalyzer::handleType(set<const Type *> &TypeSet,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
cerr << "ModuleAnalyzer::handleType, type unknown: '"
|
std::cerr << "ModuleAnalyzer::handleType, type unknown: '"
|
||||||
<< T->getName() << "'\n";
|
<< T->getName() << "'\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include "Support/DepthFirstIterator.h"
|
#include "Support/DepthFirstIterator.h"
|
||||||
#include "Support/STLExtras.h"
|
#include "Support/STLExtras.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
using std::set;
|
||||||
|
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Helper Template
|
// Helper Template
|
||||||
|
@ -12,6 +12,10 @@
|
|||||||
#include "llvm/Analysis/InductionVariable.h"
|
#include "llvm/Analysis/InductionVariable.h"
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
using std::ostream;
|
||||||
|
using std::set;
|
||||||
|
using std::vector;
|
||||||
|
using std::string;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Interval Printing Routines
|
// Interval Printing Routines
|
||||||
@ -23,19 +27,19 @@ void cfg::WriteToOutput(const Interval *I, ostream &o) {
|
|||||||
|
|
||||||
// Print out all of the basic blocks in the interval...
|
// Print out all of the basic blocks in the interval...
|
||||||
copy(I->Nodes.begin(), I->Nodes.end(),
|
copy(I->Nodes.begin(), I->Nodes.end(),
|
||||||
ostream_iterator<BasicBlock*>(o, "\n"));
|
std::ostream_iterator<BasicBlock*>(o, "\n"));
|
||||||
|
|
||||||
o << "Interval Predecessors:\n";
|
o << "Interval Predecessors:\n";
|
||||||
copy(I->Predecessors.begin(), I->Predecessors.end(),
|
copy(I->Predecessors.begin(), I->Predecessors.end(),
|
||||||
ostream_iterator<BasicBlock*>(o, "\n"));
|
std::ostream_iterator<BasicBlock*>(o, "\n"));
|
||||||
|
|
||||||
o << "Interval Successors:\n";
|
o << "Interval Successors:\n";
|
||||||
copy(I->Successors.begin(), I->Successors.end(),
|
copy(I->Successors.begin(), I->Successors.end(),
|
||||||
ostream_iterator<BasicBlock*>(o, "\n"));
|
std::ostream_iterator<BasicBlock*>(o, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) {
|
void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) {
|
||||||
copy(IP.begin(), IP.end(), ostream_iterator<const Interval *>(o, "\n"));
|
copy(IP.begin(), IP.end(), std::ostream_iterator<const Interval *>(o, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -45,7 +49,7 @@ void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
ostream &operator<<(ostream &o, const set<const BasicBlock*> &BBs) {
|
ostream &operator<<(ostream &o, const set<const BasicBlock*> &BBs) {
|
||||||
copy(BBs.begin(), BBs.end(), ostream_iterator<const BasicBlock*>(o, "\n"));
|
copy(BBs.begin(),BBs.end(), std::ostream_iterator<const BasicBlock*>(o,"\n"));
|
||||||
return o;
|
return o;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +57,7 @@ void cfg::WriteToOutput(const DominatorSet &DS, ostream &o) {
|
|||||||
for (DominatorSet::const_iterator I = DS.begin(), E = DS.end(); I != E; ++I) {
|
for (DominatorSet::const_iterator I = DS.begin(), E = DS.end(); I != E; ++I) {
|
||||||
o << "=============================--------------------------------\n"
|
o << "=============================--------------------------------\n"
|
||||||
<< "\nDominator Set For Basic Block\n" << I->first
|
<< "\nDominator Set For Basic Block\n" << I->first
|
||||||
<< "-------------------------------\n" << I->second << endl;
|
<< "-------------------------------\n" << I->second << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +67,7 @@ void cfg::WriteToOutput(const ImmediateDominators &ID, ostream &o) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
o << "=============================--------------------------------\n"
|
o << "=============================--------------------------------\n"
|
||||||
<< "\nImmediate Dominator For Basic Block\n" << I->first
|
<< "\nImmediate Dominator For Basic Block\n" << I->first
|
||||||
<< "is: \n" << I->second << endl;
|
<< "is: \n" << I->second << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +97,7 @@ void cfg::WriteToOutput(const DominanceFrontier &DF, ostream &o) {
|
|||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
o << "=============================--------------------------------\n"
|
o << "=============================--------------------------------\n"
|
||||||
<< "\nDominance Frontier For Basic Block\n" << I->first
|
<< "\nDominance Frontier For Basic Block\n" << I->first
|
||||||
<< "is: \n" << I->second << endl;
|
<< "is: \n" << I->second << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,15 +113,15 @@ void cfg::WriteToOutput(const Loop *L, ostream &o) {
|
|||||||
if (i) o << ",";
|
if (i) o << ",";
|
||||||
WriteAsOperand(o, (const Value*)L->getBlocks()[i]);
|
WriteAsOperand(o, (const Value*)L->getBlocks()[i]);
|
||||||
}
|
}
|
||||||
o << endl;
|
o << "\n";
|
||||||
|
|
||||||
copy(L->getSubLoops().begin(), L->getSubLoops().end(),
|
copy(L->getSubLoops().begin(), L->getSubLoops().end(),
|
||||||
ostream_iterator<const Loop*>(o, "\n"));
|
std::ostream_iterator<const Loop*>(o, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void cfg::WriteToOutput(const LoopInfo &LI, ostream &o) {
|
void cfg::WriteToOutput(const LoopInfo &LI, ostream &o) {
|
||||||
copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(),
|
copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(),
|
||||||
ostream_iterator<const Loop*>(o, "\n"));
|
std::ostream_iterator<const Loop*>(o, "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -138,11 +142,11 @@ void WriteToOutput(const InductionVariable &IV, ostream &o) {
|
|||||||
WriteAsOperand(o, (const Value*)IV.Phi);
|
WriteAsOperand(o, (const Value*)IV.Phi);
|
||||||
o << ":\n" << (const Value*)IV.Phi;
|
o << ":\n" << (const Value*)IV.Phi;
|
||||||
} else {
|
} else {
|
||||||
o << endl;
|
o << "\n";
|
||||||
}
|
}
|
||||||
if (IV.InductionType == InductionVariable::Unknown) return;
|
if (IV.InductionType == InductionVariable::Unknown) return;
|
||||||
|
|
||||||
o << " Start ="; WriteAsOperand(o, IV.Start);
|
o << " Start ="; WriteAsOperand(o, IV.Start);
|
||||||
o << " Step =" ; WriteAsOperand(o, IV.Step);
|
o << " Step =" ; WriteAsOperand(o, IV.Step);
|
||||||
o << endl;
|
o << "\n";
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "ParserInternals.h"
|
#include "ParserInternals.h"
|
||||||
#include <stdio.h> // for sprintf
|
#include <stdio.h> // for sprintf
|
||||||
|
using std::string;
|
||||||
|
|
||||||
// The useful interface defined by this file... Parse an ascii file, and return
|
// The useful interface defined by this file... Parse an ascii file, and return
|
||||||
// the internal representation in a nice slice'n'dice'able representation.
|
// the internal representation in a nice slice'n'dice'able representation.
|
||||||
@ -30,7 +31,7 @@ Module *ParseAssemblyFile(const string &Filename) { // throw (ParseException)
|
|||||||
fclose(F);
|
fclose(F);
|
||||||
|
|
||||||
if (Result) { // Check to see that it is valid...
|
if (Result) { // Check to see that it is valid...
|
||||||
vector<string> Errors;
|
std::vector<string> Errors;
|
||||||
if (verify(Result, Errors)) {
|
if (verify(Result, Errors)) {
|
||||||
delete Result; Result = 0;
|
delete Result; Result = 0;
|
||||||
string Message;
|
string Message;
|
||||||
|
@ -23,12 +23,12 @@
|
|||||||
class Module;
|
class Module;
|
||||||
|
|
||||||
// Global variables exported from the lexer...
|
// Global variables exported from the lexer...
|
||||||
extern FILE *llvmAsmin;
|
extern std::FILE *llvmAsmin;
|
||||||
extern int llvmAsmlineno;
|
extern int llvmAsmlineno;
|
||||||
|
|
||||||
// Globals exported by the parser...
|
// Globals exported by the parser...
|
||||||
extern string CurFilename;
|
extern std::string CurFilename;
|
||||||
Module *RunVMAsmParser(const string &Filename, FILE *F);
|
Module *RunVMAsmParser(const std::string &Filename, FILE *F);
|
||||||
|
|
||||||
|
|
||||||
// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
|
// UnEscapeLexed - Run through the specified buffer and change \xx codes to the
|
||||||
@ -47,7 +47,7 @@ char *UnEscapeLexed(char *Buffer, bool AllowNull = false);
|
|||||||
// This also helps me because I keep typing 'throw new ParseException' instead
|
// This also helps me because I keep typing 'throw new ParseException' instead
|
||||||
// of just 'throw ParseException'... sigh...
|
// of just 'throw ParseException'... sigh...
|
||||||
//
|
//
|
||||||
static inline void ThrowException(const string &message,
|
static inline void ThrowException(const std::string &message,
|
||||||
int LineNo = -1) {
|
int LineNo = -1) {
|
||||||
if (LineNo == -1) LineNo = llvmAsmlineno;
|
if (LineNo == -1) LineNo = llvmAsmlineno;
|
||||||
// TODO: column number in exception
|
// TODO: column number in exception
|
||||||
@ -116,18 +116,19 @@ struct ValID {
|
|||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline string getName() const {
|
inline std::string getName() const {
|
||||||
switch (Type) {
|
switch (Type) {
|
||||||
case NumberVal : return string("#") + itostr(Num);
|
case NumberVal : return std::string("#") + itostr(Num);
|
||||||
case NameVal : return Name;
|
case NameVal : return Name;
|
||||||
case ConstStringVal: return string("\"") + Name + string("\"");
|
case ConstStringVal: return std::string("\"") + Name + std::string("\"");
|
||||||
case ConstFPVal : return ftostr(ConstPoolFP);
|
case ConstFPVal : return ftostr(ConstPoolFP);
|
||||||
case ConstNullVal : return "null";
|
case ConstNullVal : return "null";
|
||||||
case ConstUIntVal :
|
case ConstUIntVal :
|
||||||
case ConstSIntVal : return string("%") + itostr(ConstPool64);
|
case ConstSIntVal : return std::string("%") + itostr(ConstPool64);
|
||||||
default:
|
default:
|
||||||
assert(0 && "Unknown value!");
|
assert(0 && "Unknown value!");
|
||||||
abort();
|
abort();
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,7 +164,7 @@ public:
|
|||||||
struct InstPlaceHolderHelper : public Instruction {
|
struct InstPlaceHolderHelper : public Instruction {
|
||||||
InstPlaceHolderHelper(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
|
InstPlaceHolderHelper(const Type *Ty) : Instruction(Ty, UserOp1, "") {}
|
||||||
|
|
||||||
virtual Instruction *clone() const { abort(); }
|
virtual Instruction *clone() const { abort(); return 0; }
|
||||||
virtual const char *getOpcodeName() const { return "placeholder"; }
|
virtual const char *getOpcodeName() const { return "placeholder"; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user