mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Removed trailing whitespace.
llvm-svn: 65196
This commit is contained in:
parent
13dd5f564d
commit
7ee4196e74
@ -16,7 +16,7 @@
|
||||
#define LLVM_SUPPORT_ALIGNOF_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
||||
template <typename T>
|
||||
struct AlignmentCalcImpl {
|
||||
char x;
|
||||
@ -24,7 +24,7 @@ struct AlignmentCalcImpl {
|
||||
private:
|
||||
AlignmentCalcImpl() {} // Never instantiate.
|
||||
};
|
||||
|
||||
|
||||
/// AlignOf - A templated class that contains an enum value representing
|
||||
/// the alignment of the template argument. For example,
|
||||
/// 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_8Bytes = Alignment >= 8 ? 1 : 0 };
|
||||
enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 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_16Bytes = Alignment <= 16 ? 1 : 0 };
|
||||
|
||||
@ -55,6 +55,6 @@ struct AlignOf {
|
||||
/// alignof<int>() returns the alignment of an int.
|
||||
template <typename T>
|
||||
static inline unsigned alignof() { return AlignOf<T>::Alignment; }
|
||||
|
||||
|
||||
} // end namespace llvm
|
||||
#endif
|
||||
|
@ -18,24 +18,24 @@
|
||||
#include <cstdlib>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
||||
class MallocAllocator {
|
||||
public:
|
||||
MallocAllocator() {}
|
||||
~MallocAllocator() {}
|
||||
|
||||
|
||||
void Reset() {}
|
||||
|
||||
void *Allocate(size_t Size, size_t /*Alignment*/) { return malloc(Size); }
|
||||
|
||||
|
||||
template <typename T>
|
||||
T *Allocate() { return static_cast<T*>(malloc(sizeof(T))); }
|
||||
|
||||
|
||||
template <typename T>
|
||||
T *Allocate(size_t Num) {
|
||||
T *Allocate(size_t Num) {
|
||||
return static_cast<T*>(malloc(sizeof(T)*Num));
|
||||
}
|
||||
|
||||
|
||||
void Deallocate(const void *Ptr) { free(const_cast<void*>(Ptr)); }
|
||||
|
||||
void PrintStats() const {}
|
||||
@ -53,7 +53,7 @@ class BumpPtrAllocator {
|
||||
public:
|
||||
BumpPtrAllocator();
|
||||
~BumpPtrAllocator();
|
||||
|
||||
|
||||
void Reset();
|
||||
|
||||
void *Allocate(size_t Size, size_t Alignment);
|
||||
@ -61,21 +61,21 @@ public:
|
||||
/// Allocate space, but do not construct, one object.
|
||||
///
|
||||
template <typename T>
|
||||
T *Allocate() {
|
||||
T *Allocate() {
|
||||
return static_cast<T*>(Allocate(sizeof(T),AlignOf<T>::Alignment));
|
||||
}
|
||||
|
||||
|
||||
/// Allocate space for an array of objects. This does not construct the
|
||||
/// objects though.
|
||||
template <typename T>
|
||||
T *Allocate(size_t Num) {
|
||||
T *Allocate(size_t Num) {
|
||||
return static_cast<T*>(Allocate(Num * sizeof(T), AlignOf<T>::Alignment));
|
||||
}
|
||||
|
||||
|
||||
/// Allocate space for a specific count of elements and with a specified
|
||||
/// alignment.
|
||||
template <typename T>
|
||||
T *Allocate(size_t Num, unsigned Alignment) {
|
||||
T *Allocate(size_t Num, unsigned Alignment) {
|
||||
// Round EltSize up to the specified alignment.
|
||||
unsigned EltSize = (sizeof(T)+Alignment-1)&~Alignment;
|
||||
return static_cast<T*>(Allocate(Num * EltSize, Alignment));
|
||||
|
@ -59,7 +59,7 @@ class ConstantRange {
|
||||
|
||||
/// 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
|
||||
///
|
||||
|
@ -54,7 +54,7 @@ struct DefaultDOTGraphTraits {
|
||||
static std::string getNodeLabel(const void *Node, const GraphType& Graph) {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
/// hasNodeAddressLabel - If this method returns true, the address of the node
|
||||
/// is added to the label of the node.
|
||||
template<typename GraphType>
|
||||
|
@ -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.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
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
|
||||
|
||||
template <> struct GraphTraits<const User*> {
|
||||
|
@ -64,7 +64,7 @@ bool isCurrentDebugType(const char *Type);
|
||||
/// getErrorOutputStream - Returns the error output stream (std::cerr). This
|
||||
/// 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.
|
||||
///
|
||||
///
|
||||
OStream &getErrorOutputStream(const char *DebugType);
|
||||
|
||||
#ifdef NDEBUG
|
||||
|
@ -10,7 +10,7 @@
|
||||
// This file contains constants used for implementing Dwarf debug support. For
|
||||
// Details on the Dwarf 3 specfication see DWARF Debugging Information Format
|
||||
// V.3 reference manual http://dwarf.freestandards.org ,
|
||||
//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_DWARF_H
|
||||
@ -42,23 +42,23 @@ namespace dwarf {
|
||||
enum llvm_dwarf_constants {
|
||||
// llvm mock tags
|
||||
DW_TAG_invalid = ~0U, // Tag for invalid results.
|
||||
|
||||
|
||||
DW_TAG_anchor = 0, // Tag for descriptor anchors.
|
||||
DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables.
|
||||
DW_TAG_arg_variable = 0x101, // Tag for argument variables.
|
||||
DW_TAG_return_variable = 0x102, // Tag for return variables.
|
||||
|
||||
|
||||
DW_TAG_vector_type = 0x103, // Tag for vector types.
|
||||
|
||||
|
||||
DW_TAG_user_base = 0x1000, // Recommended base for user tags.
|
||||
|
||||
|
||||
DW_CIE_VERSION = 1, // Common frame information version.
|
||||
DW_CIE_ID = 0xffffffff // Common frame information mark.
|
||||
};
|
||||
|
||||
enum dwarf_constants {
|
||||
DWARF_VERSION = 2,
|
||||
|
||||
|
||||
// Tags
|
||||
DW_TAG_array_type = 0x01,
|
||||
DW_TAG_class_type = 0x02,
|
||||
@ -357,7 +357,7 @@ enum dwarf_constants {
|
||||
DW_ACCESS_protected = 0x02,
|
||||
DW_ACCESS_private = 0x03,
|
||||
|
||||
// Visibility codes
|
||||
// Visibility codes
|
||||
DW_VIS_local = 0x01,
|
||||
DW_VIS_exported = 0x02,
|
||||
DW_VIS_qualified = 0x03,
|
||||
@ -366,7 +366,7 @@ enum dwarf_constants {
|
||||
DW_VIRTUALITY_none = 0x00,
|
||||
DW_VIRTUALITY_virtual = 0x01,
|
||||
DW_VIRTUALITY_pure_virtual = 0x02,
|
||||
|
||||
|
||||
// Language names
|
||||
DW_LANG_C89 = 0x0001,
|
||||
DW_LANG_C = 0x0002,
|
||||
@ -389,7 +389,7 @@ enum dwarf_constants {
|
||||
DW_LANG_D = 0x0013,
|
||||
DW_LANG_lo_user = 0x8000,
|
||||
DW_LANG_hi_user = 0xffff,
|
||||
|
||||
|
||||
// Identifier case codes
|
||||
DW_ID_case_sensitive = 0x00,
|
||||
DW_ID_up_case = 0x01,
|
||||
@ -409,7 +409,7 @@ enum dwarf_constants {
|
||||
DW_INL_declared_not_inlined = 0x02,
|
||||
DW_INL_declared_inlined = 0x03,
|
||||
|
||||
// Array ordering
|
||||
// Array ordering
|
||||
DW_ORD_row_major = 0x00,
|
||||
DW_ORD_col_major = 0x01,
|
||||
|
||||
@ -565,7 +565,7 @@ const char *DiscriminantString(unsigned Discriminant);
|
||||
/// LNStandardString - Return the string for the specified line number standard.
|
||||
///
|
||||
const char *LNStandardString(unsigned Standard);
|
||||
|
||||
|
||||
/// LNExtendedString - Return the string for the specified line number extended
|
||||
/// opcode encodings.
|
||||
const char *LNExtendedString(unsigned Encoding);
|
||||
|
@ -26,7 +26,7 @@ namespace llvm {
|
||||
/// option, it will set the string to an error message if an error occurs, or
|
||||
/// if the files are different.
|
||||
///
|
||||
int DiffFilesWithTolerance(const sys::PathWithStatus &FileA,
|
||||
int DiffFilesWithTolerance(const sys::PathWithStatus &FileA,
|
||||
const sys::PathWithStatus &FileB,
|
||||
double AbsTol, double RelTol,
|
||||
std::string *Error = 0);
|
||||
|
@ -39,7 +39,7 @@ protected:
|
||||
public:
|
||||
format_object_base(const char *fmt) : Fmt(fmt) {}
|
||||
virtual ~format_object_base() {}
|
||||
|
||||
|
||||
/// print - Format the object into the specified buffer. On success, this
|
||||
/// 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.
|
||||
@ -57,7 +57,7 @@ public:
|
||||
format_object1(const char *fmt, const T &val)
|
||||
: format_object_base(fmt), Val(val) {
|
||||
}
|
||||
|
||||
|
||||
/// print - Format the object into the specified buffer. On success, this
|
||||
/// 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.
|
||||
@ -71,7 +71,7 @@ public:
|
||||
return N;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// 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
|
||||
/// 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_object_base(fmt), Val1(val1), Val2(val2) {
|
||||
}
|
||||
|
||||
|
||||
/// print - Format the object into the specified buffer. On success, this
|
||||
/// 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.
|
||||
@ -112,7 +112,7 @@ public:
|
||||
format_object3(const char *fmt, const T1 &val1, const T2 &val2,const T3 &val3)
|
||||
: format_object_base(fmt), Val1(val1), Val2(val2), Val3(val3) {
|
||||
}
|
||||
|
||||
|
||||
/// print - Format the object into the specified buffer. On success, this
|
||||
/// 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.
|
||||
@ -149,7 +149,7 @@ template <typename T1, typename T2, typename T3>
|
||||
const T2 &Val2, const T3 &Val3) {
|
||||
return format_object3<T1, T2, T3>(Fmt, Val1, Val2, Val3);
|
||||
}
|
||||
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
|
@ -67,7 +67,7 @@ namespace DOT { // Private functions...
|
||||
}
|
||||
|
||||
void DisplayGraph(const sys::Path& Filename);
|
||||
|
||||
|
||||
template<typename GraphType>
|
||||
class GraphWriter {
|
||||
std::ostream &O;
|
||||
@ -113,7 +113,7 @@ public:
|
||||
I != E; ++I)
|
||||
writeNode(*I);
|
||||
}
|
||||
|
||||
|
||||
void writeNode(NodeType& Node) {
|
||||
writeNode(&Node);
|
||||
}
|
||||
@ -271,7 +271,7 @@ std::ostream &WriteGraph(std::ostream &O, const GraphType &G,
|
||||
|
||||
template<typename GraphType>
|
||||
sys::Path WriteGraph(const GraphType &G,
|
||||
const std::string& Name,
|
||||
const std::string& Name,
|
||||
const std::string& Title = "") {
|
||||
std::string ErrMsg;
|
||||
sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg);
|
||||
@ -286,7 +286,7 @@ sys::Path WriteGraph(const GraphType &G,
|
||||
}
|
||||
|
||||
cerr << "Writing '" << Filename << "'... ";
|
||||
|
||||
|
||||
std::ofstream O(Filename.c_str());
|
||||
|
||||
if (O.good()) {
|
||||
@ -298,23 +298,23 @@ sys::Path WriteGraph(const GraphType &G,
|
||||
cerr << "error opening file for writing!\n";
|
||||
Filename.clear();
|
||||
}
|
||||
|
||||
|
||||
return Filename;
|
||||
}
|
||||
|
||||
|
||||
/// ViewGraph - Emit a dot graph, run 'dot', run gv on the postscript file,
|
||||
/// then cleanup. For use from the debugger.
|
||||
///
|
||||
template<typename GraphType>
|
||||
void ViewGraph(const GraphType& G,
|
||||
const std::string& Name,
|
||||
void ViewGraph(const GraphType& G,
|
||||
const std::string& Name,
|
||||
const std::string& Title = "") {
|
||||
sys::Path Filename = WriteGraph(G, Name, Title);
|
||||
|
||||
if (Filename.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
DisplayGraph(Filename);
|
||||
}
|
||||
|
||||
|
@ -635,16 +635,16 @@ public:
|
||||
|
||||
/// CreateIsNull - Return an i1 value testing if \arg Arg is null.
|
||||
Value *CreateIsNull(Value *Arg, const char *Name = "") {
|
||||
return CreateICmpEQ(Arg, llvm::Constant::getNullValue(Arg->getType()),
|
||||
return CreateICmpEQ(Arg, llvm::Constant::getNullValue(Arg->getType()),
|
||||
Name);
|
||||
}
|
||||
|
||||
/// CreateIsNotNull - Return an i1 value testing if \arg Arg is not null.
|
||||
Value *CreateIsNotNull(Value *Arg, const char *Name = "") {
|
||||
return CreateICmpNE(Arg, llvm::Constant::getNullValue(Arg->getType()),
|
||||
return CreateICmpNE(Arg, llvm::Constant::getNullValue(Arg->getType()),
|
||||
Name);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -31,15 +31,15 @@ namespace llvm {
|
||||
/// @brief Base class for instruction visitors
|
||||
///
|
||||
/// Instruction visitors are used when you want to perform different action for
|
||||
/// different kinds of instruction without without having to use lots of casts
|
||||
/// and a big switch statement (in your code that is).
|
||||
/// different kinds of instruction without without having to use lots of casts
|
||||
/// and a big switch statement (in your code that is).
|
||||
///
|
||||
/// To define your own visitor, inherit from this class, specifying your
|
||||
/// new type for the 'SubClass' template parameter, and "override" visitXXX
|
||||
/// functions in your class. I say "overriding" because this class is defined
|
||||
/// in terms of statically resolved overloading, not virtual functions.
|
||||
///
|
||||
/// For example, here is a visitor that counts the number of malloc
|
||||
/// functions in your class. I say "overriding" because this class is defined
|
||||
/// in terms of statically resolved overloading, not virtual functions.
|
||||
///
|
||||
/// For example, here is a visitor that counts the number of malloc
|
||||
/// instructions processed:
|
||||
///
|
||||
/// /// 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
|
||||
/// supported, if you handle on of their superclasses.
|
||||
///
|
||||
/// The optional second template argument specifies the type that instruction
|
||||
/// visitation functions should return. If you specify this, you *MUST* provide
|
||||
/// The optional second template argument specifies the type that instruction
|
||||
/// visitation functions should return. If you specify this, you *MUST* provide
|
||||
/// an implementation of visitInstruction though!.
|
||||
///
|
||||
/// Note that this class is specifically designed as a template to avoid
|
||||
|
@ -31,12 +31,12 @@ protected:
|
||||
mutable void *Ptr;
|
||||
mutable void (*DeleterFn)(void*);
|
||||
mutable const ManagedStaticBase *Next;
|
||||
|
||||
|
||||
void RegisterManagedStatic(void *ObjPtr, void (*deleter)(void*)) const;
|
||||
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; }
|
||||
|
||||
|
||||
void destroy() const;
|
||||
};
|
||||
|
||||
@ -48,7 +48,7 @@ public:
|
||||
template<class C>
|
||||
class ManagedStatic : public ManagedStaticBase {
|
||||
public:
|
||||
|
||||
|
||||
// Accessors.
|
||||
C &operator*() {
|
||||
if (!Ptr) LazyInit();
|
||||
@ -66,7 +66,7 @@ public:
|
||||
if (!Ptr) LazyInit();
|
||||
return static_cast<C*>(Ptr);
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
void LazyInit() const {
|
||||
RegisterManagedStatic(new C(), object_deleter<C>);
|
||||
@ -83,14 +83,14 @@ public:
|
||||
/// llvm_shutdown - Deallocate and destroy all ManagedStatic variables.
|
||||
void llvm_shutdown();
|
||||
|
||||
|
||||
|
||||
/// llvm_shutdown_obj - This is a simple helper class that calls
|
||||
/// llvm_shutdown() when it is destroyed.
|
||||
struct llvm_shutdown_obj {
|
||||
llvm_shutdown_obj() {}
|
||||
~llvm_shutdown_obj() { llvm_shutdown(); }
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -28,17 +28,17 @@ class Mangler {
|
||||
/// Prefix - This string is added to each symbol that is emitted, unless the
|
||||
/// symbol is marked as not needing this prefix.
|
||||
const char *Prefix;
|
||||
|
||||
|
||||
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
|
||||
/// the space character. By default, this is false.
|
||||
bool UseQuotes;
|
||||
|
||||
|
||||
/// PreserveAsmNames - If this is set, the asm escape character is not removed
|
||||
/// from names with 'asm' specifiers.
|
||||
/// from names with 'asm' specifiers.
|
||||
bool PreserveAsmNames;
|
||||
|
||||
|
||||
/// Memo - This is used to remember the name that we assign a value.
|
||||
///
|
||||
DenseMap<const Value*, std::string> Memo;
|
||||
@ -46,7 +46,7 @@ class Mangler {
|
||||
/// Count - This simple counter is used to unique value names.
|
||||
///
|
||||
unsigned Count;
|
||||
|
||||
|
||||
/// 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.
|
||||
DenseMap<const Type*, unsigned> TypeMap;
|
||||
@ -64,11 +64,11 @@ public:
|
||||
/// setUseQuotes - If UseQuotes is set to true, this target accepts quoted
|
||||
/// strings for assembler labels.
|
||||
void setUseQuotes(bool Val) { UseQuotes = Val; }
|
||||
|
||||
|
||||
/// setPreserveAsmNames - If the mangler should not strip off the asm name
|
||||
/// @verbatim identifier (\001), this should be set. @endverbatim
|
||||
void setPreserveAsmNames(bool Val) { PreserveAsmNames = Val; }
|
||||
|
||||
|
||||
/// Acceptable Characters - This allows the target to specify which characters
|
||||
/// are acceptable to the assembler without being mangled. By default we
|
||||
/// allow letters, numbers, '_', '$', and '.', which is what GAS accepts.
|
||||
@ -81,7 +81,7 @@ public:
|
||||
bool isCharAcceptable(unsigned char X) const {
|
||||
return (AcceptableChars[X/32] & (1 << (X&31))) != 0;
|
||||
}
|
||||
|
||||
|
||||
/// getValueName - Returns the mangled name of V, an LLVM Value,
|
||||
/// in the current module.
|
||||
///
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
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
|
||||
// ambiguity.
|
||||
|
||||
@ -33,23 +33,23 @@ inline uint32_t Lo_32(uint64_t Value) {
|
||||
}
|
||||
|
||||
/// is?Type - these functions produce optimal testing for integer data types.
|
||||
inline bool isInt8 (int64_t Value) {
|
||||
return static_cast<int8_t>(Value) == Value;
|
||||
inline bool isInt8 (int64_t Value) {
|
||||
return static_cast<int8_t>(Value) == Value;
|
||||
}
|
||||
inline bool isUInt8 (int64_t Value) {
|
||||
return static_cast<uint8_t>(Value) == Value;
|
||||
inline bool isUInt8 (int64_t Value) {
|
||||
return static_cast<uint8_t>(Value) == Value;
|
||||
}
|
||||
inline bool isInt16 (int64_t Value) {
|
||||
return static_cast<int16_t>(Value) == Value;
|
||||
inline bool isInt16 (int64_t Value) {
|
||||
return static_cast<int16_t>(Value) == Value;
|
||||
}
|
||||
inline bool isUInt16(int64_t Value) {
|
||||
return static_cast<uint16_t>(Value) == Value;
|
||||
inline bool isUInt16(int64_t Value) {
|
||||
return static_cast<uint16_t>(Value) == Value;
|
||||
}
|
||||
inline bool isInt32 (int64_t Value) {
|
||||
return static_cast<int32_t>(Value) == Value;
|
||||
inline bool isInt32 (int64_t Value) {
|
||||
return static_cast<int32_t>(Value) == Value;
|
||||
}
|
||||
inline bool isUInt32(int64_t Value) {
|
||||
return static_cast<uint32_t>(Value) == Value;
|
||||
inline bool isUInt32(int64_t Value) {
|
||||
return static_cast<uint32_t>(Value) == Value;
|
||||
}
|
||||
|
||||
/// 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;
|
||||
}
|
||||
|
||||
/// 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.)
|
||||
/// Ex. isShiftedMask_32(0x0000FF00U) == true.
|
||||
inline bool isShiftedMask_32(uint32_t 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.)
|
||||
inline bool isShiftedMask_64(uint64_t 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.)
|
||||
inline bool isPowerOf2_32(uint32_t Value) {
|
||||
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
|
||||
/// 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.)
|
||||
/// Returns 64 if the word is zero.
|
||||
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
|
||||
/// 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.)
|
||||
/// Returns 64 if the word is all ones.
|
||||
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
|
||||
/// 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.)
|
||||
/// Returns 64 if the word is zero.
|
||||
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
|
||||
/// 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.)
|
||||
/// Returns 64 if the word is all ones.
|
||||
inline unsigned CountTrailingOnes_64(uint64_t Value) {
|
||||
@ -301,14 +301,14 @@ inline unsigned CountPopulation_64(uint64_t Value) {
|
||||
#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.)
|
||||
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
|
||||
inline unsigned Log2_32(uint32_t 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.)
|
||||
inline unsigned Log2_64(uint64_t Value) {
|
||||
return 63 - CountLeadingZeros_64(Value);
|
||||
@ -321,7 +321,7 @@ inline unsigned Log2_32_Ceil(uint32_t Value) {
|
||||
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.)
|
||||
inline unsigned Log2_64_Ceil(uint64_t Value) {
|
||||
return 64-CountLeadingZeros_64(Value-1);
|
||||
@ -337,7 +337,7 @@ inline uint64_t GreatestCommonDivisor64(uint64_t A, uint64_t B) {
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
/// BitsToDouble - This function takes a 64-bit integer and returns the bit
|
||||
/// equivalent double.
|
||||
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) {
|
||||
return ((Value + Align - 1) / Align) * Align;
|
||||
}
|
||||
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
@ -37,11 +37,11 @@ protected:
|
||||
void initCopyOf(const char *BufStart, const char *BufEnd);
|
||||
public:
|
||||
virtual ~MemoryBuffer();
|
||||
|
||||
|
||||
const char *getBufferStart() const { return BufferStart; }
|
||||
const char *getBufferEnd() const { return BufferEnd; }
|
||||
size_t getBufferSize() const { return BufferEnd-BufferStart; }
|
||||
|
||||
|
||||
/// getBufferIdentifier - Return an identifier for this buffer, typically the
|
||||
/// filename it was read from.
|
||||
virtual const char *getBufferIdentifier() const {
|
||||
@ -60,32 +60,32 @@ public:
|
||||
/// that EndPtr[0] must be a null byte and be accessible!
|
||||
static MemoryBuffer *getMemBuffer(const char *StartPtr, const char *EndPtr,
|
||||
const char *BufferName = "");
|
||||
|
||||
|
||||
/// getMemBufferCopy - Open the specified memory range as a MemoryBuffer,
|
||||
/// copying the contents and taking ownership of it. This has no requirements
|
||||
/// on EndPtr[0].
|
||||
static MemoryBuffer *getMemBufferCopy(const char *StartPtr,const char *EndPtr,
|
||||
const char *BufferName = "");
|
||||
|
||||
|
||||
/// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that
|
||||
/// is completely initialized to zeros. Note that the caller should
|
||||
/// initialize the memory allocated by this method. The memory is owned by
|
||||
/// the MemoryBuffer object.
|
||||
static MemoryBuffer *getNewMemBuffer(size_t Size,
|
||||
const char *BufferName = "");
|
||||
|
||||
|
||||
/// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size
|
||||
/// that is not initialized. Note that the caller should initialize the
|
||||
/// memory allocated by this method. The memory is owned by the MemoryBuffer
|
||||
/// object.
|
||||
static MemoryBuffer *getNewUninitMemBuffer(size_t Size,
|
||||
const char *BufferName = "");
|
||||
|
||||
|
||||
/// getSTDIN - Read all of stdin into a file buffer, and return it. This
|
||||
/// returns null if stdin is empty.
|
||||
static MemoryBuffer *getSTDIN();
|
||||
|
||||
|
||||
|
||||
|
||||
/// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
|
||||
/// 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)
|
||||
@ -93,7 +93,7 @@ public:
|
||||
static MemoryBuffer *getFileOrSTDIN(const char *Filename,
|
||||
std::string *ErrStr = 0,
|
||||
int64_t FileSize = -1);
|
||||
|
||||
|
||||
/// getFileOrSTDIN - Open the specified file as a MemoryBuffer, or open stdin
|
||||
/// if the Filename is "-". If an error occurs, this returns null and fills
|
||||
/// in *ErrStr with a reason.
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
||||
class OutputBuffer {
|
||||
/// Output buffer.
|
||||
std::vector<unsigned char> &Output;
|
||||
@ -37,7 +37,7 @@ namespace llvm {
|
||||
assert(Boundary && (Boundary & (Boundary - 1)) == 0 &&
|
||||
"Must align to 2^k boundary");
|
||||
size_t Size = Output.size();
|
||||
|
||||
|
||||
if (Size & (Boundary - 1)) {
|
||||
// Add padding to get alignment to the correct place.
|
||||
size_t Pad = Boundary - (Size & (Boundary - 1));
|
||||
@ -111,10 +111,10 @@ namespace llvm {
|
||||
? static_cast<unsigned>(S.length()) : Length;
|
||||
unsigned len_to_fill = static_cast<unsigned>(S.length()) < Length
|
||||
? Length - static_cast<unsigned>(S.length()) : 0;
|
||||
|
||||
|
||||
for (unsigned i = 0; i < len_to_copy; ++i)
|
||||
outbyte(S[i]);
|
||||
|
||||
|
||||
for (unsigned i = 0; i < len_to_fill; ++i)
|
||||
outbyte(0);
|
||||
}
|
||||
@ -148,7 +148,7 @@ namespace llvm {
|
||||
return Output[Index];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
} // end llvm namespace
|
||||
|
||||
#endif // LLVM_SUPPORT_OUTPUTBUFFER_H
|
||||
|
@ -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.
|
||||
inline bind_ty<ConstantInt> m_ConstantInt(ConstantInt *&CI) { return CI; }
|
||||
|
||||
|
||||
/// specificval_ty - Match a specified Value*.
|
||||
struct specificval_ty {
|
||||
const Value *Val;
|
||||
specificval_ty(const Value *V) : Val(V) {}
|
||||
|
||||
|
||||
template<typename ITy>
|
||||
bool match(ITy *V) {
|
||||
return V == Val;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/// m_Specific - Match if we have a specific specified value.
|
||||
inline specificval_ty m_Specific(const Value *V) { return V; }
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Matchers for specific binary operators.
|
||||
//
|
||||
|
||||
template<typename LHS_t, typename RHS_t,
|
||||
template<typename LHS_t, typename RHS_t,
|
||||
unsigned Opcode, typename ConcreteTy = BinaryOperator>
|
||||
struct BinaryOp_match {
|
||||
LHS_t L;
|
||||
@ -223,19 +223,19 @@ inline BinaryOp_match<LHS, RHS, Instruction::Xor> m_Xor(const LHS &L,
|
||||
}
|
||||
|
||||
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) {
|
||||
return BinaryOp_match<LHS, RHS, Instruction::Shl>(L, R);
|
||||
}
|
||||
|
||||
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) {
|
||||
return BinaryOp_match<LHS, RHS, Instruction::LShr>(L, R);
|
||||
}
|
||||
|
||||
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) {
|
||||
return BinaryOp_match<LHS, RHS, Instruction::AShr>(L, R);
|
||||
}
|
||||
@ -310,14 +310,14 @@ struct BinaryOpClass_match {
|
||||
template<typename LHS, typename RHS>
|
||||
inline BinaryOpClass_match<LHS, RHS, BinaryOperator, Instruction::BinaryOps>
|
||||
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);
|
||||
}
|
||||
|
||||
template<typename LHS, typename RHS>
|
||||
inline BinaryOpClass_match<LHS, RHS, BinaryOperator, Instruction::BinaryOps>
|
||||
m_Shift(const LHS &L, const RHS &R) {
|
||||
return BinaryOpClass_match<LHS, RHS,
|
||||
return BinaryOpClass_match<LHS, RHS,
|
||||
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>
|
||||
inline SelectClass_match<Cond, constantint_ty<L>, constantint_ty<R> >
|
||||
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>(),
|
||||
m_ConstantInt<R>());
|
||||
}
|
||||
@ -408,9 +408,9 @@ m_SelectCst(const Cond &C) {
|
||||
template<typename Op_t, typename Class>
|
||||
struct CastClass_match {
|
||||
Op_t Op;
|
||||
|
||||
|
||||
CastClass_match(const Op_t &OpMatch) : Op(OpMatch) {}
|
||||
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Matchers for unary operators
|
||||
//
|
||||
@ -468,9 +468,9 @@ inline not_match<LHS> m_Not(const LHS &L) { return L; }
|
||||
template<typename LHS_t>
|
||||
struct neg_match {
|
||||
LHS_t L;
|
||||
|
||||
|
||||
neg_match(const LHS_t &LHS) : L(LHS) {}
|
||||
|
||||
|
||||
template<typename OpTy>
|
||||
bool match(OpTy *V) {
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
|
@ -31,7 +31,7 @@ namespace llvm {
|
||||
/// Memory - This is the space that holds cached preds.
|
||||
BumpPtrAllocator Memory;
|
||||
public:
|
||||
|
||||
|
||||
/// GetPreds - Get a cached list for the null-terminated predecessor list of
|
||||
/// the specified block. This can be used in a loop like this:
|
||||
/// for (BasicBlock **PI = PredCache->GetPreds(BB); *PI; ++PI)
|
||||
@ -41,15 +41,15 @@ namespace llvm {
|
||||
BasicBlock **GetPreds(BasicBlock *BB) {
|
||||
BasicBlock **&Entry = BlockToPredsMap[BB];
|
||||
if (Entry) return Entry;
|
||||
|
||||
|
||||
SmallVector<BasicBlock*, 32> PredCache(pred_begin(BB), pred_end(BB));
|
||||
PredCache.push_back(0); // null terminator.
|
||||
|
||||
|
||||
Entry = Memory.Allocate<BasicBlock*>(PredCache.size());
|
||||
std::copy(PredCache.begin(), PredCache.end(), Entry);
|
||||
return Entry;
|
||||
}
|
||||
|
||||
|
||||
/// clear - Remove all information.
|
||||
void clear() {
|
||||
BlockToPredsMap.clear();
|
||||
|
@ -24,9 +24,9 @@ namespace llvm {
|
||||
|
||||
/// 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
|
||||
/// @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).
|
||||
///
|
||||
///
|
||||
template <typename StreamTy>
|
||||
class BaseStream {
|
||||
StreamTy *Stream;
|
||||
@ -69,7 +69,7 @@ namespace llvm {
|
||||
if (Stream) Stream->write(A, N);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
operator StreamTy* () { return Stream; }
|
||||
|
||||
bool operator == (const StreamTy &S) { return &S == Stream; }
|
||||
|
@ -9,21 +9,21 @@
|
||||
//
|
||||
// This file declares an interned string pool, which helps reduce the cost of
|
||||
// strings by using the same storage for identical strings.
|
||||
//
|
||||
//
|
||||
// To intern a string:
|
||||
//
|
||||
//
|
||||
// StringPool Pool;
|
||||
// PooledStringPtr Str = Pool.intern("wakka wakka");
|
||||
//
|
||||
//
|
||||
// To use the value of an interned string, use operator bool and operator*:
|
||||
//
|
||||
//
|
||||
// if (Str)
|
||||
// cerr << "the string is" << *Str << "\n";
|
||||
//
|
||||
//
|
||||
// Pooled strings are immutable, but you can change a PooledStringPtr to point
|
||||
// to another instance. So that interned strings can eventually be freed,
|
||||
// strings in the string pool are reference-counted (automatically).
|
||||
//
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_STRINGPOOL_H
|
||||
@ -46,36 +46,36 @@ namespace llvm {
|
||||
struct PooledString {
|
||||
StringPool *Pool; ///< So the string can remove itself.
|
||||
unsigned Refcount; ///< Number of referencing PooledStringPtrs.
|
||||
|
||||
|
||||
public:
|
||||
PooledString() : Pool(0), Refcount(0) { }
|
||||
};
|
||||
|
||||
|
||||
friend class PooledStringPtr;
|
||||
|
||||
|
||||
typedef StringMap<PooledString> table_t;
|
||||
typedef StringMapEntry<PooledString> entry_t;
|
||||
table_t InternTable;
|
||||
|
||||
|
||||
public:
|
||||
StringPool();
|
||||
~StringPool();
|
||||
|
||||
|
||||
/// intern - Adds a string to the pool and returns a reference-counted
|
||||
/// pointer to it. No additional memory is allocated if the string already
|
||||
/// exists in the pool.
|
||||
PooledStringPtr intern(const char *Begin, const char *End);
|
||||
|
||||
|
||||
/// intern - Adds a null-terminated string to the pool and returns a
|
||||
/// reference-counted pointer to it. No additional memory is allocated if
|
||||
/// the string already exists in the pool.
|
||||
inline PooledStringPtr intern(const char *Str);
|
||||
|
||||
|
||||
/// empty - Checks whether the pool is empty. Returns true if so.
|
||||
///
|
||||
///
|
||||
inline bool empty() const { return InternTable.empty(); }
|
||||
};
|
||||
|
||||
|
||||
/// 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.
|
||||
/// This is a lightweight value class with storage requirements equivalent to
|
||||
@ -84,18 +84,18 @@ namespace llvm {
|
||||
class PooledStringPtr {
|
||||
typedef StringPool::entry_t entry_t;
|
||||
entry_t *S;
|
||||
|
||||
|
||||
public:
|
||||
PooledStringPtr() : S(0) {}
|
||||
|
||||
|
||||
explicit PooledStringPtr(entry_t *E) : S(E) {
|
||||
if (S) ++S->getValue().Refcount;
|
||||
}
|
||||
|
||||
|
||||
PooledStringPtr(const PooledStringPtr &That) : S(That.S) {
|
||||
if (S) ++S->getValue().Refcount;
|
||||
}
|
||||
|
||||
|
||||
PooledStringPtr &operator=(const PooledStringPtr &That) {
|
||||
if (S != That.S) {
|
||||
clear();
|
||||
@ -104,7 +104,7 @@ namespace llvm {
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void clear() {
|
||||
if (!S)
|
||||
return;
|
||||
@ -114,31 +114,31 @@ namespace llvm {
|
||||
}
|
||||
S = 0;
|
||||
}
|
||||
|
||||
|
||||
~PooledStringPtr() { clear(); }
|
||||
|
||||
|
||||
inline const char *begin() const {
|
||||
assert(*this && "Attempt to dereference empty PooledStringPtr!");
|
||||
return S->getKeyData();
|
||||
}
|
||||
|
||||
|
||||
inline const char *end() const {
|
||||
assert(*this && "Attempt to dereference empty PooledStringPtr!");
|
||||
return S->getKeyData() + S->getKeyLength();
|
||||
}
|
||||
|
||||
|
||||
inline unsigned size() const {
|
||||
assert(*this && "Attempt to dereference empty PooledStringPtr!");
|
||||
return S->getKeyLength();
|
||||
}
|
||||
|
||||
|
||||
inline const char *operator*() const { return begin(); }
|
||||
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; }
|
||||
};
|
||||
|
||||
|
||||
PooledStringPtr StringPool::intern(const char *Str) {
|
||||
return intern(Str, Str + strlen(Str));
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ namespace llvm {
|
||||
class format_object_base;
|
||||
template <typename T>
|
||||
class SmallVectorImpl;
|
||||
|
||||
|
||||
/// raw_ostream - This class implements an extremely fast bulk output stream
|
||||
/// 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
|
||||
@ -41,62 +41,62 @@ public:
|
||||
virtual ~raw_ostream() {
|
||||
delete [] OutBufStart;
|
||||
}
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Configuration Interface
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
|
||||
/// SetBufferSize - Set the internal buffer size to the specified amount
|
||||
/// instead of the default.
|
||||
void SetBufferSize(unsigned Size) {
|
||||
assert(Size >= 64 &&
|
||||
"Buffer size must be somewhat large for invariants to hold");
|
||||
flush();
|
||||
|
||||
|
||||
delete [] OutBufStart;
|
||||
OutBufStart = new char[Size];
|
||||
OutBufEnd = OutBufStart+Size;
|
||||
OutBufCur = OutBufStart;
|
||||
}
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Data Output Interface
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
|
||||
void flush() {
|
||||
if (OutBufCur != OutBufStart)
|
||||
flush_impl();
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &operator<<(char C) {
|
||||
if (OutBufCur >= OutBufEnd)
|
||||
flush_impl();
|
||||
*OutBufCur++ = C;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &operator<<(unsigned char C) {
|
||||
if (OutBufCur >= OutBufEnd)
|
||||
flush_impl();
|
||||
*OutBufCur++ = C;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &operator<<(signed char C) {
|
||||
if (OutBufCur >= OutBufEnd)
|
||||
flush_impl();
|
||||
*OutBufCur++ = C;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &operator<<(const char *Str) {
|
||||
return write(Str, strlen(Str));
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &operator<<(const std::string& Str) {
|
||||
return write(Str.data(), Str.length());
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &operator<<(unsigned long N);
|
||||
raw_ostream &operator<<(long N);
|
||||
raw_ostream &operator<<(unsigned long long N);
|
||||
@ -105,7 +105,7 @@ public:
|
||||
raw_ostream &operator<<(unsigned int N) {
|
||||
return this->operator<<(static_cast<unsigned long>(N));
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &operator<<(int N) {
|
||||
return this->operator<<(static_cast<long>(N));
|
||||
}
|
||||
@ -113,23 +113,23 @@ public:
|
||||
raw_ostream &operator<<(double N) {
|
||||
return this->operator<<(ftostr(N));
|
||||
}
|
||||
|
||||
|
||||
raw_ostream &write(const char *Ptr, unsigned Size);
|
||||
|
||||
|
||||
// Formatted output, see the format() function in Support/Format.h.
|
||||
raw_ostream &operator<<(const format_object_base &Fmt);
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
// Subclass Interface
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
/// flush_impl - The is the piece of the class that is implemented by
|
||||
/// subclasses. This outputs the currently buffered data and resets the
|
||||
/// buffer to empty.
|
||||
virtual void flush_impl() = 0;
|
||||
|
||||
|
||||
/// HandleFlush - A stream's implementation of flush should call this after
|
||||
/// emitting the bytes to the data sink.
|
||||
void HandleFlush() {
|
||||
@ -141,11 +141,11 @@ private:
|
||||
// An out of line virtual method to provide a home for the class vtable.
|
||||
virtual void handle();
|
||||
};
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// File Output Streams
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
/// raw_fd_ostream - A raw_ostream that writes to a file descriptor.
|
||||
///
|
||||
class raw_fd_ostream : public raw_ostream {
|
||||
@ -163,31 +163,31 @@ public:
|
||||
/// \param Binary - The file should be opened in binary mode on
|
||||
/// platforms that support this distinction.
|
||||
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
|
||||
/// 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();
|
||||
|
||||
|
||||
/// flush_impl - The is the piece of the class that is implemented by
|
||||
/// subclasses. This outputs the currently buffered data and resets the
|
||||
/// buffer to empty.
|
||||
virtual void flush_impl();
|
||||
|
||||
|
||||
/// close - Manually flush the stream and close the file.
|
||||
void close();
|
||||
|
||||
|
||||
/// tell - Return the current offset with the file.
|
||||
uint64_t tell() {
|
||||
return pos + (OutBufCur - OutBufStart);
|
||||
}
|
||||
|
||||
|
||||
/// seek - Flushes the stream and repositions the underlying file descriptor
|
||||
/// positition to the offset specified from the beginning of the file.
|
||||
uint64_t seek(uint64_t off);
|
||||
};
|
||||
|
||||
|
||||
/// raw_stdout_ostream - This is a stream that always prints to stdout.
|
||||
///
|
||||
class raw_stdout_ostream : public raw_fd_ostream {
|
||||
@ -205,7 +205,7 @@ class raw_stderr_ostream : public raw_fd_ostream {
|
||||
public:
|
||||
raw_stderr_ostream();
|
||||
};
|
||||
|
||||
|
||||
/// outs() - This returns a reference to a raw_ostream for standard output.
|
||||
/// Use it like: outs() << "foo" << "bar";
|
||||
raw_ostream &outs();
|
||||
@ -213,12 +213,12 @@ raw_ostream &outs();
|
||||
/// errs() - This returns a reference to a raw_ostream for standard error.
|
||||
/// Use it like: errs() << "foo" << "bar";
|
||||
raw_ostream &errs();
|
||||
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Output Stream Adaptors
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
/// raw_os_ostream - A raw_ostream that writes to an std::ostream. This is a
|
||||
/// simple adaptor class.
|
||||
class raw_os_ostream : public raw_ostream {
|
||||
@ -240,20 +240,20 @@ class raw_string_ostream : public raw_ostream {
|
||||
public:
|
||||
raw_string_ostream(std::string &O) : OS(O) {}
|
||||
~raw_string_ostream();
|
||||
|
||||
|
||||
/// str - Flushes the stream contents to the target string and returns
|
||||
/// the string's reference.
|
||||
std::string& str() {
|
||||
flush();
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
||||
/// flush_impl - The is the piece of the class that is implemented by
|
||||
/// subclasses. This outputs the currently buffered data and resets the
|
||||
/// buffer to empty.
|
||||
virtual void flush_impl();
|
||||
};
|
||||
|
||||
|
||||
/// raw_svector_ostream - A raw_ostream that writes to an SmallVector or
|
||||
/// SmallString. This is a simple adaptor class.
|
||||
class raw_svector_ostream : public raw_ostream {
|
||||
@ -261,13 +261,13 @@ class raw_svector_ostream : public raw_ostream {
|
||||
public:
|
||||
raw_svector_ostream(SmallVectorImpl<char> &O) : OS(O) {}
|
||||
~raw_svector_ostream();
|
||||
|
||||
|
||||
/// flush_impl - The is the piece of the class that is implemented by
|
||||
/// subclasses. This outputs the currently buffered data and resets the
|
||||
/// buffer to empty.
|
||||
virtual void flush_impl();
|
||||
};
|
||||
|
||||
|
||||
} // end llvm namespace
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user