diff options
Diffstat (limited to 'include/llvm/Support')
-rw-r--r-- | include/llvm/Support/CFG.h | 2 | ||||
-rw-r--r-- | include/llvm/Support/DebugLoc.h | 53 | ||||
-rw-r--r-- | include/llvm/Support/Mangler.h | 142 | ||||
-rw-r--r-- | include/llvm/Support/PassNameParser.h | 4 | ||||
-rw-r--r-- | include/llvm/Support/SMLoc.h | 44 | ||||
-rw-r--r-- | include/llvm/Support/SourceMgr.h | 24 | ||||
-rw-r--r-- | include/llvm/Support/raw_ostream.h | 5 |
7 files changed, 59 insertions, 215 deletions
diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index 90b95bf..3875f0b 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -149,8 +149,8 @@ public: } inline bool operator>(const _Self& x) const { - return idx > x.idx; assert(Term == x.Term && "Cannot compare iterators of different blocks!"); + return idx > x.idx; } inline _Self& operator+=(int Right) { diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h index 6814f63..32631fc 100644 --- a/include/llvm/Support/DebugLoc.h +++ b/include/llvm/Support/DebugLoc.h @@ -21,29 +21,6 @@ namespace llvm { class MDNode; - /// DebugLocTuple - Debug location tuple of filename id, line and column. - /// - struct DebugLocTuple { - MDNode *Scope; - MDNode *InlinedAtLoc; - unsigned Line, Col; - - DebugLocTuple() - : Scope(0), InlinedAtLoc(0), Line(~0U), Col(~0U) {} - - DebugLocTuple(MDNode *n, MDNode *i, unsigned l, unsigned c) - : Scope(n), InlinedAtLoc(i), Line(l), Col(c) {} - - bool operator==(const DebugLocTuple &DLT) const { - return Scope == DLT.Scope && - InlinedAtLoc == DLT.InlinedAtLoc && - Line == DLT.Line && Col == DLT.Col; - } - bool operator!=(const DebugLocTuple &DLT) const { - return !(*this == DLT); - } - }; - /// DebugLoc - Debug location id. This is carried by SDNode and MachineInstr /// to index into a vector of unique debug location tuples. class DebugLoc { @@ -65,40 +42,16 @@ namespace llvm { bool operator!=(const DebugLoc &DL) const { return !(*this == DL); } }; - // Specialize DenseMapInfo for DebugLocTuple. - template<> struct DenseMapInfo<DebugLocTuple> { - static inline DebugLocTuple getEmptyKey() { - return DebugLocTuple(0, 0, ~0U, ~0U); - } - static inline DebugLocTuple getTombstoneKey() { - return DebugLocTuple((MDNode*)~1U, (MDNode*)~1U, ~1U, ~1U); - } - static unsigned getHashValue(const DebugLocTuple &Val) { - return DenseMapInfo<MDNode*>::getHashValue(Val.Scope) ^ - DenseMapInfo<MDNode*>::getHashValue(Val.InlinedAtLoc) ^ - DenseMapInfo<unsigned>::getHashValue(Val.Line) ^ - DenseMapInfo<unsigned>::getHashValue(Val.Col); - } - static bool isEqual(const DebugLocTuple &LHS, const DebugLocTuple &RHS) { - return LHS.Scope == RHS.Scope && - LHS.InlinedAtLoc == RHS.InlinedAtLoc && - LHS.Line == RHS.Line && - LHS.Col == RHS.Col; - } - }; - template <> struct isPodLike<DebugLocTuple> {static const bool value = true;}; - - - /// DebugLocTracker - This class tracks debug location information. + /// DebugLocTracker - This class tracks debug location information. /// struct DebugLocTracker { /// DebugLocations - A vector of unique DebugLocTuple's. /// - std::vector<DebugLocTuple> DebugLocations; + std::vector<MDNode *> DebugLocations; /// DebugIdMap - This maps DebugLocTuple's to indices into the /// DebugLocations vector. - DenseMap<DebugLocTuple, unsigned> DebugIdMap; + DenseMap<MDNode *, unsigned> DebugIdMap; DebugLocTracker() {} }; diff --git a/include/llvm/Support/Mangler.h b/include/llvm/Support/Mangler.h deleted file mode 100644 index aa230d4..0000000 --- a/include/llvm/Support/Mangler.h +++ /dev/null @@ -1,142 +0,0 @@ -//===-- llvm/Support/Mangler.h - Self-contained name mangler ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Unified name mangler for various backends. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_MANGLER_H -#define LLVM_SUPPORT_MANGLER_H - -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" -#include <string> - -namespace llvm { -class Twine; -class Type; -class Module; -class Value; -class GlobalValue; -template <typename T> class SmallVectorImpl; - -class Mangler { -public: - enum ManglerPrefixTy { - Default, ///< Emit default string before each symbol. - Private, ///< Emit "private" prefix before each symbol. - LinkerPrivate ///< Emit "linker private" prefix before each symbol. - }; - -private: - /// Prefix - This string is added to each symbol that is emitted, unless the - /// symbol is marked as not needing this prefix. - const char *Prefix; - - /// PrivatePrefix - This string is emitted before each symbol with private - /// linkage. - const char *PrivatePrefix; - - /// LinkerPrivatePrefix - This string is emitted before each symbol with - /// "linker_private" linkage. - const char *LinkerPrivatePrefix; - - /// 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; - - /// SymbolsCanStartWithDigit - If this is set, the target allows symbols to - /// start with digits (e.g., "0x0021"). By default, this is false. - bool SymbolsCanStartWithDigit; - - /// AnonGlobalIDs - We need to give global values the same name every time - /// they are mangled. This keeps track of the number we give to anonymous - /// ones. - /// - DenseMap<const GlobalValue*, unsigned> AnonGlobalIDs; - - /// NextAnonGlobalID - This simple counter is used to unique value names. - /// - unsigned NextAnonGlobalID; - - /// AcceptableChars - This bitfield contains a one for each character that is - /// allowed to be part of an unmangled name. - unsigned AcceptableChars[256 / 32]; - -public: - // Mangler ctor - if a prefix is specified, it will be prepended onto all - // symbols. - Mangler(Module &M, const char *Prefix = "", const char *privatePrefix = "", - const char *linkerPrivatePrefix = ""); - - /// setUseQuotes - If UseQuotes is set to true, this target accepts quoted - /// strings for assembler labels. - void setUseQuotes(bool Val) { UseQuotes = Val; } - - /// setSymbolsCanStartWithDigit - If SymbolsCanStartWithDigit is set to true, - /// this target allows symbols to start with digits. - void setSymbolsCanStartWithDigit(bool Val) { SymbolsCanStartWithDigit = 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, '_', '$', '.', which is what GAS accepts, and '@'. - void markCharAcceptable(unsigned char X) { - AcceptableChars[X/32] |= 1 << (X&31); - } - void markCharUnacceptable(unsigned char X) { - AcceptableChars[X/32] &= ~(1 << (X&31)); - } - bool isCharAcceptable(unsigned char X) const { - return (AcceptableChars[X/32] & (1 << (X&31))) != 0; - } - - /// getMangledName - Returns the mangled name of V, an LLVM Value, - /// in the current module. If 'Suffix' is specified, the name ends with the - /// specified suffix. If 'ForcePrivate' is specified, the label is specified - /// to have a private label prefix. - /// - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use - /// MCSymbol printing to handle quotes or not etc. - /// - std::string getMangledName(const GlobalValue *V, const char *Suffix = "", - bool ForcePrivate = false); - - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix - /// and the specified global variable's name. If the global variable doesn't - /// have a name, this fills in a unique name for the global. - void getNameWithPrefix(SmallVectorImpl<char> &OutName, const GlobalValue *GV, - bool isImplicitlyPrivate); - - /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix - /// and the specified name as the global variable name. GVName must not be - /// empty. - void getNameWithPrefix(SmallVectorImpl<char> &OutName, const Twine &GVName, - ManglerPrefixTy PrefixTy = Mangler::Default); - -private: - /// makeNameProper - We don't want identifier names with ., space, or - /// - in them, so we mangle these characters into the strings "d_", - /// "s_", and "D_", respectively. This is a very simple mangling that - /// doesn't guarantee unique names for values. getValueName already - /// does this for you, so there's no point calling it on the result - /// from getValueName. - /// - /// FIXME: This is deprecated, new code should use getNameWithPrefix and use - /// MCSymbol printing to handle quotes or not etc. - /// - void makeNameProper(SmallVectorImpl<char> &OutName, - const Twine &Name, - ManglerPrefixTy PrefixTy = Mangler::Default); - -}; - -} // End llvm namespace - -#endif // LLVM_SUPPORT_MANGLER_H diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index ea4fe01..cdca978 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -41,7 +41,9 @@ class PassNameParser : public PassRegistrationListener, cl::Option *Opt; public: PassNameParser() : Opt(0) {} - + virtual ~PassNameParser(); + + void initialize(cl::Option &O) { Opt = &O; cl::parser<const PassInfo*>::initialize(O); diff --git a/include/llvm/Support/SMLoc.h b/include/llvm/Support/SMLoc.h new file mode 100644 index 0000000..967bf14 --- /dev/null +++ b/include/llvm/Support/SMLoc.h @@ -0,0 +1,44 @@ +//===- SMLoc.h - Source location for use with diagnostics -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the SMLoc class. This class encapsulates a location in +// source code for use in diagnostics. +// +//===----------------------------------------------------------------------===// + +#ifndef SUPPORT_SMLOC_H +#define SUPPORT_SMLOC_H + +namespace llvm { + +// SMLoc - Represents a location in source code. +class SMLoc { + const char *Ptr; +public: + SMLoc() : Ptr(0) {} + SMLoc(const SMLoc &RHS) : Ptr(RHS.Ptr) {} + + bool isValid() const { return Ptr != 0; } + + bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; } + bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; } + + const char *getPointer() const { return Ptr; } + + static SMLoc getFromPointer(const char *Ptr) { + SMLoc L; + L.Ptr = Ptr; + return L; + } +}; + +} + +#endif + diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h index b695ff1..5433a00 100644 --- a/include/llvm/Support/SourceMgr.h +++ b/include/llvm/Support/SourceMgr.h @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file declares the SMLoc, SMDiagnostic and SourceMgr classes. This +// This file declares the SMDiagnostic and SourceMgr classes. This // provides a simple substrate for diagnostics, #include handling, and other low // level things for simple parsers. // @@ -16,6 +16,8 @@ #ifndef SUPPORT_SOURCEMGR_H #define SUPPORT_SOURCEMGR_H +#include "llvm/Support/SMLoc.h" + #include <string> #include <vector> #include <cassert> @@ -25,26 +27,6 @@ namespace llvm { class SourceMgr; class SMDiagnostic; class raw_ostream; - -class SMLoc { - const char *Ptr; -public: - SMLoc() : Ptr(0) {} - SMLoc(const SMLoc &RHS) : Ptr(RHS.Ptr) {} - - bool isValid() const { return Ptr != 0; } - - bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; } - bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; } - - const char *getPointer() const { return Ptr; } - - static SMLoc getFromPointer(const char *Ptr) { - SMLoc L; - L.Ptr = Ptr; - return L; - } -}; /// SourceMgr - This owns the files read by a parser, handles include stacks, /// and handles diagnostic wrangling. diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index d3c45c2..0f227cc 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -456,6 +456,11 @@ public: explicit raw_svector_ostream(SmallVectorImpl<char> &O); ~raw_svector_ostream(); + /// resync - This is called when the SmallVector we're appending to is changed + /// outside of the raw_svector_ostream's control. It is only safe to do this + /// if the raw_svector_ostream has previously been flushed. + void resync(); + /// str - Flushes the stream contents to the target vector and return a /// StringRef for the vector contents. StringRef str(); |