Removed trailing whitespace.

llvm-svn: 65196
This commit is contained in:
Misha Brukman 2009-02-20 22:51:36 +00:00
parent 13dd5f564d
commit 7ee4196e74
22 changed files with 202 additions and 202 deletions

View File

@ -16,7 +16,7 @@
#define LLVM_SUPPORT_ALIGNOF_H #define LLVM_SUPPORT_ALIGNOF_H
namespace llvm { namespace llvm {
template <typename T> template <typename T>
struct AlignmentCalcImpl { struct AlignmentCalcImpl {
char x; char x;
@ -24,7 +24,7 @@ struct AlignmentCalcImpl {
private: private:
AlignmentCalcImpl() {} // Never instantiate. AlignmentCalcImpl() {} // Never instantiate.
}; };
/// AlignOf - A templated class that contains an enum value representing /// AlignOf - A templated class that contains an enum value representing
/// the alignment of the template argument. For example, /// the alignment of the template argument. For example,
/// AlignOf<int>::Alignment represents the alignment of type "int". The /// AlignOf<int>::Alignment represents the alignment of type "int". The
@ -41,9 +41,9 @@ struct AlignOf {
enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 }; enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 };
enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 }; enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 };
enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 }; enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 };
enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 }; enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 };
enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 }; enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 };
enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 }; enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 };
enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 }; enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 };
@ -55,6 +55,6 @@ struct AlignOf {
/// alignof<int>() returns the alignment of an int. /// alignof<int>() returns the alignment of an int.
template <typename T> template <typename T>
static inline unsigned alignof() { return AlignOf<T>::Alignment; } static inline unsigned alignof() { return AlignOf<T>::Alignment; }
} // end namespace llvm } // end namespace llvm
#endif #endif

View File

@ -18,24 +18,24 @@
#include <cstdlib> #include <cstdlib>
namespace llvm { namespace llvm {
class MallocAllocator { class MallocAllocator {
public: public:
MallocAllocator() {} MallocAllocator() {}
~MallocAllocator() {} ~MallocAllocator() {}
void Reset() {} void Reset() {}
void *Allocate(size_t Size, size_t /*Alignment*/) { return malloc(Size); } void *Allocate(size_t Size, size_t /*Alignment*/) { return malloc(Size); }
template <typename T> template <typename T>
T *Allocate() { return static_cast<T*>(malloc(sizeof(T))); } T *Allocate() { return static_cast<T*>(malloc(sizeof(T))); }
template <typename T> template <typename T>
T *Allocate(size_t Num) { T *Allocate(size_t Num) {
return static_cast<T*>(malloc(sizeof(T)*Num)); return static_cast<T*>(malloc(sizeof(T)*Num));
} }
void Deallocate(const void *Ptr) { free(const_cast<void*>(Ptr)); } void Deallocate(const void *Ptr) { free(const_cast<void*>(Ptr)); }
void PrintStats() const {} void PrintStats() const {}
@ -53,7 +53,7 @@ class BumpPtrAllocator {
public: public:
BumpPtrAllocator(); BumpPtrAllocator();
~BumpPtrAllocator(); ~BumpPtrAllocator();
void Reset(); void Reset();
void *Allocate(size_t Size, size_t Alignment); void *Allocate(size_t Size, size_t Alignment);
@ -61,21 +61,21 @@ public:
/// Allocate space, but do not construct, one object. /// Allocate space, but do not construct, one object.
/// ///
template <typename T> template <typename T>
T *Allocate() { T *Allocate() {
return static_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment)); return static_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
} }
/// Allocate space for an array of objects. This does not construct the /// Allocate space for an array of objects. This does not construct the
/// objects though. /// objects though.
template <typename T> template <typename T>
T *Allocate(size_t Num) { T *Allocate(size_t Num) {
return static_cast<T*>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment)); return static_cast<T*>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment));
} }
/// Allocate space for a specific count of elements and with a specified /// Allocate space for a specific count of elements and with a specified
/// alignment. /// alignment.
template <typename T> template <typename T>
T *Allocate(size_t Num, unsigned Alignment) { T *Allocate(size_t Num, unsigned Alignment) {
// Round EltSize up to the specified alignment. // Round EltSize up to the specified alignment.
unsigned EltSize = (sizeof(T)+Alignment-1)&~Alignment; unsigned EltSize = (sizeof(T)+Alignment-1)&~Alignment;
return static_cast<T*>(Allocate(Num * EltSize, Alignment)); return static_cast<T*>(Allocate(Num * EltSize, Alignment));

View File

@ -59,7 +59,7 @@ class ConstantRange {
/// getUpper - Return the upper value for this range... /// getUpper - Return the upper value for this range...
/// ///
const APInt &getUpper() const { return Upper; } const APInt &getUpper() const { return Upper; }
/// getBitWidth - get the bit width of this ConstantRange /// getBitWidth - get the bit width of this ConstantRange
/// ///

View File

@ -54,7 +54,7 @@ struct DefaultDOTGraphTraits {
static std::string getNodeLabel(const void *Node, const GraphType& Graph) { static std::string getNodeLabel(const void *Node, const GraphType& Graph) {
return ""; return "";
} }
/// hasNodeAddressLabel - If this method returns true, the address of the node /// hasNodeAddressLabel - If this method returns true, the address of the node
/// is added to the label of the node. /// is added to the label of the node.
template<typename GraphType> template<typename GraphType>

View File

@ -7,7 +7,7 @@
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// //
// This file defines specializations of GraphTraits that allows Use-Def and // This file defines specializations of GraphTraits that allows Use-Def and
// Def-Use relations to be treated as proper graphs for generic algorithms. // Def-Use relations to be treated as proper graphs for generic algorithms.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -20,7 +20,7 @@
namespace llvm { namespace llvm {
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Provide specializations of GraphTraits to be able to treat def-use/use-def // Provide specializations of GraphTraits to be able to treat def-use/use-def
// chains as graphs // chains as graphs
template <> struct GraphTraits<const User*> { template <> struct GraphTraits<const User*> {

View File

@ -64,7 +64,7 @@ bool isCurrentDebugType(const char *Type);
/// getErrorOutputStream - Returns the error output stream (std::cerr). This /// getErrorOutputStream - Returns the error output stream (std::cerr). This
/// places the std::c* I/O streams into one .cpp file and relieves the whole /// places the std::c* I/O streams into one .cpp file and relieves the whole
/// program from having to have hundreds of static c'tor/d'tors for them. /// program from having to have hundreds of static c'tor/d'tors for them.
/// ///
OStream &getErrorOutputStream(const char *DebugType); OStream &getErrorOutputStream(const char *DebugType);
#ifdef NDEBUG #ifdef NDEBUG

View File

@ -10,7 +10,7 @@
// This file contains constants used for implementing Dwarf debug support. For // This file contains constants used for implementing Dwarf debug support. For
// Details on the Dwarf 3 specfication see DWARF Debugging Information Format // Details on the Dwarf 3 specfication see DWARF Debugging Information Format
// V.3 reference manual http://dwarf.freestandards.org , // V.3 reference manual http://dwarf.freestandards.org ,
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_DWARF_H #ifndef LLVM_SUPPORT_DWARF_H
@ -42,23 +42,23 @@ namespace dwarf {
enum llvm_dwarf_constants { enum llvm_dwarf_constants {
// llvm mock tags // llvm mock tags
DW_TAG_invalid = ~0U, // Tag for invalid results. DW_TAG_invalid = ~0U, // Tag for invalid results.
DW_TAG_anchor = 0, // Tag for descriptor anchors. DW_TAG_anchor = 0, // Tag for descriptor anchors.
DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables. DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables.
DW_TAG_arg_variable = 0x101, // Tag for argument variables. DW_TAG_arg_variable = 0x101, // Tag for argument variables.
DW_TAG_return_variable = 0x102, // Tag for return variables. DW_TAG_return_variable = 0x102, // Tag for return variables.
DW_TAG_vector_type = 0x103, // Tag for vector types. DW_TAG_vector_type = 0x103, // Tag for vector types.
DW_TAG_user_base = 0x1000, // Recommended base for user tags. DW_TAG_user_base = 0x1000, // Recommended base for user tags.
DW_CIE_VERSION = 1, // Common frame information version. DW_CIE_VERSION = 1, // Common frame information version.
DW_CIE_ID = 0xffffffff // Common frame information mark. DW_CIE_ID = 0xffffffff // Common frame information mark.
}; };
enum dwarf_constants { enum dwarf_constants {
DWARF_VERSION = 2, DWARF_VERSION = 2,
// Tags // Tags
DW_TAG_array_type = 0x01, DW_TAG_array_type = 0x01,
DW_TAG_class_type = 0x02, DW_TAG_class_type = 0x02,
@ -357,7 +357,7 @@ enum dwarf_constants {
DW_ACCESS_protected = 0x02, DW_ACCESS_protected = 0x02,
DW_ACCESS_private = 0x03, DW_ACCESS_private = 0x03,
// Visibility codes // Visibility codes
DW_VIS_local = 0x01, DW_VIS_local = 0x01,
DW_VIS_exported = 0x02, DW_VIS_exported = 0x02,
DW_VIS_qualified = 0x03, DW_VIS_qualified = 0x03,
@ -366,7 +366,7 @@ enum dwarf_constants {
DW_VIRTUALITY_none = 0x00, DW_VIRTUALITY_none = 0x00,
DW_VIRTUALITY_virtual = 0x01, DW_VIRTUALITY_virtual = 0x01,
DW_VIRTUALITY_pure_virtual = 0x02, DW_VIRTUALITY_pure_virtual = 0x02,
// Language names // Language names
DW_LANG_C89 = 0x0001, DW_LANG_C89 = 0x0001,
DW_LANG_C = 0x0002, DW_LANG_C = 0x0002,
@ -389,7 +389,7 @@ enum dwarf_constants {
DW_LANG_D = 0x0013, DW_LANG_D = 0x0013,
DW_LANG_lo_user = 0x8000, DW_LANG_lo_user = 0x8000,
DW_LANG_hi_user = 0xffff, DW_LANG_hi_user = 0xffff,
// Identifier case codes // Identifier case codes
DW_ID_case_sensitive = 0x00, DW_ID_case_sensitive = 0x00,
DW_ID_up_case = 0x01, DW_ID_up_case = 0x01,
@ -409,7 +409,7 @@ enum dwarf_constants {
DW_INL_declared_not_inlined = 0x02, DW_INL_declared_not_inlined = 0x02,
DW_INL_declared_inlined = 0x03, DW_INL_declared_inlined = 0x03,
// Array ordering // Array ordering
DW_ORD_row_major = 0x00, DW_ORD_row_major = 0x00,
DW_ORD_col_major = 0x01, DW_ORD_col_major = 0x01,
@ -565,7 +565,7 @@ const char *DiscriminantString(unsigned Discriminant);
/// LNStandardString - Return the string for the specified line number standard. /// LNStandardString - Return the string for the specified line number standard.
/// ///
const char *LNStandardString(unsigned Standard); const char *LNStandardString(unsigned Standard);
/// LNExtendedString - Return the string for the specified line number extended /// LNExtendedString - Return the string for the specified line number extended
/// opcode encodings. /// opcode encodings.
const char *LNExtendedString(unsigned Encoding); const char *LNExtendedString(unsigned Encoding);

View File

@ -26,7 +26,7 @@ namespace llvm {
/// option, it will set the string to an error message if an error occurs, or /// option, it will set the string to an error message if an error occurs, or
/// if the files are different. /// if the files are different.
/// ///
int DiffFilesWithTolerance(const sys::PathWithStatus &FileA, int DiffFilesWithTolerance(const sys::PathWithStatus &FileA,
const sys::PathWithStatus &FileB, const sys::PathWithStatus &FileB,
double AbsTol, double RelTol, double AbsTol, double RelTol,
std::string *Error = 0); std::string *Error = 0);

View File

@ -39,7 +39,7 @@ protected:
public: public:
format_object_base(const char *fmt) : Fmt(fmt) {} format_object_base(const char *fmt) : Fmt(fmt) {}
virtual ~format_object_base() {} virtual ~format_object_base() {}
/// print - Format the object into the specified buffer. On success, this /// print - Format the object into the specified buffer. On success, this
/// returns the length of the formatted string. If the buffer is too small, /// returns the length of the formatted string. If the buffer is too small,
/// this returns a length to retry with, which will be larger than BufferSize. /// this returns a length to retry with, which will be larger than BufferSize.
@ -57,7 +57,7 @@ public:
format_object1(const char *fmt, const T &val) format_object1(const char *fmt, const T &val)
: format_object_base(fmt), Val(val) { : format_object_base(fmt), Val(val) {
} }
/// print - Format the object into the specified buffer. On success, this /// print - Format the object into the specified buffer. On success, this
/// returns the length of the formatted string. If the buffer is too small, /// returns the length of the formatted string. If the buffer is too small,
/// this returns a length to retry with, which will be larger than BufferSize. /// this returns a length to retry with, which will be larger than BufferSize.
@ -71,7 +71,7 @@ public:
return N; return N;
} }
}; };
/// format_object2 - This is a templated helper class used by the format /// format_object2 - This is a templated helper class used by the format
/// function that captures the object to be formated and the format string. When /// function that captures the object to be formated and the format string. When
/// actually printed, this synthesizes the string into a temporary buffer /// actually printed, this synthesizes the string into a temporary buffer
@ -84,7 +84,7 @@ public:
format_object2(const char *fmt, const T1 &val1, const T2 &val2) format_object2(const char *fmt, const T1 &val1, const T2 &val2)
: format_object_base(fmt), Val1(val1), Val2(val2) { : format_object_base(fmt), Val1(val1), Val2(val2) {
} }
/// print - Format the object into the specified buffer. On success, this /// print - Format the object into the specified buffer. On success, this
/// returns the length of the formatted string. If the buffer is too small, /// returns the length of the formatted string. If the buffer is too small,
/// this returns a length to retry with, which will be larger than BufferSize. /// this returns a length to retry with, which will be larger than BufferSize.
@ -112,7 +112,7 @@ public:
format_object3(const char *fmt, const T1 &val1, const T2 &val2,const T3 &val3) format_object3(const char *fmt, const T1 &val1, const T2 &val2,const T3 &val3)
: format_object_base(fmt), Val1(val1), Val2(val2), Val3(val3) { : format_object_base(fmt), Val1(val1), Val2(val2), Val3(val3) {
} }
/// print - Format the object into the specified buffer. On success, this /// print - Format the object into the specified buffer. On success, this
/// returns the length of the formatted string. If the buffer is too small, /// returns the length of the formatted string. If the buffer is too small,
/// this returns a length to retry with, which will be larger than BufferSize. /// this returns a length to retry with, which will be larger than BufferSize.
@ -149,7 +149,7 @@ template <typename T1, typename T2, typename T3>
const T2 &Val2, const T3 &Val3) { const T2 &Val2, const T3 &Val3) {
return format_object3<T1, T2, T3>(Fmt, Val1, Val2, Val3); return format_object3<T1, T2, T3>(Fmt, Val1, Val2, Val3);
} }
} // end namespace llvm } // end namespace llvm
#endif #endif

View File

@ -67,7 +67,7 @@ namespace DOT { // Private functions...
} }
void DisplayGraph(const sys::Path& Filename); void DisplayGraph(const sys::Path& Filename);
template<typename GraphType> template<typename GraphType>
class GraphWriter { class GraphWriter {
std::ostream &O; std::ostream &O;
@ -113,7 +113,7 @@ public:
I != E; ++I) I != E; ++I)
writeNode(*I); writeNode(*I);
} }
void writeNode(NodeType& Node) { void writeNode(NodeType& Node) {
writeNode(&Node); writeNode(&Node);
} }
@ -271,7 +271,7 @@ std::ostream &WriteGraph(std::ostream &O, const GraphType &G,
template<typename GraphType> template<typename GraphType>
sys::Path WriteGraph(const GraphType &G, sys::Path WriteGraph(const GraphType &G,
const std::string& Name, const std::string& Name,
const std::string& Title = "") { const std::string& Title = "") {
std::string ErrMsg; std::string ErrMsg;
sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg); sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
@ -286,7 +286,7 @@ sys::Path WriteGraph(const GraphType &G,
} }
cerr << "Writing '" << Filename << "'... "; cerr << "Writing '" << Filename << "'... ";
std::ofstream O(Filename.c_str()); std::ofstream O(Filename.c_str());
if (O.good()) { if (O.good()) {
@ -298,23 +298,23 @@ sys::Path WriteGraph(const GraphType &G,
cerr << "error opening file for writing!\n"; cerr << "error opening file for writing!\n";
Filename.clear(); Filename.clear();
} }
return Filename; return Filename;
} }
/// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file, /// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
/// then cleanup. For use from the debugger. /// then cleanup. For use from the debugger.
/// ///
template<typename GraphType> template<typename GraphType>
void ViewGraph(const GraphType& G, void ViewGraph(const GraphType& G,
const std::string& Name, const std::string& Name,
const std::string& Title = "") { const std::string& Title = "") {
sys::Path Filename = WriteGraph(G, Name, Title); sys::Path Filename = WriteGraph(G, Name, Title);
if (Filename.isEmpty()) { if (Filename.isEmpty()) {
return; return;
} }
DisplayGraph(Filename); DisplayGraph(Filename);
} }

View File

@ -635,16 +635,16 @@ public:
/// CreateIsNull - Return an i1 value testing if \arg Arg is null. /// CreateIsNull - Return an i1 value testing if \arg Arg is null.
Value *CreateIsNull(Value *Arg, const char *Name = "") { Value *CreateIsNull(Value *Arg, const char *Name = "") {
return CreateICmpEQ(Arg, llvm::Constant::getNullValue(Arg->getType()), return CreateICmpEQ(Arg, llvm::Constant::getNullValue(Arg->getType()),
Name); Name);
} }
/// CreateIsNotNull - Return an i1 value testing if \arg Arg is not null. /// CreateIsNotNull - Return an i1 value testing if \arg Arg is not null.
Value *CreateIsNotNull(Value *Arg, const char *Name = "") { Value *CreateIsNotNull(Value *Arg, const char *Name = "") {
return CreateICmpNE(Arg, llvm::Constant::getNullValue(Arg->getType()), return CreateICmpNE(Arg, llvm::Constant::getNullValue(Arg->getType()),
Name); Name);
} }
}; };
} }

View File

@ -31,15 +31,15 @@ namespace llvm {
/// @brief Base class for instruction visitors /// @brief Base class for instruction visitors
/// ///
/// Instruction visitors are used when you want to perform different action for /// Instruction visitors are used when you want to perform different action for
/// different kinds of instruction without without having to use lots of casts /// different kinds of instruction without without having to use lots of casts
/// and a big switch statement (in your code that is). /// and a big switch statement (in your code that is).
/// ///
/// To define your own visitor, inherit from this class, specifying your /// To define your own visitor, inherit from this class, specifying your
/// new type for the 'SubClass' template parameter, and "override" visitXXX /// new type for the 'SubClass' template parameter, and "override" visitXXX
/// functions in your class. I say "overriding" because this class is defined /// functions in your class. I say "overriding" because this class is defined
/// in terms of statically resolved overloading, not virtual functions. /// in terms of statically resolved overloading, not virtual functions.
/// ///
/// For example, here is a visitor that counts the number of malloc /// For example, here is a visitor that counts the number of malloc
/// instructions processed: /// instructions processed:
/// ///
/// /// Declare the class. Note that we derive from InstVisitor instantiated /// /// Declare the class. Note that we derive from InstVisitor instantiated
@ -65,8 +65,8 @@ namespace llvm {
/// if instructions are added in the future, they will be automatically /// if instructions are added in the future, they will be automatically
/// supported, if you handle on of their superclasses. /// supported, if you handle on of their superclasses.
/// ///
/// The optional second template argument specifies the type that instruction /// The optional second template argument specifies the type that instruction
/// visitation functions should return. If you specify this, you *MUST* provide /// visitation functions should return. If you specify this, you *MUST* provide
/// an implementation of visitInstruction though!. /// an implementation of visitInstruction though!.
/// ///
/// Note that this class is specifically designed as a template to avoid /// Note that this class is specifically designed as a template to avoid

View File

@ -31,12 +31,12 @@ protected:
mutable void *Ptr; mutable void *Ptr;
mutable void (*DeleterFn)(void*); mutable void (*DeleterFn)(void*);
mutable const ManagedStaticBase *Next; mutable const ManagedStaticBase *Next;
void RegisterManagedStatic(void *ObjPtr, void (*deleter)(void*)) const; void RegisterManagedStatic(void *ObjPtr, void (*deleter)(void*)) const;
public: public:
/// isConstructed - Return true if this object has not been created yet. /// isConstructed - Return true if this object has not been created yet.
bool isConstructed() const { return Ptr != 0; } bool isConstructed() const { return Ptr != 0; }
void destroy() const; void destroy() const;
}; };
@ -48,7 +48,7 @@ public:
template<class C> template<class C>
class ManagedStatic : public ManagedStaticBase { class ManagedStatic : public ManagedStaticBase {
public: public:
// Accessors. // Accessors.
C &operator*() { C &operator*() {
if (!Ptr) LazyInit(); if (!Ptr) LazyInit();
@ -66,7 +66,7 @@ public:
if (!Ptr) LazyInit(); if (!Ptr) LazyInit();
return static_cast<C*>(Ptr); return static_cast<C*>(Ptr);
} }
public: public:
void LazyInit() const { void LazyInit() const {
RegisterManagedStatic(new C(), object_deleter<C>); RegisterManagedStatic(new C(), object_deleter<C>);
@ -83,14 +83,14 @@ public:
/// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
void llvm_shutdown(); void llvm_shutdown();
/// llvm_shutdown_obj - This is a simple helper class that calls /// llvm_shutdown_obj - This is a simple helper class that calls
/// llvm_shutdown() when it is destroyed. /// llvm_shutdown() when it is destroyed.
struct llvm_shutdown_obj { struct llvm_shutdown_obj {
llvm_shutdown_obj() {} llvm_shutdown_obj() {}
~llvm_shutdown_obj() { llvm_shutdown(); } ~llvm_shutdown_obj() { llvm_shutdown(); }
}; };
} }
#endif #endif

View File

@ -28,17 +28,17 @@ class Mangler {
/// Prefix - This string is added to each symbol that is emitted, unless the /// Prefix - This string is added to each symbol that is emitted, unless the
/// symbol is marked as not needing this prefix. /// symbol is marked as not needing this prefix.
const char *Prefix; const char *Prefix;
const char *PrivatePrefix; const char *PrivatePrefix;
/// UseQuotes - If this is set, the target accepts global names in quotes, /// UseQuotes - If this is set, the target accepts global names in quotes,
/// e.g. "foo bar" is a legal name. This syntax is used instead of escaping /// e.g. "foo bar" is a legal name. This syntax is used instead of escaping
/// the space character. By default, this is false. /// the space character. By default, this is false.
bool UseQuotes; bool UseQuotes;
/// PreserveAsmNames - If this is set, the asm escape character is not removed /// PreserveAsmNames - If this is set, the asm escape character is not removed
/// from names with 'asm' specifiers. /// from names with 'asm' specifiers.
bool PreserveAsmNames; bool PreserveAsmNames;
/// Memo - This is used to remember the name that we assign a value. /// Memo - This is used to remember the name that we assign a value.
/// ///
DenseMap<const Value*, std::string> Memo; DenseMap<const Value*, std::string> Memo;
@ -46,7 +46,7 @@ class Mangler {
/// Count - This simple counter is used to unique value names. /// Count - This simple counter is used to unique value names.
/// ///
unsigned Count; unsigned Count;
/// TypeMap - If the client wants us to unique types, this keeps track of the /// TypeMap - If the client wants us to unique types, this keeps track of the
/// current assignments and TypeCounter keeps track of the next id to assign. /// current assignments and TypeCounter keeps track of the next id to assign.
DenseMap<const Type*, unsigned> TypeMap; DenseMap<const Type*, unsigned> TypeMap;
@ -64,11 +64,11 @@ public:
/// setUseQuotes - If UseQuotes is set to true, this target accepts quoted /// setUseQuotes - If UseQuotes is set to true, this target accepts quoted
/// strings for assembler labels. /// strings for assembler labels.
void setUseQuotes(bool Val) { UseQuotes = Val; } void setUseQuotes(bool Val) { UseQuotes = Val; }
/// setPreserveAsmNames - If the mangler should not strip off the asm name /// setPreserveAsmNames - If the mangler should not strip off the asm name
/// @verbatim identifier (\001), this should be set. @endverbatim /// @verbatim identifier (\001), this should be set. @endverbatim
void setPreserveAsmNames(bool Val) { PreserveAsmNames = Val; } void setPreserveAsmNames(bool Val) { PreserveAsmNames = Val; }
/// Acceptable Characters - This allows the target to specify which characters /// Acceptable Characters - This allows the target to specify which characters
/// are acceptable to the assembler without being mangled. By default we /// are acceptable to the assembler without being mangled. By default we
/// allow letters, numbers, '_', '$', and '.', which is what GAS accepts. /// allow letters, numbers, '_', '$', and '.', which is what GAS accepts.
@ -81,7 +81,7 @@ public:
bool isCharAcceptable(unsigned char X) const { bool isCharAcceptable(unsigned char X) const {
return (AcceptableChars[X/32] & (1 << (X&31))) != 0; return (AcceptableChars[X/32] & (1 << (X&31))) != 0;
} }
/// getValueName - Returns the mangled name of V, an LLVM Value, /// getValueName - Returns the mangled name of V, an LLVM Value,
/// in the current module. /// in the current module.
/// ///

View File

@ -18,7 +18,7 @@
namespace llvm { namespace llvm {
// NOTE: The following support functions use the _32/_64 extensions instead of // NOTE: The following support functions use the _32/_64 extensions instead of
// type overloading so that signed and unsigned integers can be used without // type overloading so that signed and unsigned integers can be used without
// ambiguity. // ambiguity.
@ -33,23 +33,23 @@ inline uint32_t Lo_32(uint64_t Value) {
} }
/// is?Type - these functions produce optimal testing for integer data types. /// is?Type - these functions produce optimal testing for integer data types.
inline bool isInt8 (int64_t Value) { inline bool isInt8 (int64_t Value) {
return static_cast<int8_t>(Value) == Value; return static_cast<int8_t>(Value) == Value;
} }
inline bool isUInt8 (int64_t Value) { inline bool isUInt8 (int64_t Value) {
return static_cast<uint8_t>(Value) == Value; return static_cast<uint8_t>(Value) == Value;
} }
inline bool isInt16 (int64_t Value) { inline bool isInt16 (int64_t Value) {
return static_cast<int16_t>(Value) == Value; return static_cast<int16_t>(Value) == Value;
} }
inline bool isUInt16(int64_t Value) { inline bool isUInt16(int64_t Value) {
return static_cast<uint16_t>(Value) == Value; return static_cast<uint16_t>(Value) == Value;
} }
inline bool isInt32 (int64_t Value) { inline bool isInt32 (int64_t Value) {
return static_cast<int32_t>(Value) == Value; return static_cast<int32_t>(Value) == Value;
} }
inline bool isUInt32(int64_t Value) { inline bool isUInt32(int64_t Value) {
return static_cast<uint32_t>(Value) == Value; return static_cast<uint32_t>(Value) == Value;
} }
/// isMask_32 - This function returns true if the argument is a sequence of ones /// isMask_32 - This function returns true if the argument is a sequence of ones
@ -66,20 +66,20 @@ inline bool isMask_64(uint64_t Value) {
return Value && ((Value + 1) & Value) == 0; return Value && ((Value + 1) & Value) == 0;
} }
/// isShiftedMask_32 - This function returns true if the argument contains a /// isShiftedMask_32 - This function returns true if the argument contains a
/// sequence of ones with the remainder zero (32 bit version.) /// sequence of ones with the remainder zero (32 bit version.)
/// Ex. isShiftedMask_32(0x0000FF00U) == true. /// Ex. isShiftedMask_32(0x0000FF00U) == true.
inline bool isShiftedMask_32(uint32_t Value) { inline bool isShiftedMask_32(uint32_t Value) {
return isMask_32((Value - 1) | Value); return isMask_32((Value - 1) | Value);
} }
/// isShiftedMask_64 - This function returns true if the argument contains a /// isShiftedMask_64 - This function returns true if the argument contains a
/// sequence of ones with the remainder zero (64 bit version.) /// sequence of ones with the remainder zero (64 bit version.)
inline bool isShiftedMask_64(uint64_t Value) { inline bool isShiftedMask_64(uint64_t Value) {
return isMask_64((Value - 1) | Value); return isMask_64((Value - 1) | Value);
} }
/// isPowerOf2_32 - This function returns true if the argument is a power of /// isPowerOf2_32 - This function returns true if the argument is a power of
/// two > 0. Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.) /// two > 0. Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.)
inline bool isPowerOf2_32(uint32_t Value) { inline bool isPowerOf2_32(uint32_t Value) {
return Value && !(Value & (Value - 1)); return Value && !(Value & (Value - 1));
@ -172,7 +172,7 @@ inline unsigned CountLeadingOnes_32(uint32_t Value) {
} }
/// CountLeadingZeros_64 - This function performs the platform optimal form /// CountLeadingZeros_64 - This function performs the platform optimal form
/// of counting the number of zeros from the most significant bit to the first /// of counting the number of zeros from the most significant bit to the first
/// one bit (64 bit edition.) /// one bit (64 bit edition.)
/// Returns 64 if the word is zero. /// Returns 64 if the word is zero.
inline unsigned CountLeadingZeros_64(uint64_t Value) { inline unsigned CountLeadingZeros_64(uint64_t Value) {
@ -216,7 +216,7 @@ inline unsigned CountLeadingZeros_64(uint64_t Value) {
} }
/// CountLeadingOnes_64 - This function performs the operation /// CountLeadingOnes_64 - This function performs the operation
/// of counting the number of ones from the most significant bit to the first /// of counting the number of ones from the most significant bit to the first
/// zero bit (64 bit edition.) /// zero bit (64 bit edition.)
/// Returns 64 if the word is all ones. /// Returns 64 if the word is all ones.
inline unsigned CountLeadingOnes_64(uint64_t Value) { inline unsigned CountLeadingOnes_64(uint64_t Value) {
@ -249,7 +249,7 @@ inline unsigned CountTrailingOnes_32(uint32_t Value) {
} }
/// CountTrailingZeros_64 - This function performs the platform optimal form /// CountTrailingZeros_64 - This function performs the platform optimal form
/// of counting the number of zeros from the least significant bit to the first /// of counting the number of zeros from the least significant bit to the first
/// one bit (64 bit edition.) /// one bit (64 bit edition.)
/// Returns 64 if the word is zero. /// Returns 64 if the word is zero.
inline unsigned CountTrailingZeros_64(uint64_t Value) { inline unsigned CountTrailingZeros_64(uint64_t Value) {
@ -268,7 +268,7 @@ inline unsigned CountTrailingZeros_64(uint64_t Value) {
} }
/// CountTrailingOnes_64 - This function performs the operation /// CountTrailingOnes_64 - This function performs the operation
/// of counting the number of ones from the least significant bit to the first /// of counting the number of ones from the least significant bit to the first
/// zero bit (64 bit edition.) /// zero bit (64 bit edition.)
/// Returns 64 if the word is all ones. /// Returns 64 if the word is all ones.
inline unsigned CountTrailingOnes_64(uint64_t Value) { inline unsigned CountTrailingOnes_64(uint64_t Value) {
@ -301,14 +301,14 @@ inline unsigned CountPopulation_64(uint64_t Value) {
#endif #endif
} }
/// Log2_32 - This function returns the floor log base 2 of the specified value, /// Log2_32 - This function returns the floor log base 2 of the specified value,
/// -1 if the value is zero. (32 bit edition.) /// -1 if the value is zero. (32 bit edition.)
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2 /// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
inline unsigned Log2_32(uint32_t Value) { inline unsigned Log2_32(uint32_t Value) {
return 31 - CountLeadingZeros_32(Value); return 31 - CountLeadingZeros_32(Value);
} }
/// Log2_64 - This function returns the floor log base 2 of the specified value, /// Log2_64 - This function returns the floor log base 2 of the specified value,
/// -1 if the value is zero. (64 bit edition.) /// -1 if the value is zero. (64 bit edition.)
inline unsigned Log2_64(uint64_t Value) { inline unsigned Log2_64(uint64_t Value) {
return 63 - CountLeadingZeros_64(Value); return 63 - CountLeadingZeros_64(Value);
@ -321,7 +321,7 @@ inline unsigned Log2_32_Ceil(uint32_t Value) {
return 32-CountLeadingZeros_32(Value-1); return 32-CountLeadingZeros_32(Value-1);
} }
/// Log2_64 - This function returns the ceil log base 2 of the specified value, /// Log2_64 - This function returns the ceil log base 2 of the specified value,
/// 64 if the value is zero. (64 bit edition.) /// 64 if the value is zero. (64 bit edition.)
inline unsigned Log2_64_Ceil(uint64_t Value) { inline unsigned Log2_64_Ceil(uint64_t Value) {
return 64-CountLeadingZeros_64(Value-1); return 64-CountLeadingZeros_64(Value-1);
@ -337,7 +337,7 @@ inline uint64_t GreatestCommonDivisor64(uint64_t A, uint64_t B) {
} }
return A; return A;
} }
/// BitsToDouble - This function takes a 64-bit integer and returns the bit /// BitsToDouble - This function takes a 64-bit integer and returns the bit
/// equivalent double. /// equivalent double.
inline double BitsToDouble(uint64_t Bits) { inline double BitsToDouble(uint64_t Bits) {
@ -424,7 +424,7 @@ static inline uint64_t NextPowerOf2(uint64_t A) {
inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) { inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) {
return ((Value + Align - 1) / Align) * Align; return ((Value + Align - 1) / Align) * Align;
} }
} // End llvm namespace } // End llvm namespace
#endif #endif

View File

@ -37,11 +37,11 @@ protected:
void initCopyOf(const char *BufStart, const char *BufEnd); void initCopyOf(const char *BufStart, const char *BufEnd);
public: public:
virtual ~MemoryBuffer(); virtual ~MemoryBuffer();
const char *getBufferStart() const { return BufferStart; } const char *getBufferStart() const { return BufferStart; }
const char *getBufferEnd() const { return BufferEnd; } const char *getBufferEnd() const { return BufferEnd; }
size_t getBufferSize() const { return BufferEnd-BufferStart; } size_t getBufferSize() const { return BufferEnd-BufferStart; }
/// getBufferIdentifier - Return an identifier for this buffer, typically the /// getBufferIdentifier - Return an identifier for this buffer, typically the
/// filename it was read from. /// filename it was read from.
virtual const char *getBufferIdentifier() const { virtual const char *getBufferIdentifier() const {
@ -60,32 +60,32 @@ public:
/// that EndPtr[0] must be a null byte and be accessible! /// that EndPtr[0] must be a null byte and be accessible!
static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr, static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr,
const char *BufferName = ""); const char *BufferName = "");
/// getMemBufferCopy - Open the specified memory range as a MemoryBuffer, /// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
/// copying the contents and taking ownership of it. This has no requirements /// copying the contents and taking ownership of it. This has no requirements
/// on EndPtr[0]. /// on EndPtr[0].
static MemoryBuffer *getMemBufferCopy(const char *StartPtr,const char *EndPtr, static MemoryBuffer *getMemBufferCopy(const char *StartPtr,const char *EndPtr,
const char *BufferName = ""); const char *BufferName = "");
/// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that /// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that
/// is completely initialized to zeros. Note that the caller should /// is completely initialized to zeros. Note that the caller should
/// initialize the memory allocated by this method. The memory is owned by /// initialize the memory allocated by this method. The memory is owned by
/// the MemoryBuffer object. /// the MemoryBuffer object.
static MemoryBuffer *getNewMemBuffer(size_t Size, static MemoryBuffer *getNewMemBuffer(size_t Size,
const char *BufferName = ""); const char *BufferName = "");
/// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size
/// that is not initialized. Note that the caller should initialize the /// that is not initialized. Note that the caller should initialize the
/// memory allocated by this method. The memory is owned by the MemoryBuffer /// memory allocated by this method. The memory is owned by the MemoryBuffer
/// object. /// object.
static MemoryBuffer *getNewUninitMemBuffer(size_t Size, static MemoryBuffer *getNewUninitMemBuffer(size_t Size,
const char *BufferName = ""); const char *BufferName = "");
/// getSTDIN - Read all of stdin into a file buffer, and return it. This /// getSTDIN - Read all of stdin into a file buffer, and return it. This
/// returns null if stdin is empty. /// returns null if stdin is empty.
static MemoryBuffer *getSTDIN(); static MemoryBuffer *getSTDIN();
/// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
/// if the Filename is "-". If an error occurs, this returns null and fills /// if the Filename is "-". If an error occurs, this returns null and fills
/// in *ErrStr with a reason. If stdin is empty, this API (unlike getSTDIN) /// in *ErrStr with a reason. If stdin is empty, this API (unlike getSTDIN)
@ -93,7 +93,7 @@ public:
static MemoryBuffer *getFileOrSTDIN(const char *Filename, static MemoryBuffer *getFileOrSTDIN(const char *Filename,
std::string *ErrStr = 0, std::string *ErrStr = 0,
int64_t FileSize = -1); int64_t FileSize = -1);
/// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin /// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
/// if the Filename is "-". If an error occurs, this returns null and fills /// if the Filename is "-". If an error occurs, this returns null and fills
/// in *ErrStr with a reason. /// in *ErrStr with a reason.

View File

@ -18,7 +18,7 @@
#include <vector> #include <vector>
namespace llvm { namespace llvm {
class OutputBuffer { class OutputBuffer {
/// Output buffer. /// Output buffer.
std::vector<unsigned char> &Output; std::vector<unsigned char> &Output;
@ -37,7 +37,7 @@ namespace llvm {
assert(Boundary && (Boundary & (Boundary - 1)) == 0 && assert(Boundary && (Boundary & (Boundary - 1)) == 0 &&
"Must align to 2^k boundary"); "Must align to 2^k boundary");
size_t Size = Output.size(); size_t Size = Output.size();
if (Size & (Boundary - 1)) { if (Size & (Boundary - 1)) {
// Add padding to get alignment to the correct place. // Add padding to get alignment to the correct place.
size_t Pad = Boundary - (Size & (Boundary - 1)); size_t Pad = Boundary - (Size & (Boundary - 1));
@ -111,10 +111,10 @@ namespace llvm {
? static_cast<unsigned>(S.length()) : Length; ? static_cast<unsigned>(S.length()) : Length;
unsigned len_to_fill = static_cast<unsigned>(S.length()) < Length unsigned len_to_fill = static_cast<unsigned>(S.length()) < Length
? Length - static_cast<unsigned>(S.length()) : 0; ? Length - static_cast<unsigned>(S.length()) : 0;
for (unsigned i = 0; i < len_to_copy; ++i) for (unsigned i = 0; i < len_to_copy; ++i)
outbyte(S[i]); outbyte(S[i]);
for (unsigned i = 0; i < len_to_fill; ++i) for (unsigned i = 0; i < len_to_fill; ++i)
outbyte(0); outbyte(0);
} }
@ -148,7 +148,7 @@ namespace llvm {
return Output[Index]; return Output[Index];
} }
}; };
} // end llvm namespace } // end llvm namespace
#endif // LLVM_SUPPORT_OUTPUTBUFFER_H #endif // LLVM_SUPPORT_OUTPUTBUFFER_H

View File

@ -108,27 +108,27 @@ inline bind_ty<Value> m_Value(Value *&V) { return V; }
/// m_ConstantInt - Match a ConstantInt, capturing the value if we match. /// m_ConstantInt - Match a ConstantInt, capturing the value if we match.
inline bind_ty<ConstantInt> m_ConstantInt(ConstantInt *&CI) { return CI; } inline bind_ty<ConstantInt> m_ConstantInt(ConstantInt *&CI) { return CI; }
/// specificval_ty - Match a specified Value*. /// specificval_ty - Match a specified Value*.
struct specificval_ty { struct specificval_ty {
const Value *Val; const Value *Val;
specificval_ty(const Value *V) : Val(V) {} specificval_ty(const Value *V) : Val(V) {}
template<typename ITy> template<typename ITy>
bool match(ITy *V) { bool match(ITy *V) {
return V == Val; return V == Val;
} }
}; };
/// m_Specific - Match if we have a specific specified value. /// m_Specific - Match if we have a specific specified value.
inline specificval_ty m_Specific(const Value *V) { return V; } inline specificval_ty m_Specific(const Value *V) { return V; }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Matchers for specific binary operators. // Matchers for specific binary operators.
// //
template<typename LHS_t, typename RHS_t, template<typename LHS_t, typename RHS_t,
unsigned Opcode, typename ConcreteTy = BinaryOperator> unsigned Opcode, typename ConcreteTy = BinaryOperator>
struct BinaryOp_match { struct BinaryOp_match {
LHS_t L; LHS_t L;
@ -223,19 +223,19 @@ inline BinaryOp_match<LHS, RHS, Instruction::Xor> m_Xor(const LHS &L,
} }
template<typename LHS, typename RHS> template<typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, Instruction::Shl> m_Shl(const LHS &L, inline BinaryOp_match<LHS, RHS, Instruction::Shl> m_Shl(const LHS &L,
const RHS &R) { const RHS &R) {
return BinaryOp_match<LHS, RHS, Instruction::Shl>(L, R); return BinaryOp_match<LHS, RHS, Instruction::Shl>(L, R);
} }
template<typename LHS, typename RHS> template<typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, Instruction::LShr> m_LShr(const LHS &L, inline BinaryOp_match<LHS, RHS, Instruction::LShr> m_LShr(const LHS &L,
const RHS &R) { const RHS &R) {
return BinaryOp_match<LHS, RHS, Instruction::LShr>(L, R); return BinaryOp_match<LHS, RHS, Instruction::LShr>(L, R);
} }
template<typename LHS, typename RHS> template<typename LHS, typename RHS>
inline BinaryOp_match<LHS, RHS, Instruction::AShr> m_AShr(const LHS &L, inline BinaryOp_match<LHS, RHS, Instruction::AShr> m_AShr(const LHS &L,
const RHS &R) { const RHS &R) {
return BinaryOp_match<LHS, RHS, Instruction::AShr>(L, R); return BinaryOp_match<LHS, RHS, Instruction::AShr>(L, R);
} }
@ -310,14 +310,14 @@ struct BinaryOpClass_match {
template<typename LHS, typename RHS> template<typename LHS, typename RHS>
inline BinaryOpClass_match<LHS, RHS, BinaryOperator, Instruction::BinaryOps> inline BinaryOpClass_match<LHS, RHS, BinaryOperator, Instruction::BinaryOps>
m_Shift(Instruction::BinaryOps &Op, const LHS &L, const RHS &R) { m_Shift(Instruction::BinaryOps &Op, const LHS &L, const RHS &R) {
return BinaryOpClass_match<LHS, RHS, return BinaryOpClass_match<LHS, RHS,
BinaryOperator, Instruction::BinaryOps>(Op, L, R); BinaryOperator, Instruction::BinaryOps>(Op, L, R);
} }
template<typename LHS, typename RHS> template<typename LHS, typename RHS>
inline BinaryOpClass_match<LHS, RHS, BinaryOperator, Instruction::BinaryOps> inline BinaryOpClass_match<LHS, RHS, BinaryOperator, Instruction::BinaryOps>
m_Shift(const LHS &L, const RHS &R) { m_Shift(const LHS &L, const RHS &R) {
return BinaryOpClass_match<LHS, RHS, return BinaryOpClass_match<LHS, RHS,
BinaryOperator, Instruction::BinaryOps>(L, R); BinaryOperator, Instruction::BinaryOps>(L, R);
} }
@ -395,7 +395,7 @@ m_Select(const Cond &C, const LHS &L, const RHS &R) {
template<int64_t L, int64_t R, typename Cond> template<int64_t L, int64_t R, typename Cond>
inline SelectClass_match<Cond, constantint_ty<L>, constantint_ty<R> > inline SelectClass_match<Cond, constantint_ty<L>, constantint_ty<R> >
m_SelectCst(const Cond &C) { m_SelectCst(const Cond &C) {
return SelectClass_match<Cond, constantint_ty<L>, return SelectClass_match<Cond, constantint_ty<L>,
constantint_ty<R> >(C, m_ConstantInt<L>(), constantint_ty<R> >(C, m_ConstantInt<L>(),
m_ConstantInt<R>()); m_ConstantInt<R>());
} }
@ -408,9 +408,9 @@ m_SelectCst(const Cond &C) {
template<typename Op_t, typename Class> template<typename Op_t, typename Class>
struct CastClass_match { struct CastClass_match {
Op_t Op; Op_t Op;
CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {} CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
template<typename OpTy> template<typename OpTy>
bool match(OpTy *V) { bool match(OpTy *V) {
if (Class *I = dyn_cast<Class>(V)) if (Class *I = dyn_cast<Class>(V))
@ -424,7 +424,7 @@ inline CastClass_match<OpTy, Class> m_Cast(const OpTy &Op) {
return CastClass_match<OpTy, Class>(Op); return CastClass_match<OpTy, Class>(Op);
} }
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Matchers for unary operators // Matchers for unary operators
// //
@ -468,9 +468,9 @@ inline not_match<LHS> m_Not(const LHS &L) { return L; }
template<typename LHS_t> template<typename LHS_t>
struct neg_match { struct neg_match {
LHS_t L; LHS_t L;
neg_match(const LHS_t &LHS) : L(LHS) {} neg_match(const LHS_t &LHS) : L(LHS) {}
template<typename OpTy> template<typename OpTy>
bool match(OpTy *V) { bool match(OpTy *V) {
if (Instruction *I = dyn_cast<Instruction>(V)) if (Instruction *I = dyn_cast<Instruction>(V))

View File

@ -31,7 +31,7 @@ namespace llvm {
/// Memory - This is the space that holds cached preds. /// Memory - This is the space that holds cached preds.
BumpPtrAllocator Memory; BumpPtrAllocator Memory;
public: public:
/// GetPreds - Get a cached list for the null-terminated predecessor list of /// GetPreds - Get a cached list for the null-terminated predecessor list of
/// the specified block. This can be used in a loop like this: /// the specified block. This can be used in a loop like this:
/// for (BasicBlock **PI = PredCache->GetPreds(BB); *PI; ++PI) /// for (BasicBlock **PI = PredCache->GetPreds(BB); *PI; ++PI)
@ -41,15 +41,15 @@ namespace llvm {
BasicBlock **GetPreds(BasicBlock *BB) { BasicBlock **GetPreds(BasicBlock *BB) {
BasicBlock **&Entry = BlockToPredsMap[BB]; BasicBlock **&Entry = BlockToPredsMap[BB];
if (Entry) return Entry; if (Entry) return Entry;
SmallVector<BasicBlock*, 32> PredCache(pred_begin(BB), pred_end(BB)); SmallVector<BasicBlock*, 32> PredCache(pred_begin(BB), pred_end(BB));
PredCache.push_back(0); // null terminator. PredCache.push_back(0); // null terminator.
Entry = Memory.Allocate<BasicBlock*>(PredCache.size()); Entry = Memory.Allocate<BasicBlock*>(PredCache.size());
std::copy(PredCache.begin(), PredCache.end(), Entry); std::copy(PredCache.begin(), PredCache.end(), Entry);
return Entry; return Entry;
} }
/// clear - Remove all information. /// clear - Remove all information.
void clear() { void clear() {
BlockToPredsMap.clear(); BlockToPredsMap.clear();

View File

@ -24,9 +24,9 @@ namespace llvm {
/// BaseStream - Acts like the STL streams. It's a wrapper for the std::cerr, /// BaseStream - Acts like the STL streams. It's a wrapper for the std::cerr,
/// std::cout, std::cin, etc. streams. However, it doesn't require #including /// std::cout, std::cin, etc. streams. However, it doesn't require #including
/// @verbatim <iostream> @endverbatm in every file (doing so increases static /// @verbatim <iostream> @endverbatm in every file (doing so increases static
/// c'tors & d'tors in the object code). /// c'tors & d'tors in the object code).
/// ///
template <typename StreamTy> template <typename StreamTy>
class BaseStream { class BaseStream {
StreamTy *Stream; StreamTy *Stream;
@ -69,7 +69,7 @@ namespace llvm {
if (Stream) Stream->write(A, N); if (Stream) Stream->write(A, N);
return *this; return *this;
} }
operator StreamTy* () { return Stream; } operator StreamTy* () { return Stream; }
bool operator == (const StreamTy &S) { return &S == Stream; } bool operator == (const StreamTy &S) { return &S == Stream; }

View File

@ -9,21 +9,21 @@
// //
// This file declares an interned string pool, which helps reduce the cost of // This file declares an interned string pool, which helps reduce the cost of
// strings by using the same storage for identical strings. // strings by using the same storage for identical strings.
// //
// To intern a string: // To intern a string:
// //
// StringPool Pool; // StringPool Pool;
// PooledStringPtr Str = Pool.intern("wakka wakka"); // PooledStringPtr Str = Pool.intern("wakka wakka");
// //
// To use the value of an interned string, use operator bool and operator*: // To use the value of an interned string, use operator bool and operator*:
// //
// if (Str) // if (Str)
// cerr << "the string is" << *Str << "\n"; // cerr << "the string is" << *Str << "\n";
// //
// Pooled strings are immutable, but you can change a PooledStringPtr to point // Pooled strings are immutable, but you can change a PooledStringPtr to point
// to another instance. So that interned strings can eventually be freed, // to another instance. So that interned strings can eventually be freed,
// strings in the string pool are reference-counted (automatically). // strings in the string pool are reference-counted (automatically).
// //
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_STRINGPOOL_H #ifndef LLVM_SUPPORT_STRINGPOOL_H
@ -46,36 +46,36 @@ namespace llvm {
struct PooledString { struct PooledString {
StringPool *Pool; ///< So the string can remove itself. StringPool *Pool; ///< So the string can remove itself.
unsigned Refcount; ///< Number of referencing PooledStringPtrs. unsigned Refcount; ///< Number of referencing PooledStringPtrs.
public: public:
PooledString() : Pool(0), Refcount(0) { } PooledString() : Pool(0), Refcount(0) { }
}; };
friend class PooledStringPtr; friend class PooledStringPtr;
typedef StringMap<PooledString> table_t; typedef StringMap<PooledString> table_t;
typedef StringMapEntry<PooledString> entry_t; typedef StringMapEntry<PooledString> entry_t;
table_t InternTable; table_t InternTable;
public: public:
StringPool(); StringPool();
~StringPool(); ~StringPool();
/// intern - Adds a string to the pool and returns a reference-counted /// intern - Adds a string to the pool and returns a reference-counted
/// pointer to it. No additional memory is allocated if the string already /// pointer to it. No additional memory is allocated if the string already
/// exists in the pool. /// exists in the pool.
PooledStringPtr intern(const char *Begin, const char *End); PooledStringPtr intern(const char *Begin, const char *End);
/// intern - Adds a null-terminated string to the pool and returns a /// intern - Adds a null-terminated string to the pool and returns a
/// reference-counted pointer to it. No additional memory is allocated if /// reference-counted pointer to it. No additional memory is allocated if
/// the string already exists in the pool. /// the string already exists in the pool.
inline PooledStringPtr intern(const char *Str); inline PooledStringPtr intern(const char *Str);
/// empty - Checks whether the pool is empty. Returns true if so. /// empty - Checks whether the pool is empty. Returns true if so.
/// ///
inline bool empty() const { return InternTable.empty(); } inline bool empty() const { return InternTable.empty(); }
}; };
/// PooledStringPtr - A pointer to an interned string. Use operator bool to /// PooledStringPtr - A pointer to an interned string. Use operator bool to
/// test whether the pointer is valid, and operator * to get the string if so. /// test whether the pointer is valid, and operator * to get the string if so.
/// This is a lightweight value class with storage requirements equivalent to /// This is a lightweight value class with storage requirements equivalent to
@ -84,18 +84,18 @@ namespace llvm {
class PooledStringPtr { class PooledStringPtr {
typedef StringPool::entry_t entry_t; typedef StringPool::entry_t entry_t;
entry_t *S; entry_t *S;
public: public:
PooledStringPtr() : S(0) {} PooledStringPtr() : S(0) {}
explicit PooledStringPtr(entry_t *E) : S(E) { explicit PooledStringPtr(entry_t *E) : S(E) {
if (S) ++S->getValue().Refcount; if (S) ++S->getValue().Refcount;
} }
PooledStringPtr(const PooledStringPtr &That) : S(That.S) { PooledStringPtr(const PooledStringPtr &That) : S(That.S) {
if (S) ++S->getValue().Refcount; if (S) ++S->getValue().Refcount;
} }
PooledStringPtr &operator=(const PooledStringPtr &That) { PooledStringPtr &operator=(const PooledStringPtr &That) {
if (S != That.S) { if (S != That.S) {
clear(); clear();
@ -104,7 +104,7 @@ namespace llvm {
} }
return *this; return *this;
} }
void clear() { void clear() {
if (!S) if (!S)
return; return;
@ -114,31 +114,31 @@ namespace llvm {
} }
S = 0; S = 0;
} }
~PooledStringPtr() { clear(); } ~PooledStringPtr() { clear(); }
inline const char *begin() const { inline const char *begin() const {
assert(*this && "Attempt to dereference empty PooledStringPtr!"); assert(*this && "Attempt to dereference empty PooledStringPtr!");
return S->getKeyData(); return S->getKeyData();
} }
inline const char *end() const { inline const char *end() const {
assert(*this && "Attempt to dereference empty PooledStringPtr!"); assert(*this && "Attempt to dereference empty PooledStringPtr!");
return S->getKeyData() + S->getKeyLength(); return S->getKeyData() + S->getKeyLength();
} }
inline unsigned size() const { inline unsigned size() const {
assert(*this && "Attempt to dereference empty PooledStringPtr!"); assert(*this && "Attempt to dereference empty PooledStringPtr!");
return S->getKeyLength(); return S->getKeyLength();
} }
inline const char *operator*() const { return begin(); } inline const char *operator*() const { return begin(); }
inline operator bool() const { return S != 0; } inline operator bool() const { return S != 0; }
inline bool operator==(const PooledStringPtr &That) { return S == That.S; } inline bool operator==(const PooledStringPtr &That) { return S == That.S; }
inline bool operator!=(const PooledStringPtr &That) { return S != That.S; } inline bool operator!=(const PooledStringPtr &That) { return S != That.S; }
}; };
PooledStringPtr StringPool::intern(const char *Str) { PooledStringPtr StringPool::intern(const char *Str) {
return intern(Str, Str + strlen(Str)); return intern(Str, Str + strlen(Str));
} }

View File

@ -24,7 +24,7 @@ namespace llvm {
class format_object_base; class format_object_base;
template <typename T> template <typename T>
class SmallVectorImpl; class SmallVectorImpl;
/// raw_ostream - This class implements an extremely fast bulk output stream /// raw_ostream - This class implements an extremely fast bulk output stream
/// that can *only* output to a stream. It does not support seeking, reopening, /// that can *only* output to a stream. It does not support seeking, reopening,
/// rewinding, line buffered disciplines etc. It is a simple buffer that outputs /// rewinding, line buffered disciplines etc. It is a simple buffer that outputs
@ -41,62 +41,62 @@ public:
virtual ~raw_ostream() { virtual ~raw_ostream() {
delete [] OutBufStart; delete [] OutBufStart;
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Configuration Interface // Configuration Interface
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
/// SetBufferSize - Set the internal buffer size to the specified amount /// SetBufferSize - Set the internal buffer size to the specified amount
/// instead of the default. /// instead of the default.
void SetBufferSize(unsigned Size) { void SetBufferSize(unsigned Size) {
assert(Size >= 64 && assert(Size >= 64 &&
"Buffer size must be somewhat large for invariants to hold"); "Buffer size must be somewhat large for invariants to hold");
flush(); flush();
delete [] OutBufStart; delete [] OutBufStart;
OutBufStart = new char[Size]; OutBufStart = new char[Size];
OutBufEnd = OutBufStart+Size; OutBufEnd = OutBufStart+Size;
OutBufCur = OutBufStart; OutBufCur = OutBufStart;
} }
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Data Output Interface // Data Output Interface
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
void flush() { void flush() {
if (OutBufCur != OutBufStart) if (OutBufCur != OutBufStart)
flush_impl(); flush_impl();
} }
raw_ostream &operator<<(char C) { raw_ostream &operator<<(char C) {
if (OutBufCur >= OutBufEnd) if (OutBufCur >= OutBufEnd)
flush_impl(); flush_impl();
*OutBufCur++ = C; *OutBufCur++ = C;
return *this; return *this;
} }
raw_ostream &operator<<(unsigned char C) { raw_ostream &operator<<(unsigned char C) {
if (OutBufCur >= OutBufEnd) if (OutBufCur >= OutBufEnd)
flush_impl(); flush_impl();
*OutBufCur++ = C; *OutBufCur++ = C;
return *this; return *this;
} }
raw_ostream &operator<<(signed char C) { raw_ostream &operator<<(signed char C) {
if (OutBufCur >= OutBufEnd) if (OutBufCur >= OutBufEnd)
flush_impl(); flush_impl();
*OutBufCur++ = C; *OutBufCur++ = C;
return *this; return *this;
} }
raw_ostream &operator<<(const char *Str) { raw_ostream &operator<<(const char *Str) {
return write(Str, strlen(Str)); return write(Str, strlen(Str));
} }
raw_ostream &operator<<(const std::string& Str) { raw_ostream &operator<<(const std::string& Str) {
return write(Str.data(), Str.length()); return write(Str.data(), Str.length());
} }
raw_ostream &operator<<(unsigned long N); raw_ostream &operator<<(unsigned long N);
raw_ostream &operator<<(long N); raw_ostream &operator<<(long N);
raw_ostream &operator<<(unsigned long long N); raw_ostream &operator<<(unsigned long long N);
@ -105,7 +105,7 @@ public:
raw_ostream &operator<<(unsigned int N) { raw_ostream &operator<<(unsigned int N) {
return this->operator<<(static_cast<unsigned long>(N)); return this->operator<<(static_cast<unsigned long>(N));
} }
raw_ostream &operator<<(int N) { raw_ostream &operator<<(int N) {
return this->operator<<(static_cast<long>(N)); return this->operator<<(static_cast<long>(N));
} }
@ -113,23 +113,23 @@ public:
raw_ostream &operator<<(double N) { raw_ostream &operator<<(double N) {
return this->operator<<(ftostr(N)); return this->operator<<(ftostr(N));
} }
raw_ostream &write(const char *Ptr, unsigned Size); raw_ostream &write(const char *Ptr, unsigned Size);
// Formatted output, see the format() function in Support/Format.h. // Formatted output, see the format() function in Support/Format.h.
raw_ostream &operator<<(const format_object_base &Fmt); raw_ostream &operator<<(const format_object_base &Fmt);
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
// Subclass Interface // Subclass Interface
//===--------------------------------------------------------------------===// //===--------------------------------------------------------------------===//
protected: protected:
/// flush_impl - The is the piece of the class that is implemented by /// flush_impl - The is the piece of the class that is implemented by
/// subclasses. This outputs the currently buffered data and resets the /// subclasses. This outputs the currently buffered data and resets the
/// buffer to empty. /// buffer to empty.
virtual void flush_impl() = 0; virtual void flush_impl() = 0;
/// HandleFlush - A stream's implementation of flush should call this after /// HandleFlush - A stream's implementation of flush should call this after
/// emitting the bytes to the data sink. /// emitting the bytes to the data sink.
void HandleFlush() { void HandleFlush() {
@ -141,11 +141,11 @@ private:
// An out of line virtual method to provide a home for the class vtable. // An out of line virtual method to provide a home for the class vtable.
virtual void handle(); virtual void handle();
}; };
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// File Output Streams // File Output Streams
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// raw_fd_ostream - A raw_ostream that writes to a file descriptor. /// raw_fd_ostream - A raw_ostream that writes to a file descriptor.
/// ///
class raw_fd_ostream : public raw_ostream { class raw_fd_ostream : public raw_ostream {
@ -163,31 +163,31 @@ public:
/// \param Binary - The file should be opened in binary mode on /// \param Binary - The file should be opened in binary mode on
/// platforms that support this distinction. /// platforms that support this distinction.
raw_fd_ostream(const char *Filename, bool Binary, std::string &ErrorInfo); raw_fd_ostream(const char *Filename, bool Binary, std::string &ErrorInfo);
/// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If
/// ShouldClose is true, this closes the file when /// ShouldClose is true, this closes the file when
raw_fd_ostream(int fd, bool shouldClose) : FD(fd), ShouldClose(shouldClose) {} raw_fd_ostream(int fd, bool shouldClose) : FD(fd), ShouldClose(shouldClose) {}
~raw_fd_ostream(); ~raw_fd_ostream();
/// flush_impl - The is the piece of the class that is implemented by /// flush_impl - The is the piece of the class that is implemented by
/// subclasses. This outputs the currently buffered data and resets the /// subclasses. This outputs the currently buffered data and resets the
/// buffer to empty. /// buffer to empty.
virtual void flush_impl(); virtual void flush_impl();
/// close - Manually flush the stream and close the file. /// close - Manually flush the stream and close the file.
void close(); void close();
/// tell - Return the current offset with the file. /// tell - Return the current offset with the file.
uint64_t tell() { uint64_t tell() {
return pos + (OutBufCur - OutBufStart); return pos + (OutBufCur - OutBufStart);
} }
/// seek - Flushes the stream and repositions the underlying file descriptor /// seek - Flushes the stream and repositions the underlying file descriptor
/// positition to the offset specified from the beginning of the file. /// positition to the offset specified from the beginning of the file.
uint64_t seek(uint64_t off); uint64_t seek(uint64_t off);
}; };
/// raw_stdout_ostream - This is a stream that always prints to stdout. /// raw_stdout_ostream - This is a stream that always prints to stdout.
/// ///
class raw_stdout_ostream : public raw_fd_ostream { class raw_stdout_ostream : public raw_fd_ostream {
@ -205,7 +205,7 @@ class raw_stderr_ostream : public raw_fd_ostream {
public: public:
raw_stderr_ostream(); raw_stderr_ostream();
}; };
/// outs() - This returns a reference to a raw_ostream for standard output. /// outs() - This returns a reference to a raw_ostream for standard output.
/// Use it like: outs() << "foo" << "bar"; /// Use it like: outs() << "foo" << "bar";
raw_ostream &outs(); raw_ostream &outs();
@ -213,12 +213,12 @@ raw_ostream &outs();
/// errs() - This returns a reference to a raw_ostream for standard error. /// errs() - This returns a reference to a raw_ostream for standard error.
/// Use it like: errs() << "foo" << "bar"; /// Use it like: errs() << "foo" << "bar";
raw_ostream &errs(); raw_ostream &errs();
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Output Stream Adaptors // Output Stream Adaptors
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/// raw_os_ostream - A raw_ostream that writes to an std::ostream. This is a /// raw_os_ostream - A raw_ostream that writes to an std::ostream. This is a
/// simple adaptor class. /// simple adaptor class.
class raw_os_ostream : public raw_ostream { class raw_os_ostream : public raw_ostream {
@ -240,20 +240,20 @@ class raw_string_ostream : public raw_ostream {
public: public:
raw_string_ostream(std::string &O) : OS(O) {} raw_string_ostream(std::string &O) : OS(O) {}
~raw_string_ostream(); ~raw_string_ostream();
/// str - Flushes the stream contents to the target string and returns /// str - Flushes the stream contents to the target string and returns
/// the string's reference. /// the string's reference.
std::string& str() { std::string& str() {
flush(); flush();
return OS; return OS;
} }
/// flush_impl - The is the piece of the class that is implemented by /// flush_impl - The is the piece of the class that is implemented by
/// subclasses. This outputs the currently buffered data and resets the /// subclasses. This outputs the currently buffered data and resets the
/// buffer to empty. /// buffer to empty.
virtual void flush_impl(); virtual void flush_impl();
}; };
/// raw_svector_ostream - A raw_ostream that writes to an SmallVector or /// raw_svector_ostream - A raw_ostream that writes to an SmallVector or
/// SmallString. This is a simple adaptor class. /// SmallString. This is a simple adaptor class.
class raw_svector_ostream : public raw_ostream { class raw_svector_ostream : public raw_ostream {
@ -261,13 +261,13 @@ class raw_svector_ostream : public raw_ostream {
public: public:
raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {} raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {}
~raw_svector_ostream(); ~raw_svector_ostream();
/// flush_impl - The is the piece of the class that is implemented by /// flush_impl - The is the piece of the class that is implemented by
/// subclasses. This outputs the currently buffered data and resets the /// subclasses. This outputs the currently buffered data and resets the
/// buffer to empty. /// buffer to empty.
virtual void flush_impl(); virtual void flush_impl();
}; };
} // end llvm namespace } // end llvm namespace
#endif #endif