From dbab15a2c9accc0242109881e1632137cb97dbc9 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Jul 2001 17:17:47 +0000 Subject: Initial checkin git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 399 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 399 insertions(+) create mode 100644 lib/Support/CommandLine.cpp (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp new file mode 100644 index 0000000000..013c22fe92 --- /dev/null +++ b/lib/Support/CommandLine.cpp @@ -0,0 +1,399 @@ +//===-- CommandLine.cpp - Command line parser implementation --------------===// +// +// This class implements a command line argument processor that is useful when +// creating a tool. It provides a simple, minimalistic interface that is easily +// extensible and supports nonlocal (library) command line options. +// +//===----------------------------------------------------------------------===// + +#include "llvm/Tools/CommandLine.h" +#include "llvm/Tools/STLExtras.h" +#include +#include +#include +#include +using namespace cl; + +// Return the global command line option vector. Making it a function scoped +// static ensures that it will be initialized before its first use correctly. +// +static map &getOpts() { + static map CommandLineOptions; + return CommandLineOptions; +} + +static void AddArgument(const string &ArgName, Option *Opt) { + if (getOpts().find(ArgName) != getOpts().end()) { + cerr << "CommandLine Error: Argument '" << ArgName + << "' specified more than once!\n"; + } else { + getOpts()[ArgName] = Opt; // Add argument to the argument map! + } +} + +static const char *ProgramName = 0; +static const char *ProgramOverview = 0; + +void cl::ParseCommandLineOptions(int &argc, char **argv, + const char *Overview = 0) { + ProgramName = argv[0]; // Save this away safe and snug + ProgramOverview = Overview; + bool ErrorParsing = false; + + // Loop over all of the arguments... processing them. + for (int i = 1; i < argc; ++i) { + Option *Handler = 0; + const char *Value = ""; + const char *ArgName = ""; + if (argv[i][0] != '-') { // Unnamed argument? + Handler = getOpts()[""]; + Value = argv[i]; + } else { // We start with a - or --, eat dashes + ArgName = argv[i]+1; + while (*ArgName == '-') ++ArgName; // Eat leading dashes + + const char *ArgNameEnd = ArgName; + while (*ArgNameEnd && *ArgNameEnd != '=') ++ArgNameEnd; // Scan till end + + Value = ArgNameEnd; + if (*Value) // If we have an equals sign... + ++Value; // Advance to value... + + if (*ArgName != 0) { + string ArgNameStr(ArgName, ArgNameEnd); // Extract arg name part + Handler = getOpts()[ArgNameStr]; + } + } + + if (Handler == 0) { + cerr << "Unknown command line argument '" << argv[i] << "'. Try: " + << argv[0] << " --help\n'"; + ErrorParsing = true; + continue; + } + + // Enforce value requirements + switch (Handler->Flags & ValueMask) { + case ValueRequired: + if (Value == 0 || *Value == 0) { // No value specified? + if (i+1 < argc) { // Steal the next argument, like for '-o filename' + Value = argv[++i]; + } else { + ErrorParsing = Handler->error(" requires a value!"); + continue; + } + } + break; + case ValueDisallowed: + if (*Value != 0) { + ErrorParsing = Handler->error(" does not allow a value! '" + + string(Value) + "' specified."); + continue; + } + break; + case Optional: break; + default: cerr << "Bad ValueMask flag! CommandLine usage error!\n"; abort(); + } + + // Run the handler now! + ErrorParsing |= Handler->addOccurance(ArgName, Value); + } + + // TODO: loop over args and make sure all required args are specified! + + // Free all of the memory allocated to the vector. Command line options may + // only be processed once! + getOpts().clear(); + + // If we had an error processing our arguments, don't let the program execute + if (ErrorParsing) exit(1); +} + +//===----------------------------------------------------------------------===// +// Option Base class implementation +// +Option::Option(const char *argStr, const char *helpStr, int flags) + : NumOccurances(0), ArgStr(argStr), HelpStr(helpStr), Flags(flags) { + AddArgument(ArgStr, this); +} + +bool Option::error(string Message, const char *ArgName = 0) { + if (ArgName == 0) ArgName = ArgStr; + cerr << "-" << ArgName << " option" << Message << endl; + return true; +} + +bool Option::addOccurance(const char *ArgName, const string &Value) { + NumOccurances++; // Increment the number of times we have been seen + + switch (Flags & OccurancesMask) { + case Optional: + if (NumOccurances > 1) + return error(": may only occur zero or one times!", ArgName); + break; + case Required: + if (NumOccurances > 1) + return error(": must occur exactly one time!", ArgName); + // Fall through + case OneOrMore: + case ZeroOrMore: break; + default: return error(": bad num occurances flag value!"); + } + + return handleOccurance(ArgName, Value); +} + +// Return the width of the option tag for printing... +unsigned Option::getOptionWidth() const { + return std::strlen(ArgStr)+6; +} + +void Option::printOptionInfo(unsigned GlobalWidth) const { + unsigned L = std::strlen(ArgStr); + if (L == 0) return; // Don't print the empty arg like this! + cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " + << HelpStr << endl; +} + + +//===----------------------------------------------------------------------===// +// Boolean/flag command line option implementation +// + +bool Flag::handleOccurance(const char *ArgName, const string &Arg) { + if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || + Arg == "1") { + Value = true; + } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") { + Value = false; + } else { + return error(": '" + Arg + "' is invalid value for boolean argument! Try 0 or 1"); + } + + return false; +} + +//===----------------------------------------------------------------------===// +// Integer valued command line option implementation +// +bool Int::handleOccurance(const char *ArgName, const string &Arg) { + const char *ArgStart = Arg.c_str(); + char *End; + Value = (int)strtol(ArgStart, &End, 0); + if (*End != 0) + return error(": '" + Arg + "' value invalid for integer argument!"); + return false; +} + +//===----------------------------------------------------------------------===// +// String valued command line option implementation +// +bool String::handleOccurance(const char *ArgName, const string &Arg) { + Value = Arg; + return false; +} + +//===----------------------------------------------------------------------===// +// Enum valued command line option implementation +// +void EnumBase::processValues(va_list Vals) { + while (const char *EnumName = va_arg(Vals, const char *)) { + int EnumVal = va_arg(Vals, int); + const char *EnumDesc = va_arg(Vals, const char *); + ValueMap.push_back(make_pair(EnumName, // Add value to value map + make_pair(EnumVal, EnumDesc))); + } +} + +// registerArgs - notify the system about these new arguments +void EnumBase::registerArgs() { + for (unsigned i = 0; i < ValueMap.size(); ++i) + AddArgument(ValueMap[i].first, this); +} + +const char *EnumBase::getArgName(int ID) const { + for (unsigned i = 0; i < ValueMap.size(); ++i) + if (ID == ValueMap[i].second.first) return ValueMap[i].first; + return ""; +} +const char *EnumBase::getArgDescription(int ID) const { + for (unsigned i = 0; i < ValueMap.size(); ++i) + if (ID == ValueMap[i].second.first) return ValueMap[i].second.second; + return ""; +} + + + +bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { + unsigned i; + for (i = 0; i < ValueMap.size(); ++i) + if (ValueMap[i].first == Arg) break; + if (i == ValueMap.size()) + return error(": unrecognized alternative '"+Arg+"'!"); + Value = ValueMap[i].second.first; + return false; +} + +// Return the width of the option tag for printing... +unsigned EnumValueBase::getOptionWidth() const { + unsigned BaseSize = Option::getOptionWidth(); + for (unsigned i = 0; i < ValueMap.size(); ++i) + BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+8); + return BaseSize; +} + +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void EnumValueBase::printOptionInfo(unsigned GlobalWidth) const { + Option::printOptionInfo(GlobalWidth); + for (unsigned i = 0; i < ValueMap.size(); ++i) { + unsigned NumSpaces = GlobalWidth-strlen(ValueMap[i].first)-8; + cerr << " =" << ValueMap[i].first << string(NumSpaces, ' ') << " - " + << ValueMap[i].second.second; + + if (i == 0) cerr << " (default)"; + cerr << endl; + } +} + +//===----------------------------------------------------------------------===// +// Enum flags command line option implementation +// + +bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) { + return EnumValueBase::handleOccurance("", ArgName); +} + +unsigned EnumFlagsBase::getOptionWidth() const { + unsigned BaseSize = 0; + for (unsigned i = 0; i < ValueMap.size(); ++i) + BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6); + return BaseSize; +} + +void EnumFlagsBase::printOptionInfo(unsigned GlobalWidth) const { + for (unsigned i = 0; i < ValueMap.size(); ++i) { + unsigned L = std::strlen(ValueMap[i].first); + cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " + << ValueMap[i].second.second; + if (i == 0) cerr << " (default)"; + cerr << endl; + } +} + + +//===----------------------------------------------------------------------===// +// Enum list command line option implementation +// + +bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) { + unsigned i; + for (i = 0; i < ValueMap.size(); ++i) + if (ValueMap[i].first == string(ArgName)) break; + if (i == ValueMap.size()) + return error(": CommandLine INTERNAL ERROR", ArgName); + Values.push_back(ValueMap[i].second.first); + return false; +} + +// Return the width of the option tag for printing... +unsigned EnumListBase::getOptionWidth() const { + unsigned BaseSize = 0; + for (unsigned i = 0; i < ValueMap.size(); ++i) + BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6); + return BaseSize; +} + + +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void EnumListBase::printOptionInfo(unsigned GlobalWidth) const { + for (unsigned i = 0; i < ValueMap.size(); ++i) { + unsigned L = std::strlen(ValueMap[i].first); + cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " + << ValueMap[i].second.second << endl; + } +} + + +//===----------------------------------------------------------------------===// +// Help option... always automatically provided. +// +namespace { + +// isHidden/isReallyHidden - Predicates to be used to filter down arg lists. +inline bool isHidden(pair &OptPair) { + return (OptPair.second->Flags & HiddenMask) == Hidden; +} +inline bool isReallyHidden(pair &OptPair) { + return (OptPair.second->Flags & HiddenMask) == ReallyHidden; +} + +class Help : public Option { + unsigned MaxArgLen; + const Option *EmptyArg; + const bool ShowHidden; + + virtual bool handleOccurance(const char *ArgName, const string &Arg) { + // Copy Options into a vector so we can sort them as we like... + vector > Options; + copy(getOpts().begin(), getOpts().end(), back_inserter(Options)); + + // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden + Options.erase(remove_if(Options.begin(), Options.end(), + ptr_fun(ShowHidden ? isReallyHidden : isHidden)), + Options.end()); + + // Eliminate duplicate entries in table (from enum flags options, f.e.) + set OptionSet; + for (unsigned i = 0; i < Options.size(); ) + if (OptionSet.count(Options[i].second) == 0) + OptionSet.insert(Options[i++].second); // Add to set + else + Options.erase(Options.begin()+i); // Erase duplicate + + + if (ProgramOverview) + cerr << "OVERVIEW:" << ProgramOverview << endl; + // TODO: Sort options by some criteria + + cerr << "USAGE: " << ProgramName << " [options]\n\n"; + // TODO: print usage nicer + + // Compute the maximum argument length... + MaxArgLen = 0; + for_each(Options.begin(), Options.end(), + bind_obj(this, &Help::getMaxArgLen)); + + cerr << "OPTIONS:\n"; + for_each(Options.begin(), Options.end(), + bind_obj(this, &Help::printOption)); + + return true; // Displaying help is cause to terminate the program + } + + void getMaxArgLen(pair OptPair) { + const Option *Opt = OptPair.second; + if (Opt->ArgStr[0] == 0) EmptyArg = Opt; // Capture the empty arg if exists + MaxArgLen = max(MaxArgLen, Opt->getOptionWidth()); + } + + void printOption(pair OptPair) { + const Option *Opt = OptPair.second; + Opt->printOptionInfo(MaxArgLen); + } + +public: + inline Help(const char *ArgVal, const char *HelpVal, bool showHidden) + : Option(ArgVal, HelpVal, showHidden ? Hidden : 0), ShowHidden(showHidden) { + EmptyArg = 0; + } +}; + +Help HelpOp("help", "display available options" + " (-help-hidden for more)", false); +Help HelpHiddenOpt("help-hidden", "display all available options", true); + +} // End anonymous namespace -- cgit v1.2.3-70-g09d2 From 57dbb3ad63b6a0e77798edb156ef43daa3bfc67e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Jul 2001 17:46:59 +0000 Subject: Moved inline/llvm/Tools/* to include/llvm/Support/* git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bytecode/Primitives.h | 2 +- include/llvm/CodeGen/MachineInstr.h | 2 +- include/llvm/CodeGen/TargetMachine.h | 2 +- include/llvm/ConstPoolVals.h | 2 +- include/llvm/Support/DataTypes.h | 25 ++ include/llvm/Support/HashExtras.h | 22 ++ include/llvm/Support/STLExtras.h | 210 +++++++++++++++ include/llvm/Support/StringExtras.h | 70 +++++ include/llvm/Tools/CommandLine.h | 284 --------------------- include/llvm/Tools/DataTypes.h | 26 -- include/llvm/Tools/STLExtras.h | 210 --------------- include/llvm/Tools/StringExtras.h | 70 ----- lib/Analysis/IntervalPartition.cpp | 2 +- lib/Analysis/LoopDepth.cpp | 2 +- lib/Analysis/ModuleAnalyzer.cpp | 2 +- lib/Analysis/PostDominators.cpp | 2 +- lib/AsmParser/ParserInternals.h | 2 +- lib/Bytecode/Writer/InstructionWriter.cpp | 1 - lib/Bytecode/Writer/WriterInternals.h | 2 +- lib/CodeGen/InstrSelection/InstrSelection.cpp | 2 +- lib/Support/CommandLine.cpp | 4 +- .../SparcV9/InstrSelection/InstrSelection.cpp | 2 +- lib/Transforms/Scalar/ADCE.cpp | 2 +- lib/Transforms/Scalar/DCE.cpp | 2 +- lib/Transforms/Scalar/InductionVars.cpp | 2 +- lib/Transforms/Scalar/SCCP.cpp | 2 +- lib/VMCore/ConstantPool.cpp | 2 +- lib/VMCore/Dominators.cpp | 2 +- lib/VMCore/Module.cpp | 2 +- lib/VMCore/SymbolTable.cpp | 2 +- lib/VMCore/Type.cpp | 2 +- support/lib/Support/CommandLine.cpp | 4 +- tools/analyze/analyze.cpp | 2 +- tools/as/as.cpp | 2 +- tools/dis/dis.cpp | 2 +- tools/llc/llc.cpp | 2 +- tools/llvm-as/as.cpp | 2 +- tools/llvm-as/llvm-as.cpp | 2 +- tools/llvm-dis/dis.cpp | 2 +- tools/llvm-dis/llvm-dis.cpp | 2 +- tools/opt/opt.cpp | 2 +- 41 files changed, 361 insertions(+), 625 deletions(-) create mode 100644 include/llvm/Support/DataTypes.h create mode 100644 include/llvm/Support/HashExtras.h create mode 100644 include/llvm/Support/STLExtras.h create mode 100644 include/llvm/Support/StringExtras.h delete mode 100644 include/llvm/Tools/CommandLine.h delete mode 100644 include/llvm/Tools/DataTypes.h delete mode 100644 include/llvm/Tools/STLExtras.h delete mode 100644 include/llvm/Tools/StringExtras.h (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Bytecode/Primitives.h b/include/llvm/Bytecode/Primitives.h index e5f93e718c..d687fb8185 100644 --- a/include/llvm/Bytecode/Primitives.h +++ b/include/llvm/Bytecode/Primitives.h @@ -12,7 +12,7 @@ #ifndef LLVM_BYTECODE_PRIMITIVES_H #define LLVM_BYTECODE_PRIMITIVES_H -#include "llvm/Tools/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include #include diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 72f299f015..5c6fb62928 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -16,7 +16,7 @@ #define LLVM_CODEGEN_MACHINEINSTR_H #include "llvm/CodeGen/InstrForest.h" -#include "llvm/Tools/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include "llvm/Support/Unique.h" #include "llvm/CodeGen/TargetMachine.h" diff --git a/include/llvm/CodeGen/TargetMachine.h b/include/llvm/CodeGen/TargetMachine.h index 97bcc54e25..0be7e54baf 100644 --- a/include/llvm/CodeGen/TargetMachine.h +++ b/include/llvm/CodeGen/TargetMachine.h @@ -13,7 +13,7 @@ #define LLVM_CODEGEN_TARGETMACHINE_H #include "llvm/Support/Unique.h" -#include "llvm/Tools/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include class Type; diff --git a/include/llvm/ConstPoolVals.h b/include/llvm/ConstPoolVals.h index a9730c2f8a..a2a5d8a7ff 100644 --- a/include/llvm/ConstPoolVals.h +++ b/include/llvm/ConstPoolVals.h @@ -10,7 +10,7 @@ #include "llvm/User.h" #include "llvm/SymTabValue.h" -#include "llvm/Tools/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include class ArrayType; diff --git a/include/llvm/Support/DataTypes.h b/include/llvm/Support/DataTypes.h new file mode 100644 index 0000000000..84b8a65ab1 --- /dev/null +++ b/include/llvm/Support/DataTypes.h @@ -0,0 +1,25 @@ + +// TODO: This file sucks. Not only does it not work, but this stuff should be +// autoconfiscated anyways. Major FIXME + + +#ifndef LLVM_SUPPORT_DATATYPES_H +#define LLVM_SUPPORT_DATATYPES_H + +// Should define the following: +// LITTLE_ENDIAN if applicable +// int64_t +// uint64_t + +#ifdef LINUX +#include // Defined by ISO C 99 +#include + +#else +#include +#ifdef _LITTLE_ENDIAN +#define LITTLE_ENDIAN 1 +#endif +#endif + +#endif diff --git a/include/llvm/Support/HashExtras.h b/include/llvm/Support/HashExtras.h new file mode 100644 index 0000000000..ecd572e3d9 --- /dev/null +++ b/include/llvm/Support/HashExtras.h @@ -0,0 +1,22 @@ +//===-- HashExtras.h - Useful functions for STL hash containers --*- C++ -*--=// +// +// This file contains some templates that are useful if you are working with the +// STL Hashed containers. +// +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_HASHEXTRAS_H +#define LLVM_SUPPORT_HASHEXTRAS_H + +#include +#include + +template <> struct hash { + size_t operator()(string const &str) const { + return hash()(str.c_str()); + } +}; + +#endif diff --git a/include/llvm/Support/STLExtras.h b/include/llvm/Support/STLExtras.h new file mode 100644 index 0000000000..867e112819 --- /dev/null +++ b/include/llvm/Support/STLExtras.h @@ -0,0 +1,210 @@ +//===-- STLExtras.h - Useful functions when working with the STL -*- C++ -*--=// +// +// This file contains some templates that are useful if you are working with the +// STL at all. +// +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_STL_EXTRAS_H +#define LLVM_SUPPORT_STL_EXTRAS_H + +#include + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// bind_obj - Often times you want to apply the member function of an object +// as a unary functor. This macro is shorthand that makes it happen less +// verbosely. +// +// Example: +// struct Summer { void accumulate(int x); } +// vector Numbers; +// Summer MyS; +// for_each(Numbers.begin(), Numbers.end(), +// bind_obj(&MyS, &Summer::accumulate)); +// +// TODO: When I get lots of extra time, convert this from an evil macro +// +#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ) + + +// bitwise_or - This is a simple functor that applys operator| on its two +// arguments to get a boolean result. +// +template +struct bitwise_or : public binary_function { + bool operator()(const Ty& left, const Ty& right) const { + return left | right; + } +}; + + +// deleter - Very very very simple method that is used to invoke operator +// delete on something. It is used like this: +// +// for_each(V.begin(), B.end(), deleter); +// +template +static inline void deleter(T *Ptr) { + delete Ptr; +} + + + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// mapped_iterator - This is a simple iterator adapter that causes a function to +// be dereferenced whenever operator* is invoked on the iterator. +// +// It turns out that this is disturbingly similar to boost::transform_iterator +// +#if 1 +template +class mapped_iterator { + RootIt current; +public: + typedef typename iterator_traits::iterator_category + iterator_category; + typedef typename iterator_traits::difference_type + difference_type; + typedef typename UnaryFunc::result_type value_type; + typedef typename UnaryFunc::result_type *pointer; + typedef void reference; // Can't modify value returned by fn + + typedef RootIt iterator_type; + typedef mapped_iterator _Self; + + inline RootIt &getCurrent() const { return current; } + + inline explicit mapped_iterator(const RootIt &I) : current(I) {} + inline mapped_iterator(const mapped_iterator &It) : current(It.current) {} + + inline value_type operator*() const { // All this work to do this + return UnaryFunc()(*current); // little change + } + + _Self& operator++() { ++current; return *this; } + _Self& operator--() { --current; return *this; } + _Self operator++(int) { _Self __tmp = *this; ++current; return __tmp; } + _Self operator--(int) { _Self __tmp = *this; --current; return __tmp; } + _Self operator+ (difference_type n) const { return _Self(current + n); } + _Self& operator+= (difference_type n) { current += n; return *this; } + _Self operator- (difference_type n) const { return _Self(current - n); } + _Self& operator-= (difference_type n) { current -= n; return *this; } + reference operator[](difference_type n) const { return *(*this + n); } + + inline bool operator==(const _Self &X) const { return current == X.current; } + inline bool operator< (const _Self &X) const { return current < X.current; } + + inline difference_type operator-(const _Self &X) const { + return current - X.current; + } +}; + +template +inline mapped_iterator<_Iterator, Func> +operator+(typename mapped_iterator<_Iterator, Func>::difference_type N, + const mapped_iterator<_Iterator, Func>& X) { + return mapped_iterator<_Iterator, Func>(X.getCurrent() - N); +} + +#else + +// This fails to work, because some iterators are not classes, for example +// vector iterators are commonly value_type **'s +template +class mapped_iterator : public RootIt { +public: + typedef typename UnaryFunc::result_type value_type; + typedef typename UnaryFunc::result_type *pointer; + typedef void reference; // Can't modify value returned by fn + + typedef mapped_iterator _Self; + typedef RootIt super; + inline explicit mapped_iterator(const RootIt &I) : super(I) {} + inline mapped_iterator(const super &It) : super(It) {} + + inline value_type operator*() const { // All this work to do + return UnaryFunc(super::operator*()); // this little thing + } +}; +#endif + +// map_iterator - Provide a convenient way to create mapped_iterators, just like +// make_pair is useful for creating pairs... +// +template +inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { + return mapped_iterator(I); +} + + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// apply_until - Apply a functor to a sequence continually, unless the +// functor returns true. Return true if the functor returned true, return false +// if the functor never returned true. +// +template +bool apply_until(InputIt First, InputIt Last, Function Func) { + for ( ; First != Last; ++First) + if (Func(*First)) return true; + return false; +} + + +// reduce - Reduce a sequence values into a single value, given an initial +// value and an operator. +// +template +ValueType reduce(InputIt First, InputIt Last, Function Func, ValueType Value) { + for ( ; First != Last; ++First) + Value = Func(*First, Value); + return Value; +} + +#if 1 // This is likely to be more efficient + +// reduce_apply - Reduce the result of applying a function to each value in a +// sequence, given an initial value, an operator, a function, and a sequence. +// +template +inline ValueType reduce_apply(InputIt First, InputIt Last, Function Func, + ValueType Value, TransFunc XForm) { + for ( ; First != Last; ++First) + Value = Func(XForm(*First), Value); + return Value; +} + +#else // This is arguably more elegant + +// reduce_apply - Reduce the result of applying a function to each value in a +// sequence, given an initial value, an operator, a function, and a sequence. +// +template +inline ValueType reduce_apply2(InputIt First, InputIt Last, Function Func, + ValueType Value, TransFunc XForm) { + return reduce(map_iterator(First, XForm), map_iterator(Last, XForm), + Func, Value); +} +#endif + + +// reduce_apply_bool - Reduce the result of applying a (bool returning) function +// to each value in a sequence. All of the bools returned by the mapped +// function are bitwise or'd together, and the result is returned. +// +template +inline bool reduce_apply_bool(InputIt First, InputIt Last, Function Func) { + return reduce_apply(First, Last, bitwise_or(), false, Func); +} + +#endif diff --git a/include/llvm/Support/StringExtras.h b/include/llvm/Support/StringExtras.h new file mode 100644 index 0000000000..585a42ca4c --- /dev/null +++ b/include/llvm/Support/StringExtras.h @@ -0,0 +1,70 @@ +//===-- StringExtras.h - Useful string functions -----------------*- C++ -*--=// +// +// This file contains some functions that are useful when dealing with strings. +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TOOLS_STRING_EXTRAS_H +#define LLVM_TOOLS_STRING_EXTRAS_H + +#include +#include +#include "llvm/Support/DataTypes.h" + +static inline string utostr(uint64_t X, bool isNeg = false) { + char Buffer[40]; + char *BufPtr = Buffer+39; + + *BufPtr = 0; // Null terminate buffer... + if (X == 0) *--BufPtr = '0'; // Handle special case... + + while (X) { + *--BufPtr = '0' + (X % 10); + X /= 10; + } + + if (isNeg) *--BufPtr = '-'; // Add negative sign... + + return string(BufPtr); +} + +static inline string itostr(int64_t X) { + if (X < 0) + return utostr((uint64_t)-X, true); + else + return utostr((uint64_t)X); +} + + +static inline string utostr(unsigned X, bool isNeg = false) { + char Buffer[20]; + char *BufPtr = Buffer+19; + + *BufPtr = 0; // Null terminate buffer... + if (X == 0) *--BufPtr = '0'; // Handle special case... + + while (X) { + *--BufPtr = '0' + (X % 10); + X /= 10; + } + + if (isNeg) *--BufPtr = '-'; // Add negative sign... + + return string(BufPtr); +} + +static inline string itostr(int X) { + if (X < 0) + return utostr((unsigned)-X, true); + else + return utostr((unsigned)X); +} + +static inline string ftostr(double V) { + char Buffer[200]; + snprintf(Buffer, 200, "%f", V); + return Buffer; +} + +#endif diff --git a/include/llvm/Tools/CommandLine.h b/include/llvm/Tools/CommandLine.h deleted file mode 100644 index 35d96d4922..0000000000 --- a/include/llvm/Tools/CommandLine.h +++ /dev/null @@ -1,284 +0,0 @@ -//===-- llvm/Tools/CommandLine.h - Command line parser for tools -*- C++ -*--=// -// -// This class implements a command line argument processor that is useful when -// creating a tool. It provides a simple, minimalistic interface that is easily -// extensible and supports nonlocal (library) command line options. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_COMMANDLINE_H -#define LLVM_TOOLS_COMMANDLINE_H - -#include -#include -#include -#include - -namespace cl { // Short namespace to make usage concise - -//===----------------------------------------------------------------------===// -// ParseCommandLineOptions - Minimalistic command line option processing entry -// -void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0); - - -//===----------------------------------------------------------------------===// -// Global flags permitted to be passed to command line arguments - -enum FlagsOptions { - NoFlags = 0x00, // Marker to make explicit that we have no flags - - // Flags for the number of occurances allowed... - Optional = 0x00, // Zero or One occurance - ZeroOrMore = 0x01, // Zero or more occurances allowed - Required = 0x02, // One occurance required - OneOrMore = 0x03, // One or more occurances required - OccurancesMask = 0x07, - - // Number of arguments to a value expected... - //Optional = 0x00, // The value can oppear... or not - ValueRequired = 0x08, // The value is required to appear! - ValueDisallowed = 0x10, // A value may not be specified (for flags) - ValueMask = 0x18, - - // Control whether -help shows the command line option... - Hidden = 0x20, // -help doesn't -help-hidden does - ReallyHidden = 0x60, // Neither -help nor -help-hidden show this arg - HiddenMask = 0x60, -}; - - -//===----------------------------------------------------------------------===// -// Option Base class -// -class Option { - friend void cl::ParseCommandLineOptions(int &, char **, const char *Overview); - - // handleOccurances - Overriden by subclasses to handle the value passed into - // an argument. Should return true if there was an error processing the - // argument and the program should exit. - // - virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0; - - int NumOccurances; // The number of times specified -public: - const char * const ArgStr; // The argument string itself (ex: "help", "o") - const char * const HelpStr; // The descriptive text message for --help - const int Flags; // Flags for the argument - -protected: - Option(const char *ArgStr, const char *Message, int Flags); - Option(int flags) : ArgStr(""), HelpStr(""), Flags(flags) {} - - // Prints option name followed by message. Always returns true. - bool error(string Message, const char *ArgName = 0); - - // addOccurance - Wrapper around handleOccurance that enforces Flags - // - bool addOccurance(const char *ArgName, const string &Value); - -public: - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; - - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; - -public: - inline int getNumOccurances() const { return NumOccurances; } - virtual ~Option() {} -}; - - -//===----------------------------------------------------------------------===// -// Boolean/flag command line option -// -class Flag : public Option { - bool Value; - virtual bool handleOccurance(const char *ArgName, const string &Arg); -public: - inline Flag(const char *ArgStr, const char *Message, int Flags = 0, - bool DefaultVal = 0) : Option(ArgStr, Message, Flags), - Value(DefaultVal) {} - operator bool() const { return Value; } - inline bool getValue() const { return Value; } - inline void setValue(bool Val) { Value = Val; } -}; - - - -//===----------------------------------------------------------------------===// -// Integer valued command line option -// -class Int : public Option { - int Value; - virtual bool handleOccurance(const char *ArgName, const string &Arg); -public: - inline Int(const char *ArgStr, const char *Help, int Flags = 0, - int DefaultVal = 0) : Option(ArgStr, Help, Flags | ValueRequired), - Value(DefaultVal) {} - inline operator int() const { return Value; } - inline int getValue() const { return Value; } - inline void setValue(int Val) { Value = Val; } -}; - - -//===----------------------------------------------------------------------===// -// String valued command line option -// -class String : public Option { - string Value; - virtual bool handleOccurance(const char *ArgName, const string &Arg); -public: - inline String(const char *ArgStr, const char *Help, int Flags = 0, - const char *DefaultVal = "") - : Option(ArgStr, Help, Flags | ValueRequired), Value(DefaultVal) {} - - inline const string &getValue() const { return Value; } - inline void setValue(const string &Val) { Value = Val; } -}; - - -//===----------------------------------------------------------------------===// -// Enum valued command line option -// -#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, ENUMVAL, DESC -#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, ENUMVAL, DESC - -// EnumBase - Base class for all enum/varargs related argument types... -class EnumBase : public Option { -protected: - // Use a vector instead of a map, because the lists should be short, - // the overhead is less, and most importantly, it keeps them in the order - // inserted so we can print our option out nicely. - vector > > ValueMap; - - inline EnumBase(const char *ArgStr, const char *Help, int Flags) - : Option(ArgStr, Help, Flags) {} - inline EnumBase(int Flags) : Option(Flags) {} - - // processValues - Incorporate the specifed varargs arglist into the - // ValueMap. - // - void processValues(va_list Vals); - - // registerArgs - notify the system about these new arguments - void registerArgs(); - -public: - // Turn an enum into the arg name that activates it - const char *getArgName(int ID) const; - const char *getArgDescription(int ID) const; -}; - -class EnumValueBase : public EnumBase { -protected: - int Value; - inline EnumValueBase(const char *ArgStr, const char *Help, int Flags) - : EnumBase(ArgStr, Help, Flags) {} - inline EnumValueBase(int Flags) : EnumBase(Flags) {} - - // handleOccurance - Set Value to the enum value specified by Arg - virtual bool handleOccurance(const char *ArgName, const string &Arg); - - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; - - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; -}; - -template // The enum we are representing -class Enum : public EnumValueBase { -public: - inline Enum(const char *ArgStr, int Flags, const char *Help, ...) - : EnumValueBase(ArgStr, Help, Flags | ValueRequired) { - va_list Values; - va_start(Values, Help); - processValues(Values); - va_end(Values); - Value = ValueMap.front().second.first; // Grab default value - } - - inline E getValue() const { return (E)Value; } - inline void setValue(E Val) { Value = (E)Val; } -}; - - -//===----------------------------------------------------------------------===// -// Enum flags command line option -// -class EnumFlagsBase : public EnumValueBase { -protected: - virtual bool handleOccurance(const char *ArgName, const string &Arg); - inline EnumFlagsBase(int Flags) : EnumValueBase(Flags | ValueDisallowed) {} - - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; - - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; -}; - -template // The enum we are representing -class EnumFlags : public EnumFlagsBase { -public: - inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - Value = ValueMap.front().second.first; // Grab default value - } - inline E getValue() const { return (E)Value; } - inline void setValue(E Val) { Value = (E)Val; } -}; - - -//===----------------------------------------------------------------------===// -// Enum list command line option -// -class EnumListBase : public EnumBase { -protected: - vector Values; // The options specified so far. - - inline EnumListBase(int Flags) - : EnumBase(Flags | ValueDisallowed | ZeroOrMore) {} - virtual bool handleOccurance(const char *ArgName, const string &Arg); - - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; - - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; -public: - inline unsigned size() { return Values.size(); } -}; - -template // The enum we are representing -class EnumList : public EnumListBase { -public: - inline EnumList(int Flags, ...) : EnumListBase(Flags) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - } - inline E getValue(unsigned i) const { return (E)Values[i]; } - inline E operator[](unsigned i) const { return (E)Values[i]; } -}; - -} // End namespace cl - -#endif diff --git a/include/llvm/Tools/DataTypes.h b/include/llvm/Tools/DataTypes.h deleted file mode 100644 index ada16c24da..0000000000 --- a/include/llvm/Tools/DataTypes.h +++ /dev/null @@ -1,26 +0,0 @@ - -// TODO: This file sucks. Not only does it not work, but this stuff should be -// autoconfiscated anyways. Major FIXME - - -#ifndef LLVM_TOOLS_DATATYPES_H -#define LLVM_TOOLS_DATATYPES_H - -// Should define the following: -// LITTLE_ENDIAN if applicable -// int64_t -// uint64_t - -#ifdef LINUX -#include // Defined by ISO C 99 -#include - -#else -#include -#ifdef _LITTLE_ENDIAN -#define LITTLE_ENDIAN 1 -#endif -#endif - - -#endif diff --git a/include/llvm/Tools/STLExtras.h b/include/llvm/Tools/STLExtras.h deleted file mode 100644 index 933db3a8ff..0000000000 --- a/include/llvm/Tools/STLExtras.h +++ /dev/null @@ -1,210 +0,0 @@ -//===-- STLExtras.h - Useful functions when working with the STL --*- C++ -*--=// -// -// This file contains some templates that are useful if you are working with the -// STL at all. -// -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_STL_EXTRAS_H -#define LLVM_TOOLS_STL_EXTRAS_H - -#include - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// bind_obj - Often times you want to apply the member function of an object -// as a unary functor. This macro is shorthand that makes it happen less -// verbosely. -// -// Example: -// struct Summer { void accumulate(int x); } -// vector Numbers; -// Summer MyS; -// for_each(Numbers.begin(), Numbers.end(), -// bind_obj(&MyS, &Summer::accumulate)); -// -// TODO: When I get lots of extra time, convert this from an evil macro -// -#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ) - - -// bitwise_or - This is a simple functor that applys operator| on its two -// arguments to get a boolean result. -// -template -struct bitwise_or : public binary_function { - bool operator()(const Ty& left, const Ty& right) const { - return left | right; - } -}; - - -// deleter - Very very very simple method that is used to invoke operator -// delete on something. It is used like this: -// -// for_each(V.begin(), B.end(), deleter); -// -template -static inline void deleter(T *Ptr) { - delete Ptr; -} - - - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// mapped_iterator - This is a simple iterator adapter that causes a function to -// be dereferenced whenever operator* is invoked on the iterator. -// -// It turns out that this is disturbingly similar to boost::transform_iterator -// -#if 1 -template -class mapped_iterator { - RootIt current; -public: - typedef typename iterator_traits::iterator_category - iterator_category; - typedef typename iterator_traits::difference_type - difference_type; - typedef typename UnaryFunc::result_type value_type; - typedef typename UnaryFunc::result_type *pointer; - typedef void reference; // Can't modify value returned by fn - - typedef RootIt iterator_type; - typedef mapped_iterator _Self; - - inline RootIt &getCurrent() const { return current; } - - inline explicit mapped_iterator(const RootIt &I) : current(I) {} - inline mapped_iterator(const mapped_iterator &It) : current(It.current) {} - - inline value_type operator*() const { // All this work to do this - return UnaryFunc()(*current); // little change - } - - _Self& operator++() { ++current; return *this; } - _Self& operator--() { --current; return *this; } - _Self operator++(int) { _Self __tmp = *this; ++current; return __tmp; } - _Self operator--(int) { _Self __tmp = *this; --current; return __tmp; } - _Self operator+ (difference_type n) const { return _Self(current + n); } - _Self& operator+= (difference_type n) { current += n; return *this; } - _Self operator- (difference_type n) const { return _Self(current - n); } - _Self& operator-= (difference_type n) { current -= n; return *this; } - reference operator[](difference_type n) const { return *(*this + n); } - - inline bool operator==(const _Self &X) const { return current == X.current; } - inline bool operator< (const _Self &X) const { return current < X.current; } - - inline difference_type operator-(const _Self &X) const { - return current - X.current; - } -}; - -template -inline mapped_iterator<_Iterator, Func> -operator+(typename mapped_iterator<_Iterator, Func>::difference_type N, - const mapped_iterator<_Iterator, Func>& X) { - return mapped_iterator<_Iterator, Func>(X.getCurrent() - N); -} - -#else - -// This fails to work, because some iterators are not classes, for example -// vector iterators are commonly value_type **'s -template -class mapped_iterator : public RootIt { -public: - typedef typename UnaryFunc::result_type value_type; - typedef typename UnaryFunc::result_type *pointer; - typedef void reference; // Can't modify value returned by fn - - typedef mapped_iterator _Self; - typedef RootIt super; - inline explicit mapped_iterator(const RootIt &I) : super(I) {} - inline mapped_iterator(const super &It) : super(It) {} - - inline value_type operator*() const { // All this work to do - return UnaryFunc(super::operator*()); // this little thing - } -}; -#endif - -// map_iterator - Provide a convenient way to create mapped_iterators, just like -// make_pair is useful for creating pairs... -// -template -inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { - return mapped_iterator(I); -} - - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// apply_until - Apply a functor to a sequence continually, unless the -// functor returns true. Return true if the functor returned true, return false -// if the functor never returned true. -// -template -bool apply_until(InputIt First, InputIt Last, Function Func) { - for ( ; First != Last; ++First) - if (Func(*First)) return true; - return false; -} - - -// reduce - Reduce a sequence values into a single value, given an initial -// value and an operator. -// -template -ValueType reduce(InputIt First, InputIt Last, Function Func, ValueType Value) { - for ( ; First != Last; ++First) - Value = Func(*First, Value); - return Value; -} - -#if 1 // This is likely to be more efficient - -// reduce_apply - Reduce the result of applying a function to each value in a -// sequence, given an initial value, an operator, a function, and a sequence. -// -template -inline ValueType reduce_apply(InputIt First, InputIt Last, Function Func, - ValueType Value, TransFunc XForm) { - for ( ; First != Last; ++First) - Value = Func(XForm(*First), Value); - return Value; -} - -#else // This is arguably more elegant - -// reduce_apply - Reduce the result of applying a function to each value in a -// sequence, given an initial value, an operator, a function, and a sequence. -// -template -inline ValueType reduce_apply2(InputIt First, InputIt Last, Function Func, - ValueType Value, TransFunc XForm) { - return reduce(map_iterator(First, XForm), map_iterator(Last, XForm), - Func, Value); -} -#endif - - -// reduce_apply_bool - Reduce the result of applying a (bool returning) function -// to each value in a sequence. All of the bools returned by the mapped -// function are bitwise or'd together, and the result is returned. -// -template -inline bool reduce_apply_bool(InputIt First, InputIt Last, Function Func) { - return reduce_apply(First, Last, bitwise_or(), false, Func); -} - -#endif diff --git a/include/llvm/Tools/StringExtras.h b/include/llvm/Tools/StringExtras.h deleted file mode 100644 index 819da2f054..0000000000 --- a/include/llvm/Tools/StringExtras.h +++ /dev/null @@ -1,70 +0,0 @@ -//===-- StringExtras.h - Useful string functions -----------------*- C++ -*--=// -// -// This file contains some functions that are useful when dealing with strings. -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_STRING_EXTRAS_H -#define LLVM_TOOLS_STRING_EXTRAS_H - -#include -#include -#include "llvm/Tools/DataTypes.h" - -static inline string utostr(uint64_t X, bool isNeg = false) { - char Buffer[40]; - char *BufPtr = Buffer+39; - - *BufPtr = 0; // Null terminate buffer... - if (X == 0) *--BufPtr = '0'; // Handle special case... - - while (X) { - *--BufPtr = '0' + (X % 10); - X /= 10; - } - - if (isNeg) *--BufPtr = '-'; // Add negative sign... - - return string(BufPtr); -} - -static inline string itostr(int64_t X) { - if (X < 0) - return utostr((uint64_t)-X, true); - else - return utostr((uint64_t)X); -} - - -static inline string utostr(unsigned X, bool isNeg = false) { - char Buffer[20]; - char *BufPtr = Buffer+19; - - *BufPtr = 0; // Null terminate buffer... - if (X == 0) *--BufPtr = '0'; // Handle special case... - - while (X) { - *--BufPtr = '0' + (X % 10); - X /= 10; - } - - if (isNeg) *--BufPtr = '-'; // Add negative sign... - - return string(BufPtr); -} - -static inline string itostr(int X) { - if (X < 0) - return utostr((unsigned)-X, true); - else - return utostr((unsigned)X); -} - -static inline string ftostr(double V) { - char Buffer[200]; - snprintf(Buffer, 200, "%f", V); - return Buffer; -} - -#endif diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index bbdcbef65f..4bff950a82 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -6,7 +6,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/IntervalIterator.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" using namespace cfg; diff --git a/lib/Analysis/LoopDepth.cpp b/lib/Analysis/LoopDepth.cpp index ac73fda26f..7518606c89 100644 --- a/lib/Analysis/LoopDepth.cpp +++ b/lib/Analysis/LoopDepth.cpp @@ -7,7 +7,7 @@ #include "llvm/Analysis/LoopDepth.h" #include "llvm/Analysis/IntervalPartition.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include inline void LoopDepthCalculator::AddBB(const BasicBlock *BB) { diff --git a/lib/Analysis/ModuleAnalyzer.cpp b/lib/Analysis/ModuleAnalyzer.cpp index 7f509855d9..45637c9c0a 100644 --- a/lib/Analysis/ModuleAnalyzer.cpp +++ b/lib/Analysis/ModuleAnalyzer.cpp @@ -13,7 +13,7 @@ #include "llvm/BasicBlock.h" #include "llvm/DerivedTypes.h" #include "llvm/ConstPoolVals.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include // processModule - Driver function to call all of my subclasses virtual methods. diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 14ed6c8b81..707b5334a5 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -7,7 +7,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/SimplifyCFG.h" // To get cfg::UnifyAllExitNodes #include "llvm/CFG.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include //===----------------------------------------------------------------------===// diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 5d97bc605d..ae44602614 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -18,7 +18,7 @@ #include "llvm/Method.h" #include "llvm/Type.h" #include "llvm/Assembly/Parser.h" -#include "llvm/Tools/StringExtras.h" +#include "llvm/Support/StringExtras.h" class Module; diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp index 73969e65df..a9b5e8d304 100644 --- a/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/lib/Bytecode/Writer/InstructionWriter.cpp @@ -15,7 +15,6 @@ #include "llvm/BasicBlock.h" #include "llvm/Instruction.h" #include "llvm/DerivedTypes.h" -#include "llvm/Tools/DataTypes.h" #include typedef unsigned char uchar; diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h index be9ccf9667..41f0b4de75 100644 --- a/lib/Bytecode/Writer/WriterInternals.h +++ b/lib/Bytecode/Writer/WriterInternals.h @@ -16,7 +16,7 @@ #include "llvm/Bytecode/Format.h" #include "llvm/Bytecode/Primitives.h" #include "llvm/Analysis/SlotCalculator.h" -#include "llvm/Tools/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include "llvm/Instruction.h" class BytecodeWriter : public ModuleAnalyzer { diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index 0526dda40e..bfeec4412e 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -17,7 +17,7 @@ #include "llvm/iMemory.h" #include "llvm/Instruction.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" enum DebugLev { NoDebugInfo, diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 013c22fe92..7c3f29305e 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Tools/CommandLine.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/STLExtras.h" #include #include #include diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index 0526dda40e..bfeec4412e 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -17,7 +17,7 @@ #include "llvm/iMemory.h" #include "llvm/Instruction.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" enum DebugLev { NoDebugInfo, diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index cb4de3c8ef..f9b9ee3640 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -10,7 +10,7 @@ #include "llvm/Instruction.h" #include "llvm/Type.h" #include "llvm/Analysis/Dominators.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include "llvm/Analysis/Writer.h" #include #include diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 56a6d1e822..515fd00f81 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -23,7 +23,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Optimizations/DCE.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include "llvm/Module.h" #include "llvm/Method.h" #include "llvm/BasicBlock.h" diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 4f88685fc1..42397e0a3a 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -23,7 +23,7 @@ #include "llvm/ConstPoolVals.h" #include "llvm/Analysis/IntervalPartition.h" #include "llvm/Assembly/Writer.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include "llvm/SymbolTable.h" #include "llvm/iOther.h" #include "llvm/CFG.h" diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index a28155260e..f1f8d77d7d 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -25,7 +25,7 @@ #include "llvm/iOther.h" #include "llvm/iMemory.h" #include "llvm/iTerminators.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include "llvm/Assembly/Writer.h" #include #include diff --git a/lib/VMCore/ConstantPool.cpp b/lib/VMCore/ConstantPool.cpp index 092ca61ff1..caa79bb53e 100644 --- a/lib/VMCore/ConstantPool.cpp +++ b/lib/VMCore/ConstantPool.cpp @@ -7,7 +7,7 @@ #define __STDC_LIMIT_MACROS // Get defs for INT64_MAX and friends... #include "llvm/ConstPoolVals.h" #include "llvm/ConstantPool.h" -#include "llvm/Tools/StringExtras.h" // itostr +#include "llvm/Support/StringExtras.h" // itostr #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" #include diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 14ed6c8b81..707b5334a5 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -7,7 +7,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/SimplifyCFG.h" // To get cfg::UnifyAllExitNodes #include "llvm/CFG.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" #include //===----------------------------------------------------------------------===// diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 9d0015f769..618e27b873 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -9,7 +9,7 @@ #include "llvm/BasicBlock.h" #include "llvm/InstrTypes.h" #include "llvm/ValueHolderImpl.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/STLExtras.h" // Instantiate Templates - This ugliness is the price we have to pay // for having a DefHolderImpl.h file seperate from DefHolder.h! :( diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index 07e4b87f02..e054b8850c 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -6,7 +6,7 @@ #include "llvm/SymbolTable.h" #include "llvm/InstrTypes.h" -#include "llvm/Tools/StringExtras.h" +#include "llvm/Support/StringExtras.h" #ifndef NDEBUG #include "llvm/BasicBlock.h" // Required for assertions to work. #include "llvm/Type.h" diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index e28c3d1391..2adba049bc 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -5,7 +5,7 @@ //===----------------------------------------------------------------------===// #include "llvm/DerivedTypes.h" -#include "llvm/Tools/StringExtras.h" +#include "llvm/Support/StringExtras.h" //===----------------------------------------------------------------------===// // Type Class Implementation diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 013c22fe92..7c3f29305e 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Tools/CommandLine.h" -#include "llvm/Tools/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/STLExtras.h" #include #include #include diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 4dc00b2c57..3adef161de 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -16,7 +16,7 @@ #include "llvm/Method.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Assembly/Parser.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Analysis/Writer.h" #include "llvm/Analysis/Dominators.h" diff --git a/tools/as/as.cpp b/tools/as/as.cpp index da05a36f7f..8cb274798d 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -16,7 +16,7 @@ #include "llvm/Assembly/Parser.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", 0, ""); diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index d1f61d70b0..59594763eb 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -21,7 +21,7 @@ #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Method.h" #include "llvm/CFG.h" diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index ab1f532b36..c4370d9e84 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -17,7 +17,7 @@ #include "llvm/Bytecode/Writer.h" #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/Sparc.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" cl::String InputFilename ("", "Input filename", cl::NoFlags, ""); cl::String OutputFilename("o", "Output filename", cl::NoFlags, ""); diff --git a/tools/llvm-as/as.cpp b/tools/llvm-as/as.cpp index da05a36f7f..8cb274798d 100644 --- a/tools/llvm-as/as.cpp +++ b/tools/llvm-as/as.cpp @@ -16,7 +16,7 @@ #include "llvm/Assembly/Parser.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", 0, ""); diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index da05a36f7f..8cb274798d 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -16,7 +16,7 @@ #include "llvm/Assembly/Parser.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", 0, ""); diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp index d1f61d70b0..59594763eb 100644 --- a/tools/llvm-dis/dis.cpp +++ b/tools/llvm-dis/dis.cpp @@ -21,7 +21,7 @@ #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Method.h" #include "llvm/CFG.h" diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index d1f61d70b0..59594763eb 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -21,7 +21,7 @@ #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Method.h" #include "llvm/CFG.h" diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 2b5b069106..3dedd0b10c 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -24,7 +24,7 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Tools/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Optimizations/AllOpts.h" using namespace opt; -- cgit v1.2.3-70-g09d2 From 1e78f36127fb0e405d2cf893e2ce3381300a667b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Jul 2001 19:27:24 +0000 Subject: CommandLine library cleanup. No longer use getValue/setValue, instead, just treat the commandline args as the objects they represent and the "right thing" will happen git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/InstrSelection/InstrSelection.cpp | 6 +-- lib/Support/CommandLine.cpp | 2 +- .../SparcV9/InstrSelection/InstrSelection.cpp | 6 +-- support/lib/Support/CommandLine.cpp | 2 +- tools/analyze/analyze.cpp | 6 +-- tools/as/as.cpp | 32 ++++++++-------- tools/dis/dis.cpp | 34 ++++++++--------- tools/llc/llc.cpp | 43 ++++++++-------------- tools/llvm-as/as.cpp | 32 ++++++++-------- tools/llvm-as/llvm-as.cpp | 32 ++++++++-------- tools/llvm-dis/dis.cpp | 34 ++++++++--------- tools/llvm-dis/llvm-dis.cpp | 34 ++++++++--------- tools/opt/opt.cpp | 10 ++--- 13 files changed, 130 insertions(+), 143 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index bfeec4412e..9cc054ca4d 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -67,7 +67,7 @@ bool SelectInstructionsForMethod(Method* method, TargetMachine &Target) { // Invoke BURM to label each tree node with a state (void) burm_label(basicNode); - if (DebugLevel.getValue() >= DebugBurgTrees) + if (DebugLevel >= DebugBurgTrees) { printcover(basicNode, 1, 0); cerr << "\nCover cost == " << treecost(basicNode, 1, 0) << "\n\n"; @@ -84,7 +84,7 @@ bool SelectInstructionsForMethod(Method* method, TargetMachine &Target) { if (!failed) { - if (DebugLevel.getValue() >= DebugInstTrees) + if (DebugLevel >= DebugInstTrees) { cout << "\n\n*** Instruction trees for method " << (method->hasName()? method->getName() : "") @@ -92,7 +92,7 @@ bool SelectInstructionsForMethod(Method* method, TargetMachine &Target) { instrForest.dump(); } - if (DebugLevel.getValue() > NoDebugInfo) + if (DebugLevel > NoDebugInfo) PrintMachineInstructions(method); } diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 7c3f29305e..c7590aba19 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -189,7 +189,7 @@ bool Int::handleOccurance(const char *ArgName, const string &Arg) { // String valued command line option implementation // bool String::handleOccurance(const char *ArgName, const string &Arg) { - Value = Arg; + *this = Arg; return false; } diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index bfeec4412e..9cc054ca4d 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -67,7 +67,7 @@ bool SelectInstructionsForMethod(Method* method, TargetMachine &Target) { // Invoke BURM to label each tree node with a state (void) burm_label(basicNode); - if (DebugLevel.getValue() >= DebugBurgTrees) + if (DebugLevel >= DebugBurgTrees) { printcover(basicNode, 1, 0); cerr << "\nCover cost == " << treecost(basicNode, 1, 0) << "\n\n"; @@ -84,7 +84,7 @@ bool SelectInstructionsForMethod(Method* method, TargetMachine &Target) { if (!failed) { - if (DebugLevel.getValue() >= DebugInstTrees) + if (DebugLevel >= DebugInstTrees) { cout << "\n\n*** Instruction trees for method " << (method->hasName()? method->getName() : "") @@ -92,7 +92,7 @@ bool SelectInstructionsForMethod(Method* method, TargetMachine &Target) { instrForest.dump(); } - if (DebugLevel.getValue() > NoDebugInfo) + if (DebugLevel > NoDebugInfo) PrintMachineInstructions(method); } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 7c3f29305e..c7590aba19 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -189,7 +189,7 @@ bool Int::handleOccurance(const char *ArgName, const string &Arg) { // String valued command line option implementation // bool String::handleOccurance(const char *ArgName, const string &Arg) { - Value = Arg; + *this = Arg; return false; } diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 3adef161de..3163981248 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -92,7 +92,7 @@ enum Ans { postdomset, postidom, postdomtree, postdomfrontier, }; -cl::String InputFilename ("", "Load file to analyze", 0, "-"); +cl::String InputFilename ("", "Load file to analyze", cl::NoFlags, "-"); cl::Flag Quiet ("q", "Don't print analysis pass names", 0, false); cl::EnumList AnalysesList(cl::NoFlags, clEnumVal(print , "Print each Method"), @@ -132,8 +132,8 @@ struct { int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm analysis printer tool\n"); - Module *C = ParseBytecodeFile(InputFilename.getValue()); - if (!C && !(C = ParseAssemblyFile(InputFilename.getValue()))) { + Module *C = ParseBytecodeFile(InputFilename); + if (!C && !(C = ParseAssemblyFile(InputFilename))) { cerr << "Input file didn't read correctly.\n"; return 1; } diff --git a/tools/as/as.cpp b/tools/as/as.cpp index 8cb274798d..72b63ecfdd 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -19,8 +19,8 @@ #include "llvm/Support/CommandLine.h" cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); -cl::String OutputFilename("o", "Override output filename", 0, ""); -cl::Flag Force ("f", "Overwrite output files", 0, false); +cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); +cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false); cl::Flag DumpAsm ("d", "Print assembly as parsed", cl::Hidden, false); int main(int argc, char **argv) { @@ -29,38 +29,38 @@ int main(int argc, char **argv) { ostream *Out = 0; try { // Parse the file now... - Module *C = ParseAssemblyFile(InputFilename.getValue()); + Module *C = ParseAssemblyFile(InputFilename); if (C == 0) { cerr << "assembly didn't read correctly.\n"; return 1; } - if (DumpAsm.getValue()) + if (DumpAsm) cerr << "Here's the assembly:\n" << C; - if (OutputFilename.getValue() != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + if (OutputFilename != "") { // Specified an output filename? + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } else { - if (InputFilename.getValue() == "-") { - OutputFilename.setValue("-"); + if (InputFilename == "-") { + OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename.getValue(); + string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { // Source ends in .ll - OutputFilename.setValue(string(IFN.begin(), IFN.end()-3)); + OutputFilename = string(IFN.begin(), IFN.end()-3); } else { - OutputFilename.setValue(IFN); // Append a .bc to it + OutputFilename = IFN; // Append a .bc to it } - OutputFilename.setValue(OutputFilename.getValue() + ".bc"); - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + OutputFilename += ".bc"; + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } if (!Out->good()) { - cerr << "Error opening " << OutputFilename.getValue() << "!\n"; + cerr << "Error opening " << OutputFilename << "!\n"; delete C; return 1; } diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 59594763eb..462ad7f7b9 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -35,8 +35,8 @@ enum OutputMode { }; cl::String InputFilename ("", "Load file, print as assembly", 0, "-"); -cl::String OutputFilename("o", "Override output filename", 0, ""); -cl::Flag Force ("f", "Overwrite output files", 0, false); +cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); +cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false); cl::EnumFlags WriteMode(cl::NoFlags, clEnumVal(Default, "Write basic blocks in bytecode order"), clEnumVal(dfo , "Write basic blocks in depth first order"), @@ -49,36 +49,36 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); ostream *Out = &cout; // Default to printing to stdout... - Module *C = ParseBytecodeFile(InputFilename.getValue()); + Module *C = ParseBytecodeFile(InputFilename); if (C == 0) { cerr << "bytecode didn't read correctly.\n"; return 1; } - if (OutputFilename.getValue() != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + if (OutputFilename != "") { // Specified an output filename? + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } else { - if (InputFilename.getValue() == "-") { - OutputFilename.setValue("-"); + if (InputFilename == "-") { + OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename.getValue(); + string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { // Source ends in .bc - OutputFilename.setValue(string(IFN.begin(), IFN.end()-3)); + OutputFilename = string(IFN.begin(), IFN.end()-3); } else { - OutputFilename.setValue(IFN); // Append a .ll to it + OutputFilename = IFN; // Append a .ll to it } - OutputFilename.setValue(OutputFilename.getValue() + ".ll"); - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + OutputFilename += ".ll"; + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } } if (!Out->good()) { - cerr << "Error opening " << OutputFilename.getValue() + cerr << "Error opening " << OutputFilename << ": sending to stdout instead!\n"; Out = &cout; } @@ -86,7 +86,7 @@ int main(int argc, char **argv) { // All that dis does is write the assembly out to a file... which is exactly // what the writer library is supposed to do... // - if (WriteMode.getValue() == Default) { + if (WriteMode == Default) { (*Out) << C; // Print out in list order } else { // TODO: This does not print anything other than the basic blocks in the @@ -97,7 +97,7 @@ int main(int argc, char **argv) { Method *M = *I; (*Out) << "-------------- Method: " << M->getName() << " -------------\n"; - switch (WriteMode.getValue()) { + switch (WriteMode) { case dfo: // Depth First ordering copy(cfg::df_begin(M), cfg::df_end(M), ostream_iterator(*Out, "\n")); diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index c4370d9e84..a3312967d6 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -14,31 +14,25 @@ #include "llvm/Module.h" #include "llvm/Method.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Bytecode/Writer.h" #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/Sparc.h" #include "llvm/Support/CommandLine.h" -cl::String InputFilename ("", "Input filename", cl::NoFlags, ""); +cl::String InputFilename ("", "Input filename", cl::NoFlags, "-"); cl::String OutputFilename("o", "Output filename", cl::NoFlags, ""); -static bool CompileModule(Module *module, TargetMachine &Target) { +static bool CompileModule(Module *M, TargetMachine &Target) { bool failed = false; - for (Module::MethodListType::const_iterator - methodIter = module->getMethodList().begin(); - methodIter != module->getMethodList().end(); - ++methodIter) - { - Method* method = *methodIter; + for (Module::const_iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) { + Method * method = *MI; - if (SelectInstructionsForMethod(method, Target)) - { - failed = true; - cerr << "Instruction selection failed for method " - << method->getName() << "\n\n"; - } + if (SelectInstructionsForMethod(method, Target)) { + failed = true; + cerr << "Instruction selection failed for method " + << method->getName() << "\n\n"; } + } return failed; } @@ -54,24 +48,17 @@ int main(int argc, char** argv) { cl::ParseCommandLineOptions(argc, argv, " llvm system compiler\n"); UltraSparc Target; - Module *module = ParseBytecodeFile(InputFilename.getValue()); + Module *module = ParseBytecodeFile(InputFilename); if (module == 0) { cerr << "bytecode didn't read correctly.\n"; return 1; } - bool failure = CompileModule(module, Target); - - if (failure) { - cerr << "Error compiling " - << InputFilename.getValue() << "!\n"; - delete module; - return 1; - } - - // Okay, we're done now... write out result... - // WriteBytecodeToFile(module, - // OutputFilename.getValue()); + if (CompileModule(module, Target)) { + cerr << "Error compiling " << InputFilename << "!\n"; + delete module; + return 1; + } // Clean up and exit delete module; diff --git a/tools/llvm-as/as.cpp b/tools/llvm-as/as.cpp index 8cb274798d..72b63ecfdd 100644 --- a/tools/llvm-as/as.cpp +++ b/tools/llvm-as/as.cpp @@ -19,8 +19,8 @@ #include "llvm/Support/CommandLine.h" cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); -cl::String OutputFilename("o", "Override output filename", 0, ""); -cl::Flag Force ("f", "Overwrite output files", 0, false); +cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); +cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false); cl::Flag DumpAsm ("d", "Print assembly as parsed", cl::Hidden, false); int main(int argc, char **argv) { @@ -29,38 +29,38 @@ int main(int argc, char **argv) { ostream *Out = 0; try { // Parse the file now... - Module *C = ParseAssemblyFile(InputFilename.getValue()); + Module *C = ParseAssemblyFile(InputFilename); if (C == 0) { cerr << "assembly didn't read correctly.\n"; return 1; } - if (DumpAsm.getValue()) + if (DumpAsm) cerr << "Here's the assembly:\n" << C; - if (OutputFilename.getValue() != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + if (OutputFilename != "") { // Specified an output filename? + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } else { - if (InputFilename.getValue() == "-") { - OutputFilename.setValue("-"); + if (InputFilename == "-") { + OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename.getValue(); + string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { // Source ends in .ll - OutputFilename.setValue(string(IFN.begin(), IFN.end()-3)); + OutputFilename = string(IFN.begin(), IFN.end()-3); } else { - OutputFilename.setValue(IFN); // Append a .bc to it + OutputFilename = IFN; // Append a .bc to it } - OutputFilename.setValue(OutputFilename.getValue() + ".bc"); - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + OutputFilename += ".bc"; + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } if (!Out->good()) { - cerr << "Error opening " << OutputFilename.getValue() << "!\n"; + cerr << "Error opening " << OutputFilename << "!\n"; delete C; return 1; } diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index 8cb274798d..72b63ecfdd 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -19,8 +19,8 @@ #include "llvm/Support/CommandLine.h" cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); -cl::String OutputFilename("o", "Override output filename", 0, ""); -cl::Flag Force ("f", "Overwrite output files", 0, false); +cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); +cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false); cl::Flag DumpAsm ("d", "Print assembly as parsed", cl::Hidden, false); int main(int argc, char **argv) { @@ -29,38 +29,38 @@ int main(int argc, char **argv) { ostream *Out = 0; try { // Parse the file now... - Module *C = ParseAssemblyFile(InputFilename.getValue()); + Module *C = ParseAssemblyFile(InputFilename); if (C == 0) { cerr << "assembly didn't read correctly.\n"; return 1; } - if (DumpAsm.getValue()) + if (DumpAsm) cerr << "Here's the assembly:\n" << C; - if (OutputFilename.getValue() != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + if (OutputFilename != "") { // Specified an output filename? + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } else { - if (InputFilename.getValue() == "-") { - OutputFilename.setValue("-"); + if (InputFilename == "-") { + OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename.getValue(); + string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { // Source ends in .ll - OutputFilename.setValue(string(IFN.begin(), IFN.end()-3)); + OutputFilename = string(IFN.begin(), IFN.end()-3); } else { - OutputFilename.setValue(IFN); // Append a .bc to it + OutputFilename = IFN; // Append a .bc to it } - OutputFilename.setValue(OutputFilename.getValue() + ".bc"); - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + OutputFilename += ".bc"; + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } if (!Out->good()) { - cerr << "Error opening " << OutputFilename.getValue() << "!\n"; + cerr << "Error opening " << OutputFilename << "!\n"; delete C; return 1; } diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp index 59594763eb..462ad7f7b9 100644 --- a/tools/llvm-dis/dis.cpp +++ b/tools/llvm-dis/dis.cpp @@ -35,8 +35,8 @@ enum OutputMode { }; cl::String InputFilename ("", "Load file, print as assembly", 0, "-"); -cl::String OutputFilename("o", "Override output filename", 0, ""); -cl::Flag Force ("f", "Overwrite output files", 0, false); +cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); +cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false); cl::EnumFlags WriteMode(cl::NoFlags, clEnumVal(Default, "Write basic blocks in bytecode order"), clEnumVal(dfo , "Write basic blocks in depth first order"), @@ -49,36 +49,36 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); ostream *Out = &cout; // Default to printing to stdout... - Module *C = ParseBytecodeFile(InputFilename.getValue()); + Module *C = ParseBytecodeFile(InputFilename); if (C == 0) { cerr << "bytecode didn't read correctly.\n"; return 1; } - if (OutputFilename.getValue() != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + if (OutputFilename != "") { // Specified an output filename? + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } else { - if (InputFilename.getValue() == "-") { - OutputFilename.setValue("-"); + if (InputFilename == "-") { + OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename.getValue(); + string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { // Source ends in .bc - OutputFilename.setValue(string(IFN.begin(), IFN.end()-3)); + OutputFilename = string(IFN.begin(), IFN.end()-3); } else { - OutputFilename.setValue(IFN); // Append a .ll to it + OutputFilename = IFN; // Append a .ll to it } - OutputFilename.setValue(OutputFilename.getValue() + ".ll"); - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + OutputFilename += ".ll"; + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } } if (!Out->good()) { - cerr << "Error opening " << OutputFilename.getValue() + cerr << "Error opening " << OutputFilename << ": sending to stdout instead!\n"; Out = &cout; } @@ -86,7 +86,7 @@ int main(int argc, char **argv) { // All that dis does is write the assembly out to a file... which is exactly // what the writer library is supposed to do... // - if (WriteMode.getValue() == Default) { + if (WriteMode == Default) { (*Out) << C; // Print out in list order } else { // TODO: This does not print anything other than the basic blocks in the @@ -97,7 +97,7 @@ int main(int argc, char **argv) { Method *M = *I; (*Out) << "-------------- Method: " << M->getName() << " -------------\n"; - switch (WriteMode.getValue()) { + switch (WriteMode) { case dfo: // Depth First ordering copy(cfg::df_begin(M), cfg::df_end(M), ostream_iterator(*Out, "\n")); diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 59594763eb..462ad7f7b9 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -35,8 +35,8 @@ enum OutputMode { }; cl::String InputFilename ("", "Load file, print as assembly", 0, "-"); -cl::String OutputFilename("o", "Override output filename", 0, ""); -cl::Flag Force ("f", "Overwrite output files", 0, false); +cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); +cl::Flag Force ("f", "Overwrite output files", cl::NoFlags, false); cl::EnumFlags WriteMode(cl::NoFlags, clEnumVal(Default, "Write basic blocks in bytecode order"), clEnumVal(dfo , "Write basic blocks in depth first order"), @@ -49,36 +49,36 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); ostream *Out = &cout; // Default to printing to stdout... - Module *C = ParseBytecodeFile(InputFilename.getValue()); + Module *C = ParseBytecodeFile(InputFilename); if (C == 0) { cerr << "bytecode didn't read correctly.\n"; return 1; } - if (OutputFilename.getValue() != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + if (OutputFilename != "") { // Specified an output filename? + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } else { - if (InputFilename.getValue() == "-") { - OutputFilename.setValue("-"); + if (InputFilename == "-") { + OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename.getValue(); + string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { // Source ends in .bc - OutputFilename.setValue(string(IFN.begin(), IFN.end()-3)); + OutputFilename = string(IFN.begin(), IFN.end()-3); } else { - OutputFilename.setValue(IFN); // Append a .ll to it + OutputFilename = IFN; // Append a .ll to it } - OutputFilename.setValue(OutputFilename.getValue() + ".ll"); - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + OutputFilename += ".ll"; + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); } } if (!Out->good()) { - cerr << "Error opening " << OutputFilename.getValue() + cerr << "Error opening " << OutputFilename << ": sending to stdout instead!\n"; Out = &cout; } @@ -86,7 +86,7 @@ int main(int argc, char **argv) { // All that dis does is write the assembly out to a file... which is exactly // what the writer library is supposed to do... // - if (WriteMode.getValue() == Default) { + if (WriteMode == Default) { (*Out) << C; // Print out in list order } else { // TODO: This does not print anything other than the basic blocks in the @@ -97,7 +97,7 @@ int main(int argc, char **argv) { Method *M = *I; (*Out) << "-------------- Method: " << M->getName() << " -------------\n"; - switch (WriteMode.getValue()) { + switch (WriteMode) { case dfo: // Depth First ordering copy(cfg::df_begin(M), cfg::df_end(M), ostream_iterator(*Out, "\n")); diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 3dedd0b10c..0dc94f5bdd 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -75,7 +75,7 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .bc modular optimizer\n"); - Module *C = ParseBytecodeFile(InputFilename.getValue()); + Module *C = ParseBytecodeFile(InputFilename); if (C == 0) { cerr << "bytecode didn't read correctly.\n"; return 1; @@ -99,11 +99,11 @@ int main(int argc, char **argv) { } ostream *Out = &cout; // Default to printing to stdout... - if (OutputFilename.getValue() != "") { - Out = new ofstream(OutputFilename.getValue().c_str(), - (Force.getValue() ? 0 : ios::noreplace)|ios::out); + if (OutputFilename != "") { + Out = new ofstream(OutputFilename.c_str(), + (Force ? 0 : ios::noreplace)|ios::out); if (!Out->good()) { - cerr << "Error opening " << OutputFilename.getValue() << "!\n"; + cerr << "Error opening " << OutputFilename << "!\n"; delete C; return 1; } -- cgit v1.2.3-70-g09d2 From dc4693dbcf164ec404a3a91c67cf1dbe5f45a8e5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Jul 2001 23:02:45 +0000 Subject: Minor changes to implementation of CommandLine library to let users override options forced by different subclasses of Option git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 26 +++++++++++++++++++------- support/lib/Support/CommandLine.cpp | 26 +++++++++++++++++++------- 2 files changed, 38 insertions(+), 14 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index c7590aba19..c3de975801 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -73,7 +73,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } // Enforce value requirements - switch (Handler->Flags & ValueMask) { + switch (Handler->getValueExpectedFlag()) { case ValueRequired: if (Value == 0 || *Value == 0) { // No value specified? if (i+1 < argc) { // Steal the next argument, like for '-o filename' @@ -99,7 +99,19 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ErrorParsing |= Handler->addOccurance(ArgName, Value); } - // TODO: loop over args and make sure all required args are specified! + // Loop over args and make sure all required args are specified! + for (map::iterator I = getOpts().begin(), + E = getOpts().end(); I != E; ++I) { + switch (I->second->getNumOccurancesFlag()) { + case Required: + case OneOrMore: + if (I->second->getNumOccurances() == 0) + I->second->error(" must be specified at least once!"); + // Fall through + default: + break; + } + } // Free all of the memory allocated to the vector. Command line options may // only be processed once! @@ -113,7 +125,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // Option::Option(const char *argStr, const char *helpStr, int flags) - : NumOccurances(0), ArgStr(argStr), HelpStr(helpStr), Flags(flags) { + : NumOccurances(0), Flags(flags), ArgStr(argStr), HelpStr(helpStr) { AddArgument(ArgStr, this); } @@ -126,7 +138,7 @@ bool Option::error(string Message, const char *ArgName = 0) { bool Option::addOccurance(const char *ArgName, const string &Value) { NumOccurances++; // Increment the number of times we have been seen - switch (Flags & OccurancesMask) { + switch (getNumOccurancesFlag()) { case Optional: if (NumOccurances > 1) return error(": may only occur zero or one times!", ArgName); @@ -325,10 +337,10 @@ namespace { // isHidden/isReallyHidden - Predicates to be used to filter down arg lists. inline bool isHidden(pair &OptPair) { - return (OptPair.second->Flags & HiddenMask) == Hidden; + return OptPair.second->getOptionHiddenFlag() >= Hidden; } inline bool isReallyHidden(pair &OptPair) { - return (OptPair.second->Flags & HiddenMask) == ReallyHidden; + return OptPair.second->getOptionHiddenFlag() == ReallyHidden; } class Help : public Option { @@ -393,7 +405,7 @@ public: }; Help HelpOp("help", "display available options" - " (-help-hidden for more)", false); + " (--help-hidden for more)", false); Help HelpHiddenOpt("help-hidden", "display all available options", true); } // End anonymous namespace diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index c7590aba19..c3de975801 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -73,7 +73,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } // Enforce value requirements - switch (Handler->Flags & ValueMask) { + switch (Handler->getValueExpectedFlag()) { case ValueRequired: if (Value == 0 || *Value == 0) { // No value specified? if (i+1 < argc) { // Steal the next argument, like for '-o filename' @@ -99,7 +99,19 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ErrorParsing |= Handler->addOccurance(ArgName, Value); } - // TODO: loop over args and make sure all required args are specified! + // Loop over args and make sure all required args are specified! + for (map::iterator I = getOpts().begin(), + E = getOpts().end(); I != E; ++I) { + switch (I->second->getNumOccurancesFlag()) { + case Required: + case OneOrMore: + if (I->second->getNumOccurances() == 0) + I->second->error(" must be specified at least once!"); + // Fall through + default: + break; + } + } // Free all of the memory allocated to the vector. Command line options may // only be processed once! @@ -113,7 +125,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // Option::Option(const char *argStr, const char *helpStr, int flags) - : NumOccurances(0), ArgStr(argStr), HelpStr(helpStr), Flags(flags) { + : NumOccurances(0), Flags(flags), ArgStr(argStr), HelpStr(helpStr) { AddArgument(ArgStr, this); } @@ -126,7 +138,7 @@ bool Option::error(string Message, const char *ArgName = 0) { bool Option::addOccurance(const char *ArgName, const string &Value) { NumOccurances++; // Increment the number of times we have been seen - switch (Flags & OccurancesMask) { + switch (getNumOccurancesFlag()) { case Optional: if (NumOccurances > 1) return error(": may only occur zero or one times!", ArgName); @@ -325,10 +337,10 @@ namespace { // isHidden/isReallyHidden - Predicates to be used to filter down arg lists. inline bool isHidden(pair &OptPair) { - return (OptPair.second->Flags & HiddenMask) == Hidden; + return OptPair.second->getOptionHiddenFlag() >= Hidden; } inline bool isReallyHidden(pair &OptPair) { - return (OptPair.second->Flags & HiddenMask) == ReallyHidden; + return OptPair.second->getOptionHiddenFlag() == ReallyHidden; } class Help : public Option { @@ -393,7 +405,7 @@ public: }; Help HelpOp("help", "display available options" - " (-help-hidden for more)", false); + " (--help-hidden for more)", false); Help HelpHiddenOpt("help-hidden", "display all available options", true); } // End anonymous namespace -- cgit v1.2.3-70-g09d2 From 03fe1bd149b21855098e9cc9f959c8e8ca80693c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Jul 2001 23:04:07 +0000 Subject: Add a comment indicating that there is documentation of the library git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 3 +++ support/lib/Support/CommandLine.cpp | 3 +++ 2 files changed, 6 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index c3de975801..a28b86f551 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -4,6 +4,9 @@ // creating a tool. It provides a simple, minimalistic interface that is easily // extensible and supports nonlocal (library) command line options. // +// Note that rather than trying to figure out what this code does, you could try +// reading the library documentation located in docs/CommandLine.html +// //===----------------------------------------------------------------------===// #include "llvm/Support/CommandLine.h" diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index c3de975801..a28b86f551 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -4,6 +4,9 @@ // creating a tool. It provides a simple, minimalistic interface that is easily // extensible and supports nonlocal (library) command line options. // +// Note that rather than trying to figure out what this code does, you could try +// reading the library documentation located in docs/CommandLine.html +// //===----------------------------------------------------------------------===// #include "llvm/Support/CommandLine.h" -- cgit v1.2.3-70-g09d2 From 2233a07b686ead865b0bfeed5a50d178d05f9549 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 23 Jul 2001 23:14:23 +0000 Subject: Doh! Wrong Optional flag. :( git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 5 +++-- support/lib/Support/CommandLine.cpp | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index a28b86f551..db2c3f373f 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -94,8 +94,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, continue; } break; - case Optional: break; - default: cerr << "Bad ValueMask flag! CommandLine usage error!\n"; abort(); + case ValueOptional: break; + default: cerr << "Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << endl; abort(); } // Run the handler now! diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index a28b86f551..db2c3f373f 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -94,8 +94,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, continue; } break; - case Optional: break; - default: cerr << "Bad ValueMask flag! CommandLine usage error!\n"; abort(); + case ValueOptional: break; + default: cerr << "Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << endl; abort(); } // Run the handler now! -- cgit v1.2.3-70-g09d2 From 3805e4ccfa6b908c5035256ea6ee51e219f029db Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 25 Jul 2001 18:40:49 +0000 Subject: Fixed a bug exposed when doing something like this: -notanoption --help git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 8 +++++--- support/lib/Support/CommandLine.cpp | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index db2c3f373f..0584590688 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -49,7 +49,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Value = ""; const char *ArgName = ""; if (argv[i][0] != '-') { // Unnamed argument? - Handler = getOpts()[""]; + map::iterator I = getOpts().find(""); + Handler = I != getOpts().end() ? I->second : 0; Value = argv[i]; } else { // We start with a - or --, eat dashes ArgName = argv[i]+1; @@ -63,8 +64,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ++Value; // Advance to value... if (*ArgName != 0) { - string ArgNameStr(ArgName, ArgNameEnd); // Extract arg name part - Handler = getOpts()[ArgNameStr]; + // Extract arg name part + map::iterator I = getOpts().find(string(ArgName, ArgNameEnd)); + Handler = I != getOpts().end() ? I->second : 0; } } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index db2c3f373f..0584590688 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -49,7 +49,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Value = ""; const char *ArgName = ""; if (argv[i][0] != '-') { // Unnamed argument? - Handler = getOpts()[""]; + map::iterator I = getOpts().find(""); + Handler = I != getOpts().end() ? I->second : 0; Value = argv[i]; } else { // We start with a - or --, eat dashes ArgName = argv[i]+1; @@ -63,8 +64,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ++Value; // Advance to value... if (*ArgName != 0) { - string ArgNameStr(ArgName, ArgNameEnd); // Extract arg name part - Handler = getOpts()[ArgNameStr]; + // Extract arg name part + map::iterator I = getOpts().find(string(ArgName, ArgNameEnd)); + Handler = I != getOpts().end() ? I->second : 0; } } -- cgit v1.2.3-70-g09d2 From d215fd1f5610033fbe704c975805790530262d26 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 13 Oct 2001 06:53:19 +0000 Subject: Add StringList support git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@766 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 11 ++++++++++- support/lib/Support/CommandLine.cpp | 11 ++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 0584590688..76d9e3690a 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -185,7 +185,8 @@ bool Flag::handleOccurance(const char *ArgName, const string &Arg) { } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") { Value = false; } else { - return error(": '" + Arg + "' is invalid value for boolean argument! Try 0 or 1"); + return error(": '" + Arg + + "' is invalid value for boolean argument! Try 0 or 1"); } return false; @@ -211,6 +212,14 @@ bool String::handleOccurance(const char *ArgName, const string &Arg) { return false; } +//===----------------------------------------------------------------------===// +// StringList valued command line option implementation +// +bool StringList::handleOccurance(const char *ArgName, const string &Arg) { + Values.push_back(Arg); + return false; +} + //===----------------------------------------------------------------------===// // Enum valued command line option implementation // diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 0584590688..76d9e3690a 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -185,7 +185,8 @@ bool Flag::handleOccurance(const char *ArgName, const string &Arg) { } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") { Value = false; } else { - return error(": '" + Arg + "' is invalid value for boolean argument! Try 0 or 1"); + return error(": '" + Arg + + "' is invalid value for boolean argument! Try 0 or 1"); } return false; @@ -211,6 +212,14 @@ bool String::handleOccurance(const char *ArgName, const string &Arg) { return false; } +//===----------------------------------------------------------------------===// +// StringList valued command line option implementation +// +bool StringList::handleOccurance(const char *ArgName, const string &Arg) { + Values.push_back(Arg); + return false; +} + //===----------------------------------------------------------------------===// // Enum valued command line option implementation // -- cgit v1.2.3-70-g09d2 From f038acbee21cfed998451aedd00a81901d299516 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 24 Oct 2001 06:21:56 +0000 Subject: Clean up error handling a bit. Add / as a seperator for command line arguments. This is just a big old ugly hack. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@974 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 9 ++++++--- support/lib/Support/CommandLine.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 76d9e3690a..07220a6bf9 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -57,7 +57,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, while (*ArgName == '-') ++ArgName; // Eat leading dashes const char *ArgNameEnd = ArgName; - while (*ArgNameEnd && *ArgNameEnd != '=') ++ArgNameEnd; // Scan till end + while (*ArgNameEnd && *ArgNameEnd != '=' && + *ArgNameEnd != '/') ++ArgNameEnd; // Scan till end Value = ArgNameEnd; if (*Value) // If we have an equals sign... @@ -72,7 +73,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (Handler == 0) { cerr << "Unknown command line argument '" << argv[i] << "'. Try: " - << argv[0] << " --help\n'"; + << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -111,8 +112,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, switch (I->second->getNumOccurancesFlag()) { case Required: case OneOrMore: - if (I->second->getNumOccurances() == 0) + if (I->second->getNumOccurances() == 0) { I->second->error(" must be specified at least once!"); + ErrorParsing = true; + } // Fall through default: break; diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 76d9e3690a..07220a6bf9 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -57,7 +57,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, while (*ArgName == '-') ++ArgName; // Eat leading dashes const char *ArgNameEnd = ArgName; - while (*ArgNameEnd && *ArgNameEnd != '=') ++ArgNameEnd; // Scan till end + while (*ArgNameEnd && *ArgNameEnd != '=' && + *ArgNameEnd != '/') ++ArgNameEnd; // Scan till end Value = ArgNameEnd; if (*Value) // If we have an equals sign... @@ -72,7 +73,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (Handler == 0) { cerr << "Unknown command line argument '" << argv[i] << "'. Try: " - << argv[0] << " --help\n'"; + << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -111,8 +112,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, switch (I->second->getNumOccurancesFlag()) { case Required: case OneOrMore: - if (I->second->getNumOccurances() == 0) + if (I->second->getNumOccurances() == 0) { I->second->error(" must be specified at least once!"); + ErrorParsing = true; + } // Fall through default: break; -- cgit v1.2.3-70-g09d2 From caccd761a6320d9068a44198b9e1b6c3659f8bb5 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 27 Oct 2001 05:54:17 +0000 Subject: Provide option to enable eating of all arguments following a specific one git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@986 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 69 ++++++++++++++++++++++--------------- support/lib/Support/CommandLine.cpp | 69 ++++++++++++++++++++++--------------- 2 files changed, 82 insertions(+), 56 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 07220a6bf9..84dd26dff9 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -37,6 +37,35 @@ static void AddArgument(const string &ArgName, Option *Opt) { static const char *ProgramName = 0; static const char *ProgramOverview = 0; +static inline bool ProvideOption(Option *Handler, const char *ArgName, + const char *Value, int argc, char **argv, + int &i) { + // Enforce value requirements + switch (Handler->getValueExpectedFlag()) { + case ValueRequired: + if (Value == 0 || *Value == 0) { // No value specified? + if (i+1 < argc) { // Steal the next argument, like for '-o filename' + Value = argv[++i]; + } else { + return Handler->error(" requires a value!"); + } + } + break; + case ValueDisallowed: + if (*Value != 0) + return Handler->error(" does not allow a value! '" + + string(Value) + "' specified."); + break; + case ValueOptional: break; + default: cerr << "Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << endl; abort(); + } + + // Run the handler now! + return Handler->addOccurance(ArgName, Value); +} + + void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview = 0) { ProgramName = argv[0]; // Save this away safe and snug @@ -59,6 +88,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *ArgNameEnd = ArgName; while (*ArgNameEnd && *ArgNameEnd != '=' && *ArgNameEnd != '/') ++ArgNameEnd; // Scan till end + // TODO: Remove '/' case. Implement single letter args properly! Value = ArgNameEnd; if (*Value) // If we have an equals sign... @@ -66,7 +96,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (*ArgName != 0) { // Extract arg name part - map::iterator I = getOpts().find(string(ArgName, ArgNameEnd)); + map::iterator I = + getOpts().find(string(ArgName, ArgNameEnd)); Handler = I != getOpts().end() ? I->second : 0; } } @@ -78,32 +109,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, continue; } - // Enforce value requirements - switch (Handler->getValueExpectedFlag()) { - case ValueRequired: - if (Value == 0 || *Value == 0) { // No value specified? - if (i+1 < argc) { // Steal the next argument, like for '-o filename' - Value = argv[++i]; - } else { - ErrorParsing = Handler->error(" requires a value!"); - continue; - } - } - break; - case ValueDisallowed: - if (*Value != 0) { - ErrorParsing = Handler->error(" does not allow a value! '" + - string(Value) + "' specified."); - continue; - } - break; - case ValueOptional: break; - default: cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << endl; abort(); - } + ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); - // Run the handler now! - ErrorParsing |= Handler->addOccurance(ArgName, Value); + // If this option should consume all arguments that come after it... + if (Handler->getNumOccurancesFlag() == ConsumeAfter) { + for (++i; i < argc; ++i) + ErrorParsing |= ProvideOption(Handler, ArgName, argv[i], argc, argv, i); + } } // Loop over args and make sure all required args are specified! @@ -157,7 +169,8 @@ bool Option::addOccurance(const char *ArgName, const string &Value) { return error(": must occur exactly one time!", ArgName); // Fall through case OneOrMore: - case ZeroOrMore: break; + case ZeroOrMore: + case ConsumeAfter: break; default: return error(": bad num occurances flag value!"); } @@ -219,7 +232,7 @@ bool String::handleOccurance(const char *ArgName, const string &Arg) { // StringList valued command line option implementation // bool StringList::handleOccurance(const char *ArgName, const string &Arg) { - Values.push_back(Arg); + push_back(Arg); return false; } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 07220a6bf9..84dd26dff9 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -37,6 +37,35 @@ static void AddArgument(const string &ArgName, Option *Opt) { static const char *ProgramName = 0; static const char *ProgramOverview = 0; +static inline bool ProvideOption(Option *Handler, const char *ArgName, + const char *Value, int argc, char **argv, + int &i) { + // Enforce value requirements + switch (Handler->getValueExpectedFlag()) { + case ValueRequired: + if (Value == 0 || *Value == 0) { // No value specified? + if (i+1 < argc) { // Steal the next argument, like for '-o filename' + Value = argv[++i]; + } else { + return Handler->error(" requires a value!"); + } + } + break; + case ValueDisallowed: + if (*Value != 0) + return Handler->error(" does not allow a value! '" + + string(Value) + "' specified."); + break; + case ValueOptional: break; + default: cerr << "Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << endl; abort(); + } + + // Run the handler now! + return Handler->addOccurance(ArgName, Value); +} + + void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview = 0) { ProgramName = argv[0]; // Save this away safe and snug @@ -59,6 +88,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *ArgNameEnd = ArgName; while (*ArgNameEnd && *ArgNameEnd != '=' && *ArgNameEnd != '/') ++ArgNameEnd; // Scan till end + // TODO: Remove '/' case. Implement single letter args properly! Value = ArgNameEnd; if (*Value) // If we have an equals sign... @@ -66,7 +96,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (*ArgName != 0) { // Extract arg name part - map::iterator I = getOpts().find(string(ArgName, ArgNameEnd)); + map::iterator I = + getOpts().find(string(ArgName, ArgNameEnd)); Handler = I != getOpts().end() ? I->second : 0; } } @@ -78,32 +109,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, continue; } - // Enforce value requirements - switch (Handler->getValueExpectedFlag()) { - case ValueRequired: - if (Value == 0 || *Value == 0) { // No value specified? - if (i+1 < argc) { // Steal the next argument, like for '-o filename' - Value = argv[++i]; - } else { - ErrorParsing = Handler->error(" requires a value!"); - continue; - } - } - break; - case ValueDisallowed: - if (*Value != 0) { - ErrorParsing = Handler->error(" does not allow a value! '" + - string(Value) + "' specified."); - continue; - } - break; - case ValueOptional: break; - default: cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << endl; abort(); - } + ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); - // Run the handler now! - ErrorParsing |= Handler->addOccurance(ArgName, Value); + // If this option should consume all arguments that come after it... + if (Handler->getNumOccurancesFlag() == ConsumeAfter) { + for (++i; i < argc; ++i) + ErrorParsing |= ProvideOption(Handler, ArgName, argv[i], argc, argv, i); + } } // Loop over args and make sure all required args are specified! @@ -157,7 +169,8 @@ bool Option::addOccurance(const char *ArgName, const string &Value) { return error(": must occur exactly one time!", ArgName); // Fall through case OneOrMore: - case ZeroOrMore: break; + case ZeroOrMore: + case ConsumeAfter: break; default: return error(": bad num occurances flag value!"); } @@ -219,7 +232,7 @@ bool String::handleOccurance(const char *ArgName, const string &Arg) { // StringList valued command line option implementation // bool StringList::handleOccurance(const char *ArgName, const string &Arg) { - Values.push_back(Arg); + push_back(Arg); return false; } -- cgit v1.2.3-70-g09d2 From f78032fe064bdd2b9a19b875261747b7d0a27a73 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 26 Nov 2001 18:58:34 +0000 Subject: * Implement support for folding multiple single letter arguments together like with ls: ls -la === ls -l -a * Implement support for trimming arguments that start with a single letter argument so that -lfoo is recognized as -l foo for the linker git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1378 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 74 +++++++++++++++++++++++++++++++++---- support/lib/Support/CommandLine.cpp | 74 +++++++++++++++++++++++++++++++++---- 2 files changed, 132 insertions(+), 16 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 84dd26dff9..bc337ee8b5 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -18,7 +18,7 @@ using namespace cl; // Return the global command line option vector. Making it a function scoped -// static ensures that it will be initialized before its first use correctly. +// static ensures that it will be initialized correctly before its first use. // static map &getOpts() { static map CommandLineOptions; @@ -30,7 +30,8 @@ static void AddArgument(const string &ArgName, Option *Opt) { cerr << "CommandLine Error: Argument '" << ArgName << "' specified more than once!\n"; } else { - getOpts()[ArgName] = Opt; // Add argument to the argument map! + // Add argument to the argument map! + getOpts().insert(make_pair(ArgName, Opt)); } } @@ -65,9 +66,29 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->addOccurance(ArgName, Value); } +// ValueGroupedArgs - Return true if the specified string is valid as a group +// of single letter arguments stuck together like the 'ls -la' case. +// +static inline bool ValidGroupedArgs(string Args) { + for (unsigned i = 0; i < Args.size(); ++i) { + map::iterator I = getOpts().find(string(1, Args[i])); + if (I == getOpts().end()) return false; // Make sure option exists + + // Grouped arguments have no value specified, make sure that if this option + // exists that it can accept no argument. + // + switch (I->second->getValueExpectedFlag()) { + case ValueDisallowed: + case ValueOptional: break; + default: return false; + } + } + + return true; +} void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0) { + const char *Overview = 0, int Flags = 0) { ProgramName = argv[0]; // Save this away safe and snug ProgramOverview = Overview; bool ErrorParsing = false; @@ -86,18 +107,55 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, while (*ArgName == '-') ++ArgName; // Eat leading dashes const char *ArgNameEnd = ArgName; - while (*ArgNameEnd && *ArgNameEnd != '=' && - *ArgNameEnd != '/') ++ArgNameEnd; // Scan till end - // TODO: Remove '/' case. Implement single letter args properly! + while (*ArgNameEnd && *ArgNameEnd != '=') + ++ArgNameEnd; // Scan till end of argument name... Value = ArgNameEnd; if (*Value) // If we have an equals sign... ++Value; // Advance to value... if (*ArgName != 0) { + string RealName(ArgName, ArgNameEnd); // Extract arg name part - map::iterator I = - getOpts().find(string(ArgName, ArgNameEnd)); + map::iterator I = getOpts().find(RealName); + + if (I == getOpts().end() && !*Value && RealName.size() > 1) { + // If grouping of single letter arguments is enabled, see if this is a + // legal grouping... + // + if (!(Flags & DisableSingleLetterArgGrouping) && + ValidGroupedArgs(RealName)) { + + for (unsigned i = 0; i < RealName.size(); ++i) { + char ArgName[2] = { 0, 0 }; int Dummy; + ArgName[0] = RealName[i]; + I = getOpts().find(ArgName); + assert(I != getOpts().end() && "ValidGroupedArgs failed!"); + + // Because ValueRequired is an invalid flag for grouped arguments, + // we don't need to pass argc/argv in... + // + ErrorParsing |= ProvideOption(I->second, ArgName, "", + 0, 0, Dummy); + } + continue; + } else if (Flags & EnableSingleLetterArgValue) { + // Check to see if the first letter is a single letter argument that + // have a value that is equal to the rest of the string. If this + // is the case, recognize it now. (Example: -lfoo for a linker) + // + I = getOpts().find(string(1, RealName[0])); + if (I != getOpts().end()) { + // If we are successful, fall through to later processing, by + // setting up the argument name flags and value fields. + // + ArgNameEnd = ArgName+1; + Value = ArgNameEnd; + } + } + } + + Handler = I != getOpts().end() ? I->second : 0; } } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 84dd26dff9..bc337ee8b5 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -18,7 +18,7 @@ using namespace cl; // Return the global command line option vector. Making it a function scoped -// static ensures that it will be initialized before its first use correctly. +// static ensures that it will be initialized correctly before its first use. // static map &getOpts() { static map CommandLineOptions; @@ -30,7 +30,8 @@ static void AddArgument(const string &ArgName, Option *Opt) { cerr << "CommandLine Error: Argument '" << ArgName << "' specified more than once!\n"; } else { - getOpts()[ArgName] = Opt; // Add argument to the argument map! + // Add argument to the argument map! + getOpts().insert(make_pair(ArgName, Opt)); } } @@ -65,9 +66,29 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->addOccurance(ArgName, Value); } +// ValueGroupedArgs - Return true if the specified string is valid as a group +// of single letter arguments stuck together like the 'ls -la' case. +// +static inline bool ValidGroupedArgs(string Args) { + for (unsigned i = 0; i < Args.size(); ++i) { + map::iterator I = getOpts().find(string(1, Args[i])); + if (I == getOpts().end()) return false; // Make sure option exists + + // Grouped arguments have no value specified, make sure that if this option + // exists that it can accept no argument. + // + switch (I->second->getValueExpectedFlag()) { + case ValueDisallowed: + case ValueOptional: break; + default: return false; + } + } + + return true; +} void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0) { + const char *Overview = 0, int Flags = 0) { ProgramName = argv[0]; // Save this away safe and snug ProgramOverview = Overview; bool ErrorParsing = false; @@ -86,18 +107,55 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, while (*ArgName == '-') ++ArgName; // Eat leading dashes const char *ArgNameEnd = ArgName; - while (*ArgNameEnd && *ArgNameEnd != '=' && - *ArgNameEnd != '/') ++ArgNameEnd; // Scan till end - // TODO: Remove '/' case. Implement single letter args properly! + while (*ArgNameEnd && *ArgNameEnd != '=') + ++ArgNameEnd; // Scan till end of argument name... Value = ArgNameEnd; if (*Value) // If we have an equals sign... ++Value; // Advance to value... if (*ArgName != 0) { + string RealName(ArgName, ArgNameEnd); // Extract arg name part - map::iterator I = - getOpts().find(string(ArgName, ArgNameEnd)); + map::iterator I = getOpts().find(RealName); + + if (I == getOpts().end() && !*Value && RealName.size() > 1) { + // If grouping of single letter arguments is enabled, see if this is a + // legal grouping... + // + if (!(Flags & DisableSingleLetterArgGrouping) && + ValidGroupedArgs(RealName)) { + + for (unsigned i = 0; i < RealName.size(); ++i) { + char ArgName[2] = { 0, 0 }; int Dummy; + ArgName[0] = RealName[i]; + I = getOpts().find(ArgName); + assert(I != getOpts().end() && "ValidGroupedArgs failed!"); + + // Because ValueRequired is an invalid flag for grouped arguments, + // we don't need to pass argc/argv in... + // + ErrorParsing |= ProvideOption(I->second, ArgName, "", + 0, 0, Dummy); + } + continue; + } else if (Flags & EnableSingleLetterArgValue) { + // Check to see if the first letter is a single letter argument that + // have a value that is equal to the rest of the string. If this + // is the case, recognize it now. (Example: -lfoo for a linker) + // + I = getOpts().find(string(1, RealName[0])); + if (I != getOpts().end()) { + // If we are successful, fall through to later processing, by + // setting up the argument name flags and value fields. + // + ArgNameEnd = ArgName+1; + Value = ArgNameEnd; + } + } + } + + Handler = I != getOpts().end() ? I->second : 0; } } -- cgit v1.2.3-70-g09d2 From cee8f9ae67104576b2028125b56e9ba4856a1d66 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 27 Nov 2001 00:03:19 +0000 Subject: Create a new #include "Support/..." directory structure to move things from "llvm/Support/..." that are not llvm dependant. Move files and fix #includes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1400 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CommandLine.html | 4 +- include/Support/CommandLine.h | 399 +++++++++++++++++++++ include/Support/DepthFirstIterator.h | 147 ++++++++ include/Support/GraphTraits.h | 65 ++++ include/Support/HashExtras.h | 27 ++ include/Support/MathExtras.h | 32 ++ include/Support/NonCopyable.h | 37 ++ include/Support/PostOrderIterator.h | 145 ++++++++ include/Support/STLExtras.h | 222 ++++++++++++ include/Support/StringExtras.h | 69 ++++ include/Support/Tree.h | 52 +++ include/llvm/ADT/DepthFirstIterator.h | 147 ++++++++ include/llvm/ADT/GraphTraits.h | 65 ++++ include/llvm/ADT/HashExtras.h | 27 ++ include/llvm/ADT/PostOrderIterator.h | 145 ++++++++ include/llvm/ADT/STLExtras.h | 222 ++++++++++++ include/llvm/ADT/StringExtras.h | 69 ++++ include/llvm/ADT/Tree.h | 52 +++ include/llvm/Analysis/CallGraph.h | 2 +- include/llvm/Analysis/InstForest.h | 2 +- include/llvm/BasicBlock.h | 2 +- include/llvm/CodeGen/InstrForest.h | 4 +- include/llvm/CodeGen/InstrScheduling.h | 2 +- include/llvm/CodeGen/MachineInstr.h | 6 +- include/llvm/CodeGen/RegAllocCommon.h | 2 +- include/llvm/Support/CommandLine.h | 399 +++++++++++++++++++++ include/llvm/Support/DepthFirstIterator.h | 147 -------- include/llvm/Support/GraphTraits.h | 65 ---- include/llvm/Support/HashExtras.h | 27 -- include/llvm/Support/MathExtras.h | 32 ++ include/llvm/Support/NonCopyable.h | 37 -- include/llvm/Support/PostOrderIterator.h | 145 -------- include/llvm/Support/STLExtras.h | 222 ------------ include/llvm/Support/StringExtras.h | 88 ----- include/llvm/Support/Tree.h | 52 --- include/llvm/Target/TargetFrameInfo.h | 2 +- include/llvm/Target/TargetMachine.h | 2 +- include/llvm/Target/TargetRegInfo.h | 2 +- include/llvm/Type.h | 2 +- lib/Analysis/IPA/CallGraph.cpp | 2 +- lib/Analysis/IPA/FindUnsafePointerTypes.cpp | 2 +- lib/Analysis/IntervalPartition.cpp | 2 +- lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp | 2 +- lib/Analysis/LoopDepth.cpp | 2 +- lib/Analysis/LoopInfo.cpp | 2 +- lib/Analysis/ModuleAnalyzer.cpp | 2 +- lib/Analysis/PostDominators.cpp | 4 +- lib/AsmParser/ParserInternals.h | 2 +- lib/AsmParser/llvmAsmParser.y | 4 +- lib/Bytecode/Writer/SlotCalculator.cpp | 4 +- lib/CodeGen/InstrSched/InstrScheduling.cpp | 8 +- lib/CodeGen/InstrSched/SchedGraph.cpp | 30 +- lib/CodeGen/InstrSched/SchedGraph.h | 6 +- lib/CodeGen/InstrSched/SchedPriorities.cpp | 2 +- lib/CodeGen/InstrSelection/InstrForest.cpp | 2 +- lib/CodeGen/InstrSelection/InstrSelection.cpp | 2 +- lib/CodeGen/RegAlloc/RegAllocCommon.h | 2 +- lib/ExecutionEngine/Interpreter/Execution.cpp | 2 +- lib/Support/CommandLine.cpp | 4 +- lib/Target/SparcV9/InstrSched/InstrScheduling.cpp | 8 +- lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 30 +- lib/Target/SparcV9/InstrSched/SchedGraph.h | 6 +- lib/Target/SparcV9/InstrSched/SchedPriorities.cpp | 2 +- lib/Target/SparcV9/InstrSelection/InstrForest.cpp | 2 +- .../SparcV9/InstrSelection/InstrSelection.cpp | 2 +- lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp | 2 +- lib/Target/SparcV9/RegAlloc/RegAllocCommon.h | 2 +- lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 67 +++- lib/Target/SparcV9/SparcV9InstrSelection.cpp | 4 +- lib/Transforms/ExprTypeConvert.cpp | 2 +- lib/Transforms/IPO/GlobalDCE.cpp | 2 +- lib/Transforms/Instrumentation/TraceValues.cpp | 4 +- lib/Transforms/LevelRaise.cpp | 2 +- lib/Transforms/Scalar/ADCE.cpp | 4 +- lib/Transforms/Scalar/DCE.cpp | 2 +- lib/Transforms/Scalar/InductionVars.cpp | 2 +- lib/Transforms/Scalar/SCCP.cpp | 2 +- lib/VMCore/AsmWriter.cpp | 4 +- lib/VMCore/ConstPoolVals.cpp | 2 +- lib/VMCore/Dominators.cpp | 4 +- lib/VMCore/Module.cpp | 2 +- lib/VMCore/SlotCalculator.cpp | 4 +- lib/VMCore/SymbolTable.cpp | 2 +- lib/VMCore/Type.cpp | 4 +- support/lib/Support/CommandLine.cpp | 4 +- support/lib/Support/StringExtras.cpp | 66 ---- tools/analyze/analyze.cpp | 3 +- tools/as/as.cpp | 7 +- tools/dis/dis.cpp | 9 +- tools/gccas/gccas.cpp | 2 +- tools/link/link.cpp | 4 +- tools/llc/llc.cpp | 2 +- tools/lli/lli.cpp | 2 +- tools/llvm-as/as.cpp | 7 +- tools/llvm-as/llvm-as.cpp | 7 +- tools/llvm-dis/dis.cpp | 9 +- tools/llvm-dis/llvm-dis.cpp | 9 +- tools/llvm-link/llvm-link.cpp | 4 +- tools/opt/opt.cpp | 2 +- 99 files changed, 2546 insertions(+), 1012 deletions(-) create mode 100644 include/Support/CommandLine.h create mode 100644 include/Support/DepthFirstIterator.h create mode 100644 include/Support/GraphTraits.h create mode 100644 include/Support/HashExtras.h create mode 100644 include/Support/MathExtras.h create mode 100644 include/Support/NonCopyable.h create mode 100644 include/Support/PostOrderIterator.h create mode 100644 include/Support/STLExtras.h create mode 100644 include/Support/StringExtras.h create mode 100644 include/Support/Tree.h create mode 100644 include/llvm/ADT/DepthFirstIterator.h create mode 100644 include/llvm/ADT/GraphTraits.h create mode 100644 include/llvm/ADT/HashExtras.h create mode 100644 include/llvm/ADT/PostOrderIterator.h create mode 100644 include/llvm/ADT/STLExtras.h create mode 100644 include/llvm/ADT/StringExtras.h create mode 100644 include/llvm/ADT/Tree.h create mode 100644 include/llvm/Support/CommandLine.h delete mode 100644 include/llvm/Support/DepthFirstIterator.h delete mode 100644 include/llvm/Support/GraphTraits.h delete mode 100644 include/llvm/Support/HashExtras.h create mode 100644 include/llvm/Support/MathExtras.h delete mode 100644 include/llvm/Support/NonCopyable.h delete mode 100644 include/llvm/Support/PostOrderIterator.h delete mode 100644 include/llvm/Support/STLExtras.h delete mode 100644 include/llvm/Support/StringExtras.h delete mode 100644 include/llvm/Support/Tree.h delete mode 100644 support/lib/Support/StringExtras.cpp (limited to 'lib/Support/CommandLine.cpp') diff --git a/docs/CommandLine.html b/docs/CommandLine.html index 1660639dcb..f12525b263 100644 --- a/docs/CommandLine.html +++ b/docs/CommandLine.html @@ -64,7 +64,7 @@ This section of the manual runs through a simple CommandLine'ification of a util To start out, you need to include the CommandLine header file into your program:

-  #include "llvm/Support/CommandLine.h"
+  #include "Support/CommandLine.h"
 

Additionally, you need to add this as the first line of your main program:

@@ -353,7 +353,7 @@ Extension Guide: TODO

Chris Lattner
-Last modified: Mon Jul 23 17:33:57 CDT 2001 +Last modified: Mon Nov 26 17:09:39 CST 2001 diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h new file mode 100644 index 0000000000..84a3bc9b59 --- /dev/null +++ b/include/Support/CommandLine.h @@ -0,0 +1,399 @@ +//===- Support/CommandLine.h - Flexible Command line parser ------*- C++ -*--=// +// +// This class implements a command line argument processor that is useful when +// creating a tool. It provides a simple, minimalistic interface that is easily +// extensible and supports nonlocal (library) command line options. +// +// Note that rather than trying to figure out what this code does, you could try +// reading the library documentation located in docs/CommandLine.html +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_COMMANDLINE_H +#define LLVM_SUPPORT_COMMANDLINE_H + +#include +#include +#include +#include + +namespace cl { // Short namespace to make usage concise + +//===----------------------------------------------------------------------===// +// ParseCommandLineOptions - Minimalistic command line option processing entry +// +void cl::ParseCommandLineOptions(int &argc, char **argv, + const char *Overview = 0, + int Flags = 0); + +// ParserOptions - This set of option is use to control global behavior of the +// command line processor. +// +enum ParserOptions { + // DisableSingleLetterArgGrouping - With this option enabled, multiple letter + // options are allowed to bunch together with only a single hyphen for the + // whole group. This allows emulation of the behavior that ls uses for + // example: ls -la === ls -l -a Providing this option, disables this. + // + DisableSingleLetterArgGrouping = 0x0001, + + // EnableSingleLetterArgValue - This option allows arguments that are + // otherwise unrecognized to match single letter flags that take a value. + // This is useful for cases like a linker, where options are typically of the + // form '-lfoo' or '-L../../include' where -l or -L are the actual flags. + // + EnableSingleLetterArgValue = 0x0002, +}; + + +//===----------------------------------------------------------------------===// +// Global flags permitted to be passed to command line arguments + +enum FlagsOptions { + NoFlags = 0x00, // Marker to make explicit that we have no flags + Default = 0x00, // Equally, marker to use the default flags + + GlobalsMask = 0x80, +}; + +enum NumOccurances { // Flags for the number of occurances allowed... + Optional = 0x01, // Zero or One occurance + ZeroOrMore = 0x02, // Zero or more occurances allowed + Required = 0x03, // One occurance required + OneOrMore = 0x04, // One or more occurances required + + // ConsumeAfter - Marker for a null ("") flag that can be used to indicate + // that anything that matches the null marker starts a sequence of options + // that all get sent to the null marker. Thus, for example, all arguments + // to LLI are processed until a filename is found. Once a filename is found, + // all of the succeeding arguments are passed, unprocessed, to the null flag. + // + ConsumeAfter = 0x05, + + OccurancesMask = 0x07, +}; + +enum ValueExpected { // Is a value required for the option? + ValueOptional = 0x08, // The value can oppear... or not + ValueRequired = 0x10, // The value is required to appear! + ValueDisallowed = 0x18, // A value may not be specified (for flags) + ValueMask = 0x18, +}; + +enum OptionHidden { // Control whether -help shows this option + NotHidden = 0x20, // Option included in --help & --help-hidden + Hidden = 0x40, // -help doesn't, but --help-hidden does + ReallyHidden = 0x60, // Neither --help nor --help-hidden show this arg + HiddenMask = 0x60, +}; + + +//===----------------------------------------------------------------------===// +// Option Base class +// +class Alias; +class Option { + friend void cl::ParseCommandLineOptions(int &, char **, const char *, int); + friend class Alias; + + // handleOccurances - Overriden by subclasses to handle the value passed into + // an argument. Should return true if there was an error processing the + // argument and the program should exit. + // + virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0; + + virtual enum NumOccurances getNumOccurancesFlagDefault() const { + return Optional; + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueOptional; + } + virtual enum OptionHidden getOptionHiddenFlagDefault() const { + return NotHidden; + } + + int NumOccurances; // The number of times specified + const int Flags; // Flags for the argument +public: + const char * const ArgStr; // The argument string itself (ex: "help", "o") + const char * const HelpStr; // The descriptive text message for --help + + inline enum NumOccurances getNumOccurancesFlag() const { + int NO = Flags & OccurancesMask; + return NO ? (enum NumOccurances)NO : getNumOccurancesFlagDefault(); + } + inline enum ValueExpected getValueExpectedFlag() const { + int VE = Flags & ValueMask; + return VE ? (enum ValueExpected)VE : getValueExpectedFlagDefault(); + } + inline enum OptionHidden getOptionHiddenFlag() const { + int OH = Flags & HiddenMask; + return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault(); + } + +protected: + Option(const char *ArgStr, const char *Message, int Flags); + Option(int flags) : NumOccurances(0), Flags(flags), ArgStr(""), HelpStr("") {} + +public: + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; + + // addOccurance - Wrapper around handleOccurance that enforces Flags + // + bool addOccurance(const char *ArgName, const string &Value); + + // Prints option name followed by message. Always returns true. + bool error(string Message, const char *ArgName = 0); + +public: + inline int getNumOccurances() const { return NumOccurances; } + virtual ~Option() {} +}; + + +//===----------------------------------------------------------------------===// +// Aliased command line option (alias this name to a preexisting name) +// +class Alias : public Option { + Option &AliasFor; + virtual bool handleOccurance(const char *ArgName, const string &Arg) { + return AliasFor.handleOccurance(AliasFor.ArgStr, Arg); + } + virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} +public: + inline Alias(const char *ArgStr, const char *Message, int Flags, + Option &aliasFor) : Option(ArgStr, Message, Flags), + AliasFor(aliasFor) {} +}; + +//===----------------------------------------------------------------------===// +// Boolean/flag command line option +// +class Flag : public Option { + bool Value; + virtual bool handleOccurance(const char *ArgName, const string &Arg); +public: + inline Flag(const char *ArgStr, const char *Message, int Flags = 0, + bool DefaultVal = 0) : Option(ArgStr, Message, Flags), + Value(DefaultVal) {} + operator const bool() const { return Value; } + inline bool operator=(bool Val) { Value = Val; return Val; } +}; + + + +//===----------------------------------------------------------------------===// +// Integer valued command line option +// +class Int : public Option { + int Value; + virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } +public: + inline Int(const char *ArgStr, const char *Help, int Flags = 0, + int DefaultVal = 0) : Option(ArgStr, Help, Flags), + Value(DefaultVal) {} + inline operator int() const { return Value; } + inline int operator=(int Val) { Value = Val; return Val; } +}; + + +//===----------------------------------------------------------------------===// +// String valued command line option +// +class String : public Option, public string { + virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } +public: + inline String(const char *ArgStr, const char *Help, int Flags = 0, + const char *DefaultVal = "") + : Option(ArgStr, Help, Flags), string(DefaultVal) {} + + inline const string &operator=(const string &Val) { + return string::operator=(Val); + } +}; + + +//===----------------------------------------------------------------------===// +// String list command line option +// +class StringList : public Option, public vector { + + virtual enum NumOccurances getNumOccurancesFlagDefault() const { + return ZeroOrMore; + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } + virtual bool handleOccurance(const char *ArgName, const string &Arg); + +public: + inline StringList(const char *ArgStr, const char *Help, int Flags = 0) + : Option(ArgStr, Help, Flags) {} +}; + + +//===----------------------------------------------------------------------===// +// Enum valued command line option +// +#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, ENUMVAL, DESC +#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, ENUMVAL, DESC + +// EnumBase - Base class for all enum/varargs related argument types... +class EnumBase : public Option { +protected: + // Use a vector instead of a map, because the lists should be short, + // the overhead is less, and most importantly, it keeps them in the order + // inserted so we can print our option out nicely. + vector > > ValueMap; + + inline EnumBase(const char *ArgStr, const char *Help, int Flags) + : Option(ArgStr, Help, Flags) {} + inline EnumBase(int Flags) : Option(Flags) {} + + // processValues - Incorporate the specifed varargs arglist into the + // ValueMap. + // + void processValues(va_list Vals); + + // registerArgs - notify the system about these new arguments + void registerArgs(); + +public: + // Turn an enum into the arg name that activates it + const char *getArgName(int ID) const; + const char *getArgDescription(int ID) const; +}; + +class EnumValueBase : public EnumBase { +protected: + int Value; + inline EnumValueBase(const char *ArgStr, const char *Help, int Flags) + : EnumBase(ArgStr, Help, Flags) {} + inline EnumValueBase(int Flags) : EnumBase(Flags) {} + + // handleOccurance - Set Value to the enum value specified by Arg + virtual bool handleOccurance(const char *ArgName, const string &Arg); + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; +}; + +template // The enum we are representing +class Enum : public EnumValueBase { + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } +public: + inline Enum(const char *ArgStr, int Flags, const char *Help, ...) + : EnumValueBase(ArgStr, Help, Flags) { + va_list Values; + va_start(Values, Help); + processValues(Values); + va_end(Values); + Value = ValueMap.front().second.first; // Grab default value + } + + inline operator E() const { return (E)Value; } + inline E operator=(E Val) { Value = Val; return Val; } +}; + + +//===----------------------------------------------------------------------===// +// Enum flags command line option +// +class EnumFlagsBase : public EnumValueBase { + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueDisallowed; + } +protected: + virtual bool handleOccurance(const char *ArgName, const string &Arg); + inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {} + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; +}; + +template // The enum we are representing +class EnumFlags : public EnumFlagsBase { +public: + inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags) { + va_list Values; + va_start(Values, Flags); + processValues(Values); + va_end(Values); + registerArgs(); + Value = ValueMap.front().second.first; // Grab default value + } + + inline operator E() const { return (E)Value; } + inline E operator=(E Val) { Value = Val; return Val; } +}; + + +//===----------------------------------------------------------------------===// +// Enum list command line option +// +class EnumListBase : public EnumBase { + virtual enum NumOccurances getNumOccurancesFlagDefault() const { + return ZeroOrMore; + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueDisallowed; + } +protected: + vector Values; // The options specified so far. + + inline EnumListBase(int Flags) + : EnumBase(Flags) {} + virtual bool handleOccurance(const char *ArgName, const string &Arg); + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; +public: + inline unsigned size() { return Values.size(); } +}; + +template // The enum we are representing +class EnumList : public EnumListBase { +public: + inline EnumList(int Flags, ...) : EnumListBase(Flags) { + va_list Values; + va_start(Values, Flags); + processValues(Values); + va_end(Values); + registerArgs(); + } + inline E operator[](unsigned i) const { return (E)Values[i]; } + inline E &operator[](unsigned i) { return (E&)Values[i]; } +}; + +} // End namespace cl + +#endif diff --git a/include/Support/DepthFirstIterator.h b/include/Support/DepthFirstIterator.h new file mode 100644 index 0000000000..a2d5a9df68 --- /dev/null +++ b/include/Support/DepthFirstIterator.h @@ -0,0 +1,147 @@ +//===- Support/DepthFirstIterator.h - Depth First iterator -------*- C++ -*--=// +// +// This file builds on the Support/GraphTraits.h file to build generic depth +// first graph iterator. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_DEPTH_FIRST_ITERATOR_H +#define LLVM_SUPPORT_DEPTH_FIRST_ITERATOR_H + +#include "Support/GraphTraits.h" +#include +#include +#include + +// Generic Depth First Iterator +template > +class df_iterator : public std::forward_iterator { + typedef typename GT::NodeType NodeType; + typedef typename GT::ChildIteratorType ChildItTy; + + set Visited; // All of the blocks visited so far... + // VisitStack - Used to maintain the ordering. Top = current block + // First element is node pointer, second is the 'next child' to visit + stack > VisitStack; + const bool Reverse; // Iterate over children before self? +private: + void reverseEnterNode() { + pair &Top = VisitStack.top(); + NodeType *Node = Top.first; + ChildItTy &It = Top.second; + for (; It != GT::child_end(Node); ++It) { + NodeType *Child = *It; + if (!Visited.count(Child)) { + Visited.insert(Child); + VisitStack.push(make_pair(Child, GT::child_begin(Child))); + reverseEnterNode(); + return; + } + } + } + + inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) { + Visited.insert(Node); + VisitStack.push(make_pair(Node, GT::child_begin(Node))); + if (Reverse) reverseEnterNode(); + } + inline df_iterator() { /* End is when stack is empty */ } + +public: + typedef df_iterator _Self; + + // Provide static begin and end methods as our public "constructors" + static inline _Self begin(GraphT G, bool Reverse = false) { + return _Self(GT::getEntryNode(G), Reverse); + } + static inline _Self end(GraphT G) { return _Self(); } + + + inline bool operator==(const _Self& x) const { + return VisitStack == x.VisitStack; + } + inline bool operator!=(const _Self& x) const { return !operator==(x); } + + inline pointer operator*() const { + return VisitStack.top().first; + } + + // This is a nonstandard operator-> that dereferences the pointer an extra + // time... so that you can actually call methods ON the Node, because + // the contained type is a pointer. This allows BBIt->getTerminator() f.e. + // + inline NodeType *operator->() const { return operator*(); } + + inline _Self& operator++() { // Preincrement + if (Reverse) { // Reverse Depth First Iterator + if (VisitStack.top().second == GT::child_end(VisitStack.top().first)) + VisitStack.pop(); + if (!VisitStack.empty()) + reverseEnterNode(); + } else { // Normal Depth First Iterator + do { + pair &Top = VisitStack.top(); + NodeType *Node = Top.first; + ChildItTy &It = Top.second; + + while (It != GT::child_end(Node)) { + NodeType *Next = *It++; + if (!Visited.count(Next)) { // Has our next sibling been visited? + // No, do it now. + Visited.insert(Next); + VisitStack.push(make_pair(Next, GT::child_begin(Next))); + return *this; + } + } + + // Oops, ran out of successors... go up a level on the stack. + VisitStack.pop(); + } while (!VisitStack.empty()); + } + return *this; + } + + inline _Self operator++(int) { // Postincrement + _Self tmp = *this; ++*this; return tmp; + } + + // nodeVisited - return true if this iterator has already visited the + // specified node. This is public, and will probably be used to iterate over + // nodes that a depth first iteration did not find: ie unreachable nodes. + // + inline bool nodeVisited(NodeType *Node) const { + return Visited.count(Node) != 0; + } +}; + + +// Provide global constructors that automatically figure out correct types... +// +template +df_iterator df_begin(T G, bool Reverse = false) { + return df_iterator::begin(G, Reverse); +} + +template +df_iterator df_end(T G) { + return df_iterator::end(G); +} + +// Provide global definitions of inverse depth first iterators... +template +struct idf_iterator : public df_iterator > { + idf_iterator(const df_iterator > &V) :df_iterator >(V){} +}; + +template +idf_iterator idf_begin(T G, bool Reverse = false) { + return idf_iterator::begin(G, Reverse); +} + +template +idf_iterator idf_end(T G){ + return idf_iterator::end(G); +} + +#endif diff --git a/include/Support/GraphTraits.h b/include/Support/GraphTraits.h new file mode 100644 index 0000000000..00973d59fa --- /dev/null +++ b/include/Support/GraphTraits.h @@ -0,0 +1,65 @@ +//===-- Support/GraphTraits.h - Graph traits template ------------*- C++ -*--=// +// +// This file defines the little GraphTraits template class that should be +// specialized by classes that want to be iteratable by generic graph iterators. +// +// This file also defines the marker class Inverse that is used to iterate over +// graphs in a graph defined, inverse ordering... +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_GRAPH_TRAITS_H +#define LLVM_SUPPORT_GRAPH_TRAITS_H + +// GraphTraits - This class should be specialized by different graph types... +// which is why the default version is empty. +// +template +struct GraphTraits { + // Elements to provide: + + // typedef NodeType - Type of Node in the graph + // typedef ChildIteratorType - Type used to iterate over children in graph + + // static NodeType *getEntryNode(GraphType *) + // Return the entry node of the graph + + // static ChildIteratorType child_begin(NodeType *) + // static ChildIteratorType child_end (NodeType *) + // Return iterators that point to the beginning and ending of the child + // node list for the specified node. + // + + + // If anyone tries to use this class without having an appropriate + // specialization, make an error. If you get this error, it's because you + // need to include the appropriate specialization of GraphTraits<> for your + // graph, or you need to define it for a new graph type. Either that or + // your argument to XXX_begin(...) is unknown or needs to have the proper .h + // file #include'd. + // + typedef typename GraphType::UnknownGraphTypeError NodeType; +}; + + +// Inverse - This class is used as a little marker class to tell the graph +// iterator to iterate over the graph in a graph defined "Inverse" ordering. +// Not all graphs define an inverse ordering, and if they do, it depends on +// the graph exactly what that is. Here's an example of usage with the +// df_iterator: +// +// idf_iterator I = idf_begin(M), E = idf_end(M); +// for (; I != E; ++I) { ... } +// +// Which is equivalent to: +// df_iterator > I = idf_begin(M), E = idf_end(M); +// for (; I != E; ++I) { ... } +// +template +struct Inverse { + GraphType &Graph; + + inline Inverse(GraphType &G) : Graph(G) {} +}; + +#endif diff --git a/include/Support/HashExtras.h b/include/Support/HashExtras.h new file mode 100644 index 0000000000..6ea831e78f --- /dev/null +++ b/include/Support/HashExtras.h @@ -0,0 +1,27 @@ +//===-- HashExtras.h - Useful functions for STL hash containers --*- C++ -*--=// +// +// This file contains some templates that are useful if you are working with the +// STL Hashed containers. +// +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_HASHEXTRAS_H +#define LLVM_SUPPORT_HASHEXTRAS_H + +#include +#include + +template <> struct hash { + size_t operator()(string const &str) const { + return hash()(str.c_str()); + } +}; + +// Provide a hash function for arbitrary pointers... +template struct hash { + inline size_t operator()(const T *Val) const { return (size_t)Val; } +}; + +#endif diff --git a/include/Support/MathExtras.h b/include/Support/MathExtras.h new file mode 100644 index 0000000000..f3dc3de17b --- /dev/null +++ b/include/Support/MathExtras.h @@ -0,0 +1,32 @@ +// $Id$ -*-c++-*- +//*************************************************************************** +// File: +// MathExtras.h +// +// Purpose: +// +// History: +// 8/25/01 - Vikram Adve - Created +//**************************************************************************/ + +#ifndef LLVM_SUPPORT_MATH_EXTRAS_H +#define LLVM_SUPPORT_MATH_EXTRAS_H + +#include + +inline bool IsPowerOf2 (int64_t C, unsigned& getPow); + +inline +bool IsPowerOf2(int64_t C, unsigned& getPow) +{ + if (C < 0) + C = -C; + bool isBool = C > 0 && (C == (C & ~(C - 1))); + if (isBool) + for (getPow = 0; C > 1; getPow++) + C = C >> 1; + + return isBool; +} + +#endif /*LLVM_SUPPORT_MATH_EXTRAS_H*/ diff --git a/include/Support/NonCopyable.h b/include/Support/NonCopyable.h new file mode 100644 index 0000000000..f4fc26805a --- /dev/null +++ b/include/Support/NonCopyable.h @@ -0,0 +1,37 @@ +//===-- NonCopyable.h - Disable copy ctor and op= in subclasses --*- C++ -*--=// +// +// This file defines the NonCopyable and NonCopyableV classes. These mixin +// classes may be used to mark a class not being copyable. You should derive +// from NonCopyable if you don't want to have a virtual dtor, or NonCopyableV +// if you do want polymorphic behavior in your class. +// +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_NONCOPYABLE_H +#define LLVM_SUPPORT_NONCOPYABLE_H + +class NonCopyable { + // Disable the copy constructor and the assignment operator + // by making them both private: + // + NonCopyable(const NonCopyable &); // DO NOT IMPLEMENT + NonCopyable &operator=(const NonCopyable &); // DO NOT IMPLEMENT +protected: + inline NonCopyable() {} + inline ~NonCopyable() {} +}; + +class NonCopyableV { + // Disable the copy constructor and the assignment operator + // by making them both private: + // + NonCopyableV(const NonCopyableV &); // DO NOT IMPLEMENT + NonCopyableV &operator=(const NonCopyableV &); // DO NOT IMPLEMENT +protected: + inline NonCopyableV() {} + virtual ~NonCopyableV() {} +}; + +#endif diff --git a/include/Support/PostOrderIterator.h b/include/Support/PostOrderIterator.h new file mode 100644 index 0000000000..89a9b4db86 --- /dev/null +++ b/include/Support/PostOrderIterator.h @@ -0,0 +1,145 @@ +//===-- Support/PostOrderIterator.h - Generic PostOrder iterator -*- C++ -*--=// +// +// This file builds on the Support/GraphTraits.h file to build a generic graph +// post order iterator. This should work over any graph type that has a +// GraphTraits specialization. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_POSTORDER_ITERATOR_H +#define LLVM_SUPPORT_POSTORDER_ITERATOR_H + +#include "Support/GraphTraits.h" +#include +#include +#include + +template > +class po_iterator : public std::forward_iterator { + typedef typename GT::NodeType NodeType; + typedef typename GT::ChildIteratorType ChildItTy; + + set Visited; // All of the blocks visited so far... + // VisitStack - Used to maintain the ordering. Top = current block + // First element is basic block pointer, second is the 'next child' to visit + stack > VisitStack; + + void traverseChild() { + while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) { + NodeType *BB = *VisitStack.top().second++; + if (!Visited.count(BB)) { // If the block is not visited... + Visited.insert(BB); + VisitStack.push(make_pair(BB, GT::child_begin(BB))); + } + } + } + + inline po_iterator(NodeType *BB) { + Visited.insert(BB); + VisitStack.push(make_pair(BB, GT::child_begin(BB))); + traverseChild(); + } + inline po_iterator() { /* End is when stack is empty */ } +public: + typedef po_iterator _Self; + + // Provide static "constructors"... + static inline _Self begin(GraphT G) { return _Self(GT::getEntryNode(G)); } + static inline _Self end (GraphT G) { return _Self(); } + + inline bool operator==(const _Self& x) const { + return VisitStack == x.VisitStack; + } + inline bool operator!=(const _Self& x) const { return !operator==(x); } + + inline pointer operator*() const { + return VisitStack.top().first; + } + + // This is a nonstandard operator-> that dereferences the pointer an extra + // time... so that you can actually call methods ON the BasicBlock, because + // the contained type is a pointer. This allows BBIt->getTerminator() f.e. + // + inline NodeType *operator->() const { return operator*(); } + + inline _Self& operator++() { // Preincrement + VisitStack.pop(); + if (!VisitStack.empty()) + traverseChild(); + return *this; + } + + inline _Self operator++(int) { // Postincrement + _Self tmp = *this; ++*this; return tmp; + } +}; + +// Provide global constructors that automatically figure out correct types... +// +template +po_iterator po_begin(T G) { return po_iterator::begin(G); } +template +po_iterator po_end (T G) { return po_iterator::end(G); } + +// Provide global definitions of inverse post order iterators... +template +struct ipo_iterator : public po_iterator > { + ipo_iterator(const po_iterator > &V) :po_iterator >(V){} +}; + +template +ipo_iterator ipo_begin(T G, bool Reverse = false) { + return ipo_iterator::begin(G, Reverse); +} + +template +ipo_iterator ipo_end(T G){ + return ipo_iterator::end(G); +} + + +//===--------------------------------------------------------------------===// +// Reverse Post Order CFG iterator code +//===--------------------------------------------------------------------===// +// +// This is used to visit basic blocks in a method in reverse post order. This +// class is awkward to use because I don't know a good incremental algorithm to +// computer RPO from a graph. Because of this, the construction of the +// ReversePostOrderTraversal object is expensive (it must walk the entire graph +// with a postorder iterator to build the data structures). The moral of this +// story is: Don't create more ReversePostOrderTraversal classes than neccesary. +// +// This class should be used like this: +// { +// cfg::ReversePostOrderTraversal RPOT(MethodPtr); // Expensive to create +// for (cfg::rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { +// ... +// } +// for (cfg::rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { +// ... +// } +// } +// + +typedef reverse_iterator::iterator> rpo_iterator; +// TODO: FIXME: ReversePostOrderTraversal is not generic! +class ReversePostOrderTraversal { + vector Blocks; // Block list in normal PO order + inline void Initialize(BasicBlock *BB) { + copy(po_begin(BB), po_end(BB), back_inserter(Blocks)); + } +public: + inline ReversePostOrderTraversal(Method *M) { + Initialize(M->front()); + } + inline ReversePostOrderTraversal(BasicBlock *BB) { + Initialize(BB); + } + + // Because we want a reverse post order, use reverse iterators from the vector + inline rpo_iterator begin() { return Blocks.rbegin(); } + inline rpo_iterator end() { return Blocks.rend(); } +}; + +#endif diff --git a/include/Support/STLExtras.h b/include/Support/STLExtras.h new file mode 100644 index 0000000000..44d789dcf2 --- /dev/null +++ b/include/Support/STLExtras.h @@ -0,0 +1,222 @@ +//===-- STLExtras.h - Useful functions when working with the STL -*- C++ -*--=// +// +// This file contains some templates that are useful if you are working with the +// STL at all. +// +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_STL_EXTRAS_H +#define LLVM_SUPPORT_STL_EXTRAS_H + +#include + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// bind_obj - Often times you want to apply the member function of an object +// as a unary functor. This macro is shorthand that makes it happen less +// verbosely. +// +// Example: +// struct Summer { void accumulate(int x); } +// vector Numbers; +// Summer MyS; +// for_each(Numbers.begin(), Numbers.end(), +// bind_obj(&MyS, &Summer::accumulate)); +// +// TODO: When I get lots of extra time, convert this from an evil macro +// +#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ) + + +// bitwise_or - This is a simple functor that applys operator| on its two +// arguments to get a boolean result. +// +template +struct bitwise_or : public binary_function { + bool operator()(const Ty& left, const Ty& right) const { + return left | right; + } +}; + + +// deleter - Very very very simple method that is used to invoke operator +// delete on something. It is used like this: +// +// for_each(V.begin(), B.end(), deleter); +// +template +static inline void deleter(T *Ptr) { + delete Ptr; +} + + + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// mapped_iterator - This is a simple iterator adapter that causes a function to +// be dereferenced whenever operator* is invoked on the iterator. +// +// It turns out that this is disturbingly similar to boost::transform_iterator +// +#if 1 +template +class mapped_iterator { + RootIt current; + UnaryFunc Fn; +public: + typedef typename iterator_traits::iterator_category + iterator_category; + typedef typename iterator_traits::difference_type + difference_type; + typedef typename UnaryFunc::result_type value_type; + typedef typename UnaryFunc::result_type *pointer; + typedef void reference; // Can't modify value returned by fn + + typedef RootIt iterator_type; + typedef mapped_iterator _Self; + + inline RootIt &getCurrent() const { return current; } + + inline explicit mapped_iterator(const RootIt &I, UnaryFunc F) + : current(I), Fn(F) {} + inline mapped_iterator(const mapped_iterator &It) + : current(It.current), Fn(It.Fn) {} + + inline value_type operator*() const { // All this work to do this + return Fn(*current); // little change + } + + _Self& operator++() { ++current; return *this; } + _Self& operator--() { --current; return *this; } + _Self operator++(int) { _Self __tmp = *this; ++current; return __tmp; } + _Self operator--(int) { _Self __tmp = *this; --current; return __tmp; } + _Self operator+ (difference_type n) const { return _Self(current + n); } + _Self& operator+= (difference_type n) { current += n; return *this; } + _Self operator- (difference_type n) const { return _Self(current - n); } + _Self& operator-= (difference_type n) { current -= n; return *this; } + reference operator[](difference_type n) const { return *(*this + n); } + + inline bool operator==(const _Self &X) const { return current == X.current; } + inline bool operator< (const _Self &X) const { return current < X.current; } + + inline difference_type operator-(const _Self &X) const { + return current - X.current; + } +}; + +template +inline mapped_iterator<_Iterator, Func> +operator+(typename mapped_iterator<_Iterator, Func>::difference_type N, + const mapped_iterator<_Iterator, Func>& X) { + return mapped_iterator<_Iterator, Func>(X.getCurrent() - N); +} + +#else + +// This fails to work, because some iterators are not classes, for example +// vector iterators are commonly value_type **'s +template +class mapped_iterator : public RootIt { + UnaryFunc Fn; +public: + typedef typename UnaryFunc::result_type value_type; + typedef typename UnaryFunc::result_type *pointer; + typedef void reference; // Can't modify value returned by fn + + typedef mapped_iterator _Self; + typedef RootIt super; + inline explicit mapped_iterator(const RootIt &I) : super(I) {} + inline mapped_iterator(const super &It) : super(It) {} + + inline value_type operator*() const { // All this work to do + return Fn(super::operator*()); // this little thing + } +}; +#endif + +// map_iterator - Provide a convenient way to create mapped_iterators, just like +// make_pair is useful for creating pairs... +// +template +inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { + return mapped_iterator(I, F); +} + + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// apply_until - Apply a functor to a sequence continually, unless the +// functor returns true. Return true if the functor returned true, return false +// if the functor never returned true. +// +template +bool apply_until(InputIt First, InputIt Last, Function Func) { + for ( ; First != Last; ++First) + if (Func(*First)) return true; + return false; +} + + +// reduce - Reduce a sequence values into a single value, given an initial +// value and an operator. +// +template +ValueType reduce(InputIt First, InputIt Last, Function Func, ValueType Value) { + for ( ; First != Last; ++First) + Value = Func(*First, Value); + return Value; +} + +#if 1 // This is likely to be more efficient + +// reduce_apply - Reduce the result of applying a function to each value in a +// sequence, given an initial value, an operator, a function, and a sequence. +// +template +inline ValueType reduce_apply(InputIt First, InputIt Last, Function Func, + ValueType Value, TransFunc XForm) { + for ( ; First != Last; ++First) + Value = Func(XForm(*First), Value); + return Value; +} + +#else // This is arguably more elegant + +// reduce_apply - Reduce the result of applying a function to each value in a +// sequence, given an initial value, an operator, a function, and a sequence. +// +template +inline ValueType reduce_apply2(InputIt First, InputIt Last, Function Func, + ValueType Value, TransFunc XForm) { + return reduce(map_iterator(First, XForm), map_iterator(Last, XForm), + Func, Value); +} +#endif + + +// reduce_apply_bool - Reduce the result of applying a (bool returning) function +// to each value in a sequence. All of the bools returned by the mapped +// function are bitwise or'd together, and the result is returned. +// +template +inline bool reduce_apply_bool(InputIt First, InputIt Last, Function Func) { + return reduce_apply(First, Last, bitwise_or(), false, Func); +} + + +// map - This function maps the specified input sequence into the specified +// output iterator, applying a unary function in between. +// +template +inline OutIt mapto(InIt Begin, InIt End, OutIt Dest, Functor F) { + return copy(map_iterator(Begin, F), map_iterator(End, F), Dest); +} +#endif diff --git a/include/Support/StringExtras.h b/include/Support/StringExtras.h new file mode 100644 index 0000000000..e67e25ced5 --- /dev/null +++ b/include/Support/StringExtras.h @@ -0,0 +1,69 @@ +//===-- Support/StringExtras.h - Useful string functions ---------*- C++ -*--=// +// +// This file contains some functions that are useful when dealing with strings. +// +//===----------------------------------------------------------------------===// + +#ifndef SUPPORT_STRING_EXTRAS_H +#define SUPPORT_STRING_EXTRAS_H + +#include "Support/DataTypes.h" +#include +#include + +static inline string utostr(uint64_t X, bool isNeg = false) { + char Buffer[40]; + char *BufPtr = Buffer+39; + + *BufPtr = 0; // Null terminate buffer... + if (X == 0) *--BufPtr = '0'; // Handle special case... + + while (X) { + *--BufPtr = '0' + (X % 10); + X /= 10; + } + + if (isNeg) *--BufPtr = '-'; // Add negative sign... + + return string(BufPtr); +} + +static inline string itostr(int64_t X) { + if (X < 0) + return utostr((uint64_t)-X, true); + else + return utostr((uint64_t)X); +} + + +static inline string utostr(unsigned X, bool isNeg = false) { + char Buffer[20]; + char *BufPtr = Buffer+19; + + *BufPtr = 0; // Null terminate buffer... + if (X == 0) *--BufPtr = '0'; // Handle special case... + + while (X) { + *--BufPtr = '0' + (X % 10); + X /= 10; + } + + if (isNeg) *--BufPtr = '-'; // Add negative sign... + + return string(BufPtr); +} + +static inline string itostr(int X) { + if (X < 0) + return utostr((unsigned)-X, true); + else + return utostr((unsigned)X); +} + +static inline string ftostr(double V) { + char Buffer[200]; + snprintf(Buffer, 200, "%e", V); + return Buffer; +} + +#endif diff --git a/include/Support/Tree.h b/include/Support/Tree.h new file mode 100644 index 0000000000..33b0bb7b03 --- /dev/null +++ b/include/Support/Tree.h @@ -0,0 +1,52 @@ +//===- Support/Tree.h - Generic n-way tree structure -------------*- C++ -*--=// +// +// This class defines a generic N way tree node structure. The tree structure +// is immutable after creation, but the payload contained within it is not. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_TREE_H +#define LLVM_SUPPORT_TREE_H + +#include + +template +class Tree { + vector Children; // This nodes children, if any + ConcreteTreeNode *Parent; // Parent of this node... + Payload Data; // Data held in this node... + +protected: + void setChildren(const vector &children) { + Children = children; + } +public: + inline Tree(ConcreteTreeNode *parent) : Parent(parent) {} + inline Tree(const vector &children, ConcreteTreeNode *par) + : Children(children), Parent(par) {} + + inline Tree(const vector &children, ConcreteTreeNode *par, + const Payload &data) + : Children(children), Parent(parent), Data(data) {} + + // Tree dtor - Free all children + inline ~Tree() { + for (unsigned i = Children.size(); i > 0; --i) + delete Children[i-1]; + } + + // Tree manipulation/walking routines... + inline ConcreteTreeNode *getParent() const { return Parent; } + inline unsigned getNumChildren() const { return Children.size(); } + inline ConcreteTreeNode *getChild(unsigned i) const { + assert(i < Children.size() && "Tree::getChild with index out of range!"); + return Children[i]; + } + + // Payload access... + inline Payload &getTreeData() { return Data; } + inline const Payload &getTreeData() const { return Data; } +}; + + +#endif diff --git a/include/llvm/ADT/DepthFirstIterator.h b/include/llvm/ADT/DepthFirstIterator.h new file mode 100644 index 0000000000..a2d5a9df68 --- /dev/null +++ b/include/llvm/ADT/DepthFirstIterator.h @@ -0,0 +1,147 @@ +//===- Support/DepthFirstIterator.h - Depth First iterator -------*- C++ -*--=// +// +// This file builds on the Support/GraphTraits.h file to build generic depth +// first graph iterator. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_DEPTH_FIRST_ITERATOR_H +#define LLVM_SUPPORT_DEPTH_FIRST_ITERATOR_H + +#include "Support/GraphTraits.h" +#include +#include +#include + +// Generic Depth First Iterator +template > +class df_iterator : public std::forward_iterator { + typedef typename GT::NodeType NodeType; + typedef typename GT::ChildIteratorType ChildItTy; + + set Visited; // All of the blocks visited so far... + // VisitStack - Used to maintain the ordering. Top = current block + // First element is node pointer, second is the 'next child' to visit + stack > VisitStack; + const bool Reverse; // Iterate over children before self? +private: + void reverseEnterNode() { + pair &Top = VisitStack.top(); + NodeType *Node = Top.first; + ChildItTy &It = Top.second; + for (; It != GT::child_end(Node); ++It) { + NodeType *Child = *It; + if (!Visited.count(Child)) { + Visited.insert(Child); + VisitStack.push(make_pair(Child, GT::child_begin(Child))); + reverseEnterNode(); + return; + } + } + } + + inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) { + Visited.insert(Node); + VisitStack.push(make_pair(Node, GT::child_begin(Node))); + if (Reverse) reverseEnterNode(); + } + inline df_iterator() { /* End is when stack is empty */ } + +public: + typedef df_iterator _Self; + + // Provide static begin and end methods as our public "constructors" + static inline _Self begin(GraphT G, bool Reverse = false) { + return _Self(GT::getEntryNode(G), Reverse); + } + static inline _Self end(GraphT G) { return _Self(); } + + + inline bool operator==(const _Self& x) const { + return VisitStack == x.VisitStack; + } + inline bool operator!=(const _Self& x) const { return !operator==(x); } + + inline pointer operator*() const { + return VisitStack.top().first; + } + + // This is a nonstandard operator-> that dereferences the pointer an extra + // time... so that you can actually call methods ON the Node, because + // the contained type is a pointer. This allows BBIt->getTerminator() f.e. + // + inline NodeType *operator->() const { return operator*(); } + + inline _Self& operator++() { // Preincrement + if (Reverse) { // Reverse Depth First Iterator + if (VisitStack.top().second == GT::child_end(VisitStack.top().first)) + VisitStack.pop(); + if (!VisitStack.empty()) + reverseEnterNode(); + } else { // Normal Depth First Iterator + do { + pair &Top = VisitStack.top(); + NodeType *Node = Top.first; + ChildItTy &It = Top.second; + + while (It != GT::child_end(Node)) { + NodeType *Next = *It++; + if (!Visited.count(Next)) { // Has our next sibling been visited? + // No, do it now. + Visited.insert(Next); + VisitStack.push(make_pair(Next, GT::child_begin(Next))); + return *this; + } + } + + // Oops, ran out of successors... go up a level on the stack. + VisitStack.pop(); + } while (!VisitStack.empty()); + } + return *this; + } + + inline _Self operator++(int) { // Postincrement + _Self tmp = *this; ++*this; return tmp; + } + + // nodeVisited - return true if this iterator has already visited the + // specified node. This is public, and will probably be used to iterate over + // nodes that a depth first iteration did not find: ie unreachable nodes. + // + inline bool nodeVisited(NodeType *Node) const { + return Visited.count(Node) != 0; + } +}; + + +// Provide global constructors that automatically figure out correct types... +// +template +df_iterator df_begin(T G, bool Reverse = false) { + return df_iterator::begin(G, Reverse); +} + +template +df_iterator df_end(T G) { + return df_iterator::end(G); +} + +// Provide global definitions of inverse depth first iterators... +template +struct idf_iterator : public df_iterator > { + idf_iterator(const df_iterator > &V) :df_iterator >(V){} +}; + +template +idf_iterator idf_begin(T G, bool Reverse = false) { + return idf_iterator::begin(G, Reverse); +} + +template +idf_iterator idf_end(T G){ + return idf_iterator::end(G); +} + +#endif diff --git a/include/llvm/ADT/GraphTraits.h b/include/llvm/ADT/GraphTraits.h new file mode 100644 index 0000000000..00973d59fa --- /dev/null +++ b/include/llvm/ADT/GraphTraits.h @@ -0,0 +1,65 @@ +//===-- Support/GraphTraits.h - Graph traits template ------------*- C++ -*--=// +// +// This file defines the little GraphTraits template class that should be +// specialized by classes that want to be iteratable by generic graph iterators. +// +// This file also defines the marker class Inverse that is used to iterate over +// graphs in a graph defined, inverse ordering... +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_GRAPH_TRAITS_H +#define LLVM_SUPPORT_GRAPH_TRAITS_H + +// GraphTraits - This class should be specialized by different graph types... +// which is why the default version is empty. +// +template +struct GraphTraits { + // Elements to provide: + + // typedef NodeType - Type of Node in the graph + // typedef ChildIteratorType - Type used to iterate over children in graph + + // static NodeType *getEntryNode(GraphType *) + // Return the entry node of the graph + + // static ChildIteratorType child_begin(NodeType *) + // static ChildIteratorType child_end (NodeType *) + // Return iterators that point to the beginning and ending of the child + // node list for the specified node. + // + + + // If anyone tries to use this class without having an appropriate + // specialization, make an error. If you get this error, it's because you + // need to include the appropriate specialization of GraphTraits<> for your + // graph, or you need to define it for a new graph type. Either that or + // your argument to XXX_begin(...) is unknown or needs to have the proper .h + // file #include'd. + // + typedef typename GraphType::UnknownGraphTypeError NodeType; +}; + + +// Inverse - This class is used as a little marker class to tell the graph +// iterator to iterate over the graph in a graph defined "Inverse" ordering. +// Not all graphs define an inverse ordering, and if they do, it depends on +// the graph exactly what that is. Here's an example of usage with the +// df_iterator: +// +// idf_iterator I = idf_begin(M), E = idf_end(M); +// for (; I != E; ++I) { ... } +// +// Which is equivalent to: +// df_iterator > I = idf_begin(M), E = idf_end(M); +// for (; I != E; ++I) { ... } +// +template +struct Inverse { + GraphType &Graph; + + inline Inverse(GraphType &G) : Graph(G) {} +}; + +#endif diff --git a/include/llvm/ADT/HashExtras.h b/include/llvm/ADT/HashExtras.h new file mode 100644 index 0000000000..6ea831e78f --- /dev/null +++ b/include/llvm/ADT/HashExtras.h @@ -0,0 +1,27 @@ +//===-- HashExtras.h - Useful functions for STL hash containers --*- C++ -*--=// +// +// This file contains some templates that are useful if you are working with the +// STL Hashed containers. +// +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_HASHEXTRAS_H +#define LLVM_SUPPORT_HASHEXTRAS_H + +#include +#include + +template <> struct hash { + size_t operator()(string const &str) const { + return hash()(str.c_str()); + } +}; + +// Provide a hash function for arbitrary pointers... +template struct hash { + inline size_t operator()(const T *Val) const { return (size_t)Val; } +}; + +#endif diff --git a/include/llvm/ADT/PostOrderIterator.h b/include/llvm/ADT/PostOrderIterator.h new file mode 100644 index 0000000000..89a9b4db86 --- /dev/null +++ b/include/llvm/ADT/PostOrderIterator.h @@ -0,0 +1,145 @@ +//===-- Support/PostOrderIterator.h - Generic PostOrder iterator -*- C++ -*--=// +// +// This file builds on the Support/GraphTraits.h file to build a generic graph +// post order iterator. This should work over any graph type that has a +// GraphTraits specialization. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_POSTORDER_ITERATOR_H +#define LLVM_SUPPORT_POSTORDER_ITERATOR_H + +#include "Support/GraphTraits.h" +#include +#include +#include + +template > +class po_iterator : public std::forward_iterator { + typedef typename GT::NodeType NodeType; + typedef typename GT::ChildIteratorType ChildItTy; + + set Visited; // All of the blocks visited so far... + // VisitStack - Used to maintain the ordering. Top = current block + // First element is basic block pointer, second is the 'next child' to visit + stack > VisitStack; + + void traverseChild() { + while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) { + NodeType *BB = *VisitStack.top().second++; + if (!Visited.count(BB)) { // If the block is not visited... + Visited.insert(BB); + VisitStack.push(make_pair(BB, GT::child_begin(BB))); + } + } + } + + inline po_iterator(NodeType *BB) { + Visited.insert(BB); + VisitStack.push(make_pair(BB, GT::child_begin(BB))); + traverseChild(); + } + inline po_iterator() { /* End is when stack is empty */ } +public: + typedef po_iterator _Self; + + // Provide static "constructors"... + static inline _Self begin(GraphT G) { return _Self(GT::getEntryNode(G)); } + static inline _Self end (GraphT G) { return _Self(); } + + inline bool operator==(const _Self& x) const { + return VisitStack == x.VisitStack; + } + inline bool operator!=(const _Self& x) const { return !operator==(x); } + + inline pointer operator*() const { + return VisitStack.top().first; + } + + // This is a nonstandard operator-> that dereferences the pointer an extra + // time... so that you can actually call methods ON the BasicBlock, because + // the contained type is a pointer. This allows BBIt->getTerminator() f.e. + // + inline NodeType *operator->() const { return operator*(); } + + inline _Self& operator++() { // Preincrement + VisitStack.pop(); + if (!VisitStack.empty()) + traverseChild(); + return *this; + } + + inline _Self operator++(int) { // Postincrement + _Self tmp = *this; ++*this; return tmp; + } +}; + +// Provide global constructors that automatically figure out correct types... +// +template +po_iterator po_begin(T G) { return po_iterator::begin(G); } +template +po_iterator po_end (T G) { return po_iterator::end(G); } + +// Provide global definitions of inverse post order iterators... +template +struct ipo_iterator : public po_iterator > { + ipo_iterator(const po_iterator > &V) :po_iterator >(V){} +}; + +template +ipo_iterator ipo_begin(T G, bool Reverse = false) { + return ipo_iterator::begin(G, Reverse); +} + +template +ipo_iterator ipo_end(T G){ + return ipo_iterator::end(G); +} + + +//===--------------------------------------------------------------------===// +// Reverse Post Order CFG iterator code +//===--------------------------------------------------------------------===// +// +// This is used to visit basic blocks in a method in reverse post order. This +// class is awkward to use because I don't know a good incremental algorithm to +// computer RPO from a graph. Because of this, the construction of the +// ReversePostOrderTraversal object is expensive (it must walk the entire graph +// with a postorder iterator to build the data structures). The moral of this +// story is: Don't create more ReversePostOrderTraversal classes than neccesary. +// +// This class should be used like this: +// { +// cfg::ReversePostOrderTraversal RPOT(MethodPtr); // Expensive to create +// for (cfg::rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { +// ... +// } +// for (cfg::rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { +// ... +// } +// } +// + +typedef reverse_iterator::iterator> rpo_iterator; +// TODO: FIXME: ReversePostOrderTraversal is not generic! +class ReversePostOrderTraversal { + vector Blocks; // Block list in normal PO order + inline void Initialize(BasicBlock *BB) { + copy(po_begin(BB), po_end(BB), back_inserter(Blocks)); + } +public: + inline ReversePostOrderTraversal(Method *M) { + Initialize(M->front()); + } + inline ReversePostOrderTraversal(BasicBlock *BB) { + Initialize(BB); + } + + // Because we want a reverse post order, use reverse iterators from the vector + inline rpo_iterator begin() { return Blocks.rbegin(); } + inline rpo_iterator end() { return Blocks.rend(); } +}; + +#endif diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h new file mode 100644 index 0000000000..44d789dcf2 --- /dev/null +++ b/include/llvm/ADT/STLExtras.h @@ -0,0 +1,222 @@ +//===-- STLExtras.h - Useful functions when working with the STL -*- C++ -*--=// +// +// This file contains some templates that are useful if you are working with the +// STL at all. +// +// No library is required when using these functinons. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_STL_EXTRAS_H +#define LLVM_SUPPORT_STL_EXTRAS_H + +#include + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// bind_obj - Often times you want to apply the member function of an object +// as a unary functor. This macro is shorthand that makes it happen less +// verbosely. +// +// Example: +// struct Summer { void accumulate(int x); } +// vector Numbers; +// Summer MyS; +// for_each(Numbers.begin(), Numbers.end(), +// bind_obj(&MyS, &Summer::accumulate)); +// +// TODO: When I get lots of extra time, convert this from an evil macro +// +#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ) + + +// bitwise_or - This is a simple functor that applys operator| on its two +// arguments to get a boolean result. +// +template +struct bitwise_or : public binary_function { + bool operator()(const Ty& left, const Ty& right) const { + return left | right; + } +}; + + +// deleter - Very very very simple method that is used to invoke operator +// delete on something. It is used like this: +// +// for_each(V.begin(), B.end(), deleter); +// +template +static inline void deleter(T *Ptr) { + delete Ptr; +} + + + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// mapped_iterator - This is a simple iterator adapter that causes a function to +// be dereferenced whenever operator* is invoked on the iterator. +// +// It turns out that this is disturbingly similar to boost::transform_iterator +// +#if 1 +template +class mapped_iterator { + RootIt current; + UnaryFunc Fn; +public: + typedef typename iterator_traits::iterator_category + iterator_category; + typedef typename iterator_traits::difference_type + difference_type; + typedef typename UnaryFunc::result_type value_type; + typedef typename UnaryFunc::result_type *pointer; + typedef void reference; // Can't modify value returned by fn + + typedef RootIt iterator_type; + typedef mapped_iterator _Self; + + inline RootIt &getCurrent() const { return current; } + + inline explicit mapped_iterator(const RootIt &I, UnaryFunc F) + : current(I), Fn(F) {} + inline mapped_iterator(const mapped_iterator &It) + : current(It.current), Fn(It.Fn) {} + + inline value_type operator*() const { // All this work to do this + return Fn(*current); // little change + } + + _Self& operator++() { ++current; return *this; } + _Self& operator--() { --current; return *this; } + _Self operator++(int) { _Self __tmp = *this; ++current; return __tmp; } + _Self operator--(int) { _Self __tmp = *this; --current; return __tmp; } + _Self operator+ (difference_type n) const { return _Self(current + n); } + _Self& operator+= (difference_type n) { current += n; return *this; } + _Self operator- (difference_type n) const { return _Self(current - n); } + _Self& operator-= (difference_type n) { current -= n; return *this; } + reference operator[](difference_type n) const { return *(*this + n); } + + inline bool operator==(const _Self &X) const { return current == X.current; } + inline bool operator< (const _Self &X) const { return current < X.current; } + + inline difference_type operator-(const _Self &X) const { + return current - X.current; + } +}; + +template +inline mapped_iterator<_Iterator, Func> +operator+(typename mapped_iterator<_Iterator, Func>::difference_type N, + const mapped_iterator<_Iterator, Func>& X) { + return mapped_iterator<_Iterator, Func>(X.getCurrent() - N); +} + +#else + +// This fails to work, because some iterators are not classes, for example +// vector iterators are commonly value_type **'s +template +class mapped_iterator : public RootIt { + UnaryFunc Fn; +public: + typedef typename UnaryFunc::result_type value_type; + typedef typename UnaryFunc::result_type *pointer; + typedef void reference; // Can't modify value returned by fn + + typedef mapped_iterator _Self; + typedef RootIt super; + inline explicit mapped_iterator(const RootIt &I) : super(I) {} + inline mapped_iterator(const super &It) : super(It) {} + + inline value_type operator*() const { // All this work to do + return Fn(super::operator*()); // this little thing + } +}; +#endif + +// map_iterator - Provide a convenient way to create mapped_iterators, just like +// make_pair is useful for creating pairs... +// +template +inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { + return mapped_iterator(I, F); +} + + +//===----------------------------------------------------------------------===// +// Extra additions to +//===----------------------------------------------------------------------===// + +// apply_until - Apply a functor to a sequence continually, unless the +// functor returns true. Return true if the functor returned true, return false +// if the functor never returned true. +// +template +bool apply_until(InputIt First, InputIt Last, Function Func) { + for ( ; First != Last; ++First) + if (Func(*First)) return true; + return false; +} + + +// reduce - Reduce a sequence values into a single value, given an initial +// value and an operator. +// +template +ValueType reduce(InputIt First, InputIt Last, Function Func, ValueType Value) { + for ( ; First != Last; ++First) + Value = Func(*First, Value); + return Value; +} + +#if 1 // This is likely to be more efficient + +// reduce_apply - Reduce the result of applying a function to each value in a +// sequence, given an initial value, an operator, a function, and a sequence. +// +template +inline ValueType reduce_apply(InputIt First, InputIt Last, Function Func, + ValueType Value, TransFunc XForm) { + for ( ; First != Last; ++First) + Value = Func(XForm(*First), Value); + return Value; +} + +#else // This is arguably more elegant + +// reduce_apply - Reduce the result of applying a function to each value in a +// sequence, given an initial value, an operator, a function, and a sequence. +// +template +inline ValueType reduce_apply2(InputIt First, InputIt Last, Function Func, + ValueType Value, TransFunc XForm) { + return reduce(map_iterator(First, XForm), map_iterator(Last, XForm), + Func, Value); +} +#endif + + +// reduce_apply_bool - Reduce the result of applying a (bool returning) function +// to each value in a sequence. All of the bools returned by the mapped +// function are bitwise or'd together, and the result is returned. +// +template +inline bool reduce_apply_bool(InputIt First, InputIt Last, Function Func) { + return reduce_apply(First, Last, bitwise_or(), false, Func); +} + + +// map - This function maps the specified input sequence into the specified +// output iterator, applying a unary function in between. +// +template +inline OutIt mapto(InIt Begin, InIt End, OutIt Dest, Functor F) { + return copy(map_iterator(Begin, F), map_iterator(End, F), Dest); +} +#endif diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h new file mode 100644 index 0000000000..e67e25ced5 --- /dev/null +++ b/include/llvm/ADT/StringExtras.h @@ -0,0 +1,69 @@ +//===-- Support/StringExtras.h - Useful string functions ---------*- C++ -*--=// +// +// This file contains some functions that are useful when dealing with strings. +// +//===----------------------------------------------------------------------===// + +#ifndef SUPPORT_STRING_EXTRAS_H +#define SUPPORT_STRING_EXTRAS_H + +#include "Support/DataTypes.h" +#include +#include + +static inline string utostr(uint64_t X, bool isNeg = false) { + char Buffer[40]; + char *BufPtr = Buffer+39; + + *BufPtr = 0; // Null terminate buffer... + if (X == 0) *--BufPtr = '0'; // Handle special case... + + while (X) { + *--BufPtr = '0' + (X % 10); + X /= 10; + } + + if (isNeg) *--BufPtr = '-'; // Add negative sign... + + return string(BufPtr); +} + +static inline string itostr(int64_t X) { + if (X < 0) + return utostr((uint64_t)-X, true); + else + return utostr((uint64_t)X); +} + + +static inline string utostr(unsigned X, bool isNeg = false) { + char Buffer[20]; + char *BufPtr = Buffer+19; + + *BufPtr = 0; // Null terminate buffer... + if (X == 0) *--BufPtr = '0'; // Handle special case... + + while (X) { + *--BufPtr = '0' + (X % 10); + X /= 10; + } + + if (isNeg) *--BufPtr = '-'; // Add negative sign... + + return string(BufPtr); +} + +static inline string itostr(int X) { + if (X < 0) + return utostr((unsigned)-X, true); + else + return utostr((unsigned)X); +} + +static inline string ftostr(double V) { + char Buffer[200]; + snprintf(Buffer, 200, "%e", V); + return Buffer; +} + +#endif diff --git a/include/llvm/ADT/Tree.h b/include/llvm/ADT/Tree.h new file mode 100644 index 0000000000..33b0bb7b03 --- /dev/null +++ b/include/llvm/ADT/Tree.h @@ -0,0 +1,52 @@ +//===- Support/Tree.h - Generic n-way tree structure -------------*- C++ -*--=// +// +// This class defines a generic N way tree node structure. The tree structure +// is immutable after creation, but the payload contained within it is not. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_TREE_H +#define LLVM_SUPPORT_TREE_H + +#include + +template +class Tree { + vector Children; // This nodes children, if any + ConcreteTreeNode *Parent; // Parent of this node... + Payload Data; // Data held in this node... + +protected: + void setChildren(const vector &children) { + Children = children; + } +public: + inline Tree(ConcreteTreeNode *parent) : Parent(parent) {} + inline Tree(const vector &children, ConcreteTreeNode *par) + : Children(children), Parent(par) {} + + inline Tree(const vector &children, ConcreteTreeNode *par, + const Payload &data) + : Children(children), Parent(parent), Data(data) {} + + // Tree dtor - Free all children + inline ~Tree() { + for (unsigned i = Children.size(); i > 0; --i) + delete Children[i-1]; + } + + // Tree manipulation/walking routines... + inline ConcreteTreeNode *getParent() const { return Parent; } + inline unsigned getNumChildren() const { return Children.size(); } + inline ConcreteTreeNode *getChild(unsigned i) const { + assert(i < Children.size() && "Tree::getChild with index out of range!"); + return Children[i]; + } + + // Payload access... + inline Payload &getTreeData() { return Data; } + inline const Payload &getTreeData() const { return Data; } +}; + + +#endif diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 62b1846952..8365a4f397 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -16,7 +16,7 @@ #ifndef LLVM_ANALYSIS_CALLGRAPH_H #define LLVM_ANALYSIS_CALLGRAPH_H -#include "llvm/Support/GraphTraits.h" +#include "Support/GraphTraits.h" #include #include class Method; diff --git a/include/llvm/Analysis/InstForest.h b/include/llvm/Analysis/InstForest.h index 967ed45ec9..497bb46188 100644 --- a/include/llvm/Analysis/InstForest.h +++ b/include/llvm/Analysis/InstForest.h @@ -14,8 +14,8 @@ #ifndef LLVM_ANALYSIS_INSTFOREST_H #define LLVM_ANALYSIS_INSTFOREST_H -#include "llvm/Support/Tree.h" #include "llvm/Instruction.h" +#include "Support/Tree.h" #include namespace analysis { diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index cf29cbd00e..df9447fb09 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -24,8 +24,8 @@ #include "llvm/Value.h" #include "llvm/ValueHolder.h" -#include "llvm/Support/GraphTraits.h" #include "llvm/InstrTypes.h" +#include "Support/GraphTraits.h" #include class Instruction; diff --git a/include/llvm/CodeGen/InstrForest.h b/include/llvm/CodeGen/InstrForest.h index 1b9af714b9..e7bd3ad145 100644 --- a/include/llvm/CodeGen/InstrForest.h +++ b/include/llvm/CodeGen/InstrForest.h @@ -24,9 +24,9 @@ #ifndef LLVM_CODEGEN_INSTRFOREST_H #define LLVM_CODEGEN_INSTRFOREST_H -#include "llvm/Support/NonCopyable.h" -#include "llvm/Support/HashExtras.h" #include "llvm/Instruction.h" +#include "Support/NonCopyable.h" +#include "Support/HashExtras.h" #include #include diff --git a/include/llvm/CodeGen/InstrScheduling.h b/include/llvm/CodeGen/InstrScheduling.h index 8f88a61590..69390fae96 100644 --- a/include/llvm/CodeGen/InstrScheduling.h +++ b/include/llvm/CodeGen/InstrScheduling.h @@ -12,8 +12,8 @@ #ifndef LLVM_CODEGEN_INSTR_SCHEDULING_H #define LLVM_CODEGEN_INSTR_SCHEDULING_H -#include "llvm/Support/CommandLine.h" #include "llvm/CodeGen/MachineInstr.h" +#include "Support/CommandLine.h" class Method; class SchedulingManager; diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 91ae9def7f..a20431848e 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -15,13 +15,13 @@ #ifndef LLVM_CODEGEN_MACHINEINSTR_H #define LLVM_CODEGEN_MACHINEINSTR_H -#include -#include "llvm/CodeGen/InstrForest.h" #include "Support/DataTypes.h" -#include "llvm/Support/NonCopyable.h" +#include "Support/NonCopyable.h" +#include "llvm/CodeGen/InstrForest.h" #include "llvm/Target/MachineInstrInfo.h" #include "llvm/Annotation.h" #include "llvm/Method.h" +#include #include #include #include diff --git a/include/llvm/CodeGen/RegAllocCommon.h b/include/llvm/CodeGen/RegAllocCommon.h index 5fa51c034f..02b3331132 100644 --- a/include/llvm/CodeGen/RegAllocCommon.h +++ b/include/llvm/CodeGen/RegAllocCommon.h @@ -1,5 +1,5 @@ -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" #ifndef REG_ALLOC_COMMON_H #define REG_ALLOC_COMMON_H diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h new file mode 100644 index 0000000000..84a3bc9b59 --- /dev/null +++ b/include/llvm/Support/CommandLine.h @@ -0,0 +1,399 @@ +//===- Support/CommandLine.h - Flexible Command line parser ------*- C++ -*--=// +// +// This class implements a command line argument processor that is useful when +// creating a tool. It provides a simple, minimalistic interface that is easily +// extensible and supports nonlocal (library) command line options. +// +// Note that rather than trying to figure out what this code does, you could try +// reading the library documentation located in docs/CommandLine.html +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_COMMANDLINE_H +#define LLVM_SUPPORT_COMMANDLINE_H + +#include +#include +#include +#include + +namespace cl { // Short namespace to make usage concise + +//===----------------------------------------------------------------------===// +// ParseCommandLineOptions - Minimalistic command line option processing entry +// +void cl::ParseCommandLineOptions(int &argc, char **argv, + const char *Overview = 0, + int Flags = 0); + +// ParserOptions - This set of option is use to control global behavior of the +// command line processor. +// +enum ParserOptions { + // DisableSingleLetterArgGrouping - With this option enabled, multiple letter + // options are allowed to bunch together with only a single hyphen for the + // whole group. This allows emulation of the behavior that ls uses for + // example: ls -la === ls -l -a Providing this option, disables this. + // + DisableSingleLetterArgGrouping = 0x0001, + + // EnableSingleLetterArgValue - This option allows arguments that are + // otherwise unrecognized to match single letter flags that take a value. + // This is useful for cases like a linker, where options are typically of the + // form '-lfoo' or '-L../../include' where -l or -L are the actual flags. + // + EnableSingleLetterArgValue = 0x0002, +}; + + +//===----------------------------------------------------------------------===// +// Global flags permitted to be passed to command line arguments + +enum FlagsOptions { + NoFlags = 0x00, // Marker to make explicit that we have no flags + Default = 0x00, // Equally, marker to use the default flags + + GlobalsMask = 0x80, +}; + +enum NumOccurances { // Flags for the number of occurances allowed... + Optional = 0x01, // Zero or One occurance + ZeroOrMore = 0x02, // Zero or more occurances allowed + Required = 0x03, // One occurance required + OneOrMore = 0x04, // One or more occurances required + + // ConsumeAfter - Marker for a null ("") flag that can be used to indicate + // that anything that matches the null marker starts a sequence of options + // that all get sent to the null marker. Thus, for example, all arguments + // to LLI are processed until a filename is found. Once a filename is found, + // all of the succeeding arguments are passed, unprocessed, to the null flag. + // + ConsumeAfter = 0x05, + + OccurancesMask = 0x07, +}; + +enum ValueExpected { // Is a value required for the option? + ValueOptional = 0x08, // The value can oppear... or not + ValueRequired = 0x10, // The value is required to appear! + ValueDisallowed = 0x18, // A value may not be specified (for flags) + ValueMask = 0x18, +}; + +enum OptionHidden { // Control whether -help shows this option + NotHidden = 0x20, // Option included in --help & --help-hidden + Hidden = 0x40, // -help doesn't, but --help-hidden does + ReallyHidden = 0x60, // Neither --help nor --help-hidden show this arg + HiddenMask = 0x60, +}; + + +//===----------------------------------------------------------------------===// +// Option Base class +// +class Alias; +class Option { + friend void cl::ParseCommandLineOptions(int &, char **, const char *, int); + friend class Alias; + + // handleOccurances - Overriden by subclasses to handle the value passed into + // an argument. Should return true if there was an error processing the + // argument and the program should exit. + // + virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0; + + virtual enum NumOccurances getNumOccurancesFlagDefault() const { + return Optional; + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueOptional; + } + virtual enum OptionHidden getOptionHiddenFlagDefault() const { + return NotHidden; + } + + int NumOccurances; // The number of times specified + const int Flags; // Flags for the argument +public: + const char * const ArgStr; // The argument string itself (ex: "help", "o") + const char * const HelpStr; // The descriptive text message for --help + + inline enum NumOccurances getNumOccurancesFlag() const { + int NO = Flags & OccurancesMask; + return NO ? (enum NumOccurances)NO : getNumOccurancesFlagDefault(); + } + inline enum ValueExpected getValueExpectedFlag() const { + int VE = Flags & ValueMask; + return VE ? (enum ValueExpected)VE : getValueExpectedFlagDefault(); + } + inline enum OptionHidden getOptionHiddenFlag() const { + int OH = Flags & HiddenMask; + return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault(); + } + +protected: + Option(const char *ArgStr, const char *Message, int Flags); + Option(int flags) : NumOccurances(0), Flags(flags), ArgStr(""), HelpStr("") {} + +public: + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; + + // addOccurance - Wrapper around handleOccurance that enforces Flags + // + bool addOccurance(const char *ArgName, const string &Value); + + // Prints option name followed by message. Always returns true. + bool error(string Message, const char *ArgName = 0); + +public: + inline int getNumOccurances() const { return NumOccurances; } + virtual ~Option() {} +}; + + +//===----------------------------------------------------------------------===// +// Aliased command line option (alias this name to a preexisting name) +// +class Alias : public Option { + Option &AliasFor; + virtual bool handleOccurance(const char *ArgName, const string &Arg) { + return AliasFor.handleOccurance(AliasFor.ArgStr, Arg); + } + virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} +public: + inline Alias(const char *ArgStr, const char *Message, int Flags, + Option &aliasFor) : Option(ArgStr, Message, Flags), + AliasFor(aliasFor) {} +}; + +//===----------------------------------------------------------------------===// +// Boolean/flag command line option +// +class Flag : public Option { + bool Value; + virtual bool handleOccurance(const char *ArgName, const string &Arg); +public: + inline Flag(const char *ArgStr, const char *Message, int Flags = 0, + bool DefaultVal = 0) : Option(ArgStr, Message, Flags), + Value(DefaultVal) {} + operator const bool() const { return Value; } + inline bool operator=(bool Val) { Value = Val; return Val; } +}; + + + +//===----------------------------------------------------------------------===// +// Integer valued command line option +// +class Int : public Option { + int Value; + virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } +public: + inline Int(const char *ArgStr, const char *Help, int Flags = 0, + int DefaultVal = 0) : Option(ArgStr, Help, Flags), + Value(DefaultVal) {} + inline operator int() const { return Value; } + inline int operator=(int Val) { Value = Val; return Val; } +}; + + +//===----------------------------------------------------------------------===// +// String valued command line option +// +class String : public Option, public string { + virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } +public: + inline String(const char *ArgStr, const char *Help, int Flags = 0, + const char *DefaultVal = "") + : Option(ArgStr, Help, Flags), string(DefaultVal) {} + + inline const string &operator=(const string &Val) { + return string::operator=(Val); + } +}; + + +//===----------------------------------------------------------------------===// +// String list command line option +// +class StringList : public Option, public vector { + + virtual enum NumOccurances getNumOccurancesFlagDefault() const { + return ZeroOrMore; + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } + virtual bool handleOccurance(const char *ArgName, const string &Arg); + +public: + inline StringList(const char *ArgStr, const char *Help, int Flags = 0) + : Option(ArgStr, Help, Flags) {} +}; + + +//===----------------------------------------------------------------------===// +// Enum valued command line option +// +#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, ENUMVAL, DESC +#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, ENUMVAL, DESC + +// EnumBase - Base class for all enum/varargs related argument types... +class EnumBase : public Option { +protected: + // Use a vector instead of a map, because the lists should be short, + // the overhead is less, and most importantly, it keeps them in the order + // inserted so we can print our option out nicely. + vector > > ValueMap; + + inline EnumBase(const char *ArgStr, const char *Help, int Flags) + : Option(ArgStr, Help, Flags) {} + inline EnumBase(int Flags) : Option(Flags) {} + + // processValues - Incorporate the specifed varargs arglist into the + // ValueMap. + // + void processValues(va_list Vals); + + // registerArgs - notify the system about these new arguments + void registerArgs(); + +public: + // Turn an enum into the arg name that activates it + const char *getArgName(int ID) const; + const char *getArgDescription(int ID) const; +}; + +class EnumValueBase : public EnumBase { +protected: + int Value; + inline EnumValueBase(const char *ArgStr, const char *Help, int Flags) + : EnumBase(ArgStr, Help, Flags) {} + inline EnumValueBase(int Flags) : EnumBase(Flags) {} + + // handleOccurance - Set Value to the enum value specified by Arg + virtual bool handleOccurance(const char *ArgName, const string &Arg); + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; +}; + +template // The enum we are representing +class Enum : public EnumValueBase { + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } +public: + inline Enum(const char *ArgStr, int Flags, const char *Help, ...) + : EnumValueBase(ArgStr, Help, Flags) { + va_list Values; + va_start(Values, Help); + processValues(Values); + va_end(Values); + Value = ValueMap.front().second.first; // Grab default value + } + + inline operator E() const { return (E)Value; } + inline E operator=(E Val) { Value = Val; return Val; } +}; + + +//===----------------------------------------------------------------------===// +// Enum flags command line option +// +class EnumFlagsBase : public EnumValueBase { + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueDisallowed; + } +protected: + virtual bool handleOccurance(const char *ArgName, const string &Arg); + inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {} + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; +}; + +template // The enum we are representing +class EnumFlags : public EnumFlagsBase { +public: + inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags) { + va_list Values; + va_start(Values, Flags); + processValues(Values); + va_end(Values); + registerArgs(); + Value = ValueMap.front().second.first; // Grab default value + } + + inline operator E() const { return (E)Value; } + inline E operator=(E Val) { Value = Val; return Val; } +}; + + +//===----------------------------------------------------------------------===// +// Enum list command line option +// +class EnumListBase : public EnumBase { + virtual enum NumOccurances getNumOccurancesFlagDefault() const { + return ZeroOrMore; + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { + return ValueDisallowed; + } +protected: + vector Values; // The options specified so far. + + inline EnumListBase(int Flags) + : EnumBase(Flags) {} + virtual bool handleOccurance(const char *ArgName, const string &Arg); + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth() const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(unsigned GlobalWidth) const; +public: + inline unsigned size() { return Values.size(); } +}; + +template // The enum we are representing +class EnumList : public EnumListBase { +public: + inline EnumList(int Flags, ...) : EnumListBase(Flags) { + va_list Values; + va_start(Values, Flags); + processValues(Values); + va_end(Values); + registerArgs(); + } + inline E operator[](unsigned i) const { return (E)Values[i]; } + inline E &operator[](unsigned i) { return (E&)Values[i]; } +}; + +} // End namespace cl + +#endif diff --git a/include/llvm/Support/DepthFirstIterator.h b/include/llvm/Support/DepthFirstIterator.h deleted file mode 100644 index 73017067b3..0000000000 --- a/include/llvm/Support/DepthFirstIterator.h +++ /dev/null @@ -1,147 +0,0 @@ -//===- llvm/Support/DepthFirstIterator.h - Depth First iterators -*- C++ -*--=// -// -// This file builds on the Support/GraphTraits.h file to build generic depth -// first graph iterator. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_DEPTH_FIRST_ITERATOR_H -#define LLVM_SUPPORT_DEPTH_FIRST_ITERATOR_H - -#include "llvm/Support/GraphTraits.h" -#include -#include -#include - -// Generic Depth First Iterator -template > -class df_iterator : public std::forward_iterator { - typedef typename GT::NodeType NodeType; - typedef typename GT::ChildIteratorType ChildItTy; - - set Visited; // All of the blocks visited so far... - // VisitStack - Used to maintain the ordering. Top = current block - // First element is node pointer, second is the 'next child' to visit - stack > VisitStack; - const bool Reverse; // Iterate over children before self? -private: - void reverseEnterNode() { - pair &Top = VisitStack.top(); - NodeType *Node = Top.first; - ChildItTy &It = Top.second; - for (; It != GT::child_end(Node); ++It) { - NodeType *Child = *It; - if (!Visited.count(Child)) { - Visited.insert(Child); - VisitStack.push(make_pair(Child, GT::child_begin(Child))); - reverseEnterNode(); - return; - } - } - } - - inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) { - Visited.insert(Node); - VisitStack.push(make_pair(Node, GT::child_begin(Node))); - if (Reverse) reverseEnterNode(); - } - inline df_iterator() { /* End is when stack is empty */ } - -public: - typedef df_iterator _Self; - - // Provide static begin and end methods as our public "constructors" - static inline _Self begin(GraphT G, bool Reverse = false) { - return _Self(GT::getEntryNode(G), Reverse); - } - static inline _Self end(GraphT G) { return _Self(); } - - - inline bool operator==(const _Self& x) const { - return VisitStack == x.VisitStack; - } - inline bool operator!=(const _Self& x) const { return !operator==(x); } - - inline pointer operator*() const { - return VisitStack.top().first; - } - - // This is a nonstandard operator-> that dereferences the pointer an extra - // time... so that you can actually call methods ON the Node, because - // the contained type is a pointer. This allows BBIt->getTerminator() f.e. - // - inline NodeType *operator->() const { return operator*(); } - - inline _Self& operator++() { // Preincrement - if (Reverse) { // Reverse Depth First Iterator - if (VisitStack.top().second == GT::child_end(VisitStack.top().first)) - VisitStack.pop(); - if (!VisitStack.empty()) - reverseEnterNode(); - } else { // Normal Depth First Iterator - do { - pair &Top = VisitStack.top(); - NodeType *Node = Top.first; - ChildItTy &It = Top.second; - - while (It != GT::child_end(Node)) { - NodeType *Next = *It++; - if (!Visited.count(Next)) { // Has our next sibling been visited? - // No, do it now. - Visited.insert(Next); - VisitStack.push(make_pair(Next, GT::child_begin(Next))); - return *this; - } - } - - // Oops, ran out of successors... go up a level on the stack. - VisitStack.pop(); - } while (!VisitStack.empty()); - } - return *this; - } - - inline _Self operator++(int) { // Postincrement - _Self tmp = *this; ++*this; return tmp; - } - - // nodeVisited - return true if this iterator has already visited the - // specified node. This is public, and will probably be used to iterate over - // nodes that a depth first iteration did not find: ie unreachable nodes. - // - inline bool nodeVisited(NodeType *Node) const { - return Visited.count(Node) != 0; - } -}; - - -// Provide global constructors that automatically figure out correct types... -// -template -df_iterator df_begin(T G, bool Reverse = false) { - return df_iterator::begin(G, Reverse); -} - -template -df_iterator df_end(T G) { - return df_iterator::end(G); -} - -// Provide global definitions of inverse depth first iterators... -template -struct idf_iterator : public df_iterator > { - idf_iterator(const df_iterator > &V) :df_iterator >(V){} -}; - -template -idf_iterator idf_begin(T G, bool Reverse = false) { - return idf_iterator::begin(G, Reverse); -} - -template -idf_iterator idf_end(T G){ - return idf_iterator::end(G); -} - -#endif diff --git a/include/llvm/Support/GraphTraits.h b/include/llvm/Support/GraphTraits.h deleted file mode 100644 index 67fe7c9360..0000000000 --- a/include/llvm/Support/GraphTraits.h +++ /dev/null @@ -1,65 +0,0 @@ -//===-- llvm/Support/GraphTraits.h - Graph traits template -------*- C++ -*--=// -// -// This file defines the little GraphTraits template class that should be -// specialized by classes that want to be iteratable by generic graph iterators. -// -// This file also defines the marker class Inverse that is used to iterate over -// graphs in a graph defined, inverse ordering... -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_GRAPH_TRAITS_H -#define LLVM_SUPPORT_GRAPH_TRAITS_H - -// GraphTraits - This class should be specialized by different graph types... -// which is why the default version is empty. -// -template -struct GraphTraits { - // Elements to provide: - - // typedef NodeType - Type of Node in the graph - // typedef ChildIteratorType - Type used to iterate over children in graph - - // static NodeType *getEntryNode(GraphType *) - // Return the entry node of the graph - - // static ChildIteratorType child_begin(NodeType *) - // static ChildIteratorType child_end (NodeType *) - // Return iterators that point to the beginning and ending of the child - // node list for the specified node. - // - - - // If anyone tries to use this class without having an appropriate - // specialization, make an error. If you get this error, it's because you - // need to include the appropriate specialization of GraphTraits<> for your - // graph, or you need to define it for a new graph type. Either that or - // your argument to XXX_begin(...) is unknown or needs to have the proper .h - // file #include'd. - // - typedef typename GraphType::UnknownGraphTypeError NodeType; -}; - - -// Inverse - This class is used as a little marker class to tell the graph -// iterator to iterate over the graph in a graph defined "Inverse" ordering. -// Not all graphs define an inverse ordering, and if they do, it depends on -// the graph exactly what that is. Here's an example of usage with the -// df_iterator: -// -// idf_iterator I = idf_begin(M), E = idf_end(M); -// for (; I != E; ++I) { ... } -// -// Which is equivalent to: -// df_iterator > I = idf_begin(M), E = idf_end(M); -// for (; I != E; ++I) { ... } -// -template -struct Inverse { - GraphType &Graph; - - inline Inverse(GraphType &G) : Graph(G) {} -}; - -#endif diff --git a/include/llvm/Support/HashExtras.h b/include/llvm/Support/HashExtras.h deleted file mode 100644 index 6ea831e78f..0000000000 --- a/include/llvm/Support/HashExtras.h +++ /dev/null @@ -1,27 +0,0 @@ -//===-- HashExtras.h - Useful functions for STL hash containers --*- C++ -*--=// -// -// This file contains some templates that are useful if you are working with the -// STL Hashed containers. -// -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_HASHEXTRAS_H -#define LLVM_SUPPORT_HASHEXTRAS_H - -#include -#include - -template <> struct hash { - size_t operator()(string const &str) const { - return hash()(str.c_str()); - } -}; - -// Provide a hash function for arbitrary pointers... -template struct hash { - inline size_t operator()(const T *Val) const { return (size_t)Val; } -}; - -#endif diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h new file mode 100644 index 0000000000..f3dc3de17b --- /dev/null +++ b/include/llvm/Support/MathExtras.h @@ -0,0 +1,32 @@ +// $Id$ -*-c++-*- +//*************************************************************************** +// File: +// MathExtras.h +// +// Purpose: +// +// History: +// 8/25/01 - Vikram Adve - Created +//**************************************************************************/ + +#ifndef LLVM_SUPPORT_MATH_EXTRAS_H +#define LLVM_SUPPORT_MATH_EXTRAS_H + +#include + +inline bool IsPowerOf2 (int64_t C, unsigned& getPow); + +inline +bool IsPowerOf2(int64_t C, unsigned& getPow) +{ + if (C < 0) + C = -C; + bool isBool = C > 0 && (C == (C & ~(C - 1))); + if (isBool) + for (getPow = 0; C > 1; getPow++) + C = C >> 1; + + return isBool; +} + +#endif /*LLVM_SUPPORT_MATH_EXTRAS_H*/ diff --git a/include/llvm/Support/NonCopyable.h b/include/llvm/Support/NonCopyable.h deleted file mode 100644 index f4fc26805a..0000000000 --- a/include/llvm/Support/NonCopyable.h +++ /dev/null @@ -1,37 +0,0 @@ -//===-- NonCopyable.h - Disable copy ctor and op= in subclasses --*- C++ -*--=// -// -// This file defines the NonCopyable and NonCopyableV classes. These mixin -// classes may be used to mark a class not being copyable. You should derive -// from NonCopyable if you don't want to have a virtual dtor, or NonCopyableV -// if you do want polymorphic behavior in your class. -// -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_NONCOPYABLE_H -#define LLVM_SUPPORT_NONCOPYABLE_H - -class NonCopyable { - // Disable the copy constructor and the assignment operator - // by making them both private: - // - NonCopyable(const NonCopyable &); // DO NOT IMPLEMENT - NonCopyable &operator=(const NonCopyable &); // DO NOT IMPLEMENT -protected: - inline NonCopyable() {} - inline ~NonCopyable() {} -}; - -class NonCopyableV { - // Disable the copy constructor and the assignment operator - // by making them both private: - // - NonCopyableV(const NonCopyableV &); // DO NOT IMPLEMENT - NonCopyableV &operator=(const NonCopyableV &); // DO NOT IMPLEMENT -protected: - inline NonCopyableV() {} - virtual ~NonCopyableV() {} -}; - -#endif diff --git a/include/llvm/Support/PostOrderIterator.h b/include/llvm/Support/PostOrderIterator.h deleted file mode 100644 index fa135f8785..0000000000 --- a/include/llvm/Support/PostOrderIterator.h +++ /dev/null @@ -1,145 +0,0 @@ -//===-- llvm/Support/PostOrderIterator.h - Generic PO iterator ---*- C++ -*--=// -// -// This file builds on the Support/GraphTraits.h file to build a generic graph -// post order iterator. This should work over any graph type that has a -// GraphTraits specialization. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_POSTORDER_ITERATOR_H -#define LLVM_SUPPORT_POSTORDER_ITERATOR_H - -#include "llvm/Support/GraphTraits.h" -#include -#include -#include - -template > -class po_iterator : public std::forward_iterator { - typedef typename GT::NodeType NodeType; - typedef typename GT::ChildIteratorType ChildItTy; - - set Visited; // All of the blocks visited so far... - // VisitStack - Used to maintain the ordering. Top = current block - // First element is basic block pointer, second is the 'next child' to visit - stack > VisitStack; - - void traverseChild() { - while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) { - NodeType *BB = *VisitStack.top().second++; - if (!Visited.count(BB)) { // If the block is not visited... - Visited.insert(BB); - VisitStack.push(make_pair(BB, GT::child_begin(BB))); - } - } - } - - inline po_iterator(NodeType *BB) { - Visited.insert(BB); - VisitStack.push(make_pair(BB, GT::child_begin(BB))); - traverseChild(); - } - inline po_iterator() { /* End is when stack is empty */ } -public: - typedef po_iterator _Self; - - // Provide static "constructors"... - static inline _Self begin(GraphT G) { return _Self(GT::getEntryNode(G)); } - static inline _Self end (GraphT G) { return _Self(); } - - inline bool operator==(const _Self& x) const { - return VisitStack == x.VisitStack; - } - inline bool operator!=(const _Self& x) const { return !operator==(x); } - - inline pointer operator*() const { - return VisitStack.top().first; - } - - // This is a nonstandard operator-> that dereferences the pointer an extra - // time... so that you can actually call methods ON the BasicBlock, because - // the contained type is a pointer. This allows BBIt->getTerminator() f.e. - // - inline NodeType *operator->() const { return operator*(); } - - inline _Self& operator++() { // Preincrement - VisitStack.pop(); - if (!VisitStack.empty()) - traverseChild(); - return *this; - } - - inline _Self operator++(int) { // Postincrement - _Self tmp = *this; ++*this; return tmp; - } -}; - -// Provide global constructors that automatically figure out correct types... -// -template -po_iterator po_begin(T G) { return po_iterator::begin(G); } -template -po_iterator po_end (T G) { return po_iterator::end(G); } - -// Provide global definitions of inverse post order iterators... -template -struct ipo_iterator : public po_iterator > { - ipo_iterator(const po_iterator > &V) :po_iterator >(V){} -}; - -template -ipo_iterator ipo_begin(T G, bool Reverse = false) { - return ipo_iterator::begin(G, Reverse); -} - -template -ipo_iterator ipo_end(T G){ - return ipo_iterator::end(G); -} - - -//===--------------------------------------------------------------------===// -// Reverse Post Order CFG iterator code -//===--------------------------------------------------------------------===// -// -// This is used to visit basic blocks in a method in reverse post order. This -// class is awkward to use because I don't know a good incremental algorithm to -// computer RPO from a graph. Because of this, the construction of the -// ReversePostOrderTraversal object is expensive (it must walk the entire graph -// with a postorder iterator to build the data structures). The moral of this -// story is: Don't create more ReversePostOrderTraversal classes than neccesary. -// -// This class should be used like this: -// { -// cfg::ReversePostOrderTraversal RPOT(MethodPtr); // Expensive to create -// for (cfg::rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { -// ... -// } -// for (cfg::rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { -// ... -// } -// } -// - -typedef reverse_iterator::iterator> rpo_iterator; -// TODO: FIXME: ReversePostOrderTraversal is not generic! -class ReversePostOrderTraversal { - vector Blocks; // Block list in normal PO order - inline void Initialize(BasicBlock *BB) { - copy(po_begin(BB), po_end(BB), back_inserter(Blocks)); - } -public: - inline ReversePostOrderTraversal(Method *M) { - Initialize(M->front()); - } - inline ReversePostOrderTraversal(BasicBlock *BB) { - Initialize(BB); - } - - // Because we want a reverse post order, use reverse iterators from the vector - inline rpo_iterator begin() { return Blocks.rbegin(); } - inline rpo_iterator end() { return Blocks.rend(); } -}; - -#endif diff --git a/include/llvm/Support/STLExtras.h b/include/llvm/Support/STLExtras.h deleted file mode 100644 index 44d789dcf2..0000000000 --- a/include/llvm/Support/STLExtras.h +++ /dev/null @@ -1,222 +0,0 @@ -//===-- STLExtras.h - Useful functions when working with the STL -*- C++ -*--=// -// -// This file contains some templates that are useful if you are working with the -// STL at all. -// -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_STL_EXTRAS_H -#define LLVM_SUPPORT_STL_EXTRAS_H - -#include - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// bind_obj - Often times you want to apply the member function of an object -// as a unary functor. This macro is shorthand that makes it happen less -// verbosely. -// -// Example: -// struct Summer { void accumulate(int x); } -// vector Numbers; -// Summer MyS; -// for_each(Numbers.begin(), Numbers.end(), -// bind_obj(&MyS, &Summer::accumulate)); -// -// TODO: When I get lots of extra time, convert this from an evil macro -// -#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ) - - -// bitwise_or - This is a simple functor that applys operator| on its two -// arguments to get a boolean result. -// -template -struct bitwise_or : public binary_function { - bool operator()(const Ty& left, const Ty& right) const { - return left | right; - } -}; - - -// deleter - Very very very simple method that is used to invoke operator -// delete on something. It is used like this: -// -// for_each(V.begin(), B.end(), deleter); -// -template -static inline void deleter(T *Ptr) { - delete Ptr; -} - - - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// mapped_iterator - This is a simple iterator adapter that causes a function to -// be dereferenced whenever operator* is invoked on the iterator. -// -// It turns out that this is disturbingly similar to boost::transform_iterator -// -#if 1 -template -class mapped_iterator { - RootIt current; - UnaryFunc Fn; -public: - typedef typename iterator_traits::iterator_category - iterator_category; - typedef typename iterator_traits::difference_type - difference_type; - typedef typename UnaryFunc::result_type value_type; - typedef typename UnaryFunc::result_type *pointer; - typedef void reference; // Can't modify value returned by fn - - typedef RootIt iterator_type; - typedef mapped_iterator _Self; - - inline RootIt &getCurrent() const { return current; } - - inline explicit mapped_iterator(const RootIt &I, UnaryFunc F) - : current(I), Fn(F) {} - inline mapped_iterator(const mapped_iterator &It) - : current(It.current), Fn(It.Fn) {} - - inline value_type operator*() const { // All this work to do this - return Fn(*current); // little change - } - - _Self& operator++() { ++current; return *this; } - _Self& operator--() { --current; return *this; } - _Self operator++(int) { _Self __tmp = *this; ++current; return __tmp; } - _Self operator--(int) { _Self __tmp = *this; --current; return __tmp; } - _Self operator+ (difference_type n) const { return _Self(current + n); } - _Self& operator+= (difference_type n) { current += n; return *this; } - _Self operator- (difference_type n) const { return _Self(current - n); } - _Self& operator-= (difference_type n) { current -= n; return *this; } - reference operator[](difference_type n) const { return *(*this + n); } - - inline bool operator==(const _Self &X) const { return current == X.current; } - inline bool operator< (const _Self &X) const { return current < X.current; } - - inline difference_type operator-(const _Self &X) const { - return current - X.current; - } -}; - -template -inline mapped_iterator<_Iterator, Func> -operator+(typename mapped_iterator<_Iterator, Func>::difference_type N, - const mapped_iterator<_Iterator, Func>& X) { - return mapped_iterator<_Iterator, Func>(X.getCurrent() - N); -} - -#else - -// This fails to work, because some iterators are not classes, for example -// vector iterators are commonly value_type **'s -template -class mapped_iterator : public RootIt { - UnaryFunc Fn; -public: - typedef typename UnaryFunc::result_type value_type; - typedef typename UnaryFunc::result_type *pointer; - typedef void reference; // Can't modify value returned by fn - - typedef mapped_iterator _Self; - typedef RootIt super; - inline explicit mapped_iterator(const RootIt &I) : super(I) {} - inline mapped_iterator(const super &It) : super(It) {} - - inline value_type operator*() const { // All this work to do - return Fn(super::operator*()); // this little thing - } -}; -#endif - -// map_iterator - Provide a convenient way to create mapped_iterators, just like -// make_pair is useful for creating pairs... -// -template -inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { - return mapped_iterator(I, F); -} - - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// apply_until - Apply a functor to a sequence continually, unless the -// functor returns true. Return true if the functor returned true, return false -// if the functor never returned true. -// -template -bool apply_until(InputIt First, InputIt Last, Function Func) { - for ( ; First != Last; ++First) - if (Func(*First)) return true; - return false; -} - - -// reduce - Reduce a sequence values into a single value, given an initial -// value and an operator. -// -template -ValueType reduce(InputIt First, InputIt Last, Function Func, ValueType Value) { - for ( ; First != Last; ++First) - Value = Func(*First, Value); - return Value; -} - -#if 1 // This is likely to be more efficient - -// reduce_apply - Reduce the result of applying a function to each value in a -// sequence, given an initial value, an operator, a function, and a sequence. -// -template -inline ValueType reduce_apply(InputIt First, InputIt Last, Function Func, - ValueType Value, TransFunc XForm) { - for ( ; First != Last; ++First) - Value = Func(XForm(*First), Value); - return Value; -} - -#else // This is arguably more elegant - -// reduce_apply - Reduce the result of applying a function to each value in a -// sequence, given an initial value, an operator, a function, and a sequence. -// -template -inline ValueType reduce_apply2(InputIt First, InputIt Last, Function Func, - ValueType Value, TransFunc XForm) { - return reduce(map_iterator(First, XForm), map_iterator(Last, XForm), - Func, Value); -} -#endif - - -// reduce_apply_bool - Reduce the result of applying a (bool returning) function -// to each value in a sequence. All of the bools returned by the mapped -// function are bitwise or'd together, and the result is returned. -// -template -inline bool reduce_apply_bool(InputIt First, InputIt Last, Function Func) { - return reduce_apply(First, Last, bitwise_or(), false, Func); -} - - -// map - This function maps the specified input sequence into the specified -// output iterator, applying a unary function in between. -// -template -inline OutIt mapto(InIt Begin, InIt End, OutIt Dest, Functor F) { - return copy(map_iterator(Begin, F), map_iterator(End, F), Dest); -} -#endif diff --git a/include/llvm/Support/StringExtras.h b/include/llvm/Support/StringExtras.h deleted file mode 100644 index aaae8577ef..0000000000 --- a/include/llvm/Support/StringExtras.h +++ /dev/null @@ -1,88 +0,0 @@ -//===-- StringExtras.h - Useful string functions -----------------*- C++ -*--=// -// -// This file contains some functions that are useful when dealing with strings. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_TOOLS_STRING_EXTRAS_H -#define LLVM_TOOLS_STRING_EXTRAS_H - -#include -#include -#include "Support/DataTypes.h" - -class ConstPoolArray; - -static inline string utostr(uint64_t X, bool isNeg = false) { - char Buffer[40]; - char *BufPtr = Buffer+39; - - *BufPtr = 0; // Null terminate buffer... - if (X == 0) *--BufPtr = '0'; // Handle special case... - - while (X) { - *--BufPtr = '0' + (X % 10); - X /= 10; - } - - if (isNeg) *--BufPtr = '-'; // Add negative sign... - - return string(BufPtr); -} - -static inline string itostr(int64_t X) { - if (X < 0) - return utostr((uint64_t)-X, true); - else - return utostr((uint64_t)X); -} - - -static inline string utostr(unsigned X, bool isNeg = false) { - char Buffer[20]; - char *BufPtr = Buffer+19; - - *BufPtr = 0; // Null terminate buffer... - if (X == 0) *--BufPtr = '0'; // Handle special case... - - while (X) { - *--BufPtr = '0' + (X % 10); - X /= 10; - } - - if (isNeg) *--BufPtr = '-'; // Add negative sign... - - return string(BufPtr); -} - -static inline string itostr(int X) { - if (X < 0) - return utostr((unsigned)-X, true); - else - return utostr((unsigned)X); -} - -static inline string ftostr(double V) { - char Buffer[200]; - snprintf(Buffer, 200, "%e", V); - return Buffer; -} - -static inline void -printIndent(unsigned int indent, ostream& os=cout, const char* const istr=" ") -{ - for (unsigned i=0; i < indent; i++) - os << istr; -} - -// Can we treat the specified array as a string? Only if it is an array of -// ubytes or non-negative sbytes. -// -bool isStringCompatible(ConstPoolArray *CPA); - -// getAsCString - Return the specified array as a C compatible string, only if -// the predicate isStringCompatible is true. -// -string getAsCString(ConstPoolArray *CPA); - -#endif diff --git a/include/llvm/Support/Tree.h b/include/llvm/Support/Tree.h deleted file mode 100644 index 679b6dfd83..0000000000 --- a/include/llvm/Support/Tree.h +++ /dev/null @@ -1,52 +0,0 @@ -//===- llvm/Support/Tree.h - Generic n-way tree structure --------*- C++ -*--=// -// -// This class defines a generic N way tree node structure. The tree structure -// is immutable after creation, but the payload contained within it is not. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_TREE_H -#define LLVM_SUPPORT_TREE_H - -#include - -template -class Tree { - vector Children; // This nodes children, if any - ConcreteTreeNode *Parent; // Parent of this node... - Payload Data; // Data held in this node... - -protected: - void setChildren(const vector &children) { - Children = children; - } -public: - inline Tree(ConcreteTreeNode *parent) : Parent(parent) {} - inline Tree(const vector &children, ConcreteTreeNode *par) - : Children(children), Parent(par) {} - - inline Tree(const vector &children, ConcreteTreeNode *par, - const Payload &data) - : Children(children), Parent(parent), Data(data) {} - - // Tree dtor - Free all children - inline ~Tree() { - for (unsigned i = Children.size(); i > 0; --i) - delete Children[i-1]; - } - - // Tree manipulation/walking routines... - inline ConcreteTreeNode *getParent() const { return Parent; } - inline unsigned getNumChildren() const { return Children.size(); } - inline ConcreteTreeNode *getChild(unsigned i) const { - assert(i < Children.size() && "Tree::getChild with index out of range!"); - return Children[i]; - } - - // Payload access... - inline Payload &getTreeData() { return Data; } - inline const Payload &getTreeData() const { return Data; } -}; - - -#endif diff --git a/include/llvm/Target/TargetFrameInfo.h b/include/llvm/Target/TargetFrameInfo.h index 4f19cc95c3..df16c730b2 100644 --- a/include/llvm/Target/TargetFrameInfo.h +++ b/include/llvm/Target/TargetFrameInfo.h @@ -13,7 +13,7 @@ #ifndef LLVM_CODEGEN_FRAMEINFO_H #define LLVM_CODEGEN_FRAMEINFO_H -#include "llvm/Support/NonCopyable.h" +#include "Support/NonCopyable.h" #include diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 4f0b934bb9..ad1f105958 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -8,7 +8,7 @@ #define LLVM_TARGET_TARGETMACHINE_H #include "llvm/Target/TargetData.h" -#include "llvm/Support/NonCopyable.h" +#include "Support/NonCopyable.h" class TargetMachine; class MachineInstrInfo; diff --git a/include/llvm/Target/TargetRegInfo.h b/include/llvm/Target/TargetRegInfo.h index 8f7fad5711..4bd2319d02 100644 --- a/include/llvm/Target/TargetRegInfo.h +++ b/include/llvm/Target/TargetRegInfo.h @@ -8,7 +8,7 @@ #ifndef LLVM_TARGET_MACHINEREGINFO_H #define LLVM_TARGET_MACHINEREGINFO_H -#include "llvm/Support/NonCopyable.h" +#include "Support/NonCopyable.h" #include #include diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 04780e9e3c..905aa2d11f 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -27,7 +27,7 @@ #define LLVM_TYPE_H #include "llvm/Value.h" -#include "llvm/Support/GraphTraits.h" +#include "Support/GraphTraits.h" class DerivedType; class MethodType; diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index a323610427..47dbde7148 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -12,11 +12,11 @@ #include "llvm/Analysis/CallGraph.h" #include "llvm/Analysis/Writer.h" -#include "llvm/Support/STLExtras.h" #include "llvm/Module.h" #include "llvm/Method.h" #include "llvm/iOther.h" #include "llvm/iTerminators.h" +#include "Support/STLExtras.h" #include // getNodeFor - Return the node for the specified method or create one if it diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index d47e1d7f6a..852763755a 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -18,8 +18,8 @@ #include "llvm/Analysis/FindUnsafePointerTypes.h" #include "llvm/Assembly/CachedWriter.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Type.h" +#include "Support/CommandLine.h" // Provide a command line option to turn on printing of which instructions cause // a type to become invalid diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index 4bff950a82..8616cb721c 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -6,7 +6,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/IntervalIterator.h" -#include "llvm/Support/STLExtras.h" +#include "Support/STLExtras.h" using namespace cfg; diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp index 32201beb6a..e981a86642 100644 --- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp @@ -11,7 +11,7 @@ #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/PostOrderIterator.h" +#include "Support/PostOrderIterator.h" /************************** Constructor/Destructor ***************************/ diff --git a/lib/Analysis/LoopDepth.cpp b/lib/Analysis/LoopDepth.cpp index 7518606c89..ed96bd4f57 100644 --- a/lib/Analysis/LoopDepth.cpp +++ b/lib/Analysis/LoopDepth.cpp @@ -7,7 +7,7 @@ #include "llvm/Analysis/LoopDepth.h" #include "llvm/Analysis/IntervalPartition.h" -#include "llvm/Support/STLExtras.h" +#include "Support/STLExtras.h" #include inline void LoopDepthCalculator::AddBB(const BasicBlock *BB) { diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index a240ec8b8b..40a195b042 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -9,8 +9,8 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/Dominators.h" -#include "llvm/Support/DepthFirstIterator.h" #include "llvm/BasicBlock.h" +#include "Support/DepthFirstIterator.h" #include bool cfg::Loop::contains(const BasicBlock *BB) const { diff --git a/lib/Analysis/ModuleAnalyzer.cpp b/lib/Analysis/ModuleAnalyzer.cpp index d543216349..dc6ee710c4 100644 --- a/lib/Analysis/ModuleAnalyzer.cpp +++ b/lib/Analysis/ModuleAnalyzer.cpp @@ -12,7 +12,7 @@ #include "llvm/BasicBlock.h" #include "llvm/DerivedTypes.h" #include "llvm/ConstPoolVals.h" -#include "llvm/Support/STLExtras.h" +#include "Support/STLExtras.h" #include // processModule - Driver function to call all of my subclasses virtual methods. diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 2bc3edbc2a..2ed02dbed2 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -6,9 +6,9 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/SimplifyCFG.h" // To get cfg::UnifyAllExitNodes -#include "llvm/Support/DepthFirstIterator.h" -#include "llvm/Support/STLExtras.h" #include "llvm/Method.h" +#include "Support/DepthFirstIterator.h" +#include "Support/STLExtras.h" #include //===----------------------------------------------------------------------===// diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 0f25f5461d..76052fa541 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -18,7 +18,7 @@ #include "llvm/Method.h" #include "llvm/DerivedTypes.h" #include "llvm/Assembly/Parser.h" -#include "llvm/Support/StringExtras.h" +#include "Support/StringExtras.h" class Module; diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index aca9878da3..0f5c11e1ea 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -21,8 +21,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/iTerminators.h" #include "llvm/iMemory.h" -#include "llvm/Support/STLExtras.h" -#include "llvm/Support/DepthFirstIterator.h" +#include "Support/STLExtras.h" +#include "Support/DepthFirstIterator.h" #include #include // Get definition of pair class #include diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 3211e728ff..6fed526bd6 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -19,8 +19,8 @@ #include "llvm/iOther.h" #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" -#include "llvm/Support/STLExtras.h" -#include "llvm/Support/DepthFirstIterator.h" +#include "Support/DepthFirstIterator.h" +#include "Support/STLExtras.h" #include #if 0 diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index 0ba218da1c..528e5abdd3 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -13,15 +13,11 @@ //************************* User Include Files *****************************/ #include "llvm/CodeGen/InstrScheduling.h" -#include "SchedPriorities.h" #include "llvm/Analysis/LiveVar/BBLiveVar.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Instruction.h" - - -//************************ System Include Files *****************************/ - +#include "Support/CommandLine.h" +#include "SchedPriorities.h" #include #include #include diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index 9d3651a256..9e9af5b80d 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -21,8 +21,8 @@ #include "llvm/CodeGen/InstrSelection.h" #include "llvm/Target/MachineInstrInfo.h" #include "llvm/Target/MachineRegInfo.h" -#include "llvm/Support/StringExtras.h" #include "llvm/iOther.h" +#include "Support/StringExtras.h" #include #include #include @@ -132,7 +132,7 @@ SchedGraphEdge::~SchedGraphEdge() } void SchedGraphEdge::dump(int indent=0) const { - printIndent(indent); cout << *this; + cout << string(indent*2, ' ') << *this; } @@ -168,7 +168,7 @@ SchedGraphNode::~SchedGraphNode() } void SchedGraphNode::dump(int indent=0) const { - printIndent(indent); cout << *this; + cout << string(indent*2, ' ') << *this; } @@ -1023,32 +1023,24 @@ operator<<(ostream& os, const SchedGraphEdge& edge) ostream& operator<<(ostream& os, const SchedGraphNode& node) { - printIndent(4, os); - os << "Node " << node.nodeId << " : " - << "latency = " << node.latency << endl; - - printIndent(6, os); + os << string(8, ' ') + << "Node " << node.nodeId << " : " + << "latency = " << node.latency << endl << string(12, ' '); if (node.getMachineInstr() == NULL) os << "(Dummy node)" << endl; else { - os << *node.getMachineInstr() << endl; - - printIndent(6, os); + os << *node.getMachineInstr() << endl << string(12, ' '); os << node.inEdges.size() << " Incoming Edges:" << endl; for (unsigned i=0, N=node.inEdges.size(); i < N; i++) - { - printIndent(8, os); - os << * node.inEdges[i]; - } + os << string(16, ' ') << *node.inEdges[i]; - printIndent(6, os); - os << node.outEdges.size() << " Outgoing Edges:" << endl; + os << string(12, ' ') << node.outEdges.size() + << " Outgoing Edges:" << endl; for (unsigned i=0, N=node.outEdges.size(); i < N; i++) { - printIndent(8, os); - os << * node.outEdges[i]; + os << string(16, ' ') << * node.outEdges[i]; } } diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h index 44d59a1aa5..a4567a5198 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.h +++ b/lib/CodeGen/InstrSched/SchedGraph.h @@ -19,11 +19,11 @@ #ifndef LLVM_CODEGEN_SCHEDGRAPH_H #define LLVM_CODEGEN_SCHEDGRAPH_H -#include "llvm/Support/NonCopyable.h" -#include "llvm/Support/HashExtras.h" -#include "llvm/Support/GraphTraits.h" #include "llvm/Target/MachineInstrInfo.h" #include "llvm/CodeGen/MachineInstr.h" +#include "Support/NonCopyable.h" +#include "Support/HashExtras.h" +#include "Support/GraphTraits.h" #include class Value; diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp index 31d9f6c592..acbe552d05 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.cpp +++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp @@ -19,7 +19,7 @@ //**************************************************************************/ #include "SchedPriorities.h" -#include "llvm/Support/PostOrderIterator.h" +#include "Support/PostOrderIterator.h" SchedPriorities::SchedPriorities(const Method* method, diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp index f928683060..c6d53674ac 100644 --- a/lib/CodeGen/InstrSelection/InstrForest.cpp +++ b/lib/CodeGen/InstrSelection/InstrForest.cpp @@ -30,7 +30,7 @@ #include "llvm/ConstPoolVals.h" #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/STLExtras.h" +#include "Support/STLExtras.h" //------------------------------------------------------------------------ // class InstrTreeNode diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index f27ad710e0..ce26a1d073 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -17,12 +17,12 @@ #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelectionSupport.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Instruction.h" #include "llvm/BasicBlock.h" #include "llvm/Method.h" #include "llvm/iOther.h" #include "llvm/Target/MachineRegInfo.h" +#include "Support/CommandLine.h" #include diff --git a/lib/CodeGen/RegAlloc/RegAllocCommon.h b/lib/CodeGen/RegAlloc/RegAllocCommon.h index 5fa51c034f..02b3331132 100644 --- a/lib/CodeGen/RegAlloc/RegAllocCommon.h +++ b/lib/CodeGen/RegAlloc/RegAllocCommon.h @@ -1,5 +1,5 @@ -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" #ifndef REG_ALLOC_COMMON_H #define REG_ALLOC_COMMON_H diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 538e39ad0c..2f0ee41c52 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -26,7 +26,7 @@ CachedWriter CW; // Object to accelerate printing of LLVM #ifdef PROFILE_STRUCTURE_FIELDS -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" static cl::Flag ProfileStructureFields("profilestructfields", "Profile Structure Field Accesses"); #include diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index bc337ee8b5..f6938169da 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -9,8 +9,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/STLExtras.h" +#include "Support/CommandLine.h" +#include "Support/STLExtras.h" #include #include #include diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index 0ba218da1c..528e5abdd3 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -13,15 +13,11 @@ //************************* User Include Files *****************************/ #include "llvm/CodeGen/InstrScheduling.h" -#include "SchedPriorities.h" #include "llvm/Analysis/LiveVar/BBLiveVar.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Instruction.h" - - -//************************ System Include Files *****************************/ - +#include "Support/CommandLine.h" +#include "SchedPriorities.h" #include #include #include diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index 9d3651a256..9e9af5b80d 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -21,8 +21,8 @@ #include "llvm/CodeGen/InstrSelection.h" #include "llvm/Target/MachineInstrInfo.h" #include "llvm/Target/MachineRegInfo.h" -#include "llvm/Support/StringExtras.h" #include "llvm/iOther.h" +#include "Support/StringExtras.h" #include #include #include @@ -132,7 +132,7 @@ SchedGraphEdge::~SchedGraphEdge() } void SchedGraphEdge::dump(int indent=0) const { - printIndent(indent); cout << *this; + cout << string(indent*2, ' ') << *this; } @@ -168,7 +168,7 @@ SchedGraphNode::~SchedGraphNode() } void SchedGraphNode::dump(int indent=0) const { - printIndent(indent); cout << *this; + cout << string(indent*2, ' ') << *this; } @@ -1023,32 +1023,24 @@ operator<<(ostream& os, const SchedGraphEdge& edge) ostream& operator<<(ostream& os, const SchedGraphNode& node) { - printIndent(4, os); - os << "Node " << node.nodeId << " : " - << "latency = " << node.latency << endl; - - printIndent(6, os); + os << string(8, ' ') + << "Node " << node.nodeId << " : " + << "latency = " << node.latency << endl << string(12, ' '); if (node.getMachineInstr() == NULL) os << "(Dummy node)" << endl; else { - os << *node.getMachineInstr() << endl; - - printIndent(6, os); + os << *node.getMachineInstr() << endl << string(12, ' '); os << node.inEdges.size() << " Incoming Edges:" << endl; for (unsigned i=0, N=node.inEdges.size(); i < N; i++) - { - printIndent(8, os); - os << * node.inEdges[i]; - } + os << string(16, ' ') << *node.inEdges[i]; - printIndent(6, os); - os << node.outEdges.size() << " Outgoing Edges:" << endl; + os << string(12, ' ') << node.outEdges.size() + << " Outgoing Edges:" << endl; for (unsigned i=0, N=node.outEdges.size(); i < N; i++) { - printIndent(8, os); - os << * node.outEdges[i]; + os << string(16, ' ') << * node.outEdges[i]; } } diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h index 44d59a1aa5..a4567a5198 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.h +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h @@ -19,11 +19,11 @@ #ifndef LLVM_CODEGEN_SCHEDGRAPH_H #define LLVM_CODEGEN_SCHEDGRAPH_H -#include "llvm/Support/NonCopyable.h" -#include "llvm/Support/HashExtras.h" -#include "llvm/Support/GraphTraits.h" #include "llvm/Target/MachineInstrInfo.h" #include "llvm/CodeGen/MachineInstr.h" +#include "Support/NonCopyable.h" +#include "Support/HashExtras.h" +#include "Support/GraphTraits.h" #include class Value; diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp index 31d9f6c592..acbe552d05 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp @@ -19,7 +19,7 @@ //**************************************************************************/ #include "SchedPriorities.h" -#include "llvm/Support/PostOrderIterator.h" +#include "Support/PostOrderIterator.h" SchedPriorities::SchedPriorities(const Method* method, diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index f928683060..c6d53674ac 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -30,7 +30,7 @@ #include "llvm/ConstPoolVals.h" #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/STLExtras.h" +#include "Support/STLExtras.h" //------------------------------------------------------------------------ // class InstrTreeNode diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index f27ad710e0..ce26a1d073 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -17,12 +17,12 @@ #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelectionSupport.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Instruction.h" #include "llvm/BasicBlock.h" #include "llvm/Method.h" #include "llvm/iOther.h" #include "llvm/Target/MachineRegInfo.h" +#include "Support/CommandLine.h" #include diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp index 32201beb6a..e981a86642 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp @@ -11,7 +11,7 @@ #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/Support/PostOrderIterator.h" +#include "Support/PostOrderIterator.h" /************************** Constructor/Destructor ***************************/ diff --git a/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h b/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h index 5fa51c034f..02b3331132 100644 --- a/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h +++ b/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h @@ -1,5 +1,5 @@ -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" #ifndef REG_ALLOC_COMMON_H #define REG_ALLOC_COMMON_H diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 618fb6dc30..3edeb96203 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -19,8 +19,8 @@ #include "llvm/BasicBlock.h" #include "llvm/Method.h" #include "llvm/Module.h" -#include "llvm/Support/HashExtras.h" -#include "llvm/Support/StringExtras.h" +#include "Support/StringExtras.h" +#include "Support/HashExtras.h" #include namespace { @@ -161,6 +161,69 @@ private : } }; + +// Can we treat the specified array as a string? Only if it is an array of +// ubytes or non-negative sbytes. +// +static bool isStringCompatible(ConstPoolArray *CPA) { + const Type *ETy = cast(CPA->getType())->getElementType(); + if (ETy == Type::UByteTy) return true; + if (ETy != Type::SByteTy) return false; + + for (unsigned i = 0; i < CPA->getNumOperands(); ++i) + if (cast(CPA->getOperand(i))->getValue() < 0) + return false; + + return true; +} + +// toOctal - Convert the low order bits of X into an octal letter +static inline char toOctal(int X) { + return (X&7)+'0'; +} + +// getAsCString - Return the specified array as a C compatible string, only if +// the predicate isStringCompatible is true. +// +static string getAsCString(ConstPoolArray *CPA) { + if (isStringCompatible(CPA)) { + string Result; + const Type *ETy = cast(CPA->getType())->getElementType(); + Result = "\""; + for (unsigned i = 0; i < CPA->getNumOperands(); ++i) { + unsigned char C = (ETy == Type::SByteTy) ? + (unsigned char)cast(CPA->getOperand(i))->getValue() : + (unsigned char)cast(CPA->getOperand(i))->getValue(); + + if (isprint(C)) { + Result += C; + } else { + switch(C) { + case '\a': Result += "\\a"; break; + case '\b': Result += "\\b"; break; + case '\f': Result += "\\f"; break; + case '\n': Result += "\\n"; break; + case '\r': Result += "\\r"; break; + case '\t': Result += "\\t"; break; + case '\v': Result += "\\v"; break; + default: + Result += '\\'; + Result += toOctal(C >> 6); + Result += toOctal(C >> 3); + Result += toOctal(C >> 0); + break; + } + } + } + Result += "\""; + + return Result; + } else { + return CPA->getStrValue(); + } +} + + inline bool SparcAsmPrinter::OpIsBranchTargetLabel(const MachineInstr *MI, unsigned int opNum) { diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index c1b8aa38c8..631d609018 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -16,7 +16,6 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/InstrForest.h" #include "llvm/CodeGen/InstrSelection.h" -#include "llvm/Support/MathExtras.h" #include "llvm/DerivedTypes.h" #include "llvm/iTerminators.h" #include "llvm/iMemory.h" @@ -24,10 +23,9 @@ #include "llvm/BasicBlock.h" #include "llvm/Method.h" #include "llvm/ConstPoolVals.h" +#include "Support/MathExtras.h" #include -//******************** Internal Data Declarations ************************/ - //************************* Forward Declarations ***************************/ diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 327cb6301d..a1d92f1b26 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -8,13 +8,13 @@ #include "TransformInternals.h" #include "llvm/Method.h" -#include "llvm/Support/STLExtras.h" #include "llvm/iOther.h" #include "llvm/iMemory.h" #include "llvm/ConstPoolVals.h" #include "llvm/Optimizations/ConstantHandling.h" #include "llvm/Optimizations/DCE.h" #include "llvm/Analysis/Expressions.h" +#include "Support/STLExtras.h" #include #include diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index 24945c02b4..7395bab803 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -6,9 +6,9 @@ #include "llvm/Transforms/IPO/GlobalDCE.h" #include "llvm/Analysis/CallGraph.h" -#include "llvm/Support/DepthFirstIterator.h" #include "llvm/Module.h" #include "llvm/Method.h" +#include "Support/DepthFirstIterator.h" #include static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) { diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index f59b0aed24..07db02854e 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -27,8 +27,8 @@ #include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "llvm/Assembly/Writer.h" -#include "llvm/Support/HashExtras.h" -#include "llvm/Support/StringExtras.h" +#include "Support/StringExtras.h" +#include "Support/HashExtras.h" #include #include diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index d4bf823a54..f80270567d 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -9,7 +9,6 @@ #include "llvm/Transforms/LevelChange.h" #include "TransformInternals.h" #include "llvm/Method.h" -#include "llvm/Support/STLExtras.h" #include "llvm/iOther.h" #include "llvm/iMemory.h" #include "llvm/ConstPoolVals.h" @@ -17,6 +16,7 @@ #include "llvm/Optimizations/DCE.h" #include "llvm/Optimizations/ConstantProp.h" #include "llvm/Analysis/Expressions.h" +#include "Support/STLExtras.h" #include #include "llvm/Assembly/Writer.h" diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 14a1811618..a5d1d12bcf 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -10,11 +10,11 @@ #include "llvm/Instruction.h" #include "llvm/Type.h" #include "llvm/Analysis/Dominators.h" -#include "llvm/Support/STLExtras.h" -#include "llvm/Support/DepthFirstIterator.h" #include "llvm/Analysis/Writer.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" +#include "Support/STLExtras.h" +#include "Support/DepthFirstIterator.h" #include #include diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 16d9534018..caacf32d38 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -24,7 +24,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Optimizations/DCE.h" -#include "llvm/Support/STLExtras.h" #include "llvm/Module.h" #include "llvm/GlobalVariable.h" #include "llvm/Method.h" @@ -32,6 +31,7 @@ #include "llvm/iTerminators.h" #include "llvm/iOther.h" #include "llvm/Assembly/Writer.h" +#include "Support/STLExtras.h" #include // dceInstruction - Inspect the instruction at *BBI and figure out if it's diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index 1cec66de71..9f0513f36e 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -23,9 +23,9 @@ #include "llvm/ConstPoolVals.h" #include "llvm/Analysis/IntervalPartition.h" #include "llvm/Assembly/Writer.h" -#include "llvm/Support/STLExtras.h" #include "llvm/SymbolTable.h" #include "llvm/iOther.h" +#include "Support/STLExtras.h" #include #include "llvm/Analysis/LoopDepth.h" diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index bca3f9b2f3..256fadf637 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -24,8 +24,8 @@ #include "llvm/iOther.h" #include "llvm/iMemory.h" #include "llvm/iTerminators.h" -#include "llvm/Support/STLExtras.h" #include "llvm/Assembly/Writer.h" +#include "Support/STLExtras.h" #include #include #include diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 1bfdff9364..2be172324c 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -21,8 +21,8 @@ #include "llvm/iMemory.h" #include "llvm/iTerminators.h" #include "llvm/SymbolTable.h" -#include "llvm/Support/STLExtras.h" -#include "llvm/Support/StringExtras.h" +#include "Support/StringExtras.h" +#include "Support/STLExtras.h" #include #include diff --git a/lib/VMCore/ConstPoolVals.cpp b/lib/VMCore/ConstPoolVals.cpp index 3b8fe10f46..dd301716fb 100644 --- a/lib/VMCore/ConstPoolVals.cpp +++ b/lib/VMCore/ConstPoolVals.cpp @@ -6,12 +6,12 @@ #define __STDC_LIMIT_MACROS // Get defs for INT64_MAX and friends... #include "llvm/ConstPoolVals.h" -#include "llvm/Support/StringExtras.h" // itostr #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" #include "llvm/GlobalValue.h" #include "llvm/Module.h" #include "llvm/Analysis/SlotCalculator.h" +#include "Support/StringExtras.h" #include #include diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 2bc3edbc2a..2ed02dbed2 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -6,9 +6,9 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/SimplifyCFG.h" // To get cfg::UnifyAllExitNodes -#include "llvm/Support/DepthFirstIterator.h" -#include "llvm/Support/STLExtras.h" #include "llvm/Method.h" +#include "Support/DepthFirstIterator.h" +#include "Support/STLExtras.h" #include //===----------------------------------------------------------------------===// diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index bb5e5b5a25..86b944d79f 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -10,9 +10,9 @@ #include "llvm/BasicBlock.h" #include "llvm/InstrTypes.h" #include "llvm/ValueHolderImpl.h" -#include "llvm/Support/STLExtras.h" #include "llvm/Type.h" #include "llvm/ConstPoolVals.h" +#include "Support/STLExtras.h" #include // Instantiate Templates - This ugliness is the price we have to pay diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index 3211e728ff..6fed526bd6 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -19,8 +19,8 @@ #include "llvm/iOther.h" #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" -#include "llvm/Support/STLExtras.h" -#include "llvm/Support/DepthFirstIterator.h" +#include "Support/DepthFirstIterator.h" +#include "Support/STLExtras.h" #include #if 0 diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index b8da428a2c..c32cec9365 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -6,10 +6,10 @@ #include "llvm/SymbolTable.h" #include "llvm/InstrTypes.h" -#include "llvm/Support/StringExtras.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Method.h" +#include "Support/StringExtras.h" #define DEBUG_SYMBOL_TABLE 0 #define DEBUG_ABSTYPE 0 diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 53844d605d..5f39682ca4 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -5,9 +5,9 @@ //===----------------------------------------------------------------------===// #include "llvm/DerivedTypes.h" -#include "llvm/Support/StringExtras.h" #include "llvm/SymbolTable.h" -#include "llvm/Support/STLExtras.h" +#include "Support/StringExtras.h" +#include "Support/STLExtras.h" // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // created and later destroyed, all in an effort to make sure that there is only diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index bc337ee8b5..f6938169da 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -9,8 +9,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/CommandLine.h" -#include "llvm/Support/STLExtras.h" +#include "Support/CommandLine.h" +#include "Support/STLExtras.h" #include #include #include diff --git a/support/lib/Support/StringExtras.cpp b/support/lib/Support/StringExtras.cpp deleted file mode 100644 index 2229df049a..0000000000 --- a/support/lib/Support/StringExtras.cpp +++ /dev/null @@ -1,66 +0,0 @@ - - -#include "llvm/Support/StringExtras.h" -#include "llvm/ConstPoolVals.h" -#include "llvm/DerivedTypes.h" - -// Can we treat the specified array as a string? Only if it is an array of -// ubytes or non-negative sbytes. -// -bool isStringCompatible(ConstPoolArray *CPA) { - const Type *ETy = cast(CPA->getType())->getElementType(); - if (ETy == Type::UByteTy) return true; - if (ETy != Type::SByteTy) return false; - - for (unsigned i = 0; i < CPA->getNumOperands(); ++i) - if (cast(CPA->getOperand(i))->getValue() < 0) - return false; - - return true; -} - -// toOctal - Convert the low order bits of X into an octal letter -static inline char toOctal(int X) { - return (X&7)+'0'; -} - -// getAsCString - Return the specified array as a C compatible string, only if -// the predicate isStringCompatible is true. -// -string getAsCString(ConstPoolArray *CPA) { - if (isStringCompatible(CPA)) { - string Result; - const Type *ETy = cast(CPA->getType())->getElementType(); - Result = "\""; - for (unsigned i = 0; i < CPA->getNumOperands(); ++i) { - unsigned char C = (ETy == Type::SByteTy) ? - (unsigned char)cast(CPA->getOperand(i))->getValue() : - (unsigned char)cast(CPA->getOperand(i))->getValue(); - - if (isprint(C)) { - Result += C; - } else { - switch(C) { - case '\a': Result += "\\a"; break; - case '\b': Result += "\\b"; break; - case '\f': Result += "\\f"; break; - case '\n': Result += "\\n"; break; - case '\r': Result += "\\r"; break; - case '\t': Result += "\\t"; break; - case '\v': Result += "\\v"; break; - default: - Result += '\\'; - Result += toOctal(C >> 6); - Result += toOctal(C >> 3); - Result += toOctal(C >> 0); - break; - } - } - } - Result += "\""; - - return Result; - } else { - return CPA->getStrValue(); - } -} diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index ec5d2c0431..da7de6ec9a 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -15,9 +15,7 @@ #include "llvm/Method.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Assembly/Parser.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Analysis/Writer.h" - #include "llvm/Analysis/InstForest.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/IntervalPartition.h" @@ -27,6 +25,7 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/FindUnsafePointerTypes.h" #include "llvm/Analysis/FindUsedTypes.h" +#include "Support/CommandLine.h" #include static void PrintMethod(Method *M) { diff --git a/tools/as/as.cpp b/tools/as/as.cpp index 72b63ecfdd..ee664f1524 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -9,14 +9,13 @@ // //===------------------------------------------------------------------------=== -#include -#include -#include #include "llvm/Module.h" #include "llvm/Assembly/Parser.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" +#include +#include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 712cf85e81..2a7eb4e06e 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -16,15 +16,14 @@ // //===----------------------------------------------------------------------===// -#include -#include #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Method.h" -#include "llvm/Support/DepthFirstIterator.h" -#include "llvm/Support/PostOrderIterator.h" +#include "Support/DepthFirstIterator.h" +#include "Support/PostOrderIterator.h" +#include "Support/CommandLine.h" +#include // OutputMode - The different orderings to print basic blocks in... enum OutputMode { diff --git a/tools/gccas/gccas.cpp b/tools/gccas/gccas.cpp index e19508fdac..c5ab2dff68 100644 --- a/tools/gccas/gccas.cpp +++ b/tools/gccas/gccas.cpp @@ -15,7 +15,7 @@ #include "llvm/Optimizations/DCE.h" #include "llvm/Transforms/ConstantMerge.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" #include #include #include diff --git a/tools/link/link.cpp b/tools/link/link.cpp index 80a39b2d9c..9bf766fcaa 100644 --- a/tools/link/link.cpp +++ b/tools/link/link.cpp @@ -13,10 +13,10 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Writer.h" #include "llvm/Assembly/Writer.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Module.h" #include "llvm/Method.h" -#include +#include "Support/CommandLine.h" +#include #include diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 1490cf40d1..7c8c3a608b 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -13,9 +13,9 @@ #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Transforms/ConstantMerge.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Module.h" #include "llvm/Method.h" +#include "Support/CommandLine.h" #include #include #include diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index ef9dddf750..f4145c169c 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -8,7 +8,7 @@ //===----------------------------------------------------------------------===// #include "Interpreter.h" -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" cl::StringList InputArgv("" , "Input command line", cl::ConsumeAfter); cl::String MainFunction ("f" , "Function to execute", cl::NoFlags, "main"); diff --git a/tools/llvm-as/as.cpp b/tools/llvm-as/as.cpp index 72b63ecfdd..ee664f1524 100644 --- a/tools/llvm-as/as.cpp +++ b/tools/llvm-as/as.cpp @@ -9,14 +9,13 @@ // //===------------------------------------------------------------------------=== -#include -#include -#include #include "llvm/Module.h" #include "llvm/Assembly/Parser.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" +#include +#include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index 72b63ecfdd..ee664f1524 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -9,14 +9,13 @@ // //===------------------------------------------------------------------------=== -#include -#include -#include #include "llvm/Module.h" #include "llvm/Assembly/Parser.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Support/CommandLine.h" +#include "Support/CommandLine.h" +#include +#include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp index 712cf85e81..2a7eb4e06e 100644 --- a/tools/llvm-dis/dis.cpp +++ b/tools/llvm-dis/dis.cpp @@ -16,15 +16,14 @@ // //===----------------------------------------------------------------------===// -#include -#include #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Method.h" -#include "llvm/Support/DepthFirstIterator.h" -#include "llvm/Support/PostOrderIterator.h" +#include "Support/DepthFirstIterator.h" +#include "Support/PostOrderIterator.h" +#include "Support/CommandLine.h" +#include // OutputMode - The different orderings to print basic blocks in... enum OutputMode { diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 712cf85e81..2a7eb4e06e 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -16,15 +16,14 @@ // //===----------------------------------------------------------------------===// -#include -#include #include "llvm/Module.h" #include "llvm/Assembly/Writer.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Method.h" -#include "llvm/Support/DepthFirstIterator.h" -#include "llvm/Support/PostOrderIterator.h" +#include "Support/DepthFirstIterator.h" +#include "Support/PostOrderIterator.h" +#include "Support/CommandLine.h" +#include // OutputMode - The different orderings to print basic blocks in... enum OutputMode { diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 80a39b2d9c..9bf766fcaa 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -13,10 +13,10 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Writer.h" #include "llvm/Assembly/Writer.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Module.h" #include "llvm/Method.h" -#include +#include "Support/CommandLine.h" +#include #include diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 0386a4955f..927a69a5f3 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -9,7 +9,6 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Writer.h" -#include "llvm/Support/CommandLine.h" #include "llvm/Optimizations/AllOpts.h" #include "llvm/Transforms/Instrumentation/TraceValues.h" #include "llvm/Assembly/PrintModulePass.h" @@ -18,6 +17,7 @@ #include "llvm/Transforms/LevelChange.h" #include "llvm/Transforms/SwapStructContents.h" #include "llvm/Transforms/IPO/GlobalDCE.h" +#include "Support/CommandLine.h" #include #include -- cgit v1.2.3-70-g09d2 From 697954c15da58bd8b186dbafdedd8b06db770201 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 20 Jan 2002 22:54:45 +0000 Subject: Changes to build successfully with GCC 3.02 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1503 91177308-0d34-0410-b5e6-96231b3b80d8 --- Makefile.common | 2 +- Makefile.rules | 2 +- include/Support/Annotation.h | 7 +- include/Support/CommandLine.h | 36 ++--- include/Support/DepthFirstIterator.h | 14 +- include/Support/HashExtras.h | 7 +- include/Support/PostOrderIterator.h | 8 +- include/Support/STLExtras.h | 7 +- include/Support/StringExtras.h | 14 +- include/Support/Tree.h | 16 +- include/llvm/ADT/DepthFirstIterator.h | 14 +- include/llvm/ADT/HashExtras.h | 7 +- include/llvm/ADT/PostOrderIterator.h | 8 +- include/llvm/ADT/STLExtras.h | 7 +- include/llvm/ADT/StringExtras.h | 14 +- include/llvm/ADT/Tree.h | 16 +- include/llvm/Analysis/CallGraph.h | 8 +- include/llvm/Analysis/Dominators.h | 23 +-- include/llvm/Analysis/FindUnsafePointerTypes.h | 6 +- include/llvm/Analysis/FindUsedTypes.h | 6 +- include/llvm/Analysis/InstForest.h | 34 +++-- include/llvm/Analysis/Interval.h | 12 +- include/llvm/Analysis/IntervalIterator.h | 6 +- include/llvm/Analysis/IntervalPartition.h | 6 +- include/llvm/Analysis/LiveVar/LiveVarMap.h | 10 +- include/llvm/Analysis/LiveVar/LiveVarSet.h | 2 +- include/llvm/Analysis/LiveVar/ValueSet.h | 29 +--- include/llvm/Analysis/LoopDepth.h | 4 +- include/llvm/Analysis/LoopInfo.h | 18 ++- include/llvm/Analysis/ModuleAnalyzer.h | 2 +- include/llvm/Analysis/SlotCalculator.h | 8 +- include/llvm/Analysis/Verifier.h | 4 +- include/llvm/Analysis/Writer.h | 47 +++--- include/llvm/Annotation.h | 7 +- include/llvm/Assembly/CachedWriter.h | 10 +- include/llvm/Assembly/Parser.h | 14 +- include/llvm/Assembly/PrintModulePass.h | 7 +- include/llvm/Assembly/Writer.h | 38 ++--- include/llvm/BasicBlock.h | 8 +- include/llvm/Bytecode/Primitives.h | 24 +-- include/llvm/Bytecode/Reader.h | 5 +- include/llvm/CodeGen/InstrForest.h | 9 +- include/llvm/CodeGen/InstrSelection.h | 5 +- include/llvm/CodeGen/InstrSelectionSupport.h | 13 +- include/llvm/CodeGen/InterferenceGraph.h | 12 +- include/llvm/CodeGen/MachineInstr.h | 40 +++-- include/llvm/CodeGen/RegClass.h | 16 +- include/llvm/CodeGen/ValueSet.h | 29 +--- include/llvm/Constants.h | 36 ++--- include/llvm/DerivedTypes.h | 15 +- include/llvm/Function.h | 18 +-- include/llvm/GlobalValue.h | 2 +- include/llvm/GlobalVariable.h | 4 +- include/llvm/InstrTypes.h | 8 +- include/llvm/Instruction.h | 4 +- include/llvm/Linker.h | 2 +- include/llvm/Module.h | 16 +- include/llvm/Pass.h | 4 +- include/llvm/SlotCalculator.h | 8 +- include/llvm/Support/Annotation.h | 7 +- include/llvm/Support/CommandLine.h | 36 ++--- include/llvm/Support/Linker.h | 2 +- include/llvm/Support/NameMangling.h | 4 +- include/llvm/SymbolTable.h | 15 +- include/llvm/Target/MachineInstrInfo.h | 25 ++- include/llvm/Target/TargetCacheInfo.h | 6 +- include/llvm/Target/TargetData.h | 6 +- include/llvm/Target/TargetInstrInfo.h | 25 ++- include/llvm/Target/TargetMachine.h | 6 +- include/llvm/Target/TargetRegInfo.h | 10 +- include/llvm/Target/TargetSchedInfo.h | 46 +++--- include/llvm/Transforms/IPO/ConstantMerge.h | 2 +- include/llvm/Transforms/MutateStructTypes.h | 14 +- include/llvm/Transforms/Utils/Linker.h | 2 +- include/llvm/Type.h | 10 +- include/llvm/User.h | 8 +- include/llvm/Value.h | 16 +- include/llvm/ValueHolder.h | 10 +- include/llvm/iMemory.h | 28 ++-- include/llvm/iOperators.h | 6 +- include/llvm/iOther.h | 10 +- include/llvm/iPHINode.h | 2 +- include/llvm/iTerminators.h | 2 +- lib/Analysis/Expressions.cpp | 7 +- lib/Analysis/IPA/CallGraph.cpp | 8 +- lib/Analysis/IPA/FindUnsafePointerTypes.cpp | 8 +- lib/Analysis/IPA/FindUsedTypes.cpp | 10 +- lib/Analysis/InductionVariable.cpp | 4 +- lib/Analysis/IntervalPartition.cpp | 1 + lib/Analysis/LiveVar/BBLiveVar.cpp | 13 +- lib/Analysis/LiveVar/BBLiveVar.h | 2 +- lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp | 12 +- lib/Analysis/LiveVar/ValueSet.cpp | 21 ++- lib/Analysis/LoopDepth.cpp | 4 +- lib/Analysis/LoopInfo.cpp | 6 +- lib/Analysis/ModuleAnalyzer.cpp | 6 +- lib/Analysis/PostDominators.cpp | 2 + lib/Analysis/Writer.cpp | 30 ++-- lib/AsmParser/Parser.cpp | 3 +- lib/AsmParser/ParserInternals.h | 19 +-- lib/AsmParser/llvmAsmParser.y | 47 +++--- lib/Bytecode/Reader/ConstantReader.cpp | 17 ++- lib/Bytecode/Reader/InstructionReader.cpp | 7 +- lib/Bytecode/Reader/Reader.cpp | 32 ++-- lib/Bytecode/Reader/ReaderInternals.h | 26 ++-- lib/Bytecode/Writer/ConstantWriter.cpp | 4 +- lib/Bytecode/Writer/InstructionWriter.cpp | 10 +- lib/Bytecode/Writer/SlotCalculator.cpp | 5 +- lib/Bytecode/Writer/SlotCalculator.h | 8 +- lib/Bytecode/Writer/Writer.cpp | 14 +- lib/Bytecode/Writer/WriterInternals.h | 8 +- lib/CodeGen/InstrSched/InstrScheduling.cpp | 43 +++--- lib/CodeGen/InstrSched/SchedGraph.cpp | 92 ++++++----- lib/CodeGen/InstrSched/SchedGraph.h | 85 ++++------- lib/CodeGen/InstrSched/SchedPriorities.cpp | 62 +++++--- lib/CodeGen/InstrSched/SchedPriorities.h | 58 +++---- lib/CodeGen/InstrSelection/InstrForest.cpp | 37 ++--- lib/CodeGen/InstrSelection/InstrSelection.cpp | 32 ++-- .../InstrSelection/InstrSelectionSupport.cpp | 2 +- lib/CodeGen/MachineInstr.cpp | 53 +++---- lib/CodeGen/RegAlloc/IGNode.cpp | 24 +-- lib/CodeGen/RegAlloc/IGNode.h | 13 +- lib/CodeGen/RegAlloc/InterferenceGraph.cpp | 76 ++++----- lib/CodeGen/RegAlloc/InterferenceGraph.h | 12 +- lib/CodeGen/RegAlloc/LiveRange.h | 5 +- lib/CodeGen/RegAlloc/LiveRangeInfo.cpp | 124 +++++++-------- lib/CodeGen/RegAlloc/LiveRangeInfo.h | 10 +- lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 170 +++++++++------------ lib/CodeGen/RegAlloc/PhyRegAlloc.h | 18 +-- lib/CodeGen/RegAlloc/RegClass.cpp | 25 +-- lib/CodeGen/RegAlloc/RegClass.h | 16 +- lib/ExecutionEngine/Interpreter/Execution.cpp | 85 ++++++----- .../Interpreter/ExecutionAnnotations.h | 2 +- .../Interpreter/ExternalFunctions.cpp | 25 +-- lib/ExecutionEngine/Interpreter/Interpreter.h | 31 ++-- lib/ExecutionEngine/Interpreter/Support.cpp | 22 +-- lib/ExecutionEngine/Interpreter/UserInput.cpp | 27 ++-- lib/Linker/LinkModules.cpp | 32 ++-- lib/Support/Annotation.cpp | 4 + lib/Support/CommandLine.cpp | 40 ++--- lib/Target/SparcV9/InstrSched/InstrScheduling.cpp | 43 +++--- lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 92 ++++++----- lib/Target/SparcV9/InstrSched/SchedGraph.h | 85 ++++------- lib/Target/SparcV9/InstrSched/SchedPriorities.cpp | 62 +++++--- lib/Target/SparcV9/InstrSched/SchedPriorities.h | 58 +++---- lib/Target/SparcV9/InstrSelection/InstrForest.cpp | 37 ++--- .../SparcV9/InstrSelection/InstrSelection.cpp | 32 ++-- .../InstrSelection/InstrSelectionSupport.cpp | 2 +- lib/Target/SparcV9/LiveVar/BBLiveVar.cpp | 13 +- lib/Target/SparcV9/LiveVar/BBLiveVar.h | 2 +- lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp | 12 +- lib/Target/SparcV9/LiveVar/ValueSet.cpp | 21 ++- lib/Target/SparcV9/RegAlloc/IGNode.cpp | 24 +-- lib/Target/SparcV9/RegAlloc/IGNode.h | 13 +- lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp | 76 ++++----- lib/Target/SparcV9/RegAlloc/InterferenceGraph.h | 12 +- lib/Target/SparcV9/RegAlloc/LiveRange.h | 5 +- lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp | 124 +++++++-------- lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h | 10 +- lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 170 +++++++++------------ lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h | 18 +-- lib/Target/SparcV9/RegAlloc/RegClass.cpp | 25 +-- lib/Target/SparcV9/RegAlloc/RegClass.h | 16 +- lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 68 ++++----- lib/Target/SparcV9/SparcV9InstrInfo.cpp | 34 ++--- lib/Target/SparcV9/SparcV9InstrSelection.cpp | 23 ++- lib/Target/SparcV9/SparcV9InstrSelectionSupport.h | 2 +- lib/Target/SparcV9/SparcV9Internals.h | 40 ++--- lib/Target/SparcV9/SparcV9RegClassInfo.cpp | 19 +-- lib/Target/SparcV9/SparcV9RegClassInfo.h | 16 +- lib/Target/SparcV9/SparcV9RegInfo.cpp | 86 +++++------ lib/Target/SparcV9/SparcV9TargetMachine.cpp | 12 +- lib/Target/TargetData.cpp | 6 +- lib/Target/TargetSchedInfo.cpp | 14 +- lib/Transforms/ExprTypeConvert.cpp | 40 ++--- lib/Transforms/HoistPHIConstants.cpp | 10 +- lib/Transforms/IPO/ConstantMerge.cpp | 8 +- lib/Transforms/IPO/DeadTypeElimination.cpp | 22 +-- lib/Transforms/IPO/GlobalDCE.cpp | 8 +- lib/Transforms/IPO/InlineSimple.cpp | 13 +- lib/Transforms/IPO/MutateStructTypes.cpp | 16 +- lib/Transforms/IPO/SimpleStructMutation.cpp | 14 +- lib/Transforms/Instrumentation/TraceValues.cpp | 15 +- lib/Transforms/LevelRaise.cpp | 8 +- lib/Transforms/Scalar/ADCE.cpp | 20 +-- lib/Transforms/Scalar/ConstantProp.cpp | 2 +- lib/Transforms/Scalar/DCE.cpp | 4 +- lib/Transforms/Scalar/IndVarSimplify.cpp | 10 +- lib/Transforms/Scalar/InductionVars.cpp | 18 ++- lib/Transforms/Scalar/InstructionCombining.cpp | 4 +- lib/Transforms/Scalar/SCCP.cpp | 14 +- lib/Transforms/Scalar/SymbolStripping.cpp | 2 +- lib/Transforms/TransformInternals.cpp | 4 +- lib/Transforms/TransformInternals.h | 15 +- lib/Transforms/Utils/Linker.cpp | 32 ++-- lib/Transforms/Utils/LowerAllocations.cpp | 2 + lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 1 + lib/VMCore/AsmWriter.cpp | 16 +- lib/VMCore/BasicBlock.cpp | 4 +- lib/VMCore/Constants.cpp | 53 ++++--- lib/VMCore/Dominators.cpp | 2 + lib/VMCore/Function.cpp | 8 +- lib/VMCore/InstrTypes.cpp | 6 +- lib/VMCore/Instruction.cpp | 6 +- lib/VMCore/Linker.cpp | 32 ++-- lib/VMCore/Module.cpp | 6 +- lib/VMCore/SlotCalculator.cpp | 5 +- lib/VMCore/SymbolTable.cpp | 15 +- lib/VMCore/Type.cpp | 8 + lib/VMCore/Value.cpp | 8 +- lib/VMCore/Verifier.cpp | 3 + lib/VMCore/iBranch.cpp | 3 +- lib/VMCore/iCall.cpp | 9 +- lib/VMCore/iMemory.cpp | 18 +-- lib/VMCore/iOperators.cpp | 16 +- support/lib/Support/Annotation.cpp | 4 + support/lib/Support/CommandLine.cpp | 40 ++--- support/lib/Support/NameMangling.cpp | 1 + tools/analyze/analyze.cpp | 8 +- tools/as/as.cpp | 44 +++--- tools/dis/dis.cpp | 40 +++-- tools/gccas/gccas.cpp | 8 +- tools/link/link.cpp | 24 +-- tools/llc/llc.cpp | 48 ++++-- tools/llvm-as/as.cpp | 44 +++--- tools/llvm-as/llvm-as.cpp | 44 +++--- tools/llvm-dis/dis.cpp | 40 +++-- tools/llvm-dis/llvm-dis.cpp | 40 +++-- tools/llvm-link/llvm-link.cpp | 24 +-- tools/opt/opt.cpp | 12 +- 230 files changed, 2368 insertions(+), 2440 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/Makefile.common b/Makefile.common index 95f3aa9f09..72d9a32ed7 100644 --- a/Makefile.common +++ b/Makefile.common @@ -52,7 +52,7 @@ RunBurg = $(BURG) $(BURG_OPTS) #Prof = -pg # TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti -CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include +CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused-parameter -Wno-missing-braces -I$(LEVEL)/include # Compile a file, don't link... Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts) diff --git a/Makefile.rules b/Makefile.rules index 95f3aa9f09..72d9a32ed7 100644 --- a/Makefile.rules +++ b/Makefile.rules @@ -52,7 +52,7 @@ RunBurg = $(BURG) $(BURG_OPTS) #Prof = -pg # TODO: Get rid of exceptions! : -fno-exceptions -fno-rtti -CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused -I$(LEVEL)/include +CompileCommonOpts = $(Prof) -Wall -W -Wwrite-strings -Wno-unused-parameter -Wno-missing-braces -I$(LEVEL)/include # Compile a file, don't link... Compile = $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CompileCommonOpts) diff --git a/include/Support/Annotation.h b/include/Support/Annotation.h index 9919732692..c0642e1d23 100644 --- a/include/Support/Annotation.h +++ b/include/Support/Annotation.h @@ -166,12 +166,13 @@ struct AnnotationManager { //===--------------------------------------------------------------------===// // Basic ID <-> Name map functionality - static AnnotationID getID (const string &Name); // Name -> ID - static const string &getName(AnnotationID ID); // ID -> Name + static AnnotationID getID(const std::string &Name); // Name -> ID + static const std::string &getName(AnnotationID ID); // ID -> Name // getID - Name -> ID + registration of a factory function for demand driven // annotation support. - static AnnotationID getID (const string &Name, Factory Fact, void *Data=0); + static AnnotationID getID(const std::string &Name, Factory Fact, + void *Data = 0); //===--------------------------------------------------------------------===// // Annotation creation on demand support... diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index 84a3bc9b59..3c0ac1ac69 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -100,7 +100,7 @@ class Option { // an argument. Should return true if there was an error processing the // argument and the program should exit. // - virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0; + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0; virtual enum NumOccurances getNumOccurancesFlagDefault() const { return Optional; @@ -146,10 +146,10 @@ public: // addOccurance - Wrapper around handleOccurance that enforces Flags // - bool addOccurance(const char *ArgName, const string &Value); + bool addOccurance(const char *ArgName, const std::string &Value); // Prints option name followed by message. Always returns true. - bool error(string Message, const char *ArgName = 0); + bool error(std::string Message, const char *ArgName = 0); public: inline int getNumOccurances() const { return NumOccurances; } @@ -162,7 +162,7 @@ public: // class Alias : public Option { Option &AliasFor; - virtual bool handleOccurance(const char *ArgName, const string &Arg) { + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { return AliasFor.handleOccurance(AliasFor.ArgStr, Arg); } virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} @@ -177,7 +177,7 @@ public: // class Flag : public Option { bool Value; - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); public: inline Flag(const char *ArgStr, const char *Message, int Flags = 0, bool DefaultVal = 0) : Option(ArgStr, Message, Flags), @@ -193,7 +193,7 @@ public: // class Int : public Option { int Value; - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } @@ -209,18 +209,18 @@ public: //===----------------------------------------------------------------------===// // String valued command line option // -class String : public Option, public string { - virtual bool handleOccurance(const char *ArgName, const string &Arg); +class String : public Option, public std::string { + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } public: inline String(const char *ArgStr, const char *Help, int Flags = 0, const char *DefaultVal = "") - : Option(ArgStr, Help, Flags), string(DefaultVal) {} + : Option(ArgStr, Help, Flags), std::string(DefaultVal) {} - inline const string &operator=(const string &Val) { - return string::operator=(Val); + inline const std::string &operator=(const std::string &Val) { + return std::string::operator=(Val); } }; @@ -228,7 +228,7 @@ public: //===----------------------------------------------------------------------===// // String list command line option // -class StringList : public Option, public vector { +class StringList : public Option, public std::vector { virtual enum NumOccurances getNumOccurancesFlagDefault() const { return ZeroOrMore; @@ -236,7 +236,7 @@ class StringList : public Option, public vector { virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); public: inline StringList(const char *ArgStr, const char *Help, int Flags = 0) @@ -256,7 +256,7 @@ protected: // Use a vector instead of a map, because the lists should be short, // the overhead is less, and most importantly, it keeps them in the order // inserted so we can print our option out nicely. - vector > > ValueMap; + std::vector > > ValueMap; inline EnumBase(const char *ArgStr, const char *Help, int Flags) : Option(ArgStr, Help, Flags) {} @@ -284,7 +284,7 @@ protected: inline EnumValueBase(int Flags) : EnumBase(Flags) {} // handleOccurance - Set Value to the enum value specified by Arg - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); // Return the width of the option tag for printing... virtual unsigned getOptionWidth() const; @@ -323,7 +323,7 @@ class EnumFlagsBase : public EnumValueBase { return ValueDisallowed; } protected: - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {} // Return the width of the option tag for printing... @@ -363,11 +363,11 @@ class EnumListBase : public EnumBase { return ValueDisallowed; } protected: - vector Values; // The options specified so far. + std::vector Values; // The options specified so far. inline EnumListBase(int Flags) : EnumBase(Flags) {} - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); // Return the width of the option tag for printing... virtual unsigned getOptionWidth() const; diff --git a/include/Support/DepthFirstIterator.h b/include/Support/DepthFirstIterator.h index a2d5a9df68..2961497adc 100644 --- a/include/Support/DepthFirstIterator.h +++ b/include/Support/DepthFirstIterator.h @@ -20,21 +20,21 @@ class df_iterator : public std::forward_iterator Visited; // All of the blocks visited so far... + std::set Visited; // All of the blocks visited so far... // VisitStack - Used to maintain the ordering. Top = current block // First element is node pointer, second is the 'next child' to visit - stack > VisitStack; + std::stack > VisitStack; const bool Reverse; // Iterate over children before self? private: void reverseEnterNode() { - pair &Top = VisitStack.top(); + std::pair &Top = VisitStack.top(); NodeType *Node = Top.first; ChildItTy &It = Top.second; for (; It != GT::child_end(Node); ++It) { NodeType *Child = *It; if (!Visited.count(Child)) { Visited.insert(Child); - VisitStack.push(make_pair(Child, GT::child_begin(Child))); + VisitStack.push(std::make_pair(Child, GT::child_begin(Child))); reverseEnterNode(); return; } @@ -43,7 +43,7 @@ private: inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) { Visited.insert(Node); - VisitStack.push(make_pair(Node, GT::child_begin(Node))); + VisitStack.push(std::make_pair(Node, GT::child_begin(Node))); if (Reverse) reverseEnterNode(); } inline df_iterator() { /* End is when stack is empty */ } @@ -81,7 +81,7 @@ public: reverseEnterNode(); } else { // Normal Depth First Iterator do { - pair &Top = VisitStack.top(); + std::pair &Top = VisitStack.top(); NodeType *Node = Top.first; ChildItTy &It = Top.second; @@ -90,7 +90,7 @@ public: if (!Visited.count(Next)) { // Has our next sibling been visited? // No, do it now. Visited.insert(Next); - VisitStack.push(make_pair(Next, GT::child_begin(Next))); + VisitStack.push(std::make_pair(Next, GT::child_begin(Next))); return *this; } } diff --git a/include/Support/HashExtras.h b/include/Support/HashExtras.h index 6ea831e78f..d7e48a3b62 100644 --- a/include/Support/HashExtras.h +++ b/include/Support/HashExtras.h @@ -11,7 +11,10 @@ #define LLVM_SUPPORT_HASHEXTRAS_H #include -#include +#include + +// Cannot specialize hash template from outside of the std namespace. +namespace std { template <> struct hash { size_t operator()(string const &str) const { @@ -24,4 +27,6 @@ template struct hash { inline size_t operator()(const T *Val) const { return (size_t)Val; } }; +} // End namespace std + #endif diff --git a/include/Support/PostOrderIterator.h b/include/Support/PostOrderIterator.h index 89a9b4db86..85b3bf649c 100644 --- a/include/Support/PostOrderIterator.h +++ b/include/Support/PostOrderIterator.h @@ -20,10 +20,10 @@ class po_iterator : public std::forward_iterator Visited; // All of the blocks visited so far... + std::set Visited; // All of the blocks visited so far... // VisitStack - Used to maintain the ordering. Top = current block // First element is basic block pointer, second is the 'next child' to visit - stack > VisitStack; + std::stack > VisitStack; void traverseChild() { while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) { @@ -122,10 +122,10 @@ ipo_iterator ipo_end(T G){ // } // -typedef reverse_iterator::iterator> rpo_iterator; +typedef std::vector::reverse_iterator rpo_iterator; // TODO: FIXME: ReversePostOrderTraversal is not generic! class ReversePostOrderTraversal { - vector Blocks; // Block list in normal PO order + std::vector Blocks; // Block list in normal PO order inline void Initialize(BasicBlock *BB) { copy(po_begin(BB), po_end(BB), back_inserter(Blocks)); } diff --git a/include/Support/STLExtras.h b/include/Support/STLExtras.h index 44d789dcf2..0168bf2624 100644 --- a/include/Support/STLExtras.h +++ b/include/Support/STLExtras.h @@ -36,7 +36,7 @@ // arguments to get a boolean result. // template -struct bitwise_or : public binary_function { +struct bitwise_or : public std::binary_function { bool operator()(const Ty& left, const Ty& right) const { return left | right; } @@ -70,9 +70,9 @@ class mapped_iterator { RootIt current; UnaryFunc Fn; public: - typedef typename iterator_traits::iterator_category + typedef typename std::iterator_traits::iterator_category iterator_category; - typedef typename iterator_traits::difference_type + typedef typename std::iterator_traits::difference_type difference_type; typedef typename UnaryFunc::result_type value_type; typedef typename UnaryFunc::result_type *pointer; @@ -102,6 +102,7 @@ public: _Self& operator-= (difference_type n) { current -= n; return *this; } reference operator[](difference_type n) const { return *(*this + n); } + inline bool operator!=(const _Self &X) const { return !operator==(X); } inline bool operator==(const _Self &X) const { return current == X.current; } inline bool operator< (const _Self &X) const { return current < X.current; } diff --git a/include/Support/StringExtras.h b/include/Support/StringExtras.h index e67e25ced5..46e2c5aaf0 100644 --- a/include/Support/StringExtras.h +++ b/include/Support/StringExtras.h @@ -11,7 +11,7 @@ #include #include -static inline string utostr(uint64_t X, bool isNeg = false) { +static inline std::string utostr(uint64_t X, bool isNeg = false) { char Buffer[40]; char *BufPtr = Buffer+39; @@ -25,10 +25,10 @@ static inline string utostr(uint64_t X, bool isNeg = false) { if (isNeg) *--BufPtr = '-'; // Add negative sign... - return string(BufPtr); + return std::string(BufPtr); } -static inline string itostr(int64_t X) { +static inline std::string itostr(int64_t X) { if (X < 0) return utostr((uint64_t)-X, true); else @@ -36,7 +36,7 @@ static inline string itostr(int64_t X) { } -static inline string utostr(unsigned X, bool isNeg = false) { +static inline std::string utostr(unsigned X, bool isNeg = false) { char Buffer[20]; char *BufPtr = Buffer+19; @@ -50,17 +50,17 @@ static inline string utostr(unsigned X, bool isNeg = false) { if (isNeg) *--BufPtr = '-'; // Add negative sign... - return string(BufPtr); + return std::string(BufPtr); } -static inline string itostr(int X) { +static inline std::string itostr(int X) { if (X < 0) return utostr((unsigned)-X, true); else return utostr((unsigned)X); } -static inline string ftostr(double V) { +static inline std::string ftostr(double V) { char Buffer[200]; snprintf(Buffer, 200, "%e", V); return Buffer; diff --git a/include/Support/Tree.h b/include/Support/Tree.h index 33b0bb7b03..9e8d5ae7ef 100644 --- a/include/Support/Tree.h +++ b/include/Support/Tree.h @@ -12,21 +12,21 @@ template class Tree { - vector Children; // This nodes children, if any - ConcreteTreeNode *Parent; // Parent of this node... - Payload Data; // Data held in this node... + std::vector Children; // This nodes children, if any + ConcreteTreeNode *Parent; // Parent of this node... + Payload Data; // Data held in this node... protected: - void setChildren(const vector &children) { + void setChildren(const std::vector &children) { Children = children; } public: inline Tree(ConcreteTreeNode *parent) : Parent(parent) {} - inline Tree(const vector &children, ConcreteTreeNode *par) - : Children(children), Parent(par) {} + inline Tree(const std::vector &children, + ConcreteTreeNode *par) : Children(children), Parent(par) {} - inline Tree(const vector &children, ConcreteTreeNode *par, - const Payload &data) + inline Tree(const std::vector &children, + ConcreteTreeNode *par, const Payload &data) : Children(children), Parent(parent), Data(data) {} // Tree dtor - Free all children diff --git a/include/llvm/ADT/DepthFirstIterator.h b/include/llvm/ADT/DepthFirstIterator.h index a2d5a9df68..2961497adc 100644 --- a/include/llvm/ADT/DepthFirstIterator.h +++ b/include/llvm/ADT/DepthFirstIterator.h @@ -20,21 +20,21 @@ class df_iterator : public std::forward_iterator Visited; // All of the blocks visited so far... + std::set Visited; // All of the blocks visited so far... // VisitStack - Used to maintain the ordering. Top = current block // First element is node pointer, second is the 'next child' to visit - stack > VisitStack; + std::stack > VisitStack; const bool Reverse; // Iterate over children before self? private: void reverseEnterNode() { - pair &Top = VisitStack.top(); + std::pair &Top = VisitStack.top(); NodeType *Node = Top.first; ChildItTy &It = Top.second; for (; It != GT::child_end(Node); ++It) { NodeType *Child = *It; if (!Visited.count(Child)) { Visited.insert(Child); - VisitStack.push(make_pair(Child, GT::child_begin(Child))); + VisitStack.push(std::make_pair(Child, GT::child_begin(Child))); reverseEnterNode(); return; } @@ -43,7 +43,7 @@ private: inline df_iterator(NodeType *Node, bool reverse) : Reverse(reverse) { Visited.insert(Node); - VisitStack.push(make_pair(Node, GT::child_begin(Node))); + VisitStack.push(std::make_pair(Node, GT::child_begin(Node))); if (Reverse) reverseEnterNode(); } inline df_iterator() { /* End is when stack is empty */ } @@ -81,7 +81,7 @@ public: reverseEnterNode(); } else { // Normal Depth First Iterator do { - pair &Top = VisitStack.top(); + std::pair &Top = VisitStack.top(); NodeType *Node = Top.first; ChildItTy &It = Top.second; @@ -90,7 +90,7 @@ public: if (!Visited.count(Next)) { // Has our next sibling been visited? // No, do it now. Visited.insert(Next); - VisitStack.push(make_pair(Next, GT::child_begin(Next))); + VisitStack.push(std::make_pair(Next, GT::child_begin(Next))); return *this; } } diff --git a/include/llvm/ADT/HashExtras.h b/include/llvm/ADT/HashExtras.h index 6ea831e78f..d7e48a3b62 100644 --- a/include/llvm/ADT/HashExtras.h +++ b/include/llvm/ADT/HashExtras.h @@ -11,7 +11,10 @@ #define LLVM_SUPPORT_HASHEXTRAS_H #include -#include +#include + +// Cannot specialize hash template from outside of the std namespace. +namespace std { template <> struct hash { size_t operator()(string const &str) const { @@ -24,4 +27,6 @@ template struct hash { inline size_t operator()(const T *Val) const { return (size_t)Val; } }; +} // End namespace std + #endif diff --git a/include/llvm/ADT/PostOrderIterator.h b/include/llvm/ADT/PostOrderIterator.h index 89a9b4db86..85b3bf649c 100644 --- a/include/llvm/ADT/PostOrderIterator.h +++ b/include/llvm/ADT/PostOrderIterator.h @@ -20,10 +20,10 @@ class po_iterator : public std::forward_iterator Visited; // All of the blocks visited so far... + std::set Visited; // All of the blocks visited so far... // VisitStack - Used to maintain the ordering. Top = current block // First element is basic block pointer, second is the 'next child' to visit - stack > VisitStack; + std::stack > VisitStack; void traverseChild() { while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) { @@ -122,10 +122,10 @@ ipo_iterator ipo_end(T G){ // } // -typedef reverse_iterator::iterator> rpo_iterator; +typedef std::vector::reverse_iterator rpo_iterator; // TODO: FIXME: ReversePostOrderTraversal is not generic! class ReversePostOrderTraversal { - vector Blocks; // Block list in normal PO order + std::vector Blocks; // Block list in normal PO order inline void Initialize(BasicBlock *BB) { copy(po_begin(BB), po_end(BB), back_inserter(Blocks)); } diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 44d789dcf2..0168bf2624 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -36,7 +36,7 @@ // arguments to get a boolean result. // template -struct bitwise_or : public binary_function { +struct bitwise_or : public std::binary_function { bool operator()(const Ty& left, const Ty& right) const { return left | right; } @@ -70,9 +70,9 @@ class mapped_iterator { RootIt current; UnaryFunc Fn; public: - typedef typename iterator_traits::iterator_category + typedef typename std::iterator_traits::iterator_category iterator_category; - typedef typename iterator_traits::difference_type + typedef typename std::iterator_traits::difference_type difference_type; typedef typename UnaryFunc::result_type value_type; typedef typename UnaryFunc::result_type *pointer; @@ -102,6 +102,7 @@ public: _Self& operator-= (difference_type n) { current -= n; return *this; } reference operator[](difference_type n) const { return *(*this + n); } + inline bool operator!=(const _Self &X) const { return !operator==(X); } inline bool operator==(const _Self &X) const { return current == X.current; } inline bool operator< (const _Self &X) const { return current < X.current; } diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index e67e25ced5..46e2c5aaf0 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -11,7 +11,7 @@ #include #include -static inline string utostr(uint64_t X, bool isNeg = false) { +static inline std::string utostr(uint64_t X, bool isNeg = false) { char Buffer[40]; char *BufPtr = Buffer+39; @@ -25,10 +25,10 @@ static inline string utostr(uint64_t X, bool isNeg = false) { if (isNeg) *--BufPtr = '-'; // Add negative sign... - return string(BufPtr); + return std::string(BufPtr); } -static inline string itostr(int64_t X) { +static inline std::string itostr(int64_t X) { if (X < 0) return utostr((uint64_t)-X, true); else @@ -36,7 +36,7 @@ static inline string itostr(int64_t X) { } -static inline string utostr(unsigned X, bool isNeg = false) { +static inline std::string utostr(unsigned X, bool isNeg = false) { char Buffer[20]; char *BufPtr = Buffer+19; @@ -50,17 +50,17 @@ static inline string utostr(unsigned X, bool isNeg = false) { if (isNeg) *--BufPtr = '-'; // Add negative sign... - return string(BufPtr); + return std::string(BufPtr); } -static inline string itostr(int X) { +static inline std::string itostr(int X) { if (X < 0) return utostr((unsigned)-X, true); else return utostr((unsigned)X); } -static inline string ftostr(double V) { +static inline std::string ftostr(double V) { char Buffer[200]; snprintf(Buffer, 200, "%e", V); return Buffer; diff --git a/include/llvm/ADT/Tree.h b/include/llvm/ADT/Tree.h index 33b0bb7b03..9e8d5ae7ef 100644 --- a/include/llvm/ADT/Tree.h +++ b/include/llvm/ADT/Tree.h @@ -12,21 +12,21 @@ template class Tree { - vector Children; // This nodes children, if any - ConcreteTreeNode *Parent; // Parent of this node... - Payload Data; // Data held in this node... + std::vector Children; // This nodes children, if any + ConcreteTreeNode *Parent; // Parent of this node... + Payload Data; // Data held in this node... protected: - void setChildren(const vector &children) { + void setChildren(const std::vector &children) { Children = children; } public: inline Tree(ConcreteTreeNode *parent) : Parent(parent) {} - inline Tree(const vector &children, ConcreteTreeNode *par) - : Children(children), Parent(par) {} + inline Tree(const std::vector &children, + ConcreteTreeNode *par) : Children(children), Parent(par) {} - inline Tree(const vector &children, ConcreteTreeNode *par, - const Payload &data) + inline Tree(const std::vector &children, + ConcreteTreeNode *par, const Payload &data) : Children(children), Parent(parent), Data(data) {} // Tree dtor - Free all children diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 8365a4f397..f5b020269c 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -27,12 +27,12 @@ namespace cfg { class CallGraph; class CallGraphNode { Method *Meth; - vector CalledMethods; + std::vector CalledMethods; CallGraphNode(const CallGraphNode &); // Do not implement public: - typedef vector::iterator iterator; - typedef vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; // getMethod - Return the method that this call graph node represents... Method *getMethod() const { return Meth; } @@ -65,7 +65,7 @@ private: // Stuff to construct the node, used by CallGraph class CallGraph { Module *Mod; // The module this call graph represents - typedef map MethodMapTy; + typedef std::map MethodMapTy; MethodMapTy MethodMap; // Map from a method to its node CallGraphNode *Root; diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 6639b64a05..c018eafe2c 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -47,8 +47,9 @@ public: // class DominatorSet : public DominatorBase { public: - typedef set DomSetType; // Dom set for a bb - typedef map DomSetMapType; // Map of dom sets + typedef std::set DomSetType; // Dom set for a bb + // Map of dom sets + typedef std::map DomSetMapType; private: DomSetMapType Doms; @@ -91,7 +92,7 @@ public: // method. // class ImmediateDominators : public DominatorBase { - map IDoms; + std::map IDoms; void calcIDoms(const DominatorSet &DS); public: @@ -104,7 +105,7 @@ public: } // Accessor interface: - typedef map IDomMapType; + typedef std::map IDomMapType; typedef IDomMapType::const_iterator const_iterator; inline const_iterator begin() const { return IDoms.begin(); } inline const_iterator end() const { return IDoms.end(); } @@ -114,7 +115,7 @@ public: // node returns null, because it does not have an immediate dominator. // inline const BasicBlock *operator[](const BasicBlock *BB) const { - map::const_iterator I = + std::map::const_iterator I = IDoms.find(BB); return I != IDoms.end() ? I->second : 0; } @@ -130,18 +131,18 @@ class DominatorTree : public DominatorBase { public: typedef Node2 Node; private: - map Nodes; + std::map Nodes; void calculate(const DominatorSet &DS); - typedef map NodeMapType; + typedef std::map NodeMapType; public: - class Node2 : public vector { + class Node2 : public std::vector { friend class DominatorTree; const BasicBlock *TheNode; Node2 * const IDom; public: inline const BasicBlock *getNode() const { return TheNode; } inline Node2 *getIDom() const { return IDom; } - inline const vector &getChildren() const { return *this; } + inline const std::vector &getChildren() const { return *this; } // dominates - Returns true iff this dominates N. Note that this is not a // constant time operation! @@ -181,8 +182,8 @@ public: // class DominanceFrontier : public DominatorBase { public: - typedef set DomSetType; // Dom set for a bb - typedef map DomSetMapType; // Map of dom sets + typedef std::set DomSetType; // Dom set for a bb + typedef std::map DomSetMapType; // Dom set map private: DomSetMapType Frontiers; const DomSetType &calcDomFrontier(const DominatorTree &DT, diff --git a/include/llvm/Analysis/FindUnsafePointerTypes.h b/include/llvm/Analysis/FindUnsafePointerTypes.h index 3f66f3308b..c52ca2fbbb 100644 --- a/include/llvm/Analysis/FindUnsafePointerTypes.h +++ b/include/llvm/Analysis/FindUnsafePointerTypes.h @@ -24,11 +24,11 @@ class PointerType; struct FindUnsafePointerTypes : public Pass { // UnsafeTypes - Set of types that are not safe to transform. - set UnsafeTypes; + std::set UnsafeTypes; public: // Accessor for underlying type set... - inline const set &getUnsafeTypes() const { + inline const std::set &getUnsafeTypes() const { return UnsafeTypes; } @@ -41,7 +41,7 @@ public: // printResults - Loop over the results of the analysis, printing out unsafe // types. // - void printResults(const Module *Mod, ostream &o); + void printResults(const Module *Mod, std::ostream &o); }; #endif diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index aa00e5f8a8..956901dfaa 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -12,7 +12,7 @@ class SymbolTable; class FindUsedTypes : public Pass { - set UsedTypes; + std::set UsedTypes; bool IncludeSymbolTables; public: @@ -25,13 +25,13 @@ public: // getTypes - After the pass has been run, return the set containing all of // the types used in the module. // - inline const set &getTypes() const { return UsedTypes; } + inline const std::set &getTypes() const { return UsedTypes; } // Print the types found in the module. If the optional Module parameter is // passed in, then the types are printed symbolically if possible, using the // symbol table from the module. // - void printTypes(ostream &o, const Module *M = 0) const; + void printTypes(std::ostream &o, const Module *M = 0) const; private: // IncorporateType - Incorporate one type and all of its subtypes into the diff --git a/include/llvm/Analysis/InstForest.h b/include/llvm/Analysis/InstForest.h index e8ab0aae08..13eb54fa52 100644 --- a/include/llvm/Analysis/InstForest.h +++ b/include/llvm/Analysis/InstForest.h @@ -35,10 +35,12 @@ template class InstForest; // template class InstTreeNode : - public Tree, pair, Payload> > { + public Tree, + std::pair, Payload> > { friend class InstForest; - typedef Tree, pair, Payload> > super; + typedef Tree, + std::pair, Payload> > super; // Constants used for the node type value enum NodeTypeTy { @@ -104,15 +106,15 @@ public: public: // print - Called by operator<< below... - void print(ostream &o, unsigned Indent) const { - o << string(Indent*2, ' '); + void print(std::ostream &o, unsigned Indent) const { + o << std::string(Indent*2, ' '); switch (getNodeType()) { case ConstNode : o << "Constant : "; break; - case BasicBlockNode : o << "BasicBlock : " << getValue()->getName() << endl; + case BasicBlockNode : o << "BasicBlock : " << getValue()->getName() << "\n"; return; case InstructionNode: o << "Instruction: "; break; case TemporaryNode : o << "Temporary : "; break; - default: o << "UNKNOWN NODE TYPE: " << getNodeType() << endl; abort(); + default: o << "UNKNOWN NODE TYPE: " << getNodeType() << "\n"; abort(); } o << getValue(); @@ -124,7 +126,8 @@ public: }; template -inline ostream &operator<<(ostream &o, const InstTreeNode *N) { +inline std::ostream &operator<<(std::ostream &o, + const InstTreeNode *N) { N->print(o, 0); return o; } @@ -137,16 +140,16 @@ inline ostream &operator<<(ostream &o, const InstTreeNode *N) { // guaranteed to be an instruction node. The constructor builds the forest. // template -class InstForest : public vector *> { +class InstForest : public std::vector *> { friend class InstTreeNode; // InstMap - Map contains entries for ALL instructions in the method and the // InstTreeNode that they correspond to. // - map *> InstMap; + std::map *> InstMap; void addInstMapping(Instruction *I, InstTreeNode *IN) { - InstMap.insert(make_pair(I, IN)); + InstMap.insert(std::make_pair(I, IN)); } void removeInstFromRootList(Instruction *I) { @@ -180,26 +183,27 @@ public: // the parent pointer can be used to find the root of the tree. // inline InstTreeNode *getInstNode(Instruction *Inst) { - map *>::iterator I = InstMap.find(Inst); + std::map *>::iterator I = + InstMap.find(Inst); if (I != InstMap.end()) return I->second; return 0; } inline const InstTreeNode *getInstNode(const Instruction *Inst)const{ - map*>::const_iterator I = + std::map*>::const_iterator I = InstMap.find(Inst); if (I != InstMap.end()) return I->second; return 0; } // print - Called by operator<< below... - void print(ostream &out) const { + void print(std::ostream &out) const { for (const_iterator I = begin(), E = end(); I != E; ++I) out << *I; } }; template -inline ostream &operator<<(ostream &o, const InstForest &IF) { +inline std::ostream &operator<<(std::ostream &o, const InstForest &IF){ IF.print(o); return o; } @@ -254,7 +258,7 @@ InstTreeNode::InstTreeNode(InstForest &IF, Value *V, // Otherwise, we are an internal instruction node. We must process our // uses and add them as children of this node. // - vector Children; + std::vector Children; // Make sure that the forest knows about us! IF.addInstMapping(I, this); diff --git a/include/llvm/Analysis/Interval.h b/include/llvm/Analysis/Interval.h index db9d67c15a..18f3a88c7e 100644 --- a/include/llvm/Analysis/Interval.h +++ b/include/llvm/Analysis/Interval.h @@ -31,9 +31,9 @@ class Interval { // BasicBlock *HeaderNode; public: - typedef vector::iterator succ_iterator; - typedef vector::iterator pred_iterator; - typedef vector::iterator node_iterator; + typedef std::vector::iterator succ_iterator; + typedef std::vector::iterator pred_iterator; + typedef std::vector::iterator node_iterator; inline Interval(BasicBlock *Header) : HeaderNode(Header) { Nodes.push_back(Header); @@ -46,18 +46,18 @@ public: // Nodes - The basic blocks in this interval. // - vector Nodes; + std::vector Nodes; // Successors - List of BasicBlocks that are reachable directly from nodes in // this interval, but are not in the interval themselves. // These nodes neccesarily must be header nodes for other intervals. // - vector Successors; + std::vector Successors; // Predecessors - List of BasicBlocks that have this Interval's header block // as one of their successors. // - vector Predecessors; + std::vector Predecessors; // contains - Find out if a basic block is in this interval inline bool contains(BasicBlock *BB) const { diff --git a/include/llvm/Analysis/IntervalIterator.h b/include/llvm/Analysis/IntervalIterator.h index 454c0ca07e..52d2cc807d 100644 --- a/include/llvm/Analysis/IntervalIterator.h +++ b/include/llvm/Analysis/IntervalIterator.h @@ -79,8 +79,8 @@ inline void addNodeToInterval(Interval *Int, Interval *I) { template class IntervalIterator { - stack > IntStack; - set Visited; + std::stack > IntStack; + std::set Visited; OrigContainer_t *OrigContainer; bool IOwnMem; // If True, delete intervals when done with them // See file header for conditions of use @@ -88,7 +88,7 @@ public: typedef BasicBlock* _BB; typedef IntervalIterator _Self; - typedef forward_iterator_tag iterator_category; + typedef std::forward_iterator_tag iterator_category; IntervalIterator() {} // End iterator, empty stack IntervalIterator(Method *M, bool OwnMemory) : IOwnMem(OwnMemory) { diff --git a/include/llvm/Analysis/IntervalPartition.h b/include/llvm/Analysis/IntervalPartition.h index 494ccd2097..f05408b022 100644 --- a/include/llvm/Analysis/IntervalPartition.h +++ b/include/llvm/Analysis/IntervalPartition.h @@ -31,11 +31,11 @@ namespace cfg { // BasicBlock is a (possibly nonexistent) loop with a "tail" of non looping // nodes following it. // -class IntervalPartition : public vector { - typedef map IntervalMapTy; +class IntervalPartition : public std::vector { + typedef std::map IntervalMapTy; IntervalMapTy IntervalMap; - typedef vector IntervalListTy; + typedef std::vector IntervalListTy; Interval *RootInterval; public: diff --git a/include/llvm/Analysis/LiveVar/LiveVarMap.h b/include/llvm/Analysis/LiveVar/LiveVarMap.h index bc00d4f281..44b3bbb7a4 100644 --- a/include/llvm/Analysis/LiveVar/LiveVarMap.h +++ b/include/llvm/Analysis/LiveVar/LiveVarMap.h @@ -12,7 +12,7 @@ #ifndef LIVE_VAR_MAP_H #define LIVE_VAR_MAP_H -#include +#include class BasicBlock; class BBLiveVar; @@ -34,11 +34,11 @@ struct hashFuncBB { // sturcture containing the hash function for BB -typedef hash_map BBToBBLiveVarMapType; +typedef std::hash_map BBToBBLiveVarMapType; -typedef hash_map MInstToLiveVarSetMapType; +typedef std::hash_map MInstToLiveVarSetMapType; #endif diff --git a/include/llvm/Analysis/LiveVar/LiveVarSet.h b/include/llvm/Analysis/LiveVar/LiveVarSet.h index 17524fccd3..d7761cfc20 100644 --- a/include/llvm/Analysis/LiveVar/LiveVarSet.h +++ b/include/llvm/Analysis/LiveVar/LiveVarSet.h @@ -8,7 +8,7 @@ #ifndef LIVE_VAR_SET_H #define LIVE_VAR_SET_H -#include "ValueSet.h" +#include "llvm/Analysis/LiveVar/ValueSet.h" #include "llvm/Instruction.h" #include "llvm/Type.h" diff --git a/include/llvm/Analysis/LiveVar/ValueSet.h b/include/llvm/Analysis/LiveVar/ValueSet.h index ee6aa15aab..d17e0229a1 100644 --- a/include/llvm/Analysis/LiveVar/ValueSet.h +++ b/include/llvm/Analysis/LiveVar/ValueSet.h @@ -1,4 +1,4 @@ -/* Title: ValueSet.h +/* Title: ValueSet.h -*- C++ -*- Author: Ruchira Sasanka Date: Jun 30, 01 Purpose: Contains a mathematical set of Values. LiveVarSet is derived from @@ -8,24 +8,9 @@ #ifndef VALUE_SET_H #define VALUE_SET_H -#include - -#include -#include -//#include -#include - -#include "llvm/Value.h" - - -//------------------------ Support functions --------------------------------- - -struct hashFuncValue { // sturcture containing the hash func - inline size_t operator () (const Value *const val) const - { return (size_t) val; } -}; - - +class Value; +#include "Support/HashExtras.h" +#include //------------------- Class Definition for ValueSet -------------------------- @@ -33,12 +18,8 @@ void printValue( const Value *const v); // func to print a Value -class ValueSet : public hash_set -{ - +class ValueSet : public std::hash_set { public: - ValueSet(); // constructor - inline void add(const Value *const val) { assert( val ); insert(val);} // for adding a live variable to set diff --git a/include/llvm/Analysis/LoopDepth.h b/include/llvm/Analysis/LoopDepth.h index 76a590c31f..89068d6bb7 100644 --- a/include/llvm/Analysis/LoopDepth.h +++ b/include/llvm/Analysis/LoopDepth.h @@ -14,14 +14,14 @@ class Method; namespace cfg {class Interval; } class LoopDepthCalculator { - map LoopDepth; + std::map LoopDepth; inline void AddBB(const BasicBlock *BB); // Increment count for this block inline void ProcessInterval(cfg::Interval *I); public: LoopDepthCalculator(Method *M); inline unsigned getLoopDepth(const BasicBlock *BB) const { - map::const_iterator I = LoopDepth.find(BB); + std::map::const_iterator I = LoopDepth.find(BB); return I != LoopDepth.end() ? I->second : 0; } }; diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 3a20226520..10fcfe9f30 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -25,8 +25,8 @@ namespace cfg { // class Loop { Loop *ParentLoop; - vector Blocks; // First entry is the header node - vector SubLoops; // Loops contained entirely within this one + std::vector Blocks; // First entry is the header node + std::vector SubLoops; // Loops contained entirely within this one unsigned LoopDepth; // Nesting depth of this loop Loop(const Loop &); // DO NOT IMPLEMENT @@ -40,8 +40,10 @@ public: bool contains(const BasicBlock *BB) const; // getSubLoops - Return the loops contained entirely within this loop - inline const vector &getSubLoops() const { return SubLoops; } - inline const vector &getBlocks() const { return Blocks; } + inline const std::vector &getSubLoops() const { return SubLoops; } + inline const std::vector &getBlocks() const { + return Blocks; + } private: friend class LoopInfo; @@ -62,19 +64,19 @@ private: // class LoopInfo { // BBMap - Mapping of basic blocks to the inner most loop they occur in - map BBMap; - vector TopLevelLoops; + std::map BBMap; + std::vector TopLevelLoops; public: // LoopInfo ctor - Calculate the natural loop information for a CFG LoopInfo(const DominatorSet &DS); - const vector &getTopLevelLoops() const { return TopLevelLoops; } + const std::vector &getTopLevelLoops() const { return TopLevelLoops; } // getLoopFor - Return the inner most loop that BB lives in. If a basic block // is in no loop (for example the entry node), null is returned. // const Loop *getLoopFor(const BasicBlock *BB) const { - map::const_iterator I = BBMap.find(BB); + std::map::const_iterator I = BBMap.find(BB); return I != BBMap.end() ? I->second : 0; } inline const Loop *operator[](const BasicBlock *BB) const { diff --git a/include/llvm/Analysis/ModuleAnalyzer.h b/include/llvm/Analysis/ModuleAnalyzer.h index a0baa8a7dd..8493becc64 100644 --- a/include/llvm/Analysis/ModuleAnalyzer.h +++ b/include/llvm/Analysis/ModuleAnalyzer.h @@ -78,7 +78,7 @@ protected: virtual bool processInstruction(const Instruction *I) { return false; } private: - bool handleType(set &TypeSet, const Type *T); + bool handleType(std::set &TypeSet, const Type *T); }; #endif diff --git a/include/llvm/Analysis/SlotCalculator.h b/include/llvm/Analysis/SlotCalculator.h index c7b3149054..95282447a5 100644 --- a/include/llvm/Analysis/SlotCalculator.h +++ b/include/llvm/Analysis/SlotCalculator.h @@ -23,14 +23,14 @@ class SlotCalculator { const Module *TheModule; bool IgnoreNamedNodes; // Shall we not count named nodes? - typedef vector TypePlane; - vector Table; - map NodeMap; + typedef std::vector TypePlane; + std::vector Table; + std::map NodeMap; // ModuleLevel - Used to keep track of which values belong to the module, // and which values belong to the currently incorporated method. // - vector ModuleLevel; + std::vector ModuleLevel; public: SlotCalculator(const Module *M, bool IgnoreNamed); diff --git a/include/llvm/Analysis/Verifier.h b/include/llvm/Analysis/Verifier.h index 2feadca779..eb125396c5 100644 --- a/include/llvm/Analysis/Verifier.h +++ b/include/llvm/Analysis/Verifier.h @@ -22,7 +22,7 @@ class Method; // error messages corresponding to the problem are added to the errorMsgs // vectors, and a value of true is returned. // -bool verify(const Module *M, vector &ErrorMsgs); -bool verify(const Method *M, vector &ErrorMsgs); +bool verify(const Module *M, std::vector &ErrorMsgs); +bool verify(const Method *M, std::vector &ErrorMsgs); #endif diff --git a/include/llvm/Analysis/Writer.h b/include/llvm/Analysis/Writer.h index 2b43231872..daaf65729e 100644 --- a/include/llvm/Analysis/Writer.h +++ b/include/llvm/Analysis/Writer.h @@ -16,13 +16,14 @@ namespace cfg { class Interval; class IntervalPartition; - void WriteToOutput(const Interval *I, ostream &o); - inline ostream &operator <<(ostream &o, const Interval *I) { + void WriteToOutput(const Interval *I, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, const Interval *I) { WriteToOutput(I, o); return o; } - void WriteToOutput(const IntervalPartition &IP, ostream &o); - inline ostream &operator <<(ostream &o, const IntervalPartition &IP) { + void WriteToOutput(const IntervalPartition &IP, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, + const IntervalPartition &IP) { WriteToOutput(IP, o); return o; } @@ -32,23 +33,25 @@ namespace cfg { class DominatorTree; class DominanceFrontier; - void WriteToOutput(const DominatorSet &, ostream &o); - inline ostream &operator <<(ostream &o, const DominatorSet &DS) { + void WriteToOutput(const DominatorSet &, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, const DominatorSet &DS) { WriteToOutput(DS, o); return o; } - void WriteToOutput(const ImmediateDominators &, ostream &o); - inline ostream &operator <<(ostream &o, const ImmediateDominators &ID) { + void WriteToOutput(const ImmediateDominators &, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, + const ImmediateDominators &ID) { WriteToOutput(ID, o); return o; } - void WriteToOutput(const DominatorTree &, ostream &o); - inline ostream &operator <<(ostream &o, const DominatorTree &DT) { + void WriteToOutput(const DominatorTree &, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, const DominatorTree &DT) { WriteToOutput(DT, o); return o; } - void WriteToOutput(const DominanceFrontier &, ostream &o); - inline ostream &operator <<(ostream &o, const DominanceFrontier &DF) { + void WriteToOutput(const DominanceFrontier &, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, + const DominanceFrontier &DF) { WriteToOutput(DF, o); return o; } @@ -56,13 +59,13 @@ namespace cfg { class CallGraph; class CallGraphNode; - void WriteToOutput(const CallGraph &, ostream &o); - inline ostream &operator <<(ostream &o, const CallGraph &CG) { + void WriteToOutput(const CallGraph &, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, const CallGraph &CG) { WriteToOutput(CG, o); return o; } - void WriteToOutput(const CallGraphNode *, ostream &o); - inline ostream &operator <<(ostream &o, const CallGraphNode *CGN) { + void WriteToOutput(const CallGraphNode *, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, const CallGraphNode *CGN) { WriteToOutput(CGN, o); return o; } @@ -70,21 +73,21 @@ namespace cfg { class Loop; class LoopInfo; - void WriteToOutput(const LoopInfo &, ostream &o); - inline ostream &operator <<(ostream &o, const LoopInfo &LI) { + void WriteToOutput(const LoopInfo &, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, const LoopInfo &LI) { WriteToOutput(LI, o); return o; } - void WriteToOutput(const Loop *, ostream &o); - inline ostream &operator <<(ostream &o, const Loop *L) { + void WriteToOutput(const Loop *, std::ostream &o); + inline std::ostream &operator <<(std::ostream &o, const Loop *L) { WriteToOutput(L, o); return o; } } // End namespace CFG class InductionVariable; -void WriteToOutput(const InductionVariable &, ostream &o); -inline ostream &operator <<(ostream &o, const InductionVariable &IV) { +void WriteToOutput(const InductionVariable &, std::ostream &o); +inline std::ostream &operator <<(std::ostream &o, const InductionVariable &IV) { WriteToOutput(IV, o); return o; } diff --git a/include/llvm/Annotation.h b/include/llvm/Annotation.h index 9919732692..c0642e1d23 100644 --- a/include/llvm/Annotation.h +++ b/include/llvm/Annotation.h @@ -166,12 +166,13 @@ struct AnnotationManager { //===--------------------------------------------------------------------===// // Basic ID <-> Name map functionality - static AnnotationID getID (const string &Name); // Name -> ID - static const string &getName(AnnotationID ID); // ID -> Name + static AnnotationID getID(const std::string &Name); // Name -> ID + static const std::string &getName(AnnotationID ID); // ID -> Name // getID - Name -> ID + registration of a factory function for demand driven // annotation support. - static AnnotationID getID (const string &Name, Factory Fact, void *Data=0); + static AnnotationID getID(const std::string &Name, Factory Fact, + void *Data = 0); //===--------------------------------------------------------------------===// // Annotation creation on demand support... diff --git a/include/llvm/Assembly/CachedWriter.h b/include/llvm/Assembly/CachedWriter.h index b5171b4097..cccf0377a4 100644 --- a/include/llvm/Assembly/CachedWriter.h +++ b/include/llvm/Assembly/CachedWriter.h @@ -11,6 +11,7 @@ #define LLVM_ASSEMBLY_CACHED_WRITER_H #include "llvm/Assembly/Writer.h" +#include class AssemblyWriter; // Internal private class class SlotCalculator; @@ -19,10 +20,11 @@ class CachedWriter { AssemblyWriter *AW; SlotCalculator *SC; public: - ostream &Out; + std::ostream &Out; public: - CachedWriter(ostream &O = cout) : AW(0), SC(0), Out(O) { } - CachedWriter(const Module *M, ostream &O = cout) : AW(0), SC(0), Out(O) { + CachedWriter(std::ostream &O = std::cout) : AW(0), SC(0), Out(O) { } + CachedWriter(const Module *M, std::ostream &O = std::cout) + : AW(0), SC(0), Out(O) { setModule(M); } ~CachedWriter(); @@ -63,7 +65,7 @@ public: return *this << (const Value*)X; } - inline CachedWriter &operator<<(ostream &(&Manip)(ostream &)) { + inline CachedWriter &operator<<(std::ostream &(&Manip)(std::ostream &)) { Out << Manip; return *this; } diff --git a/include/llvm/Assembly/Parser.h b/include/llvm/Assembly/Parser.h index 011594d132..02e5d4fbb6 100644 --- a/include/llvm/Assembly/Parser.h +++ b/include/llvm/Assembly/Parser.h @@ -16,7 +16,7 @@ class ParseException; // The useful interface defined by this file... Parse an ascii file, and return // the internal representation in a nice slice'n'dice'able representation. // -Module *ParseAssemblyFile(const string &Filename);// throw (ParseException); +Module *ParseAssemblyFile(const std::string &Filename);// throw (ParseException) //===------------------------------------------------------------------------=== // Helper Classes @@ -27,7 +27,7 @@ Module *ParseAssemblyFile(const string &Filename);// throw (ParseException); // class ParseException { public: - ParseException(const string &filename, const string &message, + ParseException(const std::string &filename, const std::string &message, int LineNo = -1, int ColNo = -1); ParseException(const ParseException &E); @@ -35,13 +35,13 @@ public: // getMessage - Return the message passed in at construction time plus extra // information extracted from the options used to parse with... // - const string getMessage() const; + const std::string getMessage() const; - inline const string getRawMessage() const { // Just the raw message... + inline const std::string &getRawMessage() const { // Just the raw message... return Message; } - inline const string &getFilename() const { + inline const std::string &getFilename() const { return Filename; } @@ -55,8 +55,8 @@ public: } private : - string Filename; - string Message; + std::string Filename; + std::string Message; int LineNo, ColumnNo; // -1 if not relevant ParseException &operator=(const ParseException &E); // objects by reference diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h index a03b3492e6..72d8fabde0 100644 --- a/include/llvm/Assembly/PrintModulePass.h +++ b/include/llvm/Assembly/PrintModulePass.h @@ -10,14 +10,15 @@ #include "llvm/Pass.h" #include "llvm/Assembly/Writer.h" +#include class PrintModulePass : public Pass { - string Banner; // String to print before each method - ostream *Out; // ostream to print on + std::string Banner; // String to print before each method + std::ostream *Out; // ostream to print on bool DeleteStream; // Delete the ostream in our dtor? bool PrintPerMethod; // Print one method at a time rather than the whole? public: - inline PrintModulePass(const string &B, ostream *o = &cout, + inline PrintModulePass(const std::string &B, std::ostream *o = &std::cout, bool DS = false, bool printPerMethod = true) : Banner(B), Out(o), DeleteStream(DS), PrintPerMethod(printPerMethod) { diff --git a/include/llvm/Assembly/Writer.h b/include/llvm/Assembly/Writer.h index 02c9fd0cc1..6ef33ad1b6 100644 --- a/include/llvm/Assembly/Writer.h +++ b/include/llvm/Assembly/Writer.h @@ -30,26 +30,26 @@ class SlotCalculator; // representation of an object into an ascii bytestream that the parser can // understand later... (the parser only understands whole classes though) // -void WriteToAssembly(const Module *Module, ostream &o); -void WriteToAssembly(const GlobalVariable *G, ostream &o); -void WriteToAssembly(const Method *Method, ostream &o); -void WriteToAssembly(const BasicBlock *BB, ostream &o); -void WriteToAssembly(const Instruction *In, ostream &o); -void WriteToAssembly(const Constant *V, ostream &o); +void WriteToAssembly(const Module *Module, std::ostream &o); +void WriteToAssembly(const GlobalVariable *G, std::ostream &o); +void WriteToAssembly(const Method *Method, std::ostream &o); +void WriteToAssembly(const BasicBlock *BB, std::ostream &o); +void WriteToAssembly(const Instruction *In, std::ostream &o); +void WriteToAssembly(const Constant *V, std::ostream &o); // WriteTypeSymbolic - This attempts to write the specified type as a symbolic // type, iff there is an entry in the modules symbol table for the specified // type or one of it's component types. This is slower than a simple x << Type; // -ostream &WriteTypeSymbolic(ostream &o, const Type *Ty, const Module *Module); +std::ostream &WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); // WriteAsOperand - Write the name of the specified value out to the specified // ostream. This can be useful when you just want to print int %reg126, not the // whole instruction that generated it. // -ostream &WriteAsOperand(ostream &o, const Value *V, bool PrintType = true, - bool PrintName = true, SlotCalculator *Table = 0); +std::ostream &WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, + bool PrintName = true, SlotCalculator *Table = 0); // WriteToVCG - Dump the specified structure to a VCG file. If method is @@ -57,8 +57,8 @@ ostream &WriteAsOperand(ostream &o, const Value *V, bool PrintType = true, // family of files with a common base name is created, with a method name // suffix. // -void WriteToVCG(const Module *Module, const string &Filename); -void WriteToVCG(const Method *Method, const string &Filename); +void WriteToVCG(const Module *Module, const std::string &Filename); +void WriteToVCG(const Method *Method, const std::string &Filename); @@ -66,37 +66,37 @@ void WriteToVCG(const Method *Method, const string &Filename); // Define operator<< to work on the various classes that we can send to an // ostream... // -inline ostream &operator<<(ostream &o, const Module *C) { +inline std::ostream &operator<<(std::ostream &o, const Module *C) { WriteToAssembly(C, o); return o; } -inline ostream &operator<<(ostream &o, const GlobalVariable *G) { +inline std::ostream &operator<<(std::ostream &o, const GlobalVariable *G) { WriteToAssembly(G, o); return o; } -inline ostream &operator<<(ostream &o, const Method *M) { +inline std::ostream &operator<<(std::ostream &o, const Method *M) { WriteToAssembly(M, o); return o; } -inline ostream &operator<<(ostream &o, const BasicBlock *B) { +inline std::ostream &operator<<(std::ostream &o, const BasicBlock *B) { WriteToAssembly(B, o); return o; } -inline ostream &operator<<(ostream &o, const Instruction *I) { +inline std::ostream &operator<<(std::ostream &o, const Instruction *I) { WriteToAssembly(I, o); return o; } -inline ostream &operator<<(ostream &o, const Constant *I) { +inline std::ostream &operator<<(std::ostream &o, const Constant *I) { WriteToAssembly(I, o); return o; } -inline ostream &operator<<(ostream &o, const Type *T) { +inline std::ostream &operator<<(std::ostream &o, const Type *T) { if (!T) return o << ""; return o << T->getDescription(); } -inline ostream &operator<<(ostream &o, const Value *I) { +inline std::ostream &operator<<(std::ostream &o, const Value *I) { switch (I->getValueType()) { case Value::TypeVal: return o << cast(I); case Value::ConstantVal: WriteToAssembly(cast(I) , o); break; diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 50de364f3e..6770aa38ae 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -49,8 +49,8 @@ public: // Instruction iterators... typedef InstListType::iterator iterator; typedef InstListType::const_iterator const_iterator; - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; // Predecessor and successor iterators... typedef PredIterator pred_iterator; @@ -61,11 +61,11 @@ public: const BasicBlock> succ_const_iterator; // Ctor, dtor - BasicBlock(const string &Name = "", Method *Parent = 0); + BasicBlock(const std::string &Name = "", Method *Parent = 0); ~BasicBlock(); // Specialize setName to take care of symbol table majik - virtual void setName(const string &name, SymbolTable *ST = 0); + virtual void setName(const std::string &name, SymbolTable *ST = 0); // getParent - Return the enclosing method, or null if none const Method *getParent() const { return InstList.getParent(); } diff --git a/include/llvm/Bytecode/Primitives.h b/include/llvm/Bytecode/Primitives.h index e0c25a15ca..4058bd21ad 100644 --- a/include/llvm/Bytecode/Primitives.h +++ b/include/llvm/Bytecode/Primitives.h @@ -116,12 +116,12 @@ static inline bool align32(const unsigned char *&Buf, } static inline bool read(const unsigned char *&Buf, const unsigned char *EndBuf, - string &Result, bool Aligned = true) { + std::string &Result, bool Aligned = true) { unsigned Size; if (read_vbr(Buf, EndBuf, Size)) return true; // Failure reading size? if (Buf+Size > EndBuf) return true; // Size invalid? - Result = string((char*)Buf, Size); + Result = std::string((char*)Buf, Size); Buf += Size; if (Aligned) // If we should stay aligned do so... @@ -157,7 +157,8 @@ static inline bool input_data(const unsigned char *&Buf, // string... note that this should be inlined always so only the relevant IF // body should be included... // -static inline void output(unsigned i, deque &Out, int pos = -1){ +static inline void output(unsigned i, std::deque &Out, + int pos = -1) { #ifdef LITTLE_ENDIAN if (pos == -1) Out.insert(Out.end(), (unsigned char*)&i, (unsigned char*)&i+4); @@ -178,7 +179,7 @@ static inline void output(unsigned i, deque &Out, int pos = -1){ #endif } -static inline void output(int i, deque &Out) { +static inline void output(int i, std::deque &Out) { output((unsigned)i, Out); } @@ -191,7 +192,7 @@ static inline void output(int i, deque &Out) { // // Note that using this may cause the output buffer to become unaligned... // -static inline void output_vbr(uint64_t i, deque &out) { +static inline void output_vbr(uint64_t i, std::deque &out) { while (1) { if (i < 0x80) { // done? out.push_back((unsigned char)i); // We know the high bit is clear... @@ -205,7 +206,7 @@ static inline void output_vbr(uint64_t i, deque &out) { } } -static inline void output_vbr(unsigned i, deque &out) { +static inline void output_vbr(unsigned i, std::deque &out) { while (1) { if (i < 0x80) { // done? out.push_back((unsigned char)i); // We know the high bit is clear... @@ -219,7 +220,7 @@ static inline void output_vbr(unsigned i, deque &out) { } } -static inline void output_vbr(int64_t i, deque &out) { +static inline void output_vbr(int64_t i, std::deque &out) { if (i < 0) output_vbr(((uint64_t)(-i) << 1) | 1, out); // Set low order sign bit... else @@ -227,7 +228,7 @@ static inline void output_vbr(int64_t i, deque &out) { } -static inline void output_vbr(int i, deque &out) { +static inline void output_vbr(int i, std::deque &out) { if (i < 0) output_vbr(((unsigned)(-i) << 1) | 1, out); // Set low order sign bit... else @@ -237,12 +238,12 @@ static inline void output_vbr(int i, deque &out) { // align32 - emit the minimal number of bytes that will bring us to 32 bit // alignment... // -static inline void align32(deque &Out) { +static inline void align32(std::deque &Out) { int NumPads = (4-(Out.size() & 3)) & 3; // Bytes to get padding to 32 bits while (NumPads--) Out.push_back((unsigned char)0xAB); } -static inline void output(const string &s, deque &Out, +static inline void output(const std::string &s, std::deque &Out, bool Aligned = true) { unsigned Len = s.length(); output_vbr(Len, Out); // Strings may have an arbitrary length... @@ -253,7 +254,8 @@ static inline void output(const string &s, deque &Out, } static inline void output_data(void *Ptr, void *End, - deque &Out, bool Align = false) { + std::deque &Out, + bool Align = false) { #ifdef LITTLE_ENDIAN Out.insert(Out.end(), (unsigned char*)Ptr, (unsigned char*)End); #else diff --git a/include/llvm/Bytecode/Reader.h b/include/llvm/Bytecode/Reader.h index 2ef2532d4d..7cd2365c98 100644 --- a/include/llvm/Bytecode/Reader.h +++ b/include/llvm/Bytecode/Reader.h @@ -18,8 +18,9 @@ class Module; // Parse and return a class... // -Module *ParseBytecodeFile(const string &Filename, string *ErrorStr = 0); +Module *ParseBytecodeFile(const std::string &Filename, + std::string *ErrorStr = 0); Module *ParseBytecodeBuffer(const char *Buffer, unsigned BufferSize, - string *ErrorStr = 0); + std::string *ErrorStr = 0); #endif diff --git a/include/llvm/CodeGen/InstrForest.h b/include/llvm/CodeGen/InstrForest.h index aa101f934d..0f614a6a9f 100644 --- a/include/llvm/CodeGen/InstrForest.h +++ b/include/llvm/CodeGen/InstrForest.h @@ -27,8 +27,7 @@ #include "llvm/Instruction.h" #include "Support/NonCopyable.h" #include "Support/HashExtras.h" -#include -#include +#include class Constant; class BasicBlock; @@ -239,9 +238,9 @@ protected: // //------------------------------------------------------------------------ -class InstrForest : private hash_map { +class InstrForest : private std::hash_map { private: - hash_set treeRoots; + std::hash_set treeRoots; public: /*ctor*/ InstrForest (Method *M); @@ -251,7 +250,7 @@ public: return (*this)[instr]; } - inline const hash_set &getRootSet() const { + inline const std::hash_set &getRootSet() const { return treeRoots; } diff --git a/include/llvm/CodeGen/InstrSelection.h b/include/llvm/CodeGen/InstrSelection.h index 27e3ebe553..287992a47c 100644 --- a/include/llvm/CodeGen/InstrSelection.h +++ b/include/llvm/CodeGen/InstrSelection.h @@ -84,7 +84,8 @@ class TmpInstruction : public Instruction { public: // Constructor that uses the type of S1 as the type of the temporary. // s1 must be a valid value. s2 may be NULL. - TmpInstruction(OtherOps opcode, Value *s1, Value* s2, const string &name="") + TmpInstruction(OtherOps opcode, Value *s1, Value* s2, + const std::string &name = "") : Instruction(s1->getType(), opcode, name) { assert(s1 != NULL && "Use different constructor if both operands are 0"); @@ -94,7 +95,7 @@ public: // Constructor that allows the type of the temporary to be specified. // Both S1 and S2 may be NULL. TmpInstruction(OtherOps opcode, const Type* tmpType, - Value *s1, Value* s2, const string &name = "") + Value *s1, Value* s2, const std::string &name = "") : Instruction(tmpType, opcode, name) { Initialize(opcode, s1, s2); diff --git a/include/llvm/CodeGen/InstrSelectionSupport.h b/include/llvm/CodeGen/InstrSelectionSupport.h index 2cce1dc754..33af635d8e 100644 --- a/include/llvm/CodeGen/InstrSelectionSupport.h +++ b/include/llvm/CodeGen/InstrSelectionSupport.h @@ -24,8 +24,6 @@ class TmpInstruction; class Constant; class TargetMachine; -//************************ Exported Functions ******************************/ - //--------------------------------------------------------------------------- // Function GetConstantValueAsSignedInt @@ -54,7 +52,7 @@ int64_t GetConstantValueAsSignedInt (const Value *V, //--------------------------------------------------------------------------- Value* FoldGetElemChain (const InstructionNode* getElemInstrNode, - vector& chainIdxVec); + std::vector& chainIdxVec); //------------------------------------------------------------------------ @@ -130,11 +128,8 @@ MachineOperand::MachineOperandType // fall under case 3; these must be inserted before `minstr'. //--------------------------------------------------------------------------- -vector FixConstantOperandsForInstr (Instruction* vmInstr, - MachineInstr* minstr, - TargetMachine& target); - - -//**************************************************************************/ +std::vector FixConstantOperandsForInstr (Instruction* vmInstr, + MachineInstr* minstr, + TargetMachine& target); #endif diff --git a/include/llvm/CodeGen/InterferenceGraph.h b/include/llvm/CodeGen/InterferenceGraph.h index 99dea8fbe0..408bee4558 100644 --- a/include/llvm/CodeGen/InterferenceGraph.h +++ b/include/llvm/CodeGen/InterferenceGraph.h @@ -1,4 +1,4 @@ -/* Title: InterferenceGraph.h +/* Title: InterferenceGraph.h -*- C++ -*- Author: Ruchira Sasanka Date: July 20, 01 Purpose: Interference Graph used for register coloring. @@ -24,7 +24,7 @@ #include "llvm/CodeGen/IGNode.h" -typedef vector IGNodeListType; +typedef std::vector IGNodeListType; class InterferenceGraph @@ -47,6 +47,8 @@ class InterferenceGraph // to create it after adding all IGNodes to the IGNodeList InterferenceGraph(RegClass *const RC); + ~InterferenceGraph(); + void createGraph(); void addLRToIG(LiveRange *const LR); @@ -65,12 +67,6 @@ class InterferenceGraph void printIG() const; void printIGNodeList() const; - - ~InterferenceGraph(); - - }; - #endif - diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index d6b8ef7154..4c5dd1056c 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -22,8 +22,6 @@ #include "llvm/Annotation.h" #include "llvm/Method.h" #include -#include -#include #include template class ValOpIterator; @@ -131,7 +129,7 @@ public: } public: - friend ostream& operator<<(ostream& os, const MachineOperand& mop); + friend std::ostream& operator<<(std::ostream& os, const MachineOperand& mop); private: @@ -262,9 +260,9 @@ class MachineInstr : public NonCopyable { private: MachineOpCode opCode; OpCodeMask opCodeMask; // extra bits for variants of an opcode - vector operands; - vector implicitRefs; // values implicitly referenced by this - vector implicitIsDef; // machine instruction (eg, call args) + std::vector operands; + std::vector implicitRefs; // values implicitly referenced by this + std::vector implicitIsDef; // machine instruction (eg, call args) public: typedef ValOpIterator val_const_op_iterator; @@ -306,9 +304,9 @@ public: public: - friend ostream& operator<<(ostream& os, const MachineInstr& minstr); - friend val_const_op_iterator; - friend val_op_iterator; + friend std::ostream& operator<<(std::ostream& os, const MachineInstr& minstr); + friend class val_const_op_iterator; + friend class val_op_iterator; public: // Access to set the operands when building the machine instruction @@ -449,17 +447,17 @@ public: // //--------------------------------------------------------------------------- -class MachineCodeForVMInstr: public vector +class MachineCodeForVMInstr: public std::vector { private: - vector tempVec; // used by m/c instr but not VM instr + std::vector tempVec; // used by m/c instr but not VM instr public: /*ctor*/ MachineCodeForVMInstr () {} /*ctor*/ ~MachineCodeForVMInstr (); - const vector& getTempValues () const { return tempVec; } - vector& getTempValues () { return tempVec; } + const std::vector& getTempValues () const { return tempVec; } + std::vector& getTempValues () { return tempVec; } void addTempValue (Value* val) { tempVec.push_back(val); } @@ -499,10 +497,10 @@ MachineCodeForVMInstr::~MachineCodeForVMInstr() //--------------------------------------------------------------------------- -class MachineCodeForBasicBlock: public vector { +class MachineCodeForBasicBlock: public std::vector { public: - typedef vector::iterator iterator; - typedef vector::const_iterator const_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; }; @@ -529,8 +527,8 @@ private: unsigned currentOptionalArgsSize; unsigned maxOptionalArgsSize; unsigned currentTmpValuesSize; - hash_set constantsForConstPool; - hash_map offsets; + std::hash_set constantsForConstPool; + std::hash_map offsets; // hash_map offsetsFromSP; public: @@ -572,7 +570,7 @@ public: inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;} inline unsigned getCurrentOptionalArgsSize() const { return currentOptionalArgsSize;} - inline const hash_set& + inline const std::hash_set& getConstantPoolValues() const {return constantsForConstPool;} // @@ -628,10 +626,10 @@ private: //--------------------------------------------------------------------------- -ostream& operator<< (ostream& os, const MachineInstr& minstr); +std::ostream& operator<< (std::ostream& os, const MachineInstr& minstr); -ostream& operator<< (ostream& os, const MachineOperand& mop); +std::ostream& operator<< (std::ostream& os, const MachineOperand& mop); void PrintMachineInstructions(const Method *method); diff --git a/include/llvm/CodeGen/RegClass.h b/include/llvm/CodeGen/RegClass.h index d6cbaf892b..fe25986f40 100644 --- a/include/llvm/CodeGen/RegClass.h +++ b/include/llvm/CodeGen/RegClass.h @@ -13,8 +13,9 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MachineRegInfo.h" #include +#include -typedef vector ReservedColorListType; +typedef std::vector ReservedColorListType; //----------------------------------------------------------------------------- @@ -46,7 +47,7 @@ class RegClass InterferenceGraph IG; // Interference graph - constructed by // buildInterferenceGraph - stack IGNodeStack; // the stack used for coloring + std::stack IGNodeStack; // the stack used for coloring const ReservedColorListType *const ReservedColorList; // @@ -117,21 +118,14 @@ class RegClass inline void printIGNodeList() const { - cerr << "IG Nodes for Register Class " << RegClassID << ":" << endl; + std::cerr << "IG Nodes for Register Class " << RegClassID << ":" << "\n"; IG.printIGNodeList(); } inline void printIG() { - cerr << "IG for Register Class " << RegClassID << ":" << endl; + std::cerr << "IG for Register Class " << RegClassID << ":" << "\n"; IG.printIG(); } - }; - - - - - - #endif diff --git a/include/llvm/CodeGen/ValueSet.h b/include/llvm/CodeGen/ValueSet.h index ee6aa15aab..d17e0229a1 100644 --- a/include/llvm/CodeGen/ValueSet.h +++ b/include/llvm/CodeGen/ValueSet.h @@ -1,4 +1,4 @@ -/* Title: ValueSet.h +/* Title: ValueSet.h -*- C++ -*- Author: Ruchira Sasanka Date: Jun 30, 01 Purpose: Contains a mathematical set of Values. LiveVarSet is derived from @@ -8,24 +8,9 @@ #ifndef VALUE_SET_H #define VALUE_SET_H -#include - -#include -#include -//#include -#include - -#include "llvm/Value.h" - - -//------------------------ Support functions --------------------------------- - -struct hashFuncValue { // sturcture containing the hash func - inline size_t operator () (const Value *const val) const - { return (size_t) val; } -}; - - +class Value; +#include "Support/HashExtras.h" +#include //------------------- Class Definition for ValueSet -------------------------- @@ -33,12 +18,8 @@ void printValue( const Value *const v); // func to print a Value -class ValueSet : public hash_set -{ - +class ValueSet : public std::hash_set { public: - ValueSet(); // constructor - inline void add(const Value *const val) { assert( val ); insert(val);} // for adding a live variable to set diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 7ce2feced7..1a4ebda6ec 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -36,9 +36,9 @@ protected: void destroyConstantImpl(); public: // Specialize setName to handle symbol table majik... - virtual void setName(const string &name, SymbolTable *ST = 0); + virtual void setName(const std::string &name, SymbolTable *ST = 0); - virtual string getStrValue() const = 0; + virtual std::string getStrValue() const = 0; // Static constructor to get a '0' constant of arbitrary type... static Constant *getNullConstant(const Type *Ty); @@ -78,7 +78,7 @@ public: // inverted - Return the opposite value of the current value. inline ConstantBool *inverted() const { return (this==True) ? False : True; } - virtual string getStrValue() const; + virtual std::string getStrValue() const; inline bool getValue() const { return Val; } // isNullValue - Return true if this is the value that would be returned by @@ -149,7 +149,7 @@ protected: public: static ConstantSInt *get(const Type *Ty, int64_t V); - virtual string getStrValue() const; + virtual std::string getStrValue() const; static bool isValueValidForType(const Type *Ty, int64_t V); inline int64_t getValue() const { return Val.Signed; } @@ -173,7 +173,7 @@ protected: public: static ConstantUInt *get(const Type *Ty, uint64_t V); - virtual string getStrValue() const; + virtual std::string getStrValue() const; static bool isValueValidForType(const Type *Ty, uint64_t V); inline uint64_t getValue() const { return Val.Unsigned; } @@ -199,7 +199,7 @@ protected: public: static ConstantFP *get(const Type *Ty, double V); - virtual string getStrValue() const; + virtual std::string getStrValue() const; static bool isValueValidForType(const Type *Ty, double V); inline double getValue() const { return Val; } @@ -223,20 +223,20 @@ public: class ConstantArray : public Constant { ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT protected: - ConstantArray(const ArrayType *T, const vector &Val); + ConstantArray(const ArrayType *T, const std::vector &Val); ~ConstantArray() {} virtual void destroyConstant(); public: - static ConstantArray *get(const ArrayType *T, const vector &); - static ConstantArray *get(const string &Initializer); + static ConstantArray *get(const ArrayType *T, const std::vector &); + static ConstantArray *get(const std::string &Initializer); - virtual string getStrValue() const; + virtual std::string getStrValue() const; inline const ArrayType *getType() const { return (ArrayType*)Value::getType(); } - inline const vector &getValues() const { return Operands; } + inline const std::vector &getValues() const { return Operands; } // isNullValue - Return true if this is the value that would be returned by // getNullConstant. @@ -257,20 +257,20 @@ public: class ConstantStruct : public Constant { ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT protected: - ConstantStruct(const StructType *T, const vector &Val); + ConstantStruct(const StructType *T, const std::vector &Val); ~ConstantStruct() {} virtual void destroyConstant(); public: static ConstantStruct *get(const StructType *T, - const vector &V); + const std::vector &V); - virtual string getStrValue() const; + virtual std::string getStrValue() const; inline const StructType *getType() const { return (StructType*)Value::getType(); } - inline const vector &getValues() const { return Operands; } + inline const std::vector &getValues() const { return Operands; } // isNullValue - Return true if this is the value that would be returned by // getNullConstant. @@ -297,7 +297,7 @@ protected: inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){} ~ConstantPointer() {} public: - virtual string getStrValue() const = 0; + virtual std::string getStrValue() const = 0; inline const PointerType *getType() const { return (PointerType*)Value::getType(); } @@ -322,7 +322,7 @@ protected: inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {} inline ~ConstantPointerNull() {} public: - virtual string getStrValue() const; + virtual std::string getStrValue() const; static ConstantPointerNull *get(const PointerType *T); @@ -359,7 +359,7 @@ protected: public: static ConstantPointerRef *get(GlobalValue *GV); - virtual string getStrValue() const; + virtual std::string getStrValue() const; const GlobalValue *getValue() const { return cast(Operands[0].get()); diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index 4e69a8c067..10ff57bd42 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -18,7 +18,7 @@ class DerivedType : public Type { // if I am a type, and I get resolved into a more concrete type. // ///// FIXME: kill mutable nonsense when Type's are not const - mutable vector AbstractTypeUsers; + mutable std::vector AbstractTypeUsers; char isRefining; // Used for recursive types @@ -94,7 +94,7 @@ public: class MethodType : public DerivedType { public: - typedef vector > ParamTypes; + typedef std::vector > ParamTypes; private: PATypeHandle ResultType; ParamTypes ParamTys; @@ -108,7 +108,7 @@ protected: // defines private constructors and has no friends // Private ctor - Only can be created by a static member... - MethodType(const Type *Result, const vector &Params, + MethodType(const Type *Result, const std::vector &Params, bool IsVarArgs); public: @@ -130,7 +130,8 @@ public: // virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); - static MethodType *get(const Type *Result, const vector &Params, + static MethodType *get(const Type *Result, + const std::vector &Params, bool isVarArg); @@ -180,7 +181,7 @@ public: class StructType : public CompositeType { public: - typedef vector > ElementTypes; + typedef std::vector > ElementTypes; private: ElementTypes ETypes; // Element types of struct @@ -194,7 +195,7 @@ protected: // defines private constructors and has no friends // Private ctor - Only can be created by a static member... - StructType(const vector &Types); + StructType(const std::vector &Types); public: inline const ElementTypes &getElementTypes() const { return ETypes; } @@ -221,7 +222,7 @@ public: // virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy); - static StructType *get(const vector &Params); + static StructType *get(const std::vector &Params); // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const StructType *T) { return true; } diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 9c026cc9a3..93b9dc6d7a 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -29,8 +29,8 @@ public: // BasicBlock iterators... typedef BasicBlocksType::iterator iterator; typedef BasicBlocksType::const_iterator const_iterator; - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; private: @@ -42,11 +42,11 @@ private: void setParent(Module *parent); public: - Method(const MethodType *Ty, bool isInternal, const string &Name = ""); + Method(const MethodType *Ty, bool isInternal, const std::string &Name = ""); ~Method(); // Specialize setName to handle symbol table majik... - virtual void setName(const string &name, SymbolTable *ST = 0); + virtual void setName(const std::string &name, SymbolTable *ST = 0); const Type *getReturnType() const; // Return the return type of method const MethodType *getMethodType() const; // Return the MethodType for me @@ -129,11 +129,11 @@ public: _BB_i_t BB; // BasicBlocksType::iterator _BI_t BI; // BasicBlock::iterator public: - typedef bidirectional_iterator_tag iterator_category; - typedef IIty value_type; - typedef unsigned difference_type; - typedef BIty pointer; - typedef IIty reference; + typedef std::bidirectional_iterator_tag iterator_category; + typedef IIty value_type; + typedef unsigned difference_type; + typedef BIty pointer; + typedef IIty reference; template InstIterator(M &m) : BBs(m.getBasicBlocks()), BB(BBs.begin()) { // begin ctor diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h index d6a977bd37..1527940d79 100644 --- a/include/llvm/GlobalValue.h +++ b/include/llvm/GlobalValue.h @@ -17,7 +17,7 @@ class GlobalValue : public User { GlobalValue(const GlobalValue &); // do not implement protected: GlobalValue(const Type *Ty, ValueTy vty, bool hasInternalLinkage, - const string &name = "") + const std::string &name = "") : User(Ty, vty, name), HasInternalLinkage(hasInternalLinkage), Parent(0) {} bool HasInternalLinkage; // Is this value accessable externally? diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h index f46fa359cb..9f10f719ef 100644 --- a/include/llvm/GlobalVariable.h +++ b/include/llvm/GlobalVariable.h @@ -25,11 +25,11 @@ class GlobalVariable : public GlobalValue { bool isConstantGlobal; // Is this a global constant? public: GlobalVariable(const Type *Ty, bool isConstant, bool isInternal, - Constant *Initializer = 0, const string &Name = ""); + Constant *Initializer = 0, const std::string &Name = ""); ~GlobalVariable() {} // Specialize setName to handle symbol table majik... - virtual void setName(const string &name, SymbolTable *ST = 0); + virtual void setName(const std::string &name, SymbolTable *ST = 0); // The initializer for the global variable/constant is held by Operands[0] if // an initializer is specified. diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index 3d834e97a0..4aa612af70 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -25,7 +25,7 @@ class TerminatorInst : public Instruction { public: TerminatorInst(Instruction::TermOps iType); TerminatorInst(const Type *Ty, Instruction::TermOps iType, - const string &Name = ""); + const std::string &Name = ""); inline ~TerminatorInst() {} // Terminators must implement the methods required by Instruction... @@ -66,7 +66,7 @@ public: // static UnaryOperator *create(UnaryOps Op, Value *Source); - UnaryOperator(Value *S, UnaryOps iType, const string &Name = "") + UnaryOperator(Value *S, UnaryOps iType, const std::string &Name = "") : Instruction(S->getType(), iType, Name) { Operands.reserve(1); Operands.push_back(Use(S, this)); @@ -105,10 +105,10 @@ public: // and the two operands. // static BinaryOperator *create(BinaryOps Op, Value *S1, Value *S2, - const string &Name = ""); + const std::string &Name = ""); BinaryOperator(BinaryOps iType, Value *S1, Value *S2, - const string &Name = "") + const std::string &Name = "") : Instruction(S1->getType(), iType, Name) { Operands.reserve(2); Operands.push_back(Use(S1, this)); diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index a7407ab3c8..efcecc9303 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -25,11 +25,11 @@ class Instruction : public User { protected: unsigned iType; // InstructionType public: - Instruction(const Type *Ty, unsigned iType, const string &Name = ""); + Instruction(const Type *Ty, unsigned iType, const std::string &Name = ""); virtual ~Instruction(); // Virtual dtor == good. // Specialize setName to handle symbol table majik... - virtual void setName(const string &name, SymbolTable *ST = 0); + virtual void setName(const std::string &name, SymbolTable *ST = 0); // clone() - Create a copy of 'this' instruction that is identical in all ways // except the following: diff --git a/include/llvm/Linker.h b/include/llvm/Linker.h index 3650ccbadf..e74c5d40fa 100644 --- a/include/llvm/Linker.h +++ b/include/llvm/Linker.h @@ -16,7 +16,7 @@ class Module; // error occurs, true is returned and ErrorMsg (if not null) is set to indicate // the problem. // -bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0); +bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0); #endif diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 92f137eb95..617840c809 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -26,16 +26,16 @@ public: typedef ValueHolder MethodListType; // Global Variable iterators... - typedef GlobalListType::iterator giterator; - typedef GlobalListType::const_iterator const_giterator; - typedef reverse_iterator reverse_giterator; - typedef reverse_iterator const_reverse_giterator; + typedef GlobalListType::iterator giterator; + typedef GlobalListType::const_iterator const_giterator; + typedef std::reverse_iterator reverse_giterator; + typedef std::reverse_iterator const_reverse_giterator; // Method iterators... - typedef MethodListType::iterator iterator; - typedef MethodListType::const_iterator const_iterator; - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; + typedef MethodListType::iterator iterator; + typedef MethodListType::const_iterator const_iterator; + typedef std::reverse_iterator reverse_iterator; + typedef std::reverse_iterator const_reverse_iterator; private: GlobalListType GlobalList; // The Global Variables diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index e357df0037..c00092786e 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -45,7 +45,7 @@ struct Pass { // // runAllPasses - Run a bunch of passes on the specified module, efficiently. - static bool runAllPasses(Module *M, vector &Passes) { + static bool runAllPasses(Module *M, std::vector &Passes) { bool MadeChanges = false; // Run all of the pass initializers for (unsigned i = 0; i < Passes.size(); ++i) @@ -65,7 +65,7 @@ struct Pass { // runAllPassesAndFree - Run a bunch of passes on the specified module, // efficiently. When done, delete all of the passes. // - static bool runAllPassesAndFree(Module *M, vector &Passes) { + static bool runAllPassesAndFree(Module *M, std::vector &Passes) { // First run all of the passes bool MadeChanges = runAllPasses(M, Passes); diff --git a/include/llvm/SlotCalculator.h b/include/llvm/SlotCalculator.h index c7b3149054..95282447a5 100644 --- a/include/llvm/SlotCalculator.h +++ b/include/llvm/SlotCalculator.h @@ -23,14 +23,14 @@ class SlotCalculator { const Module *TheModule; bool IgnoreNamedNodes; // Shall we not count named nodes? - typedef vector TypePlane; - vector Table; - map NodeMap; + typedef std::vector TypePlane; + std::vector Table; + std::map NodeMap; // ModuleLevel - Used to keep track of which values belong to the module, // and which values belong to the currently incorporated method. // - vector ModuleLevel; + std::vector ModuleLevel; public: SlotCalculator(const Module *M, bool IgnoreNamed); diff --git a/include/llvm/Support/Annotation.h b/include/llvm/Support/Annotation.h index 9919732692..c0642e1d23 100644 --- a/include/llvm/Support/Annotation.h +++ b/include/llvm/Support/Annotation.h @@ -166,12 +166,13 @@ struct AnnotationManager { //===--------------------------------------------------------------------===// // Basic ID <-> Name map functionality - static AnnotationID getID (const string &Name); // Name -> ID - static const string &getName(AnnotationID ID); // ID -> Name + static AnnotationID getID(const std::string &Name); // Name -> ID + static const std::string &getName(AnnotationID ID); // ID -> Name // getID - Name -> ID + registration of a factory function for demand driven // annotation support. - static AnnotationID getID (const string &Name, Factory Fact, void *Data=0); + static AnnotationID getID(const std::string &Name, Factory Fact, + void *Data = 0); //===--------------------------------------------------------------------===// // Annotation creation on demand support... diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 84a3bc9b59..3c0ac1ac69 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -100,7 +100,7 @@ class Option { // an argument. Should return true if there was an error processing the // argument and the program should exit. // - virtual bool handleOccurance(const char *ArgName, const string &Arg) = 0; + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0; virtual enum NumOccurances getNumOccurancesFlagDefault() const { return Optional; @@ -146,10 +146,10 @@ public: // addOccurance - Wrapper around handleOccurance that enforces Flags // - bool addOccurance(const char *ArgName, const string &Value); + bool addOccurance(const char *ArgName, const std::string &Value); // Prints option name followed by message. Always returns true. - bool error(string Message, const char *ArgName = 0); + bool error(std::string Message, const char *ArgName = 0); public: inline int getNumOccurances() const { return NumOccurances; } @@ -162,7 +162,7 @@ public: // class Alias : public Option { Option &AliasFor; - virtual bool handleOccurance(const char *ArgName, const string &Arg) { + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { return AliasFor.handleOccurance(AliasFor.ArgStr, Arg); } virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} @@ -177,7 +177,7 @@ public: // class Flag : public Option { bool Value; - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); public: inline Flag(const char *ArgStr, const char *Message, int Flags = 0, bool DefaultVal = 0) : Option(ArgStr, Message, Flags), @@ -193,7 +193,7 @@ public: // class Int : public Option { int Value; - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } @@ -209,18 +209,18 @@ public: //===----------------------------------------------------------------------===// // String valued command line option // -class String : public Option, public string { - virtual bool handleOccurance(const char *ArgName, const string &Arg); +class String : public Option, public std::string { + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } public: inline String(const char *ArgStr, const char *Help, int Flags = 0, const char *DefaultVal = "") - : Option(ArgStr, Help, Flags), string(DefaultVal) {} + : Option(ArgStr, Help, Flags), std::string(DefaultVal) {} - inline const string &operator=(const string &Val) { - return string::operator=(Val); + inline const std::string &operator=(const std::string &Val) { + return std::string::operator=(Val); } }; @@ -228,7 +228,7 @@ public: //===----------------------------------------------------------------------===// // String list command line option // -class StringList : public Option, public vector { +class StringList : public Option, public std::vector { virtual enum NumOccurances getNumOccurancesFlagDefault() const { return ZeroOrMore; @@ -236,7 +236,7 @@ class StringList : public Option, public vector { virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); public: inline StringList(const char *ArgStr, const char *Help, int Flags = 0) @@ -256,7 +256,7 @@ protected: // Use a vector instead of a map, because the lists should be short, // the overhead is less, and most importantly, it keeps them in the order // inserted so we can print our option out nicely. - vector > > ValueMap; + std::vector > > ValueMap; inline EnumBase(const char *ArgStr, const char *Help, int Flags) : Option(ArgStr, Help, Flags) {} @@ -284,7 +284,7 @@ protected: inline EnumValueBase(int Flags) : EnumBase(Flags) {} // handleOccurance - Set Value to the enum value specified by Arg - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); // Return the width of the option tag for printing... virtual unsigned getOptionWidth() const; @@ -323,7 +323,7 @@ class EnumFlagsBase : public EnumValueBase { return ValueDisallowed; } protected: - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {} // Return the width of the option tag for printing... @@ -363,11 +363,11 @@ class EnumListBase : public EnumBase { return ValueDisallowed; } protected: - vector Values; // The options specified so far. + std::vector Values; // The options specified so far. inline EnumListBase(int Flags) : EnumBase(Flags) {} - virtual bool handleOccurance(const char *ArgName, const string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg); // Return the width of the option tag for printing... virtual unsigned getOptionWidth() const; diff --git a/include/llvm/Support/Linker.h b/include/llvm/Support/Linker.h index 3650ccbadf..e74c5d40fa 100644 --- a/include/llvm/Support/Linker.h +++ b/include/llvm/Support/Linker.h @@ -16,7 +16,7 @@ class Module; // error occurs, true is returned and ErrorMsg (if not null) is set to indicate // the problem. // -bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0); +bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0); #endif diff --git a/include/llvm/Support/NameMangling.h b/include/llvm/Support/NameMangling.h index 67e68c7738..8d33dcc435 100644 --- a/include/llvm/Support/NameMangling.h +++ b/include/llvm/Support/NameMangling.h @@ -14,14 +14,14 @@ class Value; // MangleTypeName - Implement a consistent name-mangling scheme for // a given type. // -string MangleTypeName(const Type *type); +std::string MangleTypeName(const Type *type); // MangleName - implement a consistent name-mangling scheme for all // externally visible (i.e., global) objects. // // privateName should be unique within the module. // -string MangleName(const string &privateName, const Value *V); +std::string MangleName(const std::string &privateName, const Value *V); #endif diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h index 243631161c..e425e88d0d 100644 --- a/include/llvm/SymbolTable.h +++ b/include/llvm/SymbolTable.h @@ -27,10 +27,11 @@ class Type; class SymbolTable : public AbstractTypeUser, - public map > { + public std::map > { public: - typedef map VarMap; - typedef map super; + typedef std::map VarMap; + typedef std::map super; private: SymbolTable *ParentSymTab; @@ -51,7 +52,7 @@ public: SymbolTable *getParentSymTab() { return ParentSymTab; } // lookup - Returns null on failure... - Value *lookup(const Type *Ty, const string &name); + Value *lookup(const Type *Ty, const std::string &name); // insert - Add named definition to the symbol table... inline void insert(Value *N) { @@ -63,7 +64,7 @@ public: // name... There can be a many to one mapping between names and // (constant/type)s. // - inline void insert(const string &Name, Value *V) { + inline void insert(const std::string &Name, Value *V) { assert((isa(V) || isa(V)) && "Can only insert types and constants here!"); insertEntry(Name, V->getType(), V); @@ -78,7 +79,7 @@ public: // it (or derived from it) that does not already occur in the symbol table for // the specified type. // - string getUniqueName(const Type *Ty, const string &BaseName); + std::string getUniqueName(const Type *Ty, const std::string &BaseName); inline unsigned type_size(const Type *TypeID) const { return find(TypeID)->second.size(); @@ -121,7 +122,7 @@ private: // insertEntry - Insert a value into the symbol table with the specified // name... // - void insertEntry(const string &Name, const Type *Ty, Value *V); + void insertEntry(const std::string &Name, const Type *Ty, Value *V); // removeEntry - Remove a value from the symbol table... // diff --git a/include/llvm/Target/MachineInstrInfo.h b/include/llvm/Target/MachineInstrInfo.h index 6b1804fd14..e2489f4045 100644 --- a/include/llvm/Target/MachineInstrInfo.h +++ b/include/llvm/Target/MachineInstrInfo.h @@ -59,11 +59,11 @@ const unsigned int M_PSEUDO_FLAG = 1 << 14; struct MachineInstrDescriptor { - string opCodeString; // Assembly language mnemonic for the opcode. - int numOperands; // Number of args; -1 if variable #args - int resultPos; // Position of the result; -1 if no result + std::string opCodeString; // Assembly language mnemonic for the opcode. + int numOperands; // Number of args; -1 if variable #args + int resultPos; // Position of the result; -1 if no result unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0. - bool immedIsSignExtended; // Is IMMED field sign-extended? If so, + bool immedIsSignExtended; // Is IMMED field sign-extended? If so, // smallest -ve value is -(maxImmedConst+1). unsigned int numDelaySlots; // Number of delay slots after instruction unsigned int latency; // Latency in machine cycles @@ -246,8 +246,8 @@ public: // virtual void CreateCodeToLoadConst(Value* val, Instruction* dest, - vector& minstrVec, - vector& temps) const =0; + std::vector& minstrVec, + std::vector &) const = 0; // Create an instruction sequence to copy an integer value `val' // to a floating point value `dest' by copying to memory and back. @@ -258,8 +258,8 @@ public: virtual void CreateCodeToCopyIntToFloat(Method* method, Value* val, Instruction* dest, - vector& minstrVec, - vector& tempVec, + std::vector& minstVec, + std::vector& tmpVec, TargetMachine& target) const = 0; // Similarly, create an instruction sequence to copy an FP value @@ -269,8 +269,8 @@ public: virtual void CreateCodeToCopyFloatToInt(Method* method, Value* val, Instruction* dest, - vector& minstrVec, - vector& tempVec, + std::vector& minstVec, + std::vector& tmpVec, TargetMachine& target) const = 0; @@ -279,10 +279,7 @@ public: CreateCopyInstructionsByType(const TargetMachine& target, Value* src, Instruction* dest, - vector& minstrVec) const = 0; - - - + std::vector& minstrVec) const = 0; }; #endif diff --git a/include/llvm/Target/TargetCacheInfo.h b/include/llvm/Target/TargetCacheInfo.h index 21436d09fc..34194ec997 100644 --- a/include/llvm/Target/TargetCacheInfo.h +++ b/include/llvm/Target/TargetCacheInfo.h @@ -28,9 +28,9 @@ public: protected: unsigned int numLevels; - vector cacheLineSizes; - vector cacheSizes; - vector cacheAssoc; + std::vector cacheLineSizes; + std::vector cacheSizes; + std::vector cacheAssoc; public: /*ctor*/ MachineCacheInfo (const TargetMachine& tgt); diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h index edd6b26540..2bce5f40b9 100644 --- a/include/llvm/Target/TargetData.h +++ b/include/llvm/Target/TargetData.h @@ -31,7 +31,7 @@ class TargetData { static Annotation *TypeAnFactory(AnnotationID, const Annotable *, void *); public: - TargetData(const string &TargetName, unsigned char PtrSize = 8, + TargetData(const std::string &TargetName, unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8, unsigned char FloatAl = 4, unsigned char LongAl = 8, unsigned char IntAl = 4, unsigned char ShortAl = 2, @@ -61,7 +61,7 @@ public: // stores that include the implicit form of getelementptr. // unsigned getIndexedOffset(const Type *Ty, - const vector &Indices) const; + const std::vector &Indices) const; inline const StructLayout *getStructLayout(const StructType *Ty) const { return (const StructLayout*)((const Type*)Ty)->getOrCreateAnnotation(AID); @@ -73,7 +73,7 @@ public: // TargetData structure. // struct StructLayout : public Annotation { - vector MemberOffsets; + std::vector MemberOffsets; unsigned StructSize; unsigned StructAlignment; private: diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index 6b1804fd14..e2489f4045 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -59,11 +59,11 @@ const unsigned int M_PSEUDO_FLAG = 1 << 14; struct MachineInstrDescriptor { - string opCodeString; // Assembly language mnemonic for the opcode. - int numOperands; // Number of args; -1 if variable #args - int resultPos; // Position of the result; -1 if no result + std::string opCodeString; // Assembly language mnemonic for the opcode. + int numOperands; // Number of args; -1 if variable #args + int resultPos; // Position of the result; -1 if no result unsigned int maxImmedConst; // Largest +ve constant in IMMMED field or 0. - bool immedIsSignExtended; // Is IMMED field sign-extended? If so, + bool immedIsSignExtended; // Is IMMED field sign-extended? If so, // smallest -ve value is -(maxImmedConst+1). unsigned int numDelaySlots; // Number of delay slots after instruction unsigned int latency; // Latency in machine cycles @@ -246,8 +246,8 @@ public: // virtual void CreateCodeToLoadConst(Value* val, Instruction* dest, - vector& minstrVec, - vector& temps) const =0; + std::vector& minstrVec, + std::vector &) const = 0; // Create an instruction sequence to copy an integer value `val' // to a floating point value `dest' by copying to memory and back. @@ -258,8 +258,8 @@ public: virtual void CreateCodeToCopyIntToFloat(Method* method, Value* val, Instruction* dest, - vector& minstrVec, - vector& tempVec, + std::vector& minstVec, + std::vector& tmpVec, TargetMachine& target) const = 0; // Similarly, create an instruction sequence to copy an FP value @@ -269,8 +269,8 @@ public: virtual void CreateCodeToCopyFloatToInt(Method* method, Value* val, Instruction* dest, - vector& minstrVec, - vector& tempVec, + std::vector& minstVec, + std::vector& tmpVec, TargetMachine& target) const = 0; @@ -279,10 +279,7 @@ public: CreateCopyInstructionsByType(const TargetMachine& target, Value* src, Instruction* dest, - vector& minstrVec) const = 0; - - - + std::vector& minstrVec) const = 0; }; #endif diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index ad1f105958..6effeedef5 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -38,14 +38,14 @@ typedef int OpCodeMask; class TargetMachine : public NonCopyableV { public: - const string TargetName; + const std::string TargetName; const TargetData DataLayout; // Calculates type size & alignment int optSizeForSubWordData; int minMemOpWordSize; int maxAtomicMemOpWordSize; protected: - TargetMachine(const string &targetname, // Can only create subclasses... + TargetMachine(const std::string &targetname, // Can only create subclasses... unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8, unsigned char FloatAl = 4, unsigned char LongAl = 8, unsigned char IntAl = 4, @@ -86,7 +86,7 @@ public: // method. The specified method must have been compiled before this may be // used. // - virtual void emitAssembly(const Module *M, ostream &OutStr) const = 0; + virtual void emitAssembly(const Module *M, std::ostream &OutStr) const = 0; }; #endif diff --git a/include/llvm/Target/TargetRegInfo.h b/include/llvm/Target/TargetRegInfo.h index ae083c9b13..b2fa048492 100644 --- a/include/llvm/Target/TargetRegInfo.h +++ b/include/llvm/Target/TargetRegInfo.h @@ -9,7 +9,7 @@ #define LLVM_TARGET_MACHINEREGINFO_H #include "Support/NonCopyable.h" -#include +#include #include class TargetMachine; @@ -76,11 +76,11 @@ public: -typedef hash_map AddedInstrMapType; +typedef std::hash_map AddedInstrMapType; // A vector of all machine register classes // -typedef vector MachineRegClassArrayType; +typedef std::vector MachineRegClassArrayType; class MachineRegInfo : public NonCopyableV { @@ -128,7 +128,7 @@ public: LiveRangeInfo & LRI) const = 0; virtual void suggestRegs4CallArgs(const MachineInstr *const CallI, - LiveRangeInfo& LRI, vector RCL) const = 0; + LiveRangeInfo& LRI, std::vector RCL) const = 0; virtual void suggestReg4RetValue(const MachineInstr *const RetI, LiveRangeInfo& LRI) const = 0; @@ -186,7 +186,7 @@ public: // virtual int getUnifiedRegNum(int RegClassID, int reg) const = 0; - virtual const string getUnifiedRegName(int UnifiedRegNum) const = 0; + virtual const std::string getUnifiedRegName(int UnifiedRegNum) const = 0; // Gives the type of a register based on the type of the LR diff --git a/include/llvm/Target/TargetSchedInfo.h b/include/llvm/Target/TargetSchedInfo.h index 356c7851b0..e8908c532a 100644 --- a/include/llvm/Target/TargetSchedInfo.h +++ b/include/llvm/Target/TargetSchedInfo.h @@ -8,10 +8,10 @@ #define LLVM_TARGET_MACHINESCHEDINFO_H #include "llvm/Target/MachineInstrInfo.h" -#include +#include typedef long long cycles_t; -const cycles_t HUGE_LATENCY = ~((unsigned long long) 1 << sizeof(cycles_t)-1); +const cycles_t HUGE_LATENCY = ~((unsigned long long) 1 << sizeof(cycles_t)-2); const cycles_t INVALID_LATENCY = -HUGE_LATENCY; static const unsigned MAX_OPCODE_SIZE = 16; @@ -28,13 +28,13 @@ private: OpCodePair(); // disable for now }; - +namespace std { template <> struct hash { size_t operator()(const OpCodePair& pair) const { return hash()(pair.val); } }; - +} //--------------------------------------------------------------------------- // class MachineResource @@ -50,10 +50,10 @@ typedef unsigned int resourceId_t; class MachineResource { public: - const string rname; + const std::string rname; resourceId_t rid; - /*ctor*/ MachineResource(const string& resourceName) + /*ctor*/ MachineResource(const std::string& resourceName) : rname(resourceName), rid(nextId++) {} private: @@ -66,7 +66,7 @@ class CPUResource : public MachineResource { public: int maxNumUsers; // MAXINT if no restriction - /*ctor*/ CPUResource(const string& rname, int maxUsers) + /*ctor*/ CPUResource(const std::string& rname, int maxUsers) : MachineResource(rname), maxNumUsers(maxUsers) {} }; @@ -147,11 +147,11 @@ struct InstrRUsage { cycles_t numBubbles; // Feasible slots to use for this instruction. - vector feasibleSlots; + std::vector feasibleSlots; // Resource usages for this instruction, with one resource vector per cycle. cycles_t numCycles; - vector > resourcesByCycle; + std::vector > resourcesByCycle; private: // Conveniences for initializing this structure @@ -243,7 +243,7 @@ InstrRUsage::addUsageDelta(const InstrRUsageDelta& delta) // resize the resources vector if more cycles are specified unsigned maxCycles = this->numCycles; - maxCycles = max(maxCycles, delta.startCycle + abs(NC) - 1); + maxCycles = std::max(maxCycles, delta.startCycle + abs(NC) - 1); if (maxCycles > this->numCycles) { this->resourcesByCycle.resize(maxCycles); @@ -259,7 +259,7 @@ InstrRUsage::addUsageDelta(const InstrRUsageDelta& delta) { // Look for the resource backwards so we remove the last entry // for that resource in each cycle. - vector& rvec = this->resourcesByCycle[c]; + std::vector& rvec = this->resourcesByCycle[c]; int r; for (r = (int) rvec.size(); r >= 0; r--) if (rvec[r] == delta.resourceId) @@ -349,14 +349,14 @@ public: inline int getMinIssueGap (MachineOpCode fromOp, MachineOpCode toOp) const { - hash_map::const_iterator + std::hash_map::const_iterator I = issueGaps.find(OpCodePair(fromOp, toOp)); return (I == issueGaps.end())? 0 : (*I).second; } - inline const vector* + inline const std::vector* getConflictList(MachineOpCode opCode) const { - hash_map >::const_iterator + std::hash_map >::const_iterator I = conflictLists.find(opCode); return (I == conflictLists.end())? NULL : & (*I).second; } @@ -377,22 +377,22 @@ protected: virtual void initializeResources (); private: - void computeInstrResources(const vector& instrRUForClasses); - void computeIssueGaps(const vector& instrRUForClasses); + void computeInstrResources(const std::vector& instrRUForClasses); + void computeIssueGaps(const std::vector& instrRUForClasses); protected: int numSchedClasses; const MachineInstrInfo* mii; - const InstrClassRUsage* classRUsages; // raw array by sclass - const InstrRUsageDelta* usageDeltas; // raw array [1:numUsageDeltas] - const InstrIssueDelta* issueDeltas; // raw array [1:numIssueDeltas] + const InstrClassRUsage* classRUsages; // raw array by sclass + const InstrRUsageDelta* usageDeltas; // raw array [1:numUsageDeltas] + const InstrIssueDelta* issueDeltas; // raw array [1:numIssueDeltas] unsigned int numUsageDeltas; unsigned int numIssueDeltas; - vector instrRUsages; // indexed by opcode - hash_map issueGaps; // indexed by opcode pair - hash_map > - conflictLists; // indexed by opcode + std::vector instrRUsages; // indexed by opcode + std::hash_map issueGaps; // indexed by opcode pair + std::hash_map > + conflictLists; // indexed by opcode }; #endif diff --git a/include/llvm/Transforms/IPO/ConstantMerge.h b/include/llvm/Transforms/IPO/ConstantMerge.h index 6eed771288..37d830ccf8 100644 --- a/include/llvm/Transforms/IPO/ConstantMerge.h +++ b/include/llvm/Transforms/IPO/ConstantMerge.h @@ -24,7 +24,7 @@ class GlobalVariable; class ConstantMerge : public Pass { protected: - map Constants; + std::map Constants; unsigned LastConstantSeen; public: inline ConstantMerge() : LastConstantSeen(0) {} diff --git a/include/llvm/Transforms/MutateStructTypes.h b/include/llvm/Transforms/MutateStructTypes.h index b2d4b30c27..23bf71c3b1 100644 --- a/include/llvm/Transforms/MutateStructTypes.h +++ b/include/llvm/Transforms/MutateStructTypes.h @@ -28,19 +28,19 @@ class MutateStructTypes : public Pass { // incoming slot [or negative if the specified incoming slot should be // removed]. // - typedef pair > TransformType; + typedef std::pair > TransformType; // Transforms to do for each structure type... - map Transforms; + std::map Transforms; // Mapping of old type to new types... - map > TypeMap; + std::map > TypeMap; // Mapping from global value of old type, to a global value of the new type... - map GlobalMap; + std::map GlobalMap; // Mapping from intra method value to intra method value - map LocalValueMap; + std::map LocalValueMap; public: // Ctor - Take a map that specifies what transformation to do for each field @@ -49,7 +49,7 @@ public: // the destination structure the field should end up in. A negative value // indicates that the field should be deleted entirely. // - typedef map > TransformsType; + typedef std::map > TransformsType; MutateStructTypes(const TransformsType &Transforms); @@ -83,7 +83,7 @@ private: // AdjustIndices - Convert the indexes specifed by Idx to the new changed form // using the specified OldTy as the base type being indexed into. // - void AdjustIndices(const CompositeType *OldTy, vector &Idx, + void AdjustIndices(const CompositeType *OldTy, std::vector &Idx, unsigned idx = 0); }; diff --git a/include/llvm/Transforms/Utils/Linker.h b/include/llvm/Transforms/Utils/Linker.h index 3650ccbadf..e74c5d40fa 100644 --- a/include/llvm/Transforms/Utils/Linker.h +++ b/include/llvm/Transforms/Utils/Linker.h @@ -16,7 +16,7 @@ class Module; // error occurs, true is returned and ErrorMsg (if not null) is set to indicate // the problem. // -bool LinkModules(Module *Dest, const Module *Src, string *ErrorMsg = 0); +bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0); #endif diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 3617aaed9e..1bbe02337b 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -71,23 +71,23 @@ public: private: PrimitiveID ID; // The current base type of this type... unsigned UID; // The unique ID number for this class - string Desc; // The printed name of the string... + std::string Desc; // The printed name of the string... bool Abstract; // True if type contains an OpaqueType bool Recursive; // True if the type is recursive protected: // ctor is protected, so only subclasses can create Type objects... - Type(const string &Name, PrimitiveID id); + Type(const std::string &Name, PrimitiveID id); virtual ~Type() {} // When types are refined, they update their description to be more concrete. // - inline void setDescription(const string &D) { Desc = D; } + inline void setDescription(const std::string &D) { Desc = D; } // setName - Associate the name with this type in the symbol table, but don't // set the local name to be equal specified name. // - virtual void setName(const string &Name, SymbolTable *ST = 0); + virtual void setName(const std::string &Name, SymbolTable *ST = 0); // Types can become nonabstract later, if they are refined. // @@ -116,7 +116,7 @@ public: inline unsigned getUniqueID() const { return UID; } // getDescription - Return the string representation of the type... - inline const string &getDescription() const { return Desc; } + inline const std::string &getDescription() const { return Desc; } // isSigned - Return whether a numeric type is signed. virtual bool isSigned() const { return 0; } diff --git a/include/llvm/User.h b/include/llvm/User.h index 2ea3a43fd0..007db5f74c 100644 --- a/include/llvm/User.h +++ b/include/llvm/User.h @@ -17,9 +17,9 @@ class User : public Value { User(const User &); // Do not implement protected: - vector Operands; + std::vector Operands; public: - User(const Type *Ty, ValueTy vty, const string &name = ""); + User(const Type *Ty, ValueTy vty, const std::string &name = ""); virtual ~User() { dropAllReferences(); } inline Value *getOperand(unsigned i) { @@ -39,8 +39,8 @@ public: // --------------------------------------------------------------------------- // Operand Iterator interface... // - typedef vector::iterator op_iterator; - typedef vector::const_iterator const_op_iterator; + typedef std::vector::iterator op_iterator; + typedef std::vector::const_iterator const_op_iterator; inline op_iterator op_begin() { return Operands.begin(); } inline const_op_iterator op_begin() const { return Operands.begin(); } diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 8a0014c85a..19839706f2 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -49,8 +49,8 @@ public: }; private: - vector Uses; - string Name; + std::vector Uses; + std::string Name; PATypeHandle Ty; ValueTy VTy; @@ -58,7 +58,7 @@ private: protected: inline void setType(const Type *ty) { Ty = ty; } public: - Value(const Type *Ty, ValueTy vty, const string &name = ""); + Value(const Type *Ty, ValueTy vty, const std::string &name = ""); virtual ~Value(); // Support for debugging @@ -68,10 +68,10 @@ public: inline const Type *getType() const { return Ty; } // All values can potentially be named... - inline bool hasName() const { return Name != ""; } - inline const string &getName() const { return Name; } + inline bool hasName() const { return Name != ""; } + inline const std::string &getName() const { return Name; } - virtual void setName(const string &name, SymbolTable * = 0) { + virtual void setName(const std::string &name, SymbolTable * = 0) { Name = name; } @@ -101,8 +101,8 @@ public: //---------------------------------------------------------------------- // Methods for handling the vector of uses of this Value. // - typedef vector::iterator use_iterator; - typedef vector::const_iterator use_const_iterator; + typedef std::vector::iterator use_iterator; + typedef std::vector::const_iterator use_const_iterator; inline unsigned use_size() const { return Uses.size(); } inline bool use_empty() const { return Uses.empty(); } diff --git a/include/llvm/ValueHolder.h b/include/llvm/ValueHolder.h index ef4ed1949f..b75d243a3d 100644 --- a/include/llvm/ValueHolder.h +++ b/include/llvm/ValueHolder.h @@ -25,7 +25,7 @@ // template class ValueHolder { - vector ValueList; + std::vector ValueList; ItemParentType *ItemParent; SymTabType *Parent; @@ -66,10 +66,10 @@ public: // sub-Definition iterator code //===--------------------------------------------------------------------===// // - typedef vector::iterator iterator; - typedef vector::const_iterator const_iterator; - typedef reverse_iterator const_reverse_iterator; - typedef reverse_iterator reverse_iterator; + typedef std::vector::iterator iterator; + typedef std::vector::const_iterator const_iterator; + typedef std::reverse_iterator const_reverse_iterator; + typedef std::reverse_iterator reverse_iterator; inline iterator begin() { return ValueList.begin(); } inline const_iterator begin() const { return ValueList.begin(); } diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h index bf384a6169..13b1400d3a 100644 --- a/include/llvm/iMemory.h +++ b/include/llvm/iMemory.h @@ -21,7 +21,7 @@ class AllocationInst : public Instruction { public: AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, - const string &Name = "") + const std::string &Name = "") : Instruction(Ty, iTy, Name) { assert(Ty->isPointerType() && "Can't allocate a non pointer type!"); @@ -67,7 +67,7 @@ public: class MallocInst : public AllocationInst { public: - MallocInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "") + MallocInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "") : AllocationInst(Ty, ArraySize, Malloc, Name) {} virtual Instruction *clone() const { @@ -94,7 +94,7 @@ public: class AllocaInst : public AllocationInst { public: - AllocaInst(const Type *Ty, Value *ArraySize = 0, const string &Name = "") + AllocaInst(const Type *Ty, Value *ArraySize = 0, const std::string &Name = "") : AllocationInst(Ty, ArraySize, Alloca, Name) {} virtual Instruction *clone() const { @@ -154,7 +154,7 @@ public: class MemAccessInst : public Instruction { protected: inline MemAccessInst(const Type *Ty, unsigned Opcode, - const string &Nam = "") + const std::string &Nam = "") : Instruction(Ty, Opcode, Nam) {} public: // getIndexedType - Returns the type of the element that would be loaded with @@ -164,7 +164,7 @@ public: // pointer type. // static const Type *getIndexedType(const Type *Ptr, - const vector &Indices, + const std::vector &Indices, bool AllowStructLeaf = false); inline op_iterator idx_begin() { @@ -177,8 +177,8 @@ public: inline const_op_iterator idx_end() const { return op_end(); } - vector copyIndices() const { - return vector(idx_begin(), idx_end()); + std::vector copyIndices() const { + return std::vector(idx_begin(), idx_end()); } Value *getPointerOperand() { @@ -217,8 +217,8 @@ class LoadInst : public MemAccessInst { Operands.push_back(Use(LI.Operands[i], this)); } public: - LoadInst(Value *Ptr, const vector &Idx, const string &Name = ""); - LoadInst(Value *Ptr, const string &Name = ""); + LoadInst(Value *Ptr, const std::vector &Ix, const std::string & = ""); + LoadInst(Value *Ptr, const std::string &Name = ""); virtual Instruction *clone() const { return new LoadInst(*this); } virtual const char *getOpcodeName() const { return "load"; } @@ -247,9 +247,9 @@ class StoreInst : public MemAccessInst { Operands.push_back(Use(SI.Operands[i], this)); } public: - StoreInst(Value *Val, Value *Ptr, const vector &Idx, - const string &Name = ""); - StoreInst(Value *Val, Value *Ptr, const string &Name = ""); + StoreInst(Value *Val, Value *Ptr, const std::vector &Idx, + const std::string &Name = ""); + StoreInst(Value *Val, Value *Ptr, const std::string &Name = ""); virtual Instruction *clone() const { return new StoreInst(*this); } virtual const char *getOpcodeName() const { return "store"; } @@ -280,8 +280,8 @@ class GetElementPtrInst : public MemAccessInst { Operands.push_back(Use(EPI.Operands[i], this)); } public: - GetElementPtrInst(Value *Ptr, const vector &Idx, - const string &Name = ""); + GetElementPtrInst(Value *Ptr, const std::vector &Idx, + const std::string &Name = ""); virtual Instruction *clone() const { return new GetElementPtrInst(*this); } virtual const char *getOpcodeName() const { return "getelementptr"; } virtual unsigned getFirstIndexOperandNumber() const { return 1; } diff --git a/include/llvm/iOperators.h b/include/llvm/iOperators.h index 7cbaecf64a..f9cba9f68c 100644 --- a/include/llvm/iOperators.h +++ b/include/llvm/iOperators.h @@ -15,7 +15,7 @@ // class GenericUnaryInst : public UnaryOperator { public: - GenericUnaryInst(UnaryOps Opcode, Value *S1, const string &Name = "") + GenericUnaryInst(UnaryOps Opcode, Value *S1, const std::string &Name = "") : UnaryOperator(S1, Opcode, Name) { } @@ -32,7 +32,7 @@ public: class GenericBinaryInst : public BinaryOperator { public: GenericBinaryInst(BinaryOps Opcode, Value *S1, Value *S2, - const string &Name = "") + const std::string &Name = "") : BinaryOperator(Opcode, S1, S2, Name) { } @@ -43,7 +43,7 @@ class SetCondInst : public BinaryOperator { BinaryOps OpType; public: SetCondInst(BinaryOps opType, Value *S1, Value *S2, - const string &Name = ""); + const std::string &Name = ""); virtual const char *getOpcodeName() const; }; diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h index de1532d590..85698da761 100644 --- a/include/llvm/iOther.h +++ b/include/llvm/iOther.h @@ -24,7 +24,7 @@ class CastInst : public Instruction { Operands.push_back(Use(CI.Operands[0], this)); } public: - CastInst(Value *S, const Type *Ty, const string &Name = "") + CastInst(Value *S, const Type *Ty, const std::string &Name = "") : Instruction(Ty, Cast, Name) { Operands.reserve(1); Operands.push_back(Use(S, this)); @@ -55,13 +55,13 @@ class MethodArgument : public Value { // Defined in the InstrType.cpp file inline void setParent(Method *parent) { Parent = parent; } public: - MethodArgument(const Type *Ty, const string &Name = "") + MethodArgument(const Type *Ty, const std::string &Name = "") : Value(Ty, Value::MethodArgumentVal, Name) { Parent = 0; } // Specialize setName to handle symbol table majik... - virtual void setName(const string &name, SymbolTable *ST = 0); + virtual void setName(const std::string &name, SymbolTable *ST = 0); inline const Method *getParent() const { return Parent; } inline Method *getParent() { return Parent; } @@ -81,7 +81,7 @@ public: class CallInst : public Instruction { CallInst(const CallInst &CI); public: - CallInst(Value *Meth, const vector ¶ms, const string &Name = ""); + CallInst(Value *M, const std::vector &Par, const std::string & = ""); virtual const char *getOpcodeName() const { return "call"; } @@ -123,7 +123,7 @@ class ShiftInst : public Instruction { Operands.push_back(Use(SI.Operands[1], this)); } public: - ShiftInst(OtherOps Opcode, Value *S, Value *SA, const string &Name = "") + ShiftInst(OtherOps Opcode, Value *S, Value *SA, const std::string &Name = "") : Instruction(S->getType(), Opcode, Name) { assert((Opcode == Shl || Opcode == Shr) && "ShiftInst Opcode invalid!"); Operands.reserve(2); diff --git a/include/llvm/iPHINode.h b/include/llvm/iPHINode.h index 66afac62c0..0ac0d44c66 100644 --- a/include/llvm/iPHINode.h +++ b/include/llvm/iPHINode.h @@ -21,7 +21,7 @@ class BasicBlock; class PHINode : public Instruction { PHINode(const PHINode &PN); public: - PHINode(const Type *Ty, const string &Name = ""); + PHINode(const Type *Ty, const std::string &Name = ""); virtual Instruction *clone() const { return new PHINode(*this); } virtual const char *getOpcodeName() const { return "phi"; } diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h index ebd8b873dd..6ed75fa687 100644 --- a/include/llvm/iTerminators.h +++ b/include/llvm/iTerminators.h @@ -198,7 +198,7 @@ class InvokeInst : public TerminatorInst { InvokeInst(const InvokeInst &BI); public: InvokeInst(Value *Meth, BasicBlock *IfNormal, BasicBlock *IfException, - const vector &Params, const string &Name = ""); + const std::vector &Params, const std::string &Name = ""); virtual Instruction *clone() const { return new InvokeInst(*this); } diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index a35e37a963..e94c796059 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -11,6 +11,7 @@ #include "llvm/Optimizations/ConstantHandling.h" #include "llvm/Method.h" #include "llvm/BasicBlock.h" +#include using namespace opt; // Get all the constant handling stuff using namespace analysis; @@ -178,7 +179,7 @@ inline const ConstantInt *operator*(const DefZero &L, const DefOne &R) { static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) { const Type *Ty = V->getType(); if (Left.ExprTy > Right.ExprTy) - swap(Left, Right); // Make left be simpler than right + std::swap(Left, Right); // Make left be simpler than right switch (Left.ExprTy) { case ExprType::Constant: @@ -229,7 +230,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { case Value::TypeVal: case Value::BasicBlockVal: case Value::MethodVal: case Value::ModuleVal: default: //assert(0 && "Unexpected expression type to classify!"); - cerr << "Bizarre thing to expr classify: " << Expr << endl; + std::cerr << "Bizarre thing to expr classify: " << Expr << "\n"; return Expr; case Value::GlobalVariableVal: // Global Variable & Method argument: case Value::MethodArgumentVal: // nothing known, return variable itself @@ -280,7 +281,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) { ExprType Left (ClassifyExpression(I->getOperand(0))); ExprType Right(ClassifyExpression(I->getOperand(1))); if (Left.ExprTy > Right.ExprTy) - swap(Left, Right); // Make left be simpler than right + std::swap(Left, Right); // Make left be simpler than right if (Left.ExprTy != ExprType::Constant) // RHS must be > constant return I; // Quadratic eqn! :( diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index d77064cf35..e48cf7fa38 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -29,7 +29,7 @@ cfg::CallGraphNode *cfg::CallGraph::getNodeFor(Method *M) { assert(M->getParent() == Mod && "Method not in current module!"); CallGraphNode *New = new CallGraphNode(M); - MethodMap.insert(pair(M, New)); + MethodMap.insert(std::make_pair(M, New)); return New; } @@ -71,7 +71,7 @@ cfg::CallGraph::~CallGraph() { } -void cfg::WriteToOutput(const CallGraphNode *CGN, ostream &o) { +void cfg::WriteToOutput(const CallGraphNode *CGN, std::ostream &o) { if (CGN->getMethod()) o << "Call graph node for method: '" << CGN->getMethod()->getName() <<"'\n"; else @@ -79,10 +79,10 @@ void cfg::WriteToOutput(const CallGraphNode *CGN, ostream &o) { for (unsigned i = 0; i < CGN->size(); ++i) o << " Calls method '" << (*CGN)[i]->getMethod()->getName() << "'\n"; - o << endl; + o << "\n"; } -void cfg::WriteToOutput(const CallGraph &CG, ostream &o) { +void cfg::WriteToOutput(const CallGraph &CG, std::ostream &o) { WriteToOutput(CG.getRoot(), o); for (CallGraph::const_iterator I = CG.begin(), E = CG.end(); I != E; ++I) o << I->second; diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 50fb8ea7b6..1058e6ed39 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -60,7 +60,7 @@ bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) { UnsafeTypes.insert((PointerType*)ITy); if (PrintFailures) { - CachedWriter CW(M->getParent(), cerr); + CachedWriter CW(M->getParent(), std::cerr); CW << "FindUnsafePointerTypes: Type '" << ITy << "' marked unsafe in '" << Meth->getName() << "' by:\n" << Inst; } @@ -74,7 +74,7 @@ bool FindUnsafePointerTypes::doPerMethodWork(Method *Meth) { // printResults - Loop over the results of the analysis, printing out unsafe // types. // -void FindUnsafePointerTypes::printResults(const Module *M, ostream &o) { +void FindUnsafePointerTypes::printResults(const Module *M, std::ostream &o) { if (UnsafeTypes.empty()) { o << "SafePointerAccess Analysis: No unsafe types found!\n"; return; @@ -84,9 +84,9 @@ void FindUnsafePointerTypes::printResults(const Module *M, ostream &o) { CW << "SafePointerAccess Analysis: Found these unsafe types:\n"; unsigned Counter = 1; - for (set::const_iterator I = getUnsafeTypes().begin(), + for (std::set::const_iterator I = getUnsafeTypes().begin(), E = getUnsafeTypes().end(); I != E; ++I, ++Counter) { - CW << " #" << Counter << ". " << (Value*)*I << endl; + CW << " #" << Counter << ". " << (Value*)*I << "\n"; } } diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 6f8049abad..1d98983115 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -78,15 +78,15 @@ bool FindUsedTypes::doPerMethodWork(Method *m) { // passed in, then the types are printed symbolically if possible, using the // symbol table from the module. // -void FindUsedTypes::printTypes(ostream &o, const Module *M = 0) const { +void FindUsedTypes::printTypes(std::ostream &o, const Module *M = 0) const { o << "Types in use by this module:\n"; if (M) { CachedWriter CW(M, o); - for (set::const_iterator I = UsedTypes.begin(), + for (std::set::const_iterator I = UsedTypes.begin(), E = UsedTypes.end(); I != E; ++I) - CW << " " << *I << endl; + CW << " " << *I << "\n"; } else - for (set::const_iterator I = UsedTypes.begin(), + for (std::set::const_iterator I = UsedTypes.begin(), E = UsedTypes.end(); I != E; ++I) - o << " " << *I << endl; + o << " " << *I << "\n"; } diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp index d88c9cfc68..045c932332 100644 --- a/lib/Analysis/InductionVariable.cpp +++ b/lib/Analysis/InductionVariable.cpp @@ -88,7 +88,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) { ExprType E2 = analysis::ClassifyExpression(V2); if (E1.ExprTy > E2.ExprTy) // Make E1 be the simpler expression - swap(E1, E2); + std::swap(E1, E2); // E1 must be a constant incoming value, and E2 must be a linear expression // with respect to the PHI node. @@ -109,7 +109,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) { // Make sure that V1 is the incoming value, and V2 is from the backedge of // the loop. if (L->contains(Phi->getIncomingBlock(0))) // Wrong order. Swap now. - swap(V1, V2); + std::swap(V1, V2); Start = V1; // We know that Start has to be loop invariant... Step = 0; diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index 8616cb721c..fff8d224e2 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -9,6 +9,7 @@ #include "Support/STLExtras.h" using namespace cfg; +using std::make_pair; //===----------------------------------------------------------------------===// // IntervalPartition Implementation diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp index d7e036b256..0ecf96cf13 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.cpp +++ b/lib/Analysis/LiveVar/BBLiveVar.cpp @@ -1,8 +1,13 @@ #include "llvm/Analysis/LiveVar/BBLiveVar.h" #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" + +/// BROKEN: Should not include sparc stuff directly into here #include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn +using std::cerr; +using std::endl; +using std::pair; //----------------------------------------------------------------------------- // Constructor @@ -39,7 +44,7 @@ void BBLiveVar::calcDefUseSets() if( DEBUG_LV > 1) { // debug msg cerr << " *Iterating over machine instr "; MInst->dump(); - cerr << endl; + cerr << "\n"; } // iterate over MI operands to find defs @@ -85,9 +90,9 @@ void BBLiveVar::calcDefUseSets() if( DEBUG_LV > 1) { // debug msg of level 2 cerr << " - phi operand "; printValue( ArgVal ); - cerr << " came from BB "; + cerr << " came from BB "; printValue( PhiArgMap[ ArgVal ]); - cerr< 1) { - cerr << " +Def: "; printValue( Op ); cerr << endl; + cerr << " +Def: "; printValue( Op ); cerr << "\n"; } } diff --git a/lib/Analysis/LiveVar/BBLiveVar.h b/lib/Analysis/LiveVar/BBLiveVar.h index 6d7d4eb533..9ce56a88f6 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.h +++ b/lib/Analysis/LiveVar/BBLiveVar.h @@ -28,7 +28,7 @@ class BBLiveVar // map that contains phi args->BB they came // set by calcDefUseSets & used by setPropagate - hash_map PhiArgMap; + std::hash_map PhiArgMap; // method to propogate an InSet to OutSet of a predecessor bool setPropagate( LiveVarSet *const OutSetOfPred, diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp index 636359d1d0..5de35ff1be 100644 --- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp @@ -12,15 +12,15 @@ #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" #include "Support/PostOrderIterator.h" - +#include +using std::cout; +using std::endl; //************************** Constructor/Destructor *************************** -MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M), - BB2BBLVMap() -{ - assert(! M->isExternal() ); // cannot be a prototype decleration +MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M) { + assert(!M->isExternal() && "Cannot be a prototype declaration"); HasAnalyzed = false; // still we haven't called analyze() } @@ -55,8 +55,6 @@ MethodLiveVarInfo:: ~MethodLiveVarInfo() if( (*MI).first ) // delete all LiveVarSets in MInst2LVSetBI delete (*MI).second; } - - } diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp index 6806d1c563..d176d9e53c 100644 --- a/lib/Analysis/LiveVar/ValueSet.cpp +++ b/lib/Analysis/LiveVar/ValueSet.cpp @@ -1,11 +1,14 @@ #include "llvm/Analysis/LiveVar/ValueSet.h" #include "llvm/ConstantVals.h" - +#include +using std::cerr; +using std::endl; +using std::pair; +using std::hash_set; void printValue( const Value *const v) // func to print a Value { - if (v->hasName()) cerr << v << "(" << ((*v).getName()) << ") "; else if (Constant *C = dyn_cast(v)) @@ -16,17 +19,13 @@ void printValue( const Value *const v) // func to print a Value //---------------- Method implementations -------------------------- - - -ValueSet:: ValueSet() : hash_set () { } - // for performing two set unions bool ValueSet::setUnion( const ValueSet *const set1) { const_iterator set1it; pair result; bool changed = false; - for( set1it = set1->begin() ; set1it != set1->end(); set1it++) { + for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) { // for all all elements in set1 result = insert( *set1it ); // insert to this set if( result.second == true) changed = true; @@ -41,7 +40,7 @@ void ValueSet::setDifference( const ValueSet *const set1, const ValueSet *const set2) { const_iterator set1it, set2it; - for( set1it = set1->begin() ; set1it != set1->end(); set1it++) { + for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) { // for all elements in set1 iterator set2it = set2->find( *set1it ); // find wether the elem is in set2 if( set2it == set2->end() ) // if the element is not in set2 @@ -53,7 +52,7 @@ void ValueSet::setDifference( const ValueSet *const set1, // for performing set subtraction void ValueSet::setSubtract( const ValueSet *const set1) { const_iterator set1it; - for( set1it = set1->begin() ; set1it != set1->end(); set1it++) + for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) // for all elements in set1 erase( *set1it ); // erase that element from this set } @@ -62,7 +61,5 @@ void ValueSet::setSubtract( const ValueSet *const set1) { void ValueSet::printSet() const { // for printing a live variable set - const_iterator it; - for( it = begin() ; it != end(); it++) - printValue( *it ); + for_each(begin(), end(), printValue); } diff --git a/lib/Analysis/LoopDepth.cpp b/lib/Analysis/LoopDepth.cpp index ed96bd4f57..994b7cd3c9 100644 --- a/lib/Analysis/LoopDepth.cpp +++ b/lib/Analysis/LoopDepth.cpp @@ -22,8 +22,6 @@ inline void LoopDepthCalculator::ProcessInterval(cfg::Interval *I) { } LoopDepthCalculator::LoopDepthCalculator(Method *M) { - //map LoopDepth; - cfg::IntervalPartition *IP = new cfg::IntervalPartition(M); while (!IP->isDegeneratePartition()) { for_each(IP->begin(), IP->end(), @@ -34,7 +32,7 @@ LoopDepthCalculator::LoopDepthCalculator(Method *M) { // cfg::IntervalPartition *NewIP = new cfg::IntervalPartition(*IP, true); if (NewIP->size() == IP->size()) { - cerr << "IRREDUCIBLE GRAPH FOUND!!!\n"; + assert(0 && "IRREDUCIBLE GRAPH FOUND!!!\n"); // TODO: fix irreducible graph return; } diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 40a195b042..ed91ca8bd5 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -33,7 +33,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB, const DominatorSet &DS) { if (BBMap.find(BB) != BBMap.end()) return 0; // Havn't processed this node? - vector TodoStack; + std::vector TodoStack; // Scan the predecessors of BB, checking to see if BB dominates any of // them. @@ -64,7 +64,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB, // loop can be found for them. Also check subsidary basic blocks to see if // they start subloops of their own. // - for (vector::reverse_iterator I = L->Blocks.rbegin(), + for (std::vector::reverse_iterator I = L->Blocks.rbegin(), E = L->Blocks.rend(); I != E; ++I) { // Check to see if this block starts a new loop @@ -74,7 +74,7 @@ cfg::Loop *cfg::LoopInfo::ConsiderForLoop(const BasicBlock *BB, } if (BBMap.find(*I) == BBMap.end()) - BBMap.insert(make_pair(*I, L)); + BBMap.insert(std::make_pair(*I, L)); } return L; diff --git a/lib/Analysis/ModuleAnalyzer.cpp b/lib/Analysis/ModuleAnalyzer.cpp index 129fb3b862..dc07512cb5 100644 --- a/lib/Analysis/ModuleAnalyzer.cpp +++ b/lib/Analysis/ModuleAnalyzer.cpp @@ -13,6 +13,8 @@ #include "llvm/DerivedTypes.h" #include "Support/STLExtras.h" #include +#include +using std::set; // processModule - Driver function to call all of my subclasses virtual methods. // @@ -59,8 +61,8 @@ inline bool ModuleAnalyzer::handleType(set &TypeSet, break; default: - cerr << "ModuleAnalyzer::handleType, type unknown: '" - << T->getName() << "'\n"; + std::cerr << "ModuleAnalyzer::handleType, type unknown: '" + << T->getName() << "'\n"; break; } diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 2ed02dbed2..2e4f6e4df1 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -10,6 +10,8 @@ #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" #include +using std::set; + //===----------------------------------------------------------------------===// // Helper Template diff --git a/lib/Analysis/Writer.cpp b/lib/Analysis/Writer.cpp index 3d9134f0dc..1e873bfa52 100644 --- a/lib/Analysis/Writer.cpp +++ b/lib/Analysis/Writer.cpp @@ -12,6 +12,10 @@ #include "llvm/Analysis/InductionVariable.h" #include #include +using std::ostream; +using std::set; +using std::vector; +using std::string; //===----------------------------------------------------------------------===// // Interval Printing Routines @@ -23,19 +27,19 @@ void cfg::WriteToOutput(const Interval *I, ostream &o) { // Print out all of the basic blocks in the interval... copy(I->Nodes.begin(), I->Nodes.end(), - ostream_iterator(o, "\n")); + std::ostream_iterator(o, "\n")); o << "Interval Predecessors:\n"; copy(I->Predecessors.begin(), I->Predecessors.end(), - ostream_iterator(o, "\n")); + std::ostream_iterator(o, "\n")); o << "Interval Successors:\n"; copy(I->Successors.begin(), I->Successors.end(), - ostream_iterator(o, "\n")); + std::ostream_iterator(o, "\n")); } void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) { - copy(IP.begin(), IP.end(), ostream_iterator(o, "\n")); + copy(IP.begin(), IP.end(), std::ostream_iterator(o, "\n")); } @@ -45,7 +49,7 @@ void cfg::WriteToOutput(const IntervalPartition &IP, ostream &o) { //===----------------------------------------------------------------------===// ostream &operator<<(ostream &o, const set &BBs) { - copy(BBs.begin(), BBs.end(), ostream_iterator(o, "\n")); + copy(BBs.begin(),BBs.end(), std::ostream_iterator(o,"\n")); return o; } @@ -53,7 +57,7 @@ void cfg::WriteToOutput(const DominatorSet &DS, ostream &o) { for (DominatorSet::const_iterator I = DS.begin(), E = DS.end(); I != E; ++I) { o << "=============================--------------------------------\n" << "\nDominator Set For Basic Block\n" << I->first - << "-------------------------------\n" << I->second << endl; + << "-------------------------------\n" << I->second << "\n"; } } @@ -63,7 +67,7 @@ void cfg::WriteToOutput(const ImmediateDominators &ID, ostream &o) { I != E; ++I) { o << "=============================--------------------------------\n" << "\nImmediate Dominator For Basic Block\n" << I->first - << "is: \n" << I->second << endl; + << "is: \n" << I->second << "\n"; } } @@ -93,7 +97,7 @@ void cfg::WriteToOutput(const DominanceFrontier &DF, ostream &o) { I != E; ++I) { o << "=============================--------------------------------\n" << "\nDominance Frontier For Basic Block\n" << I->first - << "is: \n" << I->second << endl; + << "is: \n" << I->second << "\n"; } } @@ -109,15 +113,15 @@ void cfg::WriteToOutput(const Loop *L, ostream &o) { if (i) o << ","; WriteAsOperand(o, (const Value*)L->getBlocks()[i]); } - o << endl; + o << "\n"; copy(L->getSubLoops().begin(), L->getSubLoops().end(), - ostream_iterator(o, "\n")); + std::ostream_iterator(o, "\n")); } void cfg::WriteToOutput(const LoopInfo &LI, ostream &o) { copy(LI.getTopLevelLoops().begin(), LI.getTopLevelLoops().end(), - ostream_iterator(o, "\n")); + std::ostream_iterator(o, "\n")); } @@ -138,11 +142,11 @@ void WriteToOutput(const InductionVariable &IV, ostream &o) { WriteAsOperand(o, (const Value*)IV.Phi); o << ":\n" << (const Value*)IV.Phi; } else { - o << endl; + o << "\n"; } if (IV.InductionType == InductionVariable::Unknown) return; o << " Start ="; WriteAsOperand(o, IV.Start); o << " Step =" ; WriteAsOperand(o, IV.Step); - o << endl; + o << "\n"; } diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index b487042bcb..4b280efd7d 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -8,6 +8,7 @@ #include "llvm/Module.h" #include "ParserInternals.h" #include // for sprintf +using std::string; // The useful interface defined by this file... Parse an ascii file, and return // the internal representation in a nice slice'n'dice'able representation. @@ -30,7 +31,7 @@ Module *ParseAssemblyFile(const string &Filename) { // throw (ParseException) fclose(F); if (Result) { // Check to see that it is valid... - vector Errors; + std::vector Errors; if (verify(Result, Errors)) { delete Result; Result = 0; string Message; diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 750833fae8..e1e2c4954c 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -23,12 +23,12 @@ class Module; // Global variables exported from the lexer... -extern FILE *llvmAsmin; +extern std::FILE *llvmAsmin; extern int llvmAsmlineno; // Globals exported by the parser... -extern string CurFilename; -Module *RunVMAsmParser(const string &Filename, FILE *F); +extern std::string CurFilename; +Module *RunVMAsmParser(const std::string &Filename, FILE *F); // UnEscapeLexed - Run through the specified buffer and change \xx codes to the @@ -47,7 +47,7 @@ char *UnEscapeLexed(char *Buffer, bool AllowNull = false); // This also helps me because I keep typing 'throw new ParseException' instead // of just 'throw ParseException'... sigh... // -static inline void ThrowException(const string &message, +static inline void ThrowException(const std::string &message, int LineNo = -1) { if (LineNo == -1) LineNo = llvmAsmlineno; // TODO: column number in exception @@ -116,18 +116,19 @@ struct ValID { return Result; } - inline string getName() const { + inline std::string getName() const { switch (Type) { - case NumberVal : return string("#") + itostr(Num); + case NumberVal : return std::string("#") + itostr(Num); case NameVal : return Name; - case ConstStringVal: return string("\"") + Name + string("\""); + case ConstStringVal: return std::string("\"") + Name + std::string("\""); case ConstFPVal : return ftostr(ConstPoolFP); case ConstNullVal : return "null"; case ConstUIntVal : - case ConstSIntVal : return string("%") + itostr(ConstPool64); + case ConstSIntVal : return std::string("%") + itostr(ConstPool64); default: assert(0 && "Unknown value!"); abort(); + return ""; } } @@ -163,7 +164,7 @@ public: struct InstPlaceHolderHelper : public Instruction { InstPlaceHolderHelper(const Type *Ty) : Instruction(Ty, UserOp1, "") {} - virtual Instruction *clone() const { abort(); } + virtual Instruction *clone() const { abort(); return 0; } virtual const char *getOpcodeName() const { return "placeholder"; } }; diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 285e78acef..aab868abb9 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -22,6 +22,15 @@ #include // Get definition of pair class #include #include // This embarasment is due to our flex lexer... +#include +using std::list; +using std::vector; +using std::pair; +using std::map; +using std::pair; +using std::make_pair; +using std::cerr; +using std::string; int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit int yylex(); // declaration" of xxx warnings. @@ -46,7 +55,6 @@ string CurFilename; typedef vector ValueList; // Numbered defs static void ResolveDefinitions(vector &LateResolvers, vector *FutureLateResolvers = 0); -static void ResolveTypes (vector > &LateResolveTypes); static struct PerModuleInfo { Module *CurrentModule; @@ -425,22 +433,6 @@ static void ResolveDefinitions(vector &LateResolvers, LateResolvers.clear(); } -// ResolveType - Take a specified unresolved type and resolve it. If there is -// nothing to resolve it to yet, return true. Otherwise resolve it and return -// false. -// -static bool ResolveType(PATypeHolder &T) { - const Type *Ty = T; - ValID &DID = getValIDFromPlaceHolder(Ty); - - const Type *TheRealType = getTypeVal(DID, true); - if (TheRealType == 0 || TheRealType == Ty) return true; - - // Refine the opaque type we had to the new type we are getting. - cast(Ty)->refineAbstractTypeTo(TheRealType); - return false; -} - // ResolveTypeTo - A brand new type was just declared. This means that (if // name is not null) things referencing Name can be resolved. Otherwise, things // refering to the number can be resolved. Do this now. @@ -641,12 +633,13 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) { PATypeHolder *TypeVal; Value *ValueVal; - list *MethodArgList; - vector *ValueList; - list > *TypeList; - list > *PHIList; // Represent the RHS of PHI node - list > *JumpTable; - vector *ConstVector; + std::list *MethodArgList; + std::vector *ValueList; + std::list > *TypeList; + std::list > *PHIList; // Represent the RHS of PHI node + std::list > *JumpTable; + std::vector *ConstVector; int64_t SInt64Val; uint64_t UInt64Val; @@ -812,8 +805,8 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference } | UpRTypesV '(' ArgTypeListI ')' { // Method derived type? vector Params; - mapto($3->begin(), $3->end(), back_inserter(Params), - mem_fun_ref(&PATypeHandle::get)); + mapto($3->begin(), $3->end(), std::back_inserter(Params), + std::mem_fun_ref(&PATypeHandle::get)); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); @@ -827,8 +820,8 @@ UpRTypes : '\\' EUINT64VAL { // Type UpReference } | '{' TypeListI '}' { // Structure type? vector Elements; - mapto($2->begin(), $2->end(), back_inserter(Elements), - mem_fun_ref(&PATypeHandle::get)); + mapto($2->begin(), $2->end(), std::back_inserter(Elements), + std::mem_fun_ref(&PATypeHandle::get)); $$ = newTH(HandleUpRefs(StructType::get(Elements))); delete $2; diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index 78da567f01..d5833dbeed 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -14,8 +14,9 @@ #include "llvm/ConstantVals.h" #include "llvm/GlobalVariable.h" #include - - +#include +using std::make_pair; +using std::cerr; const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf, const uchar *EndBuf) { @@ -36,7 +37,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf, unsigned NumParams; if (read_vbr(Buf, EndBuf, NumParams)) return failure(Val); - vector Params; + std::vector Params; while (NumParams--) { if (read_vbr(Buf, EndBuf, Typ)) return failure(Val); const Type *Ty = getType(Typ); @@ -59,12 +60,12 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf, if (read_vbr(Buf, EndBuf, NumElements)) return failure(Val); BCR_TRACE(5, "Array Type Constant #" << ElTyp << " size=" - << NumElements << endl); + << NumElements << "\n"); return ArrayType::get(ElementType, NumElements); } case Type::StructTyID: { unsigned Typ; - vector Elements; + std::vector Elements; if (read_vbr(Buf, EndBuf, Typ)) return failure(Val); while (Typ) { // List is terminated by void/0 typeid @@ -80,7 +81,7 @@ const Type *BytecodeParser::parseTypeConstant(const uchar *&Buf, case Type::PointerTyID: { unsigned ElTyp; if (read_vbr(Buf, EndBuf, ElTyp)) return failure(Val); - BCR_TRACE(5, "Pointer Type Constant #" << (ElTyp-14) << endl); + BCR_TRACE(5, "Pointer Type Constant #" << (ElTyp-14) << "\n"); const Type *ElementType = getType(ElTyp); if (ElementType == 0) return failure(Val); return PointerType::get(ElementType); @@ -241,7 +242,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf, const ArrayType *AT = cast(Ty); unsigned NumElements = AT->getNumElements(); - vector Elements; + std::vector Elements; while (NumElements--) { // Read all of the elements of the constant. unsigned Slot; if (read_vbr(Buf, EndBuf, Slot)) return failure(true); @@ -257,7 +258,7 @@ bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf, const StructType *ST = cast(Ty); const StructType::ElementTypes &ET = ST->getElementTypes(); - vector Elements; + std::vector Elements; for (unsigned i = 0; i < ET.size(); ++i) { unsigned Slot; if (read_vbr(Buf, EndBuf, Slot)) return failure(true); diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index b498ac90c1..8402db5e82 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -16,6 +16,9 @@ #include "llvm/iMemory.h" #include "llvm/iPHINode.h" #include "llvm/iOther.h" +#include +using std::vector; +using std::cerr; bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf, RawInst &Result) { @@ -107,7 +110,7 @@ bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf, #if 0 cerr << "NO: " << Result.NumOperands << " opcode: " << Result.Opcode << " Ty: " << Result.Ty->getDescription() << " arg1: " << Result.Arg1 - << " arg2: " << Result.Arg2 << " arg3: " << Result.Arg3 << endl; + << " arg2: " << Result.Arg2 << " arg3: " << Result.Arg3 << "\n"; #endif return false; } @@ -441,6 +444,6 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf, } // end switch(Raw.Opcode) cerr << "Unrecognized instruction! " << Raw.Opcode - << " ADDR = 0x" << (void*)Buf << endl; + << " ADDR = 0x" << (void*)Buf << "\n"; return failure(true); } diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index c8be36845a..d0c4d7a5ae 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -20,11 +20,15 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include -#include +typedef int blksize_t; #include +#include #include #include #include +#include +using std::cerr; +using std::make_pair; bool BytecodeParser::getTypeSlot(const Type *Ty, unsigned &Slot) { if (Ty->isPrimitiveType()) { @@ -42,7 +46,7 @@ bool BytecodeParser::getTypeSlot(const Type *Ty, unsigned &Slot) { Slot = FirstDerivedTyID + (&*I - &ModuleTypeValues[0]); } } - //cerr << "getTypeSlot '" << Ty->getName() << "' = " << Slot << endl; + //cerr << "getTypeSlot '" << Ty->getName() << "' = " << Slot << "\n"; return false; } @@ -50,7 +54,7 @@ const Type *BytecodeParser::getType(unsigned ID) { const Type *T = Type::getPrimitiveType((Type::PrimitiveID)ID); if (T) return T; - //cerr << "Looking up Type ID: " << ID << endl; + //cerr << "Looking up Type ID: " << ID << "\n"; const Value *D = getValue(Type::TypeTy, ID, false); if (D == 0) return failure(0); @@ -58,7 +62,7 @@ const Type *BytecodeParser::getType(unsigned ID) { return cast(D); } -int BytecodeParser::insertValue(Value *Val, vector &ValueTab) { +int BytecodeParser::insertValue(Value *Val, std::vector &ValueTab) { unsigned type; if (getTypeSlot(Val->getType(), type)) return failure(-1); assert(type != Type::TypeTyID && "Types should never be insertValue'd!"); @@ -67,7 +71,7 @@ int BytecodeParser::insertValue(Value *Val, vector &ValueTab) { ValueTab.resize(type+1, ValueList()); //cerr << "insertValue Values[" << type << "][" << ValueTab[type].size() - // << "] = " << Val << endl; + // << "] = " << Val << "\n"; ValueTab[type].push_back(Val); return ValueTab[type].size()-1; @@ -115,7 +119,7 @@ Value *BytecodeParser::getValue(const Type *Ty, unsigned oNum, bool Create) { case Type::LabelTyID: d = new BBPHolder(Ty, oNum); break; case Type::MethodTyID: cerr << "Creating method pholder! : " << type << ":" << oNum << " " - << Ty->getName() << endl; + << Ty->getName() << "\n"; d = new MethPHolder(Ty, oNum); if (insertValue(d, LateResolveModuleValues) ==-1) return failure(0); return d; @@ -196,17 +200,17 @@ bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf, // Symtab entry: [def slot #][name] unsigned slot; if (read_vbr(Buf, EndBuf, slot)) return failure(true); - string Name; + std::string Name; if (read(Buf, EndBuf, Name, false)) // Not aligned... return failure(true); Value *D = getValue(Ty, slot, false); // Find mapping... if (D == 0) { - BCR_TRACE(3, "FAILED LOOKUP: Slot #" << slot << endl); + BCR_TRACE(3, "FAILED LOOKUP: Slot #" << slot << "\n"); return failure(true); } BCR_TRACE(4, "Map: '" << Name << "' to #" << slot << ":" << D; - if (!isa(D)) cerr << endl); + if (!isa(D)) cerr << "\n"); D->setName(Name, ST); } @@ -272,7 +276,7 @@ bool BytecodeParser::ParseMethod(const uchar *&Buf, const uchar *EndBuf, MethodSignatureList.pop_front(); Method *M = new Method(MTy, isInternal != 0); - BCR_TRACE(2, "METHOD TYPE: " << MTy << endl); + BCR_TRACE(2, "METHOD TYPE: " << MTy << "\n"); const MethodType::ParamTypes &Params = MTy->getParamTypes(); for (MethodType::ParamTypes::const_iterator It = Params.begin(); @@ -418,7 +422,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End, DeclareNewGlobalValue(GV, unsigned(DestSlot)); BCR_TRACE(2, "Global Variable of type: " << PTy->getDescription() - << " into slot #" << DestSlot << endl); + << " into slot #" << DestSlot << "\n"); if (read_vbr(Buf, End, VarType)) return failure(true); } @@ -459,7 +463,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End, MethodSignatureList.push_back( make_pair(cast(Val->getType()), SlotNo)); if (read_vbr(Buf, End, MethSignature)) return failure(true); - BCR_TRACE(2, "Method of type: " << Ty << endl); + BCR_TRACE(2, "Method of type: " << Ty << "\n"); } if (align32(Buf, End)) return failure(true); @@ -566,11 +570,11 @@ Module *ParseBytecodeBuffer(const uchar *Buffer, unsigned Length) { // Parse and return a class file... // -Module *ParseBytecodeFile(const string &Filename, string *ErrorStr) { +Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) { struct stat StatBuf; Module *Result = 0; - if (Filename != string("-")) { // Read from a file... + if (Filename != std::string("-")) { // Read from a file... int FD = open(Filename.c_str(), O_RDONLY); if (FD == -1) { if (ErrorStr) *ErrorStr = "Error opening file!"; diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index 6abaa2e56b..8a7297a8b3 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -21,7 +21,7 @@ #if TRACE_LEVEL // ByteCodeReading_TRACEer #include "llvm/Assembly/Writer.h" -#define BCR_TRACE(n, X) if (n < TRACE_LEVEL) cerr << string(n*2, ' ') << X +#define BCR_TRACE(n, X) if (n < TRACE_LEVEL) cerr << std::string(n*2, ' ') << X #else #define BCR_TRACE(n, X) #endif @@ -41,12 +41,12 @@ struct RawInst { // The raw fields out of the bytecode stream... unsigned Arg1, Arg2; union { unsigned Arg3; - vector *VarArgs; // Contains arg #3,4,5... if NumOperands > 3 + std::vector *VarArgs; // Contains arg #3,4,5... if NumOperands > 3 }; }; class BytecodeParser : public AbstractTypeUser { - string Error; // Error message string goes here... + std::string Error; // Error message string goes here... public: BytecodeParser() { // Define this in case we don't see a ModuleGlobalInfo block. @@ -55,13 +55,13 @@ public: Module *ParseBytecode(const uchar *Buf, const uchar *EndBuf); - string getError() const { return Error; } + std::string getError() const { return Error; } private: // All of this data is transient across calls to ParseBytecode Module *TheModule; // Current Module being read into... - typedef vector ValueList; - typedef vector ValueTable; + typedef std::vector ValueList; + typedef std::vector ValueTable; ValueTable Values, LateResolveValues; ValueTable ModuleValues, LateResolveModuleValues; @@ -70,14 +70,14 @@ private: // All of this data is transient across calls to ParseBytecode // are defined, and if so, the temporary object that they represent is held // here. // - typedef map, GlobalVariable*> - GlobalRefsType; + typedef std::map, + GlobalVariable*> GlobalRefsType; GlobalRefsType GlobalRefs; // TypesLoaded - This vector mirrors the Values[TypeTyID] plane. It is used // to deal with forward references to types. // - typedef vector > TypeValuesListTy; + typedef std::vector > TypeValuesListTy; TypeValuesListTy ModuleTypeValues; TypeValuesListTy MethodTypeValues; @@ -89,11 +89,11 @@ private: // All of this data is transient across calls to ParseBytecode // into its slot to reserve it. When the method is loaded, this placeholder // is replaced. // - list > MethodSignatureList; + std::list > MethodSignatureList; private: - bool ParseModule (const uchar * Buf, const uchar *End, Module *&); - bool ParseModuleGlobalInfo (const uchar *&Buf, const uchar *End, Module *); + bool ParseModule (const uchar * Buf, const uchar *End, Module *&); + bool ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End, Module *); bool ParseSymbolTable (const uchar *&Buf, const uchar *End, SymbolTable *); bool ParseMethod (const uchar *&Buf, const uchar *End, Module *); bool ParseBasicBlock (const uchar *&Buf, const uchar *End, BasicBlock *&); @@ -111,7 +111,7 @@ private: Value *getValue(const Type *Ty, unsigned num, bool Create = true); const Type *getType(unsigned ID); - int insertValue(Value *D, vector &D); // -1 = Failure + int insertValue(Value *D, std::vector &D); // -1 = Failure bool postResolveValues(ValueTable &ValTab); bool getTypeSlot(const Type *Ty, unsigned &Slot); diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp index bcfa976573..73130f3ee8 100644 --- a/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/lib/Bytecode/Writer/ConstantWriter.cpp @@ -13,6 +13,8 @@ #include "llvm/ConstantVals.h" #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" +#include +using std::cerr; void BytecodeWriter::outputType(const Type *T) { output_vbr((unsigned)T->getPrimitiveID(), Out); @@ -134,7 +136,7 @@ bool BytecodeWriter::outputConstant(const Constant *CPV) { case Type::StructTyID: { const ConstantStruct *CPS = cast(CPV); - const vector &Vals = CPS->getValues(); + const std::vector &Vals = CPS->getValues(); for (unsigned i = 0; i < Vals.size(); ++i) { int Slot = Table.getValSlot(Vals[i]); diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp index 825fde6a16..f047ab5e1c 100644 --- a/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/lib/Bytecode/Writer/InstructionWriter.cpp @@ -28,7 +28,7 @@ typedef unsigned char uchar; // static void outputInstructionFormat0(const Instruction *I, const SlotCalculator &Table, - unsigned Type, deque &Out) { + unsigned Type, std::deque &Out) { // Opcode must have top two bits clear... output_vbr(I->getOpcode() << 2, Out); // Instruction Opcode ID output_vbr(Type, Out); // Result type @@ -63,7 +63,7 @@ static void outputInstructionFormat0(const Instruction *I, // static void outputInstrVarArgsCall(const Instruction *I, const SlotCalculator &Table, unsigned Type, - deque &Out) { + std::deque &Out) { assert(isa(I) || isa(I)); // Opcode must have top two bits clear... output_vbr(I->getOpcode() << 2, Out); // Instruction Opcode ID @@ -106,7 +106,7 @@ static void outputInstrVarArgsCall(const Instruction *I, // static void outputInstructionFormat1(const Instruction *I, const SlotCalculator &Table, int *Slots, - unsigned Type, deque &Out) { + unsigned Type, std::deque &Out) { unsigned Opcode = I->getOpcode(); // Instruction Opcode ID // bits Instruction format: @@ -127,7 +127,7 @@ static void outputInstructionFormat1(const Instruction *I, // static void outputInstructionFormat2(const Instruction *I, const SlotCalculator &Table, int *Slots, - unsigned Type, deque &Out) { + unsigned Type, std::deque &Out) { unsigned Opcode = I->getOpcode(); // Instruction Opcode ID // bits Instruction format: @@ -151,7 +151,7 @@ static void outputInstructionFormat2(const Instruction *I, // static void outputInstructionFormat3(const Instruction *I, const SlotCalculator &Table, int *Slots, - unsigned Type, deque &Out) { + unsigned Type, std::deque &Out) { unsigned Opcode = I->getOpcode(); // Instruction Opcode ID // bits Instruction format: diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index ede822846d..4738f712a1 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -196,7 +196,8 @@ void SlotCalculator::purgeMethod() { while (CurPlane.size() != ModuleSize) { //SC_DEBUG(" Removing [" << i << "] Value=" << CurPlane.back() << "\n"); - map::iterator NI = NodeMap.find(CurPlane.back()); + std::map::iterator NI = + NodeMap.find(CurPlane.back()); assert(NI != NodeMap.end() && "Node not in nodemap?"); NodeMap.erase(NI); // Erase from nodemap CurPlane.pop_back(); // Shrink plane @@ -223,7 +224,7 @@ void SlotCalculator::purgeMethod() { } int SlotCalculator::getValSlot(const Value *D) const { - map::const_iterator I = NodeMap.find(D); + std::map::const_iterator I = NodeMap.find(D); if (I == NodeMap.end()) return -1; return (int)I->second; diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h index c7b3149054..95282447a5 100644 --- a/lib/Bytecode/Writer/SlotCalculator.h +++ b/lib/Bytecode/Writer/SlotCalculator.h @@ -23,14 +23,14 @@ class SlotCalculator { const Module *TheModule; bool IgnoreNamedNodes; // Shall we not count named nodes? - typedef vector TypePlane; - vector Table; - map NodeMap; + typedef std::vector TypePlane; + std::vector Table; + std::map NodeMap; // ModuleLevel - Used to keep track of which values belong to the module, // and which values belong to the currently incorporated method. // - vector ModuleLevel; + std::vector ModuleLevel; public: SlotCalculator(const Module *M, bool IgnoreNamed); diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 3091384722..9ea5d37451 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -34,7 +34,7 @@ #include #include -BytecodeWriter::BytecodeWriter(deque &o, const Module *M) +BytecodeWriter::BytecodeWriter(std::deque &o, const Module *M) : Out(o), Table(M, false) { outputSignature(); @@ -66,7 +66,7 @@ void BytecodeWriter::outputConstants(bool isMethod) { unsigned NumPlanes = Table.getNumPlanes(); for (unsigned pno = 0; pno < NumPlanes; pno++) { - const vector &Plane = Table.getPlane(pno); + const std::vector &Plane = Table.getPlane(pno); if (Plane.empty()) continue; // Skip empty type planes... unsigned ValNo = 0; @@ -95,8 +95,8 @@ void BytecodeWriter::outputConstants(bool isMethod) { assert (Slot != -1 && "Type in constant pool but not in method!!"); output_vbr((unsigned)Slot, Out); - //cout << "Emitting " << NC << " constants of type '" - // << Plane.front()->getType()->getName() << "' = Slot #" << Slot << endl; + //cerr << "Emitting " << NC << " constants of type '" + // << Plane.front()->getType()->getName() << "' = Slot #" << Slot << "\n"; for (unsigned i = ValNo; i < ValNo+NC; ++i) { const Value *V = Plane[i]; @@ -211,7 +211,7 @@ void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) { void WriteBytecodeToFile(const Module *C, ostream &Out) { assert(C && "You can't write a null module!!"); - deque Buffer; + std::deque Buffer; // This object populates buffer for us... BytecodeWriter BCW(Buffer, C); @@ -220,7 +220,7 @@ void WriteBytecodeToFile(const Module *C, ostream &Out) { // sequential in memory, however, so write out as much as possible in big // chunks, until we're done. // - deque::const_iterator I = Buffer.begin(), E = Buffer.end(); + std::deque::const_iterator I = Buffer.begin(),E = Buffer.end(); while (I != E) { // Loop until it's all written // Scan to see how big this chunk is... const unsigned char *ChunkPtr = &*I; @@ -235,7 +235,7 @@ void WriteBytecodeToFile(const Module *C, ostream &Out) { } // Write out the chunk... - Out.write(ChunkPtr, LastPtr-ChunkPtr); + Out.write((char*)ChunkPtr, LastPtr-ChunkPtr); } Out.flush(); diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h index 8a929870f4..10170305b3 100644 --- a/lib/Bytecode/Writer/WriterInternals.h +++ b/lib/Bytecode/Writer/WriterInternals.h @@ -20,10 +20,10 @@ #include class BytecodeWriter { - deque &Out; + std::deque &Out; SlotCalculator Table; public: - BytecodeWriter(deque &o, const Module *M); + BytecodeWriter(std::deque &o, const Module *M); protected: void outputConstants(bool isMethod); @@ -51,12 +51,12 @@ private : // class BytecodeBlock { unsigned Loc; - deque &Out; + std::deque &Out; BytecodeBlock(const BytecodeBlock &); // do not implement void operator=(const BytecodeBlock &); // do not implement public: - inline BytecodeBlock(unsigned ID, deque &o) : Out(o) { + inline BytecodeBlock(unsigned ID, std::deque &o) : Out(o) { output(ID, Out); output((unsigned)0, Out); // Reserve the space for the block size... Loc = Out.size(); diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index 528e5abdd3..ea41b6f822 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -18,10 +18,12 @@ #include "llvm/Instruction.h" #include "Support/CommandLine.h" #include "SchedPriorities.h" -#include #include #include - +#include +#include +using std::cerr; +using std::vector; //************************* External Data Types *****************************/ @@ -353,11 +355,11 @@ private: unsigned int totalInstrCount; cycles_t curTime; cycles_t nextEarliestIssueTime; // next cycle we can issue - vector > choicesForSlot; // indexed by slot# + vector > choicesForSlot; // indexed by slot# vector choiceVec; // indexed by node ptr vector numInClass; // indexed by sched class vector nextEarliestStartTime; // indexed by opCode - hash_map delaySlotInfoForBranches; + std::hash_map delaySlotInfoForBranches; // indexed by branch node ptr public: @@ -419,7 +421,7 @@ public: return choiceVec[i]; } - inline hash_set& getChoicesForSlot(unsigned slotNum) { + inline std::hash_set& getChoicesForSlot(unsigned slotNum) { assert(slotNum < nslots); return choicesForSlot[slotNum]; } @@ -495,7 +497,7 @@ public: bool createIfMissing=false) { DelaySlotInfo* dinfo; - hash_map::const_iterator + std::hash_map::const_iterator I = delaySlotInfoForBranches.find(bn); if (I == delaySlotInfoForBranches.end()) { @@ -552,7 +554,7 @@ SchedulingManager::updateEarliestStartTimes(const SchedGraphNode* node, { if (schedInfo.numBubblesAfter(node->getOpCode()) > 0) { // Update next earliest time before which *nothing* can issue. - nextEarliestIssueTime = max(nextEarliestIssueTime, + nextEarliestIssueTime = std::max(nextEarliestIssueTime, curTime + 1 + schedInfo.numBubblesAfter(node->getOpCode())); } @@ -603,7 +605,7 @@ AssignInstructionsToSlots(class SchedulingManager& S, unsigned maxIssue) unsigned numIssued; for (numIssued = 0; numIssued < maxIssue; numIssued++) { - int chosenSlot = -1, chosenNodeIndex = -1; + int chosenSlot = -1; for (unsigned s=startSlot; s < S.nslots; s++) if ((*igroup)[s] == NULL && S.getChoicesForSlot(s).size() == 1) { @@ -877,7 +879,7 @@ FindSlotChoices(SchedulingManager& S, assert(s < S.nslots && "No feasible slot for instruction?"); - highestSlotUsed = max(highestSlotUsed, (int) s); + highestSlotUsed = std::max(highestSlotUsed, (int) s); } assert(highestSlotUsed <= (int) S.nslots-1 && "Invalid slot used?"); @@ -961,7 +963,6 @@ FindSlotChoices(SchedulingManager& S, // Otherwise, just ignore the instruction. for (unsigned i=indexForBreakingNode+1; i < S.getNumChoices(); i++) { - bool foundLowerSlot = false; MachineOpCode opCode = S.getChoice(i)->getOpCode(); for (unsigned int s=startSlot; s < nslotsToUse; s++) if (S.schedInfo.instrCanUseSlot(opCode, s)) @@ -1001,15 +1002,15 @@ ChooseOneGroup(SchedulingManager& S) { for (cycles_t c = firstCycle; c <= S.getTime(); c++) { - cout << " Cycle " << c << " : Scheduled instructions:\n"; + cerr << " Cycle " << (long)c << " : Scheduled instructions:\n"; const InstrGroup* igroup = S.isched.getIGroup(c); for (unsigned int s=0; s < S.nslots; s++) { - cout << " "; + cerr << " "; if ((*igroup)[s] != NULL) - cout << * ((*igroup)[s])->getMachineInstr() << endl; + cerr << * ((*igroup)[s])->getMachineInstr() << "\n"; else - cout << "" << endl; + cerr << "\n"; } } } @@ -1056,9 +1057,9 @@ ForwardListSchedule(SchedulingManager& S) // an instruction can be issued, or the next earliest in which // one will be ready, or to the next cycle, whichever is latest. // - S.updateTime(max(S.getTime() + 1, - max(S.getEarliestIssueTime(), - S.schedPrio.getEarliestReadyTime()))); + S.updateTime(std::max(S.getTime() + 1, + std::max(S.getEarliestIssueTime(), + S.schedPrio.getEarliestReadyTime()))); } } @@ -1499,8 +1500,7 @@ ScheduleInstructionsWithSSA(Method* method, if (SchedDebugLevel >= Sched_PrintSchedGraphs) { - cout << endl << "*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING" - << endl; + cerr << "\n*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING\n"; graphSet.dump(); } @@ -1513,7 +1513,7 @@ ScheduleInstructionsWithSSA(Method* method, const BasicBlock* bb = bbvec[0]; if (SchedDebugLevel >= Sched_PrintSchedTrace) - cout << endl << "*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; + cerr << "\n*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; SchedPriorities schedPrio(method, graph); // expensive! SchedulingManager S(target, graph, schedPrio); @@ -1527,8 +1527,7 @@ ScheduleInstructionsWithSSA(Method* method, if (SchedDebugLevel >= Sched_PrintMachineCode) { - cout << endl - << "*** Machine instructions after INSTRUCTION SCHEDULING" << endl; + cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n"; MachineCodeForMethod::get(method).dump(); } diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index 9e9af5b80d..7c83e1a58c 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -23,10 +23,16 @@ #include "llvm/Target/MachineRegInfo.h" #include "llvm/iOther.h" #include "Support/StringExtras.h" +#include "Support/STLExtras.h" #include -#include #include +#include +#include +using std::vector; +using std::pair; +using std::hash_map; +using std::cerr; //*********************** Internal Data Structures *************************/ @@ -132,7 +138,7 @@ SchedGraphEdge::~SchedGraphEdge() } void SchedGraphEdge::dump(int indent=0) const { - cout << string(indent*2, ' ') << *this; + cerr << std::string(indent*2, ' ') << *this; } @@ -168,7 +174,7 @@ SchedGraphNode::~SchedGraphNode() } void SchedGraphNode::dump(int indent=0) const { - cout << string(indent*2, ' ') << *this; + cerr << std::string(indent*2, ' ') << *this; } @@ -222,21 +228,20 @@ SchedGraph::SchedGraph(const BasicBlock* bb, const TargetMachine& target) { bbVec.push_back(bb); - this->buildGraph(target); + buildGraph(target); } /*dtor*/ SchedGraph::~SchedGraph() { - for (iterator I=begin(); I != end(); ++I) + for (const_iterator I = begin(); I != end(); ++I) { - SchedGraphNode* node = (*I).second; + SchedGraphNode *node = I->second; // for each node, delete its out-edges - for (SchedGraphNode::iterator I = node->beginOutEdges(); - I != node->endOutEdges(); ++I) - delete *I; + std::for_each(node->beginOutEdges(), node->endOutEdges(), + deleter); // then delete the node itself. delete node; @@ -247,24 +252,24 @@ SchedGraph::~SchedGraph() void SchedGraph::dump() const { - cout << " Sched Graph for Basic Blocks: "; + cerr << " Sched Graph for Basic Blocks: "; for (unsigned i=0, N=bbVec.size(); i < N; i++) { - cout << (bbVec[i]->hasName()? bbVec[i]->getName() : "block") + cerr << (bbVec[i]->hasName()? bbVec[i]->getName() : "block") << " (" << bbVec[i] << ")" << ((i == N-1)? "" : ", "); } - cout << endl << endl << " Actual Root nodes : "; + cerr << "\n\n Actual Root nodes : "; for (unsigned i=0, N=graphRoot->outEdges.size(); i < N; i++) - cout << graphRoot->outEdges[i]->getSink()->getNodeId() + cerr << graphRoot->outEdges[i]->getSink()->getNodeId() << ((i == N-1)? "" : ", "); - cout << endl << " Graph Nodes:" << endl; + cerr << "\n Graph Nodes:\n"; for (const_iterator I=begin(); I != end(); ++I) - cout << endl << * (*I).second; + cerr << "\n" << *I->second; - cout << endl; + cerr << "\n"; } @@ -690,7 +695,7 @@ SchedGraph::addNonSSAEdgesForValue(const Instruction* instr, // this operand is a definition or use of value `instr' SchedGraphNode* node = this->getGraphNodeForInstr(mvec[i]); assert(node && "No node for machine instruction in this BB?"); - refVec.push_back(make_pair(node, o)); + refVec.push_back(std::make_pair(node, o)); } } @@ -747,8 +752,8 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target, { int regNum = mop.getMachineRegNum(); if (regNum != target.getRegInfo().getZeroRegNum()) - regToRefVecMap[mop.getMachineRegNum()].push_back(make_pair(node, - i)); + regToRefVecMap[mop.getMachineRegNum()].push_back( + std::make_pair(node, i)); continue; // nothing more to do } @@ -762,7 +767,7 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target, && "Do not expect any other kind of operand to be defined!"); const Instruction* defInstr = cast(mop.getVRegValue()); - valueToDefVecMap[defInstr].push_back(make_pair(node, i)); + valueToDefVecMap[defInstr].push_back(std::make_pair(node, i)); } // @@ -774,7 +779,7 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target, if (const Instruction* defInstr = dyn_cast_or_null(minstr.getImplicitRef(i))) { - valueToDefVecMap[defInstr].push_back(make_pair(node, -i)); + valueToDefVecMap[defInstr].push_back(std::make_pair(node, -i)); } } @@ -860,7 +865,6 @@ SchedGraph::buildNodesforBB(const TargetMachine& target, void SchedGraph::buildGraph(const TargetMachine& target) { - const MachineInstrInfo& mii = target.getInstrInfo(); const BasicBlock* bb = bbVec[0]; assert(bbVec.size() == 1 && "Only handling a single basic block here"); @@ -966,24 +970,22 @@ SchedGraphSet::SchedGraphSet(const Method* _method, SchedGraphSet::~SchedGraphSet() { // delete all the graphs - for (iterator I=begin(); I != end(); ++I) - delete (*I).second; + for (const_iterator I = begin(); I != end(); ++I) + delete I->second; } void SchedGraphSet::dump() const { - cout << "======== Sched graphs for method `" - << (method->hasName()? method->getName() : "???") - << "' ========" << endl << endl; + cerr << "======== Sched graphs for method `" << method->getName() + << "' ========\n\n"; for (const_iterator I=begin(); I != end(); ++I) - (*I).second->dump(); + I->second->dump(); - cout << endl << "====== End graphs for method `" - << (method->hasName()? method->getName() : "") - << "' ========" << endl << endl; + cerr << "\n====== End graphs for method `" << method->getName() + << "' ========\n\n"; } @@ -1000,8 +1002,7 @@ SchedGraphSet::buildGraphsForMethod(const Method *method, -ostream& -operator<<(ostream& os, const SchedGraphEdge& edge) +std::ostream &operator<<(std::ostream &os, const SchedGraphEdge& edge) { os << "edge [" << edge.src->getNodeId() << "] -> [" << edge.sink->getNodeId() << "] : "; @@ -1015,33 +1016,30 @@ operator<<(ostream& os, const SchedGraphEdge& edge) default: assert(0); break; } - os << " : delay = " << edge.minDelay << endl; + os << " : delay = " << edge.minDelay << "\n"; return os; } -ostream& -operator<<(ostream& os, const SchedGraphNode& node) +std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node) { - os << string(8, ' ') + os << std::string(8, ' ') << "Node " << node.nodeId << " : " - << "latency = " << node.latency << endl << string(12, ' '); + << "latency = " << node.latency << "\n" << std::string(12, ' '); if (node.getMachineInstr() == NULL) - os << "(Dummy node)" << endl; + os << "(Dummy node)\n"; else { - os << *node.getMachineInstr() << endl << string(12, ' '); - os << node.inEdges.size() << " Incoming Edges:" << endl; + os << *node.getMachineInstr() << "\n" << std::string(12, ' '); + os << node.inEdges.size() << " Incoming Edges:\n"; for (unsigned i=0, N=node.inEdges.size(); i < N; i++) - os << string(16, ' ') << *node.inEdges[i]; + os << std::string(16, ' ') << *node.inEdges[i]; - os << string(12, ' ') << node.outEdges.size() - << " Outgoing Edges:" << endl; + os << std::string(12, ' ') << node.outEdges.size() + << " Outgoing Edges:\n"; for (unsigned i=0, N=node.outEdges.size(); i < N; i++) - { - os << string(16, ' ') << * node.outEdges[i]; - } + os << std::string(16, ' ') << *node.outEdges[i]; } return os; diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h index a4567a5198..2890241d59 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.h +++ b/lib/CodeGen/InstrSched/SchedGraph.h @@ -24,7 +24,7 @@ #include "Support/NonCopyable.h" #include "Support/HashExtras.h" #include "Support/GraphTraits.h" -#include +#include class Value; class Instruction; @@ -128,7 +128,7 @@ public: // // Debugging support // - friend ostream& operator<<(ostream& os, const SchedGraphEdge& edge); + friend std::ostream& operator<<(std::ostream& os, const SchedGraphEdge& edge); void dump (int indent=0) const; @@ -144,16 +144,16 @@ private: unsigned int nodeId; const BasicBlock* bb; const MachineInstr* minstr; - vector inEdges; - vector outEdges; + std::vector inEdges; + std::vector outEdges; int origIndexInBB; // original position of machine instr in BB int latency; public: - typedef vector:: iterator iterator; - typedef vector::const_iterator const_iterator; - typedef vector:: reverse_iterator reverse_iterator; - typedef vector::const_reverse_iterator const_reverse_iterator; + typedef std::vector:: iterator iterator; + typedef std::vector::const_iterator const_iterator; + typedef std::vector:: reverse_iterator reverse_iterator; + typedef std::vector::const_reverse_iterator const_reverse_iterator; public: // @@ -186,7 +186,7 @@ public: // // Debugging support // - friend ostream& operator<<(ostream& os, const SchedGraphNode& node); + friend std::ostream& operator<<(std::ostream& os, const SchedGraphNode& node); void dump (int indent=0) const; @@ -214,22 +214,23 @@ private: class SchedGraph : public NonCopyable, - private hash_map + private std::hash_map { private: - vector bbVec; // basic blocks included in the graph + std::vector bbVec; // basic blocks included in the graph SchedGraphNode* graphRoot; // the root and leaf are not inserted SchedGraphNode* graphLeaf; // in the hash_map (see getNumNodes()) + typedef std::hash_map map_base; public: - typedef hash_map::iterator iterator; - typedef hash_map::const_iterator const_iterator; + using map_base::iterator; + using map_base::const_iterator; public: // // Accessor methods // - const vector& getBasicBlocks() const { return bbVec; } + const std::vector& getBasicBlocks() const { return bbVec; } const unsigned int getNumNodes() const { return size()+2; } SchedGraphNode* getRoot() const { return graphRoot; } SchedGraphNode* getLeaf() const { return graphLeaf; } @@ -257,19 +258,9 @@ public: // Unordered iterators. // Return values is pair. // - iterator begin() { - return hash_map::begin(); - } - iterator end() { - return hash_map::end(); - } - const_iterator begin() const { - return hash_map::begin(); - } - const_iterator end() const { - return hash_map::end(); - } - + using map_base::begin; + using map_base::end; + // // Ordered iterators. // Return values is pair. @@ -308,13 +299,13 @@ private: void buildNodesforBB (const TargetMachine& target, const BasicBlock* bb, - vector& memNodeVec, + std::vector& memNod, RegToRefVecMap& regToRefVecMap, ValueToDefVecMap& valueToDefVecMap); void findDefUseInfoAtInstr (const TargetMachine& target, SchedGraphNode* node, - vector& memNodeVec, + std::vector& memNode, RegToRefVecMap& regToRefVecMap, ValueToDefVecMap& valueToDefVecMap); @@ -325,10 +316,10 @@ private: void addCDEdges (const TerminatorInst* term, const TargetMachine& target); - void addMemEdges (const vector& memNodeVec, + void addMemEdges (const std::vector& memNod, const TargetMachine& target); - void addCallCCEdges (const vector& memNodeVec, + void addCallCCEdges (const std::vector& memNod, MachineCodeForBasicBlock& bbMvec, const TargetMachine& target); @@ -347,14 +338,15 @@ private: class SchedGraphSet : public NonCopyable, - private hash_map + private std::hash_map { private: const Method* method; public: - typedef hash_map::iterator iterator; - typedef hash_map::const_iterator const_iterator; + typedef std::hash_map map_base; + using map_base::iterator; + using map_base::const_iterator; public: /*ctor*/ SchedGraphSet (const Method* _method, @@ -372,18 +364,8 @@ public: // // Iterators // - iterator begin() { - return hash_map::begin(); - } - iterator end() { - return hash_map::end(); - } - const_iterator begin() const { - return hash_map::begin(); - } - const_iterator end() const { - return hash_map::end(); - } + using map_base::begin; + using map_base::end; // // Debugging support @@ -544,14 +526,7 @@ template <> struct GraphTraits { }; -//************************ External Functions *****************************/ - - -ostream& operator<<(ostream& os, const SchedGraphEdge& edge); - -ostream& operator<<(ostream& os, const SchedGraphNode& node); - - -/***************************************************************************/ +std::ostream &operator<<(std::ostream& os, const SchedGraphEdge& edge); +std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node); #endif diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp index 1769707238..8cde252115 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.cpp +++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp @@ -20,20 +20,17 @@ #include "SchedPriorities.h" #include "Support/PostOrderIterator.h" - +#include +using std::cerr; SchedPriorities::SchedPriorities(const Method* method, const SchedGraph* _graph) : curTime(0), graph(_graph), - methodLiveVarInfo(method), // expensive! - lastUseMap(), - nodeDelayVec(_graph->getNumNodes(),INVALID_LATENCY), //make errors obvious + methodLiveVarInfo(method), // expensive! + nodeDelayVec(_graph->getNumNodes(), INVALID_LATENCY), // make errors obvious earliestForNode(_graph->getNumNodes(), 0), earliestReadyTime(0), - candsAsHeap(), - candsAsSet(), - mcands(), nextToTry(candsAsHeap.begin()) { methodLiveVarInfo.analyze(); @@ -66,7 +63,7 @@ SchedPriorities::computeDelays(const SchedGraph* graph) E != node->endOutEdges(); ++E) { cycles_t sinkDelay = getNodeDelayRef((*E)->getSink()); - nodeDelay = max(nodeDelay, sinkDelay + (*E)->getMinDelay()); + nodeDelay = std::max(nodeDelay, sinkDelay + (*E)->getMinDelay()); } } getNodeDelayRef(node) = nodeDelay; @@ -87,20 +84,37 @@ SchedPriorities::initializeReadyHeap(const SchedGraph* graph) #undef TEST_HEAP_CONVERSION #ifdef TEST_HEAP_CONVERSION - cout << "Before heap conversion:" << endl; + cerr << "Before heap conversion:\n"; copy(candsAsHeap.begin(), candsAsHeap.end(), - ostream_iterator(cout,"\n")); + ostream_iterator(cerr,"\n")); #endif candsAsHeap.makeHeap(); #ifdef TEST_HEAP_CONVERSION - cout << "After heap conversion:" << endl; + cerr << "After heap conversion:\n"; copy(candsAsHeap.begin(), candsAsHeap.end(), - ostream_iterator(cout,"\n")); + ostream_iterator(cerr,"\n")); #endif } +void +SchedPriorities::insertReady(const SchedGraphNode* node) +{ + candsAsHeap.insert(node, nodeDelayVec[node->getNodeId()]); + candsAsSet.insert(node); + mcands.clear(); // ensure reset choices is called before any more choices + earliestReadyTime = std::min(earliestReadyTime, + earliestForNode[node->getNodeId()]); + + if (SchedDebugLevel >= Sched_PrintSchedTrace) + { + cerr << " Cycle " << (long)getTime() << ": " + << " Node " << node->getNodeId() << " is ready; " + << " Delay = " << (long)getNodeDelayRef(node) << "; Instruction: \n"; + cerr << " " << *node->getMachineInstr() << "\n"; + } +} void SchedPriorities::issuedReadyNodeAt(cycles_t curTime, @@ -116,7 +130,7 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime, for (NodeHeap::const_iterator I=candsAsHeap.begin(); I != candsAsHeap.end(); ++I) if (candsAsHeap.getNode(I)) - earliestReadyTime = min(earliestReadyTime, + earliestReadyTime = std::min(earliestReadyTime, getEarliestForNodeRef(candsAsHeap.getNode(I))); } @@ -125,7 +139,7 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime, E != node->endOutEdges(); ++E) { cycles_t& etime = getEarliestForNodeRef((*E)->getSink()); - etime = max(etime, curTime + (*E)->getMinDelay()); + etime = std::max(etime, curTime + (*E)->getMinDelay()); } } @@ -140,14 +154,14 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime, //---------------------------------------------------------------------- inline int -SchedPriorities::chooseByRule1(vector& mcands) +SchedPriorities::chooseByRule1(std::vector& mcands) { return (mcands.size() == 1)? 0 // only one choice exists so take it : -1; // -1 indicates multiple choices } inline int -SchedPriorities::chooseByRule2(vector& mcands) +SchedPriorities::chooseByRule2(std::vector& mcands) { assert(mcands.size() >= 1 && "Should have at least one candidate here."); for (unsigned i=0, N = mcands.size(); i < N; i++) @@ -158,7 +172,7 @@ SchedPriorities::chooseByRule2(vector& mcands) } inline int -SchedPriorities::chooseByRule3(vector& mcands) +SchedPriorities::chooseByRule3(std::vector& mcands) { assert(mcands.size() >= 1 && "Should have at least one candidate here."); int maxUses = candsAsHeap.getNode(mcands[0])->getNumOutEdges(); @@ -224,7 +238,7 @@ SchedPriorities::getNextHighest(const SchedulingManager& S, void -SchedPriorities::findSetWithMaxDelay(vector& mcands, +SchedPriorities::findSetWithMaxDelay(std::vector& mcands, const SchedulingManager& S) { if (mcands.size() == 0 && nextToTry != candsAsHeap.end()) @@ -240,12 +254,12 @@ SchedPriorities::findSetWithMaxDelay(vector& mcands, if (SchedDebugLevel >= Sched_PrintSchedTrace) { - cout << " Cycle " << this->getTime() << ": " - << "Next highest delay = " << maxDelay << " : " + cerr << " Cycle " << (long)getTime() << ": " + << "Next highest delay = " << (long)maxDelay << " : " << mcands.size() << " Nodes with this delay: "; for (unsigned i=0; i < mcands.size(); i++) - cout << candsAsHeap.getNode(mcands[i])->getNodeId() << ", "; - cout << endl; + cerr << candsAsHeap.getNode(mcands[i])->getNodeId() << ", "; + cerr << "\n"; } } } @@ -257,10 +271,10 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo, { const MachineInstr* minstr = graphNode->getMachineInstr(); - hash_map::const_iterator + std::hash_map::const_iterator ui = lastUseMap.find(minstr); if (ui != lastUseMap.end()) - return (*ui).second; + return ui->second; // else check if instruction is a last use and save it in the hash_map bool hasLastUse = false; diff --git a/lib/CodeGen/InstrSched/SchedPriorities.h b/lib/CodeGen/InstrSched/SchedPriorities.h index 81a2e6a053..a8b3e23397 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.h +++ b/lib/CodeGen/InstrSched/SchedPriorities.h @@ -26,6 +26,7 @@ #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/Target/MachineSchedInfo.h" #include +#include class Method; class MachineInstr; @@ -36,22 +37,22 @@ struct NodeDelayPair { const SchedGraphNode* node; cycles_t delay; NodeDelayPair(const SchedGraphNode* n, cycles_t d) : node(n), delay(d) {} - inline bool operator< (const NodeDelayPair& np) { return delay < np.delay; } + inline bool operator<(const NodeDelayPair& np) { return delay < np.delay; } }; inline bool NDPLessThan(const NodeDelayPair* np1, const NodeDelayPair* np2) { - return (np1->delay < np2->delay); + return np1->delay < np2->delay; } -class NodeHeap: public list, public NonCopyable { +class NodeHeap: public std::list, public NonCopyable { public: - typedef list::iterator iterator; - typedef list::const_iterator const_iterator; + typedef std::list::iterator iterator; + typedef std::list::const_iterator const_iterator; public: - /*ctor*/ NodeHeap () : list(), _size(0) {} + /*ctor*/ NodeHeap () : std::list(), _size(0) {} /*dtor*/ ~NodeHeap () {} inline unsigned int size () const { return _size; } @@ -89,7 +90,7 @@ public: iterator I=begin(); for ( ; I != end() && getDelay(I) >= delay; ++I) ; - list::insert(I, ndp); + std::list::insert(I, ndp); } _size++; } @@ -131,22 +132,22 @@ private: cycles_t curTime; const SchedGraph* graph; MethodLiveVarInfo methodLiveVarInfo; - hash_map lastUseMap; - vector nodeDelayVec; - vector earliestForNode; + std::hash_map lastUseMap; + std::vector nodeDelayVec; + std::vector earliestForNode; cycles_t earliestReadyTime; NodeHeap candsAsHeap; // candidate nodes, ready to go - hash_set candsAsSet; // same entries as candsAsHeap, + std::hash_set candsAsSet;//same entries as candsAsHeap, // but as set for fast lookup - vector mcands; // holds pointers into cands + std::vector mcands; // holds pointers into cands candIndex nextToTry; // next cand after the last // one tried in this cycle - int chooseByRule1 (vector& mcands); - int chooseByRule2 (vector& mcands); - int chooseByRule3 (vector& mcands); + int chooseByRule1 (std::vector& mcands); + int chooseByRule2 (std::vector& mcands); + int chooseByRule3 (std::vector& mcands); - void findSetWithMaxDelay (vector& mcands, + void findSetWithMaxDelay (std::vector& mcands, const SchedulingManager& S); void computeDelays (const SchedGraph* graph); @@ -169,36 +170,15 @@ private: }; -inline void -SchedPriorities::insertReady(const SchedGraphNode* node) -{ - candsAsHeap.insert(node, nodeDelayVec[node->getNodeId()]); - candsAsSet.insert(node); - mcands.clear(); // ensure reset choices is called before any more choices - earliestReadyTime = min(earliestReadyTime, - earliestForNode[node->getNodeId()]); - - if (SchedDebugLevel >= Sched_PrintSchedTrace) - { - cout << " Cycle " << this->getTime() << ": " - << " Node " << node->getNodeId() << " is ready; " - << " Delay = " << this->getNodeDelayRef(node) << "; Instruction: " - << endl; - cout << " " << *node->getMachineInstr() << endl; - } -} - inline void SchedPriorities::updateTime(cycles_t c) { curTime = c; nextToTry = candsAsHeap.begin(); mcands.clear(); } -inline ostream& operator<< (ostream& os, const NodeDelayPair* nd) { +inline std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd) { return os << "Delay for node " << nd->node->getNodeId() - << " = " << nd->delay << endl; + << " = " << (long)nd->delay << "\n"; } -/***************************************************************************/ - #endif diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp index ce3e2c3a3f..20cbe8d71b 100644 --- a/lib/CodeGen/InstrSelection/InstrForest.cpp +++ b/lib/CodeGen/InstrSelection/InstrForest.cpp @@ -31,6 +31,9 @@ #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" #include "Support/STLExtras.h" +#include +using std::cerr; +using std::vector; //------------------------------------------------------------------------ // class InstrTreeNode @@ -119,21 +122,21 @@ void InstructionNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << getInstruction()->getOpcodeName(); + cerr << getInstruction()->getOpcodeName(); const vector &mvec = getInstruction()->getMachineInstrVec(); if (mvec.size() > 0) - cout << "\tMachine Instructions: "; + cerr << "\tMachine Instructions: "; for (unsigned int i=0; i < mvec.size(); i++) { mvec[i]->dump(0); if (i < mvec.size() - 1) - cout << "; "; + cerr << "; "; } - cout << endl; + cerr << "\n"; } @@ -141,9 +144,9 @@ void VRegListNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "List" << endl; + cerr << "List" << "\n"; } @@ -151,29 +154,29 @@ void VRegNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "VReg " << getValue() << "\t(type " - << (int) getValue()->getValueType() << ")" << endl; + cerr << "VReg " << getValue() << "\t(type " + << (int) getValue()->getValueType() << ")" << "\n"; } void ConstantNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "Constant " << getValue() << "\t(type " - << (int) getValue()->getValueType() << ")" << endl; + cerr << "Constant " << getValue() << "\t(type " + << (int) getValue()->getValueType() << ")" << "\n"; } void LabelNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "Label " << getValue() << endl; + cerr << "Label " << getValue() << "\n"; } //------------------------------------------------------------------------ @@ -190,7 +193,7 @@ InstrForest::InstrForest(Method *M) InstrForest::~InstrForest() { - for (hash_map:: iterator I = begin(); + for (std::hash_map::iterator I = begin(); I != end(); ++I) delete (*I).second; } @@ -198,7 +201,7 @@ InstrForest::~InstrForest() void InstrForest::dump() const { - for (hash_set::const_iterator I = treeRoots.begin(); + for (std::hash_set::const_iterator I = treeRoots.begin(); I != treeRoots.end(); ++I) (*I)->dump(/*dumpChildren*/ 1, /*indent*/ 0); } diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index b959c90ca3..ab489c507e 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -23,8 +23,8 @@ #include "llvm/iPHINode.h" #include "llvm/Target/MachineRegInfo.h" #include "Support/CommandLine.h" -#include - +#include +using std::cerr; //******************** Internal Data Declarations ************************/ @@ -84,17 +84,17 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) if (SelectDebugLevel >= Select_DebugInstTrees) { - cout << "\n\n*** Instruction trees for method " + cerr << "\n\n*** Instruction trees for method " << (method->hasName()? method->getName() : "") - << endl << endl; + << "\n\n"; instrForest.dump(); } // // Invoke BURG instruction selection for each tree // - const hash_set &treeRoots = instrForest.getRootSet(); - for (hash_set::const_iterator + const std::hash_set &treeRoots = instrForest.getRootSet(); + for (std::hash_set::const_iterator treeRootIter = treeRoots.begin(); treeRootIter != treeRoots.end(); ++treeRootIter) { @@ -138,8 +138,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) if (SelectDebugLevel >= Select_PrintMachineCode) { - cout << endl - << "*** Machine instructions after INSTRUCTION SELECTION" << endl; + cerr << "\n*** Machine instructions after INSTRUCTION SELECTION\n"; MachineCodeForMethod::get(method).dump(); } @@ -210,7 +209,7 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) { // insert the copy instruction to the predecessor BB - vector CopyInstVec; + std::vector CopyInstVec; MachineInstr *CpMI = target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PN); @@ -250,25 +249,18 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) { PHINode *PN = (PHINode *) (*IIt); - Value *PhiCpRes = new Value(PN->getType(), PN->getValueType()); - - string *Name = new string("PhiCp:"); - (*Name) += (int) PhiCpRes; - PhiCpRes->setName( *Name ); - + Value *PhiCpRes = new Value(PN->getType(), PN->getValueType(),"PhiCp:"); // for each incoming value of the phi, insert phi elimination // for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) { // insert the copy instruction to the predecessor BB - MachineInstr *CpMI = target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes); InsertPhiElimInst(PN->getIncomingBlock(i), CpMI); - } @@ -279,8 +271,6 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) { MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec(); bbMvec.insert( bbMvec.begin(), CpMI2); - - } else break; // since PHI nodes can only be at the top @@ -338,7 +328,7 @@ PostprocessMachineCodeForTree(InstructionNode* instrNode, MachineCodeForVMInstr& mvec = vmInstr->getMachineInstrVec(); for (int i = (int) mvec.size()-1; i >= 0; i--) { - vector loadConstVec = + std::vector loadConstVec = FixConstantOperandsForInstr(vmInstr, mvec[i], target); if (loadConstVec.size() > 0) @@ -372,7 +362,7 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt, if (ruleForNode == 0) { - cerr << "Could not match instruction tree for instr selection" << endl; + cerr << "Could not match instruction tree for instr selection\n"; assert(0); return true; } diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index 30d9c7eb78..34dd83b49e 100644 --- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -22,7 +22,7 @@ #include "llvm/Instruction.h" #include "llvm/Type.h" #include "llvm/iMemory.h" - +using std::vector; //*************************** Local Functions ******************************/ diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 5832b8ed18..ccb52c2c98 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -20,6 +20,8 @@ #include "llvm/Method.h" #include "llvm/iOther.h" #include "llvm/Instruction.h" +#include +using std::cerr; AnnotationID MachineCodeForMethod::AID( AnnotationManager::getID("MachineCodeForMethodAnnotation")); @@ -83,13 +85,12 @@ void MachineInstr::dump(unsigned int indent) const { for (unsigned i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << *this; + cerr << *this; } -ostream& -operator<< (ostream& os, const MachineInstr& minstr) +std::ostream &operator<<(std::ostream& os, const MachineInstr& minstr) { os << TargetInstrDescriptors[minstr.opCode].opCodeString; @@ -101,7 +102,7 @@ operator<< (ostream& os, const MachineInstr& minstr) #undef DEBUG_VAL_OP_ITERATOR #ifdef DEBUG_VAL_OP_ITERATOR - os << endl << "\tValue operands are: "; + os << "\n\tValue operands are: "; for (MachineInstr::val_const_op_iterator vo(&minstr); ! vo.done(); ++vo) { const Value* val = *vo; @@ -127,15 +128,11 @@ operator<< (ostream& os, const MachineInstr& minstr) } #endif - - - os << endl; - - return os; + return os << "\n"; } -static inline ostream& -OutputOperand(ostream &os, const MachineOperand &mop) +static inline std::ostream &OutputOperand(std::ostream &os, + const MachineOperand &mop) { Value* val; switch (mop.getOperandType()) @@ -145,7 +142,7 @@ OutputOperand(ostream &os, const MachineOperand &mop) val = mop.getVRegValue(); os << "(val "; if (val && val->hasName()) - os << val->getName().c_str(); + os << val->getName(); else os << val; return os << ")"; @@ -158,8 +155,7 @@ OutputOperand(ostream &os, const MachineOperand &mop) } -ostream& -operator<<(ostream &os, const MachineOperand &mop) +std::ostream &operator<<(std::ostream &os, const MachineOperand &mop) { switch(mop.opType) { @@ -171,16 +167,16 @@ operator<<(ostream &os, const MachineOperand &mop) os << "%ccreg"; return OutputOperand(os, mop); case MachineOperand::MO_SignExtendedImmed: - return os << mop.immedVal; + return os << (long)mop.immedVal; case MachineOperand::MO_UnextendedImmed: - return os << mop.immedVal; + return os << (long)mop.immedVal; case MachineOperand::MO_PCRelativeDisp: { const Value* opVal = mop.getVRegValue(); bool isLabel = isa(opVal) || isa(opVal); os << "%disp(" << (isLabel? "label " : "addr-of-val "); if (opVal->hasName()) - os << opVal->getName().c_str(); + os << opVal->getName(); else os << opVal; return os << ")"; @@ -403,8 +399,7 @@ MachineCodeForMethod::pushTempValue(const TargetMachine& target, size += align - mod; } - offset = growUp? firstTmpOffset + offset - : firstTmpOffset - offset; + offset = growUp ? firstTmpOffset + offset : firstTmpOffset - offset; currentTmpValuesSize += size; return offset; @@ -419,28 +414,26 @@ MachineCodeForMethod::popAllTempValues(const TargetMachine& target) int MachineCodeForMethod::getOffset(const Value* val) const { - hash_map::const_iterator pair = offsets.find(val); - return (pair == offsets.end())? INVALID_FRAME_OFFSET : (*pair).second; + std::hash_map::const_iterator pair = offsets.find(val); + return (pair == offsets.end())? INVALID_FRAME_OFFSET : pair->second; } void MachineCodeForMethod::dump() const { - cout << "\n" << method->getReturnType() - << " \"" << method->getName() << "\"" << endl; + cerr << "\n" << method->getReturnType() + << " \"" << method->getName() << "\"\n"; for (Method::const_iterator BI = method->begin(); BI != method->end(); ++BI) { BasicBlock* bb = *BI; - cout << "\n" + cerr << "\n" << (bb->hasName()? bb->getName() : "Label") - << " (" << bb << ")" << ":" - << endl; + << " (" << bb << ")" << ":\n"; MachineCodeForBasicBlock& mvec = bb->getMachineInstrVec(); for (unsigned i=0; i < mvec.size(); i++) - cout << "\t" << *mvec[i]; + cerr << "\t" << *mvec[i]; } - cout << endl << "End method \"" << method->getName() << "\"" - << endl << endl; + cerr << "\nEnd method \"" << method->getName() << "\"\n\n"; } diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp index 4e66d9a762..a225742052 100644 --- a/lib/CodeGen/RegAlloc/IGNode.cpp +++ b/lib/CodeGen/RegAlloc/IGNode.cpp @@ -1,12 +1,13 @@ #include "llvm/CodeGen/IGNode.h" - +#include +#include +using std::cerr; //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- -IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind), - AdjList(), - ParentLR(PLR) +IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind), + ParentLR(PLR) { OnStack = false; CurDegree = -1 ; @@ -23,11 +24,12 @@ void IGNode::pushOnStack() int neighs = AdjList.size(); if( neighs < 0) { - cout << "\nAdj List size = " << neighs; + cerr << "\nAdj List size = " << neighs; assert(0 && "Invalid adj list size"); } - for(int i=0; i < neighs; i++) (AdjList[i])->decCurDegree(); + for(int i=0; i < neighs; i++) + AdjList[i]->decCurDegree(); } //----------------------------------------------------------------------------- @@ -35,11 +37,9 @@ void IGNode::pushOnStack() // two IGNodes together. //----------------------------------------------------------------------------- void IGNode::delAdjIGNode(const IGNode *const Node) { - vector ::iterator It = AdjList.begin(); - - // find Node - for( ; It != AdjList.end() && (*It != Node); It++ ) ; + std::vector::iterator It = + find(AdjList.begin(), AdjList.end(), Node); assert( It != AdjList.end() ); // the node must be there - - AdjList.erase( It ); + + AdjList.erase(It); } diff --git a/lib/CodeGen/RegAlloc/IGNode.h b/lib/CodeGen/RegAlloc/IGNode.h index 0f4cf9c82a..b89aea32b1 100644 --- a/lib/CodeGen/RegAlloc/IGNode.h +++ b/lib/CodeGen/RegAlloc/IGNode.h @@ -29,8 +29,6 @@ #include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/CodeGen/LiveRange.h" - - //---------------------------------------------------------------------------- // Class IGNode // @@ -39,13 +37,11 @@ class IGNode { - private: - const int Index; // index within IGNodeList bool OnStack; // this has been pushed on to stack for coloring - vector AdjList; // adjacency list for this live range + std::vector AdjList; // adjacency list for this live range int CurDegree; // @@ -54,7 +50,6 @@ class IGNode // Decremented when a neighbor is pushed on to the stack. // After that, never incremented/set again nor used. - LiveRange *const ParentLR; // parent LR (cannot be a const) @@ -152,10 +147,4 @@ class IGNode }; - - - - - - #endif diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp index e18c9a7a34..0de7275acf 100644 --- a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp +++ b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp @@ -1,4 +1,7 @@ #include "llvm/CodeGen/InterferenceGraph.h" +#include "Support/STLExtras.h" +#include +using std::cerr; //----------------------------------------------------------------------------- // Constructor: Records the RegClass and initalizes IGNodeList. @@ -11,7 +14,7 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC), IG = NULL; Size = 0; if( DEBUG_RA) { - cout << "Interference graph created!" << endl; + cerr << "Interference graph created!\n"; } } @@ -22,19 +25,12 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC), InterferenceGraph:: ~InterferenceGraph() { // delete the matrix - // - if( IG ) - delete []IG; + for(unsigned int r=0; r < IGNodeList.size(); ++r) + delete[] IG[r]; + delete[] IG; // delete all IGNodes in the IGNodeList - // - vector::const_iterator IGIt = IGNodeList.begin(); - for(unsigned i=0; i < IGNodeList.size() ; ++i) { - - const IGNode *const Node = IGNodeList[i]; - if( Node ) delete Node; - } - + for_each(IGNodeList.begin(), IGNodeList.end(), deleter); } @@ -46,13 +42,13 @@ InterferenceGraph:: ~InterferenceGraph() { void InterferenceGraph::createGraph() { Size = IGNodeList.size(); - IG = (char **) new char *[Size]; + IG = new char*[Size]; for( unsigned int r=0; r < Size; ++r) IG[r] = new char[Size]; // init IG matrix for(unsigned int i=0; i < Size; i++) - for( unsigned int j=0; j < Size ; j++) + for(unsigned int j=0; j < Size; j++) IG[i][j] = 0; } @@ -61,9 +57,7 @@ void InterferenceGraph::createGraph() //----------------------------------------------------------------------------- void InterferenceGraph::addLRToIG(LiveRange *const LR) { - IGNode *Node = new IGNode(LR, IGNodeList.size() ); - IGNodeList.push_back( Node ); - + IGNodeList.push_back(new IGNode(LR, IGNodeList.size())); } @@ -92,12 +86,11 @@ void InterferenceGraph::setInterference(const LiveRange *const LR1, char *val; if( DEBUG_RA > 1) - cout << "setting intf for: [" << row << "][" << col << "]" << endl; + cerr << "setting intf for: [" << row << "][" << col << "]\n"; ( row > col) ? val = &IG[row][col]: val = &IG[col][row]; if( ! (*val) ) { // if this interf is not previously set - *val = 1; // add edges between nodes IGNode1->addAdjIGNode( IGNode2 ); IGNode2->addAdjIGNode( IGNode1 ); @@ -123,7 +116,10 @@ unsigned InterferenceGraph::getInterference(const LiveRange *const LR1, const unsigned int col = LR2->getUserIGNode()->getIndex(); char ret; - ( row > col) ? (ret = IG[row][col]) : (ret = IG[col][row]) ; + if (row > col) + ret = IG[row][col]; + else + ret = IG[col][row]; return ret; } @@ -148,9 +144,9 @@ void InterferenceGraph::mergeIGNodesOfLRs(const LiveRange *const LR1, assertIGNode( SrcNode ); if( DEBUG_RA > 1) { - cout << "Merging LRs: \""; LR1->printSet(); - cout << "\" and \""; LR2->printSet(); - cout << "\"" << endl; + cerr << "Merging LRs: \""; LR1->printSet(); + cerr << "\" and \""; LR2->printSet(); + cerr << "\"\n"; } unsigned SrcDegree = SrcNode->getNumOfNeighbors(); @@ -217,17 +213,16 @@ void InterferenceGraph::printIG() const for(unsigned int i=0; i < Size; i++) { const IGNode *const Node = IGNodeList[i]; - if( ! Node ) - continue; // skip empty rows - - cout << " [" << i << "] "; + if(Node) { + cerr << " [" << i << "] "; - for( unsigned int j=0; j < Size; j++) { - if( j >= i) break; - if( IG[i][j] ) cout << "(" << i << "," << j << ") "; + for( unsigned int j=0; j < i; j++) { + if(IG[i][j]) + cerr << "(" << i << "," << j << ") "; } - cout << endl; + cerr << "\n"; } + } } //---------------------------------------------------------------------------- @@ -235,21 +230,14 @@ void InterferenceGraph::printIG() const //---------------------------------------------------------------------------- void InterferenceGraph::printIGNodeList() const { - vector::const_iterator IGIt = IGNodeList.begin(); // hash map iter - for(unsigned i=0; i < IGNodeList.size() ; ++i) { - const IGNode *const Node = IGNodeList[i]; - if( ! Node ) - continue; - - cout << " [" << Node->getIndex() << "] "; - (Node->getParentLR())->printSet(); - //int Deg = Node->getCurDegree(); - cout << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl; - + if (Node) { + cerr << " [" << Node->getIndex() << "] "; + Node->getParentLR()->printSet(); + //int Deg = Node->getCurDegree(); + cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">\n"; + } } } - - diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.h b/lib/CodeGen/RegAlloc/InterferenceGraph.h index 99dea8fbe0..408bee4558 100644 --- a/lib/CodeGen/RegAlloc/InterferenceGraph.h +++ b/lib/CodeGen/RegAlloc/InterferenceGraph.h @@ -1,4 +1,4 @@ -/* Title: InterferenceGraph.h +/* Title: InterferenceGraph.h -*- C++ -*- Author: Ruchira Sasanka Date: July 20, 01 Purpose: Interference Graph used for register coloring. @@ -24,7 +24,7 @@ #include "llvm/CodeGen/IGNode.h" -typedef vector IGNodeListType; +typedef std::vector IGNodeListType; class InterferenceGraph @@ -47,6 +47,8 @@ class InterferenceGraph // to create it after adding all IGNodes to the IGNodeList InterferenceGraph(RegClass *const RC); + ~InterferenceGraph(); + void createGraph(); void addLRToIG(LiveRange *const LR); @@ -65,12 +67,6 @@ class InterferenceGraph void printIG() const; void printIGNodeList() const; - - ~InterferenceGraph(); - - }; - #endif - diff --git a/lib/CodeGen/RegAlloc/LiveRange.h b/lib/CodeGen/RegAlloc/LiveRange.h index 778e070046..8034751da9 100644 --- a/lib/CodeGen/RegAlloc/LiveRange.h +++ b/lib/CodeGen/RegAlloc/LiveRange.h @@ -1,4 +1,4 @@ -/* Title: LiveRange.h +/* Title: LiveRange.h -*- C++ -*- Author: Ruchira Sasanka Date: July 25, 01 Purpose: To keep info about a live range. @@ -13,6 +13,7 @@ #include "llvm/Analysis/LiveVar/ValueSet.h" #include "llvm/Type.h" +#include class RegClass; class IGNode; @@ -176,7 +177,7 @@ class LiveRange : public ValueSet if(SuggestedColor == -1 ) SuggestedColor = Col; else if (DEBUG_RA) - cerr << "Already has a suggested color " << Col << endl; + std::cerr << "Already has a suggested color " << Col << "\n"; } inline unsigned getSuggestedColor() const { diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp index 7fb688f55e..b66e6ef308 100644 --- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp +++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp @@ -1,15 +1,15 @@ #include "llvm/CodeGen/LiveRangeInfo.h" +#include +using std::cerr; //--------------------------------------------------------------------------- // Constructor //--------------------------------------------------------------------------- LiveRangeInfo::LiveRangeInfo(const Method *const M, const TargetMachine& tm, - vector &RCL) - : Meth(M), LiveRangeMap(), - TM(tm), RegClassList(RCL), - MRI( tm.getRegInfo()), - CallRetInstrList() + std::vector &RCL) + : Meth(M), LiveRangeMap(), TM(tm), + RegClassList(RCL), MRI(tm.getRegInfo()) { } @@ -17,33 +17,25 @@ LiveRangeInfo::LiveRangeInfo(const Method *const M, // Destructor: Deletes all LiveRanges in the LiveRangeMap //--------------------------------------------------------------------------- LiveRangeInfo::~LiveRangeInfo() { - LiveRangeMapType::iterator MI = LiveRangeMap.begin(); for( ; MI != LiveRangeMap.end() ; ++MI) { - if( (*MI).first ) { - - LiveRange *LR = (*MI).second; - - if( LR ) { - - // we need to be careful in deleting LiveRanges in LiveRangeMap - // since two/more Values in the live range map can point to the same - // live range. We have to make the other entries NULL when we delete - // a live range. - - LiveRange::iterator LI = LR->begin(); - - for( ; LI != LR->end() ; ++LI) { - LiveRangeMap[*LI] = NULL; - } + if (MI->first && MI->second) { + LiveRange *LR = MI->second; - delete LR; + // we need to be careful in deleting LiveRanges in LiveRangeMap + // since two/more Values in the live range map can point to the same + // live range. We have to make the other entries NULL when we delete + // a live range. - } + LiveRange::iterator LI = LR->begin(); + + for( ; LI != LR->end() ; ++LI) + LiveRangeMap[*LI] = 0; + + delete LR; } } - } @@ -82,7 +74,7 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *const L1, LiveRange *L2) L1->addSpillCost( L2->getSpillCost() ); // add the spill costs - delete ( L2 ); // delete L2 as it is no longer needed + delete L2; // delete L2 as it is no longer needed } @@ -96,7 +88,7 @@ void LiveRangeInfo::constructLiveRanges() { if( DEBUG_RA) - cout << "Consturcting Live Ranges ..." << endl; + cerr << "Consturcting Live Ranges ...\n"; // first find the live ranges for all incoming args of the method since // those LRs start from the start of the method @@ -108,14 +100,13 @@ void LiveRangeInfo::constructLiveRanges() for( ; ArgIt != ArgList.end() ; ++ArgIt) { // for each argument - LiveRange * ArgRange = new LiveRange(); // creates a new LR and const Value *const Val = (const Value *) *ArgIt; assert( Val); - ArgRange->add( Val ); // add the arg (def) to it - LiveRangeMap[ Val ] = ArgRange; + ArgRange->add(Val); // add the arg (def) to it + LiveRangeMap[Val] = ArgRange; // create a temp machine op to find the register class of value //const MachineOperand Op(MachineOperand::MO_VirtualRegister); @@ -125,8 +116,8 @@ void LiveRangeInfo::constructLiveRanges() if( DEBUG_RA > 1) { - cout << " adding LiveRange for argument "; - printValue( (const Value *) *ArgIt); cout << endl; + cerr << " adding LiveRange for argument "; + printValue((const Value *) *ArgIt); cerr << "\n"; } } @@ -140,7 +131,6 @@ void LiveRangeInfo::constructLiveRanges() Method::const_iterator BBI = Meth->begin(); // random iterator for BBs - for( ; BBI != Meth->end(); ++BBI) { // go thru BBs in random order // Now find all LRs for machine the instructions. A new LR will be created @@ -150,8 +140,7 @@ void LiveRangeInfo::constructLiveRanges() // get the iterator for machine instructions const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec(); - MachineCodeForBasicBlock::const_iterator - MInstIterator = MIVec.begin(); + MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin(); // iterate over all the machine instructions in BB for( ; MInstIterator != MIVec.end(); MInstIterator++) { @@ -161,53 +150,46 @@ void LiveRangeInfo::constructLiveRanges() // Now if the machine instruction is a call/return instruction, // add it to CallRetInstrList for processing its implicit operands - if( (TM.getInstrInfo()).isReturn( MInst->getOpCode()) || - (TM.getInstrInfo()).isCall( MInst->getOpCode()) ) + if(TM.getInstrInfo().isReturn(MInst->getOpCode()) || + TM.getInstrInfo().isCall(MInst->getOpCode())) CallRetInstrList.push_back( MInst ); // iterate over MI operands to find defs - for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) { - - if( DEBUG_RA) { + for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) { + if(DEBUG_RA) { MachineOperand::MachineOperandType OpTyp = OpI.getMachineOperand().getOperandType(); - if ( OpTyp == MachineOperand::MO_CCRegister) { - cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:"; + if (OpTyp == MachineOperand::MO_CCRegister) { + cerr << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:"; printValue( OpI.getMachineOperand().getVRegValue() ); - cout << endl; + cerr << "\n"; } } // create a new LR iff this operand is a def if( OpI.isDef() ) { - const Value *const Def = *OpI; - // Only instruction values are accepted for live ranges here - if( Def->getValueType() != Value::InstructionVal ) { - cout << "\n**%%Error: Def is not an instruction val. Def="; - printValue( Def ); cout << endl; + cerr << "\n**%%Error: Def is not an instruction val. Def="; + printValue( Def ); cerr << "\n"; continue; } - LiveRange *DefRange = LiveRangeMap[Def]; // see LR already there (because of multiple defs) - if( !DefRange) { // if it is not in LiveRangeMap - DefRange = new LiveRange(); // creates a new live range and DefRange->add( Def ); // add the instruction (def) to it LiveRangeMap[ Def ] = DefRange; // update the map if( DEBUG_RA > 1) { - cout << " creating a LR for def: "; - printValue(Def); cout << endl; + cerr << " creating a LR for def: "; + printValue(Def); cerr << "\n"; } // set the register class of the new live range @@ -221,7 +203,7 @@ void LiveRangeInfo::constructLiveRanges() if(isCC && DEBUG_RA) { - cout << "\a**created a LR for a CC reg:"; + cerr << "\a**created a LR for a CC reg:"; printValue( OpI.getMachineOperand().getVRegValue() ); } @@ -235,8 +217,8 @@ void LiveRangeInfo::constructLiveRanges() LiveRangeMap[ Def ] = DefRange; if( DEBUG_RA > 1) { - cout << " added to an existing LR for def: "; - printValue( Def ); cout << endl; + cerr << " added to an existing LR for def: "; + printValue( Def ); cerr << "\n"; } } @@ -256,7 +238,7 @@ void LiveRangeInfo::constructLiveRanges() suggestRegs4CallRets(); if( DEBUG_RA) - cout << "Initial Live Ranges constructed!" << endl; + cerr << "Initial Live Ranges constructed!\n"; } @@ -312,11 +294,8 @@ void LiveRangeInfo::suggestRegs4CallRets() //--------------------------------------------------------------------------- void LiveRangeInfo::coalesceLRs() { - - - if( DEBUG_RA) - cout << endl << "Coalscing LRs ..." << endl; + cerr << "\nCoalscing LRs ...\n"; Method::const_iterator BBI = Meth->begin(); // random iterator for BBs @@ -324,8 +303,7 @@ void LiveRangeInfo::coalesceLRs() // get the iterator for machine instructions const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec(); - MachineCodeForBasicBlock::const_iterator - MInstIterator = MIVec.begin(); + MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin(); // iterate over all the machine instructions in BB for( ; MInstIterator != MIVec.end(); ++MInstIterator) { @@ -333,9 +311,9 @@ void LiveRangeInfo::coalesceLRs() const MachineInstr * MInst = *MInstIterator; if( DEBUG_RA > 1) { - cout << " *Iterating over machine instr "; + cerr << " *Iterating over machine instr "; MInst->dump(); - cout << endl; + cerr << "\n"; } @@ -357,8 +335,8 @@ void LiveRangeInfo::coalesceLRs() //don't warn about labels if (!((*UseI)->getType())->isLabelType() && DEBUG_RA) { - cout<<" !! Warning: No LR for use "; printValue(*UseI); - cout << endl; + cerr<<" !! Warning: No LR for use "; printValue(*UseI); + cerr << "\n"; } continue; // ignore and continue } @@ -407,7 +385,7 @@ void LiveRangeInfo::coalesceLRs() } // for all BBs if( DEBUG_RA) - cout << endl << "Coalscing Done!" << endl; + cerr << "\nCoalscing Done!\n"; } @@ -421,11 +399,11 @@ void LiveRangeInfo::coalesceLRs() void LiveRangeInfo::printLiveRanges() { LiveRangeMapType::iterator HMI = LiveRangeMap.begin(); // hash map iterator - cout << endl << "Printing Live Ranges from Hash Map:" << endl; - for( ; HMI != LiveRangeMap.end() ; HMI ++ ) { - if( (*HMI).first && (*HMI).second ) { - cout <<" "; printValue((*HMI).first); cout << "\t: "; - ((*HMI).second)->printSet(); cout << endl; + cerr << "\nPrinting Live Ranges from Hash Map:\n"; + for( ; HMI != LiveRangeMap.end() ; ++HMI) { + if( HMI->first && HMI->second ) { + cerr <<" "; printValue((*HMI).first); cerr << "\t: "; + HMI->second->printSet(); cerr << "\n"; } } } diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.h b/lib/CodeGen/RegAlloc/LiveRangeInfo.h index 1eee1aea5e..9e7ef06fe2 100644 --- a/lib/CodeGen/RegAlloc/LiveRangeInfo.h +++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.h @@ -1,4 +1,4 @@ -/* Title: LiveRangeInfo.h +/* Title: LiveRangeInfo.h -*- C++ -*- Author: Ruchira Sasanka Date: Jun 30, 01 Purpose: @@ -34,8 +34,8 @@ #include "llvm/CodeGen/RegClass.h" -typedef hash_map LiveRangeMapType; -typedef vector CallRetInstrListType; +typedef std::hash_map LiveRangeMapType; +typedef std::vector CallRetInstrListType; @@ -59,7 +59,7 @@ private: const TargetMachine& TM; // target machine description - vector & RegClassList;// a vector containing register classess + std::vector & RegClassList;// vector containing register classess const MachineRegInfo& MRI; // machine reg info @@ -82,7 +82,7 @@ public: LiveRangeInfo(const Method *const M, const TargetMachine& tm, - vector & RCList); + std::vector & RCList); // Destructor to destroy all LiveRanges in the LiveRange Map diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 7d6fbb7cc9..e2d455bad9 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -14,7 +14,9 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MachineFrameInfo.h" +#include #include +using std::cerr; // ***TODO: There are several places we add instructions. Validate the order @@ -35,18 +37,16 @@ cl::Enum DEBUG_RA("dregalloc", cl::NoFlags, PhyRegAlloc::PhyRegAlloc(Method *M, const TargetMachine& tm, MethodLiveVarInfo *const Lvi) - : RegClassList(), - TM(tm), - Meth(M), + : TM(tm), Meth(M), mcInfo(MachineCodeForMethod::get(M)), LVI(Lvi), LRI(M, tm, RegClassList), MRI( tm.getRegInfo() ), NumOfRegClasses(MRI.getNumOfRegClasses()), - AddedInstrMap(), LoopDepthCalc(M), ResColList() { + LoopDepthCalc(M) { // create each RegisterClass and put in RegClassList // - for( unsigned int rc=0; rc < NumOfRegClasses; rc++) + for(unsigned int rc=0; rc < NumOfRegClasses; rc++) RegClassList.push_back( new RegClass(M, MRI.getMachineRegClass(rc), &ResColList) ); } @@ -69,7 +69,7 @@ PhyRegAlloc::~PhyRegAlloc() { //---------------------------------------------------------------------------- void PhyRegAlloc::createIGNodeListsAndIGs() { - if(DEBUG_RA ) cout << "Creating LR lists ..." << endl; + if(DEBUG_RA ) cerr << "Creating LR lists ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin(); @@ -85,8 +85,8 @@ void PhyRegAlloc::createIGNodeListsAndIGs() if( !L) { if( DEBUG_RA) { - cout << "\n*?!?Warning: Null liver range found for: "; - printValue( (*HMI).first) ; cout << endl; + cerr << "\n*?!?Warning: Null liver range found for: "; + printValue(HMI->first); cerr << "\n"; } continue; } @@ -108,7 +108,7 @@ void PhyRegAlloc::createIGNodeListsAndIGs() RegClassList[ rc ]->createInterferenceGraph(); if( DEBUG_RA) - cout << "LRLists Created!" << endl; + cerr << "LRLists Created!\n"; } @@ -140,8 +140,8 @@ void PhyRegAlloc::addInterference(const Value *const Def, for( ; LIt != LVSet->end(); ++LIt) { if( DEBUG_RA > 1) { - cout << "< Def="; printValue(Def); - cout << ", Lvar="; printValue( *LIt); cout << "> "; + cerr << "< Def="; printValue(Def); + cerr << ", Lvar="; printValue( *LIt); cerr << "> "; } // get the live range corresponding to live var @@ -166,8 +166,8 @@ void PhyRegAlloc::addInterference(const Value *const Def, else if(DEBUG_RA > 1) { // we will not have LRs for values not explicitly allocated in the // instruction stream (e.g., constants) - cout << " warning: no live range for " ; - printValue( *LIt); cout << endl; } + cerr << " warning: no live range for " ; + printValue(*LIt); cerr << "\n"; } } @@ -203,7 +203,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, } if( DEBUG_RA) - cout << "\n For call inst: " << *MInst; + cerr << "\n For call inst: " << *MInst; LiveVarSet::const_iterator LIt = LVSetAft->begin(); @@ -216,7 +216,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, LiveRange *const LR = LRI.getLiveRangeForValue(*LIt ); if( LR && DEBUG_RA) { - cout << "\n\tLR Aft Call: "; + cerr << "\n\tLR Aft Call: "; LR->printSet(); } @@ -227,7 +227,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, if( LR && (LR != RetValLR) ) { LR->setCallInterference(); if( DEBUG_RA) { - cout << "\n ++Added call interf for LR: " ; + cerr << "\n ++Added call interf for LR: " ; LR->printSet(); } } @@ -247,7 +247,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, void PhyRegAlloc::buildInterferenceGraphs() { - if(DEBUG_RA) cout << "Creating interference graphs ..." << endl; + if(DEBUG_RA) cerr << "Creating interference graphs ...\n"; unsigned BBLoopDepthCost; Method::const_iterator BBI = Meth->begin(); // random iterator for BBs @@ -333,7 +333,7 @@ void PhyRegAlloc::buildInterferenceGraphs() addInterferencesForArgs(); if( DEBUG_RA) - cout << "Interference graphs calculted!" << endl; + cerr << "Interference graphs calculted!\n"; } @@ -411,8 +411,8 @@ void PhyRegAlloc::addInterferencesForArgs() addInterference( *ArgIt, InSet, false ); // add interferences between // args and LVars at start if( DEBUG_RA > 1) { - cout << " - %% adding interference for argument "; - printValue( (const Value *) *ArgIt); cout << endl; + cerr << " - %% adding interference for argument "; + printValue((const Value *)*ArgIt); cerr << "\n"; } } } @@ -510,7 +510,7 @@ void PhyRegAlloc::updateMachineCode() // delete this condition checking later (must assert if Val is null) if( !Val) { if (DEBUG_RA) - cout << "Warning: NULL Value found for operand" << endl; + cerr << "Warning: NULL Value found for operand\n"; continue; } assert( Val && "Value is NULL"); @@ -522,9 +522,9 @@ void PhyRegAlloc::updateMachineCode() // nothing to worry if it's a const or a label if (DEBUG_RA) { - cout << "*NO LR for operand : " << Op ; - cout << " [reg:" << Op.getAllocatedRegNum() << "]"; - cout << " in inst:\t" << *MInst << endl; + cerr << "*NO LR for operand : " << Op ; + cerr << " [reg:" << Op.getAllocatedRegNum() << "]"; + cerr << " in inst:\t" << *MInst << "\n"; } // if register is not allocated, mark register as invalid @@ -563,18 +563,16 @@ void PhyRegAlloc::updateMachineCode() // instruction, add them now. // if( AddedInstrMap[ MInst ] ) { - - deque &IBef = (AddedInstrMap[MInst])->InstrnsBefore; + std::deque &IBef = AddedInstrMap[MInst]->InstrnsBefore; if( ! IBef.empty() ) { - - deque::iterator AdIt; + std::deque::iterator AdIt; for( AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt ) { if( DEBUG_RA) { cerr << "For inst " << *MInst; - cerr << " PREPENDed instr: " << **AdIt << endl; + cerr << " PREPENDed instr: " << **AdIt << "\n"; } MInstIterator = MIVec.insert( MInstIterator, *AdIt ); @@ -600,7 +598,7 @@ void PhyRegAlloc::updateMachineCode() if((delay=TM.getInstrInfo().getNumDelaySlots(MInst->getOpCode())) >0){ move2DelayedInstr(MInst, *(MInstIterator+delay) ); - if(DEBUG_RA) cout<< "\nMoved an added instr after the delay slot"; + if(DEBUG_RA) cerr<< "\nMoved an added instr after the delay slot"; } else { @@ -609,11 +607,11 @@ void PhyRegAlloc::updateMachineCode() // Here we can add the "instructions after" to the current // instruction since there are no delay slots for this instruction - deque &IAft = (AddedInstrMap[MInst])->InstrnsAfter; + std::deque &IAft = AddedInstrMap[MInst]->InstrnsAfter; if( ! IAft.empty() ) { - deque::iterator AdIt; + std::deque::iterator AdIt; ++MInstIterator; // advance to the next instruction @@ -621,7 +619,7 @@ void PhyRegAlloc::updateMachineCode() if(DEBUG_RA) { cerr << "For inst " << *MInst; - cerr << " APPENDed instr: " << **AdIt << endl; + cerr << " APPENDed instr: " << **AdIt << "\n"; } MInstIterator = MIVec.insert( MInstIterator, *AdIt ); @@ -669,9 +667,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR, RegClass *RC = LR->getRegClass(); const LiveVarSet *LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB); - - int TmpOff = - mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) ); + mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) ); MachineInstr *MIBef=NULL, *AdIMid=NULL, *MIAft=NULL; @@ -854,13 +850,10 @@ int PhyRegAlloc::getUniRegNotUsedByThisInst(RegClass *RC, return MRI.getUnifiedRegNum(RC->getID(), c); else assert( 0 && "FATAL: No free register could be found in reg class!!"); - + return 0; } - - - //---------------------------------------------------------------------------- // This method modifies the IsColorUsedArr of the register class passed to it. // It sets the bits corresponding to the registers used by this machine @@ -909,14 +902,10 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, LiveRange *const LRofImpRef = LRI.getLiveRangeForValue( MInst->getImplicitRef(z) ); - - if( LRofImpRef ) - if( LRofImpRef->hasColor() ) - IsColorUsedArr[ LRofImpRef->getColor() ] = true; + + if(LRofImpRef && LRofImpRef->hasColor()) + IsColorUsedArr[LRofImpRef->getColor()] = true; } - - - } @@ -936,9 +925,8 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI, const MachineInstr *DelayedMI) { - // "added after" instructions of the original instr - deque &OrigAft = (AddedInstrMap[OrigMI])->InstrnsAfter; + std::deque &OrigAft = AddedInstrMap[OrigMI]->InstrnsAfter; // "added instructions" of the delayed instr AddedInstrns *DelayAdI = AddedInstrMap[DelayedMI]; @@ -949,21 +937,15 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI, } // "added after" instructions of the delayed instr - deque &DelayedAft = DelayAdI->InstrnsAfter; + std::deque &DelayedAft = DelayAdI->InstrnsAfter; // go thru all the "added after instructions" of the original instruction // and append them to the "addded after instructions" of the delayed // instructions - - deque::iterator OrigAdIt; - - for( OrigAdIt = OrigAft.begin(); OrigAdIt != OrigAft.end() ; ++OrigAdIt ) { - DelayedAft.push_back( *OrigAdIt ); - } + DelayedAft.insert(DelayedAft.end(), OrigAft.begin(), OrigAft.end()); // empty the "added after instructions" of the original instruction OrigAft.clear(); - } //---------------------------------------------------------------------------- @@ -973,14 +955,14 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI, void PhyRegAlloc::printMachineCode() { - cout << endl << ";************** Method "; - cout << Meth->getName() << " *****************" << endl; + cerr << "\n;************** Method " << Meth->getName() + << " *****************\n"; Method::const_iterator BBI = Meth->begin(); // random iterator for BBs for( ; BBI != Meth->end(); ++BBI) { // traverse BBs in random order - cout << endl ; printLabel( *BBI); cout << ": "; + cerr << "\n"; printLabel( *BBI); cerr << ": "; // get the iterator for machine instructions MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec(); @@ -992,8 +974,8 @@ void PhyRegAlloc::printMachineCode() MachineInstr *const MInst = *MInstIterator; - cout << endl << "\t"; - cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString; + cerr << "\n\t"; + cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString; //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) { @@ -1009,41 +991,39 @@ void PhyRegAlloc::printMachineCode() const Value *const Val = Op.getVRegValue () ; // ****this code is temporary till NULL Values are fixed if( ! Val ) { - cout << "\t<*NULL*>"; + cerr << "\t<*NULL*>"; continue; } // if a label or a constant - if( (Val->getValueType() == Value::BasicBlockVal) ) { - - cout << "\t"; printLabel( Op.getVRegValue () ); - } - else { + if(isa(Val) { + cerr << "\t"; printLabel( Op.getVRegValue () ); + } else { // else it must be a register value const int RegNum = Op.getAllocatedRegNum(); - cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum ); + cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum ); if (Val->hasName() ) - cout << "(" << Val->getName() << ")"; + cerr << "(" << Val->getName() << ")"; else - cout << "(" << Val << ")"; + cerr << "(" << Val << ")"; if( Op.opIsDef() ) - cout << "*"; + cerr << "*"; const LiveRange *LROfVal = LRI.getLiveRangeForValue(Val); if( LROfVal ) if( LROfVal->hasSpillOffset() ) - cout << "$"; + cerr << "$"; } } else if(Op.getOperandType() == MachineOperand::MO_MachineRegister) { - cout << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum()); + cerr << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum()); } else - cout << "\t" << Op; // use dump field + cerr << "\t" << Op; // use dump field } @@ -1051,23 +1031,22 @@ void PhyRegAlloc::printMachineCode() unsigned NumOfImpRefs = MInst->getNumImplicitRefs(); if( NumOfImpRefs > 0 ) { - cout << "\tImplicit:"; + cerr << "\tImplicit:"; for(unsigned z=0; z < NumOfImpRefs; z++) { printValue( MInst->getImplicitRef(z) ); - cout << "\t"; + cerr << "\t"; } } } // for all machine instructions - - cout << endl; + cerr << "\n"; } // for all BBs - cout << endl; + cerr << "\n"; } @@ -1125,9 +1104,9 @@ void PhyRegAlloc::colorIncomingArgs() assert( FirstMI && "No machine instruction in entry BB"); AddedInstrns *AI = AddedInstrMap[ FirstMI ]; - if ( !AI ) { + if (!AI) { AI = new AddedInstrns(); - AddedInstrMap[ FirstMI ] = AI; + AddedInstrMap[FirstMI] = AI; } MRI.colorMethodArgs(Meth, LRI, AI ); @@ -1137,12 +1116,11 @@ void PhyRegAlloc::colorIncomingArgs() //---------------------------------------------------------------------------- // Used to generate a label for a basic block //---------------------------------------------------------------------------- -void PhyRegAlloc::printLabel(const Value *const Val) -{ - if( Val->hasName() ) - cout << Val->getName(); +void PhyRegAlloc::printLabel(const Value *const Val) { + if (Val->hasName()) + cerr << Val->getName(); else - cout << "Label" << Val; + cerr << "Label" << Val; } @@ -1155,7 +1133,7 @@ void PhyRegAlloc::printLabel(const Value *const Val) void PhyRegAlloc::markUnusableSugColors() { - if(DEBUG_RA ) cout << "\nmarking unusable suggested colors ..." << endl; + if(DEBUG_RA ) cerr << "\nmarking unusable suggested colors ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin(); @@ -1193,22 +1171,18 @@ void PhyRegAlloc::markUnusableSugColors() void PhyRegAlloc::allocateStackSpace4SpilledLRs() { - if(DEBUG_RA ) cout << "\nsetting LR stack offsets ..." << endl; + if(DEBUG_RA ) cerr << "\nsetting LR stack offsets ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin(); LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end(); for( ; HMI != HMIEnd ; ++HMI ) { - if( (*HMI).first ) { - LiveRange *L = (*HMI).second; // get the LiveRange - if(L) - if( ! L->hasColor() ) - - // NOTE: ** allocating the size of long Type ** - L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, - Type::LongTy)); - + if(HMI->first && HMI->second) { + LiveRange *L = HMI->second; // get the LiveRange + if( ! L->hasColor() ) + // NOTE: ** allocating the size of long Type ** + L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy)); } } // for all LR's in hash map } diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.h b/lib/CodeGen/RegAlloc/PhyRegAlloc.h index 9d34557b01..6871b2d28a 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.h +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.h @@ -1,4 +1,4 @@ -/* Title: PhyRegAlloc.h +/* Title: PhyRegAlloc.h -*- C++ -*- Author: Ruchira Sasanka Date: Aug 20, 01 Purpose: This is the main entry point for register allocation. @@ -54,13 +54,11 @@ class AddedInstrns { public: - deque InstrnsBefore; // Added insts BEFORE an existing inst - deque InstrnsAfter; // Added insts AFTER an existing inst - - AddedInstrns() : InstrnsBefore(), InstrnsAfter() { } + std::deque InstrnsBefore;// Added insts BEFORE an existing inst + std::deque InstrnsAfter; // Added insts AFTER an existing inst }; -typedef hash_map AddedInstrMapType; +typedef std::hash_map AddedInstrMapType; @@ -74,7 +72,7 @@ typedef hash_map AddedInstrMapType; class PhyRegAlloc: public NonCopyable { - vector RegClassList ; // vector of register classes + std::vector RegClassList; // vector of register classes const TargetMachine &TM; // target machine const Method* Meth; // name of the method we work on MachineCodeForMethod& mcInfo; // descriptor for method's native code @@ -115,8 +113,7 @@ class PhyRegAlloc: public NonCopyable const BasicBlock *BB, const unsigned OpNum); - inline void constructLiveRanges() - { LRI.constructLiveRanges(); } + inline void constructLiveRanges() { LRI.constructLiveRanges(); } void colorIncomingArgs(); void colorCallRetArgs(); @@ -141,12 +138,9 @@ class PhyRegAlloc: public NonCopyable void addInterf4PseudoInstr(const MachineInstr *MInst); - public: - PhyRegAlloc(Method *const M, const TargetMachine& TM, MethodLiveVarInfo *const Lvi); - ~PhyRegAlloc(); // main method called for allocating registers diff --git a/lib/CodeGen/RegAlloc/RegClass.cpp b/lib/CodeGen/RegAlloc/RegClass.cpp index 3918871d69..8ba6a15ad1 100644 --- a/lib/CodeGen/RegAlloc/RegClass.cpp +++ b/lib/CodeGen/RegAlloc/RegClass.cpp @@ -1,5 +1,6 @@ #include "llvm/CodeGen/RegClass.h" - +#include +using std::cerr; //---------------------------------------------------------------------------- // This constructor inits IG. The actual matrix is created by a call to @@ -11,7 +12,7 @@ RegClass::RegClass(const Method *const M, : Meth(M), MRC(Mrc), RegClassID( Mrc->getRegClassID() ), IG(this), IGNodeStack(), ReservedColorList(RCL) { if( DEBUG_RA) - cout << "Created Reg Class: " << RegClassID << endl; + cerr << "Created Reg Class: " << RegClassID << "\n"; IsColorUsedArr = new bool[ Mrc->getNumOfAllRegs() ]; } @@ -23,7 +24,7 @@ RegClass::RegClass(const Method *const M, //---------------------------------------------------------------------------- void RegClass::colorAllRegs() { - if(DEBUG_RA) cout << "Coloring IG of reg class " << RegClassID << " ...\n"; + if(DEBUG_RA) cerr << "Coloring IG of reg class " << RegClassID << " ...\n"; // pre-color IGNodes pushAllIGNodes(); // push all IG Nodes @@ -57,9 +58,9 @@ void RegClass::pushAllIGNodes() bool PushedAll = pushUnconstrainedIGNodes(); if( DEBUG_RA) { - cout << " Puhsed all-unconstrained IGNodes. "; - if( PushedAll ) cout << " No constrained nodes left."; - cout << endl; + cerr << " Puhsed all-unconstrained IGNodes. "; + if( PushedAll ) cerr << " No constrained nodes left."; + cerr << "\n"; } if( PushedAll ) // if NO constrained nodes left @@ -129,8 +130,8 @@ bool RegClass::pushUnconstrainedIGNodes() IGNode->pushOnStack(); // set OnStack and dec deg of neighs if (DEBUG_RA > 1) { - cout << " pushed un-constrained IGNode " << IGNode->getIndex() ; - cout << " on to stack" << endl; + cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ; + cerr << " on to stack\n"; } } else pushedall = false; // we didn't push all live ranges @@ -215,16 +216,16 @@ void RegClass::colorIGNode(IGNode *const Node) } else { if( DEBUG_RA ) { - cout << " Node " << Node->getIndex(); - cout << " already colored with color " << Node->getColor() << endl; + cerr << " Node " << Node->getIndex(); + cerr << " already colored with color " << Node->getColor() << "\n"; } } if( !Node->hasColor() ) { if( DEBUG_RA ) { - cout << " Node " << Node->getIndex(); - cout << " - could not find a color (needs spilling)" << endl; + cerr << " Node " << Node->getIndex(); + cerr << " - could not find a color (needs spilling)\n"; } } diff --git a/lib/CodeGen/RegAlloc/RegClass.h b/lib/CodeGen/RegAlloc/RegClass.h index d6cbaf892b..fe25986f40 100644 --- a/lib/CodeGen/RegAlloc/RegClass.h +++ b/lib/CodeGen/RegAlloc/RegClass.h @@ -13,8 +13,9 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MachineRegInfo.h" #include +#include -typedef vector ReservedColorListType; +typedef std::vector ReservedColorListType; //----------------------------------------------------------------------------- @@ -46,7 +47,7 @@ class RegClass InterferenceGraph IG; // Interference graph - constructed by // buildInterferenceGraph - stack IGNodeStack; // the stack used for coloring + std::stack IGNodeStack; // the stack used for coloring const ReservedColorListType *const ReservedColorList; // @@ -117,21 +118,14 @@ class RegClass inline void printIGNodeList() const { - cerr << "IG Nodes for Register Class " << RegClassID << ":" << endl; + std::cerr << "IG Nodes for Register Class " << RegClassID << ":" << "\n"; IG.printIGNodeList(); } inline void printIG() { - cerr << "IG for Register Class " << RegClassID << ":" << endl; + std::cerr << "IG for Register Class " << RegClassID << ":" << "\n"; IG.printIG(); } - }; - - - - - - #endif diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index c48ec92b3e..d92764e49a 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -19,6 +19,10 @@ #include // For fmod #include #include +#include +using std::vector; +using std::cout; +using std::cerr; cl::Flag QuietMode ("quiet" , "Do not emit any non-program output"); cl::Alias QuietModeA("q" , "Alias for -quiet", cl::NoFlags, QuietMode); @@ -35,7 +39,7 @@ CachedWriter CW; // Object to accelerate printing of LLVM static cl::Flag ProfileStructureFields("profilestructfields", "Profile Structure Field Accesses"); #include -static map > FieldAccessCounts; +static std::map > FieldAccessCounts; #endif sigjmp_buf SignalRecoverBuffer; @@ -91,14 +95,14 @@ static GenericValue getOperandValue(Value *V, ExecutionContext &SF) { case Type::PointerTyID: if (isa(CPV)) { Result.PointerVal = 0; - } else if (ConstantPointerRef *CPR =dyn_cast(CPV)) { + } else if (isa(CPV)) { assert(0 && "Not implemented!"); } else { assert(0 && "Unknown constant pointer type!"); } break; default: - cout << "ERROR: Constant unimp for type: " << CPV->getType() << endl; + cout << "ERROR: Constant unimp for type: " << CPV->getType() << "\n"; } return Result; } else if (GlobalValue *GV = dyn_cast(V)) { @@ -134,7 +138,7 @@ static void printOperandInfo(Value *V, ExecutionContext &SF) { cout << ( Cur >= 160? char((Cur>>4)+'A'-10) : char((Cur>>4) + '0')) << ((Cur&15) >= 10? char((Cur&15)+'A'-10) : char((Cur&15) + '0')); } - cout << endl; + cout << "\n"; } } @@ -143,7 +147,7 @@ static void printOperandInfo(Value *V, ExecutionContext &SF) { static void SetValue(Value *V, GenericValue Val, ExecutionContext &SF) { unsigned TyP = V->getType()->getUniqueID(); // TypePlane for value - //cout << "Setting value: " << &SF.Values[TyP][getOperandSlot(V)] << endl; + //cout << "Setting value: " << &SF.Values[TyP][getOperandSlot(V)] << "\n"; SF.Values[TyP][getOperandSlot(V)] = Val; } @@ -217,7 +221,7 @@ static void InitializeMemory(Constant *Init, char *Addr) { return; default: - CW << "Bad Type: " << Init->getType() << endl; + CW << "Bad Type: " << Init->getType() << "\n"; assert(0 && "Unknown constant type to initialize memory with!"); } } @@ -277,7 +281,7 @@ static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(+, Double); IMPLEMENT_BINARY_OPERATOR(+, Pointer); default: - cout << "Unhandled type for Add instruction: " << Ty << endl; + cout << "Unhandled type for Add instruction: " << Ty << "\n"; } return Dest; } @@ -298,7 +302,7 @@ static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(-, Double); IMPLEMENT_BINARY_OPERATOR(-, Pointer); default: - cout << "Unhandled type for Sub instruction: " << Ty << endl; + cout << "Unhandled type for Sub instruction: " << Ty << "\n"; } return Dest; } @@ -319,7 +323,7 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(*, Double); IMPLEMENT_BINARY_OPERATOR(*, Pointer); default: - cout << "Unhandled type for Mul instruction: " << Ty << endl; + cout << "Unhandled type for Mul instruction: " << Ty << "\n"; } return Dest; } @@ -340,7 +344,7 @@ static GenericValue executeDivInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(/, Double); IMPLEMENT_BINARY_OPERATOR(/, Pointer); default: - cout << "Unhandled type for Div instruction: " << Ty << endl; + cout << "Unhandled type for Div instruction: " << Ty << "\n"; } return Dest; } @@ -365,7 +369,7 @@ static GenericValue executeRemInst(GenericValue Src1, GenericValue Src2, Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal); break; default: - cout << "Unhandled type for Rem instruction: " << Ty << endl; + cout << "Unhandled type for Rem instruction: " << Ty << "\n"; } return Dest; } @@ -384,7 +388,7 @@ static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(&, Long); IMPLEMENT_BINARY_OPERATOR(&, Pointer); default: - cout << "Unhandled type for And instruction: " << Ty << endl; + cout << "Unhandled type for And instruction: " << Ty << "\n"; } return Dest; } @@ -404,7 +408,7 @@ static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(|, Long); IMPLEMENT_BINARY_OPERATOR(|, Pointer); default: - cout << "Unhandled type for Or instruction: " << Ty << endl; + cout << "Unhandled type for Or instruction: " << Ty << "\n"; } return Dest; } @@ -424,7 +428,7 @@ static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(^, Long); IMPLEMENT_BINARY_OPERATOR(^, Pointer); default: - cout << "Unhandled type for Xor instruction: " << Ty << endl; + cout << "Unhandled type for Xor instruction: " << Ty << "\n"; } return Dest; } @@ -449,7 +453,7 @@ static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(==, Double); IMPLEMENT_SETCC(==, Pointer); default: - cout << "Unhandled type for SetEQ instruction: " << Ty << endl; + cout << "Unhandled type for SetEQ instruction: " << Ty << "\n"; } return Dest; } @@ -471,7 +475,7 @@ static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(!=, Pointer); default: - cout << "Unhandled type for SetNE instruction: " << Ty << endl; + cout << "Unhandled type for SetNE instruction: " << Ty << "\n"; } return Dest; } @@ -492,7 +496,7 @@ static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(<=, Double); IMPLEMENT_SETCC(<=, Pointer); default: - cout << "Unhandled type for SetLE instruction: " << Ty << endl; + cout << "Unhandled type for SetLE instruction: " << Ty << "\n"; } return Dest; } @@ -513,7 +517,7 @@ static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(>=, Double); IMPLEMENT_SETCC(>=, Pointer); default: - cout << "Unhandled type for SetGE instruction: " << Ty << endl; + cout << "Unhandled type for SetGE instruction: " << Ty << "\n"; } return Dest; } @@ -534,7 +538,7 @@ static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(<, Double); IMPLEMENT_SETCC(<, Pointer); default: - cout << "Unhandled type for SetLT instruction: " << Ty << endl; + cout << "Unhandled type for SetLT instruction: " << Ty << "\n"; } return Dest; } @@ -555,7 +559,7 @@ static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(>, Double); IMPLEMENT_SETCC(>, Pointer); default: - cout << "Unhandled type for SetGT instruction: " << Ty << endl; + cout << "Unhandled type for SetGT instruction: " << Ty << "\n"; } return Dest; } @@ -598,7 +602,7 @@ static void PerformExitStuff() { // Print out structure field accounting information... if (!FieldAccessCounts.empty()) { CW << "Profile Field Access Counts:\n"; - map >::iterator + std::map >::iterator I = FieldAccessCounts.begin(), E = FieldAccessCounts.end(); for (; I != E; ++I) { vector &OfC = I->second; @@ -613,9 +617,9 @@ static void PerformExitStuff() { if (i) CW << ", "; CW << OfC[i]; } - CW << endl; + CW << "\n"; } - CW << endl; + CW << "\n"; CW << "Profile Field Access Percentages:\n"; cout.precision(3); @@ -630,9 +634,9 @@ static void PerformExitStuff() { if (i) CW << ", "; CW << double(OfC[i])/Sum; } - CW << endl; + CW << "\n"; } - CW << endl; + CW << "\n"; FieldAccessCounts.clear(); } @@ -673,7 +677,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) { CW << "Method " << M->getType() << " \"" << M->getName() << "\" returned "; print(RetTy, Result); - cout << endl; + cout << "\n"; } if (RetTy->isIntegral()) @@ -701,7 +705,7 @@ void Interpreter::executeRetInst(ReturnInst *I, ExecutionContext &SF) { CW << "Method " << M->getType() << " \"" << M->getName() << "\" returned "; print(RetTy, Result); - cout << endl; + cout << "\n"; } } @@ -930,7 +934,7 @@ static void executeShlInst(ShiftInst *I, ExecutionContext &SF) { IMPLEMENT_SHIFT(<<, ULong); IMPLEMENT_SHIFT(<<, Long); default: - cout << "Unhandled type for Shl instruction: " << Ty << endl; + cout << "Unhandled type for Shl instruction: " << Ty << "\n"; } SetValue(I, Dest, SF); } @@ -951,7 +955,7 @@ static void executeShrInst(ShiftInst *I, ExecutionContext &SF) { IMPLEMENT_SHIFT(>>, ULong); IMPLEMENT_SHIFT(>>, Long); default: - cout << "Unhandled type for Shr instruction: " << Ty << endl; + cout << "Unhandled type for Shr instruction: " << Ty << "\n"; } SetValue(I, Dest, SF); } @@ -977,7 +981,7 @@ static void executeShrInst(ShiftInst *I, ExecutionContext &SF) { IMPLEMENT_CAST(DESTTY, DESTCTY, Double) #define IMPLEMENT_CAST_CASE_END() \ - default: cout << "Unhandled cast: " << SrcTy << " to " << Ty << endl; \ + default: cout << "Unhandled cast: " << SrcTy << " to " << Ty << "\n"; \ break; \ } \ break @@ -1006,7 +1010,7 @@ static void executeCastInst(CastInst *I, ExecutionContext &SF) { IMPLEMENT_CAST_CASE(Float , (float)); IMPLEMENT_CAST_CASE(Double , (double)); default: - cout << "Unhandled dest type for cast instruction: " << Ty << endl; + cout << "Unhandled dest type for cast instruction: " << Ty << "\n"; } SetValue(I, Dest, SF); } @@ -1060,7 +1064,6 @@ void Interpreter::callMethod(Method *M, const vector &ArgVals) { if (RetTy != Type::VoidTy) { if (!ECStack.empty() && ECStack.back().Caller) { ExecutionContext &SF = ECStack.back(); - CallInst *Caller = SF.Caller; SetValue(SF.Caller, Result, SF); SF.Caller = 0; // We returned from the call... @@ -1069,7 +1072,7 @@ void Interpreter::callMethod(Method *M, const vector &ArgVals) { CW << "Method " << M->getType() << " \"" << M->getName() << "\" returned "; print(RetTy, Result); - cout << endl; + cout << "\n"; if (RetTy->isIntegral()) ExitCode = Result.SByteVal; // Capture the exit code of the program @@ -1290,8 +1293,8 @@ void Interpreter::printValue(const Type *Ty, GenericValue V) { case Type::UShortTyID: cout << V.UShortVal; break; case Type::IntTyID: cout << V.IntVal; break; case Type::UIntTyID: cout << V.UIntVal; break; - case Type::LongTyID: cout << V.LongVal; break; - case Type::ULongTyID: cout << V.ULongVal; break; + case Type::LongTyID: cout << (long)V.LongVal; break; + case Type::ULongTyID: cout << (unsigned long)V.ULongVal; break; case Type::FloatTyID: cout << V.FloatVal; break; case Type::DoubleTyID: cout << V.DoubleVal; break; case Type::PointerTyID:cout << (void*)V.PointerVal; break; @@ -1306,31 +1309,31 @@ void Interpreter::print(const Type *Ty, GenericValue V) { printValue(Ty, V); } -void Interpreter::print(const string &Name) { +void Interpreter::print(const std::string &Name) { Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name)); if (!PickedVal) return; if (const Method *M = dyn_cast(PickedVal)) { CW << M; // Print the method } else if (const Type *Ty = dyn_cast(PickedVal)) { - CW << "type %" << Name << " = " << Ty->getDescription() << endl; + CW << "type %" << Name << " = " << Ty->getDescription() << "\n"; } else if (const BasicBlock *BB = dyn_cast(PickedVal)) { CW << BB; // Print the basic block } else { // Otherwise there should be an annotation for the slot# print(PickedVal->getType(), getOperandValue(PickedVal, ECStack[CurFrame])); - cout << endl; + cout << "\n"; } } -void Interpreter::infoValue(const string &Name) { +void Interpreter::infoValue(const std::string &Name) { Value *PickedVal = ChooseOneOption(Name, LookupMatchingNames(Name)); if (!PickedVal) return; cout << "Value: "; print(PickedVal->getType(), getOperandValue(PickedVal, ECStack[CurFrame])); - cout << endl; + cout << "\n"; printOperandInfo(PickedVal, ECStack[CurFrame]); } @@ -1353,7 +1356,7 @@ void Interpreter::printStackFrame(int FrameNo = -1) { printValue(Args[i]->getType(), getOperandValue(Args[i], ECStack[FrameNo])); } - cout << ")" << endl; + cout << ")\n"; CW << *(ECStack[FrameNo].CurInst-(FrameNo != int(ECStack.size()-1))); } diff --git a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h index f6a27265f0..12717ec48e 100644 --- a/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h +++ b/lib/ExecutionEngine/Interpreter/ExecutionAnnotations.h @@ -23,7 +23,7 @@ static AnnotationID MethodInfoAID( struct MethodInfo : public Annotation { MethodInfo(Method *M); - vector NumPlaneElements; + std::vector NumPlaneElements; // Create - Factory function to allow MethodInfo annotations to be diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index a54a6f1ced..bcff5e5795 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -13,26 +13,29 @@ #include "llvm/DerivedTypes.h" #include #include +#include #include #include #include +using std::vector; +using std::cout; typedef GenericValue (*ExFunc)(MethodType *, const vector &); -static map Functions; -static map FuncNames; +static std::map Functions; +static std::map FuncNames; static Interpreter *TheInterpreter; // getCurrentExecutablePath() - Return the directory that the lli executable // lives in. // -string Interpreter::getCurrentExecutablePath() const { +std::string Interpreter::getCurrentExecutablePath() const { Dl_info Info; if (dladdr(&TheInterpreter, &Info) == 0) return ""; - string LinkAddr(Info.dli_fname); + std::string LinkAddr(Info.dli_fname); unsigned SlashPos = LinkAddr.rfind('/'); - if (SlashPos != string::npos) + if (SlashPos != std::string::npos) LinkAddr.resize(SlashPos); // Trim the executable name off... return LinkAddr; @@ -65,7 +68,7 @@ static char getTypeID(const Type *Ty) { static ExFunc lookupMethod(const Method *M) { // Function not found, look it up... start by figuring out what the // composite function name should be. - string ExtName = "lle_"; + std::string ExtName = "lle_"; const MethodType *MT = M->getMethodType(); for (unsigned i = 0; const Type *Ty = MT->getContainedType(i); ++i) ExtName += getTypeID(Ty); @@ -80,7 +83,7 @@ static ExFunc lookupMethod(const Method *M) { if (FnPtr == 0) // Try calling a generic function... if it exists... FnPtr = (ExFunc)dlsym(RTLD_DEFAULT, ("lle_X_"+M->getName()).c_str()); if (FnPtr != 0) - Functions.insert(make_pair(M, FnPtr)); // Cache for later + Functions.insert(std::make_pair(M, FnPtr)); // Cache for later return FnPtr; } @@ -90,11 +93,11 @@ GenericValue Interpreter::callExternalMethod(Method *M, // Do a lookup to see if the method is in our cache... this should just be a // defered annotation! - map::iterator FI = Functions.find(M); + std::map::iterator FI = Functions.find(M); ExFunc Fn = (FI == Functions.end()) ? lookupMethod(M) : FI->second; if (Fn == 0) { cout << "Tried to execute an unknown external method: " - << M->getType()->getDescription() << " " << M->getName() << endl; + << M->getType()->getDescription() << " " << M->getName() << "\n"; return GenericValue(); } @@ -177,13 +180,13 @@ GenericValue lle_Vb_putchar(MethodType *M, const vector &Args) { // int "putchar"(int) GenericValue lle_ii_putchar(MethodType *M, const vector &Args) { - cout << ((char)Args[0].IntVal) << flush; + cout << ((char)Args[0].IntVal) << std::flush; return Args[0]; } // void "putchar"(ubyte) GenericValue lle_VB_putchar(MethodType *M, const vector &Args) { - cout << Args[0].SByteVal << flush; + cout << Args[0].SByteVal << std::flush; return Args[0]; } diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h index 44b382bd9f..ffe1001597 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -41,7 +41,7 @@ union GenericValue { PointerTy PointerVal; }; -typedef vector ValuePlaneTy; +typedef std::vector ValuePlaneTy; // ExecutionContext struct - This struct represents one stack frame currently // executing. @@ -51,7 +51,7 @@ struct ExecutionContext { BasicBlock *CurBB; // The currently executing BB BasicBlock::iterator CurInst; // The next instruction to execute MethodInfo *MethInfo; // The MethInfo annotation for the method - vector Values; // ValuePlanes for each type + std::vector Values;// ValuePlanes for each type BasicBlock *PrevBB; // The previous BB or null if in first BB CallInst *Caller; // Holds the call that called subframes. @@ -69,7 +69,7 @@ class Interpreter { // The runtime stack of executing code. The top of the stack is the current // method record. - vector ECStack; + std::vector ECStack; public: Interpreter(); @@ -86,24 +86,24 @@ public: void handleUserInput(); // User Interation Methods... - void loadModule(const string &Filename); + void loadModule(const std::string &Filename); bool flushModule(); - bool callMethod(const string &Name); // return true on failure - void setBreakpoint(const string &Name); - void infoValue(const string &Name); - void print(const string &Name); + bool callMethod(const std::string &Name); // return true on failure + void setBreakpoint(const std::string &Name); + void infoValue(const std::string &Name); + void print(const std::string &Name); static void print(const Type *Ty, GenericValue V); static void printValue(const Type *Ty, GenericValue V); // Hack until we can parse command line args... - bool callMainMethod(const string &MainName, - const vector &InputFilename); + bool callMainMethod(const std::string &MainName, + const std::vector &InputFilename); void list(); // Do the 'list' command void printStackTrace(); // Do the 'backtrace' command // Code execution methods... - void callMethod (Method *Meth, const vector &ArgVals); + void callMethod(Method *Meth, const std::vector &ArgVals); bool executeInstruction(); // Execute one instruction... void stepInstruction(); // Do the 'step' command @@ -117,7 +117,7 @@ public: void executeBrInst(BranchInst *I, ExecutionContext &SF); void executeAllocInst(AllocationInst *I, ExecutionContext &SF); GenericValue callExternalMethod(Method *Meth, - const vector &ArgVals); + const std::vector &ArgVals); void exitCalled(GenericValue GV); // getCurrentMethod - Return the currently executing method @@ -134,7 +134,7 @@ private: // Helper functions // getCurrentExecutablePath() - Return the directory that the lli executable // lives in. // - string getCurrentExecutablePath() const; + std::string getCurrentExecutablePath() const; // printCurrentInstruction - Print out the instruction that the virtual PC is // at, or fail silently if no program is running. @@ -151,13 +151,14 @@ private: // Helper functions // matches to that name. This is obviously slow, and should only be used for // user interaction. // - vector LookupMatchingNames(const string &Name); + std::vector LookupMatchingNames(const std::string &Name); // ChooseOneOption - Prompt the user to choose among the specified options to // pick one value. If no options are provided, emit an error. If a single // option is provided, just return that option. // - Value *ChooseOneOption(const string &Name, const vector &Opts); + Value *ChooseOneOption(const std::string &Name, + const std::vector &Opts); void initializeExecutionEngine(); diff --git a/lib/ExecutionEngine/Interpreter/Support.cpp b/lib/ExecutionEngine/Interpreter/Support.cpp index a619304c62..ca89ae3333 100644 --- a/lib/ExecutionEngine/Interpreter/Support.cpp +++ b/lib/ExecutionEngine/Interpreter/Support.cpp @@ -7,13 +7,15 @@ #include "Interpreter.h" #include "llvm/SymbolTable.h" #include "llvm/Assembly/Writer.h" +#include +using std::cout; //===----------------------------------------------------------------------===// // // LookupMatchingNames helper - Search a symbol table for values matching Name. // -static inline void LookupMatchingNames(const string &Name, SymTabValue &STV, - vector &Results) { +static inline void LookupMatchingNames(const std::string &Name,SymTabValue &STV, + std::vector &Results) { SymbolTable *SymTab = STV.getSymbolTable(); if (SymTab == 0) return; // No symbolic values :( @@ -34,8 +36,8 @@ static inline void LookupMatchingNames(const string &Name, SymTabValue &STV, // matches to that name. This is obviously slow, and should only be used for // user interaction. // -vector Interpreter::LookupMatchingNames(const string &Name) { - vector Results; +std::vector Interpreter::LookupMatchingNames(const std::string &Name) { + std::vector Results; Method *CurMeth = getCurrentMethod(); if (CurMeth) ::LookupMatchingNames(Name, *CurMeth, Results); @@ -47,8 +49,8 @@ vector Interpreter::LookupMatchingNames(const string &Name) { // pick one value. If no options are provided, emit an error. If a single // option is provided, just return that option. // -Value *Interpreter::ChooseOneOption(const string &Name, - const vector &Opts) { +Value *Interpreter::ChooseOneOption(const std::string &Name, + const std::vector &Opts) { switch (Opts.size()) { case 1: return Opts[0]; case 0: @@ -61,16 +63,16 @@ Value *Interpreter::ChooseOneOption(const string &Name, cout << " 0. Cancel operation\n"; for (unsigned i = 0; i < Opts.size(); ++i) { cout << " " << (i+1) << "."; - WriteAsOperand(cout, Opts[i]) << endl; + WriteAsOperand(cout, Opts[i]) << "\n"; } unsigned Option; do { - cout << "lli> " << flush; - cin >> Option; + cout << "lli> " << std::flush; + std::cin >> Option; if (Option > Opts.size()) cout << "Invalid selection: Please choose from 0 to " << Opts.size() - << endl; + << "\n"; } while (Option > Opts.size()); if (Option == 0) return 0; diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp index 179b97d277..1cd8b08c1f 100644 --- a/lib/ExecutionEngine/Interpreter/UserInput.cpp +++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp @@ -10,6 +10,9 @@ #include "llvm/DerivedTypes.h" #include "llvm/Transforms/Linker.h" #include +using std::string; +using std::cout; +using std::cin; enum CommandID { Quit, Help, // Basics @@ -69,14 +72,14 @@ void Interpreter::handleUserInput() { bool UserQuit = false; // Sort the table... - sort(CommandTable, CommandTableEnd); + std::sort(CommandTable, CommandTableEnd); // Print the instruction that we are stopped at... printCurrentInstruction(); do { string Command; - cout << "lli> " << flush; + cout << "lli> " << std::flush; cin >> Command; CommandTableElement *E = find(CommandTable, CommandTableEnd, Command); @@ -164,11 +167,11 @@ void Interpreter::loadModule(const string &Filename) { if (Module *SupportLib = ParseBytecodeFile(RuntimeLib, &ErrorMsg)) { if (LinkModules(CurMod, SupportLib, &ErrorMsg)) - cerr << "Error Linking runtime library into current module: " - << ErrorMsg << endl; + std::cerr << "Error Linking runtime library into current module: " + << ErrorMsg << "\n"; } else { - cerr << "Error loading runtime library '"+RuntimeLib+"': " - << ErrorMsg << "\n"; + std::cerr << "Error loading runtime library '"+RuntimeLib+"': " + << ErrorMsg << "\n"; } } @@ -208,7 +211,7 @@ void Interpreter::setBreakpoint(const string &Name) { // callMethod - Enter the specified method... // bool Interpreter::callMethod(const string &Name) { - vector Options = LookupMatchingNames(Name); + std::vector Options = LookupMatchingNames(Name); for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches... if (!isa(Options[i])) { @@ -223,7 +226,7 @@ bool Interpreter::callMethod(const string &Name) { Method *M = cast(PickedMeth); - vector Args; + std::vector Args; // TODO, get args from user... callMethod(M, Args); // Start executing it... @@ -234,7 +237,7 @@ bool Interpreter::callMethod(const string &Name) { return false; } -static void *CreateArgv(const vector &InputArgv) { +static void *CreateArgv(const std::vector &InputArgv) { // Pointers are 64 bits... uint64_t *Result = new PointerTy[InputArgv.size()+1]; @@ -255,8 +258,8 @@ static void *CreateArgv(const vector &InputArgv) { // callMethod can parse command line options and stuff for us. // bool Interpreter::callMainMethod(const string &Name, - const vector &InputArgv) { - vector Options = LookupMatchingNames(Name); + const std::vector &InputArgv) { + std::vector Options = LookupMatchingNames(Name); for (unsigned i = 0; i < Options.size(); ++i) { // Remove nonmethod matches... if (!isa(Options[i])) { @@ -272,7 +275,7 @@ bool Interpreter::callMainMethod(const string &Name, Method *M = cast(PickedMeth); const MethodType *MT = M->getMethodType(); - vector Args; + std::vector Args; switch (MT->getParamTypes().size()) { default: cout << "Unknown number of arguments to synthesize for '" << Name << "'!\n"; diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index f04c8a46a3..e1622529c2 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -17,6 +17,10 @@ #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/ConstantVals.h" +#include +using std::cerr; +using std::string; +using std::map; // Error - Simple wrapper function to conditionally assign to E and return true. // This just makes error return conditions a little bit simpler... @@ -70,7 +74,7 @@ static void PrintMap(const map &M) { for (map::const_iterator I = M.begin(), E = M.end(); I != E; ++I) { cerr << " Fr: " << (void*)I->first << " " << I->first - << " To: " << (void*)I->second << " " << I->second << endl; + << " To: " << (void*)I->second << " " << I->second << "\n"; } } @@ -97,15 +101,15 @@ static Value *RemapOperand(const Value *In, map &LocalMap, Constant *Result = 0; if (ConstantArray *CPA = dyn_cast(CPV)) { - const vector &Ops = CPA->getValues(); - vector Operands(Ops.size()); + const std::vector &Ops = CPA->getValues(); + std::vector Operands(Ops.size()); for (unsigned i = 0; i < Ops.size(); ++i) Operands[i] = cast(RemapOperand(Ops[i], LocalMap, GlobalMap)); Result = ConstantArray::get(cast(CPA->getType()), Operands); } else if (ConstantStruct *CPS = dyn_cast(CPV)) { - const vector &Ops = CPS->getValues(); - vector Operands(Ops.size()); + const std::vector &Ops = CPS->getValues(); + std::vector Operands(Ops.size()); for (unsigned i = 0; i < Ops.size(); ++i) Operands[i] = cast(RemapOperand(Ops[i], LocalMap, GlobalMap)); @@ -120,7 +124,7 @@ static Value *RemapOperand(const Value *In, map &LocalMap, } // Cache the mapping in our local map structure... - LocalMap.insert(make_pair(In, CPV)); + LocalMap.insert(std::make_pair(In, CPV)); return Result; } @@ -132,7 +136,7 @@ static Value *RemapOperand(const Value *In, map &LocalMap, PrintMap(*GlobalMap); } - cerr << "Couldn't remap value: " << (void*)In << " " << In << endl; + cerr << "Couldn't remap value: " << (void*)In << " " << In << "\n"; assert(0 && "Couldn't remap value!"); return 0; } @@ -172,7 +176,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, " - Global variables differ in const'ness"); // Okay, everything is cool, remember the mapping... - ValueMap.insert(make_pair(SGV, DGV)); + ValueMap.insert(std::make_pair(SGV, DGV)); } else { // No linking to be performed, simply create an identical version of the // symbol over in the dest module... the initializer will be filled in @@ -186,7 +190,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, Dest->getGlobalList().push_back(DGV); // Make sure to remember this mapping... - ValueMap.insert(make_pair(SGV, DGV)); + ValueMap.insert(std::make_pair(SGV, DGV)); } } return false; @@ -262,7 +266,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src, SM->getName() + "\" - Method is already defined!"); // Otherwise, just remember this mapping... - ValueMap.insert(make_pair(SM, DM)); + ValueMap.insert(std::make_pair(SM, DM)); } else { // Method does not already exist, simply insert an external method // signature identical to SM into the dest module... @@ -273,7 +277,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src, Dest->getMethodList().push_back(DM); // ... and remember this mapping... - ValueMap.insert(make_pair(SM, DM)); + ValueMap.insert(std::make_pair(SM, DM)); } } return false; @@ -300,7 +304,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, Dest->getArgumentList().push_back(DMA); // Add a mapping to our local map - LocalMap.insert(make_pair(SMA, DMA)); + LocalMap.insert(std::make_pair(SMA, DMA)); } // Loop over all of the basic blocks, copying the instructions over... @@ -310,7 +314,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, // Create new basic block and add to mapping and the Dest method... BasicBlock *DBB = new BasicBlock(SBB->getName(), Dest); - LocalMap.insert(make_pair(SBB, DBB)); + LocalMap.insert(std::make_pair(SBB, DBB)); // Loop over all of the instructions in the src basic block, copying them // over. Note that this is broken in a strict sense because the cloned @@ -324,7 +328,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, Instruction *DI = SI->clone(); DI->setName(SI->getName()); DBB->getInstList().push_back(DI); - LocalMap.insert(make_pair(SI, DI)); + LocalMap.insert(std::make_pair(SI, DI)); } } diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp index 65a049d42d..d0d13cda86 100644 --- a/lib/Support/Annotation.cpp +++ b/lib/Support/Annotation.cpp @@ -6,6 +6,10 @@ #include #include "llvm/Annotation.h" +using std::string; +using std::map; +using std::pair; +using std::make_pair; typedef map IDMapType; static unsigned IDCounter = 0; // Unique ID counter diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index f6938169da..549f42c4e3 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -15,7 +15,13 @@ #include #include #include +#include using namespace cl; +using std::map; +using std::pair; +using std::vector; +using std::string; +using std::cerr; // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. @@ -31,7 +37,7 @@ static void AddArgument(const string &ArgName, Option *Opt) { << "' specified more than once!\n"; } else { // Add argument to the argument map! - getOpts().insert(make_pair(ArgName, Opt)); + getOpts().insert(std::make_pair(ArgName, Opt)); } } @@ -59,7 +65,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, break; case ValueOptional: break; default: cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << endl; abort(); + << Handler->getValueExpectedFlag() << "\n"; abort(); } // Run the handler now! @@ -210,7 +216,7 @@ Option::Option(const char *argStr, const char *helpStr, int flags) bool Option::error(string Message, const char *ArgName = 0) { if (ArgName == 0) ArgName = ArgStr; - cerr << "-" << ArgName << " option" << Message << endl; + cerr << "-" << ArgName << " option" << Message << "\n"; return true; } @@ -244,7 +250,7 @@ void Option::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); if (L == 0) return; // Don't print the empty arg like this! cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " - << HelpStr << endl; + << HelpStr << "\n"; } @@ -301,8 +307,8 @@ void EnumBase::processValues(va_list Vals) { while (const char *EnumName = va_arg(Vals, const char *)) { int EnumVal = va_arg(Vals, int); const char *EnumDesc = va_arg(Vals, const char *); - ValueMap.push_back(make_pair(EnumName, // Add value to value map - make_pair(EnumVal, EnumDesc))); + ValueMap.push_back(std::make_pair(EnumName, // Add value to value map + std::make_pair(EnumVal, EnumDesc))); } } @@ -339,7 +345,7 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumValueBase::getOptionWidth() const { unsigned BaseSize = Option::getOptionWidth(); for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+8); + BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+8); return BaseSize; } @@ -354,7 +360,7 @@ void EnumValueBase::printOptionInfo(unsigned GlobalWidth) const { << ValueMap[i].second.second; if (i == 0) cerr << " (default)"; - cerr << endl; + cerr << "\n"; } } @@ -369,7 +375,7 @@ bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumFlagsBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); return BaseSize; } @@ -379,7 +385,7 @@ void EnumFlagsBase::printOptionInfo(unsigned GlobalWidth) const { cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " << ValueMap[i].second.second; if (i == 0) cerr << " (default)"; - cerr << endl; + cerr << "\n"; } } @@ -402,7 +408,7 @@ bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumListBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); return BaseSize; } @@ -414,7 +420,7 @@ void EnumListBase::printOptionInfo(unsigned GlobalWidth) const { for (unsigned i = 0; i < ValueMap.size(); ++i) { unsigned L = std::strlen(ValueMap[i].first); cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " - << ValueMap[i].second.second << endl; + << ValueMap[i].second.second << "\n"; } } @@ -440,15 +446,15 @@ class Help : public Option { virtual bool handleOccurance(const char *ArgName, const string &Arg) { // Copy Options into a vector so we can sort them as we like... vector > Options; - copy(getOpts().begin(), getOpts().end(), back_inserter(Options)); + copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden Options.erase(remove_if(Options.begin(), Options.end(), - ptr_fun(ShowHidden ? isReallyHidden : isHidden)), + std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), Options.end()); // Eliminate duplicate entries in table (from enum flags options, f.e.) - set OptionSet; + std::set OptionSet; for (unsigned i = 0; i < Options.size(); ) if (OptionSet.count(Options[i].second) == 0) OptionSet.insert(Options[i++].second); // Add to set @@ -457,7 +463,7 @@ class Help : public Option { if (ProgramOverview) - cerr << "OVERVIEW:" << ProgramOverview << endl; + cerr << "OVERVIEW:" << ProgramOverview << "\n"; // TODO: Sort options by some criteria cerr << "USAGE: " << ProgramName << " [options]\n\n"; @@ -478,7 +484,7 @@ class Help : public Option { void getMaxArgLen(pair OptPair) { const Option *Opt = OptPair.second; if (Opt->ArgStr[0] == 0) EmptyArg = Opt; // Capture the empty arg if exists - MaxArgLen = max(MaxArgLen, Opt->getOptionWidth()); + MaxArgLen = std::max(MaxArgLen, Opt->getOptionWidth()); } void printOption(pair OptPair) { diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index 528e5abdd3..ea41b6f822 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -18,10 +18,12 @@ #include "llvm/Instruction.h" #include "Support/CommandLine.h" #include "SchedPriorities.h" -#include #include #include - +#include +#include +using std::cerr; +using std::vector; //************************* External Data Types *****************************/ @@ -353,11 +355,11 @@ private: unsigned int totalInstrCount; cycles_t curTime; cycles_t nextEarliestIssueTime; // next cycle we can issue - vector > choicesForSlot; // indexed by slot# + vector > choicesForSlot; // indexed by slot# vector choiceVec; // indexed by node ptr vector numInClass; // indexed by sched class vector nextEarliestStartTime; // indexed by opCode - hash_map delaySlotInfoForBranches; + std::hash_map delaySlotInfoForBranches; // indexed by branch node ptr public: @@ -419,7 +421,7 @@ public: return choiceVec[i]; } - inline hash_set& getChoicesForSlot(unsigned slotNum) { + inline std::hash_set& getChoicesForSlot(unsigned slotNum) { assert(slotNum < nslots); return choicesForSlot[slotNum]; } @@ -495,7 +497,7 @@ public: bool createIfMissing=false) { DelaySlotInfo* dinfo; - hash_map::const_iterator + std::hash_map::const_iterator I = delaySlotInfoForBranches.find(bn); if (I == delaySlotInfoForBranches.end()) { @@ -552,7 +554,7 @@ SchedulingManager::updateEarliestStartTimes(const SchedGraphNode* node, { if (schedInfo.numBubblesAfter(node->getOpCode()) > 0) { // Update next earliest time before which *nothing* can issue. - nextEarliestIssueTime = max(nextEarliestIssueTime, + nextEarliestIssueTime = std::max(nextEarliestIssueTime, curTime + 1 + schedInfo.numBubblesAfter(node->getOpCode())); } @@ -603,7 +605,7 @@ AssignInstructionsToSlots(class SchedulingManager& S, unsigned maxIssue) unsigned numIssued; for (numIssued = 0; numIssued < maxIssue; numIssued++) { - int chosenSlot = -1, chosenNodeIndex = -1; + int chosenSlot = -1; for (unsigned s=startSlot; s < S.nslots; s++) if ((*igroup)[s] == NULL && S.getChoicesForSlot(s).size() == 1) { @@ -877,7 +879,7 @@ FindSlotChoices(SchedulingManager& S, assert(s < S.nslots && "No feasible slot for instruction?"); - highestSlotUsed = max(highestSlotUsed, (int) s); + highestSlotUsed = std::max(highestSlotUsed, (int) s); } assert(highestSlotUsed <= (int) S.nslots-1 && "Invalid slot used?"); @@ -961,7 +963,6 @@ FindSlotChoices(SchedulingManager& S, // Otherwise, just ignore the instruction. for (unsigned i=indexForBreakingNode+1; i < S.getNumChoices(); i++) { - bool foundLowerSlot = false; MachineOpCode opCode = S.getChoice(i)->getOpCode(); for (unsigned int s=startSlot; s < nslotsToUse; s++) if (S.schedInfo.instrCanUseSlot(opCode, s)) @@ -1001,15 +1002,15 @@ ChooseOneGroup(SchedulingManager& S) { for (cycles_t c = firstCycle; c <= S.getTime(); c++) { - cout << " Cycle " << c << " : Scheduled instructions:\n"; + cerr << " Cycle " << (long)c << " : Scheduled instructions:\n"; const InstrGroup* igroup = S.isched.getIGroup(c); for (unsigned int s=0; s < S.nslots; s++) { - cout << " "; + cerr << " "; if ((*igroup)[s] != NULL) - cout << * ((*igroup)[s])->getMachineInstr() << endl; + cerr << * ((*igroup)[s])->getMachineInstr() << "\n"; else - cout << "" << endl; + cerr << "\n"; } } } @@ -1056,9 +1057,9 @@ ForwardListSchedule(SchedulingManager& S) // an instruction can be issued, or the next earliest in which // one will be ready, or to the next cycle, whichever is latest. // - S.updateTime(max(S.getTime() + 1, - max(S.getEarliestIssueTime(), - S.schedPrio.getEarliestReadyTime()))); + S.updateTime(std::max(S.getTime() + 1, + std::max(S.getEarliestIssueTime(), + S.schedPrio.getEarliestReadyTime()))); } } @@ -1499,8 +1500,7 @@ ScheduleInstructionsWithSSA(Method* method, if (SchedDebugLevel >= Sched_PrintSchedGraphs) { - cout << endl << "*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING" - << endl; + cerr << "\n*** SCHEDULING GRAPHS FOR INSTRUCTION SCHEDULING\n"; graphSet.dump(); } @@ -1513,7 +1513,7 @@ ScheduleInstructionsWithSSA(Method* method, const BasicBlock* bb = bbvec[0]; if (SchedDebugLevel >= Sched_PrintSchedTrace) - cout << endl << "*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; + cerr << "\n*** TRACE OF INSTRUCTION SCHEDULING OPERATIONS\n\n"; SchedPriorities schedPrio(method, graph); // expensive! SchedulingManager S(target, graph, schedPrio); @@ -1527,8 +1527,7 @@ ScheduleInstructionsWithSSA(Method* method, if (SchedDebugLevel >= Sched_PrintMachineCode) { - cout << endl - << "*** Machine instructions after INSTRUCTION SCHEDULING" << endl; + cerr << "\n*** Machine instructions after INSTRUCTION SCHEDULING\n"; MachineCodeForMethod::get(method).dump(); } diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index 9e9af5b80d..7c83e1a58c 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -23,10 +23,16 @@ #include "llvm/Target/MachineRegInfo.h" #include "llvm/iOther.h" #include "Support/StringExtras.h" +#include "Support/STLExtras.h" #include -#include #include +#include +#include +using std::vector; +using std::pair; +using std::hash_map; +using std::cerr; //*********************** Internal Data Structures *************************/ @@ -132,7 +138,7 @@ SchedGraphEdge::~SchedGraphEdge() } void SchedGraphEdge::dump(int indent=0) const { - cout << string(indent*2, ' ') << *this; + cerr << std::string(indent*2, ' ') << *this; } @@ -168,7 +174,7 @@ SchedGraphNode::~SchedGraphNode() } void SchedGraphNode::dump(int indent=0) const { - cout << string(indent*2, ' ') << *this; + cerr << std::string(indent*2, ' ') << *this; } @@ -222,21 +228,20 @@ SchedGraph::SchedGraph(const BasicBlock* bb, const TargetMachine& target) { bbVec.push_back(bb); - this->buildGraph(target); + buildGraph(target); } /*dtor*/ SchedGraph::~SchedGraph() { - for (iterator I=begin(); I != end(); ++I) + for (const_iterator I = begin(); I != end(); ++I) { - SchedGraphNode* node = (*I).second; + SchedGraphNode *node = I->second; // for each node, delete its out-edges - for (SchedGraphNode::iterator I = node->beginOutEdges(); - I != node->endOutEdges(); ++I) - delete *I; + std::for_each(node->beginOutEdges(), node->endOutEdges(), + deleter); // then delete the node itself. delete node; @@ -247,24 +252,24 @@ SchedGraph::~SchedGraph() void SchedGraph::dump() const { - cout << " Sched Graph for Basic Blocks: "; + cerr << " Sched Graph for Basic Blocks: "; for (unsigned i=0, N=bbVec.size(); i < N; i++) { - cout << (bbVec[i]->hasName()? bbVec[i]->getName() : "block") + cerr << (bbVec[i]->hasName()? bbVec[i]->getName() : "block") << " (" << bbVec[i] << ")" << ((i == N-1)? "" : ", "); } - cout << endl << endl << " Actual Root nodes : "; + cerr << "\n\n Actual Root nodes : "; for (unsigned i=0, N=graphRoot->outEdges.size(); i < N; i++) - cout << graphRoot->outEdges[i]->getSink()->getNodeId() + cerr << graphRoot->outEdges[i]->getSink()->getNodeId() << ((i == N-1)? "" : ", "); - cout << endl << " Graph Nodes:" << endl; + cerr << "\n Graph Nodes:\n"; for (const_iterator I=begin(); I != end(); ++I) - cout << endl << * (*I).second; + cerr << "\n" << *I->second; - cout << endl; + cerr << "\n"; } @@ -690,7 +695,7 @@ SchedGraph::addNonSSAEdgesForValue(const Instruction* instr, // this operand is a definition or use of value `instr' SchedGraphNode* node = this->getGraphNodeForInstr(mvec[i]); assert(node && "No node for machine instruction in this BB?"); - refVec.push_back(make_pair(node, o)); + refVec.push_back(std::make_pair(node, o)); } } @@ -747,8 +752,8 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target, { int regNum = mop.getMachineRegNum(); if (regNum != target.getRegInfo().getZeroRegNum()) - regToRefVecMap[mop.getMachineRegNum()].push_back(make_pair(node, - i)); + regToRefVecMap[mop.getMachineRegNum()].push_back( + std::make_pair(node, i)); continue; // nothing more to do } @@ -762,7 +767,7 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target, && "Do not expect any other kind of operand to be defined!"); const Instruction* defInstr = cast(mop.getVRegValue()); - valueToDefVecMap[defInstr].push_back(make_pair(node, i)); + valueToDefVecMap[defInstr].push_back(std::make_pair(node, i)); } // @@ -774,7 +779,7 @@ SchedGraph::findDefUseInfoAtInstr(const TargetMachine& target, if (const Instruction* defInstr = dyn_cast_or_null(minstr.getImplicitRef(i))) { - valueToDefVecMap[defInstr].push_back(make_pair(node, -i)); + valueToDefVecMap[defInstr].push_back(std::make_pair(node, -i)); } } @@ -860,7 +865,6 @@ SchedGraph::buildNodesforBB(const TargetMachine& target, void SchedGraph::buildGraph(const TargetMachine& target) { - const MachineInstrInfo& mii = target.getInstrInfo(); const BasicBlock* bb = bbVec[0]; assert(bbVec.size() == 1 && "Only handling a single basic block here"); @@ -966,24 +970,22 @@ SchedGraphSet::SchedGraphSet(const Method* _method, SchedGraphSet::~SchedGraphSet() { // delete all the graphs - for (iterator I=begin(); I != end(); ++I) - delete (*I).second; + for (const_iterator I = begin(); I != end(); ++I) + delete I->second; } void SchedGraphSet::dump() const { - cout << "======== Sched graphs for method `" - << (method->hasName()? method->getName() : "???") - << "' ========" << endl << endl; + cerr << "======== Sched graphs for method `" << method->getName() + << "' ========\n\n"; for (const_iterator I=begin(); I != end(); ++I) - (*I).second->dump(); + I->second->dump(); - cout << endl << "====== End graphs for method `" - << (method->hasName()? method->getName() : "") - << "' ========" << endl << endl; + cerr << "\n====== End graphs for method `" << method->getName() + << "' ========\n\n"; } @@ -1000,8 +1002,7 @@ SchedGraphSet::buildGraphsForMethod(const Method *method, -ostream& -operator<<(ostream& os, const SchedGraphEdge& edge) +std::ostream &operator<<(std::ostream &os, const SchedGraphEdge& edge) { os << "edge [" << edge.src->getNodeId() << "] -> [" << edge.sink->getNodeId() << "] : "; @@ -1015,33 +1016,30 @@ operator<<(ostream& os, const SchedGraphEdge& edge) default: assert(0); break; } - os << " : delay = " << edge.minDelay << endl; + os << " : delay = " << edge.minDelay << "\n"; return os; } -ostream& -operator<<(ostream& os, const SchedGraphNode& node) +std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node) { - os << string(8, ' ') + os << std::string(8, ' ') << "Node " << node.nodeId << " : " - << "latency = " << node.latency << endl << string(12, ' '); + << "latency = " << node.latency << "\n" << std::string(12, ' '); if (node.getMachineInstr() == NULL) - os << "(Dummy node)" << endl; + os << "(Dummy node)\n"; else { - os << *node.getMachineInstr() << endl << string(12, ' '); - os << node.inEdges.size() << " Incoming Edges:" << endl; + os << *node.getMachineInstr() << "\n" << std::string(12, ' '); + os << node.inEdges.size() << " Incoming Edges:\n"; for (unsigned i=0, N=node.inEdges.size(); i < N; i++) - os << string(16, ' ') << *node.inEdges[i]; + os << std::string(16, ' ') << *node.inEdges[i]; - os << string(12, ' ') << node.outEdges.size() - << " Outgoing Edges:" << endl; + os << std::string(12, ' ') << node.outEdges.size() + << " Outgoing Edges:\n"; for (unsigned i=0, N=node.outEdges.size(); i < N; i++) - { - os << string(16, ' ') << * node.outEdges[i]; - } + os << std::string(16, ' ') << *node.outEdges[i]; } return os; diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h index a4567a5198..2890241d59 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.h +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h @@ -24,7 +24,7 @@ #include "Support/NonCopyable.h" #include "Support/HashExtras.h" #include "Support/GraphTraits.h" -#include +#include class Value; class Instruction; @@ -128,7 +128,7 @@ public: // // Debugging support // - friend ostream& operator<<(ostream& os, const SchedGraphEdge& edge); + friend std::ostream& operator<<(std::ostream& os, const SchedGraphEdge& edge); void dump (int indent=0) const; @@ -144,16 +144,16 @@ private: unsigned int nodeId; const BasicBlock* bb; const MachineInstr* minstr; - vector inEdges; - vector outEdges; + std::vector inEdges; + std::vector outEdges; int origIndexInBB; // original position of machine instr in BB int latency; public: - typedef vector:: iterator iterator; - typedef vector::const_iterator const_iterator; - typedef vector:: reverse_iterator reverse_iterator; - typedef vector::const_reverse_iterator const_reverse_iterator; + typedef std::vector:: iterator iterator; + typedef std::vector::const_iterator const_iterator; + typedef std::vector:: reverse_iterator reverse_iterator; + typedef std::vector::const_reverse_iterator const_reverse_iterator; public: // @@ -186,7 +186,7 @@ public: // // Debugging support // - friend ostream& operator<<(ostream& os, const SchedGraphNode& node); + friend std::ostream& operator<<(std::ostream& os, const SchedGraphNode& node); void dump (int indent=0) const; @@ -214,22 +214,23 @@ private: class SchedGraph : public NonCopyable, - private hash_map + private std::hash_map { private: - vector bbVec; // basic blocks included in the graph + std::vector bbVec; // basic blocks included in the graph SchedGraphNode* graphRoot; // the root and leaf are not inserted SchedGraphNode* graphLeaf; // in the hash_map (see getNumNodes()) + typedef std::hash_map map_base; public: - typedef hash_map::iterator iterator; - typedef hash_map::const_iterator const_iterator; + using map_base::iterator; + using map_base::const_iterator; public: // // Accessor methods // - const vector& getBasicBlocks() const { return bbVec; } + const std::vector& getBasicBlocks() const { return bbVec; } const unsigned int getNumNodes() const { return size()+2; } SchedGraphNode* getRoot() const { return graphRoot; } SchedGraphNode* getLeaf() const { return graphLeaf; } @@ -257,19 +258,9 @@ public: // Unordered iterators. // Return values is pair. // - iterator begin() { - return hash_map::begin(); - } - iterator end() { - return hash_map::end(); - } - const_iterator begin() const { - return hash_map::begin(); - } - const_iterator end() const { - return hash_map::end(); - } - + using map_base::begin; + using map_base::end; + // // Ordered iterators. // Return values is pair. @@ -308,13 +299,13 @@ private: void buildNodesforBB (const TargetMachine& target, const BasicBlock* bb, - vector& memNodeVec, + std::vector& memNod, RegToRefVecMap& regToRefVecMap, ValueToDefVecMap& valueToDefVecMap); void findDefUseInfoAtInstr (const TargetMachine& target, SchedGraphNode* node, - vector& memNodeVec, + std::vector& memNode, RegToRefVecMap& regToRefVecMap, ValueToDefVecMap& valueToDefVecMap); @@ -325,10 +316,10 @@ private: void addCDEdges (const TerminatorInst* term, const TargetMachine& target); - void addMemEdges (const vector& memNodeVec, + void addMemEdges (const std::vector& memNod, const TargetMachine& target); - void addCallCCEdges (const vector& memNodeVec, + void addCallCCEdges (const std::vector& memNod, MachineCodeForBasicBlock& bbMvec, const TargetMachine& target); @@ -347,14 +338,15 @@ private: class SchedGraphSet : public NonCopyable, - private hash_map + private std::hash_map { private: const Method* method; public: - typedef hash_map::iterator iterator; - typedef hash_map::const_iterator const_iterator; + typedef std::hash_map map_base; + using map_base::iterator; + using map_base::const_iterator; public: /*ctor*/ SchedGraphSet (const Method* _method, @@ -372,18 +364,8 @@ public: // // Iterators // - iterator begin() { - return hash_map::begin(); - } - iterator end() { - return hash_map::end(); - } - const_iterator begin() const { - return hash_map::begin(); - } - const_iterator end() const { - return hash_map::end(); - } + using map_base::begin; + using map_base::end; // // Debugging support @@ -544,14 +526,7 @@ template <> struct GraphTraits { }; -//************************ External Functions *****************************/ - - -ostream& operator<<(ostream& os, const SchedGraphEdge& edge); - -ostream& operator<<(ostream& os, const SchedGraphNode& node); - - -/***************************************************************************/ +std::ostream &operator<<(std::ostream& os, const SchedGraphEdge& edge); +std::ostream &operator<<(std::ostream &os, const SchedGraphNode& node); #endif diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp index 1769707238..8cde252115 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp @@ -20,20 +20,17 @@ #include "SchedPriorities.h" #include "Support/PostOrderIterator.h" - +#include +using std::cerr; SchedPriorities::SchedPriorities(const Method* method, const SchedGraph* _graph) : curTime(0), graph(_graph), - methodLiveVarInfo(method), // expensive! - lastUseMap(), - nodeDelayVec(_graph->getNumNodes(),INVALID_LATENCY), //make errors obvious + methodLiveVarInfo(method), // expensive! + nodeDelayVec(_graph->getNumNodes(), INVALID_LATENCY), // make errors obvious earliestForNode(_graph->getNumNodes(), 0), earliestReadyTime(0), - candsAsHeap(), - candsAsSet(), - mcands(), nextToTry(candsAsHeap.begin()) { methodLiveVarInfo.analyze(); @@ -66,7 +63,7 @@ SchedPriorities::computeDelays(const SchedGraph* graph) E != node->endOutEdges(); ++E) { cycles_t sinkDelay = getNodeDelayRef((*E)->getSink()); - nodeDelay = max(nodeDelay, sinkDelay + (*E)->getMinDelay()); + nodeDelay = std::max(nodeDelay, sinkDelay + (*E)->getMinDelay()); } } getNodeDelayRef(node) = nodeDelay; @@ -87,20 +84,37 @@ SchedPriorities::initializeReadyHeap(const SchedGraph* graph) #undef TEST_HEAP_CONVERSION #ifdef TEST_HEAP_CONVERSION - cout << "Before heap conversion:" << endl; + cerr << "Before heap conversion:\n"; copy(candsAsHeap.begin(), candsAsHeap.end(), - ostream_iterator(cout,"\n")); + ostream_iterator(cerr,"\n")); #endif candsAsHeap.makeHeap(); #ifdef TEST_HEAP_CONVERSION - cout << "After heap conversion:" << endl; + cerr << "After heap conversion:\n"; copy(candsAsHeap.begin(), candsAsHeap.end(), - ostream_iterator(cout,"\n")); + ostream_iterator(cerr,"\n")); #endif } +void +SchedPriorities::insertReady(const SchedGraphNode* node) +{ + candsAsHeap.insert(node, nodeDelayVec[node->getNodeId()]); + candsAsSet.insert(node); + mcands.clear(); // ensure reset choices is called before any more choices + earliestReadyTime = std::min(earliestReadyTime, + earliestForNode[node->getNodeId()]); + + if (SchedDebugLevel >= Sched_PrintSchedTrace) + { + cerr << " Cycle " << (long)getTime() << ": " + << " Node " << node->getNodeId() << " is ready; " + << " Delay = " << (long)getNodeDelayRef(node) << "; Instruction: \n"; + cerr << " " << *node->getMachineInstr() << "\n"; + } +} void SchedPriorities::issuedReadyNodeAt(cycles_t curTime, @@ -116,7 +130,7 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime, for (NodeHeap::const_iterator I=candsAsHeap.begin(); I != candsAsHeap.end(); ++I) if (candsAsHeap.getNode(I)) - earliestReadyTime = min(earliestReadyTime, + earliestReadyTime = std::min(earliestReadyTime, getEarliestForNodeRef(candsAsHeap.getNode(I))); } @@ -125,7 +139,7 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime, E != node->endOutEdges(); ++E) { cycles_t& etime = getEarliestForNodeRef((*E)->getSink()); - etime = max(etime, curTime + (*E)->getMinDelay()); + etime = std::max(etime, curTime + (*E)->getMinDelay()); } } @@ -140,14 +154,14 @@ SchedPriorities::issuedReadyNodeAt(cycles_t curTime, //---------------------------------------------------------------------- inline int -SchedPriorities::chooseByRule1(vector& mcands) +SchedPriorities::chooseByRule1(std::vector& mcands) { return (mcands.size() == 1)? 0 // only one choice exists so take it : -1; // -1 indicates multiple choices } inline int -SchedPriorities::chooseByRule2(vector& mcands) +SchedPriorities::chooseByRule2(std::vector& mcands) { assert(mcands.size() >= 1 && "Should have at least one candidate here."); for (unsigned i=0, N = mcands.size(); i < N; i++) @@ -158,7 +172,7 @@ SchedPriorities::chooseByRule2(vector& mcands) } inline int -SchedPriorities::chooseByRule3(vector& mcands) +SchedPriorities::chooseByRule3(std::vector& mcands) { assert(mcands.size() >= 1 && "Should have at least one candidate here."); int maxUses = candsAsHeap.getNode(mcands[0])->getNumOutEdges(); @@ -224,7 +238,7 @@ SchedPriorities::getNextHighest(const SchedulingManager& S, void -SchedPriorities::findSetWithMaxDelay(vector& mcands, +SchedPriorities::findSetWithMaxDelay(std::vector& mcands, const SchedulingManager& S) { if (mcands.size() == 0 && nextToTry != candsAsHeap.end()) @@ -240,12 +254,12 @@ SchedPriorities::findSetWithMaxDelay(vector& mcands, if (SchedDebugLevel >= Sched_PrintSchedTrace) { - cout << " Cycle " << this->getTime() << ": " - << "Next highest delay = " << maxDelay << " : " + cerr << " Cycle " << (long)getTime() << ": " + << "Next highest delay = " << (long)maxDelay << " : " << mcands.size() << " Nodes with this delay: "; for (unsigned i=0; i < mcands.size(); i++) - cout << candsAsHeap.getNode(mcands[i])->getNodeId() << ", "; - cout << endl; + cerr << candsAsHeap.getNode(mcands[i])->getNodeId() << ", "; + cerr << "\n"; } } } @@ -257,10 +271,10 @@ SchedPriorities::instructionHasLastUse(MethodLiveVarInfo& methodLiveVarInfo, { const MachineInstr* minstr = graphNode->getMachineInstr(); - hash_map::const_iterator + std::hash_map::const_iterator ui = lastUseMap.find(minstr); if (ui != lastUseMap.end()) - return (*ui).second; + return ui->second; // else check if instruction is a last use and save it in the hash_map bool hasLastUse = false; diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.h b/lib/Target/SparcV9/InstrSched/SchedPriorities.h index 81a2e6a053..a8b3e23397 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.h +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.h @@ -26,6 +26,7 @@ #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/Target/MachineSchedInfo.h" #include +#include class Method; class MachineInstr; @@ -36,22 +37,22 @@ struct NodeDelayPair { const SchedGraphNode* node; cycles_t delay; NodeDelayPair(const SchedGraphNode* n, cycles_t d) : node(n), delay(d) {} - inline bool operator< (const NodeDelayPair& np) { return delay < np.delay; } + inline bool operator<(const NodeDelayPair& np) { return delay < np.delay; } }; inline bool NDPLessThan(const NodeDelayPair* np1, const NodeDelayPair* np2) { - return (np1->delay < np2->delay); + return np1->delay < np2->delay; } -class NodeHeap: public list, public NonCopyable { +class NodeHeap: public std::list, public NonCopyable { public: - typedef list::iterator iterator; - typedef list::const_iterator const_iterator; + typedef std::list::iterator iterator; + typedef std::list::const_iterator const_iterator; public: - /*ctor*/ NodeHeap () : list(), _size(0) {} + /*ctor*/ NodeHeap () : std::list(), _size(0) {} /*dtor*/ ~NodeHeap () {} inline unsigned int size () const { return _size; } @@ -89,7 +90,7 @@ public: iterator I=begin(); for ( ; I != end() && getDelay(I) >= delay; ++I) ; - list::insert(I, ndp); + std::list::insert(I, ndp); } _size++; } @@ -131,22 +132,22 @@ private: cycles_t curTime; const SchedGraph* graph; MethodLiveVarInfo methodLiveVarInfo; - hash_map lastUseMap; - vector nodeDelayVec; - vector earliestForNode; + std::hash_map lastUseMap; + std::vector nodeDelayVec; + std::vector earliestForNode; cycles_t earliestReadyTime; NodeHeap candsAsHeap; // candidate nodes, ready to go - hash_set candsAsSet; // same entries as candsAsHeap, + std::hash_set candsAsSet;//same entries as candsAsHeap, // but as set for fast lookup - vector mcands; // holds pointers into cands + std::vector mcands; // holds pointers into cands candIndex nextToTry; // next cand after the last // one tried in this cycle - int chooseByRule1 (vector& mcands); - int chooseByRule2 (vector& mcands); - int chooseByRule3 (vector& mcands); + int chooseByRule1 (std::vector& mcands); + int chooseByRule2 (std::vector& mcands); + int chooseByRule3 (std::vector& mcands); - void findSetWithMaxDelay (vector& mcands, + void findSetWithMaxDelay (std::vector& mcands, const SchedulingManager& S); void computeDelays (const SchedGraph* graph); @@ -169,36 +170,15 @@ private: }; -inline void -SchedPriorities::insertReady(const SchedGraphNode* node) -{ - candsAsHeap.insert(node, nodeDelayVec[node->getNodeId()]); - candsAsSet.insert(node); - mcands.clear(); // ensure reset choices is called before any more choices - earliestReadyTime = min(earliestReadyTime, - earliestForNode[node->getNodeId()]); - - if (SchedDebugLevel >= Sched_PrintSchedTrace) - { - cout << " Cycle " << this->getTime() << ": " - << " Node " << node->getNodeId() << " is ready; " - << " Delay = " << this->getNodeDelayRef(node) << "; Instruction: " - << endl; - cout << " " << *node->getMachineInstr() << endl; - } -} - inline void SchedPriorities::updateTime(cycles_t c) { curTime = c; nextToTry = candsAsHeap.begin(); mcands.clear(); } -inline ostream& operator<< (ostream& os, const NodeDelayPair* nd) { +inline std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd) { return os << "Delay for node " << nd->node->getNodeId() - << " = " << nd->delay << endl; + << " = " << (long)nd->delay << "\n"; } -/***************************************************************************/ - #endif diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index ce3e2c3a3f..20cbe8d71b 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -31,6 +31,9 @@ #include "llvm/BasicBlock.h" #include "llvm/CodeGen/MachineInstr.h" #include "Support/STLExtras.h" +#include +using std::cerr; +using std::vector; //------------------------------------------------------------------------ // class InstrTreeNode @@ -119,21 +122,21 @@ void InstructionNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << getInstruction()->getOpcodeName(); + cerr << getInstruction()->getOpcodeName(); const vector &mvec = getInstruction()->getMachineInstrVec(); if (mvec.size() > 0) - cout << "\tMachine Instructions: "; + cerr << "\tMachine Instructions: "; for (unsigned int i=0; i < mvec.size(); i++) { mvec[i]->dump(0); if (i < mvec.size() - 1) - cout << "; "; + cerr << "; "; } - cout << endl; + cerr << "\n"; } @@ -141,9 +144,9 @@ void VRegListNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "List" << endl; + cerr << "List" << "\n"; } @@ -151,29 +154,29 @@ void VRegNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "VReg " << getValue() << "\t(type " - << (int) getValue()->getValueType() << ")" << endl; + cerr << "VReg " << getValue() << "\t(type " + << (int) getValue()->getValueType() << ")" << "\n"; } void ConstantNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "Constant " << getValue() << "\t(type " - << (int) getValue()->getValueType() << ")" << endl; + cerr << "Constant " << getValue() << "\t(type " + << (int) getValue()->getValueType() << ")" << "\n"; } void LabelNode::dumpNode(int indent) const { for (int i=0; i < indent; i++) - cout << " "; + cerr << " "; - cout << "Label " << getValue() << endl; + cerr << "Label " << getValue() << "\n"; } //------------------------------------------------------------------------ @@ -190,7 +193,7 @@ InstrForest::InstrForest(Method *M) InstrForest::~InstrForest() { - for (hash_map:: iterator I = begin(); + for (std::hash_map::iterator I = begin(); I != end(); ++I) delete (*I).second; } @@ -198,7 +201,7 @@ InstrForest::~InstrForest() void InstrForest::dump() const { - for (hash_set::const_iterator I = treeRoots.begin(); + for (std::hash_set::const_iterator I = treeRoots.begin(); I != treeRoots.end(); ++I) (*I)->dump(/*dumpChildren*/ 1, /*indent*/ 0); } diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index b959c90ca3..ab489c507e 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -23,8 +23,8 @@ #include "llvm/iPHINode.h" #include "llvm/Target/MachineRegInfo.h" #include "Support/CommandLine.h" -#include - +#include +using std::cerr; //******************** Internal Data Declarations ************************/ @@ -84,17 +84,17 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) if (SelectDebugLevel >= Select_DebugInstTrees) { - cout << "\n\n*** Instruction trees for method " + cerr << "\n\n*** Instruction trees for method " << (method->hasName()? method->getName() : "") - << endl << endl; + << "\n\n"; instrForest.dump(); } // // Invoke BURG instruction selection for each tree // - const hash_set &treeRoots = instrForest.getRootSet(); - for (hash_set::const_iterator + const std::hash_set &treeRoots = instrForest.getRootSet(); + for (std::hash_set::const_iterator treeRootIter = treeRoots.begin(); treeRootIter != treeRoots.end(); ++treeRootIter) { @@ -138,8 +138,7 @@ SelectInstructionsForMethod(Method* method, TargetMachine &target) if (SelectDebugLevel >= Select_PrintMachineCode) { - cout << endl - << "*** Machine instructions after INSTRUCTION SELECTION" << endl; + cerr << "\n*** Machine instructions after INSTRUCTION SELECTION\n"; MachineCodeForMethod::get(method).dump(); } @@ -210,7 +209,7 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) { // insert the copy instruction to the predecessor BB - vector CopyInstVec; + std::vector CopyInstVec; MachineInstr *CpMI = target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PN); @@ -250,25 +249,18 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) { PHINode *PN = (PHINode *) (*IIt); - Value *PhiCpRes = new Value(PN->getType(), PN->getValueType()); - - string *Name = new string("PhiCp:"); - (*Name) += (int) PhiCpRes; - PhiCpRes->setName( *Name ); - + Value *PhiCpRes = new Value(PN->getType(), PN->getValueType(),"PhiCp:"); // for each incoming value of the phi, insert phi elimination // for (unsigned i = 0; i < PN->getNumIncomingValues(); ++i) { // insert the copy instruction to the predecessor BB - MachineInstr *CpMI = target.getRegInfo().cpValue2Value(PN->getIncomingValue(i), PhiCpRes); InsertPhiElimInst(PN->getIncomingBlock(i), CpMI); - } @@ -279,8 +271,6 @@ void InsertCode4AllPhisInMeth(Method *method, TargetMachine &target) { MachineCodeForBasicBlock& bbMvec = BB->getMachineInstrVec(); bbMvec.insert( bbMvec.begin(), CpMI2); - - } else break; // since PHI nodes can only be at the top @@ -338,7 +328,7 @@ PostprocessMachineCodeForTree(InstructionNode* instrNode, MachineCodeForVMInstr& mvec = vmInstr->getMachineInstrVec(); for (int i = (int) mvec.size()-1; i >= 0; i--) { - vector loadConstVec = + std::vector loadConstVec = FixConstantOperandsForInstr(vmInstr, mvec[i], target); if (loadConstVec.size() > 0) @@ -372,7 +362,7 @@ SelectInstructionsForTree(InstrTreeNode* treeRoot, int goalnt, if (ruleForNode == 0) { - cerr << "Could not match instruction tree for instr selection" << endl; + cerr << "Could not match instruction tree for instr selection\n"; assert(0); return true; } diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index 30d9c7eb78..34dd83b49e 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -22,7 +22,7 @@ #include "llvm/Instruction.h" #include "llvm/Type.h" #include "llvm/iMemory.h" - +using std::vector; //*************************** Local Functions ******************************/ diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp index d7e036b256..0ecf96cf13 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp @@ -1,8 +1,13 @@ #include "llvm/Analysis/LiveVar/BBLiveVar.h" #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" + +/// BROKEN: Should not include sparc stuff directly into here #include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn +using std::cerr; +using std::endl; +using std::pair; //----------------------------------------------------------------------------- // Constructor @@ -39,7 +44,7 @@ void BBLiveVar::calcDefUseSets() if( DEBUG_LV > 1) { // debug msg cerr << " *Iterating over machine instr "; MInst->dump(); - cerr << endl; + cerr << "\n"; } // iterate over MI operands to find defs @@ -85,9 +90,9 @@ void BBLiveVar::calcDefUseSets() if( DEBUG_LV > 1) { // debug msg of level 2 cerr << " - phi operand "; printValue( ArgVal ); - cerr << " came from BB "; + cerr << " came from BB "; printValue( PhiArgMap[ ArgVal ]); - cerr< 1) { - cerr << " +Def: "; printValue( Op ); cerr << endl; + cerr << " +Def: "; printValue( Op ); cerr << "\n"; } } diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.h b/lib/Target/SparcV9/LiveVar/BBLiveVar.h index 6d7d4eb533..9ce56a88f6 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.h +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.h @@ -28,7 +28,7 @@ class BBLiveVar // map that contains phi args->BB they came // set by calcDefUseSets & used by setPropagate - hash_map PhiArgMap; + std::hash_map PhiArgMap; // method to propogate an InSet to OutSet of a predecessor bool setPropagate( LiveVarSet *const OutSetOfPred, diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp index 636359d1d0..5de35ff1be 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp @@ -12,15 +12,15 @@ #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" #include "Support/PostOrderIterator.h" - +#include +using std::cout; +using std::endl; //************************** Constructor/Destructor *************************** -MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M), - BB2BBLVMap() -{ - assert(! M->isExternal() ); // cannot be a prototype decleration +MethodLiveVarInfo::MethodLiveVarInfo(const Method *const M) : Meth(M) { + assert(!M->isExternal() && "Cannot be a prototype declaration"); HasAnalyzed = false; // still we haven't called analyze() } @@ -55,8 +55,6 @@ MethodLiveVarInfo:: ~MethodLiveVarInfo() if( (*MI).first ) // delete all LiveVarSets in MInst2LVSetBI delete (*MI).second; } - - } diff --git a/lib/Target/SparcV9/LiveVar/ValueSet.cpp b/lib/Target/SparcV9/LiveVar/ValueSet.cpp index 6806d1c563..d176d9e53c 100644 --- a/lib/Target/SparcV9/LiveVar/ValueSet.cpp +++ b/lib/Target/SparcV9/LiveVar/ValueSet.cpp @@ -1,11 +1,14 @@ #include "llvm/Analysis/LiveVar/ValueSet.h" #include "llvm/ConstantVals.h" - +#include +using std::cerr; +using std::endl; +using std::pair; +using std::hash_set; void printValue( const Value *const v) // func to print a Value { - if (v->hasName()) cerr << v << "(" << ((*v).getName()) << ") "; else if (Constant *C = dyn_cast(v)) @@ -16,17 +19,13 @@ void printValue( const Value *const v) // func to print a Value //---------------- Method implementations -------------------------- - - -ValueSet:: ValueSet() : hash_set () { } - // for performing two set unions bool ValueSet::setUnion( const ValueSet *const set1) { const_iterator set1it; pair result; bool changed = false; - for( set1it = set1->begin() ; set1it != set1->end(); set1it++) { + for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) { // for all all elements in set1 result = insert( *set1it ); // insert to this set if( result.second == true) changed = true; @@ -41,7 +40,7 @@ void ValueSet::setDifference( const ValueSet *const set1, const ValueSet *const set2) { const_iterator set1it, set2it; - for( set1it = set1->begin() ; set1it != set1->end(); set1it++) { + for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) { // for all elements in set1 iterator set2it = set2->find( *set1it ); // find wether the elem is in set2 if( set2it == set2->end() ) // if the element is not in set2 @@ -53,7 +52,7 @@ void ValueSet::setDifference( const ValueSet *const set1, // for performing set subtraction void ValueSet::setSubtract( const ValueSet *const set1) { const_iterator set1it; - for( set1it = set1->begin() ; set1it != set1->end(); set1it++) + for( set1it = set1->begin() ; set1it != set1->end(); ++set1it) // for all elements in set1 erase( *set1it ); // erase that element from this set } @@ -62,7 +61,5 @@ void ValueSet::setSubtract( const ValueSet *const set1) { void ValueSet::printSet() const { // for printing a live variable set - const_iterator it; - for( it = begin() ; it != end(); it++) - printValue( *it ); + for_each(begin(), end(), printValue); } diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.cpp b/lib/Target/SparcV9/RegAlloc/IGNode.cpp index 4e66d9a762..a225742052 100644 --- a/lib/Target/SparcV9/RegAlloc/IGNode.cpp +++ b/lib/Target/SparcV9/RegAlloc/IGNode.cpp @@ -1,12 +1,13 @@ #include "llvm/CodeGen/IGNode.h" - +#include +#include +using std::cerr; //----------------------------------------------------------------------------- // Constructor //----------------------------------------------------------------------------- -IGNode::IGNode(LiveRange *const PLR, unsigned int Ind): Index(Ind), - AdjList(), - ParentLR(PLR) +IGNode::IGNode(LiveRange *const PLR, unsigned int Ind) : Index(Ind), + ParentLR(PLR) { OnStack = false; CurDegree = -1 ; @@ -23,11 +24,12 @@ void IGNode::pushOnStack() int neighs = AdjList.size(); if( neighs < 0) { - cout << "\nAdj List size = " << neighs; + cerr << "\nAdj List size = " << neighs; assert(0 && "Invalid adj list size"); } - for(int i=0; i < neighs; i++) (AdjList[i])->decCurDegree(); + for(int i=0; i < neighs; i++) + AdjList[i]->decCurDegree(); } //----------------------------------------------------------------------------- @@ -35,11 +37,9 @@ void IGNode::pushOnStack() // two IGNodes together. //----------------------------------------------------------------------------- void IGNode::delAdjIGNode(const IGNode *const Node) { - vector ::iterator It = AdjList.begin(); - - // find Node - for( ; It != AdjList.end() && (*It != Node); It++ ) ; + std::vector::iterator It = + find(AdjList.begin(), AdjList.end(), Node); assert( It != AdjList.end() ); // the node must be there - - AdjList.erase( It ); + + AdjList.erase(It); } diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.h b/lib/Target/SparcV9/RegAlloc/IGNode.h index 0f4cf9c82a..b89aea32b1 100644 --- a/lib/Target/SparcV9/RegAlloc/IGNode.h +++ b/lib/Target/SparcV9/RegAlloc/IGNode.h @@ -29,8 +29,6 @@ #include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/CodeGen/LiveRange.h" - - //---------------------------------------------------------------------------- // Class IGNode // @@ -39,13 +37,11 @@ class IGNode { - private: - const int Index; // index within IGNodeList bool OnStack; // this has been pushed on to stack for coloring - vector AdjList; // adjacency list for this live range + std::vector AdjList; // adjacency list for this live range int CurDegree; // @@ -54,7 +50,6 @@ class IGNode // Decremented when a neighbor is pushed on to the stack. // After that, never incremented/set again nor used. - LiveRange *const ParentLR; // parent LR (cannot be a const) @@ -152,10 +147,4 @@ class IGNode }; - - - - - - #endif diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp index e18c9a7a34..0de7275acf 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp @@ -1,4 +1,7 @@ #include "llvm/CodeGen/InterferenceGraph.h" +#include "Support/STLExtras.h" +#include +using std::cerr; //----------------------------------------------------------------------------- // Constructor: Records the RegClass and initalizes IGNodeList. @@ -11,7 +14,7 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC), IG = NULL; Size = 0; if( DEBUG_RA) { - cout << "Interference graph created!" << endl; + cerr << "Interference graph created!\n"; } } @@ -22,19 +25,12 @@ InterferenceGraph::InterferenceGraph(RegClass *const RC) : RegCl(RC), InterferenceGraph:: ~InterferenceGraph() { // delete the matrix - // - if( IG ) - delete []IG; + for(unsigned int r=0; r < IGNodeList.size(); ++r) + delete[] IG[r]; + delete[] IG; // delete all IGNodes in the IGNodeList - // - vector::const_iterator IGIt = IGNodeList.begin(); - for(unsigned i=0; i < IGNodeList.size() ; ++i) { - - const IGNode *const Node = IGNodeList[i]; - if( Node ) delete Node; - } - + for_each(IGNodeList.begin(), IGNodeList.end(), deleter); } @@ -46,13 +42,13 @@ InterferenceGraph:: ~InterferenceGraph() { void InterferenceGraph::createGraph() { Size = IGNodeList.size(); - IG = (char **) new char *[Size]; + IG = new char*[Size]; for( unsigned int r=0; r < Size; ++r) IG[r] = new char[Size]; // init IG matrix for(unsigned int i=0; i < Size; i++) - for( unsigned int j=0; j < Size ; j++) + for(unsigned int j=0; j < Size; j++) IG[i][j] = 0; } @@ -61,9 +57,7 @@ void InterferenceGraph::createGraph() //----------------------------------------------------------------------------- void InterferenceGraph::addLRToIG(LiveRange *const LR) { - IGNode *Node = new IGNode(LR, IGNodeList.size() ); - IGNodeList.push_back( Node ); - + IGNodeList.push_back(new IGNode(LR, IGNodeList.size())); } @@ -92,12 +86,11 @@ void InterferenceGraph::setInterference(const LiveRange *const LR1, char *val; if( DEBUG_RA > 1) - cout << "setting intf for: [" << row << "][" << col << "]" << endl; + cerr << "setting intf for: [" << row << "][" << col << "]\n"; ( row > col) ? val = &IG[row][col]: val = &IG[col][row]; if( ! (*val) ) { // if this interf is not previously set - *val = 1; // add edges between nodes IGNode1->addAdjIGNode( IGNode2 ); IGNode2->addAdjIGNode( IGNode1 ); @@ -123,7 +116,10 @@ unsigned InterferenceGraph::getInterference(const LiveRange *const LR1, const unsigned int col = LR2->getUserIGNode()->getIndex(); char ret; - ( row > col) ? (ret = IG[row][col]) : (ret = IG[col][row]) ; + if (row > col) + ret = IG[row][col]; + else + ret = IG[col][row]; return ret; } @@ -148,9 +144,9 @@ void InterferenceGraph::mergeIGNodesOfLRs(const LiveRange *const LR1, assertIGNode( SrcNode ); if( DEBUG_RA > 1) { - cout << "Merging LRs: \""; LR1->printSet(); - cout << "\" and \""; LR2->printSet(); - cout << "\"" << endl; + cerr << "Merging LRs: \""; LR1->printSet(); + cerr << "\" and \""; LR2->printSet(); + cerr << "\"\n"; } unsigned SrcDegree = SrcNode->getNumOfNeighbors(); @@ -217,17 +213,16 @@ void InterferenceGraph::printIG() const for(unsigned int i=0; i < Size; i++) { const IGNode *const Node = IGNodeList[i]; - if( ! Node ) - continue; // skip empty rows - - cout << " [" << i << "] "; + if(Node) { + cerr << " [" << i << "] "; - for( unsigned int j=0; j < Size; j++) { - if( j >= i) break; - if( IG[i][j] ) cout << "(" << i << "," << j << ") "; + for( unsigned int j=0; j < i; j++) { + if(IG[i][j]) + cerr << "(" << i << "," << j << ") "; } - cout << endl; + cerr << "\n"; } + } } //---------------------------------------------------------------------------- @@ -235,21 +230,14 @@ void InterferenceGraph::printIG() const //---------------------------------------------------------------------------- void InterferenceGraph::printIGNodeList() const { - vector::const_iterator IGIt = IGNodeList.begin(); // hash map iter - for(unsigned i=0; i < IGNodeList.size() ; ++i) { - const IGNode *const Node = IGNodeList[i]; - if( ! Node ) - continue; - - cout << " [" << Node->getIndex() << "] "; - (Node->getParentLR())->printSet(); - //int Deg = Node->getCurDegree(); - cout << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">" << endl; - + if (Node) { + cerr << " [" << Node->getIndex() << "] "; + Node->getParentLR()->printSet(); + //int Deg = Node->getCurDegree(); + cerr << "\t <# of Neighs: " << Node->getNumOfNeighbors() << ">\n"; + } } } - - diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h index 99dea8fbe0..408bee4558 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h @@ -1,4 +1,4 @@ -/* Title: InterferenceGraph.h +/* Title: InterferenceGraph.h -*- C++ -*- Author: Ruchira Sasanka Date: July 20, 01 Purpose: Interference Graph used for register coloring. @@ -24,7 +24,7 @@ #include "llvm/CodeGen/IGNode.h" -typedef vector IGNodeListType; +typedef std::vector IGNodeListType; class InterferenceGraph @@ -47,6 +47,8 @@ class InterferenceGraph // to create it after adding all IGNodes to the IGNodeList InterferenceGraph(RegClass *const RC); + ~InterferenceGraph(); + void createGraph(); void addLRToIG(LiveRange *const LR); @@ -65,12 +67,6 @@ class InterferenceGraph void printIG() const; void printIGNodeList() const; - - ~InterferenceGraph(); - - }; - #endif - diff --git a/lib/Target/SparcV9/RegAlloc/LiveRange.h b/lib/Target/SparcV9/RegAlloc/LiveRange.h index 778e070046..8034751da9 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRange.h +++ b/lib/Target/SparcV9/RegAlloc/LiveRange.h @@ -1,4 +1,4 @@ -/* Title: LiveRange.h +/* Title: LiveRange.h -*- C++ -*- Author: Ruchira Sasanka Date: July 25, 01 Purpose: To keep info about a live range. @@ -13,6 +13,7 @@ #include "llvm/Analysis/LiveVar/ValueSet.h" #include "llvm/Type.h" +#include class RegClass; class IGNode; @@ -176,7 +177,7 @@ class LiveRange : public ValueSet if(SuggestedColor == -1 ) SuggestedColor = Col; else if (DEBUG_RA) - cerr << "Already has a suggested color " << Col << endl; + std::cerr << "Already has a suggested color " << Col << "\n"; } inline unsigned getSuggestedColor() const { diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp index 7fb688f55e..b66e6ef308 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp @@ -1,15 +1,15 @@ #include "llvm/CodeGen/LiveRangeInfo.h" +#include +using std::cerr; //--------------------------------------------------------------------------- // Constructor //--------------------------------------------------------------------------- LiveRangeInfo::LiveRangeInfo(const Method *const M, const TargetMachine& tm, - vector &RCL) - : Meth(M), LiveRangeMap(), - TM(tm), RegClassList(RCL), - MRI( tm.getRegInfo()), - CallRetInstrList() + std::vector &RCL) + : Meth(M), LiveRangeMap(), TM(tm), + RegClassList(RCL), MRI(tm.getRegInfo()) { } @@ -17,33 +17,25 @@ LiveRangeInfo::LiveRangeInfo(const Method *const M, // Destructor: Deletes all LiveRanges in the LiveRangeMap //--------------------------------------------------------------------------- LiveRangeInfo::~LiveRangeInfo() { - LiveRangeMapType::iterator MI = LiveRangeMap.begin(); for( ; MI != LiveRangeMap.end() ; ++MI) { - if( (*MI).first ) { - - LiveRange *LR = (*MI).second; - - if( LR ) { - - // we need to be careful in deleting LiveRanges in LiveRangeMap - // since two/more Values in the live range map can point to the same - // live range. We have to make the other entries NULL when we delete - // a live range. - - LiveRange::iterator LI = LR->begin(); - - for( ; LI != LR->end() ; ++LI) { - LiveRangeMap[*LI] = NULL; - } + if (MI->first && MI->second) { + LiveRange *LR = MI->second; - delete LR; + // we need to be careful in deleting LiveRanges in LiveRangeMap + // since two/more Values in the live range map can point to the same + // live range. We have to make the other entries NULL when we delete + // a live range. - } + LiveRange::iterator LI = LR->begin(); + + for( ; LI != LR->end() ; ++LI) + LiveRangeMap[*LI] = 0; + + delete LR; } } - } @@ -82,7 +74,7 @@ void LiveRangeInfo::unionAndUpdateLRs(LiveRange *const L1, LiveRange *L2) L1->addSpillCost( L2->getSpillCost() ); // add the spill costs - delete ( L2 ); // delete L2 as it is no longer needed + delete L2; // delete L2 as it is no longer needed } @@ -96,7 +88,7 @@ void LiveRangeInfo::constructLiveRanges() { if( DEBUG_RA) - cout << "Consturcting Live Ranges ..." << endl; + cerr << "Consturcting Live Ranges ...\n"; // first find the live ranges for all incoming args of the method since // those LRs start from the start of the method @@ -108,14 +100,13 @@ void LiveRangeInfo::constructLiveRanges() for( ; ArgIt != ArgList.end() ; ++ArgIt) { // for each argument - LiveRange * ArgRange = new LiveRange(); // creates a new LR and const Value *const Val = (const Value *) *ArgIt; assert( Val); - ArgRange->add( Val ); // add the arg (def) to it - LiveRangeMap[ Val ] = ArgRange; + ArgRange->add(Val); // add the arg (def) to it + LiveRangeMap[Val] = ArgRange; // create a temp machine op to find the register class of value //const MachineOperand Op(MachineOperand::MO_VirtualRegister); @@ -125,8 +116,8 @@ void LiveRangeInfo::constructLiveRanges() if( DEBUG_RA > 1) { - cout << " adding LiveRange for argument "; - printValue( (const Value *) *ArgIt); cout << endl; + cerr << " adding LiveRange for argument "; + printValue((const Value *) *ArgIt); cerr << "\n"; } } @@ -140,7 +131,6 @@ void LiveRangeInfo::constructLiveRanges() Method::const_iterator BBI = Meth->begin(); // random iterator for BBs - for( ; BBI != Meth->end(); ++BBI) { // go thru BBs in random order // Now find all LRs for machine the instructions. A new LR will be created @@ -150,8 +140,7 @@ void LiveRangeInfo::constructLiveRanges() // get the iterator for machine instructions const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec(); - MachineCodeForBasicBlock::const_iterator - MInstIterator = MIVec.begin(); + MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin(); // iterate over all the machine instructions in BB for( ; MInstIterator != MIVec.end(); MInstIterator++) { @@ -161,53 +150,46 @@ void LiveRangeInfo::constructLiveRanges() // Now if the machine instruction is a call/return instruction, // add it to CallRetInstrList for processing its implicit operands - if( (TM.getInstrInfo()).isReturn( MInst->getOpCode()) || - (TM.getInstrInfo()).isCall( MInst->getOpCode()) ) + if(TM.getInstrInfo().isReturn(MInst->getOpCode()) || + TM.getInstrInfo().isCall(MInst->getOpCode())) CallRetInstrList.push_back( MInst ); // iterate over MI operands to find defs - for( MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done(); ++OpI) { - - if( DEBUG_RA) { + for (MachineInstr::val_const_op_iterator OpI(MInst); !OpI.done(); ++OpI) { + if(DEBUG_RA) { MachineOperand::MachineOperandType OpTyp = OpI.getMachineOperand().getOperandType(); - if ( OpTyp == MachineOperand::MO_CCRegister) { - cout << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:"; + if (OpTyp == MachineOperand::MO_CCRegister) { + cerr << "\n**CC reg found. Is Def=" << OpI.isDef() << " Val:"; printValue( OpI.getMachineOperand().getVRegValue() ); - cout << endl; + cerr << "\n"; } } // create a new LR iff this operand is a def if( OpI.isDef() ) { - const Value *const Def = *OpI; - // Only instruction values are accepted for live ranges here - if( Def->getValueType() != Value::InstructionVal ) { - cout << "\n**%%Error: Def is not an instruction val. Def="; - printValue( Def ); cout << endl; + cerr << "\n**%%Error: Def is not an instruction val. Def="; + printValue( Def ); cerr << "\n"; continue; } - LiveRange *DefRange = LiveRangeMap[Def]; // see LR already there (because of multiple defs) - if( !DefRange) { // if it is not in LiveRangeMap - DefRange = new LiveRange(); // creates a new live range and DefRange->add( Def ); // add the instruction (def) to it LiveRangeMap[ Def ] = DefRange; // update the map if( DEBUG_RA > 1) { - cout << " creating a LR for def: "; - printValue(Def); cout << endl; + cerr << " creating a LR for def: "; + printValue(Def); cerr << "\n"; } // set the register class of the new live range @@ -221,7 +203,7 @@ void LiveRangeInfo::constructLiveRanges() if(isCC && DEBUG_RA) { - cout << "\a**created a LR for a CC reg:"; + cerr << "\a**created a LR for a CC reg:"; printValue( OpI.getMachineOperand().getVRegValue() ); } @@ -235,8 +217,8 @@ void LiveRangeInfo::constructLiveRanges() LiveRangeMap[ Def ] = DefRange; if( DEBUG_RA > 1) { - cout << " added to an existing LR for def: "; - printValue( Def ); cout << endl; + cerr << " added to an existing LR for def: "; + printValue( Def ); cerr << "\n"; } } @@ -256,7 +238,7 @@ void LiveRangeInfo::constructLiveRanges() suggestRegs4CallRets(); if( DEBUG_RA) - cout << "Initial Live Ranges constructed!" << endl; + cerr << "Initial Live Ranges constructed!\n"; } @@ -312,11 +294,8 @@ void LiveRangeInfo::suggestRegs4CallRets() //--------------------------------------------------------------------------- void LiveRangeInfo::coalesceLRs() { - - - if( DEBUG_RA) - cout << endl << "Coalscing LRs ..." << endl; + cerr << "\nCoalscing LRs ...\n"; Method::const_iterator BBI = Meth->begin(); // random iterator for BBs @@ -324,8 +303,7 @@ void LiveRangeInfo::coalesceLRs() // get the iterator for machine instructions const MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec(); - MachineCodeForBasicBlock::const_iterator - MInstIterator = MIVec.begin(); + MachineCodeForBasicBlock::const_iterator MInstIterator = MIVec.begin(); // iterate over all the machine instructions in BB for( ; MInstIterator != MIVec.end(); ++MInstIterator) { @@ -333,9 +311,9 @@ void LiveRangeInfo::coalesceLRs() const MachineInstr * MInst = *MInstIterator; if( DEBUG_RA > 1) { - cout << " *Iterating over machine instr "; + cerr << " *Iterating over machine instr "; MInst->dump(); - cout << endl; + cerr << "\n"; } @@ -357,8 +335,8 @@ void LiveRangeInfo::coalesceLRs() //don't warn about labels if (!((*UseI)->getType())->isLabelType() && DEBUG_RA) { - cout<<" !! Warning: No LR for use "; printValue(*UseI); - cout << endl; + cerr<<" !! Warning: No LR for use "; printValue(*UseI); + cerr << "\n"; } continue; // ignore and continue } @@ -407,7 +385,7 @@ void LiveRangeInfo::coalesceLRs() } // for all BBs if( DEBUG_RA) - cout << endl << "Coalscing Done!" << endl; + cerr << "\nCoalscing Done!\n"; } @@ -421,11 +399,11 @@ void LiveRangeInfo::coalesceLRs() void LiveRangeInfo::printLiveRanges() { LiveRangeMapType::iterator HMI = LiveRangeMap.begin(); // hash map iterator - cout << endl << "Printing Live Ranges from Hash Map:" << endl; - for( ; HMI != LiveRangeMap.end() ; HMI ++ ) { - if( (*HMI).first && (*HMI).second ) { - cout <<" "; printValue((*HMI).first); cout << "\t: "; - ((*HMI).second)->printSet(); cout << endl; + cerr << "\nPrinting Live Ranges from Hash Map:\n"; + for( ; HMI != LiveRangeMap.end() ; ++HMI) { + if( HMI->first && HMI->second ) { + cerr <<" "; printValue((*HMI).first); cerr << "\t: "; + HMI->second->printSet(); cerr << "\n"; } } } diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h index 1eee1aea5e..9e7ef06fe2 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h @@ -1,4 +1,4 @@ -/* Title: LiveRangeInfo.h +/* Title: LiveRangeInfo.h -*- C++ -*- Author: Ruchira Sasanka Date: Jun 30, 01 Purpose: @@ -34,8 +34,8 @@ #include "llvm/CodeGen/RegClass.h" -typedef hash_map LiveRangeMapType; -typedef vector CallRetInstrListType; +typedef std::hash_map LiveRangeMapType; +typedef std::vector CallRetInstrListType; @@ -59,7 +59,7 @@ private: const TargetMachine& TM; // target machine description - vector & RegClassList;// a vector containing register classess + std::vector & RegClassList;// vector containing register classess const MachineRegInfo& MRI; // machine reg info @@ -82,7 +82,7 @@ public: LiveRangeInfo(const Method *const M, const TargetMachine& tm, - vector & RCList); + std::vector & RCList); // Destructor to destroy all LiveRanges in the LiveRange Map diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 7d6fbb7cc9..e2d455bad9 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -14,7 +14,9 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MachineFrameInfo.h" +#include #include +using std::cerr; // ***TODO: There are several places we add instructions. Validate the order @@ -35,18 +37,16 @@ cl::Enum DEBUG_RA("dregalloc", cl::NoFlags, PhyRegAlloc::PhyRegAlloc(Method *M, const TargetMachine& tm, MethodLiveVarInfo *const Lvi) - : RegClassList(), - TM(tm), - Meth(M), + : TM(tm), Meth(M), mcInfo(MachineCodeForMethod::get(M)), LVI(Lvi), LRI(M, tm, RegClassList), MRI( tm.getRegInfo() ), NumOfRegClasses(MRI.getNumOfRegClasses()), - AddedInstrMap(), LoopDepthCalc(M), ResColList() { + LoopDepthCalc(M) { // create each RegisterClass and put in RegClassList // - for( unsigned int rc=0; rc < NumOfRegClasses; rc++) + for(unsigned int rc=0; rc < NumOfRegClasses; rc++) RegClassList.push_back( new RegClass(M, MRI.getMachineRegClass(rc), &ResColList) ); } @@ -69,7 +69,7 @@ PhyRegAlloc::~PhyRegAlloc() { //---------------------------------------------------------------------------- void PhyRegAlloc::createIGNodeListsAndIGs() { - if(DEBUG_RA ) cout << "Creating LR lists ..." << endl; + if(DEBUG_RA ) cerr << "Creating LR lists ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin(); @@ -85,8 +85,8 @@ void PhyRegAlloc::createIGNodeListsAndIGs() if( !L) { if( DEBUG_RA) { - cout << "\n*?!?Warning: Null liver range found for: "; - printValue( (*HMI).first) ; cout << endl; + cerr << "\n*?!?Warning: Null liver range found for: "; + printValue(HMI->first); cerr << "\n"; } continue; } @@ -108,7 +108,7 @@ void PhyRegAlloc::createIGNodeListsAndIGs() RegClassList[ rc ]->createInterferenceGraph(); if( DEBUG_RA) - cout << "LRLists Created!" << endl; + cerr << "LRLists Created!\n"; } @@ -140,8 +140,8 @@ void PhyRegAlloc::addInterference(const Value *const Def, for( ; LIt != LVSet->end(); ++LIt) { if( DEBUG_RA > 1) { - cout << "< Def="; printValue(Def); - cout << ", Lvar="; printValue( *LIt); cout << "> "; + cerr << "< Def="; printValue(Def); + cerr << ", Lvar="; printValue( *LIt); cerr << "> "; } // get the live range corresponding to live var @@ -166,8 +166,8 @@ void PhyRegAlloc::addInterference(const Value *const Def, else if(DEBUG_RA > 1) { // we will not have LRs for values not explicitly allocated in the // instruction stream (e.g., constants) - cout << " warning: no live range for " ; - printValue( *LIt); cout << endl; } + cerr << " warning: no live range for " ; + printValue(*LIt); cerr << "\n"; } } @@ -203,7 +203,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, } if( DEBUG_RA) - cout << "\n For call inst: " << *MInst; + cerr << "\n For call inst: " << *MInst; LiveVarSet::const_iterator LIt = LVSetAft->begin(); @@ -216,7 +216,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, LiveRange *const LR = LRI.getLiveRangeForValue(*LIt ); if( LR && DEBUG_RA) { - cout << "\n\tLR Aft Call: "; + cerr << "\n\tLR Aft Call: "; LR->printSet(); } @@ -227,7 +227,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, if( LR && (LR != RetValLR) ) { LR->setCallInterference(); if( DEBUG_RA) { - cout << "\n ++Added call interf for LR: " ; + cerr << "\n ++Added call interf for LR: " ; LR->printSet(); } } @@ -247,7 +247,7 @@ void PhyRegAlloc::setCallInterferences(const MachineInstr *MInst, void PhyRegAlloc::buildInterferenceGraphs() { - if(DEBUG_RA) cout << "Creating interference graphs ..." << endl; + if(DEBUG_RA) cerr << "Creating interference graphs ...\n"; unsigned BBLoopDepthCost; Method::const_iterator BBI = Meth->begin(); // random iterator for BBs @@ -333,7 +333,7 @@ void PhyRegAlloc::buildInterferenceGraphs() addInterferencesForArgs(); if( DEBUG_RA) - cout << "Interference graphs calculted!" << endl; + cerr << "Interference graphs calculted!\n"; } @@ -411,8 +411,8 @@ void PhyRegAlloc::addInterferencesForArgs() addInterference( *ArgIt, InSet, false ); // add interferences between // args and LVars at start if( DEBUG_RA > 1) { - cout << " - %% adding interference for argument "; - printValue( (const Value *) *ArgIt); cout << endl; + cerr << " - %% adding interference for argument "; + printValue((const Value *)*ArgIt); cerr << "\n"; } } } @@ -510,7 +510,7 @@ void PhyRegAlloc::updateMachineCode() // delete this condition checking later (must assert if Val is null) if( !Val) { if (DEBUG_RA) - cout << "Warning: NULL Value found for operand" << endl; + cerr << "Warning: NULL Value found for operand\n"; continue; } assert( Val && "Value is NULL"); @@ -522,9 +522,9 @@ void PhyRegAlloc::updateMachineCode() // nothing to worry if it's a const or a label if (DEBUG_RA) { - cout << "*NO LR for operand : " << Op ; - cout << " [reg:" << Op.getAllocatedRegNum() << "]"; - cout << " in inst:\t" << *MInst << endl; + cerr << "*NO LR for operand : " << Op ; + cerr << " [reg:" << Op.getAllocatedRegNum() << "]"; + cerr << " in inst:\t" << *MInst << "\n"; } // if register is not allocated, mark register as invalid @@ -563,18 +563,16 @@ void PhyRegAlloc::updateMachineCode() // instruction, add them now. // if( AddedInstrMap[ MInst ] ) { - - deque &IBef = (AddedInstrMap[MInst])->InstrnsBefore; + std::deque &IBef = AddedInstrMap[MInst]->InstrnsBefore; if( ! IBef.empty() ) { - - deque::iterator AdIt; + std::deque::iterator AdIt; for( AdIt = IBef.begin(); AdIt != IBef.end() ; ++AdIt ) { if( DEBUG_RA) { cerr << "For inst " << *MInst; - cerr << " PREPENDed instr: " << **AdIt << endl; + cerr << " PREPENDed instr: " << **AdIt << "\n"; } MInstIterator = MIVec.insert( MInstIterator, *AdIt ); @@ -600,7 +598,7 @@ void PhyRegAlloc::updateMachineCode() if((delay=TM.getInstrInfo().getNumDelaySlots(MInst->getOpCode())) >0){ move2DelayedInstr(MInst, *(MInstIterator+delay) ); - if(DEBUG_RA) cout<< "\nMoved an added instr after the delay slot"; + if(DEBUG_RA) cerr<< "\nMoved an added instr after the delay slot"; } else { @@ -609,11 +607,11 @@ void PhyRegAlloc::updateMachineCode() // Here we can add the "instructions after" to the current // instruction since there are no delay slots for this instruction - deque &IAft = (AddedInstrMap[MInst])->InstrnsAfter; + std::deque &IAft = AddedInstrMap[MInst]->InstrnsAfter; if( ! IAft.empty() ) { - deque::iterator AdIt; + std::deque::iterator AdIt; ++MInstIterator; // advance to the next instruction @@ -621,7 +619,7 @@ void PhyRegAlloc::updateMachineCode() if(DEBUG_RA) { cerr << "For inst " << *MInst; - cerr << " APPENDed instr: " << **AdIt << endl; + cerr << " APPENDed instr: " << **AdIt << "\n"; } MInstIterator = MIVec.insert( MInstIterator, *AdIt ); @@ -669,9 +667,7 @@ void PhyRegAlloc::insertCode4SpilledLR(const LiveRange *LR, RegClass *RC = LR->getRegClass(); const LiveVarSet *LVSetBef = LVI->getLiveVarSetBeforeMInst(MInst, BB); - - int TmpOff = - mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) ); + mcInfo.pushTempValue(TM, MRI.getSpilledRegSize(RegType) ); MachineInstr *MIBef=NULL, *AdIMid=NULL, *MIAft=NULL; @@ -854,13 +850,10 @@ int PhyRegAlloc::getUniRegNotUsedByThisInst(RegClass *RC, return MRI.getUnifiedRegNum(RC->getID(), c); else assert( 0 && "FATAL: No free register could be found in reg class!!"); - + return 0; } - - - //---------------------------------------------------------------------------- // This method modifies the IsColorUsedArr of the register class passed to it. // It sets the bits corresponding to the registers used by this machine @@ -909,14 +902,10 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, LiveRange *const LRofImpRef = LRI.getLiveRangeForValue( MInst->getImplicitRef(z) ); - - if( LRofImpRef ) - if( LRofImpRef->hasColor() ) - IsColorUsedArr[ LRofImpRef->getColor() ] = true; + + if(LRofImpRef && LRofImpRef->hasColor()) + IsColorUsedArr[LRofImpRef->getColor()] = true; } - - - } @@ -936,9 +925,8 @@ void PhyRegAlloc::setRelRegsUsedByThisInst(RegClass *RC, void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI, const MachineInstr *DelayedMI) { - // "added after" instructions of the original instr - deque &OrigAft = (AddedInstrMap[OrigMI])->InstrnsAfter; + std::deque &OrigAft = AddedInstrMap[OrigMI]->InstrnsAfter; // "added instructions" of the delayed instr AddedInstrns *DelayAdI = AddedInstrMap[DelayedMI]; @@ -949,21 +937,15 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI, } // "added after" instructions of the delayed instr - deque &DelayedAft = DelayAdI->InstrnsAfter; + std::deque &DelayedAft = DelayAdI->InstrnsAfter; // go thru all the "added after instructions" of the original instruction // and append them to the "addded after instructions" of the delayed // instructions - - deque::iterator OrigAdIt; - - for( OrigAdIt = OrigAft.begin(); OrigAdIt != OrigAft.end() ; ++OrigAdIt ) { - DelayedAft.push_back( *OrigAdIt ); - } + DelayedAft.insert(DelayedAft.end(), OrigAft.begin(), OrigAft.end()); // empty the "added after instructions" of the original instruction OrigAft.clear(); - } //---------------------------------------------------------------------------- @@ -973,14 +955,14 @@ void PhyRegAlloc:: move2DelayedInstr(const MachineInstr *OrigMI, void PhyRegAlloc::printMachineCode() { - cout << endl << ";************** Method "; - cout << Meth->getName() << " *****************" << endl; + cerr << "\n;************** Method " << Meth->getName() + << " *****************\n"; Method::const_iterator BBI = Meth->begin(); // random iterator for BBs for( ; BBI != Meth->end(); ++BBI) { // traverse BBs in random order - cout << endl ; printLabel( *BBI); cout << ": "; + cerr << "\n"; printLabel( *BBI); cerr << ": "; // get the iterator for machine instructions MachineCodeForBasicBlock& MIVec = (*BBI)->getMachineInstrVec(); @@ -992,8 +974,8 @@ void PhyRegAlloc::printMachineCode() MachineInstr *const MInst = *MInstIterator; - cout << endl << "\t"; - cout << TargetInstrDescriptors[MInst->getOpCode()].opCodeString; + cerr << "\n\t"; + cerr << TargetInstrDescriptors[MInst->getOpCode()].opCodeString; //for(MachineInstr::val_const_op_iterator OpI(MInst);!OpI.done();++OpI) { @@ -1009,41 +991,39 @@ void PhyRegAlloc::printMachineCode() const Value *const Val = Op.getVRegValue () ; // ****this code is temporary till NULL Values are fixed if( ! Val ) { - cout << "\t<*NULL*>"; + cerr << "\t<*NULL*>"; continue; } // if a label or a constant - if( (Val->getValueType() == Value::BasicBlockVal) ) { - - cout << "\t"; printLabel( Op.getVRegValue () ); - } - else { + if(isa(Val) { + cerr << "\t"; printLabel( Op.getVRegValue () ); + } else { // else it must be a register value const int RegNum = Op.getAllocatedRegNum(); - cout << "\t" << "%" << MRI.getUnifiedRegName( RegNum ); + cerr << "\t" << "%" << MRI.getUnifiedRegName( RegNum ); if (Val->hasName() ) - cout << "(" << Val->getName() << ")"; + cerr << "(" << Val->getName() << ")"; else - cout << "(" << Val << ")"; + cerr << "(" << Val << ")"; if( Op.opIsDef() ) - cout << "*"; + cerr << "*"; const LiveRange *LROfVal = LRI.getLiveRangeForValue(Val); if( LROfVal ) if( LROfVal->hasSpillOffset() ) - cout << "$"; + cerr << "$"; } } else if(Op.getOperandType() == MachineOperand::MO_MachineRegister) { - cout << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum()); + cerr << "\t" << "%" << MRI.getUnifiedRegName(Op.getMachineRegNum()); } else - cout << "\t" << Op; // use dump field + cerr << "\t" << Op; // use dump field } @@ -1051,23 +1031,22 @@ void PhyRegAlloc::printMachineCode() unsigned NumOfImpRefs = MInst->getNumImplicitRefs(); if( NumOfImpRefs > 0 ) { - cout << "\tImplicit:"; + cerr << "\tImplicit:"; for(unsigned z=0; z < NumOfImpRefs; z++) { printValue( MInst->getImplicitRef(z) ); - cout << "\t"; + cerr << "\t"; } } } // for all machine instructions - - cout << endl; + cerr << "\n"; } // for all BBs - cout << endl; + cerr << "\n"; } @@ -1125,9 +1104,9 @@ void PhyRegAlloc::colorIncomingArgs() assert( FirstMI && "No machine instruction in entry BB"); AddedInstrns *AI = AddedInstrMap[ FirstMI ]; - if ( !AI ) { + if (!AI) { AI = new AddedInstrns(); - AddedInstrMap[ FirstMI ] = AI; + AddedInstrMap[FirstMI] = AI; } MRI.colorMethodArgs(Meth, LRI, AI ); @@ -1137,12 +1116,11 @@ void PhyRegAlloc::colorIncomingArgs() //---------------------------------------------------------------------------- // Used to generate a label for a basic block //---------------------------------------------------------------------------- -void PhyRegAlloc::printLabel(const Value *const Val) -{ - if( Val->hasName() ) - cout << Val->getName(); +void PhyRegAlloc::printLabel(const Value *const Val) { + if (Val->hasName()) + cerr << Val->getName(); else - cout << "Label" << Val; + cerr << "Label" << Val; } @@ -1155,7 +1133,7 @@ void PhyRegAlloc::printLabel(const Value *const Val) void PhyRegAlloc::markUnusableSugColors() { - if(DEBUG_RA ) cout << "\nmarking unusable suggested colors ..." << endl; + if(DEBUG_RA ) cerr << "\nmarking unusable suggested colors ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin(); @@ -1193,22 +1171,18 @@ void PhyRegAlloc::markUnusableSugColors() void PhyRegAlloc::allocateStackSpace4SpilledLRs() { - if(DEBUG_RA ) cout << "\nsetting LR stack offsets ..." << endl; + if(DEBUG_RA ) cerr << "\nsetting LR stack offsets ...\n"; // hash map iterator LiveRangeMapType::const_iterator HMI = (LRI.getLiveRangeMap())->begin(); LiveRangeMapType::const_iterator HMIEnd = (LRI.getLiveRangeMap())->end(); for( ; HMI != HMIEnd ; ++HMI ) { - if( (*HMI).first ) { - LiveRange *L = (*HMI).second; // get the LiveRange - if(L) - if( ! L->hasColor() ) - - // NOTE: ** allocating the size of long Type ** - L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, - Type::LongTy)); - + if(HMI->first && HMI->second) { + LiveRange *L = HMI->second; // get the LiveRange + if( ! L->hasColor() ) + // NOTE: ** allocating the size of long Type ** + L->setSpillOffFromFP(mcInfo.allocateSpilledValue(TM, Type::LongTy)); } } // for all LR's in hash map } diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h index 9d34557b01..6871b2d28a 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h @@ -1,4 +1,4 @@ -/* Title: PhyRegAlloc.h +/* Title: PhyRegAlloc.h -*- C++ -*- Author: Ruchira Sasanka Date: Aug 20, 01 Purpose: This is the main entry point for register allocation. @@ -54,13 +54,11 @@ class AddedInstrns { public: - deque InstrnsBefore; // Added insts BEFORE an existing inst - deque InstrnsAfter; // Added insts AFTER an existing inst - - AddedInstrns() : InstrnsBefore(), InstrnsAfter() { } + std::deque InstrnsBefore;// Added insts BEFORE an existing inst + std::deque InstrnsAfter; // Added insts AFTER an existing inst }; -typedef hash_map AddedInstrMapType; +typedef std::hash_map AddedInstrMapType; @@ -74,7 +72,7 @@ typedef hash_map AddedInstrMapType; class PhyRegAlloc: public NonCopyable { - vector RegClassList ; // vector of register classes + std::vector RegClassList; // vector of register classes const TargetMachine &TM; // target machine const Method* Meth; // name of the method we work on MachineCodeForMethod& mcInfo; // descriptor for method's native code @@ -115,8 +113,7 @@ class PhyRegAlloc: public NonCopyable const BasicBlock *BB, const unsigned OpNum); - inline void constructLiveRanges() - { LRI.constructLiveRanges(); } + inline void constructLiveRanges() { LRI.constructLiveRanges(); } void colorIncomingArgs(); void colorCallRetArgs(); @@ -141,12 +138,9 @@ class PhyRegAlloc: public NonCopyable void addInterf4PseudoInstr(const MachineInstr *MInst); - public: - PhyRegAlloc(Method *const M, const TargetMachine& TM, MethodLiveVarInfo *const Lvi); - ~PhyRegAlloc(); // main method called for allocating registers diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.cpp b/lib/Target/SparcV9/RegAlloc/RegClass.cpp index 3918871d69..8ba6a15ad1 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.cpp +++ b/lib/Target/SparcV9/RegAlloc/RegClass.cpp @@ -1,5 +1,6 @@ #include "llvm/CodeGen/RegClass.h" - +#include +using std::cerr; //---------------------------------------------------------------------------- // This constructor inits IG. The actual matrix is created by a call to @@ -11,7 +12,7 @@ RegClass::RegClass(const Method *const M, : Meth(M), MRC(Mrc), RegClassID( Mrc->getRegClassID() ), IG(this), IGNodeStack(), ReservedColorList(RCL) { if( DEBUG_RA) - cout << "Created Reg Class: " << RegClassID << endl; + cerr << "Created Reg Class: " << RegClassID << "\n"; IsColorUsedArr = new bool[ Mrc->getNumOfAllRegs() ]; } @@ -23,7 +24,7 @@ RegClass::RegClass(const Method *const M, //---------------------------------------------------------------------------- void RegClass::colorAllRegs() { - if(DEBUG_RA) cout << "Coloring IG of reg class " << RegClassID << " ...\n"; + if(DEBUG_RA) cerr << "Coloring IG of reg class " << RegClassID << " ...\n"; // pre-color IGNodes pushAllIGNodes(); // push all IG Nodes @@ -57,9 +58,9 @@ void RegClass::pushAllIGNodes() bool PushedAll = pushUnconstrainedIGNodes(); if( DEBUG_RA) { - cout << " Puhsed all-unconstrained IGNodes. "; - if( PushedAll ) cout << " No constrained nodes left."; - cout << endl; + cerr << " Puhsed all-unconstrained IGNodes. "; + if( PushedAll ) cerr << " No constrained nodes left."; + cerr << "\n"; } if( PushedAll ) // if NO constrained nodes left @@ -129,8 +130,8 @@ bool RegClass::pushUnconstrainedIGNodes() IGNode->pushOnStack(); // set OnStack and dec deg of neighs if (DEBUG_RA > 1) { - cout << " pushed un-constrained IGNode " << IGNode->getIndex() ; - cout << " on to stack" << endl; + cerr << " pushed un-constrained IGNode " << IGNode->getIndex() ; + cerr << " on to stack\n"; } } else pushedall = false; // we didn't push all live ranges @@ -215,16 +216,16 @@ void RegClass::colorIGNode(IGNode *const Node) } else { if( DEBUG_RA ) { - cout << " Node " << Node->getIndex(); - cout << " already colored with color " << Node->getColor() << endl; + cerr << " Node " << Node->getIndex(); + cerr << " already colored with color " << Node->getColor() << "\n"; } } if( !Node->hasColor() ) { if( DEBUG_RA ) { - cout << " Node " << Node->getIndex(); - cout << " - could not find a color (needs spilling)" << endl; + cerr << " Node " << Node->getIndex(); + cerr << " - could not find a color (needs spilling)\n"; } } diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.h b/lib/Target/SparcV9/RegAlloc/RegClass.h index d6cbaf892b..fe25986f40 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.h +++ b/lib/Target/SparcV9/RegAlloc/RegClass.h @@ -13,8 +13,9 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/MachineRegInfo.h" #include +#include -typedef vector ReservedColorListType; +typedef std::vector ReservedColorListType; //----------------------------------------------------------------------------- @@ -46,7 +47,7 @@ class RegClass InterferenceGraph IG; // Interference graph - constructed by // buildInterferenceGraph - stack IGNodeStack; // the stack used for coloring + std::stack IGNodeStack; // the stack used for coloring const ReservedColorListType *const ReservedColorList; // @@ -117,21 +118,14 @@ class RegClass inline void printIGNodeList() const { - cerr << "IG Nodes for Register Class " << RegClassID << ":" << endl; + std::cerr << "IG Nodes for Register Class " << RegClassID << ":" << "\n"; IG.printIGNodeList(); } inline void printIG() { - cerr << "IG for Register Class " << RegClassID << ":" << endl; + std::cerr << "IG for Register Class " << RegClassID << ":" << "\n"; IG.printIG(); } - }; - - - - - - #endif diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index fb2888b05d..098da9074e 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -22,16 +22,17 @@ #include "Support/StringExtras.h" #include "Support/HashExtras.h" #include +using std::string; namespace { class SparcAsmPrinter { - typedef hash_map ValIdMap; + typedef std::hash_map ValIdMap; typedef ValIdMap:: iterator ValIdMapIterator; typedef ValIdMap::const_iterator ValIdMapConstIterator; - ostream &toAsm; + std::ostream &toAsm; SlotCalculator Table; // map anonymous values to unique integer IDs ValIdMap valToIdMap; // used for values not handled by SlotCalculator const UltraSparc &Target; @@ -45,7 +46,7 @@ class SparcAsmPrinter { } CurSection; public: - inline SparcAsmPrinter(ostream &o, const Module *M, const UltraSparc &t) + inline SparcAsmPrinter(std::ostream &o, const Module *M, const UltraSparc &t) : toAsm(o), Table(SlotCalculator(M, true)), Target(t), CurSection(Unknown) { emitModule(M); } @@ -61,7 +62,7 @@ private : void printGlobalVariable( const GlobalVariable* GV); void printSingleConstant( const Constant* CV); void printConstantValueOnly(const Constant* CV); - void printConstant( const Constant* CV, string valID=string("")); + void printConstant( const Constant* CV, std::string valID = ""); unsigned int printOperands(const MachineInstr *MI, unsigned int opNum); void printOneOperand(const MachineOperand &Op); @@ -88,7 +89,7 @@ private : toAsm << "\n"; } - string getValidSymbolName(const string &S) { + std::string getValidSymbolName(const string &S) { string Result; // Symbol names in Sparc assembly language have these rules: @@ -318,7 +319,7 @@ SparcAsmPrinter::printOneOperand(const MachineOperand &op) case MachineOperand::MO_SignExtendedImmed: case MachineOperand::MO_UnextendedImmed: - toAsm << op.getImmedValue(); + toAsm << (long)op.getImmedValue(); break; default: @@ -351,7 +352,7 @@ SparcAsmPrinter::emitMachineInst(const MachineInstr *MI) else N = 1; - toAsm << endl; + toAsm << "\n"; } void @@ -393,7 +394,7 @@ SparcAsmPrinter::emitMethod(const Method *M) // Output a .size directive so the debugger knows the extents of the function toAsm << ".EndOf_" << methName << ":\n\t.size " << methName << ", .EndOf_" - << methName << "-" << methName << endl; + << methName << "-" << methName << "\n"; // Put some spaces between the methods toAsm << "\n\n"; @@ -487,7 +488,6 @@ TypeToAlignment(const Type* type, const TargetMachine& target) inline unsigned int ConstantToAlignment(const Constant* CV, const TargetMachine& target) { - unsigned int constantSize; if (ConstantArray* CPA = dyn_cast(CV)) if (ArrayTypeIsString(cast(CPA->getType()))) return SizeToAlignment(1 + CPA->getNumOperands(), target); @@ -515,16 +515,15 @@ SparcAsmPrinter::printSingleConstant(const Constant* CV) { if (CV->getType() == Type::FloatTy || CV->getType() == Type::DoubleTy) toAsm << "0r"; // FP constants must have this prefix - toAsm << CV->getStrValue() << endl; + toAsm << CV->getStrValue() << "\n"; } else if (ConstantPointer* CPP = dyn_cast(CV)) { - if (! CPP->isNullValue()) - assert(0 && "Cannot yet print non-null pointer constants to assembly"); - else - toAsm << (void*) NULL << endl; + assert(CPP->isNullValue() && + "Cannot yet print non-null pointer constants to assembly"); + toAsm << "0\n"; } - else if (ConstantPointerRef* CPRef = dyn_cast(CV)) + else if (isa(CV)) { assert(0 && "Cannot yet initialize pointer refs in assembly"); } @@ -543,17 +542,17 @@ SparcAsmPrinter::printConstantValueOnly(const Constant* CV) if (CPA && isStringCompatible(CPA)) { // print the string alone and return - toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << endl; + toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << "\n"; } else if (CPA) { // Not a string. Print the values in successive locations - const vector& constValues = CPA->getValues(); + const std::vector &constValues = CPA->getValues(); for (unsigned i=1; i < constValues.size(); i++) this->printConstantValueOnly(cast(constValues[i].get())); } else if (ConstantStruct *CPS = dyn_cast(CV)) { // Print the fields in successive locations - const vector& constValues = CPS->getValues(); + const std::vector& constValues = CPS->getValues(); for (unsigned i=1; i < constValues.size(); i++) this->printConstantValueOnly(cast(constValues[i].get())); } @@ -571,25 +570,25 @@ SparcAsmPrinter::printConstant(const Constant* CV, string valID) valID = getID(CV); toAsm << "\t.align\t" << ConstantToAlignment(CV, Target) - << endl; + << "\n"; // Print .size and .type only if it is not a string. ConstantArray *CPA = dyn_cast(CV); if (CPA && isStringCompatible(CPA)) { // print it as a string and return - toAsm << valID << ":" << endl; - toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << endl; + toAsm << valID << ":\n"; + toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << "\n"; return; } - toAsm << "\t.type" << "\t" << valID << ",#object" << endl; + toAsm << "\t.type" << "\t" << valID << ",#object\n"; unsigned int constSize = ConstantToSize(CV, Target); if (constSize) toAsm << "\t.size" << "\t" << valID << "," - << constSize << endl; + << constSize << "\n"; - toAsm << valID << ":" << endl; + toAsm << valID << ":\n"; this->printConstantValueOnly(CV); } @@ -598,29 +597,29 @@ SparcAsmPrinter::printConstant(const Constant* CV, string valID) void SparcAsmPrinter::printGlobalVariable(const GlobalVariable* GV) { - toAsm << "\t.global\t" << getID(GV) << endl; + toAsm << "\t.global\t" << getID(GV) << "\n"; if (GV->hasInitializer()) printConstant(GV->getInitializer(), getID(GV)); else { toAsm << "\t.align\t" - << TypeToAlignment(GV->getType()->getElementType(), Target) << endl; - toAsm << "\t.type\t" << getID(GV) << ",#object" << endl; + << TypeToAlignment(GV->getType()->getElementType(), Target) << "\n"; + toAsm << "\t.type\t" << getID(GV) << ",#object\n"; toAsm << "\t.reserve\t" << getID(GV) << "," << TypeToSize(GV->getType()->getElementType(), Target) - << endl; + << "\n"; } } static void FoldConstants(const Module *M, - hash_set& moduleConstants) + std::hash_set& moduleConstants) { for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I) if (! (*I)->isExternal()) { - const hash_set& pool = + const std::hash_set& pool = MachineCodeForMethod::get(*I).getConstantPoolValues(); moduleConstants.insert(pool.begin(), pool.end()); } @@ -636,7 +635,7 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M) // lets force these constants into the slot table so that we can get // unique names for unnamed constants also. // - hash_set moduleConstants; + std::hash_set moduleConstants; FoldConstants(M, moduleConstants); // Now, emit the three data sections separately; the cost of I/O should @@ -654,7 +653,8 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M) } } - for (hash_set::const_iterator I = moduleConstants.begin(), + for (std::hash_set::const_iterator + I = moduleConstants.begin(), E = moduleConstants.end(); I != E; ++I) printConstant(*I); @@ -682,7 +682,7 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M) } } - toAsm << endl; + toAsm << "\n"; } @@ -705,7 +705,7 @@ SparcAsmPrinter::emitModule(const Module *M) // used. // void -UltraSparc::emitAssembly(const Module *M, ostream &toAsm) const +UltraSparc::emitAssembly(const Module *M, std::ostream &toAsm) const { SparcAsmPrinter Print(toAsm, M, *this); } diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index 99bb14d12e..e00c871545 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -27,7 +27,7 @@ static inline MachineInstr* CreateIntSetInstruction(int64_t C, Value* dest, - vector& tempVec) + std::vector& tempVec) { MachineInstr* minstr; uint64_t absC = (C >= 0)? C : -C; @@ -55,7 +55,7 @@ CreateIntSetInstruction(int64_t C, Value* dest, static inline MachineInstr* CreateUIntSetInstruction(uint64_t C, Value* dest, - vector& tempVec) + std::vector& tempVec) { MachineInstr* minstr; if (C > (unsigned int) ~0) @@ -109,9 +109,9 @@ UltraSparcInstrInfo::UltraSparcInstrInfo(const TargetMachine& tgt) // void UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val, - Instruction* dest, - vector& minstrVec, - vector& tempVec) const + Instruction* dest, + std::vector& minstrVec, + std::vector& tempVec) const { MachineInstr* minstr; @@ -200,19 +200,17 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val, // void UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method, - Value* val, - Instruction* dest, - vector& minstrVec, - vector& tempVec, - TargetMachine& target) const + Value* val, + Instruction* dest, + std::vector& minstrVec, + std::vector& tempVec, + TargetMachine& target) const { assert((val->getType()->isIntegral() || val->getType()->isPointerType()) && "Source type must be integral"); assert((dest->getType() ==Type::FloatTy || dest->getType() ==Type::DoubleTy) && "Dest type must be float/double"); - const MachineFrameInfo& frameInfo = ((UltraSparc&) target).getFrameInfo(); - MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(method); int offset = mcinfo.allocateLocalVar(target, val); @@ -246,19 +244,17 @@ UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(Method* method, // void UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(Method* method, - Value* val, - Instruction* dest, - vector& minstrVec, - vector& tempVec, - TargetMachine& target) const + Value* val, + Instruction* dest, + std::vector& minstrVec, + std::vector& tempVec, + TargetMachine& target) const { assert((val->getType() ==Type::FloatTy || val->getType() ==Type::DoubleTy) && "Source type must be float/double"); assert((dest->getType()->isIntegral() || dest->getType()->isPointerType()) && "Dest type must be integral"); - const MachineFrameInfo& frameInfo = ((UltraSparc&) target).getFrameInfo(); - MachineCodeForMethod& mcinfo = MachineCodeForMethod::get(method); int offset = mcinfo.allocateLocalVar(target, val); diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index c4fe735672..c20c65a5ce 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -25,7 +25,7 @@ #include "llvm/ConstantVals.h" #include "Support/MathExtras.h" #include - +using std::vector; //************************* Forward Declarations ***************************/ @@ -34,7 +34,7 @@ static void SetMemOperands_Internal (MachineInstr* minstr, const InstructionNode* vmInstrNode, Value* ptrVal, Value* arrayOffsetVal, - const vector& idxVec, + const std::vector& idxVec, const TargetMachine& target); @@ -143,7 +143,7 @@ ChooseBFpccInstruction(const InstructionNode* instrNode, static TmpInstruction* GetTmpForCC(Value* boolVal, const Method* method, const Type* ccType) { - typedef hash_map BoolTmpCache; + typedef std::hash_map BoolTmpCache; static BoolTmpCache boolToTmpCache; // Map boolVal -> TmpInstruction* static const Method* lastMethod = NULL; // Use to flush cache between methods @@ -519,7 +519,6 @@ CreateMulConstInstruction(TargetMachine &target, { MachineInstr* minstr = NULL; // return NULL if we cannot exploit constant getMinstr2 = NULL; // to create a cheaper instruction - bool needNeg = false; Value* constOp = ((InstrTreeNode*) instrNode->rightChild())->getValue(); assert(isa(constOp)); @@ -1011,8 +1010,6 @@ GetInstructionsForProlog(BasicBlock* entryBB, TargetMachine &target, MachineInstr** mvec) { - int64_t s0=0; // used to avoid overloading ambiguity below - const MachineFrameInfo& frameInfo = target.getFrameInfo(); // The second operand is the stack size. If it does not fit in the @@ -1048,11 +1045,10 @@ GetInstructionsForEpilog(BasicBlock* anExitBB, TargetMachine &target, MachineInstr** mvec) { - int64_t s0=0; // used to avoid overloading ambiguity below - mvec[0] = new MachineInstr(RESTORE); mvec[0]->SetMachineOperand(0, target.getRegInfo().getZeroRegNum()); - mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed, s0); + mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed, + (int64_t)0); mvec[0]->SetMachineOperand(2, target.getRegInfo().getZeroRegNum()); return 1; @@ -1118,8 +1114,6 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, bool checkCast = false; // initialize here to use fall-through int nextRule; int forwardOperandNum = -1; - int64_t s0=0, s8=8; // variables holding constants to avoid - uint64_t u0=0; // overloading ambiguities below for (unsigned i=0; i < MAX_INSTR_PER_VMINSTR; i++) mvec[i] = NULL; @@ -1162,7 +1156,8 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, mvec[0] = new MachineInstr(JMPLRET); mvec[0]->SetMachineOperand(0, MachineOperand::MO_VirtualRegister, returnReg); - mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed,s8); + mvec[0]->SetMachineOperand(1, MachineOperand::MO_SignExtendedImmed, + (int64_t)8); mvec[0]->SetMachineOperand(2, target.getRegInfo().getZeroRegNum()); if (returnInstr->getReturnValue() != NULL) @@ -1775,7 +1770,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, int n = numInstr++; mvec[n] = new MachineInstr(SETHI); mvec[n]->SetMachineOperand(0,MachineOperand::MO_UnextendedImmed, - s0); + (int64_t)0); mvec[n]->SetMachineOperand(1,MachineOperand::MO_VirtualRegister, setCCInstr); } @@ -2021,7 +2016,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, phi->getOperand(i)); break; } -#endif NEED_PHI_MACHINE_INSTRS +#endif // NEED_PHI_MACHINE_INSTRS case 71: // reg: VReg case 72: // reg: Constant diff --git a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h index f62457cb49..848ddddd38 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h +++ b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h @@ -58,4 +58,4 @@ ChooseStoreInstruction(const Type *DestTy) return 0; } -#endif SPARC_INSTR_SELECTION_SUPPORT_h +#endif diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h index 51609f683f..a82d122336 100644 --- a/lib/Target/SparcV9/SparcV9Internals.h +++ b/lib/Target/SparcV9/SparcV9Internals.h @@ -128,8 +128,8 @@ public: // virtual void CreateCodeToLoadConst(Value* val, Instruction* dest, - vector& minstrVec, - vector& tempVec) const; + std::vector& minstrVec, + std::vector& tmp) const; // Create an instruction sequence to copy an integer value `val' @@ -141,8 +141,8 @@ public: virtual void CreateCodeToCopyIntToFloat(Method* method, Value* val, Instruction* dest, - vector& minstrVec, - vector& tempVec, + std::vector& minstr, + std::vector& temp, TargetMachine& target) const; // Similarly, create an instruction sequence to copy an FP value @@ -152,8 +152,8 @@ public: virtual void CreateCodeToCopyFloatToInt(Method* method, Value* val, Instruction* dest, - vector& minstrVec, - vector& tempVec, + std::vector& minstr, + std::vector& temp, TargetMachine& target) const; // create copy instruction(s) @@ -161,7 +161,7 @@ public: CreateCopyInstructionsByType(const TargetMachine& target, Value* src, Instruction* dest, - vector& minstrVec) const; + std::vector& minstr) const; }; @@ -245,7 +245,7 @@ class UltraSparcRegInfo : public MachineRegInfo LiveRangeInfo& LRI) const; void suggestReg4CallAddr(const MachineInstr * CallMI, LiveRangeInfo& LRI, - vector RCList) const; + std::vector RCList) const; @@ -348,12 +348,13 @@ class UltraSparcRegInfo : public MachineRegInfo // the register allocator in association with method calling. See // SparcRegInfo.cpp for more details // - void moveInst2OrdVec(vector &OrdVec, MachineInstr *UnordInst, - PhyRegAlloc &PRA ) const; + void moveInst2OrdVec(std::vector &OrdVec, + MachineInstr *UnordInst, + PhyRegAlloc &PRA) const; - void OrderAddedInstrns( vector &UnordVec, - vector &OrdVec, - PhyRegAlloc &PRA) const; + void OrderAddedInstrns(std::vector &UnordVec, + std::vector &OrdVec, + PhyRegAlloc &PRA) const; // To find whether a particular call is to a var arg method @@ -410,7 +411,7 @@ class UltraSparcRegInfo : public MachineRegInfo else if( ty <= Type::DoubleTyID) res = FloatRegClassID; // sparc float reg class else { - cerr << "TypeID: " << ty << endl; + std::cerr << "TypeID: " << ty << "\n"; assert(0 && "Cannot resolve register class for type"); return 0; } @@ -449,10 +450,11 @@ class UltraSparcRegInfo : public MachineRegInfo LiveRangeInfo& LRI) const; void suggestRegs4CallArgs(const MachineInstr *const CallMI, - LiveRangeInfo& LRI, vector RCL) const; + LiveRangeInfo& LRI, + std::vector RCL) const; void suggestReg4RetValue(const MachineInstr *const RetMI, - LiveRangeInfo& LRI ) const; + LiveRangeInfo& LRI) const; void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI, @@ -493,7 +495,7 @@ class UltraSparcRegInfo : public MachineRegInfo // given the unified register number, this gives the name // for generating assembly code or debugging. // - inline const string getUnifiedRegName(int reg) const { + inline const std::string getUnifiedRegName(int reg) const { if( reg < 32 ) return SparcIntRegOrder::getRegName(reg); else if ( reg < (64 + 32) ) @@ -513,7 +515,7 @@ class UltraSparcRegInfo : public MachineRegInfo // The fllowing methods are used by instruction selection // - inline unsigned int getRegNumInCallersWindow(int reg) { + inline unsigned getRegNumInCallersWindow(int reg) { if (reg == InvalidRegNum || reg >= 32) return reg; return SparcIntRegOrder::getRegNumInCallersWindow(reg); @@ -1433,7 +1435,7 @@ public: // module. The specified module must have been compiled before this may be // used. // - virtual void emitAssembly(const Module *M, ostream &OutStr) const; + virtual void emitAssembly(const Module *M, std::ostream &OutStr) const; }; diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp index 6b39d61f5e..709a8f4c7f 100644 --- a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp @@ -1,7 +1,8 @@ -#include "llvm/CodeGen/IGNode.h" #include "SparcInternals.h" - +#include "llvm/CodeGen/IGNode.h" #include "llvm/Target/Sparc.h" +#include +using std::cerr; //----------------------------------------------------------------------------- // Int Register Class - method for coloring a node in the interference graph. @@ -37,7 +38,7 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const } if( DEBUG_RA ) { - cout << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:"; + cerr << "\nColoring LR [CallInt=" << LR->isCallInterference() <<"]:"; LR->printSet(); } @@ -53,18 +54,18 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const // there are no call interferences. Otherwise, it will get spilled. if (DEBUG_RA) - cout << "\n -Coloring with sug color: " << SugCol; + cerr << "\n -Coloring with sug color: " << SugCol; LR->setColor( LR->getSuggestedColor() ); return; } else if(DEBUG_RA) - cout << "\n Couldn't alloc Sug col - LR voloatile & calls interf"; + cerr << "\n Couldn't alloc Sug col - LR voloatile & calls interf"; } else if ( DEBUG_RA ) { // can't allocate the suggested col cerr << " \n Could NOT allocate the suggested color (already used) "; - LR->printSet(); cerr << endl; + LR->printSet(); cerr << "\n"; } } @@ -91,7 +92,7 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const if( ColorFound) { LR->setColor(c); // first color found in preffered order - if (DEBUG_RA) cout << "\n Colored after first search with col " << c ; + if (DEBUG_RA) cerr << "\n Colored after first search with col " << c ; } // if color is not found because of call interference @@ -113,7 +114,7 @@ void SparcIntRegClass::colorIGNode(IGNode * Node, bool IsColorUsedArr[]) const // since LR span across calls, must save across calls // LR->markForSaveAcrossCalls(); - if(DEBUG_RA) cout << "\n Colored after SECOND search with col " << c ; + if(DEBUG_RA) cerr << "\n Colored after SECOND search with col " << c ; } } @@ -193,7 +194,7 @@ void SparcFloatRegClass::colorIGNode(IGNode * Node,bool IsColorUsedArr[]) const } else if (DEBUG_RA) { // can't allocate the suggested col cerr << " Could NOT allocate the suggested color for LR "; - LR->printSet(); cerr << endl; + LR->printSet(); cerr << "\n"; } } diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.h b/lib/Target/SparcV9/SparcV9RegClassInfo.h index 0a5f5169d1..9127ffdaf6 100644 --- a/lib/Target/SparcV9/SparcV9RegClassInfo.h +++ b/lib/Target/SparcV9/SparcV9RegClassInfo.h @@ -17,7 +17,7 @@ // Int register names in same order as enum in class SparcIntRegOrder -static string const IntRegNames[] = +static const std::string IntRegNames[] = { "o0", "o1", "o2", "o3", "o4", "o5", "o7", "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7", @@ -75,7 +75,7 @@ class SparcIntRegOrder{ static unsigned int const NumOfAllRegs = o6 + 1; - static const string getRegName(const unsigned reg) { + static const std::string getRegName(const unsigned reg) { assert( reg < NumOfAllRegs ); return IntRegNames[reg]; } @@ -119,7 +119,7 @@ class SparcIntRegClass : public MachineRegClassInfo // Float Register Class //----------------------------------------------------------------------------- -static string const FloatRegNames[] = +static const std::string FloatRegNames[] = { "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19", @@ -157,7 +157,7 @@ class SparcFloatRegOrder{ static unsigned int const StartOfAllRegs = f0; - static const string getRegName(const unsigned reg) { + static const std::string getRegName(const unsigned reg) { assert( reg < NumOfAllRegs ); return FloatRegNames[reg]; } @@ -203,7 +203,7 @@ class SparcFloatRegClass : public MachineRegClassInfo //----------------------------------------------------------------------------- -static string const IntCCRegNames[] = +static const std::string IntCCRegNames[] = { "xcc", "ccr" }; @@ -218,7 +218,7 @@ class SparcIntCCRegOrder{ xcc, ccr // only one is available - see the note above }; - static const string getRegName(const unsigned reg) { + static const std::string getRegName(const unsigned reg) { assert( reg < 2 ); return IntCCRegNames[reg]; } @@ -253,7 +253,7 @@ public: //----------------------------------------------------------------------------- -static string const FloatCCRegNames[] = +static const std::string FloatCCRegNames[] = { "fcc0", "fcc1", "fcc2", "fcc3" }; @@ -268,7 +268,7 @@ class SparcFloatCCRegOrder{ fcc0, fcc1, fcc2, fcc3 }; - static const string getRegName(const unsigned reg) { + static const std::string getRegName(const unsigned reg) { assert( reg < 4 ); return FloatCCRegNames[reg]; } diff --git a/lib/Target/SparcV9/SparcV9RegInfo.cpp b/lib/Target/SparcV9/SparcV9RegInfo.cpp index 6543397957..dcfc5fa378 100644 --- a/lib/Target/SparcV9/SparcV9RegInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegInfo.cpp @@ -8,6 +8,8 @@ #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/CodeGen/PhyRegAlloc.h" #include "llvm/DerivedTypes.h" +#include +using std::cerr; //--------------------------------------------------------------------------- // Purpose: @@ -21,11 +23,10 @@ //--------------------------------------------------------------------------- const Value * UltraSparcRegInfo::getCallInstRetVal(const MachineInstr *CallMI) const { - unsigned OpCode = CallMI->getOpCode(); - unsigned NumOfImpRefs = CallMI->getNumImplicitRefs(); + unsigned NumOfImpRefs = CallMI->getNumImplicitRefs(); - if( OpCode == CALL ) { + if (OpCode == CALL) { // The one before the last implicit operand is the return value of // a CALL instr @@ -34,14 +35,13 @@ UltraSparcRegInfo::getCallInstRetVal(const MachineInstr *CallMI) const { if( CallMI->implicitRefIsDefined(NumOfImpRefs-2) ) return CallMI->getImplicitRef(NumOfImpRefs-2); - } - else if( OpCode == JMPLCALL) { + } else if (OpCode == JMPLCALL) { // The last implicit operand is the return value of a JMPL // - if( NumOfImpRefs > 0 ) - if( CallMI->implicitRefIsDefined(NumOfImpRefs-1) ) - return CallMI->getImplicitRef(NumOfImpRefs-1); + if(NumOfImpRefs > 0) + if (CallMI->implicitRefIsDefined(NumOfImpRefs-1)) + return CallMI->getImplicitRef(NumOfImpRefs-1); } else assert(0 && "OpCode must be CALL/JMPL for a call instr"); @@ -189,7 +189,7 @@ void UltraSparcRegInfo::suggestReg4RetAddr(const MachineInstr * RetMI, //--------------------------------------------------------------------------- void UltraSparcRegInfo::suggestReg4CallAddr(const MachineInstr * CallMI, LiveRangeInfo& LRI, - vector RCList) const { + std::vector RCList) const { const Value *RetAddrVal = getCallInstRetAddr( CallMI ); @@ -361,10 +361,8 @@ void UltraSparcRegInfo::colorMethodArgs(const Method *const Meth, // that on to the stack pos of LR if( isArgInReg ) { - - MachineInstr *AdIBef = - cpReg2MemMI(UniArgReg, getFramePointer(), - LR->getSpillOffFromFP(), RegType ); + cpReg2MemMI(UniArgReg, getFramePointer(), + LR->getSpillOffFromFP(), RegType ); FirstAI->InstrnsBefore.push_back( AdMI ); } @@ -404,7 +402,7 @@ void UltraSparcRegInfo::colorMethodArgs(const Method *const Meth, //--------------------------------------------------------------------------- void UltraSparcRegInfo::suggestRegs4CallArgs(const MachineInstr *const CallMI, LiveRangeInfo& LRI, - vector RCList) const { + std::vector RCList) const { assert ( (UltraSparcInfo->getInstrInfo()).isCall(CallMI->getOpCode()) ); @@ -469,7 +467,7 @@ void UltraSparcRegInfo::suggestRegs4CallArgs(const MachineInstr *const CallMI, if( !LR ) { if( DEBUG_RA) { cerr << " ERROR: In call instr, no LR for arg: " ; - printValue(CallArg); cerr << endl; + printValue(CallArg); cerr << "\n"; } assert(0 && "NO LR for call arg"); // continue; @@ -485,7 +483,7 @@ void UltraSparcRegInfo::suggestRegs4CallArgs(const MachineInstr *const CallMI, else if (DEBUG_RA) // Do NOTHING as this will be colored as a normal value. - cerr << " Regr not suggested for int call arg" << endl; + cerr << " Regr not suggested for int call arg\n"; } else if( RegType == FPSingleRegType && (argNo*2 +1)< NumOfFloatArgRegs) @@ -535,7 +533,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI, if( !RetValLR ) { cerr << "\nNo LR for:"; printValue( RetVal ); - cerr << endl; + cerr << "\n"; assert( RetValLR && "ERR:No LR for non-void return value"); //return; } @@ -601,7 +599,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI, // Now color all args of the call instruction //------------------------------------------- - vector AddedInstrnsBefore; + std::vector AddedInstrnsBefore; unsigned NumOfCallArgs = getCallInstNumArgs( CallMI ); @@ -662,7 +660,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI, if( !LR ) { if( DEBUG_RA) { cerr << " ERROR: In call instr, no LR for arg: " ; - printValue(CallArg); cerr << endl; + printValue(CallArg); cerr << "\n"; } assert(0 && "NO LR for call arg"); // continue; @@ -812,7 +810,7 @@ void UltraSparcRegInfo::colorCallArgs(const MachineInstr *const CallMI, cerr << *(AddedInstrnsBefore[i]); } - vector TmpVec; + std::vector TmpVec; OrderAddedInstrns(AddedInstrnsBefore, TmpVec, PRA); if( DEBUG_RA ) { @@ -855,13 +853,12 @@ void UltraSparcRegInfo::suggestReg4RetValue(const MachineInstr *const RetMI, // The first implicit operand is the return value of a return instr const Value *RetVal = RetMI->getImplicitRef(0); - MachineInstr *AdMI; LiveRange *const LR = LRI.getLiveRangeForValue( RetVal ); if( !LR ) { cerr << "\nNo LR for:"; printValue( RetVal ); - cerr << endl; + cerr << "\n"; assert( LR && "No LR for return value of non-void method"); //return; } @@ -898,13 +895,12 @@ void UltraSparcRegInfo::colorRetValue(const MachineInstr *const RetMI, // The first implicit operand is the return value of a return instr const Value *RetVal = RetMI->getImplicitRef(0); - MachineInstr *AdMI; LiveRange *const LR = LRI.getLiveRangeForValue( RetVal ); if( ! LR ) { cerr << "\nNo LR for:"; printValue( RetVal ); - cerr << endl; + cerr << "\n"; // assert( LR && "No LR for return value of non-void method"); return; } @@ -941,16 +937,14 @@ void UltraSparcRegInfo::colorRetValue(const MachineInstr *const RetMI, // the LR received UniLRReg but must be colored with UniRetReg // to pass as the return value - - AdMI = cpReg2RegMI( UniLRReg, UniRetReg, RegType); - RetAI->InstrnsBefore.push_back( AdMI ); + RetAI->InstrnsBefore.push_back(cpReg2RegMI(UniLRReg, UniRetReg, RegType)); } else { // if the LR is spilled - - AdMI = cpMem2RegMI(getFramePointer(), LR->getSpillOffFromFP(), - UniRetReg, RegType); - RetAI->InstrnsBefore.push_back( AdMI ); - cout << "\nCopied the return value from stack"; + MachineInstr *AdMI = cpMem2RegMI(getFramePointer(), + LR->getSpillOffFromFP(), + UniRetReg, RegType); + RetAI->InstrnsBefore.push_back(AdMI); + cerr << "\nCopied the return value from stack\n"; } } // if there is a return value @@ -1179,9 +1173,7 @@ void UltraSparcRegInfo::insertCallerSavingCode(const MachineInstr *MInst, // has set to record which registers were saved/restored // - hash_set PushedRegSet; - - + std::hash_set PushedRegSet; // Now find the LR of the return value of the call // The last *implicit operand* is the return value of a call @@ -1394,7 +1386,7 @@ void UltraSparcRegInfo::printReg(const LiveRange *const LR) { cerr << " *Node " << (LR->getUserIGNode())->getIndex(); if( ! LR->hasColor() ) { - cerr << " - could not find a color" << endl; + cerr << " - could not find a color\n"; return; } @@ -1403,15 +1395,13 @@ void UltraSparcRegInfo::printReg(const LiveRange *const LR) { cerr << " colored with color "<< LR->getColor(); if( RegClassID == IntRegClassID ) { + cerr<< " [" << SparcIntRegOrder::getRegName(LR->getColor()) << "]\n"; - cerr<< " [" << SparcIntRegOrder::getRegName(LR->getColor()) ; - cerr << "]" << endl; - } - else if ( RegClassID == FloatRegClassID) { + } else if ( RegClassID == FloatRegClassID) { cerr << "[" << SparcFloatRegOrder::getRegName(LR->getColor()); if( LR->getTypeID() == Type::DoubleTyID ) cerr << "+" << SparcFloatRegOrder::getRegName(LR->getColor()+1); - cerr << "]" << endl; + cerr << "]\n"; } } @@ -1436,9 +1426,9 @@ void UltraSparcRegInfo::printReg(const LiveRange *const LR) { //--------------------------------------------------------------------------- -void UltraSparcRegInfo::OrderAddedInstrns( vector &UnordVec, - vector &OrdVec, - PhyRegAlloc &PRA) const{ +void UltraSparcRegInfo::OrderAddedInstrns(std::vector &UnordVec, + std::vector &OrdVec, + PhyRegAlloc &PRA) const{ /* Problem: We can have instructions inserted by RegAlloc like @@ -1476,7 +1466,7 @@ void UltraSparcRegInfo::OrderAddedInstrns( vector &UnordVec, CouldMoveAll = true; - vector::iterator DefIt = UnordVec.begin(); + std::vector::iterator DefIt = UnordVec.begin(); for( ; DefIt != UnordVec.end(); ++DefIt ) { @@ -1498,7 +1488,7 @@ void UltraSparcRegInfo::OrderAddedInstrns( vector &UnordVec, bool DefEqUse = false; - vector::iterator UseIt = DefIt; + std::vector::iterator UseIt = DefIt; UseIt++; for( ; UseIt != UnordVec.end(); ++UseIt ) { @@ -1572,7 +1562,7 @@ void UltraSparcRegInfo::OrderAddedInstrns( vector &UnordVec, -void UltraSparcRegInfo::moveInst2OrdVec(vector &OrdVec, +void UltraSparcRegInfo::moveInst2OrdVec(std::vector &OrdVec, MachineInstr *UnordInst, PhyRegAlloc &PRA ) const { @@ -1585,7 +1575,7 @@ void UltraSparcRegInfo::moveInst2OrdVec(vector &OrdVec, // before in the OrdVec bool DefEqUse = false; - vector::iterator OrdIt = OrdVec.begin(); + std::vector::iterator OrdIt = OrdVec.begin(); for( ; OrdIt != OrdVec.end(); ++OrdIt ) { diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp index 9524e80515..dd9e330474 100644 --- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp +++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp @@ -17,7 +17,8 @@ #include "llvm/CodeGen/PhyRegAlloc.h" #include "llvm/Analysis/LiveVar/MethodLiveVarInfo.h" #include "llvm/Method.h" - +#include +using std::cerr; // Build the MachineInstruction Description Array... const MachineInstrDescriptor SparcMachineInstrDesc[] = { @@ -47,10 +48,9 @@ void AllocateRegisters(Method *M, TargetMachine &target) if ( (M)->isExternal() ) // don't process prototypes return; - if( DEBUG_RA ) { - cerr << endl << "******************** Method "<< (M)->getName(); - cerr << " ********************" <getName() + << " ********************\n"; MethodLiveVarInfo LVI(M ); // Analyze live varaibles LVI.analyze(); @@ -60,7 +60,7 @@ void AllocateRegisters(Method *M, TargetMachine &target) PRA.allocateRegisters(); - if( DEBUG_RA ) cerr << endl << "Register allocation complete!" << endl; + if( DEBUG_RA ) cerr << "\nRegister allocation complete!\n"; } diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index b290f29b85..0df60fde67 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -40,7 +40,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) StructSize = (StructSize/TyAlign + 1) * TyAlign; // Add padding... // Keep track of maximum alignment constraint - StructAlignment = max(TyAlign, StructAlignment); + StructAlignment = std::max(TyAlign, StructAlignment); MemberOffsets.push_back(StructSize); StructSize += TySize; // Consume space for this data item... @@ -71,7 +71,7 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T, // TargetData Class Implementation //===----------------------------------------------------------------------===// -TargetData::TargetData(const string &TargetName, unsigned char PtrSize = 8, +TargetData::TargetData(const std::string &TargetName, unsigned char PtrSize = 8, unsigned char PtrAl = 8, unsigned char DoubleAl = 8, unsigned char FloatAl = 4, unsigned char LongAl = 8, unsigned char IntAl = 4, unsigned char ShortAl = 2, @@ -146,7 +146,7 @@ unsigned char TargetData::getTypeAlignment(const Type *Ty) const { } unsigned TargetData::getIndexedOffset(const Type *ptrTy, - const vector &Idx) const { + const std::vector &Idx) const { const PointerType *PtrTy = cast(ptrTy); unsigned Result = 0; diff --git a/lib/Target/TargetSchedInfo.cpp b/lib/Target/TargetSchedInfo.cpp index f9dca290b0..c02654f03b 100644 --- a/lib/Target/TargetSchedInfo.cpp +++ b/lib/Target/TargetSchedInfo.cpp @@ -21,8 +21,8 @@ resourceId_t MachineResource::nextId = 0; // (stl_algo.h). // inline static bool -RUConflict(const vector& fromRVec, - const vector& toRVec) +RUConflict(const std::vector& fromRVec, + const std::vector& toRVec) { unsigned fN = fromRVec.size(), tN = toRVec.size(); @@ -57,7 +57,7 @@ ComputeMinGap(const InstrRUsage &fromRU, { // check if instr. #2 can start executing `gap' cycles after #1 // by checking for resource conflicts in each overlapping cycle - cycles_t numOverlap = min(fromRU.numCycles - gap, toRU.numCycles); + cycles_t numOverlap =std::min(fromRU.numCycles - gap, toRU.numCycles); for (cycles_t c = 0; c <= numOverlap-1; c++) if (RUConflict(fromRU.resourcesByCycle[gap + c], toRU.resourcesByCycle[c])) @@ -102,7 +102,7 @@ MachineSchedInfo::initializeResources() // most instructions will probably behave the same as their class. // Cannot allocate a vector of InstrRUsage so new each one. // - vector instrRUForClasses; + std::vector instrRUForClasses; instrRUForClasses.resize(numSchedClasses); for (InstrSchedClass sc = 0; sc < numSchedClasses; sc++) { // instrRUForClasses.push_back(new InstrRUsage); @@ -116,7 +116,7 @@ MachineSchedInfo::initializeResources() void -MachineSchedInfo::computeInstrResources(const vector& +MachineSchedInfo::computeInstrResources(const std::vector& instrRUForClasses) { int numOpCodes = mii->getNumRealOpCodes(); @@ -146,7 +146,7 @@ MachineSchedInfo::computeInstrResources(const vector& void -MachineSchedInfo::computeIssueGaps(const vector& +MachineSchedInfo::computeIssueGaps(const std::vector& instrRUForClasses) { int numOpCodes = mii->getNumRealOpCodes(); @@ -186,7 +186,7 @@ MachineSchedInfo::computeIssueGaps(const vector& { issueGaps[OpCodePair(fromOp,toOp)] = instrPairGap; conflictLists[fromOp].push_back(toOp); - longestIssueConflict = max(longestIssueConflict, instrPairGap); + longestIssueConflict = std::max(longestIssueConflict, instrPairGap); } } } diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 02e14b6caa..7f33fe280b 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -18,6 +18,8 @@ #include "Support/STLExtras.h" #include #include +#include +using std::cerr; #include "llvm/Assembly/Writer.h" @@ -96,7 +98,8 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty, } static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty, - const string &Name, ValueMapCache &VMC){ + const std::string &Name, + ValueMapCache &VMC){ BasicBlock *BB = MI->getParent(); BasicBlock::iterator It = BB->end(); @@ -270,7 +273,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty, // index array. If there are, check to see if removing them causes us to // get to the right type... // - vector Indices = GEP->copyIndices(); + std::vector Indices = GEP->copyIndices(); const Type *BaseType = GEP->getPointerOperand()->getType(); const Type *ElTy = 0; @@ -302,7 +305,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty, // Check to see if 'N' is an expression that can be converted to // the appropriate size... if so, allow it. // - vector Indices; + std::vector Indices; const Type *ElTy = ConvertableToGEP(PTy, I->getOperand(1), Indices); if (ElTy) { assert(ElTy == PVTy && "Internal error, setup wrong!"); @@ -378,7 +381,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { BasicBlock *BB = I->getParent(); BasicBlock::InstListType &BIL = BB->getInstList(); - string Name = I->getName(); if (!Name.empty()) I->setName(""); + std::string Name = I->getName(); if (!Name.empty()) I->setName(""); Instruction *Res; // Result of conversion ValueHandle IHandle(VMC, I); // Prevent I from being removed! @@ -460,7 +463,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { // index array. If there are, check to see if removing them causes us to // get to the right type... // - vector Indices = GEP->copyIndices(); + std::vector Indices = GEP->copyIndices(); const Type *BaseType = GEP->getPointerOperand()->getType(); const Type *PVTy = cast(Ty)->getElementType(); Res = 0; @@ -491,7 +494,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) { // Check to see if 'N' is an expression that can be converted to // the appropriate size... if so, allow it. // - vector Indices; + std::vector Indices; const Type *ElTy = ConvertableToGEP(NewSrcTy, I->getOperand(1), Indices, &It); if (ElTy) { @@ -634,7 +637,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty, case Instruction::Add: if (isa(Ty)) { Value *IndexVal = I->getOperand(V == I->getOperand(0) ? 1 : 0); - vector Indices; + std::vector Indices; if (const Type *ETy = ConvertableToGEP(Ty, IndexVal, Indices)) { const Type *RetTy = PointerType::get(ETy); @@ -685,7 +688,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty, // They could be loading the first element of a composite type... if (const CompositeType *CT = dyn_cast(LoadedTy)) { unsigned Offset = 0; // No offset, get first leaf. - vector Indices; // Discarded... + std::vector Indices; // Discarded... LoadedTy = getStructOffsetType(CT, Offset, Indices, false); assert(Offset == 0 && "Offset changed from zero???"); } @@ -751,7 +754,7 @@ static bool OperandConvertableToType(User *U, Value *V, const Type *Ty, // Check to see if the second argument is an expression that can // be converted to the appropriate size... if so, allow it. // - vector Indices; + std::vector Indices; const Type *ElTy = ConvertableToGEP(Ty, Index, Indices); delete TempScale; // Free our temporary multiply if we made it @@ -823,7 +826,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, BasicBlock *BB = I->getParent(); BasicBlock::InstListType &BIL = BB->getInstList(); - string Name = I->getName(); if (!Name.empty()) I->setName(""); + std::string Name = I->getName(); if (!Name.empty()) I->setName(""); Instruction *Res; // Result of conversion //cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I << "BB Before: " << BB << endl; @@ -844,12 +847,12 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, case Instruction::Add: if (isa(NewTy)) { Value *IndexVal = I->getOperand(OldVal == I->getOperand(0) ? 1 : 0); - vector Indices; + std::vector Indices; BasicBlock::iterator It = find(BIL.begin(), BIL.end(), I); if (const Type *ETy = ConvertableToGEP(NewTy, IndexVal, Indices, &It)) { // If successful, convert the add to a GEP - const Type *RetTy = PointerType::get(ETy); + //const Type *RetTy = PointerType::get(ETy); // First operand is actually the given pointer... Res = new GetElementPtrInst(NewVal, Indices, Name); assert(cast(Res->getType())->getElementType() == ETy && @@ -892,7 +895,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, const Type *LoadedTy = cast(NewVal->getType())->getElementType(); - vector Indices; + std::vector Indices; Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); if (const CompositeType *CT = dyn_cast(LoadedTy)) { @@ -914,7 +917,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), NewPT, VMC)); } else { // Replace the source pointer const Type *ValTy = cast(NewTy)->getElementType(); - vector Indices; + std::vector Indices; #if 0 Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); while (ArrayType *AT = dyn_cast(ValTy)) { @@ -948,7 +951,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, // Perform the conversion now... // - vector Indices; + std::vector Indices; const Type *ElTy = ConvertableToGEP(NewVal->getType(), Index, Indices, &It); assert(ElTy != 0 && "GEP Conversion Failure!"); Res = new GetElementPtrInst(NewVal, Indices, Name); @@ -965,7 +968,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, // Check to see if the second argument is an expression that can // be converted to the appropriate size... if so, allow it. // - vector Indices; + std::vector Indices; const Type *ElTy = ConvertableToGEP(NewVal->getType(), I->getOperand(1), Indices, &It); assert(ElTy != 0 && "GEP Conversion Failure!"); @@ -1001,9 +1004,10 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, case Instruction::Call: { Value *Meth = I->getOperand(0); - vector Params(I->op_begin()+1, I->op_end()); + std::vector Params(I->op_begin()+1, I->op_end()); - vector::iterator OI = find(Params.begin(), Params.end(), OldVal); + std::vector::iterator OI = + find(Params.begin(), Params.end(), OldVal); assert (OI != Params.end() && "Not using value!"); *OI = NewVal; diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp index e28e8a2fe4..43ed725d94 100644 --- a/lib/Transforms/HoistPHIConstants.cpp +++ b/lib/Transforms/HoistPHIConstants.cpp @@ -14,8 +14,8 @@ #include #include -typedef pair BBConstTy; -typedef map CachedCopyMap; +typedef std::pair BBConstTy; +typedef std::map CachedCopyMap; static Value *NormalizePhiOperand(PHINode *PN, Value *CPV, BasicBlock *Pred, CachedCopyMap &CopyCache) { @@ -33,7 +33,7 @@ static Value *NormalizePhiOperand(PHINode *PN, Value *CPV, // Create a copy instruction and add it to the cache... CastInst *Inst = new CastInst(CPV, CPV->getType()); - CopyCache.insert(make_pair(BBConstTy(Pred, CPV), Inst)); + CopyCache.insert(std::make_pair(BBConstTy(Pred, CPV), Inst)); // Insert the copy just before the terminator inst of the predecessor BB assert(Pred->getTerminator() && "Degenerate BB encountered!"); @@ -52,7 +52,7 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) { bool Changed = false; for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) { - vector phis; // normalizing invalidates BB iterator + std::vector phis; // normalizing invalidates BB iterator for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) { if (PHINode *PN = dyn_cast(*II)) @@ -61,7 +61,7 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) { break; // All PHIs occur at top of BB! } - for (vector::iterator PI=phis.begin(); PI != phis.end(); ++PI) + for (std::vector::iterator PI=phis.begin(); PI != phis.end();++PI) for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i) { Value *Op = (*PI)->getIncomingValue(i); diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 70e3437bb9..ff2442d2b6 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -23,7 +23,7 @@ // static inline bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, - map &CMap) { + std::map &CMap) { Module::GlobalListType &GList = M->getGlobalList(); if (GList.size() <= ConstantNo) return false; // No new constants bool MadeChanges = false; @@ -35,10 +35,10 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, Constant *Init = GV->getInitializer(); // Check to see if the initializer is already known... - map::iterator I = CMap.find(Init); + std::map::iterator I = CMap.find(Init); if (I == CMap.end()) { // Nope, add it to the map - CMap.insert(make_pair(Init, GV)); + CMap.insert(std::make_pair(Init, GV)); } else { // Yup, this is a duplicate! // Make all uses of the duplicate constant use the cannonical version... GV->replaceAllUsesWith(I->second); @@ -59,7 +59,7 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo, // deal with passes. // bool ConstantMerge::mergeDuplicateConstants(Module *M) { - map Constants; + std::map Constants; unsigned LastConstantSeen = 0; return ::mergeDuplicateConstants(M, LastConstantSeen, Constants); } diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index ec4c3fd66e..d5e9ea07bd 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -23,6 +23,10 @@ #include "llvm/iTerminators.h" #include "llvm/iOther.h" #include +#include +using std::vector; +using std::string; +using std::cerr; static const Type *PtrSByte = 0; // 'sbyte*' type @@ -78,7 +82,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) { SymbolTable *ST = M->getSymbolTable(); if (!ST) return false; - map > Methods; + std::map > Methods; // Loop over the entries in the symbol table. If an entry is a method pointer, // then add it to the Methods map. We do a two pass algorithm here to avoid @@ -86,7 +90,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) { // for (SymbolTable::iterator I = ST->begin(), E = ST->end(); I != E; ++I) if (const PointerType *PT = dyn_cast(I->first)) - if (const MethodType *MT = dyn_cast(PT->getElementType())) { + if (isa(PT->getElementType())) { SymbolTable::VarMap &Plane = I->second; for (SymbolTable::type_iterator PI = Plane.begin(), PE = Plane.end(); PI != PE; ++PI) { @@ -101,7 +105,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) { // Now we have a list of all methods with a particular name. If there is more // than one entry in a list, merge the methods together. // - for (map >::iterator I = Methods.begin(), + for (std::map >::iterator I = Methods.begin(), E = Methods.end(); I != E; ++I) { vector &Methods = I->second; Method *Implementation = 0; // Find the implementation @@ -145,7 +149,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) { cerr << "Warning: Found methods types that are not compatible:\n"; for (unsigned i = 0; i < Methods.size(); ++i) { cerr << "\t" << Methods[i]->getType()->getDescription() << " %" - << Methods[i]->getName() << endl; + << Methods[i]->getName() << "\n"; } cerr << " No linkage of methods named '" << Methods[0]->getName() << "' performed!\n"; @@ -185,7 +189,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) { ++i; } } else { - cerr << "Cannot convert use of method: " << U << endl; + cerr << "Cannot convert use of method: " << U << "\n"; ++i; } } @@ -201,7 +205,7 @@ bool CleanupGCCOutput::PatchUpMethodReferences(Module *M) { // ShouldNukSymtabEntry - Return true if this module level symbol table entry // should be eliminated. // -static inline bool ShouldNukeSymtabEntry(const pair &E) { +static inline bool ShouldNukeSymtabEntry(const std::pair &E) { // Nuke all names for primitive types! if (cast(E.second)->isPrimitiveType()) return true; @@ -357,8 +361,8 @@ static inline bool FixCastsAndPHIs(BasicBlock *BB) { Value *Src = CI->getOperand(0); // Move the cast instruction to the current insert position... - --InsertPos; // New position for cast to go... - swap(*InsertPos, *I); // Cast goes down, PHI goes up + --InsertPos; // New position for cast to go... + std::swap(*InsertPos, *I); // Cast goes down, PHI goes up if (isa(Src) && // Handle case #1 cast(Src)->getParent() == BB) { @@ -561,7 +565,7 @@ bool CleanupGCCOutput::doPassFinalization(Module *M) { if (M->hasSymbolTable()) { SymbolTable *ST = M->getSymbolTable(); - const set &UsedTypes = FUT.getTypes(); + const std::set &UsedTypes = FUT.getTypes(); // Check the symbol table for superfluous type entries that aren't used in // the program diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index 7395bab803..dacd3295ef 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -18,14 +18,14 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) { // Calculate which methods are reachable from the external methods in the call // graph. // - set ReachableNodes(df_begin(&CallGraph), - df_end(&CallGraph)); + std::set ReachableNodes(df_begin(&CallGraph), + df_end(&CallGraph)); // Loop over the methods in the module twice. The first time is used to drop // references that methods have to each other before they are deleted. The // second pass removes the methods that need to be removed. // - vector MethodsToDelete; // Track unused methods + std::vector MethodsToDelete; // Track unused methods for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) { cfg::CallGraphNode *N = CallGraph[*I]; if (!ReachableNodes.count(N)) { // Not reachable?? @@ -45,7 +45,7 @@ static bool RemoveUnreachableMethods(Module *M, cfg::CallGraph *CG) { // Unreachables methods have been found and should have no references to them, // delete them now. // - for (vector::iterator I = MethodsToDelete.begin(), + for (std::vector::iterator I = MethodsToDelete.begin(), E = MethodsToDelete.end(); I != E; ++I) delete CallGraph.removeMethodFromModule(*I); diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 40b98bd67d..9d86c86895 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -27,6 +27,8 @@ #include "llvm/iOther.h" #include #include +#include +using std::cerr; #include "llvm/Assembly/Writer.h" @@ -36,7 +38,7 @@ using namespace opt; // current values into those specified by ValueMap. // static inline void RemapInstruction(Instruction *I, - map &ValueMap) { + std::map &ValueMap) { for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) { const Value *Op = I->getOperand(op); @@ -45,8 +47,8 @@ static inline void RemapInstruction(Instruction *I, continue; // Globals and constants don't get relocated if (!V) { - cerr << "Val = " << endl << Op << "Addr = " << (void*)Op << endl; - cerr << "Inst = " << I; + cerr << "Val = \n" << Op << "Addr = " << (void*)Op; + cerr << "\nInst = " << I; } assert(V && "Referenced value not in value map!"); I->setOperand(op, V); @@ -72,10 +74,9 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) { const Method *CalledMeth = CI->getCalledMethod(); if (CalledMeth == 0 || // Can't inline external method or indirect call! CalledMeth->isExternal()) return false; - Method *CurrentMeth = CI->getParent()->getParent(); //cerr << "Inlining " << CalledMeth->getName() << " into " - // << CurrentMeth->getName() << endl; + // << CurrentMeth->getName() << "\n"; BasicBlock *OrigBB = CI->getParent(); @@ -111,7 +112,7 @@ bool opt::InlineMethod(BasicBlock::iterator CIIt) { // code's values. This includes all of: Method arguments, instruction values, // constant pool entries, and basic blocks. // - map ValueMap; + std::map ValueMap; // Add the method arguments to the mapping: (start counting at 1 to skip the // method reference itself) diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index c91c00c647..df2b67ef41 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -21,6 +21,9 @@ #include "llvm/iTerminators.h" #include "llvm/iOther.h" #include +using std::map; +using std::make_pair; +using std::vector; // To enable debugging, uncomment this... //#define DEBUG_MST(x) x @@ -37,7 +40,7 @@ struct ValuePlaceHolder : public Instruction { ValuePlaceHolder(const Type *Ty) : Instruction(Ty, UserOp1, "") {} - virtual Instruction *clone() const { abort(); } + virtual Instruction *clone() const { abort(); return 0; } virtual const char *getOpcodeName() const { return "placeholder"; } }; @@ -291,8 +294,8 @@ bool MutateStructTypes::doPassInitialization(Module *M) { // of the methods and global variables that we no longer need. bool MutateStructTypes::doPassFinalization(Module *M) { // The first half of the methods in the module have to go. - unsigned NumMethods = M->size(); - unsigned NumGVars = M->gsize(); + //unsigned NumMethods = M->size(); + //unsigned NumGVars = M->gsize(); // Prepare for deletion of globals by dropping their interdependencies... for(Module::iterator I = M->begin(); I != M->end(); ++I) { @@ -436,12 +439,11 @@ bool MutateStructTypes::doPerMethodWork(Method *m) { AdjustIndices(cast(PTy), Indices); } - if (const LoadInst *LI = dyn_cast(I)) { + if (isa(I)) { NewI = new LoadInst(NewPtr, Indices); - } else if (const StoreInst *SI = dyn_cast(I)) { + } else if (isa(I)) { NewI = new StoreInst(ConvertValue(I->getOperand(0)), NewPtr, Indices); - } else if (const GetElementPtrInst *GEP = - dyn_cast(I)) { + } else if (isa(I)) { NewI = new GetElementPtrInst(NewPtr, Indices); } else { assert(0 && "Unknown memory access inst!!!"); diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index d9385453e8..d0b8bb2807 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -12,9 +12,14 @@ #include "llvm/Analysis/FindUnsafePointerTypes.h" #include "TransformInternals.h" #include +#include +using std::vector; +using std::set; +using std::pair; #include "llvm/Assembly/Writer.h" + // PruneTypes - Given a type Ty, make sure that neither it, or one of its // subtypes, occur in TypesToModify. // @@ -26,7 +31,7 @@ static void PruneTypes(const Type *Ty, set &TypesToModify, // If the element is in TypesToModify, remove it now... if (const StructType *ST = dyn_cast(Ty)) { TypesToModify.erase(ST); // This doesn't fail if the element isn't present - cerr << "Unable to swap type: " << ST << endl; + std::cerr << "Unable to swap type: " << ST << "\n"; } // Remove all types that this type contains as well... do not remove types @@ -69,7 +74,8 @@ static inline void GetTransformation(const StructType *ST, // Build mapping from index to size for (unsigned i = 0; i < NumElements; ++i) - ElList.push_back(make_pair(i, TD.getTypeSize(ST->getElementTypes()[i]))); + ElList.push_back( + std::make_pair(i, TD.getTypeSize(ST->getElementTypes()[i]))); sort(ElList.begin(), ElList.end(), ptr_fun(FirstLess)); @@ -118,14 +124,14 @@ PrebuiltStructMutation::TransformsType set ProcessedTypes; for (set::const_iterator I = UnsafePTys.begin(), E = UnsafePTys.end(); I != E; ++I) { - //cerr << "Pruning type: " << *I << endl; + //cerr << "Pruning type: " << *I << "\n"; PruneTypes(*I, TypesToModify, ProcessedTypes); } // Build up a set of structure types that we are going to modify, and // information describing how to modify them. - map > Transforms; + std::map > Transforms; for (set::iterator I = TypesToModify.begin(), E = TypesToModify.end(); I != E; ++I) { diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index 7948266c25..00acac8d1f 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -18,7 +18,8 @@ #include "llvm/Assembly/Writer.h" #include "Support/StringExtras.h" #include - +using std::vector; +using std::string; // Add a prototype for printf if it is not already in the program. // @@ -110,8 +111,6 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI, // Escape Message by replacing all % characters with %% chars. unsigned Offset = 0; while ((Offset = Message.find('%', Offset)) != string::npos) { - string::iterator Offs = Message.begin()+Offset; - //Message.replace(Offs, Offs+1, "%%"); Message.replace(Offset, 2, "%%"); Offset += 2; // Skip over the new %'s } @@ -140,7 +139,7 @@ static void InsertPrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI, static void InsertVerbosePrintInst(Value *V, BasicBlock *BB, BasicBlock::iterator &BBI, const string &Message, Method *Printf) { - ostringstream OutStr; + std::ostringstream OutStr; if (V) WriteAsOperand(OutStr, V); InsertPrintInst(V, BB, BBI, Message+OutStr.str()+" = ", Printf); } @@ -184,7 +183,7 @@ static void TraceValuesAtBBExit(BasicBlock *BB, Method *Printf, // Copy all of the instructions into a vector to avoid problems with Setcc const vector Insts(BB->begin(), InsertPos); - ostringstream OutStr; + std::ostringstream OutStr; WriteAsOperand(OutStr, BB, false); InsertPrintInst(0, BB, InsertPos, "LEAVING BB:" + OutStr.str(), Printf); @@ -211,7 +210,7 @@ static inline void InsertCodeToShowMethodEntry(Method *M, Method *Printf) { BasicBlock *BB = M->getEntryNode(); BasicBlock::iterator BBI = BB->begin(); - ostringstream OutStr; + std::ostringstream OutStr; WriteAsOperand(OutStr, M, true); InsertPrintInst(0, BB, BBI, "ENTERING METHOD: " + OutStr.str(), Printf); @@ -231,7 +230,7 @@ static inline void InsertCodeToShowMethodExit(BasicBlock *BB, Method *Printf) { BasicBlock::iterator BBI = BB->end()-1; ReturnInst *Ret = cast(*BBI); - ostringstream OutStr; + std::ostringstream OutStr; WriteAsOperand(OutStr, BB->getParent(), true); InsertPrintInst(0, BB, BBI, "LEAVING METHOD: " + OutStr.str(), Printf); @@ -249,8 +248,6 @@ bool InsertTraceCode::doit(Method *M, bool traceBasicBlockExits, vector valuesStoredInMethod; vector exitBlocks; - Module *module = M->getParent(); - if (traceMethodEvents) InsertCodeToShowMethodEntry(M, Printf); diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index e47eb90642..f140676937 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -75,7 +75,7 @@ static bool HandleCastToPointer(BasicBlock::iterator BI, } } - vector Indices; + std::vector Indices; Value *Src = CI->getOperand(0); const Type *Result = ConvertableToGEP(DestPTy, Src, Indices, &BI); if (Result == 0) return false; // Not convertable... @@ -137,7 +137,7 @@ static bool PeepholeOptimizeAddCast(BasicBlock *BB, BasicBlock::iterator &BI, if (!CompTy || !SrcPtr || !OffsetVal->getType()->isIntegral()) return false; - vector Indices; + std::vector Indices; if (!ConvertableToGEP(SrcPtr->getType(), OffsetVal, Indices, &BI)) return false; // Not convertable... perhaps next time @@ -174,7 +174,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { PRINT_PEEPHOLE1("cast-of-self-ty", CI); CI->replaceAllUsesWith(Src); if (!Src->hasName() && CI->hasName()) { - string Name = CI->getName(); + std::string Name = CI->getName(); CI->setName(""); Src->setName(Name, BB->getParent()->getSymbolTable()); } @@ -299,7 +299,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) { const Type *ElTy = 0; // Build the index vector, full of all zeros - vector Indices; + std::vector Indices; Indices.push_back(ConstantUInt::get(Type::UIntTy, 0)); while (CurCTy && !isa(CurCTy)) { if (const StructType *CurSTy = dyn_cast(CurCTy)) { diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index a38dbc5617..45a57a2f43 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -17,6 +17,8 @@ #include "Support/DepthFirstIterator.h" #include #include +#include +using std::cerr; #define DEBUG_ADCE 1 @@ -28,8 +30,8 @@ // class ADCE { Method *M; // The method that we are working on... - vector WorkList; // Instructions that just became live - set LiveSet; // The set of live instructions + std::vector WorkList; // Instructions that just became live + std::set LiveSet; // The set of live instructions bool MadeChanges; //===--------------------------------------------------------------------===// @@ -66,8 +68,8 @@ private: // fixupCFG - Walk the CFG in depth first order, eliminating references to // dead blocks. // - BasicBlock *fixupCFG(BasicBlock *Head, set &VisitedBlocks, - const set &AliveBlocks); + BasicBlock *fixupCFG(BasicBlock *Head, std::set &VisitedBlocks, + const std::set &AliveBlocks); }; @@ -121,7 +123,7 @@ bool ADCE::doADCE() { // AliveBlocks - Set of basic blocks that we know have instructions that are // alive in them... // - set AliveBlocks; + std::set AliveBlocks; // Process the work list of instructions that just became live... if they // became live, then that means that all of their operands are neccesary as @@ -169,7 +171,7 @@ bool ADCE::doADCE() { // After the worklist is processed, recursively walk the CFG in depth first // order, patching up references to dead blocks... // - set VisitedBlocks; + std::set VisitedBlocks; BasicBlock *EntryBlock = fixupCFG(M->front(), VisitedBlocks, AliveBlocks); if (EntryBlock && EntryBlock != M->front()) { if (isa(EntryBlock->front())) { @@ -194,7 +196,7 @@ bool ADCE::doADCE() { } else { // We need to move the new entry block to be the first bb of the method. Method::iterator EBI = find(M->begin(), M->end(), EntryBlock); - swap(*EBI, *M->begin()); // Exchange old location with start of method + std::swap(*EBI, *M->begin());// Exchange old location with start of method MadeChanges = true; } } @@ -242,8 +244,8 @@ bool ADCE::doADCE() { // been in the alive set). // 3. Return the nonnull child, or 0 if no non-null children. // -BasicBlock *ADCE::fixupCFG(BasicBlock *BB, set &VisitedBlocks, - const set &AliveBlocks) { +BasicBlock *ADCE::fixupCFG(BasicBlock *BB, std::set &VisitedBlocks, + const std::set &AliveBlocks) { if (VisitedBlocks.count(BB)) return 0; // Revisiting a node? No update. VisitedBlocks.insert(BB); // We have now visited this node! diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index c267d95ea4..a961bad927 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -159,7 +159,7 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) { bool opt::ConstantPropogation::doConstantPropogation(BasicBlock *BB, BasicBlock::iterator &II) { Instruction *Inst = *II; - if (BinaryOperator *BInst = dyn_cast(Inst)) { + if (isa(Inst)) { Constant *D1 = dyn_cast(Inst->getOperand(0)); Constant *D2 = dyn_cast(Inst->getOperand(1)); diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 6c4e3d2a20..eadf7b18e0 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -117,7 +117,7 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { // If there is more than one predecessor, and there are PHI nodes in // the successor, then we need to add incoming edges for the PHI nodes // - const vector BBPreds(BB->pred_begin(), BB->pred_end()); + const std::vector BBPreds(BB->pred_begin(), BB->pred_end()); // Check to see if one of the predecessors of BB is already a predecessor of // Succ. If so, we cannot do the transformation! @@ -134,7 +134,7 @@ static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) { Value *OldVal = PN->removeIncomingValue(BB); assert(OldVal && "No entry in PHI for Pred BB!"); - for (vector::const_iterator PredI = BBPreds.begin(), + for (std::vector::const_iterator PredI = BBPreds.begin(), End = BBPreds.end(); PredI != End; ++PredI) { // Add an incoming value for each of the new incoming values... PN->addIncoming(OldVal, *PredI); diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index d03b4f3f40..35844cadb6 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -35,7 +35,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) { // Transform all subloops before this loop... bool Changed = reduce_apply_bool(Loop->getSubLoops().begin(), Loop->getSubLoops().end(), - std::bind1st(ptr_fun(TransformLoop), Loops)); + std::bind1st(std::ptr_fun(TransformLoop), Loops)); // Get the header node for this loop. All of the phi nodes that could be // induction variables must live in this basic block. BasicBlock *Header = (BasicBlock*)Loop->getBlocks().front(); @@ -44,7 +44,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) { // induction variables that they represent... stuffing the induction variable // info into a vector... // - vector IndVars; // Induction variables for block + std::vector IndVars; // Induction variables for block for (BasicBlock::iterator I = Header->begin(); PHINode *PN = dyn_cast(*I); ++I) IndVars.push_back(InductionVariable(PN, Loops)); @@ -133,7 +133,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) { Instruction *Val = IterCount; if (!isa(IV->Step) || // If the step != 1 !cast(IV->Step)->equalsInt(1)) { - string Name; // Create a scale by the step value... + std::string Name; // Create a scale by the step value... if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-scale"; // If the types are not compatible, insert a cast now... @@ -148,7 +148,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) { if (!isa(IV->Start) || // If the start != 0 !cast(IV->Start)->isNullValue()) { - string Name; // Create a offset by the start value... + std::string Name; // Create a offset by the start value... if (IV->Phi->hasName()) Name = IV->Phi->getName()+"-offset"; // If the types are not compatible, insert a cast now... @@ -170,7 +170,7 @@ static bool TransformLoop(cfg::LoopInfo *Loops, cfg::Loop *Loop) { IV->Phi->replaceAllUsesWith(Val); // Move the PHI name to it's new equivalent value... - string OldName = IV->Phi->getName(); + std::string OldName = IV->Phi->getName(); IV->Phi->setName(""); Val->setName(OldName); diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index d4b7bc5010..93ab189dee 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -27,6 +27,8 @@ #include "llvm/iPHINode.h" #include "Support/STLExtras.h" #include +#include +using std::cerr; #include "llvm/Analysis/LoopDepth.h" @@ -176,7 +178,7 @@ static inline bool isSimpleInductionVar(PHINode *PN) { // present induction variables (instead of always using uint) // static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) { - string PHIName, AddName; + std::string PHIName, AddName; BasicBlock *Header = Int->getHeaderNode(); Method *M = Header->getParent(); @@ -205,7 +207,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) { assert(++PI == Header->pred_end() && "Header node should have 2 preds!"); // Make Pred1 be the loop entrance predecessor, Pred2 be the Loop predecessor - if (Int->contains(Pred1)) swap(Pred1, Pred2); + if (Int->contains(Pred1)) std::swap(Pred1, Pred2); assert(!Int->contains(Pred1) && "Pred1 should be loop entrance!"); assert( Int->contains(Pred2) && "Pred2 should be looping edge!"); @@ -250,7 +252,7 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) { static bool ProcessInterval(cfg::Interval *Int) { if (!Int->isLoop()) return false; // Not a loop? Ignore it! - vector InductionVars; + std::vector InductionVars; BasicBlock *Header = Int->getHeaderNode(); // Loop over all of the PHI nodes in the interval header... @@ -278,7 +280,7 @@ static bool ProcessInterval(cfg::Interval *Int) { if (isLoopInvariant(Int, V2)) { // They *are* loop invariant. Exchange BB1/BB2 and V1/V2 so that // V1 is always the loop invariant computation. - swap(V1, V2); swap(BB1, BB2); + std::swap(V1, V2); std::swap(BB1, BB2); } else { // Neither value is loop invariant. Must not be an induction variable. // This case can happen if there is an unreachable loop in the CFG that @@ -292,7 +294,7 @@ static bool ProcessInterval(cfg::Interval *Int) { // anything about BB2/V2. Check now to see if V2 is a linear induction // variable. // - cerr << "Found loop invariant computation: " << V1 << endl; + cerr << "Found loop invariant computation: " << V1 << "\n"; if (!isLinearInductionVariable(Int, V2, PN)) continue; // No, it is not a linear ind var, ignore the PHI node. @@ -308,7 +310,7 @@ static bool ProcessInterval(cfg::Interval *Int) { if (InductionVars.empty()) return false; // Search to see if there is already a "simple" induction variable. - vector::iterator It = + std::vector::iterator It = find_if(InductionVars.begin(), InductionVars.end(), isSimpleInductionVar); PHINode *PrimaryIndVar; @@ -329,7 +331,7 @@ static bool ProcessInterval(cfg::Interval *Int) { "How could Primary IndVar not be in the header!?!!?"); if (i != Header->begin()) - iter_swap(i, Header->begin()); + std::iter_swap(i, Header->begin()); } // Now we know that there is a simple induction variable PrimaryIndVar. @@ -364,7 +366,7 @@ static bool ProcessIntervalPartition(cfg::IntervalPartition &IP) { // variables in intervals that represent loops. // return reduce_apply(IP.begin(), IP.end(), bitwise_or(), false, - ptr_fun(ProcessInterval)); + std::ptr_fun(ProcessInterval)); } // DoInductionVariableCannonicalize - Simplify induction variables in loops. diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 87f8ed1897..795418f939 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -76,7 +76,7 @@ static Instruction *CombineIndicies(MemAccessInst *MAI) { dyn_cast(MAI->getPointerOperand()); if (!Src) return 0; - vector Indices; + std::vector Indices; // Only special case we have to watch out for is pointer arithmetic on the // 0th index of MAI. @@ -128,7 +128,7 @@ bool InstructionCombining::CombineInstruction(Instruction *I) { bool InstructionCombining::doit(Method *M) { // Start the worklist out with all of the instructions in the method in it. - vector WorkList(M->inst_begin(), M->inst_end()); + std::vector WorkList(M->inst_begin(), M->inst_end()); while (!WorkList.empty()) { Instruction *I = WorkList.back(); // Get an instruction from the worklist diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 26a52d61bf..68be844095 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -30,6 +30,8 @@ #include #include #include +#include +using std::cerr; // InstVal class - This class represents the different lattice values that an // instruction may occupy. It is a simple class with value semantics. The @@ -84,13 +86,13 @@ public: // It's public interface consists of a constructor and a doSCCP() method. // class SCCP { - Method *M; // The method that we are working on... + Method *M; // The method that we are working on... - set BBExecutable; // The basic blocks that are executable - map ValueState; // The state each value is in... + std::set BBExecutable;// The basic blocks that are executable + std::map ValueState; // The state each value is in... - vector InstWorkList; // The instruction work list - vector BBWorkList; // The BasicBlock work list + std::vector InstWorkList;// The instruction work list + std::vector BBWorkList; // The BasicBlock work list //===--------------------------------------------------------------------===// // The public interface for this class @@ -144,7 +146,7 @@ private: // Instruction object, then use this accessor to get its value from the map. // inline InstVal &getValueState(Value *V) { - map::iterator I = ValueState.find(V); + std::map::iterator I = ValueState.find(V); if (I != ValueState.end()) return I->second; // Common case, in the map if (Constant *CPV = dyn_cast(V)) { // Constants are constant diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index bb4f01c90b..417376b89d 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -24,7 +24,7 @@ static bool StripSymbolTable(SymbolTable *SymTab) { bool RemovedSymbol = false; for (SymbolTable::iterator I = SymTab->begin(); I != SymTab->end(); ++I) { - map &Plane = I->second; + std::map &Plane = I->second; SymbolTable::type_iterator B; while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane! diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index cd6288540a..6c7f856619 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -82,7 +82,7 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To) { // false if you want a leaf // const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, - vector &Offsets, + std::vector &Offsets, bool StopEarly = true) { if (Offset == 0 && StopEarly && !Offsets.empty()) return Ty; // Return the leaf type @@ -130,7 +130,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, // instruction. The type returned is the root type that the GEP would point to // const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, - vector &Indices, + std::vector &Indices, BasicBlock::iterator *BI = 0) { const CompositeType *CompTy = dyn_cast(Ty); if (CompTy == 0) return 0; diff --git a/lib/Transforms/TransformInternals.h b/lib/Transforms/TransformInternals.h index 200a4d7b98..7bc3df4fc3 100644 --- a/lib/Transforms/TransformInternals.h +++ b/lib/Transforms/TransformInternals.h @@ -24,7 +24,7 @@ // extern const TargetData TD; -static int getConstantValue(const ConstantInt *CPI) { +static inline int getConstantValue(const ConstantInt *CPI) { if (const ConstantSInt *CSI = dyn_cast(CPI)) return CSI->getValue(); return cast(CPI)->getValue(); @@ -65,25 +65,26 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To); // If BI is nonnull, cast instructions are inserted as appropriate for the // arguments of the getelementptr. // -const Type *ConvertableToGEP(const Type *Ty, Value *V, vector &Indices, +const Type *ConvertableToGEP(const Type *Ty, Value *V, + std::vector &Indices, BasicBlock::iterator *BI = 0); // ------------- Expression Conversion --------------------- -typedef map ValueTypeCache; +typedef std::map ValueTypeCache; struct ValueMapCache { // Operands mapped - Contains an entry if the first value (the user) has had // the second value (the operand) mapped already. // - set OperandsMapped; + std::set OperandsMapped; // Expression Map - Contains an entry from the old value to the new value of // an expression that has been converted over. // - map ExprMap; - typedef map ExprMapTy; + std::map ExprMap; + typedef std::map ExprMapTy; }; @@ -137,7 +138,7 @@ public: // false if you want a leaf // const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, - vector &Offsets, + std::vector &Offsets, bool StopEarly = true); #endif diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index f04c8a46a3..e1622529c2 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -17,6 +17,10 @@ #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/ConstantVals.h" +#include +using std::cerr; +using std::string; +using std::map; // Error - Simple wrapper function to conditionally assign to E and return true. // This just makes error return conditions a little bit simpler... @@ -70,7 +74,7 @@ static void PrintMap(const map &M) { for (map::const_iterator I = M.begin(), E = M.end(); I != E; ++I) { cerr << " Fr: " << (void*)I->first << " " << I->first - << " To: " << (void*)I->second << " " << I->second << endl; + << " To: " << (void*)I->second << " " << I->second << "\n"; } } @@ -97,15 +101,15 @@ static Value *RemapOperand(const Value *In, map &LocalMap, Constant *Result = 0; if (ConstantArray *CPA = dyn_cast(CPV)) { - const vector &Ops = CPA->getValues(); - vector Operands(Ops.size()); + const std::vector &Ops = CPA->getValues(); + std::vector Operands(Ops.size()); for (unsigned i = 0; i < Ops.size(); ++i) Operands[i] = cast(RemapOperand(Ops[i], LocalMap, GlobalMap)); Result = ConstantArray::get(cast(CPA->getType()), Operands); } else if (ConstantStruct *CPS = dyn_cast(CPV)) { - const vector &Ops = CPS->getValues(); - vector Operands(Ops.size()); + const std::vector &Ops = CPS->getValues(); + std::vector Operands(Ops.size()); for (unsigned i = 0; i < Ops.size(); ++i) Operands[i] = cast(RemapOperand(Ops[i], LocalMap, GlobalMap)); @@ -120,7 +124,7 @@ static Value *RemapOperand(const Value *In, map &LocalMap, } // Cache the mapping in our local map structure... - LocalMap.insert(make_pair(In, CPV)); + LocalMap.insert(std::make_pair(In, CPV)); return Result; } @@ -132,7 +136,7 @@ static Value *RemapOperand(const Value *In, map &LocalMap, PrintMap(*GlobalMap); } - cerr << "Couldn't remap value: " << (void*)In << " " << In << endl; + cerr << "Couldn't remap value: " << (void*)In << " " << In << "\n"; assert(0 && "Couldn't remap value!"); return 0; } @@ -172,7 +176,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, " - Global variables differ in const'ness"); // Okay, everything is cool, remember the mapping... - ValueMap.insert(make_pair(SGV, DGV)); + ValueMap.insert(std::make_pair(SGV, DGV)); } else { // No linking to be performed, simply create an identical version of the // symbol over in the dest module... the initializer will be filled in @@ -186,7 +190,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, Dest->getGlobalList().push_back(DGV); // Make sure to remember this mapping... - ValueMap.insert(make_pair(SGV, DGV)); + ValueMap.insert(std::make_pair(SGV, DGV)); } } return false; @@ -262,7 +266,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src, SM->getName() + "\" - Method is already defined!"); // Otherwise, just remember this mapping... - ValueMap.insert(make_pair(SM, DM)); + ValueMap.insert(std::make_pair(SM, DM)); } else { // Method does not already exist, simply insert an external method // signature identical to SM into the dest module... @@ -273,7 +277,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src, Dest->getMethodList().push_back(DM); // ... and remember this mapping... - ValueMap.insert(make_pair(SM, DM)); + ValueMap.insert(std::make_pair(SM, DM)); } } return false; @@ -300,7 +304,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, Dest->getArgumentList().push_back(DMA); // Add a mapping to our local map - LocalMap.insert(make_pair(SMA, DMA)); + LocalMap.insert(std::make_pair(SMA, DMA)); } // Loop over all of the basic blocks, copying the instructions over... @@ -310,7 +314,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, // Create new basic block and add to mapping and the Dest method... BasicBlock *DBB = new BasicBlock(SBB->getName(), Dest); - LocalMap.insert(make_pair(SBB, DBB)); + LocalMap.insert(std::make_pair(SBB, DBB)); // Loop over all of the instructions in the src basic block, copying them // over. Note that this is broken in a strict sense because the cloned @@ -324,7 +328,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, Instruction *DI = SI->clone(); DI->setName(SI->getName()); DBB->getInstList().push_back(DI); - LocalMap.insert(make_pair(SI, DI)); + LocalMap.insert(std::make_pair(SI, DI)); } } diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 666b6d976e..ca1085e3ed 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -14,6 +14,8 @@ #include "llvm/iOther.h" #include "llvm/SymbolTable.h" #include "llvm/ConstantVals.h" +using std::vector; + // doPassInitialization - For the lower allocations pass, this ensures that a // module contains a declaration for a malloc and a free function. diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index efc7676bb7..56c4b204ca 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -11,6 +11,7 @@ #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" #include "llvm/Type.h" +using std::vector; // UnifyAllExitNodes - Unify all exit nodes of the CFG by creating a new // BasicBlock, and converting all returns to unconditional branches to this diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 2b3a1c4c22..c218c0fcd0 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -26,6 +26,10 @@ #include "Support/STLExtras.h" #include #include +using std::string; +using std::map; +using std::vector; +using std::ostream; static const Module *getModuleFromVal(const Value *V) { if (const MethodArgument *MA =dyn_cast(V)) @@ -112,7 +116,7 @@ static void fillTypeNameTable(const Module *M, const Type *Ty = cast(I->second); if (!isa(Ty) || !cast(Ty)->getElementType()->isPrimitiveType()) - TypeNames.insert(make_pair(Ty, "%"+I->first)); + TypeNames.insert(std::make_pair(Ty, "%"+I->first)); } } } @@ -215,7 +219,7 @@ static ostream &printTypeInt(ostream &Out, const Type *Ty, // vector TypeStack; string TypeName = calcTypeName(Ty, TypeStack, TypeNames); - TypeNames.insert(make_pair(Ty, TypeName)); // Cache type name for later use + TypeNames.insert(std::make_pair(Ty, TypeName));//Cache type name for later use return Out << TypeName; } @@ -331,7 +335,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) { writeOperand(GV->getInitializer(), false, false); printInfoComment(GV); - Out << endl; + Out << "\n"; } @@ -348,7 +352,7 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) { if (const Constant *CPV = dyn_cast(V)) { printConstant(CPV); } else if (const Type *Ty = dyn_cast(V)) { - Out << "\t%" << I->first << " = type " << Ty->getDescription() << endl; + Out << "\t%" << I->first << " = type " << Ty->getDescription() << "\n"; } } } @@ -378,7 +382,7 @@ void AssemblyWriter::printConstant(const Constant *CPV) { else Out << ""; } - Out << endl; + Out << "\n"; } // printMethod - Print all aspects of a method. @@ -614,7 +618,7 @@ void AssemblyWriter::printInstruction(const Instruction *I) { } printInfoComment(I); - Out << endl; + Out << "\n"; } diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 861aea43c2..df999b84bf 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -18,7 +18,7 @@ // template class ValueHolder; -BasicBlock::BasicBlock(const string &name, Method *Parent) +BasicBlock::BasicBlock(const std::string &name, Method *Parent) : Value(Type::LabelTy, Value::BasicBlockVal, name), InstList(this, 0), machineInstrVec(new MachineCodeForBasicBlock) { if (Parent) @@ -32,7 +32,7 @@ BasicBlock::~BasicBlock() { } // Specialize setName to take care of symbol table majik -void BasicBlock::setName(const string &name, SymbolTable *ST) { +void BasicBlock::setName(const std::string &name, SymbolTable *ST) { Method *P; assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) && "Invalid symtab argument!"); diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 257bd7622c..d9a2fa7431 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -15,6 +15,10 @@ #include #include +using std::map; +using std::pair; +using std::make_pair; + ConstantBool *ConstantBool::True = new ConstantBool(true); ConstantBool *ConstantBool::False = new ConstantBool(false); @@ -24,7 +28,7 @@ ConstantBool *ConstantBool::False = new ConstantBool(false); //===----------------------------------------------------------------------===// // Specialize setName to take care of symbol table majik -void Constant::setName(const string &Name, SymbolTable *ST) { +void Constant::setName(const std::string &Name, SymbolTable *ST) { assert(ST && "Type::setName - Must provide symbol table argument!"); if (Name.size()) ST->insert(Name, this); @@ -56,6 +60,7 @@ Constant *Constant::getNullConstant(const Type *Ty) { #ifndef NDEBUG #include "llvm/Assembly/Writer.h" +using std::cerr; #endif void Constant::destroyConstantImpl() { @@ -70,8 +75,8 @@ void Constant::destroyConstantImpl() { Value *V = use_back(); #ifndef NDEBUG // Only in -g mode... if (!isa(V)) { - cerr << "While deleting: " << this << endl; - cerr << "Use still stuck around after Def is destroyed: " << V << endl; + cerr << "While deleting: " << this << "\n"; + cerr << "Use still stuck around after Def is destroyed: " << V << "\n"; } #endif assert(isa(V) && "References remain to ConstantPointerRef!"); @@ -115,7 +120,7 @@ ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty) { } ConstantArray::ConstantArray(const ArrayType *T, - const vector &V) : Constant(T) { + const std::vector &V) : Constant(T) { for (unsigned i = 0; i < V.size(); i++) { assert(V[i]->getType() == T->getElementType()); Operands.push_back(Use(V[i], this)); @@ -123,7 +128,7 @@ ConstantArray::ConstantArray(const ArrayType *T, } ConstantStruct::ConstantStruct(const StructType *T, - const vector &V) : Constant(T) { + const std::vector &V) : Constant(T) { const StructType::ElementTypes &ETypes = T->getElementTypes(); for (unsigned i = 0; i < V.size(); i++) { @@ -142,24 +147,24 @@ ConstantPointerRef::ConstantPointerRef(GlobalValue *GV) //===----------------------------------------------------------------------===// // getStrValue implementations -string ConstantBool::getStrValue() const { +std::string ConstantBool::getStrValue() const { return Val ? "true" : "false"; } -string ConstantSInt::getStrValue() const { +std::string ConstantSInt::getStrValue() const { return itostr(Val.Signed); } -string ConstantUInt::getStrValue() const { +std::string ConstantUInt::getStrValue() const { return utostr(Val.Unsigned); } -string ConstantFP::getStrValue() const { +std::string ConstantFP::getStrValue() const { return ftostr(Val); } -string ConstantArray::getStrValue() const { - string Result; +std::string ConstantArray::getStrValue() const { + std::string Result; // As a special case, print the array as a string if it is an array of // ubytes or an array of sbytes with positive values. @@ -208,8 +213,8 @@ string ConstantArray::getStrValue() const { return Result; } -string ConstantStruct::getStrValue() const { - string Result = "{"; +std::string ConstantStruct::getStrValue() const { + std::string Result = "{"; if (Operands.size()) { Result += " " + Operands[0]->getType()->getDescription() + " " + cast(Operands[0])->getStrValue(); @@ -221,11 +226,11 @@ string ConstantStruct::getStrValue() const { return Result + " }"; } -string ConstantPointerNull::getStrValue() const { +std::string ConstantPointerNull::getStrValue() const { return "null"; } -string ConstantPointerRef::getStrValue() const { +std::string ConstantPointerRef::getStrValue() const { const GlobalValue *V = getValue(); if (V->hasName()) return "%" + V->getName(); @@ -233,7 +238,7 @@ string ConstantPointerRef::getStrValue() const { int Slot = Table->getValSlot(V); delete Table; - if (Slot >= 0) return string(" %") + itostr(Slot); + if (Slot >= 0) return std::string(" %") + itostr(Slot); else return ""; } @@ -337,7 +342,7 @@ unsigned ConstantFP::hash(const Type *Ty, double V) { } unsigned ConstantArray::hash(const ArrayType *Ty, - const vector &V) { + const std::vector &V) { unsigned Result = (Ty->getUniqueID() << 5) ^ (Ty->getUniqueID() * 7); for (unsigned i = 0; i < V.size(); ++i) Result ^= V[i]->getHash() << (i & 7); @@ -345,7 +350,7 @@ unsigned ConstantArray::hash(const ArrayType *Ty, } unsigned ConstantStruct::hash(const StructType *Ty, - const vector &V) { + const std::vector &V) { unsigned Result = (Ty->getUniqueID() << 5) ^ (Ty->getUniqueID() * 7); for (unsigned i = 0; i < V.size(); ++i) Result ^= V[i]->getHash() << (i & 7); @@ -418,10 +423,10 @@ ConstantFP *ConstantFP::get(const Type *Ty, double V) { //---- ConstantArray::get() implementation... // -static ValueMap, ConstantArray> ArrayConstants; +static ValueMap, ConstantArray> ArrayConstants; ConstantArray *ConstantArray::get(const ArrayType *Ty, - const vector &V) { + const std::vector &V) { ConstantArray *Result = ArrayConstants.get(Ty, V); if (!Result) // If no preexisting value, create one now... ArrayConstants.add(Ty, V, Result = new ConstantArray(Ty, V)); @@ -432,8 +437,8 @@ ConstantArray *ConstantArray::get(const ArrayType *Ty, // contain the specified string. A null terminator is added to the specified // string so that it may be used in a natural way... // -ConstantArray *ConstantArray::get(const string &Str) { - vector ElementVals; +ConstantArray *ConstantArray::get(const std::string &Str) { + std::vector ElementVals; for (unsigned i = 0; i < Str.length(); ++i) ElementVals.push_back(ConstantSInt::get(Type::SByteTy, Str[i])); @@ -455,10 +460,10 @@ void ConstantArray::destroyConstant() { //---- ConstantStruct::get() implementation... // -static ValueMap, ConstantStruct> StructConstants; +static ValueMap, ConstantStruct> StructConstants; ConstantStruct *ConstantStruct::get(const StructType *Ty, - const vector &V) { + const std::vector &V) { ConstantStruct *Result = StructConstants.get(Ty, V); if (!Result) // If no preexisting value, create one now... StructConstants.add(Ty, V, Result = new ConstantStruct(Ty, V)); diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 2ed02dbed2..2e4f6e4df1 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -10,6 +10,8 @@ #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" #include +using std::set; + //===----------------------------------------------------------------------===// // Helper Template diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index 4b38ce1196..e7d10c1496 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -25,7 +25,7 @@ template class ValueHolder; template class ValueHolder; -Method::Method(const MethodType *Ty, bool isInternal, const string &name) +Method::Method(const MethodType *Ty, bool isInternal, const std::string &name) : GlobalValue(PointerType::get(Ty), Value::MethodVal, isInternal, name), SymTabValue(this), BasicBlocks(this), ArgumentList(this, this) { assert(::isa(Ty) && "Method signature must be of method type!"); @@ -45,7 +45,7 @@ Method::~Method() { } // Specialize setName to take care of symbol table majik -void Method::setName(const string &name, SymbolTable *ST) { +void Method::setName(const std::string &name, SymbolTable *ST) { Module *P; assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) && "Invalid symtab argument!"); @@ -87,14 +87,14 @@ void Method::dropAllReferences() { GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern, Constant *Initializer = 0, - const string &Name = "") + const std::string &Name = "") : GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name), isConstantGlobal(constant) { if (Initializer) Operands.push_back(Use((Value*)Initializer, this)); } // Specialize setName to take care of symbol table majik -void GlobalVariable::setName(const string &name, SymbolTable *ST) { +void GlobalVariable::setName(const std::string &name, SymbolTable *ST) { Module *P; assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) && "Invalid symtab argument!"); diff --git a/lib/VMCore/InstrTypes.cpp b/lib/VMCore/InstrTypes.cpp index 69a703c0c7..a4c8212632 100644 --- a/lib/VMCore/InstrTypes.cpp +++ b/lib/VMCore/InstrTypes.cpp @@ -21,7 +21,7 @@ TerminatorInst::TerminatorInst(Instruction::TermOps iType) } TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType, - const string &Name = "") + const std::string &Name = "") : Instruction(Ty, iType, Name) { } @@ -31,7 +31,7 @@ TerminatorInst::TerminatorInst(const Type *Ty, Instruction::TermOps iType, //===----------------------------------------------------------------------===// // Specialize setName to take care of symbol table majik -void MethodArgument::setName(const string &name, SymbolTable *ST) { +void MethodArgument::setName(const std::string &name, SymbolTable *ST) { Method *P; assert((ST == 0 || (!getParent() || ST == getParent()->getSymbolTable())) && "Invalid symtab argument!"); @@ -45,7 +45,7 @@ void MethodArgument::setName(const string &name, SymbolTable *ST) { // PHINode Class //===----------------------------------------------------------------------===// -PHINode::PHINode(const Type *Ty, const string &name) +PHINode::PHINode(const Type *Ty, const std::string &name) : Instruction(Ty, Instruction::PHINode, name) { } diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 8b37510d35..186c85007e 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -10,7 +10,7 @@ #include "llvm/SymbolTable.h" #include "llvm/CodeGen/MachineInstr.h" -Instruction::Instruction(const Type *ty, unsigned it, const string &Name) +Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name) : User(ty, Value::InstructionVal, Name), machineInstrVec(new MachineCodeForVMInstr) { Parent = 0; @@ -23,7 +23,7 @@ Instruction::~Instruction() { } // Specialize setName to take care of symbol table majik -void Instruction::setName(const string &name, SymbolTable *ST) { +void Instruction::setName(const std::string &name, SymbolTable *ST) { BasicBlock *P = 0; Method *PP = 0; assert((ST == 0 || !getParent() || !getParent()->getParent() || ST == getParent()->getParent()->getSymbolTable()) && @@ -44,7 +44,7 @@ void Instruction::addMachineInstruction(MachineInstr* minstr) { // sequence of forward declarations. Trying to fix that will // cause a serious circularity in link order. // -const vector &Instruction::getTempValuesForMachineCode() const { +const std::vector &Instruction::getTempValuesForMachineCode() const { return machineInstrVec->getTempValues(); } #endif diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index f04c8a46a3..e1622529c2 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -17,6 +17,10 @@ #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/ConstantVals.h" +#include +using std::cerr; +using std::string; +using std::map; // Error - Simple wrapper function to conditionally assign to E and return true. // This just makes error return conditions a little bit simpler... @@ -70,7 +74,7 @@ static void PrintMap(const map &M) { for (map::const_iterator I = M.begin(), E = M.end(); I != E; ++I) { cerr << " Fr: " << (void*)I->first << " " << I->first - << " To: " << (void*)I->second << " " << I->second << endl; + << " To: " << (void*)I->second << " " << I->second << "\n"; } } @@ -97,15 +101,15 @@ static Value *RemapOperand(const Value *In, map &LocalMap, Constant *Result = 0; if (ConstantArray *CPA = dyn_cast(CPV)) { - const vector &Ops = CPA->getValues(); - vector Operands(Ops.size()); + const std::vector &Ops = CPA->getValues(); + std::vector Operands(Ops.size()); for (unsigned i = 0; i < Ops.size(); ++i) Operands[i] = cast(RemapOperand(Ops[i], LocalMap, GlobalMap)); Result = ConstantArray::get(cast(CPA->getType()), Operands); } else if (ConstantStruct *CPS = dyn_cast(CPV)) { - const vector &Ops = CPS->getValues(); - vector Operands(Ops.size()); + const std::vector &Ops = CPS->getValues(); + std::vector Operands(Ops.size()); for (unsigned i = 0; i < Ops.size(); ++i) Operands[i] = cast(RemapOperand(Ops[i], LocalMap, GlobalMap)); @@ -120,7 +124,7 @@ static Value *RemapOperand(const Value *In, map &LocalMap, } // Cache the mapping in our local map structure... - LocalMap.insert(make_pair(In, CPV)); + LocalMap.insert(std::make_pair(In, CPV)); return Result; } @@ -132,7 +136,7 @@ static Value *RemapOperand(const Value *In, map &LocalMap, PrintMap(*GlobalMap); } - cerr << "Couldn't remap value: " << (void*)In << " " << In << endl; + cerr << "Couldn't remap value: " << (void*)In << " " << In << "\n"; assert(0 && "Couldn't remap value!"); return 0; } @@ -172,7 +176,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, " - Global variables differ in const'ness"); // Okay, everything is cool, remember the mapping... - ValueMap.insert(make_pair(SGV, DGV)); + ValueMap.insert(std::make_pair(SGV, DGV)); } else { // No linking to be performed, simply create an identical version of the // symbol over in the dest module... the initializer will be filled in @@ -186,7 +190,7 @@ static bool LinkGlobals(Module *Dest, const Module *Src, Dest->getGlobalList().push_back(DGV); // Make sure to remember this mapping... - ValueMap.insert(make_pair(SGV, DGV)); + ValueMap.insert(std::make_pair(SGV, DGV)); } } return false; @@ -262,7 +266,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src, SM->getName() + "\" - Method is already defined!"); // Otherwise, just remember this mapping... - ValueMap.insert(make_pair(SM, DM)); + ValueMap.insert(std::make_pair(SM, DM)); } else { // Method does not already exist, simply insert an external method // signature identical to SM into the dest module... @@ -273,7 +277,7 @@ static bool LinkMethodProtos(Module *Dest, const Module *Src, Dest->getMethodList().push_back(DM); // ... and remember this mapping... - ValueMap.insert(make_pair(SM, DM)); + ValueMap.insert(std::make_pair(SM, DM)); } } return false; @@ -300,7 +304,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, Dest->getArgumentList().push_back(DMA); // Add a mapping to our local map - LocalMap.insert(make_pair(SMA, DMA)); + LocalMap.insert(std::make_pair(SMA, DMA)); } // Loop over all of the basic blocks, copying the instructions over... @@ -310,7 +314,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, // Create new basic block and add to mapping and the Dest method... BasicBlock *DBB = new BasicBlock(SBB->getName(), Dest); - LocalMap.insert(make_pair(SBB, DBB)); + LocalMap.insert(std::make_pair(SBB, DBB)); // Loop over all of the instructions in the src basic block, copying them // over. Note that this is broken in a strict sense because the cloned @@ -324,7 +328,7 @@ static bool LinkMethodBody(Method *Dest, const Method *Src, Instruction *DI = SI->clone(); DI->setName(SI->getName()); DBB->getInstList().push_back(DI); - LocalMap.insert(make_pair(SI, DI)); + LocalMap.insert(std::make_pair(SI, DI)); } } diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index a42535580b..606d3aef14 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -24,7 +24,7 @@ template class ValueHolder; // Define the GlobalValueRefMap as a struct that wraps a map so that we don't // have Module.h depend on // -struct GlobalValueRefMap : public map{ +struct GlobalValueRefMap : public std::map{ }; @@ -97,7 +97,7 @@ ConstantPointerRef *Module::getConstantPointerRef(GlobalValue *V){ if (I != GVRefMap->end()) return I->second; ConstantPointerRef *Ref = new ConstantPointerRef(V); - GVRefMap->insert(make_pair(V, Ref)); + GVRefMap->insert(std::make_pair(V, Ref)); return Ref; } @@ -112,5 +112,5 @@ void Module::mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) { GVRefMap->erase(I); // Insert the new entry... - GVRefMap->insert(make_pair(NewGV, Ref)); + GVRefMap->insert(std::make_pair(NewGV, Ref)); } diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index ede822846d..4738f712a1 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -196,7 +196,8 @@ void SlotCalculator::purgeMethod() { while (CurPlane.size() != ModuleSize) { //SC_DEBUG(" Removing [" << i << "] Value=" << CurPlane.back() << "\n"); - map::iterator NI = NodeMap.find(CurPlane.back()); + std::map::iterator NI = + NodeMap.find(CurPlane.back()); assert(NI != NodeMap.end() && "Node not in nodemap?"); NodeMap.erase(NI); // Erase from nodemap CurPlane.pop_back(); // Shrink plane @@ -223,7 +224,7 @@ void SlotCalculator::purgeMethod() { } int SlotCalculator::getValSlot(const Value *D) const { - map::const_iterator I = NodeMap.find(D); + std::map::const_iterator I = NodeMap.find(D); if (I == NodeMap.end()) return -1; return (int)I->second; diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index dd6329fc97..ab98a73184 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -10,6 +10,14 @@ #include "llvm/Module.h" #include "llvm/Method.h" #include "Support/StringExtras.h" +#include + +using std::string; +using std::pair; +using std::make_pair; +using std::map; +using std::cerr; +using std::cout; #define DEBUG_SYMBOL_TABLE 0 #define DEBUG_ABSTYPE 0 @@ -35,7 +43,8 @@ SymbolTable::~SymbolTable() { for (type_iterator I = i->second.begin(); I != i->second.end(); ++I) if (!isa(I->second) && !isa(I->second)) { cerr << "Value still in symbol table! Type = '" - << i->first->getDescription() << "' Name = '" << I->first << "'\n"; + << i->first->getDescription() << "' Name = '" + << I->first << "'\n"; LeftoverValues = false; } } @@ -305,11 +314,11 @@ void SymbolTable::refineAbstractType(const DerivedType *OldType, #include static void DumpVal(const pair &V) { - cout << " '" << V.first << "' = " << V.second << endl; + cout << " '" << V.first << "' = " << V.second << "\n"; } static void DumpPlane(const pair >&P) { - cout << " Plane: " << P.first << endl; + cout << " Plane: " << P.first << "\n"; for_each(P.second.begin(), P.second.end(), DumpVal); } diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index cbcdf3f37d..316f97d439 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -8,6 +8,14 @@ #include "llvm/SymbolTable.h" #include "Support/StringExtras.h" #include "Support/STLExtras.h" +#include + +using std::vector; +using std::string; +using std::map; +using std::swap; +using std::make_pair; +using std::cerr; // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // created and later destroyed, all in an effort to make sure that there is only diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 0ac7205104..af9d2e4f62 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -11,6 +11,8 @@ #include "llvm/Type.h" #ifndef NDEBUG // Only in -g mode... #include "llvm/Assembly/Writer.h" +#include +using std::cerr; #endif #include @@ -23,7 +25,7 @@ static inline const Type *checkType(const Type *Ty) { return Ty; } -Value::Value(const Type *ty, ValueTy vty, const string &name = "") +Value::Value(const Type *ty, ValueTy vty, const std::string &name = "") : Name(name), Ty(checkType(ty), this) { VTy = vty; } @@ -39,7 +41,7 @@ Value::~Value() { if (Uses.begin() != Uses.end()) { cerr << "While deleting: " << this; for (use_const_iterator I = Uses.begin(); I != Uses.end(); ++I) - cerr << "Use still stuck around after Def is destroyed:" << *I << endl; + cerr << "Use still stuck around after Def is destroyed:" << *I << "\n"; } #endif assert(Uses.begin() == Uses.end()); @@ -98,7 +100,7 @@ void Value::dump() const { // User Class //===----------------------------------------------------------------------===// -User::User(const Type *Ty, ValueTy vty, const string &name) +User::User(const Type *Ty, ValueTy vty, const std::string &name) : Value(Ty, vty, name) { } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 55424fc478..0702e85f0e 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -34,6 +34,9 @@ #include "llvm/Module.h" #include "llvm/BasicBlock.h" #include "llvm/Type.h" +using std::string; +using std::vector; + // Error - Define a macro to do the common task of pushing a message onto the // end of the error list and setting Bad to true. diff --git a/lib/VMCore/iBranch.cpp b/lib/VMCore/iBranch.cpp index d0f437e293..f020ab6213 100644 --- a/lib/VMCore/iBranch.cpp +++ b/lib/VMCore/iBranch.cpp @@ -10,6 +10,7 @@ #ifndef NDEBUG #include "llvm/Type.h" // Only used for assertions... #include "llvm/Assembly/Writer.h" +#include #endif BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond) @@ -27,7 +28,7 @@ BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond) #ifndef NDEBUG if (Cond != 0 && Cond->getType() != Type::BoolTy) - cerr << "Bad Condition: " << Cond << endl; + std::cerr << "Bad Condition: " << Cond << "\n"; #endif assert((Cond == 0 || Cond->getType() == Type::BoolTy) && "May only branch on boolean predicates!!!!"); diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp index 7f4efaf7b2..37eb24e86c 100644 --- a/lib/VMCore/iCall.cpp +++ b/lib/VMCore/iCall.cpp @@ -13,8 +13,8 @@ // CallInst Implementation //===----------------------------------------------------------------------===// -CallInst::CallInst(Value *Meth, const vector ¶ms, - const string &Name) +CallInst::CallInst(Value *Meth, const std::vector ¶ms, + const std::string &Name) : Instruction(cast(cast(Meth->getType()) ->getElementType())->getReturnType(), Instruction::Call, Name) { @@ -44,8 +44,9 @@ CallInst::CallInst(const CallInst &CI) //===----------------------------------------------------------------------===// InvokeInst::InvokeInst(Value *Meth, BasicBlock *IfNormal, \ - BasicBlock *IfException, const vector¶ms, - const string &Name) + BasicBlock *IfException, + const std::vector ¶ms, + const std::string &Name) : TerminatorInst(cast(cast(Meth->getType()) ->getElementType())->getReturnType(), Instruction::Invoke, Name) { diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp index c845fd9936..4226a69615 100644 --- a/lib/VMCore/iMemory.cpp +++ b/lib/VMCore/iMemory.cpp @@ -22,7 +22,7 @@ static inline const Type *checkType(const Type *Ty) { // pointer type. // const Type* MemAccessInst::getIndexedType(const Type *Ptr, - const vector &Idx, + const std::vector &Idx, bool AllowCompositeLeaf = false) { if (!Ptr->isPointerType()) return 0; // Type isn't a pointer type! @@ -48,8 +48,8 @@ const Type* MemAccessInst::getIndexedType(const Type *Ptr, // LoadInst Implementation //===----------------------------------------------------------------------===// -LoadInst::LoadInst(Value *Ptr, const vector &Idx, - const string &Name = "") +LoadInst::LoadInst(Value *Ptr, const std::vector &Idx, + const std::string &Name = "") : MemAccessInst(checkType(getIndexedType(Ptr->getType(), Idx)), Load, Name) { assert(getIndexedType(Ptr->getType(), Idx) && "Load operands invalid!"); Operands.reserve(1+Idx.size()); @@ -60,7 +60,7 @@ LoadInst::LoadInst(Value *Ptr, const vector &Idx, } -LoadInst::LoadInst(Value *Ptr, const string &Name = "") +LoadInst::LoadInst(Value *Ptr, const std::string &Name = "") : MemAccessInst(cast(Ptr->getType())->getElementType(), Load, Name) { Operands.reserve(1); @@ -72,8 +72,8 @@ LoadInst::LoadInst(Value *Ptr, const string &Name = "") // StoreInst Implementation //===----------------------------------------------------------------------===// -StoreInst::StoreInst(Value *Val, Value *Ptr, const vector &Idx, - const string &Name = "") +StoreInst::StoreInst(Value *Val, Value *Ptr, const std::vector &Idx, + const std::string &Name = "") : MemAccessInst(Type::VoidTy, Store, Name) { assert(getIndexedType(Ptr->getType(), Idx) && "Store operands invalid!"); @@ -85,7 +85,7 @@ StoreInst::StoreInst(Value *Val, Value *Ptr, const vector &Idx, Operands.push_back(Use(Idx[i], this)); } -StoreInst::StoreInst(Value *Val, Value *Ptr, const string &Name = "") +StoreInst::StoreInst(Value *Val, Value *Ptr, const std::string &Name = "") : MemAccessInst(Type::VoidTy, Store, Name) { Operands.reserve(2); @@ -98,8 +98,8 @@ StoreInst::StoreInst(Value *Val, Value *Ptr, const string &Name = "") // GetElementPtrInst Implementation //===----------------------------------------------------------------------===// -GetElementPtrInst::GetElementPtrInst(Value *Ptr, const vector &Idx, - const string &Name = "") +GetElementPtrInst::GetElementPtrInst(Value *Ptr, const std::vector &Idx, + const std::string &Name = "") : MemAccessInst(PointerType::get(checkType(getIndexedType(Ptr->getType(), Idx, true))), GetElementPtr, Name) { diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp index cb53d5e034..c2fe1bc04a 100644 --- a/lib/VMCore/iOperators.cpp +++ b/lib/VMCore/iOperators.cpp @@ -6,6 +6,8 @@ #include "llvm/iOperators.h" #include "llvm/Type.h" +#include +using std::cerr; //===----------------------------------------------------------------------===// // UnaryOperator Class @@ -15,7 +17,7 @@ UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source) { switch (Op) { case Not: return new GenericUnaryInst(Op, Source); default: - cerr << "Don't know how to Create UnaryOperator " << Op << endl; + cerr << "Don't know how to Create UnaryOperator " << Op << "\n"; return 0; } } @@ -30,9 +32,10 @@ const char *GenericUnaryInst::getOpcodeName() const { case Not: return "not"; case Cast: return "cast"; default: - cerr << "Invalid unary operator type!" << getOpcode() << endl; + cerr << "Invalid unary operator type!" << getOpcode() << "\n"; abort(); } + return 0; } @@ -41,7 +44,7 @@ const char *GenericUnaryInst::getOpcodeName() const { //===----------------------------------------------------------------------===// BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2, - const string &Name) { + const std::string &Name) { switch (Op) { // Binary comparison operators... case SetLT: case SetGT: case SetLE: @@ -75,7 +78,7 @@ bool BinaryOperator::swapOperands() { default: return true; } - swap(Operands[0], Operands[1]); + std::swap(Operands[0], Operands[1]); return false; } @@ -98,9 +101,10 @@ const char *GenericBinaryInst::getOpcodeName() const { case Or : return "or"; case Xor: return "xor"; default: - cerr << "Invalid binary operator type!" << getOpcode() << endl; + cerr << "Invalid binary operator type!" << getOpcode() << "\n"; abort(); } + return 0; } @@ -109,7 +113,7 @@ const char *GenericBinaryInst::getOpcodeName() const { //===----------------------------------------------------------------------===// SetCondInst::SetCondInst(BinaryOps opType, Value *S1, Value *S2, - const string &Name) + const std::string &Name) : BinaryOperator(opType, S1, S2, Name) { OpType = opType; diff --git a/support/lib/Support/Annotation.cpp b/support/lib/Support/Annotation.cpp index 65a049d42d..d0d13cda86 100644 --- a/support/lib/Support/Annotation.cpp +++ b/support/lib/Support/Annotation.cpp @@ -6,6 +6,10 @@ #include #include "llvm/Annotation.h" +using std::string; +using std::map; +using std::pair; +using std::make_pair; typedef map IDMapType; static unsigned IDCounter = 0; // Unique ID counter diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index f6938169da..549f42c4e3 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -15,7 +15,13 @@ #include #include #include +#include using namespace cl; +using std::map; +using std::pair; +using std::vector; +using std::string; +using std::cerr; // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. @@ -31,7 +37,7 @@ static void AddArgument(const string &ArgName, Option *Opt) { << "' specified more than once!\n"; } else { // Add argument to the argument map! - getOpts().insert(make_pair(ArgName, Opt)); + getOpts().insert(std::make_pair(ArgName, Opt)); } } @@ -59,7 +65,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, break; case ValueOptional: break; default: cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << endl; abort(); + << Handler->getValueExpectedFlag() << "\n"; abort(); } // Run the handler now! @@ -210,7 +216,7 @@ Option::Option(const char *argStr, const char *helpStr, int flags) bool Option::error(string Message, const char *ArgName = 0) { if (ArgName == 0) ArgName = ArgStr; - cerr << "-" << ArgName << " option" << Message << endl; + cerr << "-" << ArgName << " option" << Message << "\n"; return true; } @@ -244,7 +250,7 @@ void Option::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); if (L == 0) return; // Don't print the empty arg like this! cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " - << HelpStr << endl; + << HelpStr << "\n"; } @@ -301,8 +307,8 @@ void EnumBase::processValues(va_list Vals) { while (const char *EnumName = va_arg(Vals, const char *)) { int EnumVal = va_arg(Vals, int); const char *EnumDesc = va_arg(Vals, const char *); - ValueMap.push_back(make_pair(EnumName, // Add value to value map - make_pair(EnumVal, EnumDesc))); + ValueMap.push_back(std::make_pair(EnumName, // Add value to value map + std::make_pair(EnumVal, EnumDesc))); } } @@ -339,7 +345,7 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumValueBase::getOptionWidth() const { unsigned BaseSize = Option::getOptionWidth(); for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+8); + BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+8); return BaseSize; } @@ -354,7 +360,7 @@ void EnumValueBase::printOptionInfo(unsigned GlobalWidth) const { << ValueMap[i].second.second; if (i == 0) cerr << " (default)"; - cerr << endl; + cerr << "\n"; } } @@ -369,7 +375,7 @@ bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumFlagsBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); return BaseSize; } @@ -379,7 +385,7 @@ void EnumFlagsBase::printOptionInfo(unsigned GlobalWidth) const { cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " << ValueMap[i].second.second; if (i == 0) cerr << " (default)"; - cerr << endl; + cerr << "\n"; } } @@ -402,7 +408,7 @@ bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumListBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); return BaseSize; } @@ -414,7 +420,7 @@ void EnumListBase::printOptionInfo(unsigned GlobalWidth) const { for (unsigned i = 0; i < ValueMap.size(); ++i) { unsigned L = std::strlen(ValueMap[i].first); cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " - << ValueMap[i].second.second << endl; + << ValueMap[i].second.second << "\n"; } } @@ -440,15 +446,15 @@ class Help : public Option { virtual bool handleOccurance(const char *ArgName, const string &Arg) { // Copy Options into a vector so we can sort them as we like... vector > Options; - copy(getOpts().begin(), getOpts().end(), back_inserter(Options)); + copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden Options.erase(remove_if(Options.begin(), Options.end(), - ptr_fun(ShowHidden ? isReallyHidden : isHidden)), + std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), Options.end()); // Eliminate duplicate entries in table (from enum flags options, f.e.) - set OptionSet; + std::set OptionSet; for (unsigned i = 0; i < Options.size(); ) if (OptionSet.count(Options[i].second) == 0) OptionSet.insert(Options[i++].second); // Add to set @@ -457,7 +463,7 @@ class Help : public Option { if (ProgramOverview) - cerr << "OVERVIEW:" << ProgramOverview << endl; + cerr << "OVERVIEW:" << ProgramOverview << "\n"; // TODO: Sort options by some criteria cerr << "USAGE: " << ProgramName << " [options]\n\n"; @@ -478,7 +484,7 @@ class Help : public Option { void getMaxArgLen(pair OptPair) { const Option *Opt = OptPair.second; if (Opt->ArgStr[0] == 0) EmptyArg = Opt; // Capture the empty arg if exists - MaxArgLen = max(MaxArgLen, Opt->getOptionWidth()); + MaxArgLen = std::max(MaxArgLen, Opt->getOptionWidth()); } void printOption(pair OptPair) { diff --git a/support/lib/Support/NameMangling.cpp b/support/lib/Support/NameMangling.cpp index bed520a92b..2fbcb887e3 100644 --- a/support/lib/Support/NameMangling.cpp +++ b/support/lib/Support/NameMangling.cpp @@ -7,6 +7,7 @@ #include "llvm/Support/NameMangling.h" #include "llvm/DerivedTypes.h" #include "llvm/GlobalValue.h" +using std::string; // MangleTypeName - Implement a consistent name-mangling scheme for // a given type. diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 9a53bd45af..9241216f34 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -28,6 +28,10 @@ #include "llvm/Analysis/FindUsedTypes.h" #include "Support/CommandLine.h" #include +#include +using std::cout; +using std::cerr; +using std::pair; static void PrintMethod(Method *M) { cout << M; @@ -38,7 +42,7 @@ static void PrintIntervalPartition(Method *M) { } static void PrintClassifiedExprs(Method *M) { - cout << "Classified expressions for: " << M->getName() << endl; + cout << "Classified expressions for: " << M->getName() << "\n"; Method::inst_iterator I = M->inst_begin(), E = M->inst_end(); for (; I != E; ++I) { cout << *I; @@ -61,7 +65,7 @@ static void PrintClassifiedExprs(Method *M) { if (R.Offset) WriteAsOperand(cout, (Value*)R.Offset); else cout << " 0"; break; } - cout << endl << endl; + cout << "\n\n"; } } diff --git a/tools/as/as.cpp b/tools/as/as.cpp index ee664f1524..0fbd1e6cd4 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -16,6 +16,7 @@ #include "Support/CommandLine.h" #include #include +#include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); @@ -28,46 +29,55 @@ int main(int argc, char **argv) { ostream *Out = 0; try { // Parse the file now... - Module *C = ParseAssemblyFile(InputFilename); - if (C == 0) { + std::auto_ptr C(ParseAssemblyFile(InputFilename)); + if (C.get() == 0) { cerr << "assembly didn't read correctly.\n"; return 1; } if (DumpAsm) - cerr << "Here's the assembly:\n" << C; + cerr << "Here's the assembly:\n" << C.get(); if (OutputFilename != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + Out = new std::ofstream(OutputFilename.c_str()); } else { if (InputFilename == "-") { OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename; + std::string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { // Source ends in .ll - OutputFilename = string(IFN.begin(), IFN.end()-3); + OutputFilename = std::string(IFN.begin(), IFN.end()-3); } else { OutputFilename = IFN; // Append a .bc to it } OutputFilename += ".bc"; - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + + Out = new std::ofstream(OutputFilename.c_str()); } + } - if (!Out->good()) { - cerr << "Error opening " << OutputFilename << "!\n"; - delete C; - return 1; - } + if (!Out->good()) { + cerr << "Error opening " << OutputFilename << "!\n"; + return 1; } - WriteBytecodeToFile(C, *Out); - - delete C; + WriteBytecodeToFile(C.get(), *Out); } catch (const ParseException &E) { cerr << E.getMessage() << endl; return 1; diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index 2a7eb4e06e..55e8d5d669 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -24,6 +24,8 @@ #include "Support/PostOrderIterator.h" #include "Support/CommandLine.h" #include +#include +using std::cerr; // OutputMode - The different orderings to print basic blocks in... enum OutputMode { @@ -47,7 +49,7 @@ cl::EnumFlags WriteMode(cl::NoFlags, int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); - ostream *Out = &cout; // Default to printing to stdout... + std::ostream *Out = &std::cout; // Default to printing to stdout... Module *C = ParseBytecodeFile(InputFilename); if (C == 0) { @@ -56,31 +58,41 @@ int main(int argc, char **argv) { } if (OutputFilename != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename + << "': File exists! Sending to standard output.\n"; + } else { + Out = new std::ofstream(OutputFilename.c_str()); + } } else { if (InputFilename == "-") { OutputFilename = "-"; - Out = &cout; } else { - string IFN = InputFilename; + std::string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { // Source ends in .bc - OutputFilename = string(IFN.begin(), IFN.end()-3); + OutputFilename = std::string(IFN.begin(), IFN.end()-3); } else { OutputFilename = IFN; // Append a .ll to it } OutputFilename += ".ll"; - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename + << "': File exists! Sending to standard output.\n"; + } else { + Out = new std::ofstream(OutputFilename.c_str()); + } } } if (!Out->good()) { cerr << "Error opening " << OutputFilename << ": sending to stdout instead!\n"; - Out = &cout; + Out = &std::cout; } // All that dis does is write the assembly out to a file... which is exactly @@ -100,20 +112,20 @@ int main(int argc, char **argv) { switch (WriteMode) { case dfo: // Depth First ordering copy(df_begin(M), df_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case rdfo: // Reverse Depth First ordering copy(df_begin(M, true), df_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case po: // Post Order copy(po_begin(M), po_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case rpo: { // Reverse Post Order ReversePostOrderTraversal RPOT(M); copy(RPOT.begin(), RPOT.end(), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; } default: @@ -124,6 +136,6 @@ int main(int argc, char **argv) { } delete C; - if (Out != &cout) delete Out; + if (Out != &std::cout) delete Out; return 0; } diff --git a/tools/gccas/gccas.cpp b/tools/gccas/gccas.cpp index b9e3a6207d..073b248349 100644 --- a/tools/gccas/gccas.cpp +++ b/tools/gccas/gccas.cpp @@ -44,17 +44,17 @@ int main(int argc, char **argv) { } if (OutputFilename == "") { // Didn't specify an output filename? - string IFN = InputFilename; + std::string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-2] == '.' && IFN[Len-1] == 's') { // Source ends in .s? - OutputFilename = string(IFN.begin(), IFN.end()-2); + OutputFilename = std::string(IFN.begin(), IFN.end()-2); } else { OutputFilename = IFN; // Append a .o to it } OutputFilename += ".o"; } - Out = new ofstream(OutputFilename.c_str(), ios::out); + Out = new std::ofstream(OutputFilename.c_str(), ios::out); if (!Out->good()) { cerr << "Error opening " << OutputFilename << "!\n"; return 1; @@ -63,7 +63,7 @@ int main(int argc, char **argv) { // In addition to just parsing the input from GCC, we also want to spiff it up // a little bit. Do this now. // - vector Passes; + std::vector Passes; Passes.push_back(new opt::DeadCodeElimination()); // Remove Dead code/vars Passes.push_back(new CleanupGCCOutput()); // Fix gccisms Passes.push_back(new InductionVariableSimplify()); // Simplify indvars diff --git a/tools/link/link.cpp b/tools/link/link.cpp index 83141c86e7..ad4cbdbe8c 100644 --- a/tools/link/link.cpp +++ b/tools/link/link.cpp @@ -19,6 +19,7 @@ #include #include #include // For FileExists +typedef int blksize_t; // SYS/TYPES is broken!!! #include @@ -32,7 +33,7 @@ cl::StringList LibPaths ("L", "Specify a library search path", cl::ZeroOrMore); // FileExists - Return true if the specified string is an openable file... -static inline bool FileExists(const string &FN) { +static inline bool FileExists(const std::string &FN) { struct stat StatBuf; return stat(FN.c_str(), &StatBuf) != -1; } @@ -40,9 +41,9 @@ static inline bool FileExists(const string &FN) { // LoadFile - Read the specified bytecode file in and return it. This routine // searches the link path for the specified file to try to find it... // -static inline std::auto_ptr LoadFile(const string &FN) { - string Filename = FN; - string ErrorMessage; +static inline std::auto_ptr LoadFile(const std::string &FN) { + std::string Filename = FN; + std::string ErrorMessage; unsigned NextLibPathIdx = 0; bool FoundAFile = false; @@ -81,7 +82,7 @@ int main(int argc, char **argv) { assert(InputFilenames.size() > 0 && "OneOrMore is not working"); unsigned BaseArg = 0; - string ErrorMessage; + std::string ErrorMessage; // TODO: TEST argv[0] for llvm-ar forms... for now, this is a huge hack. if (InputFilenames.size() >= 3 && InputFilenames[0] == "rc" && @@ -94,7 +95,7 @@ int main(int argc, char **argv) { if (Composite.get() == 0) return 1; for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) { - auto_ptr M(LoadFile(InputFilenames[i])); + std::auto_ptr M(LoadFile(InputFilenames[i])); if (M.get() == 0) return 1; if (Verbose) cerr << "Linking in '" << InputFilenames[i] << "'\n"; @@ -111,8 +112,13 @@ int main(int argc, char **argv) { ostream *Out = &cout; // Default to printing to stdout... if (OutputFilename != "-") { - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + Out = new std::ofstream(OutputFilename.c_str()); if (!Out->good()) { cerr << "Error opening '" << OutputFilename << "'!\n"; return 1; @@ -122,6 +128,6 @@ int main(int argc, char **argv) { if (Verbose) cerr << "Writing bytecode...\n"; WriteBytecodeToFile(Composite.get(), *Out); - if (Out != &cout) delete Out; + if (Out != &std::cout) delete Out; return 0; } diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 7c8c3a608b..6b51f79b38 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -19,6 +19,7 @@ #include #include #include +using std::string; cl::String InputFilename ("", "Input filename", cl::NoFlags, "-"); cl::String OutputFilename("o", "Output filename", cl::NoFlags, ""); @@ -78,10 +79,10 @@ public: class EmitAssembly : public Pass { const TargetMachine &Target; // Target to compile for - ostream *Out; // Stream to print on + std::ostream *Out; // Stream to print on bool DeleteStream; // Delete stream in dtor? public: - inline EmitAssembly(const TargetMachine &T, ostream *O, bool D) + inline EmitAssembly(const TargetMachine &T, std::ostream *O, bool D) : Target(T), Out(O), DeleteStream(D) {} @@ -105,20 +106,20 @@ int main(int argc, char **argv) { // Allocate a target... in the future this will be controllable on the // command line. - auto_ptr target(allocateSparcTargetMachine()); + std::auto_ptr target(allocateSparcTargetMachine()); assert(target.get() && "Could not allocate target machine!"); TargetMachine &Target = *target.get(); // Load the module to be compiled... - auto_ptr M(ParseBytecodeFile(InputFilename)); + std::auto_ptr M(ParseBytecodeFile(InputFilename)); if (M.get() == 0) { cerr << "bytecode didn't read correctly.\n"; return 1; } // Build up all of the passes that we want to do to the module... - vector Passes; + std::vector Passes; // Hoist constants out of PHI nodes into predecessor BB's Passes.push_back(new HoistPHIConstants()); @@ -135,8 +136,15 @@ int main(int argc, char **argv) { assert(InputFilename != "-" && "files on stdin not supported with tracing"); string traceFileName = GetFileNameRoot(InputFilename) + ".trace.bc"; - ostream *os = new ofstream(traceFileName.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + + std::ostream *os = new std::ofstream(traceFileName.c_str()); if (!os->good()) { cerr << "Error opening " << traceFileName << "! SKIPPING OUTPUT OF TRACE CODE\n"; @@ -161,19 +169,31 @@ int main(int argc, char **argv) { if (!DoNotEmitAssembly) { // If asm output is enabled... // Figure out where we are going to send the output... - ostream *Out = 0; + std::ostream *Out = 0; if (OutputFilename != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + Out = new std::ofstream(OutputFilename.c_str()); } else { if (InputFilename == "-") { OutputFilename = "-"; - Out = &cout; + Out = &std::cout; } else { string OutputFilename = GetFileNameRoot(InputFilename); OutputFilename += ".s"; - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + + Out = new std::ofstream(OutputFilename.c_str()); if (!Out->good()) { cerr << "Error opening " << OutputFilename << "!\n"; delete Out; @@ -183,7 +203,7 @@ int main(int argc, char **argv) { } // Output assembly language to the .s file - Passes.push_back(new EmitAssembly(Target, Out, Out != &cout)); + Passes.push_back(new EmitAssembly(Target, Out, Out != &std::cout)); } // Run our queue of passes all at once now, efficiently. This form of diff --git a/tools/llvm-as/as.cpp b/tools/llvm-as/as.cpp index ee664f1524..0fbd1e6cd4 100644 --- a/tools/llvm-as/as.cpp +++ b/tools/llvm-as/as.cpp @@ -16,6 +16,7 @@ #include "Support/CommandLine.h" #include #include +#include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); @@ -28,46 +29,55 @@ int main(int argc, char **argv) { ostream *Out = 0; try { // Parse the file now... - Module *C = ParseAssemblyFile(InputFilename); - if (C == 0) { + std::auto_ptr C(ParseAssemblyFile(InputFilename)); + if (C.get() == 0) { cerr << "assembly didn't read correctly.\n"; return 1; } if (DumpAsm) - cerr << "Here's the assembly:\n" << C; + cerr << "Here's the assembly:\n" << C.get(); if (OutputFilename != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + Out = new std::ofstream(OutputFilename.c_str()); } else { if (InputFilename == "-") { OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename; + std::string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { // Source ends in .ll - OutputFilename = string(IFN.begin(), IFN.end()-3); + OutputFilename = std::string(IFN.begin(), IFN.end()-3); } else { OutputFilename = IFN; // Append a .bc to it } OutputFilename += ".bc"; - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + + Out = new std::ofstream(OutputFilename.c_str()); } + } - if (!Out->good()) { - cerr << "Error opening " << OutputFilename << "!\n"; - delete C; - return 1; - } + if (!Out->good()) { + cerr << "Error opening " << OutputFilename << "!\n"; + return 1; } - WriteBytecodeToFile(C, *Out); - - delete C; + WriteBytecodeToFile(C.get(), *Out); } catch (const ParseException &E) { cerr << E.getMessage() << endl; return 1; diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index ee664f1524..0fbd1e6cd4 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -16,6 +16,7 @@ #include "Support/CommandLine.h" #include #include +#include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); cl::String OutputFilename("o", "Override output filename", cl::NoFlags, ""); @@ -28,46 +29,55 @@ int main(int argc, char **argv) { ostream *Out = 0; try { // Parse the file now... - Module *C = ParseAssemblyFile(InputFilename); - if (C == 0) { + std::auto_ptr C(ParseAssemblyFile(InputFilename)); + if (C.get() == 0) { cerr << "assembly didn't read correctly.\n"; return 1; } if (DumpAsm) - cerr << "Here's the assembly:\n" << C; + cerr << "Here's the assembly:\n" << C.get(); if (OutputFilename != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + Out = new std::ofstream(OutputFilename.c_str()); } else { if (InputFilename == "-") { OutputFilename = "-"; Out = &cout; } else { - string IFN = InputFilename; + std::string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'l' && IFN[Len-1] == 'l') { // Source ends in .ll - OutputFilename = string(IFN.begin(), IFN.end()-3); + OutputFilename = std::string(IFN.begin(), IFN.end()-3); } else { OutputFilename = IFN; // Append a .bc to it } OutputFilename += ".bc"; - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + + Out = new std::ofstream(OutputFilename.c_str()); } + } - if (!Out->good()) { - cerr << "Error opening " << OutputFilename << "!\n"; - delete C; - return 1; - } + if (!Out->good()) { + cerr << "Error opening " << OutputFilename << "!\n"; + return 1; } - WriteBytecodeToFile(C, *Out); - - delete C; + WriteBytecodeToFile(C.get(), *Out); } catch (const ParseException &E) { cerr << E.getMessage() << endl; return 1; diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp index 2a7eb4e06e..55e8d5d669 100644 --- a/tools/llvm-dis/dis.cpp +++ b/tools/llvm-dis/dis.cpp @@ -24,6 +24,8 @@ #include "Support/PostOrderIterator.h" #include "Support/CommandLine.h" #include +#include +using std::cerr; // OutputMode - The different orderings to print basic blocks in... enum OutputMode { @@ -47,7 +49,7 @@ cl::EnumFlags WriteMode(cl::NoFlags, int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); - ostream *Out = &cout; // Default to printing to stdout... + std::ostream *Out = &std::cout; // Default to printing to stdout... Module *C = ParseBytecodeFile(InputFilename); if (C == 0) { @@ -56,31 +58,41 @@ int main(int argc, char **argv) { } if (OutputFilename != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename + << "': File exists! Sending to standard output.\n"; + } else { + Out = new std::ofstream(OutputFilename.c_str()); + } } else { if (InputFilename == "-") { OutputFilename = "-"; - Out = &cout; } else { - string IFN = InputFilename; + std::string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { // Source ends in .bc - OutputFilename = string(IFN.begin(), IFN.end()-3); + OutputFilename = std::string(IFN.begin(), IFN.end()-3); } else { OutputFilename = IFN; // Append a .ll to it } OutputFilename += ".ll"; - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename + << "': File exists! Sending to standard output.\n"; + } else { + Out = new std::ofstream(OutputFilename.c_str()); + } } } if (!Out->good()) { cerr << "Error opening " << OutputFilename << ": sending to stdout instead!\n"; - Out = &cout; + Out = &std::cout; } // All that dis does is write the assembly out to a file... which is exactly @@ -100,20 +112,20 @@ int main(int argc, char **argv) { switch (WriteMode) { case dfo: // Depth First ordering copy(df_begin(M), df_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case rdfo: // Reverse Depth First ordering copy(df_begin(M, true), df_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case po: // Post Order copy(po_begin(M), po_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case rpo: { // Reverse Post Order ReversePostOrderTraversal RPOT(M); copy(RPOT.begin(), RPOT.end(), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; } default: @@ -124,6 +136,6 @@ int main(int argc, char **argv) { } delete C; - if (Out != &cout) delete Out; + if (Out != &std::cout) delete Out; return 0; } diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 2a7eb4e06e..55e8d5d669 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -24,6 +24,8 @@ #include "Support/PostOrderIterator.h" #include "Support/CommandLine.h" #include +#include +using std::cerr; // OutputMode - The different orderings to print basic blocks in... enum OutputMode { @@ -47,7 +49,7 @@ cl::EnumFlags WriteMode(cl::NoFlags, int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .bc -> .ll disassembler\n"); - ostream *Out = &cout; // Default to printing to stdout... + std::ostream *Out = &std::cout; // Default to printing to stdout... Module *C = ParseBytecodeFile(InputFilename); if (C == 0) { @@ -56,31 +58,41 @@ int main(int argc, char **argv) { } if (OutputFilename != "") { // Specified an output filename? - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename + << "': File exists! Sending to standard output.\n"; + } else { + Out = new std::ofstream(OutputFilename.c_str()); + } } else { if (InputFilename == "-") { OutputFilename = "-"; - Out = &cout; } else { - string IFN = InputFilename; + std::string IFN = InputFilename; int Len = IFN.length(); if (IFN[Len-3] == '.' && IFN[Len-2] == 'b' && IFN[Len-1] == 'c') { // Source ends in .bc - OutputFilename = string(IFN.begin(), IFN.end()-3); + OutputFilename = std::string(IFN.begin(), IFN.end()-3); } else { OutputFilename = IFN; // Append a .ll to it } OutputFilename += ".ll"; - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename + << "': File exists! Sending to standard output.\n"; + } else { + Out = new std::ofstream(OutputFilename.c_str()); + } } } if (!Out->good()) { cerr << "Error opening " << OutputFilename << ": sending to stdout instead!\n"; - Out = &cout; + Out = &std::cout; } // All that dis does is write the assembly out to a file... which is exactly @@ -100,20 +112,20 @@ int main(int argc, char **argv) { switch (WriteMode) { case dfo: // Depth First ordering copy(df_begin(M), df_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case rdfo: // Reverse Depth First ordering copy(df_begin(M, true), df_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case po: // Post Order copy(po_begin(M), po_end(M), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; case rpo: { // Reverse Post Order ReversePostOrderTraversal RPOT(M); copy(RPOT.begin(), RPOT.end(), - ostream_iterator(*Out, "\n")); + std::ostream_iterator(*Out, "\n")); break; } default: @@ -124,6 +136,6 @@ int main(int argc, char **argv) { } delete C; - if (Out != &cout) delete Out; + if (Out != &std::cout) delete Out; return 0; } diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 83141c86e7..ad4cbdbe8c 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -19,6 +19,7 @@ #include #include #include // For FileExists +typedef int blksize_t; // SYS/TYPES is broken!!! #include @@ -32,7 +33,7 @@ cl::StringList LibPaths ("L", "Specify a library search path", cl::ZeroOrMore); // FileExists - Return true if the specified string is an openable file... -static inline bool FileExists(const string &FN) { +static inline bool FileExists(const std::string &FN) { struct stat StatBuf; return stat(FN.c_str(), &StatBuf) != -1; } @@ -40,9 +41,9 @@ static inline bool FileExists(const string &FN) { // LoadFile - Read the specified bytecode file in and return it. This routine // searches the link path for the specified file to try to find it... // -static inline std::auto_ptr LoadFile(const string &FN) { - string Filename = FN; - string ErrorMessage; +static inline std::auto_ptr LoadFile(const std::string &FN) { + std::string Filename = FN; + std::string ErrorMessage; unsigned NextLibPathIdx = 0; bool FoundAFile = false; @@ -81,7 +82,7 @@ int main(int argc, char **argv) { assert(InputFilenames.size() > 0 && "OneOrMore is not working"); unsigned BaseArg = 0; - string ErrorMessage; + std::string ErrorMessage; // TODO: TEST argv[0] for llvm-ar forms... for now, this is a huge hack. if (InputFilenames.size() >= 3 && InputFilenames[0] == "rc" && @@ -94,7 +95,7 @@ int main(int argc, char **argv) { if (Composite.get() == 0) return 1; for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) { - auto_ptr M(LoadFile(InputFilenames[i])); + std::auto_ptr M(LoadFile(InputFilenames[i])); if (M.get() == 0) return 1; if (Verbose) cerr << "Linking in '" << InputFilenames[i] << "'\n"; @@ -111,8 +112,13 @@ int main(int argc, char **argv) { ostream *Out = &cout; // Default to printing to stdout... if (OutputFilename != "-") { - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + Out = new std::ofstream(OutputFilename.c_str()); if (!Out->good()) { cerr << "Error opening '" << OutputFilename << "'!\n"; return 1; @@ -122,6 +128,6 @@ int main(int argc, char **argv) { if (Verbose) cerr << "Writing bytecode...\n"; WriteBytecodeToFile(Composite.get(), *Out); - if (Out != &cout) delete Out; + if (Out != &std::cout) delete Out; return 0; } diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 9dfb51a487..8a2208d92d 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -122,10 +122,16 @@ int main(int argc, char **argv) { for (unsigned i = 0; i < OptimizationList.size(); ++i) RunOptimization(M.get(), OptimizationList[i]); - ostream *Out = &cout; // Default to printing to stdout... + std::ostream *Out = &std::cout; // Default to printing to stdout... if (OutputFilename != "") { - Out = new ofstream(OutputFilename.c_str(), - (Force ? 0 : ios::noreplace)|ios::out); + if (!Force && !std::ifstream(OutputFilename.c_str())) { + // If force is not specified, make sure not to overwrite a file! + cerr << "Error opening '" << OutputFilename << "': File exists!\n" + << "Use -f command line argument to force output\n"; + return 1; + } + Out = new std::ofstream(OutputFilename.c_str()); + if (!Out->good()) { cerr << "Error opening " << OutputFilename << "!\n"; return 1; -- cgit v1.2.3-70-g09d2 From 9c9be48b8396e7244e47d2af8890da8eec71c72d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 31 Jan 2002 00:42:56 +0000 Subject: If an invalid alternative is listed for an argument, print the valid options git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1604 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 15 ++++++++++++--- support/lib/Support/CommandLine.cpp | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 549f42c4e3..d3966279b4 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -34,7 +34,7 @@ static map &getOpts() { static void AddArgument(const string &ArgName, Option *Opt) { if (getOpts().find(ArgName) != getOpts().end()) { cerr << "CommandLine Error: Argument '" << ArgName - << "' specified more than once!\n"; + << "' defined more than once!\n"; } else { // Add argument to the argument map! getOpts().insert(std::make_pair(ArgName, Opt)); @@ -335,8 +335,17 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned i; for (i = 0; i < ValueMap.size(); ++i) if (ValueMap[i].first == Arg) break; - if (i == ValueMap.size()) - return error(": unrecognized alternative '"+Arg+"'!"); + + if (i == ValueMap.size()) { + string Alternatives; + for (i = 0; i < ValueMap.size(); ++i) { + if (i) Alternatives += ", "; + Alternatives += ValueMap[i].first; + } + + return error(": unrecognized alternative '" + Arg + + "'! Alternatives are: " + Alternatives); + } Value = ValueMap[i].second.first; return false; } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 549f42c4e3..d3966279b4 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -34,7 +34,7 @@ static map &getOpts() { static void AddArgument(const string &ArgName, Option *Opt) { if (getOpts().find(ArgName) != getOpts().end()) { cerr << "CommandLine Error: Argument '" << ArgName - << "' specified more than once!\n"; + << "' defined more than once!\n"; } else { // Add argument to the argument map! getOpts().insert(std::make_pair(ArgName, Opt)); @@ -335,8 +335,17 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned i; for (i = 0; i < ValueMap.size(); ++i) if (ValueMap[i].first == Arg) break; - if (i == ValueMap.size()) - return error(": unrecognized alternative '"+Arg+"'!"); + + if (i == ValueMap.size()) { + string Alternatives; + for (i = 0; i < ValueMap.size(); ++i) { + if (i) Alternatives += ", "; + Alternatives += ValueMap[i].first; + } + + return error(": unrecognized alternative '" + Arg + + "'! Alternatives are: " + Alternatives); + } Value = ValueMap[i].second.first; return false; } -- cgit v1.2.3-70-g09d2 From 7f1576f0424542d6162c1cedc14629e4cbc3e80a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 24 Feb 2002 23:02:12 +0000 Subject: 64 bit clean now git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1789 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 7 ++++--- support/lib/Support/CommandLine.cpp | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index d3966279b4..8633bef934 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -16,6 +16,7 @@ #include #include #include + using namespace cl; using std::map; using std::pair; @@ -354,7 +355,7 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumValueBase::getOptionWidth() const { unsigned BaseSize = Option::getOptionWidth(); for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+8); + BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+8); return BaseSize; } @@ -384,7 +385,7 @@ bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumFlagsBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); return BaseSize; } @@ -417,7 +418,7 @@ bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumListBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); return BaseSize; } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index d3966279b4..8633bef934 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -16,6 +16,7 @@ #include #include #include + using namespace cl; using std::map; using std::pair; @@ -354,7 +355,7 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumValueBase::getOptionWidth() const { unsigned BaseSize = Option::getOptionWidth(); for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+8); + BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+8); return BaseSize; } @@ -384,7 +385,7 @@ bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumFlagsBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); return BaseSize; } @@ -417,7 +418,7 @@ bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) { unsigned EnumListBase::getOptionWidth() const { unsigned BaseSize = 0; for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, std::strlen(ValueMap[i].first)+6); + BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); return BaseSize; } -- cgit v1.2.3-70-g09d2 From c6f3ae5c66c8e0dab6a2bd9601d0e253ef9ba794 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 29 Apr 2002 17:42:12 +0000 Subject: Eliminate duplicate or unneccesary #include's git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2397 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bytecode/Writer.h | 4 ++-- include/llvm/CodeGen/RegClass.h | 2 -- lib/Analysis/IPA/FindUnsafePointerTypes.cpp | 1 - lib/Analysis/IPA/FindUsedTypes.cpp | 1 - lib/Analysis/LiveVar/BBLiveVar.cpp | 1 - lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp | 1 - lib/Analysis/PostDominators.cpp | 1 - lib/AsmParser/Parser.cpp | 1 - lib/AsmParser/ParserInternals.h | 3 --- lib/AsmParser/llvmAsmParser.y | 5 ----- lib/Bytecode/Reader/ConstantReader.cpp | 1 - lib/Bytecode/Reader/Reader.cpp | 1 - lib/Bytecode/Writer/InstructionWriter.cpp | 1 - lib/Bytecode/Writer/WriterInternals.h | 1 - lib/CodeGen/InstrSched/InstrScheduling.cpp | 6 +----- lib/CodeGen/InstrSched/SchedGraph.cpp | 2 -- lib/CodeGen/InstrSched/SchedGraph.h | 1 - lib/CodeGen/InstrSched/SchedPriorities.cpp | 1 - lib/CodeGen/InstrSelection/InstrSelection.cpp | 1 - lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp | 1 - lib/CodeGen/MachineCodeForInstruction.cpp | 1 - lib/CodeGen/RegAlloc/IGNode.h | 1 - lib/CodeGen/RegAlloc/InterferenceGraph.cpp | 2 +- lib/CodeGen/RegAlloc/LiveRangeInfo.cpp | 2 +- lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 1 + lib/CodeGen/RegAlloc/RegClass.cpp | 2 +- lib/CodeGen/RegAlloc/RegClass.h | 2 -- lib/Support/CommandLine.cpp | 1 - lib/Target/SparcV9/InstrSched/InstrScheduling.cpp | 6 +----- lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 2 -- lib/Target/SparcV9/InstrSched/SchedGraph.h | 1 - lib/Target/SparcV9/InstrSched/SchedPriorities.cpp | 1 - lib/Target/SparcV9/InstrSelection/InstrSelection.cpp | 1 - lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp | 1 - lib/Target/SparcV9/LiveVar/BBLiveVar.cpp | 1 - lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp | 1 - lib/Target/SparcV9/RegAlloc/IGNode.h | 1 - lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp | 2 +- lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp | 2 +- lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 1 + lib/Target/SparcV9/RegAlloc/RegClass.cpp | 2 +- lib/Target/SparcV9/RegAlloc/RegClass.h | 2 -- lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 2 -- lib/Target/SparcV9/SparcV9InstrInfo.cpp | 1 - lib/Target/SparcV9/SparcV9Internals.h | 1 - lib/Target/SparcV9/SparcV9RegClassInfo.cpp | 2 +- lib/Target/SparcV9/SparcV9RegInfo.cpp | 1 + lib/Transforms/ExprTypeConvert.cpp | 3 --- lib/Transforms/HoistPHIConstants.cpp | 2 -- lib/Transforms/IPO/DeadTypeElimination.cpp | 1 - lib/Transforms/IPO/GlobalDCE.cpp | 2 -- lib/Transforms/IPO/InlineSimple.cpp | 1 - lib/Transforms/IPO/OldPoolAllocate.cpp | 1 - lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp | 3 --- lib/Transforms/LevelRaise.cpp | 2 -- lib/Transforms/Scalar/ADCE.cpp | 1 - lib/Transforms/Scalar/DCE.cpp | 2 -- lib/Transforms/Scalar/GCSE.cpp | 2 -- lib/Transforms/Scalar/IndVarSimplify.cpp | 2 -- lib/Transforms/Scalar/InductionVars.cpp | 5 +---- lib/Transforms/Scalar/InstructionCombining.cpp | 1 - lib/Transforms/Scalar/SCCP.cpp | 3 --- lib/Transforms/Utils/LowerAllocations.cpp | 2 -- lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 1 - lib/VMCore/AsmWriter.cpp | 1 - lib/VMCore/BasicBlock.cpp | 1 - lib/VMCore/Dominators.cpp | 1 - lib/VMCore/Function.cpp | 1 - lib/VMCore/Module.cpp | 1 - lib/VMCore/Verifier.cpp | 2 -- support/lib/Support/CommandLine.cpp | 1 - tools/analyze/analyze.cpp | 3 --- tools/as/as.cpp | 1 - tools/dis/dis.cpp | 1 - tools/gccas/gccas.cpp | 1 - tools/llc/llc.cpp | 1 - tools/llvm-as/as.cpp | 1 - tools/llvm-as/llvm-as.cpp | 1 - tools/llvm-dis/dis.cpp | 1 - tools/llvm-dis/llvm-dis.cpp | 1 - 80 files changed, 15 insertions(+), 117 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Bytecode/Writer.h b/include/llvm/Bytecode/Writer.h index e28ea77f07..b4d5e78fd0 100644 --- a/include/llvm/Bytecode/Writer.h +++ b/include/llvm/Bytecode/Writer.h @@ -17,9 +17,9 @@ #ifndef LLVM_BYTECODE_WRITER_H #define LLVM_BYTECODE_WRITER_H -#include +#include class Module; -void WriteBytecodeToFile(const Module *C, ostream &Out); +void WriteBytecodeToFile(const Module *C, std::ostream &Out); #endif diff --git a/include/llvm/CodeGen/RegClass.h b/include/llvm/CodeGen/RegClass.h index 3db72b7363..c93d6961e0 100644 --- a/include/llvm/CodeGen/RegClass.h +++ b/include/llvm/CodeGen/RegClass.h @@ -8,11 +8,9 @@ #ifndef REG_CLASS_H #define REG_CLASS_H -#include "llvm/CodeGen/IGNode.h" #include "llvm/CodeGen/InterferenceGraph.h" #include "llvm/Target/MachineRegInfo.h" #include -#include class MachineRegClassInfo; typedef std::vector ReservedColorListType; diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 9f908c6c71..627c7ff5f3 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -20,7 +20,6 @@ #include "llvm/Assembly/CachedWriter.h" #include "llvm/Type.h" #include "llvm/Instruction.h" -#include "llvm/Function.h" #include "llvm/Module.h" #include "llvm/Support/InstIterator.h" #include "Support/CommandLine.h" diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 86061d8610..b4897a265a 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -10,7 +10,6 @@ #include "llvm/GlobalVariable.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "llvm/Function.h" #include "llvm/Instruction.h" #include "llvm/Support/InstIterator.h" diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp index 958f7d7c66..7d735b79e4 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.cpp +++ b/lib/Analysis/LiveVar/BBLiveVar.cpp @@ -7,7 +7,6 @@ #include "BBLiveVar.h" #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" #include "Support/SetOperations.h" #include diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp index 58d4691b76..295a9ed5e5 100644 --- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp @@ -8,7 +8,6 @@ #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" #include "BBLiveVar.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" #include "Support/PostOrderIterator.h" #include "Support/SetOperations.h" diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 30d170b669..f542d112b8 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -7,7 +7,6 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Transforms/UnifyFunctionExitNodes.h" -#include "llvm/Function.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index a99849d31b..19632dd131 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -7,7 +7,6 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Module.h" #include "ParserInternals.h" -#include // for sprintf using std::string; // The useful interface defined by this file... Parse an ascii file, and return diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 3571138a0d..656d718e38 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -8,10 +8,7 @@ #ifndef PARSER_INTERNALS_H #define PARSER_INTERNALS_H -#include #define __STDC_LIMIT_MACROS - -#include "llvm/InstrTypes.h" #include "llvm/BasicBlock.h" #include "llvm/Constants.h" #include "llvm/iOther.h" diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 776e8c52a6..ad5e57e04a 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -6,13 +6,9 @@ %{ #include "ParserInternals.h" -#include "llvm/Assembly/Parser.h" #include "llvm/SymbolTable.h" #include "llvm/Module.h" #include "llvm/GlobalVariable.h" -#include "llvm/Function.h" -#include "llvm/BasicBlock.h" -#include "llvm/DerivedTypes.h" #include "llvm/iTerminators.h" #include "llvm/iMemory.h" #include "llvm/iPHINode.h" @@ -22,7 +18,6 @@ #include #include // Get definition of pair class #include -#include // This embarasment is due to our flex lexer... #include using std::list; using std::vector; diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index 4c7ebb119a..eb0cadc8ec 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -10,7 +10,6 @@ #include "ReaderInternals.h" #include "llvm/Module.h" -#include "llvm/BasicBlock.h" #include "llvm/Constants.h" #include "llvm/GlobalVariable.h" #include diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 7418c81bbe..70a6ae97f3 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -15,7 +15,6 @@ #include "llvm/Bytecode/Format.h" #include "llvm/GlobalVariable.h" #include "llvm/Module.h" -#include "llvm/BasicBlock.h" #include "llvm/Constants.h" #include "llvm/iPHINode.h" #include "llvm/iOther.h" diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp index c32c6b476f..2c1ce975bc 100644 --- a/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/lib/Bytecode/Writer/InstructionWriter.cpp @@ -13,7 +13,6 @@ #include "llvm/Module.h" #include "llvm/Function.h" #include "llvm/BasicBlock.h" -#include "llvm/Instruction.h" #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/iTerminators.h" diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h index 73884bbdcc..bd4a328826 100644 --- a/lib/Bytecode/Writer/WriterInternals.h +++ b/lib/Bytecode/Writer/WriterInternals.h @@ -17,7 +17,6 @@ #include "llvm/Bytecode/Primitives.h" #include "llvm/SlotCalculator.h" #include "llvm/Instruction.h" -#include class BytecodeWriter { std::deque &Out; diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index b042279747..d219ef6b6d 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -5,7 +5,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/InstrScheduling.h" +#include "SchedPriorities.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineCodeForMethod.h" @@ -13,11 +13,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/BasicBlock.h" #include "llvm/Instruction.h" -#include "SchedPriorities.h" -#include #include -#include -#include using std::cerr; using std::vector; diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index 28679bfbdc..0629f8c75f 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -14,9 +14,7 @@ #include "SchedGraph.h" #include "llvm/CodeGen/InstrSelection.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" -#include "llvm/Target/MachineInstrInfo.h" #include "llvm/Target/MachineRegInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/BasicBlock.h" diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h index 8a8a523f00..441a46c0e5 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.h +++ b/lib/CodeGen/InstrSched/SchedGraph.h @@ -20,7 +20,6 @@ #define LLVM_CODEGEN_SCHEDGRAPH_H #include "llvm/CodeGen/MachineInstr.h" -#include "Support/NonCopyable.h" #include "Support/HashExtras.h" #include "Support/GraphTraits.h" diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp index a4480e8865..aba49bd54c 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.cpp +++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp @@ -22,7 +22,6 @@ #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" #include "llvm/Support/CFG.h" #include "Support/PostOrderIterator.h" -#include using std::cerr; SchedPriorities::SchedPriorities(const Function *, const SchedGraph *G, diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index 583df38360..1724ce4489 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -16,7 +16,6 @@ #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelectionSupport.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/InstrForest.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineCodeForMethod.h" diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index c042e368c9..d06ac172db 100644 --- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -13,7 +13,6 @@ #include "llvm/CodeGen/InstrSelectionSupport.h" #include "llvm/CodeGen/InstrSelection.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineCodeForMethod.h" #include "llvm/CodeGen/InstrForest.h" diff --git a/lib/CodeGen/MachineCodeForInstruction.cpp b/lib/CodeGen/MachineCodeForInstruction.cpp index a4ebbec187..98871a7e85 100644 --- a/lib/CodeGen/MachineCodeForInstruction.cpp +++ b/lib/CodeGen/MachineCodeForInstruction.cpp @@ -19,7 +19,6 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/InstrSelection.h" -#include "llvm/Instruction.h" static AnnotationID MCFI_AID( AnnotationManager::getID("CodeGen::MachineCodeForInstruction")); diff --git a/lib/CodeGen/RegAlloc/IGNode.h b/lib/CodeGen/RegAlloc/IGNode.h index 177800c5bb..bcf850f68b 100644 --- a/lib/CodeGen/RegAlloc/IGNode.h +++ b/lib/CodeGen/RegAlloc/IGNode.h @@ -25,7 +25,6 @@ #ifndef IG_NODE_H #define IG_NODE_H -#include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/CodeGen/LiveRange.h" class LiveRange; class RegClass; diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp index c90ae4ae24..412f35fe93 100644 --- a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp +++ b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp @@ -1,6 +1,6 @@ #include "llvm/CodeGen/InterferenceGraph.h" #include "Support/STLExtras.h" -#include +#include "llvm/CodeGen/RegAllocCommon.h" #include using std::cerr; diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp index fb29af2bf1..6661eca801 100644 --- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp +++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp @@ -5,7 +5,7 @@ #include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "Support/SetOperations.h" -#include +#include "llvm/CodeGen/RegAllocCommon.h" using std::cerr; LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm, diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index b783255699..d54229e838 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -21,6 +21,7 @@ #include "llvm/BasicBlock.h" #include "llvm/Function.h" #include "llvm/Type.h" +#include "llvm/CodeGen/RegAllocCommon.h" #include #include using std::cerr; diff --git a/lib/CodeGen/RegAlloc/RegClass.cpp b/lib/CodeGen/RegAlloc/RegClass.cpp index 607a4daf62..249b8db266 100644 --- a/lib/CodeGen/RegAlloc/RegClass.cpp +++ b/lib/CodeGen/RegAlloc/RegClass.cpp @@ -1,5 +1,5 @@ #include "llvm/CodeGen/RegClass.h" -#include +#include "llvm/CodeGen/RegAllocCommon.h" using std::cerr; //---------------------------------------------------------------------------- diff --git a/lib/CodeGen/RegAlloc/RegClass.h b/lib/CodeGen/RegAlloc/RegClass.h index 3db72b7363..c93d6961e0 100644 --- a/lib/CodeGen/RegAlloc/RegClass.h +++ b/lib/CodeGen/RegAlloc/RegClass.h @@ -8,11 +8,9 @@ #ifndef REG_CLASS_H #define REG_CLASS_H -#include "llvm/CodeGen/IGNode.h" #include "llvm/CodeGen/InterferenceGraph.h" #include "llvm/Target/MachineRegInfo.h" #include -#include class MachineRegClassInfo; typedef std::vector ReservedColorListType; diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 8633bef934..194dd33b27 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -11,7 +11,6 @@ #include "Support/CommandLine.h" #include "Support/STLExtras.h" -#include #include #include #include diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index b042279747..d219ef6b6d 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -5,7 +5,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/CodeGen/InstrScheduling.h" +#include "SchedPriorities.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineCodeForMethod.h" @@ -13,11 +13,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/BasicBlock.h" #include "llvm/Instruction.h" -#include "SchedPriorities.h" -#include #include -#include -#include using std::cerr; using std::vector; diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index 28679bfbdc..0629f8c75f 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -14,9 +14,7 @@ #include "SchedGraph.h" #include "llvm/CodeGen/InstrSelection.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" -#include "llvm/Target/MachineInstrInfo.h" #include "llvm/Target/MachineRegInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/BasicBlock.h" diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h index 8a8a523f00..441a46c0e5 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.h +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h @@ -20,7 +20,6 @@ #define LLVM_CODEGEN_SCHEDGRAPH_H #include "llvm/CodeGen/MachineInstr.h" -#include "Support/NonCopyable.h" #include "Support/HashExtras.h" #include "Support/GraphTraits.h" diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp index a4480e8865..aba49bd54c 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp @@ -22,7 +22,6 @@ #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" #include "llvm/Support/CFG.h" #include "Support/PostOrderIterator.h" -#include using std::cerr; SchedPriorities::SchedPriorities(const Function *, const SchedGraph *G, diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index 583df38360..1724ce4489 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -16,7 +16,6 @@ #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelectionSupport.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/InstrForest.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineCodeForMethod.h" diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index c042e368c9..d06ac172db 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -13,7 +13,6 @@ #include "llvm/CodeGen/InstrSelectionSupport.h" #include "llvm/CodeGen/InstrSelection.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineCodeForMethod.h" #include "llvm/CodeGen/InstrForest.h" diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp index 958f7d7c66..7d735b79e4 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp @@ -7,7 +7,6 @@ #include "BBLiveVar.h" #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" #include "Support/SetOperations.h" #include diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp index 58d4691b76..295a9ed5e5 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp @@ -8,7 +8,6 @@ #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" #include "BBLiveVar.h" #include "llvm/CodeGen/MachineInstr.h" -#include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" #include "Support/PostOrderIterator.h" #include "Support/SetOperations.h" diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.h b/lib/Target/SparcV9/RegAlloc/IGNode.h index 177800c5bb..bcf850f68b 100644 --- a/lib/Target/SparcV9/RegAlloc/IGNode.h +++ b/lib/Target/SparcV9/RegAlloc/IGNode.h @@ -25,7 +25,6 @@ #ifndef IG_NODE_H #define IG_NODE_H -#include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/CodeGen/LiveRange.h" class LiveRange; class RegClass; diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp index c90ae4ae24..412f35fe93 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp @@ -1,6 +1,6 @@ #include "llvm/CodeGen/InterferenceGraph.h" #include "Support/STLExtras.h" -#include +#include "llvm/CodeGen/RegAllocCommon.h" #include using std::cerr; diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp index fb29af2bf1..6661eca801 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp @@ -5,7 +5,7 @@ #include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "Support/SetOperations.h" -#include +#include "llvm/CodeGen/RegAllocCommon.h" using std::cerr; LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm, diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index b783255699..d54229e838 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -21,6 +21,7 @@ #include "llvm/BasicBlock.h" #include "llvm/Function.h" #include "llvm/Type.h" +#include "llvm/CodeGen/RegAllocCommon.h" #include #include using std::cerr; diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.cpp b/lib/Target/SparcV9/RegAlloc/RegClass.cpp index 607a4daf62..249b8db266 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.cpp +++ b/lib/Target/SparcV9/RegAlloc/RegClass.cpp @@ -1,5 +1,5 @@ #include "llvm/CodeGen/RegClass.h" -#include +#include "llvm/CodeGen/RegAllocCommon.h" using std::cerr; //---------------------------------------------------------------------------- diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.h b/lib/Target/SparcV9/RegAlloc/RegClass.h index 3db72b7363..c93d6961e0 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.h +++ b/lib/Target/SparcV9/RegAlloc/RegClass.h @@ -8,11 +8,9 @@ #ifndef REG_CLASS_H #define REG_CLASS_H -#include "llvm/CodeGen/IGNode.h" #include "llvm/CodeGen/InterferenceGraph.h" #include "llvm/Target/MachineRegInfo.h" #include -#include class MachineRegClassInfo; typedef std::vector ReservedColorListType; diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 8d87bfec6b..868f8710d8 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -17,7 +17,6 @@ #include "llvm/GlobalVariable.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -#include "llvm/Annotation.h" #include "llvm/BasicBlock.h" #include "llvm/Function.h" #include "llvm/Module.h" @@ -25,7 +24,6 @@ #include "llvm/Pass.h" #include "llvm/Assembly/Writer.h" #include "Support/StringExtras.h" -#include "Support/HashExtras.h" #include using std::string; diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index 354c39aa6b..71380ed92a 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -15,7 +15,6 @@ #include "llvm/Target/Sparc.h" #include "llvm/CodeGen/InstrSelection.h" #include "llvm/CodeGen/InstrSelectionSupport.h" -#include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineCodeForMethod.h" #include "llvm/Function.h" #include "llvm/Constants.h" diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h index 0e80179f4e..4ca66163ac 100644 --- a/lib/Target/SparcV9/SparcV9Internals.h +++ b/lib/Target/SparcV9/SparcV9Internals.h @@ -13,7 +13,6 @@ #define SPARC_INTERNALS_H #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/MachineInstrInfo.h" #include "llvm/Target/MachineSchedInfo.h" #include "llvm/Target/MachineFrameInfo.h" #include "llvm/Target/MachineCacheInfo.h" diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp index b25dd01ba9..6f645b1df7 100644 --- a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp @@ -1,5 +1,5 @@ #include "SparcRegClassInfo.h" -#include "llvm/CodeGen/IGNode.h" +#include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/Target/Sparc.h" #include "llvm/Type.h" #include diff --git a/lib/Target/SparcV9/SparcV9RegInfo.cpp b/lib/Target/SparcV9/SparcV9RegInfo.cpp index ad0dd25685..b660e89805 100644 --- a/lib/Target/SparcV9/SparcV9RegInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegInfo.cpp @@ -11,6 +11,7 @@ #include "llvm/CodeGen/MachineCodeForMethod.h" #include "llvm/CodeGen/PhyRegAlloc.h" #include "llvm/CodeGen/MachineInstr.h" +#include "llvm/CodeGen/RegAllocCommon.h" #include "llvm/Analysis/LiveVar/FunctionLiveVarInfo.h" #include "llvm/iTerminators.h" #include "llvm/iOther.h" diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index cd14bb3828..9f75198e1c 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -7,16 +7,13 @@ //===----------------------------------------------------------------------===// #include "TransformInternals.h" -#include "llvm/Function.h" #include "llvm/iOther.h" #include "llvm/iPHINode.h" #include "llvm/iMemory.h" -#include "llvm/Constants.h" #include "llvm/ConstantHandling.h" #include "llvm/Transforms/Scalar/DCE.h" #include "llvm/Analysis/Expressions.h" #include "Support/STLExtras.h" -#include #include #include using std::cerr; diff --git a/lib/Transforms/HoistPHIConstants.cpp b/lib/Transforms/HoistPHIConstants.cpp index 05480ea950..bdf2efc952 100644 --- a/lib/Transforms/HoistPHIConstants.cpp +++ b/lib/Transforms/HoistPHIConstants.cpp @@ -12,8 +12,6 @@ #include "llvm/BasicBlock.h" #include "llvm/Function.h" #include "llvm/Pass.h" -#include -#include typedef std::pair BBConstTy; typedef std::map CachedCopyMap; diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index dc330b29f8..75d1c5343a 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -25,7 +25,6 @@ #include "llvm/iTerminators.h" #include "llvm/iOther.h" #include "llvm/Support/CFG.h" -#include "llvm/Pass.h" #include #include using std::vector; diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index e852a6a29f..2f938079a8 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -9,9 +9,7 @@ #include "llvm/Analysis/CallGraph.h" #include "llvm/Module.h" #include "llvm/Function.h" -#include "llvm/Pass.h" #include "Support/DepthFirstIterator.h" -#include static bool RemoveUnreachableFunctions(Module *M, CallGraph &CallGraph) { // Calculate which functions are reachable from the external functions in the diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index ba64a6abce..9e84138b08 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -28,7 +28,6 @@ #include "llvm/Type.h" #include "llvm/Argument.h" #include -#include #include using std::cerr; diff --git a/lib/Transforms/IPO/OldPoolAllocate.cpp b/lib/Transforms/IPO/OldPoolAllocate.cpp index bb99002052..8255bcac52 100644 --- a/lib/Transforms/IPO/OldPoolAllocate.cpp +++ b/lib/Transforms/IPO/OldPoolAllocate.cpp @@ -11,7 +11,6 @@ #include "llvm/Transforms/IPO/PoolAllocate.h" #include "llvm/Transforms/CloneFunction.h" -#include "llvm/Analysis/DataStructure.h" #include "llvm/Analysis/DataStructureGraph.h" #include "llvm/Module.h" #include "llvm/Function.h" diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index 3a44dbf918..ebd290cd91 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -27,12 +27,9 @@ #include "llvm/Transforms/Instrumentation/ProfilePaths.h" #include "llvm/Transforms/UnifyFunctionExitNodes.h" #include "llvm/Support/CFG.h" -#include "llvm/Function.h" -#include "llvm/BasicBlock.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" -#include "llvm/Pass.h" #include "Graph.h" using std::vector; diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index f9f9abeace..2a6c6da20d 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -8,10 +8,8 @@ #include "llvm/Transforms/LevelChange.h" #include "TransformInternals.h" -#include "llvm/Function.h" #include "llvm/iOther.h" #include "llvm/iMemory.h" -#include "llvm/Constants.h" #include "llvm/Pass.h" #include "llvm/ConstantHandling.h" #include "llvm/Transforms/Scalar/DCE.h" diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index bd60b519a7..4c322aa9d3 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -7,7 +7,6 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar/DCE.h" -#include "llvm/Instruction.h" #include "llvm/Type.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/Writer.h" diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 4aac04114e..7fc519baf4 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -26,8 +26,6 @@ #include "llvm/Transforms/Scalar/DCE.h" #include "llvm/Module.h" #include "llvm/GlobalVariable.h" -#include "llvm/Function.h" -#include "llvm/BasicBlock.h" #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" #include "llvm/Constant.h" diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index 2676609141..06877a5ee9 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -15,13 +15,11 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/Scalar/GCSE.h" -#include "llvm/Pass.h" #include "llvm/InstrTypes.h" #include "llvm/iMemory.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Support/InstIterator.h" -#include #include namespace { diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 1e8621b5ed..6cfdc59687 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -11,9 +11,7 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/Type.h" -#include "llvm/BasicBlock.h" #include "llvm/Constants.h" -#include "llvm/Pass.h" #include "llvm/Support/CFG.h" #include "Support/STLExtras.h" diff --git a/lib/Transforms/Scalar/InductionVars.cpp b/lib/Transforms/Scalar/InductionVars.cpp index ee7c4c8a72..b4a440f4cc 100644 --- a/lib/Transforms/Scalar/InductionVars.cpp +++ b/lib/Transforms/Scalar/InductionVars.cpp @@ -21,13 +21,10 @@ #include "llvm/Transforms/Scalar/InductionVars.h" #include "llvm/Constants.h" -#include "llvm/Analysis/IntervalPartition.h" #include "llvm/iPHINode.h" -#include "llvm/Function.h" -#include "llvm/BasicBlock.h" -#include "llvm/InstrTypes.h" #include "llvm/Type.h" #include "llvm/Support/CFG.h" +#include "llvm/Analysis/IntervalPartition.h" #include "Support/STLExtras.h" #include #include diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index c8d2bed789..71c8723e42 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -16,7 +16,6 @@ #include "llvm/Transforms/Scalar/InstructionCombining.h" #include "llvm/ConstantHandling.h" -#include "llvm/Function.h" #include "llvm/iMemory.h" #include "llvm/iOther.h" #include "llvm/iOperators.h" diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 8271c9bce4..1a3649e881 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -18,8 +18,6 @@ #include "llvm/Transforms/Scalar/ConstantProp.h" #include "llvm/ConstantHandling.h" #include "llvm/Function.h" -#include "llvm/BasicBlock.h" -#include "llvm/Constants.h" #include "llvm/iPHINode.h" #include "llvm/iMemory.h" #include "llvm/iTerminators.h" @@ -28,7 +26,6 @@ #include "llvm/Support/InstVisitor.h" #include "Support/STLExtras.h" #include -#include #include #include using std::cerr; diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index c6cb81f0f5..07c034bad0 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -8,13 +8,11 @@ //===----------------------------------------------------------------------===// #include "llvm/Transforms/ChangeAllocations.h" -#include "llvm/Target/TargetData.h" #include "llvm/Module.h" #include "llvm/Function.h" #include "llvm/DerivedTypes.h" #include "llvm/iMemory.h" #include "llvm/iOther.h" -#include "llvm/Constants.h" #include "llvm/Pass.h" #include "TransformInternals.h" using std::vector; diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 3d81a8bde0..cfaeeccdf6 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -22,7 +22,6 @@ #include "llvm/iMemory.h" #include "llvm/iPHINode.h" #include "llvm/iTerminators.h" -#include "llvm/Pass.h" #include "llvm/Function.h" #include "llvm/BasicBlock.h" #include "llvm/Constant.h" diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 5b4ad43d10..8e5de34256 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -25,7 +25,6 @@ #include "Support/StringExtras.h" #include "Support/STLExtras.h" #include -#include using std::string; using std::map; using std::vector; diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index bd750df1bf..a3fdb28f49 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -6,7 +6,6 @@ #include "ValueHolderImpl.h" #include "llvm/iTerminators.h" -#include "llvm/SymbolTable.h" #include "llvm/Type.h" #include "llvm/Support/CFG.h" #include "llvm/iPHINode.h" diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 30d170b669..f542d112b8 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -7,7 +7,6 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Transforms/UnifyFunctionExitNodes.h" -#include "llvm/Function.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include "Support/STLExtras.h" diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index c15a88808d..a91948f31c 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -7,7 +7,6 @@ #include "llvm/Function.h" #include "llvm/DerivedTypes.h" -#include "llvm/SymbolTable.h" #include "llvm/Module.h" #include "llvm/GlobalVariable.h" #include "llvm/BasicBlock.h" diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index f06c9e3f60..0d25691cba 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -8,7 +8,6 @@ #include "llvm/Function.h" #include "llvm/GlobalVariable.h" #include "llvm/InstrTypes.h" -#include "llvm/Type.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "Support/STLExtras.h" diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 0196a99ce6..f33eb311d3 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -36,9 +36,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Pass.h" -#include "llvm/Function.h" #include "llvm/Module.h" -#include "llvm/BasicBlock.h" #include "llvm/DerivedTypes.h" #include "llvm/iPHINode.h" #include "llvm/iTerminators.h" diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 8633bef934..194dd33b27 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -11,7 +11,6 @@ #include "Support/CommandLine.h" #include "Support/STLExtras.h" -#include #include #include #include diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 7dbd3b7d1b..e347b4331b 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -10,9 +10,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Instruction.h" #include "llvm/Module.h" -#include "llvm/Function.h" #include "llvm/iPHINode.h" #include "llvm/Type.h" #include "llvm/PassManager.h" @@ -34,7 +32,6 @@ #include "llvm/Support/InstIterator.h" #include "Support/CommandLine.h" #include -#include using std::ostream; using std::string; diff --git a/tools/as/as.cpp b/tools/as/as.cpp index 9eff972172..594feb8dd8 100644 --- a/tools/as/as.cpp +++ b/tools/as/as.cpp @@ -15,7 +15,6 @@ #include "Support/CommandLine.h" #include "Support/Signals.h" #include -#include #include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); diff --git a/tools/dis/dis.cpp b/tools/dis/dis.cpp index e14dcdc9a7..e3d0ef0a4b 100644 --- a/tools/dis/dis.cpp +++ b/tools/dis/dis.cpp @@ -18,7 +18,6 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Function.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include "Support/PostOrderIterator.h" diff --git a/tools/gccas/gccas.cpp b/tools/gccas/gccas.cpp index 613f51c8f3..ef502c22f9 100644 --- a/tools/gccas/gccas.cpp +++ b/tools/gccas/gccas.cpp @@ -24,7 +24,6 @@ #include "Support/Signals.h" #include #include -#include cl::String InputFilename ("", "Parse file, compile to bytecode", cl::Required, ""); diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 802fd03729..6f6ab2ade6 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -20,7 +20,6 @@ #include "Support/CommandLine.h" #include "Support/Signals.h" #include -#include #include using std::string; diff --git a/tools/llvm-as/as.cpp b/tools/llvm-as/as.cpp index 9eff972172..594feb8dd8 100644 --- a/tools/llvm-as/as.cpp +++ b/tools/llvm-as/as.cpp @@ -15,7 +15,6 @@ #include "Support/CommandLine.h" #include "Support/Signals.h" #include -#include #include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index 9eff972172..594feb8dd8 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -15,7 +15,6 @@ #include "Support/CommandLine.h" #include "Support/Signals.h" #include -#include #include cl::String InputFilename ("", "Parse file, compile to bytecode", 0, "-"); diff --git a/tools/llvm-dis/dis.cpp b/tools/llvm-dis/dis.cpp index e14dcdc9a7..e3d0ef0a4b 100644 --- a/tools/llvm-dis/dis.cpp +++ b/tools/llvm-dis/dis.cpp @@ -18,7 +18,6 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Function.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include "Support/PostOrderIterator.h" diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index e14dcdc9a7..e3d0ef0a4b 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -18,7 +18,6 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" -#include "llvm/Function.h" #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" #include "Support/PostOrderIterator.h" -- cgit v1.2.3-70-g09d2 From 71fb71628ab3f5280a7f4602f52ba365bca31f29 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 22 May 2002 17:03:05 +0000 Subject: Add ability to update existing variables with values read from the command line to certain classes. This is nice because it means that in header files we can just declare a value, and still have that value be set based on a command-line argument. The difference is now that the #include of CommandLine.h does not need to go into the header file as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2708 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 57 +++++++++++++++++++++++++++++++------ include/llvm/Support/CommandLine.h | 57 +++++++++++++++++++++++++++++++------ lib/Support/CommandLine.cpp | 2 +- support/lib/Support/CommandLine.cpp | 2 +- 4 files changed, 98 insertions(+), 20 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index 3c0ac1ac69..b07b162a47 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -176,12 +176,22 @@ public: // Boolean/flag command line option // class Flag : public Option { - bool Value; + bool &Value; + bool DValue; virtual bool handleOccurance(const char *ArgName, const std::string &Arg); public: inline Flag(const char *ArgStr, const char *Message, int Flags = 0, - bool DefaultVal = 0) : Option(ArgStr, Message, Flags), - Value(DefaultVal) {} + bool DefaultVal = false) + : Option(ArgStr, Message, Flags), Value(DValue) { + Value = DefaultVal; + } + + inline Flag(bool &UpdateVal, const char *ArgStr, const char *Message, + int Flags = 0, bool DefaultVal = false) + : Option(ArgStr, Message, Flags), Value(UpdateVal) { + Value = DefaultVal; + } + operator const bool() const { return Value; } inline bool operator=(bool Val) { Value = Val; return Val; } }; @@ -278,7 +288,6 @@ public: class EnumValueBase : public EnumBase { protected: - int Value; inline EnumValueBase(const char *ArgStr, const char *Help, int Flags) : EnumBase(ArgStr, Help, Flags) {} inline EnumValueBase(int Flags) : EnumBase(Flags) {} @@ -293,6 +302,9 @@ protected: // to-be-maintained width is specified. // virtual void printOptionInfo(unsigned GlobalWidth) const; + + // setValue - Subclasses override this when they need to receive a new value + virtual void setValue(int Val) = 0; }; template // The enum we are representing @@ -300,17 +312,31 @@ class Enum : public EnumValueBase { virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } + E DVal; + E &Value; + + // setValue - Subclasses override this when they need to receive a new value + virtual void setValue(int Val) { Value = (E)Val; } public: inline Enum(const char *ArgStr, int Flags, const char *Help, ...) - : EnumValueBase(ArgStr, Help, Flags) { + : EnumValueBase(ArgStr, Help, Flags), Value(DVal) { va_list Values; va_start(Values, Help); processValues(Values); va_end(Values); - Value = ValueMap.front().second.first; // Grab default value + Value = (E)ValueMap.front().second.first; // Grab default value } - inline operator E() const { return (E)Value; } + inline Enum(E &EUpdate, const char *ArgStr, int Flags, const char *Help, ...) + : EnumValueBase(ArgStr, Help, Flags), Value(EUpdate) { + va_list Values; + va_start(Values, Help); + processValues(Values); + va_end(Values); + Value = (E)ValueMap.front().second.first; // Grab default value + } + + inline operator E() const { return Value; } inline E operator=(E Val) { Value = Val; return Val; } }; @@ -337,14 +363,27 @@ protected: template // The enum we are representing class EnumFlags : public EnumFlagsBase { + E DVal; + E &Value; + + // setValue - Subclasses override this when they need to receive a new value + virtual void setValue(int Val) { Value = (E)Val; } public: - inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags) { + inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags), Value(DVal) { + va_list Values; + va_start(Values, Flags); + processValues(Values); + va_end(Values); + registerArgs(); + Value = (E)ValueMap.front().second.first; // Grab default value + } + inline EnumFlags(E &RV, int Flags, ...) : EnumFlagsBase(Flags), Value(RV) { va_list Values; va_start(Values, Flags); processValues(Values); va_end(Values); registerArgs(); - Value = ValueMap.front().second.first; // Grab default value + Value = (E)ValueMap.front().second.first; // Grab default value } inline operator E() const { return (E)Value; } diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 3c0ac1ac69..b07b162a47 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -176,12 +176,22 @@ public: // Boolean/flag command line option // class Flag : public Option { - bool Value; + bool &Value; + bool DValue; virtual bool handleOccurance(const char *ArgName, const std::string &Arg); public: inline Flag(const char *ArgStr, const char *Message, int Flags = 0, - bool DefaultVal = 0) : Option(ArgStr, Message, Flags), - Value(DefaultVal) {} + bool DefaultVal = false) + : Option(ArgStr, Message, Flags), Value(DValue) { + Value = DefaultVal; + } + + inline Flag(bool &UpdateVal, const char *ArgStr, const char *Message, + int Flags = 0, bool DefaultVal = false) + : Option(ArgStr, Message, Flags), Value(UpdateVal) { + Value = DefaultVal; + } + operator const bool() const { return Value; } inline bool operator=(bool Val) { Value = Val; return Val; } }; @@ -278,7 +288,6 @@ public: class EnumValueBase : public EnumBase { protected: - int Value; inline EnumValueBase(const char *ArgStr, const char *Help, int Flags) : EnumBase(ArgStr, Help, Flags) {} inline EnumValueBase(int Flags) : EnumBase(Flags) {} @@ -293,6 +302,9 @@ protected: // to-be-maintained width is specified. // virtual void printOptionInfo(unsigned GlobalWidth) const; + + // setValue - Subclasses override this when they need to receive a new value + virtual void setValue(int Val) = 0; }; template // The enum we are representing @@ -300,17 +312,31 @@ class Enum : public EnumValueBase { virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } + E DVal; + E &Value; + + // setValue - Subclasses override this when they need to receive a new value + virtual void setValue(int Val) { Value = (E)Val; } public: inline Enum(const char *ArgStr, int Flags, const char *Help, ...) - : EnumValueBase(ArgStr, Help, Flags) { + : EnumValueBase(ArgStr, Help, Flags), Value(DVal) { va_list Values; va_start(Values, Help); processValues(Values); va_end(Values); - Value = ValueMap.front().second.first; // Grab default value + Value = (E)ValueMap.front().second.first; // Grab default value } - inline operator E() const { return (E)Value; } + inline Enum(E &EUpdate, const char *ArgStr, int Flags, const char *Help, ...) + : EnumValueBase(ArgStr, Help, Flags), Value(EUpdate) { + va_list Values; + va_start(Values, Help); + processValues(Values); + va_end(Values); + Value = (E)ValueMap.front().second.first; // Grab default value + } + + inline operator E() const { return Value; } inline E operator=(E Val) { Value = Val; return Val; } }; @@ -337,14 +363,27 @@ protected: template // The enum we are representing class EnumFlags : public EnumFlagsBase { + E DVal; + E &Value; + + // setValue - Subclasses override this when they need to receive a new value + virtual void setValue(int Val) { Value = (E)Val; } public: - inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags) { + inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags), Value(DVal) { + va_list Values; + va_start(Values, Flags); + processValues(Values); + va_end(Values); + registerArgs(); + Value = (E)ValueMap.front().second.first; // Grab default value + } + inline EnumFlags(E &RV, int Flags, ...) : EnumFlagsBase(Flags), Value(RV) { va_list Values; va_start(Values, Flags); processValues(Values); va_end(Values); registerArgs(); - Value = ValueMap.front().second.first; // Grab default value + Value = (E)ValueMap.front().second.first; // Grab default value } inline operator E() const { return (E)Value; } diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 194dd33b27..c3f18bd152 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -346,7 +346,7 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { return error(": unrecognized alternative '" + Arg + "'! Alternatives are: " + Alternatives); } - Value = ValueMap[i].second.first; + setValue(ValueMap[i].second.first); return false; } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 194dd33b27..c3f18bd152 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -346,7 +346,7 @@ bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { return error(": unrecognized alternative '" + Arg + "'! Alternatives are: " + Alternatives); } - Value = ValueMap[i].second.first; + setValue(ValueMap[i].second.first); return false; } -- cgit v1.2.3-70-g09d2 From 331de23705a719514e37c211f327379688f81b0d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 22 Jul 2002 02:07:59 +0000 Subject: Checkin CommandLine 2.0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2982 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 991 +++++++++++++++++++++++++++--------- include/llvm/Support/CommandLine.h | 991 +++++++++++++++++++++++++++--------- lib/Support/CommandLine.cpp | 687 ++++++++++++++++--------- support/lib/Support/CommandLine.cpp | 687 ++++++++++++++++--------- 4 files changed, 2414 insertions(+), 942 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index b07b162a47..e8a4250a89 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -4,8 +4,9 @@ // creating a tool. It provides a simple, minimalistic interface that is easily // extensible and supports nonlocal (library) command line options. // -// Note that rather than trying to figure out what this code does, you could try -// reading the library documentation located in docs/CommandLine.html +// Note that rather than trying to figure out what this code does, you should +// read the library documentation located in docs/CommandLine.html or looks at +// the many example usages in tools/*/*.cpp // //===----------------------------------------------------------------------===// @@ -16,45 +17,19 @@ #include #include #include +#include "boost/type_traits/object_traits.hpp" namespace cl { // Short namespace to make usage concise //===----------------------------------------------------------------------===// -// ParseCommandLineOptions - Minimalistic command line option processing entry +// ParseCommandLineOptions - Command line option processing entry point. // void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0, - int Flags = 0); - -// ParserOptions - This set of option is use to control global behavior of the -// command line processor. -// -enum ParserOptions { - // DisableSingleLetterArgGrouping - With this option enabled, multiple letter - // options are allowed to bunch together with only a single hyphen for the - // whole group. This allows emulation of the behavior that ls uses for - // example: ls -la === ls -l -a Providing this option, disables this. - // - DisableSingleLetterArgGrouping = 0x0001, - - // EnableSingleLetterArgValue - This option allows arguments that are - // otherwise unrecognized to match single letter flags that take a value. - // This is useful for cases like a linker, where options are typically of the - // form '-lfoo' or '-L../../include' where -l or -L are the actual flags. - // - EnableSingleLetterArgValue = 0x0002, -}; - + const char *Overview = 0); //===----------------------------------------------------------------------===// -// Global flags permitted to be passed to command line arguments - -enum FlagsOptions { - NoFlags = 0x00, // Marker to make explicit that we have no flags - Default = 0x00, // Equally, marker to use the default flags - - GlobalsMask = 0x80, -}; +// Flags permitted to be passed to command line arguments +// enum NumOccurances { // Flags for the number of occurances allowed... Optional = 0x01, // Zero or One occurance @@ -62,11 +37,12 @@ enum NumOccurances { // Flags for the number of occurances allowed... Required = 0x03, // One occurance required OneOrMore = 0x04, // One or more occurances required - // ConsumeAfter - Marker for a null ("") flag that can be used to indicate - // that anything that matches the null marker starts a sequence of options - // that all get sent to the null marker. Thus, for example, all arguments - // to LLI are processed until a filename is found. Once a filename is found, - // all of the succeeding arguments are passed, unprocessed, to the null flag. + // ConsumeAfter - Indicates that this option is fed anything that follows the + // last positional argument required by the application (it is an error if + // there are zero positional arguments, and a ConsumeAfter option is used). + // Thus, for example, all arguments to LLI are processed until a filename is + // found. Once a filename is found, all of the succeeding arguments are + // passed, unprocessed, to the ConsumeAfter option. // ConsumeAfter = 0x05, @@ -87,14 +63,37 @@ enum OptionHidden { // Control whether -help shows this option HiddenMask = 0x60, }; +// Formatting flags - This controls special features that the option might have +// that cause it to be parsed differently... +// +// Prefix - This option allows arguments that are otherwise unrecognized to be +// matched by options that are a prefix of the actual value. This is useful for +// cases like a linker, where options are typically of the form '-lfoo' or +// '-L../../include' where -l or -L are the actual flags. When prefix is +// enabled, and used, the value for the flag comes from the suffix of the +// argument. +// +// Grouping - With this option enabled, multiple letter options are allowed to +// bunch together with only a single hyphen for the whole group. This allows +// emulation of the behavior that ls uses for example: ls -la === ls -l -a +// + +enum FormattingFlags { + NormalFormatting = 0x000, // Nothing special + Positional = 0x080, // Is a positional argument, no '-' required + Prefix = 0x100, // Can this option directly prefix its value? + Grouping = 0x180, // Can this option group with other options? + FormattingMask = 0x180, +}; + //===----------------------------------------------------------------------===// // Option Base class // -class Alias; +class alias; class Option { friend void cl::ParseCommandLineOptions(int &, char **, const char *, int); - friend class Alias; + friend class alias; // handleOccurances - Overriden by subclasses to handle the value passed into // an argument. Should return true if there was an error processing the @@ -111,12 +110,16 @@ class Option { virtual enum OptionHidden getOptionHiddenFlagDefault() const { return NotHidden; } + virtual enum FormattingFlags getFormattingFlagDefault() const { + return NormalFormatting; + } - int NumOccurances; // The number of times specified - const int Flags; // Flags for the argument + int NumOccurances; // The number of times specified + int Flags; // Flags for the argument public: - const char * const ArgStr; // The argument string itself (ex: "help", "o") - const char * const HelpStr; // The descriptive text message for --help + const char *ArgStr; // The argument string itself (ex: "help", "o") + const char *HelpStr; // The descriptive text message for --help + const char *ValueStr; // String describing what the value of this option is inline enum NumOccurances getNumOccurancesFlag() const { int NO = Flags & OccurancesMask; @@ -130,19 +133,54 @@ public: int OH = Flags & HiddenMask; return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault(); } + inline enum FormattingFlags getFormattingFlag() const { + int OH = Flags & FormattingMask; + return OH ? (enum FormattingFlags)OH : getFormattingFlagDefault(); + } + + // hasArgStr - Return true if the argstr != "" + bool hasArgStr() const { return ArgStr[0] != 0; } + + //-------------------------------------------------------------------------=== + // Accessor functions set by OptionModifiers + // + void setArgStr(const char *S) { ArgStr = S; } + void setDescription(const char *S) { HelpStr = S; } + void setValueStr(const char *S) { ValueStr = S; } + + void setFlag(unsigned Flag, unsigned FlagMask) { + if (Flags & FlagMask) { + error(": Specified two settings for the same option!"); + exit(1); + } + + Flags |= Flag; + } + + void setNumOccurancesFlag(enum NumOccurances Val) { + setFlag(Val, OccurancesMask); + } + void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); } + void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } + void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } protected: - Option(const char *ArgStr, const char *Message, int Flags); - Option(int flags) : NumOccurances(0), Flags(flags), ArgStr(""), HelpStr("") {} + Option() : NumOccurances(0), Flags(0), + ArgStr(""), HelpStr(""), ValueStr("") {} public: + // addArgument - Tell the system that this Option subclass will handle all + // occurances of -ArgStr on the command line. + // + void addArgument(const char *ArgStr); + // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + virtual unsigned getOptionWidth() const = 0; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(unsigned GlobalWidth) const; + virtual void printOptionInfo(unsigned GlobalWidth) const = 0; // addOccurance - Wrapper around handleOccurance that enforces Flags // @@ -158,279 +196,774 @@ public: //===----------------------------------------------------------------------===// -// Aliased command line option (alias this name to a preexisting name) +// Command line option modifiers that can be used to modify the behavior of +// command line option parsers... // -class Alias : public Option { - Option &AliasFor; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { - return AliasFor.handleOccurance(AliasFor.ArgStr, Arg); - } - virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} -public: - inline Alias(const char *ArgStr, const char *Message, int Flags, - Option &aliasFor) : Option(ArgStr, Message, Flags), - AliasFor(aliasFor) {} + +// desc - Modifier to set the description shown in the --help output... +struct desc { + const char *Desc; + desc(const char *Str) : Desc(Str) {} + void apply(Option &O) const { O.setDescription(Desc); } +}; + +// value_desc - Modifier to set the value description shown in the --help +// output... +struct value_desc { + const char *Desc; + value_desc(const char *Str) : Desc(Str) {} + void apply(Option &O) const { O.setValueStr(Desc); } +}; + + +// init - Specify a default (initial) value for the command line argument, if +// the default constructor for the argument type does not give you what you +// want. This is only valid on "opt" arguments, not on "list" arguments. +// +template +struct initializer { + const Ty &Init; + initializer(const Ty &Val) : Init(Val) {} + + template + void apply(Opt &O) const { O.setInitialValue(Init); } }; +template +initializer init(const Ty &Val) { + return initializer(Val); +} + + +// location - Allow the user to specify which external variable they want to +// store the results of the command line argument processing into, if they don't +// want to store it in the option itself. +// +template +struct LocationClass { + Ty &Loc; + LocationClass(Ty &L) : Loc(L) {} + + template + void apply(Opt &O) const { O.setLocation(O, Loc); } +}; + +template +LocationClass location(Ty &L) { return LocationClass(L); } + + //===----------------------------------------------------------------------===// -// Boolean/flag command line option +// Enum valued command line option // -class Flag : public Option { - bool &Value; - bool DValue; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); +#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, ENUMVAL, DESC +#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, ENUMVAL, DESC + +// values - For custom data types, allow specifying a group of values together +// as the values that go into the mapping that the option handler uses. Note +// that the values list must always have a 0 at the end of the list to indicate +// that the list has ended. +// +template +class ValuesClass { + // Use a vector instead of a map, because the lists should be short, + // the overhead is less, and most importantly, it keeps them in the order + // inserted so we can print our option out nicely. + std::vector > > Values; + void processValues(va_list Vals); public: - inline Flag(const char *ArgStr, const char *Message, int Flags = 0, - bool DefaultVal = false) - : Option(ArgStr, Message, Flags), Value(DValue) { - Value = DefaultVal; + ValuesClass(const char *EnumName, DataType Val, const char *Desc, + va_list ValueArgs) { + // Insert the first value, which is required. + Values.push_back(std::make_pair(EnumName, std::make_pair(Val, Desc))); + + // Process the varargs portion of the values... + while (const char *EnumName = va_arg(ValueArgs, const char *)) { + DataType EnumVal = va_arg(ValueArgs, DataType); + const char *EnumDesc = va_arg(ValueArgs, const char *); + Values.push_back(std::make_pair(EnumName, // Add value to value map + std::make_pair(EnumVal, EnumDesc))); + } } - inline Flag(bool &UpdateVal, const char *ArgStr, const char *Message, - int Flags = 0, bool DefaultVal = false) - : Option(ArgStr, Message, Flags), Value(UpdateVal) { - Value = DefaultVal; + template + void apply(Opt &O) const { + for (unsigned i = 0, e = Values.size(); i != e; ++i) + O.getParser().addLiteralOption(Values[i].first, Values[i].second.first, + Values[i].second.second); } - - operator const bool() const { return Value; } - inline bool operator=(bool Val) { Value = Val; return Val; } }; +template +ValuesClass values(const char *Arg, DataType Val, const char *Desc, + ...) { + va_list ValueArgs; + va_start(ValueArgs, Desc); + ValuesClass Vals(Arg, Val, Desc, ValueArgs); + va_end(ValueArgs); + return Vals; +} //===----------------------------------------------------------------------===// -// Integer valued command line option +// parser class - Parameterizable parser for different data types. By default, +// known data types (string, int, bool) have specialized parsers, that do what +// you would expect. The default parser, used for data types that are not +// built-in, uses a mapping table to map specific options to values, which is +// used, among other things, to handle enum types. + +//-------------------------------------------------- +// generic_parser_base - This class holds all the non-generic code that we do +// not need replicated for every instance of the generic parser. This also +// allows us to put stuff into CommandLine.cpp // -class Int : public Option { - int Value; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueRequired; +struct generic_parser_base { + virtual ~generic_parser_base() {} // Base class should have virtual-dtor + + // getNumOptions - Virtual function implemented by generic subclass to + // indicate how many entries are in Values. + // + virtual unsigned getNumOptions() const = 0; + + // getOption - Return option name N. + virtual const char *getOption(unsigned N) const = 0; + + // getDescription - Return description N + virtual const char *getDescription(unsigned N) const = 0; + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; + + void initialize(Option &O) { + // All of the modifiers for the option have been processed by now, so the + // argstr field should be stable, copy it down now. + // + hasArgStr = O.hasArgStr(); + + // If there has been no argstr specified, that means that we need to add an + // argument for every possible option. This ensures that our options are + // vectored to us. + // + if (!hasArgStr) + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) + O.addArgument(getOption(i)); } -public: - inline Int(const char *ArgStr, const char *Help, int Flags = 0, - int DefaultVal = 0) : Option(ArgStr, Help, Flags), - Value(DefaultVal) {} - inline operator int() const { return Value; } - inline int operator=(int Val) { Value = Val; return Val; } -}; + enum ValueExpected getValueExpectedFlagDefault() const { + // If there is an ArgStr specified, then we are of the form: + // + // -opt=O2 or -opt O2 or -optO2 + // + // In which case, the value is required. Otherwise if an arg str has not + // been specified, we are of the form: + // + // -O2 or O2 or -la (where -l and -a are seperate options) + // + // If this is the case, we cannot allow a value. + // + if (hasArgStr) + return ValueRequired; + else + return ValueDisallowed; + } -//===----------------------------------------------------------------------===// -// String valued command line option +protected: + bool hasArgStr; +}; + +// Default parser implementation - This implementation depends on having a +// mapping of recognized options to values of some sort. In addition to this, +// each entry in the mapping also tracks a help message that is printed with the +// command line option for --help. Because this is a simple mapping parser, the +// data type can be any unsupported type. // -class String : public Option, public std::string { - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueRequired; +template +class parser : public generic_parser_base { + std::vector > > Values; + + // Implement virtual functions needed by generic_parser_base + unsigned getNumOptions() const { return Values.size(); } + const char *getOption(unsigned N) const { return Values[N].first; } + const char *getDescription(unsigned N) const { + return Values[N].second.second; } + public: - inline String(const char *ArgStr, const char *Help, int Flags = 0, - const char *DefaultVal = "") - : Option(ArgStr, Help, Flags), std::string(DefaultVal) {} + // Default implementation, requires user to populate it with values somehow. + template // parse - Return true on error. + bool parse(Opt &O, const char *ArgName, const string &Arg) { + string ArgVal; + if (hasArgStr) + ArgVal = Arg; + else + ArgVal = ArgName; + + for (unsigned i = 0, e = Values.size(); i != e; ++i) + if (ArgVal == Values[i].first) { + O.addValue(Values[i].second.first); + return false; + } + + return O.error(": Cannot find option named '" + ArgVal + "'!"); + } - inline const std::string &operator=(const std::string &Val) { - return std::string::operator=(Val); + // addLiteralOption - Add an entry to the mapping table... + template + void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) { + Values.push_back(std::make_pair(Name, std::make_pair((DataType)V,HelpStr))); } }; -//===----------------------------------------------------------------------===// -// String list command line option +//-------------------------------------------------- +// parser // -class StringList : public Option, public std::vector { - - virtual enum NumOccurances getNumOccurancesFlagDefault() const { - return ZeroOrMore; +template<> +class parser { + static bool parseImpl(Option &O, const string &Arg, bool &Val); +public: + + template // parse - Return true on error. + bool parse(Opt &O, const char *ArgName, const string &Arg) { + bool Val; + bool Error = parseImpl(O, Arg, Val); + if (!Error) O.addValue(Val); + return Error; } - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueRequired; + + enum ValueExpected getValueExpectedFlagDefault() const { + return ValueOptional; } - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); -public: - inline StringList(const char *ArgStr, const char *Help, int Flags = 0) - : Option(ArgStr, Help, Flags) {} + void initialize(Option &O) {} + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; }; -//===----------------------------------------------------------------------===// -// Enum valued command line option +//-------------------------------------------------- +// parser // -#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, ENUMVAL, DESC -#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, ENUMVAL, DESC +template<> +class parser { + static bool parseImpl(Option &O, const string &Arg, int &Val); +public: + + // parse - Return true on error. + template + bool parse(Opt &O, const char *ArgName, const string &Arg) { + int Val; + bool Error = parseImpl(O, Arg, Val); + if (!Error) O.addValue(Val); + return Error; + } -// EnumBase - Base class for all enum/varargs related argument types... -class EnumBase : public Option { -protected: - // Use a vector instead of a map, because the lists should be short, - // the overhead is less, and most importantly, it keeps them in the order - // inserted so we can print our option out nicely. - std::vector > > ValueMap; + enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } + + void initialize(Option &O) {} - inline EnumBase(const char *ArgStr, const char *Help, int Flags) - : Option(ArgStr, Help, Flags) {} - inline EnumBase(int Flags) : Option(Flags) {} + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; - // processValues - Incorporate the specifed varargs arglist into the - // ValueMap. + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. // - void processValues(va_list Vals); + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; +}; - // registerArgs - notify the system about these new arguments - void registerArgs(); +//-------------------------------------------------- +// parser +// +template<> +class parser { + static bool parseImpl(Option &O, const string &Arg, double &Val); public: - // Turn an enum into the arg name that activates it - const char *getArgName(int ID) const; - const char *getArgDescription(int ID) const; -}; + + // parse - Return true on error. + template + bool parse(Opt &O, const char *ArgName, const string &Arg) { + double Val; + bool Error = parseImpl(O, Arg, Val); + if (!Error) O.addValue(Val); + return Error; + } -class EnumValueBase : public EnumBase { -protected: - inline EnumValueBase(const char *ArgStr, const char *Help, int Flags) - : EnumBase(ArgStr, Help, Flags) {} - inline EnumValueBase(int Flags) : EnumBase(Flags) {} + enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } - // handleOccurance - Set Value to the enum value specified by Arg - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); + void initialize(Option &O) {} // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + virtual unsigned getOptionWidth(const Option &O) const; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(unsigned GlobalWidth) const; - - // setValue - Subclasses override this when they need to receive a new value - virtual void setValue(int Val) = 0; + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; }; -template // The enum we are representing -class Enum : public EnumValueBase { - virtual enum ValueExpected getValueExpectedFlagDefault() const { +// Parser is the same as parser +template<> struct parser : public parser {}; + + + +//-------------------------------------------------- +// parser +// +template<> +struct parser { + // parse - Return true on error. + template + bool parse(Opt &O, const char *ArgName, const string &Arg) { + O.addValue(Arg); + return false; + } + enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } - E DVal; - E &Value; - // setValue - Subclasses override this when they need to receive a new value - virtual void setValue(int Val) { Value = (E)Val; } + void initialize(Option &O) {} + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; +}; + + + +//===----------------------------------------------------------------------===// +// applicator class - This class is used because we must use partial +// specialization to handle literal string arguments specially (const char* does +// not correctly respond to the apply method). Because the syntax to use this +// is a pain, we have the 'apply' method below to handle the nastiness... +// +template struct applicator { + template + static void opt(const Mod &M, Opt &O) { M.apply(O); } +}; + +// Handle const char* as a special case... +template struct applicator { + template + static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +}; +template<> struct applicator { + template + static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +}; + +template<> struct applicator { + static void opt(NumOccurances NO, Option &O) { O.setNumOccurancesFlag(NO); } +}; +template<> struct applicator { + static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); } +}; +template<> struct applicator { + static void opt(OptionHidden OH, Option &O) { O.setHiddenFlag(OH); } +}; +template<> struct applicator { + static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); } +}; + +// apply method - Apply a modifier to an option in a type safe way. +template +void apply(const Mod &M, Opt *O) { + applicator::opt(M, *O); +} + + +//===----------------------------------------------------------------------===// +// opt_storage class + +// Default storage class definition: external storage. This implementation +// assumes the user will specify a variable to store the data into with the +// cl::location(x) modifier. +// +template +class opt_storage { + DataType *Location; // Where to store the object... + + void check() { + assert(Location != 0 && "cl::location(...) not specified for a command " + "line option with external storage!"); + } public: - inline Enum(const char *ArgStr, int Flags, const char *Help, ...) - : EnumValueBase(ArgStr, Help, Flags), Value(DVal) { - va_list Values; - va_start(Values, Help); - processValues(Values); - va_end(Values); - Value = (E)ValueMap.front().second.first; // Grab default value + opt_storage() : Location(0) {} + + bool setLocation(Option &O, DataType &L) { + if (Location) + return O.error(": cl::location(x) specified more than once!"); + Location = &L; + return false; } - inline Enum(E &EUpdate, const char *ArgStr, int Flags, const char *Help, ...) - : EnumValueBase(ArgStr, Help, Flags), Value(EUpdate) { - va_list Values; - va_start(Values, Help); - processValues(Values); - va_end(Values); - Value = (E)ValueMap.front().second.first; // Grab default value + template + void setValue(const T &V) { + check(); + *Location = V; } - inline operator E() const { return Value; } - inline E operator=(E Val) { Value = Val; return Val; } + DataType &getValue() { check(); return *Location; } + const DataType &getValue() const { check(); return *Location; } +}; + + +// Define how to hold a class type object, such as a string. Since we can +// inherit from a class, we do so. This makes us exactly compatible with the +// object in all cases that it is used. +// +template +struct opt_storage : public DataType { + + template + void setValue(const T &V) { DataType::operator=(V); } + + DataType &getValue() { return *this; } + const DataType &getValue() const { return *this; } +}; + +// Define a partial specialization to handle things we cannot inherit from. In +// this case, we store an instance through containment, and overload operators +// to get at the value. +// +template +struct opt_storage { + DataType Value; + + // Make sure we initialize the value with the default constructor for the + // type. + opt_storage() : Value(DataType()) {} + + template + void setValue(const T &V) { Value = V; } + DataType &getValue() { return Value; } + DataType getValue() const { return Value; } }; //===----------------------------------------------------------------------===// -// Enum flags command line option +// opt - A scalar command line option. // -class EnumFlagsBase : public EnumValueBase { +template > +class opt : public Option, + public opt_storage::value>{ + ParserClass Parser; + + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + return Parser.parse(*this, ArgName, Arg); + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueDisallowed; + return Parser.getValueExpectedFlagDefault(); } -protected: - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); - inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {} - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + // Forward printing stuff to the parser... + virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(unsigned GlobalWidth) const { + Parser.printOptionInfo(*this, GlobalWidth); + } - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; + void done() { + addArgument(ArgStr); + Parser.initialize(*this); + } +public: + // setInitialValue - Used by the cl::init modifier... + void setInitialValue(const DataType &V) { setValue(V); } + + // addValue - Used by the parser to add a value to the option + template + void addValue(const T &V) { setValue(V); } + ParserClass &getParser() { return Parser; } + + operator DataType() const { return getValue(); } + + template + DataType &operator=(const T &Val) { setValue(Val); return getValue(); } + + // One option... + template + opt(const M0t &M0) { + apply(M0, this); + done(); + } + + // Two options... + template + opt(const M0t &M0, const M1t &M1) { + apply(M0, this); apply(M1, this); + done(); + } + + // Three options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2) { + apply(M0, this); apply(M1, this); apply(M2, this); + done(); + } + // Four options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + done(); + } + // Five options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); + done(); + } + // Six options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); + done(); + } + // Seven options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); + done(); + } + // Eight options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); + done(); + } }; -template // The enum we are representing -class EnumFlags : public EnumFlagsBase { - E DVal; - E &Value; +//===----------------------------------------------------------------------===// +// list_storage class + +// Default storage class definition: external storage. This implementation +// assumes the user will specify a variable to store the data into with the +// cl::location(x) modifier. +// +template +class list_storage { + StorageClass *Location; // Where to store the object... - // setValue - Subclasses override this when they need to receive a new value - virtual void setValue(int Val) { Value = (E)Val; } public: - inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags), Value(DVal) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - Value = (E)ValueMap.front().second.first; // Grab default value + list_storage() : Location(0) {} + + bool setLocation(Option &O, StorageClass &L) { + if (Location) + return O.error(": cl::location(x) specified more than once!"); + Location = &L; + return false; } - inline EnumFlags(E &RV, int Flags, ...) : EnumFlagsBase(Flags), Value(RV) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - Value = (E)ValueMap.front().second.first; // Grab default value + + template + void addValue(const T &V) { + assert(Location != 0 && "cl::location(...) not specified for a command " + "line option with external storage!"); + Location->push_back(V); } +}; + + +// Define how to hold a class type object, such as a string. Since we can +// inherit from a class, we do so. This makes us exactly compatible with the +// object in all cases that it is used. +// +template +struct list_storage : public std::vector { - inline operator E() const { return (E)Value; } - inline E operator=(E Val) { Value = Val; return Val; } + template + void addValue(const T &V) { push_back(V); } }; //===----------------------------------------------------------------------===// -// Enum list command line option +// list - A list of command line options. // -class EnumListBase : public EnumBase { +template > +class list : public Option, public list_storage { + ParserClass Parser; + virtual enum NumOccurances getNumOccurancesFlagDefault() const { return ZeroOrMore; } virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueDisallowed; + return Parser.getValueExpectedFlagDefault(); } -protected: - std::vector Values; // The options specified so far. - inline EnumListBase(int Flags) - : EnumBase(Flags) {} - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + return Parser.parse(*this, ArgName, Arg); + } - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + // Forward printing stuff to the parser... + virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(unsigned GlobalWidth) const { + Parser.printOptionInfo(*this, GlobalWidth); + } - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; + void done() { + addArgument(ArgStr); + Parser.initialize(*this); + } public: - inline unsigned size() { return Values.size(); } + ParserClass &getParser() { return Parser; } + + // One option... + template + list(const M0t &M0) { + apply(M0, this); + done(); + } + // Two options... + template + list(const M0t &M0, const M1t &M1) { + apply(M0, this); apply(M1, this); + done(); + } + // Three options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2) { + apply(M0, this); apply(M1, this); apply(M2, this); + done(); + } + // Four options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + done(); + } + // Five options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); + done(); + } + // Six options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); + done(); + } + // Seven options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); + done(); + } + // Eight options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); + done(); + } }; -template // The enum we are representing -class EnumList : public EnumListBase { + + +//===----------------------------------------------------------------------===// +// Aliased command line option (alias this name to a preexisting name) +// + +class alias : public Option { + Option *AliasFor; + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + return AliasFor->handleOccurance(AliasFor->ArgStr, Arg); + } + // Aliases default to be hidden... + virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} + + // Handle printing stuff... + virtual unsigned getOptionWidth() const; + virtual void printOptionInfo(unsigned GlobalWidth) const; + + void done() { + if (!hasArgStr()) + error(": cl::alias must have argument name specified!"); + if (AliasFor == 0) + error(": cl::alias must have an cl::aliasopt(option) specified!"); + addArgument(ArgStr); + } public: - inline EnumList(int Flags, ...) : EnumListBase(Flags) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - } - inline E operator[](unsigned i) const { return (E)Values[i]; } - inline E &operator[](unsigned i) { return (E&)Values[i]; } + void setAliasFor(Option &O) { + if (AliasFor) + error(": cl::alias must only have one cl::aliasopt(...) specified!"); + AliasFor = &O; + } + + // One option... + template + alias(const M0t &M0) : AliasFor(0) { + apply(M0, this); + done(); + } + // Two options... + template + alias(const M0t &M0, const M1t &M1) : AliasFor(0) { + apply(M0, this); apply(M1, this); + done(); + } + // Three options... + template + alias(const M0t &M0, const M1t &M1, const M2t &M2) : AliasFor(0) { + apply(M0, this); apply(M1, this); apply(M2, this); + done(); + } + // Four options... + template + alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) + : AliasFor(0) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + done(); + } +}; + +// aliasfor - Modifier to set the option an alias aliases. +struct aliasopt { + Option &Opt; + aliasopt(Option &O) : Opt(O) {} + void apply(alias &A) const { A.setAliasFor(Opt); } }; } // End namespace cl diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index b07b162a47..e8a4250a89 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -4,8 +4,9 @@ // creating a tool. It provides a simple, minimalistic interface that is easily // extensible and supports nonlocal (library) command line options. // -// Note that rather than trying to figure out what this code does, you could try -// reading the library documentation located in docs/CommandLine.html +// Note that rather than trying to figure out what this code does, you should +// read the library documentation located in docs/CommandLine.html or looks at +// the many example usages in tools/*/*.cpp // //===----------------------------------------------------------------------===// @@ -16,45 +17,19 @@ #include #include #include +#include "boost/type_traits/object_traits.hpp" namespace cl { // Short namespace to make usage concise //===----------------------------------------------------------------------===// -// ParseCommandLineOptions - Minimalistic command line option processing entry +// ParseCommandLineOptions - Command line option processing entry point. // void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0, - int Flags = 0); - -// ParserOptions - This set of option is use to control global behavior of the -// command line processor. -// -enum ParserOptions { - // DisableSingleLetterArgGrouping - With this option enabled, multiple letter - // options are allowed to bunch together with only a single hyphen for the - // whole group. This allows emulation of the behavior that ls uses for - // example: ls -la === ls -l -a Providing this option, disables this. - // - DisableSingleLetterArgGrouping = 0x0001, - - // EnableSingleLetterArgValue - This option allows arguments that are - // otherwise unrecognized to match single letter flags that take a value. - // This is useful for cases like a linker, where options are typically of the - // form '-lfoo' or '-L../../include' where -l or -L are the actual flags. - // - EnableSingleLetterArgValue = 0x0002, -}; - + const char *Overview = 0); //===----------------------------------------------------------------------===// -// Global flags permitted to be passed to command line arguments - -enum FlagsOptions { - NoFlags = 0x00, // Marker to make explicit that we have no flags - Default = 0x00, // Equally, marker to use the default flags - - GlobalsMask = 0x80, -}; +// Flags permitted to be passed to command line arguments +// enum NumOccurances { // Flags for the number of occurances allowed... Optional = 0x01, // Zero or One occurance @@ -62,11 +37,12 @@ enum NumOccurances { // Flags for the number of occurances allowed... Required = 0x03, // One occurance required OneOrMore = 0x04, // One or more occurances required - // ConsumeAfter - Marker for a null ("") flag that can be used to indicate - // that anything that matches the null marker starts a sequence of options - // that all get sent to the null marker. Thus, for example, all arguments - // to LLI are processed until a filename is found. Once a filename is found, - // all of the succeeding arguments are passed, unprocessed, to the null flag. + // ConsumeAfter - Indicates that this option is fed anything that follows the + // last positional argument required by the application (it is an error if + // there are zero positional arguments, and a ConsumeAfter option is used). + // Thus, for example, all arguments to LLI are processed until a filename is + // found. Once a filename is found, all of the succeeding arguments are + // passed, unprocessed, to the ConsumeAfter option. // ConsumeAfter = 0x05, @@ -87,14 +63,37 @@ enum OptionHidden { // Control whether -help shows this option HiddenMask = 0x60, }; +// Formatting flags - This controls special features that the option might have +// that cause it to be parsed differently... +// +// Prefix - This option allows arguments that are otherwise unrecognized to be +// matched by options that are a prefix of the actual value. This is useful for +// cases like a linker, where options are typically of the form '-lfoo' or +// '-L../../include' where -l or -L are the actual flags. When prefix is +// enabled, and used, the value for the flag comes from the suffix of the +// argument. +// +// Grouping - With this option enabled, multiple letter options are allowed to +// bunch together with only a single hyphen for the whole group. This allows +// emulation of the behavior that ls uses for example: ls -la === ls -l -a +// + +enum FormattingFlags { + NormalFormatting = 0x000, // Nothing special + Positional = 0x080, // Is a positional argument, no '-' required + Prefix = 0x100, // Can this option directly prefix its value? + Grouping = 0x180, // Can this option group with other options? + FormattingMask = 0x180, +}; + //===----------------------------------------------------------------------===// // Option Base class // -class Alias; +class alias; class Option { friend void cl::ParseCommandLineOptions(int &, char **, const char *, int); - friend class Alias; + friend class alias; // handleOccurances - Overriden by subclasses to handle the value passed into // an argument. Should return true if there was an error processing the @@ -111,12 +110,16 @@ class Option { virtual enum OptionHidden getOptionHiddenFlagDefault() const { return NotHidden; } + virtual enum FormattingFlags getFormattingFlagDefault() const { + return NormalFormatting; + } - int NumOccurances; // The number of times specified - const int Flags; // Flags for the argument + int NumOccurances; // The number of times specified + int Flags; // Flags for the argument public: - const char * const ArgStr; // The argument string itself (ex: "help", "o") - const char * const HelpStr; // The descriptive text message for --help + const char *ArgStr; // The argument string itself (ex: "help", "o") + const char *HelpStr; // The descriptive text message for --help + const char *ValueStr; // String describing what the value of this option is inline enum NumOccurances getNumOccurancesFlag() const { int NO = Flags & OccurancesMask; @@ -130,19 +133,54 @@ public: int OH = Flags & HiddenMask; return OH ? (enum OptionHidden)OH : getOptionHiddenFlagDefault(); } + inline enum FormattingFlags getFormattingFlag() const { + int OH = Flags & FormattingMask; + return OH ? (enum FormattingFlags)OH : getFormattingFlagDefault(); + } + + // hasArgStr - Return true if the argstr != "" + bool hasArgStr() const { return ArgStr[0] != 0; } + + //-------------------------------------------------------------------------=== + // Accessor functions set by OptionModifiers + // + void setArgStr(const char *S) { ArgStr = S; } + void setDescription(const char *S) { HelpStr = S; } + void setValueStr(const char *S) { ValueStr = S; } + + void setFlag(unsigned Flag, unsigned FlagMask) { + if (Flags & FlagMask) { + error(": Specified two settings for the same option!"); + exit(1); + } + + Flags |= Flag; + } + + void setNumOccurancesFlag(enum NumOccurances Val) { + setFlag(Val, OccurancesMask); + } + void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); } + void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } + void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } protected: - Option(const char *ArgStr, const char *Message, int Flags); - Option(int flags) : NumOccurances(0), Flags(flags), ArgStr(""), HelpStr("") {} + Option() : NumOccurances(0), Flags(0), + ArgStr(""), HelpStr(""), ValueStr("") {} public: + // addArgument - Tell the system that this Option subclass will handle all + // occurances of -ArgStr on the command line. + // + void addArgument(const char *ArgStr); + // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + virtual unsigned getOptionWidth() const = 0; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(unsigned GlobalWidth) const; + virtual void printOptionInfo(unsigned GlobalWidth) const = 0; // addOccurance - Wrapper around handleOccurance that enforces Flags // @@ -158,279 +196,774 @@ public: //===----------------------------------------------------------------------===// -// Aliased command line option (alias this name to a preexisting name) +// Command line option modifiers that can be used to modify the behavior of +// command line option parsers... // -class Alias : public Option { - Option &AliasFor; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { - return AliasFor.handleOccurance(AliasFor.ArgStr, Arg); - } - virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} -public: - inline Alias(const char *ArgStr, const char *Message, int Flags, - Option &aliasFor) : Option(ArgStr, Message, Flags), - AliasFor(aliasFor) {} + +// desc - Modifier to set the description shown in the --help output... +struct desc { + const char *Desc; + desc(const char *Str) : Desc(Str) {} + void apply(Option &O) const { O.setDescription(Desc); } +}; + +// value_desc - Modifier to set the value description shown in the --help +// output... +struct value_desc { + const char *Desc; + value_desc(const char *Str) : Desc(Str) {} + void apply(Option &O) const { O.setValueStr(Desc); } +}; + + +// init - Specify a default (initial) value for the command line argument, if +// the default constructor for the argument type does not give you what you +// want. This is only valid on "opt" arguments, not on "list" arguments. +// +template +struct initializer { + const Ty &Init; + initializer(const Ty &Val) : Init(Val) {} + + template + void apply(Opt &O) const { O.setInitialValue(Init); } }; +template +initializer init(const Ty &Val) { + return initializer(Val); +} + + +// location - Allow the user to specify which external variable they want to +// store the results of the command line argument processing into, if they don't +// want to store it in the option itself. +// +template +struct LocationClass { + Ty &Loc; + LocationClass(Ty &L) : Loc(L) {} + + template + void apply(Opt &O) const { O.setLocation(O, Loc); } +}; + +template +LocationClass location(Ty &L) { return LocationClass(L); } + + //===----------------------------------------------------------------------===// -// Boolean/flag command line option +// Enum valued command line option // -class Flag : public Option { - bool &Value; - bool DValue; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); +#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, ENUMVAL, DESC +#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, ENUMVAL, DESC + +// values - For custom data types, allow specifying a group of values together +// as the values that go into the mapping that the option handler uses. Note +// that the values list must always have a 0 at the end of the list to indicate +// that the list has ended. +// +template +class ValuesClass { + // Use a vector instead of a map, because the lists should be short, + // the overhead is less, and most importantly, it keeps them in the order + // inserted so we can print our option out nicely. + std::vector > > Values; + void processValues(va_list Vals); public: - inline Flag(const char *ArgStr, const char *Message, int Flags = 0, - bool DefaultVal = false) - : Option(ArgStr, Message, Flags), Value(DValue) { - Value = DefaultVal; + ValuesClass(const char *EnumName, DataType Val, const char *Desc, + va_list ValueArgs) { + // Insert the first value, which is required. + Values.push_back(std::make_pair(EnumName, std::make_pair(Val, Desc))); + + // Process the varargs portion of the values... + while (const char *EnumName = va_arg(ValueArgs, const char *)) { + DataType EnumVal = va_arg(ValueArgs, DataType); + const char *EnumDesc = va_arg(ValueArgs, const char *); + Values.push_back(std::make_pair(EnumName, // Add value to value map + std::make_pair(EnumVal, EnumDesc))); + } } - inline Flag(bool &UpdateVal, const char *ArgStr, const char *Message, - int Flags = 0, bool DefaultVal = false) - : Option(ArgStr, Message, Flags), Value(UpdateVal) { - Value = DefaultVal; + template + void apply(Opt &O) const { + for (unsigned i = 0, e = Values.size(); i != e; ++i) + O.getParser().addLiteralOption(Values[i].first, Values[i].second.first, + Values[i].second.second); } - - operator const bool() const { return Value; } - inline bool operator=(bool Val) { Value = Val; return Val; } }; +template +ValuesClass values(const char *Arg, DataType Val, const char *Desc, + ...) { + va_list ValueArgs; + va_start(ValueArgs, Desc); + ValuesClass Vals(Arg, Val, Desc, ValueArgs); + va_end(ValueArgs); + return Vals; +} //===----------------------------------------------------------------------===// -// Integer valued command line option +// parser class - Parameterizable parser for different data types. By default, +// known data types (string, int, bool) have specialized parsers, that do what +// you would expect. The default parser, used for data types that are not +// built-in, uses a mapping table to map specific options to values, which is +// used, among other things, to handle enum types. + +//-------------------------------------------------- +// generic_parser_base - This class holds all the non-generic code that we do +// not need replicated for every instance of the generic parser. This also +// allows us to put stuff into CommandLine.cpp // -class Int : public Option { - int Value; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueRequired; +struct generic_parser_base { + virtual ~generic_parser_base() {} // Base class should have virtual-dtor + + // getNumOptions - Virtual function implemented by generic subclass to + // indicate how many entries are in Values. + // + virtual unsigned getNumOptions() const = 0; + + // getOption - Return option name N. + virtual const char *getOption(unsigned N) const = 0; + + // getDescription - Return description N + virtual const char *getDescription(unsigned N) const = 0; + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; + + void initialize(Option &O) { + // All of the modifiers for the option have been processed by now, so the + // argstr field should be stable, copy it down now. + // + hasArgStr = O.hasArgStr(); + + // If there has been no argstr specified, that means that we need to add an + // argument for every possible option. This ensures that our options are + // vectored to us. + // + if (!hasArgStr) + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) + O.addArgument(getOption(i)); } -public: - inline Int(const char *ArgStr, const char *Help, int Flags = 0, - int DefaultVal = 0) : Option(ArgStr, Help, Flags), - Value(DefaultVal) {} - inline operator int() const { return Value; } - inline int operator=(int Val) { Value = Val; return Val; } -}; + enum ValueExpected getValueExpectedFlagDefault() const { + // If there is an ArgStr specified, then we are of the form: + // + // -opt=O2 or -opt O2 or -optO2 + // + // In which case, the value is required. Otherwise if an arg str has not + // been specified, we are of the form: + // + // -O2 or O2 or -la (where -l and -a are seperate options) + // + // If this is the case, we cannot allow a value. + // + if (hasArgStr) + return ValueRequired; + else + return ValueDisallowed; + } -//===----------------------------------------------------------------------===// -// String valued command line option +protected: + bool hasArgStr; +}; + +// Default parser implementation - This implementation depends on having a +// mapping of recognized options to values of some sort. In addition to this, +// each entry in the mapping also tracks a help message that is printed with the +// command line option for --help. Because this is a simple mapping parser, the +// data type can be any unsupported type. // -class String : public Option, public std::string { - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueRequired; +template +class parser : public generic_parser_base { + std::vector > > Values; + + // Implement virtual functions needed by generic_parser_base + unsigned getNumOptions() const { return Values.size(); } + const char *getOption(unsigned N) const { return Values[N].first; } + const char *getDescription(unsigned N) const { + return Values[N].second.second; } + public: - inline String(const char *ArgStr, const char *Help, int Flags = 0, - const char *DefaultVal = "") - : Option(ArgStr, Help, Flags), std::string(DefaultVal) {} + // Default implementation, requires user to populate it with values somehow. + template // parse - Return true on error. + bool parse(Opt &O, const char *ArgName, const string &Arg) { + string ArgVal; + if (hasArgStr) + ArgVal = Arg; + else + ArgVal = ArgName; + + for (unsigned i = 0, e = Values.size(); i != e; ++i) + if (ArgVal == Values[i].first) { + O.addValue(Values[i].second.first); + return false; + } + + return O.error(": Cannot find option named '" + ArgVal + "'!"); + } - inline const std::string &operator=(const std::string &Val) { - return std::string::operator=(Val); + // addLiteralOption - Add an entry to the mapping table... + template + void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) { + Values.push_back(std::make_pair(Name, std::make_pair((DataType)V,HelpStr))); } }; -//===----------------------------------------------------------------------===// -// String list command line option +//-------------------------------------------------- +// parser // -class StringList : public Option, public std::vector { - - virtual enum NumOccurances getNumOccurancesFlagDefault() const { - return ZeroOrMore; +template<> +class parser { + static bool parseImpl(Option &O, const string &Arg, bool &Val); +public: + + template // parse - Return true on error. + bool parse(Opt &O, const char *ArgName, const string &Arg) { + bool Val; + bool Error = parseImpl(O, Arg, Val); + if (!Error) O.addValue(Val); + return Error; } - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueRequired; + + enum ValueExpected getValueExpectedFlagDefault() const { + return ValueOptional; } - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); -public: - inline StringList(const char *ArgStr, const char *Help, int Flags = 0) - : Option(ArgStr, Help, Flags) {} + void initialize(Option &O) {} + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; }; -//===----------------------------------------------------------------------===// -// Enum valued command line option +//-------------------------------------------------- +// parser // -#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, ENUMVAL, DESC -#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, ENUMVAL, DESC +template<> +class parser { + static bool parseImpl(Option &O, const string &Arg, int &Val); +public: + + // parse - Return true on error. + template + bool parse(Opt &O, const char *ArgName, const string &Arg) { + int Val; + bool Error = parseImpl(O, Arg, Val); + if (!Error) O.addValue(Val); + return Error; + } -// EnumBase - Base class for all enum/varargs related argument types... -class EnumBase : public Option { -protected: - // Use a vector instead of a map, because the lists should be short, - // the overhead is less, and most importantly, it keeps them in the order - // inserted so we can print our option out nicely. - std::vector > > ValueMap; + enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } + + void initialize(Option &O) {} - inline EnumBase(const char *ArgStr, const char *Help, int Flags) - : Option(ArgStr, Help, Flags) {} - inline EnumBase(int Flags) : Option(Flags) {} + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; - // processValues - Incorporate the specifed varargs arglist into the - // ValueMap. + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. // - void processValues(va_list Vals); + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; +}; - // registerArgs - notify the system about these new arguments - void registerArgs(); +//-------------------------------------------------- +// parser +// +template<> +class parser { + static bool parseImpl(Option &O, const string &Arg, double &Val); public: - // Turn an enum into the arg name that activates it - const char *getArgName(int ID) const; - const char *getArgDescription(int ID) const; -}; + + // parse - Return true on error. + template + bool parse(Opt &O, const char *ArgName, const string &Arg) { + double Val; + bool Error = parseImpl(O, Arg, Val); + if (!Error) O.addValue(Val); + return Error; + } -class EnumValueBase : public EnumBase { -protected: - inline EnumValueBase(const char *ArgStr, const char *Help, int Flags) - : EnumBase(ArgStr, Help, Flags) {} - inline EnumValueBase(int Flags) : EnumBase(Flags) {} + enum ValueExpected getValueExpectedFlagDefault() const { + return ValueRequired; + } - // handleOccurance - Set Value to the enum value specified by Arg - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); + void initialize(Option &O) {} // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + virtual unsigned getOptionWidth(const Option &O) const; // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // - virtual void printOptionInfo(unsigned GlobalWidth) const; - - // setValue - Subclasses override this when they need to receive a new value - virtual void setValue(int Val) = 0; + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; }; -template // The enum we are representing -class Enum : public EnumValueBase { - virtual enum ValueExpected getValueExpectedFlagDefault() const { +// Parser is the same as parser +template<> struct parser : public parser {}; + + + +//-------------------------------------------------- +// parser +// +template<> +struct parser { + // parse - Return true on error. + template + bool parse(Opt &O, const char *ArgName, const string &Arg) { + O.addValue(Arg); + return false; + } + enum ValueExpected getValueExpectedFlagDefault() const { return ValueRequired; } - E DVal; - E &Value; - // setValue - Subclasses override this when they need to receive a new value - virtual void setValue(int Val) { Value = (E)Val; } + void initialize(Option &O) {} + + // Return the width of the option tag for printing... + virtual unsigned getOptionWidth(const Option &O) const; + + // printOptionInfo - Print out information about this option. The + // to-be-maintained width is specified. + // + virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; +}; + + + +//===----------------------------------------------------------------------===// +// applicator class - This class is used because we must use partial +// specialization to handle literal string arguments specially (const char* does +// not correctly respond to the apply method). Because the syntax to use this +// is a pain, we have the 'apply' method below to handle the nastiness... +// +template struct applicator { + template + static void opt(const Mod &M, Opt &O) { M.apply(O); } +}; + +// Handle const char* as a special case... +template struct applicator { + template + static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +}; +template<> struct applicator { + template + static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +}; + +template<> struct applicator { + static void opt(NumOccurances NO, Option &O) { O.setNumOccurancesFlag(NO); } +}; +template<> struct applicator { + static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); } +}; +template<> struct applicator { + static void opt(OptionHidden OH, Option &O) { O.setHiddenFlag(OH); } +}; +template<> struct applicator { + static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); } +}; + +// apply method - Apply a modifier to an option in a type safe way. +template +void apply(const Mod &M, Opt *O) { + applicator::opt(M, *O); +} + + +//===----------------------------------------------------------------------===// +// opt_storage class + +// Default storage class definition: external storage. This implementation +// assumes the user will specify a variable to store the data into with the +// cl::location(x) modifier. +// +template +class opt_storage { + DataType *Location; // Where to store the object... + + void check() { + assert(Location != 0 && "cl::location(...) not specified for a command " + "line option with external storage!"); + } public: - inline Enum(const char *ArgStr, int Flags, const char *Help, ...) - : EnumValueBase(ArgStr, Help, Flags), Value(DVal) { - va_list Values; - va_start(Values, Help); - processValues(Values); - va_end(Values); - Value = (E)ValueMap.front().second.first; // Grab default value + opt_storage() : Location(0) {} + + bool setLocation(Option &O, DataType &L) { + if (Location) + return O.error(": cl::location(x) specified more than once!"); + Location = &L; + return false; } - inline Enum(E &EUpdate, const char *ArgStr, int Flags, const char *Help, ...) - : EnumValueBase(ArgStr, Help, Flags), Value(EUpdate) { - va_list Values; - va_start(Values, Help); - processValues(Values); - va_end(Values); - Value = (E)ValueMap.front().second.first; // Grab default value + template + void setValue(const T &V) { + check(); + *Location = V; } - inline operator E() const { return Value; } - inline E operator=(E Val) { Value = Val; return Val; } + DataType &getValue() { check(); return *Location; } + const DataType &getValue() const { check(); return *Location; } +}; + + +// Define how to hold a class type object, such as a string. Since we can +// inherit from a class, we do so. This makes us exactly compatible with the +// object in all cases that it is used. +// +template +struct opt_storage : public DataType { + + template + void setValue(const T &V) { DataType::operator=(V); } + + DataType &getValue() { return *this; } + const DataType &getValue() const { return *this; } +}; + +// Define a partial specialization to handle things we cannot inherit from. In +// this case, we store an instance through containment, and overload operators +// to get at the value. +// +template +struct opt_storage { + DataType Value; + + // Make sure we initialize the value with the default constructor for the + // type. + opt_storage() : Value(DataType()) {} + + template + void setValue(const T &V) { Value = V; } + DataType &getValue() { return Value; } + DataType getValue() const { return Value; } }; //===----------------------------------------------------------------------===// -// Enum flags command line option +// opt - A scalar command line option. // -class EnumFlagsBase : public EnumValueBase { +template > +class opt : public Option, + public opt_storage::value>{ + ParserClass Parser; + + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + return Parser.parse(*this, ArgName, Arg); + } + virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueDisallowed; + return Parser.getValueExpectedFlagDefault(); } -protected: - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); - inline EnumFlagsBase(int Flags) : EnumValueBase(Flags) {} - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + // Forward printing stuff to the parser... + virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(unsigned GlobalWidth) const { + Parser.printOptionInfo(*this, GlobalWidth); + } - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; + void done() { + addArgument(ArgStr); + Parser.initialize(*this); + } +public: + // setInitialValue - Used by the cl::init modifier... + void setInitialValue(const DataType &V) { setValue(V); } + + // addValue - Used by the parser to add a value to the option + template + void addValue(const T &V) { setValue(V); } + ParserClass &getParser() { return Parser; } + + operator DataType() const { return getValue(); } + + template + DataType &operator=(const T &Val) { setValue(Val); return getValue(); } + + // One option... + template + opt(const M0t &M0) { + apply(M0, this); + done(); + } + + // Two options... + template + opt(const M0t &M0, const M1t &M1) { + apply(M0, this); apply(M1, this); + done(); + } + + // Three options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2) { + apply(M0, this); apply(M1, this); apply(M2, this); + done(); + } + // Four options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + done(); + } + // Five options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); + done(); + } + // Six options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); + done(); + } + // Seven options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); + done(); + } + // Eight options... + template + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); + done(); + } }; -template // The enum we are representing -class EnumFlags : public EnumFlagsBase { - E DVal; - E &Value; +//===----------------------------------------------------------------------===// +// list_storage class + +// Default storage class definition: external storage. This implementation +// assumes the user will specify a variable to store the data into with the +// cl::location(x) modifier. +// +template +class list_storage { + StorageClass *Location; // Where to store the object... - // setValue - Subclasses override this when they need to receive a new value - virtual void setValue(int Val) { Value = (E)Val; } public: - inline EnumFlags(int Flags, ...) : EnumFlagsBase(Flags), Value(DVal) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - Value = (E)ValueMap.front().second.first; // Grab default value + list_storage() : Location(0) {} + + bool setLocation(Option &O, StorageClass &L) { + if (Location) + return O.error(": cl::location(x) specified more than once!"); + Location = &L; + return false; } - inline EnumFlags(E &RV, int Flags, ...) : EnumFlagsBase(Flags), Value(RV) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - Value = (E)ValueMap.front().second.first; // Grab default value + + template + void addValue(const T &V) { + assert(Location != 0 && "cl::location(...) not specified for a command " + "line option with external storage!"); + Location->push_back(V); } +}; + + +// Define how to hold a class type object, such as a string. Since we can +// inherit from a class, we do so. This makes us exactly compatible with the +// object in all cases that it is used. +// +template +struct list_storage : public std::vector { - inline operator E() const { return (E)Value; } - inline E operator=(E Val) { Value = Val; return Val; } + template + void addValue(const T &V) { push_back(V); } }; //===----------------------------------------------------------------------===// -// Enum list command line option +// list - A list of command line options. // -class EnumListBase : public EnumBase { +template > +class list : public Option, public list_storage { + ParserClass Parser; + virtual enum NumOccurances getNumOccurancesFlagDefault() const { return ZeroOrMore; } virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueDisallowed; + return Parser.getValueExpectedFlagDefault(); } -protected: - std::vector Values; // The options specified so far. - inline EnumListBase(int Flags) - : EnumBase(Flags) {} - virtual bool handleOccurance(const char *ArgName, const std::string &Arg); + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + return Parser.parse(*this, ArgName, Arg); + } - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const; + // Forward printing stuff to the parser... + virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} + virtual void printOptionInfo(unsigned GlobalWidth) const { + Parser.printOptionInfo(*this, GlobalWidth); + } - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const; + void done() { + addArgument(ArgStr); + Parser.initialize(*this); + } public: - inline unsigned size() { return Values.size(); } + ParserClass &getParser() { return Parser; } + + // One option... + template + list(const M0t &M0) { + apply(M0, this); + done(); + } + // Two options... + template + list(const M0t &M0, const M1t &M1) { + apply(M0, this); apply(M1, this); + done(); + } + // Three options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2) { + apply(M0, this); apply(M1, this); apply(M2, this); + done(); + } + // Four options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + done(); + } + // Five options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); + done(); + } + // Six options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); + done(); + } + // Seven options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); + done(); + } + // Eight options... + template + list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, + const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); + done(); + } }; -template // The enum we are representing -class EnumList : public EnumListBase { + + +//===----------------------------------------------------------------------===// +// Aliased command line option (alias this name to a preexisting name) +// + +class alias : public Option { + Option *AliasFor; + virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + return AliasFor->handleOccurance(AliasFor->ArgStr, Arg); + } + // Aliases default to be hidden... + virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} + + // Handle printing stuff... + virtual unsigned getOptionWidth() const; + virtual void printOptionInfo(unsigned GlobalWidth) const; + + void done() { + if (!hasArgStr()) + error(": cl::alias must have argument name specified!"); + if (AliasFor == 0) + error(": cl::alias must have an cl::aliasopt(option) specified!"); + addArgument(ArgStr); + } public: - inline EnumList(int Flags, ...) : EnumListBase(Flags) { - va_list Values; - va_start(Values, Flags); - processValues(Values); - va_end(Values); - registerArgs(); - } - inline E operator[](unsigned i) const { return (E)Values[i]; } - inline E &operator[](unsigned i) { return (E&)Values[i]; } + void setAliasFor(Option &O) { + if (AliasFor) + error(": cl::alias must only have one cl::aliasopt(...) specified!"); + AliasFor = &O; + } + + // One option... + template + alias(const M0t &M0) : AliasFor(0) { + apply(M0, this); + done(); + } + // Two options... + template + alias(const M0t &M0, const M1t &M1) : AliasFor(0) { + apply(M0, this); apply(M1, this); + done(); + } + // Three options... + template + alias(const M0t &M0, const M1t &M1, const M2t &M2) : AliasFor(0) { + apply(M0, this); apply(M1, this); apply(M2, this); + done(); + } + // Four options... + template + alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) + : AliasFor(0) { + apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + done(); + } +}; + +// aliasfor - Modifier to set the option an alias aliases. +struct aliasopt { + Option &Opt; + aliasopt(Option &O) : Opt(O) {} + void apply(alias &A) const { A.setAliasFor(Opt); } }; } // End namespace cl diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index c3f18bd152..d11fbd7119 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -23,6 +23,10 @@ using std::vector; using std::string; using std::cerr; +//===----------------------------------------------------------------------===// +// Basic, shared command line option processing machinery... +// + // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // @@ -31,6 +35,11 @@ static map &getOpts() { return CommandLineOptions; } +static vector &getPositionalOpts() { + static vector Positional; + return Positional; +} + static void AddArgument(const string &ArgName, Option *Opt) { if (getOpts().find(ArgName) != getOpts().end()) { cerr << "CommandLine Error: Argument '" << ArgName @@ -72,46 +81,153 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->addOccurance(ArgName, Value); } -// ValueGroupedArgs - Return true if the specified string is valid as a group -// of single letter arguments stuck together like the 'ls -la' case. +static bool ProvidePositionalOption(Option *Handler, string &Arg) { + int Dummy; + return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy); +} + + +// Option predicates... +static inline bool isGrouping(const Option *O) { + return O->getFormattingFlag() == cl::Grouping; +} +static inline bool isPrefixedOrGrouping(const Option *O) { + return isGrouping(O) || O->getFormattingFlag() == cl::Prefix; +} + +// getOptionPred - Check to see if there are any options that satisfy the +// specified predicate with names that are the prefixes in Name. This is +// checked by progressively stripping characters off of the name, checking to +// see if there options that satisfy the predicate. If we find one, return it, +// otherwise return null. // -static inline bool ValidGroupedArgs(string Args) { - for (unsigned i = 0; i < Args.size(); ++i) { - map::iterator I = getOpts().find(string(1, Args[i])); - if (I == getOpts().end()) return false; // Make sure option exists +static Option *getOptionPred(std::string Name, unsigned &Length, + bool (*Pred)(const Option*)) { + + map::iterator I = getOpts().find(Name); + if (I != getOpts().end() && Pred(I->second)) { + Length = Name.length(); + return I->second; + } - // Grouped arguments have no value specified, make sure that if this option - // exists that it can accept no argument. - // - switch (I->second->getValueExpectedFlag()) { - case ValueDisallowed: - case ValueOptional: break; - default: return false; - } + if (Name.size() == 1) return 0; + do { + Name.erase(Name.end()-1, Name.end()); // Chop off the last character... + I = getOpts().find(Name); + + // Loop while we haven't found an option and Name still has at least two + // characters in it (so that the next iteration will not be the empty + // string... + } while ((I == getOpts().end() || !Pred(I->second)) && Name.size() > 1); + + if (I != getOpts().end() && Pred(I->second)) { + Length = Name.length(); + return I->second; // Found one! } + return 0; // No option found! +} - return true; +static bool RequiresValue(const Option *O) { + return O->getNumOccurancesFlag() == cl::Required || + O->getNumOccurancesFlag() == cl::OneOrMore; +} + +static bool EatsUnboundedNumberOfValues(const Option *O) { + return O->getNumOccurancesFlag() == cl::ZeroOrMore || + O->getNumOccurancesFlag() == cl::OneOrMore; } void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0, int Flags = 0) { + const char *Overview = 0) { + assert((!getOpts().empty() || !getPositionalOpts().empty()) && + "No options specified, or ParseCommandLineOptions called more" + " than once!"); ProgramName = argv[0]; // Save this away safe and snug ProgramOverview = Overview; bool ErrorParsing = false; + map &Opts = getOpts(); + vector &PositionalOpts = getPositionalOpts(); + + // Check out the positional arguments to collect information about them. + unsigned NumPositionalRequired = 0; + Option *ConsumeAfterOpt = 0; + if (!PositionalOpts.empty()) { + if (PositionalOpts[0]->getNumOccurancesFlag() == cl::ConsumeAfter) { + assert(PositionalOpts.size() > 1 && + "Cannot specify cl::ConsumeAfter without a positional argument!"); + ConsumeAfterOpt = PositionalOpts[0]; + } + + // Calculate how many positional values are _required_. + bool UnboundedFound = false; + for (unsigned i = ConsumeAfterOpt != 0, e = PositionalOpts.size(); + i != e; ++i) { + Option *Opt = PositionalOpts[i]; + if (RequiresValue(Opt)) + ++NumPositionalRequired; + else if (ConsumeAfterOpt) { + // ConsumeAfter cannot be combined with "optional" positional options + ErrorParsing |= + Opt->error(" error - this positional option will never be matched, " + "because it does not Require a value, and a " + "cl::ConsumeAfter option is active!"); + } else if (UnboundedFound) { // This option does not "require" a value... + // Make sure this option is not specified after an option that eats all + // extra arguments, or this one will never get any! + // + ErrorParsing |= Opt->error(" error - option can never match, because " + "another positional argument will match an " + "unbounded number of values, and this option" + " does not require a value!"); + } + UnboundedFound |= EatsUnboundedNumberOfValues(Opt); + } + } + + // PositionalVals - A vector of "positional" arguments we accumulate into to + // processes at the end... + // + vector PositionalVals; + // Loop over all of the arguments... processing them. + bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { Option *Handler = 0; const char *Value = ""; const char *ArgName = ""; - if (argv[i][0] != '-') { // Unnamed argument? - map::iterator I = getOpts().find(""); - Handler = I != getOpts().end() ? I->second : 0; - Value = argv[i]; - } else { // We start with a - or --, eat dashes + + // Check to see if this is a positional argument. This argument is + // considered to be positional if it doesn't start with '-', if it is "-" + // itself, or if we have see "--" already. + // + if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) { + // Positional argument! + if (!PositionalOpts.empty()) { + PositionalVals.push_back(argv[i]); + + // All of the positional arguments have been fulfulled, give the rest to + // the consume after option... if it's specified... + // + if (PositionalVals.size() == NumPositionalRequired && + ConsumeAfterOpt != 0) { + for (++i; i < argc; ++i) + PositionalVals.push_back(argv[i]); + break; // Handle outside of the argument processing loop... + } + + // Delay processing positional arguments until the end... + continue; + } + } else { // We start with a '-', must be an argument... ArgName = argv[i]+1; while (*ArgName == '-') ++ArgName; // Eat leading dashes + if (*ArgName == 0 && !DashDashFound) { // Is this the mythical "--"? + DashDashFound = true; // Yup, take note of that fact... + continue; // Don't try to process it as an argument iself. + } + const char *ArgNameEnd = ArgName; while (*ArgNameEnd && *ArgNameEnd != '=') ++ArgNameEnd; // Scan till end of argument name... @@ -123,46 +239,58 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (*ArgName != 0) { string RealName(ArgName, ArgNameEnd); // Extract arg name part - map::iterator I = getOpts().find(RealName); - - if (I == getOpts().end() && !*Value && RealName.size() > 1) { - // If grouping of single letter arguments is enabled, see if this is a - // legal grouping... - // - if (!(Flags & DisableSingleLetterArgGrouping) && - ValidGroupedArgs(RealName)) { - - for (unsigned i = 0; i < RealName.size(); ++i) { - char ArgName[2] = { 0, 0 }; int Dummy; - ArgName[0] = RealName[i]; - I = getOpts().find(ArgName); - assert(I != getOpts().end() && "ValidGroupedArgs failed!"); + map::iterator I = Opts.find(RealName); + + if (I == Opts.end() && !*Value && RealName.size() > 1) { + // Check to see if this "option" is really a prefixed or grouped + // argument... + // + unsigned Length = 0; + Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping); + + // If the option is a prefixed option, then the value is simply the + // rest of the name... so fall through to later processing, by + // setting up the argument name flags and value fields. + // + if (PGOpt && PGOpt->getFormattingFlag() == cl::Prefix) { + ArgNameEnd = ArgName+Length; + Value = ArgNameEnd; + I = Opts.find(string(ArgName, ArgNameEnd)); + assert(I->second == PGOpt); + } else if (PGOpt) { + // This must be a grouped option... handle all of them now... + assert(isGrouping(PGOpt) && "Broken getOptionPred!"); + + do { + // Move current arg name out of RealName into RealArgName... + string RealArgName(RealName.begin(), RealName.begin()+Length); + RealName.erase(RealName.begin(), RealName.begin()+Length); // Because ValueRequired is an invalid flag for grouped arguments, // we don't need to pass argc/argv in... // - ErrorParsing |= ProvideOption(I->second, ArgName, "", - 0, 0, Dummy); - } - continue; - } else if (Flags & EnableSingleLetterArgValue) { - // Check to see if the first letter is a single letter argument that - // have a value that is equal to the rest of the string. If this - // is the case, recognize it now. (Example: -lfoo for a linker) - // - I = getOpts().find(string(1, RealName[0])); - if (I != getOpts().end()) { - // If we are successful, fall through to later processing, by - // setting up the argument name flags and value fields. - // - ArgNameEnd = ArgName+1; - Value = ArgNameEnd; - } - } + assert(PGOpt->getValueExpectedFlag() != cl::ValueRequired && + "Option can not be cl::Grouping AND cl::ValueRequired!"); + int Dummy; + ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", + 0, 0, Dummy); + + // Get the next grouping option... + if (!RealName.empty()) + PGOpt = getOptionPred(RealName, Length, isGrouping); + } while (!RealName.empty() && PGOpt); + + if (RealName.empty()) // Processed all of the options, move on + continue; // to the next argv[] value... + + // If RealName is not empty, that means we did not match one of the + // options! This is an error. + // + I = Opts.end(); + } } - - Handler = I != getOpts().end() ? I->second : 0; + Handler = I != Opts.end() ? I->second : 0; } } @@ -174,17 +302,63 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); + } - // If this option should consume all arguments that come after it... - if (Handler->getNumOccurancesFlag() == ConsumeAfter) { - for (++i; i < argc; ++i) - ErrorParsing |= ProvideOption(Handler, ArgName, argv[i], argc, argv, i); + // Check and handle positional arguments now... + if (NumPositionalRequired > PositionalVals.size()) { + cerr << "Not enough positional command line arguments specified!\n"; + cerr << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; + ErrorParsing = true; + + + } else if (ConsumeAfterOpt == 0) { + // Positional args have already been handled if ConsumeAfter is specified... + unsigned ValNo = 0, NumVals = PositionalVals.size(); + for (unsigned i = 0, e = PositionalOpts.size(); i != e; ++i) { + if (RequiresValue(PositionalOpts[i])) { + ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); + --NumPositionalRequired; // We fulfilled our duty... + } + + // If we _can_ give this option more arguments, do so now, as long as we + // do not give it values that others need. 'Done' controls whether the + // option even _WANTS_ any more. + // + bool Done = PositionalOpts[i]->getNumOccurancesFlag() == cl::Required; + while (NumVals-ValNo > NumPositionalRequired && !Done) { + switch (PositionalOpts[i]->getNumOccurancesFlag()) { + case cl::Optional: + Done = true; // Optional arguments want _at most_ one value + // FALL THROUGH + case cl::ZeroOrMore: // Zero or more will take all they can get... + case cl::OneOrMore: // One or more will take all they can get... + ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); + break; + default: + assert(0 && "Internal error, unexpected NumOccurances flag in " + "positional argument processing!"); + } + } } + } else { + assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.size()); + unsigned ValNo = 0; + for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j) + if (RequiresValue(PositionalOpts[j])) + ErrorParsing |= + ProvidePositionalOption(PositionalOpts[j], PositionalVals[ValNo++]); + + // Handle over all of the rest of the arguments to the + // cl::ConsumeAfter command line option... + for (; ValNo != PositionalVals.size(); ++ValNo) + ErrorParsing |= ProvidePositionalOption(ConsumeAfterOpt, + PositionalVals[ValNo]); } // Loop over args and make sure all required args are specified! - for (map::iterator I = getOpts().begin(), - E = getOpts().end(); I != E; ++I) { + for (map::iterator I = Opts.begin(), + E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurancesFlag()) { case Required: case OneOrMore: @@ -198,9 +372,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } } - // Free all of the memory allocated to the vector. Command line options may - // only be processed once! - getOpts().clear(); + // Free all of the memory allocated to the map. Command line options may only + // be processed once! + Opts.clear(); + PositionalOpts.clear(); // If we had an error processing our arguments, don't let the program execute if (ErrorParsing) exit(1); @@ -209,14 +384,14 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, //===----------------------------------------------------------------------===// // Option Base class implementation // -Option::Option(const char *argStr, const char *helpStr, int flags) - : NumOccurances(0), Flags(flags), ArgStr(argStr), HelpStr(helpStr) { - AddArgument(ArgStr, this); -} bool Option::error(string Message, const char *ArgName = 0) { if (ArgName == 0) ArgName = ArgStr; - cerr << "-" << ArgName << " option" << Message << "\n"; + if (ArgName[0] == 0) + cerr << HelpStr; // Be nice for positional arguments + else + cerr << "-" << ArgName; + cerr << " option" << Message << "\n"; return true; } @@ -241,275 +416,303 @@ bool Option::addOccurance(const char *ArgName, const string &Value) { return handleOccurance(ArgName, Value); } +// addArgument - Tell the system that this Option subclass will handle all +// occurances of -ArgStr on the command line. +// +void Option::addArgument(const char *ArgStr) { + if (ArgStr[0]) + AddArgument(ArgStr, this); + else if (getFormattingFlag() == Positional) + getPositionalOpts().push_back(this); + else if (getNumOccurancesFlag() == ConsumeAfter) { + assert((getPositionalOpts().empty() || + getPositionalOpts().front()->getNumOccurancesFlag() != ConsumeAfter) + && "Cannot specify more than one option with cl::ConsumeAfter " + "specified!"); + getPositionalOpts().insert(getPositionalOpts().begin(), this); + } +} + + +// getValueStr - Get the value description string, using "DefaultMsg" if nothing +// has been specified yet. +// +static const char *getValueStr(const Option &O, const char *DefaultMsg) { + if (O.ValueStr[0] == 0) return DefaultMsg; + return O.ValueStr; +} + +//===----------------------------------------------------------------------===// +// cl::alias class implementation +// + // Return the width of the option tag for printing... -unsigned Option::getOptionWidth() const { +unsigned alias::getOptionWidth() const { return std::strlen(ArgStr)+6; } -void Option::printOptionInfo(unsigned GlobalWidth) const { +// Print out the option for the alias... +void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - if (L == 0) return; // Don't print the empty arg like this! cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " << HelpStr << "\n"; } + //===----------------------------------------------------------------------===// -// Boolean/flag command line option implementation +// Parser Implementation code... // -bool Flag::handleOccurance(const char *ArgName, const string &Arg) { +// parser implementation +// +bool parser::parseImpl(Option &O, const string &Arg, bool &Value) { if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") { Value = false; } else { - return error(": '" + Arg + - "' is invalid value for boolean argument! Try 0 or 1"); + return O.error(": '" + Arg + + "' is invalid value for boolean argument! Try 0 or 1"); } - return false; } -//===----------------------------------------------------------------------===// -// Integer valued command line option implementation -// -bool Int::handleOccurance(const char *ArgName, const string &Arg) { - const char *ArgStart = Arg.c_str(); - char *End; - Value = (int)strtol(ArgStart, &End, 0); - if (*End != 0) - return error(": '" + Arg + "' value invalid for integer argument!"); - return false; +// Return the width of the option tag for printing... +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+6; } -//===----------------------------------------------------------------------===// -// String valued command line option implementation +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. // -bool String::handleOccurance(const char *ArgName, const string &Arg) { - *this = Arg; - return false; +void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ + unsigned L = std::strlen(O.ArgStr); + cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') << " - " + << O.HelpStr << "\n"; } -//===----------------------------------------------------------------------===// -// StringList valued command line option implementation -// -bool StringList::handleOccurance(const char *ArgName, const string &Arg) { - push_back(Arg); - return false; -} -//===----------------------------------------------------------------------===// -// Enum valued command line option implementation + +// parser implementation // -void EnumBase::processValues(va_list Vals) { - while (const char *EnumName = va_arg(Vals, const char *)) { - int EnumVal = va_arg(Vals, int); - const char *EnumDesc = va_arg(Vals, const char *); - ValueMap.push_back(std::make_pair(EnumName, // Add value to value map - std::make_pair(EnumVal, EnumDesc))); - } +bool parser::parseImpl(Option &O, const string &Arg, int &Value) { + const char *ArgStart = Arg.c_str(); + char *End; + Value = (int)strtol(ArgStart, &End, 0); + if (*End != 0) + return O.error(": '" + Arg + "' value invalid for integer argument!"); + return false; } -// registerArgs - notify the system about these new arguments -void EnumBase::registerArgs() { - for (unsigned i = 0; i < ValueMap.size(); ++i) - AddArgument(ValueMap[i].first, this); +// Return the width of the option tag for printing... +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "int"))+9; } -const char *EnumBase::getArgName(int ID) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) - if (ID == ValueMap[i].second.first) return ValueMap[i].first; - return ""; -} -const char *EnumBase::getArgDescription(int ID) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) - if (ID == ValueMap[i].second.first) return ValueMap[i].second.second; - return ""; +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ + cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "int") << ">" + << string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; } - -bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { - unsigned i; - for (i = 0; i < ValueMap.size(); ++i) - if (ValueMap[i].first == Arg) break; - - if (i == ValueMap.size()) { - string Alternatives; - for (i = 0; i < ValueMap.size(); ++i) { - if (i) Alternatives += ", "; - Alternatives += ValueMap[i].first; - } - - return error(": unrecognized alternative '" + Arg + - "'! Alternatives are: " + Alternatives); - } - setValue(ValueMap[i].second.first); +// parser implementation +// +bool parser::parseImpl(Option &O, const string &Arg, double &Value) { + const char *ArgStart = Arg.c_str(); + char *End; + Value = strtod(ArgStart, &End); + if (*End != 0) + return O.error(": '" +Arg+ "' value invalid for floating point argument!"); return false; } // Return the width of the option tag for printing... -unsigned EnumValueBase::getOptionWidth() const { - unsigned BaseSize = Option::getOptionWidth(); - for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+8); - return BaseSize; +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "number"))+9; } // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // -void EnumValueBase::printOptionInfo(unsigned GlobalWidth) const { - Option::printOptionInfo(GlobalWidth); - for (unsigned i = 0; i < ValueMap.size(); ++i) { - unsigned NumSpaces = GlobalWidth-strlen(ValueMap[i].first)-8; - cerr << " =" << ValueMap[i].first << string(NumSpaces, ' ') << " - " - << ValueMap[i].second.second; - - if (i == 0) cerr << " (default)"; - cerr << "\n"; - } +void parser::printOptionInfo(const Option &O, + unsigned GlobalWidth) const{ + cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "number") << ">" + << string(GlobalWidth-getOptionWidth(O), ' ') + << " - " << O.HelpStr << "\n"; } -//===----------------------------------------------------------------------===// -// Enum flags command line option implementation -// -bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) { - return EnumValueBase::handleOccurance("", ArgName); -} +// parser implementation +// -unsigned EnumFlagsBase::getOptionWidth() const { - unsigned BaseSize = 0; - for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); - return BaseSize; +// Return the width of the option tag for printing... +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "string"))+9; } -void EnumFlagsBase::printOptionInfo(unsigned GlobalWidth) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) { - unsigned L = std::strlen(ValueMap[i].first); - cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " - << ValueMap[i].second.second; - if (i == 0) cerr << " (default)"; - cerr << "\n"; - } +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void parser::printOptionInfo(const Option &O, + unsigned GlobalWidth) const{ + cerr << " -" << O.ArgStr << " <" << getValueStr(O, "string") << ">" + << string(GlobalWidth-getOptionWidth(O), ' ') + << " - " << O.HelpStr << "\n"; } - -//===----------------------------------------------------------------------===// -// Enum list command line option implementation +// generic_parser_base implementation // -bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) { - unsigned i; - for (i = 0; i < ValueMap.size(); ++i) - if (ValueMap[i].first == string(ArgName)) break; - if (i == ValueMap.size()) - return error(": CommandLine INTERNAL ERROR", ArgName); - Values.push_back(ValueMap[i].second.first); - return false; -} - // Return the width of the option tag for printing... -unsigned EnumListBase::getOptionWidth() const { - unsigned BaseSize = 0; - for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); - return BaseSize; +unsigned generic_parser_base::getOptionWidth(const Option &O) const { + if (O.hasArgStr()) { + unsigned Size = std::strlen(O.ArgStr)+6; + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) + Size = std::max(Size, (unsigned)std::strlen(getOption(i))+8); + return Size; + } else { + unsigned BaseSize = 0; + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) + BaseSize = std::max(BaseSize, (unsigned)std::strlen(getOption(i))+8); + return BaseSize; + } } - // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // -void EnumListBase::printOptionInfo(unsigned GlobalWidth) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) { - unsigned L = std::strlen(ValueMap[i].first); - cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " - << ValueMap[i].second.second << "\n"; +void generic_parser_base::printOptionInfo(const Option &O, + unsigned GlobalWidth) const { + if (O.hasArgStr()) { + unsigned L = std::strlen(O.ArgStr); + cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') + << " - " << O.HelpStr << "\n"; + + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { + unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; + cerr << " =" << getOption(i) << string(NumSpaces, ' ') << " - " + << getDescription(i) << "\n"; + } + } else { + if (O.HelpStr[0]) + cerr << " " << O.HelpStr << "\n"; + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { + unsigned L = std::strlen(getOption(i)); + cerr << " -" << getOption(i) << string(GlobalWidth-L-8, ' ') << " - " + << getDescription(i) << "\n"; + } } } //===----------------------------------------------------------------------===// -// Help option... always automatically provided. +// --help and --help-hidden option implementation // namespace { -// isHidden/isReallyHidden - Predicates to be used to filter down arg lists. -inline bool isHidden(pair &OptPair) { - return OptPair.second->getOptionHiddenFlag() >= Hidden; -} -inline bool isReallyHidden(pair &OptPair) { - return OptPair.second->getOptionHiddenFlag() == ReallyHidden; -} - -class Help : public Option { +class HelpPrinter { unsigned MaxArgLen; const Option *EmptyArg; const bool ShowHidden; - virtual bool handleOccurance(const char *ArgName, const string &Arg) { + // isHidden/isReallyHidden - Predicates to be used to filter down arg lists. + inline static bool isHidden(pair &OptPair) { + return OptPair.second->getOptionHiddenFlag() >= Hidden; + } + inline static bool isReallyHidden(pair &OptPair) { + return OptPair.second->getOptionHiddenFlag() == ReallyHidden; + } + +public: + HelpPrinter(bool showHidden) : ShowHidden(showHidden) { + EmptyArg = 0; + } + + void operator=(bool Value) { + if (Value == false) return; + // Copy Options into a vector so we can sort them as we like... vector > Options; copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden - Options.erase(remove_if(Options.begin(), Options.end(), - std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), + Options.erase(std::remove_if(Options.begin(), Options.end(), + std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), Options.end()); // Eliminate duplicate entries in table (from enum flags options, f.e.) - std::set OptionSet; - for (unsigned i = 0; i < Options.size(); ) - if (OptionSet.count(Options[i].second) == 0) - OptionSet.insert(Options[i++].second); // Add to set - else - Options.erase(Options.begin()+i); // Erase duplicate - + { // Give OptionSet a scope + std::set OptionSet; + for (unsigned i = 0; i != Options.size(); ++i) + if (OptionSet.count(Options[i].second) == 0) + OptionSet.insert(Options[i].second); // Add new entry to set + else + Options.erase(Options.begin()+i--); // Erase duplicate + } if (ProgramOverview) cerr << "OVERVIEW:" << ProgramOverview << "\n"; - // TODO: Sort options by some criteria - cerr << "USAGE: " << ProgramName << " [options]\n\n"; - // TODO: print usage nicer + cerr << "USAGE: " << ProgramName << " [options]"; + + // Print out the positional options... + vector &PosOpts = getPositionalOpts(); + Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... + if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) + CAOpt = PosOpts[0]; + + for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { + cerr << " " << PosOpts[i]->HelpStr; + switch (PosOpts[i]->getNumOccurancesFlag()) { + case Optional: cerr << "?"; break; + case ZeroOrMore: cerr << "*"; break; + case Required: break; + case OneOrMore: cerr << "+"; break; + case ConsumeAfter: + default: + assert(0 && "Unknown NumOccurances Flag Value!"); + } + } + + // Print the consume after option info if it exists... + if (CAOpt) cerr << " " << CAOpt->HelpStr; + + cerr << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; - for_each(Options.begin(), Options.end(), - bind_obj(this, &Help::getMaxArgLen)); + for (unsigned i = 0, e = Options.size(); i != e; ++i) + MaxArgLen = std::max(MaxArgLen, Options[i].second->getOptionWidth()); cerr << "OPTIONS:\n"; - for_each(Options.begin(), Options.end(), - bind_obj(this, &Help::printOption)); + for (unsigned i = 0, e = Options.size(); i != e; ++i) + Options[i].second->printOptionInfo(MaxArgLen); - return true; // Displaying help is cause to terminate the program + // Halt the program if help information is printed + exit(1); } +}; - void getMaxArgLen(pair OptPair) { - const Option *Opt = OptPair.second; - if (Opt->ArgStr[0] == 0) EmptyArg = Opt; // Capture the empty arg if exists - MaxArgLen = std::max(MaxArgLen, Opt->getOptionWidth()); - } - void printOption(pair OptPair) { - const Option *Opt = OptPair.second; - Opt->printOptionInfo(MaxArgLen); - } -public: - inline Help(const char *ArgVal, const char *HelpVal, bool showHidden) - : Option(ArgVal, HelpVal, showHidden ? Hidden : 0), ShowHidden(showHidden) { - EmptyArg = 0; - } -}; +// Define the two HelpPrinter instances that are used to print out help, or +// help-hidden... +// +HelpPrinter NormalPrinter(false); +HelpPrinter HiddenPrinter(true); + +cl::opt > +HOp("help", cl::desc("display available options (--help-hidden for more)"), + cl::location(NormalPrinter)); -Help HelpOp("help", "display available options" - " (--help-hidden for more)", false); -Help HelpHiddenOpt("help-hidden", "display all available options", true); +cl::opt > +HHOp("help-hidden", cl::desc("display all available options"), + cl::location(HiddenPrinter), cl::Hidden); } // End anonymous namespace diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index c3f18bd152..d11fbd7119 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -23,6 +23,10 @@ using std::vector; using std::string; using std::cerr; +//===----------------------------------------------------------------------===// +// Basic, shared command line option processing machinery... +// + // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // @@ -31,6 +35,11 @@ static map &getOpts() { return CommandLineOptions; } +static vector &getPositionalOpts() { + static vector Positional; + return Positional; +} + static void AddArgument(const string &ArgName, Option *Opt) { if (getOpts().find(ArgName) != getOpts().end()) { cerr << "CommandLine Error: Argument '" << ArgName @@ -72,46 +81,153 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->addOccurance(ArgName, Value); } -// ValueGroupedArgs - Return true if the specified string is valid as a group -// of single letter arguments stuck together like the 'ls -la' case. +static bool ProvidePositionalOption(Option *Handler, string &Arg) { + int Dummy; + return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy); +} + + +// Option predicates... +static inline bool isGrouping(const Option *O) { + return O->getFormattingFlag() == cl::Grouping; +} +static inline bool isPrefixedOrGrouping(const Option *O) { + return isGrouping(O) || O->getFormattingFlag() == cl::Prefix; +} + +// getOptionPred - Check to see if there are any options that satisfy the +// specified predicate with names that are the prefixes in Name. This is +// checked by progressively stripping characters off of the name, checking to +// see if there options that satisfy the predicate. If we find one, return it, +// otherwise return null. // -static inline bool ValidGroupedArgs(string Args) { - for (unsigned i = 0; i < Args.size(); ++i) { - map::iterator I = getOpts().find(string(1, Args[i])); - if (I == getOpts().end()) return false; // Make sure option exists +static Option *getOptionPred(std::string Name, unsigned &Length, + bool (*Pred)(const Option*)) { + + map::iterator I = getOpts().find(Name); + if (I != getOpts().end() && Pred(I->second)) { + Length = Name.length(); + return I->second; + } - // Grouped arguments have no value specified, make sure that if this option - // exists that it can accept no argument. - // - switch (I->second->getValueExpectedFlag()) { - case ValueDisallowed: - case ValueOptional: break; - default: return false; - } + if (Name.size() == 1) return 0; + do { + Name.erase(Name.end()-1, Name.end()); // Chop off the last character... + I = getOpts().find(Name); + + // Loop while we haven't found an option and Name still has at least two + // characters in it (so that the next iteration will not be the empty + // string... + } while ((I == getOpts().end() || !Pred(I->second)) && Name.size() > 1); + + if (I != getOpts().end() && Pred(I->second)) { + Length = Name.length(); + return I->second; // Found one! } + return 0; // No option found! +} - return true; +static bool RequiresValue(const Option *O) { + return O->getNumOccurancesFlag() == cl::Required || + O->getNumOccurancesFlag() == cl::OneOrMore; +} + +static bool EatsUnboundedNumberOfValues(const Option *O) { + return O->getNumOccurancesFlag() == cl::ZeroOrMore || + O->getNumOccurancesFlag() == cl::OneOrMore; } void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0, int Flags = 0) { + const char *Overview = 0) { + assert((!getOpts().empty() || !getPositionalOpts().empty()) && + "No options specified, or ParseCommandLineOptions called more" + " than once!"); ProgramName = argv[0]; // Save this away safe and snug ProgramOverview = Overview; bool ErrorParsing = false; + map &Opts = getOpts(); + vector &PositionalOpts = getPositionalOpts(); + + // Check out the positional arguments to collect information about them. + unsigned NumPositionalRequired = 0; + Option *ConsumeAfterOpt = 0; + if (!PositionalOpts.empty()) { + if (PositionalOpts[0]->getNumOccurancesFlag() == cl::ConsumeAfter) { + assert(PositionalOpts.size() > 1 && + "Cannot specify cl::ConsumeAfter without a positional argument!"); + ConsumeAfterOpt = PositionalOpts[0]; + } + + // Calculate how many positional values are _required_. + bool UnboundedFound = false; + for (unsigned i = ConsumeAfterOpt != 0, e = PositionalOpts.size(); + i != e; ++i) { + Option *Opt = PositionalOpts[i]; + if (RequiresValue(Opt)) + ++NumPositionalRequired; + else if (ConsumeAfterOpt) { + // ConsumeAfter cannot be combined with "optional" positional options + ErrorParsing |= + Opt->error(" error - this positional option will never be matched, " + "because it does not Require a value, and a " + "cl::ConsumeAfter option is active!"); + } else if (UnboundedFound) { // This option does not "require" a value... + // Make sure this option is not specified after an option that eats all + // extra arguments, or this one will never get any! + // + ErrorParsing |= Opt->error(" error - option can never match, because " + "another positional argument will match an " + "unbounded number of values, and this option" + " does not require a value!"); + } + UnboundedFound |= EatsUnboundedNumberOfValues(Opt); + } + } + + // PositionalVals - A vector of "positional" arguments we accumulate into to + // processes at the end... + // + vector PositionalVals; + // Loop over all of the arguments... processing them. + bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { Option *Handler = 0; const char *Value = ""; const char *ArgName = ""; - if (argv[i][0] != '-') { // Unnamed argument? - map::iterator I = getOpts().find(""); - Handler = I != getOpts().end() ? I->second : 0; - Value = argv[i]; - } else { // We start with a - or --, eat dashes + + // Check to see if this is a positional argument. This argument is + // considered to be positional if it doesn't start with '-', if it is "-" + // itself, or if we have see "--" already. + // + if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) { + // Positional argument! + if (!PositionalOpts.empty()) { + PositionalVals.push_back(argv[i]); + + // All of the positional arguments have been fulfulled, give the rest to + // the consume after option... if it's specified... + // + if (PositionalVals.size() == NumPositionalRequired && + ConsumeAfterOpt != 0) { + for (++i; i < argc; ++i) + PositionalVals.push_back(argv[i]); + break; // Handle outside of the argument processing loop... + } + + // Delay processing positional arguments until the end... + continue; + } + } else { // We start with a '-', must be an argument... ArgName = argv[i]+1; while (*ArgName == '-') ++ArgName; // Eat leading dashes + if (*ArgName == 0 && !DashDashFound) { // Is this the mythical "--"? + DashDashFound = true; // Yup, take note of that fact... + continue; // Don't try to process it as an argument iself. + } + const char *ArgNameEnd = ArgName; while (*ArgNameEnd && *ArgNameEnd != '=') ++ArgNameEnd; // Scan till end of argument name... @@ -123,46 +239,58 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (*ArgName != 0) { string RealName(ArgName, ArgNameEnd); // Extract arg name part - map::iterator I = getOpts().find(RealName); - - if (I == getOpts().end() && !*Value && RealName.size() > 1) { - // If grouping of single letter arguments is enabled, see if this is a - // legal grouping... - // - if (!(Flags & DisableSingleLetterArgGrouping) && - ValidGroupedArgs(RealName)) { - - for (unsigned i = 0; i < RealName.size(); ++i) { - char ArgName[2] = { 0, 0 }; int Dummy; - ArgName[0] = RealName[i]; - I = getOpts().find(ArgName); - assert(I != getOpts().end() && "ValidGroupedArgs failed!"); + map::iterator I = Opts.find(RealName); + + if (I == Opts.end() && !*Value && RealName.size() > 1) { + // Check to see if this "option" is really a prefixed or grouped + // argument... + // + unsigned Length = 0; + Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping); + + // If the option is a prefixed option, then the value is simply the + // rest of the name... so fall through to later processing, by + // setting up the argument name flags and value fields. + // + if (PGOpt && PGOpt->getFormattingFlag() == cl::Prefix) { + ArgNameEnd = ArgName+Length; + Value = ArgNameEnd; + I = Opts.find(string(ArgName, ArgNameEnd)); + assert(I->second == PGOpt); + } else if (PGOpt) { + // This must be a grouped option... handle all of them now... + assert(isGrouping(PGOpt) && "Broken getOptionPred!"); + + do { + // Move current arg name out of RealName into RealArgName... + string RealArgName(RealName.begin(), RealName.begin()+Length); + RealName.erase(RealName.begin(), RealName.begin()+Length); // Because ValueRequired is an invalid flag for grouped arguments, // we don't need to pass argc/argv in... // - ErrorParsing |= ProvideOption(I->second, ArgName, "", - 0, 0, Dummy); - } - continue; - } else if (Flags & EnableSingleLetterArgValue) { - // Check to see if the first letter is a single letter argument that - // have a value that is equal to the rest of the string. If this - // is the case, recognize it now. (Example: -lfoo for a linker) - // - I = getOpts().find(string(1, RealName[0])); - if (I != getOpts().end()) { - // If we are successful, fall through to later processing, by - // setting up the argument name flags and value fields. - // - ArgNameEnd = ArgName+1; - Value = ArgNameEnd; - } - } + assert(PGOpt->getValueExpectedFlag() != cl::ValueRequired && + "Option can not be cl::Grouping AND cl::ValueRequired!"); + int Dummy; + ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", + 0, 0, Dummy); + + // Get the next grouping option... + if (!RealName.empty()) + PGOpt = getOptionPred(RealName, Length, isGrouping); + } while (!RealName.empty() && PGOpt); + + if (RealName.empty()) // Processed all of the options, move on + continue; // to the next argv[] value... + + // If RealName is not empty, that means we did not match one of the + // options! This is an error. + // + I = Opts.end(); + } } - - Handler = I != getOpts().end() ? I->second : 0; + Handler = I != Opts.end() ? I->second : 0; } } @@ -174,17 +302,63 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); + } - // If this option should consume all arguments that come after it... - if (Handler->getNumOccurancesFlag() == ConsumeAfter) { - for (++i; i < argc; ++i) - ErrorParsing |= ProvideOption(Handler, ArgName, argv[i], argc, argv, i); + // Check and handle positional arguments now... + if (NumPositionalRequired > PositionalVals.size()) { + cerr << "Not enough positional command line arguments specified!\n"; + cerr << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; + ErrorParsing = true; + + + } else if (ConsumeAfterOpt == 0) { + // Positional args have already been handled if ConsumeAfter is specified... + unsigned ValNo = 0, NumVals = PositionalVals.size(); + for (unsigned i = 0, e = PositionalOpts.size(); i != e; ++i) { + if (RequiresValue(PositionalOpts[i])) { + ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); + --NumPositionalRequired; // We fulfilled our duty... + } + + // If we _can_ give this option more arguments, do so now, as long as we + // do not give it values that others need. 'Done' controls whether the + // option even _WANTS_ any more. + // + bool Done = PositionalOpts[i]->getNumOccurancesFlag() == cl::Required; + while (NumVals-ValNo > NumPositionalRequired && !Done) { + switch (PositionalOpts[i]->getNumOccurancesFlag()) { + case cl::Optional: + Done = true; // Optional arguments want _at most_ one value + // FALL THROUGH + case cl::ZeroOrMore: // Zero or more will take all they can get... + case cl::OneOrMore: // One or more will take all they can get... + ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); + break; + default: + assert(0 && "Internal error, unexpected NumOccurances flag in " + "positional argument processing!"); + } + } } + } else { + assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.size()); + unsigned ValNo = 0; + for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j) + if (RequiresValue(PositionalOpts[j])) + ErrorParsing |= + ProvidePositionalOption(PositionalOpts[j], PositionalVals[ValNo++]); + + // Handle over all of the rest of the arguments to the + // cl::ConsumeAfter command line option... + for (; ValNo != PositionalVals.size(); ++ValNo) + ErrorParsing |= ProvidePositionalOption(ConsumeAfterOpt, + PositionalVals[ValNo]); } // Loop over args and make sure all required args are specified! - for (map::iterator I = getOpts().begin(), - E = getOpts().end(); I != E; ++I) { + for (map::iterator I = Opts.begin(), + E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurancesFlag()) { case Required: case OneOrMore: @@ -198,9 +372,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } } - // Free all of the memory allocated to the vector. Command line options may - // only be processed once! - getOpts().clear(); + // Free all of the memory allocated to the map. Command line options may only + // be processed once! + Opts.clear(); + PositionalOpts.clear(); // If we had an error processing our arguments, don't let the program execute if (ErrorParsing) exit(1); @@ -209,14 +384,14 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, //===----------------------------------------------------------------------===// // Option Base class implementation // -Option::Option(const char *argStr, const char *helpStr, int flags) - : NumOccurances(0), Flags(flags), ArgStr(argStr), HelpStr(helpStr) { - AddArgument(ArgStr, this); -} bool Option::error(string Message, const char *ArgName = 0) { if (ArgName == 0) ArgName = ArgStr; - cerr << "-" << ArgName << " option" << Message << "\n"; + if (ArgName[0] == 0) + cerr << HelpStr; // Be nice for positional arguments + else + cerr << "-" << ArgName; + cerr << " option" << Message << "\n"; return true; } @@ -241,275 +416,303 @@ bool Option::addOccurance(const char *ArgName, const string &Value) { return handleOccurance(ArgName, Value); } +// addArgument - Tell the system that this Option subclass will handle all +// occurances of -ArgStr on the command line. +// +void Option::addArgument(const char *ArgStr) { + if (ArgStr[0]) + AddArgument(ArgStr, this); + else if (getFormattingFlag() == Positional) + getPositionalOpts().push_back(this); + else if (getNumOccurancesFlag() == ConsumeAfter) { + assert((getPositionalOpts().empty() || + getPositionalOpts().front()->getNumOccurancesFlag() != ConsumeAfter) + && "Cannot specify more than one option with cl::ConsumeAfter " + "specified!"); + getPositionalOpts().insert(getPositionalOpts().begin(), this); + } +} + + +// getValueStr - Get the value description string, using "DefaultMsg" if nothing +// has been specified yet. +// +static const char *getValueStr(const Option &O, const char *DefaultMsg) { + if (O.ValueStr[0] == 0) return DefaultMsg; + return O.ValueStr; +} + +//===----------------------------------------------------------------------===// +// cl::alias class implementation +// + // Return the width of the option tag for printing... -unsigned Option::getOptionWidth() const { +unsigned alias::getOptionWidth() const { return std::strlen(ArgStr)+6; } -void Option::printOptionInfo(unsigned GlobalWidth) const { +// Print out the option for the alias... +void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - if (L == 0) return; // Don't print the empty arg like this! cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " << HelpStr << "\n"; } + //===----------------------------------------------------------------------===// -// Boolean/flag command line option implementation +// Parser Implementation code... // -bool Flag::handleOccurance(const char *ArgName, const string &Arg) { +// parser implementation +// +bool parser::parseImpl(Option &O, const string &Arg, bool &Value) { if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") { Value = false; } else { - return error(": '" + Arg + - "' is invalid value for boolean argument! Try 0 or 1"); + return O.error(": '" + Arg + + "' is invalid value for boolean argument! Try 0 or 1"); } - return false; } -//===----------------------------------------------------------------------===// -// Integer valued command line option implementation -// -bool Int::handleOccurance(const char *ArgName, const string &Arg) { - const char *ArgStart = Arg.c_str(); - char *End; - Value = (int)strtol(ArgStart, &End, 0); - if (*End != 0) - return error(": '" + Arg + "' value invalid for integer argument!"); - return false; +// Return the width of the option tag for printing... +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+6; } -//===----------------------------------------------------------------------===// -// String valued command line option implementation +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. // -bool String::handleOccurance(const char *ArgName, const string &Arg) { - *this = Arg; - return false; +void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ + unsigned L = std::strlen(O.ArgStr); + cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') << " - " + << O.HelpStr << "\n"; } -//===----------------------------------------------------------------------===// -// StringList valued command line option implementation -// -bool StringList::handleOccurance(const char *ArgName, const string &Arg) { - push_back(Arg); - return false; -} -//===----------------------------------------------------------------------===// -// Enum valued command line option implementation + +// parser implementation // -void EnumBase::processValues(va_list Vals) { - while (const char *EnumName = va_arg(Vals, const char *)) { - int EnumVal = va_arg(Vals, int); - const char *EnumDesc = va_arg(Vals, const char *); - ValueMap.push_back(std::make_pair(EnumName, // Add value to value map - std::make_pair(EnumVal, EnumDesc))); - } +bool parser::parseImpl(Option &O, const string &Arg, int &Value) { + const char *ArgStart = Arg.c_str(); + char *End; + Value = (int)strtol(ArgStart, &End, 0); + if (*End != 0) + return O.error(": '" + Arg + "' value invalid for integer argument!"); + return false; } -// registerArgs - notify the system about these new arguments -void EnumBase::registerArgs() { - for (unsigned i = 0; i < ValueMap.size(); ++i) - AddArgument(ValueMap[i].first, this); +// Return the width of the option tag for printing... +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "int"))+9; } -const char *EnumBase::getArgName(int ID) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) - if (ID == ValueMap[i].second.first) return ValueMap[i].first; - return ""; -} -const char *EnumBase::getArgDescription(int ID) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) - if (ID == ValueMap[i].second.first) return ValueMap[i].second.second; - return ""; +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ + cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "int") << ">" + << string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; } - -bool EnumValueBase::handleOccurance(const char *ArgName, const string &Arg) { - unsigned i; - for (i = 0; i < ValueMap.size(); ++i) - if (ValueMap[i].first == Arg) break; - - if (i == ValueMap.size()) { - string Alternatives; - for (i = 0; i < ValueMap.size(); ++i) { - if (i) Alternatives += ", "; - Alternatives += ValueMap[i].first; - } - - return error(": unrecognized alternative '" + Arg + - "'! Alternatives are: " + Alternatives); - } - setValue(ValueMap[i].second.first); +// parser implementation +// +bool parser::parseImpl(Option &O, const string &Arg, double &Value) { + const char *ArgStart = Arg.c_str(); + char *End; + Value = strtod(ArgStart, &End); + if (*End != 0) + return O.error(": '" +Arg+ "' value invalid for floating point argument!"); return false; } // Return the width of the option tag for printing... -unsigned EnumValueBase::getOptionWidth() const { - unsigned BaseSize = Option::getOptionWidth(); - for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+8); - return BaseSize; +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "number"))+9; } // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // -void EnumValueBase::printOptionInfo(unsigned GlobalWidth) const { - Option::printOptionInfo(GlobalWidth); - for (unsigned i = 0; i < ValueMap.size(); ++i) { - unsigned NumSpaces = GlobalWidth-strlen(ValueMap[i].first)-8; - cerr << " =" << ValueMap[i].first << string(NumSpaces, ' ') << " - " - << ValueMap[i].second.second; - - if (i == 0) cerr << " (default)"; - cerr << "\n"; - } +void parser::printOptionInfo(const Option &O, + unsigned GlobalWidth) const{ + cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "number") << ">" + << string(GlobalWidth-getOptionWidth(O), ' ') + << " - " << O.HelpStr << "\n"; } -//===----------------------------------------------------------------------===// -// Enum flags command line option implementation -// -bool EnumFlagsBase::handleOccurance(const char *ArgName, const string &Arg) { - return EnumValueBase::handleOccurance("", ArgName); -} +// parser implementation +// -unsigned EnumFlagsBase::getOptionWidth() const { - unsigned BaseSize = 0; - for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); - return BaseSize; +// Return the width of the option tag for printing... +unsigned parser::getOptionWidth(const Option &O) const { + return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "string"))+9; } -void EnumFlagsBase::printOptionInfo(unsigned GlobalWidth) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) { - unsigned L = std::strlen(ValueMap[i].first); - cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " - << ValueMap[i].second.second; - if (i == 0) cerr << " (default)"; - cerr << "\n"; - } +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void parser::printOptionInfo(const Option &O, + unsigned GlobalWidth) const{ + cerr << " -" << O.ArgStr << " <" << getValueStr(O, "string") << ">" + << string(GlobalWidth-getOptionWidth(O), ' ') + << " - " << O.HelpStr << "\n"; } - -//===----------------------------------------------------------------------===// -// Enum list command line option implementation +// generic_parser_base implementation // -bool EnumListBase::handleOccurance(const char *ArgName, const string &Arg) { - unsigned i; - for (i = 0; i < ValueMap.size(); ++i) - if (ValueMap[i].first == string(ArgName)) break; - if (i == ValueMap.size()) - return error(": CommandLine INTERNAL ERROR", ArgName); - Values.push_back(ValueMap[i].second.first); - return false; -} - // Return the width of the option tag for printing... -unsigned EnumListBase::getOptionWidth() const { - unsigned BaseSize = 0; - for (unsigned i = 0; i < ValueMap.size(); ++i) - BaseSize = std::max(BaseSize, (unsigned)std::strlen(ValueMap[i].first)+6); - return BaseSize; +unsigned generic_parser_base::getOptionWidth(const Option &O) const { + if (O.hasArgStr()) { + unsigned Size = std::strlen(O.ArgStr)+6; + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) + Size = std::max(Size, (unsigned)std::strlen(getOption(i))+8); + return Size; + } else { + unsigned BaseSize = 0; + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) + BaseSize = std::max(BaseSize, (unsigned)std::strlen(getOption(i))+8); + return BaseSize; + } } - // printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // -void EnumListBase::printOptionInfo(unsigned GlobalWidth) const { - for (unsigned i = 0; i < ValueMap.size(); ++i) { - unsigned L = std::strlen(ValueMap[i].first); - cerr << " -" << ValueMap[i].first << string(GlobalWidth-L-6, ' ') << " - " - << ValueMap[i].second.second << "\n"; +void generic_parser_base::printOptionInfo(const Option &O, + unsigned GlobalWidth) const { + if (O.hasArgStr()) { + unsigned L = std::strlen(O.ArgStr); + cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') + << " - " << O.HelpStr << "\n"; + + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { + unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; + cerr << " =" << getOption(i) << string(NumSpaces, ' ') << " - " + << getDescription(i) << "\n"; + } + } else { + if (O.HelpStr[0]) + cerr << " " << O.HelpStr << "\n"; + for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { + unsigned L = std::strlen(getOption(i)); + cerr << " -" << getOption(i) << string(GlobalWidth-L-8, ' ') << " - " + << getDescription(i) << "\n"; + } } } //===----------------------------------------------------------------------===// -// Help option... always automatically provided. +// --help and --help-hidden option implementation // namespace { -// isHidden/isReallyHidden - Predicates to be used to filter down arg lists. -inline bool isHidden(pair &OptPair) { - return OptPair.second->getOptionHiddenFlag() >= Hidden; -} -inline bool isReallyHidden(pair &OptPair) { - return OptPair.second->getOptionHiddenFlag() == ReallyHidden; -} - -class Help : public Option { +class HelpPrinter { unsigned MaxArgLen; const Option *EmptyArg; const bool ShowHidden; - virtual bool handleOccurance(const char *ArgName, const string &Arg) { + // isHidden/isReallyHidden - Predicates to be used to filter down arg lists. + inline static bool isHidden(pair &OptPair) { + return OptPair.second->getOptionHiddenFlag() >= Hidden; + } + inline static bool isReallyHidden(pair &OptPair) { + return OptPair.second->getOptionHiddenFlag() == ReallyHidden; + } + +public: + HelpPrinter(bool showHidden) : ShowHidden(showHidden) { + EmptyArg = 0; + } + + void operator=(bool Value) { + if (Value == false) return; + // Copy Options into a vector so we can sort them as we like... vector > Options; copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden - Options.erase(remove_if(Options.begin(), Options.end(), - std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), + Options.erase(std::remove_if(Options.begin(), Options.end(), + std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), Options.end()); // Eliminate duplicate entries in table (from enum flags options, f.e.) - std::set OptionSet; - for (unsigned i = 0; i < Options.size(); ) - if (OptionSet.count(Options[i].second) == 0) - OptionSet.insert(Options[i++].second); // Add to set - else - Options.erase(Options.begin()+i); // Erase duplicate - + { // Give OptionSet a scope + std::set OptionSet; + for (unsigned i = 0; i != Options.size(); ++i) + if (OptionSet.count(Options[i].second) == 0) + OptionSet.insert(Options[i].second); // Add new entry to set + else + Options.erase(Options.begin()+i--); // Erase duplicate + } if (ProgramOverview) cerr << "OVERVIEW:" << ProgramOverview << "\n"; - // TODO: Sort options by some criteria - cerr << "USAGE: " << ProgramName << " [options]\n\n"; - // TODO: print usage nicer + cerr << "USAGE: " << ProgramName << " [options]"; + + // Print out the positional options... + vector &PosOpts = getPositionalOpts(); + Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... + if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) + CAOpt = PosOpts[0]; + + for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { + cerr << " " << PosOpts[i]->HelpStr; + switch (PosOpts[i]->getNumOccurancesFlag()) { + case Optional: cerr << "?"; break; + case ZeroOrMore: cerr << "*"; break; + case Required: break; + case OneOrMore: cerr << "+"; break; + case ConsumeAfter: + default: + assert(0 && "Unknown NumOccurances Flag Value!"); + } + } + + // Print the consume after option info if it exists... + if (CAOpt) cerr << " " << CAOpt->HelpStr; + + cerr << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; - for_each(Options.begin(), Options.end(), - bind_obj(this, &Help::getMaxArgLen)); + for (unsigned i = 0, e = Options.size(); i != e; ++i) + MaxArgLen = std::max(MaxArgLen, Options[i].second->getOptionWidth()); cerr << "OPTIONS:\n"; - for_each(Options.begin(), Options.end(), - bind_obj(this, &Help::printOption)); + for (unsigned i = 0, e = Options.size(); i != e; ++i) + Options[i].second->printOptionInfo(MaxArgLen); - return true; // Displaying help is cause to terminate the program + // Halt the program if help information is printed + exit(1); } +}; - void getMaxArgLen(pair OptPair) { - const Option *Opt = OptPair.second; - if (Opt->ArgStr[0] == 0) EmptyArg = Opt; // Capture the empty arg if exists - MaxArgLen = std::max(MaxArgLen, Opt->getOptionWidth()); - } - void printOption(pair OptPair) { - const Option *Opt = OptPair.second; - Opt->printOptionInfo(MaxArgLen); - } -public: - inline Help(const char *ArgVal, const char *HelpVal, bool showHidden) - : Option(ArgVal, HelpVal, showHidden ? Hidden : 0), ShowHidden(showHidden) { - EmptyArg = 0; - } -}; +// Define the two HelpPrinter instances that are used to print out help, or +// help-hidden... +// +HelpPrinter NormalPrinter(false); +HelpPrinter HiddenPrinter(true); + +cl::opt > +HOp("help", cl::desc("display available options (--help-hidden for more)"), + cl::location(NormalPrinter)); -Help HelpOp("help", "display available options" - " (--help-hidden for more)", false); -Help HelpHiddenOpt("help-hidden", "display all available options", true); +cl::opt > +HHOp("help-hidden", cl::desc("display all available options"), + cl::location(HiddenPrinter), cl::Hidden); } // End anonymous namespace -- cgit v1.2.3-70-g09d2 From 54ec7aed89e4a5d8cc11c36999d88012cbfcc18a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 22 Jul 2002 02:21:57 +0000 Subject: Minor bugfix, prevents error in LLI git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2989 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 10 ++++++---- support/lib/Support/CommandLine.cpp | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index d11fbd7119..001fdac476 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -168,10 +168,12 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ++NumPositionalRequired; else if (ConsumeAfterOpt) { // ConsumeAfter cannot be combined with "optional" positional options - ErrorParsing |= - Opt->error(" error - this positional option will never be matched, " - "because it does not Require a value, and a " - "cl::ConsumeAfter option is active!"); + // unless there is only one positional argument... + if (PositionalOpts.size() > 2) + ErrorParsing |= + Opt->error(" error - this positional option will never be matched, " + "because it does not Require a value, and a " + "cl::ConsumeAfter option is active!"); } else if (UnboundedFound) { // This option does not "require" a value... // Make sure this option is not specified after an option that eats all // extra arguments, or this one will never get any! diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index d11fbd7119..001fdac476 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -168,10 +168,12 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ++NumPositionalRequired; else if (ConsumeAfterOpt) { // ConsumeAfter cannot be combined with "optional" positional options - ErrorParsing |= - Opt->error(" error - this positional option will never be matched, " - "because it does not Require a value, and a " - "cl::ConsumeAfter option is active!"); + // unless there is only one positional argument... + if (PositionalOpts.size() > 2) + ErrorParsing |= + Opt->error(" error - this positional option will never be matched, " + "because it does not Require a value, and a " + "cl::ConsumeAfter option is active!"); } else if (UnboundedFound) { // This option does not "require" a value... // Make sure this option is not specified after an option that eats all // extra arguments, or this one will never get any! -- cgit v1.2.3-70-g09d2 From aa852bbb503571d1198856fa4c6e099d7625e3b3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 23 Jul 2002 17:15:12 +0000 Subject: *** empty log message *** git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2999 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 32 ++++++++++++++++++++++++++++++++ support/lib/Support/CommandLine.cpp | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 001fdac476..cafc14d320 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -435,6 +435,22 @@ void Option::addArgument(const char *ArgStr) { } } +void Option::removeArgument(const char *ArgStr) { + if (ArgStr[0]) { + assert(getOpts()[ArgStr] == this && "Arg not in map!"); + getOpts().erase(ArgStr); + } else if (getFormattingFlag() == Positional) { + vector::iterator I = + std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); + assert(I != getPositionalOpts().end() && "Arg not registered!"); + getPositionalOpts().erase(I); + } else if (getNumOccurancesFlag() == ConsumeAfter) { + assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this && + "Arg not registered correctly!"); + getPositionalOpts().erase(getPositionalOpts().begin()); + } +} + // getValueStr - Get the value description string, using "DefaultMsg" if nothing // has been specified yet. @@ -571,6 +587,22 @@ void parser::printOptionInfo(const Option &O, // generic_parser_base implementation // +// findOption - Return the option number corresponding to the specified +// argument string. If the option is not found, getNumOptions() is returned. +// +unsigned generic_parser_base::findOption(const char *Name) { + unsigned i = 0, e = getNumOptions(); + string N(Name); + + while (i != e) + if (getOption(i) == N) + return i; + else + ++i; + return e; +} + + // Return the width of the option tag for printing... unsigned generic_parser_base::getOptionWidth(const Option &O) const { if (O.hasArgStr()) { diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 001fdac476..cafc14d320 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -435,6 +435,22 @@ void Option::addArgument(const char *ArgStr) { } } +void Option::removeArgument(const char *ArgStr) { + if (ArgStr[0]) { + assert(getOpts()[ArgStr] == this && "Arg not in map!"); + getOpts().erase(ArgStr); + } else if (getFormattingFlag() == Positional) { + vector::iterator I = + std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); + assert(I != getPositionalOpts().end() && "Arg not registered!"); + getPositionalOpts().erase(I); + } else if (getNumOccurancesFlag() == ConsumeAfter) { + assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this && + "Arg not registered correctly!"); + getPositionalOpts().erase(getPositionalOpts().begin()); + } +} + // getValueStr - Get the value description string, using "DefaultMsg" if nothing // has been specified yet. @@ -571,6 +587,22 @@ void parser::printOptionInfo(const Option &O, // generic_parser_base implementation // +// findOption - Return the option number corresponding to the specified +// argument string. If the option is not found, getNumOptions() is returned. +// +unsigned generic_parser_base::findOption(const char *Name) { + unsigned i = 0, e = getNumOptions(); + string N(Name); + + while (i != e) + if (getOption(i) == N) + return i; + else + ++i; + return e; +} + + // Return the width of the option tag for printing... unsigned generic_parser_base::getOptionWidth(const Option &O) const { if (O.hasArgStr()) { -- cgit v1.2.3-70-g09d2 From faba809472e36fbb28394da6ed907d2652ca8b83 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 24 Jul 2002 20:15:13 +0000 Subject: Fix a bug exposed by lli git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3049 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 13 +++++++++++-- support/lib/Support/CommandLine.cpp | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index cafc14d320..433cefda7b 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -348,8 +348,17 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, unsigned ValNo = 0; for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j) if (RequiresValue(PositionalOpts[j])) - ErrorParsing |= - ProvidePositionalOption(PositionalOpts[j], PositionalVals[ValNo++]); + ErrorParsing |= ProvidePositionalOption(PositionalOpts[j], + PositionalVals[ValNo++]); + + // Handle the case where there is just one positional option, and it's + // optional. In this case, we want to give JUST THE FIRST option to the + // positional option and keep the rest for the consume after. The above + // loop would have assigned no values to positional options in this case. + // + if (PositionalOpts.size() == 2 && ValNo == 0) + ErrorParsing |= ProvidePositionalOption(PositionalOpts[1], + PositionalVals[ValNo++]); // Handle over all of the rest of the arguments to the // cl::ConsumeAfter command line option... diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index cafc14d320..433cefda7b 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -348,8 +348,17 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, unsigned ValNo = 0; for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j) if (RequiresValue(PositionalOpts[j])) - ErrorParsing |= - ProvidePositionalOption(PositionalOpts[j], PositionalVals[ValNo++]); + ErrorParsing |= ProvidePositionalOption(PositionalOpts[j], + PositionalVals[ValNo++]); + + // Handle the case where there is just one positional option, and it's + // optional. In this case, we want to give JUST THE FIRST option to the + // positional option and keep the rest for the consume after. The above + // loop would have assigned no values to positional options in this case. + // + if (PositionalOpts.size() == 2 && ValNo == 0) + ErrorParsing |= ProvidePositionalOption(PositionalOpts[1], + PositionalVals[ValNo++]); // Handle over all of the rest of the arguments to the // cl::ConsumeAfter command line option... -- cgit v1.2.3-70-g09d2 From 0c0edf8afc35a42b15a24ebb5fa5f3fc674290ae Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 25 Jul 2002 06:17:51 +0000 Subject: *** empty log message *** git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3075 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/InstrSched/InstrScheduling.cpp | 2 +- lib/CodeGen/InstrSched/SchedGraph.cpp | 4 ++-- lib/CodeGen/InstrSched/SchedGraph.h | 4 ++-- lib/CodeGen/MachineFunction.cpp | 4 ++-- lib/CodeGen/MachineInstr.cpp | 10 +++++----- lib/Support/CommandLine.cpp | 4 ++-- lib/Support/PluginLoader.cpp | 3 ++- lib/Target/SparcV9/InstrSched/InstrScheduling.cpp | 2 +- lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 4 ++-- lib/Target/SparcV9/InstrSched/SchedGraph.h | 4 ++-- lib/Target/TargetData.cpp | 10 +++++----- lib/Transforms/IPO/MutateStructTypes.cpp | 2 +- lib/Transforms/IPO/OldPoolAllocate.cpp | 1 + lib/Transforms/Scalar/Reassociate.cpp | 2 +- lib/Transforms/TransformInternals.cpp | 4 ++-- support/lib/Support/CommandLine.cpp | 4 ++-- support/lib/Support/PluginLoader.cpp | 3 ++- 17 files changed, 35 insertions(+), 32 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index 2271c780a3..19c6922d34 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -79,7 +79,7 @@ private: //---------------------------------------------------------------------- template -class ScheduleIterator: public std::forward_iterator<_NodeType, ptrdiff_t> { +class ScheduleIterator : public forward_iterator<_NodeType, ptrdiff_t> { private: unsigned cycleNum; unsigned slotNum; diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index 8a9c8e573b..781604eaae 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -132,7 +132,7 @@ SchedGraphEdge::~SchedGraphEdge() { } -void SchedGraphEdge::dump(int indent=0) const { +void SchedGraphEdge::dump(int indent) const { cerr << std::string(indent*2, ' ') << *this; } @@ -171,7 +171,7 @@ SchedGraphNode::~SchedGraphNode() deleter); } -void SchedGraphNode::dump(int indent=0) const { +void SchedGraphNode::dump(int indent) const { cerr << std::string(indent*2, ' ') << *this; } diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h index 7db22d6734..0d59734e2d 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.h +++ b/lib/CodeGen/InstrSched/SchedGraph.h @@ -377,7 +377,7 @@ private: // for . // template -class SGPredIterator: public std::bidirectional_iterator<_NodeType, ptrdiff_t> { +class SGPredIterator: public bidirectional_iterator<_NodeType, ptrdiff_t> { protected: _EdgeIter oi; public: @@ -406,7 +406,7 @@ public: }; template -class SGSuccIterator: public std::bidirectional_iterator<_NodeType, ptrdiff_t> { +class SGSuccIterator : public bidirectional_iterator<_NodeType, ptrdiff_t> { protected: _EdgeIter oi; public: diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index ce39b45f12..f32f647e11 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -139,7 +139,7 @@ int MachineCodeForMethod::computeOffsetforLocalVar(const TargetMachine& target, const Value* val, unsigned int& getPaddedSize, - unsigned int sizeToUse = 0) + unsigned int sizeToUse) { bool growUp; int firstOffset =target.getFrameInfo().getFirstAutomaticVarOffset(*this, @@ -174,7 +174,7 @@ MachineCodeForMethod::computeOffsetforLocalVar(const TargetMachine& target, int MachineCodeForMethod::allocateLocalVar(const TargetMachine& target, const Value* val, - unsigned int sizeToUse = 0) + unsigned int sizeToUse) { assert(! automaticVarsAreaFrozen && "Size of auto vars area has been used to compute an offset so " diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 4fc3730658..124c28a2d9 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -44,8 +44,8 @@ void MachineInstr::SetMachineOperandVal(unsigned int i, MachineOperand::MachineOperandType opType, Value* _val, - bool isdef=false, - bool isDefAndUse=false) + bool isdef, + bool isDefAndUse) { assert(i < operands.size()); operands[i].Initialize(opType, _val); @@ -69,9 +69,9 @@ MachineInstr::SetMachineOperandConst(unsigned int i, void MachineInstr::SetMachineOperandReg(unsigned int i, int regNum, - bool isdef=false, - bool isDefAndUse=false, - bool isCCReg=false) + bool isdef, + bool isDefAndUse, + bool isCCReg) { assert(i < operands.size()); operands[i].InitializeReg(regNum, isCCReg); diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 433cefda7b..e125ebeb82 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -138,7 +138,7 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { } void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0) { + const char *Overview) { assert((!getOpts().empty() || !getPositionalOpts().empty()) && "No options specified, or ParseCommandLineOptions called more" " than once!"); @@ -396,7 +396,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // -bool Option::error(string Message, const char *ArgName = 0) { +bool Option::error(string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) cerr << HelpStr; // Be nice for positional arguments diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index c2e4e89813..dce923af7f 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -13,6 +13,7 @@ #include "Support/CommandLine.h" #include #include +#include namespace { struct PluginLoader { @@ -25,6 +26,6 @@ namespace { } // This causes operator= above to be invoked for every -load option. -static cl::opt > +static cl::opt > LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"), cl::desc("Load the specified plugin")); diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index 2271c780a3..19c6922d34 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -79,7 +79,7 @@ private: //---------------------------------------------------------------------- template -class ScheduleIterator: public std::forward_iterator<_NodeType, ptrdiff_t> { +class ScheduleIterator : public forward_iterator<_NodeType, ptrdiff_t> { private: unsigned cycleNum; unsigned slotNum; diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index 8a9c8e573b..781604eaae 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -132,7 +132,7 @@ SchedGraphEdge::~SchedGraphEdge() { } -void SchedGraphEdge::dump(int indent=0) const { +void SchedGraphEdge::dump(int indent) const { cerr << std::string(indent*2, ' ') << *this; } @@ -171,7 +171,7 @@ SchedGraphNode::~SchedGraphNode() deleter); } -void SchedGraphNode::dump(int indent=0) const { +void SchedGraphNode::dump(int indent) const { cerr << std::string(indent*2, ' ') << *this; } diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h index 7db22d6734..0d59734e2d 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.h +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h @@ -377,7 +377,7 @@ private: // for . // template -class SGPredIterator: public std::bidirectional_iterator<_NodeType, ptrdiff_t> { +class SGPredIterator: public bidirectional_iterator<_NodeType, ptrdiff_t> { protected: _EdgeIter oi; public: @@ -406,7 +406,7 @@ public: }; template -class SGSuccIterator: public std::bidirectional_iterator<_NodeType, ptrdiff_t> { +class SGSuccIterator : public bidirectional_iterator<_NodeType, ptrdiff_t> { protected: _EdgeIter oi; public: diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index e306d4e250..8712fc9f59 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -74,11 +74,11 @@ Annotation *TargetData::TypeAnFactory(AnnotationID AID, const Annotable *T, //===----------------------------------------------------------------------===// TargetData::TargetData(const std::string &TargetName, - unsigned char IntRegSize = 8, unsigned char PtrSize = 8, - unsigned char PtrAl = 8, unsigned char DoubleAl = 8, - unsigned char FloatAl = 4, unsigned char LongAl = 8, - unsigned char IntAl = 4, unsigned char ShortAl = 2, - unsigned char ByteAl = 1) + unsigned char IntRegSize, unsigned char PtrSize, + unsigned char PtrAl, unsigned char DoubleAl, + unsigned char FloatAl, unsigned char LongAl, + unsigned char IntAl, unsigned char ShortAl, + unsigned char ByteAl) : AID(AnnotationManager::getID("TargetData::" + TargetName)) { AnnotationManager::registerAnnotationFactory(AID, TypeAnFactory, this); diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index 4058a3d03a..174f7a102b 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -108,7 +108,7 @@ const Type *MutateStructTypes::ConvertType(const Type *Ty) { // void MutateStructTypes::AdjustIndices(const CompositeType *OldTy, vector &Idx, - unsigned i = 0) { + unsigned i) { assert(i < Idx.size() && "i out of range!"); const CompositeType *NewCT = cast(ConvertType(OldTy)); if (NewCT == OldTy) return; // No adjustment unless type changes diff --git a/lib/Transforms/IPO/OldPoolAllocate.cpp b/lib/Transforms/IPO/OldPoolAllocate.cpp index e74c8b22c1..c22d53ef91 100644 --- a/lib/Transforms/IPO/OldPoolAllocate.cpp +++ b/lib/Transforms/IPO/OldPoolAllocate.cpp @@ -1759,5 +1759,6 @@ bool PoolAllocate::run(Module &M) { // Pass *createPoolAllocatePass() { assert(0 && "Pool allocator disabled!"); + return 0; //return new PoolAllocate(); } diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 05758039d9..a6ad88a9ea 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -33,7 +33,7 @@ static Statistic<> NumSwapped("reassociate\t- Number of insts with operands swap namespace { class Reassociate : public FunctionPass { - map RankMap; + std::map RankMap; public: bool runOnFunction(Function &F); diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index 05bc69438b..f8476231cf 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -52,7 +52,7 @@ static const Type *getStructOffsetStep(const StructType *STy, unsigned &Offset, // const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, std::vector &Indices, - bool StopEarly = true) { + bool StopEarly) { if (Offset == 0 && StopEarly && !Indices.empty()) return Ty; // Return the leaf type @@ -87,7 +87,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, // const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal, std::vector &Indices, - BasicBlock::iterator *BI = 0) { + BasicBlock::iterator *BI) { const CompositeType *CompTy = dyn_cast(Ty); if (CompTy == 0) return 0; diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 433cefda7b..e125ebeb82 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -138,7 +138,7 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { } void cl::ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0) { + const char *Overview) { assert((!getOpts().empty() || !getPositionalOpts().empty()) && "No options specified, or ParseCommandLineOptions called more" " than once!"); @@ -396,7 +396,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // -bool Option::error(string Message, const char *ArgName = 0) { +bool Option::error(string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) cerr << HelpStr; // Be nice for positional arguments diff --git a/support/lib/Support/PluginLoader.cpp b/support/lib/Support/PluginLoader.cpp index c2e4e89813..dce923af7f 100644 --- a/support/lib/Support/PluginLoader.cpp +++ b/support/lib/Support/PluginLoader.cpp @@ -13,6 +13,7 @@ #include "Support/CommandLine.h" #include #include +#include namespace { struct PluginLoader { @@ -25,6 +26,6 @@ namespace { } // This causes operator= above to be invoked for every -load option. -static cl::opt > +static cl::opt > LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"), cl::desc("Load the specified plugin")); -- cgit v1.2.3-70-g09d2 From 99b7c1a9ead9be905d5ba97a5c4da1b066c07fe3 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 27 Jul 2002 05:25:29 +0000 Subject: Remove needless #include git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3117 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 1 - support/lib/Support/CommandLine.cpp | 1 - 2 files changed, 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index e125ebeb82..fc3d62b357 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -10,7 +10,6 @@ //===----------------------------------------------------------------------===// #include "Support/CommandLine.h" -#include "Support/STLExtras.h" #include #include #include diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index e125ebeb82..fc3d62b357 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -10,7 +10,6 @@ //===----------------------------------------------------------------------===// #include "Support/CommandLine.h" -#include "Support/STLExtras.h" #include #include #include -- cgit v1.2.3-70-g09d2 From e8e258b1a7e54a77c802e8b309d0a60a62d1a00d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 29 Jul 2002 20:58:42 +0000 Subject: * Fix assertion failure caused by command line argument getting removed after the map was freed. * Cleanup code a bit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3121 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 50 ++++++++++++++++++++++++++----------- support/lib/Support/CommandLine.cpp | 50 ++++++++++++++++++++++++++----------- 2 files changed, 70 insertions(+), 30 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index fc3d62b357..c00c42bcb9 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -29,9 +29,16 @@ using std::cerr; // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // +static map *CommandLineOptions = 0; static map &getOpts() { - static map CommandLineOptions; - return CommandLineOptions; + if (CommandLineOptions == 0) CommandLineOptions = new map(); + return *CommandLineOptions; +} + +static Option *getOption(const string &Str) { + if (CommandLineOptions == 0) return 0; + map::iterator I = CommandLineOptions->find(Str); + return I != CommandLineOptions->end() ? I->second : 0; } static vector &getPositionalOpts() { @@ -39,13 +46,26 @@ static vector &getPositionalOpts() { return Positional; } -static void AddArgument(const string &ArgName, Option *Opt) { - if (getOpts().find(ArgName) != getOpts().end()) { +static void AddArgument(const char *ArgName, Option *Opt) { + if (getOption(ArgName)) { cerr << "CommandLine Error: Argument '" << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! - getOpts().insert(std::make_pair(ArgName, Opt)); + getOpts()[ArgName] = Opt; + } +} + +// RemoveArgument - It's possible that the argument is no longer in the map if +// options have already been processed and the map has been deleted! +// +static void RemoveArgument(const char *ArgName, Option *Opt) { + if (CommandLineOptions == 0) return; + assert(getOption(ArgName) == Opt && "Arg not in map!"); + CommandLineOptions->erase(ArgName); + if (CommandLineOptions->empty()) { + delete CommandLineOptions; + CommandLineOptions = 0; } } @@ -103,25 +123,25 @@ static inline bool isPrefixedOrGrouping(const Option *O) { static Option *getOptionPred(std::string Name, unsigned &Length, bool (*Pred)(const Option*)) { - map::iterator I = getOpts().find(Name); - if (I != getOpts().end() && Pred(I->second)) { + Option *Op = getOption(Name); + if (Op && Pred(Op)) { Length = Name.length(); - return I->second; + return Op; } if (Name.size() == 1) return 0; do { Name.erase(Name.end()-1, Name.end()); // Chop off the last character... - I = getOpts().find(Name); + Op = getOption(Name); // Loop while we haven't found an option and Name still has at least two // characters in it (so that the next iteration will not be the empty // string... - } while ((I == getOpts().end() || !Pred(I->second)) && Name.size() > 1); + } while ((Op == 0 || !Pred(Op)) && Name.size() > 1); - if (I != getOpts().end() && Pred(I->second)) { + if (Op && Pred(Op)) { Length = Name.length(); - return I->second; // Found one! + return Op; // Found one! } return 0; // No option found! } @@ -384,7 +404,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Free all of the memory allocated to the map. Command line options may only // be processed once! - Opts.clear(); + delete CommandLineOptions; + CommandLineOptions = 0; PositionalOpts.clear(); // If we had an error processing our arguments, don't let the program execute @@ -445,8 +466,7 @@ void Option::addArgument(const char *ArgStr) { void Option::removeArgument(const char *ArgStr) { if (ArgStr[0]) { - assert(getOpts()[ArgStr] == this && "Arg not in map!"); - getOpts().erase(ArgStr); + RemoveArgument(ArgStr, this); } else if (getFormattingFlag() == Positional) { vector::iterator I = std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index fc3d62b357..c00c42bcb9 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -29,9 +29,16 @@ using std::cerr; // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // +static map *CommandLineOptions = 0; static map &getOpts() { - static map CommandLineOptions; - return CommandLineOptions; + if (CommandLineOptions == 0) CommandLineOptions = new map(); + return *CommandLineOptions; +} + +static Option *getOption(const string &Str) { + if (CommandLineOptions == 0) return 0; + map::iterator I = CommandLineOptions->find(Str); + return I != CommandLineOptions->end() ? I->second : 0; } static vector &getPositionalOpts() { @@ -39,13 +46,26 @@ static vector &getPositionalOpts() { return Positional; } -static void AddArgument(const string &ArgName, Option *Opt) { - if (getOpts().find(ArgName) != getOpts().end()) { +static void AddArgument(const char *ArgName, Option *Opt) { + if (getOption(ArgName)) { cerr << "CommandLine Error: Argument '" << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! - getOpts().insert(std::make_pair(ArgName, Opt)); + getOpts()[ArgName] = Opt; + } +} + +// RemoveArgument - It's possible that the argument is no longer in the map if +// options have already been processed and the map has been deleted! +// +static void RemoveArgument(const char *ArgName, Option *Opt) { + if (CommandLineOptions == 0) return; + assert(getOption(ArgName) == Opt && "Arg not in map!"); + CommandLineOptions->erase(ArgName); + if (CommandLineOptions->empty()) { + delete CommandLineOptions; + CommandLineOptions = 0; } } @@ -103,25 +123,25 @@ static inline bool isPrefixedOrGrouping(const Option *O) { static Option *getOptionPred(std::string Name, unsigned &Length, bool (*Pred)(const Option*)) { - map::iterator I = getOpts().find(Name); - if (I != getOpts().end() && Pred(I->second)) { + Option *Op = getOption(Name); + if (Op && Pred(Op)) { Length = Name.length(); - return I->second; + return Op; } if (Name.size() == 1) return 0; do { Name.erase(Name.end()-1, Name.end()); // Chop off the last character... - I = getOpts().find(Name); + Op = getOption(Name); // Loop while we haven't found an option and Name still has at least two // characters in it (so that the next iteration will not be the empty // string... - } while ((I == getOpts().end() || !Pred(I->second)) && Name.size() > 1); + } while ((Op == 0 || !Pred(Op)) && Name.size() > 1); - if (I != getOpts().end() && Pred(I->second)) { + if (Op && Pred(Op)) { Length = Name.length(); - return I->second; // Found one! + return Op; // Found one! } return 0; // No option found! } @@ -384,7 +404,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Free all of the memory allocated to the map. Command line options may only // be processed once! - Opts.clear(); + delete CommandLineOptions; + CommandLineOptions = 0; PositionalOpts.clear(); // If we had an error processing our arguments, don't let the program execute @@ -445,8 +466,7 @@ void Option::addArgument(const char *ArgStr) { void Option::removeArgument(const char *ArgStr) { if (ArgStr[0]) { - assert(getOpts()[ArgStr] == this && "Arg not in map!"); - getOpts().erase(ArgStr); + RemoveArgument(ArgStr, this); } else if (getFormattingFlag() == Positional) { vector::iterator I = std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); -- cgit v1.2.3-70-g09d2 From d16714b5ed076d0c1d14543098c1e9b90fd92a38 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 31 Jul 2002 16:29:43 +0000 Subject: Fix bug that was causing problems for lli git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3176 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 +- support/lib/Support/CommandLine.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index c00c42bcb9..9890ee2414 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -230,7 +230,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // All of the positional arguments have been fulfulled, give the rest to // the consume after option... if it's specified... // - if (PositionalVals.size() == NumPositionalRequired && + if (PositionalVals.size() >= NumPositionalRequired && ConsumeAfterOpt != 0) { for (++i; i < argc; ++i) PositionalVals.push_back(argv[i]); diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index c00c42bcb9..9890ee2414 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -230,7 +230,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // All of the positional arguments have been fulfulled, give the rest to // the consume after option... if it's specified... // - if (PositionalVals.size() == NumPositionalRequired && + if (PositionalVals.size() >= NumPositionalRequired && ConsumeAfterOpt != 0) { for (++i; i < argc; ++i) PositionalVals.push_back(argv[i]); -- cgit v1.2.3-70-g09d2 From b490c20b3891717f95804517d47d269bbcf3dc03 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 2 Aug 2002 21:51:29 +0000 Subject: Fix lli with no arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3226 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 +- support/lib/Support/CommandLine.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 9890ee2414..39bff48fd7 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -375,7 +375,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // positional option and keep the rest for the consume after. The above // loop would have assigned no values to positional options in this case. // - if (PositionalOpts.size() == 2 && ValNo == 0) + if (PositionalOpts.size() == 2 && ValNo == 0 && !PositionalVals.empty()) ErrorParsing |= ProvidePositionalOption(PositionalOpts[1], PositionalVals[ValNo++]); diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 9890ee2414..39bff48fd7 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -375,7 +375,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // positional option and keep the rest for the consume after. The above // loop would have assigned no values to positional options in this case. // - if (PositionalOpts.size() == 2 && ValNo == 0) + if (PositionalOpts.size() == 2 && ValNo == 0 && !PositionalVals.empty()) ErrorParsing |= ProvidePositionalOption(PositionalOpts[1], PositionalVals[ValNo++]); -- cgit v1.2.3-70-g09d2 From 9b14eb5a781cea80ade37ab9462ba0721cbdbb9c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 7 Aug 2002 18:36:37 +0000 Subject: Simplify writing custom parsers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3256 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 124 ++++++++++++++---------------------- support/lib/Support/CommandLine.cpp | 124 ++++++++++++++---------------------- 2 files changed, 96 insertions(+), 152 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 39bff48fd7..4eacedbdc8 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -510,9 +510,39 @@ void alias::printOptionInfo(unsigned GlobalWidth) const { // Parser Implementation code... // +// basic_parser implementation +// + +// Return the width of the option tag for printing... +unsigned basic_parser_impl::getOptionWidth(const Option &O) const { + unsigned Len = std::strlen(O.ArgStr); + if (const char *ValName = getValueName()) + Len += std::strlen(getValueStr(O, ValName))+3; + + return Len + 6; +} + +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void basic_parser_impl::printOptionInfo(const Option &O, + unsigned GlobalWidth) const { + cerr << " -" << O.ArgStr; + + if (const char *ValName = getValueName()) + cerr << "=<" << getValueStr(O, ValName) << ">"; + + cerr << string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; +} + + + + // parser implementation // -bool parser::parseImpl(Option &O, const string &Arg, bool &Value) { +bool parser::parse(Option &O, const char *ArgName, + const string &Arg, bool &Value) { if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; @@ -525,25 +555,10 @@ bool parser::parseImpl(Option &O, const string &Arg, bool &Value) { return false; } -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+6; -} - -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ - unsigned L = std::strlen(O.ArgStr); - cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') << " - " - << O.HelpStr << "\n"; -} - - - // parser implementation // -bool parser::parseImpl(Option &O, const string &Arg, int &Value) { +bool parser::parse(Option &O, const char *ArgName, + const string &Arg, int &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = (int)strtol(ArgStart, &End, 0); @@ -552,24 +567,9 @@ bool parser::parseImpl(Option &O, const string &Arg, int &Value) { return false; } -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "int"))+9; -} - -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ - cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "int") << ">" - << string(GlobalWidth-getOptionWidth(O), ' ') << " - " - << O.HelpStr << "\n"; -} - - -// parser implementation +// parser/parser implementation // -bool parser::parseImpl(Option &O, const string &Arg, double &Value) { +static bool parseDouble(Option &O, const string &Arg, double &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = strtod(ArgStart, &End); @@ -578,39 +578,21 @@ bool parser::parseImpl(Option &O, const string &Arg, double &Value) { return false; } -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "number"))+9; +bool parser::parse(Option &O, const char *AN, + const std::string &Arg, double &Val) { + return parseDouble(O, Arg, Val); } -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, - unsigned GlobalWidth) const{ - cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "number") << ">" - << string(GlobalWidth-getOptionWidth(O), ' ') - << " - " << O.HelpStr << "\n"; +bool parser::parse(Option &O, const char *AN, + const std::string &Arg, float &Val) { + double dVal; + if (parseDouble(O, Arg, dVal)) + return true; + Val = (float)dVal; + return false; } -// parser implementation -// - -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "string"))+9; -} - -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, - unsigned GlobalWidth) const{ - cerr << " -" << O.ArgStr << " <" << getValueStr(O, "string") << ">" - << string(GlobalWidth-getOptionWidth(O), ' ') - << " - " << O.HelpStr << "\n"; -} // generic_parser_base implementation // @@ -729,18 +711,8 @@ public: if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; - for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { + for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) cerr << " " << PosOpts[i]->HelpStr; - switch (PosOpts[i]->getNumOccurancesFlag()) { - case Optional: cerr << "?"; break; - case ZeroOrMore: cerr << "*"; break; - case Required: break; - case OneOrMore: cerr << "+"; break; - case ConsumeAfter: - default: - assert(0 && "Unknown NumOccurances Flag Value!"); - } - } // Print the consume after option info if it exists... if (CAOpt) cerr << " " << CAOpt->HelpStr; @@ -771,10 +743,10 @@ HelpPrinter HiddenPrinter(true); cl::opt > HOp("help", cl::desc("display available options (--help-hidden for more)"), - cl::location(NormalPrinter)); + cl::location(NormalPrinter), cl::ValueDisallowed); cl::opt > HHOp("help-hidden", cl::desc("display all available options"), - cl::location(HiddenPrinter), cl::Hidden); + cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); } // End anonymous namespace diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 39bff48fd7..4eacedbdc8 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -510,9 +510,39 @@ void alias::printOptionInfo(unsigned GlobalWidth) const { // Parser Implementation code... // +// basic_parser implementation +// + +// Return the width of the option tag for printing... +unsigned basic_parser_impl::getOptionWidth(const Option &O) const { + unsigned Len = std::strlen(O.ArgStr); + if (const char *ValName = getValueName()) + Len += std::strlen(getValueStr(O, ValName))+3; + + return Len + 6; +} + +// printOptionInfo - Print out information about this option. The +// to-be-maintained width is specified. +// +void basic_parser_impl::printOptionInfo(const Option &O, + unsigned GlobalWidth) const { + cerr << " -" << O.ArgStr; + + if (const char *ValName = getValueName()) + cerr << "=<" << getValueStr(O, ValName) << ">"; + + cerr << string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; +} + + + + // parser implementation // -bool parser::parseImpl(Option &O, const string &Arg, bool &Value) { +bool parser::parse(Option &O, const char *ArgName, + const string &Arg, bool &Value) { if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; @@ -525,25 +555,10 @@ bool parser::parseImpl(Option &O, const string &Arg, bool &Value) { return false; } -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+6; -} - -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ - unsigned L = std::strlen(O.ArgStr); - cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') << " - " - << O.HelpStr << "\n"; -} - - - // parser implementation // -bool parser::parseImpl(Option &O, const string &Arg, int &Value) { +bool parser::parse(Option &O, const char *ArgName, + const string &Arg, int &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = (int)strtol(ArgStart, &End, 0); @@ -552,24 +567,9 @@ bool parser::parseImpl(Option &O, const string &Arg, int &Value) { return false; } -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "int"))+9; -} - -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, unsigned GlobalWidth) const{ - cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "int") << ">" - << string(GlobalWidth-getOptionWidth(O), ' ') << " - " - << O.HelpStr << "\n"; -} - - -// parser implementation +// parser/parser implementation // -bool parser::parseImpl(Option &O, const string &Arg, double &Value) { +static bool parseDouble(Option &O, const string &Arg, double &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = strtod(ArgStart, &End); @@ -578,39 +578,21 @@ bool parser::parseImpl(Option &O, const string &Arg, double &Value) { return false; } -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "number"))+9; +bool parser::parse(Option &O, const char *AN, + const std::string &Arg, double &Val) { + return parseDouble(O, Arg, Val); } -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, - unsigned GlobalWidth) const{ - cerr << " -" << O.ArgStr << "=<" << getValueStr(O, "number") << ">" - << string(GlobalWidth-getOptionWidth(O), ' ') - << " - " << O.HelpStr << "\n"; +bool parser::parse(Option &O, const char *AN, + const std::string &Arg, float &Val) { + double dVal; + if (parseDouble(O, Arg, dVal)) + return true; + Val = (float)dVal; + return false; } -// parser implementation -// - -// Return the width of the option tag for printing... -unsigned parser::getOptionWidth(const Option &O) const { - return std::strlen(O.ArgStr)+std::strlen(getValueStr(O, "string"))+9; -} - -// printOptionInfo - Print out information about this option. The -// to-be-maintained width is specified. -// -void parser::printOptionInfo(const Option &O, - unsigned GlobalWidth) const{ - cerr << " -" << O.ArgStr << " <" << getValueStr(O, "string") << ">" - << string(GlobalWidth-getOptionWidth(O), ' ') - << " - " << O.HelpStr << "\n"; -} // generic_parser_base implementation // @@ -729,18 +711,8 @@ public: if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; - for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { + for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) cerr << " " << PosOpts[i]->HelpStr; - switch (PosOpts[i]->getNumOccurancesFlag()) { - case Optional: cerr << "?"; break; - case ZeroOrMore: cerr << "*"; break; - case Required: break; - case OneOrMore: cerr << "+"; break; - case ConsumeAfter: - default: - assert(0 && "Unknown NumOccurances Flag Value!"); - } - } // Print the consume after option info if it exists... if (CAOpt) cerr << " " << CAOpt->HelpStr; @@ -771,10 +743,10 @@ HelpPrinter HiddenPrinter(true); cl::opt > HOp("help", cl::desc("display available options (--help-hidden for more)"), - cl::location(NormalPrinter)); + cl::location(NormalPrinter), cl::ValueDisallowed); cl::opt > HHOp("help-hidden", cl::desc("display all available options"), - cl::location(HiddenPrinter), cl::Hidden); + cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); } // End anonymous namespace -- cgit v1.2.3-70-g09d2 From ca6433f233b7ed432916ba07976f9a4e9e0767b0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 22 May 2003 20:06:43 +0000 Subject: Destroy using declarations git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6291 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 124 +++++++++++++++++------------------- support/lib/Support/CommandLine.cpp | 124 +++++++++++++++++------------------- 2 files changed, 120 insertions(+), 128 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 4eacedbdc8..a46c68c986 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -16,11 +16,6 @@ #include using namespace cl; -using std::map; -using std::pair; -using std::vector; -using std::string; -using std::cerr; //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery... @@ -29,27 +24,28 @@ using std::cerr; // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // -static map *CommandLineOptions = 0; -static map &getOpts() { - if (CommandLineOptions == 0) CommandLineOptions = new map(); +static std::map *CommandLineOptions = 0; +static std::map &getOpts() { + if (CommandLineOptions == 0) + CommandLineOptions = new std::map(); return *CommandLineOptions; } -static Option *getOption(const string &Str) { +static Option *getOption(const std::string &Str) { if (CommandLineOptions == 0) return 0; - map::iterator I = CommandLineOptions->find(Str); + std::map::iterator I = CommandLineOptions->find(Str); return I != CommandLineOptions->end() ? I->second : 0; } -static vector &getPositionalOpts() { - static vector Positional; +static std::vector &getPositionalOpts() { + static std::vector Positional; return Positional; } static void AddArgument(const char *ArgName, Option *Opt) { if (getOption(ArgName)) { - cerr << "CommandLine Error: Argument '" << ArgName - << "' defined more than once!\n"; + std::cerr << "CommandLine Error: Argument '" << ArgName + << "' defined more than once!\n"; } else { // Add argument to the argument map! getOpts()[ArgName] = Opt; @@ -89,18 +85,18 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, case ValueDisallowed: if (*Value != 0) return Handler->error(" does not allow a value! '" + - string(Value) + "' specified."); + std::string(Value) + "' specified."); break; case ValueOptional: break; - default: cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << "\n"; abort(); + default: std::cerr << "Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << "\n"; abort(); } // Run the handler now! return Handler->addOccurance(ArgName, Value); } -static bool ProvidePositionalOption(Option *Handler, string &Arg) { +static bool ProvidePositionalOption(Option *Handler, std::string &Arg) { int Dummy; return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy); } @@ -165,8 +161,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ProgramOverview = Overview; bool ErrorParsing = false; - map &Opts = getOpts(); - vector &PositionalOpts = getPositionalOpts(); + std::map &Opts = getOpts(); + std::vector &PositionalOpts = getPositionalOpts(); // Check out the positional arguments to collect information about them. unsigned NumPositionalRequired = 0; @@ -209,7 +205,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // PositionalVals - A vector of "positional" arguments we accumulate into to // processes at the end... // - vector PositionalVals; + std::vector PositionalVals; // Loop over all of the arguments... processing them. bool DashDashFound = false; // Have we read '--'? @@ -258,9 +254,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ++Value; // Advance to value... if (*ArgName != 0) { - string RealName(ArgName, ArgNameEnd); + std::string RealName(ArgName, ArgNameEnd); // Extract arg name part - map::iterator I = Opts.find(RealName); + std::map::iterator I = Opts.find(RealName); if (I == Opts.end() && !*Value && RealName.size() > 1) { // Check to see if this "option" is really a prefixed or grouped @@ -276,7 +272,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (PGOpt && PGOpt->getFormattingFlag() == cl::Prefix) { ArgNameEnd = ArgName+Length; Value = ArgNameEnd; - I = Opts.find(string(ArgName, ArgNameEnd)); + I = Opts.find(std::string(ArgName, ArgNameEnd)); assert(I->second == PGOpt); } else if (PGOpt) { // This must be a grouped option... handle all of them now... @@ -284,7 +280,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, do { // Move current arg name out of RealName into RealArgName... - string RealArgName(RealName.begin(), RealName.begin()+Length); + std::string RealArgName(RealName.begin(),RealName.begin()+Length); RealName.erase(RealName.begin(), RealName.begin()+Length); // Because ValueRequired is an invalid flag for grouped arguments, @@ -316,8 +312,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - cerr << "Unknown command line argument '" << argv[i] << "'. Try: " - << argv[0] << " --help'\n"; + std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: " + << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -327,9 +323,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - cerr << "Not enough positional command line arguments specified!\n"; - cerr << "Must specify at least " << NumPositionalRequired - << " positional arguments: See: " << argv[0] << " --help\n"; + std::cerr << "Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; @@ -387,7 +383,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } // Loop over args and make sure all required args are specified! - for (map::iterator I = Opts.begin(), + for (std::map::iterator I = Opts.begin(), E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurancesFlag()) { case Required: @@ -416,17 +412,17 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // -bool Option::error(string Message, const char *ArgName) { +bool Option::error(std::string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) - cerr << HelpStr; // Be nice for positional arguments + std::cerr << HelpStr; // Be nice for positional arguments else - cerr << "-" << ArgName; - cerr << " option" << Message << "\n"; + std::cerr << "-" << ArgName; + std::cerr << " option" << Message << "\n"; return true; } -bool Option::addOccurance(const char *ArgName, const string &Value) { +bool Option::addOccurance(const char *ArgName, const std::string &Value) { NumOccurances++; // Increment the number of times we have been seen switch (getNumOccurancesFlag()) { @@ -468,7 +464,7 @@ void Option::removeArgument(const char *ArgStr) { if (ArgStr[0]) { RemoveArgument(ArgStr, this); } else if (getFormattingFlag() == Positional) { - vector::iterator I = + std::vector::iterator I = std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); assert(I != getPositionalOpts().end() && "Arg not registered!"); getPositionalOpts().erase(I); @@ -500,8 +496,8 @@ unsigned alias::getOptionWidth() const { // Print out the option for the alias... void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " - << HelpStr << "\n"; + std::cerr << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " + << HelpStr << "\n"; } @@ -527,13 +523,13 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const { // void basic_parser_impl::printOptionInfo(const Option &O, unsigned GlobalWidth) const { - cerr << " -" << O.ArgStr; + std::cerr << " -" << O.ArgStr; if (const char *ValName = getValueName()) - cerr << "=<" << getValueStr(O, ValName) << ">"; + std::cerr << "=<" << getValueStr(O, ValName) << ">"; - cerr << string(GlobalWidth-getOptionWidth(O), ' ') << " - " - << O.HelpStr << "\n"; + std::cerr << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; } @@ -542,7 +538,7 @@ void basic_parser_impl::printOptionInfo(const Option &O, // parser implementation // bool parser::parse(Option &O, const char *ArgName, - const string &Arg, bool &Value) { + const std::string &Arg, bool &Value) { if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; @@ -558,7 +554,7 @@ bool parser::parse(Option &O, const char *ArgName, // parser implementation // bool parser::parse(Option &O, const char *ArgName, - const string &Arg, int &Value) { + const std::string &Arg, int &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = (int)strtol(ArgStart, &End, 0); @@ -569,7 +565,7 @@ bool parser::parse(Option &O, const char *ArgName, // parser/parser implementation // -static bool parseDouble(Option &O, const string &Arg, double &Value) { +static bool parseDouble(Option &O, const std::string &Arg, double &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = strtod(ArgStart, &End); @@ -602,7 +598,7 @@ bool parser::parse(Option &O, const char *AN, // unsigned generic_parser_base::findOption(const char *Name) { unsigned i = 0, e = getNumOptions(); - string N(Name); + std::string N(Name); while (i != e) if (getOption(i) == N) @@ -635,21 +631,21 @@ void generic_parser_base::printOptionInfo(const Option &O, unsigned GlobalWidth) const { if (O.hasArgStr()) { unsigned L = std::strlen(O.ArgStr); - cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') - << " - " << O.HelpStr << "\n"; + std::cerr << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') + << " - " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; - cerr << " =" << getOption(i) << string(NumSpaces, ' ') << " - " - << getDescription(i) << "\n"; + std::cerr << " =" << getOption(i) << std::string(NumSpaces, ' ') + << " - " << getDescription(i) << "\n"; } } else { if (O.HelpStr[0]) - cerr << " " << O.HelpStr << "\n"; + std::cerr << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned L = std::strlen(getOption(i)); - cerr << " -" << getOption(i) << string(GlobalWidth-L-8, ' ') << " - " - << getDescription(i) << "\n"; + std::cerr << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') + << " - " << getDescription(i) << "\n"; } } } @@ -666,10 +662,10 @@ class HelpPrinter { const bool ShowHidden; // isHidden/isReallyHidden - Predicates to be used to filter down arg lists. - inline static bool isHidden(pair &OptPair) { + inline static bool isHidden(std::pair &OptPair) { return OptPair.second->getOptionHiddenFlag() >= Hidden; } - inline static bool isReallyHidden(pair &OptPair) { + inline static bool isReallyHidden(std::pair &OptPair) { return OptPair.second->getOptionHiddenFlag() == ReallyHidden; } @@ -682,7 +678,7 @@ public: if (Value == false) return; // Copy Options into a vector so we can sort them as we like... - vector > Options; + std::vector > Options; copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden @@ -701,30 +697,30 @@ public: } if (ProgramOverview) - cerr << "OVERVIEW:" << ProgramOverview << "\n"; + std::cerr << "OVERVIEW:" << ProgramOverview << "\n"; - cerr << "USAGE: " << ProgramName << " [options]"; + std::cerr << "USAGE: " << ProgramName << " [options]"; // Print out the positional options... - vector &PosOpts = getPositionalOpts(); + std::vector &PosOpts = getPositionalOpts(); Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) - cerr << " " << PosOpts[i]->HelpStr; + std::cerr << " " << PosOpts[i]->HelpStr; // Print the consume after option info if it exists... - if (CAOpt) cerr << " " << CAOpt->HelpStr; + if (CAOpt) std::cerr << " " << CAOpt->HelpStr; - cerr << "\n\n"; + std::cerr << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; for (unsigned i = 0, e = Options.size(); i != e; ++i) MaxArgLen = std::max(MaxArgLen, Options[i].second->getOptionWidth()); - cerr << "OPTIONS:\n"; + std::cerr << "OPTIONS:\n"; for (unsigned i = 0, e = Options.size(); i != e; ++i) Options[i].second->printOptionInfo(MaxArgLen); diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 4eacedbdc8..a46c68c986 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -16,11 +16,6 @@ #include using namespace cl; -using std::map; -using std::pair; -using std::vector; -using std::string; -using std::cerr; //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery... @@ -29,27 +24,28 @@ using std::cerr; // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // -static map *CommandLineOptions = 0; -static map &getOpts() { - if (CommandLineOptions == 0) CommandLineOptions = new map(); +static std::map *CommandLineOptions = 0; +static std::map &getOpts() { + if (CommandLineOptions == 0) + CommandLineOptions = new std::map(); return *CommandLineOptions; } -static Option *getOption(const string &Str) { +static Option *getOption(const std::string &Str) { if (CommandLineOptions == 0) return 0; - map::iterator I = CommandLineOptions->find(Str); + std::map::iterator I = CommandLineOptions->find(Str); return I != CommandLineOptions->end() ? I->second : 0; } -static vector &getPositionalOpts() { - static vector Positional; +static std::vector &getPositionalOpts() { + static std::vector Positional; return Positional; } static void AddArgument(const char *ArgName, Option *Opt) { if (getOption(ArgName)) { - cerr << "CommandLine Error: Argument '" << ArgName - << "' defined more than once!\n"; + std::cerr << "CommandLine Error: Argument '" << ArgName + << "' defined more than once!\n"; } else { // Add argument to the argument map! getOpts()[ArgName] = Opt; @@ -89,18 +85,18 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, case ValueDisallowed: if (*Value != 0) return Handler->error(" does not allow a value! '" + - string(Value) + "' specified."); + std::string(Value) + "' specified."); break; case ValueOptional: break; - default: cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << "\n"; abort(); + default: std::cerr << "Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << "\n"; abort(); } // Run the handler now! return Handler->addOccurance(ArgName, Value); } -static bool ProvidePositionalOption(Option *Handler, string &Arg) { +static bool ProvidePositionalOption(Option *Handler, std::string &Arg) { int Dummy; return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy); } @@ -165,8 +161,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ProgramOverview = Overview; bool ErrorParsing = false; - map &Opts = getOpts(); - vector &PositionalOpts = getPositionalOpts(); + std::map &Opts = getOpts(); + std::vector &PositionalOpts = getPositionalOpts(); // Check out the positional arguments to collect information about them. unsigned NumPositionalRequired = 0; @@ -209,7 +205,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // PositionalVals - A vector of "positional" arguments we accumulate into to // processes at the end... // - vector PositionalVals; + std::vector PositionalVals; // Loop over all of the arguments... processing them. bool DashDashFound = false; // Have we read '--'? @@ -258,9 +254,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ++Value; // Advance to value... if (*ArgName != 0) { - string RealName(ArgName, ArgNameEnd); + std::string RealName(ArgName, ArgNameEnd); // Extract arg name part - map::iterator I = Opts.find(RealName); + std::map::iterator I = Opts.find(RealName); if (I == Opts.end() && !*Value && RealName.size() > 1) { // Check to see if this "option" is really a prefixed or grouped @@ -276,7 +272,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (PGOpt && PGOpt->getFormattingFlag() == cl::Prefix) { ArgNameEnd = ArgName+Length; Value = ArgNameEnd; - I = Opts.find(string(ArgName, ArgNameEnd)); + I = Opts.find(std::string(ArgName, ArgNameEnd)); assert(I->second == PGOpt); } else if (PGOpt) { // This must be a grouped option... handle all of them now... @@ -284,7 +280,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, do { // Move current arg name out of RealName into RealArgName... - string RealArgName(RealName.begin(), RealName.begin()+Length); + std::string RealArgName(RealName.begin(),RealName.begin()+Length); RealName.erase(RealName.begin(), RealName.begin()+Length); // Because ValueRequired is an invalid flag for grouped arguments, @@ -316,8 +312,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - cerr << "Unknown command line argument '" << argv[i] << "'. Try: " - << argv[0] << " --help'\n"; + std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: " + << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -327,9 +323,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - cerr << "Not enough positional command line arguments specified!\n"; - cerr << "Must specify at least " << NumPositionalRequired - << " positional arguments: See: " << argv[0] << " --help\n"; + std::cerr << "Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; @@ -387,7 +383,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } // Loop over args and make sure all required args are specified! - for (map::iterator I = Opts.begin(), + for (std::map::iterator I = Opts.begin(), E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurancesFlag()) { case Required: @@ -416,17 +412,17 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // -bool Option::error(string Message, const char *ArgName) { +bool Option::error(std::string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) - cerr << HelpStr; // Be nice for positional arguments + std::cerr << HelpStr; // Be nice for positional arguments else - cerr << "-" << ArgName; - cerr << " option" << Message << "\n"; + std::cerr << "-" << ArgName; + std::cerr << " option" << Message << "\n"; return true; } -bool Option::addOccurance(const char *ArgName, const string &Value) { +bool Option::addOccurance(const char *ArgName, const std::string &Value) { NumOccurances++; // Increment the number of times we have been seen switch (getNumOccurancesFlag()) { @@ -468,7 +464,7 @@ void Option::removeArgument(const char *ArgStr) { if (ArgStr[0]) { RemoveArgument(ArgStr, this); } else if (getFormattingFlag() == Positional) { - vector::iterator I = + std::vector::iterator I = std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); assert(I != getPositionalOpts().end() && "Arg not registered!"); getPositionalOpts().erase(I); @@ -500,8 +496,8 @@ unsigned alias::getOptionWidth() const { // Print out the option for the alias... void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - cerr << " -" << ArgStr << string(GlobalWidth-L-6, ' ') << " - " - << HelpStr << "\n"; + std::cerr << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " + << HelpStr << "\n"; } @@ -527,13 +523,13 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const { // void basic_parser_impl::printOptionInfo(const Option &O, unsigned GlobalWidth) const { - cerr << " -" << O.ArgStr; + std::cerr << " -" << O.ArgStr; if (const char *ValName = getValueName()) - cerr << "=<" << getValueStr(O, ValName) << ">"; + std::cerr << "=<" << getValueStr(O, ValName) << ">"; - cerr << string(GlobalWidth-getOptionWidth(O), ' ') << " - " - << O.HelpStr << "\n"; + std::cerr << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; } @@ -542,7 +538,7 @@ void basic_parser_impl::printOptionInfo(const Option &O, // parser implementation // bool parser::parse(Option &O, const char *ArgName, - const string &Arg, bool &Value) { + const std::string &Arg, bool &Value) { if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; @@ -558,7 +554,7 @@ bool parser::parse(Option &O, const char *ArgName, // parser implementation // bool parser::parse(Option &O, const char *ArgName, - const string &Arg, int &Value) { + const std::string &Arg, int &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = (int)strtol(ArgStart, &End, 0); @@ -569,7 +565,7 @@ bool parser::parse(Option &O, const char *ArgName, // parser/parser implementation // -static bool parseDouble(Option &O, const string &Arg, double &Value) { +static bool parseDouble(Option &O, const std::string &Arg, double &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = strtod(ArgStart, &End); @@ -602,7 +598,7 @@ bool parser::parse(Option &O, const char *AN, // unsigned generic_parser_base::findOption(const char *Name) { unsigned i = 0, e = getNumOptions(); - string N(Name); + std::string N(Name); while (i != e) if (getOption(i) == N) @@ -635,21 +631,21 @@ void generic_parser_base::printOptionInfo(const Option &O, unsigned GlobalWidth) const { if (O.hasArgStr()) { unsigned L = std::strlen(O.ArgStr); - cerr << " -" << O.ArgStr << string(GlobalWidth-L-6, ' ') - << " - " << O.HelpStr << "\n"; + std::cerr << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') + << " - " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; - cerr << " =" << getOption(i) << string(NumSpaces, ' ') << " - " - << getDescription(i) << "\n"; + std::cerr << " =" << getOption(i) << std::string(NumSpaces, ' ') + << " - " << getDescription(i) << "\n"; } } else { if (O.HelpStr[0]) - cerr << " " << O.HelpStr << "\n"; + std::cerr << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned L = std::strlen(getOption(i)); - cerr << " -" << getOption(i) << string(GlobalWidth-L-8, ' ') << " - " - << getDescription(i) << "\n"; + std::cerr << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') + << " - " << getDescription(i) << "\n"; } } } @@ -666,10 +662,10 @@ class HelpPrinter { const bool ShowHidden; // isHidden/isReallyHidden - Predicates to be used to filter down arg lists. - inline static bool isHidden(pair &OptPair) { + inline static bool isHidden(std::pair &OptPair) { return OptPair.second->getOptionHiddenFlag() >= Hidden; } - inline static bool isReallyHidden(pair &OptPair) { + inline static bool isReallyHidden(std::pair &OptPair) { return OptPair.second->getOptionHiddenFlag() == ReallyHidden; } @@ -682,7 +678,7 @@ public: if (Value == false) return; // Copy Options into a vector so we can sort them as we like... - vector > Options; + std::vector > Options; copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden @@ -701,30 +697,30 @@ public: } if (ProgramOverview) - cerr << "OVERVIEW:" << ProgramOverview << "\n"; + std::cerr << "OVERVIEW:" << ProgramOverview << "\n"; - cerr << "USAGE: " << ProgramName << " [options]"; + std::cerr << "USAGE: " << ProgramName << " [options]"; // Print out the positional options... - vector &PosOpts = getPositionalOpts(); + std::vector &PosOpts = getPositionalOpts(); Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) - cerr << " " << PosOpts[i]->HelpStr; + std::cerr << " " << PosOpts[i]->HelpStr; // Print the consume after option info if it exists... - if (CAOpt) cerr << " " << CAOpt->HelpStr; + if (CAOpt) std::cerr << " " << CAOpt->HelpStr; - cerr << "\n\n"; + std::cerr << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; for (unsigned i = 0, e = Options.size(); i != e; ++i) MaxArgLen = std::max(MaxArgLen, Options[i].second->getOptionWidth()); - cerr << "OPTIONS:\n"; + std::cerr << "OPTIONS:\n"; for (unsigned i = 0, e = Options.size(); i != e; ++i) Options[i].second->printOptionInfo(MaxArgLen); -- cgit v1.2.3-70-g09d2 From 72fb8e50820f6fcccae3a63935653ccd7b9ecf84 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 22 May 2003 20:26:17 +0000 Subject: Add new CommaSeparated option modifier git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6294 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 20 ++++++++++++++++++++ support/lib/Support/CommandLine.cpp | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index a46c68c986..a0eca7a8ed 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -318,6 +318,26 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, continue; } + // Check to see if this option accepts a comma separated list of values. If + // it does, we have to split up the value into multiple values... + if (Handler->getMiscFlags() & CommaSeparated) { + std::string Val(Value); + std::string::size_type Pos = Val.find(','); + + while (Pos != std::string::npos) { + // Process the portion before the comma... + ErrorParsing |= ProvideOption(Handler, ArgName, + std::string(Val.begin(), + Val.begin()+Pos).c_str(), + argc, argv, i); + // Erase the portion before the comma, AND the comma... + Val.erase(Val.begin(), Val.begin()+Pos+1); + Value += Pos+1; // Increment the original value pointer as well... + + // Check for another comma... + Pos = Val.find(','); + } + } ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); } diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index a46c68c986..a0eca7a8ed 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -318,6 +318,26 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, continue; } + // Check to see if this option accepts a comma separated list of values. If + // it does, we have to split up the value into multiple values... + if (Handler->getMiscFlags() & CommaSeparated) { + std::string Val(Value); + std::string::size_type Pos = Val.find(','); + + while (Pos != std::string::npos) { + // Process the portion before the comma... + ErrorParsing |= ProvideOption(Handler, ArgName, + std::string(Val.begin(), + Val.begin()+Pos).c_str(), + argc, argv, i); + // Erase the portion before the comma, AND the comma... + Val.erase(Val.begin(), Val.begin()+Pos+1); + Value += Pos+1; // Increment the original value pointer as well... + + // Check for another comma... + Pos = Val.find(','); + } + } ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); } -- cgit v1.2.3-70-g09d2 From d2a6fc397ee982936dee7dd5692b1481bcd9fe8f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 28 Jun 2003 15:47:20 +0000 Subject: Add support for 'unsigned' command line arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6928 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 15 +++++++++++++++ include/llvm/Support/CommandLine.h | 15 +++++++++++++++ lib/Support/CommandLine.cpp | 15 +++++++++++++-- support/lib/Support/CommandLine.cpp | 15 +++++++++++++-- 4 files changed, 56 insertions(+), 4 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index ed2559bd2b..97b223c738 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -515,6 +515,21 @@ struct parser : public basic_parser { }; +//-------------------------------------------------- +// parser +// +template<> +struct parser : public basic_parser { + + // parse - Return true on error. + bool parse(Option &O, const char *ArgName, const std::string &Arg, + unsigned &Val); + + // getValueName - Overload in subclass to provide a better default value. + virtual const char *getValueName() const { return "uint"; } +}; + + //-------------------------------------------------- // parser // diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index ed2559bd2b..97b223c738 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -515,6 +515,21 @@ struct parser : public basic_parser { }; +//-------------------------------------------------- +// parser +// +template<> +struct parser : public basic_parser { + + // parse - Return true on error. + bool parse(Option &O, const char *ArgName, const std::string &Arg, + unsigned &Val); + + // getValueName - Overload in subclass to provide a better default value. + virtual const char *getValueName() const { return "uint"; } +}; + + //-------------------------------------------------- // parser // diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index a0eca7a8ed..bbf996af7b 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -575,14 +575,25 @@ bool parser::parse(Option &O, const char *ArgName, // bool parser::parse(Option &O, const char *ArgName, const std::string &Arg, int &Value) { - const char *ArgStart = Arg.c_str(); char *End; - Value = (int)strtol(ArgStart, &End, 0); + Value = (int)strtol(Arg.c_str(), &End, 0); if (*End != 0) return O.error(": '" + Arg + "' value invalid for integer argument!"); return false; } +// parser implementation +// +bool parser::parse(Option &O, const char *ArgName, + const std::string &Arg, unsigned &Value) { + char *End; + long long int V = strtoll(Arg.c_str(), &End, 0); + Value = (unsigned)V; + if (*End != 0 || V < 0 || Value != V) + return O.error(": '" + Arg + "' value invalid for uint argument!"); + return false; +} + // parser/parser implementation // static bool parseDouble(Option &O, const std::string &Arg, double &Value) { diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index a0eca7a8ed..bbf996af7b 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -575,14 +575,25 @@ bool parser::parse(Option &O, const char *ArgName, // bool parser::parse(Option &O, const char *ArgName, const std::string &Arg, int &Value) { - const char *ArgStart = Arg.c_str(); char *End; - Value = (int)strtol(ArgStart, &End, 0); + Value = (int)strtol(Arg.c_str(), &End, 0); if (*End != 0) return O.error(": '" + Arg + "' value invalid for integer argument!"); return false; } +// parser implementation +// +bool parser::parse(Option &O, const char *ArgName, + const std::string &Arg, unsigned &Value) { + char *End; + long long int V = strtoll(Arg.c_str(), &End, 0); + Value = (unsigned)V; + if (*End != 0 || V < 0 || Value != V) + return O.error(": '" + Arg + "' value invalid for uint argument!"); + return false; +} + // parser/parser implementation // static bool parseDouble(Option &O, const std::string &Arg, double &Value) { -- cgit v1.2.3-70-g09d2 From dd6cb6a43b78732f1a136583ccca4e715bae7d71 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Thu, 10 Jul 2003 16:49:51 +0000 Subject: `Occurrence' has no `a' and the `r' is doubled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7140 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 44 ++++++++++++++++++------------------- include/llvm/Support/CommandLine.h | 44 ++++++++++++++++++------------------- lib/Support/CommandLine.cpp | 42 +++++++++++++++++------------------ support/lib/Support/CommandLine.cpp | 42 +++++++++++++++++------------------ 4 files changed, 86 insertions(+), 86 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index eb1aa18a0b..db31e25c85 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -34,7 +34,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Flags permitted to be passed to command line arguments // -enum NumOccurances { // Flags for the number of occurances allowed... +enum NumOccurrences { // Flags for the number of occurances allowed... Optional = 0x01, // Zero or One occurance ZeroOrMore = 0x02, // Zero or more occurances allowed Required = 0x03, // One occurance required @@ -49,7 +49,7 @@ enum NumOccurances { // Flags for the number of occurances allowed... // ConsumeAfter = 0x05, - OccurancesMask = 0x07, + OccurrencesMask = 0x07, }; enum ValueExpected { // Is a value required for the option? @@ -104,13 +104,13 @@ class Option { friend void cl::ParseCommandLineOptions(int &, char **, const char *, int); friend class alias; - // handleOccurances - Overriden by subclasses to handle the value passed into + // handleOccurrences - Overriden by subclasses to handle the value passed into // an argument. Should return true if there was an error processing the // argument and the program should exit. // - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0; + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) = 0; - virtual enum NumOccurances getNumOccurancesFlagDefault() const { + virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { return Optional; } virtual enum ValueExpected getValueExpectedFlagDefault() const { @@ -123,16 +123,16 @@ class Option { return NormalFormatting; } - int NumOccurances; // The number of times specified + int NumOccurrences; // The number of times specified int Flags; // Flags for the argument public: const char *ArgStr; // The argument string itself (ex: "help", "o") const char *HelpStr; // The descriptive text message for --help const char *ValueStr; // String describing what the value of this option is - inline enum NumOccurances getNumOccurancesFlag() const { - int NO = Flags & OccurancesMask; - return NO ? (enum NumOccurances)NO : getNumOccurancesFlagDefault(); + inline enum NumOccurrences getNumOccurrencesFlag() const { + int NO = Flags & OccurrencesMask; + return NO ? (enum NumOccurrences)NO : getNumOccurrencesFlagDefault(); } inline enum ValueExpected getValueExpectedFlag() const { int VE = Flags & ValueMask; @@ -169,15 +169,15 @@ public: Flags |= Flag; } - void setNumOccurancesFlag(enum NumOccurances Val) { - setFlag(Val, OccurancesMask); + void setNumOccurrencesFlag(enum NumOccurrences Val) { + setFlag(Val, OccurrencesMask); } void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); } void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } void setMiscFlag(enum MiscFlags M) { setFlag(M, M); } protected: - Option() : NumOccurances(0), Flags(0), + Option() : NumOccurrences(0), Flags(0), ArgStr(""), HelpStr(""), ValueStr("") {} public: @@ -195,15 +195,15 @@ public: // virtual void printOptionInfo(unsigned GlobalWidth) const = 0; - // addOccurance - Wrapper around handleOccurance that enforces Flags + // addOccurrence - Wrapper around handleOccurrence that enforces Flags // - bool addOccurance(const char *ArgName, const std::string &Value); + bool addOccurrence(const char *ArgName, const std::string &Value); // Prints option name followed by message. Always returns true. bool error(std::string Message, const char *ArgName = 0); public: - inline int getNumOccurances() const { return NumOccurances; } + inline int getNumOccurrences() const { return NumOccurrences; } virtual ~Option() {} }; @@ -598,8 +598,8 @@ template<> struct applicator { static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } }; -template<> struct applicator { - static void opt(NumOccurances NO, Option &O) { O.setNumOccurancesFlag(NO); } +template<> struct applicator { + static void opt(NumOccurrences NO, Option &O) { O.setNumOccurrencesFlag(NO); } }; template<> struct applicator { static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); } @@ -700,7 +700,7 @@ class opt : public Option, ::boost::is_class::value> { ParserClass Parser; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse error! @@ -846,14 +846,14 @@ template { ParserClass Parser; - virtual enum NumOccurances getNumOccurancesFlagDefault() const { + virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { return ZeroOrMore; } virtual enum ValueExpected getValueExpectedFlagDefault() const { return Parser.getValueExpectedFlagDefault(); } - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse Error! @@ -943,8 +943,8 @@ public: class alias : public Option { Option *AliasFor; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { - return AliasFor->handleOccurance(AliasFor->ArgStr, Arg); + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { + return AliasFor->handleOccurrence(AliasFor->ArgStr, Arg); } // Aliases default to be hidden... virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index eb1aa18a0b..db31e25c85 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -34,7 +34,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Flags permitted to be passed to command line arguments // -enum NumOccurances { // Flags for the number of occurances allowed... +enum NumOccurrences { // Flags for the number of occurances allowed... Optional = 0x01, // Zero or One occurance ZeroOrMore = 0x02, // Zero or more occurances allowed Required = 0x03, // One occurance required @@ -49,7 +49,7 @@ enum NumOccurances { // Flags for the number of occurances allowed... // ConsumeAfter = 0x05, - OccurancesMask = 0x07, + OccurrencesMask = 0x07, }; enum ValueExpected { // Is a value required for the option? @@ -104,13 +104,13 @@ class Option { friend void cl::ParseCommandLineOptions(int &, char **, const char *, int); friend class alias; - // handleOccurances - Overriden by subclasses to handle the value passed into + // handleOccurrences - Overriden by subclasses to handle the value passed into // an argument. Should return true if there was an error processing the // argument and the program should exit. // - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) = 0; + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) = 0; - virtual enum NumOccurances getNumOccurancesFlagDefault() const { + virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { return Optional; } virtual enum ValueExpected getValueExpectedFlagDefault() const { @@ -123,16 +123,16 @@ class Option { return NormalFormatting; } - int NumOccurances; // The number of times specified + int NumOccurrences; // The number of times specified int Flags; // Flags for the argument public: const char *ArgStr; // The argument string itself (ex: "help", "o") const char *HelpStr; // The descriptive text message for --help const char *ValueStr; // String describing what the value of this option is - inline enum NumOccurances getNumOccurancesFlag() const { - int NO = Flags & OccurancesMask; - return NO ? (enum NumOccurances)NO : getNumOccurancesFlagDefault(); + inline enum NumOccurrences getNumOccurrencesFlag() const { + int NO = Flags & OccurrencesMask; + return NO ? (enum NumOccurrences)NO : getNumOccurrencesFlagDefault(); } inline enum ValueExpected getValueExpectedFlag() const { int VE = Flags & ValueMask; @@ -169,15 +169,15 @@ public: Flags |= Flag; } - void setNumOccurancesFlag(enum NumOccurances Val) { - setFlag(Val, OccurancesMask); + void setNumOccurrencesFlag(enum NumOccurrences Val) { + setFlag(Val, OccurrencesMask); } void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); } void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } void setMiscFlag(enum MiscFlags M) { setFlag(M, M); } protected: - Option() : NumOccurances(0), Flags(0), + Option() : NumOccurrences(0), Flags(0), ArgStr(""), HelpStr(""), ValueStr("") {} public: @@ -195,15 +195,15 @@ public: // virtual void printOptionInfo(unsigned GlobalWidth) const = 0; - // addOccurance - Wrapper around handleOccurance that enforces Flags + // addOccurrence - Wrapper around handleOccurrence that enforces Flags // - bool addOccurance(const char *ArgName, const std::string &Value); + bool addOccurrence(const char *ArgName, const std::string &Value); // Prints option name followed by message. Always returns true. bool error(std::string Message, const char *ArgName = 0); public: - inline int getNumOccurances() const { return NumOccurances; } + inline int getNumOccurrences() const { return NumOccurrences; } virtual ~Option() {} }; @@ -598,8 +598,8 @@ template<> struct applicator { static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } }; -template<> struct applicator { - static void opt(NumOccurances NO, Option &O) { O.setNumOccurancesFlag(NO); } +template<> struct applicator { + static void opt(NumOccurrences NO, Option &O) { O.setNumOccurrencesFlag(NO); } }; template<> struct applicator { static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); } @@ -700,7 +700,7 @@ class opt : public Option, ::boost::is_class::value> { ParserClass Parser; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse error! @@ -846,14 +846,14 @@ template { ParserClass Parser; - virtual enum NumOccurances getNumOccurancesFlagDefault() const { + virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { return ZeroOrMore; } virtual enum ValueExpected getValueExpectedFlagDefault() const { return Parser.getValueExpectedFlagDefault(); } - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse Error! @@ -943,8 +943,8 @@ public: class alias : public Option { Option *AliasFor; - virtual bool handleOccurance(const char *ArgName, const std::string &Arg) { - return AliasFor->handleOccurance(AliasFor->ArgStr, Arg); + virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { + return AliasFor->handleOccurrence(AliasFor->ArgStr, Arg); } // Aliases default to be hidden... virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index bbf996af7b..84aaeadd43 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -93,7 +93,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, } // Run the handler now! - return Handler->addOccurance(ArgName, Value); + return Handler->addOccurrence(ArgName, Value); } static bool ProvidePositionalOption(Option *Handler, std::string &Arg) { @@ -143,13 +143,13 @@ static Option *getOptionPred(std::string Name, unsigned &Length, } static bool RequiresValue(const Option *O) { - return O->getNumOccurancesFlag() == cl::Required || - O->getNumOccurancesFlag() == cl::OneOrMore; + return O->getNumOccurrencesFlag() == cl::Required || + O->getNumOccurrencesFlag() == cl::OneOrMore; } static bool EatsUnboundedNumberOfValues(const Option *O) { - return O->getNumOccurancesFlag() == cl::ZeroOrMore || - O->getNumOccurancesFlag() == cl::OneOrMore; + return O->getNumOccurrencesFlag() == cl::ZeroOrMore || + O->getNumOccurrencesFlag() == cl::OneOrMore; } void cl::ParseCommandLineOptions(int &argc, char **argv, @@ -168,7 +168,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, unsigned NumPositionalRequired = 0; Option *ConsumeAfterOpt = 0; if (!PositionalOpts.empty()) { - if (PositionalOpts[0]->getNumOccurancesFlag() == cl::ConsumeAfter) { + if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) { assert(PositionalOpts.size() > 1 && "Cannot specify cl::ConsumeAfter without a positional argument!"); ConsumeAfterOpt = PositionalOpts[0]; @@ -362,9 +362,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // do not give it values that others need. 'Done' controls whether the // option even _WANTS_ any more. // - bool Done = PositionalOpts[i]->getNumOccurancesFlag() == cl::Required; + bool Done = PositionalOpts[i]->getNumOccurrencesFlag() == cl::Required; while (NumVals-ValNo > NumPositionalRequired && !Done) { - switch (PositionalOpts[i]->getNumOccurancesFlag()) { + switch (PositionalOpts[i]->getNumOccurrencesFlag()) { case cl::Optional: Done = true; // Optional arguments want _at most_ one value // FALL THROUGH @@ -373,7 +373,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); break; default: - assert(0 && "Internal error, unexpected NumOccurances flag in " + assert(0 && "Internal error, unexpected NumOccurrences flag in " "positional argument processing!"); } } @@ -405,10 +405,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Loop over args and make sure all required args are specified! for (std::map::iterator I = Opts.begin(), E = Opts.end(); I != E; ++I) { - switch (I->second->getNumOccurancesFlag()) { + switch (I->second->getNumOccurrencesFlag()) { case Required: case OneOrMore: - if (I->second->getNumOccurances() == 0) { + if (I->second->getNumOccurrences() == 0) { I->second->error(" must be specified at least once!"); ErrorParsing = true; } @@ -442,16 +442,16 @@ bool Option::error(std::string Message, const char *ArgName) { return true; } -bool Option::addOccurance(const char *ArgName, const std::string &Value) { - NumOccurances++; // Increment the number of times we have been seen +bool Option::addOccurrence(const char *ArgName, const std::string &Value) { + NumOccurrences++; // Increment the number of times we have been seen - switch (getNumOccurancesFlag()) { + switch (getNumOccurrencesFlag()) { case Optional: - if (NumOccurances > 1) + if (NumOccurrences > 1) return error(": may only occur zero or one times!", ArgName); break; case Required: - if (NumOccurances > 1) + if (NumOccurrences > 1) return error(": must occur exactly one time!", ArgName); // Fall through case OneOrMore: @@ -460,7 +460,7 @@ bool Option::addOccurance(const char *ArgName, const std::string &Value) { default: return error(": bad num occurances flag value!"); } - return handleOccurance(ArgName, Value); + return handleOccurrence(ArgName, Value); } // addArgument - Tell the system that this Option subclass will handle all @@ -471,9 +471,9 @@ void Option::addArgument(const char *ArgStr) { AddArgument(ArgStr, this); else if (getFormattingFlag() == Positional) getPositionalOpts().push_back(this); - else if (getNumOccurancesFlag() == ConsumeAfter) { + else if (getNumOccurrencesFlag() == ConsumeAfter) { assert((getPositionalOpts().empty() || - getPositionalOpts().front()->getNumOccurancesFlag() != ConsumeAfter) + getPositionalOpts().front()->getNumOccurrencesFlag() != ConsumeAfter) && "Cannot specify more than one option with cl::ConsumeAfter " "specified!"); getPositionalOpts().insert(getPositionalOpts().begin(), this); @@ -488,7 +488,7 @@ void Option::removeArgument(const char *ArgStr) { std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); assert(I != getPositionalOpts().end() && "Arg not registered!"); getPositionalOpts().erase(I); - } else if (getNumOccurancesFlag() == ConsumeAfter) { + } else if (getNumOccurrencesFlag() == ConsumeAfter) { assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this && "Arg not registered correctly!"); getPositionalOpts().erase(getPositionalOpts().begin()); @@ -735,7 +735,7 @@ public: // Print out the positional options... std::vector &PosOpts = getPositionalOpts(); Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... - if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) + if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index bbf996af7b..84aaeadd43 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -93,7 +93,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, } // Run the handler now! - return Handler->addOccurance(ArgName, Value); + return Handler->addOccurrence(ArgName, Value); } static bool ProvidePositionalOption(Option *Handler, std::string &Arg) { @@ -143,13 +143,13 @@ static Option *getOptionPred(std::string Name, unsigned &Length, } static bool RequiresValue(const Option *O) { - return O->getNumOccurancesFlag() == cl::Required || - O->getNumOccurancesFlag() == cl::OneOrMore; + return O->getNumOccurrencesFlag() == cl::Required || + O->getNumOccurrencesFlag() == cl::OneOrMore; } static bool EatsUnboundedNumberOfValues(const Option *O) { - return O->getNumOccurancesFlag() == cl::ZeroOrMore || - O->getNumOccurancesFlag() == cl::OneOrMore; + return O->getNumOccurrencesFlag() == cl::ZeroOrMore || + O->getNumOccurrencesFlag() == cl::OneOrMore; } void cl::ParseCommandLineOptions(int &argc, char **argv, @@ -168,7 +168,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, unsigned NumPositionalRequired = 0; Option *ConsumeAfterOpt = 0; if (!PositionalOpts.empty()) { - if (PositionalOpts[0]->getNumOccurancesFlag() == cl::ConsumeAfter) { + if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) { assert(PositionalOpts.size() > 1 && "Cannot specify cl::ConsumeAfter without a positional argument!"); ConsumeAfterOpt = PositionalOpts[0]; @@ -362,9 +362,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // do not give it values that others need. 'Done' controls whether the // option even _WANTS_ any more. // - bool Done = PositionalOpts[i]->getNumOccurancesFlag() == cl::Required; + bool Done = PositionalOpts[i]->getNumOccurrencesFlag() == cl::Required; while (NumVals-ValNo > NumPositionalRequired && !Done) { - switch (PositionalOpts[i]->getNumOccurancesFlag()) { + switch (PositionalOpts[i]->getNumOccurrencesFlag()) { case cl::Optional: Done = true; // Optional arguments want _at most_ one value // FALL THROUGH @@ -373,7 +373,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); break; default: - assert(0 && "Internal error, unexpected NumOccurances flag in " + assert(0 && "Internal error, unexpected NumOccurrences flag in " "positional argument processing!"); } } @@ -405,10 +405,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Loop over args and make sure all required args are specified! for (std::map::iterator I = Opts.begin(), E = Opts.end(); I != E; ++I) { - switch (I->second->getNumOccurancesFlag()) { + switch (I->second->getNumOccurrencesFlag()) { case Required: case OneOrMore: - if (I->second->getNumOccurances() == 0) { + if (I->second->getNumOccurrences() == 0) { I->second->error(" must be specified at least once!"); ErrorParsing = true; } @@ -442,16 +442,16 @@ bool Option::error(std::string Message, const char *ArgName) { return true; } -bool Option::addOccurance(const char *ArgName, const std::string &Value) { - NumOccurances++; // Increment the number of times we have been seen +bool Option::addOccurrence(const char *ArgName, const std::string &Value) { + NumOccurrences++; // Increment the number of times we have been seen - switch (getNumOccurancesFlag()) { + switch (getNumOccurrencesFlag()) { case Optional: - if (NumOccurances > 1) + if (NumOccurrences > 1) return error(": may only occur zero or one times!", ArgName); break; case Required: - if (NumOccurances > 1) + if (NumOccurrences > 1) return error(": must occur exactly one time!", ArgName); // Fall through case OneOrMore: @@ -460,7 +460,7 @@ bool Option::addOccurance(const char *ArgName, const std::string &Value) { default: return error(": bad num occurances flag value!"); } - return handleOccurance(ArgName, Value); + return handleOccurrence(ArgName, Value); } // addArgument - Tell the system that this Option subclass will handle all @@ -471,9 +471,9 @@ void Option::addArgument(const char *ArgStr) { AddArgument(ArgStr, this); else if (getFormattingFlag() == Positional) getPositionalOpts().push_back(this); - else if (getNumOccurancesFlag() == ConsumeAfter) { + else if (getNumOccurrencesFlag() == ConsumeAfter) { assert((getPositionalOpts().empty() || - getPositionalOpts().front()->getNumOccurancesFlag() != ConsumeAfter) + getPositionalOpts().front()->getNumOccurrencesFlag() != ConsumeAfter) && "Cannot specify more than one option with cl::ConsumeAfter " "specified!"); getPositionalOpts().insert(getPositionalOpts().begin(), this); @@ -488,7 +488,7 @@ void Option::removeArgument(const char *ArgStr) { std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); assert(I != getPositionalOpts().end() && "Arg not registered!"); getPositionalOpts().erase(I); - } else if (getNumOccurancesFlag() == ConsumeAfter) { + } else if (getNumOccurrencesFlag() == ConsumeAfter) { assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this && "Arg not registered correctly!"); getPositionalOpts().erase(getPositionalOpts().begin()); @@ -735,7 +735,7 @@ public: // Print out the positional options... std::vector &PosOpts = getPositionalOpts(); Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... - if (!PosOpts.empty() && PosOpts[0]->getNumOccurancesFlag() == ConsumeAfter) + if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) -- cgit v1.2.3-70-g09d2 From b5c520bfb6505caaa6ad8468b372530d44c8b253 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Thu, 10 Jul 2003 17:05:26 +0000 Subject: Lowercase versions of `occurrence' need to be spelled correctly, too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7142 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 12 ++++++------ include/llvm/Support/CommandLine.h | 12 ++++++------ lib/Support/CommandLine.cpp | 30 +++++++++++++++--------------- support/lib/Support/CommandLine.cpp | 30 +++++++++++++++--------------- 4 files changed, 42 insertions(+), 42 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index db31e25c85..b53366399a 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -34,11 +34,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Flags permitted to be passed to command line arguments // -enum NumOccurrences { // Flags for the number of occurances allowed... - Optional = 0x01, // Zero or One occurance - ZeroOrMore = 0x02, // Zero or more occurances allowed - Required = 0x03, // One occurance required - OneOrMore = 0x04, // One or more occurances required +enum NumOccurrences { // Flags for the number of occurrences allowed + Optional = 0x01, // Zero or One occurrence + ZeroOrMore = 0x02, // Zero or more occurrences allowed + Required = 0x03, // One occurrence required + OneOrMore = 0x04, // One or more occurrences required // ConsumeAfter - Indicates that this option is fed anything that follows the // last positional argument required by the application (it is an error if @@ -182,7 +182,7 @@ protected: public: // addArgument - Tell the system that this Option subclass will handle all - // occurances of -ArgStr on the command line. + // occurrences of -ArgStr on the command line. // void addArgument(const char *ArgStr); void removeArgument(const char *ArgStr); diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index db31e25c85..b53366399a 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -34,11 +34,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Flags permitted to be passed to command line arguments // -enum NumOccurrences { // Flags for the number of occurances allowed... - Optional = 0x01, // Zero or One occurance - ZeroOrMore = 0x02, // Zero or more occurances allowed - Required = 0x03, // One occurance required - OneOrMore = 0x04, // One or more occurances required +enum NumOccurrences { // Flags for the number of occurrences allowed + Optional = 0x01, // Zero or One occurrence + ZeroOrMore = 0x02, // Zero or more occurrences allowed + Required = 0x03, // One occurrence required + OneOrMore = 0x04, // One or more occurrences required // ConsumeAfter - Indicates that this option is fed anything that follows the // last positional argument required by the application (it is an error if @@ -182,7 +182,7 @@ protected: public: // addArgument - Tell the system that this Option subclass will handle all - // occurances of -ArgStr on the command line. + // occurrences of -ArgStr on the command line. // void addArgument(const char *ArgStr); void removeArgument(const char *ArgStr); diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 84aaeadd43..fa67a8a4d7 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -247,18 +247,18 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *ArgNameEnd = ArgName; while (*ArgNameEnd && *ArgNameEnd != '=') - ++ArgNameEnd; // Scan till end of argument name... + ++ArgNameEnd; // Scan till end of argument name... Value = ArgNameEnd; if (*Value) // If we have an equals sign... - ++Value; // Advance to value... + ++Value; // Advance to value... if (*ArgName != 0) { - std::string RealName(ArgName, ArgNameEnd); - // Extract arg name part + std::string RealName(ArgName, ArgNameEnd); + // Extract arg name part std::map::iterator I = Opts.find(RealName); - if (I == Opts.end() && !*Value && RealName.size() > 1) { + if (I == Opts.end() && !*Value && RealName.size() > 1) { // Check to see if this "option" is really a prefixed or grouped // argument... // @@ -283,13 +283,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, std::string RealArgName(RealName.begin(),RealName.begin()+Length); RealName.erase(RealName.begin(), RealName.begin()+Length); - // Because ValueRequired is an invalid flag for grouped arguments, - // we don't need to pass argc/argv in... - // + // Because ValueRequired is an invalid flag for grouped arguments, + // we don't need to pass argc/argv in... + // assert(PGOpt->getValueExpectedFlag() != cl::ValueRequired && "Option can not be cl::Grouping AND cl::ValueRequired!"); int Dummy; - ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", + ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", 0, 0, Dummy); // Get the next grouping option... @@ -305,7 +305,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // I = Opts.end(); } - } + } Handler = I != Opts.end() ? I->second : 0; } @@ -404,12 +404,12 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Loop over args and make sure all required args are specified! for (std::map::iterator I = Opts.begin(), - E = Opts.end(); I != E; ++I) { + E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurrencesFlag()) { case Required: case OneOrMore: if (I->second->getNumOccurrences() == 0) { - I->second->error(" must be specified at least once!"); + I->second->error(" must be specified at least once!"); ErrorParsing = true; } // Fall through @@ -457,14 +457,14 @@ bool Option::addOccurrence(const char *ArgName, const std::string &Value) { case OneOrMore: case ZeroOrMore: case ConsumeAfter: break; - default: return error(": bad num occurances flag value!"); + default: return error(": bad num occurrences flag value!"); } return handleOccurrence(ArgName, Value); } // addArgument - Tell the system that this Option subclass will handle all -// occurances of -ArgStr on the command line. +// occurrences of -ArgStr on the command line. // void Option::addArgument(const char *ArgStr) { if (ArgStr[0]) @@ -715,7 +715,7 @@ public: // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden Options.erase(std::remove_if(Options.begin(), Options.end(), std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), - Options.end()); + Options.end()); // Eliminate duplicate entries in table (from enum flags options, f.e.) { // Give OptionSet a scope diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 84aaeadd43..fa67a8a4d7 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -247,18 +247,18 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *ArgNameEnd = ArgName; while (*ArgNameEnd && *ArgNameEnd != '=') - ++ArgNameEnd; // Scan till end of argument name... + ++ArgNameEnd; // Scan till end of argument name... Value = ArgNameEnd; if (*Value) // If we have an equals sign... - ++Value; // Advance to value... + ++Value; // Advance to value... if (*ArgName != 0) { - std::string RealName(ArgName, ArgNameEnd); - // Extract arg name part + std::string RealName(ArgName, ArgNameEnd); + // Extract arg name part std::map::iterator I = Opts.find(RealName); - if (I == Opts.end() && !*Value && RealName.size() > 1) { + if (I == Opts.end() && !*Value && RealName.size() > 1) { // Check to see if this "option" is really a prefixed or grouped // argument... // @@ -283,13 +283,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, std::string RealArgName(RealName.begin(),RealName.begin()+Length); RealName.erase(RealName.begin(), RealName.begin()+Length); - // Because ValueRequired is an invalid flag for grouped arguments, - // we don't need to pass argc/argv in... - // + // Because ValueRequired is an invalid flag for grouped arguments, + // we don't need to pass argc/argv in... + // assert(PGOpt->getValueExpectedFlag() != cl::ValueRequired && "Option can not be cl::Grouping AND cl::ValueRequired!"); int Dummy; - ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", + ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", 0, 0, Dummy); // Get the next grouping option... @@ -305,7 +305,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // I = Opts.end(); } - } + } Handler = I != Opts.end() ? I->second : 0; } @@ -404,12 +404,12 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Loop over args and make sure all required args are specified! for (std::map::iterator I = Opts.begin(), - E = Opts.end(); I != E; ++I) { + E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurrencesFlag()) { case Required: case OneOrMore: if (I->second->getNumOccurrences() == 0) { - I->second->error(" must be specified at least once!"); + I->second->error(" must be specified at least once!"); ErrorParsing = true; } // Fall through @@ -457,14 +457,14 @@ bool Option::addOccurrence(const char *ArgName, const std::string &Value) { case OneOrMore: case ZeroOrMore: case ConsumeAfter: break; - default: return error(": bad num occurances flag value!"); + default: return error(": bad num occurrences flag value!"); } return handleOccurrence(ArgName, Value); } // addArgument - Tell the system that this Option subclass will handle all -// occurances of -ArgStr on the command line. +// occurrences of -ArgStr on the command line. // void Option::addArgument(const char *ArgStr) { if (ArgStr[0]) @@ -715,7 +715,7 @@ public: // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden Options.erase(std::remove_if(Options.begin(), Options.end(), std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), - Options.end()); + Options.end()); // Eliminate duplicate entries in table (from enum flags options, f.e.) { // Give OptionSet a scope -- cgit v1.2.3-70-g09d2 From 1115e0483fc6da16d52382f159005baddf028063 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Thu, 10 Jul 2003 21:38:28 +0000 Subject: Fixed grammatical error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7160 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 +- support/lib/Support/CommandLine.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index fa67a8a4d7..f508483d69 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -216,7 +216,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check to see if this is a positional argument. This argument is // considered to be positional if it doesn't start with '-', if it is "-" - // itself, or if we have see "--" already. + // itself, or if we have seen "--" already. // if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) { // Positional argument! diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index fa67a8a4d7..f508483d69 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -216,7 +216,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check to see if this is a positional argument. This argument is // considered to be positional if it doesn't start with '-', if it is "-" - // itself, or if we have see "--" already. + // itself, or if we have seen "--" already. // if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) { // Positional argument! -- cgit v1.2.3-70-g09d2 From 9cf3d4770230238f2f395514bf04e0e64352d261 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 30 Jul 2003 17:34:02 +0000 Subject: Add support for "named positional arguments" git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7421 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 49 +++++++++++++++++++++++++------------ support/lib/Support/CommandLine.cpp | 49 +++++++++++++++++++++++++------------ 2 files changed, 68 insertions(+), 30 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index f508483d69..4e3a92fec2 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -96,9 +96,9 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->addOccurrence(ArgName, Value); } -static bool ProvidePositionalOption(Option *Handler, std::string &Arg) { +static bool ProvidePositionalOption(Option *Handler, const std::string &Arg) { int Dummy; - return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy); + return ProvideOption(Handler, Handler->ArgStr, Arg.c_str(), 0, 0, Dummy); } @@ -189,9 +189,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, Opt->error(" error - this positional option will never be matched, " "because it does not Require a value, and a " "cl::ConsumeAfter option is active!"); - } else if (UnboundedFound) { // This option does not "require" a value... - // Make sure this option is not specified after an option that eats all - // extra arguments, or this one will never get any! + } else if (UnboundedFound && !Opt->ArgStr[0]) { + // This option does not "require" a value... Make sure this option is + // not specified after an option that eats all extra arguments, or this + // one will never get any! // ErrorParsing |= Opt->error(" error - option can never match, because " "another positional argument will match an " @@ -207,6 +208,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // std::vector PositionalVals; + // If the program has named positional arguments, and the name has been run + // across, keep track of which positional argument was named. Otherwise put + // the positional args into the PositionalVals list... + Option *ActivePositionalArg = 0; + // Loop over all of the arguments... processing them. bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { @@ -220,7 +226,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) { // Positional argument! - if (!PositionalOpts.empty()) { + if (ActivePositionalArg) { + ProvidePositionalOption(ActivePositionalArg, argv[i]); + continue; // We are done! + } else if (!PositionalOpts.empty()) { PositionalVals.push_back(argv[i]); // All of the positional arguments have been fulfulled, give the rest to @@ -338,7 +347,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, Pos = Val.find(','); } } - ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); + + // If this is a named positional argument, just remember that it is the + // active one... + if (Handler->getFormattingFlag() == cl::Positional) + ActivePositionalArg = Handler; + else + ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); } // Check and handle positional arguments now... @@ -469,21 +484,22 @@ bool Option::addOccurrence(const char *ArgName, const std::string &Value) { void Option::addArgument(const char *ArgStr) { if (ArgStr[0]) AddArgument(ArgStr, this); - else if (getFormattingFlag() == Positional) + + if (getFormattingFlag() == Positional) getPositionalOpts().push_back(this); else if (getNumOccurrencesFlag() == ConsumeAfter) { - assert((getPositionalOpts().empty() || - getPositionalOpts().front()->getNumOccurrencesFlag() != ConsumeAfter) - && "Cannot specify more than one option with cl::ConsumeAfter " - "specified!"); + if (!getPositionalOpts().empty() && + getPositionalOpts().front()->getNumOccurrencesFlag() == ConsumeAfter) + error("Cannot specify more than one option with cl::ConsumeAfter!"); getPositionalOpts().insert(getPositionalOpts().begin(), this); } } void Option::removeArgument(const char *ArgStr) { - if (ArgStr[0]) { + if (ArgStr[0]) RemoveArgument(ArgStr, this); - } else if (getFormattingFlag() == Positional) { + + if (getFormattingFlag() == Positional) { std::vector::iterator I = std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); assert(I != getPositionalOpts().end() && "Arg not registered!"); @@ -738,8 +754,11 @@ public: if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; - for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) + for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { + if (PosOpts[i]->ArgStr[0]) + std::cerr << " --" << PosOpts[i]->ArgStr; std::cerr << " " << PosOpts[i]->HelpStr; + } // Print the consume after option info if it exists... if (CAOpt) std::cerr << " " << CAOpt->HelpStr; diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index f508483d69..4e3a92fec2 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -96,9 +96,9 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->addOccurrence(ArgName, Value); } -static bool ProvidePositionalOption(Option *Handler, std::string &Arg) { +static bool ProvidePositionalOption(Option *Handler, const std::string &Arg) { int Dummy; - return ProvideOption(Handler, "", Arg.c_str(), 0, 0, Dummy); + return ProvideOption(Handler, Handler->ArgStr, Arg.c_str(), 0, 0, Dummy); } @@ -189,9 +189,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, Opt->error(" error - this positional option will never be matched, " "because it does not Require a value, and a " "cl::ConsumeAfter option is active!"); - } else if (UnboundedFound) { // This option does not "require" a value... - // Make sure this option is not specified after an option that eats all - // extra arguments, or this one will never get any! + } else if (UnboundedFound && !Opt->ArgStr[0]) { + // This option does not "require" a value... Make sure this option is + // not specified after an option that eats all extra arguments, or this + // one will never get any! // ErrorParsing |= Opt->error(" error - option can never match, because " "another positional argument will match an " @@ -207,6 +208,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // std::vector PositionalVals; + // If the program has named positional arguments, and the name has been run + // across, keep track of which positional argument was named. Otherwise put + // the positional args into the PositionalVals list... + Option *ActivePositionalArg = 0; + // Loop over all of the arguments... processing them. bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { @@ -220,7 +226,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) { // Positional argument! - if (!PositionalOpts.empty()) { + if (ActivePositionalArg) { + ProvidePositionalOption(ActivePositionalArg, argv[i]); + continue; // We are done! + } else if (!PositionalOpts.empty()) { PositionalVals.push_back(argv[i]); // All of the positional arguments have been fulfulled, give the rest to @@ -338,7 +347,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, Pos = Val.find(','); } } - ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); + + // If this is a named positional argument, just remember that it is the + // active one... + if (Handler->getFormattingFlag() == cl::Positional) + ActivePositionalArg = Handler; + else + ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); } // Check and handle positional arguments now... @@ -469,21 +484,22 @@ bool Option::addOccurrence(const char *ArgName, const std::string &Value) { void Option::addArgument(const char *ArgStr) { if (ArgStr[0]) AddArgument(ArgStr, this); - else if (getFormattingFlag() == Positional) + + if (getFormattingFlag() == Positional) getPositionalOpts().push_back(this); else if (getNumOccurrencesFlag() == ConsumeAfter) { - assert((getPositionalOpts().empty() || - getPositionalOpts().front()->getNumOccurrencesFlag() != ConsumeAfter) - && "Cannot specify more than one option with cl::ConsumeAfter " - "specified!"); + if (!getPositionalOpts().empty() && + getPositionalOpts().front()->getNumOccurrencesFlag() == ConsumeAfter) + error("Cannot specify more than one option with cl::ConsumeAfter!"); getPositionalOpts().insert(getPositionalOpts().begin(), this); } } void Option::removeArgument(const char *ArgStr) { - if (ArgStr[0]) { + if (ArgStr[0]) RemoveArgument(ArgStr, this); - } else if (getFormattingFlag() == Positional) { + + if (getFormattingFlag() == Positional) { std::vector::iterator I = std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); assert(I != getPositionalOpts().end() && "Arg not registered!"); @@ -738,8 +754,11 @@ public: if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; - for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) + for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { + if (PosOpts[i]->ArgStr[0]) + std::cerr << " --" << PosOpts[i]->ArgStr; std::cerr << " " << PosOpts[i]->HelpStr; + } // Print the consume after option info if it exists... if (CAOpt) std::cerr << " " << CAOpt->HelpStr; -- cgit v1.2.3-70-g09d2 From 06b06c5f00acffdab8c59e3dc5baca3eacca172a Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Thu, 14 Aug 2003 22:00:59 +0000 Subject: Add support for reading command line arguments from an environment variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7851 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 7 ++++ include/llvm/Support/CommandLine.h | 7 ++++ lib/Support/CommandLine.cpp | 74 +++++++++++++++++++++++++++++++++++++ support/lib/Support/CommandLine.cpp | 74 +++++++++++++++++++++++++++++++++++++ 4 files changed, 162 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index 245d15bc51..faf82062cc 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -31,6 +31,13 @@ namespace cl { void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview = 0); +//===----------------------------------------------------------------------===// +// ParseEnvironmentOptions - Environment variable option processing alternate +// entry point. +// +void cl::ParseEnvironmentOptions (char *progName, char *envvar, + const char *Overview = 0); + //===----------------------------------------------------------------------===// // Flags permitted to be passed to command line arguments // diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 245d15bc51..faf82062cc 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -31,6 +31,13 @@ namespace cl { void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview = 0); +//===----------------------------------------------------------------------===// +// ParseEnvironmentOptions - Environment variable option processing alternate +// entry point. +// +void cl::ParseEnvironmentOptions (char *progName, char *envvar, + const char *Overview = 0); + //===----------------------------------------------------------------------===// // Flags permitted to be passed to command line arguments // diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 4e3a92fec2..f038d39154 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -152,6 +152,80 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { O->getNumOccurrencesFlag() == cl::OneOrMore; } +/// ParseStringVector - Break INPUT up wherever one or more characters +/// from DELIMS are found, and store the resulting tokens in OUTPUT. +/// +static void ParseStringVector (std::vector &output, + std::string &input, const char *delims) { + std::string work (input); + int pos = work.find_first_not_of (delims); + if (pos == -1) return; + work = work.substr (pos); + pos = work.find_first_of (delims); + while (!work.empty() && pos != -1) { + if (pos == -1) break; + output.push_back (work.substr (0,pos)); + int nextpos = work.find_first_not_of (delims, pos + 1); + if (nextpos != -1) { + work = work.substr (work.find_first_not_of (delims, pos + 1)); + pos = work.find_first_of (delims); + } else { + work = ""; + pos = -1; + } + } + if (!work.empty ()) { + output.push_back (work); + } +} + +/// ParseCStringVector - Same effect as ParseStringVector, but the +/// resulting output vector contains dynamically-allocated pointers to +/// char, instead of standard C++ strings. +/// +static void ParseCStringVector (std::vector &output, + std::string &input, const char *delims) { + std::vector work; + ParseStringVector (work, input, delims); + for (std::vector::iterator i = work.begin(), e = work.end(); + i != e; ++i) { + output.push_back (strdup (i->c_str ())); + } +} + +/// ParseEnvironmentOptions - An alternative entry point to the +/// CommandLine library, which allows you to read the program's name +/// from the caller (as PROGNAME) and its command-line arguments from +/// an environment variable (whose name is given in ENVVAR). +/// +void cl::ParseEnvironmentOptions (char *progName, char *envvar, + const char *Overview) { + // Get program's "name", which we wouldn't know without the caller + // telling us. + assert (progName && "Program name not specified"); + static std::vector newargv; // Maybe making it "static" is a hack. + int newargc; + newargv.push_back (progName); + + // Get the environment variable they want us to parse options out of. + assert (envvar && "Environment variable name missing"); + char *envvalue = getenv (envvar); + if (envvalue == NULL) { + // Env var not set --> act like there are no more command line + // arguments. + newargc = newargv.size (); + ParseCommandLineOptions (newargc, &newargv[0], Overview); + return; + } + std::string envvaluestr (envvalue); + + // Parse the value of the environment variable into a "command line" + // and hand it off to ParseCommandLineOptions(). + ParseCStringVector (newargv, envvaluestr, " \v\f\t\r\n"); + newargc = newargv.size (); + ParseCommandLineOptions (newargc, &newargv[0], Overview); +} + void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview) { assert((!getOpts().empty() || !getPositionalOpts().empty()) && diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 4e3a92fec2..f038d39154 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -152,6 +152,80 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { O->getNumOccurrencesFlag() == cl::OneOrMore; } +/// ParseStringVector - Break INPUT up wherever one or more characters +/// from DELIMS are found, and store the resulting tokens in OUTPUT. +/// +static void ParseStringVector (std::vector &output, + std::string &input, const char *delims) { + std::string work (input); + int pos = work.find_first_not_of (delims); + if (pos == -1) return; + work = work.substr (pos); + pos = work.find_first_of (delims); + while (!work.empty() && pos != -1) { + if (pos == -1) break; + output.push_back (work.substr (0,pos)); + int nextpos = work.find_first_not_of (delims, pos + 1); + if (nextpos != -1) { + work = work.substr (work.find_first_not_of (delims, pos + 1)); + pos = work.find_first_of (delims); + } else { + work = ""; + pos = -1; + } + } + if (!work.empty ()) { + output.push_back (work); + } +} + +/// ParseCStringVector - Same effect as ParseStringVector, but the +/// resulting output vector contains dynamically-allocated pointers to +/// char, instead of standard C++ strings. +/// +static void ParseCStringVector (std::vector &output, + std::string &input, const char *delims) { + std::vector work; + ParseStringVector (work, input, delims); + for (std::vector::iterator i = work.begin(), e = work.end(); + i != e; ++i) { + output.push_back (strdup (i->c_str ())); + } +} + +/// ParseEnvironmentOptions - An alternative entry point to the +/// CommandLine library, which allows you to read the program's name +/// from the caller (as PROGNAME) and its command-line arguments from +/// an environment variable (whose name is given in ENVVAR). +/// +void cl::ParseEnvironmentOptions (char *progName, char *envvar, + const char *Overview) { + // Get program's "name", which we wouldn't know without the caller + // telling us. + assert (progName && "Program name not specified"); + static std::vector newargv; // Maybe making it "static" is a hack. + int newargc; + newargv.push_back (progName); + + // Get the environment variable they want us to parse options out of. + assert (envvar && "Environment variable name missing"); + char *envvalue = getenv (envvar); + if (envvalue == NULL) { + // Env var not set --> act like there are no more command line + // arguments. + newargc = newargv.size (); + ParseCommandLineOptions (newargc, &newargv[0], Overview); + return; + } + std::string envvaluestr (envvalue); + + // Parse the value of the environment variable into a "command line" + // and hand it off to ParseCommandLineOptions(). + ParseCStringVector (newargv, envvaluestr, " \v\f\t\r\n"); + newargc = newargv.size (); + ParseCommandLineOptions (newargc, &newargv[0], Overview); +} + void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview) { assert((!getOpts().empty() || !getPositionalOpts().empty()) && -- cgit v1.2.3-70-g09d2 From c48ef2ae36e2169872a828a5399ccd1993837915 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Fri, 15 Aug 2003 21:05:57 +0000 Subject: lib/Support/CommandLine.cpp: Many changes suggested by Chris. It's okay, I'll recover from the emotional damage...maybe someday. :-) Collapse ParseCStringVector into ParseStringVector. Comment it. Make it take a const input. Use std::string::npos instead of -1 (what a mouthful!) Make ParseEnvironmentOptions take const inputs. Check its args at the very beginning. Strdup all the contents of newArgv and free them all at the end. include/Support/CommandLine.h: Constify progName and envVar arguments to ParseEnvironmentOptions(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7905 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 2 +- include/llvm/Support/CommandLine.h | 2 +- lib/Support/CommandLine.cpp | 97 +++++++++++++++++++------------------ support/lib/Support/CommandLine.cpp | 97 +++++++++++++++++++------------------ 4 files changed, 104 insertions(+), 94 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index 5febbcf1c9..410361797a 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -35,7 +35,7 @@ void ParseCommandLineOptions(int &argc, char **argv, // ParseEnvironmentOptions - Environment variable option processing alternate // entry point. // -void ParseEnvironmentOptions(char *progName, char *envvar, +void ParseEnvironmentOptions(const char *progName, const char *envvar, const char *Overview = 0); //===----------------------------------------------------------------------===// diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 5febbcf1c9..410361797a 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -35,7 +35,7 @@ void ParseCommandLineOptions(int &argc, char **argv, // ParseEnvironmentOptions - Environment variable option processing alternate // entry point. // -void ParseEnvironmentOptions(char *progName, char *envvar, +void ParseEnvironmentOptions(const char *progName, const char *envvar, const char *Overview = 0); //===----------------------------------------------------------------------===// diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index f038d39154..e9793d692a 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -152,44 +152,48 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { O->getNumOccurrencesFlag() == cl::OneOrMore; } -/// ParseStringVector - Break INPUT up wherever one or more characters -/// from DELIMS are found, and store the resulting tokens in OUTPUT. +/// ParseCStringVector - Break INPUT up wherever one or more +/// whitespace characters are found, and store the resulting tokens in +/// OUTPUT. The tokens stored in OUTPUT are dynamically allocated +/// using strdup (), so it is the caller's responsibility to free () +/// them later. /// -static void ParseStringVector (std::vector &output, - std::string &input, const char *delims) { +static void ParseCStringVector (std::vector &output, + const char *input) { + // Characters which will be treated as token separators: + static const char *delims = " \v\f\t\r\n"; + std::string work (input); - int pos = work.find_first_not_of (delims); - if (pos == -1) return; + // Skip past any delims at head of input string. + size_t pos = work.find_first_not_of (delims); + // If the string consists entirely of delims, then exit early. + if (pos == std::string::npos) return; + // Otherwise, jump forward to beginning of first word. work = work.substr (pos); + // Find position of first delimiter. pos = work.find_first_of (delims); - while (!work.empty() && pos != -1) { - if (pos == -1) break; - output.push_back (work.substr (0,pos)); - int nextpos = work.find_first_not_of (delims, pos + 1); - if (nextpos != -1) { + + while (!work.empty() && pos != std::string::npos) { + // Everything from 0 to POS is the next word to copy. + output.push_back (strdup (work.substr (0,pos).c_str ())); + // Is there another word in the string? + size_t nextpos = work.find_first_not_of (delims, pos + 1); + if (nextpos != std::string::npos) { + // Yes? Then remove delims from beginning ... work = work.substr (work.find_first_not_of (delims, pos + 1)); + // and find the end of the word. pos = work.find_first_of (delims); } else { + // No? (Remainder of string is delims.) End the loop. work = ""; - pos = -1; + pos = std::string::npos; } } - if (!work.empty ()) { - output.push_back (work); - } -} -/// ParseCStringVector - Same effect as ParseStringVector, but the -/// resulting output vector contains dynamically-allocated pointers to -/// char, instead of standard C++ strings. -/// -static void ParseCStringVector (std::vector &output, - std::string &input, const char *delims) { - std::vector work; - ParseStringVector (work, input, delims); - for (std::vector::iterator i = work.begin(), e = work.end(); - i != e; ++i) { - output.push_back (strdup (i->c_str ())); + // If `input' ended with non-delim char, then we'll get here with + // the last word of `input' in `work'; copy it now. + if (!work.empty ()) { + output.push_back (strdup (work.c_str ())); } } @@ -198,32 +202,33 @@ static void ParseCStringVector (std::vector &output, /// from the caller (as PROGNAME) and its command-line arguments from /// an environment variable (whose name is given in ENVVAR). /// -void cl::ParseEnvironmentOptions (char *progName, char *envvar, +void cl::ParseEnvironmentOptions (const char *progName, const char *envVar, const char *Overview) { - // Get program's "name", which we wouldn't know without the caller - // telling us. + // Check args. assert (progName && "Program name not specified"); - static std::vector newargv; // Maybe making it "static" is a hack. - int newargc; - newargv.push_back (progName); - + assert (envVar && "Environment variable name missing"); + // Get the environment variable they want us to parse options out of. - assert (envvar && "Environment variable name missing"); - char *envvalue = getenv (envvar); - if (envvalue == NULL) { - // Env var not set --> act like there are no more command line - // arguments. - newargc = newargv.size (); - ParseCommandLineOptions (newargc, &newargv[0], Overview); + const char *envValue = getenv (envVar); + if (!envValue) return; - } - std::string envvaluestr (envvalue); + + // Get program's "name", which we wouldn't know without the caller + // telling us. + std::vector newArgv; + newArgv.push_back (strdup (progName)); // Parse the value of the environment variable into a "command line" // and hand it off to ParseCommandLineOptions(). - ParseCStringVector (newargv, envvaluestr, " \v\f\t\r\n"); - newargc = newargv.size (); - ParseCommandLineOptions (newargc, &newargv[0], Overview); + ParseCStringVector (newArgv, envValue); + int newArgc = newArgv.size (); + ParseCommandLineOptions (newArgc, &newArgv[0], Overview); + + // Free all the strdup()ed strings. + for (std::vector::iterator i = newArgv.begin (), e = newArgv.end (); + i != e; ++i) { + free (*i); + } } void cl::ParseCommandLineOptions(int &argc, char **argv, diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index f038d39154..e9793d692a 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -152,44 +152,48 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { O->getNumOccurrencesFlag() == cl::OneOrMore; } -/// ParseStringVector - Break INPUT up wherever one or more characters -/// from DELIMS are found, and store the resulting tokens in OUTPUT. +/// ParseCStringVector - Break INPUT up wherever one or more +/// whitespace characters are found, and store the resulting tokens in +/// OUTPUT. The tokens stored in OUTPUT are dynamically allocated +/// using strdup (), so it is the caller's responsibility to free () +/// them later. /// -static void ParseStringVector (std::vector &output, - std::string &input, const char *delims) { +static void ParseCStringVector (std::vector &output, + const char *input) { + // Characters which will be treated as token separators: + static const char *delims = " \v\f\t\r\n"; + std::string work (input); - int pos = work.find_first_not_of (delims); - if (pos == -1) return; + // Skip past any delims at head of input string. + size_t pos = work.find_first_not_of (delims); + // If the string consists entirely of delims, then exit early. + if (pos == std::string::npos) return; + // Otherwise, jump forward to beginning of first word. work = work.substr (pos); + // Find position of first delimiter. pos = work.find_first_of (delims); - while (!work.empty() && pos != -1) { - if (pos == -1) break; - output.push_back (work.substr (0,pos)); - int nextpos = work.find_first_not_of (delims, pos + 1); - if (nextpos != -1) { + + while (!work.empty() && pos != std::string::npos) { + // Everything from 0 to POS is the next word to copy. + output.push_back (strdup (work.substr (0,pos).c_str ())); + // Is there another word in the string? + size_t nextpos = work.find_first_not_of (delims, pos + 1); + if (nextpos != std::string::npos) { + // Yes? Then remove delims from beginning ... work = work.substr (work.find_first_not_of (delims, pos + 1)); + // and find the end of the word. pos = work.find_first_of (delims); } else { + // No? (Remainder of string is delims.) End the loop. work = ""; - pos = -1; + pos = std::string::npos; } } - if (!work.empty ()) { - output.push_back (work); - } -} -/// ParseCStringVector - Same effect as ParseStringVector, but the -/// resulting output vector contains dynamically-allocated pointers to -/// char, instead of standard C++ strings. -/// -static void ParseCStringVector (std::vector &output, - std::string &input, const char *delims) { - std::vector work; - ParseStringVector (work, input, delims); - for (std::vector::iterator i = work.begin(), e = work.end(); - i != e; ++i) { - output.push_back (strdup (i->c_str ())); + // If `input' ended with non-delim char, then we'll get here with + // the last word of `input' in `work'; copy it now. + if (!work.empty ()) { + output.push_back (strdup (work.c_str ())); } } @@ -198,32 +202,33 @@ static void ParseCStringVector (std::vector &output, /// from the caller (as PROGNAME) and its command-line arguments from /// an environment variable (whose name is given in ENVVAR). /// -void cl::ParseEnvironmentOptions (char *progName, char *envvar, +void cl::ParseEnvironmentOptions (const char *progName, const char *envVar, const char *Overview) { - // Get program's "name", which we wouldn't know without the caller - // telling us. + // Check args. assert (progName && "Program name not specified"); - static std::vector newargv; // Maybe making it "static" is a hack. - int newargc; - newargv.push_back (progName); - + assert (envVar && "Environment variable name missing"); + // Get the environment variable they want us to parse options out of. - assert (envvar && "Environment variable name missing"); - char *envvalue = getenv (envvar); - if (envvalue == NULL) { - // Env var not set --> act like there are no more command line - // arguments. - newargc = newargv.size (); - ParseCommandLineOptions (newargc, &newargv[0], Overview); + const char *envValue = getenv (envVar); + if (!envValue) return; - } - std::string envvaluestr (envvalue); + + // Get program's "name", which we wouldn't know without the caller + // telling us. + std::vector newArgv; + newArgv.push_back (strdup (progName)); // Parse the value of the environment variable into a "command line" // and hand it off to ParseCommandLineOptions(). - ParseCStringVector (newargv, envvaluestr, " \v\f\t\r\n"); - newargc = newargv.size (); - ParseCommandLineOptions (newargc, &newargv[0], Overview); + ParseCStringVector (newArgv, envValue); + int newArgc = newArgv.size (); + ParseCommandLineOptions (newArgc, &newArgv[0], Overview); + + // Free all the strdup()ed strings. + for (std::vector::iterator i = newArgv.begin (), e = newArgv.end (); + i != e; ++i) { + free (*i); + } } void cl::ParseCommandLineOptions(int &argc, char **argv, -- cgit v1.2.3-70-g09d2 From 950971dfe6271e85292f73dd6ac105465e4898f7 Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Tue, 16 Sep 2003 15:31:46 +0000 Subject: Fixed spelling & grammar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8559 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 +- lib/Support/FileUtilities.cpp | 2 +- lib/Support/Signals.cpp | 2 +- lib/Support/SystemUtils.cpp | 2 +- support/lib/Support/CommandLine.cpp | 2 +- support/lib/Support/FileUtilities.cpp | 2 +- support/lib/Support/Signals.cpp | 2 +- support/lib/Support/SystemUtils.cpp | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index e9793d692a..2d57abdb3c 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -330,7 +330,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (*ArgName == 0 && !DashDashFound) { // Is this the mythical "--"? DashDashFound = true; // Yup, take note of that fact... - continue; // Don't try to process it as an argument iself. + continue; // Don't try to process it as an argument itself. } const char *ArgNameEnd = ArgName; diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 7c8142a4a6..ca4603628c 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -85,7 +85,7 @@ std::string getUniqueFilename(const std::string &FilenameBase) { exit(1); } - // We don't need to hold the temp file descriptor... we will trust that noone + // We don't need to hold the temp file descriptor... we will trust that no one // will overwrite/delete the file while we are working on it... close(TempFD); std::string Result(FNBuffer); diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp index effc0599e4..563147eabf 100644 --- a/lib/Support/Signals.cpp +++ b/lib/Support/Signals.cpp @@ -1,7 +1,7 @@ //===- Signals.cpp - Signal Handling support ------------------------------===// // // This file defines some helpful functions for dealing with the possibility of -// unix signals occuring while your program is running. +// Unix signals occuring while your program is running. // //===----------------------------------------------------------------------===// diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index 0d414facbd..6c4df04b77 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -103,7 +103,7 @@ static void RedirectFD(const std::string &File, int FD) { /// RunProgramWithTimeout - This function executes the specified program, with /// the specified null-terminated argument array, with the stdin/out/err fd's -/// redirected, with a timeout specified on the commandline. This terminates +/// redirected, with a timeout specified on the command line. This terminates /// the calling program if there is an error executing the specified program. /// It returns the return value of the program, or -1 if a timeout is detected. /// diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index e9793d692a..2d57abdb3c 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -330,7 +330,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (*ArgName == 0 && !DashDashFound) { // Is this the mythical "--"? DashDashFound = true; // Yup, take note of that fact... - continue; // Don't try to process it as an argument iself. + continue; // Don't try to process it as an argument itself. } const char *ArgNameEnd = ArgName; diff --git a/support/lib/Support/FileUtilities.cpp b/support/lib/Support/FileUtilities.cpp index 7c8142a4a6..ca4603628c 100644 --- a/support/lib/Support/FileUtilities.cpp +++ b/support/lib/Support/FileUtilities.cpp @@ -85,7 +85,7 @@ std::string getUniqueFilename(const std::string &FilenameBase) { exit(1); } - // We don't need to hold the temp file descriptor... we will trust that noone + // We don't need to hold the temp file descriptor... we will trust that no one // will overwrite/delete the file while we are working on it... close(TempFD); std::string Result(FNBuffer); diff --git a/support/lib/Support/Signals.cpp b/support/lib/Support/Signals.cpp index effc0599e4..563147eabf 100644 --- a/support/lib/Support/Signals.cpp +++ b/support/lib/Support/Signals.cpp @@ -1,7 +1,7 @@ //===- Signals.cpp - Signal Handling support ------------------------------===// // // This file defines some helpful functions for dealing with the possibility of -// unix signals occuring while your program is running. +// Unix signals occuring while your program is running. // //===----------------------------------------------------------------------===// diff --git a/support/lib/Support/SystemUtils.cpp b/support/lib/Support/SystemUtils.cpp index 0d414facbd..6c4df04b77 100644 --- a/support/lib/Support/SystemUtils.cpp +++ b/support/lib/Support/SystemUtils.cpp @@ -103,7 +103,7 @@ static void RedirectFD(const std::string &File, int FD) { /// RunProgramWithTimeout - This function executes the specified program, with /// the specified null-terminated argument array, with the stdin/out/err fd's -/// redirected, with a timeout specified on the commandline. This terminates +/// redirected, with a timeout specified on the command line. This terminates /// the calling program if there is an error executing the specified program. /// It returns the return value of the program, or -1 if a timeout is detected. /// -- cgit v1.2.3-70-g09d2 From c86e84bcf38a94d0bcd09e76ff127ee636354bc0 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Tue, 16 Sep 2003 18:00:35 +0000 Subject: Add missing apostrophe. It's been bugging me for years. No really, years. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8566 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 +- support/lib/Support/CommandLine.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 2d57abdb3c..c0be0ecb34 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -400,7 +400,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: " + std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; ErrorParsing = true; continue; diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index 2d57abdb3c..c0be0ecb34 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -400,7 +400,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: " + std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; ErrorParsing = true; continue; -- cgit v1.2.3-70-g09d2 From 2d6a2360036cf511af0a06f9720e6a1752779d1c Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Fri, 10 Oct 2003 17:01:36 +0000 Subject: Change to use strtoul instead of strtoll. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9010 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index c0be0ecb34..807ff165b0 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -14,6 +14,8 @@ #include #include #include +#include +#include using namespace cl; @@ -682,9 +684,12 @@ bool parser::parse(Option &O, const char *ArgName, bool parser::parse(Option &O, const char *ArgName, const std::string &Arg, unsigned &Value) { char *End; - long long int V = strtoll(Arg.c_str(), &End, 0); + errno = 0; + unsigned long V = strtoul(Arg.c_str(), &End, 0); Value = (unsigned)V; - if (*End != 0 || V < 0 || Value != V) + if (((V == ULONG_MAX) && (errno == ERANGE)) + || (*End != 0) + || (Value != V)) return O.error(": '" + Arg + "' value invalid for uint argument!"); return false; } -- cgit v1.2.3-70-g09d2 From b576c94c15af9a440f69d9d03c2afead7971118c Mon Sep 17 00:00:00 2001 From: John Criswell Date: Mon, 20 Oct 2003 19:43:21 +0000 Subject: Added LLVM project notice to the top of every C++ source file. Header files will be on the way. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9298 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/AliasAnalysis.cpp | 7 +++++++ lib/Analysis/AliasAnalysisCounter.cpp | 7 +++++++ lib/Analysis/AliasAnalysisEvaluator.cpp | 7 +++++++ lib/Analysis/AliasSetTracker.cpp | 7 +++++++ lib/Analysis/BasicAliasAnalysis.cpp | 7 +++++++ lib/Analysis/ConstantRange.cpp | 7 +++++++ lib/Analysis/DataStructure/BottomUpClosure.cpp | 7 +++++++ lib/Analysis/DataStructure/DataStructure.cpp | 7 +++++++ lib/Analysis/DataStructure/DataStructureAA.cpp | 7 +++++++ lib/Analysis/DataStructure/DataStructureOpt.cpp | 7 +++++++ lib/Analysis/DataStructure/DataStructureStats.cpp | 7 +++++++ lib/Analysis/DataStructure/GraphChecker.cpp | 7 +++++++ lib/Analysis/DataStructure/IPModRef.cpp | 7 +++++++ lib/Analysis/DataStructure/Local.cpp | 7 +++++++ lib/Analysis/DataStructure/MemoryDepAnalysis.cpp | 7 +++++++ lib/Analysis/DataStructure/Parallelize.cpp | 7 +++++++ lib/Analysis/DataStructure/PgmDependenceGraph.cpp | 7 +++++++ lib/Analysis/DataStructure/Printer.cpp | 7 +++++++ lib/Analysis/DataStructure/Steensgaard.cpp | 7 +++++++ lib/Analysis/DataStructure/TopDownClosure.cpp | 7 +++++++ lib/Analysis/Expressions.cpp | 7 +++++++ lib/Analysis/IPA/CallGraph.cpp | 7 +++++++ lib/Analysis/IPA/CallGraphSCCPass.cpp | 7 +++++++ lib/Analysis/IPA/DependenceGraph.cpp | 7 +++++++ lib/Analysis/IPA/FindUnsafePointerTypes.cpp | 7 +++++++ lib/Analysis/IPA/FindUsedTypes.cpp | 7 +++++++ lib/Analysis/IPA/IPModRef.cpp | 7 +++++++ lib/Analysis/IPA/MemoryDepAnalysis.cpp | 7 +++++++ lib/Analysis/IPA/PgmDependenceGraph.cpp | 7 +++++++ lib/Analysis/IPA/PrintSCC.cpp | 7 +++++++ lib/Analysis/InductionVariable.cpp | 7 +++++++ lib/Analysis/InstCount.cpp | 7 +++++++ lib/Analysis/Interval.cpp | 7 +++++++ lib/Analysis/IntervalPartition.cpp | 7 +++++++ lib/Analysis/LiveVar/BBLiveVar.cpp | 7 +++++++ lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp | 7 +++++++ lib/Analysis/LiveVar/ValueSet.cpp | 8 +++++++- lib/Analysis/LoadValueNumbering.cpp | 7 +++++++ lib/Analysis/LoopInfo.cpp | 7 +++++++ lib/Analysis/PostDominators.cpp | 7 +++++++ lib/Analysis/PrintSCC.cpp | 7 +++++++ lib/Analysis/ValueNumbering.cpp | 7 +++++++ lib/Archive/ArchiveReader.cpp | 7 +++++++ lib/AsmParser/Parser.cpp | 7 +++++++ lib/Bytecode/Archive/ArchiveReader.cpp | 7 +++++++ lib/Bytecode/Reader/ArchiveReader.cpp | 7 +++++++ lib/Bytecode/Reader/ConstantReader.cpp | 7 +++++++ lib/Bytecode/Reader/InstructionReader.cpp | 7 +++++++ lib/Bytecode/Reader/Reader.cpp | 7 +++++++ lib/Bytecode/Reader/ReaderWrappers.cpp | 7 +++++++ lib/Bytecode/Writer/ConstantWriter.cpp | 7 +++++++ lib/Bytecode/Writer/InstructionWriter.cpp | 7 +++++++ lib/Bytecode/Writer/SlotCalculator.cpp | 7 +++++++ lib/Bytecode/Writer/Writer.cpp | 7 +++++++ lib/CodeGen/InstrSched/InstrScheduling.cpp | 7 +++++++ lib/CodeGen/InstrSched/SchedGraph.cpp | 7 +++++++ lib/CodeGen/InstrSched/SchedGraphCommon.cpp | 7 +++++++ lib/CodeGen/InstrSched/SchedPriorities.cpp | 7 +++++++ lib/CodeGen/InstrSelection/InstrForest.cpp | 7 +++++++ lib/CodeGen/InstrSelection/InstrSelection.cpp | 7 +++++++ lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp | 7 +++++++ lib/CodeGen/LiveVariables.cpp | 7 +++++++ lib/CodeGen/MachineCodeEmitter.cpp | 7 +++++++ lib/CodeGen/MachineCodeForInstruction.cpp | 7 +++++++ lib/CodeGen/MachineFunction.cpp | 7 +++++++ lib/CodeGen/MachineInstr.cpp | 7 +++++++ lib/CodeGen/MachineInstrAnnot.cpp | 7 +++++++ lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp | 7 +++++++ lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp | 7 +++++++ lib/CodeGen/PHIElimination.cpp | 7 +++++++ lib/CodeGen/Passes.cpp | 7 +++++++ lib/CodeGen/PrologEpilogInserter.cpp | 7 +++++++ lib/CodeGen/RegAlloc/IGNode.cpp | 7 +++++++ lib/CodeGen/RegAlloc/InterferenceGraph.cpp | 7 +++++++ lib/CodeGen/RegAlloc/LiveRangeInfo.cpp | 7 +++++++ lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 7 +++++++ lib/CodeGen/RegAlloc/RegClass.cpp | 7 +++++++ lib/CodeGen/RegAllocLocal.cpp | 7 +++++++ lib/CodeGen/RegAllocSimple.cpp | 7 +++++++ lib/CodeGen/SelectionDAG/DAGBuilder.cpp | 7 +++++++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 7 +++++++ lib/ExecutionEngine/ExecutionEngine.cpp | 7 +++++++ lib/ExecutionEngine/Interpreter/Execution.cpp | 7 +++++++ lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp | 7 +++++++ lib/ExecutionEngine/Interpreter/Interpreter.cpp | 7 +++++++ lib/ExecutionEngine/JIT/Intercept.cpp | 7 +++++++ lib/ExecutionEngine/JIT/JIT.cpp | 7 +++++++ lib/ExecutionEngine/JIT/JITEmitter.cpp | 7 +++++++ lib/ExecutionEngine/JIT/VM.cpp | 7 +++++++ lib/Linker/LinkModules.cpp | 7 +++++++ lib/Support/Annotation.cpp | 7 +++++++ lib/Support/CommandLine.cpp | 7 +++++++ lib/Support/ConstantRange.cpp | 7 +++++++ lib/Support/Debug.cpp | 7 +++++++ lib/Support/DynamicLinker.cpp | 7 +++++++ lib/Support/FileUtilities.cpp | 7 +++++++ lib/Support/LeakDetector.cpp | 7 +++++++ lib/Support/Mangler.cpp | 7 +++++++ lib/Support/PluginLoader.cpp | 7 +++++++ lib/Support/Signals.cpp | 7 +++++++ lib/Support/Statistic.cpp | 7 +++++++ lib/Support/SystemUtils.cpp | 7 +++++++ lib/Support/Timer.cpp | 7 +++++++ lib/Support/ToolRunner.cpp | 7 +++++++ lib/Support/ValueHolder.cpp | 7 +++++++ lib/Target/CBackend/CBackend.cpp | 7 +++++++ lib/Target/CBackend/Writer.cpp | 7 +++++++ lib/Target/MRegisterInfo.cpp | 7 +++++++ lib/Target/SparcV9/EmitBytecodeToAssembly.cpp | 7 +++++++ lib/Target/SparcV9/InstrSched/InstrScheduling.cpp | 7 +++++++ lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 7 +++++++ lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp | 7 +++++++ lib/Target/SparcV9/InstrSched/SchedPriorities.cpp | 7 +++++++ lib/Target/SparcV9/InstrSelection/InstrForest.cpp | 7 +++++++ lib/Target/SparcV9/InstrSelection/InstrSelection.cpp | 7 +++++++ lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp | 7 +++++++ lib/Target/SparcV9/LiveVar/BBLiveVar.cpp | 7 +++++++ lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp | 7 +++++++ lib/Target/SparcV9/LiveVar/ValueSet.cpp | 8 +++++++- lib/Target/SparcV9/MappingInfo.cpp | 7 +++++++ lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp | 7 +++++++ lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp | 7 +++++++ lib/Target/SparcV9/RegAlloc/IGNode.cpp | 7 +++++++ lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp | 7 +++++++ lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp | 7 +++++++ lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 7 +++++++ lib/Target/SparcV9/RegAlloc/RegClass.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9CodeEmitter.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9InstrInfo.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9InstrSelection.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9PeepholeOpts.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9PreSelection.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9RegClassInfo.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9RegInfo.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9SchedInfo.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9StackSlots.cpp | 7 +++++++ lib/Target/SparcV9/SparcV9TargetMachine.cpp | 7 +++++++ lib/Target/TargetData.cpp | 7 +++++++ lib/Target/TargetInstrInfo.cpp | 7 +++++++ lib/Target/TargetMachine.cpp | 7 +++++++ lib/Target/TargetSchedInfo.cpp | 7 +++++++ lib/Target/X86/FloatingPoint.cpp | 7 +++++++ lib/Target/X86/InstSelectPattern.cpp | 7 +++++++ lib/Target/X86/InstSelectSimple.cpp | 7 +++++++ lib/Target/X86/PeepholeOptimizer.cpp | 7 +++++++ lib/Target/X86/Printer.cpp | 7 +++++++ lib/Target/X86/X86AsmPrinter.cpp | 7 +++++++ lib/Target/X86/X86CodeEmitter.cpp | 7 +++++++ lib/Target/X86/X86FloatingPoint.cpp | 7 +++++++ lib/Target/X86/X86ISelPattern.cpp | 7 +++++++ lib/Target/X86/X86ISelSimple.cpp | 7 +++++++ lib/Target/X86/X86InstrInfo.cpp | 7 +++++++ lib/Target/X86/X86PeepholeOpt.cpp | 7 +++++++ lib/Target/X86/X86RegisterInfo.cpp | 7 +++++++ lib/Target/X86/X86TargetMachine.cpp | 7 +++++++ lib/Transforms/ExprTypeConvert.cpp | 7 +++++++ lib/Transforms/Hello/Hello.cpp | 7 +++++++ lib/Transforms/IPO/ConstantMerge.cpp | 7 +++++++ lib/Transforms/IPO/DeadArgumentElimination.cpp | 7 +++++++ lib/Transforms/IPO/DeadTypeElimination.cpp | 7 +++++++ lib/Transforms/IPO/ExtractFunction.cpp | 7 +++++++ lib/Transforms/IPO/FunctionResolution.cpp | 7 +++++++ lib/Transforms/IPO/GlobalDCE.cpp | 7 +++++++ lib/Transforms/IPO/InlineSimple.cpp | 7 +++++++ lib/Transforms/IPO/Inliner.cpp | 7 +++++++ lib/Transforms/IPO/Internalize.cpp | 7 +++++++ lib/Transforms/IPO/LowerSetJmp.cpp | 7 +++++++ lib/Transforms/IPO/MutateStructTypes.cpp | 7 +++++++ lib/Transforms/IPO/Parallelize.cpp | 7 +++++++ lib/Transforms/IPO/PruneEH.cpp | 7 +++++++ lib/Transforms/IPO/RaiseAllocations.cpp | 7 +++++++ lib/Transforms/IPO/SimpleStructMutation.cpp | 7 +++++++ lib/Transforms/Instrumentation/EmitFunctions.cpp | 7 +++++++ lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp | 7 +++++++ lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp | 7 +++++++ lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp | 7 +++++++ lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp | 7 +++++++ lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp | 7 +++++++ lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp | 7 +++++++ lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp | 7 +++++++ lib/Transforms/Instrumentation/TraceValues.cpp | 7 +++++++ lib/Transforms/LevelRaise.cpp | 7 +++++++ lib/Transforms/Scalar/ADCE.cpp | 7 +++++++ lib/Transforms/Scalar/ConstantProp.cpp | 7 +++++++ lib/Transforms/Scalar/CorrelatedExprs.cpp | 7 +++++++ lib/Transforms/Scalar/DCE.cpp | 7 +++++++ lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp | 7 +++++++ lib/Transforms/Scalar/GCSE.cpp | 7 +++++++ lib/Transforms/Scalar/IndVarSimplify.cpp | 7 +++++++ lib/Transforms/Scalar/InstructionCombining.cpp | 7 +++++++ lib/Transforms/Scalar/LICM.cpp | 7 +++++++ lib/Transforms/Scalar/PRE.cpp | 7 +++++++ lib/Transforms/Scalar/PiNodeInsertion.cpp | 7 +++++++ lib/Transforms/Scalar/Reassociate.cpp | 7 +++++++ lib/Transforms/Scalar/SCCP.cpp | 7 +++++++ lib/Transforms/Scalar/ScalarReplAggregates.cpp | 7 +++++++ lib/Transforms/Scalar/SimplifyCFG.cpp | 7 +++++++ lib/Transforms/Scalar/SymbolStripping.cpp | 7 +++++++ lib/Transforms/Scalar/TailDuplication.cpp | 7 +++++++ lib/Transforms/Scalar/TailRecursionElimination.cpp | 7 +++++++ lib/Transforms/TransformInternals.cpp | 7 +++++++ lib/Transforms/Utils/BasicBlockUtils.cpp | 7 +++++++ lib/Transforms/Utils/BreakCriticalEdges.cpp | 7 +++++++ lib/Transforms/Utils/CloneFunction.cpp | 7 +++++++ lib/Transforms/Utils/CloneModule.cpp | 7 +++++++ lib/Transforms/Utils/CloneTrace.cpp | 7 +++++++ lib/Transforms/Utils/DemoteRegToStack.cpp | 7 +++++++ lib/Transforms/Utils/InlineFunction.cpp | 7 +++++++ lib/Transforms/Utils/Linker.cpp | 7 +++++++ lib/Transforms/Utils/Local.cpp | 7 +++++++ lib/Transforms/Utils/LoopSimplify.cpp | 7 +++++++ lib/Transforms/Utils/LowerAllocations.cpp | 7 +++++++ lib/Transforms/Utils/LowerInvoke.cpp | 7 +++++++ lib/Transforms/Utils/LowerSwitch.cpp | 7 +++++++ lib/Transforms/Utils/Mem2Reg.cpp | 7 +++++++ lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 7 +++++++ lib/Transforms/Utils/SimplifyCFG.cpp | 7 +++++++ lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 7 +++++++ lib/Transforms/Utils/ValueMapper.cpp | 7 +++++++ lib/VMCore/AsmWriter.cpp | 7 +++++++ lib/VMCore/BasicBlock.cpp | 7 +++++++ lib/VMCore/ConstantFold.cpp | 7 +++++++ lib/VMCore/ConstantRange.cpp | 7 +++++++ lib/VMCore/Constants.cpp | 7 +++++++ lib/VMCore/Dominators.cpp | 7 +++++++ lib/VMCore/Function.cpp | 7 +++++++ lib/VMCore/InstrTypes.cpp | 7 +++++++ lib/VMCore/Instruction.cpp | 7 +++++++ lib/VMCore/LeakDetector.cpp | 7 +++++++ lib/VMCore/Linker.cpp | 7 +++++++ lib/VMCore/Mangler.cpp | 7 +++++++ lib/VMCore/Module.cpp | 7 +++++++ lib/VMCore/ModuleProvider.cpp | 7 +++++++ lib/VMCore/Pass.cpp | 7 +++++++ lib/VMCore/SlotCalculator.cpp | 7 +++++++ lib/VMCore/SymbolTable.cpp | 7 +++++++ lib/VMCore/Type.cpp | 7 +++++++ lib/VMCore/Value.cpp | 7 +++++++ lib/VMCore/Verifier.cpp | 7 +++++++ lib/VMCore/iBranch.cpp | 7 +++++++ lib/VMCore/iCall.cpp | 7 +++++++ lib/VMCore/iMemory.cpp | 7 +++++++ lib/VMCore/iOperators.cpp | 7 +++++++ lib/VMCore/iSwitch.cpp | 7 +++++++ tools/analyze/PrintSCC.cpp | 7 +++++++ tools/bugpoint/ToolRunner.cpp | 7 +++++++ tools/opt/PrintSCC.cpp | 7 +++++++ 249 files changed, 1743 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index a85d28daf2..3acdf7841d 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -1,4 +1,11 @@ //===- AliasAnalysis.cpp - Generic Alias Analysis Interface Implementation -==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the generic AliasAnalysis interface which is used as the // common interface used by all clients and implementations of alias analysis. diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index 285a6d3f46..5820565223 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -1,4 +1,11 @@ //===- AliasAnalysisCounter.cpp - Alias Analysis Query Counter ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a pass which can be used to count how many alias queries // are being made and how the alias analysis implementation being used responds. diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index 81aad894ce..d4a7d18dcd 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -1,4 +1,11 @@ //===- AliasAnalysisEvaluator.cpp - Alias Analysis Accuracy Evaluator -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a simple N^2 alias analysis accuracy evaluator. // Basically, for each function in the program, it simply queries to see how the diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index f00e5c8b31..c2800326c2 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -1,4 +1,11 @@ //===- AliasSetTracker.cpp - Alias Sets Tracker implementation-------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the AliasSetTracker and AliasSet classes. // diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 9aa885e9ef..e60922ac04 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -1,4 +1,11 @@ //===- llvm/Analysis/BasicAliasAnalysis.h - Alias Analysis Impl -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the default implementation of the Alias Analysis interface // that simply implements a few identities (two different globals cannot alias, diff --git a/lib/Analysis/ConstantRange.cpp b/lib/Analysis/ConstantRange.cpp index c9d8ae6fbb..a9e1204de5 100644 --- a/lib/Analysis/ConstantRange.cpp +++ b/lib/Analysis/ConstantRange.cpp @@ -1,4 +1,11 @@ //===-- ConstantRange.cpp - ConstantRange implementation ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Represent a range of possible values that may occur when the program is run // for an integral value. This keeps track of a lower and upper bound for the diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index 95de8e45e9..b4b2e48b4e 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -1,4 +1,11 @@ //===- BottomUpClosure.cpp - Compute bottom-up interprocedural closure ----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the BUDataStructures class, which represents the // Bottom-Up Interprocedural closure of the data structure graph over the diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index bdf8d810fb..b125b5d67f 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -1,4 +1,11 @@ //===- DataStructure.cpp - Implement the core data structure analysis -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the core data structure functionality. // diff --git a/lib/Analysis/DataStructure/DataStructureAA.cpp b/lib/Analysis/DataStructure/DataStructureAA.cpp index 51df03306f..99773e3936 100644 --- a/lib/Analysis/DataStructure/DataStructureAA.cpp +++ b/lib/Analysis/DataStructure/DataStructureAA.cpp @@ -1,4 +1,11 @@ //===- DataStructureAA.cpp - Data Structure Based Alias Analysis ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass uses the top-down data structure graphs to implement a simple // context sensitive alias analysis. diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp index 297979a72a..0ca7d6bffc 100644 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp @@ -1,4 +1,11 @@ //===- DataStructureOpt.cpp - Data Structure Analysis Based Optimizations -===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass uses DSA to a series of simple optimizations, like marking // unwritten global variables 'constant'. diff --git a/lib/Analysis/DataStructure/DataStructureStats.cpp b/lib/Analysis/DataStructure/DataStructureStats.cpp index f033b99b89..8d2984845a 100644 --- a/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -1,4 +1,11 @@ //===- DSGraphStats.cpp - Various statistics for DS Graphs ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/DataStructure/GraphChecker.cpp b/lib/Analysis/DataStructure/GraphChecker.cpp index a01c483ed4..b0164da322 100644 --- a/lib/Analysis/DataStructure/GraphChecker.cpp +++ b/lib/Analysis/DataStructure/GraphChecker.cpp @@ -1,4 +1,11 @@ //===- GraphChecker.cpp - Assert that various graph properties hold -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is used to test DSA with regression tests. It can be used to check // that certain graph properties hold, such as two nodes being disjoint, whether diff --git a/lib/Analysis/DataStructure/IPModRef.cpp b/lib/Analysis/DataStructure/IPModRef.cpp index e7366a0536..754b86b74b 100644 --- a/lib/Analysis/DataStructure/IPModRef.cpp +++ b/lib/Analysis/DataStructure/IPModRef.cpp @@ -1,4 +1,11 @@ //===- IPModRef.cpp - Compute IP Mod/Ref information ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // See high-level comments in include/llvm/Analysis/IPModRef.h // diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 64e6088e7c..fcaadf3755 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -1,4 +1,11 @@ //===- Local.cpp - Compute a local data structure graph for a function ----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Compute the local version of the data structure graph for a function. The // external interface to this file is the DSGraph constructor. diff --git a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp index 110475a063..076836a5ce 100644 --- a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp +++ b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp @@ -1,4 +1,11 @@ //===- MemoryDepAnalysis.cpp - Compute dep graph for memory ops --*-C++-*--===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a pass (MemoryDepAnalysis) that computes memory-based // data dependences between instructions for each function in a module. diff --git a/lib/Analysis/DataStructure/Parallelize.cpp b/lib/Analysis/DataStructure/Parallelize.cpp index 09b7dc21cd..77e6ed3040 100644 --- a/lib/Analysis/DataStructure/Parallelize.cpp +++ b/lib/Analysis/DataStructure/Parallelize.cpp @@ -1,4 +1,11 @@ //===- Parallelize.cpp - Auto parallelization using DS Graphs -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a pass that automatically parallelizes a program, // using the Cilk multi-threaded runtime system to execute parallel code. diff --git a/lib/Analysis/DataStructure/PgmDependenceGraph.cpp b/lib/Analysis/DataStructure/PgmDependenceGraph.cpp index 705a9449db..ef44cb3efb 100644 --- a/lib/Analysis/DataStructure/PgmDependenceGraph.cpp +++ b/lib/Analysis/DataStructure/PgmDependenceGraph.cpp @@ -1,5 +1,12 @@ //===- PgmDependenceGraph.cpp - Enumerate PDG for a function ----*- C++ -*-===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // The Program Dependence Graph (PDG) for a single function represents all // data and control dependences for the function. This file provides an // iterator to enumerate all these dependences. In particular, it enumerates: diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index 87fc1f76cc..9587979560 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -1,4 +1,11 @@ //===- Printer.cpp - Code for printing data structure graphs nicely -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the 'dot' graph printer. // diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index a3034ddeac..29bbf3a3fb 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -1,4 +1,11 @@ //===- Steensgaard.cpp - Context Insensitive Alias Analysis ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass uses the data structure graphs to implement a simple context // insensitive alias analysis. It does this by computing the local analysis diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 7da1746125..d30c441ce4 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -1,4 +1,11 @@ //===- TopDownClosure.cpp - Compute the top-down interprocedure closure ---===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the TDDataStructures class, which represents the // Top-down Interprocedural closure of the data structure graph over the diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index 6692206089..4d8897e7ff 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -1,4 +1,11 @@ //===- Expressions.cpp - Expression Analysis Utilities --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines a package of expression analysis utilties: // diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index d5cbe3d02b..6a41acb6d9 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -1,4 +1,11 @@ //===- CallGraph.cpp - Build a Module's call graph ------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This interface is used to build and manipulate a call graph, which is a very // useful tool for interprocedural optimization. diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index 4f363dc1a0..74da70131e 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -1,4 +1,11 @@ //===- CallGraphSCCPass.cpp - Pass that operates BU on call graph ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the CallGraphSCCPass class, which is used for passes // which are implemented as bottom-up traversals on the call graph. Because diff --git a/lib/Analysis/IPA/DependenceGraph.cpp b/lib/Analysis/IPA/DependenceGraph.cpp index faabdd3be6..ead777aa13 100644 --- a/lib/Analysis/IPA/DependenceGraph.cpp +++ b/lib/Analysis/IPA/DependenceGraph.cpp @@ -1,4 +1,11 @@ //===- DependenceGraph.cpp - Dependence graph for a function ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements an explicit representation for the dependence graph // of a function, with one node per instruction and one edge per dependence. diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 3897ec8488..7eeff7dbc7 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -1,4 +1,11 @@ //===- FindUnsafePointerTypes.cpp - Check pointer usage safety ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines a pass that can be used to determine, interprocedurally, // which pointer types are accessed unsafely in a program. If there is an diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 78be3221e4..ad548d0f9a 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -1,4 +1,11 @@ //===- FindUsedTypes.cpp - Find all Types used by a module ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is used to seek out all of the types in use by the program. // diff --git a/lib/Analysis/IPA/IPModRef.cpp b/lib/Analysis/IPA/IPModRef.cpp index e7366a0536..754b86b74b 100644 --- a/lib/Analysis/IPA/IPModRef.cpp +++ b/lib/Analysis/IPA/IPModRef.cpp @@ -1,4 +1,11 @@ //===- IPModRef.cpp - Compute IP Mod/Ref information ------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // See high-level comments in include/llvm/Analysis/IPModRef.h // diff --git a/lib/Analysis/IPA/MemoryDepAnalysis.cpp b/lib/Analysis/IPA/MemoryDepAnalysis.cpp index 110475a063..076836a5ce 100644 --- a/lib/Analysis/IPA/MemoryDepAnalysis.cpp +++ b/lib/Analysis/IPA/MemoryDepAnalysis.cpp @@ -1,4 +1,11 @@ //===- MemoryDepAnalysis.cpp - Compute dep graph for memory ops --*-C++-*--===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a pass (MemoryDepAnalysis) that computes memory-based // data dependences between instructions for each function in a module. diff --git a/lib/Analysis/IPA/PgmDependenceGraph.cpp b/lib/Analysis/IPA/PgmDependenceGraph.cpp index 705a9449db..ef44cb3efb 100644 --- a/lib/Analysis/IPA/PgmDependenceGraph.cpp +++ b/lib/Analysis/IPA/PgmDependenceGraph.cpp @@ -1,5 +1,12 @@ //===- PgmDependenceGraph.cpp - Enumerate PDG for a function ----*- C++ -*-===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // The Program Dependence Graph (PDG) for a single function represents all // data and control dependences for the function. This file provides an // iterator to enumerate all these dependences. In particular, it enumerates: diff --git a/lib/Analysis/IPA/PrintSCC.cpp b/lib/Analysis/IPA/PrintSCC.cpp index dfb7420542..3459381158 100644 --- a/lib/Analysis/IPA/PrintSCC.cpp +++ b/lib/Analysis/IPA/PrintSCC.cpp @@ -1,4 +1,11 @@ //===- PrintSCC.cpp - Enumerate SCCs in some key graphs -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file provides passes to print out SCCs in a CFG or a CallGraph. // Normally, you would not use these passes; instead, you would use the diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp index 334a72bdfc..3119d31ded 100644 --- a/lib/Analysis/InductionVariable.cpp +++ b/lib/Analysis/InductionVariable.cpp @@ -1,4 +1,11 @@ //===- InductionVariable.cpp - Induction variable classification ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements identification and classification of induction // variables. Induction variables must contain a PHI node that exists in a diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index 85f580c25d..4d49478a9e 100644 --- a/lib/Analysis/InstCount.cpp +++ b/lib/Analysis/InstCount.cpp @@ -1,4 +1,11 @@ //===-- InstCount.cpp - Collects the count of all instructions ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass collects the count of all instructions and reports them // diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp index 1f91fdef54..28cee83631 100644 --- a/lib/Analysis/Interval.cpp +++ b/lib/Analysis/Interval.cpp @@ -1,4 +1,11 @@ //===- Interval.cpp - Interval class code ---------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains the definition of the Interval class, which represents a // partition of a control flow graph of some kind. diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index eb4975ffda..2729930998 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -1,4 +1,11 @@ //===- IntervalPartition.cpp - Interval Partition module code -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains the definition of the IntervalPartition class, which // calculates and represent the interval partition of a function. diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp index 3968430ca5..c3716c9906 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.cpp +++ b/lib/Analysis/LiveVar/BBLiveVar.cpp @@ -1,4 +1,11 @@ //===-- BBLiveVar.cpp - Live Variable Analysis for a BasicBlock -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This is a wrapper class for BasicBlock which is used by live var analysis. // diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp index 8c95eaa84f..26026d642a 100644 --- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp @@ -1,4 +1,11 @@ //===-- FunctionLiveVarInfo.cpp - Live Variable Analysis for a Function ---===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This is the interface to function level live variable information that is // provided by live variable analysis. diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp index d50d1073f6..ba944cb8cc 100644 --- a/lib/Analysis/LiveVar/ValueSet.cpp +++ b/lib/Analysis/LiveVar/ValueSet.cpp @@ -1,4 +1,10 @@ - +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // FIXME: Eliminate this file. #include "llvm/CodeGen/ValueSet.h" diff --git a/lib/Analysis/LoadValueNumbering.cpp b/lib/Analysis/LoadValueNumbering.cpp index 2022065422..cbcdd0f178 100644 --- a/lib/Analysis/LoadValueNumbering.cpp +++ b/lib/Analysis/LoadValueNumbering.cpp @@ -1,4 +1,11 @@ //===- LoadValueNumbering.cpp - Load Value #'ing Implementation -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a value numbering pass that value #'s load instructions. // To do this, it finds lexically identical load instructions, and uses alias diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 410a012382..2277a15614 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -1,4 +1,11 @@ //===- LoopInfo.cpp - Natural Loop Calculator -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the LoopInfo class that is used to identify natural loops // and determine the loop depth of various nodes of the CFG. Note that the diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index 2ff5fd331a..ee31c36b3e 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -1,4 +1,11 @@ //===- PostDominators.cpp - Post-Dominator Calculation --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the post-dominator construction algorithms. // diff --git a/lib/Analysis/PrintSCC.cpp b/lib/Analysis/PrintSCC.cpp index dfb7420542..3459381158 100644 --- a/lib/Analysis/PrintSCC.cpp +++ b/lib/Analysis/PrintSCC.cpp @@ -1,4 +1,11 @@ //===- PrintSCC.cpp - Enumerate SCCs in some key graphs -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file provides passes to print out SCCs in a CFG or a CallGraph. // Normally, you would not use these passes; instead, you would use the diff --git a/lib/Analysis/ValueNumbering.cpp b/lib/Analysis/ValueNumbering.cpp index d28f0b7367..075c1c2b3f 100644 --- a/lib/Analysis/ValueNumbering.cpp +++ b/lib/Analysis/ValueNumbering.cpp @@ -1,4 +1,11 @@ //===- ValueNumbering.cpp - Value #'ing Implementation ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the non-abstract Value Numbering methods as well as a // default implementation for the analysis group. diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index be023538e1..d155b69bee 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/Archive/ArchiveReader.cpp @@ -1,4 +1,11 @@ //===- ArchiveReader.cpp - Code to read LLVM bytecode from .a files -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the ReadArchiveFile interface, which allows a linker to // read all of the LLVM bytecode files contained in a .a file. This file diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index 05547ee099..c6caa45473 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -1,4 +1,11 @@ //===- Parser.cpp - Main dispatch module for the Parser library -------------=== +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This library implements the functionality defined in llvm/assembly/parser.h // diff --git a/lib/Bytecode/Archive/ArchiveReader.cpp b/lib/Bytecode/Archive/ArchiveReader.cpp index be023538e1..d155b69bee 100644 --- a/lib/Bytecode/Archive/ArchiveReader.cpp +++ b/lib/Bytecode/Archive/ArchiveReader.cpp @@ -1,4 +1,11 @@ //===- ArchiveReader.cpp - Code to read LLVM bytecode from .a files -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the ReadArchiveFile interface, which allows a linker to // read all of the LLVM bytecode files contained in a .a file. This file diff --git a/lib/Bytecode/Reader/ArchiveReader.cpp b/lib/Bytecode/Reader/ArchiveReader.cpp index be023538e1..d155b69bee 100644 --- a/lib/Bytecode/Reader/ArchiveReader.cpp +++ b/lib/Bytecode/Reader/ArchiveReader.cpp @@ -1,4 +1,11 @@ //===- ArchiveReader.cpp - Code to read LLVM bytecode from .a files -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the ReadArchiveFile interface, which allows a linker to // read all of the LLVM bytecode files contained in a .a file. This file diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index 0746b3b58a..097bdbe126 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -1,4 +1,11 @@ //===- ReadConst.cpp - Code to constants and constant pools ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements functionality to deserialize constants and entire // constant pools. diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index 97becaace6..a409ceebef 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -1,4 +1,11 @@ //===- ReadInst.cpp - Code to read an instruction from bytecode -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the mechanism to read an instruction from a bytecode // stream. diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index f699cf7bf2..a36ea7a734 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -1,4 +1,11 @@ //===- Reader.cpp - Code to read bytecode files ---------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This library implements the functionality defined in llvm/Bytecode/Reader.h // diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp index 28d43b4156..0df6ea5ff2 100644 --- a/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/lib/Bytecode/Reader/ReaderWrappers.cpp @@ -1,4 +1,11 @@ //===- ReaderWrappers.cpp - Parse bytecode from file or buffer -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements loading and parsing a bytecode file and parsing a // bytecode module from a given buffer. diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp index c0c4137db4..dcb034f783 100644 --- a/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/lib/Bytecode/Writer/ConstantWriter.cpp @@ -1,4 +1,11 @@ //===-- ConstantWriter.cpp - Functions for writing constants --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the routines for encoding constants to a bytecode // stream. diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp index 57012c9df9..faa576ecb4 100644 --- a/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/lib/Bytecode/Writer/InstructionWriter.cpp @@ -1,4 +1,11 @@ //===-- InstructionWriter.cpp - Functions for writing instructions --------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the routines for encoding instruction opcodes to a // bytecode stream. diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index b182f6dbfa..f527b1838f 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -1,4 +1,11 @@ //===-- SlotCalculator.cpp - Calculate what slots values land in ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a useful analysis step to figure out what numbered // slots values in a program will land in (keeping track of per plane diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 5cc3eec872..9381e355f0 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -1,4 +1,11 @@ //===-- Writer.cpp - Library for writing VM bytecode files ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This library implements the functionality defined in llvm/Bytecode/Writer.h // diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index cf4f294155..2a2ef27a29 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -1,4 +1,11 @@ //===- InstrScheduling.cpp - Generic Instruction Scheduling support -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the llvm/CodeGen/InstrScheduling.h interface, along with // generic support routines for instruction scheduling. diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index bcdd1cfcfc..f6f3791734 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -1,4 +1,11 @@ //===- SchedGraph.cpp - Scheduling Graph Implementation -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Scheduling graph based on SSA graph plus extra dependence edges capturing // dependences due to machine resources (machine registers, CC registers, and diff --git a/lib/CodeGen/InstrSched/SchedGraphCommon.cpp b/lib/CodeGen/InstrSched/SchedGraphCommon.cpp index ec0e09527f..b75e3397cb 100644 --- a/lib/CodeGen/InstrSched/SchedGraphCommon.cpp +++ b/lib/CodeGen/InstrSched/SchedGraphCommon.cpp @@ -1,4 +1,11 @@ //===- SchedGraphCommon.cpp - Scheduling Graphs Base Class- ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Scheduling graph base class that contains common information for SchedGraph // and ModuloSchedGraph scheduling graphs. diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp index 20c0f8217a..a35600c0f0 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.cpp +++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp @@ -1,5 +1,12 @@ //===-- SchedPriorities.h - Encapsulate scheduling heuristics -------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Strategy: // Priority ordering rules: // (1) Max delay, which is the order of the heap S.candsAsHeap. diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp index 7ae2373764..90993b7a8d 100644 --- a/lib/CodeGen/InstrSelection/InstrForest.cpp +++ b/lib/CodeGen/InstrSelection/InstrForest.cpp @@ -1,4 +1,11 @@ //===-- InstrForest.cpp - Build instruction forest for inst selection -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // The key goal is to group instructions into a single // tree if one or more of them might be potentially combined into a single diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index ae910b8921..32dc65e6e1 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -1,4 +1,11 @@ //===- InstrSelection.cpp - Machine Independent Inst Selection Driver -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Machine-independent driver file for instruction selection. This file // constructs a forest of BURG instruction trees and then uses the diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index c88fa23a90..f177e460b1 100644 --- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -1,4 +1,11 @@ //===-- InstrSelectionSupport.cpp -----------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Target-independent instruction selection code. See SparcInstrSelection.cpp // for usage. diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index 2a9b70d3b0..50b90b1fdc 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -1,5 +1,12 @@ //===-- LiveVariables.cpp - Live Variable Analysis for Machine Code -------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file implements the LiveVariable analysis pass. For each machine // instruction in the function, this pass calculates the set of registers that // are immediately dead after the instruction (i.e., the instruction calculates diff --git a/lib/CodeGen/MachineCodeEmitter.cpp b/lib/CodeGen/MachineCodeEmitter.cpp index 47bdc8b779..6e56594a10 100644 --- a/lib/CodeGen/MachineCodeEmitter.cpp +++ b/lib/CodeGen/MachineCodeEmitter.cpp @@ -1,4 +1,11 @@ //===-- MachineCodeEmitter.cpp - Implement the MachineCodeEmitter itf -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the MachineCodeEmitter interface. // diff --git a/lib/CodeGen/MachineCodeForInstruction.cpp b/lib/CodeGen/MachineCodeForInstruction.cpp index 7b2fb75c65..36bafe2ff9 100644 --- a/lib/CodeGen/MachineCodeForInstruction.cpp +++ b/lib/CodeGen/MachineCodeForInstruction.cpp @@ -1,4 +1,11 @@ //===-- MachineCodeForInstruction.cpp -------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Representation of the sequence of machine instructions created for a single // VM instruction. Additionally records information about hidden and implicit diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index f7aadc317e..c1eb30a196 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -1,5 +1,12 @@ //===-- MachineFunction.cpp -----------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Collect native machine code information for a function. This allows // target-specific information about the generated code to be stored with each // function. diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index c8e930e7d4..7fb8b4569e 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -1,5 +1,12 @@ //===-- MachineInstr.cpp --------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineInstr.h" diff --git a/lib/CodeGen/MachineInstrAnnot.cpp b/lib/CodeGen/MachineInstrAnnot.cpp index 419e10ecd3..bf4e68e112 100644 --- a/lib/CodeGen/MachineInstrAnnot.cpp +++ b/lib/CodeGen/MachineInstrAnnot.cpp @@ -1,5 +1,12 @@ //===-- MachineInstrAnnot.cpp ---------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file defines Annotations used to pass information between code // generation phases. // diff --git a/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp b/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp index 68b8ee39d5..6318c5ab46 100644 --- a/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp +++ b/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp @@ -1,5 +1,12 @@ //===- ModuloSchedGraph.cpp - Modulo Scheduling Graph and Set -*- C++ -*---===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Description here //===----------------------------------------------------------------------===// diff --git a/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp b/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp index 49562f49f5..91ec6c28f5 100644 --- a/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp +++ b/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp @@ -1,4 +1,11 @@ //===-- ModuloScheduling.cpp - Software Pipeling Approach - SMS -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // The is a software pipelining pass based on the Swing Modulo Scheduling // algorithm (SMS). diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp index cce1c5d94a..5a988bafe3 100644 --- a/lib/CodeGen/PHIElimination.cpp +++ b/lib/CodeGen/PHIElimination.cpp @@ -1,4 +1,11 @@ //===-- PhiElimination.cpp - Eliminate PHI nodes by inserting copies ------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass eliminates machine instruction PHI nodes by inserting copy // instructions. This destroys SSA information, but is the desired input for diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index 86f354eb32..7a51a53ad8 100644 --- a/lib/CodeGen/Passes.cpp +++ b/lib/CodeGen/Passes.cpp @@ -1,4 +1,11 @@ //===-- Passes.cpp - Target independent code generation passes -*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines interfaces to access the target independent code // generation passes provided by the LLVM backend. diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index 0ceb866965..a60b8b127b 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -1,4 +1,11 @@ //===-- PrologEpilogInserter.cpp - Insert Prolog/Epilog code in function --===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is responsible for finalizing the functions frame layout, saving // callee saved registers, and for emitting prolog & epilog code for the diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp index ce502d6e31..fcd299b28c 100644 --- a/lib/CodeGen/RegAlloc/IGNode.cpp +++ b/lib/CodeGen/RegAlloc/IGNode.cpp @@ -1,5 +1,12 @@ //===-- IGNode.cpp --------------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // class IGNode for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp index bc28ed47d4..b213dc7e7d 100644 --- a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp +++ b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp @@ -1,5 +1,12 @@ //===-- InterferenceGraph.cpp ---------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Interference graph for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp index 928d04538c..0f7958c88e 100644 --- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp +++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp @@ -1,5 +1,12 @@ //===-- LiveRangeInfo.cpp -------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Live range construction for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 616b012d77..00397d5286 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -1,5 +1,12 @@ //===-- PhyRegAlloc.cpp ---------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Traditional graph-coloring global register allocator currently used // by the SPARC back-end. // diff --git a/lib/CodeGen/RegAlloc/RegClass.cpp b/lib/CodeGen/RegAlloc/RegClass.cpp index 12582cc782..ca53a9f518 100644 --- a/lib/CodeGen/RegAlloc/RegClass.cpp +++ b/lib/CodeGen/RegAlloc/RegClass.cpp @@ -1,5 +1,12 @@ //===-- RegClass.cpp -----------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // class RegClass for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index 6b71e288e7..92aec7b72d 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -1,4 +1,11 @@ //===-- RegAllocLocal.cpp - A BasicBlock generic register allocator -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This register allocator allocates registers to a basic block at a time, // attempting to keep values in registers and reusing registers as appropriate. diff --git a/lib/CodeGen/RegAllocSimple.cpp b/lib/CodeGen/RegAllocSimple.cpp index dbf731ecc7..a210790b8d 100644 --- a/lib/CodeGen/RegAllocSimple.cpp +++ b/lib/CodeGen/RegAllocSimple.cpp @@ -1,4 +1,11 @@ //===-- RegAllocSimple.cpp - A simple generic register allocator ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a simple register allocator. *Very* simple: It immediate // spills every value right after it is computed, and it reloads all used diff --git a/lib/CodeGen/SelectionDAG/DAGBuilder.cpp b/lib/CodeGen/SelectionDAG/DAGBuilder.cpp index 03bf14bc28..a972ddf602 100644 --- a/lib/CodeGen/SelectionDAG/DAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/DAGBuilder.cpp @@ -1,4 +1,11 @@ //===-- DAGBuilder.cpp - Turn an LLVM BasicBlock into a DAG for selection -===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file turns an LLVM BasicBlock into a target independent SelectionDAG in // preparation for target specific optimizations and instruction selection. diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 6d7eeee0da..58a9639c92 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -1,4 +1,11 @@ //===-- SelectionDAG.cpp - Implement the SelectionDAG* classes ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the SelectionDAG* classes, which are used to perform // DAG-based instruction selection in a target-specific manner. diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index d25abfb63f..38bd14ab72 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -1,5 +1,12 @@ //===-- ExecutionEngine.cpp - Common Implementation shared by EEs ---------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file defines the common interface used by the various execution engine // subclasses. // diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 69e746d159..f3191c3275 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -1,5 +1,12 @@ //===-- Execution.cpp - Implement code to simulate the program ------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file contains the actual instruction interpreter. // //===----------------------------------------------------------------------===// diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 44ba87f3b3..a859f181a1 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -1,5 +1,12 @@ //===-- ExternalFunctions.cpp - Implement External Functions --------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file contains both code to deal with invoking "external" functions, but // also contains code that implements "exported" external functions. // diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp index 4bb317db9e..d3b6fba3e6 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -1,4 +1,11 @@ //===- Interpreter.cpp - Top-Level LLVM Interpreter Implementation --------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the top-level functionality for the LLVM interpreter. // This interpreter is designed to be a very simple, portable, inefficient diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp index 6df6088a3a..6162e938ab 100644 --- a/lib/ExecutionEngine/JIT/Intercept.cpp +++ b/lib/ExecutionEngine/JIT/Intercept.cpp @@ -1,4 +1,11 @@ //===-- Intercept.cpp - System function interception routines -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // If a function call occurs to an external function, the JIT is designed to use // the dynamic loader interface to find a function to call. This is useful for diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 7309b80c4b..6e229b9e8c 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -1,4 +1,11 @@ //===-- JIT.cpp - LLVM Just in Time Compiler ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the top-level support for creating a Just-In-Time // compiler for the current architecture. diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 6dd2d56f7f..98f526a5f5 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -1,4 +1,11 @@ //===-- Emitter.cpp - Write machine code to executable memory -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines a MachineCodeEmitter object that is used by Jello to write // machine code to memory and remember where relocatable values lie. diff --git a/lib/ExecutionEngine/JIT/VM.cpp b/lib/ExecutionEngine/JIT/VM.cpp index ba1ecdf31a..c6c2fdf2cf 100644 --- a/lib/ExecutionEngine/JIT/VM.cpp +++ b/lib/ExecutionEngine/JIT/VM.cpp @@ -1,4 +1,11 @@ //===-- VM.cpp - LLVM Just in Time Compiler -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This tool implements a just-in-time compiler for LLVM, allowing direct // execution of LLVM bytecode in an efficient manner. diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index a71572bd33..bd8ec8c9ce 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1,4 +1,11 @@ //===- Linker.cpp - Module Linker Implementation --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the LLVM module linker. // diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp index 1b42aae142..890b18de06 100644 --- a/lib/Support/Annotation.cpp +++ b/lib/Support/Annotation.cpp @@ -1,4 +1,11 @@ //===-- Annotation.cpp - Implement the Annotation Classes -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the AnnotationManager class. // diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 807ff165b0..de895c9117 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -1,4 +1,11 @@ //===-- CommandLine.cpp - Command line parser implementation --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This class implements a command line argument processor that is useful when // creating a tool. It provides a simple, minimalistic interface that is easily diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index c9d8ae6fbb..a9e1204de5 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -1,4 +1,11 @@ //===-- ConstantRange.cpp - ConstantRange implementation ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Represent a range of possible values that may occur when the program is run // for an integral value. This keeps track of a lower and upper bound for the diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index f87cddfe4e..895abbb1f7 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -1,4 +1,11 @@ //===-- Debug.cpp - An easy way to add debug output to your code ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a handle way of adding debugging information to your // code, without it being enabled all of the time, and without having to add diff --git a/lib/Support/DynamicLinker.cpp b/lib/Support/DynamicLinker.cpp index 7c52d3bb5b..05a63f3d76 100644 --- a/lib/Support/DynamicLinker.cpp +++ b/lib/Support/DynamicLinker.cpp @@ -1,4 +1,11 @@ //===-- DynamicLinker.cpp - Implement DynamicLinker interface -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Lightweight interface to dynamic library linking and loading, and dynamic // symbol lookup functionality, in whatever form the operating system diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index ca4603628c..5d30cc8c89 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -1,4 +1,11 @@ //===- Support/FileUtilities.cpp - File System Utilities ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a family of utility functions which are useful for doing // various things with files. diff --git a/lib/Support/LeakDetector.cpp b/lib/Support/LeakDetector.cpp index ecc4868d2e..24c946ab6e 100644 --- a/lib/Support/LeakDetector.cpp +++ b/lib/Support/LeakDetector.cpp @@ -1,4 +1,11 @@ //===-- LeakDetector.cpp - Implement LeakDetector interface ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the LeakDetector class. // diff --git a/lib/Support/Mangler.cpp b/lib/Support/Mangler.cpp index d9186a9c93..44c697d3d8 100644 --- a/lib/Support/Mangler.cpp +++ b/lib/Support/Mangler.cpp @@ -1,4 +1,11 @@ //===-- Mangler.cpp - Self-contained c/asm llvm name mangler --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Unified name mangler for CWriter and assembly backends. // diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 4cacd01613..1582a10c65 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -1,4 +1,11 @@ //===-- PluginLoader.cpp - Implement -load command line option ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the -load command line option processor. When // linked into a program, this new command line option is available that allows diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp index 563147eabf..efc5f71257 100644 --- a/lib/Support/Signals.cpp +++ b/lib/Support/Signals.cpp @@ -1,4 +1,11 @@ //===- Signals.cpp - Signal Handling support ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines some helpful functions for dealing with the possibility of // Unix signals occuring while your program is running. diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index ae9f57f80e..c60a85cdeb 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -1,4 +1,11 @@ //===-- Statistic.cpp - Easy way to expose stats information --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the 'Statistic' class, which is designed to be an easy // way to expose various success metrics from passes. These statistics are diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index e1af3f92ce..8c009ffb57 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -1,4 +1,11 @@ //===- SystemUtils.h - Utilities to do low-level system stuff --*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains functions used to do a variety of low-level, often // system-specific, tasks. diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 30a7fbb3bd..5e84f38852 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -1,4 +1,11 @@ //===-- Timer.cpp - Interval Timing Support -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Interval Timing implementation. // diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index 4ae896bd99..a66b868c22 100644 --- a/lib/Support/ToolRunner.cpp +++ b/lib/Support/ToolRunner.cpp @@ -1,4 +1,11 @@ //===-- ToolRunner.cpp ----------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the interfaces described in the ToolRunner.h file. // diff --git a/lib/Support/ValueHolder.cpp b/lib/Support/ValueHolder.cpp index e0806b538a..8661402b06 100644 --- a/lib/Support/ValueHolder.cpp +++ b/lib/Support/ValueHolder.cpp @@ -1,4 +1,11 @@ //===-- ValueHolder.cpp - Wrapper for Value implementation ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This class defines a simple subclass of User, which keeps a pointer to a // Value, which automatically updates when Value::replaceAllUsesWith is called. diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 00ad0e3bb1..f65d3d322e 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -1,4 +1,11 @@ //===-- Writer.cpp - Library for converting LLVM code to C ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This library converts LLVM code to C code, compilable by GCC. // diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 00ad0e3bb1..f65d3d322e 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -1,4 +1,11 @@ //===-- Writer.cpp - Library for converting LLVM code to C ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This library converts LLVM code to C code, compilable by GCC. // diff --git a/lib/Target/MRegisterInfo.cpp b/lib/Target/MRegisterInfo.cpp index 634a3c88d8..6f35815263 100644 --- a/lib/Target/MRegisterInfo.cpp +++ b/lib/Target/MRegisterInfo.cpp @@ -1,4 +1,11 @@ //===- MRegisterInfo.cpp - Target Register Information Implementation -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the MRegisterInfo interface. // diff --git a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp index 379639c0c5..2c45021f00 100644 --- a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp +++ b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp @@ -1,4 +1,11 @@ //===-- EmitBytecodeToAssembly.cpp - Emit bytecode to Sparc .s File --------==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the pass that writes LLVM bytecode as data to a sparc // assembly file. The bytecode gets assembled into a special bytecode section diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index cf4f294155..2a2ef27a29 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -1,4 +1,11 @@ //===- InstrScheduling.cpp - Generic Instruction Scheduling support -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the llvm/CodeGen/InstrScheduling.h interface, along with // generic support routines for instruction scheduling. diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index bcdd1cfcfc..f6f3791734 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -1,4 +1,11 @@ //===- SchedGraph.cpp - Scheduling Graph Implementation -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Scheduling graph based on SSA graph plus extra dependence edges capturing // dependences due to machine resources (machine registers, CC registers, and diff --git a/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp b/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp index ec0e09527f..b75e3397cb 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp @@ -1,4 +1,11 @@ //===- SchedGraphCommon.cpp - Scheduling Graphs Base Class- ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Scheduling graph base class that contains common information for SchedGraph // and ModuloSchedGraph scheduling graphs. diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp index 20c0f8217a..a35600c0f0 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp @@ -1,5 +1,12 @@ //===-- SchedPriorities.h - Encapsulate scheduling heuristics -------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Strategy: // Priority ordering rules: // (1) Max delay, which is the order of the heap S.candsAsHeap. diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index 7ae2373764..90993b7a8d 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -1,4 +1,11 @@ //===-- InstrForest.cpp - Build instruction forest for inst selection -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // The key goal is to group instructions into a single // tree if one or more of them might be potentially combined into a single diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index ae910b8921..32dc65e6e1 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -1,4 +1,11 @@ //===- InstrSelection.cpp - Machine Independent Inst Selection Driver -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Machine-independent driver file for instruction selection. This file // constructs a forest of BURG instruction trees and then uses the diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index c88fa23a90..f177e460b1 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -1,4 +1,11 @@ //===-- InstrSelectionSupport.cpp -----------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Target-independent instruction selection code. See SparcInstrSelection.cpp // for usage. diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp index 3968430ca5..c3716c9906 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp @@ -1,4 +1,11 @@ //===-- BBLiveVar.cpp - Live Variable Analysis for a BasicBlock -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This is a wrapper class for BasicBlock which is used by live var analysis. // diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp index 8c95eaa84f..26026d642a 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp @@ -1,4 +1,11 @@ //===-- FunctionLiveVarInfo.cpp - Live Variable Analysis for a Function ---===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This is the interface to function level live variable information that is // provided by live variable analysis. diff --git a/lib/Target/SparcV9/LiveVar/ValueSet.cpp b/lib/Target/SparcV9/LiveVar/ValueSet.cpp index d50d1073f6..ba944cb8cc 100644 --- a/lib/Target/SparcV9/LiveVar/ValueSet.cpp +++ b/lib/Target/SparcV9/LiveVar/ValueSet.cpp @@ -1,4 +1,10 @@ - +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // FIXME: Eliminate this file. #include "llvm/CodeGen/ValueSet.h" diff --git a/lib/Target/SparcV9/MappingInfo.cpp b/lib/Target/SparcV9/MappingInfo.cpp index 5f496bf2ee..db03f13b97 100644 --- a/lib/Target/SparcV9/MappingInfo.cpp +++ b/lib/Target/SparcV9/MappingInfo.cpp @@ -1,4 +1,11 @@ //===- MappingInfo.cpp - create LLVM info and output to .s file ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains a FunctionPass called MappingInfoAsmPrinter, // which creates two maps: one between LLVM Instructions and MachineInstrs diff --git a/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp b/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp index 68b8ee39d5..6318c5ab46 100644 --- a/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp +++ b/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp @@ -1,5 +1,12 @@ //===- ModuloSchedGraph.cpp - Modulo Scheduling Graph and Set -*- C++ -*---===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Description here //===----------------------------------------------------------------------===// diff --git a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp index 49562f49f5..91ec6c28f5 100644 --- a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp +++ b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp @@ -1,4 +1,11 @@ //===-- ModuloScheduling.cpp - Software Pipeling Approach - SMS -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // The is a software pipelining pass based on the Swing Modulo Scheduling // algorithm (SMS). diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.cpp b/lib/Target/SparcV9/RegAlloc/IGNode.cpp index ce502d6e31..fcd299b28c 100644 --- a/lib/Target/SparcV9/RegAlloc/IGNode.cpp +++ b/lib/Target/SparcV9/RegAlloc/IGNode.cpp @@ -1,5 +1,12 @@ //===-- IGNode.cpp --------------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // class IGNode for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp index bc28ed47d4..b213dc7e7d 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp @@ -1,5 +1,12 @@ //===-- InterferenceGraph.cpp ---------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Interference graph for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp index 928d04538c..0f7958c88e 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp @@ -1,5 +1,12 @@ //===-- LiveRangeInfo.cpp -------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Live range construction for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 616b012d77..00397d5286 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -1,5 +1,12 @@ //===-- PhyRegAlloc.cpp ---------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Traditional graph-coloring global register allocator currently used // by the SPARC back-end. // diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.cpp b/lib/Target/SparcV9/RegAlloc/RegClass.cpp index 12582cc782..ca53a9f518 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.cpp +++ b/lib/Target/SparcV9/RegAlloc/RegClass.cpp @@ -1,5 +1,12 @@ //===-- RegClass.cpp -----------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // class RegClass for coloring-based register allocation for LLVM. // //===----------------------------------------------------------------------===// diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index bbcb12e528..50249e1e35 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -1,4 +1,11 @@ //===-- EmitAssembly.cpp - Emit Sparc Specific .s File ---------------------==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements all of the stuff necessary to output a .s file from // LLVM. The code in this file assumes that the specified module has already diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp index 4118b2b0df..15bb1bc2d3 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp @@ -1,4 +1,11 @@ //===-- SparcV9CodeEmitter.cpp --------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // SPARC-specific backend for emitting machine code to memory. // diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index b4b4702352..0a3ccc84e8 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -1,4 +1,11 @@ //===-- SparcInstrInfo.cpp ------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // //===----------------------------------------------------------------------===// diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index 9633b3128d..edd7eaa7fc 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -1,4 +1,11 @@ //===-- SparcInstrSelection.cpp -------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // BURS instruction selection for SPARC V9 architecture. // diff --git a/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp b/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp index 0dbcdf3cb9..2b22558e6d 100644 --- a/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp +++ b/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp @@ -1,5 +1,12 @@ //===-- PeepholeOpts.cpp --------------------------------------------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // Support for performing several peephole opts in one or a few passes over the // machine code of a method. // diff --git a/lib/Target/SparcV9/SparcV9PreSelection.cpp b/lib/Target/SparcV9/SparcV9PreSelection.cpp index f312471bd0..6f17b52b0a 100644 --- a/lib/Target/SparcV9/SparcV9PreSelection.cpp +++ b/lib/Target/SparcV9/SparcV9PreSelection.cpp @@ -1,4 +1,11 @@ //===- PreSelection.cpp - Specialize LLVM code for target machine ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the PreSelection pass which specializes LLVM code for a // target machine, while remaining in legal portable LLVM form and diff --git a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp index b74c7df344..ff7bd7d026 100644 --- a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp +++ b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp @@ -1,4 +1,11 @@ //===-- PrologEpilogCodeInserter.cpp - Insert Prolog & Epilog code for fn -===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Insert SAVE/RESTORE instructions for the function // diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp index 6248a83323..d6de5f9c0d 100644 --- a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp @@ -1,4 +1,11 @@ //===-- SparcRegClassInfo.cpp - Register class def'ns for Sparc -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the register classes used by the Sparc target description. // diff --git a/lib/Target/SparcV9/SparcV9RegInfo.cpp b/lib/Target/SparcV9/SparcV9RegInfo.cpp index 8dde4e96ca..1a48d9cf20 100644 --- a/lib/Target/SparcV9/SparcV9RegInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegInfo.cpp @@ -1,4 +1,11 @@ //===-- SparcRegInfo.cpp - Sparc Target Register Information --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains implementation of Sparc specific helper methods // used for register allocation. diff --git a/lib/Target/SparcV9/SparcV9SchedInfo.cpp b/lib/Target/SparcV9/SparcV9SchedInfo.cpp index 45c771e10f..fd03ad69d6 100644 --- a/lib/Target/SparcV9/SparcV9SchedInfo.cpp +++ b/lib/Target/SparcV9/SparcV9SchedInfo.cpp @@ -1,4 +1,11 @@ //===-- UltraSparcSchedInfo.cpp -------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Describe the scheduling characteristics of the UltraSparc // diff --git a/lib/Target/SparcV9/SparcV9StackSlots.cpp b/lib/Target/SparcV9/SparcV9StackSlots.cpp index eff679cb4e..44103a614b 100644 --- a/lib/Target/SparcV9/SparcV9StackSlots.cpp +++ b/lib/Target/SparcV9/SparcV9StackSlots.cpp @@ -1,4 +1,11 @@ //===- StackSlots.cpp - Specialize LLVM code for target machine ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass adds 2 empty slots at the top of function stack. These two slots // are later used during code reoptimization for spilling the register values diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp index 59e84f92f1..f1742ec007 100644 --- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp +++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp @@ -1,4 +1,11 @@ //===-- Sparc.cpp - General implementation file for the Sparc Target ------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains the code for the Sparc Target that does not fit in any of // the other files in this directory. diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 22efcc598a..a377fd0d7f 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -1,4 +1,11 @@ //===-- TargetData.cpp - Data size & alignment routines --------------------==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines target properties related to datatype size/offset/alignment // information. It uses lazy annotations to cache information about how diff --git a/lib/Target/TargetInstrInfo.cpp b/lib/Target/TargetInstrInfo.cpp index aa94fbc2ae..f377d67b66 100644 --- a/lib/Target/TargetInstrInfo.cpp +++ b/lib/Target/TargetInstrInfo.cpp @@ -1,4 +1,11 @@ //===-- TargetInstrInfo.cpp - Target Instruction Information --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // //===----------------------------------------------------------------------===// diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index 24788e3c4d..b7c1b342e1 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -1,4 +1,11 @@ //===-- TargetMachine.cpp - General Target Information ---------------------==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file describes the general parts of a Target machine. // This file also implements TargetCacheInfo. diff --git a/lib/Target/TargetSchedInfo.cpp b/lib/Target/TargetSchedInfo.cpp index f70f374dab..0dbde45c38 100644 --- a/lib/Target/TargetSchedInfo.cpp +++ b/lib/Target/TargetSchedInfo.cpp @@ -1,4 +1,11 @@ //===-- SchedInfo.cpp - Generic code to support target schedulers ----------==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the generic part of a Scheduler description for a // target. This functionality is defined in the llvm/Target/SchedInfo.h file. diff --git a/lib/Target/X86/FloatingPoint.cpp b/lib/Target/X86/FloatingPoint.cpp index 23d4e17f8e..07e58ba171 100644 --- a/lib/Target/X86/FloatingPoint.cpp +++ b/lib/Target/X86/FloatingPoint.cpp @@ -1,4 +1,11 @@ //===-- FloatingPoint.cpp - Floating point Reg -> Stack converter ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the pass which converts floating point instructions from // virtual registers into register stack instructions. diff --git a/lib/Target/X86/InstSelectPattern.cpp b/lib/Target/X86/InstSelectPattern.cpp index 74f540a8da..434ceee91c 100644 --- a/lib/Target/X86/InstSelectPattern.cpp +++ b/lib/Target/X86/InstSelectPattern.cpp @@ -1,4 +1,11 @@ //===-- InstSelectPattern.cpp - A pattern matching inst selector for X86 --===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines a pattern matching instruction selector for X86. // diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 23a0f4221f..e151567264 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -1,4 +1,11 @@ //===-- InstSelectSimple.cpp - A simple instruction selector for x86 ------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines a simple peephole instruction selector for the x86 target // diff --git a/lib/Target/X86/PeepholeOptimizer.cpp b/lib/Target/X86/PeepholeOptimizer.cpp index efb6cc3e6a..fbc84f7e87 100644 --- a/lib/Target/X86/PeepholeOptimizer.cpp +++ b/lib/Target/X86/PeepholeOptimizer.cpp @@ -1,4 +1,11 @@ //===-- PeepholeOptimizer.cpp - X86 Peephole Optimizer --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains a peephole optimizer for the X86. // diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index 3df8400896..c8072da052 100644 --- a/lib/Target/X86/Printer.cpp +++ b/lib/Target/X86/Printer.cpp @@ -1,4 +1,11 @@ //===-- X86/Printer.cpp - Convert X86 LLVM code to Intel assembly ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains a printer that converts from our internal // representation of machine-dependent LLVM code to Intel-format diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 3df8400896..c8072da052 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -1,4 +1,11 @@ //===-- X86/Printer.cpp - Convert X86 LLVM code to Intel assembly ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains a printer that converts from our internal // representation of machine-dependent LLVM code to Intel-format diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index f3fd142ed8..f49fde58d2 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -1,4 +1,11 @@ //===-- X86/X86CodeEmitter.cpp - Convert X86 code to machine code ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains the pass that transforms the X86 machine instructions into // actual executable machine code. diff --git a/lib/Target/X86/X86FloatingPoint.cpp b/lib/Target/X86/X86FloatingPoint.cpp index 23d4e17f8e..07e58ba171 100644 --- a/lib/Target/X86/X86FloatingPoint.cpp +++ b/lib/Target/X86/X86FloatingPoint.cpp @@ -1,4 +1,11 @@ //===-- FloatingPoint.cpp - Floating point Reg -> Stack converter ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the pass which converts floating point instructions from // virtual registers into register stack instructions. diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp index 74f540a8da..434ceee91c 100644 --- a/lib/Target/X86/X86ISelPattern.cpp +++ b/lib/Target/X86/X86ISelPattern.cpp @@ -1,4 +1,11 @@ //===-- InstSelectPattern.cpp - A pattern matching inst selector for X86 --===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines a pattern matching instruction selector for X86. // diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index 23a0f4221f..e151567264 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -1,4 +1,11 @@ //===-- InstSelectSimple.cpp - A simple instruction selector for x86 ------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines a simple peephole instruction selector for the x86 target // diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index 6988415933..012ceadff0 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -1,4 +1,11 @@ //===- X86InstrInfo.cpp - X86 Instruction Information -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains the X86 implementation of the TargetInstrInfo class. // diff --git a/lib/Target/X86/X86PeepholeOpt.cpp b/lib/Target/X86/X86PeepholeOpt.cpp index efb6cc3e6a..fbc84f7e87 100644 --- a/lib/Target/X86/X86PeepholeOpt.cpp +++ b/lib/Target/X86/X86PeepholeOpt.cpp @@ -1,4 +1,11 @@ //===-- PeepholeOptimizer.cpp - X86 Peephole Optimizer --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains a peephole optimizer for the X86. // diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index b201fda107..e6b6319b80 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -1,4 +1,11 @@ //===- X86RegisterInfo.cpp - X86 Register Information -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file contains the X86 implementation of the MRegisterInfo class. This // file is responsible for the frame pointer elimination optimization on X86. diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 3e4ef1cd71..d094d90066 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -1,5 +1,12 @@ //===-- X86TargetMachine.cpp - Define TargetMachine for the X86 -----------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file defines the X86 specific subclass of TargetMachine. // //===----------------------------------------------------------------------===// diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 8408a297ab..d3e9287de4 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -1,4 +1,11 @@ //===- ExprTypeConvert.cpp - Code to change an LLVM Expr Type -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the part of level raising that checks to see if it is // possible to coerce an entire expression tree into a different type. If diff --git a/lib/Transforms/Hello/Hello.cpp b/lib/Transforms/Hello/Hello.cpp index 6ca450f007..a71bd34288 100644 --- a/lib/Transforms/Hello/Hello.cpp +++ b/lib/Transforms/Hello/Hello.cpp @@ -1,4 +1,11 @@ //===- Hello.cpp - Example code from "Writing an LLVM Pass" ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements two versions of the LLVM "Hello World" pass described // in docs/WritingAnLLVMPass.html diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 8372d3e0a6..e353a45546 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -1,4 +1,11 @@ //===- ConstantMerge.cpp - Merge duplicate global constants ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the interface to a pass that merges duplicate global // constants together into a single constant that is shared. This is useful diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index ece26d5fae..3442eeddf7 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -1,4 +1,11 @@ //===-- DeadArgumentElimination.cpp - Eliminate dead arguments ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass deletes dead arguments from internal functions. Dead argument // elimination removes arguments which are directly dead, as well as arguments diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index becbf4a2d0..f0d4422522 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -1,4 +1,11 @@ //===- DeadTypeElimination.cpp - Eliminate unused types for symbol table --===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is used to cleanup the output of GCC. It eliminate names for types // that are unused in the entire translation unit, using the FindUsedTypes pass. diff --git a/lib/Transforms/IPO/ExtractFunction.cpp b/lib/Transforms/IPO/ExtractFunction.cpp index 51c4e00987..1656c512dd 100644 --- a/lib/Transforms/IPO/ExtractFunction.cpp +++ b/lib/Transforms/IPO/ExtractFunction.cpp @@ -1,4 +1,11 @@ +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// #include "llvm/Transforms/IPO.h" #include "llvm/Pass.h" #include "llvm/Module.h" diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index b6c980b56e..93e1745b6d 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -1,4 +1,11 @@ //===- FunctionResolution.cpp - Resolve declarations to implementations ---===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Loop over the functions that are in the module and look for functions that // have the same name. More often than not, there will be things like: diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index b47b365d59..dc400269e6 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -1,4 +1,11 @@ //===-- GlobalDCE.cpp - DCE unreachable internal functions ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This transform is designed to eliminate unreachable internal globals from the // program. It uses an aggressive algorithm, searching out globals that are diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 8568235c83..169e57745a 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -1,4 +1,11 @@ //===- InlineSimple.cpp - Code to perform simple function inlining --------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements bottom-up inlining of functions into callees. // diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 7f75f1453f..503879e430 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -1,4 +1,11 @@ //===- InlineCommon.cpp - Code common to all inliners ---------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the code shared between the LLVM inliners. This // implements all of the boring mechanics of the bottom-up inlining. diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 7bca45970a..92d389a33d 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -1,4 +1,11 @@ //===-- Internalize.cpp - Mark functions internal -------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass loops over all of the functions in the input module, looking for a // main function. If a main function is found, all other functions and all diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index 36b0c388b4..3109fb120d 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -1,4 +1,11 @@ //===- LowerSetJmp.cpp - Code pertaining to lowering set/long jumps -------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the lowering of setjmp and longjmp to use the // LLVM invoke and unwind instructions as necessary. diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index 736da63beb..dfaf8a89c6 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -1,4 +1,11 @@ //===- MutateStructTypes.cpp - Change struct defns ------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is used to change structure accesses and type definitions in some // way. It can be used to arbitrarily permute structure fields, safely, without diff --git a/lib/Transforms/IPO/Parallelize.cpp b/lib/Transforms/IPO/Parallelize.cpp index 09b7dc21cd..77e6ed3040 100644 --- a/lib/Transforms/IPO/Parallelize.cpp +++ b/lib/Transforms/IPO/Parallelize.cpp @@ -1,4 +1,11 @@ //===- Parallelize.cpp - Auto parallelization using DS Graphs -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a pass that automatically parallelizes a program, // using the Cilk multi-threaded runtime system to execute parallel code. diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index 4008ea6d63..b377a8befe 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -1,4 +1,11 @@ //===- PruneEH.cpp - Pass which deletes unused exception handlers ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a simple interprocedural pass which walks the // call-graph, turning invoke instructions into calls, iff the callee cannot diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index d214d2edfe..81abda0006 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -1,4 +1,11 @@ //===- RaiseAllocations.cpp - Convert %malloc & %free calls to insts ------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the RaiseAllocations pass which convert malloc and free // calls to malloc and free instructions. diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index be36462869..012fa22770 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -1,4 +1,11 @@ //===- SimpleStructMutation.cpp - Swap structure elements around ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass does a simple transformation that swaps all of the elements of the // struct types in the program around. diff --git a/lib/Transforms/Instrumentation/EmitFunctions.cpp b/lib/Transforms/Instrumentation/EmitFunctions.cpp index 6961c53a71..9c395a9c1f 100644 --- a/lib/Transforms/Instrumentation/EmitFunctions.cpp +++ b/lib/Transforms/Instrumentation/EmitFunctions.cpp @@ -1,4 +1,11 @@ //===-- EmitFunctions.cpp - interface to insert instrumentation -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This inserts a global constant table with function pointers all along // diff --git a/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp b/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp index 42fa74c376..6c7bb5f360 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp @@ -1,4 +1,11 @@ //===-- CombineBranch.cpp -------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Pass to instrument loops // diff --git a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp index 8f6ddf9cb9..6a7f50e333 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp @@ -1,4 +1,11 @@ //===-- EdgeCode.cpp - generate LLVM instrumentation code -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// //It implements the class EdgeCode: which provides //support for inserting "appropriate" instrumentation at //designated points in the graph diff --git a/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp b/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp index f0e430125e..cae699a8d6 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp @@ -1,4 +1,11 @@ //===-- Graph.cpp - Implements Graph class --------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This implements Graph for helping in trace generation This graph gets used by // "ProfilePaths" class. diff --git a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp index fd44d8eed1..66b8ccd6c4 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp @@ -1,4 +1,11 @@ //===- GraphAuxiliary.cpp - Auxiliary functions on graph ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // auxiliary function associated with graph: they all operate on graph, and help // in inserting instrumentation for trace generation diff --git a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp index d2e8d14e84..b5e9d8c30c 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp @@ -1,4 +1,11 @@ //===-- InstLoops.cpp -----------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Pass to instrument loops // diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index 7f0bfa8231..d4973be25e 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -1,4 +1,11 @@ //===-- ProfilePaths.cpp - interface to insert instrumentation --*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This inserts instrumentation for counting execution of paths though a given // function Its implemented as a "Function" Pass, and called using opt diff --git a/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp b/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp index 3310488a33..58b3840587 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp @@ -1,4 +1,11 @@ //===- RetracePath.cpp ----------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Retraces a path of BasicBlock, given a path number and a graph! // diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index d4fa79c88f..95d31898a3 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -1,4 +1,11 @@ //===- TraceValues.cpp - Value Tracing for debugging ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Support for inserting LLVM code to print values at basic block and function // exits. diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index b02106a219..cf64aea1cd 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -1,4 +1,11 @@ //===- LevelRaise.cpp - Code to change LLVM to higher level ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the 'raising' part of the LevelChange API. This is // useful because, in general, it makes the LLVM code terser and easier to diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 3e11241f19..2735f95d89 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -1,4 +1,11 @@ //===- ADCE.cpp - Code to perform aggressive dead code elimination --------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements "aggressive" dead code elimination. ADCE is DCe where // values are assumed to be dead until proven otherwise. This is similar to diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index 4b8e9513c8..ceef34e54e 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -1,4 +1,11 @@ //===- ConstantProp.cpp - Code to perform Simple Constant Propagation -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements constant propagation and merging: // diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp index 5bc34b8aa3..8e6a2ae5b8 100644 --- a/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp @@ -1,4 +1,11 @@ //===- CorrelatedExprs.cpp - Pass to detect and eliminated c.e.'s ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Correlated Expression Elimination propagates information from conditional // branches to blocks dominated by destinations of the branch. It propagates diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 36a597a19d..e3fc8de396 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -1,4 +1,11 @@ //===- DCE.cpp - Code to perform dead code elimination --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements dead inst elimination and dead code elimination. // diff --git a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp index 79b6aead20..d6aee14f24 100644 --- a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp +++ b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp @@ -1,4 +1,11 @@ //===- llvm/Transforms/DecomposeMultiDimRefs.cpp - Lower array refs to 1D -===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // DecomposeMultiDimRefs - Convert multi-dimensional references consisting of // any combination of 2 or more array and structure indices into a sequence of diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index 9e1c44080a..caf68bc1c8 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -1,4 +1,11 @@ //===-- GCSE.cpp - SSA based Global Common Subexpr Elimination ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is designed to be a very quick global transformation that // eliminates global common subexpressions from a function. It does this by diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index ea27715dbe..1744fe41b2 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -1,4 +1,11 @@ //===- IndVarSimplify.cpp - Induction Variable Elimination ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Guarantees that all loops with identifiable, linear, induction variables will // be transformed to have a single, canonical, induction variable. After this diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index d69176f343..91c549d495 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -1,4 +1,11 @@ //===- InstructionCombining.cpp - Combine multiple instructions -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // InstructionCombining - Combine instructions to form fewer, simple // instructions. This pass does not modify the CFG This pass is where algebraic diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 0512bcb2f5..51a4d9e249 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -1,4 +1,11 @@ //===-- LICM.cpp - Loop Invariant Code Motion Pass ------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is a simple loop invariant code motion pass. An interesting aspect // of this pass is that it uses alias analysis for two purposes: diff --git a/lib/Transforms/Scalar/PRE.cpp b/lib/Transforms/Scalar/PRE.cpp index 77711caa0d..fad5789d5a 100644 --- a/lib/Transforms/Scalar/PRE.cpp +++ b/lib/Transforms/Scalar/PRE.cpp @@ -1,4 +1,11 @@ //===- PRE.cpp - Partial Redundancy Elimination ---------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the well-known Partial Redundancy Elimination // optimization, using an SSA formulation based on e-paths. See this paper for diff --git a/lib/Transforms/Scalar/PiNodeInsertion.cpp b/lib/Transforms/Scalar/PiNodeInsertion.cpp index 6e0562dddc..b5011af286 100644 --- a/lib/Transforms/Scalar/PiNodeInsertion.cpp +++ b/lib/Transforms/Scalar/PiNodeInsertion.cpp @@ -1,4 +1,11 @@ //===- PiNodeInsertion.cpp - Insert Pi nodes into a program ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // PiNodeInsertion - This pass inserts single entry Phi nodes into basic blocks // that are preceded by a conditional branch, where the branch gives diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 7d34df48eb..822a2d8947 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -1,4 +1,11 @@ //===- Reassociate.cpp - Reassociate binary expressions -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass reassociates commutative expressions in an order that is designed // to promote better constant propagation, GCSE, LICM, PRE... diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 301d1ce325..01e3e26ab5 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -1,4 +1,11 @@ //===- SCCP.cpp - Sparse Conditional Constant Propagation -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements sparse conditional constant propagation and merging: // diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 4b23ea2fbd..70f4dae3fd 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1,4 +1,11 @@ //===- ScalarReplAggregates.cpp - Scalar Replacement of Aggregates --------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This transformation implements the well known scalar replacement of // aggregates transformation. This xform breaks up alloca instructions of diff --git a/lib/Transforms/Scalar/SimplifyCFG.cpp b/lib/Transforms/Scalar/SimplifyCFG.cpp index 648cc91b80..224d6c5f9a 100644 --- a/lib/Transforms/Scalar/SimplifyCFG.cpp +++ b/lib/Transforms/Scalar/SimplifyCFG.cpp @@ -1,4 +1,11 @@ //===- SimplifyCFG.cpp - CFG Simplification Pass --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements dead code elimination and basic block merging. // diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index 99e596e8f2..58395c55ab 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -1,4 +1,11 @@ //===- SymbolStripping.cpp - Strip symbols for functions and modules ------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements stripping symbols out of symbol tables. // diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 688119805a..d0a7765818 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -1,4 +1,11 @@ //===- TailDuplication.cpp - Simplify CFG through tail duplication --------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass performs a limited form of tail duplication, intended to simplify // CFGs by removing some unconditional branches. This pass is necessary to diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 447c0ae849..d07f4e857e 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -1,4 +1,11 @@ //===- TailRecursionElimination.cpp - Eliminate Tail Calls ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements tail recursion elimination. // diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index 820dd3878e..3a1d51c3a0 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -1,4 +1,11 @@ //===- TransformInternals.cpp - Implement shared functions for transforms -===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines shared functions used by the different components of the // Transforms library. diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index d5f7f1f03e..22fd555a46 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -1,4 +1,11 @@ //===-- BasicBlockUtils.cpp - BasicBlock Utilities -------------------------==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This family of functions perform manipulations on basic blocks, and // instructions contained within basic blocks. diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index 99b1b2dfd0..8f8f0eea2d 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -1,4 +1,11 @@ //===- BreakCriticalEdges.cpp - Critical Edge Elimination Pass ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // BreakCriticalEdges pass - Break all of the critical edges in the CFG by // inserting a dummy basic block. This pass may be "required" by passes that diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index 0a16eb9bb2..e0312f2efb 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -1,4 +1,11 @@ //===- CloneFunction.cpp - Clone a function into another function ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the CloneFunctionInto interface, which is used as the // low-level function cloner. This is used by the CloneFunction and function diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp index 2a7d1ed586..cc22c7214a 100644 --- a/lib/Transforms/Utils/CloneModule.cpp +++ b/lib/Transforms/Utils/CloneModule.cpp @@ -1,4 +1,11 @@ //===- CloneModule.cpp - Clone an entire module ---------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the CloneModule interface which makes a copy of an // entire module. diff --git a/lib/Transforms/Utils/CloneTrace.cpp b/lib/Transforms/Utils/CloneTrace.cpp index 2890b9e2b1..9d995464bf 100644 --- a/lib/Transforms/Utils/CloneTrace.cpp +++ b/lib/Transforms/Utils/CloneTrace.cpp @@ -1,4 +1,11 @@ //===- CloneTrace.cpp - Clone a trace -------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the CloneTrace interface, which is used // when writing runtime optimizations. It takes a vector of basic blocks diff --git a/lib/Transforms/Utils/DemoteRegToStack.cpp b/lib/Transforms/Utils/DemoteRegToStack.cpp index 18266fb4ce..a720eb3eba 100644 --- a/lib/Transforms/Utils/DemoteRegToStack.cpp +++ b/lib/Transforms/Utils/DemoteRegToStack.cpp @@ -1,5 +1,12 @@ //===- DemoteRegToStack.cpp - Move a virtual reg. to stack ----------------===// // +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// // This file provide the function DemoteRegToStack(). This function takes a // virtual register computed by an Instruction& X and replaces it with a slot in // the stack frame, allocated via alloca. It returns the pointer to the diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 592babc1f9..735142b78c 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -1,4 +1,11 @@ //===- InlineFunction.cpp - Code to perform function inlining -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements inlining of a function into a call site, resolving // parameters and the return value as appropriate. diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index a71572bd33..bd8ec8c9ce 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -1,4 +1,11 @@ //===- Linker.cpp - Module Linker Implementation --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the LLVM module linker. // diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 52973f8724..2f9b07ca94 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -1,4 +1,11 @@ //===-- Local.cpp - Functions to perform local transformations ------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This family of functions perform various local transformations to the // program. diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index b964d34a6a..a1f86486b5 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -1,4 +1,11 @@ //===- LoopSimplify.cpp - Loop Canonicalization Pass ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass performs several transformations to transform natural loops into a // simpler form, which makes subsequent analyses and transformations simpler and diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index be66edf9fa..96008881bb 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -1,4 +1,11 @@ //===- LowerAllocations.cpp - Reduce malloc & free insts to calls ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // The LowerAllocations transformation is a target dependent tranformation // because it depends on the size of data types and alignment constraints. diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 00d71b2151..4885d96f19 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -1,4 +1,11 @@ //===- LowerInvoke.cpp - Eliminate Invoke & Unwind instructions -----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This transformation is designed for use by code generators which do not yet // support stack unwinding. This pass gives them the ability to execute any diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index f2608d9ef0..a45192bb0c 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -1,4 +1,11 @@ //===- LowerSwitch.cpp - Eliminate Switch instructions --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // The LowerSwitch transformation rewrites switch statements with a sequence of // branches, which allows targets to get away with not implementing the switch diff --git a/lib/Transforms/Utils/Mem2Reg.cpp b/lib/Transforms/Utils/Mem2Reg.cpp index 5203394099..d915155ed4 100644 --- a/lib/Transforms/Utils/Mem2Reg.cpp +++ b/lib/Transforms/Utils/Mem2Reg.cpp @@ -1,4 +1,11 @@ //===- Mem2Reg.cpp - The -mem2reg pass, a wrapper around the Utils lib ----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is a simple pass wrapper around the PromoteMemToReg function call // exposed by the Utils library. diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index 0292f9e770..f920718c3a 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -1,4 +1,11 @@ //===- PromoteMemoryToRegister.cpp - Convert allocas to registers ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file promote memory references to be register references. It promotes // alloca instructions which only have loads and stores as uses. An alloca is diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 305fbd85a2..a5f54b1326 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1,4 +1,11 @@ //===- SimplifyCFG.cpp - Code to perform CFG simplification ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Peephole optimize the CFG. // diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index ddce921d45..180871b093 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -1,4 +1,11 @@ //===- UnifyFunctionExitNodes.cpp - Make all functions have a single exit -===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This pass is used to ensure that functions have at most one return // instruction in them. Additionally, it keeps track of which node is the new diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index d79c21f474..adf2c5548e 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -1,4 +1,11 @@ //===- ValueMapper.cpp - Interface shared by lib/Transforms/Utils ---------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the MapValue function, which is shared by various parts of // the lib/Transforms/Utils library. diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index f8716757db..7fde122035 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -1,4 +1,11 @@ //===-- AsmWriter.cpp - Printing LLVM as an assembly file -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This library implements the functionality defined in llvm/Assembly/Writer.h // diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index c15ce24ce6..3110b4dd82 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -1,4 +1,11 @@ //===-- BasicBlock.cpp - Implement BasicBlock related methods -------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the BasicBlock class for the VMCore library. // diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 956397701f..32b9ebba74 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -1,4 +1,11 @@ //===- ConstantHandling.cpp - Implement ConstantHandling.h ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the various intrinsic operations, on constant values. // diff --git a/lib/VMCore/ConstantRange.cpp b/lib/VMCore/ConstantRange.cpp index c9d8ae6fbb..a9e1204de5 100644 --- a/lib/VMCore/ConstantRange.cpp +++ b/lib/VMCore/ConstantRange.cpp @@ -1,4 +1,11 @@ //===-- ConstantRange.cpp - ConstantRange implementation ------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Represent a range of possible values that may occur when the program is run // for an integral value. This keeps track of a lower and upper bound for the diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 4e1d905fec..a1ebd91737 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -1,4 +1,11 @@ //===-- Constants.cpp - Implement Constant nodes --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the Constant* classes... // diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index 671b49425e..c3bce78b5a 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -1,4 +1,11 @@ //===- Dominators.cpp - Dominator Calculation -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements simple dominator construction algorithms for finding // forward dominators. Postdominators are available in libanalysis, but are not diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index d31a69e49a..b86abfe905 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -1,4 +1,11 @@ //===-- Function.cpp - Implement the Global object classes ----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the Function & GlobalVariable classes for the VMCore // library. diff --git a/lib/VMCore/InstrTypes.cpp b/lib/VMCore/InstrTypes.cpp index 137f18169e..ba1d4b7160 100644 --- a/lib/VMCore/InstrTypes.cpp +++ b/lib/VMCore/InstrTypes.cpp @@ -1,4 +1,11 @@ //===-- InstrTypes.cpp - Implement Instruction subclasses -------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements // diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index b6bedf4748..b72656bdc2 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -1,4 +1,11 @@ //===-- Instruction.cpp - Implement the Instruction class -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the Instruction class for the VMCore library. // diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index ecc4868d2e..24c946ab6e 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -1,4 +1,11 @@ //===-- LeakDetector.cpp - Implement LeakDetector interface ---------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the LeakDetector class. // diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index a71572bd33..bd8ec8c9ce 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -1,4 +1,11 @@ //===- Linker.cpp - Module Linker Implementation --------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the LLVM module linker. // diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp index d9186a9c93..44c697d3d8 100644 --- a/lib/VMCore/Mangler.cpp +++ b/lib/VMCore/Mangler.cpp @@ -1,4 +1,11 @@ //===-- Mangler.cpp - Self-contained c/asm llvm name mangler --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Unified name mangler for CWriter and assembly backends. // diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 77b17674d1..af28bec8ac 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -1,4 +1,11 @@ //===-- Module.cpp - Implement the Module class ---------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the Module class for the VMCore library. // diff --git a/lib/VMCore/ModuleProvider.cpp b/lib/VMCore/ModuleProvider.cpp index cbc82369a0..ba324d0894 100644 --- a/lib/VMCore/ModuleProvider.cpp +++ b/lib/VMCore/ModuleProvider.cpp @@ -1,4 +1,11 @@ //===-- ModuleProvider.cpp - Base implementation for module providers -----===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // Minimal implementation of the abstract interface for providing a module. // diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index ddee390e50..96ad3c94e9 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -1,4 +1,11 @@ //===- Pass.cpp - LLVM Pass Infrastructure Implementation -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the LLVM Pass infrastructure. It is primarily // responsible with ensuring that passes are executed and batched together diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index b182f6dbfa..f527b1838f 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -1,4 +1,11 @@ //===-- SlotCalculator.cpp - Calculate what slots values land in ----------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements a useful analysis step to figure out what numbered // slots values in a program will land in (keeping track of per plane diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index 6812f699d5..a6b9a0007b 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -1,4 +1,11 @@ //===-- SymbolTable.cpp - Implement the SymbolTable class -----------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the SymbolTable class for the VMCore library. // diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 2227809ea8..b92c5dcaf5 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -1,4 +1,11 @@ //===-- Type.cpp - Implement the Type class -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the Type class for the VMCore library. // diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 68b4af0949..d11abc10cb 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -1,4 +1,11 @@ //===-- Value.cpp - Implement the Value class -----------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the Value and User classes. // diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 5c70b93fc5..14c14f3c08 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1,4 +1,11 @@ //===-- Verifier.cpp - Implement the Module Verifier -------------*- C++ -*-==// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file defines the function verifier interface, that can be used for some // sanity checking of input to the system. diff --git a/lib/VMCore/iBranch.cpp b/lib/VMCore/iBranch.cpp index a6032ab0fe..bcba7145cc 100644 --- a/lib/VMCore/iBranch.cpp +++ b/lib/VMCore/iBranch.cpp @@ -1,4 +1,11 @@ //===-- iBranch.cpp - Implement the Branch instruction --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the 'br' instruction, which can represent either a // conditional or unconditional branch. diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp index 823def6911..e0f99785a5 100644 --- a/lib/VMCore/iCall.cpp +++ b/lib/VMCore/iCall.cpp @@ -1,4 +1,11 @@ //===-- iCall.cpp - Implement the call & invoke instructions --------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the call and invoke instructions. // diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp index 68a628bcb9..75309ad8dc 100644 --- a/lib/VMCore/iMemory.cpp +++ b/lib/VMCore/iMemory.cpp @@ -1,4 +1,11 @@ //===-- iMemory.cpp - Implement Memory instructions -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the various memory related classes defined in iMemory.h // diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp index a4daeeebff..d893290198 100644 --- a/lib/VMCore/iOperators.cpp +++ b/lib/VMCore/iOperators.cpp @@ -1,4 +1,11 @@ //===-- iOperators.cpp - Implement binary Operators ------------*- C++ -*--===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the nontrivial binary operator instructions. // diff --git a/lib/VMCore/iSwitch.cpp b/lib/VMCore/iSwitch.cpp index 0ffe45ff92..e6a4f48ef4 100644 --- a/lib/VMCore/iSwitch.cpp +++ b/lib/VMCore/iSwitch.cpp @@ -1,4 +1,11 @@ //===-- iSwitch.cpp - Implement the Switch instruction --------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the Switch instruction... // diff --git a/tools/analyze/PrintSCC.cpp b/tools/analyze/PrintSCC.cpp index dfb7420542..3459381158 100644 --- a/tools/analyze/PrintSCC.cpp +++ b/tools/analyze/PrintSCC.cpp @@ -1,4 +1,11 @@ //===- PrintSCC.cpp - Enumerate SCCs in some key graphs -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file provides passes to print out SCCs in a CFG or a CallGraph. // Normally, you would not use these passes; instead, you would use the diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 4ae896bd99..a66b868c22 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -1,4 +1,11 @@ //===-- ToolRunner.cpp ----------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file implements the interfaces described in the ToolRunner.h file. // diff --git a/tools/opt/PrintSCC.cpp b/tools/opt/PrintSCC.cpp index dfb7420542..3459381158 100644 --- a/tools/opt/PrintSCC.cpp +++ b/tools/opt/PrintSCC.cpp @@ -1,4 +1,11 @@ //===- PrintSCC.cpp - Enumerate SCCs in some key graphs -------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file was developed by the LLVM research group and is distributed under +// the University of Illinois Open Source License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// // // This file provides passes to print out SCCs in a CFG or a CallGraph. // Normally, you would not use these passes; instead, you would use the -- cgit v1.2.3-70-g09d2 From d0fde30ce850b78371fd1386338350591f9ff494 Mon Sep 17 00:00:00 2001 From: Brian Gaeke Date: Tue, 11 Nov 2003 22:41:34 +0000 Subject: Put all LLVM code into the llvm namespace, as per bug 109. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9903 91177308-0d34-0410-b5e6-96231b3b80d8 --- autoconf/configure.ac | 1 + examples/ModuleMaker/ModuleMaker.cpp | 2 + .../ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp | 2 + include/Support/Annotation.h | 4 ++ include/Support/BitSetVector.h | 3 ++ include/Support/Casting.h | 4 ++ include/Support/CommandLine.h | 3 ++ include/Support/DOTGraphTraits.h | 4 ++ include/Support/Debug.h | 4 ++ include/Support/DepthFirstIterator.h | 3 ++ include/Support/DynamicLinker.h | 4 ++ include/Support/EquivalenceClasses.h | 4 ++ include/Support/FileUtilities.h | 4 ++ include/Support/GraphTraits.h | 4 ++ include/Support/GraphWriter.h | 4 ++ include/Support/LeakDetector.h | 5 ++ include/Support/MallocAllocator.h | 3 ++ include/Support/MathExtras.h | 4 ++ include/Support/PostOrderIterator.h | 4 ++ include/Support/SCCIterator.h | 4 ++ include/Support/STLExtras.h | 4 ++ include/Support/SetOperations.h | 4 ++ include/Support/Signals.h | 5 +- include/Support/Statistic.h | 4 ++ include/Support/StringExtras.h | 4 ++ include/Support/SystemUtils.h | 5 ++ include/Support/Timer.h | 4 ++ include/Support/Tree.h | 3 ++ include/Support/TypeInfo.h | 4 ++ include/Support/VectorExtras.h | 4 ++ include/Support/ilist | 6 ++- include/llvm/ADT/BitSetVector.h | 3 ++ include/llvm/ADT/DepthFirstIterator.h | 3 ++ include/llvm/ADT/EquivalenceClasses.h | 4 ++ include/llvm/ADT/GraphTraits.h | 4 ++ include/llvm/ADT/PostOrderIterator.h | 4 ++ include/llvm/ADT/SCCIterator.h | 4 ++ include/llvm/ADT/STLExtras.h | 4 ++ include/llvm/ADT/SetOperations.h | 4 ++ include/llvm/ADT/Statistic.h | 4 ++ include/llvm/ADT/StringExtras.h | 4 ++ include/llvm/ADT/Tree.h | 3 ++ include/llvm/ADT/VectorExtras.h | 4 ++ include/llvm/ADT/ilist | 6 ++- include/llvm/AbstractTypeUser.h | 4 ++ include/llvm/Analysis/AliasAnalysis.h | 5 ++ include/llvm/Analysis/AliasSetTracker.h | 5 ++ include/llvm/Analysis/CallGraph.h | 5 ++ include/llvm/Analysis/ConstantsScanner.h | 5 ++ include/llvm/Analysis/DSGraph.h | 5 ++ include/llvm/Analysis/DSGraphTraits.h | 4 ++ include/llvm/Analysis/DSNode.h | 4 ++ include/llvm/Analysis/DSSupport.h | 12 ++++- include/llvm/Analysis/DataStructure.h | 4 ++ include/llvm/Analysis/DataStructure/DSGraph.h | 5 ++ .../llvm/Analysis/DataStructure/DSGraphTraits.h | 4 ++ include/llvm/Analysis/DataStructure/DSNode.h | 4 ++ include/llvm/Analysis/DataStructure/DSSupport.h | 12 ++++- .../llvm/Analysis/DataStructure/DataStructure.h | 4 ++ include/llvm/Analysis/DependenceGraph.h | 4 ++ include/llvm/Analysis/Dominators.h | 4 ++ include/llvm/Analysis/Expressions.h | 4 ++ include/llvm/Analysis/FindUnsafePointerTypes.h | 4 ++ include/llvm/Analysis/FindUsedTypes.h | 5 ++ include/llvm/Analysis/IPModRef.h | 4 ++ include/llvm/Analysis/InductionVariable.h | 5 ++ include/llvm/Analysis/InstForest.h | 4 ++ include/llvm/Analysis/Interval.h | 4 ++ include/llvm/Analysis/IntervalIterator.h | 4 ++ include/llvm/Analysis/IntervalPartition.h | 4 ++ include/llvm/Analysis/LoadValueNumbering.h | 4 ++ include/llvm/Analysis/LoopInfo.h | 4 ++ include/llvm/Analysis/MemoryDepAnalysis.h | 4 ++ include/llvm/Analysis/PgmDependenceGraph.h | 5 +- include/llvm/Analysis/PostDominators.h | 4 ++ include/llvm/Analysis/SlotCalculator.h | 5 ++ include/llvm/Analysis/ValueNumbering.h | 5 ++ include/llvm/Analysis/Verifier.h | 4 ++ include/llvm/Argument.h | 4 ++ include/llvm/Assembly/AsmAnnotationWriter.h | 5 ++ include/llvm/Assembly/CWriter.h | 5 ++ include/llvm/Assembly/CachedWriter.h | 4 ++ include/llvm/Assembly/Parser.h | 4 ++ include/llvm/Assembly/PrintModulePass.h | 4 ++ include/llvm/Assembly/Writer.h | 5 ++ include/llvm/BasicBlock.h | 4 ++ include/llvm/Bytecode/Format.h | 5 ++ include/llvm/Bytecode/Primitives.h | 4 ++ include/llvm/Bytecode/Reader.h | 4 ++ include/llvm/Bytecode/WriteBytecodePass.h | 4 ++ include/llvm/Bytecode/Writer.h | 4 ++ include/llvm/CallGraphSCCPass.h | 4 ++ include/llvm/CodeGen/FunctionLiveVarInfo.h | 4 ++ include/llvm/CodeGen/InstrForest.h | 11 ++++ include/llvm/CodeGen/InstrScheduling.h | 4 ++ include/llvm/CodeGen/InstrSelection.h | 4 ++ include/llvm/CodeGen/InstrSelectionSupport.h | 5 ++ include/llvm/CodeGen/LiveVariables.h | 4 ++ include/llvm/CodeGen/MachineBasicBlock.h | 4 ++ include/llvm/CodeGen/MachineCodeEmitter.h | 5 ++ include/llvm/CodeGen/MachineCodeForInstruction.h | 4 ++ include/llvm/CodeGen/MachineConstantPool.h | 5 ++ include/llvm/CodeGen/MachineFrameInfo.h | 9 ++++ include/llvm/CodeGen/MachineFunction.h | 4 ++ include/llvm/CodeGen/MachineFunctionInfo.h | 5 ++ include/llvm/CodeGen/MachineFunctionPass.h | 4 ++ include/llvm/CodeGen/MachineInstr.h | 4 ++ include/llvm/CodeGen/MachineInstrAnnot.h | 3 ++ include/llvm/CodeGen/MachineInstrBuilder.h | 4 ++ include/llvm/CodeGen/Passes.h | 4 ++ include/llvm/CodeGen/SSARegMap.h | 4 ++ include/llvm/CodeGen/SchedGraphCommon.h | 4 ++ include/llvm/CodeGen/SelectionDAG.h | 5 ++ include/llvm/CodeGen/ValueSet.h | 5 ++ include/llvm/CodeGen/ValueTypes.h | 5 +- include/llvm/Constant.h | 4 ++ include/llvm/ConstantHandling.h | 6 +++ include/llvm/Constants.h | 4 ++ include/llvm/DerivedTypes.h | 4 ++ include/llvm/ExecutionEngine/ExecutionEngine.h | 5 ++ include/llvm/ExecutionEngine/GenericValue.h | 4 ++ include/llvm/Function.h | 6 ++- include/llvm/GlobalValue.h | 5 ++ include/llvm/GlobalVariable.h | 4 ++ include/llvm/InstrTypes.h | 4 ++ include/llvm/Instruction.def | 2 +- include/llvm/Instruction.h | 4 ++ include/llvm/Intrinsics.h | 11 ++-- include/llvm/Linker.h | 5 ++ include/llvm/Module.h | 5 ++ include/llvm/ModuleProvider.h | 4 ++ include/llvm/Pass.h | 5 ++ include/llvm/PassAnalysisSupport.h | 4 ++ include/llvm/PassManager.h | 4 ++ include/llvm/PassSupport.h | 5 ++ include/llvm/SlotCalculator.h | 5 ++ include/llvm/Support/Annotation.h | 4 ++ include/llvm/Support/CFG.h | 4 ++ include/llvm/Support/CallSite.h | 4 ++ include/llvm/Support/Casting.h | 4 ++ include/llvm/Support/CommandLine.h | 3 ++ include/llvm/Support/ConstantRange.h | 5 ++ include/llvm/Support/DOTGraphTraits.h | 4 ++ include/llvm/Support/Debug.h | 4 ++ include/llvm/Support/DynamicLinker.h | 4 ++ include/llvm/Support/FileUtilities.h | 4 ++ include/llvm/Support/GraphWriter.h | 4 ++ include/llvm/Support/InstIterator.h | 4 ++ include/llvm/Support/InstVisitor.h | 5 +- include/llvm/Support/LeakDetector.h | 5 ++ include/llvm/Support/Linker.h | 5 ++ include/llvm/Support/MallocAllocator.h | 3 ++ include/llvm/Support/Mangler.h | 9 ++++ include/llvm/Support/MathExtras.h | 4 ++ include/llvm/Support/PassNameParser.h | 4 ++ include/llvm/Support/SystemUtils.h | 5 ++ include/llvm/Support/Timer.h | 4 ++ include/llvm/Support/ToolRunner.h | 4 ++ include/llvm/Support/TypeInfo.h | 4 ++ include/llvm/Support/ValueHolder.h | 4 ++ include/llvm/SymbolTable.h | 4 ++ include/llvm/SymbolTableListTraits.h | 4 ++ include/llvm/System/Signals.h | 5 +- include/llvm/Target/MRegisterInfo.h | 4 ++ include/llvm/Target/TargetCacheInfo.h | 4 ++ include/llvm/Target/TargetData.h | 5 ++ include/llvm/Target/TargetFrameInfo.h | 4 ++ include/llvm/Target/TargetInstrInfo.h | 4 ++ include/llvm/Target/TargetMachine.h | 4 ++ include/llvm/Target/TargetMachineImpls.h | 4 ++ include/llvm/Target/TargetRegInfo.h | 4 ++ include/llvm/Target/TargetSchedInfo.h | 14 +++-- include/llvm/Transforms/IPO.h | 4 ++ include/llvm/Transforms/Instrumentation.h | 4 ++ include/llvm/Transforms/MutateStructTypes.h | 4 ++ include/llvm/Transforms/Scalar.h | 4 ++ include/llvm/Transforms/Utils/BasicBlockUtils.h | 5 +- include/llvm/Transforms/Utils/Cloning.h | 5 ++ include/llvm/Transforms/Utils/DemoteRegToStack.h | 4 ++ include/llvm/Transforms/Utils/Linker.h | 5 ++ include/llvm/Transforms/Utils/Local.h | 5 ++ include/llvm/Transforms/Utils/PromoteMemToReg.h | 7 ++- .../llvm/Transforms/Utils/UnifyFunctionExitNodes.h | 4 ++ include/llvm/Type.def | 2 +- include/llvm/Type.h | 4 ++ include/llvm/Use.h | 9 +++- include/llvm/User.h | 4 ++ include/llvm/Value.h | 4 ++ include/llvm/iMemory.h | 5 ++ include/llvm/iOperators.h | 4 ++ include/llvm/iOther.h | 4 ++ include/llvm/iPHINode.h | 5 ++ include/llvm/iTerminators.h | 4 ++ lib/Analysis/AliasAnalysis.cpp | 4 ++ lib/Analysis/AliasAnalysisCounter.cpp | 4 ++ lib/Analysis/AliasAnalysisEvaluator.cpp | 4 ++ lib/Analysis/AliasSetTracker.cpp | 5 +- lib/Analysis/BasicAliasAnalysis.cpp | 6 +-- lib/Analysis/CFGPrinter.cpp | 7 +-- lib/Analysis/ConstantRange.cpp | 4 ++ lib/Analysis/DataStructure/BottomUpClosure.cpp | 3 ++ lib/Analysis/DataStructure/DSCallSiteIterator.h | 4 ++ lib/Analysis/DataStructure/DataStructure.cpp | 7 ++- lib/Analysis/DataStructure/DataStructureAA.cpp | 4 ++ lib/Analysis/DataStructure/DataStructureOpt.cpp | 5 +- lib/Analysis/DataStructure/DataStructureStats.cpp | 4 ++ lib/Analysis/DataStructure/GraphChecker.cpp | 4 ++ lib/Analysis/DataStructure/IPModRef.cpp | 4 ++ lib/Analysis/DataStructure/Local.cpp | 8 ++- lib/Analysis/DataStructure/MemoryDepAnalysis.cpp | 5 +- lib/Analysis/DataStructure/Parallelize.cpp | 4 ++ lib/Analysis/DataStructure/PgmDependenceGraph.cpp | 3 ++ lib/Analysis/DataStructure/Printer.cpp | 5 +- lib/Analysis/DataStructure/Steensgaard.cpp | 5 +- lib/Analysis/DataStructure/TopDownClosure.cpp | 3 ++ lib/Analysis/Expressions.cpp | 4 ++ lib/Analysis/IPA/CallGraph.cpp | 4 ++ lib/Analysis/IPA/CallGraphSCCPass.cpp | 4 ++ lib/Analysis/IPA/DependenceGraph.cpp | 3 ++ lib/Analysis/IPA/FindUnsafePointerTypes.cpp | 4 ++ lib/Analysis/IPA/FindUsedTypes.cpp | 4 ++ lib/Analysis/IPA/IPModRef.cpp | 4 ++ lib/Analysis/IPA/MemoryDepAnalysis.cpp | 5 +- lib/Analysis/IPA/PgmDependenceGraph.cpp | 3 ++ lib/Analysis/IPA/PrintSCC.cpp | 4 ++ lib/Analysis/InductionVariable.cpp | 4 ++ lib/Analysis/InstCount.cpp | 4 ++ lib/Analysis/Interval.cpp | 2 + lib/Analysis/IntervalPartition.cpp | 4 ++ lib/Analysis/LiveVar/BBLiveVar.cpp | 5 +- lib/Analysis/LiveVar/BBLiveVar.h | 5 ++ lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp | 4 ++ lib/Analysis/LiveVar/ValueSet.cpp | 3 ++ lib/Analysis/LoadValueNumbering.cpp | 6 ++- lib/Analysis/LoopInfo.cpp | 4 ++ lib/Analysis/PostDominators.cpp | 4 ++ lib/Analysis/PrintSCC.cpp | 4 ++ lib/Analysis/ValueNumbering.cpp | 7 ++- lib/Archive/ArchiveReader.cpp | 5 +- lib/AsmParser/Lexer.l | 5 ++ lib/AsmParser/Parser.cpp | 4 ++ lib/AsmParser/ParserInternals.h | 14 +++-- lib/AsmParser/llvmAsmParser.y | 61 ++++++++++++---------- lib/Bytecode/Archive/ArchiveReader.cpp | 5 +- lib/Bytecode/Reader/ArchiveReader.cpp | 5 +- lib/Bytecode/Reader/ConstantReader.cpp | 4 ++ lib/Bytecode/Reader/InstructionReader.cpp | 6 ++- lib/Bytecode/Reader/Reader.cpp | 4 ++ lib/Bytecode/Reader/ReaderInternals.h | 4 ++ lib/Bytecode/Reader/ReaderWrappers.cpp | 7 ++- lib/Bytecode/Writer/ConstantWriter.cpp | 4 ++ lib/Bytecode/Writer/InstructionWriter.cpp | 4 ++ lib/Bytecode/Writer/SlotCalculator.cpp | 4 ++ lib/Bytecode/Writer/SlotCalculator.h | 5 ++ lib/Bytecode/Writer/Writer.cpp | 4 ++ lib/Bytecode/Writer/WriterInternals.h | 3 ++ lib/CodeGen/InstrSched/InstrScheduling.cpp | 5 ++ lib/CodeGen/InstrSched/SchedGraph.cpp | 4 ++ lib/CodeGen/InstrSched/SchedGraph.h | 4 ++ lib/CodeGen/InstrSched/SchedGraphCommon.cpp | 3 ++ lib/CodeGen/InstrSched/SchedPriorities.cpp | 3 ++ lib/CodeGen/InstrSched/SchedPriorities.h | 4 ++ lib/CodeGen/InstrSelection/InstrForest.cpp | 4 ++ lib/CodeGen/InstrSelection/InstrSelection.cpp | 8 ++- .../InstrSelection/InstrSelectionSupport.cpp | 3 ++ lib/CodeGen/LiveVariables.cpp | 4 ++ lib/CodeGen/MachineCodeEmitter.cpp | 24 +++++---- lib/CodeGen/MachineCodeForInstruction.cpp | 4 ++ lib/CodeGen/MachineFunction.cpp | 4 ++ lib/CodeGen/MachineInstr.cpp | 8 ++- lib/CodeGen/MachineInstrAnnot.cpp | 3 ++ lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp | 3 ++ lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h | 3 ++ lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp | 4 ++ lib/CodeGen/PHIElimination.cpp | 5 ++ lib/CodeGen/Passes.cpp | 4 ++ lib/CodeGen/PrologEpilogInserter.cpp | 5 ++ lib/CodeGen/RegAlloc/AllocInfo.h | 4 ++ lib/CodeGen/RegAlloc/IGNode.cpp | 4 ++ lib/CodeGen/RegAlloc/IGNode.h | 5 ++ lib/CodeGen/RegAlloc/InterferenceGraph.cpp | 4 ++ lib/CodeGen/RegAlloc/InterferenceGraph.h | 5 ++ lib/CodeGen/RegAlloc/LiveRange.h | 4 ++ lib/CodeGen/RegAlloc/LiveRangeInfo.cpp | 4 ++ lib/CodeGen/RegAlloc/LiveRangeInfo.h | 4 ++ lib/CodeGen/RegAlloc/PhyRegAlloc.cpp | 4 ++ lib/CodeGen/RegAlloc/PhyRegAlloc.h | 4 ++ lib/CodeGen/RegAlloc/RegAllocCommon.h | 4 ++ lib/CodeGen/RegAlloc/RegClass.cpp | 4 +- lib/CodeGen/RegAlloc/RegClass.h | 5 ++ lib/CodeGen/RegAllocLocal.cpp | 5 +- lib/CodeGen/RegAllocSimple.cpp | 4 ++ lib/CodeGen/SelectionDAG/DAGBuilder.cpp | 4 ++ lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 4 ++ lib/ExecutionEngine/ExecutionEngine.cpp | 3 ++ lib/ExecutionEngine/Interpreter/Execution.cpp | 6 ++- .../Interpreter/ExternalFunctions.cpp | 4 ++ lib/ExecutionEngine/Interpreter/Interpreter.cpp | 4 ++ lib/ExecutionEngine/Interpreter/Interpreter.h | 4 ++ lib/ExecutionEngine/JIT/Intercept.cpp | 4 ++ lib/ExecutionEngine/JIT/JIT.cpp | 4 ++ lib/ExecutionEngine/JIT/JIT.h | 4 ++ lib/ExecutionEngine/JIT/JITEmitter.cpp | 4 ++ lib/ExecutionEngine/JIT/VM.cpp | 4 ++ lib/ExecutionEngine/JIT/VM.h | 4 ++ lib/Linker/LinkArchives.cpp | 4 ++ lib/Linker/LinkModules.cpp | 3 ++ lib/Support/Annotation.cpp | 4 ++ lib/Support/CommandLine.cpp | 4 ++ lib/Support/ConstantRange.cpp | 4 ++ lib/Support/Debug.cpp | 4 ++ lib/Support/DynamicLinker.cpp | 4 ++ lib/Support/FileUtilities.cpp | 5 ++ lib/Support/LeakDetector.cpp | 4 ++ lib/Support/Mangler.cpp | 3 ++ lib/Support/PluginLoader.cpp | 4 ++ lib/Support/Signals.cpp | 4 ++ lib/Support/Statistic.cpp | 6 ++- lib/Support/SystemUtils.cpp | 3 ++ lib/Support/Timer.cpp | 7 ++- lib/Support/ToolRunner.cpp | 4 ++ lib/Support/ValueHolder.cpp | 4 ++ lib/Target/CBackend/CBackend.cpp | 28 +++++----- lib/Target/CBackend/Writer.cpp | 28 +++++----- lib/Target/MRegisterInfo.cpp | 4 ++ lib/Target/SparcV9/EmitBytecodeToAssembly.cpp | 4 ++ lib/Target/SparcV9/InstrSched/InstrScheduling.cpp | 5 ++ lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 4 ++ lib/Target/SparcV9/InstrSched/SchedGraph.h | 4 ++ lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp | 3 ++ lib/Target/SparcV9/InstrSched/SchedPriorities.cpp | 3 ++ lib/Target/SparcV9/InstrSched/SchedPriorities.h | 4 ++ lib/Target/SparcV9/InstrSelection/InstrForest.cpp | 4 ++ .../SparcV9/InstrSelection/InstrSelection.cpp | 8 ++- .../InstrSelection/InstrSelectionSupport.cpp | 3 ++ lib/Target/SparcV9/LiveVar/BBLiveVar.cpp | 5 +- lib/Target/SparcV9/LiveVar/BBLiveVar.h | 5 ++ lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp | 4 ++ lib/Target/SparcV9/LiveVar/ValueSet.cpp | 3 ++ lib/Target/SparcV9/MachineCodeForInstruction.h | 4 ++ lib/Target/SparcV9/MachineFunctionInfo.h | 5 ++ lib/Target/SparcV9/MachineInstrAnnot.h | 3 ++ lib/Target/SparcV9/MappingInfo.cpp | 4 ++ lib/Target/SparcV9/MappingInfo.h | 5 ++ .../SparcV9/ModuloScheduling/ModuloSchedGraph.cpp | 3 ++ .../SparcV9/ModuloScheduling/ModuloSchedGraph.h | 3 ++ .../SparcV9/ModuloScheduling/ModuloScheduling.cpp | 4 ++ lib/Target/SparcV9/RegAlloc/AllocInfo.h | 4 ++ lib/Target/SparcV9/RegAlloc/IGNode.cpp | 4 ++ lib/Target/SparcV9/RegAlloc/IGNode.h | 5 ++ lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp | 4 ++ lib/Target/SparcV9/RegAlloc/InterferenceGraph.h | 5 ++ lib/Target/SparcV9/RegAlloc/LiveRange.h | 4 ++ lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp | 4 ++ lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h | 4 ++ lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 4 ++ lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h | 4 ++ lib/Target/SparcV9/RegAlloc/RegAllocCommon.h | 4 ++ lib/Target/SparcV9/RegAlloc/RegClass.cpp | 4 +- lib/Target/SparcV9/RegAlloc/RegClass.h | 5 ++ lib/Target/SparcV9/SparcV9.burg.in | 2 +- lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 9 +++- lib/Target/SparcV9/SparcV9CodeEmitter.cpp | 5 +- lib/Target/SparcV9/SparcV9CodeEmitter.h | 4 ++ lib/Target/SparcV9/SparcV9InstrInfo.cpp | 4 ++ lib/Target/SparcV9/SparcV9InstrSelection.cpp | 24 +++++---- lib/Target/SparcV9/SparcV9InstrSelectionSupport.h | 4 ++ lib/Target/SparcV9/SparcV9Internals.h | 4 ++ lib/Target/SparcV9/SparcV9PeepholeOpts.cpp | 4 ++ lib/Target/SparcV9/SparcV9PreSelection.cpp | 6 ++- lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp | 4 ++ lib/Target/SparcV9/SparcV9RegClassInfo.cpp | 4 ++ lib/Target/SparcV9/SparcV9RegClassInfo.h | 4 ++ lib/Target/SparcV9/SparcV9RegInfo.cpp | 4 ++ lib/Target/SparcV9/SparcV9SchedInfo.cpp | 2 + lib/Target/SparcV9/SparcV9StackSlots.cpp | 4 ++ lib/Target/SparcV9/SparcV9TargetMachine.cpp | 4 ++ lib/Target/TargetData.cpp | 5 +- lib/Target/TargetInstrInfo.cpp | 4 ++ lib/Target/TargetMachine.cpp | 4 ++ lib/Target/TargetSchedInfo.cpp | 4 ++ lib/Target/X86/FloatingPoint.cpp | 6 ++- lib/Target/X86/InstSelectPattern.cpp | 5 +- lib/Target/X86/InstSelectSimple.cpp | 25 +++++---- lib/Target/X86/PeepholeOptimizer.cpp | 4 ++ lib/Target/X86/Printer.cpp | 4 ++ lib/Target/X86/X86.h | 5 ++ lib/Target/X86/X86AsmPrinter.cpp | 4 ++ lib/Target/X86/X86CodeEmitter.cpp | 4 ++ lib/Target/X86/X86FloatingPoint.cpp | 6 ++- lib/Target/X86/X86ISelPattern.cpp | 5 +- lib/Target/X86/X86ISelSimple.cpp | 25 +++++---- lib/Target/X86/X86InstrBuilder.h | 4 ++ lib/Target/X86/X86InstrInfo.cpp | 2 + lib/Target/X86/X86InstrInfo.h | 4 ++ lib/Target/X86/X86PeepholeOpt.cpp | 4 ++ lib/Target/X86/X86RegisterInfo.cpp | 8 +++ lib/Target/X86/X86RegisterInfo.h | 6 ++- lib/Target/X86/X86TargetMachine.cpp | 4 ++ lib/Target/X86/X86TargetMachine.h | 4 ++ lib/Transforms/ExprTypeConvert.cpp | 4 ++ lib/Transforms/Hello/Hello.cpp | 4 ++ lib/Transforms/IPO/ConstantMerge.cpp | 5 +- lib/Transforms/IPO/DeadArgumentElimination.cpp | 5 ++ lib/Transforms/IPO/DeadTypeElimination.cpp | 5 +- lib/Transforms/IPO/ExtractFunction.cpp | 4 ++ lib/Transforms/IPO/FunctionResolution.cpp | 4 ++ lib/Transforms/IPO/GlobalDCE.cpp | 4 ++ lib/Transforms/IPO/IPConstantPropagation.cpp | 4 ++ lib/Transforms/IPO/InlineSimple.cpp | 4 ++ lib/Transforms/IPO/Inliner.cpp | 4 ++ lib/Transforms/IPO/Inliner.h | 4 ++ lib/Transforms/IPO/Internalize.cpp | 4 ++ lib/Transforms/IPO/LowerSetJmp.cpp | 4 ++ lib/Transforms/IPO/MutateStructTypes.cpp | 2 + lib/Transforms/IPO/Parallelize.cpp | 4 ++ lib/Transforms/IPO/PruneEH.cpp | 4 ++ lib/Transforms/IPO/RaiseAllocations.cpp | 4 ++ lib/Transforms/IPO/SimpleStructMutation.cpp | 4 ++ lib/Transforms/Instrumentation/BlockProfiling.cpp | 4 ++ lib/Transforms/Instrumentation/EmitFunctions.cpp | 4 ++ .../Instrumentation/ProfilePaths/CombineBranch.cpp | 6 ++- .../Instrumentation/ProfilePaths/EdgeCode.cpp | 3 ++ .../Instrumentation/ProfilePaths/Graph.cpp | 4 +- .../Instrumentation/ProfilePaths/Graph.h | 12 ++++- .../ProfilePaths/GraphAuxiliary.cpp | 4 ++ .../Instrumentation/ProfilePaths/InstLoops.cpp | 4 ++ .../Instrumentation/ProfilePaths/ProfilePaths.cpp | 4 ++ .../Instrumentation/ProfilePaths/RetracePath.cpp | 4 ++ lib/Transforms/Instrumentation/TraceValues.cpp | 4 ++ lib/Transforms/LevelRaise.cpp | 7 ++- lib/Transforms/Scalar/ADCE.cpp | 4 ++ lib/Transforms/Scalar/ConstantProp.cpp | 4 ++ lib/Transforms/Scalar/CorrelatedExprs.cpp | 4 ++ lib/Transforms/Scalar/DCE.cpp | 5 +- lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp | 16 +++--- lib/Transforms/Scalar/GCSE.cpp | 5 +- lib/Transforms/Scalar/IndVarSimplify.cpp | 4 ++ lib/Transforms/Scalar/InstructionCombining.cpp | 4 ++ lib/Transforms/Scalar/LICM.cpp | 4 ++ lib/Transforms/Scalar/PRE.cpp | 6 ++- lib/Transforms/Scalar/PiNodeInsertion.cpp | 4 ++ lib/Transforms/Scalar/Reassociate.cpp | 5 ++ lib/Transforms/Scalar/SCCP.cpp | 5 +- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 5 ++ lib/Transforms/Scalar/SimplifyCFG.cpp | 5 ++ lib/Transforms/Scalar/SymbolStripping.cpp | 4 ++ lib/Transforms/Scalar/TailDuplication.cpp | 5 ++ lib/Transforms/Scalar/TailRecursionElimination.cpp | 4 ++ lib/Transforms/TransformInternals.cpp | 4 ++ lib/Transforms/TransformInternals.h | 4 ++ lib/Transforms/Utils/BasicBlockUtils.cpp | 4 ++ lib/Transforms/Utils/BreakCriticalEdges.cpp | 4 ++ lib/Transforms/Utils/CloneFunction.cpp | 4 ++ lib/Transforms/Utils/CloneModule.cpp | 4 ++ lib/Transforms/Utils/CloneTrace.cpp | 4 ++ lib/Transforms/Utils/DemoteRegToStack.cpp | 4 ++ lib/Transforms/Utils/InlineFunction.cpp | 4 ++ lib/Transforms/Utils/Linker.cpp | 3 ++ lib/Transforms/Utils/Local.cpp | 4 ++ lib/Transforms/Utils/LoopSimplify.cpp | 5 +- lib/Transforms/Utils/LowerAllocations.cpp | 4 ++ lib/Transforms/Utils/LowerInvoke.cpp | 5 ++ lib/Transforms/Utils/LowerSwitch.cpp | 4 ++ lib/Transforms/Utils/Mem2Reg.cpp | 4 ++ lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 4 ++ lib/Transforms/Utils/SimplifyCFG.cpp | 4 ++ lib/Transforms/Utils/UnifyFunctionExitNodes.cpp | 4 ++ lib/Transforms/Utils/ValueMapper.cpp | 3 ++ lib/Transforms/Utils/ValueMapper.h | 5 ++ lib/VMCore/AsmWriter.cpp | 4 ++ lib/VMCore/BasicBlock.cpp | 6 ++- lib/VMCore/ConstantFold.cpp | 4 ++ lib/VMCore/ConstantFold.h | 6 +++ lib/VMCore/ConstantFolding.h | 6 +++ lib/VMCore/ConstantRange.cpp | 4 ++ lib/VMCore/Constants.cpp | 4 ++ lib/VMCore/Dominators.cpp | 4 ++ lib/VMCore/Function.cpp | 50 ++++++++++-------- lib/VMCore/InstrTypes.cpp | 4 ++ lib/VMCore/Instruction.cpp | 4 ++ lib/VMCore/LeakDetector.cpp | 4 ++ lib/VMCore/Linker.cpp | 3 ++ lib/VMCore/Mangler.cpp | 3 ++ lib/VMCore/Module.cpp | 4 ++ lib/VMCore/ModuleProvider.cpp | 4 ++ lib/VMCore/Pass.cpp | 4 ++ lib/VMCore/PassManagerT.h | 5 ++ lib/VMCore/SlotCalculator.cpp | 4 ++ lib/VMCore/SymbolTable.cpp | 4 ++ lib/VMCore/SymbolTableListTraitsImpl.h | 4 ++ lib/VMCore/Type.cpp | 3 ++ lib/VMCore/Value.cpp | 4 ++ lib/VMCore/Verifier.cpp | 60 +++++++++++---------- lib/VMCore/iBranch.cpp | 4 ++ lib/VMCore/iCall.cpp | 7 +++ lib/VMCore/iMemory.cpp | 2 + lib/VMCore/iOperators.cpp | 4 ++ lib/VMCore/iSwitch.cpp | 4 ++ .../ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp | 2 + .../ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp | 2 + tools/analyze/AnalysisWrappers.cpp | 2 + tools/analyze/GraphPrinters.cpp | 4 ++ tools/analyze/PrintSCC.cpp | 4 ++ tools/analyze/analyze.cpp | 1 + tools/bugpoint/BugDriver.cpp | 6 +++ tools/bugpoint/BugDriver.h | 4 ++ tools/bugpoint/CodeGeneratorBug.cpp | 4 ++ tools/bugpoint/CrashDebugger.cpp | 4 ++ tools/bugpoint/ExecutionDriver.cpp | 6 +++ tools/bugpoint/ExtractFunction.cpp | 11 ++++ tools/bugpoint/ListReducer.h | 4 ++ tools/bugpoint/Miscompilation.cpp | 4 ++ tools/bugpoint/OptimizerDriver.cpp | 4 ++ tools/bugpoint/TestPasses.cpp | 2 + tools/bugpoint/ToolRunner.cpp | 4 ++ tools/bugpoint/ToolRunner.h | 4 ++ tools/bugpoint/bugpoint.cpp | 2 + tools/extract/extract.cpp | 2 + tools/gccas/gccas.cpp | 2 + tools/gccld/GenerateCode.cpp | 5 ++ tools/gccld/Linker.cpp | 4 ++ tools/gccld/gccld.cpp | 5 ++ tools/gccld/gccld.h | 3 ++ tools/llc/llc.cpp | 2 + tools/lli/lli.cpp | 2 + tools/llvm-ar/llvm-ar.cpp | 6 ++- tools/llvm-as/llvm-as.cpp | 2 + tools/llvm-dis/llvm-dis.cpp | 10 ++-- tools/llvm-extract/llvm-extract.cpp | 2 + tools/llvm-link/llvm-link.cpp | 2 + tools/llvm-nm/llvm-nm.cpp | 2 + tools/llvm-prof/ProfileInfo.cpp | 2 + tools/llvm-prof/ProfileInfo.h | 5 ++ tools/llvm-prof/llvm-prof.cpp | 2 + tools/opt/AnalysisWrappers.cpp | 2 + tools/opt/GraphPrinters.cpp | 4 ++ tools/opt/PrintSCC.cpp | 4 ++ tools/opt/opt.cpp | 1 + utils/TableGen/CodeEmitterGen.cpp | 6 +++ utils/TableGen/CodeEmitterGen.h | 4 ++ utils/TableGen/CodeGenTarget.cpp | 4 ++ utils/TableGen/CodeGenTarget.h | 5 ++ utils/TableGen/CodeGenWrappers.cpp | 4 ++ utils/TableGen/CodeGenWrappers.h | 5 ++ utils/TableGen/FileLexer.l | 11 +++- utils/TableGen/FileParser.y | 27 ++++++---- utils/TableGen/InstrInfoEmitter.cpp | 6 +++ utils/TableGen/InstrInfoEmitter.h | 5 ++ utils/TableGen/InstrSelectorEmitter.cpp | 7 ++- utils/TableGen/InstrSelectorEmitter.h | 4 ++ utils/TableGen/Record.cpp | 4 ++ utils/TableGen/Record.h | 4 ++ utils/TableGen/RegisterInfoEmitter.cpp | 7 +++ utils/TableGen/RegisterInfoEmitter.h | 4 ++ utils/TableGen/TableGen.cpp | 10 ++++ utils/TableGen/TableGenBackend.cpp | 9 +++- utils/TableGen/TableGenBackend.h | 9 ++++ 558 files changed, 2496 insertions(+), 266 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 1ae8c1cdd8..212a460ddb 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -16,6 +16,7 @@ dnl ************************************************************************** dnl * Initialize dnl ************************************************************************** AC_INIT([[[LLVM]]],[[[1.0]]],[llvmbugs@cs.uiuc.edu]) +dnl AC_CONFIG_SRC_DIR(lib/VMCore/Pass.cpp) dnl Place all of the extra autoconf files into the config subdirectory AC_CONFIG_AUX_DIR([autoconf]) diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp index 1d06c2d0dd..a1b68449f3 100644 --- a/examples/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/ModuleMaker.cpp @@ -12,6 +12,8 @@ #include "llvm/Instructions.h" #include "llvm/Bytecode/Writer.h" +using namespace llvm; + int main() { // Create the "module" or "program" or "translation unit" to hold the // function diff --git a/examples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp index 1d06c2d0dd..a1b68449f3 100644 --- a/examples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp @@ -12,6 +12,8 @@ #include "llvm/Instructions.h" #include "llvm/Bytecode/Writer.h" +using namespace llvm; + int main() { // Create the "module" or "program" or "translation unit" to hold the // function diff --git a/include/Support/Annotation.h b/include/Support/Annotation.h index 075ffc297a..cee7ab7d89 100644 --- a/include/Support/Annotation.h +++ b/include/Support/Annotation.h @@ -25,6 +25,8 @@ #include #include +namespace llvm { + class AnnotationID; class Annotation; class Annotable; @@ -217,4 +219,6 @@ inline Annotation *Annotable::getOrCreateAnnotation(AnnotationID ID) const { return A; } +} // End namespace llvm + #endif diff --git a/include/Support/BitSetVector.h b/include/Support/BitSetVector.h index 08bafa1580..72f55b38c4 100644 --- a/include/Support/BitSetVector.h +++ b/include/Support/BitSetVector.h @@ -30,6 +30,8 @@ #include #include +namespace llvm { + class BitSetVector { enum { BITSET_WORDSIZE = sizeof(long)*8 }; @@ -266,4 +268,5 @@ inline bool Disjoint(const BitSetVector& set1, return true; } +} // End llvm namespace #endif diff --git a/include/Support/Casting.h b/include/Support/Casting.h index 065919c179..4b070c18d8 100644 --- a/include/Support/Casting.h +++ b/include/Support/Casting.h @@ -15,6 +15,8 @@ #ifndef SUPPORT_CASTING_H #define SUPPORT_CASTING_H +namespace llvm { + //===----------------------------------------------------------------------===// // isa Support Templates //===----------------------------------------------------------------------===// @@ -293,4 +295,6 @@ void main() { #endif +} // End llvm namespace + #endif diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index 01f55a81d4..df40d80070 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -27,6 +27,7 @@ #include #include "boost/type_traits/object_traits.hpp" +namespace llvm { /// cl Namespace - This namespace contains all of the command line option /// processing machinery. It is intentionally a short name to make qualified /// usage concise. @@ -1022,4 +1023,6 @@ struct aliasopt { } // End namespace cl +} // End namespace llvm + #endif diff --git a/include/Support/DOTGraphTraits.h b/include/Support/DOTGraphTraits.h index 002a78ec4f..63837b7ddf 100644 --- a/include/Support/DOTGraphTraits.h +++ b/include/Support/DOTGraphTraits.h @@ -19,6 +19,8 @@ #include +namespace llvm { + /// DefaultDOTGraphTraits - This class provides the default implementations of /// all of the DOTGraphTraits methods. If a specialization does not need to /// override all methods here it should inherit so that it can get the default @@ -96,4 +98,6 @@ struct DefaultDOTGraphTraits { template class DOTGraphTraits : public DefaultDOTGraphTraits {}; +} // End llvm namespace + #endif diff --git a/include/Support/Debug.h b/include/Support/Debug.h index 8cba05771f..66a208811a 100644 --- a/include/Support/Debug.h +++ b/include/Support/Debug.h @@ -26,6 +26,8 @@ #ifndef SUPPORT_DEBUG_H #define SUPPORT_DEBUG_H +namespace llvm { + // DebugFlag - This boolean is set to true if the '-debug' command line option // is specified. This should probably not be referenced directly, instead, use // the DEBUG macro below. @@ -57,4 +59,6 @@ bool isCurrentDebugType(const char *Type); do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0) #endif +} // End llvm namespace + #endif diff --git a/include/Support/DepthFirstIterator.h b/include/Support/DepthFirstIterator.h index bb7673c83d..c465f4e549 100644 --- a/include/Support/DepthFirstIterator.h +++ b/include/Support/DepthFirstIterator.h @@ -38,6 +38,8 @@ #include #include +namespace llvm { + // df_iterator_storage - A private class which is used to figure out where to // store the visited set. template // Non-external set @@ -223,5 +225,6 @@ idf_ext_iterator idf_ext_end(T G, SetTy &S) { return idf_ext_iterator::end(G, S); } +} // End llvm namespace #endif diff --git a/include/Support/DynamicLinker.h b/include/Support/DynamicLinker.h index 8f02708268..fec9a45296 100644 --- a/include/Support/DynamicLinker.h +++ b/include/Support/DynamicLinker.h @@ -18,6 +18,8 @@ #include +namespace llvm { + /// LinkDynamicObject - Load the named file as a dynamic library /// and link it with the currently running process. Returns false /// on success, true if there is an error (and sets ErrorMessage @@ -33,4 +35,6 @@ bool LinkDynamicObject (const char *filename, std::string *ErrorMessage); void *GetAddressOfSymbol (const char *symbolName); void *GetAddressOfSymbol (const std::string &symbolName); +} // End llvm namespace + #endif // SUPPORT_DYNAMICLINKER_H diff --git a/include/Support/EquivalenceClasses.h b/include/Support/EquivalenceClasses.h index 01e8c5ef82..46e626b69b 100644 --- a/include/Support/EquivalenceClasses.h +++ b/include/Support/EquivalenceClasses.h @@ -20,6 +20,8 @@ #include #include +namespace llvm { + template class EquivalenceClasses { // Maps each element to the element that is the leader of its @@ -89,4 +91,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/Support/FileUtilities.h b/include/Support/FileUtilities.h index 0dfa625362..c276ec7aaa 100644 --- a/include/Support/FileUtilities.h +++ b/include/Support/FileUtilities.h @@ -17,6 +17,8 @@ #include +namespace llvm { + /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must /// name a readable file. /// @@ -95,4 +97,6 @@ bool MakeFileExecutable (const std::string & Filename); /// bool MakeFileReadable (const std::string & Filename); +} // End llvm namespace + #endif diff --git a/include/Support/GraphTraits.h b/include/Support/GraphTraits.h index 305f71e280..4ff74176a7 100644 --- a/include/Support/GraphTraits.h +++ b/include/Support/GraphTraits.h @@ -18,6 +18,8 @@ #ifndef SUPPORT_GRAPHTRAITS_H #define SUPPORT_GRAPHTRAITS_H +namespace llvm { + // GraphTraits - This class should be specialized by different graph types... // which is why the default version is empty. // @@ -76,4 +78,6 @@ struct Inverse { inline Inverse(GraphType &G) : Graph(G) {} }; +} // End llvm namespace + #endif diff --git a/include/Support/GraphWriter.h b/include/Support/GraphWriter.h index 2cb8fcc985..7e5aa80645 100644 --- a/include/Support/GraphWriter.h +++ b/include/Support/GraphWriter.h @@ -28,6 +28,8 @@ #include #include +namespace llvm { + namespace DOT { // Private functions... inline std::string EscapeString(const std::string &Label) { std::string Str(Label); @@ -206,4 +208,6 @@ std::ostream &WriteGraph(std::ostream &O, const GraphType &G, return O; } +} // End llvm namespace + #endif diff --git a/include/Support/LeakDetector.h b/include/Support/LeakDetector.h index b39e0b5911..e2ce9c50be 100644 --- a/include/Support/LeakDetector.h +++ b/include/Support/LeakDetector.h @@ -23,6 +23,9 @@ #define SUPPORT_LEAKDETECTOR_H #include + +namespace llvm { + class Value; struct LeakDetector { @@ -83,4 +86,6 @@ private: static void checkForGarbageImpl(const std::string &Message); }; +} // End llvm namespace + #endif diff --git a/include/Support/MallocAllocator.h b/include/Support/MallocAllocator.h index 1ba25b0d65..766a67fa22 100644 --- a/include/Support/MallocAllocator.h +++ b/include/Support/MallocAllocator.h @@ -23,6 +23,8 @@ #include #include +namespace llvm { + template struct MallocAllocator { typedef size_t size_type; @@ -79,5 +81,6 @@ namespace std { }; } +} // End llvm namespace #endif diff --git a/include/Support/MathExtras.h b/include/Support/MathExtras.h index ec742324b0..74958fbc35 100644 --- a/include/Support/MathExtras.h +++ b/include/Support/MathExtras.h @@ -16,6 +16,8 @@ #include "Support/DataTypes.h" +namespace llvm { + inline unsigned log2(uint64_t C) { unsigned getPow; for (getPow = 0; C > 1; ++getPow) @@ -33,4 +35,6 @@ inline bool isPowerOf2(int64_t C, unsigned &getPow) { return false; } +} // End llvm namespace + #endif diff --git a/include/Support/PostOrderIterator.h b/include/Support/PostOrderIterator.h index 9309554f32..d66c4b84c4 100644 --- a/include/Support/PostOrderIterator.h +++ b/include/Support/PostOrderIterator.h @@ -21,6 +21,8 @@ #include #include +namespace llvm { + template > class po_iterator : public forward_iterator { typedef forward_iterator super; @@ -149,4 +151,6 @@ public: inline rpo_iterator end() { return Blocks.rend(); } }; +} // End llvm namespace + #endif diff --git a/include/Support/SCCIterator.h b/include/Support/SCCIterator.h index cf137cd473..f21c7d162e 100644 --- a/include/Support/SCCIterator.h +++ b/include/Support/SCCIterator.h @@ -26,6 +26,8 @@ #include #include +namespace llvm { + //===----------------------------------------------------------------------===// /// /// scc_iterator - Enumerate the SCCs of a directed graph, in @@ -197,4 +199,6 @@ scc_iterator scc_end(T G) { return scc_iterator::end(G); } +} // End llvm namespace + #endif diff --git a/include/Support/STLExtras.h b/include/Support/STLExtras.h index 28c46e3d99..06a15734a7 100644 --- a/include/Support/STLExtras.h +++ b/include/Support/STLExtras.h @@ -21,6 +21,8 @@ #include "Support/iterator" #include "boost/type_traits/transform_traits.hpp" +namespace llvm { + //===----------------------------------------------------------------------===// // Extra additions to //===----------------------------------------------------------------------===// @@ -278,4 +280,6 @@ inline tier tie(T1& f, T2& s) { return tier(f, s); } +} // End llvm namespace + #endif diff --git a/include/Support/SetOperations.h b/include/Support/SetOperations.h index dc6e0d6029..bb1e68e6b2 100644 --- a/include/Support/SetOperations.h +++ b/include/Support/SetOperations.h @@ -15,6 +15,8 @@ #ifndef SUPPORT_SETOPERATIONS_H #define SUPPORT_SETOPERATIONS_H +namespace llvm { + // set_union(A, B) - Compute A := A u B, return whether A changed. // template @@ -64,4 +66,6 @@ void set_subtract(S1Ty &S1, const S2Ty &S2) { S1.erase(*SI); } +} // End llvm namespace + #endif diff --git a/include/Support/Signals.h b/include/Support/Signals.h index ce12301a15..0cbf398798 100644 --- a/include/Support/Signals.h +++ b/include/Support/Signals.h @@ -17,10 +17,13 @@ #include +namespace llvm { + // RemoveFileOnSignal - This function registers signal handlers to ensure that // if a signal gets delivered that the named file is removed. // void RemoveFileOnSignal(const std::string &Filename); -#endif +} // End llvm namespace +#endif diff --git a/include/Support/Statistic.h b/include/Support/Statistic.h index d69809ff18..4e592d5832 100644 --- a/include/Support/Statistic.h +++ b/include/Support/Statistic.h @@ -26,6 +26,8 @@ #include +namespace llvm { + // StatisticBase - Nontemplated base class for Statistic<> class... class StatisticBase { const char *Name; @@ -78,4 +80,6 @@ public: const Statistic &operator-=(const DataType &V) { Value -= V; return *this; } }; +} // End llvm namespace + #endif diff --git a/include/Support/StringExtras.h b/include/Support/StringExtras.h index 2c50c1cd5b..2ebac81935 100644 --- a/include/Support/StringExtras.h +++ b/include/Support/StringExtras.h @@ -18,6 +18,8 @@ #include #include +namespace llvm { + static inline std::string utohexstr(uint64_t X) { char Buffer[40]; char *BufPtr = Buffer+39; @@ -95,4 +97,6 @@ static inline std::string ftostr(double V) { return Buffer; } +} // End llvm namespace + #endif diff --git a/include/Support/SystemUtils.h b/include/Support/SystemUtils.h index ccde86cce6..c874d9932c 100644 --- a/include/Support/SystemUtils.h +++ b/include/Support/SystemUtils.h @@ -17,6 +17,8 @@ #include +namespace llvm { + /// isExecutableFile - This function returns true if the filename specified /// exists and is executable. /// @@ -45,4 +47,7 @@ int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, /// wait for it to terminate. /// int ExecWait (const char * const argv[], const char * const envp[]); + +} // End llvm namespace + #endif diff --git a/include/Support/Timer.h b/include/Support/Timer.h index 57ef3f0d64..ac465bb95b 100644 --- a/include/Support/Timer.h +++ b/include/Support/Timer.h @@ -20,6 +20,8 @@ #include #include +namespace llvm { + class TimerGroup; /// Timer - This class is used to track the amount of time spent between @@ -157,4 +159,6 @@ private: } }; +} // End llvm namespace + #endif diff --git a/include/Support/Tree.h b/include/Support/Tree.h index e6454317a8..bc5495f25a 100644 --- a/include/Support/Tree.h +++ b/include/Support/Tree.h @@ -17,6 +17,8 @@ #include +namespace llvm { + template class Tree { std::vector Children; // This nodes children, if any @@ -55,5 +57,6 @@ public: inline const Payload &getTreeData() const { return Data; } }; +} // End llvm namespace #endif diff --git a/include/Support/TypeInfo.h b/include/Support/TypeInfo.h index aa2093a43d..5d9035076f 100644 --- a/include/Support/TypeInfo.h +++ b/include/Support/TypeInfo.h @@ -18,6 +18,8 @@ #include +namespace llvm { + struct TypeInfo { TypeInfo() { // needed for containers struct Nil {}; // Anonymous class distinct from all others... @@ -69,4 +71,6 @@ inline bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs) { return !(lhs < rhs); } +} // End llvm namespace + #endif diff --git a/include/Support/VectorExtras.h b/include/Support/VectorExtras.h index 32778309d4..cf7cf5d2eb 100644 --- a/include/Support/VectorExtras.h +++ b/include/Support/VectorExtras.h @@ -17,6 +17,8 @@ #include +namespace llvm { + /// make_vector - Helper function which is useful for building temporary vectors /// to pass into type construction of CallInst ctors. This turns a null /// terminated list of pointers (or other value types) into a real live vector. @@ -33,4 +35,6 @@ inline std::vector make_vector(T A, ...) { return Result; } +} // End llvm namespace + #endif diff --git a/include/Support/ilist b/include/Support/ilist index 488a90ffde..7f4d2659d5 100644 --- a/include/Support/ilist +++ b/include/Support/ilist @@ -41,6 +41,8 @@ #include #include +namespace llvm { + template class iplist; template class ilist_iterator; @@ -522,10 +524,12 @@ struct ilist : public iplist { void resize(size_type newsize) { resize(newsize, NodeTy()); } }; +} // End llvm namespace + namespace std { // Ensure that swap uses the fast list swap... template - void swap(iplist &Left, iplist &Right) { + void swap(llvm::iplist &Left, llvm::iplist &Right) { Left.swap(Right); } } // End 'std' extensions... diff --git a/include/llvm/ADT/BitSetVector.h b/include/llvm/ADT/BitSetVector.h index 08bafa1580..72f55b38c4 100644 --- a/include/llvm/ADT/BitSetVector.h +++ b/include/llvm/ADT/BitSetVector.h @@ -30,6 +30,8 @@ #include #include +namespace llvm { + class BitSetVector { enum { BITSET_WORDSIZE = sizeof(long)*8 }; @@ -266,4 +268,5 @@ inline bool Disjoint(const BitSetVector& set1, return true; } +} // End llvm namespace #endif diff --git a/include/llvm/ADT/DepthFirstIterator.h b/include/llvm/ADT/DepthFirstIterator.h index bb7673c83d..c465f4e549 100644 --- a/include/llvm/ADT/DepthFirstIterator.h +++ b/include/llvm/ADT/DepthFirstIterator.h @@ -38,6 +38,8 @@ #include #include +namespace llvm { + // df_iterator_storage - A private class which is used to figure out where to // store the visited set. template // Non-external set @@ -223,5 +225,6 @@ idf_ext_iterator idf_ext_end(T G, SetTy &S) { return idf_ext_iterator::end(G, S); } +} // End llvm namespace #endif diff --git a/include/llvm/ADT/EquivalenceClasses.h b/include/llvm/ADT/EquivalenceClasses.h index 01e8c5ef82..46e626b69b 100644 --- a/include/llvm/ADT/EquivalenceClasses.h +++ b/include/llvm/ADT/EquivalenceClasses.h @@ -20,6 +20,8 @@ #include #include +namespace llvm { + template class EquivalenceClasses { // Maps each element to the element that is the leader of its @@ -89,4 +91,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/GraphTraits.h b/include/llvm/ADT/GraphTraits.h index 305f71e280..4ff74176a7 100644 --- a/include/llvm/ADT/GraphTraits.h +++ b/include/llvm/ADT/GraphTraits.h @@ -18,6 +18,8 @@ #ifndef SUPPORT_GRAPHTRAITS_H #define SUPPORT_GRAPHTRAITS_H +namespace llvm { + // GraphTraits - This class should be specialized by different graph types... // which is why the default version is empty. // @@ -76,4 +78,6 @@ struct Inverse { inline Inverse(GraphType &G) : Graph(G) {} }; +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/PostOrderIterator.h b/include/llvm/ADT/PostOrderIterator.h index 9309554f32..d66c4b84c4 100644 --- a/include/llvm/ADT/PostOrderIterator.h +++ b/include/llvm/ADT/PostOrderIterator.h @@ -21,6 +21,8 @@ #include #include +namespace llvm { + template > class po_iterator : public forward_iterator { typedef forward_iterator super; @@ -149,4 +151,6 @@ public: inline rpo_iterator end() { return Blocks.rend(); } }; +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/SCCIterator.h b/include/llvm/ADT/SCCIterator.h index cf137cd473..f21c7d162e 100644 --- a/include/llvm/ADT/SCCIterator.h +++ b/include/llvm/ADT/SCCIterator.h @@ -26,6 +26,8 @@ #include #include +namespace llvm { + //===----------------------------------------------------------------------===// /// /// scc_iterator - Enumerate the SCCs of a directed graph, in @@ -197,4 +199,6 @@ scc_iterator scc_end(T G) { return scc_iterator::end(G); } +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index 28c46e3d99..06a15734a7 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -21,6 +21,8 @@ #include "Support/iterator" #include "boost/type_traits/transform_traits.hpp" +namespace llvm { + //===----------------------------------------------------------------------===// // Extra additions to //===----------------------------------------------------------------------===// @@ -278,4 +280,6 @@ inline tier tie(T1& f, T2& s) { return tier(f, s); } +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/SetOperations.h b/include/llvm/ADT/SetOperations.h index dc6e0d6029..bb1e68e6b2 100644 --- a/include/llvm/ADT/SetOperations.h +++ b/include/llvm/ADT/SetOperations.h @@ -15,6 +15,8 @@ #ifndef SUPPORT_SETOPERATIONS_H #define SUPPORT_SETOPERATIONS_H +namespace llvm { + // set_union(A, B) - Compute A := A u B, return whether A changed. // template @@ -64,4 +66,6 @@ void set_subtract(S1Ty &S1, const S2Ty &S2) { S1.erase(*SI); } +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h index d69809ff18..4e592d5832 100644 --- a/include/llvm/ADT/Statistic.h +++ b/include/llvm/ADT/Statistic.h @@ -26,6 +26,8 @@ #include +namespace llvm { + // StatisticBase - Nontemplated base class for Statistic<> class... class StatisticBase { const char *Name; @@ -78,4 +80,6 @@ public: const Statistic &operator-=(const DataType &V) { Value -= V; return *this; } }; +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index 2c50c1cd5b..2ebac81935 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -18,6 +18,8 @@ #include #include +namespace llvm { + static inline std::string utohexstr(uint64_t X) { char Buffer[40]; char *BufPtr = Buffer+39; @@ -95,4 +97,6 @@ static inline std::string ftostr(double V) { return Buffer; } +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/Tree.h b/include/llvm/ADT/Tree.h index e6454317a8..bc5495f25a 100644 --- a/include/llvm/ADT/Tree.h +++ b/include/llvm/ADT/Tree.h @@ -17,6 +17,8 @@ #include +namespace llvm { + template class Tree { std::vector Children; // This nodes children, if any @@ -55,5 +57,6 @@ public: inline const Payload &getTreeData() const { return Data; } }; +} // End llvm namespace #endif diff --git a/include/llvm/ADT/VectorExtras.h b/include/llvm/ADT/VectorExtras.h index 32778309d4..cf7cf5d2eb 100644 --- a/include/llvm/ADT/VectorExtras.h +++ b/include/llvm/ADT/VectorExtras.h @@ -17,6 +17,8 @@ #include +namespace llvm { + /// make_vector - Helper function which is useful for building temporary vectors /// to pass into type construction of CallInst ctors. This turns a null /// terminated list of pointers (or other value types) into a real live vector. @@ -33,4 +35,6 @@ inline std::vector make_vector(T A, ...) { return Result; } +} // End llvm namespace + #endif diff --git a/include/llvm/ADT/ilist b/include/llvm/ADT/ilist index 488a90ffde..7f4d2659d5 100644 --- a/include/llvm/ADT/ilist +++ b/include/llvm/ADT/ilist @@ -41,6 +41,8 @@ #include #include +namespace llvm { + template class iplist; template class ilist_iterator; @@ -522,10 +524,12 @@ struct ilist : public iplist { void resize(size_type newsize) { resize(newsize, NodeTy()); } }; +} // End llvm namespace + namespace std { // Ensure that swap uses the fast list swap... template - void swap(iplist &Left, iplist &Right) { + void swap(llvm::iplist &Left, llvm::iplist &Right) { Left.swap(Right); } } // End 'std' extensions... diff --git a/include/llvm/AbstractTypeUser.h b/include/llvm/AbstractTypeUser.h index 9e3edddbc2..8a18f5896c 100644 --- a/include/llvm/AbstractTypeUser.h +++ b/include/llvm/AbstractTypeUser.h @@ -37,6 +37,8 @@ // #include +namespace llvm { + class Type; class DerivedType; @@ -165,4 +167,6 @@ private: void dropRef(); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index 4ce3f4baf1..dc484f5df5 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -31,6 +31,9 @@ #define LLVM_ANALYSIS_ALIAS_ANALYSIS_H #include "llvm/Support/CallSite.h" + +namespace llvm { + class LoadInst; class StoreInst; class TargetData; @@ -156,4 +159,6 @@ public: const Value *Ptr, unsigned Size); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index 72168b4756..fe57c28679 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -21,6 +21,9 @@ #include "Support/iterator" #include "Support/hash_map" #include "Support/ilist" + +namespace llvm { + class AliasAnalysis; class LoadInst; class StoreInst; @@ -283,4 +286,6 @@ inline std::ostream& operator<<(std::ostream &OS, const AliasSetTracker &AST) { return OS; } +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 3a51b05655..60649f9ed9 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -51,6 +51,9 @@ #include "Support/GraphTraits.h" #include "Support/STLExtras.h" #include "llvm/Pass.h" + +namespace llvm { + class Function; class Module; class CallGraphNode; @@ -288,4 +291,6 @@ template<> struct GraphTraits : static IncludeFile CALLGRAPH_INCLUDE_FILE((void*)&CallGraph::stub); +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/ConstantsScanner.h b/include/llvm/Analysis/ConstantsScanner.h index c7efd76cef..e1533c35bb 100644 --- a/include/llvm/Analysis/ConstantsScanner.h +++ b/include/llvm/Analysis/ConstantsScanner.h @@ -19,6 +19,9 @@ #include "llvm/Support/InstIterator.h" #include "llvm/Instruction.h" #include "Support/iterator" + +namespace llvm { + class Constant; class constant_iterator : public forward_iterator { @@ -86,4 +89,6 @@ inline constant_iterator constant_end(const Function *F) { return constant_iterator(F, true); } +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DSGraph.h b/include/llvm/Analysis/DSGraph.h index 399da007e2..b7fdb10af5 100644 --- a/include/llvm/Analysis/DSGraph.h +++ b/include/llvm/Analysis/DSGraph.h @@ -15,6 +15,9 @@ #define LLVM_ANALYSIS_DSGRAPH_H #include "llvm/Analysis/DSNode.h" + +namespace llvm { + class GlobalValue; //===----------------------------------------------------------------------===// @@ -332,4 +335,6 @@ public: void removeTriviallyDeadNodes(); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DSGraphTraits.h b/include/llvm/Analysis/DSGraphTraits.h index 086835cb92..ad2cc6fa8f 100644 --- a/include/llvm/Analysis/DSGraphTraits.h +++ b/include/llvm/Analysis/DSGraphTraits.h @@ -21,6 +21,8 @@ #include "Support/iterator" #include "Support/STLExtras.h" +namespace llvm { + template class DSNodeIterator : public forward_iterator { friend class DSNode; @@ -146,4 +148,6 @@ template <> struct GraphTraits { static ChildIteratorType child_end(const NodeType *N) { return N->end(); } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DSNode.h b/include/llvm/Analysis/DSNode.h index ba5328b2b8..f206c3e5ad 100644 --- a/include/llvm/Analysis/DSNode.h +++ b/include/llvm/Analysis/DSNode.h @@ -16,6 +16,8 @@ #include "llvm/Analysis/DSSupport.h" +namespace llvm { + template class DSNodeIterator; // Data structure graph traversal iterator class TargetData; @@ -382,4 +384,6 @@ inline void DSNodeHandle::mergeWith(const DSNodeHandle &Node) { *this = Node; } +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DSSupport.h b/include/llvm/Analysis/DSSupport.h index e5662ff0a4..4b571917ff 100644 --- a/include/llvm/Analysis/DSSupport.h +++ b/include/llvm/Analysis/DSSupport.h @@ -18,6 +18,8 @@ #include "Support/hash_set" #include "llvm/Support/CallSite.h" +namespace llvm { + class Function; class CallInst; class Value; @@ -122,10 +124,14 @@ private: DSNode *HandleForwarding() const; }; +} // End llvm namespace + namespace std { - inline void swap(DSNodeHandle &NH1, DSNodeHandle &NH2) { NH1.swap(NH2); } + inline void swap(llvm::DSNodeHandle &NH1, llvm::DSNodeHandle &NH2) { NH1.swap(NH2); } } +namespace llvm { + //===----------------------------------------------------------------------===// /// DSCallSite - Representation of a call site via its call instruction, /// the DSNode handle for the callee function (or function pointer), and @@ -287,7 +293,9 @@ public: } }; +} // End llvm namespace + namespace std { - inline void swap(DSCallSite &CS1, DSCallSite &CS2) { CS1.swap(CS2); } + inline void swap(llvm::DSCallSite &CS1, llvm::DSCallSite &CS2) { CS1.swap(CS2); } } #endif diff --git a/include/llvm/Analysis/DataStructure.h b/include/llvm/Analysis/DataStructure.h index afea126c07..4d6e3a0476 100644 --- a/include/llvm/Analysis/DataStructure.h +++ b/include/llvm/Analysis/DataStructure.h @@ -18,6 +18,8 @@ #include "llvm/Target/TargetData.h" #include "Support/hash_set" +namespace llvm { + class Type; class Instruction; class DSGraph; @@ -184,4 +186,6 @@ private: const BUDataStructures::ActualCalleesTy &ActualCallees); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DataStructure/DSGraph.h b/include/llvm/Analysis/DataStructure/DSGraph.h index 399da007e2..b7fdb10af5 100644 --- a/include/llvm/Analysis/DataStructure/DSGraph.h +++ b/include/llvm/Analysis/DataStructure/DSGraph.h @@ -15,6 +15,9 @@ #define LLVM_ANALYSIS_DSGRAPH_H #include "llvm/Analysis/DSNode.h" + +namespace llvm { + class GlobalValue; //===----------------------------------------------------------------------===// @@ -332,4 +335,6 @@ public: void removeTriviallyDeadNodes(); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DataStructure/DSGraphTraits.h b/include/llvm/Analysis/DataStructure/DSGraphTraits.h index 086835cb92..ad2cc6fa8f 100644 --- a/include/llvm/Analysis/DataStructure/DSGraphTraits.h +++ b/include/llvm/Analysis/DataStructure/DSGraphTraits.h @@ -21,6 +21,8 @@ #include "Support/iterator" #include "Support/STLExtras.h" +namespace llvm { + template class DSNodeIterator : public forward_iterator { friend class DSNode; @@ -146,4 +148,6 @@ template <> struct GraphTraits { static ChildIteratorType child_end(const NodeType *N) { return N->end(); } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DataStructure/DSNode.h b/include/llvm/Analysis/DataStructure/DSNode.h index ba5328b2b8..f206c3e5ad 100644 --- a/include/llvm/Analysis/DataStructure/DSNode.h +++ b/include/llvm/Analysis/DataStructure/DSNode.h @@ -16,6 +16,8 @@ #include "llvm/Analysis/DSSupport.h" +namespace llvm { + template class DSNodeIterator; // Data structure graph traversal iterator class TargetData; @@ -382,4 +384,6 @@ inline void DSNodeHandle::mergeWith(const DSNodeHandle &Node) { *this = Node; } +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DataStructure/DSSupport.h b/include/llvm/Analysis/DataStructure/DSSupport.h index e5662ff0a4..4b571917ff 100644 --- a/include/llvm/Analysis/DataStructure/DSSupport.h +++ b/include/llvm/Analysis/DataStructure/DSSupport.h @@ -18,6 +18,8 @@ #include "Support/hash_set" #include "llvm/Support/CallSite.h" +namespace llvm { + class Function; class CallInst; class Value; @@ -122,10 +124,14 @@ private: DSNode *HandleForwarding() const; }; +} // End llvm namespace + namespace std { - inline void swap(DSNodeHandle &NH1, DSNodeHandle &NH2) { NH1.swap(NH2); } + inline void swap(llvm::DSNodeHandle &NH1, llvm::DSNodeHandle &NH2) { NH1.swap(NH2); } } +namespace llvm { + //===----------------------------------------------------------------------===// /// DSCallSite - Representation of a call site via its call instruction, /// the DSNode handle for the callee function (or function pointer), and @@ -287,7 +293,9 @@ public: } }; +} // End llvm namespace + namespace std { - inline void swap(DSCallSite &CS1, DSCallSite &CS2) { CS1.swap(CS2); } + inline void swap(llvm::DSCallSite &CS1, llvm::DSCallSite &CS2) { CS1.swap(CS2); } } #endif diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h index afea126c07..4d6e3a0476 100644 --- a/include/llvm/Analysis/DataStructure/DataStructure.h +++ b/include/llvm/Analysis/DataStructure/DataStructure.h @@ -18,6 +18,8 @@ #include "llvm/Target/TargetData.h" #include "Support/hash_set" +namespace llvm { + class Type; class Instruction; class DSGraph; @@ -184,4 +186,6 @@ private: const BUDataStructures::ActualCalleesTy &ActualCallees); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/DependenceGraph.h b/include/llvm/Analysis/DependenceGraph.h index b5af0b9e25..b4c7aa1fcc 100644 --- a/include/llvm/Analysis/DependenceGraph.h +++ b/include/llvm/Analysis/DependenceGraph.h @@ -30,6 +30,8 @@ #include #include +namespace llvm { + class Instruction; class Function; class Dependence; @@ -264,4 +266,6 @@ public: //===----------------------------------------------------------------------===// +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index b8ac9c3e11..5688d6e811 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -28,6 +28,8 @@ #include "llvm/Pass.h" #include +namespace llvm { + class Instruction; template struct GraphTraits; @@ -487,4 +489,6 @@ private: const DominatorTree::Node *Node); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/Expressions.h b/include/llvm/Analysis/Expressions.h index 29207618d1..77475ffa6c 100644 --- a/include/llvm/Analysis/Expressions.h +++ b/include/llvm/Analysis/Expressions.h @@ -17,6 +17,8 @@ #ifndef LLVM_ANALYSIS_EXPRESSIONS_H #define LLVM_ANALYSIS_EXPRESSIONS_H +namespace llvm { + class Type; class Value; class ConstantInt; @@ -56,4 +58,6 @@ struct ExprType { const Type *getExprType(const Type *Default) const; }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/FindUnsafePointerTypes.h b/include/llvm/Analysis/FindUnsafePointerTypes.h index 8f1cdcf094..62077f37d5 100644 --- a/include/llvm/Analysis/FindUnsafePointerTypes.h +++ b/include/llvm/Analysis/FindUnsafePointerTypes.h @@ -27,6 +27,8 @@ #include "llvm/Pass.h" #include +namespace llvm { + class PointerType; struct FindUnsafePointerTypes : public Pass { @@ -55,4 +57,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/FindUsedTypes.h b/include/llvm/Analysis/FindUsedTypes.h index a246084dbb..69471791ab 100644 --- a/include/llvm/Analysis/FindUsedTypes.h +++ b/include/llvm/Analysis/FindUsedTypes.h @@ -16,6 +16,9 @@ #include "llvm/Pass.h" #include + +namespace llvm { + class Type; class FindUsedTypes : public Pass { @@ -59,4 +62,6 @@ public: static IncludeFile FIND_USED_TYPES_INCLUDE_FILE((void*)&FindUsedTypes::stub); +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/IPModRef.h b/include/llvm/Analysis/IPModRef.h index 84e55195e5..cf70d5835e 100644 --- a/include/llvm/Analysis/IPModRef.h +++ b/include/llvm/Analysis/IPModRef.h @@ -50,6 +50,8 @@ #include "Support/BitSetVector.h" #include "Support/hash_map" +namespace llvm { + class Module; class Function; class CallSite; @@ -239,4 +241,6 @@ public: //===----------------------------------------------------------------------===// +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/InductionVariable.h b/include/llvm/Analysis/InductionVariable.h index 26deb832f8..6c06a6c065 100644 --- a/include/llvm/Analysis/InductionVariable.h +++ b/include/llvm/Analysis/InductionVariable.h @@ -27,6 +27,9 @@ #define LLVM_ANALYSIS_INDUCTIONVARIABLE_H #include + +namespace llvm { + class Value; class PHINode; class Instruction; @@ -60,4 +63,6 @@ public: void print(std::ostream &OS) const; }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/InstForest.h b/include/llvm/Analysis/InstForest.h index a034c92d51..82fc46e1d1 100644 --- a/include/llvm/Analysis/InstForest.h +++ b/include/llvm/Analysis/InstForest.h @@ -25,6 +25,8 @@ #include "Support/Tree.h" #include +namespace llvm { + template class InstTreeNode; template class InstForest; @@ -288,5 +290,7 @@ InstTreeNode::InstTreeNode(InstForest &IF, Value *V, getTreeData().first.second = InstructionNode; } +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/Interval.h b/include/llvm/Analysis/Interval.h index 9839cf5dc0..0d5912305b 100644 --- a/include/llvm/Analysis/Interval.h +++ b/include/llvm/Analysis/Interval.h @@ -24,6 +24,8 @@ #include #include +namespace llvm { + class BasicBlock; //===----------------------------------------------------------------------===// @@ -146,4 +148,6 @@ template <> struct GraphTraits > { } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/IntervalIterator.h b/include/llvm/Analysis/IntervalIterator.h index 2d67ded196..091959f25f 100644 --- a/include/llvm/Analysis/IntervalIterator.h +++ b/include/llvm/Analysis/IntervalIterator.h @@ -40,6 +40,8 @@ #include #include +namespace llvm { + // getNodeHeader - Given a source graph node and the source graph, return the // BasicBlock that is the header node. This is the opposite of // getSourceGraphNode. @@ -253,4 +255,6 @@ inline interval_part_interval_iterator intervals_end(IntervalPartition &IP) { return interval_part_interval_iterator(); } +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/IntervalPartition.h b/include/llvm/Analysis/IntervalPartition.h index 45e282acdf..408ace2e7e 100644 --- a/include/llvm/Analysis/IntervalPartition.h +++ b/include/llvm/Analysis/IntervalPartition.h @@ -26,6 +26,8 @@ #include "llvm/Analysis/Interval.h" #include "llvm/Pass.h" +namespace llvm { + //===----------------------------------------------------------------------===// // // IntervalPartition - This class builds and holds an "interval partition" for @@ -102,4 +104,6 @@ private: void updatePredecessors(Interval *Int); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/LoadValueNumbering.h b/include/llvm/Analysis/LoadValueNumbering.h index 83aa5e99a6..6218133a51 100644 --- a/include/llvm/Analysis/LoadValueNumbering.h +++ b/include/llvm/Analysis/LoadValueNumbering.h @@ -21,6 +21,8 @@ #ifndef LLVM_ANALYSIS_LOAD_VALUE_NUMBERING_H #define LLVM_ANALYSIS_LOAD_VALUE_NUMBERING_H +namespace llvm { + class Pass; /// createLoadValueNumberingPass - Create and return a new pass that implements @@ -28,4 +30,6 @@ class Pass; /// Pass *createLoadValueNumberingPass(); +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 6a96834a15..1458b3bd5f 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -29,6 +29,8 @@ #include "Support/GraphTraits.h" #include +namespace llvm { + class DominatorSet; class LoopInfo; @@ -224,4 +226,6 @@ template <> struct GraphTraits { } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/MemoryDepAnalysis.h b/include/llvm/Analysis/MemoryDepAnalysis.h index 6ecc3c8250..10eb6566b6 100644 --- a/include/llvm/Analysis/MemoryDepAnalysis.h +++ b/include/llvm/Analysis/MemoryDepAnalysis.h @@ -24,6 +24,8 @@ #include "llvm/Pass.h" #include "Support/hash_map" +namespace llvm { + class ModRefTable; class DSGraph; class FunctionModRefInfo; @@ -96,4 +98,6 @@ public: void dump() const; }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/PgmDependenceGraph.h b/include/llvm/Analysis/PgmDependenceGraph.h index edb5119f00..70128740a8 100644 --- a/include/llvm/Analysis/PgmDependenceGraph.h +++ b/include/llvm/Analysis/PgmDependenceGraph.h @@ -46,6 +46,8 @@ #include "llvm/Pass.h" #include "Support/iterator" +namespace llvm { + class DSGraph; class DependenceGraph; class PgmDependenceGraph; @@ -304,7 +306,8 @@ public: void dump() const; }; - //===----------------------------------------------------------------------===// +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/PostDominators.h b/include/llvm/Analysis/PostDominators.h index b1a9b8ed16..c8eb439b41 100644 --- a/include/llvm/Analysis/PostDominators.h +++ b/include/llvm/Analysis/PostDominators.h @@ -16,6 +16,8 @@ #include "llvm/Analysis/Dominators.h" +namespace llvm { + /// PostDominatorSet Class - Concrete subclass of DominatorSetBase that is used /// to compute the post-dominator set. Because there can be multiple exit nodes @@ -117,4 +119,6 @@ private: static IncludeFile POST_DOMINATOR_INCLUDE_FILE((void*)&PostDominanceFrontier::stub); +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/SlotCalculator.h b/include/llvm/Analysis/SlotCalculator.h index 7e56de99dc..596f9324ed 100644 --- a/include/llvm/Analysis/SlotCalculator.h +++ b/include/llvm/Analysis/SlotCalculator.h @@ -22,6 +22,9 @@ #include #include + +namespace llvm { + class Value; class Module; class Function; @@ -92,4 +95,6 @@ protected: void processSymbolTableConstants(const SymbolTable *ST); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/ValueNumbering.h b/include/llvm/Analysis/ValueNumbering.h index ff4680d663..74b5c97ff2 100644 --- a/include/llvm/Analysis/ValueNumbering.h +++ b/include/llvm/Analysis/ValueNumbering.h @@ -21,6 +21,9 @@ #define LLVM_ANALYSIS_VALUE_NUMBERING_H #include + +namespace llvm { + class Value; struct ValueNumbering { @@ -34,4 +37,6 @@ struct ValueNumbering { virtual ~ValueNumbering(); // We want to be subclassed }; +} // End llvm namespace + #endif diff --git a/include/llvm/Analysis/Verifier.h b/include/llvm/Analysis/Verifier.h index 427015c6c6..51da3a5eae 100644 --- a/include/llvm/Analysis/Verifier.h +++ b/include/llvm/Analysis/Verifier.h @@ -21,6 +21,8 @@ #ifndef LLVM_ANALYSIS_VERIFIER_H #define LLVM_ANALYSIS_VERIFIER_H +namespace llvm { + class FunctionPass; class Module; class Function; @@ -40,4 +42,6 @@ bool verifyModule(const Module &M); // pass. bool verifyFunction(const Function &F); +} // End llvm namespace + #endif diff --git a/include/llvm/Argument.h b/include/llvm/Argument.h index 2d70f5314b..ab4ee1bf0e 100644 --- a/include/llvm/Argument.h +++ b/include/llvm/Argument.h @@ -17,6 +17,8 @@ #include "llvm/Value.h" +namespace llvm { + class Argument : public Value { // Defined in the Function.cpp file Function *Parent; @@ -56,4 +58,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Assembly/AsmAnnotationWriter.h b/include/llvm/Assembly/AsmAnnotationWriter.h index 192cb3de0b..3beda6df03 100644 --- a/include/llvm/Assembly/AsmAnnotationWriter.h +++ b/include/llvm/Assembly/AsmAnnotationWriter.h @@ -18,6 +18,9 @@ #define LLVM_ASSEMBLY_ASMANNOTATIONWRITER_H #include + +namespace llvm { + class Function; class BasicBlock; class Instruction; @@ -37,4 +40,6 @@ struct AssemblyAnnotationWriter { virtual void emitInstructionAnnot(const Instruction *I, std::ostream &OS) {} }; +} // End llvm namespace + #endif diff --git a/include/llvm/Assembly/CWriter.h b/include/llvm/Assembly/CWriter.h index cc7a358a9b..3029787ca4 100644 --- a/include/llvm/Assembly/CWriter.h +++ b/include/llvm/Assembly/CWriter.h @@ -16,7 +16,12 @@ #define LLVM_ASSEMBLY_CWRITER_H #include + +namespace llvm { + class Pass; Pass *createWriteToCPass(std::ostream &o); +} // End llvm namespace + #endif diff --git a/include/llvm/Assembly/CachedWriter.h b/include/llvm/Assembly/CachedWriter.h index dbddacde93..4acd3de4da 100644 --- a/include/llvm/Assembly/CachedWriter.h +++ b/include/llvm/Assembly/CachedWriter.h @@ -20,6 +20,8 @@ #include "llvm/Value.h" #include +namespace llvm { + class Module; class PointerType; class SlotCalculator; @@ -82,4 +84,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Assembly/Parser.h b/include/llvm/Assembly/Parser.h index 4f1863f071..dc1b17eb50 100644 --- a/include/llvm/Assembly/Parser.h +++ b/include/llvm/Assembly/Parser.h @@ -16,6 +16,8 @@ #include +namespace llvm { + class Module; class ParseException; @@ -70,4 +72,6 @@ private : ParseException &operator=(const ParseException &E); // objects by reference }; +} // End llvm namespace + #endif diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h index e211e8bdae..28100805a7 100644 --- a/include/llvm/Assembly/PrintModulePass.h +++ b/include/llvm/Assembly/PrintModulePass.h @@ -21,6 +21,8 @@ #include "llvm/Pass.h" #include "llvm/Module.h" +namespace llvm { + class PrintModulePass : public Pass { std::ostream *Out; // ostream to print on bool DeleteStream; // Delete the ostream in our dtor? @@ -72,4 +74,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Assembly/Writer.h b/include/llvm/Assembly/Writer.h index 5798ae8ac7..9f89b3192f 100644 --- a/include/llvm/Assembly/Writer.h +++ b/include/llvm/Assembly/Writer.h @@ -24,6 +24,9 @@ #define LLVM_ASSEMBLY_WRITER_H #include + +namespace llvm { + class Type; class Module; class Value; @@ -43,4 +46,6 @@ std::ostream &WriteTypeSymbolic(std::ostream &, const Type *, const Module *M); std::ostream &WriteAsOperand(std::ostream &, const Value *, bool PrintTy = true, bool PrintName = true, const Module *Context = 0); +} // End llvm namespace + #endif diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 1a996bcf26..9f78bc7467 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -33,6 +33,8 @@ #include "llvm/SymbolTableListTraits.h" #include "Support/ilist" +namespace llvm { + class TerminatorInst; template class SuccIterator; // Successor Iterator template class PredIterator; @@ -171,4 +173,6 @@ public: BasicBlock *splitBasicBlock(iterator I, const std::string &BBName = ""); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Bytecode/Format.h b/include/llvm/Bytecode/Format.h index 79cf9f0527..380f4df0ab 100644 --- a/include/llvm/Bytecode/Format.h +++ b/include/llvm/Bytecode/Format.h @@ -15,6 +15,8 @@ #ifndef LLVM_BYTECODE_FORMAT_H #define LLVM_BYTECODE_FORMAT_H +namespace llvm { + class BytecodeFormat { // Throw the constants into a poorman's namespace... BytecodeFormat(); // do not implement public: @@ -38,4 +40,7 @@ public: BasicBlock = 0x31, // May contain many basic blocks }; }; + +} // End llvm namespace + #endif diff --git a/include/llvm/Bytecode/Primitives.h b/include/llvm/Bytecode/Primitives.h index d9b29c00e7..3973eceadb 100644 --- a/include/llvm/Bytecode/Primitives.h +++ b/include/llvm/Bytecode/Primitives.h @@ -23,6 +23,8 @@ #include #include +namespace llvm { + //===----------------------------------------------------------------------===// // Reading Primitives //===----------------------------------------------------------------------===// @@ -275,4 +277,6 @@ static inline void output_data(void *Ptr, void *End, if (Align) align32(Out); } +} // End llvm namespace + #endif diff --git a/include/llvm/Bytecode/Reader.h b/include/llvm/Bytecode/Reader.h index 0de71002a7..1e9fa32bd1 100644 --- a/include/llvm/Bytecode/Reader.h +++ b/include/llvm/Bytecode/Reader.h @@ -23,6 +23,8 @@ #include #include +namespace llvm { + /// getBytecodeModuleProvider - lazy function-at-a-time loading from a file /// ModuleProvider *getBytecodeModuleProvider(const std::string &Filename); @@ -53,4 +55,6 @@ bool ReadArchiveFile(const std::string &Filename, std::vector &Objects, std::string *ErrorStr = 0); +} // End llvm namespace + #endif diff --git a/include/llvm/Bytecode/WriteBytecodePass.h b/include/llvm/Bytecode/WriteBytecodePass.h index ba8bc71c4c..b8863e6b47 100644 --- a/include/llvm/Bytecode/WriteBytecodePass.h +++ b/include/llvm/Bytecode/WriteBytecodePass.h @@ -19,6 +19,8 @@ #include "llvm/Bytecode/Writer.h" #include +namespace llvm { + class WriteBytecodePass : public Pass { std::ostream *Out; // ostream to print on bool DeleteStream; @@ -38,4 +40,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Bytecode/Writer.h b/include/llvm/Bytecode/Writer.h index ba82f6ad19..9fadddb66b 100644 --- a/include/llvm/Bytecode/Writer.h +++ b/include/llvm/Bytecode/Writer.h @@ -26,7 +26,11 @@ #include +namespace llvm { + class Module; void WriteBytecodeToFile(const Module *C, std::ostream &Out); +} // End llvm namespace + #endif diff --git a/include/llvm/CallGraphSCCPass.h b/include/llvm/CallGraphSCCPass.h index bb97a277cc..86cdc29f57 100644 --- a/include/llvm/CallGraphSCCPass.h +++ b/include/llvm/CallGraphSCCPass.h @@ -23,6 +23,8 @@ #include "llvm/Pass.h" +namespace llvm { + class CallGraphNode; struct CallGraphSCCPass : public Pass { @@ -46,4 +48,6 @@ struct CallGraphSCCPass : public Pass { virtual void getAnalysisUsage(AnalysisUsage &Info) const; }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/FunctionLiveVarInfo.h b/include/llvm/CodeGen/FunctionLiveVarInfo.h index e79d58f7e4..23a9d93a6e 100644 --- a/include/llvm/CodeGen/FunctionLiveVarInfo.h +++ b/include/llvm/CodeGen/FunctionLiveVarInfo.h @@ -39,6 +39,8 @@ #include "llvm/Pass.h" #include "llvm/CodeGen/ValueSet.h" +namespace llvm { + class BBLiveVar; class MachineInstr; @@ -104,4 +106,6 @@ public: const BasicBlock *BB = 0); }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/InstrForest.h b/include/llvm/CodeGen/InstrForest.h index fc82d7c165..48266715bd 100644 --- a/include/llvm/CodeGen/InstrForest.h +++ b/include/llvm/CodeGen/InstrForest.h @@ -29,16 +29,24 @@ #include "llvm/Instruction.h" #include "Support/hash_map" +namespace llvm { + class Constant; class Function; class InstrTreeNode; class InstrForest; +} // End llvm namespace + +using namespace llvm; + //-------------------------------------------------------------------------- // OpLabel values for special-case nodes created for instruction selection. // All op-labels not defined here are identical to the instruction // opcode returned by Instruction::getOpcode() //-------------------------------------------------------------------------- +// + const int InvalidOp = -1; const int VRegListOp = 97; @@ -103,6 +111,7 @@ extern void printtree (InstrTreeNode*); extern int treecost (InstrTreeNode*, int, int); extern void printMatches (InstrTreeNode*); +namespace llvm { //------------------------------------------------------------------------ // class InstrTreeNode @@ -325,4 +334,6 @@ private: InstructionNode* buildTreeForInstruction(Instruction* instr); }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/InstrScheduling.h b/include/llvm/CodeGen/InstrScheduling.h index 40ce442f55..816aa7e806 100644 --- a/include/llvm/CodeGen/InstrScheduling.h +++ b/include/llvm/CodeGen/InstrScheduling.h @@ -15,6 +15,8 @@ #ifndef LLVM_CODEGEN_INSTR_SCHEDULING_H #define LLVM_CODEGEN_INSTR_SCHEDULING_H +namespace llvm { + class FunctionPass; class TargetMachine; @@ -30,4 +32,6 @@ class TargetMachine; FunctionPass *createInstructionSchedulingWithSSAPass(const TargetMachine &TM); +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/InstrSelection.h b/include/llvm/CodeGen/InstrSelection.h index 89e827d106..2f269ea2d5 100644 --- a/include/llvm/CodeGen/InstrSelection.h +++ b/include/llvm/CodeGen/InstrSelection.h @@ -16,6 +16,8 @@ #include "llvm/Instruction.h" +namespace llvm { + class Function; class InstrForest; class MachineInstr; @@ -102,4 +104,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/InstrSelectionSupport.h b/include/llvm/CodeGen/InstrSelectionSupport.h index 2ab23c756c..c1fba48615 100644 --- a/include/llvm/CodeGen/InstrSelectionSupport.h +++ b/include/llvm/CodeGen/InstrSelectionSupport.h @@ -17,6 +17,9 @@ #include "llvm/CodeGen/MachineInstr.h" #include "Support/DataTypes.h" + +namespace llvm { + class InstructionNode; class TargetMachine; class Instruction; @@ -44,4 +47,6 @@ MachineOperand::MachineOperandType ChooseRegOrImmed(int64_t intValue, unsigned& getMachineRegNum, int64_t& getImmedValue); +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/LiveVariables.h b/include/llvm/CodeGen/LiveVariables.h index 8d1306e061..3a0d044c59 100644 --- a/include/llvm/CodeGen/LiveVariables.h +++ b/include/llvm/CodeGen/LiveVariables.h @@ -32,6 +32,8 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include +namespace llvm { + class MRegisterInfo; class LiveVariables : public MachineFunctionPass { @@ -207,4 +209,6 @@ public: void HandlePhysRegDef(unsigned Reg, MachineInstr *MI); }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index b3959e81a7..b8a0361f7f 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -15,6 +15,9 @@ #define LLVM_CODEGEN_MACHINEBASICBLOCK_H #include + +namespace llvm { + class BasicBlock; class MachineInstr; template struct ilist_traits; @@ -81,5 +84,6 @@ private: // Methods used to maintain doubly linked list of blocks... void setNext(MachineBasicBlock *N) { Next = N; } }; +} // End llvm namespace #endif diff --git a/include/llvm/CodeGen/MachineCodeEmitter.h b/include/llvm/CodeGen/MachineCodeEmitter.h index 4145851006..2d01f45d70 100644 --- a/include/llvm/CodeGen/MachineCodeEmitter.h +++ b/include/llvm/CodeGen/MachineCodeEmitter.h @@ -19,6 +19,9 @@ #include #include "Support/DataTypes.h" + +namespace llvm { + class MachineFunction; class MachineBasicBlock; class MachineConstantPool; @@ -105,4 +108,6 @@ struct MachineCodeEmitter { static MachineCodeEmitter *createFilePrinterEmitter(MachineCodeEmitter&); }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineCodeForInstruction.h b/include/llvm/CodeGen/MachineCodeForInstruction.h index d421f3e971..9a08de79af 100644 --- a/include/llvm/CodeGen/MachineCodeForInstruction.h +++ b/include/llvm/CodeGen/MachineCodeForInstruction.h @@ -28,6 +28,8 @@ #include "Support/Annotation.h" #include +namespace llvm { + class MachineInstr; class Instruction; class Value; @@ -96,4 +98,6 @@ public: CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; } }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h index 441a43a9b9..edfd601faa 100644 --- a/include/llvm/CodeGen/MachineConstantPool.h +++ b/include/llvm/CodeGen/MachineConstantPool.h @@ -23,6 +23,9 @@ #define LLVM_CODEGEN_MACHINECONSTANTPOOL_H #include + +namespace llvm { + class Constant; class MachineConstantPool { @@ -54,4 +57,6 @@ public: void dump() const; }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineFrameInfo.h b/include/llvm/CodeGen/MachineFrameInfo.h index 48b91012e0..e48158e1b5 100644 --- a/include/llvm/CodeGen/MachineFrameInfo.h +++ b/include/llvm/CodeGen/MachineFrameInfo.h @@ -38,12 +38,19 @@ #ifndef LLVM_CODEGEN_MACHINEFRAMEINFO_H #define LLVM_CODEGEN_MACHINEFRAMEINFO_H +namespace llvm { + class TargetData; class TargetRegisterClass; class Type; class MachineFunction; + +} + #include +namespace llvm { + class MachineFrameInfo { // StackObject - Represent a single object allocated on the stack. @@ -220,4 +227,6 @@ public: void dump(const MachineFunction &MF) const; }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 7474a6e29a..60478cfe5a 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -22,6 +22,8 @@ #include "Support/Annotation.h" #include "Support/ilist" +namespace llvm { + class Function; class TargetMachine; class FunctionPass; @@ -141,4 +143,6 @@ public: MachineBasicBlock & back() { return BasicBlocks.back(); } }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineFunctionInfo.h b/include/llvm/CodeGen/MachineFunctionInfo.h index db73322278..fdf135b16b 100644 --- a/include/llvm/CodeGen/MachineFunctionInfo.h +++ b/include/llvm/CodeGen/MachineFunctionInfo.h @@ -17,6 +17,9 @@ #include "Support/HashExtras.h" #include "Support/hash_set" + +namespace llvm { + class MachineFunction; class Value; class Constant; @@ -112,4 +115,6 @@ private: int allocateOptionalArg(const Type* type); }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineFunctionPass.h b/include/llvm/CodeGen/MachineFunctionPass.h index 6975b5e785..390dcb8562 100644 --- a/include/llvm/CodeGen/MachineFunctionPass.h +++ b/include/llvm/CodeGen/MachineFunctionPass.h @@ -22,6 +22,8 @@ #include "llvm/Pass.h" #include "llvm/CodeGen/MachineFunction.h" +namespace llvm { + struct MachineFunctionPass : public FunctionPass { /// runOnMachineFunction - This method must be overloaded to perform the @@ -37,4 +39,6 @@ struct MachineFunctionPass : public FunctionPass { } }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index fc886d97f5..2eb373f462 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -20,6 +20,8 @@ #include "Support/Annotation.h" #include "Support/iterator" +namespace llvm { + class Value; class Function; class MachineBasicBlock; @@ -715,4 +717,6 @@ std::ostream& operator<<(std::ostream &OS, const MachineInstr &MI); std::ostream& operator<<(std::ostream &OS, const MachineOperand &MO); void PrintMachineInstructions(const Function *F); +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/MachineInstrAnnot.h b/include/llvm/CodeGen/MachineInstrAnnot.h index 98dde590b8..19d93ab56a 100644 --- a/include/llvm/CodeGen/MachineInstrAnnot.h +++ b/include/llvm/CodeGen/MachineInstrAnnot.h @@ -17,6 +17,8 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetRegInfo.h" +namespace llvm { + class Value; class TmpInstruction; class CallInst; @@ -88,5 +90,6 @@ public: static CallArgsDescriptor *get(const MachineInstr* MI); }; +} // End llvm namespace #endif diff --git a/include/llvm/CodeGen/MachineInstrBuilder.h b/include/llvm/CodeGen/MachineInstrBuilder.h index 14c7fe041f..67255214a2 100644 --- a/include/llvm/CodeGen/MachineInstrBuilder.h +++ b/include/llvm/CodeGen/MachineInstrBuilder.h @@ -25,6 +25,8 @@ #include "llvm/CodeGen/MachineInstr.h" +namespace llvm { + class MachineInstrBuilder { MachineInstr *MI; public: @@ -162,4 +164,6 @@ inline MachineInstrBuilder BuildMI(MachineBasicBlock *BB, int Opcode, MOTy::Def); } +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 807257e2c5..11fcf29013 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -15,6 +15,8 @@ #ifndef LLVM_CODEGEN_PASSES_H #define LLVM_CODEGEN_PASSES_H +namespace llvm { + class FunctionPass; class PassInfo; class TargetMachine; @@ -52,4 +54,6 @@ FunctionPass *createPrologEpilogCodeInserter(); /// for the Sparc. FunctionPass *getRegisterAllocator(TargetMachine &T); +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/SSARegMap.h b/include/llvm/CodeGen/SSARegMap.h index 7f5d5f97e5..c31911c91b 100644 --- a/include/llvm/CodeGen/SSARegMap.h +++ b/include/llvm/CodeGen/SSARegMap.h @@ -19,6 +19,8 @@ #include "llvm/Target/MRegisterInfo.h" +namespace llvm { + class TargetRegisterClass; class SSARegMap { @@ -44,4 +46,6 @@ class SSARegMap { } }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/SchedGraphCommon.h b/include/llvm/CodeGen/SchedGraphCommon.h index 874e53d994..a422d9ae0d 100644 --- a/include/llvm/CodeGen/SchedGraphCommon.h +++ b/include/llvm/CodeGen/SchedGraphCommon.h @@ -18,6 +18,8 @@ #include "llvm/Value.h" #include +namespace llvm { + class SchedGraphEdge; class SchedGraphNode; @@ -217,4 +219,6 @@ public: ~SchedGraphCommon(); }; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index f132f7b0a2..4719bf9d21 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -27,6 +27,9 @@ #include #include #include + +namespace llvm { + class Value; class Type; class Instruction; @@ -362,4 +365,6 @@ typedef ReducedValue ReducedValue_Consta typedef ReducedValue ReducedValue_Constant_f32; typedef ReducedValue ReducedValue_Constant_f64; +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/ValueSet.h b/include/llvm/CodeGen/ValueSet.h index 149506550d..f4bc6e80d4 100644 --- a/include/llvm/CodeGen/ValueSet.h +++ b/include/llvm/CodeGen/ValueSet.h @@ -17,6 +17,9 @@ #define VALUE_SET_H #include + +namespace llvm { + class Value; // RAV - Used to print values in a form used by the register allocator. @@ -31,4 +34,6 @@ std::ostream &operator<<(std::ostream &out, RAV Val); typedef std::set ValueSet; void printSet(const ValueSet &S); +} // End llvm namespace + #endif diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index dc85ee0d3c..b523b71a14 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -16,6 +16,8 @@ #ifndef LLVM_CODEGEN_VALUETYPES_H #define LLVM_CODEGEN_VALUETYPES_H +namespace llvm { + /// MVT namespace - This namespace defines the ValueType enum, which contains /// the various low-level value types. /// @@ -40,5 +42,6 @@ namespace MVT { // MVT = Machine Value Types }; }; -#endif +} // End llvm namespace +#endif diff --git a/include/llvm/Constant.h b/include/llvm/Constant.h index ac4c82090d..fbed6ee0fb 100644 --- a/include/llvm/Constant.h +++ b/include/llvm/Constant.h @@ -16,6 +16,8 @@ #include "llvm/User.h" +namespace llvm { + class Constant : public User { protected: inline Constant(const Type *Ty) : User(Ty, Value::ConstantVal) {} @@ -91,4 +93,6 @@ public: // END WARNING!! }; +} // End llvm namespace + #endif diff --git a/include/llvm/ConstantHandling.h b/include/llvm/ConstantHandling.h index a27283c440..a0a01e5306 100644 --- a/include/llvm/ConstantHandling.h +++ b/include/llvm/ConstantHandling.h @@ -42,6 +42,9 @@ #include "llvm/Constants.h" #include "llvm/Type.h" + +namespace llvm { + class PointerType; //===----------------------------------------------------------------------===// @@ -244,4 +247,7 @@ Constant *ConstantFoldShiftInstruction(unsigned Opcode, const Constant *V1, const Constant *V2); Constant *ConstantFoldGetElementPtr(const Constant *C, const std::vector &IdxList); + +} // End llvm namespace + #endif diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 077c61c6d5..5d65b2f0c7 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -18,6 +18,8 @@ #include "llvm/Constant.h" #include "Support/DataTypes.h" +namespace llvm { + class ArrayType; class StructType; class PointerType; @@ -575,4 +577,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/DerivedTypes.h b/include/llvm/DerivedTypes.h index 8efe2695a1..8d23df10c0 100644 --- a/include/llvm/DerivedTypes.h +++ b/include/llvm/DerivedTypes.h @@ -21,6 +21,8 @@ #include "llvm/Type.h" #include +namespace llvm { + template class TypeMap; class FunctionValType; class ArrayValType; @@ -490,4 +492,6 @@ inline const Type* PATypeHolder::get() const { return *const_cast(this) = NewTy; } +} // End llvm namespace + #endif diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index c2a0a3a7d2..5dd74b7cde 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -19,6 +19,9 @@ #include #include #include + +namespace llvm { + class Constant; class Function; union GenericValue; @@ -92,4 +95,6 @@ protected: GenericValue LoadValueFromMemory(GenericValue *Ptr, const Type *Ty); }; +} // End llvm namespace + #endif diff --git a/include/llvm/ExecutionEngine/GenericValue.h b/include/llvm/ExecutionEngine/GenericValue.h index b64eb79bbd..0446795d31 100644 --- a/include/llvm/ExecutionEngine/GenericValue.h +++ b/include/llvm/ExecutionEngine/GenericValue.h @@ -17,6 +17,8 @@ #include "Support/DataTypes.h" +namespace llvm { + typedef uint64_t PointerTy; union GenericValue { @@ -44,4 +46,6 @@ inline GenericValue PTOGV(void *P) { return GenericValue(P); } inline void* GVTOP(const GenericValue &GV) { return (void*)(intptr_t)GV.PointerVal; } + +} // End llvm namespace #endif diff --git a/include/llvm/Function.h b/include/llvm/Function.h index 3c44b3658f..4dd791ec21 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -22,6 +22,8 @@ #include "llvm/BasicBlock.h" #include "llvm/Argument.h" +namespace llvm { + class FunctionType; // Traits for intrusive list of instructions... @@ -95,7 +97,7 @@ public: virtual bool isExternal() const { return BasicBlocks.empty(); } /// getIntrinsicID - This method returns the ID number of the specified - /// function, or LLVMIntrinsic::not_intrinsic if the function is not an + /// function, or Intrinsic::not_intrinsic if the function is not an /// instrinsic, or if the pointer is null. This value is always defined to be /// zero to allow easy checking for whether a function is intrinsic or not. /// The particular intrinsic functions which correspond to this value are @@ -220,4 +222,6 @@ public: void dropAllReferences(); }; +} // End llvm namespace + #endif diff --git a/include/llvm/GlobalValue.h b/include/llvm/GlobalValue.h index f2349bc3cb..47a2189fa4 100644 --- a/include/llvm/GlobalValue.h +++ b/include/llvm/GlobalValue.h @@ -18,6 +18,9 @@ #define LLVM_GLOBALVALUE_H #include "llvm/User.h" + +namespace llvm { + class PointerType; class Module; @@ -71,4 +74,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h index d1a9a293c6..03c4f39120 100644 --- a/include/llvm/GlobalVariable.h +++ b/include/llvm/GlobalVariable.h @@ -22,6 +22,8 @@ #include "llvm/GlobalValue.h" +namespace llvm { + class Module; class Constant; class PointerType; @@ -105,4 +107,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/InstrTypes.h b/include/llvm/InstrTypes.h index e3d3d61adb..7938b483c7 100644 --- a/include/llvm/InstrTypes.h +++ b/include/llvm/InstrTypes.h @@ -18,6 +18,8 @@ #include "llvm/Instruction.h" +namespace llvm { + //===----------------------------------------------------------------------===// // TerminatorInst Class //===----------------------------------------------------------------------===// @@ -134,4 +136,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Instruction.def b/include/llvm/Instruction.def index e069e2ca7a..4208642d7f 100644 --- a/include/llvm/Instruction.def +++ b/include/llvm/Instruction.def @@ -15,7 +15,7 @@ // NOTE: NO INCLUDE GUARD DESIRED! -// Provide definitions of macros so that users of this file don't have to define +// Provide definitions of macros so that users of this file do not have to define // everything to use it... // #ifndef FIRST_TERM_INST diff --git a/include/llvm/Instruction.h b/include/llvm/Instruction.h index 264356ca91..cc9a8aec2b 100644 --- a/include/llvm/Instruction.h +++ b/include/llvm/Instruction.h @@ -17,6 +17,8 @@ #include "llvm/User.h" +namespace llvm { + class AssemblyAnnotationWriter; template struct ilist_traits; @@ -151,4 +153,6 @@ public: }; }; +} // End llvm namespace + #endif diff --git a/include/llvm/Intrinsics.h b/include/llvm/Intrinsics.h index 9d7c7bc994..8ecb6c42ee 100644 --- a/include/llvm/Intrinsics.h +++ b/include/llvm/Intrinsics.h @@ -16,11 +16,13 @@ #ifndef LLVM_INTRINSICS_H #define LLVM_INTRINSICS_H -/// LLVMIntrinsic Namespace - This namespace contains an enum with a value for +namespace llvm { + +/// Intrinsic Namespace - This namespace contains an enum with a value for /// every intrinsic/builtin function known by LLVM. These enum values are /// returned by Function::getIntrinsicID(). /// -namespace LLVMIntrinsic { +namespace Intrinsic { enum ID { not_intrinsic = 0, // Must be zero @@ -125,6 +127,9 @@ namespace LLVMIntrinsic { // second parameter, the possible values for which are // defined in the AlphaSfpToSq enumeration }; -} + +} // End Intrinsic namespace + +} // End llvm namespace #endif diff --git a/include/llvm/Linker.h b/include/llvm/Linker.h index ac399034d4..9f4c8c25f6 100644 --- a/include/llvm/Linker.h +++ b/include/llvm/Linker.h @@ -15,6 +15,9 @@ #define LLVM_TRANSFORMATIONS_UTILS_LINKER_H #include + +namespace llvm { + class Module; // LinkModules - This function links two modules together, with the resulting @@ -24,5 +27,7 @@ class Module; // bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0); +} // End llvm namespace + #endif diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 19626aea03..b38269dde0 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -21,6 +21,9 @@ #include "llvm/Function.h" #include "llvm/GlobalVariable.h" + +namespace llvm { + class GlobalVariable; class GlobalValueRefMap; // Used by ConstantVals.cpp class ConstantPointerRef; @@ -213,4 +216,6 @@ inline std::ostream &operator<<(std::ostream &O, const Module &M) { return O; } +} // End llvm namespace + #endif diff --git a/include/llvm/ModuleProvider.h b/include/llvm/ModuleProvider.h index 8d4b1d23af..de9616fe2e 100644 --- a/include/llvm/ModuleProvider.h +++ b/include/llvm/ModuleProvider.h @@ -18,6 +18,8 @@ #ifndef MODULEPROVIDER_H #define MODULEPROVIDER_H +namespace llvm { + class Function; class Module; @@ -52,4 +54,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 0d0a6e6fbc..8a10ead35e 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -34,6 +34,9 @@ #include #include #include + +namespace llvm { + class Value; class BasicBlock; class Function; @@ -329,6 +332,8 @@ private: virtual void addToPassManager(PassManagerT *PM,AnalysisUsage &AU); }; +} // End llvm namespace + // Include support files that contain important APIs commonly used by Passes, // but that we want to separate out to make it easier to read the header files. // diff --git a/include/llvm/PassAnalysisSupport.h b/include/llvm/PassAnalysisSupport.h index 61fb29fb81..f62465a8b8 100644 --- a/include/llvm/PassAnalysisSupport.h +++ b/include/llvm/PassAnalysisSupport.h @@ -19,6 +19,8 @@ #ifndef LLVM_PASS_ANALYSIS_SUPPORT_H #define LLVM_PASS_ANALYSIS_SUPPORT_H +namespace llvm { + // No need to include Pass.h, we are being included by it! //===----------------------------------------------------------------------===// @@ -133,4 +135,6 @@ AnalysisType *Pass::getAnalysisToUpdate() const { return dynamic_cast(Resolver->getAnalysisToUpdate(PI)); } +} // End llvm namespace + #endif diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index c47abdaef9..b1d369b925 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -17,6 +17,8 @@ #ifndef LLVM_PASSMANAGER_H #define LLVM_PASSMANAGER_H +namespace llvm { + class Pass; class Module; class ModuleProvider; @@ -72,4 +74,6 @@ public: bool run(Function &F); }; +} // End llvm namespace + #endif diff --git a/include/llvm/PassSupport.h b/include/llvm/PassSupport.h index 226ee29357..d985bf121d 100644 --- a/include/llvm/PassSupport.h +++ b/include/llvm/PassSupport.h @@ -23,6 +23,8 @@ // No need to include Pass.h, we are being included by it! +namespace llvm { + class TargetMachine; //===--------------------------------------------------------------------------- @@ -395,4 +397,7 @@ struct PassRegistrationListener { struct IncludeFile { IncludeFile(void *); }; + +} // End llvm namespace + #endif diff --git a/include/llvm/SlotCalculator.h b/include/llvm/SlotCalculator.h index 7e56de99dc..596f9324ed 100644 --- a/include/llvm/SlotCalculator.h +++ b/include/llvm/SlotCalculator.h @@ -22,6 +22,9 @@ #include #include + +namespace llvm { + class Value; class Module; class Function; @@ -92,4 +95,6 @@ protected: void processSymbolTableConstants(const SymbolTable *ST); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/Annotation.h b/include/llvm/Support/Annotation.h index 075ffc297a..cee7ab7d89 100644 --- a/include/llvm/Support/Annotation.h +++ b/include/llvm/Support/Annotation.h @@ -25,6 +25,8 @@ #include #include +namespace llvm { + class AnnotationID; class Annotation; class Annotable; @@ -217,4 +219,6 @@ inline Annotation *Annotable::getOrCreateAnnotation(AnnotationID ID) const { return A; } +} // End namespace llvm + #endif diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index 26616dbb7a..bbe1701da1 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -20,6 +20,8 @@ #include "llvm/InstrTypes.h" #include "Support/iterator" +namespace llvm { + //===--------------------------------------------------------------------===// // BasicBlock pred_iterator definition //===--------------------------------------------------------------------===// @@ -264,4 +266,6 @@ template <> struct GraphTraits > : } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h index 5e3fd3e662..8f7cf1a786 100644 --- a/include/llvm/Support/CallSite.h +++ b/include/llvm/Support/CallSite.h @@ -23,6 +23,8 @@ #include "llvm/Instruction.h" +namespace llvm { + class CallInst; class InvokeInst; @@ -100,4 +102,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index 065919c179..4b070c18d8 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -15,6 +15,8 @@ #ifndef SUPPORT_CASTING_H #define SUPPORT_CASTING_H +namespace llvm { + //===----------------------------------------------------------------------===// // isa Support Templates //===----------------------------------------------------------------------===// @@ -293,4 +295,6 @@ void main() { #endif +} // End llvm namespace + #endif diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 01f55a81d4..df40d80070 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -27,6 +27,7 @@ #include #include "boost/type_traits/object_traits.hpp" +namespace llvm { /// cl Namespace - This namespace contains all of the command line option /// processing machinery. It is intentionally a short name to make qualified /// usage concise. @@ -1022,4 +1023,6 @@ struct aliasopt { } // End namespace cl +} // End namespace llvm + #endif diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index c173549a37..d97b73e824 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -26,6 +26,9 @@ #include "Support/DataTypes.h" #include + +namespace llvm { + class ConstantIntegral; class Type; @@ -124,4 +127,6 @@ inline std::ostream &operator<<(std::ostream &OS, const ConstantRange &CR) { return OS; } +} // End llvm namespace + #endif diff --git a/include/llvm/Support/DOTGraphTraits.h b/include/llvm/Support/DOTGraphTraits.h index 002a78ec4f..63837b7ddf 100644 --- a/include/llvm/Support/DOTGraphTraits.h +++ b/include/llvm/Support/DOTGraphTraits.h @@ -19,6 +19,8 @@ #include +namespace llvm { + /// DefaultDOTGraphTraits - This class provides the default implementations of /// all of the DOTGraphTraits methods. If a specialization does not need to /// override all methods here it should inherit so that it can get the default @@ -96,4 +98,6 @@ struct DefaultDOTGraphTraits { template class DOTGraphTraits : public DefaultDOTGraphTraits {}; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h index 8cba05771f..66a208811a 100644 --- a/include/llvm/Support/Debug.h +++ b/include/llvm/Support/Debug.h @@ -26,6 +26,8 @@ #ifndef SUPPORT_DEBUG_H #define SUPPORT_DEBUG_H +namespace llvm { + // DebugFlag - This boolean is set to true if the '-debug' command line option // is specified. This should probably not be referenced directly, instead, use // the DEBUG macro below. @@ -57,4 +59,6 @@ bool isCurrentDebugType(const char *Type); do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0) #endif +} // End llvm namespace + #endif diff --git a/include/llvm/Support/DynamicLinker.h b/include/llvm/Support/DynamicLinker.h index 8f02708268..fec9a45296 100644 --- a/include/llvm/Support/DynamicLinker.h +++ b/include/llvm/Support/DynamicLinker.h @@ -18,6 +18,8 @@ #include +namespace llvm { + /// LinkDynamicObject - Load the named file as a dynamic library /// and link it with the currently running process. Returns false /// on success, true if there is an error (and sets ErrorMessage @@ -33,4 +35,6 @@ bool LinkDynamicObject (const char *filename, std::string *ErrorMessage); void *GetAddressOfSymbol (const char *symbolName); void *GetAddressOfSymbol (const std::string &symbolName); +} // End llvm namespace + #endif // SUPPORT_DYNAMICLINKER_H diff --git a/include/llvm/Support/FileUtilities.h b/include/llvm/Support/FileUtilities.h index 0dfa625362..c276ec7aaa 100644 --- a/include/llvm/Support/FileUtilities.h +++ b/include/llvm/Support/FileUtilities.h @@ -17,6 +17,8 @@ #include +namespace llvm { + /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must /// name a readable file. /// @@ -95,4 +97,6 @@ bool MakeFileExecutable (const std::string & Filename); /// bool MakeFileReadable (const std::string & Filename); +} // End llvm namespace + #endif diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index 2cb8fcc985..7e5aa80645 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -28,6 +28,8 @@ #include #include +namespace llvm { + namespace DOT { // Private functions... inline std::string EscapeString(const std::string &Label) { std::string Str(Label); @@ -206,4 +208,6 @@ std::ostream &WriteGraph(std::ostream &O, const GraphType &G, return O; } +} // End llvm namespace + #endif diff --git a/include/llvm/Support/InstIterator.h b/include/llvm/Support/InstIterator.h index 4c2d185576..31c8b660d6 100644 --- a/include/llvm/Support/InstIterator.h +++ b/include/llvm/Support/InstIterator.h @@ -22,6 +22,8 @@ #include "llvm/BasicBlock.h" #include "llvm/Function.h" +namespace llvm { + // This class implements inst_begin() & inst_end() for // inst_iterator and const_inst_iterator's. // @@ -137,4 +139,6 @@ inline const_inst_iterator inst_end(const Function &F) { return const_inst_iterator(F, true); } +} // End llvm namespace + #endif diff --git a/include/llvm/Support/InstVisitor.h b/include/llvm/Support/InstVisitor.h index de1bce96bb..9a34edb71f 100644 --- a/include/llvm/Support/InstVisitor.h +++ b/include/llvm/Support/InstVisitor.h @@ -52,6 +52,8 @@ #include "llvm/Instruction.h" +namespace llvm { + class Module; // We operate on opaque instruction classes, so forward declare all instruction @@ -64,7 +66,6 @@ class Module; class TerminatorInst; class BinaryOperator; class AllocationInst; - #define DELEGATE(CLASS_TO_VISIT) \ return ((SubClass*)this)->visit##CLASS_TO_VISIT((CLASS_TO_VISIT&)I) @@ -186,4 +187,6 @@ struct InstVisitor { #undef DELEGATE +} // End llvm namespace + #endif diff --git a/include/llvm/Support/LeakDetector.h b/include/llvm/Support/LeakDetector.h index b39e0b5911..e2ce9c50be 100644 --- a/include/llvm/Support/LeakDetector.h +++ b/include/llvm/Support/LeakDetector.h @@ -23,6 +23,9 @@ #define SUPPORT_LEAKDETECTOR_H #include + +namespace llvm { + class Value; struct LeakDetector { @@ -83,4 +86,6 @@ private: static void checkForGarbageImpl(const std::string &Message); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/Linker.h b/include/llvm/Support/Linker.h index ac399034d4..9f4c8c25f6 100644 --- a/include/llvm/Support/Linker.h +++ b/include/llvm/Support/Linker.h @@ -15,6 +15,9 @@ #define LLVM_TRANSFORMATIONS_UTILS_LINKER_H #include + +namespace llvm { + class Module; // LinkModules - This function links two modules together, with the resulting @@ -24,5 +27,7 @@ class Module; // bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0); +} // End llvm namespace + #endif diff --git a/include/llvm/Support/MallocAllocator.h b/include/llvm/Support/MallocAllocator.h index 1ba25b0d65..766a67fa22 100644 --- a/include/llvm/Support/MallocAllocator.h +++ b/include/llvm/Support/MallocAllocator.h @@ -23,6 +23,8 @@ #include #include +namespace llvm { + template struct MallocAllocator { typedef size_t size_type; @@ -79,5 +81,6 @@ namespace std { }; } +} // End llvm namespace #endif diff --git a/include/llvm/Support/Mangler.h b/include/llvm/Support/Mangler.h index 1f56ff319e..5b312f8ef4 100644 --- a/include/llvm/Support/Mangler.h +++ b/include/llvm/Support/Mangler.h @@ -14,12 +14,19 @@ #ifndef LLVM_SUPPORT_MANGLER_H #define LLVM_SUPPORT_MANGLER_H +namespace llvm { + class Value; class Module; + +} // End llvm namespace + #include #include #include +namespace llvm { + class Mangler { /// This keeps track of which global values have had their names /// mangled in the current module. @@ -54,4 +61,6 @@ public: static std::string makeNameProper(const std::string &x); }; +} // End llvm namespace + #endif // LLVM_SUPPORT_MANGLER_H diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index ec742324b0..74958fbc35 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -16,6 +16,8 @@ #include "Support/DataTypes.h" +namespace llvm { + inline unsigned log2(uint64_t C) { unsigned getPow; for (getPow = 0; C > 1; ++getPow) @@ -33,4 +35,6 @@ inline bool isPowerOf2(int64_t C, unsigned &getPow) { return false; } +} // End llvm namespace + #endif diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index f63666ba66..0ffcabad52 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -28,6 +28,8 @@ #include #include +namespace llvm { + //===----------------------------------------------------------------------===// // PassNameParser class - Make use of the pass registration mechanism to // automatically add a command line argument to opt for each pass. @@ -114,4 +116,6 @@ struct FilteredPassNameParser : public PassNameParser { } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/SystemUtils.h b/include/llvm/Support/SystemUtils.h index ccde86cce6..c874d9932c 100644 --- a/include/llvm/Support/SystemUtils.h +++ b/include/llvm/Support/SystemUtils.h @@ -17,6 +17,8 @@ #include +namespace llvm { + /// isExecutableFile - This function returns true if the filename specified /// exists and is executable. /// @@ -45,4 +47,7 @@ int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, /// wait for it to terminate. /// int ExecWait (const char * const argv[], const char * const envp[]); + +} // End llvm namespace + #endif diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h index 57ef3f0d64..ac465bb95b 100644 --- a/include/llvm/Support/Timer.h +++ b/include/llvm/Support/Timer.h @@ -20,6 +20,8 @@ #include #include +namespace llvm { + class TimerGroup; /// Timer - This class is used to track the amount of time spent between @@ -157,4 +159,6 @@ private: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/ToolRunner.h b/include/llvm/Support/ToolRunner.h index e23ec7f312..8ce3f5d8f3 100644 --- a/include/llvm/Support/ToolRunner.h +++ b/include/llvm/Support/ToolRunner.h @@ -20,6 +20,8 @@ #include "Support/SystemUtils.h" #include +namespace llvm { + class CBE; class LLC; @@ -137,4 +139,6 @@ public: int OutputAsm(const std::string &Bytecode, std::string &OutputAsmFile); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Support/TypeInfo.h b/include/llvm/Support/TypeInfo.h index aa2093a43d..5d9035076f 100644 --- a/include/llvm/Support/TypeInfo.h +++ b/include/llvm/Support/TypeInfo.h @@ -18,6 +18,8 @@ #include +namespace llvm { + struct TypeInfo { TypeInfo() { // needed for containers struct Nil {}; // Anonymous class distinct from all others... @@ -69,4 +71,6 @@ inline bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs) { return !(lhs < rhs); } +} // End llvm namespace + #endif diff --git a/include/llvm/Support/ValueHolder.h b/include/llvm/Support/ValueHolder.h index 62ab9d9ca2..bab201287e 100644 --- a/include/llvm/Support/ValueHolder.h +++ b/include/llvm/Support/ValueHolder.h @@ -20,6 +20,8 @@ #include "llvm/User.h" +namespace llvm { + struct ValueHolder : public User { ValueHolder(Value *V = 0); ValueHolder(const ValueHolder &VH) : User(VH.getType(), Value::TypeVal) { @@ -46,4 +48,6 @@ struct ValueHolder : public User { } }; +} // End llvm namespace + #endif diff --git a/include/llvm/SymbolTable.h b/include/llvm/SymbolTable.h index 42f15aa626..8502375581 100644 --- a/include/llvm/SymbolTable.h +++ b/include/llvm/SymbolTable.h @@ -26,6 +26,8 @@ #include "llvm/Value.h" #include +namespace llvm { + class SymbolTable : public AbstractTypeUser, public std::map > { @@ -132,4 +134,6 @@ private: virtual void typeBecameConcrete(const DerivedType *AbsTy); }; +} // End llvm namespace + #endif diff --git a/include/llvm/SymbolTableListTraits.h b/include/llvm/SymbolTableListTraits.h index 820f391d40..46be356151 100644 --- a/include/llvm/SymbolTableListTraits.h +++ b/include/llvm/SymbolTableListTraits.h @@ -25,6 +25,8 @@ #ifndef LLVM_SYMBOLTABLELISTTRAITS_H #define LLVM_SYMBOLTABLELISTTRAITS_H +namespace llvm { + template class ilist_iterator; template class iplist; template struct ilist_traits; @@ -72,4 +74,6 @@ public: void setParent(SymTabClass *Parent); // This is private! }; +} // End llvm namespace + #endif diff --git a/include/llvm/System/Signals.h b/include/llvm/System/Signals.h index ce12301a15..0cbf398798 100644 --- a/include/llvm/System/Signals.h +++ b/include/llvm/System/Signals.h @@ -17,10 +17,13 @@ #include +namespace llvm { + // RemoveFileOnSignal - This function registers signal handlers to ensure that // if a signal gets delivered that the named file is removed. // void RemoveFileOnSignal(const std::string &Filename); -#endif +} // End llvm namespace +#endif diff --git a/include/llvm/Target/MRegisterInfo.h b/include/llvm/Target/MRegisterInfo.h index a87c74fc4e..3217b47b72 100644 --- a/include/llvm/Target/MRegisterInfo.h +++ b/include/llvm/Target/MRegisterInfo.h @@ -19,6 +19,8 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include +namespace llvm { + class Type; class MachineFunction; @@ -280,4 +282,6 @@ public: MachineBasicBlock &MBB) const = 0; }; +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetCacheInfo.h b/include/llvm/Target/TargetCacheInfo.h index 56f20bf524..357adf0685 100644 --- a/include/llvm/Target/TargetCacheInfo.h +++ b/include/llvm/Target/TargetCacheInfo.h @@ -16,6 +16,8 @@ #include "Support/DataTypes.h" +namespace llvm { + class TargetMachine; struct TargetCacheInfo { @@ -59,4 +61,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h index 8dcb6255d4..9be9564f16 100644 --- a/include/llvm/Target/TargetData.h +++ b/include/llvm/Target/TargetData.h @@ -24,6 +24,9 @@ #include "Support/Annotation.h" #include "Support/DataTypes.h" #include + +namespace llvm { + class Value; class Type; class StructType; @@ -101,4 +104,6 @@ private: inline StructLayout(const StructType *ST, const TargetData &TD); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetFrameInfo.h b/include/llvm/Target/TargetFrameInfo.h index 0f82e27470..2b968fab1a 100644 --- a/include/llvm/Target/TargetFrameInfo.h +++ b/include/llvm/Target/TargetFrameInfo.h @@ -14,6 +14,8 @@ #ifndef LLVM_TARGET_TARGETFRAMEINFO_H #define LLVM_TARGET_TARGETFRAMEINFO_H +namespace llvm { + class MachineFunction; struct TargetFrameInfo { @@ -99,4 +101,6 @@ public: virtual int getDynamicAreaBaseRegNum() const { abort(); } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index 76cfb392ae..c6afba5a15 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -18,6 +18,8 @@ #include #include +namespace llvm { + class MachineInstr; class TargetMachine; class Value; @@ -415,4 +417,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index af06349aa9..c0771a1746 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -17,6 +17,8 @@ #include "llvm/Target/TargetData.h" #include +namespace llvm { + class TargetInstrInfo; class TargetInstrDescriptor; class TargetSchedInfo; @@ -117,4 +119,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetMachineImpls.h b/include/llvm/Target/TargetMachineImpls.h index 670b2dc4b6..3ca20c74e9 100644 --- a/include/llvm/Target/TargetMachineImpls.h +++ b/include/llvm/Target/TargetMachineImpls.h @@ -15,6 +15,8 @@ #ifndef LLVM_TARGET_TARGETMACHINEIMPLS_H #define LLVM_TARGET_TARGETMACHINEIMPLS_H +namespace llvm { + class TargetMachine; class Module; @@ -30,4 +32,6 @@ TargetMachine *allocateSparcTargetMachine(const Module &M); // TargetMachine *allocateX86TargetMachine(const Module &M); +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetRegInfo.h b/include/llvm/Target/TargetRegInfo.h index 36bfc0b915..f9f67c7424 100644 --- a/include/llvm/Target/TargetRegInfo.h +++ b/include/llvm/Target/TargetRegInfo.h @@ -19,6 +19,8 @@ #include #include +namespace llvm { + class TargetMachine; class IGNode; class Type; @@ -289,4 +291,6 @@ public: virtual int getSpilledRegSize(int RegType) const = 0; }; +} // End llvm namespace + #endif diff --git a/include/llvm/Target/TargetSchedInfo.h b/include/llvm/Target/TargetSchedInfo.h index dd8df32044..ae97d109e3 100644 --- a/include/llvm/Target/TargetSchedInfo.h +++ b/include/llvm/Target/TargetSchedInfo.h @@ -18,6 +18,8 @@ #include "Support/hash_map" #include +namespace llvm { + typedef long long cycles_t; static const cycles_t HUGE_LATENCY = ~((long long) 1 << (sizeof(cycles_t)-2)); static const cycles_t INVALID_LATENCY = -HUGE_LATENCY; @@ -36,13 +38,17 @@ private: OpCodePair(); // disable for now }; +} // End llvm namespace + namespace HASH_NAMESPACE { - template <> struct hash { - size_t operator()(const OpCodePair& pair) const { + template <> struct hash { + size_t operator()(const llvm::OpCodePair& pair) const { return hash()(pair.val); } }; -} +} // End HASH_NAMESPACE (a macro) namespace + +namespace llvm { //--------------------------------------------------------------------------- // class MachineResource @@ -321,4 +327,6 @@ protected: }; +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/IPO.h b/include/llvm/Transforms/IPO.h index 62ed93c5bb..80f5a527ab 100644 --- a/include/llvm/Transforms/IPO.h +++ b/include/llvm/Transforms/IPO.h @@ -15,6 +15,8 @@ #ifndef LLVM_TRANSFORMS_IPO_H #define LLVM_TRANSFORMS_IPO_H +namespace llvm { + class Pass; class Function; @@ -119,4 +121,6 @@ Pass *createIPConstantPropagationPass(); Pass *createSwapElementsPass(); Pass *createSortElementsPass(); +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index abe4fc46f6..035b8d1e0c 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -14,6 +14,8 @@ #ifndef LLVM_TRANSFORMS_INSTRUMENTATION_H #define LLVM_TRANSFORMS_INSTRUMENTATION_H +namespace llvm { + class Pass; //===----------------------------------------------------------------------===// @@ -23,4 +25,6 @@ class Pass; Pass *createTraceValuesPassForFunction(); // Just trace function entry/exit Pass *createTraceValuesPassForBasicBlocks(); // Trace BB's and methods +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/MutateStructTypes.h b/include/llvm/Transforms/MutateStructTypes.h index f9b753caf4..c68f2ddf27 100644 --- a/include/llvm/Transforms/MutateStructTypes.h +++ b/include/llvm/Transforms/MutateStructTypes.h @@ -24,6 +24,8 @@ #include "llvm/Pass.h" #include "llvm/AbstractTypeUser.h" +namespace llvm { + class Value; class Type; class StructType; @@ -111,4 +113,6 @@ private: unsigned idx = 0); }; +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 81fd59767d..da17b8d10c 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -15,6 +15,8 @@ #ifndef LLVM_TRANSFORMS_SCALAR_H #define LLVM_TRANSFORMS_SCALAR_H +namespace llvm { + class Pass; class FunctionPass; class GetElementPtrInst; @@ -268,4 +270,6 @@ FunctionPass *createLowerInvokePass(); Pass *createSymbolStrippingPass(); Pass *createFullSymbolStrippingPass(); +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h index 4630d5399a..155eae8e36 100644 --- a/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -19,6 +19,9 @@ #include "llvm/BasicBlock.h" #include "llvm/Support/CFG.h" + +namespace llvm { + class Instruction; class Pass; @@ -50,7 +53,6 @@ void ReplaceInstWithInst(Instruction *From, Instruction *To); // void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum); - /// isCriticalEdge - Return true if the specified edge is a critical edge. /// Critical edges are edges from a block with multiple successors to a block /// with multiple predecessors. @@ -82,5 +84,6 @@ inline bool SplitCriticalEdge(BasicBlock *Succ, pred_iterator PI, Pass *P = 0) { return MadeChange; } +} // End llvm namespace #endif diff --git a/include/llvm/Transforms/Utils/Cloning.h b/include/llvm/Transforms/Utils/Cloning.h index 351deefa8c..f6351d4876 100644 --- a/include/llvm/Transforms/Utils/Cloning.h +++ b/include/llvm/Transforms/Utils/Cloning.h @@ -20,6 +20,9 @@ #include #include + +namespace llvm { + class Module; class Function; class BasicBlock; @@ -109,4 +112,6 @@ bool InlineFunction(CallSite CS); /// no jump to it) and returns the new vector of basic blocks. std::vector CloneTrace(const std::vector &origTrace); +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/Utils/DemoteRegToStack.h b/include/llvm/Transforms/Utils/DemoteRegToStack.h index 1d6d2c6595..5810087f82 100644 --- a/include/llvm/Transforms/Utils/DemoteRegToStack.h +++ b/include/llvm/Transforms/Utils/DemoteRegToStack.h @@ -24,7 +24,11 @@ // //===----------------------------------------------------------------------===// +namespace llvm { + class Instruction; class AllocaInst; AllocaInst *DemoteRegToStack(Instruction &X); + +} // End llvm namespace diff --git a/include/llvm/Transforms/Utils/Linker.h b/include/llvm/Transforms/Utils/Linker.h index ac399034d4..9f4c8c25f6 100644 --- a/include/llvm/Transforms/Utils/Linker.h +++ b/include/llvm/Transforms/Utils/Linker.h @@ -15,6 +15,9 @@ #define LLVM_TRANSFORMATIONS_UTILS_LINKER_H #include + +namespace llvm { + class Module; // LinkModules - This function links two modules together, with the resulting @@ -24,5 +27,7 @@ class Module; // bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg = 0); +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/Utils/Local.h b/include/llvm/Transforms/Utils/Local.h index 286aef993e..2f83174249 100644 --- a/include/llvm/Transforms/Utils/Local.h +++ b/include/llvm/Transforms/Utils/Local.h @@ -16,6 +16,9 @@ #define LLVM_TRANSFORMS_UTILS_LOCAL_H #include "llvm/Function.h" + +namespace llvm { + class Pass; //===----------------------------------------------------------------------===// @@ -67,4 +70,6 @@ bool dceInstruction(BasicBlock::iterator &BBI); /// bool SimplifyCFG(BasicBlock *BB); +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/Utils/PromoteMemToReg.h b/include/llvm/Transforms/Utils/PromoteMemToReg.h index 57d5dae43c..38ea373885 100644 --- a/include/llvm/Transforms/Utils/PromoteMemToReg.h +++ b/include/llvm/Transforms/Utils/PromoteMemToReg.h @@ -15,11 +15,14 @@ #ifndef TRANSFORMS_UTILS_PROMOTEMEMTOREG_H #define TRANSFORMS_UTILS_PROMOTEMEMTOREG_H +#include + +namespace llvm { + class AllocaInst; class DominatorTree; class DominanceFrontier; class TargetData; -#include /// isAllocaPromotable - Return true if this alloca is legal for promotion. /// This is true if there are only loads and stores to the alloca... @@ -35,4 +38,6 @@ void PromoteMemToReg(const std::vector &Allocas, DominatorTree &DT, DominanceFrontier &DF, const TargetData &TD); +} // End llvm namespace + #endif diff --git a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h index a59517c689..590d51034b 100644 --- a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h +++ b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h @@ -20,6 +20,8 @@ #include "llvm/Pass.h" +namespace llvm { + struct UnifyFunctionExitNodes : public FunctionPass { BasicBlock *ReturnBlock, *UnwindBlock; public: @@ -39,4 +41,6 @@ public: Pass *createUnifyFunctionExitNodesPass(); +} // End llvm namespace + #endif diff --git a/include/llvm/Type.def b/include/llvm/Type.def index 566a9a3f02..6101cd0aa0 100644 --- a/include/llvm/Type.def +++ b/include/llvm/Type.def @@ -16,7 +16,7 @@ // NOTE: NO INCLUDE GUARD DESIRED! -// If the user didn't specify one of the macros, give a default noop defn. +// If the user did not specify one of the macros, give a default noop defn. // #ifndef HANDLE_PRIM_TYPE #define HANDLE_PRIM_TYPE(x,y) diff --git a/include/llvm/Type.h b/include/llvm/Type.h index 4c9fd1db48..ba4ac3415f 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -37,6 +37,8 @@ #include "Support/GraphTraits.h" #include "Support/iterator" +namespace llvm { + class DerivedType; class FunctionType; class ArrayType; @@ -324,4 +326,6 @@ template <> inline bool isa_impl(const Type &Ty) { return Ty.getPrimitiveID() == Type::PointerTyID; } +} // End llvm namespace + #endif diff --git a/include/llvm/Use.h b/include/llvm/Use.h index 4deee300f6..f94045b39e 100644 --- a/include/llvm/Use.h +++ b/include/llvm/Use.h @@ -17,6 +17,9 @@ #define LLVM_USE_H #include "Support/ilist" + +namespace llvm { + template struct ilist_traits; class Value; class User; @@ -77,13 +80,13 @@ struct ilist_traits { }; -template<> struct simplify_type { +template<> struct std::simplify_type { typedef Value* SimpleType; static SimpleType getSimplifiedValue(const Use &Val) { return (SimpleType)Val.get(); } }; -template<> struct simplify_type { +template<> struct std::simplify_type { typedef Value* SimpleType; static SimpleType getSimplifiedValue(const Use &Val) { return (SimpleType)Val.get(); @@ -150,4 +153,6 @@ struct UseListConstIteratorWrapper : public iplist::const_iterator { } }; +} // End llvm namespace + #endif diff --git a/include/llvm/User.h b/include/llvm/User.h index aba56d5819..cdd9b539ca 100644 --- a/include/llvm/User.h +++ b/include/llvm/User.h @@ -22,6 +22,8 @@ #include "llvm/Value.h" #include +namespace llvm { + class User : public Value { User(const User &); // Do not implement protected: @@ -110,4 +112,6 @@ template<> struct simplify_type { template<> struct simplify_type : public simplify_type {}; +} // End llvm namespace + #endif diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 537bcba11b..e92d6fc6cb 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -23,6 +23,8 @@ #include "Support/Casting.h" #include +namespace llvm { + class Type; class Constant; class Argument; @@ -198,4 +200,6 @@ template <> inline bool isa_impl(const Value &Val) { return isa(Val) || isa(Val); } +} // End llvm namespace + #endif diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h index db82b54c01..e0a551a0f7 100644 --- a/include/llvm/iMemory.h +++ b/include/llvm/iMemory.h @@ -16,6 +16,9 @@ #define LLVM_IMEMORY_H #include "llvm/Instruction.h" + +namespace llvm { + class PointerType; //===----------------------------------------------------------------------===// @@ -296,4 +299,6 @@ public: } }; +} // End llvm namespace + #endif // LLVM_IMEMORY_H diff --git a/include/llvm/iOperators.h b/include/llvm/iOperators.h index 39bfe14660..ecf99172a1 100644 --- a/include/llvm/iOperators.h +++ b/include/llvm/iOperators.h @@ -16,6 +16,8 @@ #include "llvm/InstrTypes.h" +namespace llvm { + /// SetCondInst class - Represent a setCC operator, where CC is eq, ne, lt, gt, /// le, or ge. /// @@ -63,4 +65,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/iOther.h b/include/llvm/iOther.h index 4e23afdc89..c611e06612 100644 --- a/include/llvm/iOther.h +++ b/include/llvm/iOther.h @@ -17,6 +17,8 @@ #include "llvm/InstrTypes.h" +namespace llvm { + //===----------------------------------------------------------------------===// // CastInst Class //===----------------------------------------------------------------------===// @@ -195,4 +197,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/iPHINode.h b/include/llvm/iPHINode.h index 54b867d59d..191de040e7 100644 --- a/include/llvm/iPHINode.h +++ b/include/llvm/iPHINode.h @@ -15,6 +15,9 @@ #define LLVM_IPHINODE_H #include "llvm/Instruction.h" + +namespace llvm { + class BasicBlock; //===----------------------------------------------------------------------===// @@ -112,4 +115,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/include/llvm/iTerminators.h b/include/llvm/iTerminators.h index 5f435a05c6..93e3adce76 100644 --- a/include/llvm/iTerminators.h +++ b/include/llvm/iTerminators.h @@ -18,6 +18,8 @@ #include "llvm/InstrTypes.h" +namespace llvm { + //===--------------------------------------------------------------------------- // ReturnInst - Return a value (possibly void), from a function. Execution does // not continue in this function any longer. @@ -306,4 +308,6 @@ struct UnwindInst : public TerminatorInst { } }; +} // End llvm namespace + #endif diff --git a/lib/Analysis/AliasAnalysis.cpp b/lib/Analysis/AliasAnalysis.cpp index 3acdf7841d..c881ec283a 100644 --- a/lib/Analysis/AliasAnalysis.cpp +++ b/lib/Analysis/AliasAnalysis.cpp @@ -29,6 +29,8 @@ #include "llvm/iMemory.h" #include "llvm/Target/TargetData.h" +namespace llvm { + // Register the AliasAnalysis interface, providing a nice name to refer to. namespace { RegisterAnalysisGroup Z("Alias Analysis"); @@ -123,3 +125,5 @@ namespace { // Declare that we implement the AliasAnalysis interface RegisterAnalysisGroup Y; } // End of anonymous namespace + +} // End llvm namespace diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index 5820565223..59036a4c39 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -16,6 +16,8 @@ #include "llvm/Pass.h" #include +namespace llvm { + namespace { class AliasAnalysisCounter : public Pass, public AliasAnalysis { unsigned No, May, Must; @@ -108,3 +110,5 @@ namespace { X("count-aa", "Count Alias Analysis Query Responses"); RegisterAnalysisGroup Y; } + +} // End llvm namespace diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index d4a7d18dcd..2c967c5daa 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -26,6 +26,8 @@ #include "Support/CommandLine.h" #include +namespace llvm { + namespace { cl::opt PrintNo ("print-no-aliases", cl::ReallyHidden); cl::opt PrintMay ("print-may-aliases", cl::ReallyHidden); @@ -114,3 +116,5 @@ bool AAEval::doFinalization(Module &M) { << May*100/Sum << "%/" << Must*100/Sum<<"%\n"; return false; } + +} // End llvm namespace diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index c2800326c2..4a293448ed 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -21,6 +21,8 @@ #include "llvm/Assembly/Writer.h" #include "llvm/Support/InstIterator.h" +namespace llvm { + /// mergeSetIn - Merge the specified alias set into this alias set... /// void AliasSet::mergeSetIn(AliasSet &AS) { @@ -294,7 +296,6 @@ void AliasSetTracker::print(std::ostream &OS) const { void AliasSet::dump() const { print (std::cerr); } void AliasSetTracker::dump() const { print(std::cerr); } - //===----------------------------------------------------------------------===// // AliasSetPrinter Pass //===----------------------------------------------------------------------===// @@ -328,3 +329,5 @@ namespace { RegisterPass X("print-alias-sets", "Alias Set Printer", PassInfo::Analysis | PassInfo::Optimization); } + +} // End llvm namespace diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index e60922ac04..16512c0e17 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -23,10 +23,11 @@ #include "llvm/DerivedTypes.h" #include "llvm/Target/TargetData.h" +namespace llvm { + // Make sure that anything that uses AliasAnalysis pulls in this file... void BasicAAStub() {} - namespace { struct BasicAliasAnalysis : public ImmutablePass, public AliasAnalysis { @@ -60,8 +61,6 @@ void BasicAliasAnalysis::initializePass() { InitializeAliasAnalysis(this); } - - // hasUniqueAddress - Return true if the specified value points to something // with a unique, discernable, address. static inline bool hasUniqueAddress(const Value *V) { @@ -364,3 +363,4 @@ BasicAliasAnalysis::CheckGEPInstructions(GetElementPtrInst *GEP1, unsigned G1S, return MayAlias; } +} // End llvm namespace diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index ac93d4c1ca..bd11522c96 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -26,6 +26,8 @@ #include #include +namespace llvm { + /// CFGOnly flag - This is used to control whether or not the CFG graph printer /// prints out the contents of basic blocks or not. This is acceptable because /// this code is only really used for debugging purposes. @@ -112,9 +114,6 @@ namespace { "Print CFG of function to 'dot' file"); }; - - - /// viewCFG - This function is meant for use from the debugger. You can just /// say 'call F->viewCFG()' and a ghostview window should pop up from the /// program, displaying the CFG of the current function. This depends on there @@ -154,3 +153,5 @@ void Function::viewCFGOnly() const { viewCFG(); CFGOnly = false; } + +} // End llvm namespace diff --git a/lib/Analysis/ConstantRange.cpp b/lib/Analysis/ConstantRange.cpp index a9e1204de5..e180f12a1a 100644 --- a/lib/Analysis/ConstantRange.cpp +++ b/lib/Analysis/ConstantRange.cpp @@ -26,6 +26,8 @@ #include "llvm/Instruction.h" #include "llvm/ConstantHandling.h" +namespace llvm { + /// Initialize a full (the default) or empty set for the specified type. /// ConstantRange::ConstantRange(const Type *Ty, bool Full) { @@ -248,3 +250,5 @@ void ConstantRange::print(std::ostream &OS) const { void ConstantRange::dump() const { print(std::cerr); } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index b4b2e48b4e..66990fd923 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -20,6 +20,8 @@ #include "Support/Debug.h" #include "DSCallSiteIterator.h" +namespace llvm { + namespace { Statistic<> MaxSCC("budatastructure", "Maximum SCC Size in Call Graph"); Statistic<> NumBUInlines("budatastructures", "Number of graphs inlined"); @@ -316,3 +318,4 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { //Graph.writeGraphToFile(std::cerr, "bu_" + F.getName()); } +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/DSCallSiteIterator.h b/lib/Analysis/DataStructure/DSCallSiteIterator.h index 324111cffa..df9f36908a 100644 --- a/lib/Analysis/DataStructure/DSCallSiteIterator.h +++ b/lib/Analysis/DataStructure/DSCallSiteIterator.h @@ -19,6 +19,8 @@ #include "llvm/Analysis/DSGraph.h" #include "llvm/Function.h" +namespace llvm { + struct DSCallSiteIterator { // FCs are the edges out of the current node are the call site targets... const std::vector *FCs; @@ -129,4 +131,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index d53c7fa5d7..9cf77ae122 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -23,6 +23,8 @@ #include "Support/Timer.h" #include +namespace llvm { + namespace { Statistic<> NumFolds ("dsnode", "Number of nodes completely folded"); Statistic<> NumCallNodesMerged("dsnode", "Number of call nodes merged"); @@ -161,7 +163,6 @@ bool DSNode::isNodeCompletelyFolded() const { return getSize() == 1 && Ty == Type::VoidTy && isArray(); } - namespace { /// TypeElementWalker Class - Used for implementation of physical subtyping... /// @@ -252,7 +253,7 @@ namespace { } } }; -} +} // end anonymous namespace /// ElementTypesAreCompatible - Check to see if the specified types are /// "physically" compatible. If so, return true, else return false. We only @@ -1639,6 +1640,7 @@ void DSGraph::mergeInGlobalsGraph() { removeTriviallyDeadNodes(); } + /// computeNodeMapping - Given roots in two different DSGraphs, traverse the /// nodes reachable from the two graphs, computing the mapping of nodes from /// the first to the second graph. @@ -1669,3 +1671,4 @@ void DSGraph::computeNodeMapping(const DSNodeHandle &NH1, computeNodeMapping(N1->getLink(i), N2->getLink(N2Idx+i), NodeMap); } +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/DataStructureAA.cpp b/lib/Analysis/DataStructure/DataStructureAA.cpp index 99773e3936..4b55da7aa5 100644 --- a/lib/Analysis/DataStructure/DataStructureAA.cpp +++ b/lib/Analysis/DataStructure/DataStructureAA.cpp @@ -17,6 +17,8 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Module.h" +namespace llvm { + namespace { class DSAA : public Pass, public AliasAnalysis { TDDataStructures *TD; @@ -176,3 +178,5 @@ void DSAA::getMustAliases(Value *P, std::vector &RetVals) { #endif return getAnalysis().getMustAliases(P, RetVals); } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp index 0ca7d6bffc..d037b52145 100644 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp @@ -18,6 +18,8 @@ #include "llvm/Constant.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumGlobalsConstanted("ds-opt", "Number of globals marked constant"); @@ -47,7 +49,6 @@ namespace { RegisterOpt X("ds-opt", "DSA-based simple optimizations"); } - /// OptimizeGlobals - This method uses information taken from DSA to optimize /// global variables. /// @@ -96,3 +97,5 @@ bool DSOpt::OptimizeGlobals(Module &M) { } return Changed; } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/DataStructureStats.cpp b/lib/Analysis/DataStructure/DataStructureStats.cpp index 8d2984845a..3659c90697 100644 --- a/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -19,6 +19,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> TotalNumCallees("totalcallees", "Total number of callee functions at all indirect call sites"); @@ -139,3 +141,5 @@ bool DSGraphStats::runOnFunction(Function& F) { visit(F); return true; } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/GraphChecker.cpp b/lib/Analysis/DataStructure/GraphChecker.cpp index b0164da322..11ebc6920c 100644 --- a/lib/Analysis/DataStructure/GraphChecker.cpp +++ b/lib/Analysis/DataStructure/GraphChecker.cpp @@ -29,6 +29,8 @@ #include "llvm/Value.h" #include +namespace llvm { + namespace { enum DSPass { local, bu, td }; cl::opt @@ -193,3 +195,5 @@ void DSGC::verify(const DSGraph &G) { } } } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/IPModRef.cpp b/lib/Analysis/DataStructure/IPModRef.cpp index 64b60d48ba..01b5bd0023 100644 --- a/lib/Analysis/DataStructure/IPModRef.cpp +++ b/lib/Analysis/DataStructure/IPModRef.cpp @@ -23,6 +23,8 @@ #include "Support/StringExtras.h" #include +namespace llvm { + //---------------------------------------------------------------------------- // Private constants and data //---------------------------------------------------------------------------- @@ -441,3 +443,5 @@ void IPModRef::dump() const { print(std::cerr); } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 0aca21a437..253cbf7a35 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -28,6 +28,8 @@ // #include "llvm/Module.h" +namespace llvm { + static RegisterAnalysis X("datastructure", "Local Data Structure Analysis"); @@ -41,8 +43,8 @@ namespace DS { return false; } } -using namespace DS; +using namespace DS; namespace { cl::opt @@ -144,6 +146,8 @@ namespace { }; } +using namespace DS; + //===----------------------------------------------------------------------===// // DSGraph constructor - Simply use the GraphBuilder to construct the local // graph. @@ -617,3 +621,5 @@ void LocalDataStructures::releaseMemory() { delete GlobalsGraph; GlobalsGraph = 0; } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp index 076836a5ce..e61c076f30 100644 --- a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp +++ b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp @@ -31,6 +31,7 @@ #include "Support/hash_map" #include "Support/hash_set" +namespace llvm { ///-------------------------------------------------------------------------- /// struct ModRefTable: @@ -122,7 +123,7 @@ struct ModRefTable { class ModRefInfoBuilder : public InstVisitor { const DSGraph& funcGraph; const FunctionModRefInfo& funcModRef; - ModRefTable& modRefTable; + struct ModRefTable& modRefTable; ModRefInfoBuilder(); // DO NOT IMPLEMENT ModRefInfoBuilder(const ModRefInfoBuilder&); // DO NOT IMPLEMENT @@ -498,3 +499,5 @@ void MemoryDepAnalysis::dump() const static RegisterAnalysis Z("memdep", "Memory Dependence Analysis"); + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/Parallelize.cpp b/lib/Analysis/DataStructure/Parallelize.cpp index 77e6ed3040..fd39b6b12a 100644 --- a/lib/Analysis/DataStructure/Parallelize.cpp +++ b/lib/Analysis/DataStructure/Parallelize.cpp @@ -53,6 +53,8 @@ #include #include +namespace llvm { + //---------------------------------------------------------------------------- // Global constants used in marking Cilk functions and function calls. //---------------------------------------------------------------------------- @@ -535,3 +537,5 @@ bool Parallelize::run(Module& M) return true; } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/PgmDependenceGraph.cpp b/lib/Analysis/DataStructure/PgmDependenceGraph.cpp index ef44cb3efb..b861c89947 100644 --- a/lib/Analysis/DataStructure/PgmDependenceGraph.cpp +++ b/lib/Analysis/DataStructure/PgmDependenceGraph.cpp @@ -30,6 +30,7 @@ #include "llvm/Analysis/PostDominators.h" #include "llvm/Function.h" +namespace llvm { //---------------------------------------------------------------------------- // class DepIterState @@ -253,3 +254,5 @@ void PgmDependenceGraph::dump() const static RegisterAnalysis Z("pgmdep", "Enumerate Program Dependence Graph (data and control)"); + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index 9587979560..9902906e19 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -23,6 +23,8 @@ #include #include +namespace llvm { + // OnlyPrintMain - The DataStructure printer exposes this option to allow // printing of only the graph for "main". // @@ -32,7 +34,6 @@ namespace { Statistic<> NumFoldedNodes ("dsnode", "Number of folded nodes (in final graph)"); } - void DSNode::dump() const { print(std::cerr, 0); } static std::string getCaption(const DSNode *N, const DSGraph *G) { @@ -280,3 +281,5 @@ void BUDataStructures::print(std::ostream &O, const Module *M) const { void TDDataStructures::print(std::ostream &O, const Module *M) const { printCollection(*this, O, M, "td."); } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index 8bf917f048..d868d250f7 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -20,6 +20,8 @@ #include "llvm/Module.h" #include "Support/Debug.h" +namespace llvm { + namespace { class Steens : public Pass, public AliasAnalysis { DSGraph *ResultGraph; @@ -76,7 +78,6 @@ namespace { RegisterAnalysisGroup Y; } - /// ResolveFunctionCall - Resolve the actual arguments of a call to function F /// with the specified call site descriptor. This function links the arguments /// and the return value for the call site context-insensitively. @@ -235,3 +236,5 @@ AliasAnalysis::AliasResult Steens::alias(const Value *V1, unsigned V1Size, // return getAnalysis().alias(V1, V1Size, V2, V2Size); } + +} // End llvm namespace diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index ad5a9d7220..696368a866 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -21,6 +21,8 @@ #include "Support/Debug.h" #include "Support/Statistic.h" +namespace llvm { + namespace { RegisterAnalysis // Register the pass Y("tddatastructure", "Top-down Data Structure Analysis"); @@ -310,3 +312,4 @@ void TDDataStructures::inlineGraphIntoCallees(DSGraph &Graph) { << Graph.getFunctionCalls().size() << "]\n"); } +} // End llvm namespace diff --git a/lib/Analysis/Expressions.cpp b/lib/Analysis/Expressions.cpp index 4d8897e7ff..b316390469 100644 --- a/lib/Analysis/Expressions.cpp +++ b/lib/Analysis/Expressions.cpp @@ -18,6 +18,8 @@ #include "llvm/ConstantHandling.h" #include "llvm/Function.h" +namespace llvm { + ExprType::ExprType(Value *Val) { if (Val) if (ConstantInt *CPI = dyn_cast(Val)) { @@ -352,3 +354,5 @@ ExprType ClassifyExpression(Value *Expr) { // Otherwise, I don't know anything about this value! return I; } + +} // End llvm namespace diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 8d44242050..506198c4fa 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -53,6 +53,8 @@ #include "llvm/Support/CallSite.h" #include "Support/STLExtras.h" +namespace llvm { + static RegisterAnalysis X("callgraph", "Call Graph Construction"); static const char * const KnownExternalFunctions[] = { @@ -349,3 +351,5 @@ Function *CallGraph::removeFunctionFromModule(CallGraphNode *CGN) { } void CallGraph::stub() {} + +} // End llvm namespace diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index 74da70131e..e9ab6500c8 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -19,6 +19,8 @@ #include "llvm/Analysis/CallGraph.h" #include "Support/SCCIterator.h" +namespace llvm { + /// getAnalysisUsage - For this class, we declare that we require and preserve /// the call graph. If the derived class implements this method, it should /// always explicitly call the implementation here. @@ -35,3 +37,5 @@ bool CallGraphSCCPass::run(Module &M) { Changed = runOnSCC(*I); return Changed; } + +} // End llvm namespace diff --git a/lib/Analysis/IPA/DependenceGraph.cpp b/lib/Analysis/IPA/DependenceGraph.cpp index ead777aa13..7d62ef0350 100644 --- a/lib/Analysis/IPA/DependenceGraph.cpp +++ b/lib/Analysis/IPA/DependenceGraph.cpp @@ -24,6 +24,7 @@ #include "llvm/Analysis/DependenceGraph.h" #include "llvm/Function.h" +namespace llvm { //---------------------------------------------------------------------------- // class Dependence: @@ -82,3 +83,5 @@ void DependenceGraph::print(const Function& func, std::ostream &O) const if (const DepGraphNode* dgNode = this->getNode(*II)) dgNode->print(O); } + +} // End llvm namespace diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 7eeff7dbc7..45f5b72ecf 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -30,6 +30,8 @@ #include "llvm/Support/InstIterator.h" #include "Support/CommandLine.h" +namespace llvm { + static RegisterAnalysis X("unsafepointertypes", "Find Unsafe Pointer Types"); @@ -99,3 +101,5 @@ void FindUnsafePointerTypes::print(std::ostream &o, const Module *M) const { CW << " #" << Counter << ". " << (Value*)*I << "\n"; } } + +} // End llvm namespace diff --git a/lib/Analysis/IPA/FindUsedTypes.cpp b/lib/Analysis/IPA/FindUsedTypes.cpp index 80bf378b5e..e930499e2e 100644 --- a/lib/Analysis/IPA/FindUsedTypes.cpp +++ b/lib/Analysis/IPA/FindUsedTypes.cpp @@ -21,6 +21,8 @@ #include "llvm/Assembly/CachedWriter.h" #include "llvm/Support/InstIterator.h" +namespace llvm { + static RegisterAnalysis X("printusedtypes", "Find Used Types"); @@ -106,3 +108,5 @@ void FindUsedTypes::print(std::ostream &o, const Module *M) const { E = UsedTypes.end(); I != E; ++I) o << " " << *I << "\n"; } + +} // End llvm namespace diff --git a/lib/Analysis/IPA/IPModRef.cpp b/lib/Analysis/IPA/IPModRef.cpp index 64b60d48ba..01b5bd0023 100644 --- a/lib/Analysis/IPA/IPModRef.cpp +++ b/lib/Analysis/IPA/IPModRef.cpp @@ -23,6 +23,8 @@ #include "Support/StringExtras.h" #include +namespace llvm { + //---------------------------------------------------------------------------- // Private constants and data //---------------------------------------------------------------------------- @@ -441,3 +443,5 @@ void IPModRef::dump() const { print(std::cerr); } + +} // End llvm namespace diff --git a/lib/Analysis/IPA/MemoryDepAnalysis.cpp b/lib/Analysis/IPA/MemoryDepAnalysis.cpp index 076836a5ce..e61c076f30 100644 --- a/lib/Analysis/IPA/MemoryDepAnalysis.cpp +++ b/lib/Analysis/IPA/MemoryDepAnalysis.cpp @@ -31,6 +31,7 @@ #include "Support/hash_map" #include "Support/hash_set" +namespace llvm { ///-------------------------------------------------------------------------- /// struct ModRefTable: @@ -122,7 +123,7 @@ struct ModRefTable { class ModRefInfoBuilder : public InstVisitor { const DSGraph& funcGraph; const FunctionModRefInfo& funcModRef; - ModRefTable& modRefTable; + struct ModRefTable& modRefTable; ModRefInfoBuilder(); // DO NOT IMPLEMENT ModRefInfoBuilder(const ModRefInfoBuilder&); // DO NOT IMPLEMENT @@ -498,3 +499,5 @@ void MemoryDepAnalysis::dump() const static RegisterAnalysis Z("memdep", "Memory Dependence Analysis"); + +} // End llvm namespace diff --git a/lib/Analysis/IPA/PgmDependenceGraph.cpp b/lib/Analysis/IPA/PgmDependenceGraph.cpp index ef44cb3efb..b861c89947 100644 --- a/lib/Analysis/IPA/PgmDependenceGraph.cpp +++ b/lib/Analysis/IPA/PgmDependenceGraph.cpp @@ -30,6 +30,7 @@ #include "llvm/Analysis/PostDominators.h" #include "llvm/Function.h" +namespace llvm { //---------------------------------------------------------------------------- // class DepIterState @@ -253,3 +254,5 @@ void PgmDependenceGraph::dump() const static RegisterAnalysis Z("pgmdep", "Enumerate Program Dependence Graph (data and control)"); + +} // End llvm namespace diff --git a/lib/Analysis/IPA/PrintSCC.cpp b/lib/Analysis/IPA/PrintSCC.cpp index 3459381158..ce89fff90e 100644 --- a/lib/Analysis/IPA/PrintSCC.cpp +++ b/lib/Analysis/IPA/PrintSCC.cpp @@ -31,6 +31,8 @@ #include "llvm/Support/CFG.h" #include "Support/SCCIterator.h" +namespace llvm { + namespace { struct CFGSCC : public FunctionPass { bool runOnFunction(Function& func); @@ -101,3 +103,5 @@ bool CallGraphSCC::run(Module &M) { return true; } + +} // End llvm namespace diff --git a/lib/Analysis/InductionVariable.cpp b/lib/Analysis/InductionVariable.cpp index 3119d31ded..6e9a209b7e 100644 --- a/lib/Analysis/InductionVariable.cpp +++ b/lib/Analysis/InductionVariable.cpp @@ -36,6 +36,8 @@ #include "llvm/Assembly/Writer.h" #include "Support/Debug.h" +namespace llvm { + static bool isLoopInvariant(const Value *V, const Loop *L) { if (const Instruction *I = dyn_cast(V)) return !L->contains(I->getParent()); @@ -299,3 +301,5 @@ void InductionVariable::print(std::ostream &o) const { } o << "\n"; } + +} // End llvm namespace diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index 4d49478a9e..9177e44800 100644 --- a/lib/Analysis/InstCount.cpp +++ b/lib/Analysis/InstCount.cpp @@ -16,6 +16,8 @@ #include "llvm/Support/InstVisitor.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> TotalInsts ("instcount", "Number of instructions (of all types)"); Statistic<> TotalBlocks("instcount", "Number of basic blocks"); @@ -62,3 +64,5 @@ bool InstCount::runOnFunction(Function &F) { visit(F); return false; } + +} // End llvm namespace diff --git a/lib/Analysis/Interval.cpp b/lib/Analysis/Interval.cpp index 28cee83631..8f0bdfa003 100644 --- a/lib/Analysis/Interval.cpp +++ b/lib/Analysis/Interval.cpp @@ -17,6 +17,8 @@ #include "llvm/Support/CFG.h" #include +using namespace llvm; + //===----------------------------------------------------------------------===// // Interval Implementation //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index 2729930998..12c196f2f7 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -15,6 +15,8 @@ #include "llvm/Analysis/IntervalIterator.h" #include "Support/STLExtras.h" +namespace llvm { + static RegisterAnalysis X("intervals", "Interval Partition Construction", true); @@ -108,3 +110,5 @@ IntervalPartition::IntervalPartition(IntervalPartition &IP, bool) { for_each(Intervals.begin(), Intervals.end(), bind_obj(this, &IntervalPartition::updatePredecessors)); } + +} // End llvm namespace diff --git a/lib/Analysis/LiveVar/BBLiveVar.cpp b/lib/Analysis/LiveVar/BBLiveVar.cpp index 68eaebf7d2..758f1b1539 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.cpp +++ b/lib/Analysis/LiveVar/BBLiveVar.cpp @@ -21,6 +21,7 @@ /// BROKEN: Should not include sparc stuff directly into here #include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn +namespace llvm { BBLiveVar::BBLiveVar(const BasicBlock &bb, MachineBasicBlock &mbb, unsigned id) : BB(bb), MBB(mbb), POID(id) { @@ -229,6 +230,4 @@ void BBLiveVar::printInOutSets() const { std::cerr << " Out: "; printSet(OutSet); std::cerr << "\n"; } - - - +} // End llvm namespace diff --git a/lib/Analysis/LiveVar/BBLiveVar.h b/lib/Analysis/LiveVar/BBLiveVar.h index 33a4faf2b1..781143a93d 100644 --- a/lib/Analysis/LiveVar/BBLiveVar.h +++ b/lib/Analysis/LiveVar/BBLiveVar.h @@ -17,6 +17,9 @@ #include "llvm/CodeGen/ValueSet.h" #include "Support/hash_map" + +namespace llvm { + class BasicBlock; class Value; class MachineBasicBlock; @@ -82,4 +85,6 @@ public: void printInOutSets() const; // for printing In/Out sets }; +} // End llvm namespace + #endif diff --git a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp index 588ec646da..8f0e31811a 100644 --- a/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Analysis/LiveVar/FunctionLiveVarInfo.cpp @@ -23,6 +23,8 @@ #include "Support/CommandLine.h" #include "BBLiveVar.h" +namespace llvm { + static RegisterAnalysis X("livevar", "Live Variable Analysis"); @@ -318,3 +320,5 @@ void FunctionLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) { SetAI = NewSet; } } + +} // End llvm namespace diff --git a/lib/Analysis/LiveVar/ValueSet.cpp b/lib/Analysis/LiveVar/ValueSet.cpp index ba944cb8cc..fd8289675a 100644 --- a/lib/Analysis/LiveVar/ValueSet.cpp +++ b/lib/Analysis/LiveVar/ValueSet.cpp @@ -11,6 +11,8 @@ #include "llvm/Value.h" #include +namespace llvm { + std::ostream &operator<<(std::ostream &O, RAV V) { // func to print a Value const Value &v = V.V; if (v.hasName()) @@ -26,3 +28,4 @@ void printSet(const ValueSet &S) { std::cerr << RAV(*I); } +} // End llvm namespace diff --git a/lib/Analysis/LoadValueNumbering.cpp b/lib/Analysis/LoadValueNumbering.cpp index cbcdd0f178..2d26379417 100644 --- a/lib/Analysis/LoadValueNumbering.cpp +++ b/lib/Analysis/LoadValueNumbering.cpp @@ -31,6 +31,8 @@ #include #include +namespace llvm { + namespace { // FIXME: This should not be a FunctionPass. struct LoadVN : public FunctionPass, public ValueNumbering { @@ -70,8 +72,6 @@ namespace { RegisterAnalysisGroup Y; } - - Pass *createLoadValueNumberingPass() { return new LoadVN(); } @@ -340,3 +340,5 @@ bool LoadVN::haveEqualValueNumber(LoadInst *Load, StoreInst *Store, return true; } } + +} // End llvm namespace diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index c1f97889e6..68e7d2f845 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -21,6 +21,8 @@ #include "Support/DepthFirstIterator.h" #include +namespace llvm { + static RegisterAnalysis X("loops", "Natural Loop Construction", true); @@ -367,3 +369,5 @@ void Loop::changeExitBlock(BasicBlock *Old, BasicBlock *New) { I = std::find(I+1, ExitBlocks.end(), Old); } } + +} // End llvm namespace diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index ee31c36b3e..2589c85773 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -17,6 +17,8 @@ #include "Support/DepthFirstIterator.h" #include "Support/SetOperations.h" +namespace llvm { + //===----------------------------------------------------------------------===// // PostDominatorSet Implementation //===----------------------------------------------------------------------===// @@ -214,3 +216,5 @@ PostDominanceFrontier::calculate(const PostDominatorTree &DT, // stub - a dummy function to make linking work ok. void PostDominanceFrontier::stub() { } + +} // End llvm namespace diff --git a/lib/Analysis/PrintSCC.cpp b/lib/Analysis/PrintSCC.cpp index 3459381158..ce89fff90e 100644 --- a/lib/Analysis/PrintSCC.cpp +++ b/lib/Analysis/PrintSCC.cpp @@ -31,6 +31,8 @@ #include "llvm/Support/CFG.h" #include "Support/SCCIterator.h" +namespace llvm { + namespace { struct CFGSCC : public FunctionPass { bool runOnFunction(Function& func); @@ -101,3 +103,5 @@ bool CallGraphSCC::run(Module &M) { return true; } + +} // End llvm namespace diff --git a/lib/Analysis/ValueNumbering.cpp b/lib/Analysis/ValueNumbering.cpp index 075c1c2b3f..191e190e20 100644 --- a/lib/Analysis/ValueNumbering.cpp +++ b/lib/Analysis/ValueNumbering.cpp @@ -19,6 +19,8 @@ #include "llvm/Type.h" #include "llvm/iMemory.h" +namespace llvm { + // Register the ValueNumbering interface, providing a nice name to refer to. static RegisterAnalysisGroup X("Value Numbering"); @@ -39,6 +41,7 @@ ValueNumbering::~ValueNumbering() {} // into the tool that uses it. As such, we register and implement the class // here. // + namespace { /// BasicVN - This class is the default implementation of the ValueNumbering /// interface. It walks the SSA def-use chains to trivially identify @@ -62,9 +65,7 @@ namespace { // Declare that we implement the ValueNumbering interface RegisterAnalysisGroup Y; -} // End of anonymous namespace -namespace { /// BVNImpl - Implement BasicVN in terms of a visitor class that /// handles the different types of instructions as appropriate. /// @@ -190,3 +191,5 @@ void BVNImpl::visitGetElementPtrInst(GetElementPtrInst &I) { RetVals.push_back(Other); } } + +} // End llvm namespace diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index d155b69bee..33ae24b60e 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/Archive/ArchiveReader.cpp @@ -22,6 +22,8 @@ #include "Config/sys/mman.h" #include "Config/fcntl.h" +namespace llvm { + namespace { struct ar_hdr { char name[16]; @@ -40,7 +42,6 @@ namespace { }; } - // getObjectType - Determine the type of object that this header represents. // This is capable of parsing the variety of special sections used for various // purposes. @@ -173,3 +174,5 @@ bool ReadArchiveFile(const std::string &Filename, std::vector &Objects, return Result; } + +} // End llvm namespace diff --git a/lib/AsmParser/Lexer.l b/lib/AsmParser/Lexer.l index 6466cb721b..b0e174af50 100644 --- a/lib/AsmParser/Lexer.l +++ b/lib/AsmParser/Lexer.l @@ -35,6 +35,7 @@ #define RET_TOK(type, Enum, sym) \ llvmAsmlval.type = Instruction::Enum; return sym +namespace llvm { // TODO: All of the static identifiers are figured out by the lexer, // these should be hashed to reduce the lexer size @@ -121,6 +122,10 @@ char *UnEscapeLexed(char *Buffer, bool AllowNull) { return BOut; } +} // End llvm namespace + +using namespace llvm; + #define YY_NEVER_INTERACTIVE 1 %} diff --git a/lib/AsmParser/Parser.cpp b/lib/AsmParser/Parser.cpp index e8a7bdbbb9..2d6185efeb 100644 --- a/lib/AsmParser/Parser.cpp +++ b/lib/AsmParser/Parser.cpp @@ -15,6 +15,8 @@ #include "llvm/Module.h" #include "llvm/Analysis/Verifier.h" +namespace llvm { + // The useful interface defined by this file... Parse an ASCII file, and return // the internal representation in a nice slice'n'dice'able representation. // @@ -82,3 +84,5 @@ const std::string ParseException::getMessage() const { return Result + ": " + Message; } + +} // End llvm namespace diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index c7837959e6..c18434d1f0 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -22,18 +22,22 @@ #include "llvm/Assembly/Parser.h" #include "Support/StringExtras.h" -class Module; - // Global variables exported from the lexer... extern std::FILE *llvmAsmin; extern int llvmAsmlineno; +// Globals exported by the parser... +extern char* llvmAsmtext; +extern int llvmAsmleng; + +namespace llvm { + // Globals exported by the parser... extern std::string CurFilename; + +class Module; Module *RunVMAsmParser(const std::string &Filename, FILE *F); -extern char* llvmAsmtext; -extern int llvmAsmleng; // UnEscapeLexed - Run through the specified buffer and change \xx codes to the // appropriate character. If AllowNull is set to false, a \00 value will cause @@ -209,4 +213,6 @@ static inline int getLineNumFromPlaceHolder(const Value *Val) { } } +} // End llvm namespace + #endif diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 96d2daeec4..a55e735ca4 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -29,6 +29,8 @@ int yyerror(const char *ErrorMsg); // Forward declarations to prevent "implicit int yylex(); // declaration" of xxx warnings. int yyparse(); +namespace llvm { + static Module *ParserResult; std::string CurFilename; @@ -686,30 +688,34 @@ Module *RunVMAsmParser(const std::string &Filename, FILE *F) { return Result; } +} // End llvm namespace + +using namespace llvm; + %} %union { - Module *ModuleVal; - Function *FunctionVal; - std::pair *ArgVal; - BasicBlock *BasicBlockVal; - TerminatorInst *TermInstVal; - Instruction *InstVal; - Constant *ConstVal; - - const Type *PrimType; - PATypeHolder *TypeVal; - Value *ValueVal; - - std::vector > *ArgList; - std::vector *ValueList; - std::list *TypeList; - std::list > *PHIList; // Represent the RHS of PHI node - std::vector > *JumpTable; - std::vector *ConstVector; - - GlobalValue::LinkageTypes Linkage; + llvm::Module *ModuleVal; + llvm::Function *FunctionVal; + std::pair *ArgVal; + llvm::BasicBlock *BasicBlockVal; + llvm::TerminatorInst *TermInstVal; + llvm::Instruction *InstVal; + llvm::Constant *ConstVal; + + const llvm::Type *PrimType; + llvm::PATypeHolder *TypeVal; + llvm::Value *ValueVal; + + std::vector > *ArgList; + std::vector *ValueList; + std::list *TypeList; + std::list > *PHIList; // Represent the RHS of PHI node + std::vector > *JumpTable; + std::vector *ConstVector; + + llvm::GlobalValue::LinkageTypes Linkage; int64_t SInt64Val; uint64_t UInt64Val; int SIntVal; @@ -718,13 +724,13 @@ Module *RunVMAsmParser(const std::string &Filename, FILE *F) { bool BoolVal; char *StrVal; // This memory is strdup'd! - ValID ValIDVal; // strdup'd memory maybe! + llvm::ValID ValIDVal; // strdup'd memory maybe! - Instruction::BinaryOps BinaryOpVal; - Instruction::TermOps TermOpVal; - Instruction::MemoryOps MemOpVal; - Instruction::OtherOps OtherOpVal; - Module::Endianness Endianness; + llvm::Instruction::BinaryOps BinaryOpVal; + llvm::Instruction::TermOps TermOpVal; + llvm::Instruction::MemoryOps MemOpVal; + llvm::Instruction::OtherOps OtherOpVal; + llvm::Module::Endianness Endianness; } %type Module FunctionList @@ -1892,6 +1898,7 @@ MemoryInst : MALLOC Types { delete $2; delete $4; }; + %% int yyerror(const char *ErrorMsg) { std::string where diff --git a/lib/Bytecode/Archive/ArchiveReader.cpp b/lib/Bytecode/Archive/ArchiveReader.cpp index d155b69bee..33ae24b60e 100644 --- a/lib/Bytecode/Archive/ArchiveReader.cpp +++ b/lib/Bytecode/Archive/ArchiveReader.cpp @@ -22,6 +22,8 @@ #include "Config/sys/mman.h" #include "Config/fcntl.h" +namespace llvm { + namespace { struct ar_hdr { char name[16]; @@ -40,7 +42,6 @@ namespace { }; } - // getObjectType - Determine the type of object that this header represents. // This is capable of parsing the variety of special sections used for various // purposes. @@ -173,3 +174,5 @@ bool ReadArchiveFile(const std::string &Filename, std::vector &Objects, return Result; } + +} // End llvm namespace diff --git a/lib/Bytecode/Reader/ArchiveReader.cpp b/lib/Bytecode/Reader/ArchiveReader.cpp index d155b69bee..33ae24b60e 100644 --- a/lib/Bytecode/Reader/ArchiveReader.cpp +++ b/lib/Bytecode/Reader/ArchiveReader.cpp @@ -22,6 +22,8 @@ #include "Config/sys/mman.h" #include "Config/fcntl.h" +namespace llvm { + namespace { struct ar_hdr { char name[16]; @@ -40,7 +42,6 @@ namespace { }; } - // getObjectType - Determine the type of object that this header represents. // This is capable of parsing the variety of special sections used for various // purposes. @@ -173,3 +174,5 @@ bool ReadArchiveFile(const std::string &Filename, std::vector &Objects, return Result; } + +} // End llvm namespace diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index 00f44b3665..b4553548e8 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -20,6 +20,8 @@ #include "llvm/Constants.h" #include +namespace llvm { + const Type *BytecodeParser::parseTypeConstant(const unsigned char *&Buf, const unsigned char *EndBuf) { unsigned PrimType; @@ -356,3 +358,5 @@ void BytecodeParser::ParseConstantPool(const unsigned char *&Buf, if (Buf > EndBuf) throw std::string("Read past end of buffer."); } + +} // End llvm namespace diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index a409ceebef..ec8944e7a8 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -22,6 +22,8 @@ #include "llvm/iOther.h" #include "llvm/Module.h" +namespace llvm { + namespace { struct RawInst { // The raw fields out of the bytecode stream... unsigned NumOperands; @@ -33,8 +35,6 @@ namespace { }; } - - RawInst::RawInst(const unsigned char *&Buf, const unsigned char *EndBuf, std::vector &Args) { unsigned Op, Typ; @@ -389,3 +389,5 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, BB->getInstList().push_back(Result); BCR_TRACE(4, *Result); } + +} // End llvm namespace diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index a36ea7a734..9acb93d48a 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -32,6 +32,8 @@ #include #include +namespace llvm { + static inline void ALIGN32(const unsigned char *&begin, const unsigned char *end) { if (align32(begin, end)) @@ -693,3 +695,5 @@ void BytecodeParser::ParseBytecode(const unsigned char *Buf, unsigned Length, throw; } } + +} // End llvm namespace diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index c8905454e6..81ccde97ff 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -22,6 +22,8 @@ #include #include +namespace llvm { + // Enable to trace to figure out what the heck is going on when parsing fails //#define TRACE_LEVEL 10 //#define DEBUG_OUTPUT @@ -226,4 +228,6 @@ static inline void readBlock(const unsigned char *&Buf, #endif } +} // End llvm namespace + #endif diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp index 0df6ea5ff2..1cbead02e8 100644 --- a/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/lib/Bytecode/Reader/ReaderWrappers.cpp @@ -21,6 +21,8 @@ #include "Config/unistd.h" #include "Config/sys/mman.h" +namespace llvm { + //===----------------------------------------------------------------------===// // BytecodeFileReader - Read from an mmap'able file descriptor. // @@ -163,7 +165,7 @@ BytecodeStdinReader::BytecodeStdinReader() { unsigned char Buffer[4096*4]; // Read in all of the data from stdin, we cannot mmap stdin... - while ((BlockSize = read(0 /*stdin*/, Buffer, 4096*4))) { + while ((BlockSize = ::read(0 /*stdin*/, Buffer, 4096*4))) { if (BlockSize == -1) throw std::string("Error reading from stdin!"); @@ -249,7 +251,6 @@ static ModuleProvider *CheckVarargs(ModuleProvider *MP) { return MP; } - //===----------------------------------------------------------------------===// // Wrapper functions //===----------------------------------------------------------------------===// @@ -296,3 +297,5 @@ Module *ParseBytecodeFile(const std::string &Filename, std::string *ErrorStr) { return 0; } } + +} // End llvm namespace diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp index a9aaffe3ec..303672d166 100644 --- a/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/lib/Bytecode/Writer/ConstantWriter.cpp @@ -17,6 +17,8 @@ #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" +namespace llvm { + void BytecodeWriter::outputType(const Type *T) { output_vbr((unsigned)T->getPrimitiveID(), Out); @@ -202,3 +204,5 @@ bool BytecodeWriter::outputConstant(const Constant *CPV) { } return false; } + +} // End llvm namespace diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp index faa576ecb4..d52f24145f 100644 --- a/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/lib/Bytecode/Writer/InstructionWriter.cpp @@ -19,6 +19,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + static Statistic<> NumInstrs("bytecodewriter", "Number of instructions"); @@ -295,3 +297,5 @@ void BytecodeWriter::processInstruction(const Instruction &I) { // operands or a large operand index that we are referring to. outputInstructionFormat0(&I, Opcode, Table, Type, Out); } + +} // End llvm namespace diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index aef71763c4..c6e44e8266 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -27,6 +27,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + #if 0 #define SC_DEBUG(X) std::cerr << X #else @@ -361,3 +363,5 @@ int SlotCalculator::doInsertValue(const Value *D) { SC_DEBUG("]\n"); return (int)DestSlot; } + +} // End llvm namespace diff --git a/lib/Bytecode/Writer/SlotCalculator.h b/lib/Bytecode/Writer/SlotCalculator.h index 7e56de99dc..596f9324ed 100644 --- a/lib/Bytecode/Writer/SlotCalculator.h +++ b/lib/Bytecode/Writer/SlotCalculator.h @@ -22,6 +22,9 @@ #include #include + +namespace llvm { + class Value; class Module; class Function; @@ -92,4 +95,6 @@ protected: void processSymbolTableConstants(const SymbolTable *ST); }; +} // End llvm namespace + #endif diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 9381e355f0..9c9e1abcdd 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -36,6 +36,8 @@ #include "Config/string.h" #include +namespace llvm { + static RegisterPass X("emitbytecode", "Bytecode Writer"); static Statistic<> @@ -304,3 +306,5 @@ void WriteBytecodeToFile(const Module *C, std::ostream &Out) { Out.flush(); } + +} // End llvm namespace diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h index 5564f4238e..8cb4bfd8d6 100644 --- a/lib/Bytecode/Writer/WriterInternals.h +++ b/lib/Bytecode/Writer/WriterInternals.h @@ -25,6 +25,8 @@ #include "llvm/SlotCalculator.h" #include "llvm/Instruction.h" +namespace llvm { + class BytecodeWriter { std::deque &Out; SlotCalculator Table; @@ -79,5 +81,6 @@ public: } }; +} // End llvm namespace #endif diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index a50439de7f..4e2bf47876 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -22,6 +22,8 @@ #include "Support/CommandLine.h" #include +namespace llvm { + SchedDebugLevel_t SchedDebugLevel; static cl::opt EnableFillingDelaySlots("sched-fill-delay-slots", @@ -1518,3 +1520,6 @@ bool InstructionSchedulingWithSSA::runOnFunction(Function &F) FunctionPass *createInstructionSchedulingWithSSAPass(const TargetMachine &tgt) { return new InstructionSchedulingWithSSA(tgt); } + +} // End llvm namespace + diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index e7cd47881a..3a8088043b 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -23,6 +23,8 @@ #include "llvm/Target/TargetRegInfo.h" #include "Support/STLExtras.h" +namespace llvm { + //*********************** Internal Data Structures *************************/ // The following two types need to be classes, not typedefs, so we can use @@ -737,3 +739,5 @@ void SchedGraphNode::print(std::ostream &os) const { os << std::string(16, ' ') << *outEdges[i]; } } + +} // End llvm namespace diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h index 50cc0520e6..5aee9b25f6 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.h +++ b/lib/CodeGen/InstrSched/SchedGraph.h @@ -25,6 +25,8 @@ #include "Support/hash_map" #include "Support/GraphTraits.h" +namespace llvm { + class RegToRefVecMap; class ValueToDefVecMap; class RefVec; @@ -317,4 +319,6 @@ template <> struct GraphTraits { } }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/InstrSched/SchedGraphCommon.cpp b/lib/CodeGen/InstrSched/SchedGraphCommon.cpp index b75e3397cb..d96c201c8a 100644 --- a/lib/CodeGen/InstrSched/SchedGraphCommon.cpp +++ b/lib/CodeGen/InstrSched/SchedGraphCommon.cpp @@ -15,6 +15,8 @@ #include "llvm/CodeGen/SchedGraphCommon.h" #include "Support/STLExtras.h" +namespace llvm { + class SchedGraphCommon; // @@ -175,3 +177,4 @@ void SchedGraphCommon::eraseIncidentEdges(SchedGraphNodeCommon* node, this->eraseOutgoingEdges(node, addDummyEdges); } +} // End llvm namespace diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp index 1644d5ecbc..7e05d1417f 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.cpp +++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp @@ -23,6 +23,8 @@ #include "llvm/Support/CFG.h" #include "Support/PostOrderIterator.h" +namespace llvm { + std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd) { return os << "Delay for node " << nd->node->getNodeId() << " = " << (long)nd->delay << "\n"; @@ -278,3 +280,4 @@ SchedPriorities::instructionHasLastUse(FunctionLiveVarInfo &LVI, return lastUseMap[MI] = hasLastUse; } +} // End llvm namespace diff --git a/lib/CodeGen/InstrSched/SchedPriorities.h b/lib/CodeGen/InstrSched/SchedPriorities.h index de321f9fcb..7470467806 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.h +++ b/lib/CodeGen/InstrSched/SchedPriorities.h @@ -26,6 +26,8 @@ #include "Support/hash_set" #include +namespace llvm { + class Function; class MachineInstr; class SchedulingManager; @@ -214,4 +216,6 @@ inline void SchedPriorities::updateTime(cycles_t c) { std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd); +} // End llvm namespace + #endif diff --git a/lib/CodeGen/InstrSelection/InstrForest.cpp b/lib/CodeGen/InstrSelection/InstrForest.cpp index 5496502d5e..fd5056d22d 100644 --- a/lib/CodeGen/InstrSelection/InstrForest.cpp +++ b/lib/CodeGen/InstrSelection/InstrForest.cpp @@ -30,6 +30,8 @@ #include "Support/STLExtras.h" #include "Config/alloca.h" +namespace llvm { + //------------------------------------------------------------------------ // class InstrTreeNode //------------------------------------------------------------------------ @@ -330,3 +332,5 @@ InstructionNode* InstrForest::buildTreeForInstruction(Instruction *instr) { delete [] childArray; return treeNode; } + +} // End llvm namespace diff --git a/lib/CodeGen/InstrSelection/InstrSelection.cpp b/lib/CodeGen/InstrSelection/InstrSelection.cpp index 0e3e2cdbf2..760976509c 100644 --- a/lib/CodeGen/InstrSelection/InstrSelection.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelection.cpp @@ -28,6 +28,8 @@ #include "Support/LeakDetector.h" #include +namespace llvm { + std::vector FixConstantOperandsForInstr(Instruction* vmInstr, MachineInstr* minstr, TargetMachine& target); @@ -82,6 +84,8 @@ namespace { }; } +namespace llvm { + TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, Value *s1, Value *s2, const std::string &name) : Instruction(s1->getType(), Instruction::UserOp1, name) @@ -114,6 +118,7 @@ TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, LeakDetector::removeGarbageObject(this); } +} // End llvm namespace bool InstructionSelection::runOnFunction(Function &F) { @@ -375,7 +380,6 @@ InstructionSelection::PostprocessMachineCodeForTree(InstructionNode* instrNode, } - //===----------------------------------------------------------------------===// // createInstructionSelectionPass - Public entrypoint for instruction selection // and this file as a whole... @@ -383,3 +387,5 @@ InstructionSelection::PostprocessMachineCodeForTree(InstructionNode* instrNode, FunctionPass *createInstructionSelectionPass(TargetMachine &T) { return new InstructionSelection(T); } + +} // End llvm namespace diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp index 93f7618641..44a43596ee 100644 --- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp @@ -25,6 +25,7 @@ #include "llvm/DerivedTypes.h" #include "../../Target/Sparc/SparcInstrSelectionSupport.h" // FIXME! +namespace llvm { // Generate code to load the constant into a TmpInstruction (virtual reg) and // returns the virtual register. @@ -257,3 +258,5 @@ FixConstantOperandsForInstr(Instruction* vmInstr, return MVec; } + +} // End llvm namespace diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index 50b90b1fdc..7ec4d32c1e 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -33,6 +33,8 @@ #include "llvm/Support/CFG.h" #include "Support/DepthFirstIterator.h" +namespace llvm { + static RegisterAnalysis X("livevars", "Live Variable Analysis"); const std::pair & @@ -307,3 +309,5 @@ bool LiveVariables::runOnMachineFunction(MachineFunction &MF) { return false; } + +} // End llvm namespace diff --git a/lib/CodeGen/MachineCodeEmitter.cpp b/lib/CodeGen/MachineCodeEmitter.cpp index 6e56594a10..d9b1f7ce45 100644 --- a/lib/CodeGen/MachineCodeEmitter.cpp +++ b/lib/CodeGen/MachineCodeEmitter.cpp @@ -16,6 +16,8 @@ #include "llvm/Function.h" #include +namespace llvm { + namespace { struct DebugMachineCodeEmitter : public MachineCodeEmitter { void startFunction(MachineFunction &F) { @@ -54,18 +56,7 @@ namespace { return 0; } }; -} - - -/// createDebugMachineCodeEmitter - Return a dynamically allocated machine -/// code emitter, which just prints the opcodes and fields out the cout. This -/// can be used for debugging users of the MachineCodeEmitter interface. -/// -MachineCodeEmitter *MachineCodeEmitter::createDebugEmitter() { - return new DebugMachineCodeEmitter(); -} -namespace { class FilePrinterEmitter : public MachineCodeEmitter { std::ofstream actual; std::ostream &o; @@ -169,7 +160,18 @@ namespace { }; } +/// createDebugMachineCodeEmitter - Return a dynamically allocated machine +/// code emitter, which just prints the opcodes and fields out the cout. This +/// can be used for debugging users of the MachineCodeEmitter interface. +/// +MachineCodeEmitter * +MachineCodeEmitter::createDebugEmitter() { + return new DebugMachineCodeEmitter(); +} + MachineCodeEmitter * MachineCodeEmitter::createFilePrinterEmitter(MachineCodeEmitter &MCE) { return new FilePrinterEmitter(MCE, std::cerr); } + +} // End llvm namespace diff --git a/lib/CodeGen/MachineCodeForInstruction.cpp b/lib/CodeGen/MachineCodeForInstruction.cpp index 36bafe2ff9..000f3d175b 100644 --- a/lib/CodeGen/MachineCodeForInstruction.cpp +++ b/lib/CodeGen/MachineCodeForInstruction.cpp @@ -27,6 +27,8 @@ #include "llvm/CodeGen/MachineInstrAnnot.h" #include "llvm/CodeGen/InstrSelection.h" +namespace llvm { + AnnotationID MCFI_AID( AnnotationManager::getID("CodeGen::MachineCodeForInstruction")); @@ -68,3 +70,5 @@ MachineCodeForInstruction::~MachineCodeForInstruction() if (callArgsDesc) delete callArgsDesc; } + +} // End llvm namespace diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index c1eb30a196..790859bc87 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -28,6 +28,8 @@ #include "llvm/Pass.h" #include "Config/limits.h" +namespace llvm { + const int INVALID_FRAME_OFFSET = INT_MAX; // std::numeric_limits::max(); static AnnotationID MF_AID( @@ -414,3 +416,5 @@ MachineFunctionInfo::getOffset(const Value* val) const hash_map::const_iterator pair = offsets.find(val); return (pair == offsets.end()) ? INVALID_FRAME_OFFSET : pair->second; } + +} // End llvm namespace diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 7fb8b4569e..ef31cc4cb3 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -16,6 +16,8 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/MRegisterInfo.h" +namespace llvm { + // Global variable holding an array of descriptors for machine instructions. // The actual object needs to be created separately for each target machine. // This variable is initialized and reset by class TargetInstrInfo. @@ -289,7 +291,7 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine &TM) const { // Specialize printing if op#0 is definition if (getNumOperands() && (getOperand(0).opIsDefOnly() || getOperand(0).opIsDefAndUse())) { - ::print(getOperand(0), OS, TM); + llvm::print(getOperand(0), OS, TM); OS << " = "; ++StartOp; // Don't print this operand again! } @@ -300,7 +302,7 @@ void MachineInstr::print(std::ostream &OS, const TargetMachine &TM) const { if (i != StartOp) OS << ","; OS << " "; - ::print(mop, OS, TM); + llvm::print(mop, OS, TM); if (mop.opIsDefAndUse()) OS << ""; @@ -433,3 +435,5 @@ std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO) return OS; } + +} // End llvm namespace diff --git a/lib/CodeGen/MachineInstrAnnot.cpp b/lib/CodeGen/MachineInstrAnnot.cpp index bf4e68e112..b4b41ac176 100644 --- a/lib/CodeGen/MachineInstrAnnot.cpp +++ b/lib/CodeGen/MachineInstrAnnot.cpp @@ -18,6 +18,7 @@ #include "llvm/iOther.h" #include "llvm/Type.h" +namespace llvm { CallArgsDescriptor::CallArgsDescriptor(CallInst* _callInstr, TmpInstruction* _retAddrReg, @@ -76,3 +77,5 @@ CallArgsDescriptor *CallArgsDescriptor::get(const MachineInstr* MI) assert(desc->getCallInst()==callInstr && "Incorrect call args descriptor?"); return desc; } + +} // End llvm namespace diff --git a/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp b/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp index 6318c5ab46..8aaaa2b6b5 100644 --- a/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp +++ b/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.cpp @@ -13,6 +13,8 @@ #include "ModuloSchedGraph.h" #include "llvm/Type.h" +namespace llvm { + ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned id, int index, const Instruction *inst, const TargetMachine &targ) @@ -135,3 +137,4 @@ ModuloSchedGraphSet::~ModuloSchedGraphSet(){ //delete all the graphs } +} // End llvm namespace diff --git a/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h b/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h index 214e24cc8b..552d699e76 100644 --- a/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h +++ b/lib/CodeGen/ModuloScheduling/ModuloSchedGraph.h @@ -22,6 +22,7 @@ #include "Support/hash_map" #include +namespace llvm { class ModuloSchedGraphNode : public SchedGraphNodeCommon { @@ -106,4 +107,6 @@ public: }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp b/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp index 91ec6c28f5..219d892d31 100644 --- a/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp +++ b/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp @@ -16,6 +16,8 @@ #include "llvm/Function.h" #include "llvm/Pass.h" +namespace llvm { + namespace { class ModuloScheduling : public FunctionPass { @@ -40,3 +42,5 @@ bool ModuloScheduling::runOnFunction(Function &F) { bool Changed = false; return Changed; } + +} // End llvm namespace diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp index 5a988bafe3..c4b811aef6 100644 --- a/lib/CodeGen/PHIElimination.cpp +++ b/lib/CodeGen/PHIElimination.cpp @@ -21,6 +21,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/CFG.h" +namespace llvm { + namespace { struct PNE : public MachineFunctionPass { bool runOnMachineFunction(MachineFunction &Fn) { @@ -52,6 +54,7 @@ namespace { "Eliminate PHI nodes for register allocation"); } + const PassInfo *PHIEliminationID = X.getPassInfo(); /// EliminatePHINodes - Eliminate phi nodes by inserting copy instructions in @@ -260,3 +263,5 @@ bool PNE::EliminatePHINodes(MachineFunction &MF, MachineBasicBlock &MBB) { return true; } + +} // End llvm namespace diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index 7a51a53ad8..239eacde4c 100644 --- a/lib/CodeGen/Passes.cpp +++ b/lib/CodeGen/Passes.cpp @@ -15,6 +15,8 @@ #include "llvm/CodeGen/Passes.h" #include "Support/CommandLine.h" +namespace llvm { + namespace { enum RegAllocName { simple, local }; @@ -40,3 +42,5 @@ FunctionPass *createRegisterAllocator() return 0; // not reached } } + +} // End llvm namespace diff --git a/lib/CodeGen/PrologEpilogInserter.cpp b/lib/CodeGen/PrologEpilogInserter.cpp index a60b8b127b..8fc9b5b2c2 100644 --- a/lib/CodeGen/PrologEpilogInserter.cpp +++ b/lib/CodeGen/PrologEpilogInserter.cpp @@ -25,6 +25,8 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetInstrInfo.h" +namespace llvm { + namespace { struct PEI : public MachineFunctionPass { const char *getPassName() const { @@ -66,6 +68,7 @@ namespace { }; } + /// createPrologEpilogCodeInserter - This function returns a pass that inserts /// prolog and epilog code, and eliminates abstract frame references. /// @@ -258,3 +261,5 @@ void PEI::replaceFrameIndices(MachineFunction &Fn) { break; } } + +} // End llvm namespace diff --git a/lib/CodeGen/RegAlloc/AllocInfo.h b/lib/CodeGen/RegAlloc/AllocInfo.h index f83f2103be..67f58a7ed0 100644 --- a/lib/CodeGen/RegAlloc/AllocInfo.h +++ b/lib/CodeGen/RegAlloc/AllocInfo.h @@ -19,6 +19,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" +namespace llvm { + /// AllocInfo - Structure representing one instruction's operand's-worth of /// register allocation state. We create tables made out of these data /// structures to generate mapping information for this register allocator. @@ -77,4 +79,6 @@ struct AllocInfo { } }; +} // End llvm namespace + #endif // ALLOCINFO_H diff --git a/lib/CodeGen/RegAlloc/IGNode.cpp b/lib/CodeGen/RegAlloc/IGNode.cpp index f883fb13c1..a76fdeaa03 100644 --- a/lib/CodeGen/RegAlloc/IGNode.cpp +++ b/lib/CodeGen/RegAlloc/IGNode.cpp @@ -16,6 +16,8 @@ #include #include +namespace llvm { + //----------------------------------------------------------------------------- // Sets this IGNode on stack and reduce the degree of neighbors //----------------------------------------------------------------------------- @@ -56,3 +58,5 @@ IGNode::getCombinedDegree(const IGNode* otherNode) const { std::vector::iterator new_end = unique(nbrs.begin(), nbrs.end()); return new_end - nbrs.begin(); } + +} // End llvm namespace diff --git a/lib/CodeGen/RegAlloc/IGNode.h b/lib/CodeGen/RegAlloc/IGNode.h index 82f07e0c7e..9fdc7a6ac0 100644 --- a/lib/CodeGen/RegAlloc/IGNode.h +++ b/lib/CodeGen/RegAlloc/IGNode.h @@ -32,6 +32,9 @@ #include "LiveRange.h" #include + +namespace llvm { + class RegClass; //---------------------------------------------------------------------------- @@ -115,4 +118,6 @@ public: inline LiveRange *getParentLR() const { return ParentLR; } }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp index 392a96c11c..3cef19ea0e 100644 --- a/lib/CodeGen/RegAlloc/InterferenceGraph.cpp +++ b/lib/CodeGen/RegAlloc/InterferenceGraph.cpp @@ -17,6 +17,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + // for asserting this IG node is infact in the IGNodeList of this class inline static void assertIGNode(const InterferenceGraph *IG, const IGNode *Node) { @@ -246,3 +248,5 @@ void InterferenceGraph::printIGNodeList() const { } } } + +} // End llvm namespace diff --git a/lib/CodeGen/RegAlloc/InterferenceGraph.h b/lib/CodeGen/RegAlloc/InterferenceGraph.h index 6b8cf3cd05..79850c1fcf 100644 --- a/lib/CodeGen/RegAlloc/InterferenceGraph.h +++ b/lib/CodeGen/RegAlloc/InterferenceGraph.h @@ -30,6 +30,9 @@ #define INTERFERENCEGRAPH_H #include + +namespace llvm { + class LiveRange; class RegClass; class IGNode; @@ -67,4 +70,6 @@ class InterferenceGraph { void printIGNodeList() const; }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/RegAlloc/LiveRange.h b/lib/CodeGen/RegAlloc/LiveRange.h index aa409c63fb..d6e2cf6307 100644 --- a/lib/CodeGen/RegAlloc/LiveRange.h +++ b/lib/CodeGen/RegAlloc/LiveRange.h @@ -21,6 +21,8 @@ #include "llvm/Value.h" #include "llvm/CodeGen/ValueSet.h" +namespace llvm { + class RegClass; class IGNode; @@ -177,4 +179,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp index b9fcda789f..9fd04d2b0e 100644 --- a/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp +++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.cpp @@ -23,6 +23,8 @@ #include "llvm/Target/TargetRegInfo.h" #include "Support/SetOperations.h" +namespace llvm { + unsigned LiveRange::getRegClassID() const { return getRegClass()->getID(); } LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm, @@ -411,3 +413,5 @@ void LiveRangeInfo::printLiveRanges() { } } } + +} // End llvm namespace diff --git a/lib/CodeGen/RegAlloc/LiveRangeInfo.h b/lib/CodeGen/RegAlloc/LiveRangeInfo.h index 5c5244bd62..a8d0e7152f 100644 --- a/lib/CodeGen/RegAlloc/LiveRangeInfo.h +++ b/lib/CodeGen/RegAlloc/LiveRangeInfo.h @@ -29,6 +29,8 @@ #include "llvm/CodeGen/ValueSet.h" #include "Support/hash_map" +namespace llvm { + class LiveRange; class MachineInstr; class RegClass; @@ -121,4 +123,6 @@ public: void printLiveRanges(); }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp index 99917cdf0b..332ae9524c 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.cpp @@ -47,6 +47,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + RegAllocDebugLevel_t DEBUG_RA; /// The reoptimizer wants to be able to grovel through the register @@ -1392,3 +1394,5 @@ bool PhyRegAlloc::runOnFunction (Function &F) { if (DEBUG_RA) std::cerr << "\nRegister allocation complete!\n"; return false; // Function was not modified } + +} // End llvm namespace diff --git a/lib/CodeGen/RegAlloc/PhyRegAlloc.h b/lib/CodeGen/RegAlloc/PhyRegAlloc.h index c524f9f56c..4ec083c8ea 100644 --- a/lib/CodeGen/RegAlloc/PhyRegAlloc.h +++ b/lib/CodeGen/RegAlloc/PhyRegAlloc.h @@ -31,6 +31,8 @@ #include "llvm/Target/TargetRegInfo.h" #include +namespace llvm { + class MachineFunction; class FunctionLiveVarInfo; class MachineInstr; @@ -179,4 +181,6 @@ private: void addInterf4PseudoInstr(const MachineInstr *MI); }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/RegAlloc/RegAllocCommon.h b/lib/CodeGen/RegAlloc/RegAllocCommon.h index 97d102a253..7dd86b205a 100644 --- a/lib/CodeGen/RegAlloc/RegAllocCommon.h +++ b/lib/CodeGen/RegAlloc/RegAllocCommon.h @@ -14,6 +14,8 @@ #ifndef REGALLOCCOMMON_H #define REGALLOCCOMMON_H +namespace llvm { + enum RegAllocDebugLevel_t { RA_DEBUG_None = 0, RA_DEBUG_Results = 1, @@ -25,4 +27,6 @@ enum RegAllocDebugLevel_t { extern RegAllocDebugLevel_t DEBUG_RA; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/RegAlloc/RegClass.cpp b/lib/CodeGen/RegAlloc/RegClass.cpp index 9c8603b82c..9af87ba0e8 100644 --- a/lib/CodeGen/RegAlloc/RegClass.cpp +++ b/lib/CodeGen/RegAlloc/RegClass.cpp @@ -16,6 +16,8 @@ #include "RegClass.h" #include "llvm/Target/TargetRegInfo.h" +namespace llvm { + //---------------------------------------------------------------------------- // This constructor inits IG. The actual matrix is created by a call to // createInterferenceGraph() above. @@ -245,4 +247,4 @@ void RegClass::printIG() { IG.printIG(); } - +} // End llvm namespace diff --git a/lib/CodeGen/RegAlloc/RegClass.h b/lib/CodeGen/RegAlloc/RegClass.h index c861fbae21..0071f7c212 100644 --- a/lib/CodeGen/RegAlloc/RegClass.h +++ b/lib/CodeGen/RegAlloc/RegClass.h @@ -20,6 +20,9 @@ #include "llvm/Target/TargetRegInfo.h" #include "InterferenceGraph.h" #include + +namespace llvm { + class TargetRegClassInfo; @@ -139,4 +142,6 @@ class RegClass { void printIG(); }; +} // End llvm namespace + #endif diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index 8d19b69471..080e6c69c0 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -26,6 +26,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumSpilled ("ra-local", "Number of registers spilled"); Statistic<> NumReloaded("ra-local", "Number of registers reloaded"); @@ -203,7 +205,6 @@ namespace { }; } - /// getStackSpaceFor - This allocates space for the specified virtual register /// to be held on the stack. int RA::getStackSpaceFor(unsigned VirtReg, const TargetRegisterClass *RC) { @@ -674,3 +675,5 @@ bool RA::runOnMachineFunction(MachineFunction &Fn) { FunctionPass *createLocalRegisterAllocator() { return new RA(); } + +} // End llvm namespace diff --git a/lib/CodeGen/RegAllocSimple.cpp b/lib/CodeGen/RegAllocSimple.cpp index a210790b8d..202123ad10 100644 --- a/lib/CodeGen/RegAllocSimple.cpp +++ b/lib/CodeGen/RegAllocSimple.cpp @@ -26,6 +26,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumSpilled ("ra-simple", "Number of registers spilled"); Statistic<> NumReloaded("ra-simple", "Number of registers reloaded"); @@ -234,3 +236,5 @@ bool RegAllocSimple::runOnMachineFunction(MachineFunction &Fn) { FunctionPass *createSimpleRegisterAllocator() { return new RegAllocSimple(); } + +} // End llvm namespace diff --git a/lib/CodeGen/SelectionDAG/DAGBuilder.cpp b/lib/CodeGen/SelectionDAG/DAGBuilder.cpp index a972ddf602..fd4e7a90c7 100644 --- a/lib/CodeGen/SelectionDAG/DAGBuilder.cpp +++ b/lib/CodeGen/SelectionDAG/DAGBuilder.cpp @@ -21,6 +21,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/InstVisitor.h" +namespace llvm { + struct SelectionDAGBuilder : public InstVisitor { // DAG - the current dag we are building. SelectionDAG &DAG; @@ -270,3 +272,5 @@ SelectionDAG::SelectionDAG(MachineFunction &f, const TargetMachine &tm, SDB.visitBB(const_cast(*I)); Root = SDB.CurRoot; } + +} // End llvm namespace diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 58a9639c92..db5941060d 100644 --- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -15,6 +15,8 @@ #include "llvm/CodeGen/SelectionDAG.h" #include "llvm/Type.h" +namespace llvm { + SelectionDAG::~SelectionDAG() { for (unsigned i = 0, e = AllNodes.size(); i != e; ++i) delete AllNodes[i]; @@ -126,3 +128,5 @@ void SelectionDAGNode::printit(unsigned Offset, unsigned &LastID, std::cerr << "\n"; } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index dd647247c3..b7da23ca71 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -27,6 +27,8 @@ #include "Support/DynamicLinker.h" #include "Config/dlfcn.h" +namespace llvm { + Statistic<> NumInitBytes("lli", "Number of bytes of global vars initialized"); ExecutionEngine::ExecutionEngine(ModuleProvider *P) : @@ -390,3 +392,4 @@ void ExecutionEngine::emitGlobals() { InitializeMemory(I->getInitializer(), GlobalAddress[I]); } +} // End llvm namespace diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index b04f974911..aa32983cc3 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -18,12 +18,14 @@ #include "Support/Statistic.h" #include // For fmod -Interpreter *TheEE = 0; +namespace llvm { namespace { Statistic<> NumDynamicInsts("lli", "Number of dynamic instructions executed"); } +Interpreter *TheEE = 0; + //===----------------------------------------------------------------------===// // Value Manipulation code //===----------------------------------------------------------------------===// @@ -910,3 +912,5 @@ void Interpreter::run() { visit(I); // Dispatch to one of the visit* methods... } } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index ecf19c2f8d..f516f5de23 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -32,6 +32,8 @@ #include using std::vector; +namespace llvm { + typedef GenericValue (*ExFunc)(FunctionType *, const vector &); static std::map Functions; static std::map FuncNames; @@ -767,3 +769,5 @@ void Interpreter::initializeExternalFunctions() { FuncNames["lle_X_llvm.va_end"] = llvm_va_end; FuncNames["lle_X_llvm.va_copy"] = llvm_va_copy; } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.cpp b/lib/ExecutionEngine/Interpreter/Interpreter.cpp index bcaa8569dc..bb14cd2ee8 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.cpp +++ b/lib/ExecutionEngine/Interpreter/Interpreter.cpp @@ -17,6 +17,8 @@ #include "llvm/Module.h" #include "llvm/DerivedTypes.h" +namespace llvm { + /// create - Create a new interpreter object. This can never fail. /// ExecutionEngine *Interpreter::create(Module *M){ @@ -97,3 +99,5 @@ GenericValue Interpreter::run(Function *F, rv.IntVal = ExitCode; return rv; } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h index 00784adb71..e9015a203e 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -22,6 +22,8 @@ #include "llvm/Target/TargetData.h" #include "Support/DataTypes.h" +namespace llvm { + struct FunctionInfo; // Defined in ExecutionAnnotations.h // AllocaHolder - Object to track all of the blocks of memory allocated by @@ -166,4 +168,6 @@ private: // Helper functions void popStackAndReturnValueToCaller(const Type *RetTy, GenericValue Result); }; +} // End llvm namespace + #endif diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp index 6162e938ab..191b57d22a 100644 --- a/lib/ExecutionEngine/JIT/Intercept.cpp +++ b/lib/ExecutionEngine/JIT/Intercept.cpp @@ -19,6 +19,8 @@ #include "Support/DynamicLinker.h" #include +namespace llvm { + // AtExitHandlers - List of functions to call when the program exits, // registered with the atexit() library function. static std::vector AtExitHandlers; @@ -75,3 +77,5 @@ void *VM::getPointerToNamedFunction(const std::string &Name) { return Ptr; } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index fedb6e46b0..61d9629d93 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -24,6 +24,8 @@ #define NO_JITS_ENABLED #endif +namespace llvm { + namespace { enum ArchName { x86, Sparc }; @@ -118,3 +120,5 @@ GenericValue VM::run(Function *F, const std::vector &ArgValues) rv.IntVal = ExitCode; return rv; } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/JIT/JIT.h b/lib/ExecutionEngine/JIT/JIT.h index 685c4bd053..9a17c967c7 100644 --- a/lib/ExecutionEngine/JIT/JIT.h +++ b/lib/ExecutionEngine/JIT/JIT.h @@ -18,6 +18,8 @@ #include "llvm/PassManager.h" #include +namespace llvm { + class Function; class GlobalValue; class Constant; @@ -78,4 +80,6 @@ private: void runJITOnFunction (Function *F); }; +} // End llvm namespace + #endif diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 98f526a5f5..32d0651f22 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -27,6 +27,8 @@ #include "Config/unistd.h" #include "Config/sys/mman.h" +namespace llvm { + namespace { Statistic<> NumBytes("jit", "Number of bytes of machine code compiled"); VM *TheVM = 0; @@ -265,3 +267,5 @@ extern "C" { return TheVM->getPointerToNamedFunction(Name); } } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/JIT/VM.cpp b/lib/ExecutionEngine/JIT/VM.cpp index 2dda271fa0..d7e7685978 100644 --- a/lib/ExecutionEngine/JIT/VM.cpp +++ b/lib/ExecutionEngine/JIT/VM.cpp @@ -19,6 +19,8 @@ #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/Target/TargetMachine.h" +namespace llvm { + VM::~VM() { delete MCE; delete &TM; @@ -98,3 +100,5 @@ void *VM::recompileAndRelinkFunction(Function *F) { TM.replaceMachineCodeForFunction (OldAddr, Addr); return Addr; } + +} // End llvm namespace diff --git a/lib/ExecutionEngine/JIT/VM.h b/lib/ExecutionEngine/JIT/VM.h index 685c4bd053..9a17c967c7 100644 --- a/lib/ExecutionEngine/JIT/VM.h +++ b/lib/ExecutionEngine/JIT/VM.h @@ -18,6 +18,8 @@ #include "llvm/PassManager.h" #include +namespace llvm { + class Function; class GlobalValue; class Constant; @@ -78,4 +80,6 @@ private: void runJITOnFunction (Function *F); }; +} // End llvm namespace + #endif diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index 06f0635749..9c22891775 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -30,6 +30,8 @@ #include #include +namespace llvm { + /// FindLib - Try to convert Filename into the name of a file that we can open, /// if it does not already name a file we can open, by first trying to open /// Filename, then libFilename. for each of a set of several common @@ -405,3 +407,5 @@ bool LinkLibraries(const char *progname, return false; } + +} // End llvm namespace diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 0be840fb6c..4bc78a4cde 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -23,6 +23,8 @@ #include "llvm/iOther.h" #include "llvm/Constants.h" +namespace llvm { + // Error - Simple wrapper function to conditionally assign to E and return true. // This just makes error return conditions a little bit simpler... // @@ -902,3 +904,4 @@ bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) { return false; } +} // End llvm namespace diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp index 890b18de06..b88624dd1f 100644 --- a/lib/Support/Annotation.cpp +++ b/lib/Support/Annotation.cpp @@ -14,6 +14,8 @@ #include #include "Support/Annotation.h" +namespace llvm { + typedef std::map IDMapType; static unsigned IDCounter = 0; // Unique ID counter @@ -94,3 +96,5 @@ Annotation *AnnotationManager::createAnnotation(AnnotationID ID, if (I == getFactMap().end()) return 0; return I->second.first(ID, Obj, I->second.second); } + +} // End llvm namespace diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index de895c9117..235dc12843 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -24,6 +24,8 @@ #include #include +namespace llvm { + using namespace cl; //===----------------------------------------------------------------------===// @@ -887,3 +889,5 @@ HHOp("help-hidden", cl::desc("display all available options"), cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); } // End anonymous namespace + +} // End llvm namespace diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index a9e1204de5..e180f12a1a 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -26,6 +26,8 @@ #include "llvm/Instruction.h" #include "llvm/ConstantHandling.h" +namespace llvm { + /// Initialize a full (the default) or empty set for the specified type. /// ConstantRange::ConstantRange(const Type *Ty, bool Full) { @@ -248,3 +250,5 @@ void ConstantRange::print(std::ostream &OS) const { void ConstantRange::dump() const { print(std::cerr); } + +} // End llvm namespace diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index 895abbb1f7..1af23380a2 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -26,6 +26,8 @@ #include "Support/Statistic.h" #include "Support/CommandLine.h" +namespace llvm { + bool DebugFlag; // DebugFlag - Exported boolean set by the -debug option namespace { @@ -62,3 +64,5 @@ bool isCurrentDebugType(const char *DebugType) { return false; #endif } + +} // End llvm namespace diff --git a/lib/Support/DynamicLinker.cpp b/lib/Support/DynamicLinker.cpp index 74b3603679..1c9385eea7 100644 --- a/lib/Support/DynamicLinker.cpp +++ b/lib/Support/DynamicLinker.cpp @@ -23,6 +23,8 @@ #include "Config/dlfcn.h" #include +namespace llvm { + bool LinkDynamicObject (const char *filename, std::string *ErrorMessage) { #if defined (HAVE_DLOPEN) if (dlopen (filename, RTLD_NOW | RTLD_GLOBAL) == 0) { @@ -52,3 +54,5 @@ void *GetAddressOfSymbol (const char *symbolName) { void *GetAddressOfSymbol (const std::string &symbolName) { return GetAddressOfSymbol (symbolName.c_str ()); } + +} // End llvm namespace diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 3262ecce31..cde288925b 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -20,6 +20,9 @@ #include #include +namespace llvm +{ + /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must /// name a readable file. /// @@ -182,3 +185,5 @@ bool MakeFileExecutable (const std::string &Filename) { bool MakeFileReadable (const std::string &Filename) { return AddPermissionsBits (Filename, 0444); } + +} // End llvm namespace diff --git a/lib/Support/LeakDetector.cpp b/lib/Support/LeakDetector.cpp index 24c946ab6e..ffb081a998 100644 --- a/lib/Support/LeakDetector.cpp +++ b/lib/Support/LeakDetector.cpp @@ -15,6 +15,8 @@ #include "llvm/Value.h" #include +namespace llvm { + // Lazily allocate set so that release build doesn't have to do anything. static std::set *Objects = 0; static std::set *LLVMObjects = 0; @@ -87,3 +89,5 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) { Objects = 0; LLVMObjects = 0; } } + +} // End llvm namespace diff --git a/lib/Support/Mangler.cpp b/lib/Support/Mangler.cpp index 44c697d3d8..567fe05e32 100644 --- a/lib/Support/Mangler.cpp +++ b/lib/Support/Mangler.cpp @@ -16,6 +16,8 @@ #include "llvm/Type.h" #include "Support/StringExtras.h" +namespace llvm { + static char HexDigit(int V) { return V < 10 ? V+'0' : V+'A'-10; } @@ -99,3 +101,4 @@ Mangler::Mangler(Module &m, bool addUnderscorePrefix) FoundNames.insert(I->getName()); // Otherwise, keep track of name } +} // End llvm namespace diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 1582a10c65..1729bb3365 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -23,6 +23,8 @@ #include "Config/link.h" #include +namespace llvm { + namespace { struct PluginLoader { void operator=(const std::string &Filename) { @@ -38,3 +40,5 @@ namespace { static cl::opt > LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"), cl::desc("Load the specified plugin")); + +} // End llvm namespace diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp index efc5f71257..73decfd89b 100644 --- a/lib/Support/Signals.cpp +++ b/lib/Support/Signals.cpp @@ -20,6 +20,8 @@ #include #include "Config/config.h" // Get the signal handler return type +namespace llvm { + static std::vector FilesToRemove; // IntSigs - Signals that may interrupt the program at any time. @@ -62,3 +64,5 @@ void RemoveFileOnSignal(const std::string &Filename) { std::for_each(IntSigs, IntSigsEnd, RegisterHandler); std::for_each(KillSigs, KillSigsEnd, RegisterHandler); } + +} // End llvm namespace diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index c60a85cdeb..3ac2bf97fb 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -27,8 +27,10 @@ #include #include +namespace llvm { + // GetLibSupportInfoOutputFile - Return a file stream to print our output on... -std::ostream *GetLibSupportInfoOutputFile(); +extern std::ostream *GetLibSupportInfoOutputFile(); unsigned StatisticBase::NumStats = 0; @@ -104,3 +106,5 @@ void StatisticBase::destroy() const { delete OutStream; // Close the file... } } + +} // End llvm namespace diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index 8c009ffb57..ec535ad45a 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -24,6 +24,8 @@ #include "Config/unistd.h" #include "Config/errno.h" +namespace llvm { + /// isExecutableFile - This function returns true if the filename specified /// exists and is executable. /// @@ -272,3 +274,4 @@ ExecWait (const char * const old_argv[], const char * const old_envp[]) return 1; } +} // End llvm namespace diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 5e84f38852..d14a225fcf 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -23,6 +23,8 @@ #include #include +namespace llvm { + // getLibSupportInfoOutputFilename - This ugly hack is brought to you courtesy // of constructor/destructor ordering being unspecified by C++. Basically the // problem is that a Statistic<> object gets destroyed, which ends up calling @@ -265,7 +267,8 @@ void Timer::print(const Timer &Total, std::ostream &OS) { } // GetLibSupportInfoOutputFile - Return a file stream to print our output on... -std::ostream *GetLibSupportInfoOutputFile() { +std::ostream * +GetLibSupportInfoOutputFile() { std::string &LibSupportInfoOutputFilename = getLibSupportInfoOutputFilename(); if (LibSupportInfoOutputFilename.empty()) return &std::cerr; @@ -349,3 +352,5 @@ void TimerGroup::removeTimer() { DefaultTimerGroup = 0; } } + +} // End llvm namespace diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index a66b868c22..50a9ad21c8 100644 --- a/lib/Support/ToolRunner.cpp +++ b/lib/Support/ToolRunner.cpp @@ -18,6 +18,8 @@ #include #include +namespace llvm { + //===---------------------------------------------------------------------===// // LLI Implementation of AbstractIntepreter interface // @@ -391,3 +393,5 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message) { Message = "Found gcc: " + GCCPath + "\n"; return new GCC(GCCPath); } + +} // End llvm namespace diff --git a/lib/Support/ValueHolder.cpp b/lib/Support/ValueHolder.cpp index 8661402b06..77fdaf6b44 100644 --- a/lib/Support/ValueHolder.cpp +++ b/lib/Support/ValueHolder.cpp @@ -18,6 +18,10 @@ #include "llvm/Support/ValueHolder.h" #include "llvm/Type.h" +namespace llvm { + ValueHolder::ValueHolder(Value *V) : User(Type::TypeTy, Value::TypeVal) { Operands.push_back(Use(V, this)); } + +} // End llvm namespace diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 258c287878..bac088abf7 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -31,6 +31,8 @@ #include #include +namespace llvm { + namespace { class CWriter : public Pass, public InstVisitor { std::ostream &Out; @@ -161,7 +163,6 @@ namespace { void printIndexingExpression(Value *Ptr, User::op_iterator I, User::op_iterator E); }; -} // Pass the Type* and the variable name and this prints out the variable // declaration. @@ -339,7 +340,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) { // compiler agreeing on the conversion process (which is pretty likely since we // only deal in IEEE FP). // -static bool isFPCSafeToPrint(const ConstantFP *CFP) { +bool isFPCSafeToPrint(const ConstantFP *CFP) { #if HAVE_PRINTF_A char Buffer[100]; sprintf(Buffer, "%a", CFP->getValue()); @@ -563,7 +564,7 @@ bool CWriter::nameAllUsedStructureTypes(Module &M) { // generateCompilerSpecificCode - This is where we add conditional compilation // directives to cater to specific compilers as need be. // -static void generateCompilerSpecificCode(std::ostream& Out) { +void generateCompilerSpecificCode(std::ostream& Out) { // Alloca is hard to get, and we don't want to include stdlib.h here... Out << "/* get a declaration for alloca */\n" << "#ifdef sun\n" @@ -1058,7 +1059,7 @@ void CWriter::visitUnwindInst(UnwindInst &I) { emittedInvoke = true; } -static bool isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) { +bool isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) { // If PHI nodes need copies, we need the copy code... if (isa(To->front()) || From->getNext() != To) // Not directly successor, need goto @@ -1195,10 +1196,10 @@ void CWriter::visitCastInst(CastInst &I) { void CWriter::visitCallInst(CallInst &I) { // Handle intrinsic function calls first... if (Function *F = I.getCalledFunction()) - if (LLVMIntrinsic::ID ID = (LLVMIntrinsic::ID)F->getIntrinsicID()) { + if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) { switch (ID) { default: assert(0 && "Unknown LLVM intrinsic!"); - case LLVMIntrinsic::va_start: + case Intrinsic::va_start: Out << "0; "; Out << "va_start(*(va_list*)&" << Mang->getValueName(&I) << ", "; @@ -1212,28 +1213,28 @@ void CWriter::visitCallInst(CallInst &I) { writeOperand(&I.getParent()->getParent()->aback()); Out << ")"; return; - case LLVMIntrinsic::va_end: + case Intrinsic::va_end: Out << "va_end(*(va_list*)&"; writeOperand(I.getOperand(1)); Out << ")"; return; - case LLVMIntrinsic::va_copy: + case Intrinsic::va_copy: Out << "0;"; Out << "va_copy(*(va_list*)&" << Mang->getValueName(&I) << ", "; Out << "*(va_list*)&"; writeOperand(I.getOperand(1)); Out << ")"; return; - case LLVMIntrinsic::setjmp: - case LLVMIntrinsic::sigsetjmp: + case Intrinsic::setjmp: + case Intrinsic::sigsetjmp: // This intrinsic should never exist in the program, but until we get // setjmp/longjmp transformations going on, we should codegen it to // something reasonable. This will allow code that never calls longjmp // to work. Out << "0"; return; - case LLVMIntrinsic::longjmp: - case LLVMIntrinsic::siglongjmp: + case Intrinsic::longjmp: + case Intrinsic::siglongjmp: // Longjmp is not implemented, and never will be. It would cause an // exception throw. Out << "abort()"; @@ -1385,9 +1386,12 @@ void CWriter::visitVAArgInst(VAArgInst &I) { Out << ");\n va_end(Tmp); }"; } +} //===----------------------------------------------------------------------===// // External Interface declaration //===----------------------------------------------------------------------===// Pass *createWriteToCPass(std::ostream &o) { return new CWriter(o); } + +} // End llvm namespace diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 258c287878..bac088abf7 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -31,6 +31,8 @@ #include #include +namespace llvm { + namespace { class CWriter : public Pass, public InstVisitor { std::ostream &Out; @@ -161,7 +163,6 @@ namespace { void printIndexingExpression(Value *Ptr, User::op_iterator I, User::op_iterator E); }; -} // Pass the Type* and the variable name and this prints out the variable // declaration. @@ -339,7 +340,7 @@ void CWriter::printConstantArray(ConstantArray *CPA) { // compiler agreeing on the conversion process (which is pretty likely since we // only deal in IEEE FP). // -static bool isFPCSafeToPrint(const ConstantFP *CFP) { +bool isFPCSafeToPrint(const ConstantFP *CFP) { #if HAVE_PRINTF_A char Buffer[100]; sprintf(Buffer, "%a", CFP->getValue()); @@ -563,7 +564,7 @@ bool CWriter::nameAllUsedStructureTypes(Module &M) { // generateCompilerSpecificCode - This is where we add conditional compilation // directives to cater to specific compilers as need be. // -static void generateCompilerSpecificCode(std::ostream& Out) { +void generateCompilerSpecificCode(std::ostream& Out) { // Alloca is hard to get, and we don't want to include stdlib.h here... Out << "/* get a declaration for alloca */\n" << "#ifdef sun\n" @@ -1058,7 +1059,7 @@ void CWriter::visitUnwindInst(UnwindInst &I) { emittedInvoke = true; } -static bool isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) { +bool isGotoCodeNecessary(BasicBlock *From, BasicBlock *To) { // If PHI nodes need copies, we need the copy code... if (isa(To->front()) || From->getNext() != To) // Not directly successor, need goto @@ -1195,10 +1196,10 @@ void CWriter::visitCastInst(CastInst &I) { void CWriter::visitCallInst(CallInst &I) { // Handle intrinsic function calls first... if (Function *F = I.getCalledFunction()) - if (LLVMIntrinsic::ID ID = (LLVMIntrinsic::ID)F->getIntrinsicID()) { + if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) { switch (ID) { default: assert(0 && "Unknown LLVM intrinsic!"); - case LLVMIntrinsic::va_start: + case Intrinsic::va_start: Out << "0; "; Out << "va_start(*(va_list*)&" << Mang->getValueName(&I) << ", "; @@ -1212,28 +1213,28 @@ void CWriter::visitCallInst(CallInst &I) { writeOperand(&I.getParent()->getParent()->aback()); Out << ")"; return; - case LLVMIntrinsic::va_end: + case Intrinsic::va_end: Out << "va_end(*(va_list*)&"; writeOperand(I.getOperand(1)); Out << ")"; return; - case LLVMIntrinsic::va_copy: + case Intrinsic::va_copy: Out << "0;"; Out << "va_copy(*(va_list*)&" << Mang->getValueName(&I) << ", "; Out << "*(va_list*)&"; writeOperand(I.getOperand(1)); Out << ")"; return; - case LLVMIntrinsic::setjmp: - case LLVMIntrinsic::sigsetjmp: + case Intrinsic::setjmp: + case Intrinsic::sigsetjmp: // This intrinsic should never exist in the program, but until we get // setjmp/longjmp transformations going on, we should codegen it to // something reasonable. This will allow code that never calls longjmp // to work. Out << "0"; return; - case LLVMIntrinsic::longjmp: - case LLVMIntrinsic::siglongjmp: + case Intrinsic::longjmp: + case Intrinsic::siglongjmp: // Longjmp is not implemented, and never will be. It would cause an // exception throw. Out << "abort()"; @@ -1385,9 +1386,12 @@ void CWriter::visitVAArgInst(VAArgInst &I) { Out << ");\n va_end(Tmp); }"; } +} //===----------------------------------------------------------------------===// // External Interface declaration //===----------------------------------------------------------------------===// Pass *createWriteToCPass(std::ostream &o) { return new CWriter(o); } + +} // End llvm namespace diff --git a/lib/Target/MRegisterInfo.cpp b/lib/Target/MRegisterInfo.cpp index 6f35815263..7c1028bc32 100644 --- a/lib/Target/MRegisterInfo.cpp +++ b/lib/Target/MRegisterInfo.cpp @@ -13,6 +13,8 @@ #include "llvm/Target/MRegisterInfo.h" +namespace llvm { + MRegisterInfo::MRegisterInfo(const MRegisterDesc *D, unsigned NR, regclass_iterator RCB, regclass_iterator RCE, int CFSO, int CFDO) @@ -41,3 +43,5 @@ MRegisterInfo::MRegisterInfo(const MRegisterDesc *D, unsigned NR, MRegisterInfo::~MRegisterInfo() { delete[] PhysRegClasses; } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp index 2c45021f00..a603e94b81 100644 --- a/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp +++ b/lib/Target/SparcV9/EmitBytecodeToAssembly.cpp @@ -18,6 +18,8 @@ #include "llvm/Bytecode/Writer.h" #include +namespace llvm { + using std::ostream; namespace { @@ -113,3 +115,5 @@ namespace { Pass *UltraSparc::getBytecodeAsmPrinterPass(std::ostream &Out) { return new SparcBytecodeWriter(Out); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index a50439de7f..4e2bf47876 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -22,6 +22,8 @@ #include "Support/CommandLine.h" #include +namespace llvm { + SchedDebugLevel_t SchedDebugLevel; static cl::opt EnableFillingDelaySlots("sched-fill-delay-slots", @@ -1518,3 +1520,6 @@ bool InstructionSchedulingWithSSA::runOnFunction(Function &F) FunctionPass *createInstructionSchedulingWithSSAPass(const TargetMachine &tgt) { return new InstructionSchedulingWithSSA(tgt); } + +} // End llvm namespace + diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index e7cd47881a..3a8088043b 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -23,6 +23,8 @@ #include "llvm/Target/TargetRegInfo.h" #include "Support/STLExtras.h" +namespace llvm { + //*********************** Internal Data Structures *************************/ // The following two types need to be classes, not typedefs, so we can use @@ -737,3 +739,5 @@ void SchedGraphNode::print(std::ostream &os) const { os << std::string(16, ' ') << *outEdges[i]; } } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h index 50cc0520e6..5aee9b25f6 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.h +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h @@ -25,6 +25,8 @@ #include "Support/hash_map" #include "Support/GraphTraits.h" +namespace llvm { + class RegToRefVecMap; class ValueToDefVecMap; class RefVec; @@ -317,4 +319,6 @@ template <> struct GraphTraits { } }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp b/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp index b75e3397cb..d96c201c8a 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp @@ -15,6 +15,8 @@ #include "llvm/CodeGen/SchedGraphCommon.h" #include "Support/STLExtras.h" +namespace llvm { + class SchedGraphCommon; // @@ -175,3 +177,4 @@ void SchedGraphCommon::eraseIncidentEdges(SchedGraphNodeCommon* node, this->eraseOutgoingEdges(node, addDummyEdges); } +} // End llvm namespace diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp index 1644d5ecbc..7e05d1417f 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp @@ -23,6 +23,8 @@ #include "llvm/Support/CFG.h" #include "Support/PostOrderIterator.h" +namespace llvm { + std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd) { return os << "Delay for node " << nd->node->getNodeId() << " = " << (long)nd->delay << "\n"; @@ -278,3 +280,4 @@ SchedPriorities::instructionHasLastUse(FunctionLiveVarInfo &LVI, return lastUseMap[MI] = hasLastUse; } +} // End llvm namespace diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.h b/lib/Target/SparcV9/InstrSched/SchedPriorities.h index de321f9fcb..7470467806 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.h +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.h @@ -26,6 +26,8 @@ #include "Support/hash_set" #include +namespace llvm { + class Function; class MachineInstr; class SchedulingManager; @@ -214,4 +216,6 @@ inline void SchedPriorities::updateTime(cycles_t c) { std::ostream &operator<<(std::ostream &os, const NodeDelayPair* nd); +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index 5496502d5e..fd5056d22d 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -30,6 +30,8 @@ #include "Support/STLExtras.h" #include "Config/alloca.h" +namespace llvm { + //------------------------------------------------------------------------ // class InstrTreeNode //------------------------------------------------------------------------ @@ -330,3 +332,5 @@ InstructionNode* InstrForest::buildTreeForInstruction(Instruction *instr) { delete [] childArray; return treeNode; } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp index 0e3e2cdbf2..760976509c 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelection.cpp @@ -28,6 +28,8 @@ #include "Support/LeakDetector.h" #include +namespace llvm { + std::vector FixConstantOperandsForInstr(Instruction* vmInstr, MachineInstr* minstr, TargetMachine& target); @@ -82,6 +84,8 @@ namespace { }; } +namespace llvm { + TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, Value *s1, Value *s2, const std::string &name) : Instruction(s1->getType(), Instruction::UserOp1, name) @@ -114,6 +118,7 @@ TmpInstruction::TmpInstruction(MachineCodeForInstruction& mcfi, LeakDetector::removeGarbageObject(this); } +} // End llvm namespace bool InstructionSelection::runOnFunction(Function &F) { @@ -375,7 +380,6 @@ InstructionSelection::PostprocessMachineCodeForTree(InstructionNode* instrNode, } - //===----------------------------------------------------------------------===// // createInstructionSelectionPass - Public entrypoint for instruction selection // and this file as a whole... @@ -383,3 +387,5 @@ InstructionSelection::PostprocessMachineCodeForTree(InstructionNode* instrNode, FunctionPass *createInstructionSelectionPass(TargetMachine &T) { return new InstructionSelection(T); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index 93f7618641..44a43596ee 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -25,6 +25,7 @@ #include "llvm/DerivedTypes.h" #include "../../Target/Sparc/SparcInstrSelectionSupport.h" // FIXME! +namespace llvm { // Generate code to load the constant into a TmpInstruction (virtual reg) and // returns the virtual register. @@ -257,3 +258,5 @@ FixConstantOperandsForInstr(Instruction* vmInstr, return MVec; } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp index 68eaebf7d2..758f1b1539 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp @@ -21,6 +21,7 @@ /// BROKEN: Should not include sparc stuff directly into here #include "../../Target/Sparc/SparcInternals.h" // Only for PHI defn +namespace llvm { BBLiveVar::BBLiveVar(const BasicBlock &bb, MachineBasicBlock &mbb, unsigned id) : BB(bb), MBB(mbb), POID(id) { @@ -229,6 +230,4 @@ void BBLiveVar::printInOutSets() const { std::cerr << " Out: "; printSet(OutSet); std::cerr << "\n"; } - - - +} // End llvm namespace diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.h b/lib/Target/SparcV9/LiveVar/BBLiveVar.h index 33a4faf2b1..781143a93d 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.h +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.h @@ -17,6 +17,9 @@ #include "llvm/CodeGen/ValueSet.h" #include "Support/hash_map" + +namespace llvm { + class BasicBlock; class Value; class MachineBasicBlock; @@ -82,4 +85,6 @@ public: void printInOutSets() const; // for printing In/Out sets }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp index 588ec646da..8f0e31811a 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp @@ -23,6 +23,8 @@ #include "Support/CommandLine.h" #include "BBLiveVar.h" +namespace llvm { + static RegisterAnalysis X("livevar", "Live Variable Analysis"); @@ -318,3 +320,5 @@ void FunctionLiveVarInfo::calcLiveVarSetsForBB(const BasicBlock *BB) { SetAI = NewSet; } } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/LiveVar/ValueSet.cpp b/lib/Target/SparcV9/LiveVar/ValueSet.cpp index ba944cb8cc..fd8289675a 100644 --- a/lib/Target/SparcV9/LiveVar/ValueSet.cpp +++ b/lib/Target/SparcV9/LiveVar/ValueSet.cpp @@ -11,6 +11,8 @@ #include "llvm/Value.h" #include +namespace llvm { + std::ostream &operator<<(std::ostream &O, RAV V) { // func to print a Value const Value &v = V.V; if (v.hasName()) @@ -26,3 +28,4 @@ void printSet(const ValueSet &S) { std::cerr << RAV(*I); } +} // End llvm namespace diff --git a/lib/Target/SparcV9/MachineCodeForInstruction.h b/lib/Target/SparcV9/MachineCodeForInstruction.h index d421f3e971..9a08de79af 100644 --- a/lib/Target/SparcV9/MachineCodeForInstruction.h +++ b/lib/Target/SparcV9/MachineCodeForInstruction.h @@ -28,6 +28,8 @@ #include "Support/Annotation.h" #include +namespace llvm { + class MachineInstr; class Instruction; class Value; @@ -96,4 +98,6 @@ public: CallArgsDescriptor* getCallArgsDescriptor() const { return callArgsDesc; } }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/MachineFunctionInfo.h b/lib/Target/SparcV9/MachineFunctionInfo.h index db73322278..fdf135b16b 100644 --- a/lib/Target/SparcV9/MachineFunctionInfo.h +++ b/lib/Target/SparcV9/MachineFunctionInfo.h @@ -17,6 +17,9 @@ #include "Support/HashExtras.h" #include "Support/hash_set" + +namespace llvm { + class MachineFunction; class Value; class Constant; @@ -112,4 +115,6 @@ private: int allocateOptionalArg(const Type* type); }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/MachineInstrAnnot.h b/lib/Target/SparcV9/MachineInstrAnnot.h index 98dde590b8..19d93ab56a 100644 --- a/lib/Target/SparcV9/MachineInstrAnnot.h +++ b/lib/Target/SparcV9/MachineInstrAnnot.h @@ -17,6 +17,8 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetRegInfo.h" +namespace llvm { + class Value; class TmpInstruction; class CallInst; @@ -88,5 +90,6 @@ public: static CallArgsDescriptor *get(const MachineInstr* MI); }; +} // End llvm namespace #endif diff --git a/lib/Target/SparcV9/MappingInfo.cpp b/lib/Target/SparcV9/MappingInfo.cpp index db03f13b97..2afde6bdf5 100644 --- a/lib/Target/SparcV9/MappingInfo.cpp +++ b/lib/Target/SparcV9/MappingInfo.cpp @@ -49,6 +49,8 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "Support/StringExtras.h" +namespace llvm { + namespace { class MappingInfoAsmPrinter : public FunctionPass { std::ostream &Out; @@ -293,3 +295,5 @@ bool MappingInfoAsmPrinter::doFinalization (Module &M) { return false; } +} // End llvm namespace + diff --git a/lib/Target/SparcV9/MappingInfo.h b/lib/Target/SparcV9/MappingInfo.h index f86e2b42b7..6af116a6da 100644 --- a/lib/Target/SparcV9/MappingInfo.h +++ b/lib/Target/SparcV9/MappingInfo.h @@ -18,6 +18,9 @@ #include #include #include + +namespace llvm { + class Pass; Pass *getMappingInfoAsmPrinterPass(std::ostream &out); @@ -41,4 +44,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp b/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp index 6318c5ab46..8aaaa2b6b5 100644 --- a/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp +++ b/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.cpp @@ -13,6 +13,8 @@ #include "ModuloSchedGraph.h" #include "llvm/Type.h" +namespace llvm { + ModuloSchedGraphNode::ModuloSchedGraphNode(unsigned id, int index, const Instruction *inst, const TargetMachine &targ) @@ -135,3 +137,4 @@ ModuloSchedGraphSet::~ModuloSchedGraphSet(){ //delete all the graphs } +} // End llvm namespace diff --git a/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.h b/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.h index 214e24cc8b..552d699e76 100644 --- a/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.h +++ b/lib/Target/SparcV9/ModuloScheduling/ModuloSchedGraph.h @@ -22,6 +22,7 @@ #include "Support/hash_map" #include +namespace llvm { class ModuloSchedGraphNode : public SchedGraphNodeCommon { @@ -106,4 +107,6 @@ public: }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp index 91ec6c28f5..219d892d31 100644 --- a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp +++ b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp @@ -16,6 +16,8 @@ #include "llvm/Function.h" #include "llvm/Pass.h" +namespace llvm { + namespace { class ModuloScheduling : public FunctionPass { @@ -40,3 +42,5 @@ bool ModuloScheduling::runOnFunction(Function &F) { bool Changed = false; return Changed; } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/RegAlloc/AllocInfo.h b/lib/Target/SparcV9/RegAlloc/AllocInfo.h index f83f2103be..67f58a7ed0 100644 --- a/lib/Target/SparcV9/RegAlloc/AllocInfo.h +++ b/lib/Target/SparcV9/RegAlloc/AllocInfo.h @@ -19,6 +19,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" +namespace llvm { + /// AllocInfo - Structure representing one instruction's operand's-worth of /// register allocation state. We create tables made out of these data /// structures to generate mapping information for this register allocator. @@ -77,4 +79,6 @@ struct AllocInfo { } }; +} // End llvm namespace + #endif // ALLOCINFO_H diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.cpp b/lib/Target/SparcV9/RegAlloc/IGNode.cpp index f883fb13c1..a76fdeaa03 100644 --- a/lib/Target/SparcV9/RegAlloc/IGNode.cpp +++ b/lib/Target/SparcV9/RegAlloc/IGNode.cpp @@ -16,6 +16,8 @@ #include #include +namespace llvm { + //----------------------------------------------------------------------------- // Sets this IGNode on stack and reduce the degree of neighbors //----------------------------------------------------------------------------- @@ -56,3 +58,5 @@ IGNode::getCombinedDegree(const IGNode* otherNode) const { std::vector::iterator new_end = unique(nbrs.begin(), nbrs.end()); return new_end - nbrs.begin(); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/RegAlloc/IGNode.h b/lib/Target/SparcV9/RegAlloc/IGNode.h index 82f07e0c7e..9fdc7a6ac0 100644 --- a/lib/Target/SparcV9/RegAlloc/IGNode.h +++ b/lib/Target/SparcV9/RegAlloc/IGNode.h @@ -32,6 +32,9 @@ #include "LiveRange.h" #include + +namespace llvm { + class RegClass; //---------------------------------------------------------------------------- @@ -115,4 +118,6 @@ public: inline LiveRange *getParentLR() const { return ParentLR; } }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp index 392a96c11c..3cef19ea0e 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp @@ -17,6 +17,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + // for asserting this IG node is infact in the IGNodeList of this class inline static void assertIGNode(const InterferenceGraph *IG, const IGNode *Node) { @@ -246,3 +248,5 @@ void InterferenceGraph::printIGNodeList() const { } } } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h index 6b8cf3cd05..79850c1fcf 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.h @@ -30,6 +30,9 @@ #define INTERFERENCEGRAPH_H #include + +namespace llvm { + class LiveRange; class RegClass; class IGNode; @@ -67,4 +70,6 @@ class InterferenceGraph { void printIGNodeList() const; }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/RegAlloc/LiveRange.h b/lib/Target/SparcV9/RegAlloc/LiveRange.h index aa409c63fb..d6e2cf6307 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRange.h +++ b/lib/Target/SparcV9/RegAlloc/LiveRange.h @@ -21,6 +21,8 @@ #include "llvm/Value.h" #include "llvm/CodeGen/ValueSet.h" +namespace llvm { + class RegClass; class IGNode; @@ -177,4 +179,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp index b9fcda789f..9fd04d2b0e 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp @@ -23,6 +23,8 @@ #include "llvm/Target/TargetRegInfo.h" #include "Support/SetOperations.h" +namespace llvm { + unsigned LiveRange::getRegClassID() const { return getRegClass()->getID(); } LiveRangeInfo::LiveRangeInfo(const Function *F, const TargetMachine &tm, @@ -411,3 +413,5 @@ void LiveRangeInfo::printLiveRanges() { } } } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h index 5c5244bd62..a8d0e7152f 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h @@ -29,6 +29,8 @@ #include "llvm/CodeGen/ValueSet.h" #include "Support/hash_map" +namespace llvm { + class LiveRange; class MachineInstr; class RegClass; @@ -121,4 +123,6 @@ public: void printLiveRanges(); }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index 99917cdf0b..332ae9524c 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -47,6 +47,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + RegAllocDebugLevel_t DEBUG_RA; /// The reoptimizer wants to be able to grovel through the register @@ -1392,3 +1394,5 @@ bool PhyRegAlloc::runOnFunction (Function &F) { if (DEBUG_RA) std::cerr << "\nRegister allocation complete!\n"; return false; // Function was not modified } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h index c524f9f56c..4ec083c8ea 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h @@ -31,6 +31,8 @@ #include "llvm/Target/TargetRegInfo.h" #include +namespace llvm { + class MachineFunction; class FunctionLiveVarInfo; class MachineInstr; @@ -179,4 +181,6 @@ private: void addInterf4PseudoInstr(const MachineInstr *MI); }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h b/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h index 97d102a253..7dd86b205a 100644 --- a/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h +++ b/lib/Target/SparcV9/RegAlloc/RegAllocCommon.h @@ -14,6 +14,8 @@ #ifndef REGALLOCCOMMON_H #define REGALLOCCOMMON_H +namespace llvm { + enum RegAllocDebugLevel_t { RA_DEBUG_None = 0, RA_DEBUG_Results = 1, @@ -25,4 +27,6 @@ enum RegAllocDebugLevel_t { extern RegAllocDebugLevel_t DEBUG_RA; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.cpp b/lib/Target/SparcV9/RegAlloc/RegClass.cpp index 9c8603b82c..9af87ba0e8 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.cpp +++ b/lib/Target/SparcV9/RegAlloc/RegClass.cpp @@ -16,6 +16,8 @@ #include "RegClass.h" #include "llvm/Target/TargetRegInfo.h" +namespace llvm { + //---------------------------------------------------------------------------- // This constructor inits IG. The actual matrix is created by a call to // createInterferenceGraph() above. @@ -245,4 +247,4 @@ void RegClass::printIG() { IG.printIG(); } - +} // End llvm namespace diff --git a/lib/Target/SparcV9/RegAlloc/RegClass.h b/lib/Target/SparcV9/RegAlloc/RegClass.h index c861fbae21..0071f7c212 100644 --- a/lib/Target/SparcV9/RegAlloc/RegClass.h +++ b/lib/Target/SparcV9/RegAlloc/RegClass.h @@ -20,6 +20,9 @@ #include "llvm/Target/TargetRegInfo.h" #include "InterferenceGraph.h" #include + +namespace llvm { + class TargetRegClassInfo; @@ -139,4 +142,6 @@ class RegClass { void printIG(); }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/SparcV9.burg.in b/lib/Target/SparcV9/SparcV9.burg.in index a5bc98fa89..38dc2439ce 100644 --- a/lib/Target/SparcV9/SparcV9.burg.in +++ b/lib/Target/SparcV9/SparcV9.burg.in @@ -11,7 +11,7 @@ Xinclude Xinclude -typedef InstrTreeNode* NODEPTR_TYPE; +typedef llvm::InstrTreeNode* NODEPTR_TYPE; Xdefine OP_LABEL(p) ((p)->opLabel) Xdefine LEFT_CHILD(p) ((p)->LeftChild) Xdefine RIGHT_CHILD(p) ((p)->RightChild) diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 25034177da..6af9836e29 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -33,6 +33,8 @@ #include "SparcInternals.h" #include +namespace llvm { + namespace { Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); @@ -877,12 +879,13 @@ SparcFunctionAsmPrinter::emitFunction(const Function &F) } // End anonymous namespace +namespace llvm { + Pass *UltraSparc::getFunctionAsmPrinterPass(std::ostream &Out) { return new SparcFunctionAsmPrinter(Out, *this); } - - +} // End llvm namespace //===----------------------------------------------------------------------===// @@ -954,3 +957,5 @@ void SparcModuleAsmPrinter::emitGlobals(const Module &M) { Pass *UltraSparc::getModuleAsmPrinterPass(std::ostream &Out) { return new SparcModuleAsmPrinter(Out, *this); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp index d60d9151c1..c50dca55e7 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp @@ -38,6 +38,8 @@ #include "SparcV9CodeEmitter.h" #include "Config/alloca.h" +namespace llvm { + namespace { Statistic<> OverwrittenCalls("call-ovwr", "Number of over-written calls"); Statistic<> UnmodifiedCalls("call-skip", "Number of unmodified calls"); @@ -443,7 +445,6 @@ uint64_t JITResolver::emitStubForFunction(Function *F) { return (intptr_t)MCE.finishFunctionStub(*F)+4; /* 1 instr past the restore */ } - SparcV9CodeEmitter::SparcV9CodeEmitter(TargetMachine &tm, MachineCodeEmitter &M): TM(tm), MCE(M) { @@ -809,4 +810,6 @@ void* SparcV9CodeEmitter::getGlobalAddress(GlobalValue *V, MachineInstr &MI, } } +} // End llvm namespace + #include "SparcV9CodeEmitter.inc" diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.h b/lib/Target/SparcV9/SparcV9CodeEmitter.h index 7e19c44ce0..d21345ec04 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.h +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.h @@ -19,6 +19,8 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Target/TargetMachine.h" +namespace llvm { + class GlobalValue; class MachineInstr; class MachineOperand; @@ -81,4 +83,6 @@ private: }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index d92e3be9ca..11b0c7beab 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp @@ -23,6 +23,8 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +namespace llvm { + static const uint32_t MAXLO = (1 << 10) - 1; // set bits set by %lo(*) static const uint32_t MAXSIMM = (1 << 12) - 1; // set bits in simm13 field of OR @@ -792,3 +794,5 @@ UltraSparcInstrInfo::CreateZeroExtensionInstructions( CreateBitExtensionInstructions(/*signExtend*/ false, target, F, srcVal, destVal, numLowBits, mvec, mcfi); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index b377658b9c..21e884be8e 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp @@ -32,6 +32,8 @@ #include #include +namespace llvm { + static inline void Add3OperandInstr(unsigned Opcode, InstructionNode* Node, std::vector& mvec) { mvec.push_back(BuildMI(Opcode, 3).addReg(Node->leftChild()->getValue()) @@ -1390,12 +1392,12 @@ AllUsesAreBranches(const Instruction* setccI) // instead of a regular call. If not that kind of intrinsic, do nothing. // Returns true if code was generated, otherwise false. // -bool CodeGenIntrinsic(LLVMIntrinsic::ID iid, CallInst &callInstr, +bool CodeGenIntrinsic(Intrinsic::ID iid, CallInst &callInstr, TargetMachine &target, std::vector& mvec) { switch (iid) { - case LLVMIntrinsic::va_start: { + case Intrinsic::va_start: { // Get the address of the first incoming vararg argument on the stack bool ignore; Function* func = cast(callInstr.getParent()->getParent()); @@ -1409,10 +1411,10 @@ bool CodeGenIntrinsic(LLVMIntrinsic::ID iid, CallInst &callInstr, return true; } - case LLVMIntrinsic::va_end: + case Intrinsic::va_end: return true; // no-op on Sparc - case LLVMIntrinsic::va_copy: + case Intrinsic::va_copy: // Simple copy of current va_list (arg1) to new va_list (result) mvec.push_back(BuildMI(V9::ORr, 3). addMReg(target.getRegInfo().getZeroRegNum()). @@ -1420,8 +1422,8 @@ bool CodeGenIntrinsic(LLVMIntrinsic::ID iid, CallInst &callInstr, addRegDef(&callInstr)); return true; - case LLVMIntrinsic::sigsetjmp: - case LLVMIntrinsic::setjmp: { + case Intrinsic::sigsetjmp: + case Intrinsic::setjmp: { // act as if we return 0 unsigned g0 = target.getRegInfo().getZeroRegNum(); mvec.push_back(BuildMI(V9::ORr,3).addMReg(g0).addMReg(g0) @@ -1429,8 +1431,8 @@ bool CodeGenIntrinsic(LLVMIntrinsic::ID iid, CallInst &callInstr, return true; } - case LLVMIntrinsic::siglongjmp: - case LLVMIntrinsic::longjmp: { + case Intrinsic::siglongjmp: + case Intrinsic::longjmp: { // call abort() Module* M = callInstr.getParent()->getParent()->getParent(); const FunctionType *voidvoidFuncTy = @@ -2474,8 +2476,8 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, // sequence (e.g., va_start). Indirect calls cannot be special. // bool specialIntrinsic = false; - LLVMIntrinsic::ID iid; - if (calledFunc && (iid=(LLVMIntrinsic::ID)calledFunc->getIntrinsicID())) + Intrinsic::ID iid; + if (calledFunc && (iid=(Intrinsic::ID)calledFunc->getIntrinsicID())) specialIntrinsic = CodeGenIntrinsic(iid, *callInstr, target, mvec); // If not, generate the normal call sequence for the function. @@ -2929,3 +2931,5 @@ GetInstructionsByRule(InstructionNode* subtreeRoot, } } } + +} diff --git a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h index d49863c1c8..b69c5c2b6e 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h +++ b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h @@ -17,6 +17,8 @@ #include "llvm/DerivedTypes.h" #include "SparcInternals.h" +namespace llvm { + // Choose load instruction opcode based on type of value inline MachineOpCode ChooseLoadInstruction(const Type *DestTy) @@ -220,4 +222,6 @@ convertOpcodeFromRegToImm(unsigned Opcode) { } } +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h index 4d0a48e4d5..5e5f155e39 100644 --- a/lib/Target/SparcV9/SparcV9Internals.h +++ b/lib/Target/SparcV9/SparcV9Internals.h @@ -25,6 +25,8 @@ #include "SparcRegClassInfo.h" #include "Config/sys/types.h" +namespace llvm { + class LiveRange; class UltraSparc; class Pass; @@ -693,4 +695,6 @@ public: Pass* getBytecodeAsmPrinterPass(std::ostream &Out); }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp b/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp index 83081b7120..9713a02d95 100644 --- a/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp +++ b/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp @@ -20,6 +20,8 @@ #include "llvm/BasicBlock.h" #include "llvm/Pass.h" +namespace llvm { + //************************* Internal Functions *****************************/ static inline void @@ -163,3 +165,5 @@ bool PeepholeOpts::runOnBasicBlock(BasicBlock &BB) { FunctionPass* createPeepholeOptsPass(const TargetMachine &TM) { return new PeepholeOpts(TM); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9PreSelection.cpp b/lib/Target/SparcV9/SparcV9PreSelection.cpp index 9078dc13b1..205ecd3145 100644 --- a/lib/Target/SparcV9/SparcV9PreSelection.cpp +++ b/lib/Target/SparcV9/SparcV9PreSelection.cpp @@ -29,6 +29,8 @@ #include "llvm/Transforms/Scalar.h" #include +namespace llvm { + namespace { //===--------------------------------------------------------------------===// @@ -71,6 +73,7 @@ namespace { "Specialize LLVM code for a target machine" createPreselectionPass); #endif + } // end anonymous namespace @@ -236,7 +239,6 @@ void PreSelection::visitCallInst(CallInst &I) { visitOperands(I, (/*firstOp=*/ I.getCalledFunction()? 1 : 0)); } - //===----------------------------------------------------------------------===// // createPreSelectionPass - Public entrypoint for pre-selection pass // and this file as a whole... @@ -244,3 +246,5 @@ void PreSelection::visitCallInst(CallInst &I) { FunctionPass* createPreSelectionPass(const TargetMachine &TM) { return new PreSelection(TM); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp index ff7bd7d026..555b6b14fe 100644 --- a/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp +++ b/lib/Target/SparcV9/SparcV9PrologEpilogInserter.cpp @@ -27,6 +27,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/Intrinsics.h" +namespace llvm { + namespace { struct InsertPrologEpilogCode : public MachineFunctionPass { const char *getPassName() const { return "Sparc Prolog/Epilog Inserter"; } @@ -177,3 +179,5 @@ void InsertPrologEpilogCode::InsertEpilogCode(MachineFunction &MF) FunctionPass *UltraSparc::getPrologEpilogInsertionPass() { return new InsertPrologEpilogCode(); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp index d6de5f9c0d..564e59cd70 100644 --- a/lib/Target/SparcV9/SparcV9RegClassInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegClassInfo.cpp @@ -17,6 +17,8 @@ #include "../../CodeGen/RegAlloc/RegAllocCommon.h" // FIXME! #include "../../CodeGen/RegAlloc/IGNode.h" // FIXME! +namespace llvm { + //----------------------------------------------------------------------------- // Int Register Class - method for coloring a node in the interference graph. // @@ -390,3 +392,5 @@ int SparcFloatRegClass::findFloatColor(const LiveRange *LR, return -1; } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9RegClassInfo.h b/lib/Target/SparcV9/SparcV9RegClassInfo.h index 321ce60ab0..cc492e77c7 100644 --- a/lib/Target/SparcV9/SparcV9RegClassInfo.h +++ b/lib/Target/SparcV9/SparcV9RegClassInfo.h @@ -16,6 +16,8 @@ #include "llvm/Target/TargetRegInfo.h" +namespace llvm { + //----------------------------------------------------------------------------- // Integer Register Class //----------------------------------------------------------------------------- @@ -217,4 +219,6 @@ struct SparcSpecialRegClass : public TargetRegClassInfo { const char * const getRegName(unsigned reg) const; }; +} // End llvm namespace + #endif diff --git a/lib/Target/SparcV9/SparcV9RegInfo.cpp b/lib/Target/SparcV9/SparcV9RegInfo.cpp index 84dc92e246..5edbbe0647 100644 --- a/lib/Target/SparcV9/SparcV9RegInfo.cpp +++ b/lib/Target/SparcV9/SparcV9RegInfo.cpp @@ -27,6 +27,8 @@ #include "llvm/Function.h" #include "llvm/DerivedTypes.h" +namespace llvm { + enum { BadRegClass = ~0 }; @@ -967,3 +969,5 @@ void UltraSparcRegInfo::printReg(const LiveRange *LR) const { std::cerr << "+" << getUnifiedRegName(uRegName+1); std::cerr << "]\n"; } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9SchedInfo.cpp b/lib/Target/SparcV9/SparcV9SchedInfo.cpp index fd03ad69d6..7d8ea05066 100644 --- a/lib/Target/SparcV9/SparcV9SchedInfo.cpp +++ b/lib/Target/SparcV9/SparcV9SchedInfo.cpp @@ -13,6 +13,8 @@ #include "SparcInternals.h" +using namespace llvm; + /*--------------------------------------------------------------------------- Scheduling guidelines for SPARC IIi: diff --git a/lib/Target/SparcV9/SparcV9StackSlots.cpp b/lib/Target/SparcV9/SparcV9StackSlots.cpp index 551dd92b49..5fd0ba1927 100644 --- a/lib/Target/SparcV9/SparcV9StackSlots.cpp +++ b/lib/Target/SparcV9/SparcV9StackSlots.cpp @@ -20,6 +20,8 @@ #include "llvm/CodeGen/MachineFunctionInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" +namespace llvm { + namespace { class StackSlots : public MachineFunctionPass { const TargetMachine &Target; @@ -48,3 +50,5 @@ namespace { Pass *createStackSlotsPass(const TargetMachine &Target) { return new StackSlots(Target); } + +} // End llvm namespace diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp index d20fc758d0..73f2fd8139 100644 --- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp +++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp @@ -27,6 +27,8 @@ #include "llvm/Target/TargetMachineImpls.h" #include "Support/CommandLine.h" +namespace llvm { + static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */ // Build the MachineInstruction Description Array... const TargetInstrDescriptor SparcMachineInstrDesc[] = { @@ -267,3 +269,5 @@ bool UltraSparc::addPassesToJITCompile(FunctionPassManager &PM) { return false; // success! } + +} // End llvm namespace diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index a377fd0d7f..ed6936dd12 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -22,13 +22,14 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" +namespace llvm { + // Handle the Pass registration stuff necessary to use TargetData's. namespace { // Register the default SparcV9 implementation... RegisterPass X("targetdata", "Target Data Layout"); } - static inline void getTypeInfo(const Type *Ty, const TargetData *TD, uint64_t &Size, unsigned char &Alignment); @@ -221,3 +222,5 @@ uint64_t TargetData::getIndexedOffset(const Type *ptrTy, return Result; } + +} // End llvm namespace diff --git a/lib/Target/TargetInstrInfo.cpp b/lib/Target/TargetInstrInfo.cpp index f377d67b66..0f9015f8a6 100644 --- a/lib/Target/TargetInstrInfo.cpp +++ b/lib/Target/TargetInstrInfo.cpp @@ -15,6 +15,8 @@ #include "llvm/Constant.h" #include "llvm/DerivedTypes.h" +namespace llvm { + // External object describing the machine instructions // Initialized only when the TargetMachine class is created // and reset when that class is destroyed. @@ -59,3 +61,5 @@ bool TargetInstrInfo::ConstantTypeMustBeLoaded(const Constant* CV) const { assert(CV->getType()->isPrimitiveType() || isa(CV->getType())); return !(CV->getType()->isIntegral() || isa(CV->getType())); } + +} // End llvm namespace diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index b7c1b342e1..e7630b4ab3 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -16,6 +16,8 @@ #include "llvm/Target/TargetCacheInfo.h" #include "llvm/Type.h" +namespace llvm { + //--------------------------------------------------------------------------- // class TargetMachine // @@ -49,3 +51,5 @@ void TargetCacheInfo::Initialize() { cacheSizes.push_back(1 << 15); cacheSizes.push_back(1 << 20); cacheAssoc.push_back(1); cacheAssoc.push_back(4); } + +} // End llvm namespace diff --git a/lib/Target/TargetSchedInfo.cpp b/lib/Target/TargetSchedInfo.cpp index 0dbde45c38..f33223c43a 100644 --- a/lib/Target/TargetSchedInfo.cpp +++ b/lib/Target/TargetSchedInfo.cpp @@ -15,6 +15,8 @@ #include "llvm/Target/TargetSchedInfo.h" #include "llvm/Target/TargetMachine.h" +namespace llvm { + resourceId_t MachineResource::nextId = 0; // Check if fromRVec and toRVec have *any* common entries. @@ -249,3 +251,5 @@ void InstrRUsage::addUsageDelta(const InstrRUsageDelta &delta) { assert(r >= 0 && "Resource to remove was unused in cycle c!"); } } + +} // End llvm namespace diff --git a/lib/Target/X86/FloatingPoint.cpp b/lib/Target/X86/FloatingPoint.cpp index 07e58ba171..5c6e6ebfdd 100644 --- a/lib/Target/X86/FloatingPoint.cpp +++ b/lib/Target/X86/FloatingPoint.cpp @@ -25,6 +25,8 @@ #include #include +namespace llvm { + namespace { Statistic<> NumFXCH("x86-codegen", "Number of fxch instructions inserted"); Statistic<> NumFP ("x86-codegen", "Number of floating point instructions"); @@ -70,7 +72,7 @@ namespace { // getSTReg - Return the X86::ST(i) register which contains the specified // FP register unsigned getSTReg(unsigned RegNo) const { - return StackTop - 1 - getSlot(RegNo) + X86::ST0; + return StackTop - 1 - getSlot(RegNo) + llvm::X86::ST0; } // pushReg - Push the specifiex FP register onto the stack @@ -598,3 +600,5 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &I) { I = MBB->erase(I)-1; // Remove the pseudo instruction } + +} // End llvm namespace diff --git a/lib/Target/X86/InstSelectPattern.cpp b/lib/Target/X86/InstSelectPattern.cpp index 434ceee91c..e518294564 100644 --- a/lib/Target/X86/InstSelectPattern.cpp +++ b/lib/Target/X86/InstSelectPattern.cpp @@ -28,6 +28,8 @@ // Include the generated instruction selector... #include "X86GenInstrSelector.inc" +namespace llvm { + namespace { struct ISel : public FunctionPass, SelectionDAGTargetBuilder { TargetMachine &TM; @@ -114,7 +116,6 @@ void ISel::expandCall(SelectionDAG &SD, CallInst &CI) { assert(0 && "ISel::expandCall not implemented!"); } - /// createX86PatternInstructionSelector - This pass converts an LLVM function /// into a machine code representation using pattern matching and a machine /// description file. @@ -122,3 +123,5 @@ void ISel::expandCall(SelectionDAG &SD, CallInst &CI) { FunctionPass *createX86PatternInstructionSelector(TargetMachine &TM) { return new ISel(TM); } + +} // End llvm namespace diff --git a/lib/Target/X86/InstSelectSimple.cpp b/lib/Target/X86/InstSelectSimple.cpp index 1242545d83..de341c477d 100644 --- a/lib/Target/X86/InstSelectSimple.cpp +++ b/lib/Target/X86/InstSelectSimple.cpp @@ -29,6 +29,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/InstVisitor.h" +namespace llvm { + /// BMI - A special BuildMI variant that takes an iterator to insert the /// instruction at as well as a basic block. This is the version for when you /// have a destination register in mind. @@ -138,7 +140,7 @@ namespace { void doCall(const ValueRecord &Ret, MachineInstr *CallMI, const std::vector &Args); void visitCallInst(CallInst &I); - void visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &I); + void visitIntrinsicCall(Intrinsic::ID ID, CallInst &I); // Arithmetic operators void visitSimpleBinary(BinaryOperator &B, unsigned OpcodeClass); @@ -1045,7 +1047,7 @@ void ISel::visitCallInst(CallInst &CI) { MachineInstr *TheCall; if (Function *F = CI.getCalledFunction()) { // Is it an intrinsic function call? - if (LLVMIntrinsic::ID ID = (LLVMIntrinsic::ID)F->getIntrinsicID()) { + if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) { visitIntrinsicCall(ID, CI); // Special intrinsics are not handled here return; } @@ -1066,29 +1068,29 @@ void ISel::visitCallInst(CallInst &CI) { } -void ISel::visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &CI) { +void ISel::visitIntrinsicCall(Intrinsic::ID ID, CallInst &CI) { unsigned TmpReg1, TmpReg2; switch (ID) { - case LLVMIntrinsic::va_start: + case Intrinsic::va_start: // Get the address of the first vararg value... TmpReg1 = getReg(CI); addFrameReference(BuildMI(BB, X86::LEAr32, 5, TmpReg1), VarArgsFrameIndex); return; - case LLVMIntrinsic::va_copy: + case Intrinsic::va_copy: TmpReg1 = getReg(CI); TmpReg2 = getReg(CI.getOperand(1)); BuildMI(BB, X86::MOVrr32, 1, TmpReg1).addReg(TmpReg2); return; - case LLVMIntrinsic::va_end: return; // Noop on X86 + case Intrinsic::va_end: return; // Noop on X86 - case LLVMIntrinsic::longjmp: - case LLVMIntrinsic::siglongjmp: + case Intrinsic::longjmp: + case Intrinsic::siglongjmp: BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("abort", true); return; - case LLVMIntrinsic::setjmp: - case LLVMIntrinsic::sigsetjmp: + case Intrinsic::setjmp: + case Intrinsic::sigsetjmp: // Setjmp always returns zero... BuildMI(BB, X86::MOVir32, 1, getReg(CI)).addZImm(0); return; @@ -2127,7 +2129,6 @@ void ISel::visitFreeInst(FreeInst &I) { doCall(ValueRecord(0, Type::VoidTy), TheCall, Args); } - /// createX86SimpleInstructionSelector - This pass converts an LLVM function /// into a machine code representation is a very simple peep-hole fashion. The /// generated code sucks but the implementation is nice and simple. @@ -2135,3 +2136,5 @@ void ISel::visitFreeInst(FreeInst &I) { FunctionPass *createX86SimpleInstructionSelector(TargetMachine &TM) { return new ISel(TM); } + +} // End llvm namespace diff --git a/lib/Target/X86/PeepholeOptimizer.cpp b/lib/Target/X86/PeepholeOptimizer.cpp index fbc84f7e87..2f3280a4bb 100644 --- a/lib/Target/X86/PeepholeOptimizer.cpp +++ b/lib/Target/X86/PeepholeOptimizer.cpp @@ -15,6 +15,8 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +namespace llvm { + namespace { struct PH : public MachineFunctionPass { virtual bool runOnMachineFunction(MachineFunction &MF); @@ -131,3 +133,5 @@ bool PH::PeepholeOptimize(MachineBasicBlock &MBB, return false; } } + +} // End llvm namespace diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index 3d073f77c6..292a465e72 100644 --- a/lib/Target/X86/Printer.cpp +++ b/lib/Target/X86/Printer.cpp @@ -29,6 +29,8 @@ #include "Support/StringExtras.h" #include "Support/CommandLine.h" +namespace llvm { + namespace { Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); @@ -960,3 +962,5 @@ bool Printer::doFinalization(Module &M) { delete Mang; return false; // success } + +} // End llvm namespace diff --git a/lib/Target/X86/X86.h b/lib/Target/X86/X86.h index 01041f8d3a..5cf897fa71 100644 --- a/lib/Target/X86/X86.h +++ b/lib/Target/X86/X86.h @@ -16,6 +16,9 @@ #define TARGET_X86_H #include + +namespace llvm { + class TargetMachine; class FunctionPass; @@ -58,6 +61,8 @@ FunctionPass *createEmitX86CodeToMemory(); // Defines symbolic names for X86 registers. This defines a mapping from // register name to register number. // +} // End llvm namespace + #include "X86GenRegisterNames.inc" // Defines symbolic names for the X86 instructions. diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 3d073f77c6..292a465e72 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -29,6 +29,8 @@ #include "Support/StringExtras.h" #include "Support/CommandLine.h" +namespace llvm { + namespace { Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); @@ -960,3 +962,5 @@ bool Printer::doFinalization(Module &M) { delete Mang; return false; // success } + +} // End llvm namespace diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index f49fde58d2..e24e2904b5 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -24,6 +24,8 @@ #include "Support/Statistic.h" #include "Config/alloca.h" +namespace llvm { + namespace { Statistic<> NumEmitted("x86-emitter", "Number of machine instructions emitted"); @@ -589,3 +591,5 @@ void Emitter::emitInstruction(MachineInstr &MI) { break; } } + +} // End llvm namespace diff --git a/lib/Target/X86/X86FloatingPoint.cpp b/lib/Target/X86/X86FloatingPoint.cpp index 07e58ba171..5c6e6ebfdd 100644 --- a/lib/Target/X86/X86FloatingPoint.cpp +++ b/lib/Target/X86/X86FloatingPoint.cpp @@ -25,6 +25,8 @@ #include #include +namespace llvm { + namespace { Statistic<> NumFXCH("x86-codegen", "Number of fxch instructions inserted"); Statistic<> NumFP ("x86-codegen", "Number of floating point instructions"); @@ -70,7 +72,7 @@ namespace { // getSTReg - Return the X86::ST(i) register which contains the specified // FP register unsigned getSTReg(unsigned RegNo) const { - return StackTop - 1 - getSlot(RegNo) + X86::ST0; + return StackTop - 1 - getSlot(RegNo) + llvm::X86::ST0; } // pushReg - Push the specifiex FP register onto the stack @@ -598,3 +600,5 @@ void FPS::handleSpecialFP(MachineBasicBlock::iterator &I) { I = MBB->erase(I)-1; // Remove the pseudo instruction } + +} // End llvm namespace diff --git a/lib/Target/X86/X86ISelPattern.cpp b/lib/Target/X86/X86ISelPattern.cpp index 434ceee91c..e518294564 100644 --- a/lib/Target/X86/X86ISelPattern.cpp +++ b/lib/Target/X86/X86ISelPattern.cpp @@ -28,6 +28,8 @@ // Include the generated instruction selector... #include "X86GenInstrSelector.inc" +namespace llvm { + namespace { struct ISel : public FunctionPass, SelectionDAGTargetBuilder { TargetMachine &TM; @@ -114,7 +116,6 @@ void ISel::expandCall(SelectionDAG &SD, CallInst &CI) { assert(0 && "ISel::expandCall not implemented!"); } - /// createX86PatternInstructionSelector - This pass converts an LLVM function /// into a machine code representation using pattern matching and a machine /// description file. @@ -122,3 +123,5 @@ void ISel::expandCall(SelectionDAG &SD, CallInst &CI) { FunctionPass *createX86PatternInstructionSelector(TargetMachine &TM) { return new ISel(TM); } + +} // End llvm namespace diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index 1242545d83..de341c477d 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -29,6 +29,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/InstVisitor.h" +namespace llvm { + /// BMI - A special BuildMI variant that takes an iterator to insert the /// instruction at as well as a basic block. This is the version for when you /// have a destination register in mind. @@ -138,7 +140,7 @@ namespace { void doCall(const ValueRecord &Ret, MachineInstr *CallMI, const std::vector &Args); void visitCallInst(CallInst &I); - void visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &I); + void visitIntrinsicCall(Intrinsic::ID ID, CallInst &I); // Arithmetic operators void visitSimpleBinary(BinaryOperator &B, unsigned OpcodeClass); @@ -1045,7 +1047,7 @@ void ISel::visitCallInst(CallInst &CI) { MachineInstr *TheCall; if (Function *F = CI.getCalledFunction()) { // Is it an intrinsic function call? - if (LLVMIntrinsic::ID ID = (LLVMIntrinsic::ID)F->getIntrinsicID()) { + if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) { visitIntrinsicCall(ID, CI); // Special intrinsics are not handled here return; } @@ -1066,29 +1068,29 @@ void ISel::visitCallInst(CallInst &CI) { } -void ISel::visitIntrinsicCall(LLVMIntrinsic::ID ID, CallInst &CI) { +void ISel::visitIntrinsicCall(Intrinsic::ID ID, CallInst &CI) { unsigned TmpReg1, TmpReg2; switch (ID) { - case LLVMIntrinsic::va_start: + case Intrinsic::va_start: // Get the address of the first vararg value... TmpReg1 = getReg(CI); addFrameReference(BuildMI(BB, X86::LEAr32, 5, TmpReg1), VarArgsFrameIndex); return; - case LLVMIntrinsic::va_copy: + case Intrinsic::va_copy: TmpReg1 = getReg(CI); TmpReg2 = getReg(CI.getOperand(1)); BuildMI(BB, X86::MOVrr32, 1, TmpReg1).addReg(TmpReg2); return; - case LLVMIntrinsic::va_end: return; // Noop on X86 + case Intrinsic::va_end: return; // Noop on X86 - case LLVMIntrinsic::longjmp: - case LLVMIntrinsic::siglongjmp: + case Intrinsic::longjmp: + case Intrinsic::siglongjmp: BuildMI(BB, X86::CALLpcrel32, 1).addExternalSymbol("abort", true); return; - case LLVMIntrinsic::setjmp: - case LLVMIntrinsic::sigsetjmp: + case Intrinsic::setjmp: + case Intrinsic::sigsetjmp: // Setjmp always returns zero... BuildMI(BB, X86::MOVir32, 1, getReg(CI)).addZImm(0); return; @@ -2127,7 +2129,6 @@ void ISel::visitFreeInst(FreeInst &I) { doCall(ValueRecord(0, Type::VoidTy), TheCall, Args); } - /// createX86SimpleInstructionSelector - This pass converts an LLVM function /// into a machine code representation is a very simple peep-hole fashion. The /// generated code sucks but the implementation is nice and simple. @@ -2135,3 +2136,5 @@ void ISel::visitFreeInst(FreeInst &I) { FunctionPass *createX86SimpleInstructionSelector(TargetMachine &TM) { return new ISel(TM); } + +} // End llvm namespace diff --git a/lib/Target/X86/X86InstrBuilder.h b/lib/Target/X86/X86InstrBuilder.h index a6d65d4749..a5643bdbfb 100644 --- a/lib/Target/X86/X86InstrBuilder.h +++ b/lib/Target/X86/X86InstrBuilder.h @@ -26,6 +26,8 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" +namespace llvm { + /// addDirectMem - This function is used to add a direct memory reference to the /// current instruction -- that is, a dereference of an address in a register, /// with no scale, index or displacement. An example is: DWORD PTR [EAX]. @@ -69,4 +71,6 @@ addConstantPoolReference(const MachineInstrBuilder &MIB, unsigned CPI, return MIB.addConstantPoolIndex(CPI).addZImm(1).addReg(0).addSImm(Offset); } +} // End llvm namespace + #endif diff --git a/lib/Target/X86/X86InstrInfo.cpp b/lib/Target/X86/X86InstrInfo.cpp index 012ceadff0..681bf023d9 100644 --- a/lib/Target/X86/X86InstrInfo.cpp +++ b/lib/Target/X86/X86InstrInfo.cpp @@ -17,6 +17,8 @@ #include "X86GenInstrInfo.inc" +using namespace llvm; + X86InstrInfo::X86InstrInfo() : TargetInstrInfo(X86Insts, sizeof(X86Insts)/sizeof(X86Insts[0]), 0) { } diff --git a/lib/Target/X86/X86InstrInfo.h b/lib/Target/X86/X86InstrInfo.h index 26b2618a01..2bf82d16c6 100644 --- a/lib/Target/X86/X86InstrInfo.h +++ b/lib/Target/X86/X86InstrInfo.h @@ -17,6 +17,8 @@ #include "llvm/Target/TargetInstrInfo.h" #include "X86RegisterInfo.h" +namespace llvm { + /// X86II - This namespace holds all of the target specific flags that /// instruction info tracks. /// @@ -181,4 +183,6 @@ public: } }; +} // End llvm namespace + #endif diff --git a/lib/Target/X86/X86PeepholeOpt.cpp b/lib/Target/X86/X86PeepholeOpt.cpp index fbc84f7e87..2f3280a4bb 100644 --- a/lib/Target/X86/X86PeepholeOpt.cpp +++ b/lib/Target/X86/X86PeepholeOpt.cpp @@ -15,6 +15,8 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstrBuilder.h" +namespace llvm { + namespace { struct PH : public MachineFunctionPass { virtual bool runOnMachineFunction(MachineFunction &MF); @@ -131,3 +133,5 @@ bool PH::PeepholeOptimize(MachineBasicBlock &MBB, return false; } } + +} // End llvm namespace diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index fd8a615e31..0e8b889ad8 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -25,6 +25,8 @@ #include "llvm/Target/TargetFrameInfo.h" #include "Support/CommandLine.h" +namespace llvm { + namespace { cl::opt NoFPElim("disable-fp-elim", @@ -253,8 +255,12 @@ int X86RegisterInfo::emitEpilogue(MachineFunction &MF, return MBB.size() - oldSize; } +} // End llvm namespace + #include "X86GenRegisterInfo.inc" +namespace llvm { + const TargetRegisterClass* X86RegisterInfo::getRegClassForType(const Type* Ty) const { switch (Ty->getPrimitiveID()) { @@ -274,3 +280,5 @@ X86RegisterInfo::getRegClassForType(const Type* Ty) const { case Type::DoubleTyID: return &RFPInstance; } } + +} // End llvm namespace diff --git a/lib/Target/X86/X86RegisterInfo.h b/lib/Target/X86/X86RegisterInfo.h index 0db8e18bee..77a8a1a405 100644 --- a/lib/Target/X86/X86RegisterInfo.h +++ b/lib/Target/X86/X86RegisterInfo.h @@ -16,10 +16,12 @@ #include "llvm/Target/MRegisterInfo.h" -class Type; +class llvm::Type; #include "X86GenRegisterInfo.h.inc" +namespace llvm { + struct X86RegisterInfo : public X86GenRegisterInfo { X86RegisterInfo(); const TargetRegisterClass* getRegClassForType(const Type* Ty) const; @@ -52,4 +54,6 @@ struct X86RegisterInfo : public X86GenRegisterInfo { int emitEpilogue(MachineFunction &MF, MachineBasicBlock &MBB) const; }; +} // End llvm namespace + #endif diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 954d4f4ced..31eb4bd61c 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -22,6 +22,8 @@ #include "Support/CommandLine.h" #include "Support/Statistic.h" +namespace llvm { + namespace { cl::opt PrintCode("print-machineinstrs", cl::desc("Print generated machine code")); @@ -153,3 +155,5 @@ void X86TargetMachine::replaceMachineCodeForFunction (void *Old, void *New) { int32_t OldAddr = (intptr_t) OldWord; *OldWord = NewAddr - OldAddr - 4; // Emit PC-relative addr of New code. } + +} // End llvm namespace diff --git a/lib/Target/X86/X86TargetMachine.h b/lib/Target/X86/X86TargetMachine.h index 5581da4d81..12f5c0e6a2 100644 --- a/lib/Target/X86/X86TargetMachine.h +++ b/lib/Target/X86/X86TargetMachine.h @@ -19,6 +19,8 @@ #include "llvm/PassManager.h" #include "X86InstrInfo.h" +namespace llvm { + class X86TargetMachine : public TargetMachine { X86InstrInfo InstrInfo; TargetFrameInfo FrameInfo; @@ -55,4 +57,6 @@ public: virtual void replaceMachineCodeForFunction (void *Old, void *New); }; +} // End llvm namespace + #endif diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index d3e9287de4..970be52aa4 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -23,6 +23,8 @@ #include "Support/Debug.h" #include +namespace llvm { + static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty, ValueTypeCache &ConvertedTypes, const TargetData &TD); @@ -1298,3 +1300,5 @@ ValueHandle::~ValueHandle() { // << Operands[0]->use_size() << " " << Operands[0]); } } + +} // End llvm namespace diff --git a/lib/Transforms/Hello/Hello.cpp b/lib/Transforms/Hello/Hello.cpp index a71bd34288..4ed281a40a 100644 --- a/lib/Transforms/Hello/Hello.cpp +++ b/lib/Transforms/Hello/Hello.cpp @@ -15,6 +15,8 @@ #include "llvm/Pass.h" #include "llvm/Function.h" +namespace llvm { + namespace { // Hello - The first implementation, without getAnalysisUsage. struct Hello : public FunctionPass { @@ -39,3 +41,5 @@ namespace { }; RegisterOpt Y("hello2", "Hello World Pass (with getAnalysisUsage implemented)"); } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index a4526820e6..498cd7bb14 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -22,6 +22,8 @@ #include "llvm/Pass.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumMerged("constmerge", "Number of global constants merged"); @@ -37,7 +39,6 @@ namespace { Pass *createConstantMergePass() { return new ConstantMerge(); } - bool ConstantMerge::run(Module &M) { std::map CMap; bool MadeChanges = false; @@ -78,3 +79,5 @@ bool ConstantMerge::run(Module &M) { return MadeChanges; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index 9003f8877f..197710d650 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -30,6 +30,8 @@ #include "Support/iterator" #include +namespace llvm { + namespace { Statistic<> NumArgumentsEliminated("deadargelim", "Number of unread args removed"); @@ -576,3 +578,6 @@ bool DAE::run(Module &M) { RemoveDeadArgumentsFromFunction(*DeadRetVal.begin()); return true; } + +} // End llvm namespace + diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index c3eb416002..126991d3e6 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -19,6 +19,8 @@ #include "llvm/DerivedTypes.h" #include "Support/Statistic.h" +namespace llvm { + namespace { struct DTE : public Pass { // doPassInitialization - For this pass, it removes global symbol table @@ -45,7 +47,6 @@ Pass *createDeadTypeEliminationPass() { } - // ShouldNukeSymtabEntry - Return true if this module level symbol table entry // should be eliminated. // @@ -95,3 +96,5 @@ bool DTE::run(Module &M) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/ExtractFunction.cpp b/lib/Transforms/IPO/ExtractFunction.cpp index 1656c512dd..c1ae2d45e4 100644 --- a/lib/Transforms/IPO/ExtractFunction.cpp +++ b/lib/Transforms/IPO/ExtractFunction.cpp @@ -10,6 +10,8 @@ #include "llvm/Pass.h" #include "llvm/Module.h" +namespace llvm { + namespace { class FunctionExtractorPass : public Pass { Function *Named; @@ -90,3 +92,5 @@ namespace { Pass *createFunctionExtractionPass(Function *F) { return new FunctionExtractorPass(F); } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index a21853d207..2a366c84cd 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -29,6 +29,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<>NumResolved("funcresolve", "Number of varargs functions resolved"); Statistic<> NumGlobals("funcresolve", "Number of global variables resolved"); @@ -329,3 +331,5 @@ bool FunctionResolvingPass::run(Module &M) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index dc400269e6..8e7920dc1b 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -22,6 +22,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumFunctions("globaldce","Number of functions removed"); Statistic<> NumVariables("globaldce","Number of global variables removed"); @@ -195,3 +197,5 @@ bool GlobalDCE::SafeToDestroyConstant(Constant *C) { return true; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp index b592138b08..b0135d1531 100644 --- a/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/CallSite.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumArgumentsProped("ipconstprop", "Number of args turned into constants"); @@ -121,3 +123,5 @@ bool IPCP::processFunction(Function &F) { } return MadeChange; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp index 169e57745a..715f4462b2 100644 --- a/lib/Transforms/IPO/InlineSimple.cpp +++ b/lib/Transforms/IPO/InlineSimple.cpp @@ -17,6 +17,8 @@ #include "llvm/Support/CallSite.h" #include "llvm/Transforms/IPO.h" +namespace llvm { + namespace { // FunctionInfo - For each function, calculate the size of it in blocks and // instructions. @@ -114,3 +116,5 @@ int SimpleInliner::getInlineCost(CallSite CS) { InlineCost += CalleeFI.NumInsts*10 + CalleeFI.NumBlocks*20; return InlineCost; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index 8ad72ab9a1..bd1bd8370f 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -24,6 +24,8 @@ #include "Support/Debug.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumInlined("inline", "Number of functions inlined"); Statistic<> NumDeleted("inline", "Number of functions deleted because all callers found"); @@ -134,3 +136,5 @@ bool Inliner::performInlining(CallSite CS, std::set &SCC) { } return true; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/Inliner.h b/lib/Transforms/IPO/Inliner.h index 1f3d0d2dc2..805876c54d 100644 --- a/lib/Transforms/IPO/Inliner.h +++ b/lib/Transforms/IPO/Inliner.h @@ -20,6 +20,9 @@ #define DEBUG_TYPE "inline" #include "llvm/CallGraphSCCPass.h" #include + +namespace llvm { + class CallSite; /// Inliner - This class contains all of the helper code which is used to @@ -61,5 +64,6 @@ private: bool performInlining(CallSite CS, std::set &SCC); }; +} // End llvm namespace #endif diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 92d389a33d..574c8bf268 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -22,6 +22,8 @@ #include #include +namespace llvm { + namespace { Statistic<> NumFunctions("internalize", "Number of functions internalized"); Statistic<> NumGlobals ("internalize", "Number of global vars internalized"); @@ -119,3 +121,5 @@ namespace { Pass *createInternalizePass() { return new InternalizePass(); } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index abbc2c92c4..276523b00b 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -47,6 +47,8 @@ #include "Support/StringExtras.h" #include "Support/VectorExtras.h" +namespace llvm { + namespace { Statistic<> LongJmpsTransformed("lowersetjmp", "Number of longjmps transformed"); @@ -538,3 +540,5 @@ Pass* createLowerSetJmpPass() { return new LowerSetJmp(); } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/MutateStructTypes.cpp b/lib/Transforms/IPO/MutateStructTypes.cpp index dfaf8a89c6..41835adb48 100644 --- a/lib/Transforms/IPO/MutateStructTypes.cpp +++ b/lib/Transforms/IPO/MutateStructTypes.cpp @@ -28,6 +28,8 @@ #include "Support/Debug.h" #include +using namespace llvm; + // ValuePlaceHolder - A stupid little marker value. It appears as an // instruction of type Instruction::UserOp1. // diff --git a/lib/Transforms/IPO/Parallelize.cpp b/lib/Transforms/IPO/Parallelize.cpp index 77e6ed3040..fd39b6b12a 100644 --- a/lib/Transforms/IPO/Parallelize.cpp +++ b/lib/Transforms/IPO/Parallelize.cpp @@ -53,6 +53,8 @@ #include #include +namespace llvm { + //---------------------------------------------------------------------------- // Global constants used in marking Cilk functions and function calls. //---------------------------------------------------------------------------- @@ -535,3 +537,5 @@ bool Parallelize::run(Module& M) return true; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index b377a8befe..30e2514872 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -23,6 +23,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumRemoved("prune-eh", "Number of invokes removed"); @@ -104,3 +106,5 @@ bool PruneEH::runOnSCC(const std::vector &SCC) { return MadeChange; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 81abda0006..fd5b7fb1f1 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -22,6 +22,8 @@ #include "llvm/Support/CallSite.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumRaised("raiseallocs", "Number of allocations raised"); @@ -194,3 +196,5 @@ bool RaiseAllocations::run(Module &M) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/IPO/SimpleStructMutation.cpp b/lib/Transforms/IPO/SimpleStructMutation.cpp index 012fa22770..0c7091696e 100644 --- a/lib/Transforms/IPO/SimpleStructMutation.cpp +++ b/lib/Transforms/IPO/SimpleStructMutation.cpp @@ -23,6 +23,8 @@ using std::vector; using std::set; using std::pair; +namespace llvm { + namespace { struct SimpleStructMutation : public MutateStructTypes { enum Transform { SwapElements, SortElements }; @@ -188,3 +190,5 @@ SimpleStructMutation::TransformsType return Transforms; } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index c371a9fa69..90ef14df7e 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -25,6 +25,8 @@ #include "llvm/Module.h" #include "llvm/Pass.h" +namespace llvm { + static void insertInitializationCall(Function *MainFn, const char *FnName, GlobalValue *Array) { const Type *ArgVTy = PointerType::get(PointerType::get(Type::SByteTy)); @@ -181,3 +183,5 @@ bool BlockProfiler::run(Module &M) { insertInitializationCall(Main, "llvm_start_block_profiling", Counters); return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/EmitFunctions.cpp b/lib/Transforms/Instrumentation/EmitFunctions.cpp index 9c395a9c1f..57254b9080 100644 --- a/lib/Transforms/Instrumentation/EmitFunctions.cpp +++ b/lib/Transforms/Instrumentation/EmitFunctions.cpp @@ -17,6 +17,8 @@ #include "llvm/Pass.h" #include "llvm/Support/CFG.h" +namespace llvm { + enum Color{ WHITE, GREY, @@ -104,3 +106,5 @@ bool EmitFunctionTable::run(Module &M){ M.getGlobalList().push_back(fnCount); return true; // Always modifies program } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp b/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp index 6c7bb5f360..04207820a5 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/CombineBranch.cpp @@ -27,6 +27,8 @@ #include "llvm/Function.h" #include "llvm/Pass.h" +namespace llvm { + //this is used to color vertices //during DFS @@ -36,7 +38,7 @@ enum Color{ BLACK }; -namespace{ +namespace { struct CombineBranches : public FunctionPass { private: //DominatorSet *DS; @@ -225,3 +227,5 @@ bool CombineBranches::runOnFunction(Function &F){ return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp index 6a7f50e333..3cb5698a11 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/EdgeCode.cpp @@ -27,8 +27,10 @@ #define INSERT_LOAD_COUNT #define INSERT_STORE + using std::vector; +namespace llvm { static void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo, Value *cnt, Instruction *rInst){ @@ -369,3 +371,4 @@ void insertBB(Edge ed, } } +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp b/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp index cae699a8d6..d69c4c3b4c 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp @@ -19,6 +19,8 @@ using std::vector; +namespace llvm { + const graphListElement *findNodeInList(const Graph::nodeList &NL, Node *N) { for(Graph::nodeList::const_iterator NI = NL.begin(), NE=NL.end(); NI != NE; @@ -564,4 +566,4 @@ void Graph::getBackEdgesVisit(Node *u, vector &be, color[u]=BLACK;//done with visiting the node and its neighbors } - +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/ProfilePaths/Graph.h b/lib/Transforms/Instrumentation/ProfilePaths/Graph.h index 5597b599e0..44b63a91ea 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/Graph.h +++ b/lib/Transforms/Instrumentation/ProfilePaths/Graph.h @@ -19,6 +19,8 @@ #include #include +namespace llvm { + class Module; class Function; @@ -112,8 +114,13 @@ struct graphListElement{ } }; +} // End llvm namespace + namespace std { + +using namespace llvm; + template<> struct less : public binary_function { bool operator()(Node *n1, Node *n2) const { @@ -135,6 +142,8 @@ namespace std { }; } +namespace llvm { + struct BBSort{ bool operator()(BasicBlock *BB1, BasicBlock *BB2) const{ std::string name1=BB1->getName(); @@ -465,6 +474,7 @@ int valueAssignmentToEdges(Graph& g, std::map nodePriority, std::vector &be); void getBBtrace(std::vector &vBB, int pathNo, Function *M); -#endif +} // End llvm namespace +#endif diff --git a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp index 66b8ccd6c4..d9dc011cd5 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp @@ -24,6 +24,8 @@ using std::map; using std::vector; using std::cerr; +namespace llvm { + //check if 2 edges are equal (same endpoints and same weight) static bool edgesEqual(Edge ed1, Edge ed2){ return ((ed1==ed2) && ed1.getWeight()==ed2.getWeight()); @@ -673,3 +675,5 @@ void printGraph(Graph &g){ } cerr<<"--------------------Graph\n"; } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp index b5e9d8c30c..9d6107cd2d 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp @@ -27,6 +27,8 @@ #include "llvm/Function.h" #include "llvm/Pass.h" +namespace llvm { + //this is used to color vertices //during DFS @@ -181,3 +183,5 @@ bool InstLoops::runOnFunction(Function &F){ findAndInstrumentBackEdges(F); return true; // Function was modified. } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp index d4973be25e..5728265f42 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/ProfilePaths.cpp @@ -43,6 +43,8 @@ #include #include +namespace llvm { + struct ProfilePaths : public FunctionPass { bool runOnFunction(Function &F); @@ -245,3 +247,5 @@ bool ProfilePaths::runOnFunction(Function &F){ return true; // Always modifies function } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp b/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp index 58b3840587..cbb2ae6aee 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/RetracePath.cpp @@ -21,6 +21,8 @@ using std::vector; using std::map; using std::cerr; +namespace llvm { + //Routines to get the path trace! void getPathFrmNode(Node *n, vector &vBB, int pathNo, Graph &g, @@ -303,3 +305,5 @@ void getBBtrace(vector &vBB, int pathNo, Function *M){//, } */ } + +} // End llvm namespace diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index f19ba74000..c802f73604 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -26,6 +26,8 @@ #include #include +namespace llvm { + static cl::opt DisablePtrHashing("tracedisablehashdisable", cl::Hidden, cl::desc("Disable pointer hashing in the -trace or -tracem " @@ -433,3 +435,5 @@ bool InsertTraceCode::runOnFunction(Function &F) { return true; } + +} // End llvm namespace diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index cf64aea1cd..c5be82fca7 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -29,6 +29,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + // StartInst - This enables the -raise-start-inst=foo option to cause the level // raising pass to start at instruction "foo", which is immensely useful for // debugging! @@ -55,7 +57,6 @@ NumDCEorCP("raise", "Number of insts DCEd or constprop'd"); static Statistic<> NumVarargCallChanges("raise", "Number of vararg call peepholes"); - #define PRINT_PEEPHOLE(ID, NUM, I) \ DEBUG(std::cerr << "Inst P/H " << ID << "[" << NUM << "] " << I) @@ -86,12 +87,12 @@ namespace { RegisterOpt X("raise", "Raise Pointer References"); } + Pass *createRaisePointerReferencesPass() { return new RPR(); } - // isReinterpretingCast - Return true if the cast instruction specified will // cause the operand to be "reinterpreted". A value is reinterpreted if the // cast instruction would cause the underlying bits to change. @@ -617,3 +618,5 @@ bool RPR::runOnFunction(Function &F) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 2735f95d89..e45b273190 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -28,6 +28,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + namespace { Statistic<> NumBlockRemoved("adce", "Number of basic blocks removed"); Statistic<> NumInstRemoved ("adce", "Number of instructions removed"); @@ -456,3 +458,5 @@ bool ADCE::doADCE() { return MadeChanges; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index ceef34e54e..66e78960f7 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -27,6 +27,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumInstKilled("constprop", "Number of instructions killed"); @@ -73,3 +75,5 @@ bool ConstantPropagation::runOnFunction(Function &F) { } return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp index aad9b7f309..a0358b54ad 100644 --- a/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp @@ -42,6 +42,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumSetCCRemoved("cee", "Number of setcc instruction eliminated"); Statistic<> NumOperandsCann("cee", "Number of operands canonicalized"); @@ -1314,3 +1316,5 @@ void Relation::print(std::ostream &OS) const { void Relation::dump() const { print(std::cerr); } void ValueInfo::dump() const { print(std::cerr, 0); } void RegionInfo::dump() const { print(std::cerr); } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index e3fc8de396..3e63cadd3e 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -24,6 +24,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> DIEEliminated("die", "Number of insts removed"); Statistic<> DCEEliminated("dce", "Number of insts removed"); @@ -57,7 +59,6 @@ Pass *createDeadInstEliminationPass() { } - //===----------------------------------------------------------------------===// // DeadCodeElimination pass implementation // @@ -124,3 +125,5 @@ bool DCE::runOnFunction(Function &F) { Pass *createDeadCodeEliminationPass() { return new DCE(); } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp index d6aee14f24..e110cdac8b 100644 --- a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp +++ b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp @@ -25,6 +25,8 @@ #include "llvm/Pass.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumAdded("lowerrefs", "# of getelementptr instructions added"); @@ -36,13 +38,6 @@ namespace { RegisterOpt X("lowerrefs", "Decompose multi-dimensional " "structure/array references"); -FunctionPass -*createDecomposeMultiDimRefsPass() -{ - return new DecomposePass(); -} - - // runOnBasicBlock - Entry point for array or structure references with multiple // indices. // @@ -57,6 +52,11 @@ DecomposePass::runOnBasicBlock(BasicBlock &BB) return changed; } +FunctionPass +*createDecomposeMultiDimRefsPass() +{ + return new DecomposePass(); +} // Function: DecomposeArrayRef() // @@ -134,3 +134,5 @@ DecomposeArrayRef(GetElementPtrInst* GEP) return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index e1654e5d7f..b00d3005bf 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -23,6 +23,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumInstRemoved("gcse", "Number of instructions removed"); Statistic<> NumLoadRemoved("gcse", "Number of loads removed"); @@ -56,7 +58,6 @@ namespace { // createGCSEPass - The public interface to this file... FunctionPass *createGCSEPass() { return new GCSE(); } - // GCSE::runOnFunction - This is the main transformation entry point for a // function. // @@ -269,3 +270,5 @@ Instruction *GCSE::EliminateCSE(Instruction *I, Instruction *Other) { return Ret; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 1744fe41b2..0777a1e09f 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -26,6 +26,8 @@ #include "Support/Statistic.h" #include "Support/STLExtras.h" +namespace llvm { + namespace { Statistic<> NumRemoved ("indvars", "Number of aux indvars removed"); Statistic<> NumInserted("indvars", "Number of canonical indvars added"); @@ -217,3 +219,5 @@ namespace { Pass *createIndVarSimplifyPass() { return new InductionVariableSimplify(); } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 07736b57c2..8522b610e1 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -49,6 +49,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumCombined ("instcombine", "Number of insts combined"); Statistic<> NumConstProp("instcombine", "Number of constant folds"); @@ -2196,3 +2198,5 @@ bool InstCombiner::runOnFunction(Function &F) { Pass *createInstructionCombiningPass() { return new InstCombiner(); } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 0f582c1feb..be635dff35 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -44,6 +44,8 @@ #include "llvm/Assembly/Writer.h" #include +namespace llvm { + namespace { cl::opt DisablePromotion("disable-licm-promotion", cl::Hidden, @@ -466,3 +468,5 @@ void LICM::findPromotableValuesInLoop( } } } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/PRE.cpp b/lib/Transforms/Scalar/PRE.cpp index fad5789d5a..770cd44d75 100644 --- a/lib/Transforms/Scalar/PRE.cpp +++ b/lib/Transforms/Scalar/PRE.cpp @@ -36,10 +36,12 @@ #include "Support/Statistic.h" #include "Support/hash_set" +namespace llvm { + namespace { Statistic<> NumExprsEliminated("pre", "Number of expressions constantified"); Statistic<> NumRedundant ("pre", "Number of redundant exprs eliminated"); - Statistic<> NumInserted ("pre", "Number of expressions inserted"); + static Statistic<> NumInserted ("pre", "Number of expressions inserted"); struct PRE : public FunctionPass { virtual void getAnalysisUsage(AnalysisUsage &AU) const { @@ -630,3 +632,5 @@ bool PRE::ProcessExpression(Instruction *Expr) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/PiNodeInsertion.cpp b/lib/Transforms/Scalar/PiNodeInsertion.cpp index b5011af286..89ec20e069 100644 --- a/lib/Transforms/Scalar/PiNodeInsertion.cpp +++ b/lib/Transforms/Scalar/PiNodeInsertion.cpp @@ -42,6 +42,8 @@ #include "llvm/Support/CFG.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumInserted("pinodes", "Number of Pi nodes inserted"); @@ -182,3 +184,5 @@ bool PiNodeInserter::insertPiNodeFor(Value *V, BasicBlock *Succ, Value *Rep) { return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index befdcfec77..9e22ec4e7e 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -34,6 +34,8 @@ #include "Support/PostOrderIterator.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumLinear ("reassociate","Number of insts linearized"); Statistic<> NumChanged("reassociate","Number of insts reassociated"); @@ -58,6 +60,7 @@ namespace { RegisterOpt X("reassociate", "Reassociate expressions"); } +// Public interface to the Reassociate pass FunctionPass *createReassociatePass() { return new Reassociate(); } void Reassociate::BuildRankMap(Function &F) { @@ -291,3 +294,5 @@ bool Reassociate::runOnFunction(Function &F) { ValueRankMap.clear(); return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 01e3e26ab5..44a553a01b 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -33,6 +33,8 @@ #include #include +namespace llvm { + // InstVal class - This class represents the different lattice values that an // instruction may occupy. It is a simple class with value semantics. // @@ -253,7 +255,6 @@ private: // createSCCPPass - This is the public interface to this file... -// Pass *createSCCPPass() { return new SCCP(); } @@ -585,3 +586,5 @@ void SCCP::visitGetElementPtrInst(GetElementPtrInst &I) { markConstant(&I, ConstantExpr::getGetElementPtr(Ptr, Operands)); } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 9342a5cf40..d29119061d 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -32,6 +32,8 @@ #include "Support/Statistic.h" #include "Support/StringExtras.h" +namespace llvm { + namespace { Statistic<> NumReplaced("scalarrepl", "Number of allocas broken up"); Statistic<> NumPromoted("scalarrepl", "Number of allocas promoted"); @@ -61,6 +63,7 @@ namespace { RegisterOpt X("scalarrepl", "Scalar Replacement of Aggregates"); } +// Public interface to the ScalarReplAggregates pass Pass *createScalarReplAggregatesPass() { return new SROA(); } @@ -298,3 +301,5 @@ bool SROA::isSafeAllocaToPromote(AllocationInst *AI) { } return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/SimplifyCFG.cpp b/lib/Transforms/Scalar/SimplifyCFG.cpp index 224d6c5f9a..5a8d428153 100644 --- a/lib/Transforms/Scalar/SimplifyCFG.cpp +++ b/lib/Transforms/Scalar/SimplifyCFG.cpp @@ -26,6 +26,8 @@ #include "Support/Statistic.h" #include +namespace llvm { + namespace { Statistic<> NumSimpl("cfgsimplify", "Number of blocks simplified"); @@ -35,6 +37,7 @@ namespace { RegisterOpt X("simplifycfg", "Simplify the CFG"); } +// Public interface to the CFGSimplification pass FunctionPass *createCFGSimplificationPass() { return new CFGSimplifyPass(); } @@ -100,3 +103,5 @@ bool CFGSimplifyPass::runOnFunction(Function &F) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/SymbolStripping.cpp b/lib/Transforms/Scalar/SymbolStripping.cpp index 58395c55ab..9e058e7939 100644 --- a/lib/Transforms/Scalar/SymbolStripping.cpp +++ b/lib/Transforms/Scalar/SymbolStripping.cpp @@ -26,6 +26,8 @@ #include "llvm/SymbolTable.h" #include "llvm/Pass.h" +namespace llvm { + static bool StripSymbolTable(SymbolTable &SymTab) { bool RemovedSymbol = false; @@ -74,3 +76,5 @@ Pass *createSymbolStrippingPass() { Pass *createFullSymbolStrippingPass() { return new FullSymbolStripping(); } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index d0a7765818..07a3b1e492 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -31,6 +31,8 @@ #include "Support/Debug.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumEliminated("tailduplicate", "Number of unconditional branches eliminated"); @@ -53,6 +55,7 @@ namespace { RegisterOpt X("tailduplicate", "Tail Duplication"); } +// Public interface to the Tail Duplication pass Pass *createTailDuplicationPass() { return new TailDup(); } /// runOnFunction - Top level algorithm - Loop over each unconditional branch in @@ -339,3 +342,5 @@ Value *TailDup::GetValueOutBlock(BasicBlock *BB, Value *OrigVal, return GetValueInBlock(BB, OrigVal, ValueMap, OutValueMap); } + +} // End llvm namespace diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index d07f4e857e..dbe91a7940 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -33,6 +33,8 @@ #include "llvm/Pass.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumEliminated("tailcallelim", "Number of tail calls removed"); @@ -42,6 +44,7 @@ namespace { RegisterOpt X("tailcallelim", "Tail Call Elimination"); } +// Public interface to the TailCallElimination pass FunctionPass *createTailCallEliminationPass() { return new TailCallElim(); } @@ -105,3 +108,4 @@ bool TailCallElim::runOnFunction(Function &F) { return MadeChange; } +} // End llvm namespace diff --git a/lib/Transforms/TransformInternals.cpp b/lib/Transforms/TransformInternals.cpp index 3a1d51c3a0..b553f03a41 100644 --- a/lib/Transforms/TransformInternals.cpp +++ b/lib/Transforms/TransformInternals.cpp @@ -18,6 +18,8 @@ #include "llvm/Function.h" #include "llvm/iOther.h" +namespace llvm { + static const Type *getStructOffsetStep(const StructType *STy, uint64_t &Offset, std::vector &Indices, const TargetData &TD) { @@ -193,3 +195,5 @@ const Type *ConvertibleToGEP(const Type *Ty, Value *OffsetVal, return NextTy; } + +} // End llvm namespace diff --git a/lib/Transforms/TransformInternals.h b/lib/Transforms/TransformInternals.h index 4f92dc4eda..3b80146a27 100644 --- a/lib/Transforms/TransformInternals.h +++ b/lib/Transforms/TransformInternals.h @@ -22,6 +22,8 @@ #include #include +namespace llvm { + static inline int64_t getConstantValue(const ConstantInt *CPI) { return (int64_t)cast(CPI)->getRawValue(); } @@ -139,4 +141,6 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset, std::vector &Offsets, const TargetData &TD, bool StopEarly = true); +} // End llvm namespace + #endif diff --git a/lib/Transforms/Utils/BasicBlockUtils.cpp b/lib/Transforms/Utils/BasicBlockUtils.cpp index 22fd555a46..5fb5469332 100644 --- a/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -19,6 +19,8 @@ #include "llvm/Type.h" #include +namespace llvm { + // ReplaceInstWithValue - Replace all uses of an instruction (specified by BI) // with a value, then remove and delete the original instruction. // @@ -112,3 +114,5 @@ void RemoveSuccessor(TerminatorInst *TI, unsigned SuccNum) { if (NewTI) // If it's a different instruction, replace. ReplaceInstWithInst(TI, NewTI); } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index de59db2f9b..e8201cc391 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -25,6 +25,8 @@ #include "llvm/Support/CFG.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumBroken("break-crit-edges", "Number of blocks inserted"); @@ -168,3 +170,5 @@ bool SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P) { } return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/CloneFunction.cpp b/lib/Transforms/Utils/CloneFunction.cpp index e0312f2efb..d8aa9aebe4 100644 --- a/lib/Transforms/Utils/CloneFunction.cpp +++ b/lib/Transforms/Utils/CloneFunction.cpp @@ -19,6 +19,8 @@ #include "llvm/Function.h" #include "ValueMapper.h" +namespace llvm { + // RemapInstruction - Convert the instruction operands from referencing the // current values into those specified by ValueMap. // @@ -140,3 +142,5 @@ Function *CloneFunction(const Function *F, CloneFunctionInto(NewF, F, ValueMap, Returns); return NewF; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/CloneModule.cpp b/lib/Transforms/Utils/CloneModule.cpp index cc22c7214a..21a8675f07 100644 --- a/lib/Transforms/Utils/CloneModule.cpp +++ b/lib/Transforms/Utils/CloneModule.cpp @@ -19,6 +19,8 @@ #include "llvm/Constant.h" #include "ValueMapper.h" +namespace llvm { + /// CloneModule - Return an exact copy of the specified module. This is not as /// easy as it might seem because we have to worry about making copies of global /// variables and functions, and making their (initializers and references, @@ -88,3 +90,5 @@ Module *CloneModule(const Module *M) { return New; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/CloneTrace.cpp b/lib/Transforms/Utils/CloneTrace.cpp index 9d995464bf..990e54c783 100644 --- a/lib/Transforms/Utils/CloneTrace.cpp +++ b/lib/Transforms/Utils/CloneTrace.cpp @@ -20,6 +20,8 @@ #include "llvm/Function.h" +namespace llvm { + //Clones the trace (a vector of basic blocks) std::vector CloneTrace(const std::vector &origTrace) { @@ -86,3 +88,5 @@ std::vector CloneTrace(const std::vector &origTrace) //return new vector of basic blocks return clonedTrace; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/DemoteRegToStack.cpp b/lib/Transforms/Utils/DemoteRegToStack.cpp index bd605ca789..e35dca4de0 100644 --- a/lib/Transforms/Utils/DemoteRegToStack.cpp +++ b/lib/Transforms/Utils/DemoteRegToStack.cpp @@ -22,6 +22,8 @@ #include "llvm/Type.h" #include "Support/hash_set" +namespace llvm { + typedef hash_set PhiSet; typedef hash_set::iterator PhiSetIterator; @@ -160,3 +162,5 @@ AllocaInst* DemoteRegToStack(Instruction& X) { return XSlot; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/InlineFunction.cpp b/lib/Transforms/Utils/InlineFunction.cpp index 1481324330..265d5c419a 100644 --- a/lib/Transforms/Utils/InlineFunction.cpp +++ b/lib/Transforms/Utils/InlineFunction.cpp @@ -24,6 +24,8 @@ #include "llvm/Support/CallSite.h" #include "llvm/Transforms/Utils/Local.h" +namespace llvm { + bool InlineFunction(CallInst *CI) { return InlineFunction(CallSite(CI)); } bool InlineFunction(InvokeInst *II) { return InlineFunction(CallSite(II)); } @@ -278,3 +280,5 @@ bool InlineFunction(CallSite CS) { SimplifyCFG(AfterCallBB); return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/Linker.cpp b/lib/Transforms/Utils/Linker.cpp index 0be840fb6c..4bc78a4cde 100644 --- a/lib/Transforms/Utils/Linker.cpp +++ b/lib/Transforms/Utils/Linker.cpp @@ -23,6 +23,8 @@ #include "llvm/iOther.h" #include "llvm/Constants.h" +namespace llvm { + // Error - Simple wrapper function to conditionally assign to E and return true. // This just makes error return conditions a little bit simpler... // @@ -902,3 +904,4 @@ bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) { return false; } +} // End llvm namespace diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 2f9b07ca94..894699596e 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -17,6 +17,8 @@ #include "llvm/iOperators.h" #include "llvm/ConstantHandling.h" +namespace llvm { + //===----------------------------------------------------------------------===// // Local constant propagation... // @@ -180,3 +182,5 @@ bool dceInstruction(BasicBlock::iterator &BBI) { } return false; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index a1f86486b5..b999ed40cc 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -43,6 +43,8 @@ #include "Support/Statistic.h" #include "Support/DepthFirstIterator.h" +namespace llvm { + namespace { Statistic<> NumInserted("loopsimplify", "Number of pre-header blocks inserted"); @@ -82,7 +84,6 @@ namespace { const PassInfo *LoopSimplifyID = X.getPassInfo(); Pass *createLoopSimplifyPass() { return new LoopSimplify(); } - /// runOnFunction - Run down all loops in the CFG (recursively, but we could do /// it in any convenient order) inserting preheaders... /// @@ -566,3 +567,5 @@ void LoopSimplify::UpdateDomInfoForRevectoredPreds(BasicBlock *NewBB, } } } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index 96008881bb..eea800ad54 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -22,6 +22,8 @@ #include "llvm/Target/TargetData.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumLowered("lowerallocs", "Number of allocations lowered"); @@ -131,3 +133,5 @@ bool LowerAllocations::runOnBasicBlock(BasicBlock &BB) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 4885d96f19..ec97ca2040 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -23,6 +23,8 @@ #include "llvm/Constant.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumLowered("lowerinvoke", "Number of invoke & unwinds replaced"); @@ -37,6 +39,7 @@ namespace { X("lowerinvoke", "Lower invoke and unwind, for unwindless code generators"); } +// Public Interface To the LowerInvoke pass. FunctionPass *createLowerInvokePass() { return new LowerInvoke(); } // doInitialization - Make sure that there is a prototype for abort in the @@ -79,3 +82,5 @@ bool LowerInvoke::runOnFunction(Function &F) { } return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index a45192bb0c..1d0e47145a 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -23,6 +23,8 @@ #include "Support/Debug.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumLowered("lowerswitch", "Number of SwitchInst's replaced"); @@ -224,3 +226,5 @@ void LowerSwitch::processSwitchInst(SwitchInst *SI) { // We are now done with the switch instruction, delete it. delete SI; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/Mem2Reg.cpp b/lib/Transforms/Utils/Mem2Reg.cpp index d915155ed4..4d99280805 100644 --- a/lib/Transforms/Utils/Mem2Reg.cpp +++ b/lib/Transforms/Utils/Mem2Reg.cpp @@ -20,6 +20,8 @@ #include "llvm/Target/TargetData.h" #include "Support/Statistic.h" +namespace llvm { + namespace { Statistic<> NumPromoted("mem2reg", "Number of alloca's promoted"); @@ -78,3 +80,5 @@ bool PromotePass::runOnFunction(Function &F) { Pass *createPromoteMemoryToRegister() { return new PromotePass(); } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index f920718c3a..0859f69980 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -25,6 +25,8 @@ #include "llvm/Support/CFG.h" #include "Support/StringExtras.h" +namespace llvm { + /// isAllocaPromotable - Return true if this alloca is legal for promotion. /// This is true if there are only loads and stores to the alloca... /// @@ -459,3 +461,5 @@ void PromoteMemToReg(const std::vector &Allocas, if (Allocas.empty()) return; PromoteMem2Reg(Allocas, DT, DF, TD).run(); } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index a5f54b1326..158d9119ae 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -21,6 +21,8 @@ #include #include +namespace llvm { + // PropagatePredecessors - This gets "Succ" ready to have the predecessors from // "BB". This is a little tricky because "Succ" has PHI nodes, which need to // have extra slots added to them to hold the merge edges from BB's @@ -298,3 +300,5 @@ bool SimplifyCFG(BasicBlock *BB) { return Changed; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp index 180871b093..2591ffd6d7 100644 --- a/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp +++ b/lib/Transforms/Utils/UnifyFunctionExitNodes.cpp @@ -22,6 +22,8 @@ #include "llvm/iPHINode.h" #include "llvm/Type.h" +namespace llvm { + static RegisterOpt X("mergereturn", "Unify function exit nodes"); @@ -112,3 +114,5 @@ bool UnifyFunctionExitNodes::runOnFunction(Function &F) { ReturnBlock = NewRetBlock; return true; } + +} // End llvm namespace diff --git a/lib/Transforms/Utils/ValueMapper.cpp b/lib/Transforms/Utils/ValueMapper.cpp index 6590498bbc..248ebace7a 100644 --- a/lib/Transforms/Utils/ValueMapper.cpp +++ b/lib/Transforms/Utils/ValueMapper.cpp @@ -16,6 +16,8 @@ #include "llvm/Constants.h" #include "llvm/Instruction.h" +namespace llvm { + Value *MapValue(const Value *V, std::map &VM) { Value *&VMSlot = VM[V]; if (VMSlot) return VMSlot; // Does it exist in the map yet? @@ -105,3 +107,4 @@ Value *MapValue(const Value *V, std::map &VM) { return 0; } +} // End llvm namespace diff --git a/lib/Transforms/Utils/ValueMapper.h b/lib/Transforms/Utils/ValueMapper.h index 8264ade108..e67b3261db 100644 --- a/lib/Transforms/Utils/ValueMapper.h +++ b/lib/Transforms/Utils/ValueMapper.h @@ -16,8 +16,13 @@ #define LIB_TRANSFORMS_UTILS_VALUE_MAPPER_H #include + +namespace llvm { + class Value; Value *MapValue(const Value *V, std::map &VM); +} // End llvm namespace + #endif diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index c9c4dde7e8..67ccdd0f8d 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -33,6 +33,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + static RegisterPass X("printm", "Print module to stderr",PassInfo::Analysis|PassInfo::Optimization); static RegisterPass @@ -1052,3 +1054,5 @@ CachedWriter &CachedWriter::operator<<(const Value *V) { } return *this; } + +} // End llvm namespace diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 2458cda203..63a722b33e 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -22,6 +22,8 @@ #include "SymbolTableListTraitsImpl.h" #include +namespace llvm { + // DummyInst - An instance of this class is used to mark the end of the // instruction list. This is not a real instruction. // @@ -141,7 +143,7 @@ void BasicBlock::dropAllReferences() { // bool BasicBlock::hasConstantReferences() const { for (use_const_iterator I = use_begin(), E = use_end(); I != E; ++I) - if (::isa((Value*)*I)) + if (isa((Value*)*I)) return true; return false; @@ -263,3 +265,5 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I, const std::string &BBName) { } return New; } + +} // End llvm namespace diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp index 32b9ebba74..7fb7a05e55 100644 --- a/lib/VMCore/ConstantFold.cpp +++ b/lib/VMCore/ConstantFold.cpp @@ -17,6 +17,8 @@ #include "llvm/DerivedTypes.h" #include +namespace llvm { + AnnotationID ConstRules::AID(AnnotationManager::getID("opt::ConstRules", &ConstRules::find)); @@ -638,3 +640,5 @@ ConstRules *ConstRules::getConstantExprRules() { static EmptyRules CERules; return &CERules; } + +} // End llvm namespace diff --git a/lib/VMCore/ConstantFold.h b/lib/VMCore/ConstantFold.h index a27283c440..a0a01e5306 100644 --- a/lib/VMCore/ConstantFold.h +++ b/lib/VMCore/ConstantFold.h @@ -42,6 +42,9 @@ #include "llvm/Constants.h" #include "llvm/Type.h" + +namespace llvm { + class PointerType; //===----------------------------------------------------------------------===// @@ -244,4 +247,7 @@ Constant *ConstantFoldShiftInstruction(unsigned Opcode, const Constant *V1, const Constant *V2); Constant *ConstantFoldGetElementPtr(const Constant *C, const std::vector &IdxList); + +} // End llvm namespace + #endif diff --git a/lib/VMCore/ConstantFolding.h b/lib/VMCore/ConstantFolding.h index a27283c440..a0a01e5306 100644 --- a/lib/VMCore/ConstantFolding.h +++ b/lib/VMCore/ConstantFolding.h @@ -42,6 +42,9 @@ #include "llvm/Constants.h" #include "llvm/Type.h" + +namespace llvm { + class PointerType; //===----------------------------------------------------------------------===// @@ -244,4 +247,7 @@ Constant *ConstantFoldShiftInstruction(unsigned Opcode, const Constant *V1, const Constant *V2); Constant *ConstantFoldGetElementPtr(const Constant *C, const std::vector &IdxList); + +} // End llvm namespace + #endif diff --git a/lib/VMCore/ConstantRange.cpp b/lib/VMCore/ConstantRange.cpp index a9e1204de5..e180f12a1a 100644 --- a/lib/VMCore/ConstantRange.cpp +++ b/lib/VMCore/ConstantRange.cpp @@ -26,6 +26,8 @@ #include "llvm/Instruction.h" #include "llvm/ConstantHandling.h" +namespace llvm { + /// Initialize a full (the default) or empty set for the specified type. /// ConstantRange::ConstantRange(const Type *Ty, bool Full) { @@ -248,3 +250,5 @@ void ConstantRange::print(std::ostream &OS) const { void ConstantRange::dump() const { print(std::cerr); } + +} // End llvm namespace diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 28cc9d24e0..527eff5490 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -20,6 +20,8 @@ #include "Support/StringExtras.h" #include +namespace llvm { + ConstantBool *ConstantBool::True = new ConstantBool(true); ConstantBool *ConstantBool::False = new ConstantBool(false); @@ -1029,3 +1031,5 @@ unsigned Constant::mutateReferences(Value *OldV, Value *NewV) { return NumReplaced; } } + +} // End llvm namespace diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index c3bce78b5a..cad66853c9 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -20,6 +20,8 @@ #include "Support/DepthFirstIterator.h" #include "Support/SetOperations.h" +namespace llvm { + //===----------------------------------------------------------------------===// // DominatorSet Implementation //===----------------------------------------------------------------------===// @@ -358,3 +360,5 @@ void DominanceFrontierBase::print(std::ostream &o) const { o << " is:\t" << I->second << "\n"; } } + +} // End llvm namespace diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index f47ecea7af..364cc6f733 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -19,6 +19,8 @@ #include "Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" +namespace llvm { + BasicBlock *ilist_traits::createNode() { BasicBlock *Ret = new BasicBlock(); // This should not be garbage monitored. @@ -158,7 +160,7 @@ void Function::dropAllReferences() { } /// getIntrinsicID - This method returns the ID number of the specified -/// function, or LLVMIntrinsic::not_intrinsic if the function is not an +/// function, or Intrinsic::not_intrinsic if the function is not an /// intrinsic, or if the pointer is null. This value is always defined to be /// zero to allow easy checking for whether a function is intrinsic or not. The /// particular intrinsic functions which correspond to this value are defined in @@ -176,21 +178,21 @@ unsigned Function::getIntrinsicID() const { std::string name; // The name of the intrinsic unsigned id; // Its ID number } alpha_intrinsics[] = { - { "llvm.alpha.ctlz", LLVMIntrinsic::alpha_ctlz }, - { "llvm.alpha.cttz", LLVMIntrinsic::alpha_cttz }, - { "llvm.alpha.ctpop", LLVMIntrinsic::alpha_ctpop }, - { "llvm.alpha.umulh", LLVMIntrinsic::alpha_umulh }, - { "llvm.alpha.vecop", LLVMIntrinsic::alpha_vecop }, - { "llvm.alpha.pup", LLVMIntrinsic::alpha_pup }, - { "llvm.alpha.bytezap", LLVMIntrinsic::alpha_bytezap }, - { "llvm.alpha.bytemanip", LLVMIntrinsic::alpha_bytemanip }, - { "llvm.alpha.dfp_bop", LLVMIntrinsic::alpha_dfpbop }, - { "llvm.alpha.dfp_uop", LLVMIntrinsic::alpha_dfpuop }, - { "llvm.alpha.unordered", LLVMIntrinsic::alpha_unordered }, - { "llvm.alpha.uqtodfp", LLVMIntrinsic::alpha_uqtodfp }, - { "llvm.alpha.uqtosfp", LLVMIntrinsic::alpha_uqtosfp }, - { "llvm.alpha.dfptosq", LLVMIntrinsic::alpha_dfptosq }, - { "llvm.alpha.sfptosq", LLVMIntrinsic::alpha_sfptosq }, + { "llvm.alpha.ctlz", Intrinsic::alpha_ctlz }, + { "llvm.alpha.cttz", Intrinsic::alpha_cttz }, + { "llvm.alpha.ctpop", Intrinsic::alpha_ctpop }, + { "llvm.alpha.umulh", Intrinsic::alpha_umulh }, + { "llvm.alpha.vecop", Intrinsic::alpha_vecop }, + { "llvm.alpha.pup", Intrinsic::alpha_pup }, + { "llvm.alpha.bytezap", Intrinsic::alpha_bytezap }, + { "llvm.alpha.bytemanip", Intrinsic::alpha_bytemanip }, + { "llvm.alpha.dfp_bop", Intrinsic::alpha_dfpbop }, + { "llvm.alpha.dfp_uop", Intrinsic::alpha_dfpuop }, + { "llvm.alpha.unordered", Intrinsic::alpha_unordered }, + { "llvm.alpha.uqtodfp", Intrinsic::alpha_uqtodfp }, + { "llvm.alpha.uqtosfp", Intrinsic::alpha_uqtosfp }, + { "llvm.alpha.dfptosq", Intrinsic::alpha_dfptosq }, + { "llvm.alpha.sfptosq", Intrinsic::alpha_sfptosq }, }; const unsigned num_alpha_intrinsics = sizeof(alpha_intrinsics) / sizeof(*alpha_intrinsics); @@ -204,17 +206,17 @@ unsigned Function::getIntrinsicID() const { return alpha_intrinsics[i].id; break; case 'l': - if (getName() == "llvm.longjmp") return LLVMIntrinsic::longjmp; + if (getName() == "llvm.longjmp") return Intrinsic::longjmp; break; case 's': - if (getName() == "llvm.setjmp") return LLVMIntrinsic::setjmp; - if (getName() == "llvm.sigsetjmp") return LLVMIntrinsic::sigsetjmp; - if (getName() == "llvm.siglongjmp") return LLVMIntrinsic::siglongjmp; + if (getName() == "llvm.setjmp") return Intrinsic::setjmp; + if (getName() == "llvm.sigsetjmp") return Intrinsic::sigsetjmp; + if (getName() == "llvm.siglongjmp") return Intrinsic::siglongjmp; break; case 'v': - if (getName() == "llvm.va_copy") return LLVMIntrinsic::va_copy; - if (getName() == "llvm.va_end") return LLVMIntrinsic::va_end; - if (getName() == "llvm.va_start") return LLVMIntrinsic::va_start; + if (getName() == "llvm.va_copy") return Intrinsic::va_copy; + if (getName() == "llvm.va_end") return Intrinsic::va_end; + if (getName() == "llvm.va_start") return Intrinsic::va_start; break; } // The "llvm." namespace is reserved! @@ -257,3 +259,5 @@ void GlobalVariable::setName(const std::string &name, SymbolTable *ST) { Value::setName(name); if (P && getName() != "") P->getSymbolTable().insert(this); } + +} // End llvm namespace diff --git a/lib/VMCore/InstrTypes.cpp b/lib/VMCore/InstrTypes.cpp index ba1d4b7160..17e16fa733 100644 --- a/lib/VMCore/InstrTypes.cpp +++ b/lib/VMCore/InstrTypes.cpp @@ -19,6 +19,8 @@ #include "llvm/Type.h" #include // find +namespace llvm { + //===----------------------------------------------------------------------===// // TerminatorInst Class //===----------------------------------------------------------------------===// @@ -56,3 +58,5 @@ Value *PHINode::removeIncomingValue(unsigned Idx, bool DeletePHIIfEmpty) { } return Removed; } + +} // End llvm namespace diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index b72656bdc2..9ca2fedbf4 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -16,6 +16,8 @@ #include "llvm/Type.h" #include "Support/LeakDetector.h" +namespace llvm { + Instruction::Instruction(const Type *ty, unsigned it, const std::string &Name, Instruction *InsertBefore) : User(ty, Value::InstructionVal, Name) { @@ -163,3 +165,5 @@ bool Instruction::isTrapping(unsigned op) { return false; } } + +} // End llvm namespace diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index 24c946ab6e..ffb081a998 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -15,6 +15,8 @@ #include "llvm/Value.h" #include +namespace llvm { + // Lazily allocate set so that release build doesn't have to do anything. static std::set *Objects = 0; static std::set *LLVMObjects = 0; @@ -87,3 +89,5 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) { Objects = 0; LLVMObjects = 0; } } + +} // End llvm namespace diff --git a/lib/VMCore/Linker.cpp b/lib/VMCore/Linker.cpp index 0be840fb6c..4bc78a4cde 100644 --- a/lib/VMCore/Linker.cpp +++ b/lib/VMCore/Linker.cpp @@ -23,6 +23,8 @@ #include "llvm/iOther.h" #include "llvm/Constants.h" +namespace llvm { + // Error - Simple wrapper function to conditionally assign to E and return true. // This just makes error return conditions a little bit simpler... // @@ -902,3 +904,4 @@ bool LinkModules(Module *Dest, const Module *Src, std::string *ErrorMsg) { return false; } +} // End llvm namespace diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp index 44c697d3d8..567fe05e32 100644 --- a/lib/VMCore/Mangler.cpp +++ b/lib/VMCore/Mangler.cpp @@ -16,6 +16,8 @@ #include "llvm/Type.h" #include "Support/StringExtras.h" +namespace llvm { + static char HexDigit(int V) { return V < 10 ? V+'0' : V+'A'-10; } @@ -99,3 +101,4 @@ Mangler::Mangler(Module &m, bool addUnderscorePrefix) FoundNames.insert(I->getName()); // Otherwise, keep track of name } +} // End llvm namespace diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index e62c83f67a..6b15929506 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -22,6 +22,8 @@ #include #include +namespace llvm { + Function *ilist_traits::createNode() { FunctionType *FTy = FunctionType::get(Type::VoidTy, std::vector(), false); @@ -307,3 +309,5 @@ void Module::mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) { delete Ref; } } + +} // End llvm namespace diff --git a/lib/VMCore/ModuleProvider.cpp b/lib/VMCore/ModuleProvider.cpp index ba324d0894..8be033622d 100644 --- a/lib/VMCore/ModuleProvider.cpp +++ b/lib/VMCore/ModuleProvider.cpp @@ -14,6 +14,8 @@ #include "llvm/ModuleProvider.h" #include "llvm/Module.h" +namespace llvm { + /// ctor - always have a valid Module /// ModuleProvider::ModuleProvider() : TheModule(0) { } @@ -35,3 +37,5 @@ Module* ModuleProvider::materializeModule() { return TheModule; } + +} // End llvm namespace diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 96ad3c94e9..b387fc3524 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -21,6 +21,8 @@ #include "Support/TypeInfo.h" #include +namespace llvm { + // IncludeFile - Stub function used to help linking out. IncludeFile::IncludeFile(void*) {} @@ -467,3 +469,5 @@ void PassRegistrationListener::enumeratePasses() { E = PassInfoMap->end(); I != E; ++I) passEnumerate(I->second); } + +} // End llvm namespace diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index a715f5148e..c5cac1d7fe 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -28,6 +28,9 @@ #include "Support/Timer.h" #include #include + +namespace llvm { + class Annotable; //===----------------------------------------------------------------------===// @@ -792,4 +795,6 @@ inline bool PassManagerTraits::doFinalization(Module &M) { return Changed; } +} // End llvm namespace + #endif diff --git a/lib/VMCore/SlotCalculator.cpp b/lib/VMCore/SlotCalculator.cpp index aef71763c4..c6e44e8266 100644 --- a/lib/VMCore/SlotCalculator.cpp +++ b/lib/VMCore/SlotCalculator.cpp @@ -27,6 +27,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + #if 0 #define SC_DEBUG(X) std::cerr << X #else @@ -361,3 +363,5 @@ int SlotCalculator::doInsertValue(const Value *D) { SC_DEBUG("]\n"); return (int)DestSlot; } + +} // End llvm namespace diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index 9452cdfec4..834d619898 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -17,6 +17,8 @@ #include "Support/StringExtras.h" #include +namespace llvm { + #define DEBUG_SYMBOL_TABLE 0 #define DEBUG_ABSTYPE 0 @@ -354,3 +356,5 @@ void SymbolTable::dump() const { std::cout << "Symbol table dump:\n"; for_each(begin(), end(), DumpPlane); } + +} // End llvm namespace diff --git a/lib/VMCore/SymbolTableListTraitsImpl.h b/lib/VMCore/SymbolTableListTraitsImpl.h index aec7520cef..22d2e1d6c7 100644 --- a/lib/VMCore/SymbolTableListTraitsImpl.h +++ b/lib/VMCore/SymbolTableListTraitsImpl.h @@ -19,6 +19,8 @@ #include "llvm/SymbolTableListTraits.h" #include "llvm/SymbolTable.h" +namespace llvm { + template void SymbolTableListTraits @@ -94,4 +96,6 @@ void SymbolTableListTraits } } +} // End llvm namespace + #endif diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index ed468022cb..9e33303b7f 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -18,6 +18,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + // DEBUG_MERGE_TYPES - Enable this #define to see how and when derived types are // created and later destroyed, all in an effort to make sure that there is only // a single canonical version of a type. @@ -1114,3 +1116,4 @@ void PointerType::typeBecameConcrete(const DerivedType *AbsTy) { refineAbstractType(AbsTy, AbsTy); } +} // End llvm namespace diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index 709ae3e9ae..f389eb0132 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -18,6 +18,8 @@ #include "Support/LeakDetector.h" #include +namespace llvm { + //===----------------------------------------------------------------------===// // Value Class //===----------------------------------------------------------------------===// @@ -107,3 +109,5 @@ void User::replaceUsesOfWith(Value *From, Value *To) { setOperand(i, To); // Fix it now... } } + +} // End llvm namespace diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 14c14f3c08..1362eaab0f 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -57,6 +57,8 @@ #include "Support/STLExtras.h" #include +namespace llvm { + namespace { // Anonymous namespace for class struct Verifier : public FunctionPass, InstVisitor { @@ -149,7 +151,7 @@ namespace { // Anonymous namespace for class void visitReturnInst(ReturnInst &RI); void visitUserOp1(Instruction &I); void visitUserOp2(Instruction &I) { visitUserOp1(I); } - void visitIntrinsicFunctionCall(LLVMIntrinsic::ID ID, CallInst &CI); + void visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI); // CheckFailed - A check failed, so print out the condition and the message // that failed. This provides a nice place to put a breakpoint if you want @@ -168,7 +170,6 @@ namespace { // Anonymous namespace for class }; RegisterPass X("verify", "Module Verifier"); -} // Assert - We know that cond should be true, if not print an error message. #define Assert(C, M) \ @@ -368,7 +369,7 @@ void Verifier::visitCallInst(CallInst &CI) { CI.getOperand(i+1), FTy->getParamType(i)); if (Function *F = CI.getCalledFunction()) - if (LLVMIntrinsic::ID ID = (LLVMIntrinsic::ID)F->getIntrinsicID()) + if (Intrinsic::ID ID = (Intrinsic::ID)F->getIntrinsicID()) visitIntrinsicFunctionCall(ID, CI); visitInstruction(CI); @@ -500,7 +501,7 @@ void Verifier::visitInstruction(Instruction &I) { } /// visitIntrinsicFunction - Allow intrinsics to be verified in different ways. -void Verifier::visitIntrinsicFunctionCall(LLVMIntrinsic::ID ID, CallInst &CI) { +void Verifier::visitIntrinsicFunctionCall(Intrinsic::ID ID, CallInst &CI) { Function *IF = CI.getCalledFunction(); const FunctionType *FT = IF->getFunctionType(); Assert1(IF->isExternal(), "Intrinsic functions should never be defined!", IF); @@ -509,37 +510,37 @@ void Verifier::visitIntrinsicFunctionCall(LLVMIntrinsic::ID ID, CallInst &CI) { // FIXME: this should check the return type of each intrinsic as well, also // arguments! switch (ID) { - case LLVMIntrinsic::va_start: + case Intrinsic::va_start: Assert1(CI.getParent()->getParent()->getFunctionType()->isVarArg(), "llvm.va_start intrinsic may only occur in function with variable" " args!", &CI); NumArgs = 0; break; - case LLVMIntrinsic::va_end: NumArgs = 1; break; - case LLVMIntrinsic::va_copy: NumArgs = 1; break; + case Intrinsic::va_end: NumArgs = 1; break; + case Intrinsic::va_copy: NumArgs = 1; break; - case LLVMIntrinsic::setjmp: NumArgs = 1; break; - case LLVMIntrinsic::longjmp: NumArgs = 2; break; - case LLVMIntrinsic::sigsetjmp: NumArgs = 2; break; - case LLVMIntrinsic::siglongjmp: NumArgs = 2; break; + case Intrinsic::setjmp: NumArgs = 1; break; + case Intrinsic::longjmp: NumArgs = 2; break; + case Intrinsic::sigsetjmp: NumArgs = 2; break; + case Intrinsic::siglongjmp: NumArgs = 2; break; - case LLVMIntrinsic::alpha_ctlz: NumArgs = 1; break; - case LLVMIntrinsic::alpha_cttz: NumArgs = 1; break; - case LLVMIntrinsic::alpha_ctpop: NumArgs = 1; break; - case LLVMIntrinsic::alpha_umulh: NumArgs = 2; break; - case LLVMIntrinsic::alpha_vecop: NumArgs = 4; break; - case LLVMIntrinsic::alpha_pup: NumArgs = 3; break; - case LLVMIntrinsic::alpha_bytezap: NumArgs = 2; break; - case LLVMIntrinsic::alpha_bytemanip: NumArgs = 3; break; - case LLVMIntrinsic::alpha_dfpbop: NumArgs = 3; break; - case LLVMIntrinsic::alpha_dfpuop: NumArgs = 2; break; - case LLVMIntrinsic::alpha_unordered: NumArgs = 2; break; - case LLVMIntrinsic::alpha_uqtodfp: NumArgs = 2; break; - case LLVMIntrinsic::alpha_uqtosfp: NumArgs = 2; break; - case LLVMIntrinsic::alpha_dfptosq: NumArgs = 2; break; - case LLVMIntrinsic::alpha_sfptosq: NumArgs = 2; break; - - case LLVMIntrinsic::not_intrinsic: + case Intrinsic::alpha_ctlz: NumArgs = 1; break; + case Intrinsic::alpha_cttz: NumArgs = 1; break; + case Intrinsic::alpha_ctpop: NumArgs = 1; break; + case Intrinsic::alpha_umulh: NumArgs = 2; break; + case Intrinsic::alpha_vecop: NumArgs = 4; break; + case Intrinsic::alpha_pup: NumArgs = 3; break; + case Intrinsic::alpha_bytezap: NumArgs = 2; break; + case Intrinsic::alpha_bytemanip: NumArgs = 3; break; + case Intrinsic::alpha_dfpbop: NumArgs = 3; break; + case Intrinsic::alpha_dfpuop: NumArgs = 2; break; + case Intrinsic::alpha_unordered: NumArgs = 2; break; + case Intrinsic::alpha_uqtodfp: NumArgs = 2; break; + case Intrinsic::alpha_uqtosfp: NumArgs = 2; break; + case Intrinsic::alpha_dfptosq: NumArgs = 2; break; + case Intrinsic::alpha_sfptosq: NumArgs = 2; break; + + case Intrinsic::not_intrinsic: assert(0 && "Invalid intrinsic!"); NumArgs = 0; break; } @@ -548,6 +549,7 @@ void Verifier::visitIntrinsicFunctionCall(LLVMIntrinsic::ID ID, CallInst &CI) { "Illegal # arguments for intrinsic function!", IF); } +} // End anonymous namespace //===----------------------------------------------------------------------===// // Implement the public interfaces to this file... @@ -585,3 +587,5 @@ bool verifyModule(const Module &M) { PM.run((Module&)M); return V->Broken; } + +} // End llvm namespace diff --git a/lib/VMCore/iBranch.cpp b/lib/VMCore/iBranch.cpp index bcba7145cc..59dc303d70 100644 --- a/lib/VMCore/iBranch.cpp +++ b/lib/VMCore/iBranch.cpp @@ -16,6 +16,8 @@ #include "llvm/BasicBlock.h" #include "llvm/Type.h" +namespace llvm { + BranchInst::BranchInst(BasicBlock *True, BasicBlock *False, Value *Cond, Instruction *InsertBefore) : TerminatorInst(Instruction::Br, InsertBefore) { @@ -49,3 +51,5 @@ BranchInst::BranchInst(const BranchInst &BI) : TerminatorInst(Instruction::Br) { Operands.push_back(Use(BI.Operands[2], this)); } } + +} // End llvm namespace diff --git a/lib/VMCore/iCall.cpp b/lib/VMCore/iCall.cpp index b99c9e7bb3..c385afc778 100644 --- a/lib/VMCore/iCall.cpp +++ b/lib/VMCore/iCall.cpp @@ -17,6 +17,8 @@ #include "llvm/DerivedTypes.h" #include "llvm/Function.h" +namespace llvm { + //===----------------------------------------------------------------------===// // CallInst Implementation //===----------------------------------------------------------------------===// @@ -144,8 +146,12 @@ Function *InvokeInst::getCalledFunction() { return 0; } +} // End llvm namespace + #include "llvm/Support/CallSite.h" +namespace llvm { + Function *CallSite::getCalledFunction() const { Value *Callee = getCalledValue(); if (Function *F = dyn_cast(Callee)) @@ -155,3 +161,4 @@ Function *CallSite::getCalledFunction() const { return 0; } +} // End llvm namespace diff --git a/lib/VMCore/iMemory.cpp b/lib/VMCore/iMemory.cpp index 75309ad8dc..c1a06576cd 100644 --- a/lib/VMCore/iMemory.cpp +++ b/lib/VMCore/iMemory.cpp @@ -15,6 +15,8 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" +using namespace llvm; + AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy, const std::string &Name, Instruction *InsertBef) : Instruction(PointerType::get(Ty), iTy, Name, InsertBef) { diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp index d893290198..79fac335fe 100644 --- a/lib/VMCore/iOperators.cpp +++ b/lib/VMCore/iOperators.cpp @@ -16,6 +16,8 @@ #include "llvm/Constants.h" #include "llvm/BasicBlock.h" +namespace llvm { + //===----------------------------------------------------------------------===// // BinaryOperator Class //===----------------------------------------------------------------------===// @@ -194,3 +196,5 @@ Instruction::BinaryOps SetCondInst::getSwappedCondition(BinaryOps Opcode) { case SetLE: return SetGE; } } + +} // End llvm namespace diff --git a/lib/VMCore/iSwitch.cpp b/lib/VMCore/iSwitch.cpp index e6a4f48ef4..4386b7b837 100644 --- a/lib/VMCore/iSwitch.cpp +++ b/lib/VMCore/iSwitch.cpp @@ -14,6 +14,8 @@ #include "llvm/iTerminators.h" #include "llvm/BasicBlock.h" +namespace llvm { + SwitchInst::SwitchInst(Value *V, BasicBlock *DefaultDest, Instruction *InsertBefore) : TerminatorInst(Instruction::Switch, InsertBefore) { @@ -48,3 +50,5 @@ void SwitchInst::removeCase(unsigned idx) { assert(idx*2 < Operands.size() && "Successor index out of range!!!"); Operands.erase(Operands.begin()+idx*2, Operands.begin()+(idx+1)*2); } + +} // End llvm namespace diff --git a/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp b/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp index 1d06c2d0dd..a1b68449f3 100644 --- a/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp +++ b/projects/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp @@ -12,6 +12,8 @@ #include "llvm/Instructions.h" #include "llvm/Bytecode/Writer.h" +using namespace llvm; + int main() { // Create the "module" or "program" or "translation unit" to hold the // function diff --git a/projects/SmallExamples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp b/projects/SmallExamples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp index 1d06c2d0dd..a1b68449f3 100644 --- a/projects/SmallExamples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp +++ b/projects/SmallExamples/ModuleMaker/tools/ModuleMaker/ModuleMaker.cpp @@ -12,6 +12,8 @@ #include "llvm/Instructions.h" #include "llvm/Bytecode/Writer.h" +using namespace llvm; + int main() { // Create the "module" or "program" or "translation unit" to hold the // function diff --git a/tools/analyze/AnalysisWrappers.cpp b/tools/analyze/AnalysisWrappers.cpp index 6c4c99f5a3..a9b9cd0470 100644 --- a/tools/analyze/AnalysisWrappers.cpp +++ b/tools/analyze/AnalysisWrappers.cpp @@ -26,6 +26,8 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Support/InstIterator.h" +using namespace llvm; + namespace { struct InstForestHelper : public FunctionPass { Function *F; diff --git a/tools/analyze/GraphPrinters.cpp b/tools/analyze/GraphPrinters.cpp index 34c937f0d4..6d2750f5e2 100644 --- a/tools/analyze/GraphPrinters.cpp +++ b/tools/analyze/GraphPrinters.cpp @@ -20,6 +20,8 @@ #include "llvm/Analysis/CallGraph.h" #include +namespace llvm { + template static void WriteGraphToFile(std::ostream &O, const std::string &GraphName, const GraphType >) { @@ -72,3 +74,5 @@ namespace { RegisterAnalysis P2("print-callgraph", "Print Call Graph to 'dot' file"); }; + +} // End llvm namespace diff --git a/tools/analyze/PrintSCC.cpp b/tools/analyze/PrintSCC.cpp index 3459381158..ce89fff90e 100644 --- a/tools/analyze/PrintSCC.cpp +++ b/tools/analyze/PrintSCC.cpp @@ -31,6 +31,8 @@ #include "llvm/Support/CFG.h" #include "Support/SCCIterator.h" +namespace llvm { + namespace { struct CFGSCC : public FunctionPass { bool runOnFunction(Function& func); @@ -101,3 +103,5 @@ bool CallGraphSCC::run(Module &M) { return true; } + +} // End llvm namespace diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 836b6aa8d7..3e1e51600e 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -26,6 +26,7 @@ #include "Support/Timer.h" #include +using namespace llvm; struct ModulePassPrinter : public Pass { const PassInfo *PassToPrint; diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index f0fb785db9..12843588c8 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -23,6 +23,8 @@ #include "Support/FileUtilities.h" #include +using namespace llvm; + // Anonymous namespace to define command line options for debugging. // namespace { @@ -36,6 +38,8 @@ namespace { "(for miscompilation detection)")); } +namespace llvm { + /// getPassesString - Turn a list of passes into a string which indicates the /// command line options that must be passed to add the passes. /// @@ -179,3 +183,5 @@ void BugDriver::PrintFunctionList(const std::vector &Funcs) { } std::cout << std::flush; } + +} // End llvm namespace diff --git a/tools/bugpoint/BugDriver.h b/tools/bugpoint/BugDriver.h index e1af721a75..af04a7d61a 100644 --- a/tools/bugpoint/BugDriver.h +++ b/tools/bugpoint/BugDriver.h @@ -19,6 +19,8 @@ #include #include +namespace llvm { + class PassInfo; class Module; class Function; @@ -207,4 +209,6 @@ std::string getPassesString(const std::vector &Passes); // void DeleteFunctionBody(Function *F); +} // End llvm namespace + #endif diff --git a/tools/bugpoint/CodeGeneratorBug.cpp b/tools/bugpoint/CodeGeneratorBug.cpp index 41df79a110..b24620ea14 100644 --- a/tools/bugpoint/CodeGeneratorBug.cpp +++ b/tools/bugpoint/CodeGeneratorBug.cpp @@ -33,6 +33,8 @@ #include #include +namespace llvm { + extern cl::list InputArgv; class ReduceMisCodegenFunctions : public ListReducer { @@ -408,3 +410,5 @@ bool BugDriver::debugCodeGenerator() { return false; } + +} // End llvm namespace diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index 0b2851f220..8c29ea226a 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -29,6 +29,8 @@ #include #include +namespace llvm { + class DebugCrashes : public ListReducer { BugDriver &BD; public: @@ -397,3 +399,5 @@ bool BugDriver::debugCrash() { return false; } + +} // End llvm namespace diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 596aeb95a8..9a3bd55055 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -30,6 +30,8 @@ BUGPOINT NOTES: #include #include +using namespace llvm; + namespace { // OutputType - Allow the user to specify the way code should be run, to test // for miscompilation. @@ -58,6 +60,8 @@ namespace { "into executing programs")); } +namespace llvm { + // Anything specified after the --args option are taken as arguments to the // program being debugged. cl::list @@ -232,3 +236,5 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile, bool BugDriver::isExecutingJIT() { return InterpreterSel == RunJIT; } + +} // End llvm namespace diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index 38e25864e4..4c671be62f 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -25,8 +25,15 @@ #include "llvm/Target/TargetData.h" #include "Support/CommandLine.h" + +namespace llvm { + bool DisableSimplifyCFG = false; +} // End llvm namespace + +using namespace llvm; + namespace { cl::opt NoADCE("disable-adce", @@ -39,6 +46,8 @@ namespace { cl::desc("Do not use the -simplifycfg pass to reduce testcases")); } +namespace llvm { + /// deleteInstructionFromProgram - This method clones the current Program and /// deletes the specified instruction from the cloned module. It then runs a /// series of cleanup passes (ADCE and SimplifyCFG) to eliminate any code which @@ -125,3 +134,5 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) { } return M; } + +} // End llvm namespace diff --git a/tools/bugpoint/ListReducer.h b/tools/bugpoint/ListReducer.h index 0ab2ef9927..0ad24065cf 100644 --- a/tools/bugpoint/ListReducer.h +++ b/tools/bugpoint/ListReducer.h @@ -17,6 +17,8 @@ #include +namespace llvm { + template struct ListReducer { enum TestResult { @@ -109,4 +111,6 @@ struct ListReducer { } }; +} // End llvm namespace + #endif diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 5ec8b1543e..1fb46a62bc 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -19,6 +19,8 @@ #include "llvm/Transforms/Utils/Linker.h" #include "Support/FileUtilities.h" +namespace llvm { + class ReduceMiscompilingPasses : public ListReducer { BugDriver &BD; public: @@ -308,3 +310,5 @@ bool BugDriver::debugMiscompilation() { return false; } + +} // End llvm namespace diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 600a25ad72..af9d1e5a94 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -26,6 +26,8 @@ #include #include +namespace llvm { + /// writeProgramToFile - This writes the current "Program" to the named bytecode /// file. If an error occurs, true is returned. /// @@ -159,3 +161,5 @@ bool BugDriver::runPasses(const std::vector &Passes, // Was the child successful? return !ExitedOK; } + +} // End llvm namespace diff --git a/tools/bugpoint/TestPasses.cpp b/tools/bugpoint/TestPasses.cpp index af5c045788..ee2c0d7248 100644 --- a/tools/bugpoint/TestPasses.cpp +++ b/tools/bugpoint/TestPasses.cpp @@ -18,6 +18,8 @@ #include "llvm/Pass.h" #include "llvm/Support/InstVisitor.h" +using namespace llvm; + namespace { /// CrashOnCalls - This pass is used to test bugpoint. It intentionally /// crashes on any call instructions. diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index a66b868c22..50a9ad21c8 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -18,6 +18,8 @@ #include #include +namespace llvm { + //===---------------------------------------------------------------------===// // LLI Implementation of AbstractIntepreter interface // @@ -391,3 +393,5 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message) { Message = "Found gcc: " + GCCPath + "\n"; return new GCC(GCCPath); } + +} // End llvm namespace diff --git a/tools/bugpoint/ToolRunner.h b/tools/bugpoint/ToolRunner.h index e23ec7f312..8ce3f5d8f3 100644 --- a/tools/bugpoint/ToolRunner.h +++ b/tools/bugpoint/ToolRunner.h @@ -20,6 +20,8 @@ #include "Support/SystemUtils.h" #include +namespace llvm { + class CBE; class LLC; @@ -137,4 +139,6 @@ public: int OutputAsm(const std::string &Bytecode, std::string &OutputAsmFile); }; +} // End llvm namespace + #endif diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index 8f55804e0c..9bca7fd6fc 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -19,6 +19,8 @@ #include "Config/unistd.h" #include +using namespace llvm; + static cl::list InputFilenames(cl::Positional, cl::OneOrMore, cl::desc("")); diff --git a/tools/extract/extract.cpp b/tools/extract/extract.cpp index 272d473180..72412b8b09 100644 --- a/tools/extract/extract.cpp +++ b/tools/extract/extract.cpp @@ -21,6 +21,8 @@ #include "Support/CommandLine.h" #include +using namespace llvm; + // InputFilename - The filename to read from. static cl::opt InputFilename(cl::Positional, cl::desc(""), diff --git a/tools/gccas/gccas.cpp b/tools/gccas/gccas.cpp index d97c716da1..c7a2204e32 100644 --- a/tools/gccas/gccas.cpp +++ b/tools/gccas/gccas.cpp @@ -27,6 +27,8 @@ #include #include +using namespace llvm; + namespace { cl::opt InputFilename(cl::Positional,cl::desc(""),cl::init("-")); diff --git a/tools/gccld/GenerateCode.cpp b/tools/gccld/GenerateCode.cpp index bf32400c63..aac1f93d32 100644 --- a/tools/gccld/GenerateCode.cpp +++ b/tools/gccld/GenerateCode.cpp @@ -25,11 +25,14 @@ #include "Support/SystemUtils.h" #include "Support/CommandLine.h" +using namespace llvm; + namespace { cl::opt DisableInline("disable-inlining", cl::desc("Do not run the inliner pass")); } +namespace llvm { /// GenerateBytecode - generates a bytecode file from the specified module. /// @@ -221,3 +224,5 @@ GenerateNative(const std::string &OutputFilename, // Run the compiler to assembly and link together the program. return ExecWait(&(cmd[0]), clean_env); } + +} // End llvm namespace diff --git a/tools/gccld/Linker.cpp b/tools/gccld/Linker.cpp index 06f0635749..9c22891775 100644 --- a/tools/gccld/Linker.cpp +++ b/tools/gccld/Linker.cpp @@ -30,6 +30,8 @@ #include #include +namespace llvm { + /// FindLib - Try to convert Filename into the name of a file that we can open, /// if it does not already name a file we can open, by first trying to open /// Filename, then libFilename. for each of a set of several common @@ -405,3 +407,5 @@ bool LinkLibraries(const char *progname, return false; } + +} // End llvm namespace diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp index 45163f4396..5a1b26100a 100644 --- a/tools/gccld/gccld.cpp +++ b/tools/gccld/gccld.cpp @@ -36,6 +36,8 @@ #include #include +using namespace llvm; + namespace { cl::list InputFilenames(cl::Positional, cl::desc(""), @@ -86,6 +88,8 @@ namespace { CO5("eh-frame-hdr", cl::Hidden, cl::desc("Compatibility option: ignored")); } +namespace llvm { + // // Function: PrintAndReturn () // @@ -211,6 +215,7 @@ void RemoveEnv(const char * name, char ** const envp) { return; } +} // End llvm namespace int main(int argc, char **argv, char **envp) { cl::ParseCommandLineOptions(argc, argv, " llvm linker for GCC\n"); diff --git a/tools/gccld/gccld.h b/tools/gccld/gccld.h index e3c5504209..9b7eb1e877 100644 --- a/tools/gccld/gccld.h +++ b/tools/gccld/gccld.h @@ -17,6 +17,8 @@ #include #include +namespace llvm { + int PrintAndReturn (const char *progname, const std::string &Message, @@ -69,3 +71,4 @@ LinkFiles (const char * progname, const std::vector & Files, bool Verbose); +} // End llvm namespace diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 0143d086e7..f219b6ea16 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -23,6 +23,8 @@ #include #include +using namespace llvm; + // General options for llc. Other pass-specific options are specified // within the corresponding llc passes, and target-specific options // and back-end code generation options are specified with the target machine. diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 87fe461ce0..82b354dc18 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -28,6 +28,8 @@ #include "Support/Debug.h" #include "Support/SystemUtils.h" +using namespace llvm; + namespace { cl::opt InputFile(cl::desc(""), cl::Positional, cl::init("-")); diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 879d847630..e9a4dbf095 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -25,6 +25,8 @@ #include #include +using namespace llvm; + using std::string; using std::vector; using std::cout; @@ -69,7 +71,7 @@ namespace { //Option to generate symbol table or not //running llvm-ar -s is the same as ranlib -cl::opt SymbolTable ("s", cl::desc("Generate an archive symbol table")); +cl::opt SymbolTableOption ("s", cl::desc("Generate an archive symbol table")); //Archive name cl::opt Archive (cl::Positional, cl::desc(""), @@ -335,7 +337,7 @@ void CreateArchive() { ArchiveFile << ARMAG; //If the '-s' option was specified, generate symbol table. - if(SymbolTable) { + if(SymbolTableOption) { cout << "Symbol Table Start: " << ArchiveFile.tellp() << "\n"; if(!WriteSymbolTable(ArchiveFile)) { std::cerr << "Error creating symbol table. Exiting program."; diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index 0905466780..9be5afff11 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -24,6 +24,8 @@ #include #include +using namespace llvm; + static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("-")); diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 915755903b..8d0ca7bc2d 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -29,10 +29,12 @@ // OutputMode - The different orderings to print basic blocks in... enum OutputMode { - llvm = 0, // Generate LLVM assembly (the default) + LLVM = 0, // Generate LLVM assembly (the default) c, // Generate C code }; +using namespace llvm; + static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::init("-")); @@ -45,8 +47,8 @@ Force("f", cl::desc("Overwrite output files")); static cl::opt WriteMode(cl::desc("Specify the output format:"), - cl::values(clEnumVal(llvm, "Output LLVM assembly"), - clEnumVal(c , "Output C code for program"), + cl::values(clEnumVal(LLVM, "Output LLVM assembly"), + clEnumVal(c, "Output C code for program"), 0)); int main(int argc, char **argv) { @@ -116,7 +118,7 @@ int main(int argc, char **argv) { PassManager Passes; switch (WriteMode) { - case llvm: // Output LLVM assembly + case LLVM: // Output LLVM assembly Passes.add(new PrintModulePass(Out)); break; case c: // Convert LLVM to C diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 272d473180..72412b8b09 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -21,6 +21,8 @@ #include "Support/CommandLine.h" #include +using namespace llvm; + // InputFilename - The filename to read from. static cl::opt InputFilename(cl::Positional, cl::desc(""), diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 764b59b43f..3b49214516 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -24,6 +24,8 @@ #include // For FileExists #include +using namespace llvm; + static cl::list InputFilenames(cl::Positional, cl::OneOrMore, cl::desc("")); diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index f7a0ef6746..878aa24f43 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -21,6 +21,8 @@ #include "Support/CommandLine.h" #include +using namespace llvm; + namespace { enum OutputFormatTy { bsd, sysv, posix }; cl::opt diff --git a/tools/llvm-prof/ProfileInfo.cpp b/tools/llvm-prof/ProfileInfo.cpp index 78de9c16c7..1d37c4291a 100644 --- a/tools/llvm-prof/ProfileInfo.cpp +++ b/tools/llvm-prof/ProfileInfo.cpp @@ -20,6 +20,8 @@ #include #include +using namespace llvm; + enum ProfilingType { ArgumentInfo = 1, // The command line argument block FunctionInfo = 2, // Function profiling information diff --git a/tools/llvm-prof/ProfileInfo.h b/tools/llvm-prof/ProfileInfo.h index 24e4296156..db4500127d 100644 --- a/tools/llvm-prof/ProfileInfo.h +++ b/tools/llvm-prof/ProfileInfo.h @@ -18,6 +18,9 @@ #include #include #include + +namespace llvm { + class Module; class Function; class BasicBlock; @@ -55,4 +58,6 @@ public: void getBlockCounts(std::vector > &Counts); }; +} // End llvm namespace + #endif diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp index 4492fd67b7..438fecf07a 100644 --- a/tools/llvm-prof/llvm-prof.cpp +++ b/tools/llvm-prof/llvm-prof.cpp @@ -23,6 +23,8 @@ #include #include +using namespace llvm; + namespace { cl::opt BytecodeFile(cl::Positional, cl::desc(""), diff --git a/tools/opt/AnalysisWrappers.cpp b/tools/opt/AnalysisWrappers.cpp index 6c4c99f5a3..a9b9cd0470 100644 --- a/tools/opt/AnalysisWrappers.cpp +++ b/tools/opt/AnalysisWrappers.cpp @@ -26,6 +26,8 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Support/InstIterator.h" +using namespace llvm; + namespace { struct InstForestHelper : public FunctionPass { Function *F; diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp index 34c937f0d4..6d2750f5e2 100644 --- a/tools/opt/GraphPrinters.cpp +++ b/tools/opt/GraphPrinters.cpp @@ -20,6 +20,8 @@ #include "llvm/Analysis/CallGraph.h" #include +namespace llvm { + template static void WriteGraphToFile(std::ostream &O, const std::string &GraphName, const GraphType >) { @@ -72,3 +74,5 @@ namespace { RegisterAnalysis P2("print-callgraph", "Print Call Graph to 'dot' file"); }; + +} // End llvm namespace diff --git a/tools/opt/PrintSCC.cpp b/tools/opt/PrintSCC.cpp index 3459381158..ce89fff90e 100644 --- a/tools/opt/PrintSCC.cpp +++ b/tools/opt/PrintSCC.cpp @@ -31,6 +31,8 @@ #include "llvm/Support/CFG.h" #include "Support/SCCIterator.h" +namespace llvm { + namespace { struct CFGSCC : public FunctionPass { bool runOnFunction(Function& func); @@ -101,3 +103,5 @@ bool CallGraphSCC::run(Module &M) { return true; } + +} // End llvm namespace diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index bc0a5fcb6f..30c72f1c9e 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -27,6 +27,7 @@ #include #include +using namespace llvm; // The OptimizationList is automatically populated with registered Passes by the // PassNameParser. diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index bd3d2ffea5..2c3e374b16 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -15,6 +15,8 @@ #include "Record.h" #include "Support/Debug.h" +namespace llvm { + void CodeEmitterGen::run(std::ostream &o) { std::vector Insts = Records.getAllDerivedDefinitions("Instruction"); @@ -221,4 +223,8 @@ void CodeEmitterGen::run(std::ostream &o) { << " }\n" << " return Value;\n" << "}\n"; + + EmitSourceFileTail(o); } + +} // End llvm namespace diff --git a/utils/TableGen/CodeEmitterGen.h b/utils/TableGen/CodeEmitterGen.h index d7b4bc1adf..19ca5452f5 100644 --- a/utils/TableGen/CodeEmitterGen.h +++ b/utils/TableGen/CodeEmitterGen.h @@ -16,6 +16,8 @@ #include "TableGenBackend.h" +namespace llvm { + class CodeEmitterGen : public TableGenBackend { RecordKeeper &Records; public: @@ -28,4 +30,6 @@ private: void emitGetValueBit(std::ostream &o, const std::string &Namespace); }; +} // End llvm namespace + #endif diff --git a/utils/TableGen/CodeGenTarget.cpp b/utils/TableGen/CodeGenTarget.cpp index 5039ccaad0..bf641fa276 100644 --- a/utils/TableGen/CodeGenTarget.cpp +++ b/utils/TableGen/CodeGenTarget.cpp @@ -17,6 +17,8 @@ #include "CodeGenWrappers.h" #include "Record.h" +namespace llvm { + /// getValueType - Return the MCV::ValueType that the specified TableGen record /// corresponds to. MVT::ValueType getValueType(Record *Rec) { @@ -94,3 +96,5 @@ const std::string &CodeGenTarget::getName() const { Record *CodeGenTarget::getInstructionSet() const { return TargetRec->getValueAsDef("InstructionSet"); } + +} // End llvm namespace diff --git a/utils/TableGen/CodeGenTarget.h b/utils/TableGen/CodeGenTarget.h index f0b7200edc..948360e2b1 100644 --- a/utils/TableGen/CodeGenTarget.h +++ b/utils/TableGen/CodeGenTarget.h @@ -21,6 +21,9 @@ #include #include #include + +namespace llvm { + class Record; class RecordKeeper; @@ -60,4 +63,6 @@ public: // CodeGenInstructionSet *getInstructionSet - }; +} // End llvm namespace + #endif diff --git a/utils/TableGen/CodeGenWrappers.cpp b/utils/TableGen/CodeGenWrappers.cpp index 5039ccaad0..bf641fa276 100644 --- a/utils/TableGen/CodeGenWrappers.cpp +++ b/utils/TableGen/CodeGenWrappers.cpp @@ -17,6 +17,8 @@ #include "CodeGenWrappers.h" #include "Record.h" +namespace llvm { + /// getValueType - Return the MCV::ValueType that the specified TableGen record /// corresponds to. MVT::ValueType getValueType(Record *Rec) { @@ -94,3 +96,5 @@ const std::string &CodeGenTarget::getName() const { Record *CodeGenTarget::getInstructionSet() const { return TargetRec->getValueAsDef("InstructionSet"); } + +} // End llvm namespace diff --git a/utils/TableGen/CodeGenWrappers.h b/utils/TableGen/CodeGenWrappers.h index f0b7200edc..948360e2b1 100644 --- a/utils/TableGen/CodeGenWrappers.h +++ b/utils/TableGen/CodeGenWrappers.h @@ -21,6 +21,9 @@ #include #include #include + +namespace llvm { + class Record; class RecordKeeper; @@ -60,4 +63,6 @@ public: // CodeGenInstructionSet *getInstructionSet - }; +} // End llvm namespace + #endif diff --git a/utils/TableGen/FileLexer.l b/utils/TableGen/FileLexer.l index 0858a8c5e4..48070b34a1 100644 --- a/utils/TableGen/FileLexer.l +++ b/utils/TableGen/FileLexer.l @@ -28,9 +28,13 @@ %{ #include "Record.h" -typedef std::pair*> SubClassRefTy; +typedef std::pair*> SubClassRefTy; #include "FileParser.h" +int Fileparse(); + +namespace llvm { + // Global variable recording the location of the include directory std::string IncludeDirectory; @@ -69,7 +73,6 @@ std::ostream &err() { } -int Fileparse(); // // Function: ParseFile() @@ -171,6 +174,10 @@ int yywrap() { return 0; } +} // End llvm namespace + +using namespace llvm; + %} Comment \/\/.* diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index 491cca310d..e95e59785c 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -20,6 +20,9 @@ int yyerror(const char *ErrorMsg); int yylex(); + +namespace llvm { + extern int Filelineno; static Record *CurRec = 0; @@ -160,20 +163,23 @@ static void addSubClass(Record *SC, const std::vector &TemplateArgs) { addSuperClass(SC); } +} // End llvm namespace + +using namespace llvm; %} %union { - std::string *StrVal; - int IntVal; - RecTy *Ty; - Init *Initializer; - std::vector *FieldList; - std::vector*BitList; - Record *Rec; - SubClassRefTy *SubClassRef; - std::vector *SubClassList; - std::vector > *DagValueList; + std::string* StrVal; + int IntVal; + llvm::RecTy* Ty; + llvm::Init* Initializer; + std::vector* FieldList; + std::vector* BitList; + llvm::Record* Rec; + SubClassRefTy* SubClassRef; + std::vector* SubClassList; + std::vector >* DagValueList; }; %token INT BIT STRING BITS LIST CODE DAG CLASS DEF FIELD LET IN @@ -193,6 +199,7 @@ static void addSubClass(Record *SC, const std::vector &TemplateArgs) { %type Declaration OptID OptVarName %start File + %% ClassID : ID { diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index a11244dd98..ed040b15d9 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -16,6 +16,8 @@ #include "CodeGenWrappers.h" #include "Record.h" +namespace llvm { + // runEnums - Print out enum values for all of the instructions. void InstrInfoEmitter::runEnums(std::ostream &OS) { std::vector Insts = Records.getAllDerivedDefinitions("Instruction"); @@ -47,6 +49,7 @@ void InstrInfoEmitter::runEnums(std::ostream &OS) { OS << " };\n"; if (!Namespace.empty()) OS << "}\n"; + EmitSourceFileTail(OS); } void InstrInfoEmitter::printDefList(ListInit *LI, const std::string &Name, @@ -93,6 +96,7 @@ void InstrInfoEmitter::run(std::ostream &OS) { if (Instructions[i] != PHI) emitRecord(Instructions[i], i+1, InstrInfo, OS); OS << "};\n"; + EmitSourceFileTail(OS); } void InstrInfoEmitter::emitRecord(Record *R, unsigned Num, Record *InstrInfo, @@ -169,3 +173,5 @@ void InstrInfoEmitter::emitShiftedValue(Record *R, StringInit *Val, std::cerr << "Unhandled initializer: " << *Val << "\n"; throw "In record '" + R->getName() + "' for TSFlag emission."; } + +} // End llvm namespace diff --git a/utils/TableGen/InstrInfoEmitter.h b/utils/TableGen/InstrInfoEmitter.h index 4adac31264..2a6b063deb 100644 --- a/utils/TableGen/InstrInfoEmitter.h +++ b/utils/TableGen/InstrInfoEmitter.h @@ -16,6 +16,9 @@ #define INSTRINFO_EMITTER_H #include "TableGenBackend.h" + +namespace llvm { + class StringInit; class IntInit; class ListInit; @@ -38,4 +41,6 @@ private: std::ostream &OS); }; +} // End llvm namespace + #endif diff --git a/utils/TableGen/InstrSelectorEmitter.cpp b/utils/TableGen/InstrSelectorEmitter.cpp index 9988d55684..5d945bb841 100644 --- a/utils/TableGen/InstrSelectorEmitter.cpp +++ b/utils/TableGen/InstrSelectorEmitter.cpp @@ -19,6 +19,8 @@ #include "Support/StringExtras.h" #include +namespace llvm { + NodeType::ArgResultTypes NodeType::Translate(Record *R) { const std::string &Name = R->getName(); if (Name == "DNVT_any") return Any; @@ -978,9 +980,10 @@ void InstrSelectorEmitter::run(std::ostream &OS) { CalculateComputableValues(); + OS << "#include \"llvm/CodeGen/MachineInstrBuilder.h\"\n"; + EmitSourceFileHeader("Instruction Selector for the " + Target.getName() + " target", OS); - OS << "#include \"llvm/CodeGen/MachineInstrBuilder.h\"\n"; // Output the slot number enums... OS << "\nenum { // Slot numbers...\n" @@ -1290,5 +1293,7 @@ void InstrSelectorEmitter::run(std::ostream &OS) { << " }\n\n N->addValue(Val); // Do not ever recalculate this\n" << " return Val;\n}\n\n"; } + EmitSourceFileTail(OS); } +} // End llvm namespace diff --git a/utils/TableGen/InstrSelectorEmitter.h b/utils/TableGen/InstrSelectorEmitter.h index 2f9175c95a..a0fbbcf408 100644 --- a/utils/TableGen/InstrSelectorEmitter.h +++ b/utils/TableGen/InstrSelectorEmitter.h @@ -21,6 +21,8 @@ #include #include +namespace llvm { + class DagInit; class Init; class InstrSelectorEmitter; @@ -391,4 +393,6 @@ private: bool PrintArg, std::ostream &OS); }; +} // End llvm namespace + #endif diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 32ffe6245a..00751a1824 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -16,6 +16,8 @@ // Type implementations //===----------------------------------------------------------------------===// +namespace llvm { + void RecTy::dump() const { print(std::cerr); } Init *BitRecTy::convertValue(BitsInit *BI) { @@ -681,3 +683,5 @@ RecordKeeper::getAllDerivedDefinitions(const std::string &ClassName) const { return Defs; } + +} // End llvm namespace diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index e2233f88a8..d8a96495e7 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -21,6 +21,8 @@ #include #include +namespace llvm { + // RecTy subclasses... class BitRecTy; class BitsRecTy; @@ -853,4 +855,6 @@ std::ostream &operator<<(std::ostream &OS, const RecordKeeper &RK); extern RecordKeeper Records; +} // End llvm namespace + #endif diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index 67acc3f333..4e7aa9b584 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -19,6 +19,8 @@ #include "Support/StringExtras.h" #include +namespace llvm { + // runEnums - Print out enum values for all of the registers. void RegisterInfoEmitter::runEnums(std::ostream &OS) { std::vector Registers = Records.getAllDerivedDefinitions("Register"); @@ -40,6 +42,7 @@ void RegisterInfoEmitter::runEnums(std::ostream &OS) { OS << " };\n"; if (!Namespace.empty()) OS << "}\n"; + EmitSourceFileTail(OS); } void RegisterInfoEmitter::runHeader(std::ostream &OS) { @@ -68,6 +71,7 @@ void RegisterInfoEmitter::runHeader(std::ostream &OS) { OS << " extern TargetRegisterClass *" << Name << "RegisterClass;\n"; } OS << "} // end of namespace " << TargetName << "\n\n"; + EmitSourceFileTail(OS); } // RegisterInfoEmitter::run - Main register file description emitter. @@ -240,4 +244,7 @@ void RegisterInfoEmitter::run(std::ostream &OS) { for (unsigned i = 0, e = CSR.size(); i != e; ++i) OS << getQualifiedName(CSR[i]) << ", "; OS << " 0\n };\n return CalleeSaveRegs;\n}\n\n"; + EmitSourceFileTail(OS); } + +} // End llvm namespace diff --git a/utils/TableGen/RegisterInfoEmitter.h b/utils/TableGen/RegisterInfoEmitter.h index 22c759facf..1e6380b70a 100644 --- a/utils/TableGen/RegisterInfoEmitter.h +++ b/utils/TableGen/RegisterInfoEmitter.h @@ -18,6 +18,8 @@ #include "TableGenBackend.h" +namespace llvm { + class RegisterInfoEmitter : public TableGenBackend { RecordKeeper &Records; public: @@ -33,4 +35,6 @@ public: void runEnums(std::ostream &o); }; +} // End llvm namespace + #endif diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index 803d0f0fdd..c05ccb0bb1 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -27,6 +27,8 @@ #include #include +namespace llvm { + enum ActionType { PrintRecords, GenEmitter, @@ -406,6 +408,9 @@ static void ParseMachineCode() { } } +} // End llvm namespace + +using namespace llvm; int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv); @@ -459,12 +464,17 @@ int main(int argc, char **argv) { InstrSelectorEmitter(Records).run(*Out); break; case PrintEnums: + { std::vector Recs = Records.getAllDerivedDefinitions(Class); for (unsigned i = 0, e = Recs.size(); i != e; ++i) *Out << Recs[i] << ", "; *Out << "\n"; break; } + default: + assert(1 && "Invalid Action"); + return 1; + } } catch (const std::string &Error) { std::cerr << Error << "\n"; if (Out != &std::cout) { diff --git a/utils/TableGen/TableGenBackend.cpp b/utils/TableGen/TableGenBackend.cpp index 161b2eeb60..67a37885db 100644 --- a/utils/TableGen/TableGenBackend.cpp +++ b/utils/TableGen/TableGenBackend.cpp @@ -15,12 +15,18 @@ #include "Record.h" #include +namespace llvm { + void TableGenBackend::EmitSourceFileHeader(const std::string &Desc, std::ostream &OS) const { OS << "//===- TableGen'erated file -------------------------------------*-" " C++ -*-===//\n//\n// " << Desc << "\n//\n// Automatically generate" "d file, do not edit!\n//\n//===------------------------------------" - "----------------------------------===//\n\n"; + "----------------------------------===//\n\nnamespace llvm {\n\n"; +} + +void TableGenBackend::EmitSourceFileTail( std::ostream& OS ) const { + OS << "} // End llvm namespace \n"; } /// getQualifiedName - Return the name of the specified record, with a @@ -32,3 +38,4 @@ std::string TableGenBackend::getQualifiedName(Record *R) const { return Namespace + "::" + R->getName(); } +} // End llvm namespace diff --git a/utils/TableGen/TableGenBackend.h b/utils/TableGen/TableGenBackend.h index 23b83cac7e..869d7e939d 100644 --- a/utils/TableGen/TableGenBackend.h +++ b/utils/TableGen/TableGenBackend.h @@ -17,6 +17,9 @@ #include #include + +namespace llvm { + class Record; class RecordKeeper; @@ -33,9 +36,15 @@ public: // Useful helper routines... /// ostream. void EmitSourceFileHeader(const std::string &Desc, std::ostream &OS) const; + /// EmitSourceFileTail - Output an LLVm styelf ile tail to the specified + /// ostream. + void EmitSourceFileTail( std::ostream& OS ) const; + /// getQualifiedName - Return the name of the specified record, with a /// namespace qualifier if the record contains one. std::string getQualifiedName(Record *R) const; }; +} // End llvm namespace + #endif -- cgit v1.2.3-70-g09d2 From 2cdd21c2e4d855500dfb53f77aa74da53ccf9de6 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 14 Dec 2003 21:35:53 +0000 Subject: Finegrainify namespacification git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10464 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ConstantRange.cpp | 5 +--- lib/Support/Annotation.cpp | 5 +--- lib/Support/CommandLine.cpp | 5 +--- lib/Support/ConstantRange.cpp | 5 +--- lib/Support/Debug.cpp | 11 +++----- lib/Support/DynamicLinker.cpp | 11 +++----- lib/Support/FileUtilities.cpp | 35 ++++++++++++-------------- lib/Support/LeakDetector.cpp | 5 +--- lib/Support/Mangler.cpp | 5 +--- lib/Support/PluginLoader.cpp | 5 +--- lib/Support/Signals.cpp | 7 ++---- lib/Support/SystemUtils.cpp | 26 ++++++++----------- lib/Support/ToolRunner.cpp | 57 +++++++++++++++++++++--------------------- lib/Support/ValueHolder.cpp | 4 +-- lib/VMCore/ConstantRange.cpp | 5 +--- lib/VMCore/LeakDetector.cpp | 5 +--- lib/VMCore/Mangler.cpp | 5 +--- tools/bugpoint/ToolRunner.cpp | 57 +++++++++++++++++++++--------------------- 18 files changed, 106 insertions(+), 152 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Analysis/ConstantRange.cpp b/lib/Analysis/ConstantRange.cpp index e180f12a1a..7b45d20b53 100644 --- a/lib/Analysis/ConstantRange.cpp +++ b/lib/Analysis/ConstantRange.cpp @@ -25,8 +25,7 @@ #include "llvm/Type.h" #include "llvm/Instruction.h" #include "llvm/ConstantHandling.h" - -namespace llvm { +using namespace llvm; /// Initialize a full (the default) or empty set for the specified type. /// @@ -250,5 +249,3 @@ void ConstantRange::print(std::ostream &OS) const { void ConstantRange::dump() const { print(std::cerr); } - -} // End llvm namespace diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp index b88624dd1f..bcd196da44 100644 --- a/lib/Support/Annotation.cpp +++ b/lib/Support/Annotation.cpp @@ -13,8 +13,7 @@ #include #include "Support/Annotation.h" - -namespace llvm { +using namespace llvm; typedef std::map IDMapType; static unsigned IDCounter = 0; // Unique ID counter @@ -96,5 +95,3 @@ Annotation *AnnotationManager::createAnnotation(AnnotationID ID, if (I == getFactMap().end()) return 0; return I->second.first(ID, Obj, I->second.second); } - -} // End llvm namespace diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 235dc12843..8a6bd77e40 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -23,8 +23,7 @@ #include #include #include - -namespace llvm { +using namespace llvm; using namespace cl; @@ -889,5 +888,3 @@ HHOp("help-hidden", cl::desc("display all available options"), cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); } // End anonymous namespace - -} // End llvm namespace diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index e180f12a1a..7b45d20b53 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -25,8 +25,7 @@ #include "llvm/Type.h" #include "llvm/Instruction.h" #include "llvm/ConstantHandling.h" - -namespace llvm { +using namespace llvm; /// Initialize a full (the default) or empty set for the specified type. /// @@ -250,5 +249,3 @@ void ConstantRange::print(std::ostream &OS) const { void ConstantRange::dump() const { print(std::cerr); } - -} // End llvm namespace diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index 1af23380a2..f171342949 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -23,12 +23,11 @@ // //===----------------------------------------------------------------------===// -#include "Support/Statistic.h" +#include "Support/Debug.h" #include "Support/CommandLine.h" +using namespace llvm; -namespace llvm { - -bool DebugFlag; // DebugFlag - Exported boolean set by the -debug option +bool llvm::DebugFlag; // DebugFlag - Exported boolean set by the -debug option namespace { #ifndef NDEBUG @@ -57,12 +56,10 @@ namespace { // specified on the command line, or if none was specified on the command line // with the -debug-only=X option. // -bool isCurrentDebugType(const char *DebugType) { +bool llvm::isCurrentDebugType(const char *DebugType) { #ifndef NDEBUG return CurrentDebugType.empty() || DebugType == CurrentDebugType; #else return false; #endif } - -} // End llvm namespace diff --git a/lib/Support/DynamicLinker.cpp b/lib/Support/DynamicLinker.cpp index 1c9385eea7..801f93b5ba 100644 --- a/lib/Support/DynamicLinker.cpp +++ b/lib/Support/DynamicLinker.cpp @@ -22,10 +22,9 @@ #include "Support/DynamicLinker.h" #include "Config/dlfcn.h" #include +using namespace llvm; -namespace llvm { - -bool LinkDynamicObject (const char *filename, std::string *ErrorMessage) { +bool llvm::LinkDynamicObject (const char *filename, std::string *ErrorMessage) { #if defined (HAVE_DLOPEN) if (dlopen (filename, RTLD_NOW | RTLD_GLOBAL) == 0) { if (ErrorMessage) *ErrorMessage = dlerror (); @@ -37,7 +36,7 @@ bool LinkDynamicObject (const char *filename, std::string *ErrorMessage) { #endif } -void *GetAddressOfSymbol (const char *symbolName) { +void *llvm::GetAddressOfSymbol (const char *symbolName) { #if defined (HAVE_DLOPEN) #ifdef RTLD_DEFAULT return dlsym (RTLD_DEFAULT, symbolName); @@ -51,8 +50,6 @@ void *GetAddressOfSymbol (const char *symbolName) { } // soft, cushiony C++ interface. -void *GetAddressOfSymbol (const std::string &symbolName) { +void *llvm::GetAddressOfSymbol (const std::string &symbolName) { return GetAddressOfSymbol (symbolName.c_str ()); } - -} // End llvm namespace diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 4e3c22ce7c..e6abc8fb40 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -19,14 +19,12 @@ #include #include #include - -namespace llvm -{ +using namespace llvm; /// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must /// name a readable file. /// -bool CheckMagic (const std::string &FN, const std::string &Magic) { +bool llvm::CheckMagic(const std::string &FN, const std::string &Magic) { char buf[1 + Magic.size ()]; std::ifstream f (FN.c_str ()); f.read (buf, Magic.size ()); @@ -37,7 +35,7 @@ bool CheckMagic (const std::string &FN, const std::string &Magic) { /// IsArchive - Returns true IFF the file named FN appears to be a "ar" library /// archive. The file named FN must exist. /// -bool IsArchive(const std::string &FN) { +bool llvm::IsArchive(const std::string &FN) { // Inspect the beginning of the file to see if it contains the "ar" // library archive format magic string. return CheckMagic (FN, "!\012"); @@ -46,7 +44,7 @@ bool IsArchive(const std::string &FN) { /// IsBytecode - Returns true IFF the file named FN appears to be an LLVM /// bytecode file. The file named FN must exist. /// -bool IsBytecode(const std::string &FN) { +bool llvm::IsBytecode(const std::string &FN) { // Inspect the beginning of the file to see if it contains the LLVM // bytecode format magic string. return CheckMagic (FN, "llvm"); @@ -55,7 +53,7 @@ bool IsBytecode(const std::string &FN) { /// IsSharedObject - Returns trus IFF the file named FN appears to be a shared /// object with an ELF header. The file named FN must exist. /// -bool IsSharedObject(const std::string &FN) { +bool llvm::IsSharedObject(const std::string &FN) { // Inspect the beginning of the file to see if it contains the ELF shared // object magic string. static const char elfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' }; @@ -65,7 +63,7 @@ bool IsSharedObject(const std::string &FN) { /// FileOpenable - Returns true IFF Filename names an existing regular /// file which we can successfully open. /// -bool FileOpenable (const std::string &Filename) { +bool llvm::FileOpenable(const std::string &Filename) { struct stat s; if (stat (Filename.c_str (), &s) == -1) return false; // Cannot stat file @@ -83,8 +81,8 @@ bool FileOpenable (const std::string &Filename) { /// occurs, allowing the caller to distinguish between a failed diff and a file /// system error. /// -bool DiffFiles(const std::string &FileA, const std::string &FileB, - std::string *Error) { +bool llvm::DiffFiles(const std::string &FileA, const std::string &FileB, + std::string *Error) { std::ifstream FileAStream(FileA.c_str()); if (!FileAStream) { if (Error) *Error = "Couldn't open file '" + FileA + "'"; @@ -113,7 +111,8 @@ bool DiffFiles(const std::string &FileA, const std::string &FileB, /// or if Old does not exist, move the New file over the Old file. Otherwise, /// remove the New file. /// -void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) { +void llvm::MoveFileOverIfUpdated(const std::string &New, + const std::string &Old) { if (DiffFiles(New, Old)) { if (std::rename(New.c_str(), Old.c_str())) std::cerr << "Error renaming '" << New << "' to '" << Old << "'!\n"; @@ -124,7 +123,7 @@ void MoveFileOverIfUpdated(const std::string &New, const std::string &Old) { /// removeFile - Delete the specified file /// -void removeFile(const std::string &Filename) { +void llvm::removeFile(const std::string &Filename) { std::remove(Filename.c_str()); } @@ -132,7 +131,7 @@ void removeFile(const std::string &Filename) { /// file does not exist yet, return it, otherwise add a suffix to make it /// unique. /// -std::string getUniqueFilename(const std::string &FilenameBase) { +std::string llvm::getUniqueFilename(const std::string &FilenameBase) { if (!std::ifstream(FilenameBase.c_str())) return FilenameBase; // Couldn't open the file? Use it! @@ -183,8 +182,8 @@ static bool AddPermissionsBits (const std::string &Filename, mode_t bits) { /// umask would allow. Filename must name an existing file or /// directory. Returns true on success, false on error. /// -bool MakeFileExecutable (const std::string &Filename) { - return AddPermissionsBits (Filename, 0111); +bool llvm::MakeFileExecutable(const std::string &Filename) { + return AddPermissionsBits(Filename, 0111); } /// MakeFileReadable - Make the file named Filename readable by @@ -192,8 +191,6 @@ bool MakeFileExecutable (const std::string &Filename) { /// umask would allow. Filename must name an existing file or /// directory. Returns true on success, false on error. /// -bool MakeFileReadable (const std::string &Filename) { - return AddPermissionsBits (Filename, 0444); +bool llvm::MakeFileReadable(const std::string &Filename) { + return AddPermissionsBits(Filename, 0444); } - -} // End llvm namespace diff --git a/lib/Support/LeakDetector.cpp b/lib/Support/LeakDetector.cpp index ffb081a998..f0cb6cc1c5 100644 --- a/lib/Support/LeakDetector.cpp +++ b/lib/Support/LeakDetector.cpp @@ -14,8 +14,7 @@ #include "Support/LeakDetector.h" #include "llvm/Value.h" #include - -namespace llvm { +using namespace llvm; // Lazily allocate set so that release build doesn't have to do anything. static std::set *Objects = 0; @@ -89,5 +88,3 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) { Objects = 0; LLVMObjects = 0; } } - -} // End llvm namespace diff --git a/lib/Support/Mangler.cpp b/lib/Support/Mangler.cpp index 567fe05e32..699ecd1a65 100644 --- a/lib/Support/Mangler.cpp +++ b/lib/Support/Mangler.cpp @@ -15,8 +15,7 @@ #include "llvm/Module.h" #include "llvm/Type.h" #include "Support/StringExtras.h" - -namespace llvm { +using namespace llvm; static char HexDigit(int V) { return V < 10 ? V+'0' : V+'A'-10; @@ -100,5 +99,3 @@ Mangler::Mangler(Module &m, bool addUnderscorePrefix) else FoundNames.insert(I->getName()); // Otherwise, keep track of name } - -} // End llvm namespace diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 1729bb3365..be8833d009 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -22,8 +22,7 @@ #include "Config/dlfcn.h" #include "Config/link.h" #include - -namespace llvm { +using namespace llvm; namespace { struct PluginLoader { @@ -40,5 +39,3 @@ namespace { static cl::opt > LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin.so"), cl::desc("Load the specified plugin")); - -} // End llvm namespace diff --git a/lib/Support/Signals.cpp b/lib/Support/Signals.cpp index 73decfd89b..27e3eb80e5 100644 --- a/lib/Support/Signals.cpp +++ b/lib/Support/Signals.cpp @@ -19,8 +19,7 @@ #include #include #include "Config/config.h" // Get the signal handler return type - -namespace llvm { +using namespace llvm; static std::vector FilesToRemove; @@ -58,11 +57,9 @@ static RETSIGTYPE SignalHandler(int Sig) { static void RegisterHandler(int Signal) { signal(Signal, SignalHandler); } // RemoveFileOnSignal - The public API -void RemoveFileOnSignal(const std::string &Filename) { +void llvm::RemoveFileOnSignal(const std::string &Filename) { FilesToRemove.push_back(Filename); std::for_each(IntSigs, IntSigsEnd, RegisterHandler); std::for_each(KillSigs, KillSigsEnd, RegisterHandler); } - -} // End llvm namespace diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index ec535ad45a..e1a0bd04d4 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -23,13 +23,12 @@ #include "Config/sys/wait.h" #include "Config/unistd.h" #include "Config/errno.h" - -namespace llvm { +using namespace llvm; /// isExecutableFile - This function returns true if the filename specified /// exists and is executable. /// -bool isExecutableFile(const std::string &ExeFileName) { +bool llvm::isExecutableFile(const std::string &ExeFileName) { struct stat Buf; if (stat(ExeFileName.c_str(), &Buf)) return false; // Must not be executable! @@ -51,8 +50,8 @@ bool isExecutableFile(const std::string &ExeFileName) { /// directory, nor in the PATH. If the executable cannot be found, return an /// empty string. /// -std::string FindExecutable(const std::string &ExeName, - const std::string &ProgramPath) { +std::string llvm::FindExecutable(const std::string &ExeName, + const std::string &ProgramPath) { // First check the directory that bugpoint is in. We can do this if // BugPointPath contains at least one / character, indicating that it is a // relative path to bugpoint itself. @@ -116,11 +115,11 @@ static void RedirectFD(const std::string &File, int FD) { /// the calling program if there is an error executing the specified program. /// It returns the return value of the program, or -1 if a timeout is detected. /// -int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, - const std::string &StdInFile, - const std::string &StdOutFile, - const std::string &StdErrFile) { - +int llvm::RunProgramWithTimeout(const std::string &ProgramPath, + const char **Args, + const std::string &StdInFile, + const std::string &StdOutFile, + const std::string &StdErrFile) { // FIXME: install sigalarm handler here for timeout... int Child = fork(); @@ -204,9 +203,8 @@ int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, // // This function does not use $PATH to find programs. // -int -ExecWait (const char * const old_argv[], const char * const old_envp[]) -{ +int llvm::ExecWait(const char * const old_argv[], + const char * const old_envp[]) { // Child process ID register int child; @@ -273,5 +271,3 @@ ExecWait (const char * const old_argv[], const char * const old_envp[]) // return 1; } - -} // End llvm namespace diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index 0f2e13e20f..b1fb64b990 100644 --- a/lib/Support/ToolRunner.cpp +++ b/lib/Support/ToolRunner.cpp @@ -18,25 +18,26 @@ #include "Support/FileUtilities.h" #include #include - -namespace llvm { +using namespace llvm; //===---------------------------------------------------------------------===// // LLI Implementation of AbstractIntepreter interface // -class LLI : public AbstractInterpreter { - std::string LLIPath; // The path to the LLI executable -public: - LLI(const std::string &Path) : LLIPath(Path) { } - - - virtual int ExecuteProgram(const std::string &Bytecode, - const std::vector &Args, - const std::string &InputFile, - const std::string &OutputFile, - const std::vector &SharedLibs = +namespace { + class LLI : public AbstractInterpreter { + std::string LLIPath; // The path to the LLI executable + public: + LLI(const std::string &Path) : LLIPath(Path) { } + + + virtual int ExecuteProgram(const std::string &Bytecode, + const std::vector &Args, + const std::string &InputFile, + const std::string &OutputFile, + const std::vector &SharedLibs = std::vector()); -}; + }; +} int LLI::ExecuteProgram(const std::string &Bytecode, const std::vector &Args, @@ -148,19 +149,21 @@ LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath, //===---------------------------------------------------------------------===// // JIT Implementation of AbstractIntepreter interface // -class JIT : public AbstractInterpreter { - std::string LLIPath; // The path to the LLI executable -public: - JIT(const std::string &Path) : LLIPath(Path) { } - - - virtual int ExecuteProgram(const std::string &Bytecode, - const std::vector &Args, - const std::string &InputFile, - const std::string &OutputFile, - const std::vector &SharedLibs = +namespace { + class JIT : public AbstractInterpreter { + std::string LLIPath; // The path to the LLI executable + public: + JIT(const std::string &Path) : LLIPath(Path) { } + + + virtual int ExecuteProgram(const std::string &Bytecode, + const std::vector &Args, + const std::string &InputFile, + const std::string &OutputFile, + const std::vector &SharedLibs = std::vector()); -}; + }; +} int JIT::ExecuteProgram(const std::string &Bytecode, const std::vector &Args, @@ -396,5 +399,3 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message) { Message = "Found gcc: " + GCCPath + "\n"; return new GCC(GCCPath); } - -} // End llvm namespace diff --git a/lib/Support/ValueHolder.cpp b/lib/Support/ValueHolder.cpp index 77fdaf6b44..976f825598 100644 --- a/lib/Support/ValueHolder.cpp +++ b/lib/Support/ValueHolder.cpp @@ -18,10 +18,8 @@ #include "llvm/Support/ValueHolder.h" #include "llvm/Type.h" -namespace llvm { +using namespace llvm; ValueHolder::ValueHolder(Value *V) : User(Type::TypeTy, Value::TypeVal) { Operands.push_back(Use(V, this)); } - -} // End llvm namespace diff --git a/lib/VMCore/ConstantRange.cpp b/lib/VMCore/ConstantRange.cpp index e180f12a1a..7b45d20b53 100644 --- a/lib/VMCore/ConstantRange.cpp +++ b/lib/VMCore/ConstantRange.cpp @@ -25,8 +25,7 @@ #include "llvm/Type.h" #include "llvm/Instruction.h" #include "llvm/ConstantHandling.h" - -namespace llvm { +using namespace llvm; /// Initialize a full (the default) or empty set for the specified type. /// @@ -250,5 +249,3 @@ void ConstantRange::print(std::ostream &OS) const { void ConstantRange::dump() const { print(std::cerr); } - -} // End llvm namespace diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index ffb081a998..f0cb6cc1c5 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -14,8 +14,7 @@ #include "Support/LeakDetector.h" #include "llvm/Value.h" #include - -namespace llvm { +using namespace llvm; // Lazily allocate set so that release build doesn't have to do anything. static std::set *Objects = 0; @@ -89,5 +88,3 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) { Objects = 0; LLVMObjects = 0; } } - -} // End llvm namespace diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp index 567fe05e32..699ecd1a65 100644 --- a/lib/VMCore/Mangler.cpp +++ b/lib/VMCore/Mangler.cpp @@ -15,8 +15,7 @@ #include "llvm/Module.h" #include "llvm/Type.h" #include "Support/StringExtras.h" - -namespace llvm { +using namespace llvm; static char HexDigit(int V) { return V < 10 ? V+'0' : V+'A'-10; @@ -100,5 +99,3 @@ Mangler::Mangler(Module &m, bool addUnderscorePrefix) else FoundNames.insert(I->getName()); // Otherwise, keep track of name } - -} // End llvm namespace diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 0f2e13e20f..b1fb64b990 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -18,25 +18,26 @@ #include "Support/FileUtilities.h" #include #include - -namespace llvm { +using namespace llvm; //===---------------------------------------------------------------------===// // LLI Implementation of AbstractIntepreter interface // -class LLI : public AbstractInterpreter { - std::string LLIPath; // The path to the LLI executable -public: - LLI(const std::string &Path) : LLIPath(Path) { } - - - virtual int ExecuteProgram(const std::string &Bytecode, - const std::vector &Args, - const std::string &InputFile, - const std::string &OutputFile, - const std::vector &SharedLibs = +namespace { + class LLI : public AbstractInterpreter { + std::string LLIPath; // The path to the LLI executable + public: + LLI(const std::string &Path) : LLIPath(Path) { } + + + virtual int ExecuteProgram(const std::string &Bytecode, + const std::vector &Args, + const std::string &InputFile, + const std::string &OutputFile, + const std::vector &SharedLibs = std::vector()); -}; + }; +} int LLI::ExecuteProgram(const std::string &Bytecode, const std::vector &Args, @@ -148,19 +149,21 @@ LLC *AbstractInterpreter::createLLC(const std::string &ProgramPath, //===---------------------------------------------------------------------===// // JIT Implementation of AbstractIntepreter interface // -class JIT : public AbstractInterpreter { - std::string LLIPath; // The path to the LLI executable -public: - JIT(const std::string &Path) : LLIPath(Path) { } - - - virtual int ExecuteProgram(const std::string &Bytecode, - const std::vector &Args, - const std::string &InputFile, - const std::string &OutputFile, - const std::vector &SharedLibs = +namespace { + class JIT : public AbstractInterpreter { + std::string LLIPath; // The path to the LLI executable + public: + JIT(const std::string &Path) : LLIPath(Path) { } + + + virtual int ExecuteProgram(const std::string &Bytecode, + const std::vector &Args, + const std::string &InputFile, + const std::string &OutputFile, + const std::vector &SharedLibs = std::vector()); -}; + }; +} int JIT::ExecuteProgram(const std::string &Bytecode, const std::vector &Args, @@ -396,5 +399,3 @@ GCC *GCC::create(const std::string &ProgramPath, std::string &Message) { Message = "Found gcc: " + GCCPath + "\n"; return new GCC(GCCPath); } - -} // End llvm namespace -- cgit v1.2.3-70-g09d2 From 5f65adda508bff0e9f40cf6013469c76fdcb1a09 Mon Sep 17 00:00:00 2001 From: Alkis Evlogimenos Date: Thu, 4 Mar 2004 17:50:44 +0000 Subject: Hide variable from other functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12118 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 8a6bd77e40..2c699d9488 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -48,8 +48,9 @@ static Option *getOption(const std::string &Str) { } static std::vector &getPositionalOpts() { - static std::vector Positional; - return Positional; + static std::vector *Positional = 0; + if (!Positional) Positional = new std::vector(); + return *Positional; } static void AddArgument(const char *ArgName, Option *Opt) { -- cgit v1.2.3-70-g09d2 From bf455c236001d5424dbda50fd145352f87f11ec1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 6 May 2004 22:04:31 +0000 Subject: Implement the new cl::PositionalEatsArgs flag, refactor code a bit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13388 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 117 ++++++++++++++++++++++++-------------------- 1 file changed, 65 insertions(+), 52 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 2c699d9488..3454ffc00f 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -213,11 +213,11 @@ static void ParseCStringVector (std::vector &output, /// from the caller (as PROGNAME) and its command-line arguments from /// an environment variable (whose name is given in ENVVAR). /// -void cl::ParseEnvironmentOptions (const char *progName, const char *envVar, - const char *Overview) { +void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, + const char *Overview) { // Check args. - assert (progName && "Program name not specified"); - assert (envVar && "Environment variable name missing"); + assert(progName && "Program name not specified"); + assert(envVar && "Environment variable name missing"); // Get the environment variable they want us to parse options out of. const char *envValue = getenv (envVar); @@ -242,6 +242,29 @@ void cl::ParseEnvironmentOptions (const char *progName, const char *envVar, } } +/// LookupOption - Lookup the option specified by the specified option on the +/// command line. If there is a value specified (after an equal sign) return +/// that as well. +static Option *LookupOption(const char *&Arg, const char *&Value) { + while (*Arg == '-') ++Arg; // Eat leading dashes + + const char *ArgEnd = Arg; + while (*ArgEnd && *ArgEnd != '=') + ++ArgEnd; // Scan till end of argument name... + + Value = ArgEnd; + if (*Value) // If we have an equals sign... + ++Value; // Advance to value... + + if (*Arg == 0) return 0; + + // Look up the option. + std::map &Opts = getOpts(); + std::map::iterator I = + Opts.find(std::string(Arg, ArgEnd)); + return (I != Opts.end()) ? I->second : 0; +} + void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview) { assert((!getOpts().empty() || !getPositionalOpts().empty()) && @@ -335,78 +358,68 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Delay processing positional arguments until the end... continue; } - } else { // We start with a '-', must be an argument... + } else if (argv[i][0] == '-' && argv[i][1] == '-' && argv[i][2] == 0 && + !DashDashFound) { + DashDashFound = true; // This is the mythical "--"? + continue; // Don't try to process it as an argument itself. + } else if (ActivePositionalArg && + (ActivePositionalArg->getMiscFlags() & PositionalEatsArgs)) { + // If there is a positional argument eating options, check to see if this + // option is another positional argument. If so, treat it as an argument, + // otherwise feed it to the eating positional. ArgName = argv[i]+1; - while (*ArgName == '-') ++ArgName; // Eat leading dashes - - if (*ArgName == 0 && !DashDashFound) { // Is this the mythical "--"? - DashDashFound = true; // Yup, take note of that fact... - continue; // Don't try to process it as an argument itself. + Handler = LookupOption(ArgName, Value); + if (!Handler || Handler->getFormattingFlag() != cl::Positional) { + ProvidePositionalOption(ActivePositionalArg, argv[i]); + continue; // We are done! } - const char *ArgNameEnd = ArgName; - while (*ArgNameEnd && *ArgNameEnd != '=') - ++ArgNameEnd; // Scan till end of argument name... - - Value = ArgNameEnd; - if (*Value) // If we have an equals sign... - ++Value; // Advance to value... - - if (*ArgName != 0) { - std::string RealName(ArgName, ArgNameEnd); - // Extract arg name part - std::map::iterator I = Opts.find(RealName); + } else { // We start with a '-', must be an argument... + ArgName = argv[i]+1; + Handler = LookupOption(ArgName, Value); - if (I == Opts.end() && !*Value && RealName.size() > 1) { - // Check to see if this "option" is really a prefixed or grouped - // argument... - // + // Check to see if this "option" is really a prefixed or grouped argument. + if (Handler == 0 && *Value == 0) { + std::string RealName(ArgName); + if (RealName.size() > 1) { unsigned Length = 0; Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping); - + // If the option is a prefixed option, then the value is simply the // rest of the name... so fall through to later processing, by // setting up the argument name flags and value fields. // if (PGOpt && PGOpt->getFormattingFlag() == cl::Prefix) { - ArgNameEnd = ArgName+Length; - Value = ArgNameEnd; - I = Opts.find(std::string(ArgName, ArgNameEnd)); - assert(I->second == PGOpt); + Value = ArgName+Length; + assert(Opts.find(std::string(ArgName, Value)) != Opts.end() && + Opts.find(std::string(ArgName, Value))->second == PGOpt); + Handler = PGOpt; } else if (PGOpt) { - // This must be a grouped option... handle all of them now... + // This must be a grouped option... handle them now. assert(isGrouping(PGOpt) && "Broken getOptionPred!"); - + do { // Move current arg name out of RealName into RealArgName... - std::string RealArgName(RealName.begin(),RealName.begin()+Length); - RealName.erase(RealName.begin(), RealName.begin()+Length); - + std::string RealArgName(RealName.begin(), + RealName.begin() + Length); + RealName.erase(RealName.begin(), RealName.begin() + Length); + // Because ValueRequired is an invalid flag for grouped arguments, // we don't need to pass argc/argv in... // assert(PGOpt->getValueExpectedFlag() != cl::ValueRequired && "Option can not be cl::Grouping AND cl::ValueRequired!"); int Dummy; - ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", - 0, 0, Dummy); - + ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), + "", 0, 0, Dummy); + // Get the next grouping option... - if (!RealName.empty()) - PGOpt = getOptionPred(RealName, Length, isGrouping); - } while (!RealName.empty() && PGOpt); - - if (RealName.empty()) // Processed all of the options, move on - continue; // to the next argv[] value... - - // If RealName is not empty, that means we did not match one of the - // options! This is an error. - // - I = Opts.end(); + PGOpt = getOptionPred(RealName, Length, isGrouping); + } while (PGOpt && Length != RealName.size()); + + Handler = PGOpt; // Ate all of the options. } } - - Handler = I != Opts.end() ? I->second : 0; } } -- cgit v1.2.3-70-g09d2 From 5114004110d771e2cc838be569207784f2519010 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 3 Jul 2004 01:21:05 +0000 Subject: Fix compilation on internix git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14588 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 3454ffc00f..2337e2e255 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -23,6 +23,7 @@ #include #include #include +#include using namespace llvm; using namespace cl; -- cgit v1.2.3-70-g09d2 From f98cfc716d1916e3400d8980c972f75fe47b9061 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 18 Jul 2004 21:56:20 +0000 Subject: Add a workaround for a GCC 3.3.2 bug git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14976 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 2337e2e255..0e0cad96ea 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -69,7 +69,12 @@ static void AddArgument(const char *ArgName, Option *Opt) { // static void RemoveArgument(const char *ArgName, Option *Opt) { if (CommandLineOptions == 0) return; - assert(getOption(ArgName) == Opt && "Arg not in map!"); +#ifndef NDEBUG + // This disgusting HACK is brought to you courtesy of GCC 3.3.2, which ICE's + // If we pass ArgName directly into getOption here. + std::string Tmp = ArgName; + assert(getOption(Tmp) == Opt && "Arg not in map!"); +#endif CommandLineOptions->erase(ArgName); if (CommandLineOptions->empty()) { delete CommandLineOptions; -- cgit v1.2.3-70-g09d2 From 69105f33c190621a6b1ad61f925b1a9e6b0512af Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 4 Aug 2004 00:36:06 +0000 Subject: Add a --version option for every tool that prints out: Low Level Virtual Machine ($PACKAGE_NAME) $PACKAGE_VERSION git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15454 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 0e0cad96ea..131b95a75c 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -16,6 +16,7 @@ // //===----------------------------------------------------------------------===// +#include "Config/config.h" #include "Support/CommandLine.h" #include #include @@ -176,7 +177,7 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { /// them later. /// static void ParseCStringVector (std::vector &output, - const char *input) { + const char *input) { // Characters which will be treated as token separators: static const char *delims = " \v\f\t\r\n"; @@ -891,6 +892,16 @@ public: } }; +class VersionPrinter { +public: + void operator=(bool OptionWasSpecified) { + if (OptionWasSpecified) { + std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " + << PACKAGE_VERSION << " (see http://llvm.org/)\n"; + exit(1); + } + } +}; // Define the two HelpPrinter instances that are used to print out help, or @@ -907,4 +918,10 @@ cl::opt > HHOp("help-hidden", cl::desc("display all available options"), cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); +// Define the --version option that prints out the LLVM version for the tool +VersionPrinter VersionPrinterInstance; +cl::opt > +VersOp("version", cl::desc("display the version"), + cl::location(VersionPrinterInstance), cl::ValueDisallowed); + } // End anonymous namespace -- cgit v1.2.3-70-g09d2 From 1e13fd23d34e53b63cb08c0fe54f0857757ec200 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Fri, 13 Aug 2004 19:47:30 +0000 Subject: Allow any cl::opt to use the method getPosition() to retrieve the option's absolute position on the command line. Similarly allow any cl::list to use the method getPosition(n) to retrieve the absolute position of the nth option in the list. This provides support for two things: (a) options like -l that are actually positional and their order of occurrence matters when they are intermixed with positional arguments like "a.o"; and (b) options like -x LANG which affect only the positional arguments that come after the option. In both cases, knowing the absolute position of a given option helps. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15725 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/Support/CommandLine.h | 58 ++++++++++++++++++++++---------------- include/llvm/Support/CommandLine.h | 58 ++++++++++++++++++++++---------------- lib/Support/CommandLine.cpp | 51 ++++++++++++++++++++------------- 3 files changed, 100 insertions(+), 67 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h index 7455f623ec..053b823669 100644 --- a/include/Support/CommandLine.h +++ b/include/Support/CommandLine.h @@ -51,7 +51,7 @@ void ParseEnvironmentOptions(const char *progName, const char *envvar, // Flags permitted to be passed to command line arguments // -enum NumOccurrences { // Flags for the number of occurrences allowed +enum NumOccurrences { // Flags for the number of occurrences allowed Optional = 0x01, // Zero or One occurrence ZeroOrMore = 0x02, // Zero or more occurrences allowed Required = 0x03, // One occurrence required @@ -103,13 +103,13 @@ enum FormattingFlags { Positional = 0x080, // Is a positional argument, no '-' required Prefix = 0x100, // Can this option directly prefix its value? Grouping = 0x180, // Can this option group with other options? - FormattingMask = 0x180, + FormattingMask = 0x180, // Union of the above flags. }; -enum MiscFlags { // Miscellaneous flags to adjust argument - CommaSeparated = 0x200, // Should this cl::list split between commas? - PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args? - MiscMask = 0x600, +enum MiscFlags { // Miscellaneous flags to adjust argument + CommaSeparated = 0x200, // Should this cl::list split between commas? + PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args? + MiscMask = 0x600, // Union of the above flags. }; @@ -126,7 +126,8 @@ class Option { // an argument. Should return true if there was an error processing the // argument and the program should exit. // - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) = 0; + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) = 0; virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { return Optional; @@ -141,8 +142,9 @@ class Option { return NormalFormatting; } - int NumOccurrences; // The number of times specified + int NumOccurrences; // The number of times specified int Flags; // Flags for the argument + unsigned Position; // Position of last occurrence of the option public: const char *ArgStr; // The argument string itself (ex: "help", "o") const char *HelpStr; // The descriptive text message for --help @@ -171,6 +173,7 @@ public: inline unsigned getMiscFlags() const { return Flags & MiscMask; } + inline unsigned getPosition() const { return Position; } // hasArgStr - Return true if the argstr != "" bool hasArgStr() const { return ArgStr[0] != 0; } @@ -198,8 +201,9 @@ public: void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } void setMiscFlag(enum MiscFlags M) { setFlag(M, M); } + void setPosition(unsigned pos) { Position = pos; } protected: - Option() : NumOccurrences(0), Flags(0), + Option() : NumOccurrences(0), Flags(0), Position(0), ArgStr(""), HelpStr(""), ValueStr("") {} public: @@ -219,7 +223,8 @@ public: // addOccurrence - Wrapper around handleOccurrence that enforces Flags // - bool addOccurrence(const char *ArgName, const std::string &Value); + bool addOccurrence(unsigned pos, const char *ArgName, + const std::string &Value); // Prints option name followed by message. Always returns true. bool error(std::string Message, const char *ArgName = 0); @@ -250,7 +255,6 @@ struct value_desc { void apply(Option &O) const { O.setValueStr(Desc); } }; - // init - Specify a default (initial) value for the command line argument, if // the default constructor for the argument type does not give you what you // want. This is only valid on "opt" arguments, not on "list" arguments. @@ -438,7 +442,7 @@ public: } // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, + bool parse(Option &O, const char *ArgName, const std::string &Arg, DataType &V) { std::string ArgVal; if (hasArgStr) @@ -492,7 +496,6 @@ struct basic_parser_impl { // non-template implementation of basic_parser // void printOptionInfo(const Option &O, unsigned GlobalWidth) const; - // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "value"; } }; @@ -545,8 +548,7 @@ template<> struct parser : public basic_parser { // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, - unsigned &Val); + bool parse(Option &O, const char *AN, const std::string &Arg, unsigned &Val); // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "uint"; } @@ -585,7 +587,7 @@ struct parser : public basic_parser { template<> struct parser : public basic_parser { // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, + bool parse(Option &O, const char *AN, const std::string &Arg, std::string &Value) { Value = Arg; return false; @@ -595,8 +597,6 @@ struct parser : public basic_parser { virtual const char *getValueName() const { return "string"; } }; - - //===----------------------------------------------------------------------===// // applicator class - This class is used because we must use partial // specialization to handle literal string arguments specially (const char* does @@ -728,11 +728,13 @@ class opt : public Option, is_class::value> { ParserClass Parser; - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse error! setValue(Val); + setPosition(pos); return false; } @@ -875,6 +877,7 @@ struct list_storage : public std::vector { template > class list : public Option, public list_storage { + std::vector Positions; ParserClass Parser; virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { @@ -884,11 +887,14 @@ class list : public Option, public list_storage { return Parser.getValueExpectedFlagDefault(); } - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse Error! addValue(Val); + setPosition(pos); + Positions.push_back(pos); return false; } @@ -905,6 +911,11 @@ class list : public Option, public list_storage { public: ParserClass &getParser() { return Parser; } + unsigned getPosition(unsigned optnum) { + assert(optnum < this->size() && "Invalid option index"); + return Positions[optnum]; + } + // One option... template list(const M0t &M0) { @@ -966,16 +977,15 @@ public: } }; - - //===----------------------------------------------------------------------===// // Aliased command line option (alias this name to a preexisting name) // class alias : public Option { Option *AliasFor; - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { - return AliasFor->handleOccurrence(AliasFor->ArgStr, Arg); + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) { + return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); } // Aliases default to be hidden... virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 7455f623ec..053b823669 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -51,7 +51,7 @@ void ParseEnvironmentOptions(const char *progName, const char *envvar, // Flags permitted to be passed to command line arguments // -enum NumOccurrences { // Flags for the number of occurrences allowed +enum NumOccurrences { // Flags for the number of occurrences allowed Optional = 0x01, // Zero or One occurrence ZeroOrMore = 0x02, // Zero or more occurrences allowed Required = 0x03, // One occurrence required @@ -103,13 +103,13 @@ enum FormattingFlags { Positional = 0x080, // Is a positional argument, no '-' required Prefix = 0x100, // Can this option directly prefix its value? Grouping = 0x180, // Can this option group with other options? - FormattingMask = 0x180, + FormattingMask = 0x180, // Union of the above flags. }; -enum MiscFlags { // Miscellaneous flags to adjust argument - CommaSeparated = 0x200, // Should this cl::list split between commas? - PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args? - MiscMask = 0x600, +enum MiscFlags { // Miscellaneous flags to adjust argument + CommaSeparated = 0x200, // Should this cl::list split between commas? + PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args? + MiscMask = 0x600, // Union of the above flags. }; @@ -126,7 +126,8 @@ class Option { // an argument. Should return true if there was an error processing the // argument and the program should exit. // - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) = 0; + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) = 0; virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { return Optional; @@ -141,8 +142,9 @@ class Option { return NormalFormatting; } - int NumOccurrences; // The number of times specified + int NumOccurrences; // The number of times specified int Flags; // Flags for the argument + unsigned Position; // Position of last occurrence of the option public: const char *ArgStr; // The argument string itself (ex: "help", "o") const char *HelpStr; // The descriptive text message for --help @@ -171,6 +173,7 @@ public: inline unsigned getMiscFlags() const { return Flags & MiscMask; } + inline unsigned getPosition() const { return Position; } // hasArgStr - Return true if the argstr != "" bool hasArgStr() const { return ArgStr[0] != 0; } @@ -198,8 +201,9 @@ public: void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } void setMiscFlag(enum MiscFlags M) { setFlag(M, M); } + void setPosition(unsigned pos) { Position = pos; } protected: - Option() : NumOccurrences(0), Flags(0), + Option() : NumOccurrences(0), Flags(0), Position(0), ArgStr(""), HelpStr(""), ValueStr("") {} public: @@ -219,7 +223,8 @@ public: // addOccurrence - Wrapper around handleOccurrence that enforces Flags // - bool addOccurrence(const char *ArgName, const std::string &Value); + bool addOccurrence(unsigned pos, const char *ArgName, + const std::string &Value); // Prints option name followed by message. Always returns true. bool error(std::string Message, const char *ArgName = 0); @@ -250,7 +255,6 @@ struct value_desc { void apply(Option &O) const { O.setValueStr(Desc); } }; - // init - Specify a default (initial) value for the command line argument, if // the default constructor for the argument type does not give you what you // want. This is only valid on "opt" arguments, not on "list" arguments. @@ -438,7 +442,7 @@ public: } // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, + bool parse(Option &O, const char *ArgName, const std::string &Arg, DataType &V) { std::string ArgVal; if (hasArgStr) @@ -492,7 +496,6 @@ struct basic_parser_impl { // non-template implementation of basic_parser // void printOptionInfo(const Option &O, unsigned GlobalWidth) const; - // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "value"; } }; @@ -545,8 +548,7 @@ template<> struct parser : public basic_parser { // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, - unsigned &Val); + bool parse(Option &O, const char *AN, const std::string &Arg, unsigned &Val); // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "uint"; } @@ -585,7 +587,7 @@ struct parser : public basic_parser { template<> struct parser : public basic_parser { // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, + bool parse(Option &O, const char *AN, const std::string &Arg, std::string &Value) { Value = Arg; return false; @@ -595,8 +597,6 @@ struct parser : public basic_parser { virtual const char *getValueName() const { return "string"; } }; - - //===----------------------------------------------------------------------===// // applicator class - This class is used because we must use partial // specialization to handle literal string arguments specially (const char* does @@ -728,11 +728,13 @@ class opt : public Option, is_class::value> { ParserClass Parser; - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse error! setValue(Val); + setPosition(pos); return false; } @@ -875,6 +877,7 @@ struct list_storage : public std::vector { template > class list : public Option, public list_storage { + std::vector Positions; ParserClass Parser; virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { @@ -884,11 +887,14 @@ class list : public Option, public list_storage { return Parser.getValueExpectedFlagDefault(); } - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) { typename ParserClass::parser_data_type Val; if (Parser.parse(*this, ArgName, Arg, Val)) return true; // Parse Error! addValue(Val); + setPosition(pos); + Positions.push_back(pos); return false; } @@ -905,6 +911,11 @@ class list : public Option, public list_storage { public: ParserClass &getParser() { return Parser; } + unsigned getPosition(unsigned optnum) { + assert(optnum < this->size() && "Invalid option index"); + return Positions[optnum]; + } + // One option... template list(const M0t &M0) { @@ -966,16 +977,15 @@ public: } }; - - //===----------------------------------------------------------------------===// // Aliased command line option (alias this name to a preexisting name) // class alias : public Option { Option *AliasFor; - virtual bool handleOccurrence(const char *ArgName, const std::string &Arg) { - return AliasFor->handleOccurrence(AliasFor->ArgStr, Arg); + virtual bool handleOccurrence(unsigned pos, const char *ArgName, + const std::string &Arg) { + return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); } // Aliases default to be hidden... virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 131b95a75c..13de27eb5d 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -111,11 +111,12 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, } // Run the handler now! - return Handler->addOccurrence(ArgName, Value); + return Handler->addOccurrence(i, ArgName, Value); } -static bool ProvidePositionalOption(Option *Handler, const std::string &Arg) { - int Dummy; +static bool ProvidePositionalOption(Option *Handler, const std::string &Arg, + int i) { + int Dummy = i; return ProvideOption(Handler, Handler->ArgStr, Arg.c_str(), 0, 0, Dummy); } @@ -323,10 +324,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } } - // PositionalVals - A vector of "positional" arguments we accumulate into to - // processes at the end... + // PositionalVals - A vector of "positional" arguments we accumulate into + // the process at the end... // - std::vector PositionalVals; + std::vector > PositionalVals; // If the program has named positional arguments, and the name has been run // across, keep track of which positional argument was named. Otherwise put @@ -347,10 +348,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (argv[i][0] != '-' || argv[i][1] == 0 || DashDashFound) { // Positional argument! if (ActivePositionalArg) { - ProvidePositionalOption(ActivePositionalArg, argv[i]); + ProvidePositionalOption(ActivePositionalArg, argv[i], i); continue; // We are done! } else if (!PositionalOpts.empty()) { - PositionalVals.push_back(argv[i]); + PositionalVals.push_back(std::make_pair(argv[i],i)); // All of the positional arguments have been fulfulled, give the rest to // the consume after option... if it's specified... @@ -358,7 +359,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (PositionalVals.size() >= NumPositionalRequired && ConsumeAfterOpt != 0) { for (++i; i < argc; ++i) - PositionalVals.push_back(argv[i]); + PositionalVals.push_back(std::make_pair(argv[i],i)); break; // Handle outside of the argument processing loop... } @@ -377,7 +378,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ArgName = argv[i]+1; Handler = LookupOption(ArgName, Value); if (!Handler || Handler->getFormattingFlag() != cl::Positional) { - ProvidePositionalOption(ActivePositionalArg, argv[i]); + ProvidePositionalOption(ActivePositionalArg, argv[i], i); continue; // We are done! } @@ -479,7 +480,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, unsigned ValNo = 0, NumVals = PositionalVals.size(); for (unsigned i = 0, e = PositionalOpts.size(); i != e; ++i) { if (RequiresValue(PositionalOpts[i])) { - ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); + ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo].first, + PositionalVals[ValNo].second); + ValNo++; --NumPositionalRequired; // We fulfilled our duty... } @@ -495,7 +498,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // FALL THROUGH case cl::ZeroOrMore: // Zero or more will take all they can get... case cl::OneOrMore: // One or more will take all they can get... - ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo++]); + ProvidePositionalOption(PositionalOpts[i], + PositionalVals[ValNo].first, + PositionalVals[ValNo].second); + ValNo++; break; default: assert(0 && "Internal error, unexpected NumOccurrences flag in " @@ -507,24 +513,31 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, assert(ConsumeAfterOpt && NumPositionalRequired <= PositionalVals.size()); unsigned ValNo = 0; for (unsigned j = 1, e = PositionalOpts.size(); j != e; ++j) - if (RequiresValue(PositionalOpts[j])) + if (RequiresValue(PositionalOpts[j])) { ErrorParsing |= ProvidePositionalOption(PositionalOpts[j], - PositionalVals[ValNo++]); + PositionalVals[ValNo].first, + PositionalVals[ValNo].second); + ValNo++; + } // Handle the case where there is just one positional option, and it's // optional. In this case, we want to give JUST THE FIRST option to the // positional option and keep the rest for the consume after. The above // loop would have assigned no values to positional options in this case. // - if (PositionalOpts.size() == 2 && ValNo == 0 && !PositionalVals.empty()) + if (PositionalOpts.size() == 2 && ValNo == 0 && !PositionalVals.empty()) { ErrorParsing |= ProvidePositionalOption(PositionalOpts[1], - PositionalVals[ValNo++]); + PositionalVals[ValNo].first, + PositionalVals[ValNo].second); + ValNo++; + } // Handle over all of the rest of the arguments to the // cl::ConsumeAfter command line option... for (; ValNo != PositionalVals.size(); ++ValNo) ErrorParsing |= ProvidePositionalOption(ConsumeAfterOpt, - PositionalVals[ValNo]); + PositionalVals[ValNo].first, + PositionalVals[ValNo].second); } // Loop over args and make sure all required args are specified! @@ -567,7 +580,7 @@ bool Option::error(std::string Message, const char *ArgName) { return true; } -bool Option::addOccurrence(const char *ArgName, const std::string &Value) { +bool Option::addOccurrence(unsigned pos, const char *ArgName, const std::string &Value) { NumOccurrences++; // Increment the number of times we have been seen switch (getNumOccurrencesFlag()) { @@ -585,7 +598,7 @@ bool Option::addOccurrence(const char *ArgName, const std::string &Value) { default: return error(": bad num occurrences flag value!"); } - return handleOccurrence(ArgName, Value); + return handleOccurrence(pos, ArgName, Value); } // addArgument - Tell the system that this Option subclass will handle all -- cgit v1.2.3-70-g09d2 From e1cc150a8e6b451e42b04b04ffb41596e01bbef5 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 1 Sep 2004 04:41:28 +0000 Subject: Make CommandLine prefix error output with the name of the program. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16129 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 13de27eb5d..3bc9cbf1ca 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -29,6 +29,10 @@ using namespace llvm; using namespace cl; +// Globals for name and overview of program +static const char *ProgramName = ""; +static const char *ProgramOverview = 0; + //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery... // @@ -57,8 +61,8 @@ static std::vector &getPositionalOpts() { static void AddArgument(const char *ArgName, Option *Opt) { if (getOption(ArgName)) { - std::cerr << "CommandLine Error: Argument '" << ArgName - << "' defined more than once!\n"; + std::cerr << ProgramName << ": CommandLine Error: Argument '" + << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! getOpts()[ArgName] = Opt; @@ -83,9 +87,6 @@ static void RemoveArgument(const char *ArgName, Option *Opt) { } } -static const char *ProgramName = 0; -static const char *ProgramOverview = 0; - static inline bool ProvideOption(Option *Handler, const char *ArgName, const char *Value, int argc, char **argv, int &i) { @@ -105,9 +106,14 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->error(" does not allow a value! '" + std::string(Value) + "' specified."); break; - case ValueOptional: break; - default: std::cerr << "Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << "\n"; abort(); + case ValueOptional: + break; + default: + std::cerr << ProgramName + << ": Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << "\n"; + abort(); + break; } // Run the handler now! @@ -432,8 +438,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - std::cerr << "Unknown command line argument '" << argv[i] << "'. Try: '" - << argv[0] << " --help'\n"; + std::cerr << ProgramName << ": Unknown command line argument '" << argv[i] + << "'. Try: '" << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -469,7 +475,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - std::cerr << "Not enough positional command line arguments specified!\n" + std::cerr << ProgramName + << ": Not enough positional command line arguments specified!\n" << "Must specify at least " << NumPositionalRequired << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; @@ -575,8 +582,8 @@ bool Option::error(std::string Message, const char *ArgName) { if (ArgName[0] == 0) std::cerr << HelpStr; // Be nice for positional arguments else - std::cerr << "-" << ArgName; - std::cerr << " option" << Message << "\n"; + std::cerr << ProgramName << ": for the -" << ArgName; + std::cerr << " option: " << Message << "\n"; return true; } -- cgit v1.2.3-70-g09d2 From 551ccae044b0ff658fe629dd67edd5ffe75d10e8 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 1 Sep 2004 22:55:40 +0000 Subject: Changes For Bug 352 Move include/Config and include/Support into include/llvm/Config, include/llvm/ADT and include/llvm/Support. From here on out, all LLVM public header files must be under include/llvm/. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@16137 91177308-0d34-0410-b5e6-96231b3b80d8 --- autoconf/configure.ac | 14 +- configure | 18 +- include/Config/alloca.h | 47 - include/Config/config.h.in | 240 ----- include/Config/dlfcn.h | 23 - include/Config/fcntl.h | 23 - include/Config/limits.h | 23 - include/Config/malloc.h | 25 - include/Config/memory.h | 23 - include/Config/pagesize.h | 49 - include/Config/stdint.h | 23 - include/Config/sys/mman.h | 32 - include/Config/sys/resource.h | 34 - include/Config/sys/stat.h | 29 - include/Config/sys/time.h | 24 - include/Config/sys/types.h | 25 - include/Config/sys/wait.h | 24 - include/Config/time.h | 33 - include/Config/unistd.h | 28 - include/Config/windows.h | 25 - include/Support/Annotation.h | 217 ---- include/Support/BitSetVector.h | 272 ----- include/Support/Casting.h | 301 ------ include/Support/CommandLine.h | 1049 -------------------- include/Support/DOTGraphTraits.h | 102 -- include/Support/DataTypes.h.in | 64 -- include/Support/Debug.h | 67 -- include/Support/DenseMap.h | 73 -- include/Support/DepthFirstIterator.h | 230 ----- include/Support/DynamicLinker.h | 40 - include/Support/ELF.h | 295 ------ include/Support/EquivalenceClasses.h | 116 --- include/Support/FileUtilities.h | 170 ---- include/Support/GraphTraits.h | 83 -- include/Support/GraphWriter.h | 216 ---- include/Support/HashExtras.h | 41 - include/Support/LeakDetector.h | 91 -- include/Support/MallocAllocator.h | 85 -- include/Support/MathExtras.h | 59 -- include/Support/PluginLoader.h | 35 - include/Support/PostOrderIterator.h | 156 --- include/Support/SCCIterator.h | 199 ---- include/Support/STLExtras.h | 310 ------ include/Support/SetOperations.h | 71 -- include/Support/SetVector.h | 138 --- include/Support/SlowOperationInformer.h | 65 -- include/Support/Statistic.h | 89 -- include/Support/StringExtras.h | 125 --- include/Support/SystemUtils.h | 65 -- include/Support/ThreadSupport-NoSupport.h | 34 - include/Support/ThreadSupport-PThreads.h | 42 - include/Support/ThreadSupport.h.in | 40 - include/Support/Timer.h | 164 --- include/Support/Tree.h | 62 -- include/Support/TypeInfo.h | 76 -- include/Support/VectorExtras.h | 40 - include/Support/hash_map.in | 66 -- include/Support/hash_set.in | 67 -- include/Support/ilist | 638 ------------ include/Support/iterator.in | 66 -- include/Support/type_traits.h | 54 - include/llvm/ADT/BitSetVector.h | 6 +- include/llvm/ADT/DenseMap.h | 6 +- include/llvm/ADT/DepthFirstIterator.h | 12 +- include/llvm/ADT/EquivalenceClasses.h | 6 +- include/llvm/ADT/GraphTraits.h | 6 +- include/llvm/ADT/HashExtras.h | 8 +- include/llvm/ADT/IndexedMap.h | 6 +- include/llvm/ADT/PostOrderIterator.h | 12 +- include/llvm/ADT/SCCIterator.h | 12 +- include/llvm/ADT/STLExtras.h | 8 +- include/llvm/ADT/SetOperations.h | 6 +- include/llvm/ADT/SetVector.h | 6 +- include/llvm/ADT/Statistic.h | 6 +- include/llvm/ADT/StringExtras.h | 8 +- include/llvm/ADT/Tree.h | 6 +- include/llvm/ADT/VectorExtras.h | 6 +- include/llvm/ADT/hash_map.in | 8 +- include/llvm/ADT/hash_set.in | 8 +- include/llvm/ADT/ilist | 8 +- include/llvm/ADT/iterator.in | 6 +- include/llvm/Analysis/AliasSetTracker.h | 6 +- include/llvm/Analysis/CallGraph.h | 4 +- include/llvm/Analysis/ConstantsScanner.h | 2 +- .../llvm/Analysis/DataStructure/DSGraphTraits.h | 6 +- include/llvm/Analysis/DataStructure/DSSupport.h | 2 +- .../llvm/Analysis/DataStructure/DataStructure.h | 2 +- include/llvm/Analysis/Interval.h | 2 +- include/llvm/Analysis/LoopInfo.h | 2 +- include/llvm/BasicBlock.h | 2 +- include/llvm/CodeGen/MachineBasicBlock.h | 4 +- include/llvm/CodeGen/MachineCodeEmitter.h | 2 +- include/llvm/CodeGen/MachineFunction.h | 2 +- include/llvm/CodeGen/MachineInstr.h | 2 +- include/llvm/CodeGen/SSARegMap.h | 2 +- include/llvm/CodeGen/SchedGraphCommon.h | 2 +- include/llvm/CodeGen/SelectionDAG.h | 2 +- include/llvm/Config/alloca.h | 2 +- include/llvm/Config/config.h.in | 2 +- include/llvm/Config/dlfcn.h | 2 +- include/llvm/Config/fcntl.h | 2 +- include/llvm/Config/limits.h | 2 +- include/llvm/Config/malloc.h | 2 +- include/llvm/Config/memory.h | 2 +- include/llvm/Config/pagesize.h | 2 +- include/llvm/Config/stdint.h | 2 +- include/llvm/Config/sys/mman.h | 2 +- include/llvm/Config/sys/resource.h | 6 +- include/llvm/Config/sys/stat.h | 2 +- include/llvm/Config/sys/time.h | 2 +- include/llvm/Config/sys/types.h | 2 +- include/llvm/Config/sys/wait.h | 2 +- include/llvm/Config/time.h | 2 +- include/llvm/Config/unistd.h | 2 +- include/llvm/Config/windows.h | 2 +- include/llvm/Constants.h | 2 +- include/llvm/ExecutionEngine/GenericValue.h | 2 +- include/llvm/Function.h | 2 +- include/llvm/Support/Annotation.h | 6 +- include/llvm/Support/CFG.h | 4 +- include/llvm/Support/Casting.h | 6 +- include/llvm/Support/CommandLine.h | 8 +- include/llvm/Support/ConstantRange.h | 2 +- include/llvm/Support/DOTGraphTraits.h | 6 +- include/llvm/Support/Debug.h | 6 +- include/llvm/Support/DynamicLinker.h | 6 +- include/llvm/Support/ELF.h | 9 +- include/llvm/Support/FileUtilities.h | 6 +- include/llvm/Support/GraphWriter.h | 10 +- include/llvm/Support/LeakDetector.h | 6 +- include/llvm/Support/MallocAllocator.h | 6 +- include/llvm/Support/Mangler.h | 2 +- include/llvm/Support/MathExtras.h | 8 +- include/llvm/Support/MutexGuard.h | 4 +- include/llvm/Support/PassNameParser.h | 2 +- include/llvm/Support/PluginLoader.h | 8 +- include/llvm/Support/SlowOperationInformer.h | 6 +- include/llvm/Support/SystemUtils.h | 4 +- include/llvm/Support/ThreadSupport-NoSupport.h | 4 +- include/llvm/Support/ThreadSupport-PThreads.h | 4 +- include/llvm/Support/ThreadSupport.h.in | 4 +- include/llvm/Support/Timer.h | 6 +- include/llvm/Support/ToolRunner.h | 8 +- include/llvm/Support/TypeInfo.h | 6 +- include/llvm/Support/type_traits.h | 2 +- include/llvm/Target/TargetData.h | 2 +- include/llvm/Target/TargetInstrInfo.h | 2 +- include/llvm/Target/TargetMachineRegistry.h | 2 +- include/llvm/Target/TargetSchedInfo.h | 2 +- include/llvm/Type.h | 6 +- include/llvm/Use.h | 2 +- include/llvm/Value.h | 2 +- lib/Analysis/AliasAnalysisEvaluator.cpp | 2 +- lib/Analysis/CFGPrinter.cpp | 2 +- lib/Analysis/DataStructure/BottomUpClosure.cpp | 4 +- lib/Analysis/DataStructure/CompleteBottomUp.cpp | 8 +- lib/Analysis/DataStructure/DataStructure.cpp | 12 +- lib/Analysis/DataStructure/DataStructureOpt.cpp | 2 +- lib/Analysis/DataStructure/DataStructureStats.cpp | 2 +- lib/Analysis/DataStructure/DependenceGraph.h | 2 +- lib/Analysis/DataStructure/GraphChecker.cpp | 2 +- lib/Analysis/DataStructure/IPModRef.cpp | 6 +- lib/Analysis/DataStructure/IPModRef.h | 4 +- lib/Analysis/DataStructure/Local.cpp | 6 +- lib/Analysis/DataStructure/MemoryDepAnalysis.cpp | 10 +- lib/Analysis/DataStructure/MemoryDepAnalysis.h | 2 +- lib/Analysis/DataStructure/Parallelize.cpp | 8 +- lib/Analysis/DataStructure/PgmDependenceGraph.h | 2 +- lib/Analysis/DataStructure/Printer.cpp | 6 +- lib/Analysis/DataStructure/Steensgaard.cpp | 2 +- lib/Analysis/DataStructure/TopDownClosure.cpp | 4 +- lib/Analysis/IPA/Andersens.cpp | 4 +- lib/Analysis/IPA/CallGraph.cpp | 2 +- lib/Analysis/IPA/CallGraphSCCPass.cpp | 2 +- lib/Analysis/IPA/FindUnsafePointerTypes.cpp | 2 +- lib/Analysis/IPA/GlobalsModRef.cpp | 6 +- lib/Analysis/IPA/PrintSCC.cpp | 2 +- lib/Analysis/InstCount.cpp | 2 +- lib/Analysis/IntervalPartition.cpp | 2 +- lib/Analysis/LoopInfo.cpp | 2 +- lib/Analysis/PostDominators.cpp | 4 +- lib/Analysis/ProfileInfoLoaderPass.cpp | 2 +- lib/Analysis/ScalarEvolution.cpp | 4 +- lib/Archive/ArchiveReader.cpp | 2 +- lib/AsmParser/ParserInternals.h | 2 +- lib/AsmParser/llvmAsmParser.y | 2 +- lib/Bytecode/Archive/ArchiveReader.cpp | 2 +- lib/Bytecode/Reader/ArchiveReader.cpp | 2 +- lib/Bytecode/Reader/Reader.cpp | 14 +- lib/Bytecode/Reader/ReaderWrappers.cpp | 6 +- lib/Bytecode/Writer/SlotCalculator.cpp | 4 +- lib/Bytecode/Writer/Writer.cpp | 4 +- lib/Bytecode/Writer/WriterInternals.h | 2 +- lib/CodeGen/BranchFolding.cpp | 2 +- lib/CodeGen/InstrSched/InstrScheduling.cpp | 2 +- lib/CodeGen/InstrSched/SchedGraph.cpp | 2 +- lib/CodeGen/InstrSched/SchedGraph.h | 4 +- lib/CodeGen/InstrSched/SchedGraphCommon.cpp | 2 +- lib/CodeGen/InstrSched/SchedPriorities.cpp | 2 +- lib/CodeGen/InstrSched/SchedPriorities.h | 2 +- lib/CodeGen/LiveInterval.cpp | 2 +- lib/CodeGen/LiveIntervalAnalysis.cpp | 8 +- lib/CodeGen/LiveVariables.cpp | 4 +- lib/CodeGen/MachineBasicBlock.cpp | 2 +- lib/CodeGen/MachineFunction.cpp | 4 +- lib/CodeGen/MachineInstr.cpp | 2 +- lib/CodeGen/ModuloScheduling/MSSchedule.cpp | 2 +- lib/CodeGen/ModuloScheduling/MSchedGraph.cpp | 2 +- lib/CodeGen/ModuloScheduling/MSchedGraph.h | 6 +- lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp | 6 +- lib/CodeGen/PHIElimination.cpp | 4 +- lib/CodeGen/Passes.cpp | 2 +- lib/CodeGen/RegAllocIterativeScan.cpp | 6 +- lib/CodeGen/RegAllocLinearScan.cpp | 6 +- lib/CodeGen/RegAllocLocal.cpp | 8 +- lib/CodeGen/RegAllocSimple.cpp | 6 +- lib/CodeGen/TwoAddressInstructionPass.cpp | 6 +- lib/CodeGen/UnreachableBlockElim.cpp | 2 +- lib/CodeGen/VirtRegMap.cpp | 10 +- lib/CodeGen/VirtRegMap.h | 2 +- lib/Debugger/Debugger.cpp | 2 +- lib/Debugger/ProgramInfo.cpp | 6 +- lib/Debugger/SourceFile.cpp | 4 +- lib/Debugger/UnixLocalInferiorProcess.cpp | 4 +- lib/ExecutionEngine/ExecutionEngine.cpp | 6 +- lib/ExecutionEngine/Interpreter/Execution.cpp | 4 +- .../Interpreter/ExternalFunctions.cpp | 2 +- lib/ExecutionEngine/Interpreter/Interpreter.h | 2 +- lib/ExecutionEngine/JIT/Intercept.cpp | 2 +- lib/ExecutionEngine/JIT/JIT.cpp | 2 +- lib/ExecutionEngine/JIT/JITEmitter.cpp | 6 +- lib/Linker/LinkArchives.cpp | 8 +- lib/Support/Annotation.cpp | 2 +- lib/Support/CommandLine.cpp | 4 +- lib/Support/Debug.cpp | 4 +- lib/Support/DynamicLinker.cpp | 6 +- lib/Support/FileUtilities.cpp | 16 +- lib/Support/IsInf.cpp | 2 +- lib/Support/IsNAN.cpp | 2 +- lib/Support/PluginLoader.cpp | 4 +- lib/Support/SlowOperationInformer.cpp | 4 +- lib/Support/Statistic.cpp | 4 +- lib/Support/StringExtras.cpp | 2 +- lib/Support/SystemUtils.cpp | 18 +- lib/Support/Timer.cpp | 14 +- lib/Support/ToolRunner.cpp | 6 +- lib/System/Unix/Path.cpp | 2 +- lib/System/Unix/Path.inc | 2 +- lib/System/Unix/Program.cpp | 2 +- lib/System/Unix/Program.inc | 2 +- lib/System/Unix/Unix.h | 2 +- lib/Target/CBackend/CBackend.cpp | 6 +- lib/Target/CBackend/Writer.cpp | 6 +- lib/Target/PowerPC/PPC32AsmPrinter.cpp | 8 +- lib/Target/PowerPC/PPC32ISelSimple.cpp | 4 +- lib/Target/PowerPC/PPC64AsmPrinter.cpp | 10 +- lib/Target/PowerPC/PPC64ISelSimple.cpp | 4 +- lib/Target/PowerPC/PPC64RegisterInfo.cpp | 6 +- lib/Target/PowerPC/PPCAsmPrinter.cpp | 8 +- lib/Target/PowerPC/PPCBranchSelector.cpp | 2 +- lib/Target/PowerPC/PPCCodeEmitter.cpp | 2 +- lib/Target/PowerPC/PPCRegisterInfo.cpp | 6 +- lib/Target/PowerPC/PPCTargetMachine.cpp | 2 +- lib/Target/SparcV9/InstrSched/InstrScheduling.cpp | 2 +- lib/Target/SparcV9/InstrSched/SchedGraph.cpp | 2 +- lib/Target/SparcV9/InstrSched/SchedGraph.h | 4 +- lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp | 2 +- lib/Target/SparcV9/InstrSched/SchedPriorities.cpp | 2 +- lib/Target/SparcV9/InstrSched/SchedPriorities.h | 2 +- lib/Target/SparcV9/LiveVar/BBLiveVar.cpp | 2 +- lib/Target/SparcV9/LiveVar/BBLiveVar.h | 2 +- lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp | 6 +- lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.h | 2 +- lib/Target/SparcV9/MachineFunctionInfo.h | 4 +- lib/Target/SparcV9/MappingInfo.cpp | 2 +- lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp | 2 +- .../SparcV9/ModuloScheduling/MSchedGraph.cpp | 2 +- lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h | 6 +- .../SparcV9/ModuloScheduling/ModuloScheduling.cpp | 6 +- lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp | 2 +- lib/Target/SparcV9/RegAlloc/LiveRange.h | 2 +- lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp | 2 +- lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h | 2 +- lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp | 6 +- lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 4 +- lib/Target/SparcV9/SparcV9BurgISel.cpp | 12 +- lib/Target/SparcV9/SparcV9CodeEmitter.cpp | 8 +- lib/Target/SparcV9/SparcV9Internals.h | 2 +- lib/Target/SparcV9/SparcV9PeepholeOpts.cpp | 2 +- lib/Target/SparcV9/SparcV9RegInfo.h | 2 +- lib/Target/SparcV9/SparcV9TargetMachine.cpp | 2 +- lib/Target/SparcV9/SparcV9TmpInstr.cpp | 2 +- lib/Target/TargetData.cpp | 2 +- lib/Target/TargetMachine.cpp | 2 +- lib/Target/X86/X86AsmPrinter.cpp | 6 +- lib/Target/X86/X86CodeEmitter.cpp | 6 +- lib/Target/X86/X86FloatingPoint.cpp | 8 +- lib/Target/X86/X86ISelSimple.cpp | 2 +- lib/Target/X86/X86PeepholeOpt.cpp | 4 +- lib/Target/X86/X86RegisterInfo.cpp | 4 +- lib/Target/X86/X86TargetMachine.cpp | 4 +- lib/Transforms/ExprTypeConvert.cpp | 4 +- lib/Transforms/IPO/ArgumentPromotion.cpp | 8 +- lib/Transforms/IPO/ConstantMerge.cpp | 2 +- lib/Transforms/IPO/DeadArgumentElimination.cpp | 6 +- lib/Transforms/IPO/DeadTypeElimination.cpp | 2 +- lib/Transforms/IPO/FunctionResolution.cpp | 2 +- lib/Transforms/IPO/GlobalDCE.cpp | 2 +- lib/Transforms/IPO/GlobalOpt.cpp | 4 +- lib/Transforms/IPO/IPConstantPropagation.cpp | 2 +- lib/Transforms/IPO/Inliner.cpp | 6 +- lib/Transforms/IPO/Internalize.cpp | 6 +- lib/Transforms/IPO/LoopExtractor.cpp | 2 +- lib/Transforms/IPO/LowerSetJmp.cpp | 8 +- lib/Transforms/IPO/PruneEH.cpp | 2 +- lib/Transforms/IPO/RaiseAllocations.cpp | 2 +- .../Instrumentation/ProfilePaths/Graph.cpp | 2 +- .../ProfilePaths/GraphAuxiliary.cpp | 2 +- .../Instrumentation/ProfilePaths/InstLoops.cpp | 2 +- .../Instrumentation/TraceBasicBlocks.cpp | 2 +- lib/Transforms/Instrumentation/TraceValues.cpp | 4 +- lib/Transforms/LevelRaise.cpp | 8 +- lib/Transforms/Scalar/ADCE.cpp | 8 +- lib/Transforms/Scalar/BasicBlockPlacement.cpp | 2 +- lib/Transforms/Scalar/ConstantProp.cpp | 2 +- lib/Transforms/Scalar/CorrelatedExprs.cpp | 6 +- lib/Transforms/Scalar/DCE.cpp | 2 +- lib/Transforms/Scalar/DeadStoreElimination.cpp | 4 +- lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp | 4 +- lib/Transforms/Scalar/GCSE.cpp | 4 +- lib/Transforms/Scalar/IndVarSimplify.cpp | 4 +- lib/Transforms/Scalar/InstructionCombining.cpp | 4 +- lib/Transforms/Scalar/LICM.cpp | 6 +- lib/Transforms/Scalar/LoopUnroll.cpp | 8 +- lib/Transforms/Scalar/LoopUnswitch.cpp | 4 +- lib/Transforms/Scalar/LowerPacked.cpp | 2 +- lib/Transforms/Scalar/PRE.cpp | 10 +- lib/Transforms/Scalar/PiNodeInsertion.cpp | 2 +- lib/Transforms/Scalar/Reassociate.cpp | 6 +- lib/Transforms/Scalar/SCCP.cpp | 8 +- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 6 +- lib/Transforms/Scalar/SimplifyCFG.cpp | 2 +- lib/Transforms/Scalar/TailDuplication.cpp | 6 +- lib/Transforms/Scalar/TailRecursionElimination.cpp | 2 +- lib/Transforms/Utils/BreakCriticalEdges.cpp | 2 +- lib/Transforms/Utils/CodeExtractor.cpp | 6 +- lib/Transforms/Utils/Local.cpp | 2 +- lib/Transforms/Utils/LoopSimplify.cpp | 8 +- lib/Transforms/Utils/LowerAllocations.cpp | 2 +- lib/Transforms/Utils/LowerInvoke.cpp | 4 +- lib/Transforms/Utils/LowerSelect.cpp | 2 +- lib/Transforms/Utils/LowerSwitch.cpp | 4 +- lib/Transforms/Utils/Mem2Reg.cpp | 2 +- lib/Transforms/Utils/PromoteMemoryToRegister.cpp | 2 +- lib/Transforms/Utils/SimplifyCFG.cpp | 2 +- lib/VMCore/AsmWriter.cpp | 4 +- lib/VMCore/BasicBlock.cpp | 2 +- lib/VMCore/Constants.cpp | 2 +- lib/VMCore/Dominators.cpp | 4 +- lib/VMCore/Function.cpp | 2 +- lib/VMCore/Globals.cpp | 2 +- lib/VMCore/Instruction.cpp | 2 +- lib/VMCore/LeakDetector.cpp | 2 +- lib/VMCore/Mangler.cpp | 2 +- lib/VMCore/Module.cpp | 4 +- lib/VMCore/Pass.cpp | 4 +- lib/VMCore/PassManagerT.h | 6 +- lib/VMCore/SymbolTable.cpp | 2 +- lib/VMCore/Type.cpp | 6 +- lib/VMCore/Value.cpp | 2 +- lib/VMCore/Verifier.cpp | 2 +- projects/Stacker/lib/compiler/StackerParser.y | 4 +- projects/Stacker/lib/runtime/Makefile | 3 +- projects/Stacker/tools/stkrc/stkrc.cpp | 2 +- projects/sample/lib/sample/sample.c | 2 +- runtime/libtrace/tracelib.c | 2 +- tools/analyze/GraphPrinters.cpp | 2 +- tools/analyze/PrintSCC.cpp | 2 +- tools/analyze/analyze.cpp | 4 +- tools/bugpoint/BugDriver.cpp | 4 +- tools/bugpoint/CrashDebugger.cpp | 2 +- tools/bugpoint/ExecutionDriver.cpp | 8 +- tools/bugpoint/ExtractFunction.cpp | 6 +- tools/bugpoint/Miscompilation.cpp | 4 +- tools/bugpoint/OptimizerDriver.cpp | 2 +- tools/bugpoint/ToolRunner.cpp | 6 +- tools/bugpoint/ToolRunner.h | 8 +- tools/bugpoint/bugpoint.cpp | 19 +- tools/extract/extract.cpp | 2 +- tools/gccas/gccas.cpp | 2 +- tools/gccld/GenerateCode.cpp | 4 +- tools/gccld/Linker.cpp | 8 +- tools/gccld/gccld.cpp | 6 +- tools/llc/llc.cpp | 4 +- tools/llee/ExecveHandler.c | 2 +- tools/llee/OSInterface.h | 2 +- tools/llee/StorageProxy.c | 8 +- tools/llee/SysUtils.c | 12 +- tools/lli/lli.cpp | 4 +- tools/llvm-ar/llvm-ar.cpp | 4 +- tools/llvm-as/llvm-as.cpp | 2 +- tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp | 2 +- tools/llvm-db/CLIDebugger.cpp | 2 +- tools/llvm-db/Commands.cpp | 4 +- tools/llvm-db/llvm-db.cpp | 4 +- tools/llvm-dis/llvm-dis.cpp | 2 +- tools/llvm-extract/llvm-extract.cpp | 2 +- tools/llvm-link/llvm-link.cpp | 4 +- tools/llvm-nm/llvm-nm.cpp | 4 +- tools/llvm-prof/llvm-prof.cpp | 2 +- tools/llvm-stub/llvm-stub.c | 2 +- tools/llvmc/CompilerDriver.cpp | 6 +- tools/llvmc/Configuration.cpp | 6 +- tools/llvmc/Configuration.h | 2 +- tools/llvmc/llvmc.cpp | 2 +- tools/opt/GraphPrinters.cpp | 2 +- tools/opt/PrintSCC.cpp | 2 +- tools/opt/opt.cpp | 4 +- utils/TableGen/CodeEmitterGen.cpp | 2 +- utils/TableGen/FileParser.y | 2 +- utils/TableGen/InstrSelectorEmitter.cpp | 4 +- utils/TableGen/RegisterInfoEmitter.cpp | 4 +- utils/TableGen/TableGen.cpp | 4 +- utils/fpcmp/fpcmp.cpp | 4 +- 424 files changed, 766 insertions(+), 7662 deletions(-) delete mode 100644 include/Config/alloca.h delete mode 100644 include/Config/config.h.in delete mode 100644 include/Config/dlfcn.h delete mode 100644 include/Config/fcntl.h delete mode 100644 include/Config/limits.h delete mode 100644 include/Config/malloc.h delete mode 100644 include/Config/memory.h delete mode 100644 include/Config/pagesize.h delete mode 100644 include/Config/stdint.h delete mode 100644 include/Config/sys/mman.h delete mode 100644 include/Config/sys/resource.h delete mode 100644 include/Config/sys/stat.h delete mode 100644 include/Config/sys/time.h delete mode 100644 include/Config/sys/types.h delete mode 100644 include/Config/sys/wait.h delete mode 100644 include/Config/time.h delete mode 100644 include/Config/unistd.h delete mode 100644 include/Config/windows.h delete mode 100644 include/Support/Annotation.h delete mode 100644 include/Support/BitSetVector.h delete mode 100644 include/Support/Casting.h delete mode 100644 include/Support/CommandLine.h delete mode 100644 include/Support/DOTGraphTraits.h delete mode 100644 include/Support/DataTypes.h.in delete mode 100644 include/Support/Debug.h delete mode 100644 include/Support/DenseMap.h delete mode 100644 include/Support/DepthFirstIterator.h delete mode 100644 include/Support/DynamicLinker.h delete mode 100644 include/Support/ELF.h delete mode 100644 include/Support/EquivalenceClasses.h delete mode 100644 include/Support/FileUtilities.h delete mode 100644 include/Support/GraphTraits.h delete mode 100644 include/Support/GraphWriter.h delete mode 100644 include/Support/HashExtras.h delete mode 100644 include/Support/LeakDetector.h delete mode 100644 include/Support/MallocAllocator.h delete mode 100644 include/Support/MathExtras.h delete mode 100644 include/Support/PluginLoader.h delete mode 100644 include/Support/PostOrderIterator.h delete mode 100644 include/Support/SCCIterator.h delete mode 100644 include/Support/STLExtras.h delete mode 100644 include/Support/SetOperations.h delete mode 100644 include/Support/SetVector.h delete mode 100644 include/Support/SlowOperationInformer.h delete mode 100644 include/Support/Statistic.h delete mode 100644 include/Support/StringExtras.h delete mode 100644 include/Support/SystemUtils.h delete mode 100644 include/Support/ThreadSupport-NoSupport.h delete mode 100644 include/Support/ThreadSupport-PThreads.h delete mode 100644 include/Support/ThreadSupport.h.in delete mode 100644 include/Support/Timer.h delete mode 100644 include/Support/Tree.h delete mode 100644 include/Support/TypeInfo.h delete mode 100644 include/Support/VectorExtras.h delete mode 100644 include/Support/hash_map.in delete mode 100644 include/Support/hash_set.in delete mode 100644 include/Support/ilist delete mode 100644 include/Support/iterator.in delete mode 100644 include/Support/type_traits.h (limited to 'lib/Support/CommandLine.cpp') diff --git a/autoconf/configure.ac b/autoconf/configure.ac index 603a7c520b..86cf136939 100644 --- a/autoconf/configure.ac +++ b/autoconf/configure.ac @@ -8,7 +8,7 @@ dnl Quit if the source directory has already been configured. dnl NOTE: This relies upon undocumented autoconf behavior. if test ${srcdir} != "." then - if test -f ${srcdir}/include/Config/config.h + if test -f ${srcdir}/include/llvm/Config/config.h then AC_MSG_ERROR([Already configured in ${srcdir}]) fi @@ -27,15 +27,15 @@ do done dnl Configure header files -AC_CONFIG_HEADERS(include/Config/config.h) +AC_CONFIG_HEADERS(include/llvm/Config/config.h) dnl Configure other output file AC_CONFIG_FILES(Makefile.config - include/Support/DataTypes.h - include/Support/ThreadSupport.h - include/Support/hash_map - include/Support/hash_set - include/Support/iterator) + include/llvm/Support/DataTypes.h + include/llvm/Support/ThreadSupport.h + include/llvm/ADT/hash_map + include/llvm/ADT/hash_set + include/llvm/ADT/iterator) dnl Do special configuration of Makefiles AC_CONFIG_MAKEFILE(Makefile) diff --git a/configure b/configure index 325ed37404..3f7f65b0db 100755 --- a/configure +++ b/configure @@ -1544,7 +1544,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # This should be Cygnus configure. if test ${srcdir} != "." then - if test -f ${srcdir}/include/Config/config.h + if test -f ${srcdir}/include/llvm/Config/config.h then { { echo "$as_me:$LINENO: error: Already configured in ${srcdir}" >&5 echo "$as_me: error: Already configured in ${srcdir}" >&2;} @@ -1566,10 +1566,10 @@ subdirs="$subdirs projects/${i}" fi done - ac_config_headers="$ac_config_headers include/Config/config.h" + ac_config_headers="$ac_config_headers include/llvm/Config/config.h" - ac_config_files="$ac_config_files Makefile.config include/Support/DataTypes.h include/Support/ThreadSupport.h include/Support/hash_map include/Support/hash_set include/Support/iterator" + ac_config_files="$ac_config_files Makefile.config include/llvm/Support/DataTypes.h include/llvm/Support/ThreadSupport.h include/llvm/ADT/hash_map include/llvm/ADT/hash_set include/llvm/ADT/iterator" ac_config_commands="$ac_config_commands Makefile" @@ -24450,11 +24450,11 @@ do case "$ac_config_target" in # Handling of arguments. "Makefile.config" ) CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; - "include/Support/DataTypes.h" ) CONFIG_FILES="$CONFIG_FILES include/Support/DataTypes.h" ;; - "include/Support/ThreadSupport.h" ) CONFIG_FILES="$CONFIG_FILES include/Support/ThreadSupport.h" ;; - "include/Support/hash_map" ) CONFIG_FILES="$CONFIG_FILES include/Support/hash_map" ;; - "include/Support/hash_set" ) CONFIG_FILES="$CONFIG_FILES include/Support/hash_set" ;; - "include/Support/iterator" ) CONFIG_FILES="$CONFIG_FILES include/Support/iterator" ;; + "include/llvm/Support/DataTypes.h" ) CONFIG_FILES="$CONFIG_FILES include/llvm/Support/DataTypes.h" ;; + "include/llvm/Support/ThreadSupport.h" ) CONFIG_FILES="$CONFIG_FILES include/llvm/Support/ThreadSupport.h" ;; + "include/llvm/ADT/hash_map" ) CONFIG_FILES="$CONFIG_FILES include/llvm/ADT/hash_map" ;; + "include/llvm/ADT/hash_set" ) CONFIG_FILES="$CONFIG_FILES include/llvm/ADT/hash_set" ;; + "include/llvm/ADT/iterator" ) CONFIG_FILES="$CONFIG_FILES include/llvm/ADT/iterator" ;; "lib/System/platform" ) CONFIG_LINKS="$CONFIG_LINKS lib/System/platform:lib/System/$platform_type" ;; "Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile" ;; "Makefile.common" ) CONFIG_COMMANDS="$CONFIG_COMMANDS Makefile.common" ;; @@ -24507,7 +24507,7 @@ do "tools/Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS tools/Makefile" ;; "utils/Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS utils/Makefile" ;; "projects/Makefile" ) CONFIG_COMMANDS="$CONFIG_COMMANDS projects/Makefile" ;; - "include/Config/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/Config/config.h" ;; + "include/llvm/Config/config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS include/llvm/Config/config.h" ;; *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 echo "$as_me: error: invalid argument: $ac_config_target" >&2;} { (exit 1); exit 1; }; };; diff --git a/include/Config/alloca.h b/include/Config/alloca.h deleted file mode 100644 index 297b56fa7c..0000000000 --- a/include/Config/alloca.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file includes the infamous alloc.h header file if the - * autoconf system has found it. It hides all of the autoconf details - * from the rest of the application source code. - */ - -#ifndef _CONFIG_ALLOC_H -#define _CONFIG_ALLOC_H - -#include "Config/config.h" - -/* - * This is a modified version of that suggested by the Autoconf manual. - * 1) The #pragma is indented so that pre-ANSI C compilers ignore it. - * 2) If alloca.h cannot be found, then try stdlib.h. Some platforms - * (notably FreeBSD) defined alloca() there. - */ -#ifdef _MSC_VER -/* noop on Visual C++ */ -#elif defined(HAVE_ALLOCA_H) -#include -#elif !defined(__GNUC__) -# ifdef _AIX - # pragma alloca -# else -# ifndef alloca - char * alloca (); -# endif -# endif -#else -# ifdef HAVE_STDLIB_H -# include -# else -# error "The function alloca() is required but not found!" -# endif -#endif - -#endif - diff --git a/include/Config/config.h.in b/include/Config/config.h.in deleted file mode 100644 index fe0c77c8af..0000000000 --- a/include/Config/config.h.in +++ /dev/null @@ -1,240 +0,0 @@ -/* include/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */ - -/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP - systems. This function is required for `alloca.c' support on those systems. - */ -#undef CRAY_STACKSEG_END - -/* Define to 1 if using `alloca.c'. */ -#undef C_ALLOCA - -/* Define to 1 if you have `alloca', as a function or macro. */ -#undef HAVE_ALLOCA - -/* Define to 1 if you have and it should be used (not on Ultrix). - */ -#undef HAVE_ALLOCA_H - -/* Define to 1 if you have the `backtrace' function. */ -#undef HAVE_BACKTRACE - -/* Define to 1 if you have the header file. */ -#undef HAVE_DLFCN_H - -/* Define if dlopen() is available on this platform. */ -#undef HAVE_DLOPEN - -/* Define to 1 if you have the header file. */ -#undef HAVE_EXECINFO_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_FCNTL_H - -/* Define to 1 if your compiler defines finite in the header file. - */ -#undef HAVE_FINITE_IN_IEEEFP_H - -/* Define to 1 if you have the `getcwd' function. */ -#undef HAVE_GETCWD - -/* Define to 1 if you have the `getpagesize' function. */ -#undef HAVE_GETPAGESIZE - -/* Define to 1 if you have the `getrusage' function. */ -#undef HAVE_GETRUSAGE - -/* Define to 1 if you have the `gettimeofday' function. */ -#undef HAVE_GETTIMEOFDAY - -/* Define to 1 if the system has the type `int64_t'. */ -#undef HAVE_INT64_T - -/* Define to 1 if you have the header file. */ -#undef HAVE_INTTYPES_H - -/* Define to 1 if you have the `isatty' function. */ -#undef HAVE_ISATTY - -/* Define to 1 if your compiler defines isinf in the header file. */ -#undef HAVE_ISINF_IN_CMATH - -/* Define to 1 if your compiler defines isinf in the header file. */ -#undef HAVE_ISINF_IN_MATH_H - -/* Define to 1 if your compiler defines isnan in the header file. */ -#undef HAVE_ISNAN_IN_CMATH - -/* Define to 1 if your compiler defines isnan in the header file. */ -#undef HAVE_ISNAN_IN_MATH_H - -/* Define to 1 if you have the `elf' library (-lelf). */ -#undef HAVE_LIBELF - -/* Define to 1 if you have the header file. */ -#undef HAVE_LIMITS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_LINK_H - -/* Define if you can use -Wl,-R. to pass -R. to the linker, in order to add - the current directory to the dynamic linker search path. */ -#undef HAVE_LINK_R - -/* Define if mallinfo() is available on this platform. */ -#undef HAVE_MALLINFO - -/* Define to 1 if you have the header file. */ -#undef HAVE_MALLOC_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - -/* Define to 1 if you have the `mkstemp' function. */ -#undef HAVE_MKSTEMP - -/* Define to 1 if you have a working `mmap' system call. */ -#undef HAVE_MMAP - -/* Define if mmap() uses MAP_ANONYMOUS to map anonymous pages, or undefine if - it uses MAP_ANON */ -#undef HAVE_MMAP_ANONYMOUS - -/* Define if mmap() can map files into memory */ -#undef HAVE_MMAP_FILE - -/* define if the compiler implements namespaces */ -#undef HAVE_NAMESPACES - -/* Define to have the %a format string */ -#undef HAVE_PRINTF_A - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDINT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STDLIB_H - -/* Define to 1 if your compiler defines std::isinf in the header file. - */ -#undef HAVE_STD_ISINF_IN_CMATH - -/* Define to 1 if your compiler defines std::isnan in the header file. - */ -#undef HAVE_STD_ISNAN_IN_CMATH - -/* Define to 1 if you have the `strdup' function. */ -#undef HAVE_STRDUP - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRINGS_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_STRING_H - -/* Define to 1 if you have the `strtoll' function. */ -#undef HAVE_STRTOLL - -/* Define to 1 if you have the `strtoq' function. */ -#undef HAVE_STRTOQ - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_MMAN_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_RESOURCE_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_STAT_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TIME_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_SYS_TYPES_H - -/* Define to 1 if you have that is POSIX.1 compatible. */ -#undef HAVE_SYS_WAIT_H - -/* Define to 1 if the system has the type `uint64_t'. */ -#undef HAVE_UINT64_T - -/* Define to 1 if you have the header file. */ -#undef HAVE_UNISTD_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_WINDOWS_H - -/* Installation directory for binary executables */ -#undef LLVM_BINDIR - -/* Time at which LLVM was configured */ -#undef LLVM_CONFIGTIME - -/* Installation directory for documentation */ -#undef LLVM_DATADIR - -/* Installation directory for config files */ -#undef LLVM_ETCDIR - -/* Installation directory for include files */ -#undef LLVM_INCLUDEDIR - -/* Installation directory for .info files */ -#undef LLVM_INFODIR - -/* Installation directory for libraries */ -#undef LLVM_LIBDIR - -/* Installation directory for man pages */ -#undef LLVM_MANDIR - -/* Installation prefix directory */ -#undef LLVM_PREFIX - -/* Define to the address where bug reports for this package should be sent. */ -#undef PACKAGE_BUGREPORT - -/* Define to the full name of this package. */ -#undef PACKAGE_NAME - -/* Define to the full name and version of this package. */ -#undef PACKAGE_STRING - -/* Define to the one symbol short name of this package. */ -#undef PACKAGE_TARNAME - -/* Define to the version of this package. */ -#undef PACKAGE_VERSION - -/* Define as the return type of signal handlers (`int' or `void'). */ -#undef RETSIGTYPE - -/* Extension that shared libraries have, e.g., ".so". */ -#undef SHLIBEXT - -/* If using the C implementation of alloca, define if you know the - direction of stack growth for your system; otherwise it will be - automatically deduced at run-time. - STACK_DIRECTION > 0 => grows toward higher addresses - STACK_DIRECTION < 0 => grows toward lower addresses - STACK_DIRECTION = 0 => direction of growth unknown */ -#undef STACK_DIRECTION - -/* Define to 1 if you have the ANSI C header files. */ -#undef STDC_HEADERS - -/* Define to 1 if you can safely include both and . */ -#undef TIME_WITH_SYS_TIME - -/* Define to 1 if your declares `struct tm'. */ -#undef TM_IN_SYS_TIME - -/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a - `char[]'. */ -#undef YYTEXT_POINTER - -/* Define to `int' if does not define. */ -#undef pid_t - -/* Define to `unsigned' if does not define. */ -#undef size_t diff --git a/include/Config/dlfcn.h b/include/Config/dlfcn.h deleted file mode 100644 index c7ce5b1968..0000000000 --- a/include/Config/dlfcn.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file is the autoconf replacement for dlfcn.h (if it lives - * on the system). - */ - -#ifndef _CONFIG_DLFCN_H -#define _CONFIG_DLFCN_H - -#include "Config/config.h" - -#ifdef HAVE_DLFCN_H -#include -#endif - -#endif diff --git a/include/Config/fcntl.h b/include/Config/fcntl.h deleted file mode 100644 index ed8a1c839b..0000000000 --- a/include/Config/fcntl.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file is the autoconf replacement for fcntl.h (if it lives - * on the system). - */ - -#ifndef _CONFIG_FCNTL_H -#define _CONFIG_FCNTL_H - -#include "Config/config.h" - -#ifdef HAVE_FCNTL_H -#include -#endif - -#endif diff --git a/include/Config/limits.h b/include/Config/limits.h deleted file mode 100644 index e5a787e5e1..0000000000 --- a/include/Config/limits.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file is the autoconf replacement for limits.h (if it lives - * on the system). - */ - -#ifndef _CONFIG_LIMITS_H -#define _CONFIG_LIMITS_H - -#include "Config/config.h" - -#ifdef HAVE_LIMITS_H -#include -#endif - -#endif diff --git a/include/Config/malloc.h b/include/Config/malloc.h deleted file mode 100644 index c78408a359..0000000000 --- a/include/Config/malloc.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file includes the infamous malloc.h header file if the - * autoconf system has found it. It hides all of the autoconf details - * from the rest of the application source code. - */ - -#ifndef _SUPPORT_MALLOC_H -#define _SUPPORT_MALLOC_H - -#include "Config/config.h" - -#ifdef HAVE_MALLOC_H -#include -#endif - -#endif - diff --git a/include/Config/memory.h b/include/Config/memory.h deleted file mode 100644 index f75902b5bc..0000000000 --- a/include/Config/memory.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file is the autoconf replacement for memory.h (if it lives - * on the system). - */ - -#ifndef _CONFIG_MEMORY_H -#define _CONFIG_MEMORY_H - -#include "Config/config.h" - -#ifdef HAVE_MEMORY_H -#include -#endif - -#endif diff --git a/include/Config/pagesize.h b/include/Config/pagesize.h deleted file mode 100644 index f37b29770d..0000000000 --- a/include/Config/pagesize.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * This header file provides a platform-independent way of quering page size. - */ - -#ifndef PAGESIZE_H -#define PAGESIZE_H - -#include "Config/unistd.h" -#include - -namespace llvm { - -/* Compatibility chart: - * - * Linux/x86: _SC_PAGESIZE, _SC_PAGE_SIZE - * MacOS X/PowerPC: v. 10.2: NBPG, - * v. 10.3: _SC_PAGESIZE - * Solaris/Sparc: _SC_PAGESIZE, _SC_PAGE_SIZE - */ - -/** - * GetPageSize - wrapper to return page size in bytes for various - * architecture/OS combinations - */ -unsigned GetPageSize() { -#ifdef _SC_PAGESIZE - return sysconf(_SC_PAGESIZE); -#elif defined(_SC_PAGE_SIZE) - return sysconf(_SC_PAGE_SIZE); -#elif defined(NBPG) -#ifndef CLSIZE -#define CLSIZE 1 -#endif - return NBPG * CLSIZE; -#else - return 4096; /* allocate 4KB as a fall-back */ -#endif -} - -} - -#endif diff --git a/include/Config/stdint.h b/include/Config/stdint.h deleted file mode 100644 index a98961063e..0000000000 --- a/include/Config/stdint.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file is the autoconf replacement for stdint.h (if it lives - * on the system). - */ - -#ifndef _CONFIG_STDINT_H -#define _CONFIG_STDINT_H - -#include "Config/config.h" - -#ifdef HAVE_STDINT_H -#include -#endif - -#endif diff --git a/include/Config/sys/mman.h b/include/Config/sys/mman.h deleted file mode 100644 index 7f51e7fbfb..0000000000 --- a/include/Config/sys/mman.h +++ /dev/null @@ -1,32 +0,0 @@ -/*===-- Config/sys/mman.h - Autoconf sys/mman.h wrapper -----------*- C -*-===// - * - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * - * Description: - * This header file includes the headers needed for the mmap() system/ - * function call. It also defines some macros so that all of our calls - * to mmap() can act (more or less) the same, regardless of platform. - * - *===----------------------------------------------------------------------===// - */ - -#ifndef _CONFIG_MMAN_H -#define _CONFIG_MMAN_H - -#include "Config/config.h" - -#if defined(HAVE_SYS_MMAN_H) && !defined(_MSC_VER) -#include -#endif - -#ifndef HAVE_MMAP_ANONYMOUS -#define MAP_ANONYMOUS MAP_ANON -#endif - -#endif - diff --git a/include/Config/sys/resource.h b/include/Config/sys/resource.h deleted file mode 100644 index 1f4cc694b2..0000000000 --- a/include/Config/sys/resource.h +++ /dev/null @@ -1,34 +0,0 @@ -/*===-- Config/sys/resource.h -----------------------------------*- C++ -*-===// - * - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * - * This header file is the autoconf replacement for sys/resource.h (if it - * lives on the system). - * - *===----------------------------------------------------------------------===// - */ - -#ifndef _CONFIG_SYS_RESOURCE_H -#define _CONFIG_SYS_RESOURCE_H - -#include "Config/config.h" - -#if defined(HAVE_SYS_RESOURCE_H) && !defined(_MSC_VER) - -/* - * In LLVM, we use sys/resource.h to use getrusage() and maybe some other - * stuff. Some man pages say that you also need sys/time.h and unistd.h. - * So, to be paranoid, we will try to include all three if possible. - */ -#include "Config/sys/time.h" -#include -#include "Config/unistd.h" - -#endif - -#endif diff --git a/include/Config/sys/stat.h b/include/Config/sys/stat.h deleted file mode 100644 index 9669bcf927..0000000000 --- a/include/Config/sys/stat.h +++ /dev/null @@ -1,29 +0,0 @@ -/*===-- Config/sys/stat.h -----------------------------------*- ----C++ -*-===// - * - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * This header file includes the headers needed for the stat() system - * call. - * - *===----------------------------------------------------------------------===// - */ - -#ifndef _CONFIG_SYS_STAT_H -#define _CONFIG_SYS_STAT_H - -#include "Config/config.h" - -#ifdef HAVE_SYS_STAT_H -#include -#endif - -#if defined(_MSC_VER) -#define S_ISREG(X) ((X) & _S_IFREG) -#endif - -#endif - diff --git a/include/Config/sys/time.h b/include/Config/sys/time.h deleted file mode 100644 index 3e0ea1e810..0000000000 --- a/include/Config/sys/time.h +++ /dev/null @@ -1,24 +0,0 @@ -/*===-- Config/sys/time.h ---------------------------------------*- C++ -*-===// - * - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * This header file is the autoconf replacement for sys/time.h (if it - * lives on the system). - * - *===----------------------------------------------------------------------===// - */ - -#ifndef _CONFIG_SYS_TIME_H -#define _CONFIG_SYS_TIME_H - -#include "Config/config.h" - -#if defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) -#include -#endif - -#endif diff --git a/include/Config/sys/types.h b/include/Config/sys/types.h deleted file mode 100644 index f0a7abec35..0000000000 --- a/include/Config/sys/types.h +++ /dev/null @@ -1,25 +0,0 @@ -/*===-- Config/sys/types.h --------------------------------------*- C++ -*-===// - * - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * This header file is the autoconf substitute for sys/types.h. It - * includes it for us if it exists on this system. - * - *===----------------------------------------------------------------------===// - */ - -#ifndef _CONFIG_SYS_TYPES_H -#define _CONFIG_SYS_TYPES_H - -#include "Config/config.h" - -#ifdef HAVE_SYS_TYPES_H -#include -#endif - -#endif - diff --git a/include/Config/sys/wait.h b/include/Config/sys/wait.h deleted file mode 100644 index b3db60e435..0000000000 --- a/include/Config/sys/wait.h +++ /dev/null @@ -1,24 +0,0 @@ -/*===-- Config/sys/wait.h ---------------------------------------*- C++ -*-===// - * - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * This header file includes the headers needed for the wait() system - * call. - *===----------------------------------------------------------------------===// - */ - -#ifndef _CONFIG_SYS_WAIT_H -#define _CONFIG_SYS_WAIT_H - -#include "Config/config.h" - -#ifdef HAVE_SYS_WAIT_H -#include -#endif - -#endif - diff --git a/include/Config/time.h b/include/Config/time.h deleted file mode 100644 index b2f3e6ee05..0000000000 --- a/include/Config/time.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * - * Description: - * This header file is the autoconf replacement for time.h (if it lives - * on the system). - * - * The added benefit of this header file is that it removes the - * "time with sys/time" problem. - * - * According to the autoconf manual, some systems have a sys/time.h that - * includes time.h, but time.h is not written to handle multiple - * inclusion. This means that a program including sys/time.h cannot - * also include time.h. - * - * This header file fixes that problem. - */ - -#ifndef _CONFIG_TIME_H -#define _CONFIG_TIME_H - -#include "Config/config.h" - -#ifdef HAVE_TIME_H -#include -#endif - -#endif diff --git a/include/Config/unistd.h b/include/Config/unistd.h deleted file mode 100644 index 847db7a3c6..0000000000 --- a/include/Config/unistd.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - *===----------------------------------------------------------------------===// - * - * Description: - * This header file is the autoconf replacement for unistd.h (if it lives - * on the system). - */ - -#ifndef _CONFIG_UNISTD_H -#define _CONFIG_UNISTD_H - -#include "Config/config.h" - -#if defined(HAVE_UNISTD_H) && !defined(_MSC_VER) -#include -#endif - -#ifdef _WIN32 -#include -#include -#endif - -#endif diff --git a/include/Config/windows.h b/include/Config/windows.h deleted file mode 100644 index fded99fba8..0000000000 --- a/include/Config/windows.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * The LLVM Compiler Infrastructure - * - * This file was developed by the LLVM research group and is distributed under - * the University of Illinois Open Source License. See LICENSE.TXT for details. - * - ****************************************************************************** - * - * Description: - * This header file is the autoconf replacement for windows.h (if it lives - * on the system). - */ - -#ifndef LLVM_CONFIG_WINDOWS_H -#define LLVM_CONFIG_WINDOWS_H - -#include "Config/config.h" - -#ifdef HAVE_WINDOWS_H -#include -#undef min -#undef max -#endif - -#endif diff --git a/include/Support/Annotation.h b/include/Support/Annotation.h deleted file mode 100644 index efca20a3ec..0000000000 --- a/include/Support/Annotation.h +++ /dev/null @@ -1,217 +0,0 @@ -//===-- Support/Annotation.h - Annotation classes ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains the declarations for two classes: Annotation & Annotable. -// Using these two simple classes, anything that derives from Annotable can have -// Annotation subclasses attached to them, ready for easy retrieval. -// -// Annotations are designed to be easily attachable to various classes. -// -// The AnnotationManager class is essential for using these classes. It is -// responsible for turning Annotation name strings into tokens [unique id #'s] -// that may be used to search for and create annotations. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_ANNOTATION_H -#define SUPPORT_ANNOTATION_H - -#include -#include - -namespace llvm { - -class AnnotationID; -class Annotation; -class Annotable; -class AnnotationManager; - -//===----------------------------------------------------------------------===// -// -// AnnotationID - This class is a thin wrapper around an unsigned integer that -// is used to hopefully prevent errors using AnnotationID's. They may be copied -// freely around and passed byvalue with little or no overhead. -// -class AnnotationID { - friend class AnnotationManager; - unsigned ID; - - AnnotationID(); // Default ctor is disabled - inline AnnotationID(unsigned i) : ID(i) {} // Only creatable from AnnMgr -public: - inline AnnotationID(const AnnotationID &A) : ID(A.ID) {} - - inline bool operator==(const AnnotationID &A) const { - return A.ID == ID; - } - inline bool operator<(const AnnotationID &A) const { - return ID < A.ID; - } -}; - - -//===----------------------------------------------------------------------===// -// -// Annotation Class - This class serves as a base class for any specific -// annotations that you might need. Simply subclass this to add extra -// information to the annotations. -// -class Annotation { - friend class Annotable; // Annotable manipulates Next list - AnnotationID ID; // ID number, as obtained from AnnotationManager - Annotation *Next; // The next annotation in the linked list -public: - inline Annotation(AnnotationID id) : ID(id), Next(0) {} - virtual ~Annotation(); // Designed to be subclassed - - // getID - Return the unique ID# of this annotation - inline AnnotationID getID() const { return ID; } - - // getNext - Return the next annotation in the list... - inline Annotation *getNext() const { return Next; } -}; - - -//===----------------------------------------------------------------------===// -// -// Annotable - This class is used as a base class for all objects that would -// like to have annotation capability. One notable subclass is Value, which -// means annotations can be attached to almost everything in LLVM. -// -// Annotable objects keep their annotation list sorted as annotations are -// inserted and deleted. This is used to ensure that annotations with identical -// ID#'s are stored sequentially. -// -class Annotable { - mutable Annotation *AnnotationList; - - Annotable(const Annotable &); // Do not implement - void operator=(const Annotable &); // Do not implement -public: - Annotable() : AnnotationList(0) {} - ~Annotable(); - - // getAnnotation - Search the list for annotations of the specified ID. The - // pointer returned is either null (if no annotations of the specified ID - // exist), or it points to the first element of a potentially list of elements - // with identical ID #'s. - // - Annotation *getAnnotation(AnnotationID ID) const { - for (Annotation *A = AnnotationList; A; A = A->getNext()) - if (A->getID() == ID) return A; - return 0; - } - - // getOrCreateAnnotation - Search through the annotation list, if there is - // no annotation with the specified ID, then use the AnnotationManager to - // create one. - // - inline Annotation *getOrCreateAnnotation(AnnotationID ID) const; - - // addAnnotation - Insert the annotation into the list in a sorted location. - // - void addAnnotation(Annotation *A) const { - assert(A->Next == 0 && "Annotation already in list?!?"); - - Annotation **AL = &AnnotationList; - while (*AL && (*AL)->ID < A->getID()) // Find where to insert annotation - AL = &((*AL)->Next); - A->Next = *AL; // Link the annotation in - *AL = A; - } - - // unlinkAnnotation - Remove the first annotation of the specified ID... and - // then return the unlinked annotation. The annotation object is not deleted. - // - inline Annotation *unlinkAnnotation(AnnotationID ID) const { - for (Annotation **A = &AnnotationList; *A; A = &((*A)->Next)) - if ((*A)->getID() == ID) { - Annotation *Ret = *A; - *A = Ret->Next; - Ret->Next = 0; - return Ret; - } - return 0; - } - - // deleteAnnotation - Delete the first annotation of the specified ID in the - // list. Unlink unlinkAnnotation, this actually deletes the annotation object - // - bool deleteAnnotation(AnnotationID ID) const { - Annotation *A = unlinkAnnotation(ID); - delete A; - return A != 0; - } -}; - - -//===----------------------------------------------------------------------===// -// -// AnnotationManager - This class is primarily responsible for maintaining a -// one-to-one mapping between string Annotation names and Annotation ID numbers. -// -// Compared to the rest of the Annotation system, these mapping methods are -// relatively slow, so they should be avoided by locally caching Annotation -// ID #'s. These methods are safe to call at any time, even by static ctors, so -// they should be used by static ctors most of the time. -// -// This class also provides support for annotations that are created on demand -// by the Annotable::getOrCreateAnnotation method. To get this to work, simply -// register an annotation handler -// -struct AnnotationManager { - typedef Annotation *(*Factory)(AnnotationID, const Annotable *, void*); - - //===--------------------------------------------------------------------===// - // Basic ID <-> Name map functionality - - static AnnotationID getID(const std::string &Name); // Name -> ID - static const std::string &getName(AnnotationID ID); // ID -> Name - - // getID - Name -> ID + registration of a factory function for demand driven - // annotation support. - static AnnotationID getID(const std::string &Name, Factory Fact, - void *Data = 0); - - //===--------------------------------------------------------------------===// - // Annotation creation on demand support... - - // registerAnnotationFactory - This method is used to register a callback - // function used to create an annotation on demand if it is needed by the - // Annotable::getOrCreateAnnotation method. - // - static void registerAnnotationFactory(AnnotationID ID, Factory Func, - void *ExtraData = 0); - - // createAnnotation - Create an annotation of the specified ID for the - // specified object, using a register annotation creation function. - // - static Annotation *createAnnotation(AnnotationID ID, const Annotable *Obj); -}; - - - -// getOrCreateAnnotation - Search through the annotation list, if there is -// no annotation with the specified ID, then use the AnnotationManager to -// create one. -// -inline Annotation *Annotable::getOrCreateAnnotation(AnnotationID ID) const { - Annotation *A = getAnnotation(ID); // Fast path, check for preexisting ann - if (A) return A; - - // No annotation found, ask the annotation manager to create an annotation... - A = AnnotationManager::createAnnotation(ID, this); - assert(A && "AnnotationManager could not create annotation!"); - addAnnotation(A); - return A; -} - -} // End namespace llvm - -#endif diff --git a/include/Support/BitSetVector.h b/include/Support/BitSetVector.h deleted file mode 100644 index 276af0a68a..0000000000 --- a/include/Support/BitSetVector.h +++ /dev/null @@ -1,272 +0,0 @@ -//===-- BitVectorSet.h - A bit-vector representation of sets ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This is an implementation of the bit-vector representation of sets. Unlike -// vector, this allows much more efficient parallel set operations on -// bits, by using the bitset template. The bitset template unfortunately can -// only represent sets with a size chosen at compile-time. We therefore use a -// vector of bitsets. The maxmimum size of our sets (i.e., the size of the -// universal set) can be chosen at creation time. -// -// External functions: -// -// bool Disjoint(const BitSetVector& set1, const BitSetVector& set2): -// Tests if two sets have an empty intersection. -// This is more efficient than !(set1 & set2).any(). -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_BITSETVECTOR_H -#define SUPPORT_BITSETVECTOR_H - -#include -#include -#include -#include - -namespace llvm { - -class BitSetVector { - enum { BITSET_WORDSIZE = sizeof(long)*8 }; - - // Types used internal to the representation - typedef std::bitset bitword; - typedef bitword::reference reference; - - // Data used in the representation - std::vector bitsetVec; - unsigned maxSize; - -private: - // Utility functions for the representation - static unsigned NumWords(unsigned Size) { - return (Size+BITSET_WORDSIZE-1)/BITSET_WORDSIZE; - } - static unsigned LastWordSize(unsigned Size) { return Size % BITSET_WORDSIZE; } - - // Clear the unused bits in the last word. - // The unused bits are the high (BITSET_WORDSIZE - LastWordSize()) bits - void ClearUnusedBits() { - unsigned long usedBits = (1U << LastWordSize(size())) - 1; - bitsetVec.back() &= bitword(usedBits); - } - - const bitword& getWord(unsigned i) const { return bitsetVec[i]; } - bitword& getWord(unsigned i) { return bitsetVec[i]; } - - friend bool Disjoint(const BitSetVector& set1, - const BitSetVector& set2); - - BitSetVector(); // do not implement! - -public: - class iterator; - /// - /// Constructor: create a set of the maximum size maxSetSize. - /// The set is initialized to empty. - /// - BitSetVector(unsigned maxSetSize) - : bitsetVec(NumWords(maxSetSize)), maxSize(maxSetSize) { } - - /// size - Return the number of bits tracked by this bit vector... - unsigned size() const { return maxSize; } - - /// - /// Modifier methods: reset, set for entire set, operator[] for one element. - /// - void reset() { - for (unsigned i=0, N = bitsetVec.size(); i < N; ++i) - bitsetVec[i].reset(); - } - void set() { - for (unsigned i=0, N = bitsetVec.size(); i < N; ++i) // skip last word - bitsetVec[i].set(); - ClearUnusedBits(); - } - reference operator[](unsigned n) { - assert(n < size() && "BitSetVector: Bit number out of range"); - unsigned ndiv = n / BITSET_WORDSIZE, nmod = n % BITSET_WORDSIZE; - return bitsetVec[ndiv][nmod]; - } - iterator begin() { return iterator::begin(*this); } - iterator end() { return iterator::end(*this); } - - /// - /// Comparison operations: equal, not equal - /// - bool operator == (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal == comparison"); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - if (getWord(i) != set2.getWord(i)) - return false; - return true; - } - bool operator != (const BitSetVector& set2) const { - return ! (*this == set2); - } - - /// - /// Set membership operations: single element, any, none, count - /// - bool test(unsigned n) const { - assert(n < size() && "BitSetVector: Bit number out of range"); - unsigned ndiv = n / BITSET_WORDSIZE, nmod = n % BITSET_WORDSIZE; - return bitsetVec[ndiv].test(nmod); - } - bool any() const { - for (unsigned i = 0; i < bitsetVec.size(); ++i) - if (bitsetVec[i].any()) - return true; - return false; - } - bool none() const { - return ! any(); - } - unsigned count() const { - unsigned n = 0; - for (unsigned i = 0; i < bitsetVec.size(); ++i) - n += bitsetVec[i].count(); - return n; - } - bool all() const { - return (count() == size()); - } - - /// - /// Set operations: intersection, union, disjoint union, complement. - /// - BitSetVector operator& (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal intersection"); - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - result.getWord(i) = getWord(i) & set2.getWord(i); - return result; - } - BitSetVector operator| (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal intersection"); - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - result.getWord(i) = getWord(i) | set2.getWord(i); - return result; - } - BitSetVector operator^ (const BitSetVector& set2) const { - assert(maxSize == set2.maxSize && "Illegal intersection"); - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - result.getWord(i) = getWord(i) ^ set2.getWord(i); - return result; - } - BitSetVector operator~ () const { - BitSetVector result(maxSize); - for (unsigned i = 0; i < bitsetVec.size(); ++i) - (result.getWord(i) = getWord(i)).flip(); - result.ClearUnusedBits(); - return result; - } - - /// - /// Printing and debugging support - /// - void print(std::ostream &O) const; - void dump() const { print(std::cerr); } - -public: - // - // An iterator to enumerate the bits in a BitSetVector. - // Eventually, this needs to inherit from bidirectional_iterator. - // But this iterator may not be as useful as I once thought and - // may just go away. - // - class iterator { - unsigned currentBit; - unsigned currentWord; - BitSetVector* bitvec; - iterator(unsigned B, unsigned W, BitSetVector& _bitvec) - : currentBit(B), currentWord(W), bitvec(&_bitvec) { } - public: - iterator(BitSetVector& _bitvec) - : currentBit(0), currentWord(0), bitvec(&_bitvec) { } - iterator(const iterator& I) - : currentBit(I.currentBit),currentWord(I.currentWord),bitvec(I.bitvec) { } - iterator& operator=(const iterator& I) { - currentWord = I.currentWord; - currentBit = I.currentBit; - bitvec = I.bitvec; - return *this; - } - - // Increment and decrement operators (pre and post) - iterator& operator++() { - if (++currentBit == BITSET_WORDSIZE) - { currentBit = 0; if (currentWord < bitvec->size()) ++currentWord; } - return *this; - } - iterator& operator--() { - if (currentBit == 0) { - currentBit = BITSET_WORDSIZE-1; - currentWord = (currentWord == 0)? bitvec->size() : --currentWord; - } - else - --currentBit; - return *this; - } - iterator operator++(int) { iterator copy(*this); ++*this; return copy; } - iterator operator--(int) { iterator copy(*this); --*this; return copy; } - - // Dereferencing operators - reference operator*() { - assert(currentWord < bitvec->size() && - "Dereferencing iterator past the end of a BitSetVector"); - return bitvec->getWord(currentWord)[currentBit]; - } - - // Comparison operator - bool operator==(const iterator& I) { - return (I.bitvec == bitvec && - I.currentWord == currentWord && I.currentBit == currentBit); - } - - protected: - static iterator begin(BitSetVector& _bitvec) { return iterator(_bitvec); } - static iterator end(BitSetVector& _bitvec) { return iterator(0, - _bitvec.size(), _bitvec); } - friend class BitSetVector; - }; -}; - - -inline void BitSetVector::print(std::ostream& O) const -{ - for (std::vector::const_iterator - I=bitsetVec.begin(), E=bitsetVec.end(); I != E; ++I) - O << "<" << (*I) << ">" << (I+1 == E? "\n" : ", "); -} - -inline std::ostream& operator<< (std::ostream& O, const BitSetVector& bset) -{ - bset.print(O); - return O; -}; - - -/// -/// Optimized versions of fundamental comparison operations -/// -inline bool Disjoint(const BitSetVector& set1, - const BitSetVector& set2) -{ - assert(set1.size() == set2.size() && "Illegal intersection"); - for (unsigned i = 0; i < set1.bitsetVec.size(); ++i) - if ((set1.getWord(i) & set2.getWord(i)).any()) - return false; - return true; -} - -} // End llvm namespace -#endif diff --git a/include/Support/Casting.h b/include/Support/Casting.h deleted file mode 100644 index abc80aac7a..0000000000 --- a/include/Support/Casting.h +++ /dev/null @@ -1,301 +0,0 @@ -//===-- Support/Casting.h - Allow flexible, checked, casts ------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the isa(), cast(), dyn_cast(), cast_or_null(), -// and dyn_cast_or_null() templates. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_CASTING_H -#define SUPPORT_CASTING_H - -namespace llvm { - -//===----------------------------------------------------------------------===// -// isa Support Templates -//===----------------------------------------------------------------------===// - -template struct isa_impl_cl; - -// Define a template that can be specialized by smart pointers to reflect the -// fact that they are automatically dereferenced, and are not involved with the -// template selection process... the default implementation is a noop. -// -template struct simplify_type { - typedef From SimpleType; // The real type this represents... - - // An accessor to get the real value... - static SimpleType &getSimplifiedValue(From &Val) { return Val; } -}; - -template struct simplify_type { - typedef const From SimpleType; - static SimpleType &getSimplifiedValue(const From &Val) { - return simplify_type::getSimplifiedValue(static_cast(Val)); - } -}; - - -// isa - Return true if the parameter to the template is an instance of the -// template type argument. Used like this: -// -// if (isa(myVal)) { ... } -// -template -inline bool isa_impl(const From &Val) { - return To::classof(&Val); -} - -template -struct isa_impl_wrap { - // When From != SimplifiedType, we can simplify the type some more by using - // the simplify_type template. - static bool doit(const From &Val) { - return isa_impl_cl::template - isa(simplify_type::getSimplifiedValue(Val)); - } -}; - -template -struct isa_impl_wrap { - // When From == SimpleType, we are as simple as we are going to get. - static bool doit(const FromTy &Val) { - return isa_impl(Val); - } -}; - -// isa_impl_cl - Use class partial specialization to transform types to a single -// canonical form for isa_impl. -// -template -struct isa_impl_cl { - template - static bool isa(const FromCl &Val) { - return isa_impl_wrap::SimpleType>::doit(Val); - } -}; - -// Specialization used to strip const qualifiers off of the FromCl type... -template -struct isa_impl_cl { - template - static bool isa(const FromCl &Val) { - return isa_impl_cl::template isa(Val); - } -}; - -// Define pointer traits in terms of base traits... -template -struct isa_impl_cl { - template - static bool isa(FromCl *Val) { - return isa_impl_cl::template isa(*Val); - } -}; - -// Define reference traits in terms of base traits... -template -struct isa_impl_cl { - template - static bool isa(FromCl &Val) { - return isa_impl_cl::template isa(&Val); - } -}; - -template -inline bool isa(const Y &Val) { - return isa_impl_cl::template isa(Val); -} - -//===----------------------------------------------------------------------===// -// cast Support Templates -//===----------------------------------------------------------------------===// - -template struct cast_retty; - - -// Calculate what type the 'cast' function should return, based on a requested -// type of To and a source type of From. -template struct cast_retty_impl { - typedef To& ret_type; // Normal case, return Ty& -}; -template struct cast_retty_impl { - typedef const To &ret_type; // Normal case, return Ty& -}; - -template struct cast_retty_impl { - typedef To* ret_type; // Pointer arg case, return Ty* -}; - -template struct cast_retty_impl { - typedef const To* ret_type; // Constant pointer arg case, return const Ty* -}; - -template struct cast_retty_impl { - typedef const To* ret_type; // Constant pointer arg case, return const Ty* -}; - - -template -struct cast_retty_wrap { - // When the simplified type and the from type are not the same, use the type - // simplifier to reduce the type, then reuse cast_retty_impl to get the - // resultant type. - typedef typename cast_retty::ret_type ret_type; -}; - -template -struct cast_retty_wrap { - // When the simplified type is equal to the from type, use it directly. - typedef typename cast_retty_impl::ret_type ret_type; -}; - -template -struct cast_retty { - typedef typename cast_retty_wrap::SimpleType>::ret_type ret_type; -}; - -// Ensure the non-simple values are converted using the simplify_type template -// that may be specialized by smart pointers... -// -template struct cast_convert_val { - // This is not a simple type, use the template to simplify it... - static typename cast_retty::ret_type doit(const From &Val) { - return cast_convert_val::SimpleType>::doit( - simplify_type::getSimplifiedValue(Val)); - } -}; - -template struct cast_convert_val { - // This _is_ a simple type, just cast it. - static typename cast_retty::ret_type doit(const FromTy &Val) { - return reinterpret_cast::ret_type>( - const_cast(Val)); - } -}; - - - -// cast - Return the argument parameter cast to the specified type. This -// casting operator asserts that the type is correct, so it does not return null -// on failure. But it will correctly return NULL when the input is NULL. -// Used Like this: -// -// cast(myVal)->getParent() -// -template -inline typename cast_retty::ret_type cast(const Y &Val) { - assert(isa(Val) && "cast() argument of incompatible type!"); - return cast_convert_val::SimpleType>::doit(Val); -} - -// cast_or_null - Functionally identical to cast, except that a null value is -// accepted. -// -template -inline typename cast_retty::ret_type cast_or_null(Y *Val) { - if (Val == 0) return 0; - assert(isa(Val) && "cast_or_null() argument of incompatible type!"); - return cast(Val); -} - - -// dyn_cast - Return the argument parameter cast to the specified type. This -// casting operator returns null if the argument is of the wrong type, so it can -// be used to test for a type as well as cast if successful. This should be -// used in the context of an if statement like this: -// -// if (const Instruction *I = dyn_cast(myVal)) { ... } -// - -template -inline typename cast_retty::ret_type dyn_cast(Y Val) { - return isa(Val) ? cast(Val) : 0; -} - -// dyn_cast_or_null - Functionally identical to dyn_cast, except that a null -// value is accepted. -// -template -inline typename cast_retty::ret_type dyn_cast_or_null(Y Val) { - return (Val && isa(Val)) ? cast(Val) : 0; -} - - -#ifdef DEBUG_CAST_OPERATORS -#include - -struct bar { - bar() {} -private: - bar(const bar &); -}; -struct foo { - void ext() const; - /* static bool classof(const bar *X) { - cerr << "Classof: " << X << "\n"; - return true; - }*/ -}; - -template <> inline bool isa_impl(const bar &Val) { - cerr << "Classof: " << &Val << "\n"; - return true; -} - - -bar *fub(); -void test(bar &B1, const bar *B2) { - // test various configurations of const - const bar &B3 = B1; - const bar *const B4 = B2; - - // test isa - if (!isa(B1)) return; - if (!isa(B2)) return; - if (!isa(B3)) return; - if (!isa(B4)) return; - - // test cast - foo &F1 = cast(B1); - const foo *F3 = cast(B2); - const foo *F4 = cast(B2); - const foo &F8 = cast(B3); - const foo *F9 = cast(B4); - foo *F10 = cast(fub()); - - // test cast_or_null - const foo *F11 = cast_or_null(B2); - const foo *F12 = cast_or_null(B2); - const foo *F13 = cast_or_null(B4); - const foo *F14 = cast_or_null(fub()); // Shouldn't print. - - // These lines are errors... - //foo *F20 = cast(B2); // Yields const foo* - //foo &F21 = cast(B3); // Yields const foo& - //foo *F22 = cast(B4); // Yields const foo* - //foo &F23 = cast_or_null(B1); - //const foo &F24 = cast_or_null(B3); -} - -bar *fub() { return 0; } -void main() { - bar B; - test(B, &B); -} - -#endif - -} // End llvm namespace - -#endif diff --git a/include/Support/CommandLine.h b/include/Support/CommandLine.h deleted file mode 100644 index 053b823669..0000000000 --- a/include/Support/CommandLine.h +++ /dev/null @@ -1,1049 +0,0 @@ -//===- Support/CommandLine.h - Flexible Command line parser -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class implements a command line argument processor that is useful when -// creating a tool. It provides a simple, minimalistic interface that is easily -// extensible and supports nonlocal (library) command line options. -// -// Note that rather than trying to figure out what this code does, you should -// read the library documentation located in docs/CommandLine.html or looks at -// the many example usages in tools/*/*.cpp -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_COMMANDLINE_H -#define SUPPORT_COMMANDLINE_H - -#include "Support/type_traits.h" -#include -#include -#include -#include -#include - -namespace llvm { - -/// cl Namespace - This namespace contains all of the command line option -/// processing machinery. It is intentionally a short name to make qualified -/// usage concise. -namespace cl { - -//===----------------------------------------------------------------------===// -// ParseCommandLineOptions - Command line option processing entry point. -// -void ParseCommandLineOptions(int &argc, char **argv, - const char *Overview = 0); - -//===----------------------------------------------------------------------===// -// ParseEnvironmentOptions - Environment variable option processing alternate -// entry point. -// -void ParseEnvironmentOptions(const char *progName, const char *envvar, - const char *Overview = 0); - -//===----------------------------------------------------------------------===// -// Flags permitted to be passed to command line arguments -// - -enum NumOccurrences { // Flags for the number of occurrences allowed - Optional = 0x01, // Zero or One occurrence - ZeroOrMore = 0x02, // Zero or more occurrences allowed - Required = 0x03, // One occurrence required - OneOrMore = 0x04, // One or more occurrences required - - // ConsumeAfter - Indicates that this option is fed anything that follows the - // last positional argument required by the application (it is an error if - // there are zero positional arguments, and a ConsumeAfter option is used). - // Thus, for example, all arguments to LLI are processed until a filename is - // found. Once a filename is found, all of the succeeding arguments are - // passed, unprocessed, to the ConsumeAfter option. - // - ConsumeAfter = 0x05, - - OccurrencesMask = 0x07, -}; - -enum ValueExpected { // Is a value required for the option? - ValueOptional = 0x08, // The value can appear... or not - ValueRequired = 0x10, // The value is required to appear! - ValueDisallowed = 0x18, // A value may not be specified (for flags) - ValueMask = 0x18, -}; - -enum OptionHidden { // Control whether -help shows this option - NotHidden = 0x20, // Option included in --help & --help-hidden - Hidden = 0x40, // -help doesn't, but --help-hidden does - ReallyHidden = 0x60, // Neither --help nor --help-hidden show this arg - HiddenMask = 0x60, -}; - -// Formatting flags - This controls special features that the option might have -// that cause it to be parsed differently... -// -// Prefix - This option allows arguments that are otherwise unrecognized to be -// matched by options that are a prefix of the actual value. This is useful for -// cases like a linker, where options are typically of the form '-lfoo' or -// '-L../../include' where -l or -L are the actual flags. When prefix is -// enabled, and used, the value for the flag comes from the suffix of the -// argument. -// -// Grouping - With this option enabled, multiple letter options are allowed to -// bunch together with only a single hyphen for the whole group. This allows -// emulation of the behavior that ls uses for example: ls -la === ls -l -a -// - -enum FormattingFlags { - NormalFormatting = 0x000, // Nothing special - Positional = 0x080, // Is a positional argument, no '-' required - Prefix = 0x100, // Can this option directly prefix its value? - Grouping = 0x180, // Can this option group with other options? - FormattingMask = 0x180, // Union of the above flags. -}; - -enum MiscFlags { // Miscellaneous flags to adjust argument - CommaSeparated = 0x200, // Should this cl::list split between commas? - PositionalEatsArgs = 0x400, // Should this positional cl::list eat -args? - MiscMask = 0x600, // Union of the above flags. -}; - - - -//===----------------------------------------------------------------------===// -// Option Base class -// -class alias; -class Option { - friend void cl::ParseCommandLineOptions(int &, char **, const char *); - friend class alias; - - // handleOccurrences - Overriden by subclasses to handle the value passed into - // an argument. Should return true if there was an error processing the - // argument and the program should exit. - // - virtual bool handleOccurrence(unsigned pos, const char *ArgName, - const std::string &Arg) = 0; - - virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { - return Optional; - } - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return ValueOptional; - } - virtual enum OptionHidden getOptionHiddenFlagDefault() const { - return NotHidden; - } - virtual enum FormattingFlags getFormattingFlagDefault() const { - return NormalFormatting; - } - - int NumOccurrences; // The number of times specified - int Flags; // Flags for the argument - unsigned Position; // Position of last occurrence of the option -public: - const char *ArgStr; // The argument string itself (ex: "help", "o") - const char *HelpStr; // The descriptive text message for --help - const char *ValueStr; // String describing what the value of this option is - - inline enum NumOccurrences getNumOccurrencesFlag() const { - int NO = Flags & OccurrencesMask; - return NO ? static_cast(NO) - : getNumOccurrencesFlagDefault(); - } - inline enum ValueExpected getValueExpectedFlag() const { - int VE = Flags & ValueMask; - return VE ? static_cast(VE) - : getValueExpectedFlagDefault(); - } - inline enum OptionHidden getOptionHiddenFlag() const { - int OH = Flags & HiddenMask; - return OH ? static_cast(OH) - : getOptionHiddenFlagDefault(); - } - inline enum FormattingFlags getFormattingFlag() const { - int OH = Flags & FormattingMask; - return OH ? static_cast(OH) - : getFormattingFlagDefault(); - } - inline unsigned getMiscFlags() const { - return Flags & MiscMask; - } - inline unsigned getPosition() const { return Position; } - - // hasArgStr - Return true if the argstr != "" - bool hasArgStr() const { return ArgStr[0] != 0; } - - //-------------------------------------------------------------------------=== - // Accessor functions set by OptionModifiers - // - void setArgStr(const char *S) { ArgStr = S; } - void setDescription(const char *S) { HelpStr = S; } - void setValueStr(const char *S) { ValueStr = S; } - - void setFlag(unsigned Flag, unsigned FlagMask) { - if (Flags & FlagMask) { - error(": Specified two settings for the same option!"); - exit(1); - } - - Flags |= Flag; - } - - void setNumOccurrencesFlag(enum NumOccurrences Val) { - setFlag(Val, OccurrencesMask); - } - void setValueExpectedFlag(enum ValueExpected Val) { setFlag(Val, ValueMask); } - void setHiddenFlag(enum OptionHidden Val) { setFlag(Val, HiddenMask); } - void setFormattingFlag(enum FormattingFlags V) { setFlag(V, FormattingMask); } - void setMiscFlag(enum MiscFlags M) { setFlag(M, M); } - void setPosition(unsigned pos) { Position = pos; } -protected: - Option() : NumOccurrences(0), Flags(0), Position(0), - ArgStr(""), HelpStr(""), ValueStr("") {} - -public: - // addArgument - Tell the system that this Option subclass will handle all - // occurrences of -ArgStr on the command line. - // - void addArgument(const char *ArgStr); - void removeArgument(const char *ArgStr); - - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth() const = 0; - - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(unsigned GlobalWidth) const = 0; - - // addOccurrence - Wrapper around handleOccurrence that enforces Flags - // - bool addOccurrence(unsigned pos, const char *ArgName, - const std::string &Value); - - // Prints option name followed by message. Always returns true. - bool error(std::string Message, const char *ArgName = 0); - -public: - inline int getNumOccurrences() const { return NumOccurrences; } - virtual ~Option() {} -}; - - -//===----------------------------------------------------------------------===// -// Command line option modifiers that can be used to modify the behavior of -// command line option parsers... -// - -// desc - Modifier to set the description shown in the --help output... -struct desc { - const char *Desc; - desc(const char *Str) : Desc(Str) {} - void apply(Option &O) const { O.setDescription(Desc); } -}; - -// value_desc - Modifier to set the value description shown in the --help -// output... -struct value_desc { - const char *Desc; - value_desc(const char *Str) : Desc(Str) {} - void apply(Option &O) const { O.setValueStr(Desc); } -}; - -// init - Specify a default (initial) value for the command line argument, if -// the default constructor for the argument type does not give you what you -// want. This is only valid on "opt" arguments, not on "list" arguments. -// -template -struct initializer { - const Ty &Init; - initializer(const Ty &Val) : Init(Val) {} - - template - void apply(Opt &O) const { O.setInitialValue(Init); } -}; - -template -initializer init(const Ty &Val) { - return initializer(Val); -} - - -// location - Allow the user to specify which external variable they want to -// store the results of the command line argument processing into, if they don't -// want to store it in the option itself. -// -template -struct LocationClass { - Ty &Loc; - LocationClass(Ty &L) : Loc(L) {} - - template - void apply(Opt &O) const { O.setLocation(O, Loc); } -}; - -template -LocationClass location(Ty &L) { return LocationClass(L); } - - -//===----------------------------------------------------------------------===// -// Enum valued command line option -// -#define clEnumVal(ENUMVAL, DESC) #ENUMVAL, (int)ENUMVAL, DESC -#define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, (int)ENUMVAL, DESC -#define clEnumValEnd ((void*)0) - -// values - For custom data types, allow specifying a group of values together -// as the values that go into the mapping that the option handler uses. Note -// that the values list must always have a 0 at the end of the list to indicate -// that the list has ended. -// -template -class ValuesClass { - // Use a vector instead of a map, because the lists should be short, - // the overhead is less, and most importantly, it keeps them in the order - // inserted so we can print our option out nicely. - std::vector > > Values; - void processValues(va_list Vals); -public: - ValuesClass(const char *EnumName, DataType Val, const char *Desc, - va_list ValueArgs) { - // Insert the first value, which is required. - Values.push_back(std::make_pair(EnumName, std::make_pair(Val, Desc))); - - // Process the varargs portion of the values... - while (const char *EnumName = va_arg(ValueArgs, const char *)) { - DataType EnumVal = static_cast(va_arg(ValueArgs, int)); - const char *EnumDesc = va_arg(ValueArgs, const char *); - Values.push_back(std::make_pair(EnumName, // Add value to value map - std::make_pair(EnumVal, EnumDesc))); - } - } - - template - void apply(Opt &O) const { - for (unsigned i = 0, e = Values.size(); i != e; ++i) - O.getParser().addLiteralOption(Values[i].first, Values[i].second.first, - Values[i].second.second); - } -}; - -template -ValuesClass values(const char *Arg, DataType Val, const char *Desc, - ...) { - va_list ValueArgs; - va_start(ValueArgs, Desc); - ValuesClass Vals(Arg, Val, Desc, ValueArgs); - va_end(ValueArgs); - return Vals; -} - - -//===----------------------------------------------------------------------===// -// parser class - Parameterizable parser for different data types. By default, -// known data types (string, int, bool) have specialized parsers, that do what -// you would expect. The default parser, used for data types that are not -// built-in, uses a mapping table to map specific options to values, which is -// used, among other things, to handle enum types. - -//-------------------------------------------------- -// generic_parser_base - This class holds all the non-generic code that we do -// not need replicated for every instance of the generic parser. This also -// allows us to put stuff into CommandLine.cpp -// -struct generic_parser_base { - virtual ~generic_parser_base() {} // Base class should have virtual-dtor - - // getNumOptions - Virtual function implemented by generic subclass to - // indicate how many entries are in Values. - // - virtual unsigned getNumOptions() const = 0; - - // getOption - Return option name N. - virtual const char *getOption(unsigned N) const = 0; - - // getDescription - Return description N - virtual const char *getDescription(unsigned N) const = 0; - - // Return the width of the option tag for printing... - virtual unsigned getOptionWidth(const Option &O) const; - - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - virtual void printOptionInfo(const Option &O, unsigned GlobalWidth) const; - - void initialize(Option &O) { - // All of the modifiers for the option have been processed by now, so the - // argstr field should be stable, copy it down now. - // - hasArgStr = O.hasArgStr(); - - // If there has been no argstr specified, that means that we need to add an - // argument for every possible option. This ensures that our options are - // vectored to us. - // - if (!hasArgStr) - for (unsigned i = 0, e = getNumOptions(); i != e; ++i) - O.addArgument(getOption(i)); - } - - enum ValueExpected getValueExpectedFlagDefault() const { - // If there is an ArgStr specified, then we are of the form: - // - // -opt=O2 or -opt O2 or -optO2 - // - // In which case, the value is required. Otherwise if an arg str has not - // been specified, we are of the form: - // - // -O2 or O2 or -la (where -l and -a are separate options) - // - // If this is the case, we cannot allow a value. - // - if (hasArgStr) - return ValueRequired; - else - return ValueDisallowed; - } - - // findOption - Return the option number corresponding to the specified - // argument string. If the option is not found, getNumOptions() is returned. - // - unsigned findOption(const char *Name); - -protected: - bool hasArgStr; -}; - -// Default parser implementation - This implementation depends on having a -// mapping of recognized options to values of some sort. In addition to this, -// each entry in the mapping also tracks a help message that is printed with the -// command line option for --help. Because this is a simple mapping parser, the -// data type can be any unsupported type. -// -template -class parser : public generic_parser_base { -protected: - std::vector > > Values; -public: - typedef DataType parser_data_type; - - // Implement virtual functions needed by generic_parser_base - unsigned getNumOptions() const { return Values.size(); } - const char *getOption(unsigned N) const { return Values[N].first; } - const char *getDescription(unsigned N) const { - return Values[N].second.second; - } - - // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, - DataType &V) { - std::string ArgVal; - if (hasArgStr) - ArgVal = Arg; - else - ArgVal = ArgName; - - for (unsigned i = 0, e = Values.size(); i != e; ++i) - if (ArgVal == Values[i].first) { - V = Values[i].second.first; - return false; - } - - return O.error(": Cannot find option named '" + ArgVal + "'!"); - } - - // addLiteralOption - Add an entry to the mapping table... - template - void addLiteralOption(const char *Name, const DT &V, const char *HelpStr) { - assert(findOption(Name) == Values.size() && "Option already exists!"); - Values.push_back(std::make_pair(Name, - std::make_pair(static_cast(V),HelpStr))); - } - - // removeLiteralOption - Remove the specified option. - // - void removeLiteralOption(const char *Name) { - unsigned N = findOption(Name); - assert(N != Values.size() && "Option not found!"); - Values.erase(Values.begin()+N); - } -}; - -//-------------------------------------------------- -// basic_parser - Super class of parsers to provide boilerplate code -// -struct basic_parser_impl { // non-template implementation of basic_parser - virtual ~basic_parser_impl() {} - - enum ValueExpected getValueExpectedFlagDefault() const { - return ValueRequired; - } - - void initialize(Option &O) {} - - // Return the width of the option tag for printing... - unsigned getOptionWidth(const Option &O) const; - - // printOptionInfo - Print out information about this option. The - // to-be-maintained width is specified. - // - void printOptionInfo(const Option &O, unsigned GlobalWidth) const; - - // getValueName - Overload in subclass to provide a better default value. - virtual const char *getValueName() const { return "value"; } -}; - -// basic_parser - The real basic parser is just a template wrapper that provides -// a typedef for the provided data type. -// -template -struct basic_parser : public basic_parser_impl { - typedef DataType parser_data_type; -}; - - -//-------------------------------------------------- -// parser -// -template<> -struct parser : public basic_parser { - - // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, bool &Val); - - enum ValueExpected getValueExpectedFlagDefault() const { - return ValueOptional; - } - - // getValueName - Do not print = at all - virtual const char *getValueName() const { return 0; } -}; - - -//-------------------------------------------------- -// parser -// -template<> -struct parser : public basic_parser { - - // parse - Return true on error. - bool parse(Option &O, const char *ArgName, const std::string &Arg, int &Val); - - // getValueName - Overload in subclass to provide a better default value. - virtual const char *getValueName() const { return "int"; } -}; - - -//-------------------------------------------------- -// parser -// -template<> -struct parser : public basic_parser { - - // parse - Return true on error. - bool parse(Option &O, const char *AN, const std::string &Arg, unsigned &Val); - - // getValueName - Overload in subclass to provide a better default value. - virtual const char *getValueName() const { return "uint"; } -}; - - -//-------------------------------------------------- -// parser -// -template<> -struct parser : public basic_parser { - // parse - Return true on error. - bool parse(Option &O, const char *AN, const std::string &Arg, double &Val); - - // getValueName - Overload in subclass to provide a better default value. - virtual const char *getValueName() const { return "number"; } -}; - - -//-------------------------------------------------- -// parser -// -template<> -struct parser : public basic_parser { - // parse - Return true on error. - bool parse(Option &O, const char *AN, const std::string &Arg, float &Val); - - // getValueName - Overload in subclass to provide a better default value. - virtual const char *getValueName() const { return "number"; } -}; - - -//-------------------------------------------------- -// parser -// -template<> -struct parser : public basic_parser { - // parse - Return true on error. - bool parse(Option &O, const char *AN, const std::string &Arg, - std::string &Value) { - Value = Arg; - return false; - } - - // getValueName - Overload in subclass to provide a better default value. - virtual const char *getValueName() const { return "string"; } -}; - -//===----------------------------------------------------------------------===// -// applicator class - This class is used because we must use partial -// specialization to handle literal string arguments specially (const char* does -// not correctly respond to the apply method). Because the syntax to use this -// is a pain, we have the 'apply' method below to handle the nastiness... -// -template struct applicator { - template - static void opt(const Mod &M, Opt &O) { M.apply(O); } -}; - -// Handle const char* as a special case... -template struct applicator { - template - static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } -}; -template struct applicator { - template - static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } -}; -template<> struct applicator { - template - static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } -}; - -template<> struct applicator { - static void opt(NumOccurrences NO, Option &O) { O.setNumOccurrencesFlag(NO); } -}; -template<> struct applicator { - static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); } -}; -template<> struct applicator { - static void opt(OptionHidden OH, Option &O) { O.setHiddenFlag(OH); } -}; -template<> struct applicator { - static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); } -}; -template<> struct applicator { - static void opt(MiscFlags MF, Option &O) { O.setMiscFlag(MF); } -}; - -// apply method - Apply a modifier to an option in a type safe way. -template -void apply(const Mod &M, Opt *O) { - applicator::opt(M, *O); -} - - -//===----------------------------------------------------------------------===// -// opt_storage class - -// Default storage class definition: external storage. This implementation -// assumes the user will specify a variable to store the data into with the -// cl::location(x) modifier. -// -template -class opt_storage { - DataType *Location; // Where to store the object... - - void check() { - assert(Location != 0 && "cl::location(...) not specified for a command " - "line option with external storage, " - "or cl::init specified before cl::location()!!"); - } -public: - opt_storage() : Location(0) {} - - bool setLocation(Option &O, DataType &L) { - if (Location) - return O.error(": cl::location(x) specified more than once!"); - Location = &L; - return false; - } - - template - void setValue(const T &V) { - check(); - *Location = V; - } - - DataType &getValue() { check(); return *Location; } - const DataType &getValue() const { check(); return *Location; } -}; - - -// Define how to hold a class type object, such as a string. Since we can -// inherit from a class, we do so. This makes us exactly compatible with the -// object in all cases that it is used. -// -template -struct opt_storage : public DataType { - - template - void setValue(const T &V) { DataType::operator=(V); } - - DataType &getValue() { return *this; } - const DataType &getValue() const { return *this; } -}; - -// Define a partial specialization to handle things we cannot inherit from. In -// this case, we store an instance through containment, and overload operators -// to get at the value. -// -template -struct opt_storage { - DataType Value; - - // Make sure we initialize the value with the default constructor for the - // type. - opt_storage() : Value(DataType()) {} - - template - void setValue(const T &V) { Value = V; } - DataType &getValue() { return Value; } - DataType getValue() const { return Value; } - - // If the datatype is a pointer, support -> on it. - DataType operator->() const { return Value; } -}; - - -//===----------------------------------------------------------------------===// -// opt - A scalar command line option. -// -template > -class opt : public Option, - public opt_storage::value> { - ParserClass Parser; - - virtual bool handleOccurrence(unsigned pos, const char *ArgName, - const std::string &Arg) { - typename ParserClass::parser_data_type Val; - if (Parser.parse(*this, ArgName, Arg, Val)) - return true; // Parse error! - setValue(Val); - setPosition(pos); - return false; - } - - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return Parser.getValueExpectedFlagDefault(); - } - - // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { - Parser.printOptionInfo(*this, GlobalWidth); - } - - void done() { - addArgument(ArgStr); - Parser.initialize(*this); - } -public: - // setInitialValue - Used by the cl::init modifier... - void setInitialValue(const DataType &V) { this->setValue(V); } - - ParserClass &getParser() { return Parser; } - - operator DataType() const { return this->getValue(); } - - template - DataType &operator=(const T &Val) { - this->setValue(Val); - return this->getValue(); - } - - // One option... - template - opt(const M0t &M0) { - apply(M0, this); - done(); - } - - // Two options... - template - opt(const M0t &M0, const M1t &M1) { - apply(M0, this); apply(M1, this); - done(); - } - - // Three options... - template - opt(const M0t &M0, const M1t &M1, const M2t &M2) { - apply(M0, this); apply(M1, this); apply(M2, this); - done(); - } - // Four options... - template - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - done(); - } - // Five options... - template - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); - done(); - } - // Six options... - template - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); - done(); - } - // Seven options... - template - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, const M6t &M6) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); - done(); - } - // Eight options... - template - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); - done(); - } -}; - -//===----------------------------------------------------------------------===// -// list_storage class - -// Default storage class definition: external storage. This implementation -// assumes the user will specify a variable to store the data into with the -// cl::location(x) modifier. -// -template -class list_storage { - StorageClass *Location; // Where to store the object... - -public: - list_storage() : Location(0) {} - - bool setLocation(Option &O, StorageClass &L) { - if (Location) - return O.error(": cl::location(x) specified more than once!"); - Location = &L; - return false; - } - - template - void addValue(const T &V) { - assert(Location != 0 && "cl::location(...) not specified for a command " - "line option with external storage!"); - Location->push_back(V); - } -}; - - -// Define how to hold a class type object, such as a string. Since we can -// inherit from a class, we do so. This makes us exactly compatible with the -// object in all cases that it is used. -// -template -struct list_storage : public std::vector { - - template - void addValue(const T &V) { push_back(V); } -}; - - -//===----------------------------------------------------------------------===// -// list - A list of command line options. -// -template > -class list : public Option, public list_storage { - std::vector Positions; - ParserClass Parser; - - virtual enum NumOccurrences getNumOccurrencesFlagDefault() const { - return ZeroOrMore; - } - virtual enum ValueExpected getValueExpectedFlagDefault() const { - return Parser.getValueExpectedFlagDefault(); - } - - virtual bool handleOccurrence(unsigned pos, const char *ArgName, - const std::string &Arg) { - typename ParserClass::parser_data_type Val; - if (Parser.parse(*this, ArgName, Arg, Val)) - return true; // Parse Error! - addValue(Val); - setPosition(pos); - Positions.push_back(pos); - return false; - } - - // Forward printing stuff to the parser... - virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} - virtual void printOptionInfo(unsigned GlobalWidth) const { - Parser.printOptionInfo(*this, GlobalWidth); - } - - void done() { - addArgument(ArgStr); - Parser.initialize(*this); - } -public: - ParserClass &getParser() { return Parser; } - - unsigned getPosition(unsigned optnum) { - assert(optnum < this->size() && "Invalid option index"); - return Positions[optnum]; - } - - // One option... - template - list(const M0t &M0) { - apply(M0, this); - done(); - } - // Two options... - template - list(const M0t &M0, const M1t &M1) { - apply(M0, this); apply(M1, this); - done(); - } - // Three options... - template - list(const M0t &M0, const M1t &M1, const M2t &M2) { - apply(M0, this); apply(M1, this); apply(M2, this); - done(); - } - // Four options... - template - list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - done(); - } - // Five options... - template - list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); - done(); - } - // Six options... - template - list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); - done(); - } - // Seven options... - template - list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, const M6t &M6) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); - done(); - } - // Eight options... - template - list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); - done(); - } -}; - -//===----------------------------------------------------------------------===// -// Aliased command line option (alias this name to a preexisting name) -// - -class alias : public Option { - Option *AliasFor; - virtual bool handleOccurrence(unsigned pos, const char *ArgName, - const std::string &Arg) { - return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); - } - // Aliases default to be hidden... - virtual enum OptionHidden getOptionHiddenFlagDefault() const {return Hidden;} - - // Handle printing stuff... - virtual unsigned getOptionWidth() const; - virtual void printOptionInfo(unsigned GlobalWidth) const; - - void done() { - if (!hasArgStr()) - error(": cl::alias must have argument name specified!"); - if (AliasFor == 0) - error(": cl::alias must have an cl::aliasopt(option) specified!"); - addArgument(ArgStr); - } -public: - void setAliasFor(Option &O) { - if (AliasFor) - error(": cl::alias must only have one cl::aliasopt(...) specified!"); - AliasFor = &O; - } - - // One option... - template - alias(const M0t &M0) : AliasFor(0) { - apply(M0, this); - done(); - } - // Two options... - template - alias(const M0t &M0, const M1t &M1) : AliasFor(0) { - apply(M0, this); apply(M1, this); - done(); - } - // Three options... - template - alias(const M0t &M0, const M1t &M1, const M2t &M2) : AliasFor(0) { - apply(M0, this); apply(M1, this); apply(M2, this); - done(); - } - // Four options... - template - alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) - : AliasFor(0) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - done(); - } -}; - -// aliasfor - Modifier to set the option an alias aliases. -struct aliasopt { - Option &Opt; - aliasopt(Option &O) : Opt(O) {} - void apply(alias &A) const { A.setAliasFor(Opt); } -}; - -} // End namespace cl - -} // End namespace llvm - -#endif diff --git a/include/Support/DOTGraphTraits.h b/include/Support/DOTGraphTraits.h deleted file mode 100644 index 7dbc4ff0b6..0000000000 --- a/include/Support/DOTGraphTraits.h +++ /dev/null @@ -1,102 +0,0 @@ -//===-- Support/DotGraphTraits.h - Customize .dot output --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a template class that can be used to customize dot output -// graphs generated by the GraphWriter.h file. The default implementation of -// this file will produce a simple, but not very polished graph. By -// specializing this template, lots of customization opportunities are possible. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_DOTGRAPHTRAITS_H -#define SUPPORT_DOTGRAPHTRAITS_H - -#include - -namespace llvm { - -/// DefaultDOTGraphTraits - This class provides the default implementations of -/// all of the DOTGraphTraits methods. If a specialization does not need to -/// override all methods here it should inherit so that it can get the default -/// implementations. -/// -struct DefaultDOTGraphTraits { - /// getGraphName - Return the label for the graph as a whole. Printed at the - /// top of the graph. - /// - static std::string getGraphName(const void *Graph) { return ""; } - - /// getGraphProperties - Return any custom properties that should be included - /// in the top level graph structure for dot. - /// - static std::string getGraphProperties(const void *Graph) { - return ""; - } - - /// getNodeLabel - Given a node and a pointer to the top level graph, return - /// the label to print in the node. - static std::string getNodeLabel(const void *Node, const void *Graph) { - return ""; - } - - /// If you want to specify custom node attributes, this is the place to do so - /// - static std::string getNodeAttributes(const void *Node) { return ""; } - - /// If you want to override the dot attributes printed for a particular edge, - /// override this method. - template - static std::string getEdgeAttributes(const void *Node, EdgeIter EI) { - return ""; - } - - /// getEdgeSourceLabel - If you want to label the edge source itself, - /// implement this method. - template - static std::string getEdgeSourceLabel(const void *Node, EdgeIter I) { - return ""; - } - - /// edgeTargetsEdgeSource - This method returns true if this outgoing edge - /// should actually target another edge source, not a node. If this method is - /// implemented, getEdgeTarget should be implemented. - template - static bool edgeTargetsEdgeSource(const void *Node, EdgeIter I) { - return false; - } - - /// getEdgeTarget - If edgeTargetsEdgeSource returns true, this method is - /// called to determine which outgoing edge of Node is the target of this - /// edge. - template - static EdgeIter getEdgeTarget(const void *Node, EdgeIter I) { - return I; - } - - /// addCustomGraphFeatures - If a graph is made up of more than just - /// straight-forward nodes and edges, this is the place to put all of the - /// custom stuff necessary. The GraphWriter object, instantiated with your - /// GraphType is passed in as an argument. You may call arbitrary methods on - /// it to add things to the output graph. - /// - template - static void addCustomGraphFeatures(const void *Graph, GraphWriter &GW) {} -}; - - -/// DOTGraphTraits - Template class that can be specialized to customize how -/// graphs are converted to 'dot' graphs. When specializing, you may inherit -/// from DefaultDOTGraphTraits if you don't need to override everything. -/// -template -class DOTGraphTraits : public DefaultDOTGraphTraits {}; - -} // End llvm namespace - -#endif diff --git a/include/Support/DataTypes.h.in b/include/Support/DataTypes.h.in deleted file mode 100644 index 180258478d..0000000000 --- a/include/Support/DataTypes.h.in +++ /dev/null @@ -1,64 +0,0 @@ -//===-- include/Support/DataTypes.h - Define fixed size types ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains definitions to figure out the size of _HOST_ data types. -// This file is important because different host OS's define different macros, -// which makes portability tough. This file exports the following definitions: -// -// [u]int(32|64)_t : typedefs for signed and unsigned 32/64 bit system types -// [U]INT(8|16|32|64)_(MIN|MAX) : Constants for the min and max values. -// -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_DATATYPES_H -#define SUPPORT_DATATYPES_H - -// Note that this header's correct operation depends on __STDC_LIMIT_MACROS -// being defined. We would define it here, but in order to prevent Bad Things -// happening when system headers or C++ STL headers include stdint.h before -// we define it here, we define it on the g++ command line (in Makefile.rules). -#if !defined(__STDC_LIMIT_MACROS) -# error "Must #define __STDC_LIMIT_MACROS before #including Support/DataTypes.h" -#endif - -#ifndef _MSC_VER -// Note that includes , if this is a C99 system. -@INCLUDE_INTTYPES_H@ -@INCLUDE_SYS_TYPES_H@ -@INCLUDE_STDINT_H@ -#else -// Visual C++ doesn't provide standard integer headers, but it does provide -// built-in data types. -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef signed int ssize_t; -#define INT8_MAX 127 -#define INT8_MIN -128 -#define UINT8_MAX 255 -#define INT16_MAX 32767 -#define INT16_MIN -32768 -#define UINT16_MAX 65535 -#define INT32_MAX 2147483647 -#define INT32_MIN -2147483648 -#define UINT32_MAX 4294967295U -#endif - -#if !defined(INT64_MAX) -/* We couldn't determine INT64_MAX; default it. */ -# define INT64_MAX 9223372036854775807LL -#endif -#if !defined(UINT64_MAX) -# define UINT64_MAX 0xffffffffffffffffULL -#endif - -#endif /* SUPPORT_DATATYPES_H */ diff --git a/include/Support/Debug.h b/include/Support/Debug.h deleted file mode 100644 index f0a1b3dc5b..0000000000 --- a/include/Support/Debug.h +++ /dev/null @@ -1,67 +0,0 @@ -//===- Debug.h - An easy way to add debug output to your code ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements a handle way of adding debugging information to your -// code, without it being enabled all of the time, and without having to add -// command line options to enable it. -// -// In particular, just wrap your code with the DEBUG() macro, and it will be -// enabled automatically if you specify '-debug' on the command-line. -// Alternatively, you can also use the SET_DEBUG_TYPE("foo") macro to specify -// that your debug code belongs to class "foo". Then, on the command line, you -// can specify '-debug-only=foo' to enable JUST the debug information for the -// foo class. -// -// When compiling in release mode, the -debug-* options and all code in DEBUG() -// statements disappears, so it does not effect the runtime of the code. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_DEBUG_H -#define SUPPORT_DEBUG_H - -// Unsurprisingly, most users of this macro use std::cerr too. -#include - -namespace llvm { - -// DebugFlag - This boolean is set to true if the '-debug' command line option -// is specified. This should probably not be referenced directly, instead, use -// the DEBUG macro below. -// -extern bool DebugFlag; - -// isCurrentDebugType - Return true if the specified string is the debug type -// specified on the command line, or if none was specified on the command line -// with the -debug-only=X option. -// -bool isCurrentDebugType(const char *Type); - -// DEBUG macro - This macro should be used by passes to emit debug information. -// In the '-debug' option is specified on the commandline, and if this is a -// debug build, then the code specified as the option to the macro will be -// executed. Otherwise it will not be. Example: -// -// DEBUG(cerr << "Bitset contains: " << Bitset << "\n"); -// - -#ifndef DEBUG_TYPE -#define DEBUG_TYPE "" -#endif - -#ifdef NDEBUG -#define DEBUG(X) -#else -#define DEBUG(X) \ - do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0) -#endif - -} // End llvm namespace - -#endif diff --git a/include/Support/DenseMap.h b/include/Support/DenseMap.h deleted file mode 100644 index 4f6dc91bb6..0000000000 --- a/include/Support/DenseMap.h +++ /dev/null @@ -1,73 +0,0 @@ -//===- DenseMap.h - A dense map implmentation -------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements a dense map. A dense map template takes two -// types. The first is the mapped type and the second is a functor -// that maps its argument to a size_t. On instantiation a "null" value -// can be provided to be used as a "does not exist" indicator in the -// map. A member function grow() is provided that given the value of -// the maximally indexed key (the argument of the functor) makes sure -// the map has enough space for it. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_DENSEMAP_H -#define SUPPORT_DENSEMAP_H - -#include - -namespace llvm { - - struct IdentityFunctor : std::unary_function { - unsigned operator()(unsigned Index) const { - return Index; - } - }; - - template - class DenseMap { - typedef typename ToIndexT::argument_type IndexT; - typedef std::vector StorageT; - StorageT storage_; - T nullVal_; - ToIndexT toIndex_; - - public: - DenseMap() : nullVal_(T()) { } - - explicit DenseMap(const T& val) : nullVal_(val) { } - - typename StorageT::reference operator[](IndexT n) { - assert(toIndex_(n) < storage_.size() && "index out of bounds!"); - return storage_[toIndex_(n)]; - } - - typename StorageT::const_reference operator[](IndexT n) const { - assert(toIndex_(n) < storage_.size() && "index out of bounds!"); - return storage_[toIndex_(n)]; - } - - void clear() { - storage_.clear(); - } - - void grow(IndexT n) { - unsigned NewSize = toIndex_(n) + 1; - if (NewSize > storage_.size()) - storage_.resize(NewSize, nullVal_); - } - - typename StorageT::size_type size() const { - return storage_.size(); - } - }; - -} // End llvm namespace - -#endif diff --git a/include/Support/DepthFirstIterator.h b/include/Support/DepthFirstIterator.h deleted file mode 100644 index c465f4e549..0000000000 --- a/include/Support/DepthFirstIterator.h +++ /dev/null @@ -1,230 +0,0 @@ -//===- Support/DepthFirstIterator.h - Depth First iterator ------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file builds on the Support/GraphTraits.h file to build generic depth -// first graph iterator. This file exposes the following functions/types: -// -// df_begin/df_end/df_iterator -// * Normal depth-first iteration - visit a node and then all of its children. -// -// idf_begin/idf_end/idf_iterator -// * Depth-first iteration on the 'inverse' graph. -// -// df_ext_begin/df_ext_end/df_ext_iterator -// * Normal depth-first iteration - visit a node and then all of its children. -// This iterator stores the 'visited' set in an external set, which allows -// it to be more efficient, and allows external clients to use the set for -// other purposes. -// -// idf_ext_begin/idf_ext_end/idf_ext_iterator -// * Depth-first iteration on the 'inverse' graph. -// This iterator stores the 'visited' set in an external set, which allows -// it to be more efficient, and allows external clients to use the set for -// other purposes. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_DEPTHFIRSTITERATOR_H -#define SUPPORT_DEPTHFIRSTITERATOR_H - -#include "Support/GraphTraits.h" -#include "Support/iterator" -#include -#include - -namespace llvm { - -// df_iterator_storage - A private class which is used to figure out where to -// store the visited set. -template // Non-external set -class df_iterator_storage { -public: - SetType Visited; -}; - -template -class df_iterator_storage { -public: - df_iterator_storage(SetType &VSet) : Visited(VSet) {} - df_iterator_storage(const df_iterator_storage &S) : Visited(S.Visited) {} - SetType &Visited; -}; - - -// Generic Depth First Iterator -template::NodeType*>, - bool ExtStorage = false, class GT = GraphTraits > -class df_iterator : public forward_iterator, - public df_iterator_storage { - typedef forward_iterator super; - - typedef typename GT::NodeType NodeType; - typedef typename GT::ChildIteratorType ChildItTy; - - // VisitStack - Used to maintain the ordering. Top = current block - // First element is node pointer, second is the 'next child' to visit - std::vector > VisitStack; -private: - inline df_iterator(NodeType *Node) { - this->Visited.insert(Node); - VisitStack.push_back(std::make_pair(Node, GT::child_begin(Node))); - } - inline df_iterator() { /* End is when stack is empty */ } - - inline df_iterator(NodeType *Node, SetType &S) - : df_iterator_storage(S) { - if (!S.count(Node)) { - this->Visited.insert(Node); - VisitStack.push_back(std::make_pair(Node, GT::child_begin(Node))); - } - } - inline df_iterator(SetType &S) - : df_iterator_storage(S) { - // End is when stack is empty - } - -public: - typedef typename super::pointer pointer; - typedef df_iterator _Self; - - // Provide static begin and end methods as our public "constructors" - static inline _Self begin(GraphT G) { - return _Self(GT::getEntryNode(G)); - } - static inline _Self end(GraphT G) { return _Self(); } - - // Static begin and end methods as our public ctors for external iterators - static inline _Self begin(GraphT G, SetType &S) { - return _Self(GT::getEntryNode(G), S); - } - static inline _Self end(GraphT G, SetType &S) { return _Self(S); } - - inline bool operator==(const _Self& x) const { - return VisitStack.size() == x.VisitStack.size() && - VisitStack == x.VisitStack; - } - inline bool operator!=(const _Self& x) const { return !operator==(x); } - - inline pointer operator*() const { - return VisitStack.back().first; - } - - // This is a nonstandard operator-> that dereferences the pointer an extra - // time... so that you can actually call methods ON the Node, because - // the contained type is a pointer. This allows BBIt->getTerminator() f.e. - // - inline NodeType *operator->() const { return operator*(); } - - inline _Self& operator++() { // Preincrement - do { - std::pair &Top = VisitStack.back(); - NodeType *Node = Top.first; - ChildItTy &It = Top.second; - - while (It != GT::child_end(Node)) { - NodeType *Next = *It++; - if (!this->Visited.count(Next)) { // Has our next sibling been visited? - // No, do it now. - this->Visited.insert(Next); - VisitStack.push_back(std::make_pair(Next, GT::child_begin(Next))); - return *this; - } - } - - // Oops, ran out of successors... go up a level on the stack. - VisitStack.pop_back(); - } while (!VisitStack.empty()); - return *this; - } - - inline _Self operator++(int) { // Postincrement - _Self tmp = *this; ++*this; return tmp; - } - - // nodeVisited - return true if this iterator has already visited the - // specified node. This is public, and will probably be used to iterate over - // nodes that a depth first iteration did not find: ie unreachable nodes. - // - inline bool nodeVisited(NodeType *Node) const { - return this->Visited.count(Node) != 0; - } -}; - - -// Provide global constructors that automatically figure out correct types... -// -template -df_iterator df_begin(T G) { - return df_iterator::begin(G); -} - -template -df_iterator df_end(T G) { - return df_iterator::end(G); -} - -// Provide global definitions of external depth first iterators... -template ::NodeType*> > -struct df_ext_iterator : public df_iterator { - df_ext_iterator(const df_iterator &V) - : df_iterator(V) {} -}; - -template -df_ext_iterator df_ext_begin(T G, SetTy &S) { - return df_ext_iterator::begin(G, S); -} - -template -df_ext_iterator df_ext_end(T G, SetTy &S) { - return df_ext_iterator::end(G, S); -} - - -// Provide global definitions of inverse depth first iterators... -template ::NodeType*>, - bool External = false> -struct idf_iterator : public df_iterator, SetTy, External> { - idf_iterator(const df_iterator, SetTy, External> &V) - : df_iterator, SetTy, External>(V) {} -}; - -template -idf_iterator idf_begin(T G) { - return idf_iterator::begin(G); -} - -template -idf_iterator idf_end(T G){ - return idf_iterator::end(G); -} - -// Provide global definitions of external inverse depth first iterators... -template ::NodeType*> > -struct idf_ext_iterator : public idf_iterator { - idf_ext_iterator(const idf_iterator &V) - : idf_iterator(V) {} - idf_ext_iterator(const df_iterator, SetTy, true> &V) - : idf_iterator(V) {} -}; - -template -idf_ext_iterator idf_ext_begin(T G, SetTy &S) { - return idf_ext_iterator::begin(G, S); -} - -template -idf_ext_iterator idf_ext_end(T G, SetTy &S) { - return idf_ext_iterator::end(G, S); -} - -} // End llvm namespace - -#endif diff --git a/include/Support/DynamicLinker.h b/include/Support/DynamicLinker.h deleted file mode 100644 index fec9a45296..0000000000 --- a/include/Support/DynamicLinker.h +++ /dev/null @@ -1,40 +0,0 @@ -//===-- DynamicLinker.h - System-indep. DynamicLinker interface -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Lightweight interface to dynamic library linking and loading, and dynamic -// symbol lookup functionality, in whatever form the operating system -// provides it. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_DYNAMICLINKER_H -#define SUPPORT_DYNAMICLINKER_H - -#include - -namespace llvm { - -/// LinkDynamicObject - Load the named file as a dynamic library -/// and link it with the currently running process. Returns false -/// on success, true if there is an error (and sets ErrorMessage -/// if it is not NULL). Analogous to dlopen(). -/// -bool LinkDynamicObject (const char *filename, std::string *ErrorMessage); - -/// GetAddressOfSymbol - Returns the address of the named symbol in -/// the currently running process, as reported by the dynamic linker, -/// or NULL if the symbol does not exist or some other error has -/// occurred. -/// -void *GetAddressOfSymbol (const char *symbolName); -void *GetAddressOfSymbol (const std::string &symbolName); - -} // End llvm namespace - -#endif // SUPPORT_DYNAMICLINKER_H diff --git a/include/Support/ELF.h b/include/Support/ELF.h deleted file mode 100644 index e4b87b9022..0000000000 --- a/include/Support/ELF.h +++ /dev/null @@ -1,295 +0,0 @@ -//===-- Support/ELF.h - ELF constants and data structures -------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This header contains common, non-processor-specific data structures and -// constants for the ELF file format. -// -// The details of the ELF32 bits in this file are largely based on -// the Tool Interface Standard (TIS) Executable and Linking Format -// (ELF) Specification Version 1.2, May 1995. The ELF64 stuff is not -// standardized, as far as I can tell. It was largely based on information -// I found in OpenBSD header files. -// -//===----------------------------------------------------------------------===// - -#include "Support/DataTypes.h" -#include -#include - -namespace llvm { - -namespace ELF { - -typedef uint32_t Elf32_Addr; // Program address -typedef uint16_t Elf32_Half; -typedef uint32_t Elf32_Off; // File offset -typedef int32_t Elf32_Sword; -typedef uint32_t Elf32_Word; - -typedef uint64_t Elf64_Addr; -typedef uint64_t Elf64_Off; -typedef int32_t Elf64_Shalf; -typedef int32_t Elf64_Sword; -typedef uint32_t Elf64_Word; -typedef int64_t Elf64_Sxword; -typedef uint64_t Elf64_Xword; -typedef uint32_t Elf64_Half; -typedef uint16_t Elf64_Quarter; - -// Object file magic string. -static const char ElfMagic[] = { 0x7f, 'E', 'L', 'F', '\0' }; - -struct Elf32_Ehdr { - unsigned char e_ident[16]; // ELF Identification bytes - Elf32_Half e_type; // Type of file (see ET_* below) - Elf32_Half e_machine; // Required architecture for this file (see EM_*) - Elf32_Word e_version; // Must be equal to 1 - Elf32_Addr e_entry; // Address to jump to in order to start program - Elf32_Off e_phoff; // Program header table's file offset, in bytes - Elf32_Off e_shoff; // Section header table's file offset, in bytes - Elf32_Word e_flags; // Processor-specific flags - Elf32_Half e_ehsize; // Size of ELF header, in bytes - Elf32_Half e_phentsize; // Size of an entry in the program header table - Elf32_Half e_phnum; // Number of entries in the program header table - Elf32_Half e_shentsize; // Size of an entry in the section header table - Elf32_Half e_shnum; // Number of entries in the section header table - Elf32_Half e_shstrndx; // Sect hdr table index of sect name string table - bool checkMagic () const { - return (memcmp (e_ident, ElfMagic, strlen (ElfMagic))) == 0; - } - unsigned char getFileClass () const { return e_ident[4]; } - unsigned char getDataEncoding () { return e_ident[5]; } -}; - -// 64-bit ELF header. Fields are the same as for ELF32, but with different -// types (see above). -struct Elf64_Ehdr { - unsigned char e_ident[16]; - Elf64_Quarter e_type; - Elf64_Quarter e_machine; - Elf64_Half e_version; - Elf64_Addr e_entry; - Elf64_Off e_phoff; - Elf64_Off e_shoff; - Elf64_Half e_flags; - Elf64_Quarter e_ehsize; - Elf64_Quarter e_phentsize; - Elf64_Quarter e_phnum; - Elf64_Quarter e_shentsize; - Elf64_Quarter e_shnum; - Elf64_Quarter e_shstrndx; -}; - -// File types -enum { - ET_NONE = 0, // No file type - ET_REL = 1, // Relocatable file - ET_EXEC = 2, // Executable file - ET_DYN = 3, // Shared object file - ET_CORE = 4, // Core file - ET_LOPROC = 0xff00, // Beginning of processor-specific codes - ET_HIPROC = 0xffff // Processor-specific -}; - -// Machine architectures -enum { - EM_NONE = 0, // No machine - EM_M32 = 1, // AT&T WE 32100 - EM_SPARC = 2, // SPARC - EM_386 = 3, // Intel 386 - EM_68K = 4, // Motorola 68000 - EM_88K = 5, // Motorola 88000 - EM_486 = 6, // Intel 486 (deprecated) - EM_860 = 7, // Intel 80860 - EM_MIPS = 8, // MIPS R3000 - EM_PPC = 20, // PowerPC - EM_ARM = 40, // ARM - EM_ALPHA = 41, // DEC Alpha - EM_SPARCV9 = 43 // SPARC V9 -}; - -// Object file classes. -enum { - ELFCLASS32 = 1, // 32-bit object file - ELFCLASS64 = 2 // 64-bit object file -}; - -// Object file byte orderings. -enum { - ELFDATA2LSB = 1, // Little-endian object file - ELFDATA2MSB = 2 // Big-endian object file -}; - -// Section header. -struct Elf32_Shdr { - Elf32_Word sh_name; // Section name (index into string table) - Elf32_Word sh_type; // Section type (SHT_*) - Elf32_Word sh_flags; // Section flags (SHF_*) - Elf32_Addr sh_addr; // Address where section is to be loaded - Elf32_Off sh_offset; // File offset of section data, in bytes - Elf32_Word sh_size; // Size of section, in bytes - Elf32_Word sh_link; // Section type-specific header table index link - Elf32_Word sh_info; // Section type-specific extra information - Elf32_Word sh_addralign; // Section address alignment - Elf32_Word sh_entsize; // Size of records contained within the section -}; - -// Section header for ELF64 - same fields as ELF32, different types. -struct Elf64_Shdr { - Elf64_Half sh_name; - Elf64_Half sh_type; - Elf64_Xword sh_flags; - Elf64_Addr sh_addr; - Elf64_Off sh_offset; - Elf64_Xword sh_size; - Elf64_Half sh_link; - Elf64_Half sh_info; - Elf64_Xword sh_addralign; - Elf64_Xword sh_entsize; -}; - -// Special section indices. -enum { - SHN_UNDEF = 0, // Undefined, missing, irrelevant, or meaningless - SHN_LORESERVE = 0xff00, // Lowest reserved index - SHN_LOPROC = 0xff00, // Lowest processor-specific index - SHN_HIPROC = 0xff1f, // Highest processor-specific index - SHN_ABS = 0xfff1, // Symbol has absolute value; does not need relocation - SHN_COMMON = 0xfff2, // FORTRAN COMMON or C external global variables - SHN_HIRESERVE = 0xffff // Highest reserved index -}; - -// Section types. -enum { - SHT_NULL = 0, // No associated section (inactive entry). - SHT_PROGBITS = 1, // Program-defined contents. - SHT_SYMTAB = 2, // Symbol table. - SHT_STRTAB = 3, // String table. - SHT_RELA = 4, // Relocation entries; explicit addends. - SHT_HASH = 5, // Symbol hash table. - SHT_DYNAMIC = 6, // Information for dynamic linking. - SHT_NOTE = 7, // Information about the file. - SHT_NOBITS = 8, // Data occupies no space in the file. - SHT_REL = 9, // Relocation entries; no explicit addends. - SHT_SHLIB = 10, // Reserved. - SHT_DYNSYM = 11, // Symbol table. - SHT_LOPROC = 0x70000000, // Lowest processor architecture-specific type. - SHT_HIPROC = 0x7fffffff, // Highest processor architecture-specific type. - SHT_LOUSER = 0x80000000, // Lowest type reserved for applications. - SHT_HIUSER = 0xffffffff // Highest type reserved for applications. -}; - -// Section flags. -enum { - SHF_WRITE = 0x1, // Section data should be writable during execution. - SHF_ALLOC = 0x2, // Section occupies memory during program execution. - SHF_EXECINSTR = 0x4, // Section contains executable machine instructions. - SHF_MASKPROC = 0xf0000000 // Bits indicating processor-specific flags. -}; - -// Symbol table entries. -struct Elf32_Sym { - Elf32_Word st_name; // Symbol name (index into string table) - Elf32_Addr st_value; // Value or address associated with the symbol - Elf32_Word st_size; // Size of the symbol - unsigned char st_info; // Symbol's type and binding attributes - unsigned char st_other; // Must be zero; reserved - Elf32_Half st_shndx; // Which section (header table index) it's defined in - - // These accessors and mutators correspond to the ELF32_ST_BIND, - // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification: - unsigned char getBinding () const { return st_info >> 4; } - unsigned char getType () const { return st_info & 0x0f; } - void setBinding (unsigned char b) { setBindingAndType (b, getType ()); } - void setType (unsigned char t) { setBindingAndType (getBinding (), t); } - void setBindingAndType (unsigned char b, unsigned char t) { - st_info = (b << 4) + (t & 0x0f); - } -}; - -// Symbol bindings. -enum { - STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def - STB_GLOBAL = 1, // Global symbol, visible to all object files being combined - STB_WEAK = 2, // Weak symbol, like global but lower-precedence - STB_LOPROC = 13, // Lowest processor-specific binding type - STB_HIPROC = 15 // Highest processor-specific binding type -}; - -// Symbol types. -enum { - STT_NOTYPE = 0, // Symbol's type is not specified - STT_OBJECT = 1, // Symbol is a data object (variable, array, etc.) - STT_FUNC = 2, // Symbol is executable code (function, etc.) - STT_SECTION = 3, // Symbol refers to a section - STT_FILE = 4, // Local, absolute symbol that refers to a file - STT_LOPROC = 13, // Lowest processor-specific symbol type - STT_HIPROC = 15 // Highest processor-specific symbol type -}; - -// Relocation entry, without explicit addend. -struct Elf32_Rel { - Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf32_Word r_info; // Symbol table index and type of relocation to apply - - // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE, - // and ELF32_R_INFO macros defined in the ELF specification: - Elf32_Word getSymbol () const { return (r_info >> 8); } - unsigned char getType () const { return (unsigned char) (r_info & 0x0ff); } - void setSymbol (Elf32_Word s) { setSymbolAndType (s, getType ()); } - void setType (unsigned char t) { setSymbolAndType (getSymbol(), t); } - void setSymbolAndType (Elf32_Word s, unsigned char t) { - r_info = (s << 8) + t; - }; -}; - -// Relocation entry with explicit addend. -struct Elf32_Rela { - Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf32_Word r_info; // Symbol table index and type of relocation to apply - Elf32_Sword r_addend; // Compute value for relocatable field by adding this - - // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE, - // and ELF32_R_INFO macros defined in the ELF specification: - Elf32_Word getSymbol () const { return (r_info >> 8); } - unsigned char getType () const { return (unsigned char) (r_info & 0x0ff); } - void setSymbol (Elf32_Word s) { setSymbolAndType (s, getType ()); } - void setType (unsigned char t) { setSymbolAndType (getSymbol(), t); } - void setSymbolAndType (Elf32_Word s, unsigned char t) { - r_info = (s << 8) + t; - }; -}; - -// Program header. -struct Elf32_Phdr { - Elf32_Word p_type; // Type of segment - Elf32_Off p_offset; // File offset where segment is located, in bytes - Elf32_Addr p_vaddr; // Virtual address of beginning of segment - Elf32_Addr p_paddr; // Physical address of beginning of segment (OS-specific) - Elf32_Word p_filesz; // Num. of bytes in file image of segment (may be zero) - Elf32_Word p_memsz; // Num. of bytes in mem image of segment (may be zero) - Elf32_Word p_flags; // Segment flags - Elf32_Word p_align; // Segment alignment constraint -}; - -enum { - PT_NULL = 0, // Unused segment. - PT_LOAD = 1, // Loadable segment. - PT_DYNAMIC = 2, // Dynamic linking information. - PT_INTERP = 3, // Interpreter pathname. - PT_NOTE = 4, // Auxiliary information. - PT_SHLIB = 5, // Reserved. - PT_PHDR = 6, // The program header table itself. - PT_LOPROC = 0x70000000, // Lowest processor-specific program hdr entry type. - PT_HIPROC = 0x7fffffff // Highest processor-specific program hdr entry type. -}; - -} // end namespace ELF - -} // end namespace llvm diff --git a/include/Support/EquivalenceClasses.h b/include/Support/EquivalenceClasses.h deleted file mode 100644 index 127183614b..0000000000 --- a/include/Support/EquivalenceClasses.h +++ /dev/null @@ -1,116 +0,0 @@ -//===-- Support/EquivalenceClasses.h ----------------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Generic implementation of equivalence classes and implementation of -// union-find algorithms A not-so-fancy implementation: 2 level tree i.e root -// and one more level Overhead of a union = size of the equivalence class being -// attached Overhead of a find = 1. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_EQUIVALENCECLASSES_H -#define SUPPORT_EQUIVALENCECLASSES_H - -#include -#include -#include - -namespace llvm { - -template -class EquivalenceClasses { - // Maps each element to the element that is the leader of its - // equivalence class. - std::map Elem2LeaderMap; - - // Maintains the set of leaders - std::set LeaderSet; - - // Caches the equivalence class for each leader - std::map > LeaderToEqClassMap; - - // Make Element2 the leader of the union of classes Element1 and Element2 - // Element1 and Element2 are presumed to be leaders of their respective - // equivalence classes. - void attach(ElemTy Element1, ElemTy Element2) { - for (typename std::map::iterator ElemI = - Elem2LeaderMap.begin(), ElemE = Elem2LeaderMap.end(); - ElemI != ElemE; ++ElemI) { - if (ElemI->second == Element1) - Elem2LeaderMap[ElemI->first] = Element2; - } - } - -public: - // If an element has not yet in any class, make it a separate new class. - // Return the leader of the class containing the element. - ElemTy addElement (ElemTy NewElement) { - typename std::map::iterator ElemI = - Elem2LeaderMap.find(NewElement); - if (ElemI == Elem2LeaderMap.end()) { - Elem2LeaderMap[NewElement] = NewElement; - LeaderSet.insert(NewElement); - return NewElement; - } - else - return ElemI->second; - } - - ElemTy findClass(ElemTy Element) const { - typename std::map::const_iterator I = - Elem2LeaderMap.find(Element); - return (I == Elem2LeaderMap.end())? (ElemTy) 0 : I->second; - } - - /// Attach the set with Element1 to the set with Element2 adding Element1 and - /// Element2 to the set of equivalence classes if they are not there already. - /// Implication: Make Element1 the element in the smaller set. - /// Take Leader[Element1] out of the set of leaders. - void unionSetsWith(ElemTy Element1, ElemTy Element2) { - // If either Element1 or Element2 does not already exist, include it - const ElemTy& leader1 = addElement(Element1); - const ElemTy& leader2 = addElement(Element2); - assert(leader1 != (ElemTy) 0 && leader2 != (ElemTy) 0); - if (leader1 != leader2) { - attach(leader1, leader2); - LeaderSet.erase(leader1); - } - } - - // Returns a vector containing all the elements in the equivalence class - // including Element1 - const std::set & getEqClass(ElemTy Element1) { - assert(Elem2LeaderMap.find(Element1) != Elem2LeaderMap.end()); - const ElemTy classLeader = Elem2LeaderMap[Element1]; - - std::set & EqClass = LeaderToEqClassMap[classLeader]; - - // If the EqClass vector is empty, it has not been computed yet: do it now - if (EqClass.empty()) { - for (typename std::map::iterator - ElemI = Elem2LeaderMap.begin(), ElemE = Elem2LeaderMap.end(); - ElemI != ElemE; ++ElemI) - if (ElemI->second == classLeader) - EqClass.insert(ElemI->first); - assert(! EqClass.empty()); // must at least include the leader - } - - return EqClass; - } - - std::set& getLeaderSet() { return LeaderSet; } - const std::set& getLeaderSet() const { return LeaderSet; } - - std::map& getLeaderMap() { return Elem2LeaderMap;} - const std::map& getLeaderMap() const { return Elem2LeaderMap;} -}; - -} // End llvm namespace - -#endif diff --git a/include/Support/FileUtilities.h b/include/Support/FileUtilities.h deleted file mode 100644 index 78983b8352..0000000000 --- a/include/Support/FileUtilities.h +++ /dev/null @@ -1,170 +0,0 @@ -//===- Support/FileUtilities.h - File System Utilities ----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a family of utility functions which are useful for doing -// various things with files. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_FILEUTILITIES_H -#define SUPPORT_FILEUTILITIES_H - -#include - -namespace llvm { - -/// CheckMagic - Returns true IFF the file named FN begins with Magic. FN must -/// name a readable file. -/// -bool CheckMagic (const std::string &FN, const std::string &Magic); - -/// IsArchive - Returns true IFF the file named FN appears to be a "ar" library -/// archive. The file named FN must exist. -/// -bool IsArchive (const std::string &FN); - -/// IsBytecode - Returns true IFF the file named FN appears to be an LLVM -/// bytecode file. The file named FN must exist. -/// -bool IsBytecode (const std::string &FN); - -/// IsSharedObject - Returns trus IFF the file named FN appears to be a shared -/// object with an ELF header. The file named FN must exist. -/// -bool IsSharedObject(const std::string &FN); - -/// FileOpenable - Returns true IFF Filename names an existing regular file -/// which we can successfully open. -/// -bool FileOpenable(const std::string &Filename); - -/// DiffFiles - Compare the two files specified, returning true if they are -/// different or if there is a file error. If you specify a string to fill in -/// for the error option, it will set the string to an error message if an error -/// occurs, allowing the caller to distinguish between a failed diff and a file -/// system error. -/// -bool DiffFiles(const std::string &FileA, const std::string &FileB, - std::string *Error = 0); - -/// CopyFile - Copy the specified source file to the specified destination, -/// overwriting destination if it exists. This returns true on failure. -/// -bool CopyFile(const std::string &Dest, const std::string &Src); - -/// MoveFileOverIfUpdated - If the file specified by New is different than Old, -/// or if Old does not exist, move the New file over the Old file. Otherwise, -/// remove the New file. -/// -void MoveFileOverIfUpdated(const std::string &New, const std::string &Old); - -/// removeFile - Delete the specified file. -/// -void removeFile(const std::string &Filename); - -/// getUniqueFilename - Return a filename with the specified prefix. If the -/// file does not exist yet, return it, otherwise add a suffix to make it -/// unique. -/// -std::string getUniqueFilename(const std::string &FilenameBase); - -/// MakeFileExecutable - This method turns on whatever access attributes are -/// needed to make the specified file executable. It returns true on success. -/// In case of failure, the file's access attributes are unspecified. -/// -bool MakeFileExecutable(const std::string &Filename); - -/// MakeFileReadable - This method turns on whatever access attributes are -/// needed to make the specified file readable. It returns true on success. -/// In case of failure, the file's access attributes are unspecified. -/// -bool MakeFileReadable(const std::string &Filename); - -/// getFileSize - Return the size of the specified file in bytes, or -1 if the -/// file cannot be read or does not exist. -long long getFileSize(const std::string &Filename); - - -/// getFileTimestamp - Get the last modified time for the specified file in an -/// unspecified format. This is useful to allow checking to see if a file was -/// updated since that last time the timestampt was aquired. If the file does -/// not exist or there is an error getting the time-stamp, zero is returned. -unsigned long long getFileTimestamp(const std::string &Filename); - -/// ReadFileIntoAddressSpace - Attempt to map the specific file into the -/// address space of the current process for reading. If this succeeds, -/// return the address of the buffer and the length of the file mapped. On -/// failure, return null. -void *ReadFileIntoAddressSpace(const std::string &Filename, unsigned &Length); - -/// UnmapFileFromAddressSpace - Remove the specified file from the current -/// address space. -void UnmapFileFromAddressSpace(void *Buffer, unsigned Length); - - -/// FDHandle - Simple handle class to make sure a file descriptor gets closed -/// when the object is destroyed. This handle acts similarly to an -/// std::auto_ptr, in that the copy constructor and assignment operators -/// transfer ownership of the handle. This means that FDHandle's do not have -/// value semantics. -/// -class FDHandle { - int FD; -public: - FDHandle() : FD(-1) {} - FDHandle(int fd) : FD(fd) {} - FDHandle(FDHandle &RHS) : FD(RHS.FD) { - RHS.FD = -1; // Transfer ownership - } - - ~FDHandle() throw(); - - /// get - Get the current file descriptor, without releasing ownership of it. - int get() const { return FD; } - operator int() const { return FD; } - - FDHandle &operator=(int fd) throw(); - - FDHandle &operator=(FDHandle &RHS) { - int fd = RHS.FD; - RHS.FD = -1; // Transfer ownership - return operator=(fd); - } - - /// release - Take ownership of the file descriptor away from the FDHandle - /// object, so that the file is not closed when the FDHandle is destroyed. - int release() { - int Ret = FD; - FD = -1; - return Ret; - } -}; - - /// FileRemover - This class is a simple object meant to be stack allocated. - /// If an exception is thrown from a region, the object removes the filename - /// specified (if deleteIt is true). - /// - class FileRemover { - std::string Filename; - bool DeleteIt; - public: - FileRemover(const std::string &filename, bool deleteIt = true) - : Filename(filename), DeleteIt(deleteIt) {} - - ~FileRemover() { - if (DeleteIt) removeFile(Filename); - } - - /// releaseFile - Take ownership of the file away from the FileRemover so it - /// will not be removed when the object is destroyed. - void releaseFile() { DeleteIt = false; } - }; -} // End llvm namespace - -#endif diff --git a/include/Support/GraphTraits.h b/include/Support/GraphTraits.h deleted file mode 100644 index 4ff74176a7..0000000000 --- a/include/Support/GraphTraits.h +++ /dev/null @@ -1,83 +0,0 @@ -//===-- Support/GraphTraits.h - Graph traits template -----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the little GraphTraits template class that should be -// specialized by classes that want to be iteratable by generic graph iterators. -// -// This file also defines the marker class Inverse that is used to iterate over -// graphs in a graph defined, inverse ordering... -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_GRAPHTRAITS_H -#define SUPPORT_GRAPHTRAITS_H - -namespace llvm { - -// GraphTraits - This class should be specialized by different graph types... -// which is why the default version is empty. -// -template -struct GraphTraits { - // Elements to provide: - - // typedef NodeType - Type of Node in the graph - // typedef ChildIteratorType - Type used to iterate over children in graph - - // static NodeType *getEntryNode(GraphType *) - // Return the entry node of the graph - - // static ChildIteratorType child_begin(NodeType *) - // static ChildIteratorType child_end (NodeType *) - // Return iterators that point to the beginning and ending of the child - // node list for the specified node. - // - - - // typedef ...iterator nodes_iterator; - // static nodes_iterator nodes_begin(GraphType *G) - // static nodes_iterator nodes_end (GraphType *G) - // - // nodes_iterator/begin/end - Allow iteration over all nodes in the graph - - - // If anyone tries to use this class without having an appropriate - // specialization, make an error. If you get this error, it's because you - // need to include the appropriate specialization of GraphTraits<> for your - // graph, or you need to define it for a new graph type. Either that or - // your argument to XXX_begin(...) is unknown or needs to have the proper .h - // file #include'd. - // - typedef typename GraphType::UnknownGraphTypeError NodeType; -}; - - -// Inverse - This class is used as a little marker class to tell the graph -// iterator to iterate over the graph in a graph defined "Inverse" ordering. -// Not all graphs define an inverse ordering, and if they do, it depends on -// the graph exactly what that is. Here's an example of usage with the -// df_iterator: -// -// idf_iterator I = idf_begin(M), E = idf_end(M); -// for (; I != E; ++I) { ... } -// -// Which is equivalent to: -// df_iterator > I = idf_begin(M), E = idf_end(M); -// for (; I != E; ++I) { ... } -// -template -struct Inverse { - GraphType &Graph; - - inline Inverse(GraphType &G) : Graph(G) {} -}; - -} // End llvm namespace - -#endif diff --git a/include/Support/GraphWriter.h b/include/Support/GraphWriter.h deleted file mode 100644 index c6a5c3cdc9..0000000000 --- a/include/Support/GraphWriter.h +++ /dev/null @@ -1,216 +0,0 @@ -//===-- Support/GraphWriter.h - Write a graph to a .dot file ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a simple interface that can be used to print out generic -// LLVM graphs to ".dot" files. "dot" is a tool that is part of the AT&T -// graphviz package (http://www.research.att.com/sw/tools/graphviz/) which can -// be used to turn the files output by this interface into a variety of -// different graphics formats. -// -// Graphs do not need to implement any interface past what is already required -// by the GraphTraits template, but they can choose to implement specializations -// of the DOTGraphTraits template if they want to customize the graphs output in -// any way. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_GRAPHWRITER_H -#define SUPPORT_GRAPHWRITER_H - -#include "Support/DOTGraphTraits.h" -#include "Support/GraphTraits.h" -#include -#include - -namespace llvm { - -namespace DOT { // Private functions... - inline std::string EscapeString(const std::string &Label) { - std::string Str(Label); - for (unsigned i = 0; i != Str.length(); ++i) - switch (Str[i]) { - case '\n': - Str.insert(Str.begin()+i, '\\'); // Escape character... - ++i; - Str[i] = 'n'; - break; - case '\t': - Str.insert(Str.begin()+i, ' '); // Convert to two spaces - ++i; - Str[i] = ' '; - break; - case '\\': - if (i+1 != Str.length() && Str[i+1] == 'l') - break; // don't disturb \l - case '{': case '}': - case '<': case '>': - case '"': - Str.insert(Str.begin()+i, '\\'); // Escape character... - ++i; // don't infinite loop - break; - } - return Str; - } -} - -template -class GraphWriter { - std::ostream &O; - const GraphType &G; - - typedef DOTGraphTraits DOTTraits; - typedef GraphTraits GTraits; - typedef typename GTraits::NodeType NodeType; - typedef typename GTraits::nodes_iterator node_iterator; - typedef typename GTraits::ChildIteratorType child_iterator; -public: - GraphWriter(std::ostream &o, const GraphType &g) : O(o), G(g) {} - - void writeHeader(const std::string &Name) { - if (Name.empty()) - O << "digraph foo {\n"; // Graph name doesn't matter - else - O << "digraph " << Name << " {\n"; - - std::string GraphName = DOTTraits::getGraphName(G); - if (!GraphName.empty()) - O << "\tlabel=\"" << DOT::EscapeString(GraphName) << "\";\n"; - O << DOTTraits::getGraphProperties(G); - O << "\n"; - } - - void writeFooter() { - // Finish off the graph - O << "}\n"; - } - - void writeNodes() { - // Loop over the graph, printing it out... - for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G); - I != E; ++I) - writeNode(&*I); - } - - void writeNode(NodeType *Node) { - std::string NodeAttributes = DOTTraits::getNodeAttributes(Node); - - O << "\tNode" << reinterpret_cast(Node) << " [shape=record,"; - if (!NodeAttributes.empty()) O << NodeAttributes << ","; - O << "label=\"{" - << DOT::EscapeString(DOTTraits::getNodeLabel(Node, G)); - - // Print out the fields of the current node... - child_iterator EI = GTraits::child_begin(Node); - child_iterator EE = GTraits::child_end(Node); - if (EI != EE) { - O << "|{"; - - for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) { - if (i) O << "|"; - O << "" << DOTTraits::getEdgeSourceLabel(Node, EI); - } - - if (EI != EE) - O << "|truncated..."; - O << "}"; - } - O << "}\"];\n"; // Finish printing the "node" line - - // Output all of the edges now - EI = GTraits::child_begin(Node); - for (unsigned i = 0; EI != EE && i != 64; ++EI, ++i) - writeEdge(Node, i, EI); - for (; EI != EE; ++EI) - writeEdge(Node, 64, EI); - } - - void writeEdge(NodeType *Node, unsigned edgeidx, child_iterator EI) { - if (NodeType *TargetNode = *EI) { - int DestPort = -1; - if (DOTTraits::edgeTargetsEdgeSource(Node, EI)) { - child_iterator TargetIt = DOTTraits::getEdgeTarget(Node, EI); - - // Figure out which edge this targets... - unsigned Offset = std::distance(GTraits::child_begin(TargetNode), - TargetIt); - DestPort = static_cast(Offset); - } - - emitEdge(reinterpret_cast(Node), edgeidx, - reinterpret_cast(TargetNode), DestPort, - DOTTraits::getEdgeAttributes(Node, EI)); - } - } - - /// emitSimpleNode - Outputs a simple (non-record) node - void emitSimpleNode(const void *ID, const std::string &Attr, - const std::string &Label, unsigned NumEdgeSources = 0, - const std::vector *EdgeSourceLabels = 0) { - O << "\tNode" << ID << "[ "; - if (!Attr.empty()) - O << Attr << ","; - O << " label =\""; - if (NumEdgeSources) O << "{"; - O << DOT::EscapeString(Label); - if (NumEdgeSources) { - O << "|{"; - - for (unsigned i = 0; i != NumEdgeSources; ++i) { - if (i) O << "|"; - O << ""; - if (EdgeSourceLabels) O << (*EdgeSourceLabels)[i]; - } - O << "}}"; - } - O << "\"];\n"; - } - - /// emitEdge - Output an edge from a simple node into the graph... - void emitEdge(const void *SrcNodeID, int SrcNodePort, - const void *DestNodeID, int DestNodePort, - const std::string &Attrs) { - if (SrcNodePort > 64) return; // Eminating from truncated part? - if (DestNodePort > 64) DestNodePort = 64; // Targetting the truncated part? - - O << "\tNode" << SrcNodeID; - if (SrcNodePort >= 0) - O << ":g" << SrcNodePort; - O << " -> Node" << reinterpret_cast(DestNodeID); - if (DestNodePort >= 0) - O << ":g" << DestNodePort; - - if (!Attrs.empty()) - O << "[" << Attrs << "]"; - O << ";\n"; - } -}; - -template -std::ostream &WriteGraph(std::ostream &O, const GraphType &G, - const std::string &Name = "") { - // Start the graph emission process... - GraphWriter W(O, G); - - // Output the header for the graph... - W.writeHeader(Name); - - // Emit all of the nodes in the graph... - W.writeNodes(); - - // Output any customizations on the graph - DOTGraphTraits::addCustomGraphFeatures(G, W); - - // Output the end of the graph - W.writeFooter(); - return O; -} - -} // End llvm namespace - -#endif diff --git a/include/Support/HashExtras.h b/include/Support/HashExtras.h deleted file mode 100644 index 67f65b5f3a..0000000000 --- a/include/Support/HashExtras.h +++ /dev/null @@ -1,41 +0,0 @@ -//===-- HashExtras.h - Useful functions for STL hash containers -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains some templates that are useful if you are working with the -// STL Hashed containers. -// -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_HASHEXTRAS_H -#define SUPPORT_HASHEXTRAS_H - -#include "Support/hash_map" -#include - -// Cannot specialize hash template from outside of the std namespace. -namespace HASH_NAMESPACE { - -template <> struct hash { - size_t operator()(std::string const &str) const { - return hash()(str.c_str()); - } -}; - -// Provide a hash function for arbitrary pointers... -template struct hash { - inline size_t operator()(const T *Val) const { - return reinterpret_cast(Val); - } -}; - -} // End namespace std - -#endif diff --git a/include/Support/LeakDetector.h b/include/Support/LeakDetector.h deleted file mode 100644 index e2ce9c50be..0000000000 --- a/include/Support/LeakDetector.h +++ /dev/null @@ -1,91 +0,0 @@ -//===-- Support/LeakDetector.h - Provide simple leak detection --*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a class that can be used to provide very simple memory leak -// checks for an API. Basically LLVM uses this to make sure that Instructions, -// for example, are deleted when they are supposed to be, and not leaked away. -// -// When compiling with NDEBUG (Release build), this class does nothing, thus -// adding no checking overhead to release builds. Note that this class is -// implemented in a very simple way, requiring completely manual manipulation -// and checking for garbage, but this is intentional: users should not be using -// this API, only other APIs should. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_LEAKDETECTOR_H -#define SUPPORT_LEAKDETECTOR_H - -#include - -namespace llvm { - -class Value; - -struct LeakDetector { - /// addGarbageObject - Add a pointer to the internal set of "garbage" object - /// pointers. This should be called when objects are created, or if they are - /// taken out of an owning collection. - /// - static void addGarbageObject(void *Object) { -#ifndef NDEBUG - addGarbageObjectImpl(Object); -#endif - } - - /// removeGarbageObject - Remove a pointer from our internal representation of - /// our "garbage" objects. This should be called when an object is added to - /// an "owning" collection. - /// - static void removeGarbageObject(void *Object) { -#ifndef NDEBUG - removeGarbageObjectImpl(Object); -#endif - } - - /// checkForGarbage - Traverse the internal representation of garbage - /// pointers. If there are any pointers that have been add'ed, but not - /// remove'd, big obnoxious warnings about memory leaks are issued. - /// - /// The specified message will be printed indicating when the check was - /// performed. - /// - static void checkForGarbage(const std::string &Message) { -#ifndef NDEBUG - checkForGarbageImpl(Message); -#endif - } - - /// Overload the normal methods to work better with Value*'s because they are - /// by far the most common in LLVM. This does not affect the actual - /// functioning of this class, it just makes the warning messages nicer. - /// - static void addGarbageObject(const Value *Object) { -#ifndef NDEBUG - addGarbageObjectImpl(Object); -#endif - } - static void removeGarbageObject(const Value *Object) { -#ifndef NDEBUG - removeGarbageObjectImpl(Object); -#endif - } - -private: - // If we are debugging, the actual implementations will be called... - static void addGarbageObjectImpl(const Value *Object); - static void removeGarbageObjectImpl(const Value *Object); - static void addGarbageObjectImpl(void *Object); - static void removeGarbageObjectImpl(void *Object); - static void checkForGarbageImpl(const std::string &Message); -}; - -} // End llvm namespace - -#endif diff --git a/include/Support/MallocAllocator.h b/include/Support/MallocAllocator.h deleted file mode 100644 index 3e3da4139c..0000000000 --- a/include/Support/MallocAllocator.h +++ /dev/null @@ -1,85 +0,0 @@ -//===-- Support/MallocAllocator.h - Allocator using malloc/free -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines MallocAllocator class, an STL compatible allocator which -// just uses malloc/free to get and release memory. The default allocator uses -// the STL pool allocator runtime library, this explicitly avoids it. -// -// This file is used for variety of purposes, including the pool allocator -// project and testing, regardless of whether or not it's used directly in the -// LLVM code, so don't delete this from CVS if you think it's unused! -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_MALLOCALLOCATOR_H -#define SUPPORT_MALLOCALLOCATOR_H - -#include -#include - -namespace llvm { - -template -struct MallocAllocator { - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef T* pointer; - typedef const T* const_pointer; - typedef T& reference; - typedef const T& const_reference; - typedef T value_type; - template struct rebind { - typedef MallocAllocator other; - }; - - template - MallocAllocator(const MallocAllocator &) {} - MallocAllocator() {} - - pointer address(reference x) const { return &x; } - const_pointer address(const_reference x) const { return &x; } - size_type max_size() const { return ~0 / sizeof(T); } - - static pointer allocate(size_t n, void* hint = 0) { - return static_cast(malloc(n*sizeof(T))); - } - - static void deallocate(pointer p, size_t n) { - free(static_cast(p)); - } - - void construct(pointer p, const T &val) { - new(static_cast(p)) T(val); - } - void destroy(pointer p) { - p->~T(); - } -}; - -template -inline bool operator==(const MallocAllocator &, const MallocAllocator &) { - return true; -} -template -inline bool operator!=(const MallocAllocator&, const MallocAllocator&) { - return false; -} -} // End llvm namespace - -namespace std { - template - struct _Alloc_traits > { - static const bool _S_instanceless = true; - typedef ::llvm::MallocAllocator base_alloc_type; - typedef ::llvm::MallocAllocator _Alloc_type; - typedef ::llvm::MallocAllocator allocator_type; - }; -} - -#endif diff --git a/include/Support/MathExtras.h b/include/Support/MathExtras.h deleted file mode 100644 index c1384d3eff..0000000000 --- a/include/Support/MathExtras.h +++ /dev/null @@ -1,59 +0,0 @@ -//===-- Support/MathExtras.h - Useful math functions ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains some functions that are useful for math stuff. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_MATHEXTRAS_H -#define SUPPORT_MATHEXTRAS_H - -#include "Support/DataTypes.h" - -namespace llvm { - -#if defined(log2) -# undef log2 -#endif - -inline unsigned log2(uint64_t C) { - unsigned getPow; - for (getPow = 0; C > 1; ++getPow) - C >>= 1; - return getPow; -} - -inline unsigned log2(unsigned C) { - unsigned getPow; - for (getPow = 0; C > 1; ++getPow) - C >>= 1; - return getPow; -} - -inline bool isPowerOf2(int64_t C, unsigned &getPow) { - if (C < 0) C = -C; - if (C > 0 && C == (C & ~(C - 1))) { - getPow = log2(static_cast(C)); - return true; - } - - return false; -} - -// Platform-independent wrappers for the C99 isnan() function. -int IsNAN (float f); -int IsNAN (double d); - -// Platform-independent wrappers for the C99 isinf() function. -int IsInf (float f); -int IsInf (double d); - -} // End llvm namespace - -#endif diff --git a/include/Support/PluginLoader.h b/include/Support/PluginLoader.h deleted file mode 100644 index 7410895c3a..0000000000 --- a/include/Support/PluginLoader.h +++ /dev/null @@ -1,35 +0,0 @@ -//===-- Support/PluginLoader.h - Provide -load option to tool ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// A tool can #include this file to get a -load option that allows the user to -// load arbitrary shared objects into the tool's address space. Note that this -// header can only be included by a program ONCE, so it should never to used by -// library authors. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_PLUGINLOADER_H -#define SUPPORT_PLUGINLOADER_H - -#include "Support/CommandLine.h" - -namespace llvm { - struct PluginLoader { - void operator=(const std::string &Filename); - }; - -#ifndef DONT_GET_PLUGIN_LOADER_OPTION - // This causes operator= above to be invoked for every -load option. - static cl::opt > - LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"), - cl::desc("Load the specified plugin")); -#endif -} - -#endif diff --git a/include/Support/PostOrderIterator.h b/include/Support/PostOrderIterator.h deleted file mode 100644 index d66c4b84c4..0000000000 --- a/include/Support/PostOrderIterator.h +++ /dev/null @@ -1,156 +0,0 @@ -//===- Support/PostOrderIterator.h - Generic PostOrder iterator -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file builds on the Support/GraphTraits.h file to build a generic graph -// post order iterator. This should work over any graph type that has a -// GraphTraits specialization. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_POSTORDERITERATOR_H -#define SUPPORT_POSTORDERITERATOR_H - -#include "Support/GraphTraits.h" -#include "Support/iterator" -#include -#include - -namespace llvm { - -template > -class po_iterator : public forward_iterator { - typedef forward_iterator super; - typedef typename GT::NodeType NodeType; - typedef typename GT::ChildIteratorType ChildItTy; - - std::set Visited; // All of the blocks visited so far... - // VisitStack - Used to maintain the ordering. Top = current block - // First element is basic block pointer, second is the 'next child' to visit - std::stack > VisitStack; - - void traverseChild() { - while (VisitStack.top().second != GT::child_end(VisitStack.top().first)) { - NodeType *BB = *VisitStack.top().second++; - if (!Visited.count(BB)) { // If the block is not visited... - Visited.insert(BB); - VisitStack.push(make_pair(BB, GT::child_begin(BB))); - } - } - } - - inline po_iterator(NodeType *BB) { - Visited.insert(BB); - VisitStack.push(make_pair(BB, GT::child_begin(BB))); - traverseChild(); - } - inline po_iterator() { /* End is when stack is empty */ } -public: - typedef typename super::pointer pointer; - typedef po_iterator _Self; - - // Provide static "constructors"... - static inline _Self begin(GraphT G) { return _Self(GT::getEntryNode(G)); } - static inline _Self end (GraphT G) { return _Self(); } - - inline bool operator==(const _Self& x) const { - return VisitStack == x.VisitStack; - } - inline bool operator!=(const _Self& x) const { return !operator==(x); } - - inline pointer operator*() const { - return VisitStack.top().first; - } - - // This is a nonstandard operator-> that dereferences the pointer an extra - // time... so that you can actually call methods ON the BasicBlock, because - // the contained type is a pointer. This allows BBIt->getTerminator() f.e. - // - inline NodeType *operator->() const { return operator*(); } - - inline _Self& operator++() { // Preincrement - VisitStack.pop(); - if (!VisitStack.empty()) - traverseChild(); - return *this; - } - - inline _Self operator++(int) { // Postincrement - _Self tmp = *this; ++*this; return tmp; - } -}; - -// Provide global constructors that automatically figure out correct types... -// -template -po_iterator po_begin(T G) { return po_iterator::begin(G); } -template -po_iterator po_end (T G) { return po_iterator::end(G); } - -// Provide global definitions of inverse post order iterators... -template -struct ipo_iterator : public po_iterator > { - ipo_iterator(const po_iterator > &V) :po_iterator >(V){} -}; - -template -ipo_iterator ipo_begin(T G, bool Reverse = false) { - return ipo_iterator::begin(G, Reverse); -} - -template -ipo_iterator ipo_end(T G){ - return ipo_iterator::end(G); -} - - -//===--------------------------------------------------------------------===// -// Reverse Post Order CFG iterator code -//===--------------------------------------------------------------------===// -// -// This is used to visit basic blocks in a method in reverse post order. This -// class is awkward to use because I don't know a good incremental algorithm to -// computer RPO from a graph. Because of this, the construction of the -// ReversePostOrderTraversal object is expensive (it must walk the entire graph -// with a postorder iterator to build the data structures). The moral of this -// story is: Don't create more ReversePostOrderTraversal classes than necessary. -// -// This class should be used like this: -// { -// ReversePostOrderTraversal RPOT(FuncPtr); // Expensive to create -// for (rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { -// ... -// } -// for (rpo_iterator I = RPOT.begin(); I != RPOT.end(); ++I) { -// ... -// } -// } -// - -template > -class ReversePostOrderTraversal { - typedef typename GT::NodeType NodeType; - std::vector Blocks; // Block list in normal PO order - inline void Initialize(NodeType *BB) { - copy(po_begin(BB), po_end(BB), back_inserter(Blocks)); - } -public: - typedef typename std::vector::reverse_iterator rpo_iterator; - - inline ReversePostOrderTraversal(GraphT G) { - Initialize(GT::getEntryNode(G)); - } - - // Because we want a reverse post order, use reverse iterators from the vector - inline rpo_iterator begin() { return Blocks.rbegin(); } - inline rpo_iterator end() { return Blocks.rend(); } -}; - -} // End llvm namespace - -#endif diff --git a/include/Support/SCCIterator.h b/include/Support/SCCIterator.h deleted file mode 100644 index 2ea780ca92..0000000000 --- a/include/Support/SCCIterator.h +++ /dev/null @@ -1,199 +0,0 @@ -//===-- Support/SCCIterator.h - SCC iterator --------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This builds on the Support/GraphTraits.h file to find the strongly connected -// components (SCCs) of a graph in O(N+E) time using Tarjan's DFS algorithm. -// -// The SCC iterator has the important property that if a node in SCC S1 has an -// edge to a node in SCC S2, then it visits S1 *after* S2. -// -// To visit S1 *before* S2, use the scc_iterator on the Inverse graph. -// (NOTE: This requires some simple wrappers and is not supported yet.) -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_SCCITERATOR_H -#define SUPPORT_SCCITERATOR_H - -#include "Support/GraphTraits.h" -#include "Support/iterator" -#include -#include - -namespace llvm { - -//===----------------------------------------------------------------------===// -/// -/// scc_iterator - Enumerate the SCCs of a directed graph, in -/// reverse topological order of the SCC DAG. -/// -template > -class scc_iterator - : public forward_iterator, ptrdiff_t> { - typedef typename GT::NodeType NodeType; - typedef typename GT::ChildIteratorType ChildItTy; - typedef std::vector SccTy; - typedef forward_iterator super; - typedef typename super::reference reference; - typedef typename super::pointer pointer; - - // The visit counters used to detect when a complete SCC is on the stack. - // visitNum is the global counter. - // nodeVisitNumbers are per-node visit numbers, also used as DFS flags. - unsigned visitNum; - std::map nodeVisitNumbers; - - // SCCNodeStack - Stack holding nodes of the SCC. - std::vector SCCNodeStack; - - // CurrentSCC - The current SCC, retrieved using operator*(). - SccTy CurrentSCC; - - // VisitStack - Used to maintain the ordering. Top = current block - // First element is basic block pointer, second is the 'next child' to visit - std::vector > VisitStack; - - // MinVistNumStack - Stack holding the "min" values for each node in the DFS. - // This is used to track the minimum uplink values for all children of - // the corresponding node on the VisitStack. - std::vector MinVisitNumStack; - - // A single "visit" within the non-recursive DFS traversal. - void DFSVisitOne(NodeType* N) { - ++visitNum; // Global counter for the visit order - nodeVisitNumbers[N] = visitNum; - SCCNodeStack.push_back(N); - MinVisitNumStack.push_back(visitNum); - VisitStack.push_back(std::make_pair(N, GT::child_begin(N))); - //DEBUG(std::cerr << "TarjanSCC: Node " << N << - // " : visitNum = " << visitNum << "\n"); - } - - // The stack-based DFS traversal; defined below. - void DFSVisitChildren() { - assert(!VisitStack.empty()); - while (VisitStack.back().second != GT::child_end(VisitStack.back().first)) { - // TOS has at least one more child so continue DFS - NodeType *childN = *VisitStack.back().second++; - if (!nodeVisitNumbers.count(childN)) { - // this node has never been seen - DFSVisitOne(childN); - } else { - unsigned childNum = nodeVisitNumbers[childN]; - if (MinVisitNumStack.back() > childNum) - MinVisitNumStack.back() = childNum; - } - } - } - - // Compute the next SCC using the DFS traversal. - void GetNextSCC() { - assert(VisitStack.size() == MinVisitNumStack.size()); - CurrentSCC.clear(); // Prepare to compute the next SCC - while (!VisitStack.empty()) { - DFSVisitChildren(); - assert(VisitStack.back().second ==GT::child_end(VisitStack.back().first)); - NodeType* visitingN = VisitStack.back().first; - unsigned minVisitNum = MinVisitNumStack.back(); - VisitStack.pop_back(); - MinVisitNumStack.pop_back(); - if (!MinVisitNumStack.empty() && MinVisitNumStack.back() > minVisitNum) - MinVisitNumStack.back() = minVisitNum; - - //DEBUG(std::cerr << "TarjanSCC: Popped node " << visitingN << - // " : minVisitNum = " << minVisitNum << "; Node visit num = " << - // nodeVisitNumbers[visitingN] << "\n"); - - if (minVisitNum == nodeVisitNumbers[visitingN]) { - // A full SCC is on the SCCNodeStack! It includes all nodes below - // visitingN on the stack. Copy those nodes to CurrentSCC, - // reset their minVisit values, and return (this suspends - // the DFS traversal till the next ++). - do { - CurrentSCC.push_back(SCCNodeStack.back()); - SCCNodeStack.pop_back(); - nodeVisitNumbers[CurrentSCC.back()] = ~0UL; - } while (CurrentSCC.back() != visitingN); - return; - } - } - } - - inline scc_iterator(NodeType *entryN) : visitNum(0) { - DFSVisitOne(entryN); - GetNextSCC(); - } - inline scc_iterator() { /* End is when DFS stack is empty */ } - -public: - typedef scc_iterator _Self; - - // Provide static "constructors"... - static inline _Self begin(GraphT& G) { return _Self(GT::getEntryNode(G)); } - static inline _Self end (GraphT& G) { return _Self(); } - - // Direct loop termination test (I.fini() is more efficient than I == end()) - inline bool fini() const { - assert(!CurrentSCC.empty() || VisitStack.empty()); - return CurrentSCC.empty(); - } - - inline bool operator==(const _Self& x) const { - return VisitStack == x.VisitStack && CurrentSCC == x.CurrentSCC; - } - inline bool operator!=(const _Self& x) const { return !operator==(x); } - - // Iterator traversal: forward iteration only - inline _Self& operator++() { // Preincrement - GetNextSCC(); - return *this; - } - inline _Self operator++(int) { // Postincrement - _Self tmp = *this; ++*this; return tmp; - } - - // Retrieve a reference to the current SCC - inline const SccTy &operator*() const { - assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!"); - return CurrentSCC; - } - inline SccTy &operator*() { - assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!"); - return CurrentSCC; - } - - // hasLoop() -- Test if the current SCC has a loop. If it has more than one - // node, this is trivially true. If not, it may still contain a loop if the - // node has an edge back to itself. - bool hasLoop() const { - assert(!CurrentSCC.empty() && "Dereferencing END SCC iterator!"); - if (CurrentSCC.size() > 1) return true; - NodeType *N = CurrentSCC.front(); - for (ChildItTy CI = GT::child_begin(N), CE=GT::child_end(N); CI != CE; ++CI) - if (*CI == N) - return true; - return false; - } -}; - - -// Global constructor for the SCC iterator. -template -scc_iterator scc_begin(T G) { - return scc_iterator::begin(G); -} - -template -scc_iterator scc_end(T G) { - return scc_iterator::end(G); -} - -} // End llvm namespace - -#endif diff --git a/include/Support/STLExtras.h b/include/Support/STLExtras.h deleted file mode 100644 index b6379d2623..0000000000 --- a/include/Support/STLExtras.h +++ /dev/null @@ -1,310 +0,0 @@ -//===- STLExtras.h - Useful functions when working with the STL -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains some templates that are useful if you are working with the -// STL at all. -// -// No library is required when using these functinons. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_STLEXTRAS_H -#define SUPPORT_STLEXTRAS_H - -#include -#include // for std::pair -#include "Support/iterator" - -namespace llvm { - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// bind_obj - Often times you want to apply the member function of an object -// as a unary functor. This macro is shorthand that makes it happen less -// verbosely. -// -// Example: -// struct Summer { void accumulate(int x); } -// vector Numbers; -// Summer MyS; -// for_each(Numbers.begin(), Numbers.end(), -// bind_obj(&MyS, &Summer::accumulate)); -// -// TODO: When I get lots of extra time, convert this from an evil macro -// -#define bind_obj(OBJ, METHOD) std::bind1st(std::mem_fun(METHOD), OBJ) - - -// bitwise_or - This is a simple functor that applys operator| on its two -// arguments to get a boolean result. -// -template -struct bitwise_or : public std::binary_function { - bool operator()(const Ty& left, const Ty& right) const { - return left | right; - } -}; - -template -struct less_ptr : public std::binary_function { - bool operator()(const Ty* left, const Ty* right) const { - return *left < *right; - } -}; - -template -struct greater_ptr : public std::binary_function { - bool operator()(const Ty* left, const Ty* right) const { - return *right < *left; - } -}; - -// deleter - Very very very simple method that is used to invoke operator -// delete on something. It is used like this: -// -// for_each(V.begin(), B.end(), deleter); -// -template -static inline void deleter(T *Ptr) { - delete Ptr; -} - - - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// mapped_iterator - This is a simple iterator adapter that causes a function to -// be dereferenced whenever operator* is invoked on the iterator. -// -template -class mapped_iterator { - RootIt current; - UnaryFunc Fn; -public: - typedef typename std::iterator_traits::iterator_category - iterator_category; - typedef typename std::iterator_traits::difference_type - difference_type; - typedef typename UnaryFunc::result_type value_type; - - typedef void pointer; - //typedef typename UnaryFunc::result_type *pointer; - typedef void reference; // Can't modify value returned by fn - - typedef RootIt iterator_type; - typedef mapped_iterator _Self; - - inline RootIt &getCurrent() const { return current; } - - inline explicit mapped_iterator(const RootIt &I, UnaryFunc F) - : current(I), Fn(F) {} - inline mapped_iterator(const mapped_iterator &It) - : current(It.current), Fn(It.Fn) {} - - inline value_type operator*() const { // All this work to do this - return Fn(*current); // little change - } - - _Self& operator++() { ++current; return *this; } - _Self& operator--() { --current; return *this; } - _Self operator++(int) { _Self __tmp = *this; ++current; return __tmp; } - _Self operator--(int) { _Self __tmp = *this; --current; return __tmp; } - _Self operator+ (difference_type n) const { return _Self(current + n); } - _Self& operator+= (difference_type n) { current += n; return *this; } - _Self operator- (difference_type n) const { return _Self(current - n); } - _Self& operator-= (difference_type n) { current -= n; return *this; } - reference operator[](difference_type n) const { return *(*this + n); } - - inline bool operator!=(const _Self &X) const { return !operator==(X); } - inline bool operator==(const _Self &X) const { return current == X.current; } - inline bool operator< (const _Self &X) const { return current < X.current; } - - inline difference_type operator-(const _Self &X) const { - return current - X.current; - } -}; - -template -inline mapped_iterator<_Iterator, Func> -operator+(typename mapped_iterator<_Iterator, Func>::difference_type N, - const mapped_iterator<_Iterator, Func>& X) { - return mapped_iterator<_Iterator, Func>(X.getCurrent() - N); -} - - -// map_iterator - Provide a convenient way to create mapped_iterators, just like -// make_pair is useful for creating pairs... -// -template -inline mapped_iterator map_iterator(const ItTy &I, FuncTy F) { - return mapped_iterator(I, F); -} - - -// next/prior - These functions unlike std::advance do not modify the -// passed iterator but return a copy. -// -// next(myIt) returns copy of myIt incremented once -// next(myIt, n) returns copy of myIt incremented n times -// prior(myIt) returns copy of myIt decremented once -// prior(myIt, n) returns copy of myIt decremented n times - -template -inline ItTy next(ItTy it, Dist n) -{ - std::advance(it, n); - return it; -} - -template -inline ItTy next(ItTy it) -{ - std::advance(it, 1); - return it; -} - -template -inline ItTy prior(ItTy it, Dist n) -{ - std::advance(it, -n); - return it; -} - -template -inline ItTy prior(ItTy it) -{ - std::advance(it, -1); - return it; -} - - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// apply_until - Apply a functor to a sequence continually, unless the -// functor returns true. Return true if the functor returned true, return false -// if the functor never returned true. -// -template -bool apply_until(InputIt First, InputIt Last, Function Func) { - for ( ; First != Last; ++First) - if (Func(*First)) return true; - return false; -} - - -// reduce - Reduce a sequence values into a single value, given an initial -// value and an operator. -// -template -ValueType reduce(InputIt First, InputIt Last, Function Func, ValueType Value) { - for ( ; First != Last; ++First) - Value = Func(*First, Value); - return Value; -} - -#if 1 // This is likely to be more efficient - -// reduce_apply - Reduce the result of applying a function to each value in a -// sequence, given an initial value, an operator, a function, and a sequence. -// -template -inline ValueType reduce_apply(InputIt First, InputIt Last, Function Func, - ValueType Value, TransFunc XForm) { - for ( ; First != Last; ++First) - Value = Func(XForm(*First), Value); - return Value; -} - -#else // This is arguably more elegant - -// reduce_apply - Reduce the result of applying a function to each value in a -// sequence, given an initial value, an operator, a function, and a sequence. -// -template -inline ValueType reduce_apply2(InputIt First, InputIt Last, Function Func, - ValueType Value, TransFunc XForm) { - return reduce(map_iterator(First, XForm), map_iterator(Last, XForm), - Func, Value); -} -#endif - - -// reduce_apply_bool - Reduce the result of applying a (bool returning) function -// to each value in a sequence. All of the bools returned by the mapped -// function are bitwise or'd together, and the result is returned. -// -template -inline bool reduce_apply_bool(InputIt First, InputIt Last, Function Func) { - return reduce_apply(First, Last, bitwise_or(), false, Func); -} - - -// map - This function maps the specified input sequence into the specified -// output iterator, applying a unary function in between. -// -template -inline OutIt mapto(InIt Begin, InIt End, OutIt Dest, Functor F) { - return copy(map_iterator(Begin, F), map_iterator(End, F), Dest); -} - - -//===----------------------------------------------------------------------===// -// Extra additions to -//===----------------------------------------------------------------------===// - -// tie - this function ties two objects and returns a temporary object -// that is assignable from a std::pair. This can be used to make code -// more readable when using values returned from functions bundled in -// a std::pair. Since an example is worth 1000 words: -// -// typedef std::map Int2IntMap; -// -// Int2IntMap myMap; -// Int2IntMap::iterator where; -// bool inserted; -// tie(where, inserted) = myMap.insert(std::make_pair(123,456)); -// -// if (inserted) -// // do stuff -// else -// // do other stuff - -namespace -{ - template - struct tier { - typedef T1 &first_type; - typedef T2 &second_type; - - first_type first; - second_type second; - - tier(first_type f, second_type s) : first(f), second(s) { } - tier& operator=(const std::pair& p) { - first = p.first; - second = p.second; - return *this; - } - }; -} - -template -inline tier tie(T1& f, T2& s) { - return tier(f, s); -} - -} // End llvm namespace - -#endif diff --git a/include/Support/SetOperations.h b/include/Support/SetOperations.h deleted file mode 100644 index bb1e68e6b2..0000000000 --- a/include/Support/SetOperations.h +++ /dev/null @@ -1,71 +0,0 @@ -//===-- Support/SetOperations.h - Generic Set Operations --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines generic set operations that may be used on set's of -// different types, and different element types. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_SETOPERATIONS_H -#define SUPPORT_SETOPERATIONS_H - -namespace llvm { - -// set_union(A, B) - Compute A := A u B, return whether A changed. -// -template -bool set_union(S1Ty &S1, const S2Ty &S2) { - bool Changed = false; - - for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end(); - SI != SE; ++SI) - if (S1.insert(*SI).second) - Changed = true; - - return Changed; -} - -// set_intersect(A, B) - Compute A := A ^ B -// Identical to set_intersection, except that it works on set<>'s and -// is nicer to use. Functionally, this iterates through S1, removing -// elements that are not contained in S2. -// -template class S1Ty, class ETy, class S2Ty> -void set_intersect(S1Ty &S1, const S2Ty &S2) { - for (typename S1Ty::iterator I = S1.begin(); I != S1.end();) { - const ETy &E = *I; - ++I; - if (!S2.count(E)) S1.erase(E); // Erase element if not in S2 - } -} - -// set_difference(A, B) - Return A - B -// -template -S1Ty set_difference(const S1Ty &S1, const S2Ty &S2) { - S1Ty Result; - for (typename S1Ty::const_iterator SI = S1.begin(), SE = S1.end(); - SI != SE; ++SI) - if (!S2.count(*SI)) // if the element is not in set2 - Result.insert(*SI); - return Result; -} - -// set_subtract(A, B) - Compute A := A - B -// -template -void set_subtract(S1Ty &S1, const S2Ty &S2) { - for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end(); - SI != SE; ++SI) - S1.erase(*SI); -} - -} // End llvm namespace - -#endif diff --git a/include/Support/SetVector.h b/include/Support/SetVector.h deleted file mode 100644 index c72f49bce8..0000000000 --- a/include/Support/SetVector.h +++ /dev/null @@ -1,138 +0,0 @@ -//===- SetVector.h - A set with insertion order iteration -------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by Reid Spencer and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file implements a set that has insertion order iteration -// characteristics. This is useful for keeping a set of things that need to be -// visited later but in a deterministic order (insertion order). The interface -// is purposefully minimal. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_SETVECTOR_H -#define SUPPORT_SETVECTOR_H - -#include -#include -#include - -namespace llvm { - -/// This class provides a way to keep a set of things that also has the -/// property of a deterministic iteration order. The order of iteration is the -/// order of insertion. -/// @brief A vector that has set insertion semantics. -template -class SetVector { -public: - typedef T value_type; - typedef T key_type; - typedef T& reference; - typedef const T& const_reference; - typedef std::set set_type; - typedef std::vector vector_type; - typedef typename vector_type::iterator iterator; - typedef typename vector_type::const_iterator const_iterator; - typedef typename vector_type::size_type size_type; - - /// @brief Construct an empty SetVector - SetVector() {} - - /// @brief Initialize a SetVector with a range of elements - template - SetVector(It Start, It End) { - insert(Start, End); - } - - /// @brief Determine if the SetVector is empty or not. - bool empty() const { - return vector_.empty(); - } - - /// @brief Determine the number of elements in the SetVector. - size_type size() const { - return vector_.size(); - } - - /// @brief Get an iterator to the beginning of the SetVector. - iterator begin() { - return vector_.begin(); - } - - /// @brief Get a const_iterator to the beginning of the SetVector. - const_iterator begin() const { - return vector_.begin(); - } - - /// @brief Get an iterator to the end of the SetVector. - iterator end() { - return vector_.end(); - } - - /// @brief Get a const_iterator to the end of the SetVector. - const_iterator end() const { - return vector_.end(); - } - - /// @brief Return the last element of the SetVector. - const T &back() const { - assert(!empty() && "Cannot call back() on empty SetVector!"); - return vector_.back(); - } - - /// @brief Index into the SetVector. - const_reference operator[](size_type n) const { - assert(n < vector_.size() && "SetVector access out of range!"); - return vector_[n]; - } - - /// @returns true iff the element was inserted into the SetVector. - /// @brief Insert a new element into the SetVector. - bool insert(const value_type &X) { - bool result = set_.insert(X).second; - if (result) - vector_.push_back(X); - return result; - } - - /// @brief Insert a range of elements into the SetVector. - template - void insert(It Start, It End) { - for (; Start != End; ++Start) - if (set_.insert(*Start).second) - vector_.push_back(*Start); - } - - /// @returns 0 if the element is not in the SetVector, 1 if it is. - /// @brief Count the number of elements of a given key in the SetVector. - size_type count(const key_type &key) const { - return set_.count(key); - } - - /// @brief Completely clear the SetVector - void clear() { - set_.clear(); - vector_.clear(); - } - - /// @brief Remove the last element of the SetVector. - void pop_back() { - assert(!empty() && "Cannot remove an element from an empty SetVector!"); - set_.erase(back()); - vector_.pop_back(); - } - -private: - set_type set_; ///< The set. - vector_type vector_; ///< The vector. -}; - -} // End llvm namespace - -// vim: sw=2 ai -#endif diff --git a/include/Support/SlowOperationInformer.h b/include/Support/SlowOperationInformer.h deleted file mode 100644 index 67edf7df42..0000000000 --- a/include/Support/SlowOperationInformer.h +++ /dev/null @@ -1,65 +0,0 @@ -//===- SlowOperationInformer.h - Keep the user informed ---------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a simple object which can be used to let the user know what -// is going on when a slow operation is happening, and gives them the ability to -// cancel it. Potentially slow operations can stack allocate one of these -// objects, and periodically call the "progress" method to update the progress -// bar. If the operation takes more than 1 second to complete, the progress bar -// is automatically shown and updated. As such, the slow operation should not -// print stuff to the screen, and should not be confused if an extra line -// appears on the screen (ie, the cursor should be at the start of the line). -// -// If the user presses CTRL-C during the operation, the next invocation of the -// progress method with throw an std::string object indicating that the -// operation was cancelled. As such, client code must be exception safe around -// the progress method. -// -// Because SlowOperationInformers fiddle around with signals, they cannot be -// nested, and interact poorly with threads. The SIGALRM handler is set back to -// SIGDFL, but the SIGINT signal handler is restored when the -// SlowOperationInformer is destroyed. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_SLOW_OPERATION_INFORMER_H -#define SUPPORT_SLOW_OPERATION_INFORMER_H - -#include -#include - -namespace llvm { - class SlowOperationInformer { - std::string OperationName; - unsigned LastPrintAmount; - - SlowOperationInformer(const SlowOperationInformer&); // DO NOT IMPLEMENT - void operator=(const SlowOperationInformer&); // DO NOT IMPLEMENT - public: - SlowOperationInformer(const std::string &Name); - ~SlowOperationInformer(); - - /// progress - Clients should periodically call this method when they are in - /// an exception-safe state. The Amount variable should indicate how far - /// along the operation is, given in 1/10ths of a percent (in other words, - /// Amount should range from 0 to 1000). - void progress(unsigned Amount); - - /// progress - Same as the method above, but this performs the division for - /// you, and helps you avoid overflow if you are dealing with largish - /// numbers. - void progress(unsigned Current, unsigned Maximum) { - assert(Maximum != 0 && - "Shouldn't be doing work if there is nothing to do!"); - progress(Current*1000ULL/Maximum); - } - }; -} // end namespace llvm - -#endif /* SLOW_OPERATION_INFORMER_H */ diff --git a/include/Support/Statistic.h b/include/Support/Statistic.h deleted file mode 100644 index 79d8f9d66e..0000000000 --- a/include/Support/Statistic.h +++ /dev/null @@ -1,89 +0,0 @@ -//===-- Support/Statistic.h - Easy way to expose stats ----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the 'Statistic' class, which is designed to be an easy way -// to expose various success metrics from passes. These statistics are printed -// at the end of a run, when the -stats command line option is enabled on the -// command line. -// -// This is useful for reporting information like the number of instructions -// simplified, optimized or removed by various transformations, like this: -// -// static Statistic<> NumInstsKilled("gcse", "Number of instructions killed"); -// -// Later, in the code: ++NumInstsKilled; -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_STATISTIC_H -#define SUPPORT_STATISTIC_H - -#include - -namespace llvm { - -// StatisticBase - Nontemplated base class for Statistic<> class... -class StatisticBase { - const char *Name; - const char *Desc; - static unsigned NumStats; -protected: - StatisticBase(const char *name, const char *desc) : Name(name), Desc(desc) { - ++NumStats; // Keep track of how many stats are created... - } - virtual ~StatisticBase() {} - - // destroy - Called by subclass dtor so that we can still invoke virtual - // functions on the subclass. - void destroy() const; - - // printValue - Overridden by template class to print out the value type... - virtual void printValue(std::ostream &o) const = 0; - - // hasSomeData - Return true if some data has been aquired. Avoid printing - // lots of zero counts. - // - virtual bool hasSomeData() const = 0; -}; - -// Statistic Class - templated on the data type we are monitoring... -template -class Statistic : private StatisticBase { - DataType Value; - - virtual void printValue(std::ostream &o) const { o << Value; } - virtual bool hasSomeData() const { return Value != DataType(); } -public: - // Normal constructor, default initialize data item... - Statistic(const char *name, const char *desc) - : StatisticBase(name, desc), Value(DataType()) {} - - // Constructor to provide an initial value... - Statistic(const DataType &Val, const char *name, const char *desc) - : StatisticBase(name, desc), Value(Val) {} - - // Print information when destroyed, iff command line option is specified - ~Statistic() { destroy(); } - - // Allow use of this class as the value itself... - operator DataType() const { return Value; } - const Statistic &operator=(DataType Val) { Value = Val; return *this; } - const Statistic &operator++() { ++Value; return *this; } - DataType operator++(int) { return Value++; } - const Statistic &operator--() { --Value; return *this; } - DataType operator--(int) { return Value--; } - const Statistic &operator+=(const DataType &V) { Value += V; return *this; } - const Statistic &operator-=(const DataType &V) { Value -= V; return *this; } - const Statistic &operator*=(const DataType &V) { Value *= V; return *this; } - const Statistic &operator/=(const DataType &V) { Value /= V; return *this; } -}; - -} // End llvm namespace - -#endif diff --git a/include/Support/StringExtras.h b/include/Support/StringExtras.h deleted file mode 100644 index fcfa65f232..0000000000 --- a/include/Support/StringExtras.h +++ /dev/null @@ -1,125 +0,0 @@ -//===-- Support/StringExtras.h - Useful string functions --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains some functions that are useful when dealing with strings. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_STRINGEXTRAS_H -#define SUPPORT_STRINGEXTRAS_H - -#include "Support/DataTypes.h" -#include -#include -#include - -namespace llvm { - -static inline std::string utohexstr(uint64_t X) { - char Buffer[40]; - char *BufPtr = Buffer+39; - - *BufPtr = 0; // Null terminate buffer... - if (X == 0) *--BufPtr = '0'; // Handle special case... - - while (X) { - unsigned char Mod = (unsigned char)X & 15; - if (Mod < 10) - *--BufPtr = '0' + Mod; - else - *--BufPtr = 'A' + Mod-10; - X >>= 4; - } - return std::string(BufPtr); -} - -static inline std::string utostr(unsigned long long X, bool isNeg = false) { - char Buffer[40]; - char *BufPtr = Buffer+39; - - *BufPtr = 0; // Null terminate buffer... - if (X == 0) *--BufPtr = '0'; // Handle special case... - - while (X) { - *--BufPtr = '0' + char(X % 10); - X /= 10; - } - - if (isNeg) *--BufPtr = '-'; // Add negative sign... - return std::string(BufPtr); -} - -static inline std::string utostr(unsigned long X, bool isNeg = false) { - return utostr(static_cast(X), isNeg); -} - -static inline std::string utostr(unsigned X, bool isNeg = false) { - char Buffer[20]; - char *BufPtr = Buffer+19; - - *BufPtr = 0; // Null terminate buffer... - if (X == 0) *--BufPtr = '0'; // Handle special case... - - while (X) { - *--BufPtr = '0' + char(X % 10); - X /= 10; - } - - if (isNeg) *--BufPtr = '-'; // Add negative sign... - - return std::string(BufPtr); -} - -static inline std::string itostr(long long X) { - if (X < 0) - return utostr(static_cast(-X), true); - else - return utostr(static_cast(X)); -} - -static inline std::string itostr(long X) { - if (X < 0) - return utostr(static_cast(-X), true); - else - return utostr(static_cast(X)); -} - -static inline std::string itostr(int X) { - if (X < 0) - return utostr(static_cast(-X), true); - else - return utostr(static_cast(X)); -} - -static inline std::string ftostr(double V) { - char Buffer[200]; - sprintf(Buffer, "%20.6e", V); - return Buffer; -} - -static inline std::string LowercaseString(const std::string &S) { - std::string result(S); - for (unsigned i = 0; i < S.length(); ++i) - if (isupper(result[i])) - result[i] = (char)tolower(result[i]); - return result; -} - -/// getToken - This function extracts one token from source, ignoring any -/// leading characters that appear in the Delimiters string, and ending the -/// token at any of the characters that appear in the Delimiters string. If -/// there are no tokens in the source string, an empty string is returned. -/// The Source source string is updated in place to remove the returned string -/// and any delimiter prefix from it. -std::string getToken(std::string &Source, - const char *Delimiters = " \t\n\v\f\r"); - -} // End llvm namespace - -#endif diff --git a/include/Support/SystemUtils.h b/include/Support/SystemUtils.h deleted file mode 100644 index b8c130cc97..0000000000 --- a/include/Support/SystemUtils.h +++ /dev/null @@ -1,65 +0,0 @@ -//===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains functions used to do a variety of low-level, often -// system-specific, tasks. -// -//===----------------------------------------------------------------------===// - -#ifndef SYSTEMUTILS_H -#define SYSTEMUTILS_H - -#include - -namespace llvm { - -/// isExecutableFile - This function returns true if the filename specified -/// exists and is executable. -/// -bool isExecutableFile(const std::string &ExeFileName); - -/// isStandardOutAConsole - Return true if we can tell that the standard output -/// stream goes to a terminal window or console. -bool isStandardOutAConsole(); - -/// FindExecutable - Find a named executable, giving the argv[0] of program -/// being executed. This allows us to find another LLVM tool if it is built into -/// the same directory, but that directory is neither the current directory, nor -/// in the PATH. If the executable cannot be found, return an empty string. -/// -std::string FindExecutable(const std::string &ExeName, - const std::string &ProgramPath); - -/// RunProgramWithTimeout - This function executes the specified program, with -/// the specified null-terminated argument array, with the stdin/out/err fd's -/// redirected, with a timeout specified by the last argument. This terminates -/// the calling program if there is an error executing the specified program. -/// It returns the return value of the program, or -1 if a timeout is detected. -/// -int RunProgramWithTimeout(const std::string &ProgramPath, const char **Args, - const std::string &StdInFile = "", - const std::string &StdOutFile = "", - const std::string &StdErrFile = "", - unsigned NumSeconds = 0); - -/// ExecWait - Execute a program with the given arguments and environment and -/// wait for it to terminate. -/// -int ExecWait (const char * const argv[], const char * const envp[]); - -/// AllocateRWXMemory - Allocate a slab of memory with read/write/execute -/// permissions. This is typically used for JIT applications where we want -/// to emit code to the memory then jump to it. Getting this type of memory -/// is very OS specific. -/// -void *AllocateRWXMemory(unsigned NumBytes); - -} // End llvm namespace - -#endif diff --git a/include/Support/ThreadSupport-NoSupport.h b/include/Support/ThreadSupport-NoSupport.h deleted file mode 100644 index 5dc954efab..0000000000 --- a/include/Support/ThreadSupport-NoSupport.h +++ /dev/null @@ -1,34 +0,0 @@ -//===-- Support/ThreadSupport-NoSupport.h - Generic impl --------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines a generic ThreadSupport implementation used when there is -// no supported threading mechanism on the current system. Users should never -// #include this file directly! -// -//===----------------------------------------------------------------------===// - -// Users should never #include this file directly! As such, no include guards -// are needed. - -#ifndef SUPPORT_THREADSUPPORT_H -#error "Code should not #include Support/ThreadSupport-NoSupport.h directly!" -#endif - -namespace llvm { - /// Mutex - This class allows user code to protect variables shared between - /// threads. It implements a "recursive" mutex, to simplify user code. - /// - /// Since there is no platform support for _creating threads_, the non-thread - /// implementation of this class is a noop. - /// - struct Mutex { - void acquire () {} - void release () {} - }; -} diff --git a/include/Support/ThreadSupport-PThreads.h b/include/Support/ThreadSupport-PThreads.h deleted file mode 100644 index 6bbe682c08..0000000000 --- a/include/Support/ThreadSupport-PThreads.h +++ /dev/null @@ -1,42 +0,0 @@ -//===-- Support/ThreadSupport-PThreads.h - PThreads support -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines pthreads implementations of the generic threading -// mechanisms. Users should never #include this file directly! -// -//===----------------------------------------------------------------------===// - -// Users should never #include this file directly! As such, no include guards -// are needed. - -#ifndef SUPPORT_THREADSUPPORT_H -#error "Code should not #include Support/ThreadSupport/PThreads.h directly!" -#endif - -#include - -namespace llvm { - - /// Mutex - This class allows user code to protect variables shared between - /// threads. It implements a "recursive" mutex, to simplify user code. - /// - class Mutex { - pthread_mutex_t mutex; - Mutex(const Mutex &); // DO NOT IMPLEMENT - void operator=(const Mutex &); // DO NOT IMPLEMENT - public: - Mutex() { - pthread_mutexattr_t Attr; - pthread_mutex_init(&mutex, &Attr); - } - ~Mutex() { pthread_mutex_destroy(&mutex); } - void acquire () { pthread_mutex_lock (&mutex); } - void release () { pthread_mutex_unlock (&mutex); } - }; -} // end namespace llvm diff --git a/include/Support/ThreadSupport.h.in b/include/Support/ThreadSupport.h.in deleted file mode 100644 index 470010219f..0000000000 --- a/include/Support/ThreadSupport.h.in +++ /dev/null @@ -1,40 +0,0 @@ -//===-- Support/ThreadSupport.h - Generic threading support -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines platform-agnostic interfaces that can be used to write -// multi-threaded programs. Autoconf is used to chose the correct -// implementation of these interfaces, or default to a non-thread-capable system -// if no matching system support is available. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_THREADSUPPORT_H -#define SUPPORT_THREADSUPPORT_H - -#if @HAVE_PTHREAD_MUTEX_LOCK@ -#include "Support/ThreadSupport-PThreads.h" -#else -#include "Support/ThreadSupport-NoSupport.h" -#endif // If no system support is available - -namespace llvm { - /// MutexLocker - Instances of this class acquire a given Lock when - /// constructed and hold that lock until destruction. - /// - class MutexLocker { - Mutex &M; - MutexLocker(const MutexLocker &); // DO NOT IMPLEMENT - void operator=(const MutexLocker &); // DO NOT IMPLEMENT - public: - MutexLocker(Mutex &m) : M(m) { M.acquire(); } - ~MutexLocker() { M.release(); } - }; -} - -#endif // SUPPORT_THREADSUPPORT_H diff --git a/include/Support/Timer.h b/include/Support/Timer.h deleted file mode 100644 index ac465bb95b..0000000000 --- a/include/Support/Timer.h +++ /dev/null @@ -1,164 +0,0 @@ -//===-- Support/Timer.h - Interval Timing Support ---------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines three classes: Timer, TimeRegion, and TimerGroup, -// documented below. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_TIMER_H -#define SUPPORT_TIMER_H - -#include -#include -#include -#include - -namespace llvm { - -class TimerGroup; - -/// Timer - This class is used to track the amount of time spent between -/// invocations of it's startTimer()/stopTimer() methods. Given appropriate OS -/// support it can also keep track of the RSS of the program at various points. -/// By default, the Timer will print the amount of time it has captured to -/// standard error when the laster timer is destroyed, otherwise it is printed -/// when it's TimerGroup is destroyed. Timer's do not print their information -/// if they are never started. -/// -class Timer { - double Elapsed; // Wall clock time elapsed in seconds - double UserTime; // User time elapsed - double SystemTime; // System time elapsed - long MemUsed; // Memory allocated (in bytes) - long PeakMem; // Peak memory used - long PeakMemBase; // Temporary for peak calculation... - std::string Name; // The name of this time variable - bool Started; // Has this time variable ever been started? - TimerGroup *TG; // The TimerGroup this Timer is in. -public: - Timer(const std::string &N); - Timer(const std::string &N, TimerGroup &tg); - Timer(const Timer &T); - ~Timer(); - - double getProcessTime() const { return UserTime+SystemTime; } - double getWallTime() const { return Elapsed; } - long getMemUsed() const { return MemUsed; } - long getPeakMem() const { return PeakMem; } - std::string getName() const { return Name; } - - const Timer &operator=(const Timer &T) { - Elapsed = T.Elapsed; - UserTime = T.UserTime; - SystemTime = T.SystemTime; - MemUsed = T.MemUsed; - PeakMem = T.PeakMem; - PeakMemBase = T.PeakMemBase; - Name = T.Name; - Started = T.Started; - assert(TG == T.TG && "Can only assign timers in the same TimerGroup!"); - return *this; - } - - // operator< - Allow sorting... - bool operator<(const Timer &T) const { - // Sort by Wall Time elapsed, as it is the only thing really accurate - return Elapsed < T.Elapsed; - } - bool operator>(const Timer &T) const { return T.operator<(*this); } - - /// startTimer - Start the timer running. Time between calls to - /// startTimer/stopTimer is counted by the Timer class. Note that these calls - /// must be correctly paired. - /// - void startTimer(); - - /// stopTimer - Stop the timer. - /// - void stopTimer(); - - /// addPeakMemoryMeasurement - This method should be called whenever memory - /// usage needs to be checked. It adds a peak memory measurement to the - /// currently active timers, which will be printed when the timer group prints - /// - static void addPeakMemoryMeasurement(); - - /// print - Print the current timer to standard error, and reset the "Started" - /// flag. - void print(const Timer &Total, std::ostream &OS); - -private: - friend class TimerGroup; - - // Copy ctor, initialize with no TG member. - Timer(bool, const Timer &T); - - /// sum - Add the time accumulated in the specified timer into this timer. - /// - void sum(const Timer &T); -}; - - -/// The TimeRegion class is used as a helper class to call the startTimer() and -/// stopTimer() methods of the Timer class. When the object is constructed, it -/// starts the timer specified as it's argument. When it is destroyed, it stops -/// the relevant timer. This makes it easy to time a region of code. -/// -class TimeRegion { - Timer &T; - TimeRegion(const TimeRegion &); // DO NOT IMPLEMENT -public: - TimeRegion(Timer &t) : T(t) { - T.startTimer(); - } - ~TimeRegion() { - T.stopTimer(); - } -}; - - -/// NamedRegionTimer - This class is basically a combination of TimeRegion and -/// Timer. It allows you to declare a new timer, AND specify the region to -/// time, all in one statement. All timers with the same name are merged. This -/// is primarily used for debugging and for hunting performance problems. -/// -struct NamedRegionTimer : public TimeRegion { - NamedRegionTimer(const std::string &Name); -}; - - -/// The TimerGroup class is used to group together related timers into a single -/// report that is printed when the TimerGroup is destroyed. It is illegal to -/// destroy a TimerGroup object before all of the Timers in it are gone. A -/// TimerGroup can be specified for a newly created timer in its constructor. -/// -class TimerGroup { - std::string Name; - unsigned NumTimers; - std::vector TimersToPrint; -public: - TimerGroup(const std::string &name) : Name(name), NumTimers(0) {} - ~TimerGroup() { - assert(NumTimers == 0 && - "TimerGroup destroyed before all contained timers!"); - } - -private: - friend class Timer; - void addTimer() { ++NumTimers; } - void removeTimer(); - void addTimerToPrint(const Timer &T) { - TimersToPrint.push_back(Timer(true, T)); - } -}; - -} // End llvm namespace - -#endif diff --git a/include/Support/Tree.h b/include/Support/Tree.h deleted file mode 100644 index 48ecf5b06d..0000000000 --- a/include/Support/Tree.h +++ /dev/null @@ -1,62 +0,0 @@ -//===- Support/Tree.h - Generic n-way tree structure ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class defines a generic N way tree node structure. The tree structure -// is immutable after creation, but the payload contained within it is not. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_TREE_H -#define SUPPORT_TREE_H - -#include - -namespace llvm { - -template -class Tree { - std::vector Children; // This nodes children, if any - ConcreteTreeNode *Parent; // Parent of this node... - Payload Data; // Data held in this node... - -protected: - void setChildren(const std::vector &children) { - Children = children; - } -public: - inline Tree(ConcreteTreeNode *parent) : Parent(parent) {} - inline Tree(const std::vector &children, - ConcreteTreeNode *par) : Children(children), Parent(par) {} - - inline Tree(const std::vector &children, - ConcreteTreeNode *par, const Payload &data) - : Children(children), Parent(par), Data(data) {} - - // Tree dtor - Free all children - inline ~Tree() { - for (unsigned i = Children.size(); i > 0; --i) - delete Children[i-1]; - } - - // Tree manipulation/walking routines... - inline ConcreteTreeNode *getParent() const { return Parent; } - inline unsigned getNumChildren() const { return Children.size(); } - inline ConcreteTreeNode *getChild(unsigned i) const { - assert(i < Children.size() && "Tree::getChild with index out of range!"); - return Children[i]; - } - - // Payload access... - inline Payload &getTreeData() { return Data; } - inline const Payload &getTreeData() const { return Data; } -}; - -} // End llvm namespace - -#endif diff --git a/include/Support/TypeInfo.h b/include/Support/TypeInfo.h deleted file mode 100644 index e23f906afa..0000000000 --- a/include/Support/TypeInfo.h +++ /dev/null @@ -1,76 +0,0 @@ -//===- Support/TypeInfo.h - Support class for type_info objects -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This class makes std::type_info objects behave like first class objects that -// can be put in maps and hashtables. This code is based off of code in the -// Loki C++ library from the Modern C++ Design book. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_TYPEINFO_H -#define SUPPORT_TYPEINFO_H - -#include - -namespace llvm { - -struct TypeInfo { - TypeInfo() { // needed for containers - struct Nil {}; // Anonymous class distinct from all others... - Info = &typeid(Nil); - } - - TypeInfo(const std::type_info &ti) : Info(&ti) { // non-explicit - } - - // Access for the wrapped std::type_info - const std::type_info &get() const { - return *Info; - } - - // Compatibility functions - bool before(const TypeInfo &rhs) const { - return Info->before(*rhs.Info) != 0; - } - const char *getClassName() const { - return Info->name(); - } - -private: - const std::type_info *Info; -}; - -// Comparison operators -inline bool operator==(const TypeInfo &lhs, const TypeInfo &rhs) { - return lhs.get() == rhs.get(); -} - -inline bool operator<(const TypeInfo &lhs, const TypeInfo &rhs) { - return lhs.before(rhs); -} - -inline bool operator!=(const TypeInfo &lhs, const TypeInfo &rhs) { - return !(lhs == rhs); -} - -inline bool operator>(const TypeInfo &lhs, const TypeInfo &rhs) { - return rhs < lhs; -} - -inline bool operator<=(const TypeInfo &lhs, const TypeInfo &rhs) { - return !(lhs > rhs); -} - -inline bool operator>=(const TypeInfo &lhs, const TypeInfo &rhs) { - return !(lhs < rhs); -} - -} // End llvm namespace - -#endif diff --git a/include/Support/VectorExtras.h b/include/Support/VectorExtras.h deleted file mode 100644 index cf7cf5d2eb..0000000000 --- a/include/Support/VectorExtras.h +++ /dev/null @@ -1,40 +0,0 @@ -//===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains helper functions which are useful for working with the -// std::vector class. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_VECTOREXTRAS_H -#define SUPPORT_VECTOREXTRAS_H - -#include - -namespace llvm { - -/// make_vector - Helper function which is useful for building temporary vectors -/// to pass into type construction of CallInst ctors. This turns a null -/// terminated list of pointers (or other value types) into a real live vector. -/// -template -inline std::vector make_vector(T A, ...) { - va_list Args; - va_start(Args, A); - std::vector Result; - Result.push_back(A); - while (T Val = va_arg(Args, T)) - Result.push_back(Val); - va_end(Args); - return Result; -} - -} // End llvm namespace - -#endif diff --git a/include/Support/hash_map.in b/include/Support/hash_map.in deleted file mode 100644 index 0253de788f..0000000000 --- a/include/Support/hash_map.in +++ /dev/null @@ -1,66 +0,0 @@ -//===-- Support/hash_map - "Portable" wrapper around hash_map ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides a wrapper around the mysterious header file -// that seems to move around between GCC releases into and out of namespaces at -// will. #including this header will cause hash_map to be available in the -// global namespace. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_HASH_MAP -#define SUPPORT_HASH_MAP - -// Compiler Support Matrix -// -// Version Namespace Header File -// 2.95.x :: hash_map -// 3.0.4 std ext/hash_map -// 3.1 __gnu_cxx ext/hash_map -// - -#if @HAVE_GNU_EXT_HASH_MAP@ -// This is for GCC-3.1+ which puts hash in ext/hash_map -# include -# ifndef HASH_NAMESPACE -# define HASH_NAMESPACE __gnu_cxx -# endif - -// GCC 3.0.x puts hash_map in and in the std namespace. -#elif @HAVE_STD_EXT_HASH_MAP@ -# include -# ifndef HASH_NAMESPACE -# define HASH_NAMESPACE std -# endif - -// Older compilers such as GCC before version 3.0 do not keep -// extensions in the `ext' directory, and ignore the `std' namespace. -#elif @HAVE_GLOBAL_HASH_MAP@ -# include -# ifndef HASH_NAMESPACE -# define HASH_NAMESPACE std -# endif - -// Give a warning if we couldn't find it, instead of (or in addition to) -// randomly doing something dumb. -#else -# warning "Autoconfiguration failed to find the hash_map header file." -#endif - -using HASH_NAMESPACE::hash_map; -using HASH_NAMESPACE::hash_multimap; -using HASH_NAMESPACE::hash; - -// Include vector because ext/hash_map includes stl_vector.h and leaves -// out specializations like stl_bvector.h, causing link conflicts. -#include - -#include - -#endif diff --git a/include/Support/hash_set.in b/include/Support/hash_set.in deleted file mode 100644 index 49c5d732e8..0000000000 --- a/include/Support/hash_set.in +++ /dev/null @@ -1,67 +0,0 @@ -//===-- Support/hash_set - "Portable" wrapper around hash_set ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// vim:ft=cpp -// -// This file provides a wrapper around the mysterious header file -// that seems to move around between GCC releases into and out of namespaces at -// will. #including this header will cause hash_set to be available in the -// global namespace. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_HASH_SET -#define SUPPORT_HASH_SET - -// Compiler Support Matrix -// -// Version Namespace Header File -// 2.95.x :: hash_set -// 3.0.4 std ext/hash_set -// 3.1 __gnu_cxx ext/hash_set -// - -// GCC versions 3.1 and later put hash_set in and in -// the __gnu_cxx namespace. -#if @HAVE_GNU_EXT_HASH_SET@ -# include -# ifndef HASH_NAMESPACE -# define HASH_NAMESPACE __gnu_cxx -# endif - -// GCC 3.0.x puts hash_set in and in the std namespace. -#elif @HAVE_STD_EXT_HASH_SET@ -# include -# ifndef HASH_NAMESPACE -# define HASH_NAMESPACE std -# endif - -// Older compilers such as GCC before version 3.0 do not keep -// extensions in the `ext' directory, and ignore the `std' namespace. -#elif @HAVE_GLOBAL_HASH_SET@ -# include -# ifndef HASH_NAMESPACE -# define HASH_NAMESPACE std -# endif - -// Give a warning if we couldn't find it, instead of (or in addition to) -// randomly doing something dumb. -#else -# warning "Autoconfiguration failed to find the hash_set header file." -#endif - -using HASH_NAMESPACE::hash_set; -using HASH_NAMESPACE::hash; - -// Include vector because ext/hash_set includes stl_vector.h and leaves -// out specializations like stl_bvector.h, causing link conflicts. -#include - -#include - -#endif diff --git a/include/Support/ilist b/include/Support/ilist deleted file mode 100644 index 9d9fdf0fdb..0000000000 --- a/include/Support/ilist +++ /dev/null @@ -1,638 +0,0 @@ -//===-- Support/ilist - Intrusive Linked List Template ----------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines classes to implement an intrusive doubly linked list class -// (ie each node of the list must contain a next and previous field for the -// list. -// -// The ilist_traits trait class is used to gain access to the next and previous -// fields of the node type that the list is instantiated with. If it is not -// specialized, the list defaults to using the getPrev(), getNext() method calls -// to get the next and previous pointers. -// -// The ilist class itself, should be a plug in replacement for list, assuming -// that the nodes contain next/prev pointers. This list replacement does not -// provides a constant time size() method, so be careful to use empty() when you -// really want to know if it's empty. -// -// The ilist class is implemented by allocating a 'tail' node when the list is -// created (using ilist_traits<>::createEndMarker()). This tail node is -// absolutely required because the user must be able to compute end()-1. Because -// of this, users of the direct next/prev links will see an extra link on the -// end of the list, which should be ignored. -// -// Requirements for a user of this list: -// -// 1. The user must provide {g|s}et{Next|Prev} methods, or specialize -// ilist_traits to provide an alternate way of getting and setting next and -// prev links. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_ILIST -#define SUPPORT_ILIST - -#include -#include - -namespace llvm { - -template class iplist; -template class ilist_iterator; - -// Template traits for intrusive list. By specializing this template class, you -// can change what next/prev fields are used to store the links... -template -struct ilist_traits { - static NodeTy *getPrev(NodeTy *N) { return N->getPrev(); } - static NodeTy *getNext(NodeTy *N) { return N->getNext(); } - static const NodeTy *getPrev(const NodeTy *N) { return N->getPrev(); } - static const NodeTy *getNext(const NodeTy *N) { return N->getNext(); } - - static void setPrev(NodeTy *N, NodeTy *Prev) { N->setPrev(Prev); } - static void setNext(NodeTy *N, NodeTy *Next) { N->setNext(Next); } - - static NodeTy *createNode() { return new NodeTy(); } - static NodeTy *createNode(const NodeTy &V) { return new NodeTy(V); } - - - void addNodeToList(NodeTy *NTy) {} - void removeNodeFromList(NodeTy *NTy) {} - void transferNodesFromList(iplist &L2, - ilist_iterator first, - ilist_iterator last) {} -}; - -// Const traits are the same as nonconst traits... -template -struct ilist_traits : public ilist_traits {}; - - -//===----------------------------------------------------------------------===// -// ilist_iterator - Iterator for intrusive list. -// -template -class ilist_iterator - : public bidirectional_iterator { - typedef ilist_traits Traits; - typedef bidirectional_iterator super; - -public: - typedef size_t size_type; - typedef typename super::pointer pointer; - typedef typename super::reference reference; -private: - pointer NodePtr; -public: - - ilist_iterator(pointer NP) : NodePtr(NP) {} - ilist_iterator(reference NR) : NodePtr(&NR) {} - ilist_iterator() : NodePtr(0) {} - - // This is templated so that we can allow constructing a const iterator from - // a nonconst iterator... - template - ilist_iterator(const ilist_iterator &RHS) - : NodePtr(RHS.getNodePtrUnchecked()) {} - - // This is templated so that we can allow assigning to a const iterator from - // a nonconst iterator... - template - const ilist_iterator &operator=(const ilist_iterator &RHS) { - NodePtr = RHS.getNodePtrUnchecked(); - return *this; - } - - // Accessors... - operator pointer() const { - assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!"); - return NodePtr; - } - - reference operator*() const { - assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!"); - return *NodePtr; - } - pointer operator->() { return &operator*(); } - const pointer operator->() const { return &operator*(); } - - // Comparison operators - bool operator==(const ilist_iterator &RHS) const { - return NodePtr == RHS.NodePtr; - } - bool operator!=(const ilist_iterator &RHS) const { - return NodePtr != RHS.NodePtr; - } - - // Increment and decrement operators... - ilist_iterator &operator--() { // predecrement - Back up - NodePtr = Traits::getPrev(NodePtr); - assert(NodePtr && "--'d off the beginning of an ilist!"); - return *this; - } - ilist_iterator &operator++() { // preincrement - Advance - NodePtr = Traits::getNext(NodePtr); - assert(NodePtr && "++'d off the end of an ilist!"); - return *this; - } - ilist_iterator operator--(int) { // postdecrement operators... - ilist_iterator tmp = *this; - --*this; - return tmp; - } - ilist_iterator operator++(int) { // postincrement operators... - ilist_iterator tmp = *this; - ++*this; - return tmp; - } - - // Internal interface, do not use... - pointer getNodePtrUnchecked() const { return NodePtr; } -}; - -// do not implement. this is to catch errors when people try to use -// them as random access iterators -template -void operator-(int, ilist_iterator); -template -void operator-(ilist_iterator,int); - -template -void operator+(int, ilist_iterator); -template -void operator+(ilist_iterator,int); - -//===----------------------------------------------------------------------===// -// ilist_compat_iterator - Compatibility iterator for intrusive list. -// This makes an ilist act like an std::list, where you have to -// dereference stuff multiple times. This should only be used for temporary -// migration purposes. Because we don't support "changing the pointer", we only -// expose constant pointers. -// -template -class ilist_compat_iterator - : public bidirectional_iterator { - typedef ilist_traits Traits; - typedef bidirectional_iterator super; - -public: - typedef size_t size_type; - typedef typename super::pointer pointer; - typedef typename super::reference reference; -private: - NodeTy *NodePtr; -public: - - ilist_compat_iterator(NodeTy *NP) : NodePtr(NP) {} - ilist_compat_iterator() : NodePtr(0) {} - - // This is templated so that we can allow constructing a const iterator from - // a nonconst iterator... - template - ilist_compat_iterator(const ilist_compat_iterator &RHS) - : NodePtr(RHS.getNodePtrUnchecked()) {} - - // This is templated so that we can allow assigning to a const iterator from - // a nonconst iterator... - template - const ilist_compat_iterator &operator=(const - ilist_compat_iterator &RHS) { - NodePtr = RHS.getNodePtrUnchecked(); - return *this; - } - - // Accessors... - operator pointer() const { - assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!"); - return &NodePtr; - } - - reference operator*() const { - assert(Traits::getNext(NodePtr) != 0 && "Dereferencing end()!"); - return NodePtr; - } - pointer operator->() { return &operator*(); } - const pointer operator->() const { return &operator*(); } - - // Comparison operators - bool operator==(const ilist_compat_iterator &RHS) const { - return NodePtr == RHS.NodePtr; - } - bool operator!=(const ilist_compat_iterator &RHS) const { - return NodePtr != RHS.NodePtr; - } - - // Increment and decrement operators... - ilist_compat_iterator &operator--() { // predecrement - Back up - NodePtr = Traits::getPrev(NodePtr); - assert(NodePtr && "--'d off the beginning of an ilist!"); - return *this; - } - ilist_compat_iterator &operator++() { // preincrement - Advance - NodePtr = Traits::getNext(NodePtr); - assert(NodePtr && "++'d off the end of an ilist!"); - return *this; - } - ilist_compat_iterator operator--(int) { // postdecrement operators... - ilist_compat_iterator tmp = *this; - --*this; - return tmp; - } - ilist_compat_iterator operator++(int) { // postincrement operators... - ilist_compat_iterator tmp = *this; - ++*this; - return tmp; - } - - // Internal interface, do not use... - pointer getNodePtrUnchecked() const { return NodePtr; } -}; - - -// Allow ilist_iterators to convert into pointers to a node automatically when -// used by the dyn_cast, cast, isa mechanisms... - -template struct simplify_type; - -template struct simplify_type > { - typedef NodeTy* SimpleType; - - static SimpleType getSimplifiedValue(const ilist_iterator &Node) { - return &*Node; - } -}; -template struct simplify_type > { - typedef NodeTy* SimpleType; - - static SimpleType getSimplifiedValue(const ilist_iterator &Node) { - return &*Node; - } -}; - - -//===----------------------------------------------------------------------===// -// -// iplist - The subset of list functionality that can safely be used on nodes of -// polymorphic types, ie a heterogeneus list with a common base class that holds -// the next/prev pointers... -// -template > -class iplist : public Traits { - NodeTy *Head, *Tail; - - static bool op_less(NodeTy &L, NodeTy &R) { return L < R; } - static bool op_equal(NodeTy &L, NodeTy &R) { return L == R; } -public: - typedef NodeTy *pointer; - typedef const NodeTy *const_pointer; - typedef NodeTy &reference; - typedef const NodeTy &const_reference; - typedef NodeTy value_type; - typedef ilist_iterator iterator; - typedef ilist_iterator const_iterator; - typedef size_t size_type; - typedef ptrdiff_t difference_type; - typedef std::reverse_iterator const_reverse_iterator; - typedef std::reverse_iterator reverse_iterator; - - iplist() : Head(Traits::createNode()), Tail(Head) { - setNext(Head, 0); - setPrev(Head, 0); - } - ~iplist() { clear(); delete Tail; } - - // Iterator creation methods. - iterator begin() { return iterator(Head); } - const_iterator begin() const { return const_iterator(Head); } - iterator end() { return iterator(Tail); } - const_iterator end() const { return const_iterator(Tail); } - - // reverse iterator creation methods. - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const{ return const_reverse_iterator(end()); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const {return const_reverse_iterator(begin());} - - - // "compatibility" iterator creation methods. - typedef ilist_compat_iterator compat_iterator; - compat_iterator compat_begin() const { return compat_iterator(Head); } - compat_iterator compat_end() const { return compat_iterator(Tail); } - - // Miscellaneous inspection routines. - size_type max_size() const { return size_type(-1); } - bool empty() const { return Head == Tail; } - - // Front and back accessor functions... - reference front() { - assert(!empty() && "Called front() on empty list!"); - return *Head; - } - const_reference front() const { - assert(!empty() && "Called front() on empty list!"); - return *Head; - } - reference back() { - assert(!empty() && "Called back() on empty list!"); - return *getPrev(Tail); - } - const_reference back() const { - assert(!empty() && "Called back() on empty list!"); - return *getPrev(Tail); - } - - void swap(iplist &RHS) { - abort(); // Swap does not use list traits callback correctly yet! - std::swap(Head, RHS.Head); - std::swap(Tail, RHS.Tail); - } - - iterator insert(iterator where, NodeTy *New) { - NodeTy *CurNode = where.getNodePtrUnchecked(), *PrevNode = getPrev(CurNode); - setNext(New, CurNode); - setPrev(New, PrevNode); - - if (PrevNode) - setNext(PrevNode, New); - else - Head = New; - setPrev(CurNode, New); - - addNodeToList(New); // Notify traits that we added a node... - return New; - } - - NodeTy *remove(iterator &IT) { - assert(IT != end() && "Cannot remove end of list!"); - NodeTy *Node = &*IT; - NodeTy *NextNode = getNext(Node); - NodeTy *PrevNode = getPrev(Node); - - if (PrevNode) - setNext(PrevNode, NextNode); - else - Head = NextNode; - setPrev(NextNode, PrevNode); - IT = NextNode; - removeNodeFromList(Node); // Notify traits that we removed a node... - return Node; - } - - NodeTy *remove(const iterator &IT) { - iterator MutIt = IT; - return remove(MutIt); - } - - // erase - remove a node from the controlled sequence... and delete it. - iterator erase(iterator where) { - delete remove(where); - return where; - } - - -private: - // transfer - The heart of the splice function. Move linked list nodes from - // [first, last) into position. - // - void transfer(iterator position, iplist &L2, iterator first, iterator last) { - assert(first != last && "Should be checked by callers"); - if (position != last) { - // Remove [first, last) from its old position. - NodeTy *First = &*first, *Prev = getPrev(First); - NodeTy *Next = last.getNodePtrUnchecked(), *Last = getPrev(Next); - if (Prev) - setNext(Prev, Next); - else - L2.Head = Next; - setPrev(Next, Prev); - - // Splice [first, last) into its new position. - NodeTy *PosNext = position.getNodePtrUnchecked(); - NodeTy *PosPrev = getPrev(PosNext); - - // Fix head of list... - if (PosPrev) - setNext(PosPrev, First); - else - Head = First; - setPrev(First, PosPrev); - - // Fix end of list... - setNext(Last, PosNext); - setPrev(PosNext, Last); - - transferNodesFromList(L2, First, PosNext); - } - } - -public: - - //===----------------------------------------------------------------------=== - // Functionality derived from other functions defined above... - // - - size_type size() const { -#if __GNUC__ == 2 - // GCC 2.95 has a broken std::distance - size_type Result = 0; - std::distance(begin(), end(), Result); - return Result; -#else - return std::distance(begin(), end()); -#endif - } - - iterator erase(iterator first, iterator last) { - while (first != last) - first = erase(first); - return last; - } - - void clear() { erase(begin(), end()); } - - // Front and back inserters... - void push_front(NodeTy *val) { insert(begin(), val); } - void push_back(NodeTy *val) { insert(end(), val); } - void pop_front() { - assert(!empty() && "pop_front() on empty list!"); - erase(begin()); - } - void pop_back() { - assert(!empty() && "pop_back() on empty list!"); - iterator t = end(); erase(--t); - } - - // Special forms of insert... - template void insert(iterator where, InIt first, InIt last) { - for (; first != last; ++first) insert(where, *first); - } - - // Splice members - defined in terms of transfer... - void splice(iterator where, iplist &L2) { - if (!L2.empty()) - transfer(where, L2, L2.begin(), L2.end()); - } - void splice(iterator where, iplist &L2, iterator first) { - iterator last = first; ++last; - if (where == first || where == last) return; // No change - transfer(where, L2, first, last); - } - void splice(iterator where, iplist &L2, iterator first, iterator last) { - if (first != last) transfer(where, L2, first, last); - } - - - - //===----------------------------------------------------------------------=== - // High-Level Functionality that shouldn't really be here, but is part of list - // - - // These two functions are actually called remove/remove_if in list<>, but - // they actually do the job of erase, rename them accordingly. - // - void erase(const NodeTy &val) { - for (iterator I = begin(), E = end(); I != E; ) { - iterator next = I; ++next; - if (*I == val) erase(I); - I = next; - } - } - template void erase_if(Pr1 pred) { - for (iterator I = begin(), E = end(); I != E; ) { - iterator next = I; ++next; - if (pred(*I)) erase(I); - I = next; - } - } - - template void unique(Pr2 pred) { - if (empty()) return; - for (iterator I = begin(), E = end(), Next = begin(); ++Next != E;) { - if (pred(*I)) - erase(Next); - else - I = Next; - Next = I; - } - } - void unique() { unique(op_equal); } - - template void merge(iplist &right, Pr3 pred) { - iterator first1 = begin(), last1 = end(); - iterator first2 = right.begin(), last2 = right.end(); - while (first1 != last1 && first2 != last2) - if (pred(*first2, *first1)) { - iterator next = first2; - transfer(first1, right, first2, ++next); - first2 = next; - } else { - ++first1; - } - if (first2 != last2) transfer(last1, right, first2, last2); - } - void merge(iplist &right) { return merge(right, op_less); } - - template void sort(Pr3 pred); - void sort() { sort(op_less); } - void reverse(); -}; - - -template -struct ilist : public iplist { - typedef typename iplist::size_type size_type; - typedef typename iplist::iterator iterator; - - ilist() {} - ilist(const ilist &right) { - insert(this->begin(), right.begin(), right.end()); - } - explicit ilist(size_type count) { - insert(this->begin(), count, NodeTy()); - } - ilist(size_type count, const NodeTy &val) { - insert(this->begin(), count, val); - } - template ilist(InIt first, InIt last) { - insert(this->begin(), first, last); - } - - - // Forwarding functions: A workaround for GCC 2.95 which does not correctly - // support 'using' declarations to bring a hidden member into scope. - // - iterator insert(iterator a, NodeTy *b){ return iplist::insert(a, b); } - void push_front(NodeTy *a) { iplist::push_front(a); } - void push_back(NodeTy *a) { iplist::push_back(a); } - - - // Main implementation here - Insert for a node passed by value... - iterator insert(iterator where, const NodeTy &val) { - return insert(where, createNode(val)); - } - - - // Front and back inserters... - void push_front(const NodeTy &val) { insert(this->begin(), val); } - void push_back(const NodeTy &val) { insert(this->end(), val); } - - // Special forms of insert... - template void insert(iterator where, InIt first, InIt last) { - for (; first != last; ++first) insert(where, *first); - } - void insert(iterator where, size_type count, const NodeTy &val) { - for (; count != 0; --count) insert(where, val); - } - - // Assign special forms... - void assign(size_type count, const NodeTy &val) { - iterator I = this->begin(); - for (; I != this->end() && count != 0; ++I, --count) - *I = val; - if (count != 0) - insert(this->end(), val, val); - else - erase(I, this->end()); - } - template void assign(InIt first1, InIt last1) { - iterator first2 = this->begin(), last2 = this->end(); - for ( ; first1 != last1 && first2 != last2; ++first1, ++first2) - *first1 = *first2; - if (first2 == last2) - erase(first1, last1); - else - insert(last1, first2, last2); - } - - - // Resize members... - void resize(size_type newsize, NodeTy val) { - iterator i = this->begin(); - size_type len = 0; - for ( ; i != this->end() && len < newsize; ++i, ++len) /* empty*/ ; - - if (len == newsize) - erase(i, this->end()); - else // i == end() - insert(this->end(), newsize - len, val); - } - void resize(size_type newsize) { resize(newsize, NodeTy()); } -}; - -} // End llvm namespace - -namespace std { - // Ensure that swap uses the fast list swap... - template - void swap(llvm::iplist &Left, llvm::iplist &Right) { - Left.swap(Right); - } -} // End 'std' extensions... - -#endif diff --git a/include/Support/iterator.in b/include/Support/iterator.in deleted file mode 100644 index 93813e1985..0000000000 --- a/include/Support/iterator.in +++ /dev/null @@ -1,66 +0,0 @@ -//===-- Support/iterator - "Portable" wrapper around -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides a wrapper around the mysterious header file. -// In GCC 2.95.3, the file defines a bidirectional_iterator class (and other -// friends), instead of the standard iterator class. In GCC 3.1, the -// bidirectional_iterator class got moved out and the new, standards compliant, -// iterator<> class was added. Because there is nothing that we can do to get -// correct behavior on both compilers, we have this header with #ifdef's. Gross -// huh? -// -// By #includ'ing this file, you get the contents of plus the -// following classes in the global namespace: -// -// 1. bidirectional_iterator -// 2. forward_iterator -// -// The #if directives' expressions are filled in by Autoconf. -// -//===----------------------------------------------------------------------===// - -#ifndef SUPPORT_ITERATOR -#define SUPPORT_ITERATOR - -#include - -#if !@HAVE_BI_ITERATOR@ -# if @HAVE_STD_ITERATOR@ -/// If the bidirectional iterator is not defined, we attempt to define it in -/// terms of the C++ standard iterator. Otherwise, we import it with a "using" -/// statement. -/// -template -struct bidirectional_iterator - : public std::iterator { -}; -# else -# error "Need to have standard iterator to define bidirectional iterator!" -# endif -#else -using std::bidirectional_iterator; -#endif - -#if !@HAVE_FWD_ITERATOR@ -# if @HAVE_STD_ITERATOR@ -/// If the forward iterator is not defined, attempt to define it in terms of -/// the C++ standard iterator. Otherwise, we import it with a "using" statement. -/// -template -struct forward_iterator - : public std::iterator { -}; -# else -# error "Need to have standard iterator to define forward iterator!" -# endif -#else -using std::forward_iterator; -#endif - -#endif diff --git a/include/Support/type_traits.h b/include/Support/type_traits.h deleted file mode 100644 index de932b28db..0000000000 --- a/include/Support/type_traits.h +++ /dev/null @@ -1,54 +0,0 @@ -//===- Support/type_traits.h - Simplfied type traits ------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file provides a template class that determines if a type is a class or -// not. The basic mechanism, based on using the pointer to member function of -// a zero argument to a function was "boosted" from the boost type_traits -// library. See http://www.boost.org/ for all the gory details. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_TYPE_TRAITS_H -#define LLVM_SUPPORT_TYPE_TRAITS_H - -// This is actually the conforming implementation which works with abstract -// classes. However, enough compilers have trouble with it that most will use -// the one in boost/type_traits/object_traits.hpp. This implementation actually -// works with VC7.0, but other interactions seem to fail when we use it. - -namespace llvm { - -namespace dont_use -{ - // These two functions should never be used. They are helpers to - // the is_class template below. They cannot be located inside - // is_class because doing so causes at least GCC to think that - // the value of the "value" enumerator is not constant. Placing - // them out here (for some strange reason) allows the sizeof - // operator against them to magically be constant. This is - // important to make the is_class::value idiom zero cost. it - // evaluates to a constant 1 or 0 depending on whether the - // parameter T is a class or not (respectively). - template char is_class_helper(void(T::*)(void)); - template double is_class_helper(...); -} - -template -struct is_class -{ - // is_class<> metafunction due to Paul Mensonides (leavings@attbi.com). For - // more details: - // http://groups.google.com/groups?hl=en&selm=000001c1cc83%24e154d5e0%247772e50c%40c161550a&rnum=1 - public: - enum { value = sizeof(char) == sizeof(dont_use::is_class_helper(0)) }; -}; - -} - -#endif diff --git a/include/llvm/ADT/BitSetVector.h b/include/llvm/ADT/BitSetVector.h index 276af0a68a..73c5841ad6 100644 --- a/include/llvm/ADT/BitSetVector.h +++ b/include/llvm/ADT/BitSetVector.h @@ -1,4 +1,4 @@ -//===-- BitVectorSet.h - A bit-vector representation of sets ----*- C++ -*-===// +//===-- llvm/ADT/BitVectorSet.h - A bit-vector rep. of sets -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -22,8 +22,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_BITSETVECTOR_H -#define SUPPORT_BITSETVECTOR_H +#ifndef LLVM_ADT_BITSETVECTOR_H +#define LLVM_ADT_BITSETVECTOR_H #include #include diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index 4f6dc91bb6..c141a6c6f4 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -1,4 +1,4 @@ -//===- DenseMap.h - A dense map implmentation -------------------*- C++ -*-===// +//===- llvm/ADT/DenseMap.h - A dense map implmentation ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,8 +17,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_DENSEMAP_H -#define SUPPORT_DENSEMAP_H +#ifndef LLVM_ADT_DENSEMAP_H +#define LLVM_ADT_DENSEMAP_H #include diff --git a/include/llvm/ADT/DepthFirstIterator.h b/include/llvm/ADT/DepthFirstIterator.h index c465f4e549..d18ca9d582 100644 --- a/include/llvm/ADT/DepthFirstIterator.h +++ b/include/llvm/ADT/DepthFirstIterator.h @@ -1,4 +1,4 @@ -//===- Support/DepthFirstIterator.h - Depth First iterator ------*- C++ -*-===// +//===- llvm/ADT/DepthFirstIterator.h - Depth First iterator -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This file builds on the Support/GraphTraits.h file to build generic depth +// This file builds on the ADT/GraphTraits.h file to build generic depth // first graph iterator. This file exposes the following functions/types: // // df_begin/df_end/df_iterator @@ -30,11 +30,11 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_DEPTHFIRSTITERATOR_H -#define SUPPORT_DEPTHFIRSTITERATOR_H +#ifndef LLVM_ADT_DEPTHFIRSTITERATOR_H +#define LLVM_ADT_DEPTHFIRSTITERATOR_H -#include "Support/GraphTraits.h" -#include "Support/iterator" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/iterator" #include #include diff --git a/include/llvm/ADT/EquivalenceClasses.h b/include/llvm/ADT/EquivalenceClasses.h index 127183614b..cb4b8bcc32 100644 --- a/include/llvm/ADT/EquivalenceClasses.h +++ b/include/llvm/ADT/EquivalenceClasses.h @@ -1,4 +1,4 @@ -//===-- Support/EquivalenceClasses.h ----------------------------*- C++ -*-===// +//===-- llvm/ADT/EquivalenceClasses.h - Generic Equiv. Classes --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_EQUIVALENCECLASSES_H -#define SUPPORT_EQUIVALENCECLASSES_H +#ifndef LLVM_ADT_EQUIVALENCECLASSES_H +#define LLVM_ADT_EQUIVALENCECLASSES_H #include #include diff --git a/include/llvm/ADT/GraphTraits.h b/include/llvm/ADT/GraphTraits.h index 4ff74176a7..e5765bb713 100644 --- a/include/llvm/ADT/GraphTraits.h +++ b/include/llvm/ADT/GraphTraits.h @@ -1,4 +1,4 @@ -//===-- Support/GraphTraits.h - Graph traits template -----------*- C++ -*-===// +//===-- llvm/ADT/GraphTraits.h - Graph traits template ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,8 +15,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_GRAPHTRAITS_H -#define SUPPORT_GRAPHTRAITS_H +#ifndef LLVM_ADT_GRAPHTRAITS_H +#define LLVM_ADT_GRAPHTRAITS_H namespace llvm { diff --git a/include/llvm/ADT/HashExtras.h b/include/llvm/ADT/HashExtras.h index 67f65b5f3a..f82115a07c 100644 --- a/include/llvm/ADT/HashExtras.h +++ b/include/llvm/ADT/HashExtras.h @@ -1,4 +1,4 @@ -//===-- HashExtras.h - Useful functions for STL hash containers -*- C++ -*-===// +//===-- llvm/ADT/HashExtras.h - Useful functions for STL hash ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,10 +14,10 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_HASHEXTRAS_H -#define SUPPORT_HASHEXTRAS_H +#ifndef LLVM_ADT_HASHEXTRAS_H +#define LLVM_ADT_HASHEXTRAS_H -#include "Support/hash_map" +#include "llvm/ADT/hash_map" #include // Cannot specialize hash template from outside of the std namespace. diff --git a/include/llvm/ADT/IndexedMap.h b/include/llvm/ADT/IndexedMap.h index 4f6dc91bb6..c141a6c6f4 100644 --- a/include/llvm/ADT/IndexedMap.h +++ b/include/llvm/ADT/IndexedMap.h @@ -1,4 +1,4 @@ -//===- DenseMap.h - A dense map implmentation -------------------*- C++ -*-===// +//===- llvm/ADT/DenseMap.h - A dense map implmentation ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,8 +17,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_DENSEMAP_H -#define SUPPORT_DENSEMAP_H +#ifndef LLVM_ADT_DENSEMAP_H +#define LLVM_ADT_DENSEMAP_H #include diff --git a/include/llvm/ADT/PostOrderIterator.h b/include/llvm/ADT/PostOrderIterator.h index d66c4b84c4..8ae46768b5 100644 --- a/include/llvm/ADT/PostOrderIterator.h +++ b/include/llvm/ADT/PostOrderIterator.h @@ -1,4 +1,4 @@ -//===- Support/PostOrderIterator.h - Generic PostOrder iterator -*- C++ -*-===// +//===- llvm/ADT/PostOrderIterator.h - PostOrder iterator --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,17 +7,17 @@ // //===----------------------------------------------------------------------===// // -// This file builds on the Support/GraphTraits.h file to build a generic graph +// This file builds on the ADT/GraphTraits.h file to build a generic graph // post order iterator. This should work over any graph type that has a // GraphTraits specialization. // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_POSTORDERITERATOR_H -#define SUPPORT_POSTORDERITERATOR_H +#ifndef LLVM_ADT_POSTORDERITERATOR_H +#define LLVM_ADT_POSTORDERITERATOR_H -#include "Support/GraphTraits.h" -#include "Support/iterator" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/iterator" #include #include diff --git a/include/llvm/ADT/SCCIterator.h b/include/llvm/ADT/SCCIterator.h index 2ea780ca92..9cccd12324 100644 --- a/include/llvm/ADT/SCCIterator.h +++ b/include/llvm/ADT/SCCIterator.h @@ -1,4 +1,4 @@ -//===-- Support/SCCIterator.h - SCC iterator --------------------*- C++ -*-===// +//===-- Support/SCCIterator.h - Strongly Connected Comp. Iter. --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// This builds on the Support/GraphTraits.h file to find the strongly connected +// This builds on the llvm/ADT/GraphTraits.h file to find the strongly connected // components (SCCs) of a graph in O(N+E) time using Tarjan's DFS algorithm. // // The SCC iterator has the important property that if a node in SCC S1 has an @@ -18,11 +18,11 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_SCCITERATOR_H -#define SUPPORT_SCCITERATOR_H +#ifndef LLVM_ADT_SCCITERATOR_H +#define LLVM_ADT_SCCITERATOR_H -#include "Support/GraphTraits.h" -#include "Support/iterator" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/iterator" #include #include diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index b6379d2623..14b61bc916 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -1,4 +1,4 @@ -//===- STLExtras.h - Useful functions when working with the STL -*- C++ -*-===// +//===- llvm/ADT/STLExtras.h - Useful STL related functions ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,12 +14,12 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_STLEXTRAS_H -#define SUPPORT_STLEXTRAS_H +#ifndef LLVM_ADT_STLEXTRAS_H +#define LLVM_ADT_STLEXTRAS_H #include #include // for std::pair -#include "Support/iterator" +#include "llvm/ADT/iterator" namespace llvm { diff --git a/include/llvm/ADT/SetOperations.h b/include/llvm/ADT/SetOperations.h index bb1e68e6b2..3be8babc38 100644 --- a/include/llvm/ADT/SetOperations.h +++ b/include/llvm/ADT/SetOperations.h @@ -1,4 +1,4 @@ -//===-- Support/SetOperations.h - Generic Set Operations --------*- C++ -*-===// +//===-- llvm/ADT/SetOperations.h - Generic Set Operations -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_SETOPERATIONS_H -#define SUPPORT_SETOPERATIONS_H +#ifndef LLVM_ADT_SETOPERATIONS_H +#define LLVM_ADT_SETOPERATIONS_H namespace llvm { diff --git a/include/llvm/ADT/SetVector.h b/include/llvm/ADT/SetVector.h index c72f49bce8..6135e53286 100644 --- a/include/llvm/ADT/SetVector.h +++ b/include/llvm/ADT/SetVector.h @@ -1,4 +1,4 @@ -//===- SetVector.h - A set with insertion order iteration -------*- C++ -*-===// +//===- llvm/ADT/SetVector.h - Set with insert order iteration ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_SETVECTOR_H -#define SUPPORT_SETVECTOR_H +#ifndef LLVM_ADT_SETVECTOR_H +#define LLVM_ADT_SETVECTOR_H #include #include diff --git a/include/llvm/ADT/Statistic.h b/include/llvm/ADT/Statistic.h index 79d8f9d66e..31e9ae110d 100644 --- a/include/llvm/ADT/Statistic.h +++ b/include/llvm/ADT/Statistic.h @@ -1,4 +1,4 @@ -//===-- Support/Statistic.h - Easy way to expose stats ----------*- C++ -*-===// +//===-- llvm/ADT/Statistic.h - Easy way to expose stats ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -21,8 +21,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_STATISTIC_H -#define SUPPORT_STATISTIC_H +#ifndef LLVM_ADT_STATISTIC_H +#define LLVM_ADT_STATISTIC_H #include diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index fcfa65f232..7e25f654d8 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -1,4 +1,4 @@ -//===-- Support/StringExtras.h - Useful string functions --------*- C++ -*-===// +//===-- llvm/ADT/StringExtras.h - Useful string functions -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_STRINGEXTRAS_H -#define SUPPORT_STRINGEXTRAS_H +#ifndef LLVM_ADT_STRINGEXTRAS_H +#define LLVM_ADT_STRINGEXTRAS_H -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include #include #include diff --git a/include/llvm/ADT/Tree.h b/include/llvm/ADT/Tree.h index 48ecf5b06d..3193eecba2 100644 --- a/include/llvm/ADT/Tree.h +++ b/include/llvm/ADT/Tree.h @@ -1,4 +1,4 @@ -//===- Support/Tree.h - Generic n-way tree structure ------------*- C++ -*-===// +//===- llvm/ADT/Tree.h - Generic n-way tree structure -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_TREE_H -#define SUPPORT_TREE_H +#ifndef LLVM_ADT_TREE_H +#define LLVM_ADT_TREE_H #include diff --git a/include/llvm/ADT/VectorExtras.h b/include/llvm/ADT/VectorExtras.h index cf7cf5d2eb..adc3ff720d 100644 --- a/include/llvm/ADT/VectorExtras.h +++ b/include/llvm/ADT/VectorExtras.h @@ -1,4 +1,4 @@ -//===-- VectorExtras.h - Helper functions for std::vector -------*- C++ -*-===// +//===-- llvm/ADT/VectorExtras.h - Helpers for std::vector -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_VECTOREXTRAS_H -#define SUPPORT_VECTOREXTRAS_H +#ifndef LLVM_ADT_VECTOREXTRAS_H +#define LLVM_ADT_VECTOREXTRAS_H #include diff --git a/include/llvm/ADT/hash_map.in b/include/llvm/ADT/hash_map.in index 0253de788f..9f09ef2ba1 100644 --- a/include/llvm/ADT/hash_map.in +++ b/include/llvm/ADT/hash_map.in @@ -1,4 +1,4 @@ -//===-- Support/hash_map - "Portable" wrapper around hash_map ---*- C++ -*-===// +//===-- llvm/ADT/hash_map - "Portable" wrapper around hash_map --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_HASH_MAP -#define SUPPORT_HASH_MAP +#ifndef LLVM_ADT_HASH_MAP +#define LLVM_ADT_HASH_MAP // Compiler Support Matrix // @@ -61,6 +61,6 @@ using HASH_NAMESPACE::hash; // out specializations like stl_bvector.h, causing link conflicts. #include -#include +#include #endif diff --git a/include/llvm/ADT/hash_set.in b/include/llvm/ADT/hash_set.in index 49c5d732e8..6da8c7f6a3 100644 --- a/include/llvm/ADT/hash_set.in +++ b/include/llvm/ADT/hash_set.in @@ -1,4 +1,4 @@ -//===-- Support/hash_set - "Portable" wrapper around hash_set ---*- C++ -*-===// +//===-- llvm/ADT/hash_set - "Portable" wrapper around hash_set --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,8 +15,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_HASH_SET -#define SUPPORT_HASH_SET +#ifndef LLVM_ADT_HASH_SET +#define LLVM_ADT_HASH_SET // Compiler Support Matrix // @@ -62,6 +62,6 @@ using HASH_NAMESPACE::hash; // out specializations like stl_bvector.h, causing link conflicts. #include -#include +#include #endif diff --git a/include/llvm/ADT/ilist b/include/llvm/ADT/ilist index 9d9fdf0fdb..8c447c92e9 100644 --- a/include/llvm/ADT/ilist +++ b/include/llvm/ADT/ilist @@ -1,4 +1,4 @@ -//===-- Support/ilist - Intrusive Linked List Template ----------*- C++ -*-===// +//===-- llvm/ADT/ilist - Intrusive Linked List Template ---------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -35,10 +35,10 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_ILIST -#define SUPPORT_ILIST +#ifndef LLVM_ADT_ILIST +#define LLVM_ADT_ILIST -#include +#include #include namespace llvm { diff --git a/include/llvm/ADT/iterator.in b/include/llvm/ADT/iterator.in index 93813e1985..072beb71ee 100644 --- a/include/llvm/ADT/iterator.in +++ b/include/llvm/ADT/iterator.in @@ -1,4 +1,4 @@ -//===-- Support/iterator - "Portable" wrapper around -*- C++ -*-===// +//===-- llvm/ADT/iterator - Portable wrapper around --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -25,8 +25,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_ITERATOR -#define SUPPORT_ITERATOR +#ifndef LLVM_ADT_ITERATOR +#define LLVM_ADT_ITERATOR #include diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index 544b2b945d..ddcbbb0ad5 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -18,9 +18,9 @@ #define LLVM_ANALYSIS_ALIASSETTRACKER_H #include "llvm/Support/CallSite.h" -#include "Support/iterator" -#include "Support/hash_map" -#include "Support/ilist" +#include "llvm/ADT/iterator" +#include "llvm/ADT/hash_map" +#include "llvm/ADT/ilist" namespace llvm { diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 86a2b53ad4..2a1f49c83c 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -51,8 +51,8 @@ #ifndef LLVM_ANALYSIS_CALLGRAPH_H #define LLVM_ANALYSIS_CALLGRAPH_H -#include "Support/GraphTraits.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/Pass.h" namespace llvm { diff --git a/include/llvm/Analysis/ConstantsScanner.h b/include/llvm/Analysis/ConstantsScanner.h index e1533c35bb..48c0bd0875 100644 --- a/include/llvm/Analysis/ConstantsScanner.h +++ b/include/llvm/Analysis/ConstantsScanner.h @@ -18,7 +18,7 @@ #include "llvm/Support/InstIterator.h" #include "llvm/Instruction.h" -#include "Support/iterator" +#include "llvm/ADT/iterator" namespace llvm { diff --git a/include/llvm/Analysis/DataStructure/DSGraphTraits.h b/include/llvm/Analysis/DataStructure/DSGraphTraits.h index 608cd198ef..efb31517d1 100644 --- a/include/llvm/Analysis/DataStructure/DSGraphTraits.h +++ b/include/llvm/Analysis/DataStructure/DSGraphTraits.h @@ -17,9 +17,9 @@ #define LLVM_ANALYSIS_DSGRAPHTRAITS_H #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "Support/GraphTraits.h" -#include "Support/iterator" -#include "Support/STLExtras.h" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/iterator" +#include "llvm/ADT/STLExtras.h" namespace llvm { diff --git a/include/llvm/Analysis/DataStructure/DSSupport.h b/include/llvm/Analysis/DataStructure/DSSupport.h index 8cce6c98fd..e5bf390472 100644 --- a/include/llvm/Analysis/DataStructure/DSSupport.h +++ b/include/llvm/Analysis/DataStructure/DSSupport.h @@ -15,7 +15,7 @@ #define LLVM_ANALYSIS_DSSUPPORT_H #include -#include "Support/hash_set" +#include "llvm/ADT/hash_set" #include "llvm/Support/CallSite.h" namespace llvm { diff --git a/include/llvm/Analysis/DataStructure/DataStructure.h b/include/llvm/Analysis/DataStructure/DataStructure.h index f210003213..9351ed4c98 100644 --- a/include/llvm/Analysis/DataStructure/DataStructure.h +++ b/include/llvm/Analysis/DataStructure/DataStructure.h @@ -16,7 +16,7 @@ #include "llvm/Pass.h" #include "llvm/Target/TargetData.h" -#include "Support/hash_set" +#include "llvm/ADT/hash_set" namespace llvm { diff --git a/include/llvm/Analysis/Interval.h b/include/llvm/Analysis/Interval.h index 0d5912305b..448bcbc803 100644 --- a/include/llvm/Analysis/Interval.h +++ b/include/llvm/Analysis/Interval.h @@ -20,7 +20,7 @@ #ifndef LLVM_INTERVAL_H #define LLVM_INTERVAL_H -#include "Support/GraphTraits.h" +#include "llvm/ADT/GraphTraits.h" #include #include diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 38f9264923..c5eec83428 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -31,7 +31,7 @@ #define LLVM_ANALYSIS_LOOP_INFO_H #include "llvm/Pass.h" -#include "Support/GraphTraits.h" +#include "llvm/ADT/GraphTraits.h" namespace llvm { diff --git a/include/llvm/BasicBlock.h b/include/llvm/BasicBlock.h index 27acba4c62..9c82da266e 100644 --- a/include/llvm/BasicBlock.h +++ b/include/llvm/BasicBlock.h @@ -30,7 +30,7 @@ #include "llvm/Instruction.h" #include "llvm/SymbolTableListTraits.h" -#include "Support/ilist" +#include "llvm/ADT/ilist" namespace llvm { diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index fb03740290..578f2b6c60 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -15,8 +15,8 @@ #define LLVM_CODEGEN_MACHINEBASICBLOCK_H #include "llvm/CodeGen/MachineInstr.h" -#include "Support/GraphTraits.h" -#include "Support/ilist" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/ilist" #include namespace llvm { diff --git a/include/llvm/CodeGen/MachineCodeEmitter.h b/include/llvm/CodeGen/MachineCodeEmitter.h index a46a2c5b59..0daab91faf 100644 --- a/include/llvm/CodeGen/MachineCodeEmitter.h +++ b/include/llvm/CodeGen/MachineCodeEmitter.h @@ -18,7 +18,7 @@ #define LLVM_CODEGEN_MACHINECODEEMITTER_H #include -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" namespace llvm { diff --git a/include/llvm/CodeGen/MachineFunction.h b/include/llvm/CodeGen/MachineFunction.h index 69b86a640e..4420c3b84e 100644 --- a/include/llvm/CodeGen/MachineFunction.h +++ b/include/llvm/CodeGen/MachineFunction.h @@ -19,7 +19,7 @@ #define LLVM_CODEGEN_MACHINEFUNCTION_H #include "llvm/CodeGen/MachineBasicBlock.h" -#include "Support/Annotation.h" +#include "llvm/Support/Annotation.h" namespace llvm { diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 3a01ab0fbf..a9f1352b47 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -16,7 +16,7 @@ #ifndef LLVM_CODEGEN_MACHINEINSTR_H #define LLVM_CODEGEN_MACHINEINSTR_H -#include "Support/iterator" +#include "llvm/ADT/iterator" #include #include #include diff --git a/include/llvm/CodeGen/SSARegMap.h b/include/llvm/CodeGen/SSARegMap.h index afed38a334..893b0c7167 100644 --- a/include/llvm/CodeGen/SSARegMap.h +++ b/include/llvm/CodeGen/SSARegMap.h @@ -18,7 +18,7 @@ #define LLVM_CODEGEN_SSAREGMAP_H #include "llvm/Target/MRegisterInfo.h" -#include "Support/DenseMap.h" +#include "llvm/ADT/DenseMap.h" namespace llvm { diff --git a/include/llvm/CodeGen/SchedGraphCommon.h b/include/llvm/CodeGen/SchedGraphCommon.h index fbb9dac751..167bfb0f2d 100644 --- a/include/llvm/CodeGen/SchedGraphCommon.h +++ b/include/llvm/CodeGen/SchedGraphCommon.h @@ -16,7 +16,7 @@ #define LLVM_CODEGEN_SCHEDGRAPHCOMMON_H #include "llvm/Value.h" -#include "Support/iterator" +#include "llvm/ADT/iterator" #include namespace llvm { diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 4719bf9d21..796ee13535 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -23,7 +23,7 @@ #define LLVM_CODEGEN_SELECTIONDAG_H #include "llvm/CodeGen/ValueTypes.h" -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include #include #include diff --git a/include/llvm/Config/alloca.h b/include/llvm/Config/alloca.h index 297b56fa7c..d2bbec6e52 100644 --- a/include/llvm/Config/alloca.h +++ b/include/llvm/Config/alloca.h @@ -15,7 +15,7 @@ #ifndef _CONFIG_ALLOC_H #define _CONFIG_ALLOC_H -#include "Config/config.h" +#include "llvm/Config/config.h" /* * This is a modified version of that suggested by the Autoconf manual. diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index fe0c77c8af..c3046d22d0 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -1,4 +1,4 @@ -/* include/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */ +/* include/llvm/Config/config.h.in. Generated from autoconf/configure.ac by autoheader. */ /* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP systems. This function is required for `alloca.c' support on those systems. diff --git a/include/llvm/Config/dlfcn.h b/include/llvm/Config/dlfcn.h index c7ce5b1968..bf51315ce2 100644 --- a/include/llvm/Config/dlfcn.h +++ b/include/llvm/Config/dlfcn.h @@ -14,7 +14,7 @@ #ifndef _CONFIG_DLFCN_H #define _CONFIG_DLFCN_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_DLFCN_H #include diff --git a/include/llvm/Config/fcntl.h b/include/llvm/Config/fcntl.h index ed8a1c839b..2d0d44d956 100644 --- a/include/llvm/Config/fcntl.h +++ b/include/llvm/Config/fcntl.h @@ -14,7 +14,7 @@ #ifndef _CONFIG_FCNTL_H #define _CONFIG_FCNTL_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_FCNTL_H #include diff --git a/include/llvm/Config/limits.h b/include/llvm/Config/limits.h index e5a787e5e1..1182d90b57 100644 --- a/include/llvm/Config/limits.h +++ b/include/llvm/Config/limits.h @@ -14,7 +14,7 @@ #ifndef _CONFIG_LIMITS_H #define _CONFIG_LIMITS_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_LIMITS_H #include diff --git a/include/llvm/Config/malloc.h b/include/llvm/Config/malloc.h index c78408a359..7d16a40670 100644 --- a/include/llvm/Config/malloc.h +++ b/include/llvm/Config/malloc.h @@ -15,7 +15,7 @@ #ifndef _SUPPORT_MALLOC_H #define _SUPPORT_MALLOC_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_MALLOC_H #include diff --git a/include/llvm/Config/memory.h b/include/llvm/Config/memory.h index f75902b5bc..f6fbbaf735 100644 --- a/include/llvm/Config/memory.h +++ b/include/llvm/Config/memory.h @@ -14,7 +14,7 @@ #ifndef _CONFIG_MEMORY_H #define _CONFIG_MEMORY_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_MEMORY_H #include diff --git a/include/llvm/Config/pagesize.h b/include/llvm/Config/pagesize.h index f37b29770d..adbf87893e 100644 --- a/include/llvm/Config/pagesize.h +++ b/include/llvm/Config/pagesize.h @@ -12,7 +12,7 @@ #ifndef PAGESIZE_H #define PAGESIZE_H -#include "Config/unistd.h" +#include "llvm/Config/unistd.h" #include namespace llvm { diff --git a/include/llvm/Config/stdint.h b/include/llvm/Config/stdint.h index a98961063e..44db789d0d 100644 --- a/include/llvm/Config/stdint.h +++ b/include/llvm/Config/stdint.h @@ -14,7 +14,7 @@ #ifndef _CONFIG_STDINT_H #define _CONFIG_STDINT_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_STDINT_H #include diff --git a/include/llvm/Config/sys/mman.h b/include/llvm/Config/sys/mman.h index 7f51e7fbfb..92f394989a 100644 --- a/include/llvm/Config/sys/mman.h +++ b/include/llvm/Config/sys/mman.h @@ -18,7 +18,7 @@ #ifndef _CONFIG_MMAN_H #define _CONFIG_MMAN_H -#include "Config/config.h" +#include "llvm/Config/config.h" #if defined(HAVE_SYS_MMAN_H) && !defined(_MSC_VER) #include diff --git a/include/llvm/Config/sys/resource.h b/include/llvm/Config/sys/resource.h index 1f4cc694b2..11cb7709ca 100644 --- a/include/llvm/Config/sys/resource.h +++ b/include/llvm/Config/sys/resource.h @@ -16,7 +16,7 @@ #ifndef _CONFIG_SYS_RESOURCE_H #define _CONFIG_SYS_RESOURCE_H -#include "Config/config.h" +#include "llvm/Config/config.h" #if defined(HAVE_SYS_RESOURCE_H) && !defined(_MSC_VER) @@ -25,9 +25,9 @@ * stuff. Some man pages say that you also need sys/time.h and unistd.h. * So, to be paranoid, we will try to include all three if possible. */ -#include "Config/sys/time.h" +#include "llvm/Config/sys/time.h" #include -#include "Config/unistd.h" +#include "llvm/Config/unistd.h" #endif diff --git a/include/llvm/Config/sys/stat.h b/include/llvm/Config/sys/stat.h index 9669bcf927..98b7f72e0a 100644 --- a/include/llvm/Config/sys/stat.h +++ b/include/llvm/Config/sys/stat.h @@ -15,7 +15,7 @@ #ifndef _CONFIG_SYS_STAT_H #define _CONFIG_SYS_STAT_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_SYS_STAT_H #include diff --git a/include/llvm/Config/sys/time.h b/include/llvm/Config/sys/time.h index 3e0ea1e810..f5ca3961f2 100644 --- a/include/llvm/Config/sys/time.h +++ b/include/llvm/Config/sys/time.h @@ -15,7 +15,7 @@ #ifndef _CONFIG_SYS_TIME_H #define _CONFIG_SYS_TIME_H -#include "Config/config.h" +#include "llvm/Config/config.h" #if defined(HAVE_SYS_TIME_H) && !defined(_MSC_VER) #include diff --git a/include/llvm/Config/sys/types.h b/include/llvm/Config/sys/types.h index f0a7abec35..fd6becd38f 100644 --- a/include/llvm/Config/sys/types.h +++ b/include/llvm/Config/sys/types.h @@ -15,7 +15,7 @@ #ifndef _CONFIG_SYS_TYPES_H #define _CONFIG_SYS_TYPES_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_SYS_TYPES_H #include diff --git a/include/llvm/Config/sys/wait.h b/include/llvm/Config/sys/wait.h index b3db60e435..a1c70fbc6c 100644 --- a/include/llvm/Config/sys/wait.h +++ b/include/llvm/Config/sys/wait.h @@ -14,7 +14,7 @@ #ifndef _CONFIG_SYS_WAIT_H #define _CONFIG_SYS_WAIT_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_SYS_WAIT_H #include diff --git a/include/llvm/Config/time.h b/include/llvm/Config/time.h index b2f3e6ee05..6d66efad1c 100644 --- a/include/llvm/Config/time.h +++ b/include/llvm/Config/time.h @@ -24,7 +24,7 @@ #ifndef _CONFIG_TIME_H #define _CONFIG_TIME_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_TIME_H #include diff --git a/include/llvm/Config/unistd.h b/include/llvm/Config/unistd.h index 847db7a3c6..d6e90d0f9f 100644 --- a/include/llvm/Config/unistd.h +++ b/include/llvm/Config/unistd.h @@ -14,7 +14,7 @@ #ifndef _CONFIG_UNISTD_H #define _CONFIG_UNISTD_H -#include "Config/config.h" +#include "llvm/Config/config.h" #if defined(HAVE_UNISTD_H) && !defined(_MSC_VER) #include diff --git a/include/llvm/Config/windows.h b/include/llvm/Config/windows.h index fded99fba8..ab443911a2 100644 --- a/include/llvm/Config/windows.h +++ b/include/llvm/Config/windows.h @@ -14,7 +14,7 @@ #ifndef LLVM_CONFIG_WINDOWS_H #define LLVM_CONFIG_WINDOWS_H -#include "Config/config.h" +#include "llvm/Config/config.h" #ifdef HAVE_WINDOWS_H #include diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h index 5ef2cb0132..d0f577311e 100644 --- a/include/llvm/Constants.h +++ b/include/llvm/Constants.h @@ -17,7 +17,7 @@ #include "llvm/Constant.h" #include "llvm/Type.h" -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" namespace llvm { diff --git a/include/llvm/ExecutionEngine/GenericValue.h b/include/llvm/ExecutionEngine/GenericValue.h index 7cf1a7b395..6ea4366784 100644 --- a/include/llvm/ExecutionEngine/GenericValue.h +++ b/include/llvm/ExecutionEngine/GenericValue.h @@ -15,7 +15,7 @@ #ifndef GENERIC_VALUE_H #define GENERIC_VALUE_H -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" namespace llvm { diff --git a/include/llvm/Function.h b/include/llvm/Function.h index b363191b93..9e17f2602c 100644 --- a/include/llvm/Function.h +++ b/include/llvm/Function.h @@ -21,7 +21,7 @@ #include "llvm/GlobalValue.h" #include "llvm/BasicBlock.h" #include "llvm/Argument.h" -#include "Support/Annotation.h" +#include "llvm/Support/Annotation.h" namespace llvm { diff --git a/include/llvm/Support/Annotation.h b/include/llvm/Support/Annotation.h index efca20a3ec..4325836c29 100644 --- a/include/llvm/Support/Annotation.h +++ b/include/llvm/Support/Annotation.h @@ -1,4 +1,4 @@ -//===-- Support/Annotation.h - Annotation classes ---------------*- C++ -*-===// +//===-- llvm/Support/Annotation.h - Annotation classes ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -19,8 +19,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_ANNOTATION_H -#define SUPPORT_ANNOTATION_H +#ifndef LLVM_SUPPORT_ANNOTATION_H +#define LLVM_SUPPORT_ANNOTATION_H #include #include diff --git a/include/llvm/Support/CFG.h b/include/llvm/Support/CFG.h index a20265cd0c..badb846bac 100644 --- a/include/llvm/Support/CFG.h +++ b/include/llvm/Support/CFG.h @@ -15,10 +15,10 @@ #ifndef LLVM_SUPPORT_CFG_H #define LLVM_SUPPORT_CFG_H -#include "Support/GraphTraits.h" +#include "llvm/ADT/GraphTraits.h" #include "llvm/Function.h" #include "llvm/InstrTypes.h" -#include "Support/iterator" +#include "llvm/ADT/iterator" namespace llvm { diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index abc80aac7a..d189754865 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -1,4 +1,4 @@ -//===-- Support/Casting.h - Allow flexible, checked, casts ------*- C++ -*-===// +//===-- llvm/Support/Casting.h - Allow flexible, checked, casts -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_CASTING_H -#define SUPPORT_CASTING_H +#ifndef LLVM_SUPPORT_CASTING_H +#define LLVM_SUPPORT_CASTING_H namespace llvm { diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 053b823669..2c38e0aac0 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1,4 +1,4 @@ -//===- Support/CommandLine.h - Flexible Command line parser -----*- C++ -*-===// +//===- llvm/Support/CommandLine.h - Command line handler --------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,10 +17,10 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_COMMANDLINE_H -#define SUPPORT_COMMANDLINE_H +#ifndef LLVM_SUPPORT_COMMANDLINE_H +#define LLVM_SUPPORT_COMMANDLINE_H -#include "Support/type_traits.h" +#include "llvm/Support/type_traits.h" #include #include #include diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index 30618a1692..0c8b3b6b4c 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -24,7 +24,7 @@ #ifndef LLVM_SUPPORT_CONSTANT_RANGE_H #define LLVM_SUPPORT_CONSTANT_RANGE_H -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include namespace llvm { diff --git a/include/llvm/Support/DOTGraphTraits.h b/include/llvm/Support/DOTGraphTraits.h index 7dbc4ff0b6..b83b759f40 100644 --- a/include/llvm/Support/DOTGraphTraits.h +++ b/include/llvm/Support/DOTGraphTraits.h @@ -1,4 +1,4 @@ -//===-- Support/DotGraphTraits.h - Customize .dot output --------*- C++ -*-===// +//===-- llvm/Support/DotGraphTraits.h - Customize .dot output ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_DOTGRAPHTRAITS_H -#define SUPPORT_DOTGRAPHTRAITS_H +#ifndef LLVM_SUPPORT_DOTGRAPHTRAITS_H +#define LLVM_SUPPORT_DOTGRAPHTRAITS_H #include diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h index f0a1b3dc5b..263547c980 100644 --- a/include/llvm/Support/Debug.h +++ b/include/llvm/Support/Debug.h @@ -1,4 +1,4 @@ -//===- Debug.h - An easy way to add debug output to your code ---*- C++ -*-===// +//===- llvm/Support/Debug.h - Easy way to add debug output ------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -23,8 +23,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_DEBUG_H -#define SUPPORT_DEBUG_H +#ifndef LLVM_SUPPORT_DEBUG_H +#define LLVM_SUPPORT_DEBUG_H // Unsurprisingly, most users of this macro use std::cerr too. #include diff --git a/include/llvm/Support/DynamicLinker.h b/include/llvm/Support/DynamicLinker.h index fec9a45296..4f0bb58cab 100644 --- a/include/llvm/Support/DynamicLinker.h +++ b/include/llvm/Support/DynamicLinker.h @@ -1,4 +1,4 @@ -//===-- DynamicLinker.h - System-indep. DynamicLinker interface -*- C++ -*-===// +//===-- llvm/Support/DynamicLinker.h - Portable Dynamic Linker --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_DYNAMICLINKER_H -#define SUPPORT_DYNAMICLINKER_H +#ifndef LLVM_SUPPORT_DYNAMICLINKER_H +#define LLVM_SUPPORT_DYNAMICLINKER_H #include diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index e4b87b9022..8d9f693cf6 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -1,4 +1,4 @@ -//===-- Support/ELF.h - ELF constants and data structures -------*- C++ -*-===// +//===-- llvm/Support/ELF.h - ELF constants and data structures --*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -18,7 +18,10 @@ // //===----------------------------------------------------------------------===// -#include "Support/DataTypes.h" +#ifndef LLVM_SUPPORT_ELF_H +#define LLVM_SUPPORT_ELF_H + +#include "llvm/Support/DataTypes.h" #include #include @@ -293,3 +296,5 @@ enum { } // end namespace ELF } // end namespace llvm + +#endif diff --git a/include/llvm/Support/FileUtilities.h b/include/llvm/Support/FileUtilities.h index 78983b8352..c9f52c3248 100644 --- a/include/llvm/Support/FileUtilities.h +++ b/include/llvm/Support/FileUtilities.h @@ -1,4 +1,4 @@ -//===- Support/FileUtilities.h - File System Utilities ----------*- C++ -*-===// +//===- llvm/Support/FileUtilities.h - File System Utilities -----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_FILEUTILITIES_H -#define SUPPORT_FILEUTILITIES_H +#ifndef LLVM_SUPPORT_FILEUTILITIES_H +#define LLVM_SUPPORT_FILEUTILITIES_H #include diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index c6a5c3cdc9..feb9900d3b 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -1,4 +1,4 @@ -//===-- Support/GraphWriter.h - Write a graph to a .dot file ----*- C++ -*-===// +//===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -20,11 +20,11 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_GRAPHWRITER_H -#define SUPPORT_GRAPHWRITER_H +#ifndef LLVM_SUPPORT_GRAPHWRITER_H +#define LLVM_SUPPORT_GRAPHWRITER_H -#include "Support/DOTGraphTraits.h" -#include "Support/GraphTraits.h" +#include "llvm/Support/DOTGraphTraits.h" +#include "llvm/ADT/GraphTraits.h" #include #include diff --git a/include/llvm/Support/LeakDetector.h b/include/llvm/Support/LeakDetector.h index e2ce9c50be..6ca5405bc4 100644 --- a/include/llvm/Support/LeakDetector.h +++ b/include/llvm/Support/LeakDetector.h @@ -1,4 +1,4 @@ -//===-- Support/LeakDetector.h - Provide simple leak detection --*- C++ -*-===// +//===-- llvm/Support/LeakDetector.h - Provide leak detection ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -19,8 +19,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_LEAKDETECTOR_H -#define SUPPORT_LEAKDETECTOR_H +#ifndef LLVM_SUPPORT_LEAKDETECTOR_H +#define LLVM_SUPPORT_LEAKDETECTOR_H #include diff --git a/include/llvm/Support/MallocAllocator.h b/include/llvm/Support/MallocAllocator.h index 3e3da4139c..c17517e2a0 100644 --- a/include/llvm/Support/MallocAllocator.h +++ b/include/llvm/Support/MallocAllocator.h @@ -1,4 +1,4 @@ -//===-- Support/MallocAllocator.h - Allocator using malloc/free -*- C++ -*-===// +//===-- llvm/Support/MallocAllocator.h --------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -17,8 +17,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_MALLOCALLOCATOR_H -#define SUPPORT_MALLOCALLOCATOR_H +#ifndef LLVM_SUPPORT_MALLOCALLOCATOR_H +#define LLVM_SUPPORT_MALLOCALLOCATOR_H #include #include diff --git a/include/llvm/Support/Mangler.h b/include/llvm/Support/Mangler.h index 4043d85a71..14d68b59d3 100644 --- a/include/llvm/Support/Mangler.h +++ b/include/llvm/Support/Mangler.h @@ -1,4 +1,4 @@ -//===-- Mangler.h - Self-contained llvm name mangler ------------*- C++ -*-===// +//===-- llvm/Support/Mangler.h - Self-contained name mangler ----*- C++ -*-===// // // The LLVM Compiler Infrastructure // diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index c1384d3eff..bfc175f2c1 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -1,4 +1,4 @@ -//===-- Support/MathExtras.h - Useful math functions ------------*- C++ -*-===// +//===-- llvm/Support/MathExtras.h - Useful math functions -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_MATHEXTRAS_H -#define SUPPORT_MATHEXTRAS_H +#ifndef LLVM_SUPPORT_MATHEXTRAS_H +#define LLVM_SUPPORT_MATHEXTRAS_H -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" namespace llvm { diff --git a/include/llvm/Support/MutexGuard.h b/include/llvm/Support/MutexGuard.h index 470010219f..48428b8cde 100644 --- a/include/llvm/Support/MutexGuard.h +++ b/include/llvm/Support/MutexGuard.h @@ -18,9 +18,9 @@ #define SUPPORT_THREADSUPPORT_H #if @HAVE_PTHREAD_MUTEX_LOCK@ -#include "Support/ThreadSupport-PThreads.h" +#include "llvm/Support/ThreadSupport-PThreads.h" #else -#include "Support/ThreadSupport-NoSupport.h" +#include "llvm/Support/ThreadSupport-NoSupport.h" #endif // If no system support is available namespace llvm { diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index 0ffcabad52..71ebe41a45 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -23,7 +23,7 @@ #ifndef LLVM_SUPPORT_PASS_NAME_PARSER_H #define LLVM_SUPPORT_PASS_NAME_PARSER_H -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Pass.h" #include #include diff --git a/include/llvm/Support/PluginLoader.h b/include/llvm/Support/PluginLoader.h index 7410895c3a..48f8a7d8dc 100644 --- a/include/llvm/Support/PluginLoader.h +++ b/include/llvm/Support/PluginLoader.h @@ -1,4 +1,4 @@ -//===-- Support/PluginLoader.h - Provide -load option to tool ---*- C++ -*-===// +//===-- llvm/Support/PluginLoader.h - Plugin Loader for Tools ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,10 +14,10 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_PLUGINLOADER_H -#define SUPPORT_PLUGINLOADER_H +#ifndef LLVM_SUPPORT_PLUGINLOADER_H +#define LLVM_SUPPORT_PLUGINLOADER_H -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" namespace llvm { struct PluginLoader { diff --git a/include/llvm/Support/SlowOperationInformer.h b/include/llvm/Support/SlowOperationInformer.h index 67edf7df42..896fd3fb06 100644 --- a/include/llvm/Support/SlowOperationInformer.h +++ b/include/llvm/Support/SlowOperationInformer.h @@ -1,4 +1,4 @@ -//===- SlowOperationInformer.h - Keep the user informed ---------*- C++ -*-===// +//===- llvm/Support/SlowOperationInformer.h - Keep user informed *- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -28,8 +28,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_SLOW_OPERATION_INFORMER_H -#define SUPPORT_SLOW_OPERATION_INFORMER_H +#ifndef LLVM_SUPPORT_SLOW_OPERATION_INFORMER_H +#define LLVM_SUPPORT_SLOW_OPERATION_INFORMER_H #include #include diff --git a/include/llvm/Support/SystemUtils.h b/include/llvm/Support/SystemUtils.h index b8c130cc97..aea7df80eb 100644 --- a/include/llvm/Support/SystemUtils.h +++ b/include/llvm/Support/SystemUtils.h @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SYSTEMUTILS_H -#define SYSTEMUTILS_H +#ifndef LLVM_SUPPORT_SYSTEMUTILS_H +#define LLVM_SUPPORT_SYSTEMUTILS_H #include diff --git a/include/llvm/Support/ThreadSupport-NoSupport.h b/include/llvm/Support/ThreadSupport-NoSupport.h index 5dc954efab..3602e21cea 100644 --- a/include/llvm/Support/ThreadSupport-NoSupport.h +++ b/include/llvm/Support/ThreadSupport-NoSupport.h @@ -1,4 +1,4 @@ -//===-- Support/ThreadSupport-NoSupport.h - Generic impl --------*- C++ -*-===// +//===-- llvm/Support/ThreadSupport-NoSupport.h - Generic Impl ---*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,7 +16,7 @@ // Users should never #include this file directly! As such, no include guards // are needed. -#ifndef SUPPORT_THREADSUPPORT_H +#ifndef LLVM_SUPPORT_THREADSUPPORT_H #error "Code should not #include Support/ThreadSupport-NoSupport.h directly!" #endif diff --git a/include/llvm/Support/ThreadSupport-PThreads.h b/include/llvm/Support/ThreadSupport-PThreads.h index 6bbe682c08..1bd3f32a99 100644 --- a/include/llvm/Support/ThreadSupport-PThreads.h +++ b/include/llvm/Support/ThreadSupport-PThreads.h @@ -1,4 +1,4 @@ -//===-- Support/ThreadSupport-PThreads.h - PThreads support -----*- C++ -*-===// +//===-- llvm/Support/ThreadSupport-PThreads.h - PThreads support *- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -15,7 +15,7 @@ // Users should never #include this file directly! As such, no include guards // are needed. -#ifndef SUPPORT_THREADSUPPORT_H +#ifndef LLVM_SUPPORT_THREADSUPPORT_H #error "Code should not #include Support/ThreadSupport/PThreads.h directly!" #endif diff --git a/include/llvm/Support/ThreadSupport.h.in b/include/llvm/Support/ThreadSupport.h.in index 470010219f..48428b8cde 100644 --- a/include/llvm/Support/ThreadSupport.h.in +++ b/include/llvm/Support/ThreadSupport.h.in @@ -18,9 +18,9 @@ #define SUPPORT_THREADSUPPORT_H #if @HAVE_PTHREAD_MUTEX_LOCK@ -#include "Support/ThreadSupport-PThreads.h" +#include "llvm/Support/ThreadSupport-PThreads.h" #else -#include "Support/ThreadSupport-NoSupport.h" +#include "llvm/Support/ThreadSupport-NoSupport.h" #endif // If no system support is available namespace llvm { diff --git a/include/llvm/Support/Timer.h b/include/llvm/Support/Timer.h index ac465bb95b..a31dd3d93c 100644 --- a/include/llvm/Support/Timer.h +++ b/include/llvm/Support/Timer.h @@ -1,4 +1,4 @@ -//===-- Support/Timer.h - Interval Timing Support ---------------*- C++ -*-===// +//===-- llvm/Support/Timer.h - Interval Timing Support ----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_TIMER_H -#define SUPPORT_TIMER_H +#ifndef LLVM_SUPPORT_TIMER_H +#define LLVM_SUPPORT_TIMER_H #include #include diff --git a/include/llvm/Support/ToolRunner.h b/include/llvm/Support/ToolRunner.h index bd085eab6d..c5d89da46d 100644 --- a/include/llvm/Support/ToolRunner.h +++ b/include/llvm/Support/ToolRunner.h @@ -1,4 +1,4 @@ -//===-- Support/ToolRunner.h ------------------------------------*- C++ -*-===// +//===-- llvm/Support/ToolRunner.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,10 +14,10 @@ // //===----------------------------------------------------------------------===// -#ifndef TOOLRUNNER_H -#define TOOLRUNNER_H +#ifndef LLVM_SUPPORT_TOOLRUNNER_H +#define LLVM_SUPPORT_TOOLRUNNER_H -#include "Support/SystemUtils.h" +#include "llvm/Support/SystemUtils.h" #include #include diff --git a/include/llvm/Support/TypeInfo.h b/include/llvm/Support/TypeInfo.h index e23f906afa..54043af9de 100644 --- a/include/llvm/Support/TypeInfo.h +++ b/include/llvm/Support/TypeInfo.h @@ -1,4 +1,4 @@ -//===- Support/TypeInfo.h - Support class for type_info objects -*- C++ -*-===// +//===- llvm/Support/TypeInfo.h - Support for type_info objects -*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#ifndef SUPPORT_TYPEINFO_H -#define SUPPORT_TYPEINFO_H +#ifndef LLVM_SUPPORT_TYPEINFO_H +#define LLVM_SUPPORT_TYPEINFO_H #include diff --git a/include/llvm/Support/type_traits.h b/include/llvm/Support/type_traits.h index de932b28db..36bbdb8ea4 100644 --- a/include/llvm/Support/type_traits.h +++ b/include/llvm/Support/type_traits.h @@ -1,4 +1,4 @@ -//===- Support/type_traits.h - Simplfied type traits ------------*- C++ -*-===// +//===- llvm/Support/type_traits.h - Simplfied type traits -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // diff --git a/include/llvm/Target/TargetData.h b/include/llvm/Target/TargetData.h index d354d2098c..9de9d7044a 100644 --- a/include/llvm/Target/TargetData.h +++ b/include/llvm/Target/TargetData.h @@ -21,7 +21,7 @@ #define LLVM_TARGET_TARGETDATA_H #include "llvm/Pass.h" -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include #include diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index bc25fa722b..d5f4b94d96 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -15,7 +15,7 @@ #define LLVM_TARGET_TARGETINSTRINFO_H #include "llvm/CodeGen/MachineBasicBlock.h" -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include #include diff --git a/include/llvm/Target/TargetMachineRegistry.h b/include/llvm/Target/TargetMachineRegistry.h index 008b69c1db..08ab56e10a 100644 --- a/include/llvm/Target/TargetMachineRegistry.h +++ b/include/llvm/Target/TargetMachineRegistry.h @@ -17,7 +17,7 @@ #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H #define LLVM_TARGET_TARGETMACHINEREGISTRY_H -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" namespace llvm { class Module; diff --git a/include/llvm/Target/TargetSchedInfo.h b/include/llvm/Target/TargetSchedInfo.h index b7bd81f35a..f2a3560496 100644 --- a/include/llvm/Target/TargetSchedInfo.h +++ b/include/llvm/Target/TargetSchedInfo.h @@ -17,7 +17,7 @@ #define LLVM_TARGET_TARGETSCHEDINFO_H #include "llvm/Target/TargetInstrInfo.h" -#include "Support/hash_map" +#include "llvm/ADT/hash_map" #include namespace llvm { diff --git a/include/llvm/Type.h b/include/llvm/Type.h index fcaa9f5669..dbc7881eb1 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -35,9 +35,9 @@ #define LLVM_TYPE_H #include "AbstractTypeUser.h" -#include "Support/Casting.h" -#include "Support/GraphTraits.h" -#include "Support/iterator" +#include "llvm/Support/Casting.h" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/iterator" #include namespace llvm { diff --git a/include/llvm/Use.h b/include/llvm/Use.h index fb5eafb712..03afc24580 100644 --- a/include/llvm/Use.h +++ b/include/llvm/Use.h @@ -16,7 +16,7 @@ #ifndef LLVM_USE_H #define LLVM_USE_H -#include "Support/ilist" +#include "llvm/ADT/ilist" namespace llvm { diff --git a/include/llvm/Value.h b/include/llvm/Value.h index f5381efd0d..2b10a841a0 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -19,7 +19,7 @@ #include "llvm/AbstractTypeUser.h" #include "llvm/Use.h" -#include "Support/Casting.h" +#include "llvm/Support/Casting.h" #include namespace llvm { diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index b4a183d1c4..af0a25a409 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -24,7 +24,7 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/InstIterator.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include #include diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index 9eaaec690b..88f9843c0b 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -23,7 +23,7 @@ #include "llvm/Analysis/CFGPrinter.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" -#include "Support/GraphWriter.h" +#include "llvm/Support/GraphWriter.h" #include #include using namespace llvm; diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index 9f2124a1bb..4bc6fafcf6 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -16,8 +16,8 @@ #include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Module.h" -#include "Support/Statistic.h" -#include "Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Debug.h" #include "DSCallSiteIterator.h" using namespace llvm; diff --git a/lib/Analysis/DataStructure/CompleteBottomUp.cpp b/lib/Analysis/DataStructure/CompleteBottomUp.cpp index 589891f557..b2a0f4ba9b 100644 --- a/lib/Analysis/DataStructure/CompleteBottomUp.cpp +++ b/lib/Analysis/DataStructure/CompleteBottomUp.cpp @@ -16,10 +16,10 @@ #include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Module.h" #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "Support/Debug.h" -#include "Support/SCCIterator.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/SCCIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; namespace { diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 83aa890d96..de34265f2a 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -18,12 +18,12 @@ #include "llvm/DerivedTypes.h" #include "llvm/Target/TargetData.h" #include "llvm/Assembly/Writer.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/DepthFirstIterator.h" -#include "Support/STLExtras.h" -#include "Support/Statistic.h" -#include "Support/Timer.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Timer.h" #include using namespace llvm; diff --git a/lib/Analysis/DataStructure/DataStructureOpt.cpp b/lib/Analysis/DataStructure/DataStructureOpt.cpp index 6c2e5df3a7..f7a1ed9af3 100644 --- a/lib/Analysis/DataStructure/DataStructureOpt.cpp +++ b/lib/Analysis/DataStructure/DataStructureOpt.cpp @@ -16,7 +16,7 @@ #include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Module.h" #include "llvm/Constant.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Analysis/DataStructure/DataStructureStats.cpp b/lib/Analysis/DataStructure/DataStructureStats.cpp index 1bfe09aba5..7e3f85f3a6 100644 --- a/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -17,7 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Support/InstVisitor.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Analysis/DataStructure/DependenceGraph.h b/lib/Analysis/DataStructure/DependenceGraph.h index 679ecd7d13..520b008528 100644 --- a/lib/Analysis/DataStructure/DependenceGraph.h +++ b/lib/Analysis/DataStructure/DependenceGraph.h @@ -24,7 +24,7 @@ #ifndef LLVM_ANALYSIS_DEPENDENCEGRAPH_H #define LLVM_ANALYSIS_DEPENDENCEGRAPH_H -#include "Support/hash_map" +#include "llvm/ADT/hash_map" #include #include #include diff --git a/lib/Analysis/DataStructure/GraphChecker.cpp b/lib/Analysis/DataStructure/GraphChecker.cpp index 5cb37bb23e..8cef6b37bf 100644 --- a/lib/Analysis/DataStructure/GraphChecker.cpp +++ b/lib/Analysis/DataStructure/GraphChecker.cpp @@ -25,7 +25,7 @@ #include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/Value.h" #include #include diff --git a/lib/Analysis/DataStructure/IPModRef.cpp b/lib/Analysis/DataStructure/IPModRef.cpp index bf1940ebe6..ccc15f74e4 100644 --- a/lib/Analysis/DataStructure/IPModRef.cpp +++ b/lib/Analysis/DataStructure/IPModRef.cpp @@ -16,9 +16,9 @@ #include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Module.h" #include "llvm/Instructions.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/StringExtras.h" #include namespace llvm { diff --git a/lib/Analysis/DataStructure/IPModRef.h b/lib/Analysis/DataStructure/IPModRef.h index 57649da723..4a825dbea3 100644 --- a/lib/Analysis/DataStructure/IPModRef.h +++ b/lib/Analysis/DataStructure/IPModRef.h @@ -47,8 +47,8 @@ #define LLVM_ANALYSIS_IPMODREF_H #include "llvm/Pass.h" -#include "Support/BitSetVector.h" -#include "Support/hash_map" +#include "llvm/ADT/BitSetVector.h" +#include "llvm/ADT/hash_map" namespace llvm { diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 34c56dc2ea..b21f2f1024 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -21,9 +21,9 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Target/TargetData.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Timer.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/Timer.h" // FIXME: This should eventually be a FunctionPass that is automatically // aggregated into a Pass. diff --git a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp index 7c39365d06..49b6425930 100644 --- a/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp +++ b/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp @@ -25,11 +25,11 @@ #include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Support/CFG.h" -#include "Support/SCCIterator.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" -#include "Support/hash_map" -#include "Support/hash_set" +#include "llvm/ADT/SCCIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/hash_map" +#include "llvm/ADT/hash_set" namespace llvm { diff --git a/lib/Analysis/DataStructure/MemoryDepAnalysis.h b/lib/Analysis/DataStructure/MemoryDepAnalysis.h index 04d78dafff..570a03b679 100644 --- a/lib/Analysis/DataStructure/MemoryDepAnalysis.h +++ b/lib/Analysis/DataStructure/MemoryDepAnalysis.h @@ -22,7 +22,7 @@ #include "DependenceGraph.h" #include "llvm/Pass.h" -#include "Support/hash_map" +#include "llvm/ADT/hash_map" namespace llvm { diff --git a/lib/Analysis/DataStructure/Parallelize.cpp b/lib/Analysis/DataStructure/Parallelize.cpp index c944b8cc20..3dcb05ee06 100644 --- a/lib/Analysis/DataStructure/Parallelize.cpp +++ b/lib/Analysis/DataStructure/Parallelize.cpp @@ -46,10 +46,10 @@ #include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" -#include "Support/hash_set" -#include "Support/hash_map" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/hash_set" +#include "llvm/ADT/hash_map" #include #include using namespace llvm; diff --git a/lib/Analysis/DataStructure/PgmDependenceGraph.h b/lib/Analysis/DataStructure/PgmDependenceGraph.h index 5f7f7d581b..ec6f927a7e 100644 --- a/lib/Analysis/DataStructure/PgmDependenceGraph.h +++ b/lib/Analysis/DataStructure/PgmDependenceGraph.h @@ -43,7 +43,7 @@ /* #include "llvm/Analysis/PostDominators.h" -- see below */ #include "llvm/Instruction.h" #include "llvm/Pass.h" -#include "Support/iterator" +#include "llvm/ADT/iterator" namespace llvm { diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index 24bf768379..c951433f49 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -17,9 +17,9 @@ #include "llvm/Module.h" #include "llvm/Constants.h" #include "llvm/Assembly/Writer.h" -#include "Support/CommandLine.h" -#include "Support/GraphWriter.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/GraphWriter.h" +#include "llvm/ADT/Statistic.h" #include #include using namespace llvm; diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index 55a6deb048..deeb8b3450 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -18,7 +18,7 @@ #include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Module.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" using namespace llvm; namespace { diff --git a/lib/Analysis/DataStructure/TopDownClosure.cpp b/lib/Analysis/DataStructure/TopDownClosure.cpp index 4635787a04..1d861e8216 100644 --- a/lib/Analysis/DataStructure/TopDownClosure.cpp +++ b/lib/Analysis/DataStructure/TopDownClosure.cpp @@ -18,8 +18,8 @@ #include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 54dfd7458d..7901c91abb 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -58,8 +58,8 @@ #include "llvm/Support/InstIterator.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Analysis/AliasAnalysis.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 8025ab2d9a..75e068ba54 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -16,7 +16,7 @@ #include "llvm/Module.h" #include "llvm/Instructions.h" #include "llvm/Support/CallSite.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; diff --git a/lib/Analysis/IPA/CallGraphSCCPass.cpp b/lib/Analysis/IPA/CallGraphSCCPass.cpp index f4e2efbe1c..f7d7ab126a 100644 --- a/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -17,7 +17,7 @@ #include "llvm/CallGraphSCCPass.h" #include "llvm/Analysis/CallGraph.h" -#include "Support/SCCIterator.h" +#include "llvm/ADT/SCCIterator.h" using namespace llvm; /// getAnalysisUsage - For this class, we declare that we require and preserve diff --git a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp index 52a83a1dfd..23ee99aa59 100644 --- a/lib/Analysis/IPA/FindUnsafePointerTypes.cpp +++ b/lib/Analysis/IPA/FindUnsafePointerTypes.cpp @@ -28,7 +28,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Support/InstIterator.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; static RegisterAnalysis diff --git a/lib/Analysis/IPA/GlobalsModRef.cpp b/lib/Analysis/IPA/GlobalsModRef.cpp index 219fdbf649..c1f15ed238 100644 --- a/lib/Analysis/IPA/GlobalsModRef.cpp +++ b/lib/Analysis/IPA/GlobalsModRef.cpp @@ -22,9 +22,9 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/Support/InstIterator.h" -#include "Support/CommandLine.h" -#include "Support/Statistic.h" -#include "Support/SCCIterator.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/SCCIterator.h" #include using namespace llvm; diff --git a/lib/Analysis/IPA/PrintSCC.cpp b/lib/Analysis/IPA/PrintSCC.cpp index 8911cc36e2..e4af831752 100644 --- a/lib/Analysis/IPA/PrintSCC.cpp +++ b/lib/Analysis/IPA/PrintSCC.cpp @@ -29,7 +29,7 @@ #include "llvm/Module.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/Support/CFG.h" -#include "Support/SCCIterator.h" +#include "llvm/ADT/SCCIterator.h" #include namespace llvm { diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index 9177e44800..12d16b081e 100644 --- a/lib/Analysis/InstCount.cpp +++ b/lib/Analysis/InstCount.cpp @@ -14,7 +14,7 @@ #include "llvm/Pass.h" #include "llvm/Function.h" #include "llvm/Support/InstVisitor.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" namespace llvm { diff --git a/lib/Analysis/IntervalPartition.cpp b/lib/Analysis/IntervalPartition.cpp index 12c196f2f7..9253f721ab 100644 --- a/lib/Analysis/IntervalPartition.cpp +++ b/lib/Analysis/IntervalPartition.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Analysis/IntervalIterator.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" namespace llvm { diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 131d02a32b..710f74afe2 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -20,7 +20,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" -#include "Support/DepthFirstIterator.h" +#include "llvm/ADT/DepthFirstIterator.h" #include #include diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp index ff202f0151..e5908c496b 100644 --- a/lib/Analysis/PostDominators.cpp +++ b/lib/Analysis/PostDominators.cpp @@ -14,8 +14,8 @@ #include "llvm/Analysis/PostDominators.h" #include "llvm/Instructions.h" #include "llvm/Support/CFG.h" -#include "Support/DepthFirstIterator.h" -#include "Support/SetOperations.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SetOperations.h" using namespace llvm; //===----------------------------------------------------------------------===// diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp index 4ab56ce156..cd3f575355 100644 --- a/lib/Analysis/ProfileInfoLoaderPass.cpp +++ b/lib/Analysis/ProfileInfoLoaderPass.cpp @@ -17,7 +17,7 @@ #include "llvm/Pass.h" #include "llvm/Analysis/ProfileInfo.h" #include "llvm/Analysis/ProfileInfoLoader.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include using namespace llvm; diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index cac3b507ba..efe4d92bff 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -72,8 +72,8 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/InstIterator.h" -#include "Support/CommandLine.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Archive/ArchiveReader.cpp b/lib/Archive/ArchiveReader.cpp index 1d8530fc78..50e11d6ab5 100644 --- a/lib/Archive/ArchiveReader.cpp +++ b/lib/Archive/ArchiveReader.cpp @@ -18,7 +18,7 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Module.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/FileUtilities.h" #include #include using namespace llvm; diff --git a/lib/AsmParser/ParserInternals.h b/lib/AsmParser/ParserInternals.h index 71876a55b4..9fdc8e66f8 100644 --- a/lib/AsmParser/ParserInternals.h +++ b/lib/AsmParser/ParserInternals.h @@ -20,7 +20,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Assembly/Parser.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" // Global variables exported from the lexer... extern std::FILE *llvmAsmin; diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 8ba89bc879..1fd8782dae 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -17,7 +17,7 @@ #include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "llvm/Support/GetElementPtrTypeIterator.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include #include #include diff --git a/lib/Bytecode/Archive/ArchiveReader.cpp b/lib/Bytecode/Archive/ArchiveReader.cpp index 1d8530fc78..50e11d6ab5 100644 --- a/lib/Bytecode/Archive/ArchiveReader.cpp +++ b/lib/Bytecode/Archive/ArchiveReader.cpp @@ -18,7 +18,7 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Module.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/FileUtilities.h" #include #include using namespace llvm; diff --git a/lib/Bytecode/Reader/ArchiveReader.cpp b/lib/Bytecode/Reader/ArchiveReader.cpp index 1d8530fc78..50e11d6ab5 100644 --- a/lib/Bytecode/Reader/ArchiveReader.cpp +++ b/lib/Bytecode/Reader/ArchiveReader.cpp @@ -18,7 +18,7 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Module.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/FileUtilities.h" #include #include using namespace llvm; diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index f0b39d45de..39f238c986 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -24,7 +24,7 @@ #include "llvm/SymbolTable.h" #include "llvm/Bytecode/Format.h" #include "llvm/Support/GetElementPtrTypeIterator.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; @@ -428,14 +428,20 @@ Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) { if (!Create) return 0; // Do not create a placeholder? + // Did we already create a place holder? std::pair KeyValue(type, oNum); ForwardReferenceMap::iterator I = ForwardReferences.lower_bound(KeyValue); if (I != ForwardReferences.end() && I->first == KeyValue) return I->second; // We have already created this placeholder - Value *Val = new Argument(getType(type)); - ForwardReferences.insert(I, std::make_pair(KeyValue, Val)); - return Val; + // If the type exists (it should) + if (const Type* Ty = getType(type)) { + // Create the place holder + Value *Val = new Argument(Ty); + ForwardReferences.insert(I, std::make_pair(KeyValue, Val)); + return Val; + } + throw "Can't create placeholder for value of type slot #" + utostr(type); } /// This is just like getValue, but when a compaction table is in use, it diff --git a/lib/Bytecode/Reader/ReaderWrappers.cpp b/lib/Bytecode/Reader/ReaderWrappers.cpp index 2930a42c63..383e53e9be 100644 --- a/lib/Bytecode/Reader/ReaderWrappers.cpp +++ b/lib/Bytecode/Reader/ReaderWrappers.cpp @@ -17,9 +17,9 @@ #include "Reader.h" #include "llvm/Module.h" #include "llvm/Instructions.h" -#include "Support/FileUtilities.h" -#include "Support/StringExtras.h" -#include "Config/unistd.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Config/unistd.h" #include using namespace llvm; diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 2656edd8a5..d4145dbcdc 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -23,8 +23,8 @@ #include "llvm/SymbolTable.h" #include "llvm/Type.h" #include "llvm/Analysis/ConstantsScanner.h" -#include "Support/PostOrderIterator.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/PostOrderIterator.h" +#include "llvm/ADT/STLExtras.h" #include #include diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 7db2148603..60a48cc265 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -25,8 +25,8 @@ #include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "llvm/Support/GetElementPtrTypeIterator.h" -#include "Support/STLExtras.h" -#include "Support/Statistic.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/Statistic.h" #include #include using namespace llvm; diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h index e496da9ff8..8b5f99e94d 100644 --- a/lib/Bytecode/Writer/WriterInternals.h +++ b/lib/Bytecode/Writer/WriterInternals.h @@ -23,7 +23,7 @@ #include "llvm/Bytecode/Writer.h" #include "llvm/Bytecode/Format.h" #include "llvm/Instruction.h" -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include #include diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index af2b725017..cca9f93553 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -20,7 +20,7 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; namespace { diff --git a/lib/CodeGen/InstrSched/InstrScheduling.cpp b/lib/CodeGen/InstrSched/InstrScheduling.cpp index fc4d6a7164..69ecb90f31 100644 --- a/lib/CodeGen/InstrSched/InstrScheduling.cpp +++ b/lib/CodeGen/InstrSched/InstrScheduling.cpp @@ -20,7 +20,7 @@ #include "../../Target/SparcV9/MachineCodeForInstruction.h" #include "../../Target/SparcV9/LiveVar/FunctionLiveVarInfo.h" #include "../../Target/SparcV9/SparcV9InstrInfo.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include #include diff --git a/lib/CodeGen/InstrSched/SchedGraph.cpp b/lib/CodeGen/InstrSched/SchedGraph.cpp index e3b3cba524..00b48d537d 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.cpp +++ b/lib/CodeGen/InstrSched/SchedGraph.cpp @@ -22,7 +22,7 @@ #include "../../Target/SparcV9/MachineCodeForInstruction.h" #include "../../Target/SparcV9/SparcV9RegInfo.h" #include "../../Target/SparcV9/SparcV9InstrInfo.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include namespace llvm { diff --git a/lib/CodeGen/InstrSched/SchedGraph.h b/lib/CodeGen/InstrSched/SchedGraph.h index e327598bd5..53ded6377d 100644 --- a/lib/CodeGen/InstrSched/SchedGraph.h +++ b/lib/CodeGen/InstrSched/SchedGraph.h @@ -22,8 +22,8 @@ #include "llvm/CodeGen/SchedGraphCommon.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Transforms/Scalar.h" -#include "Support/hash_map" -#include "Support/GraphTraits.h" +#include "llvm/ADT/hash_map" +#include "llvm/ADT/GraphTraits.h" namespace llvm { diff --git a/lib/CodeGen/InstrSched/SchedGraphCommon.cpp b/lib/CodeGen/InstrSched/SchedGraphCommon.cpp index da4492f359..0ad5f5844e 100644 --- a/lib/CodeGen/InstrSched/SchedGraphCommon.cpp +++ b/lib/CodeGen/InstrSched/SchedGraphCommon.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/SchedGraphCommon.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include namespace llvm { diff --git a/lib/CodeGen/InstrSched/SchedPriorities.cpp b/lib/CodeGen/InstrSched/SchedPriorities.cpp index 3c0e0b2c33..0aaece228d 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.cpp +++ b/lib/CodeGen/InstrSched/SchedPriorities.cpp @@ -21,7 +21,7 @@ #include "../../Target/SparcV9/LiveVar/FunctionLiveVarInfo.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Support/CFG.h" -#include "Support/PostOrderIterator.h" +#include "llvm/ADT/PostOrderIterator.h" #include namespace llvm { diff --git a/lib/CodeGen/InstrSched/SchedPriorities.h b/lib/CodeGen/InstrSched/SchedPriorities.h index 7470467806..dd807f788e 100644 --- a/lib/CodeGen/InstrSched/SchedPriorities.h +++ b/lib/CodeGen/InstrSched/SchedPriorities.h @@ -23,7 +23,7 @@ #include "SchedGraph.h" #include "llvm/CodeGen/InstrScheduling.h" #include "llvm/Target/TargetSchedInfo.h" -#include "Support/hash_set" +#include "llvm/ADT/hash_set" #include namespace llvm { diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index 6bd441f643..d63cfc60fb 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -19,7 +19,7 @@ //===----------------------------------------------------------------------===// #include "LiveInterval.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include #include using namespace llvm; diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index 3c234bbd0e..95ed508fcb 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -27,10 +27,10 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include "VirtRegMap.h" #include diff --git a/lib/CodeGen/LiveVariables.cpp b/lib/CodeGen/LiveVariables.cpp index 630477d7b6..825b56d784 100644 --- a/lib/CodeGen/LiveVariables.cpp +++ b/lib/CodeGen/LiveVariables.cpp @@ -31,8 +31,8 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/DepthFirstIterator.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; static RegisterAnalysis X("livevars", "Live Variable Analysis"); diff --git a/lib/CodeGen/MachineBasicBlock.cpp b/lib/CodeGen/MachineBasicBlock.cpp index 20390a2f50..f018f9f01f 100644 --- a/lib/CodeGen/MachineBasicBlock.cpp +++ b/lib/CodeGen/MachineBasicBlock.cpp @@ -17,7 +17,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" #include using namespace llvm; diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 3478e30e1f..e38e00603a 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -23,8 +23,8 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Function.h" #include "llvm/Instructions.h" -#include "Support/LeakDetector.h" -#include "Support/GraphWriter.h" +#include "llvm/Support/LeakDetector.h" +#include "llvm/Support/GraphWriter.h" #include #include #include diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 7c5a61ecd1..a4ae09a649 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -20,7 +20,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/MRegisterInfo.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" #include using namespace llvm; diff --git a/lib/CodeGen/ModuloScheduling/MSSchedule.cpp b/lib/CodeGen/ModuloScheduling/MSSchedule.cpp index c57cb5a3bd..b8bbccf8be 100644 --- a/lib/CodeGen/ModuloScheduling/MSSchedule.cpp +++ b/lib/CodeGen/ModuloScheduling/MSSchedule.cpp @@ -13,7 +13,7 @@ #define DEBUG_TYPE "ModuloSched" #include "MSSchedule.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include "llvm/Target/TargetSchedInfo.h" using namespace llvm; diff --git a/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp b/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp index 6bee44d934..5bdcc9afcf 100644 --- a/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp +++ b/lib/CodeGen/ModuloScheduling/MSchedGraph.cpp @@ -16,7 +16,7 @@ #include "../../Target/SparcV9/SparcV9RegisterInfo.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Target/TargetInstrInfo.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include using namespace llvm; diff --git a/lib/CodeGen/ModuloScheduling/MSchedGraph.h b/lib/CodeGen/ModuloScheduling/MSchedGraph.h index 0dcbb496f1..4ea572a380 100644 --- a/lib/CodeGen/ModuloScheduling/MSchedGraph.h +++ b/lib/CodeGen/ModuloScheduling/MSchedGraph.h @@ -16,9 +16,9 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" -#include "Support/GraphTraits.h" -#include "Support/STLExtras.h" -#include "Support/iterator" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/iterator" #include namespace llvm { diff --git a/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp b/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp index dadc38570c..9ad1e4ce4b 100644 --- a/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp +++ b/lib/CodeGen/ModuloScheduling/ModuloScheduling.cpp @@ -21,9 +21,9 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/Support/CFG.h" #include "llvm/Target/TargetSchedInfo.h" -#include "Support/Debug.h" -#include "Support/GraphWriter.h" -#include "Support/StringExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/GraphWriter.h" +#include "llvm/ADT/StringExtras.h" #include #include #include diff --git a/lib/CodeGen/PHIElimination.cpp b/lib/CodeGen/PHIElimination.cpp index 4df9a92bb4..0010ccd7e6 100644 --- a/lib/CodeGen/PHIElimination.cpp +++ b/lib/CodeGen/PHIElimination.cpp @@ -20,8 +20,8 @@ #include "llvm/CodeGen/LiveVariables.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/DenseMap.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; namespace { diff --git a/lib/CodeGen/Passes.cpp b/lib/CodeGen/Passes.cpp index 7233e81473..4d2f111b2e 100644 --- a/lib/CodeGen/Passes.cpp +++ b/lib/CodeGen/Passes.cpp @@ -13,7 +13,7 @@ //===---------------------------------------------------------------------===// #include "llvm/CodeGen/Passes.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include using namespace llvm; diff --git a/lib/CodeGen/RegAllocIterativeScan.cpp b/lib/CodeGen/RegAllocIterativeScan.cpp index ffeb68d9dd..26fa7b7655 100644 --- a/lib/CodeGen/RegAllocIterativeScan.cpp +++ b/lib/CodeGen/RegAllocIterativeScan.cpp @@ -25,9 +25,9 @@ #include "llvm/CodeGen/SSARegMap.h" #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include "LiveIntervalAnalysis.h" #include "PhysRegTracker.h" #include "VirtRegMap.h" diff --git a/lib/CodeGen/RegAllocLinearScan.cpp b/lib/CodeGen/RegAllocLinearScan.cpp index 181f061986..8736a23675 100644 --- a/lib/CodeGen/RegAllocLinearScan.cpp +++ b/lib/CodeGen/RegAllocLinearScan.cpp @@ -19,9 +19,9 @@ #include "llvm/CodeGen/SSARegMap.h" #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include "LiveIntervalAnalysis.h" #include "PhysRegTracker.h" #include "VirtRegMap.h" diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp index 482325fbff..2cf8e6327e 100644 --- a/lib/CodeGen/RegAllocLocal.cpp +++ b/lib/CodeGen/RegAllocLocal.cpp @@ -21,10 +21,10 @@ #include "llvm/CodeGen/LiveVariables.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/DenseMap.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/CodeGen/RegAllocSimple.cpp b/lib/CodeGen/RegAllocSimple.cpp index 6f6c2c6352..ba05bd3830 100644 --- a/lib/CodeGen/RegAllocSimple.cpp +++ b/lib/CodeGen/RegAllocSimple.cpp @@ -22,9 +22,9 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; namespace { diff --git a/lib/CodeGen/TwoAddressInstructionPass.cpp b/lib/CodeGen/TwoAddressInstructionPass.cpp index 0268d4b01a..e3e79f01f5 100644 --- a/lib/CodeGen/TwoAddressInstructionPass.cpp +++ b/lib/CodeGen/TwoAddressInstructionPass.cpp @@ -37,9 +37,9 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; namespace { diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp index 27355ec6d3..0bde9ff23a 100644 --- a/lib/CodeGen/UnreachableBlockElim.cpp +++ b/lib/CodeGen/UnreachableBlockElim.cpp @@ -26,7 +26,7 @@ #include "llvm/Function.h" #include "llvm/Pass.h" #include "llvm/Support/CFG.h" -#include "Support/DepthFirstIterator.h" +#include "llvm/ADT/DepthFirstIterator.h" using namespace llvm; namespace { diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index c235aada9f..cffe77c518 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/lib/CodeGen/VirtRegMap.cpp @@ -22,11 +22,11 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/DenseMap.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; diff --git a/lib/CodeGen/VirtRegMap.h b/lib/CodeGen/VirtRegMap.h index c76a222341..fb694d5e1a 100644 --- a/lib/CodeGen/VirtRegMap.h +++ b/lib/CodeGen/VirtRegMap.h @@ -20,7 +20,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/SSARegMap.h" -#include "Support/DenseMap.h" +#include "llvm/ADT/DenseMap.h" #include #include diff --git a/lib/Debugger/Debugger.cpp b/lib/Debugger/Debugger.cpp index 02c4a8a491..76cdfa2014 100644 --- a/lib/Debugger/Debugger.cpp +++ b/lib/Debugger/Debugger.cpp @@ -16,7 +16,7 @@ #include "llvm/ModuleProvider.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Debugger/InferiorProcess.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" using namespace llvm; /// Debugger constructor - Initialize the debugger to its initial, empty, state. diff --git a/lib/Debugger/ProgramInfo.cpp b/lib/Debugger/ProgramInfo.cpp index 8bb8738c65..d6a4532b4f 100644 --- a/lib/Debugger/ProgramInfo.cpp +++ b/lib/Debugger/ProgramInfo.cpp @@ -20,9 +20,9 @@ #include "llvm/Module.h" #include "llvm/Debugger/SourceFile.h" #include "llvm/Debugger/SourceLanguage.h" -#include "Support/FileUtilities.h" -#include "Support/SlowOperationInformer.h" -#include "Support/STLExtras.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/SlowOperationInformer.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; diff --git a/lib/Debugger/SourceFile.cpp b/lib/Debugger/SourceFile.cpp index 2eb3b5750b..f0bd0d8a22 100644 --- a/lib/Debugger/SourceFile.cpp +++ b/lib/Debugger/SourceFile.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Debugger/SourceFile.h" -#include "Support/SlowOperationInformer.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/SlowOperationInformer.h" +#include "llvm/Support/FileUtilities.h" #include #include #include diff --git a/lib/Debugger/UnixLocalInferiorProcess.cpp b/lib/Debugger/UnixLocalInferiorProcess.cpp index 1cacb534a2..437b21864e 100644 --- a/lib/Debugger/UnixLocalInferiorProcess.cpp +++ b/lib/Debugger/UnixLocalInferiorProcess.cpp @@ -32,8 +32,8 @@ #include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" -#include "Support/FileUtilities.h" -#include "Support/StringExtras.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/ADT/StringExtras.h" #include #include #include // Unix-specific debugger support diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index 105c0b8a1d..b239cc2a53 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -23,9 +23,9 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Target/TargetData.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/DynamicLinker.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/DynamicLinker.h" using namespace llvm; namespace { diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 705fc16db8..5e1ae0629f 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -18,8 +18,8 @@ #include "llvm/Instructions.h" #include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/Support/GetElementPtrTypeIterator.h" -#include "Support/Statistic.h" -#include "Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Debug.h" #include // For fmod using namespace llvm; diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 83da7551b0..def406a4b7 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -23,7 +23,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Module.h" #include "llvm/Target/TargetData.h" -#include "Support/DynamicLinker.h" +#include "llvm/Support/DynamicLinker.h" #include #include #include diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h index 99e417c4a8..d6e590d735 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -20,7 +20,7 @@ #include "llvm/Support/InstVisitor.h" #include "llvm/Support/CallSite.h" #include "llvm/Target/TargetData.h" -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" #include namespace llvm { diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp index 8ed9447159..2eafb75cd0 100644 --- a/lib/ExecutionEngine/JIT/Intercept.cpp +++ b/lib/ExecutionEngine/JIT/Intercept.cpp @@ -16,7 +16,7 @@ //===----------------------------------------------------------------------===// #include "JIT.h" -#include "Support/DynamicLinker.h" +#include "llvm/Support/DynamicLinker.h" #include #include using namespace llvm; diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 675ef479d1..311ec4b47d 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -24,7 +24,7 @@ #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetJITInfo.h" -#include "Support/DynamicLinker.h" +#include "llvm/Support/DynamicLinker.h" #include using namespace llvm; diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 7065c56a46..5758ebc432 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -20,9 +20,9 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/Target/TargetData.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/SystemUtils.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/SystemUtils.h" using namespace llvm; namespace { diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index fcaa7af3d5..fa9ec70306 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -21,11 +21,11 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Support/Linker.h" -#include "Config/config.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Config/config.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/System/Signals.h" -#include "Support/SystemUtils.h" +#include "llvm/Support/SystemUtils.h" #include #include #include diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp index 45fd06f92e..c8cf8298b4 100644 --- a/lib/Support/Annotation.cpp +++ b/lib/Support/Annotation.cpp @@ -12,7 +12,7 @@ //===----------------------------------------------------------------------===// #include -#include "Support/Annotation.h" +#include "llvm/Support/Annotation.h" using namespace llvm; Annotation::~Annotation() {} // Designed to be subclassed diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 3bc9cbf1ca..d60b464dd5 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -16,8 +16,8 @@ // //===----------------------------------------------------------------------===// -#include "Config/config.h" -#include "Support/CommandLine.h" +#include "llvm/Config/config.h" +#include "llvm/Support/CommandLine.h" #include #include #include diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index f171342949..a58716763a 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -23,8 +23,8 @@ // //===----------------------------------------------------------------------===// -#include "Support/Debug.h" -#include "Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; bool llvm::DebugFlag; // DebugFlag - Exported boolean set by the -debug option diff --git a/lib/Support/DynamicLinker.cpp b/lib/Support/DynamicLinker.cpp index 4ac58c1bbc..a6593034c7 100644 --- a/lib/Support/DynamicLinker.cpp +++ b/lib/Support/DynamicLinker.cpp @@ -18,9 +18,9 @@ // //===----------------------------------------------------------------------===// -#include "Support/DynamicLinker.h" -#include "Config/dlfcn.h" -#include "Config/windows.h" +#include "llvm/Support/DynamicLinker.h" +#include "llvm/Config/dlfcn.h" +#include "llvm/Config/windows.h" #include #include using namespace llvm; diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 09542c3fab..6829f155b8 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -12,14 +12,14 @@ // //===----------------------------------------------------------------------===// -#include "Support/FileUtilities.h" -#include "Support/DataTypes.h" -#include "Config/unistd.h" -#include "Config/fcntl.h" -#include "Config/sys/types.h" -#include "Config/sys/stat.h" -#include "Config/sys/mman.h" -#include "Config/alloca.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/DataTypes.h" +#include "llvm/Config/unistd.h" +#include "llvm/Config/fcntl.h" +#include "llvm/Config/sys/types.h" +#include "llvm/Config/sys/stat.h" +#include "llvm/Config/sys/mman.h" +#include "llvm/Config/alloca.h" #include #include #include diff --git a/lib/Support/IsInf.cpp b/lib/Support/IsInf.cpp index 7fd857e931..c50eadff17 100644 --- a/lib/Support/IsInf.cpp +++ b/lib/Support/IsInf.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "Config/config.h" +#include "llvm/Config/config.h" #if HAVE_ISINF_IN_MATH_H # include #elif HAVE_ISINF_IN_CMATH diff --git a/lib/Support/IsNAN.cpp b/lib/Support/IsNAN.cpp index ade6bf1dc8..75c813f41a 100644 --- a/lib/Support/IsNAN.cpp +++ b/lib/Support/IsNAN.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "Config/config.h" +#include "llvm/Config/config.h" #if HAVE_ISNAN_IN_MATH_H # include #elif HAVE_ISNAN_IN_CMATH diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index cbec6fa7d4..2c13d57812 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #define DONT_GET_PLUGIN_LOADER_OPTION -#include "Support/PluginLoader.h" -#include "Support/DynamicLinker.h" +#include "llvm/Support/PluginLoader.h" +#include "llvm/Support/DynamicLinker.h" #include using namespace llvm; diff --git a/lib/Support/SlowOperationInformer.cpp b/lib/Support/SlowOperationInformer.cpp index c245f3655c..43faaadaae 100644 --- a/lib/Support/SlowOperationInformer.cpp +++ b/lib/Support/SlowOperationInformer.cpp @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#include "Support/SlowOperationInformer.h" -#include "Config/config.h" // Get the signal handler return type +#include "llvm/Support/SlowOperationInformer.h" +#include "llvm/Config/config.h" // Get the signal handler return type #include #include #include diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index 7fa7547fee..f4d9c7b9e2 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -21,8 +21,8 @@ // //===----------------------------------------------------------------------===// -#include "Support/Statistic.h" -#include "Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/CommandLine.h" #include #include #include diff --git a/lib/Support/StringExtras.cpp b/lib/Support/StringExtras.cpp index 011ce280f0..e8d423a74d 100644 --- a/lib/Support/StringExtras.cpp +++ b/lib/Support/StringExtras.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" using namespace llvm; /// getToken - This function extracts one token from source, ignoring any diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index b831f4096d..3b529df79c 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -13,15 +13,15 @@ //===----------------------------------------------------------------------===// #define _POSIX_MAPPED_FILES -#include "Support/SystemUtils.h" -#include "Config/fcntl.h" -#include "Config/pagesize.h" -#include "Config/unistd.h" -#include "Config/windows.h" -#include "Config/sys/mman.h" -#include "Config/sys/stat.h" -#include "Config/sys/types.h" -#include "Config/sys/wait.h" +#include "llvm/Support/SystemUtils.h" +#include "llvm/Config/fcntl.h" +#include "llvm/Config/pagesize.h" +#include "llvm/Config/unistd.h" +#include "llvm/Config/windows.h" +#include "llvm/Config/sys/mman.h" +#include "llvm/Config/sys/stat.h" +#include "llvm/Config/sys/types.h" +#include "llvm/Config/sys/wait.h" #include #include #include diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 52b616fa2c..ff3fd6fefe 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -11,18 +11,18 @@ // //===----------------------------------------------------------------------===// -#include "Support/Timer.h" -#include "Support/CommandLine.h" +#include "llvm/Support/Timer.h" +#include "llvm/Support/CommandLine.h" #include #include #include #include #include -#include "Config/sys/resource.h" -#include "Config/sys/time.h" -#include "Config/unistd.h" -#include "Config/malloc.h" -#include "Config/windows.h" +#include "llvm/Config/sys/resource.h" +#include "llvm/Config/sys/time.h" +#include "llvm/Config/unistd.h" +#include "llvm/Config/malloc.h" +#include "llvm/Config/windows.h" using namespace llvm; // GetLibSupportInfoOutputFile - Return a file stream to print our output on. diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index b694127e07..3dc98451de 100644 --- a/lib/Support/ToolRunner.cpp +++ b/lib/Support/ToolRunner.cpp @@ -13,9 +13,9 @@ #define DEBUG_TYPE "toolrunner" #include "llvm/Support/ToolRunner.h" -#include "Config/config.h" // for HAVE_LINK_R -#include "Support/Debug.h" -#include "Support/FileUtilities.h" +#include "llvm/Config/config.h" // for HAVE_LINK_R +#include "llvm/Support/Debug.h" +#include "llvm/Support/FileUtilities.h" #include #include using namespace llvm; diff --git a/lib/System/Unix/Path.cpp b/lib/System/Unix/Path.cpp index 9a860a0672..49b2bf4afe 100644 --- a/lib/System/Unix/Path.cpp +++ b/lib/System/Unix/Path.cpp @@ -16,10 +16,10 @@ //=== is guaranteed to work on *all* UNIX variants. //===----------------------------------------------------------------------===// +#include #include "Unix.h" #include #include -#include namespace llvm { using namespace sys; diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc index 9a860a0672..49b2bf4afe 100644 --- a/lib/System/Unix/Path.inc +++ b/lib/System/Unix/Path.inc @@ -16,10 +16,10 @@ //=== is guaranteed to work on *all* UNIX variants. //===----------------------------------------------------------------------===// +#include #include "Unix.h" #include #include -#include namespace llvm { using namespace sys; diff --git a/lib/System/Unix/Program.cpp b/lib/System/Unix/Program.cpp index ca8514dfa6..b8ef55925d 100644 --- a/lib/System/Unix/Program.cpp +++ b/lib/System/Unix/Program.cpp @@ -16,10 +16,10 @@ //=== is guaranteed to work on *all* UNIX variants. //===----------------------------------------------------------------------===// +#include #include "Unix.h" #include #include -#include #ifdef HAVE_SYS_WAIT_H #include #endif diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index ca8514dfa6..b8ef55925d 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -16,10 +16,10 @@ //=== is guaranteed to work on *all* UNIX variants. //===----------------------------------------------------------------------===// +#include #include "Unix.h" #include #include -#include #ifdef HAVE_SYS_WAIT_H #include #endif diff --git a/lib/System/Unix/Unix.h b/lib/System/Unix/Unix.h index aa6bfb1a78..b9eff46c46 100644 --- a/lib/System/Unix/Unix.h +++ b/lib/System/Unix/Unix.h @@ -16,7 +16,7 @@ //=== is guaranteed to work on all UNIX variants. //===----------------------------------------------------------------------===// -#include "Config/config.h" // Get autoconf configuration settings +#include "llvm/Config/config.h" // Get autoconf configuration settings #include #include #include diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index b8208d4a4c..45a771f9df 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -32,9 +32,9 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Support/Mangler.h" -#include "Support/StringExtras.h" -#include "Support/MathExtras.h" -#include "Config/config.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Config/config.h" #include #include #include diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index b8208d4a4c..45a771f9df 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -32,9 +32,9 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Support/Mangler.h" -#include "Support/StringExtras.h" -#include "Support/MathExtras.h" -#include "Config/config.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Config/config.h" #include #include #include diff --git a/lib/Target/PowerPC/PPC32AsmPrinter.cpp b/lib/Target/PowerPC/PPC32AsmPrinter.cpp index 2358f1608a..b30977b1a1 100644 --- a/lib/Target/PowerPC/PPC32AsmPrinter.cpp +++ b/lib/Target/PowerPC/PPC32AsmPrinter.cpp @@ -29,10 +29,10 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Support/Mangler.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/StringExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; diff --git a/lib/Target/PowerPC/PPC32ISelSimple.cpp b/lib/Target/PowerPC/PPC32ISelSimple.cpp index 923e8d57bc..5ba7a5beeb 100644 --- a/lib/Target/PowerPC/PPC32ISelSimple.cpp +++ b/lib/Target/PowerPC/PPC32ISelSimple.cpp @@ -26,8 +26,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Target/PowerPC/PPC64AsmPrinter.cpp b/lib/Target/PowerPC/PPC64AsmPrinter.cpp index 74aaad5b15..972fa01bb9 100644 --- a/lib/Target/PowerPC/PPC64AsmPrinter.cpp +++ b/lib/Target/PowerPC/PPC64AsmPrinter.cpp @@ -25,11 +25,11 @@ #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Support/Mangler.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/MathExtras.h" -#include "Support/Statistic.h" -#include "Support/StringExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" #include namespace llvm { diff --git a/lib/Target/PowerPC/PPC64ISelSimple.cpp b/lib/Target/PowerPC/PPC64ISelSimple.cpp index 637e8565b2..107266ed62 100644 --- a/lib/Target/PowerPC/PPC64ISelSimple.cpp +++ b/lib/Target/PowerPC/PPC64ISelSimple.cpp @@ -26,8 +26,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Target/PowerPC/PPC64RegisterInfo.cpp b/lib/Target/PowerPC/PPC64RegisterInfo.cpp index 774e661e62..1871c2e315 100644 --- a/lib/Target/PowerPC/PPC64RegisterInfo.cpp +++ b/lib/Target/PowerPC/PPC64RegisterInfo.cpp @@ -24,9 +24,9 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/STLExtras.h" #include #include using namespace llvm; diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index 2358f1608a..b30977b1a1 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -29,10 +29,10 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Support/Mangler.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/StringExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; diff --git a/lib/Target/PowerPC/PPCBranchSelector.cpp b/lib/Target/PowerPC/PPCBranchSelector.cpp index e2456c9320..6f7b597da3 100644 --- a/lib/Target/PowerPC/PPCBranchSelector.cpp +++ b/lib/Target/PowerPC/PPCBranchSelector.cpp @@ -22,7 +22,7 @@ #include "PPC32InstrInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineFunction.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include using namespace llvm; diff --git a/lib/Target/PowerPC/PPCCodeEmitter.cpp b/lib/Target/PowerPC/PPCCodeEmitter.cpp index b8eb6b6714..b08ce92d99 100644 --- a/lib/Target/PowerPC/PPCCodeEmitter.cpp +++ b/lib/Target/PowerPC/PPCCodeEmitter.cpp @@ -15,7 +15,7 @@ #include "llvm/CodeGen/MachineCodeEmitter.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/Passes.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" namespace llvm { diff --git a/lib/Target/PowerPC/PPCRegisterInfo.cpp b/lib/Target/PowerPC/PPCRegisterInfo.cpp index bebb868841..321a44939b 100644 --- a/lib/Target/PowerPC/PPCRegisterInfo.cpp +++ b/lib/Target/PowerPC/PPCRegisterInfo.cpp @@ -24,9 +24,9 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/STLExtras.h" #include #include using namespace llvm; diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index fa2455cc87..f9f1cb4a53 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -25,7 +25,7 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include using namespace llvm; diff --git a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp index fc4d6a7164..69ecb90f31 100644 --- a/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp +++ b/lib/Target/SparcV9/InstrSched/InstrScheduling.cpp @@ -20,7 +20,7 @@ #include "../../Target/SparcV9/MachineCodeForInstruction.h" #include "../../Target/SparcV9/LiveVar/FunctionLiveVarInfo.h" #include "../../Target/SparcV9/SparcV9InstrInfo.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include #include diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp index e3b3cba524..00b48d537d 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.cpp @@ -22,7 +22,7 @@ #include "../../Target/SparcV9/MachineCodeForInstruction.h" #include "../../Target/SparcV9/SparcV9RegInfo.h" #include "../../Target/SparcV9/SparcV9InstrInfo.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include namespace llvm { diff --git a/lib/Target/SparcV9/InstrSched/SchedGraph.h b/lib/Target/SparcV9/InstrSched/SchedGraph.h index e327598bd5..53ded6377d 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraph.h +++ b/lib/Target/SparcV9/InstrSched/SchedGraph.h @@ -22,8 +22,8 @@ #include "llvm/CodeGen/SchedGraphCommon.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Transforms/Scalar.h" -#include "Support/hash_map" -#include "Support/GraphTraits.h" +#include "llvm/ADT/hash_map" +#include "llvm/ADT/GraphTraits.h" namespace llvm { diff --git a/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp b/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp index da4492f359..0ad5f5844e 100644 --- a/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedGraphCommon.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/SchedGraphCommon.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include namespace llvm { diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp index 3c0e0b2c33..0aaece228d 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.cpp @@ -21,7 +21,7 @@ #include "../../Target/SparcV9/LiveVar/FunctionLiveVarInfo.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Support/CFG.h" -#include "Support/PostOrderIterator.h" +#include "llvm/ADT/PostOrderIterator.h" #include namespace llvm { diff --git a/lib/Target/SparcV9/InstrSched/SchedPriorities.h b/lib/Target/SparcV9/InstrSched/SchedPriorities.h index 7470467806..dd807f788e 100644 --- a/lib/Target/SparcV9/InstrSched/SchedPriorities.h +++ b/lib/Target/SparcV9/InstrSched/SchedPriorities.h @@ -23,7 +23,7 @@ #include "SchedGraph.h" #include "llvm/CodeGen/InstrScheduling.h" #include "llvm/Target/TargetSchedInfo.h" -#include "Support/hash_set" +#include "llvm/ADT/hash_set" #include namespace llvm { diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp index 09f5954269..785054c9f2 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.cpp @@ -16,7 +16,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Support/CFG.h" -#include "Support/SetOperations.h" +#include "llvm/ADT/SetOperations.h" #include "../SparcV9Internals.h" #include diff --git a/lib/Target/SparcV9/LiveVar/BBLiveVar.h b/lib/Target/SparcV9/LiveVar/BBLiveVar.h index 7e5c72e3e4..e8486acf07 100644 --- a/lib/Target/SparcV9/LiveVar/BBLiveVar.h +++ b/lib/Target/SparcV9/LiveVar/BBLiveVar.h @@ -16,7 +16,7 @@ #define LIVE_VAR_BB_H #include "llvm/CodeGen/ValueSet.h" -#include "Support/hash_map" +#include "llvm/ADT/hash_map" namespace llvm { diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp index 4a8ada9123..2883bf1c09 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.cpp @@ -18,9 +18,9 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Support/CFG.h" -#include "Support/PostOrderIterator.h" -#include "Support/SetOperations.h" -#include "Support/CommandLine.h" +#include "llvm/ADT/PostOrderIterator.h" +#include "llvm/ADT/SetOperations.h" +#include "llvm/Support/CommandLine.h" #include "BBLiveVar.h" #include diff --git a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.h b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.h index 23a9d93a6e..02d5c0531b 100644 --- a/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.h +++ b/lib/Target/SparcV9/LiveVar/FunctionLiveVarInfo.h @@ -35,7 +35,7 @@ #ifndef FUNCTION_LIVE_VAR_INFO_H #define FUNCTION_LIVE_VAR_INFO_H -#include "Support/hash_map" +#include "llvm/ADT/hash_map" #include "llvm/Pass.h" #include "llvm/CodeGen/ValueSet.h" diff --git a/lib/Target/SparcV9/MachineFunctionInfo.h b/lib/Target/SparcV9/MachineFunctionInfo.h index 70bbccded5..3596bc2fa1 100644 --- a/lib/Target/SparcV9/MachineFunctionInfo.h +++ b/lib/Target/SparcV9/MachineFunctionInfo.h @@ -20,8 +20,8 @@ #include "MachineCodeForInstruction.h" #include "llvm/CodeGen/MachineFunction.h" -#include "Support/HashExtras.h" -#include "Support/hash_set" +#include "llvm/ADT/HashExtras.h" +#include "llvm/ADT/hash_set" namespace llvm { diff --git a/lib/Target/SparcV9/MappingInfo.cpp b/lib/Target/SparcV9/MappingInfo.cpp index e8c7581ed7..1a7212c9c0 100644 --- a/lib/Target/SparcV9/MappingInfo.cpp +++ b/lib/Target/SparcV9/MappingInfo.cpp @@ -47,7 +47,7 @@ #include "llvm/Module.h" #include "llvm/CodeGen/MachineFunction.h" #include "MachineCodeForInstruction.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" namespace llvm { diff --git a/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp b/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp index c57cb5a3bd..b8bbccf8be 100644 --- a/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp +++ b/lib/Target/SparcV9/ModuloScheduling/MSSchedule.cpp @@ -13,7 +13,7 @@ #define DEBUG_TYPE "ModuloSched" #include "MSSchedule.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include "llvm/Target/TargetSchedInfo.h" using namespace llvm; diff --git a/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp b/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp index 6bee44d934..5bdcc9afcf 100644 --- a/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp +++ b/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp @@ -16,7 +16,7 @@ #include "../../Target/SparcV9/SparcV9RegisterInfo.h" #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/Target/TargetInstrInfo.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include using namespace llvm; diff --git a/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h b/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h index 0dcbb496f1..4ea572a380 100644 --- a/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h +++ b/lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h @@ -16,9 +16,9 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" -#include "Support/GraphTraits.h" -#include "Support/STLExtras.h" -#include "Support/iterator" +#include "llvm/ADT/GraphTraits.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/iterator" #include namespace llvm { diff --git a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp index dadc38570c..9ad1e4ce4b 100644 --- a/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp +++ b/lib/Target/SparcV9/ModuloScheduling/ModuloScheduling.cpp @@ -21,9 +21,9 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/Support/CFG.h" #include "llvm/Target/TargetSchedInfo.h" -#include "Support/Debug.h" -#include "Support/GraphWriter.h" -#include "Support/StringExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/GraphWriter.h" +#include "llvm/ADT/StringExtras.h" #include #include #include diff --git a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp index 9344e63f69..3f57eccd89 100644 --- a/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp +++ b/lib/Target/SparcV9/RegAlloc/InterferenceGraph.cpp @@ -14,7 +14,7 @@ #include "IGNode.h" #include "InterferenceGraph.h" #include "RegAllocCommon.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include #include diff --git a/lib/Target/SparcV9/RegAlloc/LiveRange.h b/lib/Target/SparcV9/RegAlloc/LiveRange.h index 7a37596af0..503eddac7f 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRange.h +++ b/lib/Target/SparcV9/RegAlloc/LiveRange.h @@ -16,7 +16,7 @@ #define LIVERANGE_H #include "llvm/Value.h" -#include "Support/SetVector.h" +#include "llvm/ADT/SetVector.h" #include namespace llvm { diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp index b2b49d5465..190e0c57af 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.cpp @@ -21,7 +21,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetInstrInfo.h" #include "../SparcV9RegInfo.h" -#include "Support/SetOperations.h" +#include "llvm/ADT/SetOperations.h" #include namespace llvm { diff --git a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h index 89a169ea93..a656914605 100644 --- a/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h +++ b/lib/Target/SparcV9/RegAlloc/LiveRangeInfo.h @@ -27,7 +27,7 @@ #define LIVERANGEINFO_H #include "llvm/CodeGen/ValueSet.h" -#include "Support/hash_map" +#include "llvm/ADT/hash_map" namespace llvm { diff --git a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp index bbbaee8822..6a1710ef54 100644 --- a/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp +++ b/lib/Target/SparcV9/RegAlloc/PhyRegAlloc.cpp @@ -43,9 +43,9 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/Support/InstIterator.h" #include "llvm/Target/TargetInstrInfo.h" -#include "Support/CommandLine.h" -#include "Support/SetOperations.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/SetOperations.h" +#include "llvm/ADT/STLExtras.h" #include #include diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 36deae09d8..dbfc1e1e0c 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp @@ -28,8 +28,8 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Support/Mangler.h" -#include "Support/StringExtras.h" -#include "Support/Statistic.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/Statistic.h" #include "SparcV9Internals.h" #include "MachineFunctionInfo.h" #include diff --git a/lib/Target/SparcV9/SparcV9BurgISel.cpp b/lib/Target/SparcV9/SparcV9BurgISel.cpp index 0b4685c3a4..1d4dbbd2bf 100644 --- a/lib/Target/SparcV9/SparcV9BurgISel.cpp +++ b/lib/Target/SparcV9/SparcV9BurgISel.cpp @@ -37,12 +37,12 @@ #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Type.h" -#include "Config/alloca.h" -#include "Support/CommandLine.h" -#include "Support/LeakDetector.h" -#include "Support/MathExtras.h" -#include "Support/STLExtras.h" -#include "Support/hash_map" +#include "llvm/Config/alloca.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/LeakDetector.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/hash_map" #include #include #include diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp index e870a15e86..b46d07eb7b 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp @@ -30,15 +30,15 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetData.h" -#include "Support/Debug.h" -#include "Support/hash_set" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/hash_set" +#include "llvm/ADT/Statistic.h" #include "SparcV9Internals.h" #include "SparcV9TargetMachine.h" #include "SparcV9RegInfo.h" #include "SparcV9CodeEmitter.h" #include "MachineFunctionInfo.h" -#include "Config/alloca.h" +#include "llvm/Config/alloca.h" namespace llvm { diff --git a/lib/Target/SparcV9/SparcV9Internals.h b/lib/Target/SparcV9/SparcV9Internals.h index 3ac696401f..187d984a47 100644 --- a/lib/Target/SparcV9/SparcV9Internals.h +++ b/lib/Target/SparcV9/SparcV9Internals.h @@ -22,7 +22,7 @@ #include "SparcV9RegInfo.h" #include "llvm/Type.h" #include "SparcV9RegClassInfo.h" -#include "Config/sys/types.h" +#include "llvm/Config/sys/types.h" namespace llvm { diff --git a/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp b/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp index 0b7baabb8d..778ced2532 100644 --- a/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp +++ b/lib/Target/SparcV9/SparcV9PeepholeOpts.cpp @@ -19,7 +19,7 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" namespace llvm { diff --git a/lib/Target/SparcV9/SparcV9RegInfo.h b/lib/Target/SparcV9/SparcV9RegInfo.h index 6f0ef04ae3..25a09616d0 100644 --- a/lib/Target/SparcV9/SparcV9RegInfo.h +++ b/lib/Target/SparcV9/SparcV9RegInfo.h @@ -15,7 +15,7 @@ #ifndef SPARCV9REGINFO_H #define SPARCV9REGINFO_H -#include "Support/hash_map" +#include "llvm/ADT/hash_map" #include #include diff --git a/lib/Target/SparcV9/SparcV9TargetMachine.cpp b/lib/Target/SparcV9/SparcV9TargetMachine.cpp index 29a208c68c..1019c5619f 100644 --- a/lib/Target/SparcV9/SparcV9TargetMachine.cpp +++ b/lib/Target/SparcV9/SparcV9TargetMachine.cpp @@ -29,7 +29,7 @@ #include "SparcV9Internals.h" #include "SparcV9TargetMachine.h" #include "SparcV9BurgISel.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */ diff --git a/lib/Target/SparcV9/SparcV9TmpInstr.cpp b/lib/Target/SparcV9/SparcV9TmpInstr.cpp index 605cf06189..6e53cbc3c3 100644 --- a/lib/Target/SparcV9/SparcV9TmpInstr.cpp +++ b/lib/Target/SparcV9/SparcV9TmpInstr.cpp @@ -13,7 +13,7 @@ //===----------------------------------------------------------------------===// #include "SparcV9TmpInstr.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" namespace llvm { diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 22dde60d8f..a57d6ba2fb 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -21,7 +21,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" #include "llvm/Support/GetElementPtrTypeIterator.h" -#include "Support/MathExtras.h" +#include "llvm/Support/MathExtras.h" using namespace llvm; // Handle the Pass registration stuff necessary to use TargetData's. diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index ee8ef2e5ed..973165f186 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -14,7 +14,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Type.h" #include "llvm/CodeGen/IntrinsicLowering.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; //--------------------------------------------------------------------------- diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index a0f046b62f..915ac3afd2 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.cpp @@ -29,9 +29,9 @@ #include "llvm/CodeGen/ValueTypes.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Mangler.h" -#include "Support/Statistic.h" -#include "Support/StringExtras.h" -#include "Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; namespace { diff --git a/lib/Target/X86/X86CodeEmitter.cpp b/lib/Target/X86/X86CodeEmitter.cpp index 98e3bb4912..69ab9ca928 100644 --- a/lib/Target/X86/X86CodeEmitter.cpp +++ b/lib/Target/X86/X86CodeEmitter.cpp @@ -21,9 +21,9 @@ #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Function.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Config/alloca.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Config/alloca.h" using namespace llvm; namespace { diff --git a/lib/Target/X86/X86FloatingPoint.cpp b/lib/Target/X86/X86FloatingPoint.cpp index 8d7a8e72cc..30763f0b98 100644 --- a/lib/Target/X86/X86FloatingPoint.cpp +++ b/lib/Target/X86/X86FloatingPoint.cpp @@ -37,10 +37,10 @@ #include "llvm/CodeGen/Passes.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/Debug.h" -#include "Support/DepthFirstIterator.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include #include using namespace llvm; diff --git a/lib/Target/X86/X86ISelSimple.cpp b/lib/Target/X86/X86ISelSimple.cpp index 19c61080db..e9dbc4b314 100644 --- a/lib/Target/X86/X86ISelSimple.cpp +++ b/lib/Target/X86/X86ISelSimple.cpp @@ -28,7 +28,7 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/InstVisitor.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Target/X86/X86PeepholeOpt.cpp b/lib/Target/X86/X86PeepholeOpt.cpp index 82c622bff1..f03e339d2a 100644 --- a/lib/Target/X86/X86PeepholeOpt.cpp +++ b/lib/Target/X86/X86PeepholeOpt.cpp @@ -17,8 +17,8 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/Target/TargetInstrInfo.h" #include "llvm/Target/TargetMachine.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" using namespace llvm; diff --git a/lib/Target/X86/X86RegisterInfo.cpp b/lib/Target/X86/X86RegisterInfo.cpp index bac6138f03..d78110eb8f 100644 --- a/lib/Target/X86/X86RegisterInfo.cpp +++ b/lib/Target/X86/X86RegisterInfo.cpp @@ -24,8 +24,8 @@ #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetOptions.h" -#include "Support/CommandLine.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; diff --git a/lib/Target/X86/X86TargetMachine.cpp b/lib/Target/X86/X86TargetMachine.cpp index 1a9e978dc4..06cbc49abf 100644 --- a/lib/Target/X86/X86TargetMachine.cpp +++ b/lib/Target/X86/X86TargetMachine.cpp @@ -21,8 +21,8 @@ #include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" -#include "Support/CommandLine.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; X86VectorEnum llvm::X86Vector = NoSSE; diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index a657f023df..779e23c199 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -17,8 +17,8 @@ #include "llvm/Constants.h" #include "llvm/Instructions.h" #include "llvm/Analysis/Expressions.h" -#include "Support/STLExtras.h" -#include "Support/Debug.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Debug.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/ArgumentPromotion.cpp b/lib/Transforms/IPO/ArgumentPromotion.cpp index fe945c408d..a4086524e1 100644 --- a/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -39,10 +39,10 @@ #include "llvm/Target/TargetData.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/CFG.h" -#include "Support/Debug.h" -#include "Support/DepthFirstIterator.h" -#include "Support/Statistic.h" -#include "Support/StringExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 417cb1de4b..9f3c10959c 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -20,7 +20,7 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Module.h" #include "llvm/Pass.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp index 836e0b6091..cde186c38d 100644 --- a/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -24,9 +24,9 @@ #include "llvm/Constant.h" #include "llvm/Instructions.h" #include "llvm/Support/CallSite.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/iterator" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/iterator" #include using namespace llvm; diff --git a/lib/Transforms/IPO/DeadTypeElimination.cpp b/lib/Transforms/IPO/DeadTypeElimination.cpp index cad90f5672..e2d475daf9 100644 --- a/lib/Transforms/IPO/DeadTypeElimination.cpp +++ b/lib/Transforms/IPO/DeadTypeElimination.cpp @@ -17,7 +17,7 @@ #include "llvm/Module.h" #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/IPO/FunctionResolution.cpp b/lib/Transforms/IPO/FunctionResolution.cpp index 8403226ba3..006d33cf51 100644 --- a/lib/Transforms/IPO/FunctionResolution.cpp +++ b/lib/Transforms/IPO/FunctionResolution.cpp @@ -27,7 +27,7 @@ #include "llvm/Support/CallSite.h" #include "llvm/Target/TargetData.h" #include "llvm/Assembly/Writer.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/GlobalDCE.cpp b/lib/Transforms/IPO/GlobalDCE.cpp index e025813fd0..ea5201cd23 100644 --- a/lib/Transforms/IPO/GlobalDCE.cpp +++ b/lib/Transforms/IPO/GlobalDCE.cpp @@ -19,7 +19,7 @@ #include "llvm/Constants.h" #include "llvm/Module.h" #include "llvm/Pass.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index f9be0ad246..dd9894cd19 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -23,8 +23,8 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/Pass.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp index 36ac2023c1..74a0a9b699 100644 --- a/lib/Transforms/IPO/IPConstantPropagation.cpp +++ b/lib/Transforms/IPO/IPConstantPropagation.cpp @@ -20,7 +20,7 @@ #include "llvm/Pass.h" #include "llvm/Constants.h" #include "llvm/Support/CallSite.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp index f0cb03d7b1..86d343af6a 100644 --- a/lib/Transforms/IPO/Inliner.cpp +++ b/lib/Transforms/IPO/Inliner.cpp @@ -19,9 +19,9 @@ #include "llvm/Analysis/CallGraph.h" #include "llvm/Support/CallSite.h" #include "llvm/Transforms/Utils/Cloning.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 15c68cd893..c6b75b1be9 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -16,9 +16,9 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Pass.h" #include "llvm/Module.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include #include using namespace llvm; diff --git a/lib/Transforms/IPO/LoopExtractor.cpp b/lib/Transforms/IPO/LoopExtractor.cpp index a36c99632e..e1ce290526 100644 --- a/lib/Transforms/IPO/LoopExtractor.cpp +++ b/lib/Transforms/IPO/LoopExtractor.cpp @@ -22,7 +22,7 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/FunctionUtils.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/IPO/LowerSetJmp.cpp b/lib/Transforms/IPO/LowerSetJmp.cpp index f5c36d99ae..ebd0500cba 100644 --- a/lib/Transforms/IPO/LowerSetJmp.cpp +++ b/lib/Transforms/IPO/LowerSetJmp.cpp @@ -43,10 +43,10 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/DepthFirstIterator.h" -#include "Support/Statistic.h" -#include "Support/StringExtras.h" -#include "Support/VectorExtras.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/VectorExtras.h" using namespace llvm; namespace { diff --git a/lib/Transforms/IPO/PruneEH.cpp b/lib/Transforms/IPO/PruneEH.cpp index fbb1659488..43b9acff73 100644 --- a/lib/Transforms/IPO/PruneEH.cpp +++ b/lib/Transforms/IPO/PruneEH.cpp @@ -20,7 +20,7 @@ #include "llvm/Intrinsics.h" #include "llvm/Instructions.h" #include "llvm/Analysis/CallGraph.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/IPO/RaiseAllocations.cpp b/lib/Transforms/IPO/RaiseAllocations.cpp index 36aef9c8eb..42edb7e05d 100644 --- a/lib/Transforms/IPO/RaiseAllocations.cpp +++ b/lib/Transforms/IPO/RaiseAllocations.cpp @@ -19,7 +19,7 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Support/CallSite.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp b/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp index c60636cfb5..28830afba8 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/Graph.cpp @@ -14,7 +14,7 @@ #include "Graph.h" #include "llvm/Instructions.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include using std::vector; diff --git a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp index 4e8419d965..10ef440b4f 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/GraphAuxiliary.cpp @@ -15,7 +15,7 @@ #include "llvm/Pass.h" #include "llvm/Module.h" #include "llvm/Instructions.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include #include "Graph.h" diff --git a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp index 96d23f2253..56a20730b7 100644 --- a/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp +++ b/lib/Transforms/Instrumentation/ProfilePaths/InstLoops.cpp @@ -20,7 +20,7 @@ #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Type.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include "../ProfilingUtils.h" namespace llvm { diff --git a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp index 3953c28e52..60426c4e5a 100644 --- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp +++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp @@ -20,7 +20,7 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Instructions.h" #include "ProfilingUtils.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include using namespace llvm; diff --git a/lib/Transforms/Instrumentation/TraceValues.cpp b/lib/Transforms/Instrumentation/TraceValues.cpp index ae356a2f73..1247dfcfbb 100644 --- a/lib/Transforms/Instrumentation/TraceValues.cpp +++ b/lib/Transforms/Instrumentation/TraceValues.cpp @@ -19,8 +19,8 @@ #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Assembly/Writer.h" -#include "Support/CommandLine.h" -#include "Support/StringExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/StringExtras.h" #include #include using namespace llvm; diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp index f470e50461..cc4e69d9ac 100644 --- a/lib/Transforms/LevelRaise.cpp +++ b/lib/Transforms/LevelRaise.cpp @@ -19,10 +19,10 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/ADCE.cpp b/lib/Transforms/Scalar/ADCE.cpp index 04a6417272..5770bb692c 100644 --- a/lib/Transforms/Scalar/ADCE.cpp +++ b/lib/Transforms/Scalar/ADCE.cpp @@ -23,10 +23,10 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h" -#include "Support/Debug.h" -#include "Support/DepthFirstIterator.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/BasicBlockPlacement.cpp b/lib/Transforms/Scalar/BasicBlockPlacement.cpp index a25ab0f121..cadc620170 100644 --- a/lib/Transforms/Scalar/BasicBlockPlacement.cpp +++ b/lib/Transforms/Scalar/BasicBlockPlacement.cpp @@ -30,7 +30,7 @@ #include "llvm/Function.h" #include "llvm/Pass.h" #include "llvm/Support/CFG.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/ConstantProp.cpp b/lib/Transforms/Scalar/ConstantProp.cpp index 8be02476b9..2985ceba63 100644 --- a/lib/Transforms/Scalar/ConstantProp.cpp +++ b/lib/Transforms/Scalar/ConstantProp.cpp @@ -24,7 +24,7 @@ #include "llvm/Instruction.h" #include "llvm/Pass.h" #include "llvm/Support/InstIterator.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/CorrelatedExprs.cpp b/lib/Transforms/Scalar/CorrelatedExprs.cpp index 9738879e28..53c56d2631 100644 --- a/lib/Transforms/Scalar/CorrelatedExprs.cpp +++ b/lib/Transforms/Scalar/CorrelatedExprs.cpp @@ -38,9 +38,9 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Support/ConstantRange.h" #include "llvm/Support/CFG.h" -#include "Support/Debug.h" -#include "Support/PostOrderIterator.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/PostOrderIterator.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/DCE.cpp b/lib/Transforms/Scalar/DCE.cpp index 570a5252d5..1a523cde46 100644 --- a/lib/Transforms/Scalar/DCE.cpp +++ b/lib/Transforms/Scalar/DCE.cpp @@ -21,7 +21,7 @@ #include "llvm/Instruction.h" #include "llvm/Pass.h" #include "llvm/Support/InstIterator.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/DeadStoreElimination.cpp b/lib/Transforms/Scalar/DeadStoreElimination.cpp index 40b5671e4c..82dfebb594 100644 --- a/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -22,8 +22,8 @@ #include "llvm/Analysis/AliasSetTracker.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/SetVector.h" -#include "Support/Statistic.h" +#include "llvm/ADT/SetVector.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp index b1f8f2a01a..40e1be5d46 100644 --- a/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp +++ b/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp @@ -22,8 +22,8 @@ #include "llvm/Instructions.h" #include "llvm/BasicBlock.h" #include "llvm/Pass.h" -#include "Support/Statistic.h" -#include "Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/Debug.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index a3452a3f84..776ff6603a 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -22,8 +22,8 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/ValueNumbering.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/DepthFirstIterator.h" -#include "Support/Statistic.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/IndVarSimplify.cpp b/lib/Transforms/Scalar/IndVarSimplify.cpp index 7c1f1161f5..a269353487 100644 --- a/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -46,8 +46,8 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Support/CFG.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/CommandLine.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 97cdc1196e..2340c49b56 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -49,8 +49,8 @@ #include "llvm/Support/InstIterator.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Support/PatternMatch.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; using namespace llvm::PatternMatch; diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index 792a672f04..9a104db00a 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -42,9 +42,9 @@ #include "llvm/Support/CFG.h" #include "llvm/Transforms/Utils/PromoteMemToReg.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/LoopUnroll.cpp b/lib/Transforms/Scalar/LoopUnroll.cpp index a9cced5ce1..d24b94fac8 100644 --- a/lib/Transforms/Scalar/LoopUnroll.cpp +++ b/lib/Transforms/Scalar/LoopUnroll.cpp @@ -24,10 +24,10 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include #include using namespace llvm; diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index 83dc1836d6..73a99c2212 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/lib/Transforms/Scalar/LoopUnswitch.cpp @@ -35,8 +35,8 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/LowerPacked.cpp b/lib/Transforms/Scalar/LowerPacked.cpp index 2d90ccb300..7a42bf7fba 100644 --- a/lib/Transforms/Scalar/LowerPacked.cpp +++ b/lib/Transforms/Scalar/LowerPacked.cpp @@ -19,7 +19,7 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Support/InstVisitor.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" #include #include #include diff --git a/lib/Transforms/Scalar/PRE.cpp b/lib/Transforms/Scalar/PRE.cpp index 38c5595ebc..f8752336b2 100644 --- a/lib/Transforms/Scalar/PRE.cpp +++ b/lib/Transforms/Scalar/PRE.cpp @@ -29,11 +29,11 @@ #include "llvm/Analysis/PostDominators.h" #include "llvm/Analysis/ValueNumbering.h" #include "llvm/Transforms/Scalar.h" -#include "Support/Debug.h" -#include "Support/DepthFirstIterator.h" -#include "Support/PostOrderIterator.h" -#include "Support/Statistic.h" -#include "Support/hash_set" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/PostOrderIterator.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/hash_set" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/PiNodeInsertion.cpp b/lib/Transforms/Scalar/PiNodeInsertion.cpp index 5227e7c612..202ca74040 100644 --- a/lib/Transforms/Scalar/PiNodeInsertion.cpp +++ b/lib/Transforms/Scalar/PiNodeInsertion.cpp @@ -38,7 +38,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Support/CFG.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp index 6f84344889..c74cf51ccc 100644 --- a/lib/Transforms/Scalar/Reassociate.cpp +++ b/lib/Transforms/Scalar/Reassociate.cpp @@ -30,9 +30,9 @@ #include "llvm/Pass.h" #include "llvm/Constant.h" #include "llvm/Support/CFG.h" -#include "Support/Debug.h" -#include "Support/PostOrderIterator.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/PostOrderIterator.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index 1c39160d9b..497bf0ae9b 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -30,10 +30,10 @@ #include "llvm/Type.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/Debug.h" -#include "Support/hash_map" -#include "Support/Statistic.h" -#include "Support/STLExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/hash_map" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/STLExtras.h" #include #include using namespace llvm; diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 32c9040c5b..a0d5afe0ce 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -29,9 +29,9 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/PromoteMemToReg.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" -#include "Support/StringExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/StringExtras.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/SimplifyCFG.cpp b/lib/Transforms/Scalar/SimplifyCFG.cpp index 8e0f7d3307..0f9946e6ee 100644 --- a/lib/Transforms/Scalar/SimplifyCFG.cpp +++ b/lib/Transforms/Scalar/SimplifyCFG.cpp @@ -23,7 +23,7 @@ #include "llvm/Module.h" #include "llvm/Support/CFG.h" #include "llvm/Pass.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" #include using namespace llvm; diff --git a/lib/Transforms/Scalar/TailDuplication.cpp b/lib/Transforms/Scalar/TailDuplication.cpp index 2a5a606282..717a845765 100644 --- a/lib/Transforms/Scalar/TailDuplication.cpp +++ b/lib/Transforms/Scalar/TailDuplication.cpp @@ -26,9 +26,9 @@ #include "llvm/Type.h" #include "llvm/Support/CFG.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 0ca5562bae..758628ca64 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -51,7 +51,7 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Support/CFG.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/BreakCriticalEdges.cpp b/lib/Transforms/Utils/BreakCriticalEdges.cpp index f5df661334..4a5c9d904b 100644 --- a/lib/Transforms/Utils/BreakCriticalEdges.cpp +++ b/lib/Transforms/Utils/BreakCriticalEdges.cpp @@ -22,7 +22,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Support/CFG.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index aabc587b56..5dd03bd9e7 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -24,9 +24,9 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/StringExtras.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/StringExtras.h" #include #include using namespace llvm; diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index 41454ae0cb..fe27f308cf 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#include "Support/MathExtras.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Constants.h" #include "llvm/Instructions.h" diff --git a/lib/Transforms/Utils/LoopSimplify.cpp b/lib/Transforms/Utils/LoopSimplify.cpp index 2a4d88b99e..81cf8e2778 100644 --- a/lib/Transforms/Utils/LoopSimplify.cpp +++ b/lib/Transforms/Utils/LoopSimplify.cpp @@ -41,10 +41,10 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/Support/CFG.h" #include "llvm/Transforms/Utils/Local.h" -#include "Support/SetOperations.h" -#include "Support/SetVector.h" -#include "Support/Statistic.h" -#include "Support/DepthFirstIterator.h" +#include "llvm/ADT/SetOperations.h" +#include "llvm/ADT/SetVector.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/ADT/DepthFirstIterator.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/LowerAllocations.cpp b/lib/Transforms/Utils/LowerAllocations.cpp index a5197a0e01..f3c1a79052 100644 --- a/lib/Transforms/Utils/LowerAllocations.cpp +++ b/lib/Transforms/Utils/LowerAllocations.cpp @@ -18,7 +18,7 @@ #include "llvm/Instructions.h" #include "llvm/Constants.h" #include "llvm/Pass.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/LowerInvoke.cpp b/lib/Transforms/Utils/LowerInvoke.cpp index 835a5ae789..2c6cf7e91a 100644 --- a/lib/Transforms/Utils/LowerInvoke.cpp +++ b/lib/Transforms/Utils/LowerInvoke.cpp @@ -41,8 +41,8 @@ #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" -#include "Support/Statistic.h" -#include "Support/CommandLine.h" +#include "llvm/ADT/Statistic.h" +#include "llvm/Support/CommandLine.h" #include using namespace llvm; diff --git a/lib/Transforms/Utils/LowerSelect.cpp b/lib/Transforms/Utils/LowerSelect.cpp index 647658e3a5..f914e747a1 100644 --- a/lib/Transforms/Utils/LowerSelect.cpp +++ b/lib/Transforms/Utils/LowerSelect.cpp @@ -23,7 +23,7 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Type.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index 710188aa2b..24a2963c27 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -18,8 +18,8 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Pass.h" -#include "Support/Debug.h" -#include "Support/Statistic.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/Mem2Reg.cpp b/lib/Transforms/Utils/Mem2Reg.cpp index 12dd582525..39400e72ad 100644 --- a/lib/Transforms/Utils/Mem2Reg.cpp +++ b/lib/Transforms/Utils/Mem2Reg.cpp @@ -18,7 +18,7 @@ #include "llvm/Instructions.h" #include "llvm/Function.h" #include "llvm/Target/TargetData.h" -#include "Support/Statistic.h" +#include "llvm/ADT/Statistic.h" using namespace llvm; namespace { diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp index ced2315e0e..81f5cd3ed3 100644 --- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp +++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp @@ -23,7 +23,7 @@ #include "llvm/Constant.h" #include "llvm/Support/CFG.h" #include "llvm/Support/StableBasicBlockNumbering.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" using namespace llvm; /// isAllocaPromotable - Return true if this alloca is legal for promotion. diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index e2a5c8e365..c932173330 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -17,7 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/Type.h" #include "llvm/Support/CFG.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" #include #include #include diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index f70a82839a..0c4a1f7826 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -26,8 +26,8 @@ #include "llvm/SymbolTable.h" #include "llvm/Assembly/Writer.h" #include "llvm/Support/CFG.h" -#include "Support/StringExtras.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; diff --git a/lib/VMCore/BasicBlock.cpp b/lib/VMCore/BasicBlock.cpp index 005740904d..32c86c4ce6 100644 --- a/lib/VMCore/BasicBlock.cpp +++ b/lib/VMCore/BasicBlock.cpp @@ -17,7 +17,7 @@ #include "llvm/Type.h" #include "llvm/Support/CFG.h" #include "llvm/SymbolTable.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" #include using namespace llvm; diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 8b28c0d3ff..77c34296aa 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -18,7 +18,7 @@ #include "llvm/Instructions.h" #include "llvm/SymbolTable.h" #include "llvm/Module.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" #include #include using namespace llvm; diff --git a/lib/VMCore/Dominators.cpp b/lib/VMCore/Dominators.cpp index b9eee7f459..14ec3ccd9f 100644 --- a/lib/VMCore/Dominators.cpp +++ b/lib/VMCore/Dominators.cpp @@ -17,8 +17,8 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Support/CFG.h" #include "llvm/Assembly/Writer.h" -#include "Support/DepthFirstIterator.h" -#include "Support/SetOperations.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/SetOperations.h" #include using namespace llvm; diff --git a/lib/VMCore/Function.cpp b/lib/VMCore/Function.cpp index bf9c8b48bd..e918fd5878 100644 --- a/lib/VMCore/Function.cpp +++ b/lib/VMCore/Function.cpp @@ -17,7 +17,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" #include "llvm/Intrinsics.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" using namespace llvm; diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index cfecbc91ce..b84dbf7fd4 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -16,7 +16,7 @@ #include "llvm/GlobalVariable.h" #include "llvm/Module.h" #include "llvm/SymbolTable.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" using namespace llvm; //===----------------------------------------------------------------------===// diff --git a/lib/VMCore/Instruction.cpp b/lib/VMCore/Instruction.cpp index 1350f05b9b..f54acf5f03 100644 --- a/lib/VMCore/Instruction.cpp +++ b/lib/VMCore/Instruction.cpp @@ -14,7 +14,7 @@ #include "llvm/Function.h" #include "llvm/SymbolTable.h" #include "llvm/Type.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" using namespace llvm; void Instruction::init() diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index dbdb7dd70f..807bd22b07 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" #include "llvm/Value.h" #include #include diff --git a/lib/VMCore/Mangler.cpp b/lib/VMCore/Mangler.cpp index ed58da05c9..69bbe261fa 100644 --- a/lib/VMCore/Mangler.cpp +++ b/lib/VMCore/Mangler.cpp @@ -14,7 +14,7 @@ #include "llvm/Support/Mangler.h" #include "llvm/Module.h" #include "llvm/Type.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" using namespace llvm; static char HexDigit(int V) { diff --git a/lib/VMCore/Module.cpp b/lib/VMCore/Module.cpp index 125fd123f8..d8caf7f117 100644 --- a/lib/VMCore/Module.cpp +++ b/lib/VMCore/Module.cpp @@ -15,8 +15,8 @@ #include "llvm/InstrTypes.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" -#include "Support/STLExtras.h" -#include "Support/LeakDetector.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/LeakDetector.h" #include "SymbolTableListTraitsImpl.h" #include #include diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index d6fe2fba41..5079b4ea65 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -17,8 +17,8 @@ #include "PassManagerT.h" // PassManagerT implementation #include "llvm/Module.h" #include "llvm/ModuleProvider.h" -#include "Support/STLExtras.h" -#include "Support/TypeInfo.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/TypeInfo.h" #include #include using namespace llvm; diff --git a/lib/VMCore/PassManagerT.h b/lib/VMCore/PassManagerT.h index 6c60a2d022..95e0f563c9 100644 --- a/lib/VMCore/PassManagerT.h +++ b/lib/VMCore/PassManagerT.h @@ -23,9 +23,9 @@ #define LLVM_PASSMANAGER_T_H #include "llvm/Pass.h" -#include "Support/CommandLine.h" -#include "Support/LeakDetector.h" -#include "Support/Timer.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/LeakDetector.h" +#include "llvm/Support/Timer.h" #include #include diff --git a/lib/VMCore/SymbolTable.cpp b/lib/VMCore/SymbolTable.cpp index afbb0b1c21..e5191be198 100644 --- a/lib/VMCore/SymbolTable.cpp +++ b/lib/VMCore/SymbolTable.cpp @@ -15,7 +15,7 @@ #include "llvm/SymbolTable.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" #include #include diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index bd0da45f46..0c76d1604b 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -15,9 +15,9 @@ #include "llvm/DerivedTypes.h" #include "llvm/SymbolTable.h" #include "llvm/Constants.h" -#include "Support/DepthFirstIterator.h" -#include "Support/StringExtras.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/DepthFirstIterator.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/STLExtras.h" #include #include using namespace llvm; diff --git a/lib/VMCore/Value.cpp b/lib/VMCore/Value.cpp index e41c7fd136..60be53db5b 100644 --- a/lib/VMCore/Value.cpp +++ b/lib/VMCore/Value.cpp @@ -16,7 +16,7 @@ #include "llvm/DerivedTypes.h" #include "llvm/Constant.h" #include "llvm/GlobalValue.h" -#include "Support/LeakDetector.h" +#include "llvm/Support/LeakDetector.h" #include #include using namespace llvm; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 9e99fe0136..18d9338348 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -53,7 +53,7 @@ #include "llvm/Analysis/Dominators.h" #include "llvm/Support/CFG.h" #include "llvm/Support/InstVisitor.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/STLExtras.h" #include #include #include diff --git a/projects/Stacker/lib/compiler/StackerParser.y b/projects/Stacker/lib/compiler/StackerParser.y index 2256b30ccf..40411d9628 100644 --- a/projects/Stacker/lib/compiler/StackerParser.y +++ b/projects/Stacker/lib/compiler/StackerParser.y @@ -16,8 +16,8 @@ #include "llvm/SymbolTable.h" #include "llvm/Module.h" #include "llvm/Instructions.h" -#include "Support/STLExtras.h" -#include "Support/DepthFirstIterator.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/DepthFirstIterator.h" #include #include #include diff --git a/projects/Stacker/lib/runtime/Makefile b/projects/Stacker/lib/runtime/Makefile index eaf1b48287..5f149ad432 100644 --- a/projects/Stacker/lib/runtime/Makefile +++ b/projects/Stacker/lib/runtime/Makefile @@ -8,7 +8,8 @@ LEVEL=../../../.. # # Give the name of a library. This will build a dynamic version. # -SHARED_LIBRARY=1 +BYTECODE_LIBRARY=1 +DONT_BUILD_RELINKED=1 LIBRARYNAME=stkr_runtime # diff --git a/projects/Stacker/tools/stkrc/stkrc.cpp b/projects/Stacker/tools/stkrc/stkrc.cpp index c5d92e6c2e..6006bb476e 100644 --- a/projects/Stacker/tools/stkrc/stkrc.cpp +++ b/projects/Stacker/tools/stkrc/stkrc.cpp @@ -21,7 +21,7 @@ #include "llvm/Assembly/Parser.h" #include "llvm/Bytecode/Writer.h" #include "llvm/Analysis/Verifier.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/projects/sample/lib/sample/sample.c b/projects/sample/lib/sample/sample.c index bd78ed5746..631a48d1ad 100644 --- a/projects/sample/lib/sample/sample.c +++ b/projects/sample/lib/sample/sample.c @@ -11,7 +11,7 @@ #include // LLVM Header File -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" // Header file global to this project #include "sample.h" diff --git a/runtime/libtrace/tracelib.c b/runtime/libtrace/tracelib.c index 5b4c7f6831..9de5c296b4 100644 --- a/runtime/libtrace/tracelib.c +++ b/runtime/libtrace/tracelib.c @@ -10,7 +10,7 @@ #include #include #include -#include "Support/DataTypes.h" +#include "llvm/Support/DataTypes.h" /*===---------------------------------------------------------------------===== * HASH FUNCTIONS diff --git a/tools/analyze/GraphPrinters.cpp b/tools/analyze/GraphPrinters.cpp index fc74c480cf..1176a8df10 100644 --- a/tools/analyze/GraphPrinters.cpp +++ b/tools/analyze/GraphPrinters.cpp @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -#include "Support/GraphWriter.h" +#include "llvm/Support/GraphWriter.h" #include "llvm/Pass.h" #include "llvm/Value.h" #include "llvm/Analysis/CallGraph.h" diff --git a/tools/analyze/PrintSCC.cpp b/tools/analyze/PrintSCC.cpp index 8911cc36e2..e4af831752 100644 --- a/tools/analyze/PrintSCC.cpp +++ b/tools/analyze/PrintSCC.cpp @@ -29,7 +29,7 @@ #include "llvm/Module.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/Support/CFG.h" -#include "Support/SCCIterator.h" +#include "llvm/ADT/SCCIterator.h" #include namespace llvm { diff --git a/tools/analyze/analyze.cpp b/tools/analyze/analyze.cpp index 0207b8c6e1..1542a1a068 100644 --- a/tools/analyze/analyze.cpp +++ b/tools/analyze/analyze.cpp @@ -24,8 +24,8 @@ #include "llvm/Target/TargetData.h" #include "llvm/Support/PassNameParser.h" #include "llvm/System/Signals.h" -#include "Support/PluginLoader.h" -#include "Support/Timer.h" +#include "llvm/Support/PluginLoader.h" +#include "llvm/Support/Timer.h" #include using namespace llvm; diff --git a/tools/bugpoint/BugDriver.cpp b/tools/bugpoint/BugDriver.cpp index 1826b7b780..6d13f96711 100644 --- a/tools/bugpoint/BugDriver.cpp +++ b/tools/bugpoint/BugDriver.cpp @@ -20,8 +20,8 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Support/Linker.h" #include "llvm/Support/ToolRunner.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include #include diff --git a/tools/bugpoint/CrashDebugger.cpp b/tools/bugpoint/CrashDebugger.cpp index 69837f9c2a..545d767c2a 100644 --- a/tools/bugpoint/CrashDebugger.cpp +++ b/tools/bugpoint/CrashDebugger.cpp @@ -26,7 +26,7 @@ #include "llvm/Support/ToolRunner.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Transforms/Utils/Cloning.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/FileUtilities.h" #include #include using namespace llvm; diff --git a/tools/bugpoint/ExecutionDriver.cpp b/tools/bugpoint/ExecutionDriver.cpp index 62f0a242a6..0687c4c08f 100644 --- a/tools/bugpoint/ExecutionDriver.cpp +++ b/tools/bugpoint/ExecutionDriver.cpp @@ -14,10 +14,10 @@ #include "BugDriver.h" #include "llvm/Support/ToolRunner.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/FileUtilities.h" -#include "Support/SystemUtils.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/Support/SystemUtils.h" #include using namespace llvm; diff --git a/tools/bugpoint/ExtractFunction.cpp b/tools/bugpoint/ExtractFunction.cpp index 7806857f2e..cf02ef73a9 100644 --- a/tools/bugpoint/ExtractFunction.cpp +++ b/tools/bugpoint/ExtractFunction.cpp @@ -24,9 +24,9 @@ #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Transforms/Utils/FunctionUtils.h" #include "llvm/Target/TargetData.h" -#include "Support/CommandLine.h" -#include "Support/Debug.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/Debug.h" +#include "llvm/Support/FileUtilities.h" #include using namespace llvm; diff --git a/tools/bugpoint/Miscompilation.cpp b/tools/bugpoint/Miscompilation.cpp index 0b7711b611..bead5dc992 100644 --- a/tools/bugpoint/Miscompilation.cpp +++ b/tools/bugpoint/Miscompilation.cpp @@ -23,8 +23,8 @@ #include "llvm/Support/Mangler.h" #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Support/Linker.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" using namespace llvm; namespace llvm { diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index c5c437ccdb..23e40fda5c 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -21,7 +21,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Target/TargetData.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/FileUtilities.h" #include #include #include diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index b694127e07..3dc98451de 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -13,9 +13,9 @@ #define DEBUG_TYPE "toolrunner" #include "llvm/Support/ToolRunner.h" -#include "Config/config.h" // for HAVE_LINK_R -#include "Support/Debug.h" -#include "Support/FileUtilities.h" +#include "llvm/Config/config.h" // for HAVE_LINK_R +#include "llvm/Support/Debug.h" +#include "llvm/Support/FileUtilities.h" #include #include using namespace llvm; diff --git a/tools/bugpoint/ToolRunner.h b/tools/bugpoint/ToolRunner.h index bd085eab6d..c5d89da46d 100644 --- a/tools/bugpoint/ToolRunner.h +++ b/tools/bugpoint/ToolRunner.h @@ -1,4 +1,4 @@ -//===-- Support/ToolRunner.h ------------------------------------*- C++ -*-===// +//===-- llvm/Support/ToolRunner.h -------------------------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -14,10 +14,10 @@ // //===----------------------------------------------------------------------===// -#ifndef TOOLRUNNER_H -#define TOOLRUNNER_H +#ifndef LLVM_SUPPORT_TOOLRUNNER_H +#define LLVM_SUPPORT_TOOLRUNNER_H -#include "Support/SystemUtils.h" +#include "llvm/Support/SystemUtils.h" #include #include diff --git a/tools/bugpoint/bugpoint.cpp b/tools/bugpoint/bugpoint.cpp index 1ff84f2408..a4eae3cecd 100644 --- a/tools/bugpoint/bugpoint.cpp +++ b/tools/bugpoint/bugpoint.cpp @@ -16,11 +16,12 @@ #include "BugDriver.h" #include "llvm/Support/PassNameParser.h" #include "llvm/Support/ToolRunner.h" -#include "Support/CommandLine.h" +#include "llvm/System/SysConfig.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/PluginLoader.h" #include "llvm/System/Signals.h" -#include "Support/PluginLoader.h" -#include "Config/unistd.h" -#include +#include "llvm/Config/unistd.h" +//#include using namespace llvm; static cl::list @@ -45,14 +46,8 @@ int main(int argc, char **argv) { D.addPasses(PassList.begin(), PassList.end()); // Bugpoint has the ability of generating a plethora of core files, so to - // avoid filling up the disk, set the max core file size to 0. - struct rlimit rlim; - rlim.rlim_cur = rlim.rlim_max = 0; - int res = setrlimit(RLIMIT_CORE, &rlim); - if (res < 0) { - // setrlimit() may have failed, but we're not going to let that stop us - perror("setrlimit: RLIMIT_CORE"); - } + // avoid filling up the disk, we prevent it + sys::PreventCoreFiles(); try { return D.run(); diff --git a/tools/extract/extract.cpp b/tools/extract/extract.cpp index 050793b2e6..95822d0389 100644 --- a/tools/extract/extract.cpp +++ b/tools/extract/extract.cpp @@ -18,7 +18,7 @@ #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Transforms/IPO.h" #include "llvm/Target/TargetData.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/gccas/gccas.cpp b/tools/gccas/gccas.cpp index c5f6c2395a..ab64bbf18f 100644 --- a/tools/gccas/gccas.cpp +++ b/tools/gccas/gccas.cpp @@ -22,7 +22,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/gccld/GenerateCode.cpp b/tools/gccld/GenerateCode.cpp index 029d5b90fd..633517d09d 100644 --- a/tools/gccld/GenerateCode.cpp +++ b/tools/gccld/GenerateCode.cpp @@ -24,8 +24,8 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Support/Linker.h" -#include "Support/SystemUtils.h" -#include "Support/CommandLine.h" +#include "llvm/Support/SystemUtils.h" +#include "llvm/Support/CommandLine.h" using namespace llvm; namespace { diff --git a/tools/gccld/Linker.cpp b/tools/gccld/Linker.cpp index fcaa7af3d5..fa9ec70306 100644 --- a/tools/gccld/Linker.cpp +++ b/tools/gccld/Linker.cpp @@ -21,11 +21,11 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Support/Linker.h" -#include "Config/config.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Config/config.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/System/Signals.h" -#include "Support/SystemUtils.h" +#include "llvm/Support/SystemUtils.h" #include #include #include diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp index ba4681534d..9137124f19 100644 --- a/tools/gccld/gccld.cpp +++ b/tools/gccld/gccld.cpp @@ -29,10 +29,10 @@ #include "llvm/Transforms/IPO.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Support/Linker.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/System/Signals.h" -#include "Support/SystemUtils.h" +#include "llvm/Support/SystemUtils.h" #include #include using namespace llvm; diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 0d35ea20aa..4e1e0cce7b 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -20,8 +20,8 @@ #include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Pass.h" -#include "Support/CommandLine.h" -#include "Support/PluginLoader.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/PluginLoader.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llee/ExecveHandler.c b/tools/llee/ExecveHandler.c index 088f1dba53..89d1536538 100644 --- a/tools/llee/ExecveHandler.c +++ b/tools/llee/ExecveHandler.c @@ -13,7 +13,7 @@ \*===----------------------------------------------------------------------===*/ #include "SysUtils.h" -#include "Config/unistd.h" +#include "llvm/Config/unistd.h" #include #include #include diff --git a/tools/llee/OSInterface.h b/tools/llee/OSInterface.h index 26b48fd1af..0e026e10b1 100644 --- a/tools/llee/OSInterface.h +++ b/tools/llee/OSInterface.h @@ -16,7 +16,7 @@ #ifndef OS_INTERFACE_H #define OS_INTERFACE_H -#include "Config/sys/types.h" +#include "llvm/Config/sys/types.h" struct stat; diff --git a/tools/llee/StorageProxy.c b/tools/llee/StorageProxy.c index 656d3164cf..05ffdf4b4c 100644 --- a/tools/llee/StorageProxy.c +++ b/tools/llee/StorageProxy.c @@ -7,10 +7,10 @@ #include "OSInterface.h" #include "SysUtils.h" -#include "Config/fcntl.h" -#include "Config/unistd.h" -#include "Config/sys/types.h" -#include "Config/sys/stat.h" +#include "llvm/Config/fcntl.h" +#include "llvm/Config/unistd.h" +#include "llvm/Config/sys/types.h" +#include "llvm/Config/sys/stat.h" #include #include #include diff --git a/tools/llee/SysUtils.c b/tools/llee/SysUtils.c index d7bab1d989..0325c40b9d 100644 --- a/tools/llee/SysUtils.c +++ b/tools/llee/SysUtils.c @@ -13,12 +13,12 @@ \*===----------------------------------------------------------------------===*/ #include "SysUtils.h" -#include "Config/dlfcn.h" -#include "Config/fcntl.h" -#include "Config/unistd.h" -#include "Config/sys/stat.h" -#include "Config/sys/types.h" -#include "Config/sys/wait.h" +#include "llvm/Config/dlfcn.h" +#include "llvm/Config/fcntl.h" +#include "llvm/Config/unistd.h" +#include "llvm/Config/sys/stat.h" +#include "llvm/Config/sys/types.h" +#include "llvm/Config/sys/wait.h" #include #include #include diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 066bfbc9e9..eb8ac0126e 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -19,8 +19,8 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" -#include "Support/CommandLine.h" -#include "Support/PluginLoader.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/PluginLoader.h" #include "llvm/System/Signals.h" #include diff --git a/tools/llvm-ar/llvm-ar.cpp b/tools/llvm-ar/llvm-ar.cpp index 4b79cd367d..07fc1810e8 100644 --- a/tools/llvm-ar/llvm-ar.cpp +++ b/tools/llvm-ar/llvm-ar.cpp @@ -13,8 +13,8 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index b49702c32e..1d48f7a7fa 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -19,7 +19,7 @@ #include "llvm/Assembly/Parser.h" #include "llvm/Bytecode/Writer.h" #include "llvm/Analysis/Verifier.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp index e3dff659d2..d4be138fe7 100644 --- a/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp +++ b/tools/llvm-bcanalyzer/llvm-bcanalyzer.cpp @@ -31,7 +31,7 @@ #include "llvm/Analysis/Verifier.h" #include "llvm/Bytecode/Analyzer.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-db/CLIDebugger.cpp b/tools/llvm-db/CLIDebugger.cpp index c48a919f80..75798d2352 100644 --- a/tools/llvm-db/CLIDebugger.cpp +++ b/tools/llvm-db/CLIDebugger.cpp @@ -15,7 +15,7 @@ #include "CLIDebugger.h" #include "CLICommand.h" #include "llvm/Debugger/SourceFile.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; diff --git a/tools/llvm-db/Commands.cpp b/tools/llvm-db/Commands.cpp index 56dbd53526..6df2f693a1 100644 --- a/tools/llvm-db/Commands.cpp +++ b/tools/llvm-db/Commands.cpp @@ -18,8 +18,8 @@ #include "llvm/Debugger/SourceLanguage.h" #include "llvm/Debugger/SourceFile.h" #include "llvm/Debugger/InferiorProcess.h" -#include "Support/FileUtilities.h" -#include "Support/StringExtras.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; diff --git a/tools/llvm-db/llvm-db.cpp b/tools/llvm-db/llvm-db.cpp index 1b7385c065..23cbca2ef4 100644 --- a/tools/llvm-db/llvm-db.cpp +++ b/tools/llvm-db/llvm-db.cpp @@ -13,8 +13,8 @@ //===----------------------------------------------------------------------===// #include "CLIDebugger.h" -#include "Support/CommandLine.h" -#include "Support/PluginLoader.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/PluginLoader.h" #include "llvm/System/Signals.h" #include diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index ac8101b6c4..37d5c84f75 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -20,7 +20,7 @@ #include "llvm/PassManager.h" #include "llvm/Bytecode/Reader.h" #include "llvm/Assembly/PrintModulePass.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index 050793b2e6..95822d0389 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -18,7 +18,7 @@ #include "llvm/Bytecode/WriteBytecodePass.h" #include "llvm/Transforms/IPO.h" #include "llvm/Target/TargetData.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 3cd3c7b54d..664529850c 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -17,8 +17,8 @@ #include "llvm/Bytecode/Reader.h" #include "llvm/Bytecode/Writer.h" #include "llvm/Support/Linker.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-nm/llvm-nm.cpp b/tools/llvm-nm/llvm-nm.cpp index ba8b5d7f0d..1a2b40e9c9 100644 --- a/tools/llvm-nm/llvm-nm.cpp +++ b/tools/llvm-nm/llvm-nm.cpp @@ -18,8 +18,8 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-prof/llvm-prof.cpp b/tools/llvm-prof/llvm-prof.cpp index efb44d69b5..88344078bd 100644 --- a/tools/llvm-prof/llvm-prof.cpp +++ b/tools/llvm-prof/llvm-prof.cpp @@ -18,7 +18,7 @@ #include "llvm/Assembly/AsmAnnotationWriter.h" #include "llvm/Analysis/ProfileInfoLoader.h" #include "llvm/Bytecode/Reader.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" #include #include diff --git a/tools/llvm-stub/llvm-stub.c b/tools/llvm-stub/llvm-stub.c index a64c5df9f4..8d5175af10 100644 --- a/tools/llvm-stub/llvm-stub.c +++ b/tools/llvm-stub/llvm-stub.c @@ -23,7 +23,7 @@ #include #include #include -#include "Config/unistd.h" /* provides definition of execve */ +#include "llvm/Config/unistd.h" /* provides definition of execve */ int main(int argc, char** argv) { const char *Interp = getenv("LLVMINTERP"); diff --git a/tools/llvmc/CompilerDriver.cpp b/tools/llvmc/CompilerDriver.cpp index 51164d2467..c015d9e867 100644 --- a/tools/llvmc/CompilerDriver.cpp +++ b/tools/llvmc/CompilerDriver.cpp @@ -17,9 +17,9 @@ #include "llvm/Module.h" #include "llvm/Bytecode/Reader.h" #include "llvm/System/Signals.h" -#include "Support/FileUtilities.h" -#include "Support/SetVector.h" -#include "Support/StringExtras.h" +#include "llvm/Support/FileUtilities.h" +#include "llvm/ADT/SetVector.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; diff --git a/tools/llvmc/Configuration.cpp b/tools/llvmc/Configuration.cpp index c398e529d7..6b5d33975f 100644 --- a/tools/llvmc/Configuration.cpp +++ b/tools/llvmc/Configuration.cpp @@ -15,9 +15,9 @@ #include "Configuration.h" #include "ConfigLexer.h" #include "CompilerDriver.h" -#include "Config/config.h" -#include "Support/CommandLine.h" -#include "Support/StringExtras.h" +#include "llvm/Config/config.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/ADT/StringExtras.h" #include #include diff --git a/tools/llvmc/Configuration.h b/tools/llvmc/Configuration.h index 2ed565a80e..e194dd072e 100644 --- a/tools/llvmc/Configuration.h +++ b/tools/llvmc/Configuration.h @@ -15,7 +15,7 @@ #define LLVM_TOOLS_LLVMC_CONFIGDATA_H #include "CompilerDriver.h" -#include +#include namespace llvm { /// This class provides the high level interface to the LLVM Compiler Driver. diff --git a/tools/llvmc/llvmc.cpp b/tools/llvmc/llvmc.cpp index 8dab301790..f457795a0c 100644 --- a/tools/llvmc/llvmc.cpp +++ b/tools/llvmc/llvmc.cpp @@ -18,7 +18,7 @@ #include "Configuration.h" #include "llvm/Pass.h" #include "llvm/System/Signals.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include using namespace llvm; diff --git a/tools/opt/GraphPrinters.cpp b/tools/opt/GraphPrinters.cpp index fc74c480cf..1176a8df10 100644 --- a/tools/opt/GraphPrinters.cpp +++ b/tools/opt/GraphPrinters.cpp @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -#include "Support/GraphWriter.h" +#include "llvm/Support/GraphWriter.h" #include "llvm/Pass.h" #include "llvm/Value.h" #include "llvm/Analysis/CallGraph.h" diff --git a/tools/opt/PrintSCC.cpp b/tools/opt/PrintSCC.cpp index 8911cc36e2..e4af831752 100644 --- a/tools/opt/PrintSCC.cpp +++ b/tools/opt/PrintSCC.cpp @@ -29,7 +29,7 @@ #include "llvm/Module.h" #include "llvm/Analysis/CallGraph.h" #include "llvm/Support/CFG.h" -#include "Support/SCCIterator.h" +#include "llvm/ADT/SCCIterator.h" #include namespace llvm { diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 4810ebd870..f5666bc08e 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -21,8 +21,8 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/PassNameParser.h" #include "llvm/System/Signals.h" -#include "Support/PluginLoader.h" -#include "Support/SystemUtils.h" +#include "llvm/Support/PluginLoader.h" +#include "llvm/Support/SystemUtils.h" #include #include #include diff --git a/utils/TableGen/CodeEmitterGen.cpp b/utils/TableGen/CodeEmitterGen.cpp index 906f4d6c72..dcf10672a3 100644 --- a/utils/TableGen/CodeEmitterGen.cpp +++ b/utils/TableGen/CodeEmitterGen.cpp @@ -16,7 +16,7 @@ #include "CodeEmitterGen.h" #include "CodeGenTarget.h" #include "Record.h" -#include "Support/Debug.h" +#include "llvm/Support/Debug.h" using namespace llvm; void CodeEmitterGen::run(std::ostream &o) { diff --git a/utils/TableGen/FileParser.y b/utils/TableGen/FileParser.y index bf10abc8be..8781049956 100644 --- a/utils/TableGen/FileParser.y +++ b/utils/TableGen/FileParser.y @@ -13,7 +13,7 @@ %{ #include "Record.h" -#include "Support/StringExtras.h" +#include "llvm/ADT/StringExtras.h" #include #include #define YYERROR_VERBOSE 1 diff --git a/utils/TableGen/InstrSelectorEmitter.cpp b/utils/TableGen/InstrSelectorEmitter.cpp index f6ca2a22e4..9a2ce4a6e8 100644 --- a/utils/TableGen/InstrSelectorEmitter.cpp +++ b/utils/TableGen/InstrSelectorEmitter.cpp @@ -14,8 +14,8 @@ #include "InstrSelectorEmitter.h" #include "Record.h" -#include "Support/Debug.h" -#include "Support/StringExtras.h" +#include "llvm/Support/Debug.h" +#include "llvm/ADT/StringExtras.h" #include using namespace llvm; diff --git a/utils/TableGen/RegisterInfoEmitter.cpp b/utils/TableGen/RegisterInfoEmitter.cpp index ef79c35017..487890d374 100644 --- a/utils/TableGen/RegisterInfoEmitter.cpp +++ b/utils/TableGen/RegisterInfoEmitter.cpp @@ -17,8 +17,8 @@ #include "CodeGenTarget.h" #include "CodeGenRegisters.h" #include "Record.h" -#include "Support/StringExtras.h" -#include "Support/STLExtras.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/STLExtras.h" #include using namespace llvm; diff --git a/utils/TableGen/TableGen.cpp b/utils/TableGen/TableGen.cpp index 14e2352ece..15b313191e 100644 --- a/utils/TableGen/TableGen.cpp +++ b/utils/TableGen/TableGen.cpp @@ -16,9 +16,9 @@ //===----------------------------------------------------------------------===// #include "Record.h" -#include "Support/CommandLine.h" +#include "llvm/Support/CommandLine.h" #include "llvm/System/Signals.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/FileUtilities.h" #include "CodeEmitterGen.h" #include "RegisterInfoEmitter.h" #include "InstrInfoEmitter.h" diff --git a/utils/fpcmp/fpcmp.cpp b/utils/fpcmp/fpcmp.cpp index e45c3c0a27..ff93b9bc49 100644 --- a/utils/fpcmp/fpcmp.cpp +++ b/utils/fpcmp/fpcmp.cpp @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "Support/CommandLine.h" -#include "Support/FileUtilities.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/FileUtilities.h" #include #include -- cgit v1.2.3-70-g09d2 From fb4863ac5506229abe7ee9d9cfffbe4f45fe71eb Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Sun, 7 Nov 2004 00:58:38 +0000 Subject: Replace uses of llvm.org with llvm.cs.uiuc.edu git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17549 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index d60b464dd5..90afa0d9e3 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -917,7 +917,7 @@ public: void operator=(bool OptionWasSpecified) { if (OptionWasSpecified) { std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " - << PACKAGE_VERSION << " (see http://llvm.org/)\n"; + << PACKAGE_VERSION << " (see http://llvm.cs.uiuc.edu/)\n"; exit(1); } } -- cgit v1.2.3-70-g09d2 From ad0846bd8be0a86e0277e1890fd280c9868f830a Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sun, 14 Nov 2004 22:04:00 +0000 Subject: Implement the MoreHelp utility that calls a function to printmore help information if the MoreHelp global is not null. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17774 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 90afa0d9e3..ad82c84947 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -834,6 +834,12 @@ void generic_parser_base::printOptionInfo(const Option &O, //===----------------------------------------------------------------------===// // --help and --help-hidden option implementation // + +// If this variable is set, it is a pointer to a function that the user wants +// us to call after we print out the help info. Basically a hook to allow +// additional help to be printed. +void (*cl::MoreHelp)() = 0; + namespace { class HelpPrinter { @@ -907,6 +913,10 @@ public: for (unsigned i = 0, e = Options.size(); i != e; ++i) Options[i].second->printOptionInfo(MaxArgLen); + // Call the user's hook so help output can be extended. + if (MoreHelp != 0) + (*MoreHelp)(); + // Halt the program if help information is printed exit(1); } -- cgit v1.2.3-70-g09d2 From 9bbba091396922093687d11a181e5886c42c5dfd Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Tue, 16 Nov 2004 06:11:52 +0000 Subject: Per code review: *Implement/Document the cl::extrahelp feature instead of the MoreHelp ptr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17871 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CommandLine.html | 30 ++++++++++++++++++++++++++++++ include/llvm/Support/CommandLine.h | 20 +++++++++++++------- lib/Support/CommandLine.cpp | 29 ++++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 12 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/docs/CommandLine.html b/docs/CommandLine.html index 531c0f899c..c5fa4d36f1 100644 --- a/docs/CommandLine.html +++ b/docs/CommandLine.html @@ -2,6 +2,7 @@ "http://www.w3.org/TR/html4/strict.dtd"> + CommandLine 2.0 Library Manual @@ -61,6 +62,7 @@
  • The cl::opt class
  • The cl::list class
  • The cl::alias class
  • +
  • The cl::extrahelp class
  • Builtin parsers @@ -1519,6 +1521,34 @@ the conversion from string to data.

    + + + +
    + +

    The cl::extrahelp class is a nontemplated class that allows extra +help text to be printed out for the --help option.

    + +
    +namespace cl {
    +  struct extrahelp;
    +}
    +
    + +

    To use the extrahelp, simply construct one with a const char* +parameter to the constructor. The text passed to the constructor will be printed +at the bottom of the help message, verbatim. Note that multiple +cl::extrahelp can be used but this practice is discouraged. If +your tool needs to print additional help information, put all that help into a +single cl::extrahelp instance.

    +

    For example:

    +
    +  cl::extrahelp("\nADDITIONAL HELP:\n\n  This is the extra help\n");
    +
    +
    +
    Builtin parsers diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 4d5dccd38c..3b4eda587a 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1046,13 +1046,19 @@ struct aliasopt { void apply(alias &A) const { A.setAliasFor(Opt); } }; -/// Permit the tool to provide additional help output after the normal -/// help output. To use this, create a function that returns void and -/// takes no arguments. Assign its address to cl::MoreHelp. If set, -/// this function will be called just before the CommandLine exits -/// after printing the help. -/// @brief Optional pointer to additional help function -extern void (*MoreHelp)(); +// extrahelp - provide additional help at the end of the normal help +// output. All occurrences of cl::extrahelp will be accumulated and +// printed to std::cerr at the end of the regular help, just before +// exit is called. +struct extrahelp { + const char * morehelp; + extrahelp(const char* help); +}; + +// This function just prints the help message, exactly the same way as if the +// --help option had been given on the command line. +// NOTE: THIS FUNCTION TERMINATES THE PROGRAM! +void PrintHelpMessage(); } // End namespace cl diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index ad82c84947..15fd19591a 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -838,7 +838,15 @@ void generic_parser_base::printOptionInfo(const Option &O, // If this variable is set, it is a pointer to a function that the user wants // us to call after we print out the help info. Basically a hook to allow // additional help to be printed. -void (*cl::MoreHelp)() = 0; +static std::vector* MoreHelp = 0; + +extrahelp::extrahelp(const char* Help) + : morehelp(Help) { + if (!MoreHelp) { + MoreHelp = new std::vector; + } + MoreHelp->push_back(Help); +} namespace { @@ -913,11 +921,16 @@ public: for (unsigned i = 0, e = Options.size(); i != e; ++i) Options[i].second->printOptionInfo(MaxArgLen); - // Call the user's hook so help output can be extended. - if (MoreHelp != 0) - (*MoreHelp)(); + // Print any extra help the user has declared. If MoreHelp is not null, + // then the user used at least one cl::extrahelp instance to provide + // additional help. We just print it out now. + if (MoreHelp != 0) { + for (std::vector::iterator I = MoreHelp->begin(), + E = MoreHelp->end(); I != E; ++I) + std::cerr << *I; + } - // Halt the program if help information is printed + // Halt the program since help information was printed exit(1); } }; @@ -954,4 +967,10 @@ cl::opt > VersOp("version", cl::desc("display the version"), cl::location(VersionPrinterInstance), cl::ValueDisallowed); + } // End anonymous namespace + +// Utility function for printing the help message. +void cl::PrintHelpMessage() { + NormalPrinter = true; +} -- cgit v1.2.3-70-g09d2 From 5cc498f116cd76235c9c0a2ded46bc29f8fb35e0 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Tue, 16 Nov 2004 06:50:36 +0000 Subject: Add a comment to some code that at first glance just doesn't look right. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17886 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 15fd19591a..df321653e6 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -972,5 +972,11 @@ VersOp("version", cl::desc("display the version"), // Utility function for printing the help message. void cl::PrintHelpMessage() { + // This looks weird, but it actually prints the help message. The + // NormalPrinter variable is a HelpPrinter and the help gets printed when + // its operator= is invoked. That's because the "normal" usages of the + // help printer is to be assigned true/false depending on whether the + // --help option was given or not. Since we're circumventing that we have + // to make it look like --help was given, so we assign true. NormalPrinter = true; } -- cgit v1.2.3-70-g09d2 From c540ebbc1b7c2f6a92a968b4d36137a7332cea32 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 19 Nov 2004 17:08:15 +0000 Subject: Patches to avoid "leaking" memory on process exit. Patch contributed by Morten Ofstad! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17998 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 64 ++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index df321653e6..5abeb8d2ef 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -33,6 +33,17 @@ using namespace cl; static const char *ProgramName = ""; static const char *ProgramOverview = 0; +// This collects additional help to be printed. +static std::vector &MoreHelp() { + static std::vector moreHelp; + return moreHelp; +} + +extrahelp::extrahelp(const char* Help) + : morehelp(Help) { + MoreHelp().push_back(Help); +} + //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery... // @@ -40,23 +51,19 @@ static const char *ProgramOverview = 0; // Return the global command line option vector. Making it a function scoped // static ensures that it will be initialized correctly before its first use. // -static std::map *CommandLineOptions = 0; static std::map &getOpts() { - if (CommandLineOptions == 0) - CommandLineOptions = new std::map(); - return *CommandLineOptions; + static std::map CommandLineOptions; + return CommandLineOptions; } static Option *getOption(const std::string &Str) { - if (CommandLineOptions == 0) return 0; - std::map::iterator I = CommandLineOptions->find(Str); - return I != CommandLineOptions->end() ? I->second : 0; + std::map::iterator I = getOpts().find(Str); + return I != getOpts().end() ? I->second : 0; } static std::vector &getPositionalOpts() { - static std::vector *Positional = 0; - if (!Positional) Positional = new std::vector(); - return *Positional; + static std::vector Positional; + return Positional; } static void AddArgument(const char *ArgName, Option *Opt) { @@ -73,18 +80,13 @@ static void AddArgument(const char *ArgName, Option *Opt) { // options have already been processed and the map has been deleted! // static void RemoveArgument(const char *ArgName, Option *Opt) { - if (CommandLineOptions == 0) return; #ifndef NDEBUG // This disgusting HACK is brought to you courtesy of GCC 3.3.2, which ICE's // If we pass ArgName directly into getOption here. std::string Tmp = ArgName; assert(getOption(Tmp) == Opt && "Arg not in map!"); #endif - CommandLineOptions->erase(ArgName); - if (CommandLineOptions->empty()) { - delete CommandLineOptions; - CommandLineOptions = 0; - } + getOpts().erase(ArgName); } static inline bool ProvideOption(Option *Handler, const char *ArgName, @@ -565,9 +567,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Free all of the memory allocated to the map. Command line options may only // be processed once! - delete CommandLineOptions; - CommandLineOptions = 0; + getOpts().clear(); PositionalOpts.clear(); + MoreHelp().clear(); // If we had an error processing our arguments, don't let the program execute if (ErrorParsing) exit(1); @@ -835,19 +837,6 @@ void generic_parser_base::printOptionInfo(const Option &O, // --help and --help-hidden option implementation // -// If this variable is set, it is a pointer to a function that the user wants -// us to call after we print out the help info. Basically a hook to allow -// additional help to be printed. -static std::vector* MoreHelp = 0; - -extrahelp::extrahelp(const char* Help) - : morehelp(Help) { - if (!MoreHelp) { - MoreHelp = new std::vector; - } - MoreHelp->push_back(Help); -} - namespace { class HelpPrinter { @@ -921,14 +910,11 @@ public: for (unsigned i = 0, e = Options.size(); i != e; ++i) Options[i].second->printOptionInfo(MaxArgLen); - // Print any extra help the user has declared. If MoreHelp is not null, - // then the user used at least one cl::extrahelp instance to provide - // additional help. We just print it out now. - if (MoreHelp != 0) { - for (std::vector::iterator I = MoreHelp->begin(), - E = MoreHelp->end(); I != E; ++I) - std::cerr << *I; - } + // Print any extra help the user has declared. + for (std::vector::iterator I = MoreHelp().begin(), + E = MoreHelp().end(); I != E; ++I) + std::cerr << *I; + MoreHelp().clear(); // Halt the program since help information was printed exit(1); -- cgit v1.2.3-70-g09d2 From c4ae8e903c6abd7e391e8a16f8e850073342ca4d Mon Sep 17 00:00:00 2001 From: Tanya Lattner Date: Sat, 20 Nov 2004 23:35:20 +0000 Subject: Fixed assertion from triggering. We need to check if the commandline map is empty before checking if an arg exists. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18057 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 5abeb8d2ef..9ae4cde1b2 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -80,6 +80,8 @@ static void AddArgument(const char *ArgName, Option *Opt) { // options have already been processed and the map has been deleted! // static void RemoveArgument(const char *ArgName, Option *Opt) { + if(getOpts().empty()) return; + #ifndef NDEBUG // This disgusting HACK is brought to you courtesy of GCC 3.3.2, which ICE's // If we pass ArgName directly into getOption here. -- cgit v1.2.3-70-g09d2 From 5f8448f79c2876466d586f2e1caec89e6f070623 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 24 Nov 2004 06:13:42 +0000 Subject: Implement and document prefix options with arbitrary values including an = sign. This needed to support -DNAME=value options as pass-through in llvmc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18203 91177308-0d34-0410-b5e6-96231b3b80d8 --- docs/CommandLine.html | 16 +++++++++------- lib/Support/CommandLine.cpp | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/docs/CommandLine.html b/docs/CommandLine.html index 55f54844b4..4f749b7feb 100644 --- a/docs/CommandLine.html +++ b/docs/CommandLine.html @@ -1276,13 +1276,15 @@ Arguments section for more information.
  • specifies that this option is used to capture "interpreter style" arguments. See this section for more information.
  • The cl::Prefix modifier specifies -that this option prefixes its value. With 'Prefix' options, there is no equal -sign that separates the value from the option name specified. This is useful -for processing odd arguments like '-lmalloc -L/usr/lib' in a linker -tool. Here, the 'l' and 'L' options are normal string (list) -options, that have the cl::Prefix modifier added to -allow the CommandLine library to recognize them. Note that cl::Prefix options must not have the -lmalloc and -L/usr/lib in a +linker tool or -DNAME=value in a compiler tool. Here, the +'l', 'D' and 'L' options are normal string (or list) +options, that have the cl::Prefix modifier added to +allow the CommandLine library to recognize them. Note that +cl::Prefix options must not have the cl::ValueDisallowed modifier specified.
  • The cl::Grouping modifier is used diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 9ae4cde1b2..52e4bbded0 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -397,7 +397,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, Handler = LookupOption(ArgName, Value); // Check to see if this "option" is really a prefixed or grouped argument. - if (Handler == 0 && *Value == 0) { + if (Handler == 0) { std::string RealName(ArgName); if (RealName.size() > 1) { unsigned Length = 0; -- cgit v1.2.3-70-g09d2 From a92d12c053510bdad196965a6bac3168d807802e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 14 Feb 2005 19:17:29 +0000 Subject: Work around GCC PR19958, which causes programs to sometimes crash after printing help output or version info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@20180 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 52e4bbded0..f73ec6d878 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -919,6 +919,7 @@ public: MoreHelp().clear(); // Halt the program since help information was printed + getOpts().clear(); // Don't bother making option dtors remove from map. exit(1); } }; @@ -929,6 +930,7 @@ public: if (OptionWasSpecified) { std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " << PACKAGE_VERSION << " (see http://llvm.cs.uiuc.edu/)\n"; + getOpts().clear(); // Don't bother making option dtors remove from map. exit(1); } } -- cgit v1.2.3-70-g09d2 From f976c856fcc5055f3fc7d9f070d72c2d027c1d9d Mon Sep 17 00:00:00 2001 From: Misha Brukman Date: Thu, 21 Apr 2005 22:55:34 +0000 Subject: Remove trailing whitespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21422 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/SelectionDAG/TargetLowering.cpp | 8 +- lib/ExecutionEngine/JIT/Intercept.cpp | 10 +- lib/ExecutionEngine/JIT/JIT.cpp | 14 +-- lib/ExecutionEngine/JIT/JIT.h | 8 +- lib/ExecutionEngine/JIT/JITEmitter.cpp | 12 +- lib/ExecutionEngine/JIT/TargetSelect.cpp | 4 +- lib/Linker/LinkArchives.cpp | 30 ++--- lib/Linker/LinkItems.cpp | 18 +-- lib/Linker/LinkModules.cpp | 36 +++--- lib/Linker/Linker.cpp | 28 ++--- lib/Support/Annotation.cpp | 10 +- lib/Support/CommandLine.cpp | 76 ++++++------ lib/Support/Compressor.cpp | 54 ++++----- lib/Support/Debug.cpp | 4 +- lib/Support/FileUtilities.cpp | 12 +- lib/Support/IsInf.cpp | 6 +- lib/Support/IsNAN.cpp | 6 +- lib/Support/PluginLoader.cpp | 4 +- lib/Support/SlowOperationInformer.cpp | 6 +- lib/Support/Statistic.cpp | 8 +- lib/Support/StringExtras.cpp | 8 +- lib/Support/SystemUtils.cpp | 8 +- lib/Support/Timer.cpp | 14 +-- lib/Support/ToolRunner.cpp | 36 +++--- lib/Support/bzip2/bzlib.h | 172 ++++++++++++++-------------- lib/Support/bzip2/bzlib_private.h | 32 +++--- lib/System/DynamicLibrary.cpp | 10 +- lib/System/MappedFile.cpp | 8 +- lib/System/Memory.cpp | 8 +- lib/System/Path.cpp | 12 +- lib/System/Process.cpp | 8 +- lib/System/Program.cpp | 8 +- lib/System/Signals.cpp | 6 +- lib/System/TimeValue.cpp | 6 +- lib/System/Unix/SUS/Process.cpp | 10 +- lib/System/Unix/Unix.h | 8 +- lib/System/Win32/Win32.h | 6 +- lib/Target/MRegisterInfo.cpp | 6 +- lib/Target/TargetData.cpp | 10 +- lib/Target/TargetFrameInfo.cpp | 12 +- lib/Target/TargetInstrInfo.cpp | 10 +- lib/Target/TargetMachine.cpp | 6 +- lib/Target/TargetMachineRegistry.cpp | 12 +- lib/Target/TargetSchedInfo.cpp | 52 ++++----- tools/bugpoint/ToolRunner.cpp | 36 +++--- 45 files changed, 429 insertions(+), 429 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index 206a806574..7d720f149f 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -1,10 +1,10 @@ //===-- TargetLowering.cpp - Implement the TargetLowering class -----------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This implements the TargetLowering class. @@ -76,7 +76,7 @@ void TargetLowering::computeRegisterProperties() { // Everything defaults to one. for (unsigned i = 0; i != MVT::LAST_VALUETYPE; ++i) NumElementsForVT[i] = 1; - + // Find the largest integer register class. unsigned LargestIntReg = MVT::i128; for (; RegClassForVT[LargestIntReg] == 0; --LargestIntReg) @@ -101,7 +101,7 @@ void TargetLowering::computeRegisterProperties() { TransformToType, ValueTypeActions); else TransformToType[(MVT::ValueType)IntReg] = (MVT::ValueType)IntReg; - + // If the target does not have native support for F32, promote it to F64. if (!hasNativeSupportFor(MVT::f32)) SetValueTypeAction(MVT::f32, Promote, *this, diff --git a/lib/ExecutionEngine/JIT/Intercept.cpp b/lib/ExecutionEngine/JIT/Intercept.cpp index 3c30dbb179..f078e09867 100644 --- a/lib/ExecutionEngine/JIT/Intercept.cpp +++ b/lib/ExecutionEngine/JIT/Intercept.cpp @@ -1,10 +1,10 @@ //===-- Intercept.cpp - System function interception routines -------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // If a function call occurs to an external function, the JIT is designed to use @@ -50,7 +50,7 @@ static void runAtExitHandlers() { #if defined(__linux__) #if defined(HAVE_SYS_STAT_H) #include -#endif +#endif void *FunctionPointers[] = { (void *) stat, (void *) fstat, @@ -84,9 +84,9 @@ static int jit_atexit(void (*Fn)(void)) { } //===----------------------------------------------------------------------===// -// +// /// getPointerToNamedFunction - This method returns the address of the specified -/// function by using the dynamic loader interface. As such it is only useful +/// function by using the dynamic loader interface. As such it is only useful /// for resolving library symbols, not code generated symbols. /// void *JIT::getPointerToNamedFunction(const std::string &Name) { diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp index 1d781d6e4e..0559c53e6c 100644 --- a/lib/ExecutionEngine/JIT/JIT.cpp +++ b/lib/ExecutionEngine/JIT/JIT.cpp @@ -1,10 +1,10 @@ //===-- JIT.cpp - LLVM Just in Time Compiler ------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This tool implements a just-in-time compiler for LLVM, allowing direct @@ -35,7 +35,7 @@ JIT::JIT(ModuleProvider *MP, TargetMachine &tm, TargetJITInfo &tji) // Initialize MCE MCE = createEmitter(*this); - + // Add target data PM.add(new TargetData(TM.getTargetData())); @@ -77,7 +77,7 @@ GenericValue JIT::runFunction(Function *F, if (RetTy == Type::IntTy || RetTy == Type::UIntTy || RetTy == Type::VoidTy) { switch (ArgValues.size()) { case 3: - if ((FTy->getParamType(0) == Type::IntTy || + if ((FTy->getParamType(0) == Type::IntTy || FTy->getParamType(0) == Type::UIntTy) && isa(FTy->getParamType(1)) && isa(FTy->getParamType(2))) { @@ -92,7 +92,7 @@ GenericValue JIT::runFunction(Function *F, } break; case 2: - if ((FTy->getParamType(0) == Type::IntTy || + if ((FTy->getParamType(0) == Type::IntTy || FTy->getParamType(0) == Type::UIntTy) && isa(FTy->getParamType(1))) { int (*PF)(int, char **) = (int(*)(int, char **))FPtr; @@ -105,7 +105,7 @@ GenericValue JIT::runFunction(Function *F, break; case 1: if (FTy->getNumParams() == 1 && - (FTy->getParamType(0) == Type::IntTy || + (FTy->getParamType(0) == Type::IntTy || FTy->getParamType(0) == Type::UIntTy)) { GenericValue rv; int (*PF)(int) = (int(*)(int))FPtr; @@ -239,7 +239,7 @@ void *JIT::getPointerToFunction(Function *F) { return Addr; // Check if function already code gen'd // Make sure we read in the function if it exists in this Module - if (F->hasNotBeenReadFromBytecode()) + if (F->hasNotBeenReadFromBytecode()) try { MP->materializeFunction(F); } catch ( std::string& errmsg ) { diff --git a/lib/ExecutionEngine/JIT/JIT.h b/lib/ExecutionEngine/JIT/JIT.h index 59482369ba..3c14cf71db 100644 --- a/lib/ExecutionEngine/JIT/JIT.h +++ b/lib/ExecutionEngine/JIT/JIT.h @@ -1,10 +1,10 @@ //===-- JIT.h - Class definition for the JIT --------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines the top-level JIT data structure. @@ -30,7 +30,7 @@ class MachineCodeEmitter; class JIT : public ExecutionEngine { TargetMachine &TM; // The current target we are compiling to TargetJITInfo &TJI; // The JITInfo for the target we are compiling to - + FunctionPassManager PM; // Passes to compile a function MachineCodeEmitter *MCE; // MCE object @@ -67,7 +67,7 @@ public: // CompilationCallback - Invoked the first time that a call site is found, // which causes lazy compilation of the target function. - // + // static void CompilationCallback(); /// getPointerToFunction - This returns the address of the specified function, diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp index 8b5071b31d..0905eb18e8 100644 --- a/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -1,10 +1,10 @@ //===-- JITEmitter.cpp - Write machine code to executable memory ----------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines a MachineCodeEmitter object that is used by the JIT to @@ -54,7 +54,7 @@ namespace { public: JITMemoryManager(); ~JITMemoryManager(); - + inline unsigned char *allocateStub(unsigned StubSize); inline unsigned char *allocateConstant(unsigned ConstantSize, unsigned Alignment); @@ -190,7 +190,7 @@ void *JITResolver::getFunctionStub(Function *F) { void *Actual = (void*)LazyResolverFn; if (F->isExternal() && F->hasExternalLinkage()) Actual = TheJIT->getPointerToFunction(F); - + // Otherwise, codegen a new stub. For now, the stub will call the lazy // resolver function. Stub = TheJIT->getJITInfo().emitFunctionStub(Actual, MCE); @@ -230,7 +230,7 @@ void *JITResolver::getExternalFunctionStub(void *FnAddr) { /// it if necessary, then returns the resultant function pointer. void *JITResolver::JITCompilerFn(void *Stub) { JITResolver &JR = getJITResolver(); - + // The address given to us for the stub may not be exactly right, it might be // a little bit after the stub. As such, use upper_bound to find it. std::map::iterator I = @@ -373,7 +373,7 @@ void JITEmitter::finishFunction(MachineFunction &F) { void *ResultPtr; if (MR.isString()) { ResultPtr = TheJIT->getPointerToNamedFunction(MR.getString()); - + // If the target REALLY wants a stub for this function, emit it now. if (!MR.doesntNeedFunctionStub()) ResultPtr = getJITResolver(this).getExternalFunctionStub(ResultPtr); diff --git a/lib/ExecutionEngine/JIT/TargetSelect.cpp b/lib/ExecutionEngine/JIT/TargetSelect.cpp index 7ef06a5220..851b4b4fb0 100644 --- a/lib/ExecutionEngine/JIT/TargetSelect.cpp +++ b/lib/ExecutionEngine/JIT/TargetSelect.cpp @@ -1,10 +1,10 @@ //===-- TargetSelect.cpp - Target Chooser Code ----------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This just asks the TargetMachineRegistry for the appropriate JIT to use, and diff --git a/lib/Linker/LinkArchives.cpp b/lib/Linker/LinkArchives.cpp index af15e0b1ad..5165bad199 100644 --- a/lib/Linker/LinkArchives.cpp +++ b/lib/Linker/LinkArchives.cpp @@ -1,10 +1,10 @@ //===- lib/Linker/LinkArchives.cpp - Link LLVM objects and libraries ------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file contains routines to handle linking together LLVM bytecode files, @@ -26,7 +26,7 @@ using namespace llvm; /// GetAllDefinedSymbols - Modifies its parameter DefinedSymbols to contain the /// name of each externally-visible symbol defined in M. /// -static void +static void GetAllDefinedSymbols(Module *M, std::set &DefinedSymbols) { for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) if (I->hasName() && !I->isExternal() && !I->hasInternalLinkage()) @@ -60,7 +60,7 @@ GetAllUndefinedSymbols(Module *M, std::set &UndefinedSymbols) { Function *Main = M->getMainFunction(); if (Main == 0 || Main->isExternal()) UndefinedSymbols.insert("main"); - + for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) if (I->hasName()) { if (I->isExternal()) @@ -76,7 +76,7 @@ GetAllUndefinedSymbols(Module *M, std::set &UndefinedSymbols) { else if (!I->hasInternalLinkage()) DefinedSymbols.insert(I->getName()); } - + // Prune out any defined symbols from the undefined symbols set... for (std::set::iterator I = UndefinedSymbols.begin(); I != UndefinedSymbols.end(); ) @@ -95,7 +95,7 @@ GetAllUndefinedSymbols(Module *M, std::set &UndefinedSymbols) { /// Return Value: /// TRUE - An error occurred. /// FALSE - No errors. -bool +bool Linker::LinkInArchive(const sys::Path &Filename) { // Make sure this is an archive file we're dealing with @@ -110,9 +110,9 @@ Linker::LinkInArchive(const sys::Path &Filename) { // no reason to link in any archive files. std::set UndefinedSymbols; GetAllUndefinedSymbols(Composite, UndefinedSymbols); - + if (UndefinedSymbols.empty()) { - verbose("No symbols undefined, skipping library '" + + verbose("No symbols undefined, skipping library '" + Filename.toString() + "'"); return false; // No need to link anything in! } @@ -124,7 +124,7 @@ Linker::LinkInArchive(const sys::Path &Filename) { Archive* arch = AutoArch.get(); if (!arch) - return error("Cannot read archive '" + Filename.toString() + + return error("Cannot read archive '" + Filename.toString() + "': " + ErrMsg); // Save a set of symbols that are not defined by the archive. Since we're @@ -133,13 +133,13 @@ Linker::LinkInArchive(const sys::Path &Filename) { std::set NotDefinedByArchive; // While we are linking in object files, loop. - while (true) { + while (true) { // Find the modules we need to link into the target module std::set Modules; arch->findModulesDefiningSymbols(UndefinedSymbols, Modules); - // If we didn't find any more modules to link this time, we are done + // If we didn't find any more modules to link this time, we are done // searching this archive. if (Modules.empty()) break; @@ -162,7 +162,7 @@ Linker::LinkInArchive(const sys::Path &Filename) { // Link it in if (LinkInModule(aModule)) - return error("Cannot link in module '" + + return error("Cannot link in module '" + aModule->getModuleIdentifier() + "': " + Error); } @@ -171,17 +171,17 @@ Linker::LinkInArchive(const sys::Path &Filename) { GetAllUndefinedSymbols(Composite, UndefinedSymbols); // At this point we have two sets of undefined symbols: UndefinedSymbols - // which holds the undefined symbols from all the modules, and + // which holds the undefined symbols from all the modules, and // NotDefinedByArchive which holds symbols we know the archive doesn't // define. There's no point searching for symbols that we won't find in the // archive so we subtract these sets. set_subtract(UndefinedSymbols, NotDefinedByArchive); - + // If there's no symbols left, no point in continuing to search the // archive. if (UndefinedSymbols.empty()) break; } - + return false; } diff --git a/lib/Linker/LinkItems.cpp b/lib/Linker/LinkItems.cpp index b3fb5b00cf..34677ce365 100644 --- a/lib/Linker/LinkItems.cpp +++ b/lib/Linker/LinkItems.cpp @@ -1,10 +1,10 @@ //===- lib/Linker/LinkItems.cpp - Link LLVM objects and libraries ---------===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file contains routines to handle linking together LLVM bytecode files, @@ -21,7 +21,7 @@ using namespace llvm; bool Linker::LinkInItems(const ItemList& Items) { // For each linkage item ... - for (ItemList::const_iterator I = Items.begin(), E = Items.end(); + for (ItemList::const_iterator I = Items.begin(), E = Items.end(); I != E; ++I) { if (I->second) { // Link in the library suggested. @@ -38,7 +38,7 @@ Linker::LinkInItems(const ItemList& Items) { // that module should also be aggregated with duplicates eliminated. This is // now the time to process the dependent libraries to resolve any remaining // symbols. - for (Module::lib_iterator I = Composite->lib_begin(), + for (Module::lib_iterator I = Composite->lib_begin(), E = Composite->lib_end(); I != E; ++I) if(LinkInLibrary(*I)) return true; @@ -95,9 +95,9 @@ bool Linker::LinkInLibraries(const std::vector &Libraries) { // now the time to process the dependent libraries to resolve any remaining // symbols. const Module::LibraryListType& DepLibs = Composite->getLibraries(); - for (Module::LibraryListType::const_iterator I = DepLibs.begin(), - E = DepLibs.end(); I != E; ++I) - if (LinkInLibrary(*I)) + for (Module::LibraryListType::const_iterator I = DepLibs.begin(), + E = DepLibs.end(); I != E; ++I) + if (LinkInLibrary(*I)) return true; return false; @@ -130,7 +130,7 @@ bool Linker::LinkInFile(const sys::Path &File) { verbose("Linking bytecode file '" + File.toString() + "'"); std::auto_ptr M(LoadObject(File)); - if (M.get() == 0) + if (M.get() == 0) return error("Cannot load file '" + File.toString() + "'" + Error); if (LinkInModule(M.get())) return error("Cannot link file '" + File.toString() + "'" + Error); diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 627a38cd0f..6daf061048 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -1,10 +1,10 @@ //===- lib/Linker/LinkModules.cpp - Module Linker Implementation ----------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the LLVM module linker. @@ -98,11 +98,11 @@ static bool RecursiveResolveTypesI(const PATypeHolder &DestTy, const Type *SrcTyT = SrcTy.get(); const Type *DestTyT = DestTy.get(); if (DestTyT == SrcTyT) return false; // If already equal, noop - + // If we found our opaque type, resolve it now! if (isa(DestTyT) || isa(SrcTyT)) return ResolveTypes(DestTyT, SrcTyT, DestST, Name); - + // Two types cannot be resolved together if they are of different primitive // type. For example, we cannot resolve an int to a float. if (DestTyT->getTypeID() != SrcTyT->getTypeID()) return true; @@ -123,7 +123,7 @@ static bool RecursiveResolveTypesI(const PATypeHolder &DestTy, return false; } case Type::StructTyID: { - if (getST(DestTy)->getNumContainedTypes() != + if (getST(DestTy)->getNumContainedTypes() != getST(SrcTy)->getNumContainedTypes()) return 1; for (unsigned i = 0, e = getST(DestTy)->getNumContainedTypes(); i != e; ++i) if (RecursiveResolveTypesI(getST(DestTy)->getContainedType(i), @@ -159,7 +159,7 @@ static bool RecursiveResolveTypesI(const PATypeHolder &DestTy, return Result; } default: assert(0 && "Unexpected type!"); return true; - } + } } static bool RecursiveResolveTypes(const PATypeHolder &DestTy, @@ -229,7 +229,7 @@ static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) { if (!RecursiveResolveTypes(T2, T1, DestST, Name)) { // We are making progress! DelayedTypesToResolve.erase(DelayedTypesToResolve.begin()+i); - + // Go back to the main loop, perhaps we can resolve directly by name // now... break; @@ -407,7 +407,7 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src, } else { assert(Dest->hasExternalLinkage() && Src->hasExternalLinkage() && "Unexpected linkage type!"); - return Error(Err, "Linking globals named '" + Src->getName() + + return Error(Err, "Linking globals named '" + Src->getName() + "': symbol multiply defined!"); } return false; @@ -423,7 +423,7 @@ static bool LinkGlobals(Module *Dest, Module *Src, // We will need a module level symbol table if the src module has a module // level symbol table... SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable(); - + // Loop over all of the globals in the src module, mapping them over as we go for (Module::global_iterator I = Src->global_begin(), E = Src->global_end(); I != E; ++I) { GlobalVariable *SGV = I; @@ -541,11 +541,11 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src, Constant *SInit = cast(RemapOperand(SGV->getInitializer(), ValueMap)); - GlobalVariable *DGV = cast(ValueMap[SGV]); + GlobalVariable *DGV = cast(ValueMap[SGV]); if (DGV->hasInitializer()) { if (SGV->hasExternalLinkage()) { if (DGV->getInitializer() != SInit) - return Error(Err, "Global Variable Collision on '" + + return Error(Err, "Global Variable Collision on '" + ToStr(SGV->getType(), Src) +"':%"+SGV->getName()+ " - Global variables have different initializers"); } else if (DGV->hasLinkOnceLinkage() || DGV->hasWeakLinkage()) { @@ -577,7 +577,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src, std::map &GlobalsByName, std::string *Err) { SymbolTable *ST = (SymbolTable*)&Dest->getSymbolTable(); - + // Loop over all of the functions in the src module, mapping them over as we // go for (Module::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) { @@ -637,8 +637,8 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src, "' have different linkage specifiers!"); } else if (SF->hasExternalLinkage()) { // The function is defined in both modules!! - return Error(Err, "Function '" + - ToStr(SF->getFunctionType(), Src) + "':\"" + + return Error(Err, "Function '" + + ToStr(SF->getFunctionType(), Src) + "':\"" + SF->getName() + "\" - Function is already defined!"); } else { assert(0 && "Unknown linkage configuration found!"); @@ -718,7 +718,7 @@ static bool LinkAppendingVars(Module *M, std::multimap &AppendingVars, std::string *ErrorMsg) { if (AppendingVars.empty()) return false; // Nothing to do. - + // Loop over the multimap of appending vars, processing any variables with the // same name, forming a new appending global variable with both of the // initializers merged together, then rewrite references to the old variables @@ -735,7 +735,7 @@ static bool LinkAppendingVars(Module *M, GlobalVariable *G1 = First->second, *G2 = Second->second; const ArrayType *T1 = cast(G1->getType()->getElementType()); const ArrayType *T2 = cast(G2->getType()->getElementType()); - + // Check to see that they two arrays agree on type... if (T1->getElementType() != T2->getElementType()) return Error(ErrorMsg, @@ -803,7 +803,7 @@ static bool LinkAppendingVars(Module *M, // error occurs, true is returned and ErrorMsg (if not null) is set to indicate // the problem. Upon failure, the Dest module could be in a modified state, and // shouldn't be relied on to be consistent. -bool +bool Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) { assert(Dest != 0 && "Invalid Destination module"); assert(Src != 0 && "Invalid Source Module"); @@ -824,7 +824,7 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) { if (!Src->getTargetTriple().empty() && Dest->getTargetTriple() != Src->getTargetTriple()) std::cerr << "WARNING: Linking two modules of different target triples!\n"; - + // Update the destination module's dependent libraries list with the libraries // from the source module. There's no opportunity for duplicates here as the // Module ensures that duplicate insertions are discarded. diff --git a/lib/Linker/Linker.cpp b/lib/Linker/Linker.cpp index 19fd861c4d..e09c788593 100644 --- a/lib/Linker/Linker.cpp +++ b/lib/Linker/Linker.cpp @@ -1,10 +1,10 @@ //===- lib/Linker/Linker.cpp - Basic Linker functionality ----------------===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file contains basic Linker functionality that all usages will need. @@ -42,7 +42,7 @@ Linker::~Linker() { delete Composite; } -bool +bool Linker::error(const std::string& message) { Error = message; if (!(Flags&QuietErrors)) { @@ -99,23 +99,23 @@ Linker::releaseModule() { } // LoadObject - Read in and parse the bytecode file named by FN and return the -// module it contains (wrapped in an auto_ptr), or auto_ptr() and set +// module it contains (wrapped in an auto_ptr), or auto_ptr() and set // Error if an error occurs. -std::auto_ptr +std::auto_ptr Linker::LoadObject(const sys::Path &FN) { std::string ParseErrorMessage; Module *Result = ParseBytecodeFile(FN.toString(), &ParseErrorMessage); - if (Result) + if (Result) return std::auto_ptr(Result); Error = "Bytecode file '" + FN.toString() + "' could not be loaded"; - if (ParseErrorMessage.size()) + if (ParseErrorMessage.size()) Error += ": " + ParseErrorMessage; return std::auto_ptr(); } -// IsLibrary - Determine if "Name" is a library in "Directory". Return +// IsLibrary - Determine if "Name" is a library in "Directory". Return // a non-empty sys::Path if its found, an empty one otherwise. -static inline sys::Path IsLibrary(const std::string& Name, +static inline sys::Path IsLibrary(const std::string& Name, const sys::Path& Directory) { assert(Directory.isDirectory() && "Need to specify a directory"); @@ -145,15 +145,15 @@ static inline sys::Path IsLibrary(const std::string& Name, /// FindLib - Try to convert Filename into the name of a file that we can open, /// if it does not already name a file we can open, by first trying to open /// Filename, then libFilename.[suffix] for each of a set of several common -/// library suffixes, in each of the directories in LibPaths. Returns an empty +/// library suffixes, in each of the directories in LibPaths. Returns an empty /// Path if no matching file can be found. /// -sys::Path -Linker::FindLib(const std::string &Filename) +sys::Path +Linker::FindLib(const std::string &Filename) { // Determine if the pathname can be found as it stands. sys::Path FilePath(Filename); - if (FilePath.readable() && + if (FilePath.readable() && (FilePath.isArchive() || FilePath.isDynamicLibrary())) return FilePath; diff --git a/lib/Support/Annotation.cpp b/lib/Support/Annotation.cpp index d35904e9b8..b46e218416 100644 --- a/lib/Support/Annotation.cpp +++ b/lib/Support/Annotation.cpp @@ -1,10 +1,10 @@ //===-- Annotation.cpp - Implement the Annotation Classes -----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the AnnotationManager class. @@ -67,7 +67,7 @@ AnnotationID AnnotationManager::getID(const std::string &Name, Factory Fact, void *Data) { AnnotationID Result(getID(Name)); registerAnnotationFactory(Result, Fact, Data); - return Result; + return Result; } // getName - This function is especially slow, but that's okay because it should @@ -82,7 +82,7 @@ const std::string &AnnotationManager::getName(AnnotationID ID) { // ID -> Name } // registerAnnotationFactory - This method is used to register a callback -// function used to create an annotation on demand if it is needed by the +// function used to create an annotation on demand if it is needed by the // Annotable::findOrCreateAnnotation method. // void AnnotationManager::registerAnnotationFactory(AnnotationID ID, AnnFactory F, @@ -96,7 +96,7 @@ void AnnotationManager::registerAnnotationFactory(AnnotationID ID, AnnFactory F, // createAnnotation - Create an annotation of the specified ID for the // specified object, using a register annotation creation function. // -Annotation *AnnotationManager::createAnnotation(AnnotationID ID, +Annotation *AnnotationManager::createAnnotation(AnnotationID ID, const Annotable *Obj) { FactMapType::iterator I = getFactMap().find(ID.ID); if (I == getFactMap().end()) return 0; diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index f73ec6d878..73d26cf619 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -1,10 +1,10 @@ //===-- CommandLine.cpp - Command line parser implementation --------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This class implements a command line argument processor that is useful when @@ -68,7 +68,7 @@ static std::vector &getPositionalOpts() { static void AddArgument(const char *ArgName, Option *Opt) { if (getOption(ArgName)) { - std::cerr << ProgramName << ": CommandLine Error: Argument '" + std::cerr << ProgramName << ": CommandLine Error: Argument '" << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! @@ -78,7 +78,7 @@ static void AddArgument(const char *ArgName, Option *Opt) { // RemoveArgument - It's possible that the argument is no longer in the map if // options have already been processed and the map has been deleted! -// +// static void RemoveArgument(const char *ArgName, Option *Opt) { if(getOpts().empty()) return; @@ -107,15 +107,15 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, break; case ValueDisallowed: if (*Value != 0) - return Handler->error(" does not allow a value! '" + + return Handler->error(" does not allow a value! '" + std::string(Value) + "' specified."); break; - case ValueOptional: + case ValueOptional: break; - default: - std::cerr << ProgramName - << ": Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << "\n"; + default: + std::cerr << ProgramName + << ": Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << "\n"; abort(); break; } @@ -124,7 +124,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, return Handler->addOccurrence(i, ArgName, Value); } -static bool ProvidePositionalOption(Option *Handler, const std::string &Arg, +static bool ProvidePositionalOption(Option *Handler, const std::string &Arg, int i) { int Dummy = i; return ProvideOption(Handler, Handler->ArgStr, Arg.c_str(), 0, 0, Dummy); @@ -147,7 +147,7 @@ static inline bool isPrefixedOrGrouping(const Option *O) { // static Option *getOptionPred(std::string Name, unsigned &Length, bool (*Pred)(const Option*)) { - + Option *Op = getOption(Name); if (Op && Pred(Op)) { Length = Name.length(); @@ -236,7 +236,7 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, // Check args. assert(progName && "Program name not specified"); assert(envVar && "Environment variable name missing"); - + // Get the environment variable they want us to parse options out of. const char *envValue = getenv (envVar); if (!envValue) @@ -265,7 +265,7 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, /// that as well. static Option *LookupOption(const char *&Arg, const char *&Value) { while (*Arg == '-') ++Arg; // Eat leading dashes - + const char *ArgEnd = Arg; while (*ArgEnd && *ArgEnd != '=') ++ArgEnd; // Scan till end of argument name... @@ -273,7 +273,7 @@ static Option *LookupOption(const char *&Arg, const char *&Value) { Value = ArgEnd; if (*Value) // If we have an equals sign... ++Value; // Advance to value... - + if (*Arg == 0) return 0; // Look up the option. @@ -366,7 +366,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // All of the positional arguments have been fulfulled, give the rest to // the consume after option... if it's specified... // - if (PositionalVals.size() >= NumPositionalRequired && + if (PositionalVals.size() >= NumPositionalRequired && ConsumeAfterOpt != 0) { for (++i; i < argc; ++i) PositionalVals.push_back(std::make_pair(argv[i],i)); @@ -402,7 +402,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, if (RealName.size() > 1) { unsigned Length = 0; Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping); - + // If the option is a prefixed option, then the value is simply the // rest of the name... so fall through to later processing, by // setting up the argument name flags and value fields. @@ -415,13 +415,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } else if (PGOpt) { // This must be a grouped option... handle them now. assert(isGrouping(PGOpt) && "Broken getOptionPred!"); - + do { // Move current arg name out of RealName into RealArgName... std::string RealArgName(RealName.begin(), RealName.begin() + Length); RealName.erase(RealName.begin(), RealName.begin() + Length); - + // Because ValueRequired is an invalid flag for grouped arguments, // we don't need to pass argc/argv in... // @@ -430,11 +430,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, int Dummy; ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), "", 0, 0, Dummy); - + // Get the next grouping option... PGOpt = getOptionPred(RealName, Length, isGrouping); } while (PGOpt && Length != RealName.size()); - + Handler = PGOpt; // Ate all of the options. } } @@ -473,13 +473,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // active one... if (Handler->getFormattingFlag() == cl::Positional) ActivePositionalArg = Handler; - else + else ErrorParsing |= ProvideOption(Handler, ArgName, Value, argc, argv, i); } // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - std::cerr << ProgramName + std::cerr << ProgramName << ": Not enough positional command line arguments specified!\n" << "Must specify at least " << NumPositionalRequired << " positional arguments: See: " << argv[0] << " --help\n"; @@ -491,7 +491,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, unsigned ValNo = 0, NumVals = PositionalVals.size(); for (unsigned i = 0, e = PositionalOpts.size(); i != e; ++i) { if (RequiresValue(PositionalOpts[i])) { - ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo].first, + ProvidePositionalOption(PositionalOpts[i], PositionalVals[ValNo].first, PositionalVals[ValNo].second); ValNo++; --NumPositionalRequired; // We fulfilled our duty... @@ -542,7 +542,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, PositionalVals[ValNo].second); ValNo++; } - + // Handle over all of the rest of the arguments to the // cl::ConsumeAfter command line option... for (; ValNo != PositionalVals.size(); ++ValNo) @@ -552,7 +552,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } // Loop over args and make sure all required args are specified! - for (std::map::iterator I = Opts.begin(), + for (std::map::iterator I = Opts.begin(), E = Opts.end(); I != E; ++I) { switch (I->second->getNumOccurrencesFlag()) { case Required: @@ -688,7 +688,7 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const { return Len + 6; } -// printOptionInfo - Print out information about this option. The +// printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // void basic_parser_impl::printOptionInfo(const Option &O, @@ -709,7 +709,7 @@ void basic_parser_impl::printOptionInfo(const Option &O, // bool parser::parse(Option &O, const char *ArgName, const std::string &Arg, bool &Value) { - if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || + if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || Arg == "1") { Value = true; } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") { @@ -727,7 +727,7 @@ bool parser::parse(Option &O, const char *ArgName, const std::string &Arg, int &Value) { char *End; Value = (int)strtol(Arg.c_str(), &End, 0); - if (*End != 0) + if (*End != 0) return O.error(": '" + Arg + "' value invalid for integer argument!"); return false; } @@ -753,7 +753,7 @@ static bool parseDouble(Option &O, const std::string &Arg, double &Value) { const char *ArgStart = Arg.c_str(); char *End; Value = strtod(ArgStart, &End); - if (*End != 0) + if (*End != 0) return O.error(": '" +Arg+ "' value invalid for floating point argument!"); return false; } @@ -808,7 +808,7 @@ unsigned generic_parser_base::getOptionWidth(const Option &O) const { } } -// printOptionInfo - Print out information about this option. The +// printOptionInfo - Print out information about this option. The // to-be-maintained width is specified. // void generic_parser_base::printOptionInfo(const Option &O, @@ -825,7 +825,7 @@ void generic_parser_base::printOptionInfo(const Option &O, } } else { if (O.HelpStr[0]) - std::cerr << " " << O.HelpStr << "\n"; + std::cerr << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned L = std::strlen(getOption(i)); std::cerr << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') @@ -867,7 +867,7 @@ public: copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden - Options.erase(std::remove_if(Options.begin(), Options.end(), + Options.erase(std::remove_if(Options.begin(), Options.end(), std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), Options.end()); @@ -928,7 +928,7 @@ class VersionPrinter { public: void operator=(bool OptionWasSpecified) { if (OptionWasSpecified) { - std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " + std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " << PACKAGE_VERSION << " (see http://llvm.cs.uiuc.edu/)\n"; getOpts().clear(); // Don't bother making option dtors remove from map. exit(1); @@ -943,7 +943,7 @@ public: HelpPrinter NormalPrinter(false); HelpPrinter HiddenPrinter(true); -cl::opt > +cl::opt > HOp("help", cl::desc("display available options (--help-hidden for more)"), cl::location(NormalPrinter), cl::ValueDisallowed); @@ -954,7 +954,7 @@ HHOp("help-hidden", cl::desc("display all available options"), // Define the --version option that prints out the LLVM version for the tool VersionPrinter VersionPrinterInstance; cl::opt > -VersOp("version", cl::desc("display the version"), +VersOp("version", cl::desc("display the version"), cl::location(VersionPrinterInstance), cl::ValueDisallowed); @@ -962,10 +962,10 @@ VersOp("version", cl::desc("display the version"), // Utility function for printing the help message. void cl::PrintHelpMessage() { - // This looks weird, but it actually prints the help message. The + // This looks weird, but it actually prints the help message. The // NormalPrinter variable is a HelpPrinter and the help gets printed when // its operator= is invoked. That's because the "normal" usages of the - // help printer is to be assigned true/false depending on whether the + // help printer is to be assigned true/false depending on whether the // --help option was given or not. Since we're circumventing that we have // to make it look like --help was given, so we assign true. NormalPrinter = true; diff --git a/lib/Support/Compressor.cpp b/lib/Support/Compressor.cpp index 49088b88eb..7396d4ad25 100644 --- a/lib/Support/Compressor.cpp +++ b/lib/Support/Compressor.cpp @@ -1,10 +1,10 @@ //===- lib/Support/Compressor.cpp -------------------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the llvm::Compressor class, an abstraction for memory @@ -26,7 +26,7 @@ enum CompressionTypes { COMP_TYPE_BZIP2 = '2', }; -static int getdata(char*& buffer, size_t &size, +static int getdata(char*& buffer, size_t &size, llvm::Compressor::OutputDataCallback* cb, void* context) { buffer = 0; size = 0; @@ -36,7 +36,7 @@ static int getdata(char*& buffer, size_t &size, return result; } -static int getdata_uns(char*& buffer, unsigned &size, +static int getdata_uns(char*& buffer, unsigned &size, llvm::Compressor::OutputDataCallback* cb, void* context) { size_t SizeOut; int Res = getdata(buffer, SizeOut, cb, context); @@ -45,7 +45,7 @@ static int getdata_uns(char*& buffer, unsigned &size, } //===----------------------------------------------------------------------===// -//=== NULLCOMP - a compression like set of routines that just copies data +//=== NULLCOMP - a compression like set of routines that just copies data //=== without doing any compression. This is provided so that if the //=== configured environment doesn't have a compression library the //=== program can still work, albeit using more data/memory. @@ -121,26 +121,26 @@ namespace { /// This structure is only used when a bytecode file is compressed. /// As bytecode is being decompressed, the memory buffer might need -/// to be reallocated. The buffer allocation is handled in a callback +/// to be reallocated. The buffer allocation is handled in a callback /// and this structure is needed to retain information across calls /// to the callback. /// @brief An internal buffer object used for handling decompression struct BufferContext { char* buff; size_t size; - BufferContext(size_t compressedSize) { + BufferContext(size_t compressedSize) { // Null to indicate malloc of a new block - buff = 0; + buff = 0; // Compute the initial length of the uncompression buffer. Note that this // is twice the length of the compressed buffer and will be doubled again - // in the callback for an initial allocation of 4x compressedSize. This - // calculation is based on the typical compression ratio of bzip2 on LLVM - // bytecode files which typically ranges in the 50%-75% range. Since we - // typically get at least 50%, doubling is insufficient. By using a 4x + // in the callback for an initial allocation of 4x compressedSize. This + // calculation is based on the typical compression ratio of bzip2 on LLVM + // bytecode files which typically ranges in the 50%-75% range. Since we + // typically get at least 50%, doubling is insufficient. By using a 4x // multiplier on the first allocation, we minimize the impact of having to // copy the buffer on reallocation. - size = compressedSize*2; + size = compressedSize*2; } /// trimTo - Reduce the size of the buffer down to the specified amount. This @@ -154,7 +154,7 @@ struct BufferContext { /// This function handles allocation of the buffer used for decompression of /// compressed bytecode files. It is called by Compressor::decompress which is - /// called by BytecodeReader::ParseBytecode. + /// called by BytecodeReader::ParseBytecode. static size_t callback(char*&buff, size_t &sz, void* ctxt){ // Case the context variable to our BufferContext BufferContext* bc = reinterpret_cast(ctxt); @@ -168,9 +168,9 @@ struct BufferContext { // Figure out what to return to the Compressor. If this is the first call, // then bc->buff will be null. In this case we want to return the entire // buffer because there was no previous allocation. Otherwise, when the - // buffer is reallocated, we save the new base pointer in the - // BufferContext.buff field but return the address of only the extension, - // mid-way through the buffer (since its size was doubled). Furthermore, + // buffer is reallocated, we save the new base pointer in the + // BufferContext.buff field but return the address of only the extension, + // mid-way through the buffer (since its size was doubled). Furthermore, // the sz result must be 1/2 the total size of the buffer. if (bc->buff == 0 ) { buff = bc->buff = new_buff; @@ -189,18 +189,18 @@ struct BufferContext { } }; -} // end anonymous namespace +} // end anonymous namespace namespace { // This structure retains the context when compressing the bytecode file. The // WriteCompressedData function below uses it to keep track of the previously -// filled chunk of memory (which it writes) and how many bytes have been +// filled chunk of memory (which it writes) and how many bytes have been // written. struct WriterContext { // Initialize the context - WriterContext(std::ostream*OS, size_t CS) + WriterContext(std::ostream*OS, size_t CS) : chunk(0), sz(0), written(0), compSize(CS), Out(OS) {} // Make sure we clean up memory @@ -219,10 +219,10 @@ struct WriterContext { sz = 0; } - // This function is a callback used by the Compressor::compress function to + // This function is a callback used by the Compressor::compress function to // allocate memory for the compression buffer. This function fulfills that // responsibility but also writes the previous (now filled) buffer out to the - // stream. + // stream. static size_t callback(char*& buffer, size_t &size, void* context) { // Cast the context to the structure it must point to. WriterContext* ctxt = reinterpret_cast(context); @@ -259,7 +259,7 @@ struct WriterContext { } // end anonymous namespace // Compress in one of three ways -size_t Compressor::compress(const char* in, size_t size, +size_t Compressor::compress(const char* in, size_t size, OutputDataCallback* cb, void* context) { assert(in && "Can't compress null buffer"); assert(size && "Can't compress empty buffer"); @@ -355,7 +355,7 @@ size_t Compressor::compressToNewBuffer(const char* in, size_t size, char*&out) { return result; } -size_t +size_t Compressor::compressToStream(const char*in, size_t size, std::ostream& out) { // Set up the context and writer WriterContext ctxt(&out, size / 2); @@ -460,7 +460,7 @@ size_t Compressor::decompress(const char *in, size_t size, return result; } -size_t +size_t Compressor::decompressToNewBuffer(const char* in, size_t size, char*&out) { BufferContext bc(size); size_t result = decompress(in,size,BufferContext::callback,(void*)&bc); @@ -468,7 +468,7 @@ Compressor::decompressToNewBuffer(const char* in, size_t size, char*&out) { return result; } -size_t +size_t Compressor::decompressToStream(const char*in, size_t size, std::ostream& out){ // Set up the context and writer WriterContext ctxt(&out,size / 2); diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index a58716763a..394d9c1109 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -1,10 +1,10 @@ //===-- Debug.cpp - An easy way to add debug output to your code ----------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements a handle way of adding debugging information to your diff --git a/lib/Support/FileUtilities.cpp b/lib/Support/FileUtilities.cpp index 6a65ccae3e..dd296f30a2 100644 --- a/lib/Support/FileUtilities.cpp +++ b/lib/Support/FileUtilities.cpp @@ -1,10 +1,10 @@ //===- Support/FileUtilities.cpp - File System Utilities ------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements a family of utility functions which are useful for doing @@ -24,7 +24,7 @@ using namespace llvm; static bool isNumberChar(char C) { switch (C) { case '0': case '1': case '2': case '3': case '4': - case '5': case '6': case '7': case '8': case '9': + case '5': case '6': case '7': case '8': case '9': case '.': case '+': case '-': case 'e': case 'E': return true; @@ -47,7 +47,7 @@ static bool CompareNumbers(char *&F1P, char *&F2P, char *F1End, char *F2End, double AbsTolerance, double RelTolerance, std::string *ErrorMsg) { char *F1NumEnd, *F2NumEnd; - double V1 = 0.0, V2 = 0.0; + double V1 = 0.0, V2 = 0.0; // If one of the positions is at a space and the other isn't, chomp up 'til // the end of the space. @@ -142,7 +142,7 @@ int llvm::DiffFilesWithTolerance(const sys::Path &FileA, return 1; // Now its safe to mmap the files into memory becasue both files - // have a non-zero size. + // have a non-zero size. sys::MappedFile F1(FileA); sys::MappedFile F2(FileB); F1.map(); @@ -171,7 +171,7 @@ int llvm::DiffFilesWithTolerance(const sys::Path &FileA, // If the files need padding, do so now. PadFileIfNeeded(File1Start, File1End, F1P); PadFileIfNeeded(File2Start, File2End, F2P); - + bool CompareFailed = false; while (1) { // Scan for the end of file or next difference. diff --git a/lib/Support/IsInf.cpp b/lib/Support/IsInf.cpp index e2943b05b5..070ed4fcc1 100644 --- a/lib/Support/IsInf.cpp +++ b/lib/Support/IsInf.cpp @@ -1,10 +1,10 @@ //===-- IsInf.cpp - Platform-independent wrapper around C99 isinf() -------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// #include "llvm/Config/config.h" @@ -26,7 +26,7 @@ static int isinf(double x) { return !finite(x) && x==x; } #define isinf(X) (!_finite(X)) #elif defined(_AIX) && defined(__GNUC__) // GCC's fixincludes seems to be removing the isinf() declaration from the -// system header /usr/include/math.h +// system header /usr/include/math.h # include static int isinf(double x) { return !finite(x) && x==x; } #else diff --git a/lib/Support/IsNAN.cpp b/lib/Support/IsNAN.cpp index f7bb4e3d8e..3300b7b47f 100644 --- a/lib/Support/IsNAN.cpp +++ b/lib/Support/IsNAN.cpp @@ -1,13 +1,13 @@ //===-- IsNAN.cpp ---------------------------------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // -// Platform-independent wrapper around C99 isnan(). +// Platform-independent wrapper around C99 isnan(). // //===----------------------------------------------------------------------===// diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 39e3c0afa5..85b2a310e7 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -1,10 +1,10 @@ //===-- PluginLoader.cpp - Implement -load command line option ------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the -load command line option handler. diff --git a/lib/Support/SlowOperationInformer.cpp b/lib/Support/SlowOperationInformer.cpp index 43faaadaae..671add188e 100644 --- a/lib/Support/SlowOperationInformer.cpp +++ b/lib/Support/SlowOperationInformer.cpp @@ -1,12 +1,12 @@ //===-- SlowOperationInformer.cpp - Keep the user informed ----------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// -// +// // This file implements the SlowOperationInformer class for the LLVM debugger. // //===----------------------------------------------------------------------===// diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index f4d9c7b9e2..f94f246bae 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -1,10 +1,10 @@ //===-- Statistic.cpp - Easy way to expose stats information --------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the 'Statistic' class, which is designed to be an easy @@ -78,9 +78,9 @@ void StatisticBase::destroy() const { // Figure out how long the biggest Value and Name fields are... unsigned MaxNameLen = 0, MaxValLen = 0; for (unsigned i = 0, e = AccumStats->size(); i != e; ++i) { - MaxValLen = std::max(MaxValLen, + MaxValLen = std::max(MaxValLen, (unsigned)(*AccumStats)[i].Value.length()); - MaxNameLen = std::max(MaxNameLen, + MaxNameLen = std::max(MaxNameLen, (unsigned)std::strlen((*AccumStats)[i].Name)); } diff --git a/lib/Support/StringExtras.cpp b/lib/Support/StringExtras.cpp index e8d423a74d..c4016f3e71 100644 --- a/lib/Support/StringExtras.cpp +++ b/lib/Support/StringExtras.cpp @@ -1,10 +1,10 @@ //===-- StringExtras.cpp - Implement the StringExtras header --------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the StringExtras.h header @@ -35,9 +35,9 @@ std::string llvm::getToken(std::string &Source, const char *Delimiters) { // Create the return token. std::string Result = std::string(Source.begin()+Start, Source.begin()+End); - + // Erase the token that we read in. Source.erase(Source.begin(), Source.begin()+End); - + return Result; } diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index 764f6be4eb..c77f962553 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -1,10 +1,10 @@ //===- SystemUtils.cpp - Utilities for low-level system tasks -------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file contains functions used to do a variety of low-level, often @@ -42,14 +42,14 @@ bool llvm::CheckBytecodeOutputToConsole(std::ostream* stream_to_check, #undef FindExecutable // needed on windows :( sys::Path llvm::FindExecutable(const std::string &ExeName, const std::string &ProgramPath) { - // First check the directory that the calling program is in. We can do this + // First check the directory that the calling program is in. We can do this // if ProgramPath contains at least one / character, indicating that it is a // relative path to bugpoint itself. sys::Path Result ( ProgramPath ); Result.elideFile(); if (!Result.isEmpty()) { Result.appendFile(ExeName); - if (Result.executable()) + if (Result.executable()) return Result; } diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index be58238f8b..b0012ceb51 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -1,10 +1,10 @@ //===-- Timer.cpp - Interval Timing Support -------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // Interval Timing implementation. @@ -238,7 +238,7 @@ void Timer::print(const Timer &Total, std::ostream &OS) { if (Total.getProcessTime()) printVal(getProcessTime(), Total.getProcessTime(), OS); printVal(Elapsed, Total.Elapsed, OS); - + OS << " "; if (Total.MemUsed) { @@ -294,10 +294,10 @@ void TimerGroup::removeTimer() { { // Scope to contain Total timer... don't allow total timer to drop us to // zero timers... Timer Total("TOTAL"); - + for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) Total.sum(TimersToPrint[i]); - + // Print out timing header... *OutStream << "===" << std::string(73, '-') << "===\n" << std::string(Padding, ' ') << Name << "\n" @@ -329,11 +329,11 @@ void TimerGroup::removeTimer() { if (Total.getPeakMem()) *OutStream << " -PeakMem-"; *OutStream << " --- Name ---\n"; - + // Loop through all of the timing data, printing it out... for (unsigned i = 0, e = TimersToPrint.size(); i != e; ++i) TimersToPrint[i].print(Total, *OutStream); - + Total.print(Total, *OutStream); *OutStream << std::endl; // Flush output } diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index 2f6f2f43a5..9ef14c5677 100644 --- a/lib/Support/ToolRunner.cpp +++ b/lib/Support/ToolRunner.cpp @@ -1,10 +1,10 @@ //===-- ToolRunner.cpp ----------------------------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the interfaces described in the ToolRunner.h file. @@ -36,8 +36,8 @@ static int RunProgramWithTimeout(const sys::Path &ProgramPath, redirects[0] = &StdInFile; redirects[1] = &StdOutFile; redirects[2] = &StdErrFile; - - return + + return sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, NumSeconds); } @@ -82,12 +82,12 @@ namespace { ToolArgs.clear (); if (Args) { ToolArgs = *Args; } } - + virtual int ExecuteProgram(const std::string &Bytecode, const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs = + const std::vector &SharedLibs = std::vector(), unsigned Timeout = 0); }; @@ -124,7 +124,7 @@ int LLI::ExecuteProgram(const std::string &Bytecode, std::cerr << "\n"; ); return RunProgramWithTimeout(sys::Path(LLIPath), &LLIArgs[0], - sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), + sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), Timeout); } @@ -168,7 +168,7 @@ void LLC::OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile) { std::cerr << " " << LLCArgs[i]; std::cerr << "\n"; ); - if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0], + if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0], sys::Path(), sys::Path(), sys::Path())) ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]); } @@ -228,12 +228,12 @@ namespace { ToolArgs.clear (); if (Args) { ToolArgs = *Args; } } - + virtual int ExecuteProgram(const std::string &Bytecode, const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs = + const std::vector &SharedLibs = std::vector(), unsigned Timeout =0); }; } @@ -271,7 +271,7 @@ int JIT::ExecuteProgram(const std::string &Bytecode, ); DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n"); return RunProgramWithTimeout(sys::Path(LLIPath), &JITArgs[0], - sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), + sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), Timeout); } @@ -313,7 +313,7 @@ void CBE::OutputC(const std::string &Bytecode, sys::Path& OutputCFile) { std::cerr << " " << LLCArgs[i]; std::cerr << "\n"; ); - if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(), + if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(), sys::Path())) ProcessFailure(LLCPath, &LLCArgs[0]); } @@ -335,7 +335,7 @@ int CBE::ExecuteProgram(const std::string &Bytecode, FileRemover CFileRemove(OutputCFile); - return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile, + return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile, InputFile, OutputFile, SharedLibs, Timeout); } @@ -346,7 +346,7 @@ CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath, const std::vector *Args) { sys::Path LLCPath = FindExecutable("llc", ProgramPath); if (LLCPath.isEmpty()) { - Message = + Message = "Cannot find `llc' in executable directory or PATH!\n"; return 0; } @@ -377,7 +377,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, // Specify the shared libraries to link in... for (unsigned i = 0, e = SharedLibs.size(); i != e; ++i) GCCArgs.push_back(SharedLibs[i].c_str()); - + // Specify -x explicitly in case the extension is wonky GCCArgs.push_back("-x"); if (fileType == CFile) { @@ -423,7 +423,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, FileRemover OutputBinaryRemover(OutputBinary); return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0], - sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), + sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), Timeout); } @@ -458,9 +458,9 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType, "-O2", // Optimize the program a bit... 0 }; - + std::cout << "" << std::flush; - if (RunProgramWithTimeout(GCCPath, GCCArgs, sys::Path(), sys::Path(), + if (RunProgramWithTimeout(GCCPath, GCCArgs, sys::Path(), sys::Path(), sys::Path())) { ProcessFailure(GCCPath, GCCArgs); return 1; diff --git a/lib/Support/bzip2/bzlib.h b/lib/Support/bzip2/bzlib.h index 9ac43a169d..6a004f6713 100644 --- a/lib/Support/bzip2/bzlib.h +++ b/lib/Support/bzip2/bzlib.h @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -85,7 +85,7 @@ extern "C" { #define BZ_OUTBUFF_FULL (-8) #define BZ_CONFIG_ERROR (-9) -typedef +typedef struct { char *next_in; unsigned int avail_in; @@ -102,7 +102,7 @@ typedef void *(*bzalloc)(void *,int,int); void (*bzfree)(void *,void *); void *opaque; - } + } bz_stream; @@ -135,34 +135,34 @@ typedef /*-- Core (low-level) library functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( - bz_stream* strm, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( + bz_stream* strm, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzCompress) ( - bz_stream* strm, - int action +BZ_EXTERN int BZ_API(BZ2_bzCompress) ( + bz_stream* strm, + int action ); -BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( - bz_stream *strm, - int verbosity, +BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( + bz_stream *strm, + int verbosity, int small ); -BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( - bz_stream* strm +BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( + bz_stream* strm ); -BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( - bz_stream *strm +BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( + bz_stream *strm ); @@ -174,64 +174,64 @@ BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( typedef void BZFILE; -BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( - int* bzerror, - FILE* f, - int verbosity, +BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( + int* bzerror, + FILE* f, + int verbosity, int small, - void* unused, - int nUnused + void* unused, + int nUnused ); -BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( - int* bzerror, - BZFILE* b +BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( + int* bzerror, + BZFILE* b ); -BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( - int* bzerror, - BZFILE* b, - void** unused, - int* nUnused +BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( + int* bzerror, + BZFILE* b, + void** unused, + int* nUnused ); -BZ_EXTERN int BZ_API(BZ2_bzRead) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN int BZ_API(BZ2_bzRead) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( - int* bzerror, - FILE* f, - int blockSize100k, - int verbosity, - int workFactor +BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( + int* bzerror, + FILE* f, + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN void BZ_API(BZ2_bzWrite) ( - int* bzerror, - BZFILE* b, - void* buf, - int len +BZ_EXTERN void BZ_API(BZ2_bzWrite) ( + int* bzerror, + BZFILE* b, + void* buf, + int len ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in, - unsigned int* nbytes_out +BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in, + unsigned int* nbytes_out ); -BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( - int* bzerror, - BZFILE* b, - int abandon, - unsigned int* nbytes_in_lo32, - unsigned int* nbytes_in_hi32, - unsigned int* nbytes_out_lo32, +BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( + int* bzerror, + BZFILE* b, + int abandon, + unsigned int* nbytes_in_lo32, + unsigned int* nbytes_in_hi32, + unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_hi32 ); #endif @@ -239,23 +239,23 @@ BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( /*-- Utility functions --*/ -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int blockSize100k, - int verbosity, - int workFactor + int blockSize100k, + int verbosity, + int workFactor ); -BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( - char* dest, +BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( + char* dest, unsigned int* destLen, - char* source, + char* source, unsigned int sourceLen, - int small, - int verbosity + int small, + int verbosity ); @@ -283,17 +283,17 @@ BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( int fd, const char *mode ); - + BZ_EXTERN int BZ_API(BZ2_bzread) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzwrite) ( - BZFILE* b, - void* buf, - int len + BZFILE* b, + void* buf, + int len ); BZ_EXTERN int BZ_API(BZ2_bzflush) ( @@ -305,7 +305,7 @@ BZ_EXTERN void BZ_API(BZ2_bzclose) ( ); BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( - BZFILE *b, + BZFILE *b, int *errnum ); #endif diff --git a/lib/Support/bzip2/bzlib_private.h b/lib/Support/bzip2/bzlib_private.h index ff973c3bfd..568334152e 100644 --- a/lib/Support/bzip2/bzlib_private.h +++ b/lib/Support/bzip2/bzlib_private.h @@ -17,16 +17,16 @@ 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. - 2. The origin of this software must not be misrepresented; you must - not claim that you wrote the original software. If you use this - software in a product, an acknowledgment in the product + 2. The origin of this software must not be misrepresented; you must + not claim that you wrote the original software. If you use this + software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. - 4. The name of the author may not be used to endorse or promote - products derived from this software without specific prior written + 4. The name of the author may not be used to endorse or promote + products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS @@ -91,7 +91,7 @@ typedef unsigned short UInt16; #ifndef __GNUC__ #define __inline__ /* */ -#endif +#endif #ifndef BZ_NO_STDIO extern void BZ2_bz__AssertH__fail ( int errcode ); @@ -143,7 +143,7 @@ extern void bz_internal_error ( int errcode ); #define BZ_HDR_Z 0x5a /* 'Z' */ #define BZ_HDR_h 0x68 /* 'h' */ #define BZ_HDR_0 0x30 /* '0' */ - + /*-- Constants for the back end. --*/ #define BZ_MAX_ALPHA_SIZE 258 @@ -303,19 +303,19 @@ typedef /*-- externs for compression. --*/ -extern void +extern void BZ2_blockSort ( EState* ); -extern void +extern void BZ2_compressBlock ( EState*, Bool ); -extern void +extern void BZ2_bsInitWrite ( EState* ); -extern void +extern void BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); -extern void +extern void BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); @@ -459,7 +459,7 @@ typedef Int32 save_N; Int32 save_curr; Int32 save_zt; - Int32 save_zn; + Int32 save_zn; Int32 save_zvec; Int32 save_zj; Int32 save_gSel; @@ -509,13 +509,13 @@ typedef /*-- externs for decompression. --*/ -extern Int32 +extern Int32 BZ2_indexIntoF ( Int32, Int32* ); -extern Int32 +extern Int32 BZ2_decompress ( DState* ); -extern void +extern void BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); diff --git a/lib/System/DynamicLibrary.cpp b/lib/System/DynamicLibrary.cpp index 231cdac19c..18894cbc87 100644 --- a/lib/System/DynamicLibrary.cpp +++ b/lib/System/DynamicLibrary.cpp @@ -1,10 +1,10 @@ //===-- DynamicLibrary.cpp - Runtime link/load libraries --------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This header file implements the operating system DynamicLibrary concept. @@ -33,7 +33,7 @@ using namespace llvm::sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. +//=== independent code. //===----------------------------------------------------------------------===// static bool did_initialize_ltdl = false; @@ -55,7 +55,7 @@ DynamicLibrary::DynamicLibrary() : handle(0) { if (a_handle == 0) throw std::string("Can't open program as dynamic library"); - + handle = a_handle; OpenedHandles.push_back(a_handle); } diff --git a/lib/System/MappedFile.cpp b/lib/System/MappedFile.cpp index b8caa95cdb..1470fbb518 100644 --- a/lib/System/MappedFile.cpp +++ b/lib/System/MappedFile.cpp @@ -1,10 +1,10 @@ //===- MappedFile.cpp - MappedFile Support ----------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the mapped file concept. @@ -19,7 +19,7 @@ using namespace sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. +//=== independent code. //===----------------------------------------------------------------------===// } diff --git a/lib/System/Memory.cpp b/lib/System/Memory.cpp index 71f1948de6..2ec5666ced 100644 --- a/lib/System/Memory.cpp +++ b/lib/System/Memory.cpp @@ -1,10 +1,10 @@ //===- Memory.cpp - Memory Handling Support ---------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines some helpful functions for allocating memory and dealing @@ -20,7 +20,7 @@ using namespace sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. +//=== independent code. //===----------------------------------------------------------------------===// } diff --git a/lib/System/Path.cpp b/lib/System/Path.cpp index d61a015f68..8ac23088a8 100644 --- a/lib/System/Path.cpp +++ b/lib/System/Path.cpp @@ -1,10 +1,10 @@ //===-- Path.cpp - Implement OS Path Concept --------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This header file implements the operating system Path concept. @@ -20,7 +20,7 @@ using namespace sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. +//=== independent code. //===----------------------------------------------------------------------===// Path @@ -33,7 +33,7 @@ Path::GetLLVMConfigDir() { return GetLLVMDefaultConfigDir(); } -LLVMFileType +LLVMFileType sys::IdentifyFileType(const char*magic, unsigned length) { assert(magic && "Invalid magic number string"); assert(length >=4 && "Invalid magic number length"); @@ -69,7 +69,7 @@ Path::isArchive() const { bool Path::isDynamicLibrary() const { - if (readable()) + if (readable()) return hasMagicNumber("\177ELF"); return false; } diff --git a/lib/System/Process.cpp b/lib/System/Process.cpp index ccd30b5c69..c826e5e1f7 100644 --- a/lib/System/Process.cpp +++ b/lib/System/Process.cpp @@ -1,10 +1,10 @@ //===-- Process.cpp - Implement OS Process Concept --------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This header file implements the operating system Process concept. @@ -19,7 +19,7 @@ using namespace sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. +//=== independent code. //===----------------------------------------------------------------------===// } diff --git a/lib/System/Program.cpp b/lib/System/Program.cpp index e9661dab36..abe6e189d2 100644 --- a/lib/System/Program.cpp +++ b/lib/System/Program.cpp @@ -1,10 +1,10 @@ //===-- Program.cpp - Implement OS Program Concept --------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This header file implements the operating system Program concept. @@ -19,7 +19,7 @@ using namespace sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. +//=== independent code. //===----------------------------------------------------------------------===// } diff --git a/lib/System/Signals.cpp b/lib/System/Signals.cpp index cdd730619b..28f70289b5 100644 --- a/lib/System/Signals.cpp +++ b/lib/System/Signals.cpp @@ -1,10 +1,10 @@ //===- Signals.cpp - Signal Handling support --------------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines some helpful functions for dealing with the possibility of @@ -20,7 +20,7 @@ using namespace sys; //===----------------------------------------------------------------------===// //=== WARNING: Implementation here must contain only TRULY operating system -//=== independent code. +//=== independent code. //===----------------------------------------------------------------------===// } diff --git a/lib/System/TimeValue.cpp b/lib/System/TimeValue.cpp index ccf15a2b3e..587e4440fd 100644 --- a/lib/System/TimeValue.cpp +++ b/lib/System/TimeValue.cpp @@ -1,10 +1,10 @@ //===-- TimeValue.cpp - Implement OS TimeValue Concept ----------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the operating system TimeValue concept. diff --git a/lib/System/Unix/SUS/Process.cpp b/lib/System/Unix/SUS/Process.cpp index d10b88ecff..36d475313c 100644 --- a/lib/System/Unix/SUS/Process.cpp +++ b/lib/System/Unix/SUS/Process.cpp @@ -1,10 +1,10 @@ //===- Unix/SUS/Process.cpp - Linux Process Implementation ---- -*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file provides the Linux specific implementation of the Process class. @@ -14,14 +14,14 @@ #include //===----------------------------------------------------------------------===// -//=== WARNING: Implementation here must contain only code specific to the +//=== WARNING: Implementation here must contain only code specific to the //=== SUS (Single Unix Specification). //===----------------------------------------------------------------------===// namespace llvm { using namespace sys; -unsigned +unsigned Process::GetPageSize() { static const long page_size = sysconf(_SC_PAGE_SIZE); return static_cast(page_size); diff --git a/lib/System/Unix/Unix.h b/lib/System/Unix/Unix.h index 741a817f45..32609f2215 100644 --- a/lib/System/Unix/Unix.h +++ b/lib/System/Unix/Unix.h @@ -1,10 +1,10 @@ //===- llvm/System/Unix/Unix.h - Common Unix Include File -------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines things specific to Unix implementations. @@ -37,7 +37,7 @@ #ifdef HAVE_SYS_PARAM_H #include -#endif +#endif #ifdef HAVE_ASSERT_H #include diff --git a/lib/System/Win32/Win32.h b/lib/System/Win32/Win32.h index ab6b3c2b49..6cda8c675f 100644 --- a/lib/System/Win32/Win32.h +++ b/lib/System/Win32/Win32.h @@ -1,10 +1,10 @@ //===- Win32/Win32.h - Common Win32 Include File ----------------*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // -// This file was developed by Reid Spencer and is distributed under the +// This file was developed by Reid Spencer and is distributed under the // University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines things specific to Unix implementations. diff --git a/lib/Target/MRegisterInfo.cpp b/lib/Target/MRegisterInfo.cpp index bd7d9245e8..526964b973 100644 --- a/lib/Target/MRegisterInfo.cpp +++ b/lib/Target/MRegisterInfo.cpp @@ -1,10 +1,10 @@ //===- MRegisterInfo.cpp - Target Register Information Implementation -----===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the MRegisterInfo interface. @@ -38,6 +38,6 @@ std::vector MRegisterInfo::getAllocatableSet(MachineFunction &MF) const { Allocatable[*I] = true; } return Allocatable; -} +} } // End llvm namespace diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 395f25ed67..3c71fdc3e0 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -1,10 +1,10 @@ //===-- TargetData.cpp - Data size & alignment routines --------------------==// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file defines target properties related to datatype size/offset/alignment @@ -43,7 +43,7 @@ StructLayout::StructLayout(const StructType *ST, const TargetData &TD) { StructSize = 0; // Loop over each of the elements, placing them in memory... - for (StructType::element_iterator TI = ST->element_begin(), + for (StructType::element_iterator TI = ST->element_begin(), TE = ST->element_end(); TI != TE; ++TI) { const Type *Ty = *TI; unsigned char A; @@ -95,7 +95,7 @@ unsigned StructLayout::getElementContainingOffset(uint64_t Offset) const { TargetData::TargetData(const std::string &TargetName, bool isLittleEndian, unsigned char PtrSize, unsigned char PtrAl, unsigned char DoubleAl, - unsigned char FloatAl, unsigned char LongAl, + unsigned char FloatAl, unsigned char LongAl, unsigned char IntAl, unsigned char ShortAl, unsigned char ByteAl, unsigned char BoolAl) { @@ -205,7 +205,7 @@ static inline void getTypeInfo(const Type *Ty, const TargetData *TD, Size = Layout->StructSize; Alignment = Layout->StructAlignment; return; } - + default: assert(0 && "Bad type for getTypeInfo!!!"); return; diff --git a/lib/Target/TargetFrameInfo.cpp b/lib/Target/TargetFrameInfo.cpp index 07c1663463..7255b3254f 100644 --- a/lib/Target/TargetFrameInfo.cpp +++ b/lib/Target/TargetFrameInfo.cpp @@ -1,10 +1,10 @@ //===-- TargetFrameInfo.cpp - Implement machine frame interface -*- C++ -*-===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // Implements the layout of a stack frame on the target machine. @@ -22,7 +22,7 @@ using namespace llvm; //===--------------------------------------------------------------------===// // This method adjusts a stack offset to meet alignment rules of target. -int +int TargetFrameInfo::adjustAlignment(int unalignedOffset, bool growUp, unsigned align) const { abort(); @@ -33,7 +33,7 @@ TargetFrameInfo::adjustAlignment(int unalignedOffset, bool growUp, // function. The frame contents are obtained from the MachineFunction object // for the given function. The rest must be implemented by the // machine-specific subclass. -// +// int TargetFrameInfo::getIncomingArgOffset(MachineFunction& mcInfo, unsigned argNum) const { @@ -55,7 +55,7 @@ TargetFrameInfo::getFirstAutomaticVarOffset(MachineFunction& mcInfo, return 0; } -int +int TargetFrameInfo::getRegSpillAreaOffset(MachineFunction& mcInfo, bool& growUp) const { abort(); @@ -68,7 +68,7 @@ TargetFrameInfo::getTmpAreaOffset(MachineFunction& mcInfo, bool& growUp) const { return 0; } -int +int TargetFrameInfo::getDynamicAreaOffset(MachineFunction& mcInfo, bool& growUp) const { abort(); diff --git a/lib/Target/TargetInstrInfo.cpp b/lib/Target/TargetInstrInfo.cpp index c0ae56b0f3..677f36d91b 100644 --- a/lib/Target/TargetInstrInfo.cpp +++ b/lib/Target/TargetInstrInfo.cpp @@ -1,10 +1,10 @@ //===-- TargetInstrInfo.cpp - Target Instruction Information --------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the TargetInstrInfo class. @@ -20,7 +20,7 @@ using namespace llvm; namespace llvm { // External object describing the machine instructions Initialized only when // the TargetMachine class is created and reset when that class is destroyed. - // + // // FIXME: UGLY SPARCV9 HACK! const TargetInstrDescriptor* TargetInstrDescriptors = 0; } @@ -49,13 +49,13 @@ bool TargetInstrInfo::constantFitsInImmedField(MachineOpCode opCode, // NEED TO HANDLE UNSIGNED VALUES SINCE THEY MAY BECOME MUCH // SMALLER AFTER CASTING TO SIGN-EXTENDED int, short, or char. // See CreateUIntSetInstruction in SparcInstrInfo.cpp. - + // Now check if the constant fits if (intValue <= (int64_t) maxImmedValue && intValue >= -((int64_t) maxImmedValue+1)) return true; } - + return false; } diff --git a/lib/Target/TargetMachine.cpp b/lib/Target/TargetMachine.cpp index fc7530addd..8e965767ce 100644 --- a/lib/Target/TargetMachine.cpp +++ b/lib/Target/TargetMachine.cpp @@ -1,10 +1,10 @@ //===-- TargetMachine.cpp - General Target Information ---------------------==// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file describes the general parts of a Target machine. @@ -32,7 +32,7 @@ namespace { cl::desc("Print generated machine code"), cl::location(PrintMachineCode), cl::init(false)); - cl::opt + cl::opt DisableFPElim("disable-fp-elim", cl::desc("Disable frame pointer elimination optimization"), cl::location(NoFramePointerElim), diff --git a/lib/Target/TargetMachineRegistry.cpp b/lib/Target/TargetMachineRegistry.cpp index b5a3a553b3..f753a8c784 100644 --- a/lib/Target/TargetMachineRegistry.cpp +++ b/lib/Target/TargetMachineRegistry.cpp @@ -1,10 +1,10 @@ //===-- TargetMachineRegistry.cpp - Target Auto Registration Impl ---------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file exposes the RegisterTarget class, which TargetMachine @@ -62,7 +62,7 @@ TargetMachineRegistry::getClosestStaticTargetForModule(const Module &M, return 0; } else if (UsableTargets.size() == 1) return UsableTargets.back().second; - + // Otherwise, take the best target, but make sure we don't have to equally // good best targets. std::sort(UsableTargets.begin(), UsableTargets.end()); @@ -91,7 +91,7 @@ TargetMachineRegistry::getClosestTargetForJIT(std::string &Error) { return 0; } else if (UsableTargets.size() == 1) return UsableTargets.back().second; - + // Otherwise, take the best target. If there is a tie, just pick one. unsigned MaxQual = UsableTargets.front().first; const Entry *MaxQualTarget = UsableTargets.front().second; @@ -101,7 +101,7 @@ TargetMachineRegistry::getClosestTargetForJIT(std::string &Error) { MaxQual = UsableTargets[i].first; MaxQualTarget = UsableTargets[i].second; } - + return MaxQualTarget; } - + diff --git a/lib/Target/TargetSchedInfo.cpp b/lib/Target/TargetSchedInfo.cpp index b2f66dbdee..940dab0ed5 100644 --- a/lib/Target/TargetSchedInfo.cpp +++ b/lib/Target/TargetSchedInfo.cpp @@ -1,10 +1,10 @@ //===-- SchedInfo.cpp - Generic code to support target schedulers ----------==// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the generic part of a Scheduler description for a @@ -21,7 +21,7 @@ using namespace llvm; resourceId_t llvm::CPUResource::nextId = 0; static std::vector *CPUResourceMap = 0; - + CPUResource::CPUResource(const std::string& resourceName, int maxUsers) : rname(resourceName), rid(nextId++), maxNumUsers(maxUsers) { if(!CPUResourceMap) @@ -45,8 +45,8 @@ inline static bool RUConflict(const std::vector& fromRVec, const std::vector& toRVec) { - - unsigned fN = fromRVec.size(), tN = toRVec.size(); + + unsigned fN = fromRVec.size(), tN = toRVec.size(); unsigned fi = 0, ti = 0; while (fi < fN && ti < tN) { @@ -62,14 +62,14 @@ RUConflict(const std::vector& fromRVec, static CycleCount_t -ComputeMinGap(const InstrRUsage &fromRU, +ComputeMinGap(const InstrRUsage &fromRU, const InstrRUsage &toRU) { CycleCount_t minGap = 0; - + if (fromRU.numBubbles > 0) minGap = fromRU.numBubbles; - + if (minGap < fromRU.numCycles) { // only need to check from cycle `minGap' onwards for (CycleCount_t gap=minGap; gap <= fromRU.numCycles-1; gap++) { @@ -85,7 +85,7 @@ ComputeMinGap(const InstrRUsage &fromRU, } } } - + return minGap; } @@ -114,11 +114,11 @@ TargetSchedInfo::initializeResources() { assert(MAX_NUM_SLOTS >= (int)getMaxNumIssueTotal() && "Insufficient slots for static data! Increase MAX_NUM_SLOTS"); - + // First, compute common resource usage info for each class because // most instructions will probably behave the same as their class. // Cannot allocate a vector of InstrRUsage so new each one. - // + // std::vector instrRUForClasses; instrRUForClasses.resize(numSchedClasses); for (InstrSchedClass sc = 0; sc < numSchedClasses; sc++) { @@ -126,7 +126,7 @@ TargetSchedInfo::initializeResources() instrRUForClasses[sc].setMaxSlots(getMaxNumIssueTotal()); instrRUForClasses[sc].setTo(classRUsages[sc]); } - + computeInstrResources(instrRUForClasses); computeIssueGaps(instrRUForClasses); } @@ -138,21 +138,21 @@ TargetSchedInfo::computeInstrResources(const std::vector& { int numOpCodes = mii->getNumOpcodes(); instrRUsages.resize(numOpCodes); - + // First get the resource usage information from the class resource usages. for (MachineOpCode op = 0; op < numOpCodes; ++op) { InstrSchedClass sc = getSchedClass(op); assert(sc < numSchedClasses); instrRUsages[op] = instrRUForClasses[sc]; } - + // Now, modify the resource usages as specified in the deltas. for (unsigned i = 0; i < numUsageDeltas; ++i) { MachineOpCode op = usageDeltas[i].opCode; assert(op < numOpCodes); instrRUsages[op].addUsageDelta(usageDeltas[i]); } - + // Then modify the issue restrictions as specified in the deltas. for (unsigned i = 0; i < numIssueDeltas; ++i) { MachineOpCode op = issueDeltas[i].opCode; @@ -173,14 +173,14 @@ TargetSchedInfo::computeIssueGaps(const std::vector& // First, compute issue gaps between pairs of classes based on common // resources usages for each class, because most instruction pairs will // usually behave the same as their class. - // + // int* classPairGaps = static_cast(alloca(sizeof(int) * numSchedClasses * numSchedClasses)); for (InstrSchedClass fromSC=0; fromSC < numSchedClasses; fromSC++) for (InstrSchedClass toSC=0; toSC < numSchedClasses; toSC++) { int classPairGap = ComputeMinGap(instrRUForClasses[fromSC], instrRUForClasses[toSC]); - classPairGaps[fromSC*numSchedClasses + toSC] = classPairGap; + classPairGaps[fromSC*numSchedClasses + toSC] = classPairGap; } // Now, for each pair of instructions, use the class pair gap if both @@ -191,7 +191,7 @@ TargetSchedInfo::computeIssueGaps(const std::vector& for (MachineOpCode fromOp=0; fromOp < numOpCodes; fromOp++) for (MachineOpCode toOp=0; toOp < numOpCodes; toOp++) { - int instrPairGap = + int instrPairGap = (instrRUsages[fromOp].sameAsClass && instrRUsages[toOp].sameAsClass) ? classPairGaps[getSchedClass(fromOp)*numSchedClasses + getSchedClass(toOp)] : ComputeMinGap(instrRUsages[fromOp], instrRUsages[toOp]); @@ -208,23 +208,23 @@ TargetSchedInfo::computeIssueGaps(const std::vector& void InstrRUsage::setTo(const InstrClassRUsage& classRU) { sameAsClass = true; isSingleIssue = classRU.isSingleIssue; - breaksGroup = classRU.breaksGroup; + breaksGroup = classRU.breaksGroup; numBubbles = classRU.numBubbles; - + for (unsigned i=0; i < classRU.numSlots; i++) { unsigned slot = classRU.feasibleSlots[i]; assert(slot < feasibleSlots.size() && "Invalid slot specified!"); this->feasibleSlots[slot] = true; } - + numCycles = classRU.totCycles; resourcesByCycle.resize(this->numCycles); - + for (unsigned i=0; i < classRU.numRUEntries; i++) for (unsigned c=classRU.V[i].startCycle, NC = c + classRU.V[i].numCycles; c < NC; c++) this->resourcesByCycle[c].push_back(classRU.V[i].resourceId); - + // Sort each resource usage vector by resourceId_t to speed up conflict // checking for (unsigned i=0; i < this->resourcesByCycle.size(); i++) @@ -234,11 +234,11 @@ void InstrRUsage::setTo(const InstrClassRUsage& classRU) { // Add the extra resource usage requirements specified in the delta. // Note that a negative value of `numCycles' means one entry for that // resource should be deleted for each cycle. -// +// void InstrRUsage::addUsageDelta(const InstrRUsageDelta &delta) { int NC = delta.numCycles; sameAsClass = false; - + // resize the resources vector if more cycles are specified unsigned maxCycles = this->numCycles; maxCycles = std::max(maxCycles, delta.startCycle + abs(NC) - 1); @@ -246,7 +246,7 @@ void InstrRUsage::addUsageDelta(const InstrRUsageDelta &delta) { this->resourcesByCycle.resize(maxCycles); this->numCycles = maxCycles; } - + if (NC >= 0) for (unsigned c=delta.startCycle, last=c+NC-1; c <= last; c++) this->resourcesByCycle[c].push_back(delta.resourceId); diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 2f6f2f43a5..9ef14c5677 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -1,10 +1,10 @@ //===-- ToolRunner.cpp ----------------------------------------------------===// -// +// // The LLVM Compiler Infrastructure // // This file was developed by the LLVM research group and is distributed under // the University of Illinois Open Source License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This file implements the interfaces described in the ToolRunner.h file. @@ -36,8 +36,8 @@ static int RunProgramWithTimeout(const sys::Path &ProgramPath, redirects[0] = &StdInFile; redirects[1] = &StdOutFile; redirects[2] = &StdErrFile; - - return + + return sys::Program::ExecuteAndWait(ProgramPath, Args, 0, redirects, NumSeconds); } @@ -82,12 +82,12 @@ namespace { ToolArgs.clear (); if (Args) { ToolArgs = *Args; } } - + virtual int ExecuteProgram(const std::string &Bytecode, const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs = + const std::vector &SharedLibs = std::vector(), unsigned Timeout = 0); }; @@ -124,7 +124,7 @@ int LLI::ExecuteProgram(const std::string &Bytecode, std::cerr << "\n"; ); return RunProgramWithTimeout(sys::Path(LLIPath), &LLIArgs[0], - sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), + sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), Timeout); } @@ -168,7 +168,7 @@ void LLC::OutputAsm(const std::string &Bytecode, sys::Path &OutputAsmFile) { std::cerr << " " << LLCArgs[i]; std::cerr << "\n"; ); - if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0], + if (RunProgramWithTimeout(sys::Path(LLCPath), &LLCArgs[0], sys::Path(), sys::Path(), sys::Path())) ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]); } @@ -228,12 +228,12 @@ namespace { ToolArgs.clear (); if (Args) { ToolArgs = *Args; } } - + virtual int ExecuteProgram(const std::string &Bytecode, const std::vector &Args, const std::string &InputFile, const std::string &OutputFile, - const std::vector &SharedLibs = + const std::vector &SharedLibs = std::vector(), unsigned Timeout =0); }; } @@ -271,7 +271,7 @@ int JIT::ExecuteProgram(const std::string &Bytecode, ); DEBUG(std::cerr << "\nSending output to " << OutputFile << "\n"); return RunProgramWithTimeout(sys::Path(LLIPath), &JITArgs[0], - sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), + sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), Timeout); } @@ -313,7 +313,7 @@ void CBE::OutputC(const std::string &Bytecode, sys::Path& OutputCFile) { std::cerr << " " << LLCArgs[i]; std::cerr << "\n"; ); - if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(), + if (RunProgramWithTimeout(LLCPath, &LLCArgs[0], sys::Path(), sys::Path(), sys::Path())) ProcessFailure(LLCPath, &LLCArgs[0]); } @@ -335,7 +335,7 @@ int CBE::ExecuteProgram(const std::string &Bytecode, FileRemover CFileRemove(OutputCFile); - return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile, + return gcc->ExecuteProgram(OutputCFile.toString(), Args, GCC::CFile, InputFile, OutputFile, SharedLibs, Timeout); } @@ -346,7 +346,7 @@ CBE *AbstractInterpreter::createCBE(const std::string &ProgramPath, const std::vector *Args) { sys::Path LLCPath = FindExecutable("llc", ProgramPath); if (LLCPath.isEmpty()) { - Message = + Message = "Cannot find `llc' in executable directory or PATH!\n"; return 0; } @@ -377,7 +377,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, // Specify the shared libraries to link in... for (unsigned i = 0, e = SharedLibs.size(); i != e; ++i) GCCArgs.push_back(SharedLibs[i].c_str()); - + // Specify -x explicitly in case the extension is wonky GCCArgs.push_back("-x"); if (fileType == CFile) { @@ -423,7 +423,7 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, FileRemover OutputBinaryRemover(OutputBinary); return RunProgramWithTimeout(OutputBinary, &ProgramArgs[0], - sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), + sys::Path(InputFile), sys::Path(OutputFile), sys::Path(OutputFile), Timeout); } @@ -458,9 +458,9 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType, "-O2", // Optimize the program a bit... 0 }; - + std::cout << "" << std::flush; - if (RunProgramWithTimeout(GCCPath, GCCArgs, sys::Path(), sys::Path(), + if (RunProgramWithTimeout(GCCPath, GCCArgs, sys::Path(), sys::Path(), sys::Path())) { ProcessFailure(GCCPath, GCCArgs); return 1; -- cgit v1.2.3-70-g09d2 From 6d5857e139df71410e98ccf6cd0e783f90a9fc16 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 10 May 2005 23:20:17 +0000 Subject: Do not use "" as a sentinal for a missing argument! This fixes PR560. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21850 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 73d26cf619..533d7d5606 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -97,7 +97,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, // Enforce value requirements switch (Handler->getValueExpectedFlag()) { case ValueRequired: - if (Value == 0 || *Value == 0) { // No value specified? + if (Value == 0) { // No value specified? if (i+1 < argc) { // Steal the next argument, like for '-o filename' Value = argv[++i]; } else { @@ -106,7 +106,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, } break; case ValueDisallowed: - if (*Value != 0) + if (Value) return Handler->error(" does not allow a value! '" + std::string(Value) + "' specified."); break; @@ -121,7 +121,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, } // Run the handler now! - return Handler->addOccurrence(i, ArgName, Value); + return Handler->addOccurrence(i, ArgName, Value ? Value : ""); } static bool ProvidePositionalOption(Option *Handler, const std::string &Arg, @@ -268,11 +268,11 @@ static Option *LookupOption(const char *&Arg, const char *&Value) { const char *ArgEnd = Arg; while (*ArgEnd && *ArgEnd != '=') - ++ArgEnd; // Scan till end of argument name... + ++ArgEnd; // Scan till end of argument name. + + if (*ArgEnd == '=') // If we have an equals sign... + Value = ArgEnd+1; // Get the value, not the equals - Value = ArgEnd; - if (*Value) // If we have an equals sign... - ++Value; // Advance to value... if (*Arg == 0) return 0; @@ -348,7 +348,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { Option *Handler = 0; - const char *Value = ""; + const char *Value = 0; const char *ArgName = ""; // Check to see if this is a positional argument. This argument is @@ -429,7 +429,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, "Option can not be cl::Grouping AND cl::ValueRequired!"); int Dummy; ErrorParsing |= ProvideOption(PGOpt, RealArgName.c_str(), - "", 0, 0, Dummy); + 0, 0, 0, Dummy); // Get the next grouping option... PGOpt = getOptionPred(RealName, Length, isGrouping); @@ -450,7 +450,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check to see if this option accepts a comma separated list of values. If // it does, we have to split up the value into multiple values... - if (Handler->getMiscFlags() & CommaSeparated) { + if (Value && Handler->getMiscFlags() & CommaSeparated) { std::string Val(Value); std::string::size_type Pos = Val.find(','); @@ -591,7 +591,8 @@ bool Option::error(std::string Message, const char *ArgName) { return true; } -bool Option::addOccurrence(unsigned pos, const char *ArgName, const std::string &Value) { +bool Option::addOccurrence(unsigned pos, const char *ArgName, + const std::string &Value) { NumOccurrences++; // Increment the number of times we have been seen switch (getNumOccurrencesFlag()) { -- cgit v1.2.3-70-g09d2 From 4bf7afcc271138512c38ab2e4a348e2fe6164140 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 13 May 2005 19:49:09 +0000 Subject: Capitalize git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21964 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 533d7d5606..e0a8e4d51b 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -945,17 +945,17 @@ HelpPrinter NormalPrinter(false); HelpPrinter HiddenPrinter(true); cl::opt > -HOp("help", cl::desc("display available options (--help-hidden for more)"), +HOp("help", cl::desc("Display available options (--help-hidden for more)"), cl::location(NormalPrinter), cl::ValueDisallowed); cl::opt > -HHOp("help-hidden", cl::desc("display all available options"), +HHOp("help-hidden", cl::desc("Display all available options"), cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); // Define the --version option that prints out the LLVM version for the tool VersionPrinter VersionPrinterInstance; cl::opt > -VersOp("version", cl::desc("display the version"), +VersOp("version", cl::desc("Display the version of this program"), cl::location(VersionPrinterInstance), cl::ValueDisallowed); -- cgit v1.2.3-70-g09d2 From de0132453e2939488c2d69290bfdfb2cde94a0af Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 8 Aug 2005 17:25:38 +0000 Subject: Reject command lines that have too many positional arguments passed (e.g., 'opt x y'). This fixes PR493. Patch contributed by Owen Anderson! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22705 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index e0a8e4d51b..09038d3a5f 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -297,6 +297,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check out the positional arguments to collect information about them. unsigned NumPositionalRequired = 0; + + // Determine whether or not there are an unlimited number of positionals + bool HasUnlimitedPositionals = false; + Option *ConsumeAfterOpt = 0; if (!PositionalOpts.empty()) { if (PositionalOpts[0]->getNumOccurrencesFlag() == cl::ConsumeAfter) { @@ -331,6 +335,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, " does not require a value!"); } UnboundedFound |= EatsUnboundedNumberOfValues(Opt); + + if (Opt->getNumOccurrencesFlag() == cl::ZeroOrMore + || Opt->getNumOccurrencesFlag() == cl::OneOrMore) + HasUnlimitedPositionals = true; } } @@ -484,7 +492,13 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, << "Must specify at least " << NumPositionalRequired << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; - + } else if (!HasUnlimitedPositionals + && PositionalVals.size() > PositionalOpts.size()) { + std::cerr << ProgramName + << ": Too many positional arguments specified!\n" + << "Can specify at most " << PositionalOpts.size() + << " positional arguments: See: " << argv[0] << " --help\n"; + ErrorParsing = true; } else if (ConsumeAfterOpt == 0) { // Positional args have already been handled if ConsumeAfter is specified... -- cgit v1.2.3-70-g09d2 From 21e1a79a31fe45fcd861d64118a60c1fcfad618a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 8 Aug 2005 21:57:27 +0000 Subject: Allow tools with "consume after" options (like lli) to take more positional opts than they take directly. Thanks to John C for pointing this problem out to me! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22717 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 09038d3a5f..b53706f168 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -335,11 +335,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, " does not require a value!"); } UnboundedFound |= EatsUnboundedNumberOfValues(Opt); - - if (Opt->getNumOccurrencesFlag() == cl::ZeroOrMore - || Opt->getNumOccurrencesFlag() == cl::OneOrMore) - HasUnlimitedPositionals = true; } + HasUnlimitedPositionals = UnboundedFound || ConsumeAfterOpt; } // PositionalVals - A vector of "positional" arguments we accumulate into -- cgit v1.2.3-70-g09d2 From d5bd52ca480d914845c31185b9fe10449de505b8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 16 Nov 2005 06:36:47 +0000 Subject: indicate when a tool is a debug build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24374 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index b53706f168..95887e3c08 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -941,7 +941,12 @@ public: void operator=(bool OptionWasSpecified) { if (OptionWasSpecified) { std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " - << PACKAGE_VERSION << " (see http://llvm.cs.uiuc.edu/)\n"; + << PACKAGE_VERSION << " (see http://llvm.org/)"; +#ifndef NDEBUG + std::cerr << " DEBUG BUILD\n"; +#else + std::cerr << "\n"; +#endif getOpts().clear(); // Don't bother making option dtors remove from map. exit(1); } -- cgit v1.2.3-70-g09d2 From 786e3e22a98ce45782932478f76cf8007fb73ec4 Mon Sep 17 00:00:00 2001 From: Duraid Madina Date: Mon, 26 Dec 2005 04:56:16 +0000 Subject: MERRY CHRISTMAS EVERYONE!!! (what better way to spend christmas than to try building LLVM on HP-UX! (the Right Way seems to be to tear out the ancient STL that HP ship and use http://incubator.apache.org/stdcxx/ ) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25012 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 95887e3c08..6aa6c09129 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -19,6 +19,7 @@ #include "llvm/Config/config.h" #include "llvm/Support/CommandLine.h" #include +#include #include #include #include -- cgit v1.2.3-70-g09d2 From 79959d21c7b2fb7bb970949b9a5227036cd50d39 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 17 Jan 2006 00:32:28 +0000 Subject: Add support for programs with a null argv[0] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25379 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 34 ++++++++++++++++++++++++---------- lib/Support/ToolRunner.cpp | 8 ++++++++ tools/bugpoint/ToolRunner.cpp | 8 ++++++++ 3 files changed, 40 insertions(+), 10 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 6aa6c09129..1644308077 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -448,8 +448,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - std::cerr << ProgramName << ": Unknown command line argument '" << argv[i] - << "'. Try: '" << argv[0] << " --help'\n"; + if (ProgramName) + std::cerr << ProgramName << ": Unknown command line argument '" + << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; + else + std::cerr << "Unknown command line argument '" << argv[i] << "'.\n"; ErrorParsing = true; continue; } @@ -485,17 +488,28 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - std::cerr << ProgramName - << ": Not enough positional command line arguments specified!\n" - << "Must specify at least " << NumPositionalRequired - << " positional arguments: See: " << argv[0] << " --help\n"; + if (ProgramName) + std::cerr << ProgramName + << ": Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; + else + std::cerr << "Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional arguments."; + ErrorParsing = true; } else if (!HasUnlimitedPositionals && PositionalVals.size() > PositionalOpts.size()) { - std::cerr << ProgramName - << ": Too many positional arguments specified!\n" - << "Can specify at most " << PositionalOpts.size() - << " positional arguments: See: " << argv[0] << " --help\n"; + if (ProgramName) + std::cerr << ProgramName + << ": Too many positional arguments specified!\n" + << "Can specify at most " << PositionalOpts.size() + << " positional arguments: See: " << argv[0] << " --help\n"; + else + std::cerr << "Too many positional arguments specified!\n" + << "Can specify at most " << PositionalOpts.size() + << " positional arguments.\n"; ErrorParsing = true; } else if (ConsumeAfterOpt == 0) { diff --git a/lib/Support/ToolRunner.cpp b/lib/Support/ToolRunner.cpp index 6480c23cd8..5eb763a88a 100644 --- a/lib/Support/ToolRunner.cpp +++ b/lib/Support/ToolRunner.cpp @@ -394,7 +394,15 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, sys::Path OutputBinary (ProgramFile+".gcc.exe"); OutputBinary.makeUnique(); GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file... + GCCArgs.push_back("-lz"); GCCArgs.push_back("-lm"); // Hard-code the math library... + GCCArgs.push_back("-x"); + GCCArgs.push_back("none"); + GCCArgs.push_back("/usr/local/lib/NAGWare/quickfit.o"); + GCCArgs.push_back("-Xlinker"); + GCCArgs.push_back("-flat_namespace"); + GCCArgs.push_back("/usr/local/lib/NAGWare/libf97.dylib"); + GCCArgs.push_back("/usr/local/lib/NAGWare/libf96.a"); GCCArgs.push_back("-O2"); // Optimize the program a bit... #if defined (HAVE_LINK_R) GCCArgs.push_back("-Wl,-R."); // Search this dir for .so files diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 6480c23cd8..5eb763a88a 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -394,7 +394,15 @@ int GCC::ExecuteProgram(const std::string &ProgramFile, sys::Path OutputBinary (ProgramFile+".gcc.exe"); OutputBinary.makeUnique(); GCCArgs.push_back(OutputBinary.c_str()); // Output to the right file... + GCCArgs.push_back("-lz"); GCCArgs.push_back("-lm"); // Hard-code the math library... + GCCArgs.push_back("-x"); + GCCArgs.push_back("none"); + GCCArgs.push_back("/usr/local/lib/NAGWare/quickfit.o"); + GCCArgs.push_back("-Xlinker"); + GCCArgs.push_back("-flat_namespace"); + GCCArgs.push_back("/usr/local/lib/NAGWare/libf97.dylib"); + GCCArgs.push_back("/usr/local/lib/NAGWare/libf96.a"); GCCArgs.push_back("-O2"); // Optimize the program a bit... #if defined (HAVE_LINK_R) GCCArgs.push_back("-Wl,-R."); // Search this dir for .so files -- cgit v1.2.3-70-g09d2 From a0de843535627977d107bbe84e4ad20cd2a5060a Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 28 Apr 2006 05:36:25 +0000 Subject: Fix PR743: emit -help output of a tool to cout, not cerr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28010 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 1644308077..90867e7da7 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -690,10 +690,10 @@ unsigned alias::getOptionWidth() const { return std::strlen(ArgStr)+6; } -// Print out the option for the alias... +// Print out the option for the alias. void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - std::cerr << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " + std::cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " << HelpStr << "\n"; } @@ -720,12 +720,12 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const { // void basic_parser_impl::printOptionInfo(const Option &O, unsigned GlobalWidth) const { - std::cerr << " -" << O.ArgStr; + std::cout << " -" << O.ArgStr; if (const char *ValName = getValueName()) - std::cerr << "=<" << getValueStr(O, ValName) << ">"; + std::cout << "=<" << getValueStr(O, ValName) << ">"; - std::cerr << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " + std::cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " << O.HelpStr << "\n"; } @@ -842,20 +842,20 @@ void generic_parser_base::printOptionInfo(const Option &O, unsigned GlobalWidth) const { if (O.hasArgStr()) { unsigned L = std::strlen(O.ArgStr); - std::cerr << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') + std::cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; - std::cerr << " =" << getOption(i) << std::string(NumSpaces, ' ') + std::cout << " =" << getOption(i) << std::string(NumSpaces, ' ') << " - " << getDescription(i) << "\n"; } } else { if (O.HelpStr[0]) - std::cerr << " " << O.HelpStr << "\n"; + std::cout << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned L = std::strlen(getOption(i)); - std::cerr << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') + std::cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') << " - " << getDescription(i) << "\n"; } } @@ -909,9 +909,9 @@ public: } if (ProgramOverview) - std::cerr << "OVERVIEW:" << ProgramOverview << "\n"; + std::cout << "OVERVIEW:" << ProgramOverview << "\n"; - std::cerr << "USAGE: " << ProgramName << " [options]"; + std::cout << "USAGE: " << ProgramName << " [options]"; // Print out the positional options... std::vector &PosOpts = getPositionalOpts(); @@ -921,28 +921,28 @@ public: for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { if (PosOpts[i]->ArgStr[0]) - std::cerr << " --" << PosOpts[i]->ArgStr; - std::cerr << " " << PosOpts[i]->HelpStr; + std::cout << " --" << PosOpts[i]->ArgStr; + std::cout << " " << PosOpts[i]->HelpStr; } // Print the consume after option info if it exists... - if (CAOpt) std::cerr << " " << CAOpt->HelpStr; + if (CAOpt) std::cout << " " << CAOpt->HelpStr; - std::cerr << "\n\n"; + std::cout << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; for (unsigned i = 0, e = Options.size(); i != e; ++i) MaxArgLen = std::max(MaxArgLen, Options[i].second->getOptionWidth()); - std::cerr << "OPTIONS:\n"; + std::cout << "OPTIONS:\n"; for (unsigned i = 0, e = Options.size(); i != e; ++i) Options[i].second->printOptionInfo(MaxArgLen); // Print any extra help the user has declared. for (std::vector::iterator I = MoreHelp().begin(), E = MoreHelp().end(); I != E; ++I) - std::cerr << *I; + std::cout << *I; MoreHelp().clear(); // Halt the program since help information was printed @@ -955,12 +955,12 @@ class VersionPrinter { public: void operator=(bool OptionWasSpecified) { if (OptionWasSpecified) { - std::cerr << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " + std::cout << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " << PACKAGE_VERSION << " (see http://llvm.org/)"; #ifndef NDEBUG - std::cerr << " DEBUG BUILD\n"; + std::cout << " ASSERTIONS ENABLED\n"; #else - std::cerr << "\n"; + std::cout << "\n"; #endif getOpts().clear(); // Don't bother making option dtors remove from map. exit(1); -- cgit v1.2.3-70-g09d2 From 515b5b379f3508f36f647bfdafce409e28a3d90b Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 5 Jun 2006 16:22:56 +0000 Subject: Make it possible to override the standard version printer. Not all tools built with CommandLine.h will want the --version option to report that the tool belongs to LLVM. To override simply pass a void func() to the cl::SetVersionPrinter() function and that void func() will be called when it is time to print the version information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@28687 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 7 ++++++ lib/Support/CommandLine.cpp | 47 +++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 18 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 19b5f29fb7..8517032fef 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -48,6 +48,13 @@ void ParseCommandLineOptions(int &argc, char **argv, void ParseEnvironmentOptions(const char *progName, const char *envvar, const char *Overview = 0); +///===---------------------------------------------------------------------===// +/// SetVersionPrinter - Override the default (LLVM specific) version printer +/// used to print out the version when --version is given +/// on the command line. This gives other systems using the +/// CommandLine utilities to print their own version string. +void SetVersionPrinter(void (*func)()); + //===----------------------------------------------------------------------===// // Flags permitted to be passed to command line arguments // diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 90867e7da7..4b3a1d8f7d 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -951,24 +951,6 @@ public: } }; -class VersionPrinter { -public: - void operator=(bool OptionWasSpecified) { - if (OptionWasSpecified) { - std::cout << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " - << PACKAGE_VERSION << " (see http://llvm.org/)"; -#ifndef NDEBUG - std::cout << " ASSERTIONS ENABLED\n"; -#else - std::cout << "\n"; -#endif - getOpts().clear(); // Don't bother making option dtors remove from map. - exit(1); - } - } -}; - - // Define the two HelpPrinter instances that are used to print out help, or // help-hidden... // @@ -983,6 +965,31 @@ cl::opt > HHOp("help-hidden", cl::desc("Display all available options"), cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); +void (*OverrideVersionPrinter)() = 0; + +class VersionPrinter { +public: + void operator=(bool OptionWasSpecified) { + if (OptionWasSpecified) { + if (OverrideVersionPrinter == 0) { + std::cout << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " + << PACKAGE_VERSION << " (see http://llvm.org/)"; +#ifndef NDEBUG + std::cout << " ASSERTIONS ENABLED\n"; +#else + std::cout << "\n"; +#endif + getOpts().clear(); // Don't bother making option dtors remove from map. + exit(1); + } else { + (*OverrideVersionPrinter)(); + exit(1); + } + } + } +}; + + // Define the --version option that prints out the LLVM version for the tool VersionPrinter VersionPrinterInstance; cl::opt > @@ -1002,3 +1009,7 @@ void cl::PrintHelpMessage() { // to make it look like --help was given, so we assign true. NormalPrinter = true; } + +void cl::SetVersionPrinter(void (*func)()) { + OverrideVersionPrinter = func; +} -- cgit v1.2.3-70-g09d2 From 3fc2f4e83f3317f592c06e2ae7d9f1832210decb Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 6 Jul 2006 18:33:03 +0000 Subject: Print LLVM version info like this: Low Level Virtual Machine (http://llvm.org/): llvm version 1.8cvs DEBUG build with assertions. instead of like this: Low Level Virtual Machine (llvm) 1.8cvs (see http://llvm.org/) ASSERTIONS ENABLED Also, add a place for vendor version info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29020 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 4b3a1d8f7d..164cb5286f 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -972,13 +972,21 @@ public: void operator=(bool OptionWasSpecified) { if (OptionWasSpecified) { if (OverrideVersionPrinter == 0) { - std::cout << "Low Level Virtual Machine (" << PACKAGE_NAME << ") " - << PACKAGE_VERSION << " (see http://llvm.org/)"; -#ifndef NDEBUG - std::cout << " ASSERTIONS ENABLED\n"; + std::cout << "Low Level Virtual Machine (http://llvm.org/):\n"; + std::cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION; +#ifdef LLVM_VERSION_INFO + std::cout << LLVM_VERSION_INFO; +#endif + std::cout << "\n "; +#ifndef __OPTIMIZE__ + std::cout << "DEBUG build"; #else - std::cout << "\n"; + std::cout << "Optimized build"; +#endif +#ifndef NDEBUG + std::cout << " with assertions"; #endif + std::cout << ".\n"; getOpts().clear(); // Don't bother making option dtors remove from map. exit(1); } else { -- cgit v1.2.3-70-g09d2 From 433fd76e51e9bd9a4933e2c1775a7410928112c8 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 18 Jul 2006 23:59:33 +0000 Subject: Add an out-of-line virtual method to provide a home for the cl::option class. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29191 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 3 +++ lib/Support/CommandLine.cpp | 4 ++++ 2 files changed, 7 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 8517032fef..b352686e6d 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -150,6 +150,9 @@ class Option { return NormalFormatting; } + // Out of line virtual function to provide home for the class. + virtual void anchor(); + int NumOccurrences; // The number of times specified int Flags; // Flags for the argument unsigned Position; // Position of last occurrence of the option diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 164cb5286f..08b6fcbd59 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -607,6 +607,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // +// Out of line virtual function to provide home for the class. +void Option::anchor() { +} + bool Option::error(std::string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) -- cgit v1.2.3-70-g09d2 From abe0e3e6410ca3f192b6a656cbcd042b05d0a68b Mon Sep 17 00:00:00 2001 From: Jim Laskey Date: Wed, 2 Aug 2006 20:15:56 +0000 Subject: If the Program name was NULL then all further output sent to std::cerr was suppressed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29477 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 08b6fcbd59..f7fbef6b72 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -616,7 +616,9 @@ bool Option::error(std::string Message, const char *ArgName) { if (ArgName[0] == 0) std::cerr << HelpStr; // Be nice for positional arguments else - std::cerr << ProgramName << ": for the -" << ArgName; + std::cerr << (ProgramName ? ProgramName : "***") + << ": for the -" << ArgName; + std::cerr << " option: " << Message << "\n"; return true; } -- cgit v1.2.3-70-g09d2 From 023fcf977660e686e04f5bef0e2a7321db47df7e Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Mon, 21 Aug 2006 02:04:43 +0000 Subject: For PR797: Make sys::Program::ExecuteAndWait not throw exceptions and update any affected code. It now return -9999 to signal that the program couldn't be executed. Only one case (in bugpoint) actually examines the result code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29785 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/System/Program.h | 3 ++- lib/Support/CommandLine.cpp | 2 +- lib/Support/GraphWriter.cpp | 4 +++- lib/System/Unix/Program.inc | 2 +- tools/bugpoint/OptimizerDriver.cpp | 2 ++ tools/bugpoint/ToolRunner.cpp | 2 +- tools/lto/lto.cpp | 2 +- tools/opt/opt.cpp | 3 +-- 8 files changed, 12 insertions(+), 8 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/System/Program.h b/include/llvm/System/Program.h index 92534de405..2b5b488ffb 100644 --- a/include/llvm/System/Program.h +++ b/include/llvm/System/Program.h @@ -49,7 +49,8 @@ namespace sys { /// called then a std::string is thrown. /// @returns an integer result code indicating the status of the program. /// A zero or positive value indicates the result code of the program. A - /// negative value is the signal number on which it terminated. + /// negative value is the signal number on which it terminated. A value of + /// -9999 indicates the program could not be executed. /// @throws std::string on a variety of error conditions or if the invoked /// program aborted abnormally. /// @see FindProgrambyName diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index f7fbef6b72..069940162b 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -31,7 +31,7 @@ using namespace llvm; using namespace cl; // Globals for name and overview of program -static const char *ProgramName = ""; +static const char *ProgramName = ""; static const char *ProgramOverview = 0; // This collects additional help to be printed. diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index f3255d815c..152261fbac 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -59,7 +59,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) { args.push_back(PSFilename.c_str()); args.push_back(0); - sys::Program::ExecuteAndWait(gv, &args[0]); + if (sys::Program::ExecuteAndWait(gv, &args[0])) { + std::cerr << "Error viewing graph: 'gv' not in path?\n"; + } } PSFilename.eraseFromDisk(); #elif HAVE_DOTTY diff --git a/lib/System/Unix/Program.inc b/lib/System/Unix/Program.inc index 1bf1bc91f8..c3d5d5ce6e 100644 --- a/lib/System/Unix/Program.inc +++ b/lib/System/Unix/Program.inc @@ -108,7 +108,7 @@ Program::ExecuteAndWait(const Path& path, unsigned secondsToWait ) { if (!path.canExecute()) - throw path.toString() + " is not executable"; + return -9999; #ifdef HAVE_SYS_WAIT_H // Create a child process. diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index df4f470da2..0ac514bbef 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -194,6 +194,8 @@ bool BugDriver::runPasses(const std::vector &Passes, std::cout << "Success!\n"; else if (result > 0) std::cout << "Exited with error code '" << result << "'\n"; + else if (result == -9999) + std::cout << "Program not executable\n"; else if (result < 0) std::cout << "Crashed with signal #" << abs(result) << "\n"; if (result & 0x01000000) diff --git a/tools/bugpoint/ToolRunner.cpp b/tools/bugpoint/ToolRunner.cpp index 94cccf2774..067bf658c7 100644 --- a/tools/bugpoint/ToolRunner.cpp +++ b/tools/bugpoint/ToolRunner.cpp @@ -55,7 +55,7 @@ static void ProcessFailure(sys::Path ProgPath, const char** Args) { sys::Path ErrorFilename("error_messages"); ErrorFilename.makeUnique(); RunProgramWithTimeout(ProgPath, Args, sys::Path(""), ErrorFilename, - ErrorFilename); + ErrorFilename); // FIXME: check return code // Print out the error messages generated by GCC if possible... std::ifstream ErrorFile(ErrorFilename.c_str()); diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 162bac9e61..570558a62b 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -334,7 +334,7 @@ LinkTimeOptimizer::optimizeModules(const std::string &OutputFilename, args.push_back(tmpAsmFilePath.c_str()); args.push_back(0); - int R1 = sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1); + sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1); tmpAsmFilePath.eraseFromDisk(); diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 18b4a8c157..6d3b3b648a 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -26,8 +26,7 @@ #include "llvm/Support/PluginLoader.h" #include "llvm/Support/SystemUtils.h" #include "llvm/Support/Timer.h" -#include "llvm/Analysis/LinkAllAnalyses.h" -#include "llvm/Transforms/LinkAllPasses.h" +#include "llvm/LinkAllPasses.h" #include "llvm/LinkAllVMCore.h" #include #include -- cgit v1.2.3-70-g09d2 From 6f4c60770cfe6c485cdcb1397df59d2c7778cbc9 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Wed, 23 Aug 2006 07:10:06 +0000 Subject: Make the ProgramName variable a std::string so we can eliminate the path portion fo the program name via sys::Path().getLast(). This makes error messages more readable since this is invariably used only in error messages. Instead of: /path/to/llvm/bin/directory/toolname: error message we will now get: toolname: error message Also, since we always have a program name (even if its defaulted), don't check to see if it is set or not when generating error messages. This eliminates a bunch of constant strings, saving a little under 1K of data. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29842 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 40 ++++++++++++++-------------------------- 1 file changed, 14 insertions(+), 26 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 069940162b..863f5e349d 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -18,6 +18,7 @@ #include "llvm/Config/config.h" #include "llvm/Support/CommandLine.h" +#include "llvm/System/Path.h" #include #include #include @@ -31,7 +32,7 @@ using namespace llvm; using namespace cl; // Globals for name and overview of program -static const char *ProgramName = ""; +static std::string ProgramName ( "" ); static const char *ProgramOverview = 0; // This collects additional help to be printed. @@ -289,7 +290,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, assert((!getOpts().empty() || !getPositionalOpts().empty()) && "No options specified, or ParseCommandLineOptions called more" " than once!"); - ProgramName = argv[0]; // Save this away safe and snug + sys::Path progname(argv[0]); + ProgramName = sys::Path(argv[0]).getLast(); ProgramOverview = Overview; bool ErrorParsing = false; @@ -448,11 +450,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - if (ProgramName) - std::cerr << ProgramName << ": Unknown command line argument '" + std::cerr << ProgramName << ": Unknown command line argument '" << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; - else - std::cerr << "Unknown command line argument '" << argv[i] << "'.\n"; ErrorParsing = true; continue; } @@ -488,28 +487,18 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - if (ProgramName) - std::cerr << ProgramName - << ": Not enough positional command line arguments specified!\n" - << "Must specify at least " << NumPositionalRequired - << " positional arguments: See: " << argv[0] << " --help\n"; - else - std::cerr << "Not enough positional command line arguments specified!\n" - << "Must specify at least " << NumPositionalRequired - << " positional arguments."; + std::cerr << ProgramName + << ": Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; } else if (!HasUnlimitedPositionals && PositionalVals.size() > PositionalOpts.size()) { - if (ProgramName) - std::cerr << ProgramName - << ": Too many positional arguments specified!\n" - << "Can specify at most " << PositionalOpts.size() - << " positional arguments: See: " << argv[0] << " --help\n"; - else - std::cerr << "Too many positional arguments specified!\n" - << "Can specify at most " << PositionalOpts.size() - << " positional arguments.\n"; + std::cerr << ProgramName + << ": Too many positional arguments specified!\n" + << "Can specify at most " << PositionalOpts.size() + << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; } else if (ConsumeAfterOpt == 0) { @@ -616,8 +605,7 @@ bool Option::error(std::string Message, const char *ArgName) { if (ArgName[0] == 0) std::cerr << HelpStr; // Be nice for positional arguments else - std::cerr << (ProgramName ? ProgramName : "***") - << ": for the -" << ArgName; + std::cerr << ProgramName << ": for the -" << ArgName; std::cerr << " option: " << Message << "\n"; return true; -- cgit v1.2.3-70-g09d2 From 7422a761008ef63152417c5e69ddc31252fb6b10 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 27 Aug 2006 12:45:47 +0000 Subject: Add external definitions for commonly-used template specializations and add anchor methods to others. This eliminates the vtable/template method bloat in .o files that defining a cl::opt used to impose (~4K per .o file for one cp::opt). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29909 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 39 ++++++++++++++++++++++++++++++++++++-- lib/Support/CommandLine.cpp | 35 +++++++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 9 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index b352686e6d..8af6b2adbf 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -22,6 +22,7 @@ #include "llvm/Support/type_traits.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/Compiler.h" #include #include #include @@ -509,6 +510,9 @@ struct basic_parser_impl { // non-template implementation of basic_parser // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "value"; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); }; // basic_parser - The real basic parser is just a template wrapper that provides @@ -519,7 +523,6 @@ struct basic_parser : public basic_parser_impl { typedef DataType parser_data_type; }; - //-------------------------------------------------- // parser // @@ -533,10 +536,15 @@ public: return ValueOptional; } - // getValueName - Do not print = at all + // getValueName - Do not print = at all. virtual const char *getValueName() const { return 0; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); }; +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); + //-------------------------------------------------- // parser @@ -549,8 +557,13 @@ public: // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "int"; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); }; +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); + //-------------------------------------------------- // parser @@ -563,8 +576,12 @@ public: // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "uint"; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); }; +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); //-------------------------------------------------- // parser @@ -577,8 +594,12 @@ public: // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "number"; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); }; +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); //-------------------------------------------------- // parser @@ -591,8 +612,12 @@ public: // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "number"; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); }; +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); //-------------------------------------------------- // parser @@ -609,8 +634,13 @@ public: // getValueName - Overload in subclass to provide a better default value. virtual const char *getValueName() const { return "string"; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); }; +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); + //===----------------------------------------------------------------------===// // applicator class - This class is used because we must use partial // specialization to handle literal string arguments specially (const char* does @@ -845,6 +875,11 @@ public: } }; +EXTERN_TEMPLATE_INSTANTIATION(class opt); +EXTERN_TEMPLATE_INSTANTIATION(class opt); +EXTERN_TEMPLATE_INSTANTIATION(class opt); +EXTERN_TEMPLATE_INSTANTIATION(class opt); + //===----------------------------------------------------------------------===// // list_storage class diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 863f5e349d..d9e5cf9f47 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -28,11 +28,36 @@ #include #include using namespace llvm; - using namespace cl; +//===----------------------------------------------------------------------===// +// Template instantiations and anchors. +// +TEMPLATE_INSTANTIATION(class basic_parser); +TEMPLATE_INSTANTIATION(class basic_parser); +TEMPLATE_INSTANTIATION(class basic_parser); +TEMPLATE_INSTANTIATION(class basic_parser); +TEMPLATE_INSTANTIATION(class basic_parser); +TEMPLATE_INSTANTIATION(class basic_parser); + +TEMPLATE_INSTANTIATION(class opt); +TEMPLATE_INSTANTIATION(class opt); +TEMPLATE_INSTANTIATION(class opt); +TEMPLATE_INSTANTIATION(class opt); + +void Option::anchor() {} +void basic_parser_impl::anchor() {} +void parser::anchor() {} +void parser::anchor() {} +void parser::anchor() {} +void parser::anchor() {} +void parser::anchor() {} +void parser::anchor() {} + +//===----------------------------------------------------------------------===// + // Globals for name and overview of program -static std::string ProgramName ( "" ); +static std::string ProgramName = ""; static const char *ProgramOverview = 0; // This collects additional help to be printed. @@ -47,7 +72,7 @@ extrahelp::extrahelp(const char* Help) } //===----------------------------------------------------------------------===// -// Basic, shared command line option processing machinery... +// Basic, shared command line option processing machinery. // // Return the global command line option vector. Making it a function scoped @@ -596,10 +621,6 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Option Base class implementation // -// Out of line virtual function to provide home for the class. -void Option::anchor() { -} - bool Option::error(std::string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) -- cgit v1.2.3-70-g09d2 From 232885873fb0081acc1420ab83b14ab6f8eba280 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 27 Aug 2006 22:10:29 +0000 Subject: Minor code cleanups git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@29917 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index d9e5cf9f47..57620b50d6 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -214,8 +214,8 @@ static bool EatsUnboundedNumberOfValues(const Option *O) { /// using strdup (), so it is the caller's responsibility to free () /// them later. /// -static void ParseCStringVector (std::vector &output, - const char *input) { +static void ParseCStringVector(std::vector &output, + const char *input) { // Characters which will be treated as token separators: static const char *delims = " \v\f\t\r\n"; @@ -265,26 +265,25 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, assert(envVar && "Environment variable name missing"); // Get the environment variable they want us to parse options out of. - const char *envValue = getenv (envVar); + const char *envValue = getenv(envVar); if (!envValue) return; // Get program's "name", which we wouldn't know without the caller // telling us. - std::vector newArgv; - newArgv.push_back (strdup (progName)); + std::vector newArgv; + newArgv.push_back(strdup(progName)); // Parse the value of the environment variable into a "command line" // and hand it off to ParseCommandLineOptions(). - ParseCStringVector (newArgv, envValue); - int newArgc = newArgv.size (); - ParseCommandLineOptions (newArgc, &newArgv[0], Overview); + ParseCStringVector(newArgv, envValue); + int newArgc = newArgv.size(); + ParseCommandLineOptions(newArgc, &newArgv[0], Overview); // Free all the strdup()ed strings. - for (std::vector::iterator i = newArgv.begin (), e = newArgv.end (); - i != e; ++i) { + for (std::vector::iterator i = newArgv.begin(), e = newArgv.end(); + i != e; ++i) free (*i); - } } /// LookupOption - Lookup the option specified by the specified option on the -- cgit v1.2.3-70-g09d2 From 90aa839c88776e3dd0b3a798a98ea30d85b6b53c Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 4 Oct 2006 21:52:35 +0000 Subject: Fix more static dtor issues git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30725 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/BasicAliasAnalysis.cpp | 31 ++++++----- lib/Support/CommandLine.cpp | 104 ++++++++++++++++-------------------- lib/Support/Timer.cpp | 31 +++++------ utils/TableGen/IntrinsicEmitter.cpp | 4 +- 4 files changed, 81 insertions(+), 89 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 167d3b0c02..fdc452b44f 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -22,8 +22,9 @@ #include "llvm/Instructions.h" #include "llvm/Pass.h" #include "llvm/Target/TargetData.h" -#include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/Compiler.h" +#include "llvm/Support/GetElementPtrTypeIterator.h" +#include "llvm/Support/ManagedStatic.h" #include using namespace llvm; @@ -801,21 +802,23 @@ static const char *OnlyReadsMemoryFns[] = { "feof_unlocked", "ferror_unlocked", "fileno_unlocked" }; +static ManagedStatic > NoMemoryTable; +static ManagedStatic > OnlyReadsMemoryTable; + + AliasAnalysis::ModRefBehavior BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS, std::vector *Info) { if (!F->isExternal()) return UnknownModRefBehavior; - static std::vector NoMemoryTable, OnlyReadsMemoryTable; - static bool Initialized = false; if (!Initialized) { - NoMemoryTable.insert(NoMemoryTable.end(), - DoesntAccessMemoryFns, - DoesntAccessMemoryFns+ + NoMemoryTable->insert(NoMemoryTable->end(), + DoesntAccessMemoryFns, + DoesntAccessMemoryFns+ sizeof(DoesntAccessMemoryFns)/sizeof(DoesntAccessMemoryFns[0])); - OnlyReadsMemoryTable.insert(OnlyReadsMemoryTable.end(), + OnlyReadsMemoryTable->insert(OnlyReadsMemoryTable->end(), OnlyReadsMemoryFns, OnlyReadsMemoryFns+ sizeof(OnlyReadsMemoryFns)/sizeof(OnlyReadsMemoryFns[0])); @@ -824,22 +827,22 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS, #undef GET_MODREF_BEHAVIOR // Sort the table the first time through. - std::sort(NoMemoryTable.begin(), NoMemoryTable.end(), StringCompare()); - std::sort(OnlyReadsMemoryTable.begin(), OnlyReadsMemoryTable.end(), + std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare()); + std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(), StringCompare()); Initialized = true; } std::vector::iterator Ptr = - std::lower_bound(NoMemoryTable.begin(), NoMemoryTable.end(), + std::lower_bound(NoMemoryTable->begin(), NoMemoryTable->end(), F->getName().c_str(), StringCompare()); - if (Ptr != NoMemoryTable.end() && *Ptr == F->getName()) + if (Ptr != NoMemoryTable->end() && *Ptr == F->getName()) return DoesNotAccessMemory; - Ptr = std::lower_bound(OnlyReadsMemoryTable.begin(), - OnlyReadsMemoryTable.end(), + Ptr = std::lower_bound(OnlyReadsMemoryTable->begin(), + OnlyReadsMemoryTable->end(), F->getName().c_str(), StringCompare()); - if (Ptr != OnlyReadsMemoryTable.end() && *Ptr == F->getName()) + if (Ptr != OnlyReadsMemoryTable->end() && *Ptr == F->getName()) return OnlyReadsMemory; return UnknownModRefBehavior; diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 57620b50d6..4a3ccfaa07 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -18,6 +18,7 @@ #include "llvm/Config/config.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/System/Path.h" #include #include @@ -61,36 +62,23 @@ static std::string ProgramName = ""; static const char *ProgramOverview = 0; // This collects additional help to be printed. -static std::vector &MoreHelp() { - static std::vector moreHelp; - return moreHelp; -} +static ManagedStatic > MoreHelp; -extrahelp::extrahelp(const char* Help) +extrahelp::extrahelp(const char *Help) : morehelp(Help) { - MoreHelp().push_back(Help); + MoreHelp->push_back(Help); } //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery. // -// Return the global command line option vector. Making it a function scoped -// static ensures that it will be initialized correctly before its first use. -// -static std::map &getOpts() { - static std::map CommandLineOptions; - return CommandLineOptions; -} +static ManagedStatic > Options; +static ManagedStatic > PositionalOptions; static Option *getOption(const std::string &Str) { - std::map::iterator I = getOpts().find(Str); - return I != getOpts().end() ? I->second : 0; -} - -static std::vector &getPositionalOpts() { - static std::vector Positional; - return Positional; + std::map::iterator I = Options->find(Str); + return I != Options->end() ? I->second : 0; } static void AddArgument(const char *ArgName, Option *Opt) { @@ -99,7 +87,7 @@ static void AddArgument(const char *ArgName, Option *Opt) { << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! - getOpts()[ArgName] = Opt; + (*Options)[ArgName] = Opt; } } @@ -107,7 +95,7 @@ static void AddArgument(const char *ArgName, Option *Opt) { // options have already been processed and the map has been deleted! // static void RemoveArgument(const char *ArgName, Option *Opt) { - if(getOpts().empty()) return; + if (Options->empty()) return; #ifndef NDEBUG // This disgusting HACK is brought to you courtesy of GCC 3.3.2, which ICE's @@ -115,7 +103,7 @@ static void RemoveArgument(const char *ArgName, Option *Opt) { std::string Tmp = ArgName; assert(getOption(Tmp) == Opt && "Arg not in map!"); #endif - getOpts().erase(ArgName); + Options->erase(ArgName); } static inline bool ProvideOption(Option *Handler, const char *ArgName, @@ -303,7 +291,7 @@ static Option *LookupOption(const char *&Arg, const char *&Value) { if (*Arg == 0) return 0; // Look up the option. - std::map &Opts = getOpts(); + std::map &Opts = *Options; std::map::iterator I = Opts.find(std::string(Arg, ArgEnd)); return (I != Opts.end()) ? I->second : 0; @@ -311,7 +299,7 @@ static Option *LookupOption(const char *&Arg, const char *&Value) { void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview) { - assert((!getOpts().empty() || !getPositionalOpts().empty()) && + assert((!Options->empty() || !PositionalOptions->empty()) && "No options specified, or ParseCommandLineOptions called more" " than once!"); sys::Path progname(argv[0]); @@ -319,8 +307,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ProgramOverview = Overview; bool ErrorParsing = false; - std::map &Opts = getOpts(); - std::vector &PositionalOpts = getPositionalOpts(); + std::map &Opts = *Options; + std::vector &PositionalOpts = *PositionalOptions; // Check out the positional arguments to collect information about them. unsigned NumPositionalRequired = 0; @@ -608,9 +596,9 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Free all of the memory allocated to the map. Command line options may only // be processed once! - getOpts().clear(); + Opts.clear(); PositionalOpts.clear(); - MoreHelp().clear(); + MoreHelp->clear(); // If we had an error processing our arguments, don't let the program execute if (ErrorParsing) exit(1); @@ -661,12 +649,12 @@ void Option::addArgument(const char *ArgStr) { AddArgument(ArgStr, this); if (getFormattingFlag() == Positional) - getPositionalOpts().push_back(this); + PositionalOptions->push_back(this); else if (getNumOccurrencesFlag() == ConsumeAfter) { - if (!getPositionalOpts().empty() && - getPositionalOpts().front()->getNumOccurrencesFlag() == ConsumeAfter) + if (!PositionalOptions->empty() && + PositionalOptions->front()->getNumOccurrencesFlag() == ConsumeAfter) error("Cannot specify more than one option with cl::ConsumeAfter!"); - getPositionalOpts().insert(getPositionalOpts().begin(), this); + PositionalOptions->insert(PositionalOptions->begin(), this); } } @@ -676,13 +664,13 @@ void Option::removeArgument(const char *ArgStr) { if (getFormattingFlag() == Positional) { std::vector::iterator I = - std::find(getPositionalOpts().begin(), getPositionalOpts().end(), this); - assert(I != getPositionalOpts().end() && "Arg not registered!"); - getPositionalOpts().erase(I); + std::find(PositionalOptions->begin(), PositionalOptions->end(), this); + assert(I != PositionalOptions->end() && "Arg not registered!"); + PositionalOptions->erase(I); } else if (getNumOccurrencesFlag() == ConsumeAfter) { - assert(!getPositionalOpts().empty() && getPositionalOpts()[0] == this && + assert(!PositionalOptions->empty() && (*PositionalOptions)[0] == this && "Arg not registered correctly!"); - getPositionalOpts().erase(getPositionalOpts().begin()); + PositionalOptions->erase(PositionalOptions->begin()); } } @@ -904,22 +892,22 @@ public: if (Value == false) return; // Copy Options into a vector so we can sort them as we like... - std::vector > Options; - copy(getOpts().begin(), getOpts().end(), std::back_inserter(Options)); + std::vector > Opts; + copy(Options->begin(), Options->end(), std::back_inserter(Opts)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden - Options.erase(std::remove_if(Options.begin(), Options.end(), - std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), - Options.end()); + Opts.erase(std::remove_if(Opts.begin(), Opts.end(), + std::ptr_fun(ShowHidden ? isReallyHidden : isHidden)), + Opts.end()); // Eliminate duplicate entries in table (from enum flags options, f.e.) { // Give OptionSet a scope std::set OptionSet; - for (unsigned i = 0; i != Options.size(); ++i) - if (OptionSet.count(Options[i].second) == 0) - OptionSet.insert(Options[i].second); // Add new entry to set + for (unsigned i = 0; i != Opts.size(); ++i) + if (OptionSet.count(Opts[i].second) == 0) + OptionSet.insert(Opts[i].second); // Add new entry to set else - Options.erase(Options.begin()+i--); // Erase duplicate + Opts.erase(Opts.begin()+i--); // Erase duplicate } if (ProgramOverview) @@ -927,8 +915,8 @@ public: std::cout << "USAGE: " << ProgramName << " [options]"; - // Print out the positional options... - std::vector &PosOpts = getPositionalOpts(); + // Print out the positional options. + std::vector &PosOpts = *PositionalOptions; Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) CAOpt = PosOpts[0]; @@ -946,21 +934,21 @@ public: // Compute the maximum argument length... MaxArgLen = 0; - for (unsigned i = 0, e = Options.size(); i != e; ++i) - MaxArgLen = std::max(MaxArgLen, Options[i].second->getOptionWidth()); + for (unsigned i = 0, e = Opts.size(); i != e; ++i) + MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth()); std::cout << "OPTIONS:\n"; - for (unsigned i = 0, e = Options.size(); i != e; ++i) - Options[i].second->printOptionInfo(MaxArgLen); + for (unsigned i = 0, e = Opts.size(); i != e; ++i) + Opts[i].second->printOptionInfo(MaxArgLen); // Print any extra help the user has declared. - for (std::vector::iterator I = MoreHelp().begin(), - E = MoreHelp().end(); I != E; ++I) + for (std::vector::iterator I = MoreHelp->begin(), + E = MoreHelp->end(); I != E; ++I) std::cout << *I; - MoreHelp().clear(); + MoreHelp->clear(); // Halt the program since help information was printed - getOpts().clear(); // Don't bother making option dtors remove from map. + Options->clear(); // Don't bother making option dtors remove from map. exit(1); } }; @@ -1001,7 +989,7 @@ public: std::cout << " with assertions"; #endif std::cout << ".\n"; - getOpts().clear(); // Don't bother making option dtors remove from map. + Options->clear(); // Don't bother making option dtors remove from map. exit(1); } else { (*OverrideVersionPrinter)(); diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index b0012ceb51..0c4f18f630 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -13,6 +13,7 @@ #include "llvm/Support/Timer.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/System/Process.h" #include #include @@ -32,8 +33,8 @@ namespace llvm { extern std::ostream *GetLibSupportInfoOutputFile(); } // would get destroyed before the Statistic, causing havoc to ensue. We "fix" // this by creating the string the first time it is needed and never destroying // it. +static ManagedStatic LibSupportInfoOutputFilename; static std::string &getLibSupportInfoOutputFilename() { - static std::string *LibSupportInfoOutputFilename = new std::string(); return *LibSupportInfoOutputFilename; } @@ -127,7 +128,7 @@ static TimeRecord getTimeRecord(bool Start) { return Result; } -static std::vector ActiveTimers; +static ManagedStatic > ActiveTimers; void Timer::startTimer() { Started = true; @@ -137,7 +138,7 @@ void Timer::startTimer() { SystemTime -= TR.SystemTime; MemUsed -= TR.MemUsed; PeakMemBase = TR.MemUsed; - ActiveTimers.push_back(this); + ActiveTimers->push_back(this); } void Timer::stopTimer() { @@ -147,13 +148,13 @@ void Timer::stopTimer() { SystemTime += TR.SystemTime; MemUsed += TR.MemUsed; - if (ActiveTimers.back() == this) { - ActiveTimers.pop_back(); + if (ActiveTimers->back() == this) { + ActiveTimers->pop_back(); } else { std::vector::iterator I = - std::find(ActiveTimers.begin(), ActiveTimers.end(), this); - assert(I != ActiveTimers.end() && "stop but no startTimer?"); - ActiveTimers.erase(I); + std::find(ActiveTimers->begin(), ActiveTimers->end(), this); + assert(I != ActiveTimers->end() && "stop but no startTimer?"); + ActiveTimers->erase(I); } } @@ -172,8 +173,8 @@ void Timer::sum(const Timer &T) { void Timer::addPeakMemoryMeasurement() { size_t MemUsed = getMemUsage(); - for (std::vector::iterator I = ActiveTimers.begin(), - E = ActiveTimers.end(); I != E; ++I) + for (std::vector::iterator I = ActiveTimers->begin(), + E = ActiveTimers->end(); I != E; ++I) (*I)->PeakMem = std::max((*I)->PeakMem, MemUsed-(*I)->PeakMemBase); } @@ -181,14 +182,14 @@ void Timer::addPeakMemoryMeasurement() { // NamedRegionTimer Implementation //===----------------------------------------------------------------------===// -static Timer &getNamedRegionTimer(const std::string &Name) { - static std::map NamedTimers; +static ManagedStatic > NamedTimers; - std::map::iterator I = NamedTimers.lower_bound(Name); - if (I != NamedTimers.end() && I->first == Name) +static Timer &getNamedRegionTimer(const std::string &Name) { + std::map::iterator I = NamedTimers->lower_bound(Name); + if (I != NamedTimers->end() && I->first == Name) return I->second; - return NamedTimers.insert(I, std::make_pair(Name, Timer(Name)))->second; + return NamedTimers->insert(I, std::make_pair(Name, Timer(Name)))->second; } NamedRegionTimer::NamedRegionTimer(const std::string &Name) diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index ff15996f0c..fabb7e7714 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -182,11 +182,11 @@ void IntrinsicEmitter::EmitModRefInfo(const std::vector &Ints, switch (Ints[i].ModRef) { default: break; case CodeGenIntrinsic::NoMem: - OS << " NoMemoryTable.push_back(\"" << Ints[i].Name << "\");\n"; + OS << " NoMemoryTable->push_back(\"" << Ints[i].Name << "\");\n"; break; case CodeGenIntrinsic::ReadArgMem: case CodeGenIntrinsic::ReadMem: - OS << " OnlyReadsMemoryTable.push_back(\"" << Ints[i].Name << "\");\n"; + OS << " OnlyReadsMemoryTable->push_back(\"" << Ints[i].Name << "\");\n"; break; } } -- cgit v1.2.3-70-g09d2 From 500d8bff2077ac327deec076fc8793e740b358c0 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 12 Oct 2006 22:09:17 +0000 Subject: shrink anon-ns and mark stuff static. No functionality changes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30922 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 4a3ccfaa07..cd903126f5 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -952,23 +952,25 @@ public: exit(1); } }; +} // End anonymous namespace // Define the two HelpPrinter instances that are used to print out help, or // help-hidden... // -HelpPrinter NormalPrinter(false); -HelpPrinter HiddenPrinter(true); +static HelpPrinter NormalPrinter(false); +static HelpPrinter HiddenPrinter(true); -cl::opt > +static cl::opt > HOp("help", cl::desc("Display available options (--help-hidden for more)"), cl::location(NormalPrinter), cl::ValueDisallowed); -cl::opt > +static cl::opt > HHOp("help-hidden", cl::desc("Display all available options"), cl::location(HiddenPrinter), cl::Hidden, cl::ValueDisallowed); -void (*OverrideVersionPrinter)() = 0; +static void (*OverrideVersionPrinter)() = 0; +namespace { class VersionPrinter { public: void operator=(bool OptionWasSpecified) { @@ -998,17 +1000,16 @@ public: } } }; +} // End anonymous namespace // Define the --version option that prints out the LLVM version for the tool -VersionPrinter VersionPrinterInstance; -cl::opt > +static VersionPrinter VersionPrinterInstance; + +static cl::opt > VersOp("version", cl::desc("Display the version of this program"), cl::location(VersionPrinterInstance), cl::ValueDisallowed); - -} // End anonymous namespace - // Utility function for printing the help message. void cl::PrintHelpMessage() { // This looks weird, but it actually prints the help message. The -- cgit v1.2.3-70-g09d2 From efa3da5593117eab5209c9197cad5ca42213c12e Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 13 Oct 2006 00:06:24 +0000 Subject: avoid a ctor/dtor issue with the ProgramName global. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30925 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index cd903126f5..39d388cbea 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -57,8 +57,9 @@ void parser::anchor() {} //===----------------------------------------------------------------------===// -// Globals for name and overview of program -static std::string ProgramName = ""; +// Globals for name and overview of program. Program name is not a string to +// avoid static ctor/dtor issues. +static char ProgramName[80] = ""; static const char *ProgramOverview = 0; // This collects additional help to be printed. @@ -303,7 +304,12 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, "No options specified, or ParseCommandLineOptions called more" " than once!"); sys::Path progname(argv[0]); - ProgramName = sys::Path(argv[0]).getLast(); + + // Copy the program name into ProgName, making sure not to overflow it. + std::string ProgName = sys::Path(argv[0]).getLast(); + if (ProgName.size() > 79) ProgName.resize(79); + strcpy(ProgramName, ProgName.c_str()); + ProgramOverview = Overview; bool ErrorParsing = false; -- cgit v1.2.3-70-g09d2 From fe6b146dcd09f488b12c7ff888ead9cedc92c2a6 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 26 Nov 2006 10:52:51 +0000 Subject: Removed #include and replace with llvm_* streams. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31927 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/Allocator.cpp | 6 ++-- lib/Support/CommandLine.cpp | 68 +++++++++++++++++------------------ lib/Support/GraphWriter.cpp | 18 +++++----- lib/Support/PluginLoader.cpp | 4 +-- lib/Support/SlowOperationInformer.cpp | 8 ++--- lib/Support/SystemUtils.cpp | 9 ++--- 6 files changed, 57 insertions(+), 56 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 7e7477357f..96f0743f3d 100644 --- a/lib/Support/Allocator.cpp +++ b/lib/Support/Allocator.cpp @@ -13,7 +13,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/DataTypes.h" -#include +#include "llvm/Support/Streams.h" using namespace llvm; //===----------------------------------------------------------------------===// @@ -102,6 +102,6 @@ void BumpPtrAllocator::PrintStats() const { for (; R; R = R->getNext(), ++NumRegions) BytesUsed += R->getNumBytesAllocated(); - std::cerr << "\nNumber of memory regions: " << NumRegions << "\n"; - std::cerr << "Bytes allocated: " << BytesUsed << "\n"; + llvm_cerr << "\nNumber of memory regions: " << NumRegions << "\n"; + llvm_cerr << "Bytes allocated: " << BytesUsed << "\n"; } diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 39d388cbea..3b75f478af 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -19,12 +19,12 @@ #include "llvm/Config/config.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" +#include "llvm/Support/Streams.h" #include "llvm/System/Path.h" #include #include #include #include -#include #include #include #include @@ -84,7 +84,7 @@ static Option *getOption(const std::string &Str) { static void AddArgument(const char *ArgName, Option *Opt) { if (getOption(ArgName)) { - std::cerr << ProgramName << ": CommandLine Error: Argument '" + llvm_cerr << ProgramName << ": CommandLine Error: Argument '" << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! @@ -129,7 +129,7 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, case ValueOptional: break; default: - std::cerr << ProgramName + llvm_cerr << ProgramName << ": Bad ValueMask flag! CommandLine usage error:" << Handler->getValueExpectedFlag() << "\n"; abort(); @@ -468,8 +468,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - std::cerr << ProgramName << ": Unknown command line argument '" - << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; + llvm_cerr << ProgramName << ": Unknown command line argument '" + << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -505,7 +505,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - std::cerr << ProgramName + llvm_cerr << ProgramName << ": Not enough positional command line arguments specified!\n" << "Must specify at least " << NumPositionalRequired << " positional arguments: See: " << argv[0] << " --help\n"; @@ -513,7 +513,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ErrorParsing = true; } else if (!HasUnlimitedPositionals && PositionalVals.size() > PositionalOpts.size()) { - std::cerr << ProgramName + llvm_cerr << ProgramName << ": Too many positional arguments specified!\n" << "Can specify at most " << PositionalOpts.size() << " positional arguments: See: " << argv[0] << " --help\n"; @@ -617,11 +617,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, bool Option::error(std::string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) - std::cerr << HelpStr; // Be nice for positional arguments + llvm_cerr << HelpStr; // Be nice for positional arguments else - std::cerr << ProgramName << ": for the -" << ArgName; + llvm_cerr << ProgramName << ": for the -" << ArgName; - std::cerr << " option: " << Message << "\n"; + llvm_cerr << " option: " << Message << "\n"; return true; } @@ -701,7 +701,7 @@ unsigned alias::getOptionWidth() const { // Print out the option for the alias. void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - std::cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " + llvm_cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " << HelpStr << "\n"; } @@ -728,12 +728,12 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const { // void basic_parser_impl::printOptionInfo(const Option &O, unsigned GlobalWidth) const { - std::cout << " -" << O.ArgStr; + llvm_cout << " -" << O.ArgStr; if (const char *ValName = getValueName()) - std::cout << "=<" << getValueStr(O, ValName) << ">"; + llvm_cout << "=<" << getValueStr(O, ValName) << ">"; - std::cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " + llvm_cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " << O.HelpStr << "\n"; } @@ -850,20 +850,20 @@ void generic_parser_base::printOptionInfo(const Option &O, unsigned GlobalWidth) const { if (O.hasArgStr()) { unsigned L = std::strlen(O.ArgStr); - std::cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') + llvm_cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; - std::cout << " =" << getOption(i) << std::string(NumSpaces, ' ') + llvm_cout << " =" << getOption(i) << std::string(NumSpaces, ' ') << " - " << getDescription(i) << "\n"; } } else { if (O.HelpStr[0]) - std::cout << " " << O.HelpStr << "\n"; + llvm_cout << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned L = std::strlen(getOption(i)); - std::cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') + llvm_cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') << " - " << getDescription(i) << "\n"; } } @@ -917,9 +917,9 @@ public: } if (ProgramOverview) - std::cout << "OVERVIEW:" << ProgramOverview << "\n"; + llvm_cout << "OVERVIEW:" << ProgramOverview << "\n"; - std::cout << "USAGE: " << ProgramName << " [options]"; + llvm_cout << "USAGE: " << ProgramName << " [options]"; // Print out the positional options. std::vector &PosOpts = *PositionalOptions; @@ -929,28 +929,28 @@ public: for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { if (PosOpts[i]->ArgStr[0]) - std::cout << " --" << PosOpts[i]->ArgStr; - std::cout << " " << PosOpts[i]->HelpStr; + llvm_cout << " --" << PosOpts[i]->ArgStr; + llvm_cout << " " << PosOpts[i]->HelpStr; } // Print the consume after option info if it exists... - if (CAOpt) std::cout << " " << CAOpt->HelpStr; + if (CAOpt) llvm_cout << " " << CAOpt->HelpStr; - std::cout << "\n\n"; + llvm_cout << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; for (unsigned i = 0, e = Opts.size(); i != e; ++i) MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth()); - std::cout << "OPTIONS:\n"; + llvm_cout << "OPTIONS:\n"; for (unsigned i = 0, e = Opts.size(); i != e; ++i) Opts[i].second->printOptionInfo(MaxArgLen); // Print any extra help the user has declared. for (std::vector::iterator I = MoreHelp->begin(), E = MoreHelp->end(); I != E; ++I) - std::cout << *I; + llvm_cout << *I; MoreHelp->clear(); // Halt the program since help information was printed @@ -982,21 +982,21 @@ public: void operator=(bool OptionWasSpecified) { if (OptionWasSpecified) { if (OverrideVersionPrinter == 0) { - std::cout << "Low Level Virtual Machine (http://llvm.org/):\n"; - std::cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION; + llvm_cout << "Low Level Virtual Machine (http://llvm.org/):\n"; + llvm_cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION; #ifdef LLVM_VERSION_INFO - std::cout << LLVM_VERSION_INFO; + llvm_cout << LLVM_VERSION_INFO; #endif - std::cout << "\n "; + llvm_cout << "\n "; #ifndef __OPTIMIZE__ - std::cout << "DEBUG build"; + llvm_cout << "DEBUG build"; #else - std::cout << "Optimized build"; + llvm_cout << "Optimized build"; #endif #ifndef NDEBUG - std::cout << " with assertions"; + llvm_cout << " with assertions"; #endif - std::cout << ".\n"; + llvm_cout << ".\n"; Options->clear(); // Don't bother making option dtors remove from map. exit(1); } else { diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index fa9830a34b..01da2e13c5 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -12,10 +12,10 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/GraphWriter.h" +#include "llvm/Support/Streams.h" #include "llvm/System/Path.h" #include "llvm/System/Program.h" #include "llvm/Config/config.h" -#include using namespace llvm; void llvm::DisplayGraph(const sys::Path &Filename) { @@ -28,9 +28,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) { args.push_back(Filename.c_str()); args.push_back(0); - std::cerr << "Running 'Graphviz' program... " << std::flush; + llvm_cerr << "Running 'Graphviz' program... " << std::flush; if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,&ErrMsg)) { - std::cerr << "Error viewing graph: " << ErrMsg << "\n"; + llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; } #elif (HAVE_GV && HAVE_DOT) sys::Path PSFilename = Filename; @@ -48,11 +48,11 @@ void llvm::DisplayGraph(const sys::Path &Filename) { args.push_back(PSFilename.c_str()); args.push_back(0); - std::cerr << "Running 'dot' program... " << std::flush; + llvm_cerr << "Running 'dot' program... " << std::flush; if (sys::Program::ExecuteAndWait(dot, &args[0],0,0,0,&ErrMsg)) { - std::cerr << "Error viewing graph: '" << ErrMsg << "\n"; + llvm_cerr << "Error viewing graph: '" << ErrMsg << "\n"; } else { - std::cerr << " done. \n"; + llvm_cerr << " done. \n"; sys::Path gv(LLVM_PATH_GV); args.clear(); @@ -62,7 +62,7 @@ void llvm::DisplayGraph(const sys::Path &Filename) { ErrMsg.clear(); if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,&ErrMsg)) { - std::cerr << "Error viewing graph: " << ErrMsg << "\n"; + llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; } } PSFilename.eraseFromDisk(); @@ -73,9 +73,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) { args.push_back(Filename.c_str()); args.push_back(0); - std::cerr << "Running 'dotty' program... " << std::flush; + llvm_cerr << "Running 'dotty' program... " << std::flush; if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,&ErrMsg)) { - std::cerr << "Error viewing graph: " << ErrMsg << "\n"; + llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; } else { #ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns return; diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 2ed9836fd0..abd5e7af7a 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -13,8 +13,8 @@ #define DONT_GET_PLUGIN_LOADER_OPTION #include "llvm/Support/PluginLoader.h" +#include "llvm/Support/Streams.h" #include "llvm/System/DynamicLibrary.h" -#include #include using namespace llvm; @@ -26,7 +26,7 @@ void PluginLoader::operator=(const std::string &Filename) { std::string Error; if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { - std::cerr << "Error opening '" << Filename << "': " << Error + llvm_cerr << "Error opening '" << Filename << "': " << Error << "\n -load request ignored.\n"; } else { Plugins->push_back(Filename); diff --git a/lib/Support/SlowOperationInformer.cpp b/lib/Support/SlowOperationInformer.cpp index bfdfe8808f..806e7a47cb 100644 --- a/lib/Support/SlowOperationInformer.cpp +++ b/lib/Support/SlowOperationInformer.cpp @@ -12,8 +12,8 @@ //===----------------------------------------------------------------------===// #include "llvm/Support/SlowOperationInformer.h" +#include "llvm/Support/Streams.h" #include "llvm/System/Alarm.h" -#include #include #include using namespace llvm; @@ -28,7 +28,7 @@ SlowOperationInformer::~SlowOperationInformer() { if (LastPrintAmount) { // If we have printed something, make _sure_ we print the 100% amount, and // also print a newline. - std::cout << std::string(LastPrintAmount, '\b') << "Progress " + llvm_cout << std::string(LastPrintAmount, '\b') << "Progress " << OperationName << ": 100% \n"; } } @@ -40,7 +40,7 @@ SlowOperationInformer::~SlowOperationInformer() { bool SlowOperationInformer::progress(unsigned Amount) { int status = sys::AlarmStatus(); if (status == -1) { - std::cout << "\n"; + llvm_cout << "\n"; LastPrintAmount = 0; return true; } @@ -61,6 +61,6 @@ bool SlowOperationInformer::progress(unsigned Amount) { OS << "% "; LastPrintAmount = OS.str().size(); - std::cout << ToPrint+OS.str() << std::flush; + llvm_cout << ToPrint+OS.str() << std::flush; return false; } diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index 88c3515920..d4dbaeecc4 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -12,6 +12,7 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Support/Streams.h" #include "llvm/Support/SystemUtils.h" #include "llvm/System/Process.h" #include "llvm/System/Program.h" @@ -22,10 +23,10 @@ bool llvm::CheckBytecodeOutputToConsole(std::ostream* stream_to_check, bool print_warning) { if (stream_to_check == &std::cout && sys::Process::StandardOutIsDisplayed()) { if (print_warning) { - std::cerr << "WARNING: You're attempting to print out a bytecode file.\n" - "This is inadvisable as it may cause display problems. If\n" - "you REALLY want to taste LLVM bytecode first-hand, you\n" - "can force output with the `-f' option.\n\n"; + llvm_cerr << "WARNING: You're attempting to print out a bytecode file.\n" + << "This is inadvisable as it may cause display problems. If\n" + << "you REALLY want to taste LLVM bytecode first-hand, you\n" + << "can force output with the `-f' option.\n\n"; } return true; } -- cgit v1.2.3-70-g09d2 From e81561909d128c6e2d8033cb5465a49b2596b26a Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 7 Dec 2006 01:30:32 +0000 Subject: Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are now cerr, cout, and NullStream resp. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32298 91177308-0d34-0410-b5e6-96231b3b80d8 --- examples/ModuleMaker/ModuleMaker.cpp | 2 +- include/llvm/ADT/BitSetVector.h | 10 +- include/llvm/ADT/EquivalenceClasses.h | 4 +- include/llvm/Analysis/AliasSetTracker.h | 8 +- include/llvm/Analysis/CallGraph.h | 4 +- include/llvm/Analysis/DataStructure/DSGraph.h | 4 +- include/llvm/Analysis/DataStructure/DSNode.h | 2 +- include/llvm/Analysis/LoopInfo.h | 4 +- include/llvm/Analysis/ScalarEvolution.h | 8 +- include/llvm/Analysis/Trace.h | 4 +- include/llvm/Assembly/PrintModulePass.h | 18 +- include/llvm/Bytecode/WriteBytecodePass.h | 9 +- include/llvm/Bytecode/Writer.h | 5 +- include/llvm/CodeGen/LiveInterval.h | 8 +- include/llvm/CodeGen/MachineBasicBlock.h | 4 +- include/llvm/CodeGen/MachineConstantPool.h | 8 +- include/llvm/CodeGen/MachineInstr.h | 6 +- include/llvm/CodeGen/SchedGraphCommon.h | 10 +- include/llvm/Module.h | 4 +- include/llvm/Pass.h | 2 +- include/llvm/Support/Casting.h | 4 +- include/llvm/Support/ConstantRange.h | 2 +- include/llvm/Support/Debug.h | 4 +- include/llvm/Support/GraphWriter.h | 10 +- include/llvm/Support/PassNameParser.h | 4 +- include/llvm/Support/Streams.h | 54 +- include/llvm/Type.h | 2 +- include/llvm/Value.h | 2 +- lib/Analysis/AliasAnalysisCounter.cpp | 38 +- lib/Analysis/AliasAnalysisEvaluator.cpp | 52 +- lib/Analysis/AliasSetTracker.cpp | 6 +- lib/Analysis/BasicAliasAnalysis.cpp | 4 +- lib/Analysis/CFGPrinter.cpp | 6 +- lib/Analysis/ConstantRange.cpp | 2 +- lib/Analysis/DataStructure/BottomUpClosure.cpp | 24 +- lib/Analysis/DataStructure/CallTargets.cpp | 14 +- lib/Analysis/DataStructure/DataStructure.cpp | 3 +- lib/Analysis/DataStructure/DataStructureStats.cpp | 12 +- lib/Analysis/DataStructure/EquivClassGraphs.cpp | 2 +- lib/Analysis/DataStructure/GraphChecker.cpp | 32 +- lib/Analysis/DataStructure/Local.cpp | 4 +- lib/Analysis/DataStructure/Printer.cpp | 2 +- lib/Analysis/DataStructure/Steensgaard.cpp | 2 +- lib/Analysis/IPA/Andersens.cpp | 48 +- lib/Analysis/IPA/CallGraph.cpp | 8 +- lib/Analysis/InstCount.cpp | 2 +- lib/Analysis/LoopInfo.cpp | 2 +- lib/Analysis/ProfileInfoLoader.cpp | 29 +- lib/Analysis/ProfileInfoLoaderPass.cpp | 4 +- lib/Analysis/ScalarEvolution.cpp | 34 +- lib/Analysis/ScalarEvolutionExpander.cpp | 5 +- lib/Analysis/Trace.cpp | 5 +- lib/AsmParser/llvmAsmParser.cpp.cvs | 2048 +++++++++++--------- lib/AsmParser/llvmAsmParser.h.cvs | 40 +- lib/AsmParser/llvmAsmParser.y | 6 +- lib/AsmParser/llvmAsmParser.y.cvs | 6 +- lib/Bytecode/Writer/SlotCalculator.cpp | 2 +- lib/Bytecode/Writer/Writer.cpp | 12 +- lib/CodeGen/AsmPrinter.cpp | 37 +- lib/CodeGen/DwarfWriter.cpp | 16 +- lib/CodeGen/ELFWriter.cpp | 7 +- lib/CodeGen/IntrinsicLowering.cpp | 24 +- lib/CodeGen/LiveInterval.cpp | 7 +- lib/CodeGen/LiveIntervalAnalysis.cpp | 4 +- lib/CodeGen/MachineInstr.cpp | 3 +- lib/CodeGen/VirtRegMap.cpp | 6 +- lib/CodeGen/VirtRegMap.h | 4 +- lib/ExecutionEngine/ExecutionEngine.cpp | 18 +- lib/ExecutionEngine/Interpreter/Execution.cpp | 57 +- .../Interpreter/ExternalFunctions.cpp | 14 +- lib/Linker/LinkModules.cpp | 17 +- lib/Linker/Linker.cpp | 6 +- lib/Support/Allocator.cpp | 4 +- lib/Support/CommandLine.cpp | 94 +- lib/Support/ConstantRange.cpp | 2 +- lib/Support/Debug.cpp | 6 +- lib/Support/GraphWriter.cpp | 16 +- lib/Support/PluginLoader.cpp | 4 +- lib/Support/SlowOperationInformer.cpp | 8 +- lib/Support/Streams.cpp | 7 +- lib/Support/SystemUtils.cpp | 8 +- lib/Transforms/ExprTypeConvert.cpp | 4 +- lib/Transforms/Hello/Hello.cpp | 4 +- lib/Transforms/IPO/GlobalOpt.cpp | 36 +- lib/Transforms/IPO/Internalize.cpp | 3 +- lib/Transforms/Instrumentation/BlockProfiling.cpp | 8 +- lib/Transforms/Instrumentation/EdgeProfiling.cpp | 6 +- .../Instrumentation/TraceBasicBlocks.cpp | 6 +- lib/Transforms/Scalar/InstructionCombining.cpp | 4 +- lib/Transforms/Scalar/LoopStrengthReduce.cpp | 8 +- lib/Transforms/Scalar/LowerPacked.cpp | 3 +- lib/Transforms/Scalar/SCCP.cpp | 6 +- lib/Transforms/Utils/CodeExtractor.cpp | 4 +- lib/Transforms/Utils/LowerSwitch.cpp | 3 +- lib/VMCore/AsmWriter.cpp | 10 +- lib/VMCore/LeakDetector.cpp | 19 +- lib/VMCore/PassManager.cpp | 2 +- lib/VMCore/TypeSymbolTable.cpp | 20 +- lib/VMCore/Verifier.cpp | 5 +- projects/Stacker/tools/stkrc/stkrc.cpp | 8 +- tools/bugpoint/OptimizerDriver.cpp | 51 +- tools/gccas/gccas.cpp | 10 +- tools/gccld/GenerateCode.cpp | 8 +- tools/gccld/gccld.cpp | 34 +- tools/llvm-as/llvm-as.cpp | 30 +- tools/llvm-dis/llvm-dis.cpp | 24 +- tools/llvm-extract/llvm-extract.cpp | 18 +- tools/llvm-ld/llvm-ld.cpp | 38 +- tools/llvm-link/llvm-link.cpp | 46 +- tools/llvm-upgrade/llvm-upgrade.cpp | 20 +- tools/lto/lto.cpp | 12 +- tools/opt/opt.cpp | 44 +- 112 files changed, 1844 insertions(+), 1679 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/examples/ModuleMaker/ModuleMaker.cpp b/examples/ModuleMaker/ModuleMaker.cpp index 30f63bb8f4..0c9a61853e 100644 --- a/examples/ModuleMaker/ModuleMaker.cpp +++ b/examples/ModuleMaker/ModuleMaker.cpp @@ -53,7 +53,7 @@ int main() { BB->getInstList().push_back(new ReturnInst(Add)); // Output the bytecode file to stdout - WriteBytecodeToFile(M, llvm_cout); + WriteBytecodeToFile(M, cout); // Delete the module and all of its contents. delete M; diff --git a/include/llvm/ADT/BitSetVector.h b/include/llvm/ADT/BitSetVector.h index 67e3a52d6c..5d1fc86c3a 100644 --- a/include/llvm/ADT/BitSetVector.h +++ b/include/llvm/ADT/BitSetVector.h @@ -29,7 +29,6 @@ #include #include #include -#include namespace llvm { @@ -174,11 +173,11 @@ public: /// /// Printing and debugging support /// - void print(llvm_ostream &O) const { + void print(OStream &O) const { if (O.stream()) print(*O.stream()); } void print(std::ostream &O) const; - void dump() const { print(llvm_cerr); } + void dump() const { print(cerr); } public: // @@ -235,6 +234,9 @@ public: return (I.bitvec == bitvec && I.currentWord == currentWord && I.currentBit == currentBit); } + bool operator!=(const iterator& I) { + return !(*this == I); + } protected: static iterator begin(BitSetVector& _bitvec) { return iterator(_bitvec); } @@ -252,7 +254,7 @@ inline void BitSetVector::print(std::ostream& O) const O << "<" << (*I) << ">" << (I+1 == E? "\n" : ", "); } -inline llvm_ostream& operator<< (llvm_ostream& O, const BitSetVector& bset) { +inline OStream& operator<< (OStream& O, const BitSetVector& bset) { bset.print(O); return O; } diff --git a/include/llvm/ADT/EquivalenceClasses.h b/include/llvm/ADT/EquivalenceClasses.h index b915c2aeae..7d305cb744 100644 --- a/include/llvm/ADT/EquivalenceClasses.h +++ b/include/llvm/ADT/EquivalenceClasses.h @@ -43,8 +43,8 @@ namespace llvm { /// if (!I->isLeader()) continue; // Ignore non-leader sets. /// for (EquivalenceClasses::member_iterator MI = EC.member_begin(I); /// MI != EC.member_end(); ++MI) // Loop over members in this set. -/// llvm_cerr << *MI << " "; // Print member. -/// llvm_cerr << "\n"; // Finish set. +/// cerr << *MI << " "; // Print member. +/// cerr << "\n"; // Finish set. /// } /// /// This example prints: diff --git a/include/llvm/Analysis/AliasSetTracker.h b/include/llvm/Analysis/AliasSetTracker.h index c4273ac37d..5fcda16270 100644 --- a/include/llvm/Analysis/AliasSetTracker.h +++ b/include/llvm/Analysis/AliasSetTracker.h @@ -156,7 +156,7 @@ public: iterator end() const { return iterator(); } bool empty() const { return PtrList == 0; } - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } void print(std::ostream &OS) const; @@ -248,7 +248,7 @@ private: bool aliasesCallSite(CallSite CS, AliasAnalysis &AA) const; }; -inline llvm_ostream& operator<<(llvm_ostream &OS, const AliasSet &AS) { +inline OStream& operator<<(OStream &OS, const AliasSet &AS) { AS.print(OS); return OS; } @@ -361,7 +361,7 @@ public: iterator begin() { return AliasSets.begin(); } iterator end() { return AliasSets.end(); } - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } void print(std::ostream &OS) const; @@ -390,7 +390,7 @@ private: AliasSet *findAliasSetForCallSite(CallSite CS); }; -inline llvm_ostream& operator<<(llvm_ostream &OS, const AliasSetTracker &AST) { +inline OStream& operator<<(OStream &OS, const AliasSetTracker &AST) { AST.print(OS); return OS; } diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index f29aef3a22..1f737da53c 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -152,7 +152,7 @@ public: /// void initialize(Module &M); - void print(llvm_ostream &o, const Module *M) const { + void print(OStream &o, const Module *M) const { if (o.stream()) print(*o.stream(), M); } virtual void print(std::ostream &o, const Module *M) const; @@ -201,7 +201,7 @@ public: /// dump - Print out this call graph node. /// void dump() const; - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } void print(std::ostream &OS) const; diff --git a/include/llvm/Analysis/DataStructure/DSGraph.h b/include/llvm/Analysis/DataStructure/DSGraph.h index 61853587d7..1063efad13 100644 --- a/include/llvm/Analysis/DataStructure/DSGraph.h +++ b/include/llvm/Analysis/DataStructure/DSGraph.h @@ -378,12 +378,12 @@ public: /// print - Print a dot graph to the specified ostream... /// - void print(llvm_ostream &O) const { + void print(OStream &O) const { if (O.stream()) print(*O.stream()); } void print(std::ostream &O) const; - /// dump - call print(llvm_cerr), for use from the debugger... + /// dump - call print(cerr), for use from the debugger... /// void dump() const; diff --git a/include/llvm/Analysis/DataStructure/DSNode.h b/include/llvm/Analysis/DataStructure/DSNode.h index 5eb927b90e..abcca352a6 100644 --- a/include/llvm/Analysis/DataStructure/DSNode.h +++ b/include/llvm/Analysis/DataStructure/DSNode.h @@ -362,7 +362,7 @@ public: /// void forwardNode(DSNode *To, unsigned Offset); - void print(llvm_ostream &O, const DSGraph *G) const { + void print(OStream &O, const DSGraph *G) const { if (O.stream()) print(*O.stream(), G); } void print(std::ostream &O, const DSGraph *G) const; diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 2e6d2471fc..238a0f627d 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -217,7 +217,7 @@ public: /// the mapping in the LoopInfo class. void removeBlockFromLoop(BasicBlock *BB); - void print(llvm_ostream &O, unsigned Depth = 0) const { + void print(OStream &O, unsigned Depth = 0) const { if (O.stream()) print(*O.stream(), Depth); } void print(std::ostream &O, unsigned Depth = 0) const; @@ -283,7 +283,7 @@ public: virtual bool runOnFunction(Function &F); virtual void releaseMemory(); - void print(llvm_ostream &O, const Module* = 0) const { + void print(OStream &O, const Module* = 0) const { if (O.stream()) print(*O.stream()); } void print(std::ostream &O, const Module* = 0) const; diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index f1497cdeda..4eb0bb33b2 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -97,7 +97,7 @@ namespace llvm { /// print - Print out the internal representation of this scalar to the /// specified stream. This should really only be used for debugging /// purposes. - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } virtual void print(std::ostream &OS) const = 0; @@ -107,7 +107,7 @@ namespace llvm { void dump() const; }; - inline llvm_ostream &operator<<(llvm_ostream &OS, const SCEV &S) { + inline OStream &operator<<(OStream &OS, const SCEV &S) { S.print(OS); return OS; } @@ -128,7 +128,7 @@ namespace llvm { virtual bool isLoopInvariant(const Loop *L) const; virtual const Type *getType() const; virtual bool hasComputableLoopEvolution(const Loop *L) const; - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } virtual void print(std::ostream &OS) const; @@ -242,7 +242,7 @@ namespace llvm { virtual bool runOnFunction(Function &F); virtual void releaseMemory(); virtual void getAnalysisUsage(AnalysisUsage &AU) const; - void print(llvm_ostream &OS, const Module* = 0) const { + void print(OStream &OS, const Module* = 0) const { if (OS.stream()) print(*OS.stream()); } virtual void print(std::ostream &OS, const Module* = 0) const; diff --git a/include/llvm/Analysis/Trace.h b/include/llvm/Analysis/Trace.h index ad4f37ce4d..b26101d15c 100644 --- a/include/llvm/Analysis/Trace.h +++ b/include/llvm/Analysis/Trace.h @@ -18,11 +18,11 @@ #ifndef LLVM_ANALYSIS_TRACE_H #define LLVM_ANALYSIS_TRACE_H +#include "llvm/Support/Streams.h" #include #include namespace llvm { - class llvm_ostream; class BasicBlock; class Function; class Module; @@ -106,7 +106,7 @@ public: /// print - Write trace to output stream. /// - void print (llvm_ostream &O) const; + void print (OStream &O) const; /// dump - Debugger convenience method; writes trace to standard error /// output stream. diff --git a/include/llvm/Assembly/PrintModulePass.h b/include/llvm/Assembly/PrintModulePass.h index 770682d256..cc9bca9288 100644 --- a/include/llvm/Assembly/PrintModulePass.h +++ b/include/llvm/Assembly/PrintModulePass.h @@ -25,13 +25,12 @@ namespace llvm { class PrintModulePass : public ModulePass { - llvm_ostream *Out; // ostream to print on + OStream *Out; // ostream to print on bool DeleteStream; // Delete the ostream in our dtor? public: - PrintModulePass() : Out(&llvm_cerr), DeleteStream(false) {} - PrintModulePass(llvm_ostream *o, bool DS = false) - : Out(o), DeleteStream(DS) { - } + PrintModulePass() : Out(&cerr), DeleteStream(false) {} + PrintModulePass(OStream *o, bool DS = false) + : Out(o), DeleteStream(DS) {} ~PrintModulePass() { if (DeleteStream) delete Out; @@ -49,14 +48,13 @@ public: class PrintFunctionPass : public FunctionPass { std::string Banner; // String to print before each function - llvm_ostream *Out; // ostream to print on + OStream *Out; // ostream to print on bool DeleteStream; // Delete the ostream in our dtor? public: - PrintFunctionPass() : Banner(""), Out(&llvm_cerr), DeleteStream(false) {} - PrintFunctionPass(const std::string &B, llvm_ostream *o = &llvm_cout, + PrintFunctionPass() : Banner(""), Out(&cerr), DeleteStream(false) {} + PrintFunctionPass(const std::string &B, OStream *o = &cout, bool DS = false) - : Banner(B), Out(o), DeleteStream(DS) { - } + : Banner(B), Out(o), DeleteStream(DS) {} inline ~PrintFunctionPass() { if (DeleteStream) delete Out; diff --git a/include/llvm/Bytecode/WriteBytecodePass.h b/include/llvm/Bytecode/WriteBytecodePass.h index a634812498..c4e2c5d5d5 100644 --- a/include/llvm/Bytecode/WriteBytecodePass.h +++ b/include/llvm/Bytecode/WriteBytecodePass.h @@ -17,19 +17,18 @@ #include "llvm/Pass.h" #include "llvm/Bytecode/Writer.h" +#include "llvm/Support/Streams.h" namespace llvm { -class llvm_ostream; - class WriteBytecodePass : public ModulePass { - llvm_ostream *Out; // ostream to print on + OStream *Out; // ostream to print on bool DeleteStream; bool CompressFile; public: WriteBytecodePass() - : Out(&llvm_cout), DeleteStream(false), CompressFile(true) {} - WriteBytecodePass(llvm_ostream *o, bool DS = false, bool CF = true) + : Out(&cout), DeleteStream(false), CompressFile(true) {} + WriteBytecodePass(OStream *o, bool DS = false, bool CF = true) : Out(o), DeleteStream(DS), CompressFile(CF) {} inline ~WriteBytecodePass() { diff --git a/include/llvm/Bytecode/Writer.h b/include/llvm/Bytecode/Writer.h index 374e5df482..c87cc92848 100644 --- a/include/llvm/Bytecode/Writer.h +++ b/include/llvm/Bytecode/Writer.h @@ -15,13 +15,14 @@ #ifndef LLVM_BYTECODE_WRITER_H #define LLVM_BYTECODE_WRITER_H +#include "llvm/Support/Streams.h" + namespace llvm { - class llvm_ostream; class Module; /// WriteBytecodeToFile - Write the specified module to the specified output /// stream. If compress is set to true, try to use compression when writing /// out the file. This can never fail if M is a well-formed module. - void WriteBytecodeToFile(const Module *M, llvm_ostream &Out, + void WriteBytecodeToFile(const Module *M, OStream &Out, bool compress = true); } // End llvm namespace diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 16fcd1260e..03a0f579be 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -62,7 +62,7 @@ namespace llvm { }; std::ostream& operator<<(std::ostream& os, const LiveRange &LR); - inline llvm_ostream& operator<<(llvm_ostream& os, const LiveRange &LR) { + inline OStream& operator<<(OStream& os, const LiveRange &LR) { if (os.stream()) *os.stream() << LR; return os; } @@ -258,9 +258,9 @@ namespace llvm { return beginNumber() < other.beginNumber(); } - void print(llvm_ostream OS, const MRegisterInfo *MRI = 0) const; + void print(OStream OS, const MRegisterInfo *MRI = 0) const; void print(std::ostream &OS, const MRegisterInfo *MRI = 0) const { - print(llvm_ostream(OS), MRI); + print(OStream(OS), MRI); } void dump() const; @@ -271,7 +271,7 @@ namespace llvm { LiveInterval& operator=(const LiveInterval& rhs); // DO NOT IMPLEMENT }; - inline llvm_ostream &operator<<(llvm_ostream &OS, const LiveInterval &LI) { + inline OStream &operator<<(OStream &OS, const LiveInterval &LI) { LI.print(OS); return OS; } diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index f714c735f3..c848b065b4 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -189,7 +189,7 @@ public: // Debugging methods. void dump() const; - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } void print(std::ostream &OS) const; @@ -226,7 +226,7 @@ private: // Methods used to maintain doubly linked list of blocks... }; std::ostream& operator<<(std::ostream &OS, const MachineBasicBlock &MBB); -inline llvm_ostream& operator<<(llvm_ostream &OS, const MachineBasicBlock &MBB){ +inline OStream& operator<<(OStream &OS, const MachineBasicBlock &MBB){ if (OS.stream()) *OS.stream() << MBB; return OS; } diff --git a/include/llvm/CodeGen/MachineConstantPool.h b/include/llvm/CodeGen/MachineConstantPool.h index 6bb2665985..bc701f6b86 100644 --- a/include/llvm/CodeGen/MachineConstantPool.h +++ b/include/llvm/CodeGen/MachineConstantPool.h @@ -49,14 +49,14 @@ public: /// print - Implement operator<<... /// - void print(llvm_ostream &O) const { + void print(OStream &O) const { if (O.stream()) print(*O.stream()); } virtual void print(std::ostream &O) const = 0; }; -inline llvm_ostream &operator<<(llvm_ostream &OS, - const MachineConstantPoolValue &V) { +inline OStream &operator<<(OStream &OS, + const MachineConstantPoolValue &V) { V.print(OS); return OS; } @@ -143,7 +143,7 @@ public: /// print - Used by the MachineFunction printer to print information about /// constant pool objects. Implemented in MachineFunction.cpp /// - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } void print(std::ostream &OS) const; diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index 2185d847ad..daa3974ae4 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -285,7 +285,7 @@ public: IsDead = false; } - friend llvm_ostream& operator<<(llvm_ostream& os, const MachineOperand& mop) { + friend OStream& operator<<(OStream& os, const MachineOperand& mop) { if (os.stream()) *os.stream() << mop; return os; } @@ -397,12 +397,12 @@ public: // // Debugging support // - void print(llvm_ostream &OS, const TargetMachine *TM) const { + void print(OStream &OS, const TargetMachine *TM) const { if (OS.stream()) print(*OS.stream(), TM); } void print(std::ostream &OS, const TargetMachine *TM) const; void dump() const; - friend llvm_ostream& operator<<(llvm_ostream& os, const MachineInstr& minstr){ + friend OStream& operator<<(OStream& os, const MachineInstr& minstr){ if (os.stream()) *os.stream() << minstr; return os; } diff --git a/include/llvm/CodeGen/SchedGraphCommon.h b/include/llvm/CodeGen/SchedGraphCommon.h index b4cee969e1..7da2f732ba 100644 --- a/include/llvm/CodeGen/SchedGraphCommon.h +++ b/include/llvm/CodeGen/SchedGraphCommon.h @@ -70,7 +70,7 @@ public: void dump(int indent=0) const; // Debugging support - void print(llvm_ostream &os) const { + void print(OStream &os) const { if (os.stream()) print(*os.stream()); } virtual void print(std::ostream &os) const = 0; @@ -96,8 +96,8 @@ protected: }; // ostream << operator for SchedGraphNode class -inline llvm_ostream &operator<<(llvm_ostream &os, - const SchedGraphNodeCommon &node) { +inline OStream &operator<<(OStream &os, + const SchedGraphNodeCommon &node) { node.print(os); return os; } @@ -188,7 +188,7 @@ public: public: // Debugging support - void print(llvm_ostream &os) const { + void print(OStream &os) const { if (os.stream()) print(*os.stream()); } void print(std::ostream &os) const; @@ -200,7 +200,7 @@ private: }; // ostream << operator for SchedGraphNode class -inline llvm_ostream &operator<<(llvm_ostream &os, const SchedGraphEdge &edge) { +inline OStream &operator<<(OStream &os, const SchedGraphEdge &edge) { edge.print(os); return os; } diff --git a/include/llvm/Module.h b/include/llvm/Module.h index 4cb6d279f0..35b04b1017 100644 --- a/include/llvm/Module.h +++ b/include/llvm/Module.h @@ -295,12 +295,12 @@ public: /// @{ public: /// Print the module to an output stream - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream(), 0); } void print(std::ostream &OS) const { print(OS, 0); } /// Print the module to an output stream with AssemblyAnnotationWriter. - void print(llvm_ostream &OS, AssemblyAnnotationWriter *AAW) const { + void print(OStream &OS, AssemblyAnnotationWriter *AAW) const { if (OS.stream()) print(*OS.stream(), AAW); } void print(std::ostream &OS, AssemblyAnnotationWriter *AAW) const; diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h index 30f1df9669..4a929f0b21 100644 --- a/include/llvm/Pass.h +++ b/include/llvm/Pass.h @@ -101,7 +101,7 @@ public: /// provide the Module* in case the analysis doesn't need it it can just be /// ignored. /// - void print(llvm_ostream &O, const Module *M) const { + void print(OStream &O, const Module *M) const { if (O.stream()) print(*O.stream(), M); } virtual void print(std::ostream &O, const Module *M) const; diff --git a/include/llvm/Support/Casting.h b/include/llvm/Support/Casting.h index fff44f6e64..dc318395cc 100644 --- a/include/llvm/Support/Casting.h +++ b/include/llvm/Support/Casting.h @@ -245,13 +245,13 @@ private: struct foo { void ext() const; /* static bool classof(const bar *X) { - llvm_cerr << "Classof: " << X << "\n"; + cerr << "Classof: " << X << "\n"; return true; }*/ }; template <> inline bool isa_impl(const bar &Val) { - llvm_cerr << "Classof: " << &Val << "\n"; + cerr << "Classof: " << &Val << "\n"; return true; } diff --git a/include/llvm/Support/ConstantRange.h b/include/llvm/Support/ConstantRange.h index 90a29902c3..6866ffeb11 100644 --- a/include/llvm/Support/ConstantRange.h +++ b/include/llvm/Support/ConstantRange.h @@ -141,7 +141,7 @@ class ConstantRange { /// print - Print out the bounds to a stream... /// - void print(llvm_ostream &OS) const { + void print(OStream &OS) const { if (OS.stream()) print(*OS.stream()); } void print(std::ostream &OS) const; diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h index 9f0f1611d7..09878b9d1e 100644 --- a/include/llvm/Support/Debug.h +++ b/include/llvm/Support/Debug.h @@ -65,10 +65,10 @@ bool isCurrentDebugType(const char *Type); /// 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. /// -llvm_ostream getErrorOutputStream(const char *DebugType); +OStream getErrorOutputStream(const char *DebugType); #ifdef NDEBUG -#define DOUT llvm_ostream() +#define DOUT NullStream #else #define DOUT getErrorOutputStream(DEBUG_TYPE) #endif diff --git a/include/llvm/Support/GraphWriter.h b/include/llvm/Support/GraphWriter.h index 8602e74c14..b9566b84f8 100644 --- a/include/llvm/Support/GraphWriter.h +++ b/include/llvm/Support/GraphWriter.h @@ -247,16 +247,16 @@ sys::Path WriteGraph(const GraphType &G, std::string ErrMsg; sys::Path Filename = sys::Path::GetTemporaryDirectory(&ErrMsg); if (Filename.isEmpty()) { - llvm_cerr << "Error: " << ErrMsg << "\n"; + cerr << "Error: " << ErrMsg << "\n"; return Filename; } Filename.appendComponent(Name + ".dot"); if (Filename.makeUnique(true,&ErrMsg)) { - llvm_cerr << "Error: " << ErrMsg << "\n"; + cerr << "Error: " << ErrMsg << "\n"; return sys::Path(); } - llvm_cerr << "Writing '" << Filename << "'... "; + cerr << "Writing '" << Filename << "'... "; std::ofstream O(Filename.c_str()); @@ -275,12 +275,12 @@ sys::Path WriteGraph(const GraphType &G, // Output the end of the graph W.writeFooter(); - llvm_cerr << " done. \n"; + cerr << " done. \n"; O.close(); } else { - llvm_cerr << "error opening file for writing!\n"; + cerr << "error opening file for writing!\n"; Filename.clear(); } diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index fef63c3032..83653aa745 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -65,8 +65,8 @@ public: virtual void passRegistered(const PassInfo *P) { if (ignorablePass(P) || !Opt) return; if (findOption(P->getPassArgument()) != getNumOptions()) { - llvm_cerr << "Two passes with the same argument (-" - << P->getPassArgument() << ") attempted to be registered!\n"; + cerr << "Two passes with the same argument (-" + << P->getPassArgument() << ") attempted to be registered!\n"; abort(); } addLiteralOption(P->getPassArgument(), P, P->getPassName()); diff --git a/include/llvm/Support/Streams.h b/include/llvm/Support/Streams.h index a422756c63..c4afc86baa 100644 --- a/include/llvm/Support/Streams.h +++ b/include/llvm/Support/Streams.h @@ -7,48 +7,64 @@ // //===----------------------------------------------------------------------===// // -// This file implements a wrapper for the std::cout and std::cerr I/O streams. -// It prevents the need to include to each file just to get I/O. +// This file implements a wrapper for the STL I/O streams. It prevents the need +// to include in a file just to get I/O. // //===----------------------------------------------------------------------===// #ifndef LLVM_SUPPORT_STREAMS_H #define LLVM_SUPPORT_STREAMS_H -#include // Doesn't have static d'tors!! +#include namespace llvm { - /// llvm_ostream - Acts like an ostream. It's a wrapper for the std::cerr and - /// std::cout ostreams. However, it doesn't require #including in - /// every file, which increases static c'tors & d'tors in the object code. + /// 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 + /// in every file (doing so increases static c'tors & d'tors in the + /// object code). /// - class llvm_ostream { - std::ostream* Stream; + template + class BaseStream { + StreamTy *Stream; public: - llvm_ostream() : Stream(0) {} - llvm_ostream(std::ostream &OStream) : Stream(&OStream) {} + BaseStream() : Stream(0) {} + BaseStream(StreamTy &S) : Stream(&S) {} + BaseStream(StreamTy *S) : Stream(S) {} - std::ostream* stream() const { return Stream; } + StreamTy *stream() const { return Stream; } - inline llvm_ostream &operator << (std::ostream& (*Func)(std::ostream&)) { + inline BaseStream &operator << (StreamTy &(*Func)(StreamTy&)) { if (Stream) *Stream << Func; return *this; } - + template - llvm_ostream &operator << (const Ty &Thing) { + BaseStream &operator << (const Ty &Thing) { if (Stream) *Stream << Thing; return *this; } - bool operator == (const std::ostream &OS) { return &OS == Stream; } - bool operator == (const llvm_ostream &OS) { return OS.Stream == Stream; } + template + BaseStream &operator >> (const Ty &Thing) { + if (Stream) *Stream >> Thing; + return *this; + } + + bool operator == (const StreamTy &S) { return &S == Stream; } + bool operator != (const StreamTy &S) { return !(*this == S); } + bool operator == (const BaseStream &S) { return S.Stream == Stream; } + bool operator != (const BaseStream &S) { return !(*this == S); } }; - extern llvm_ostream llvm_null; - extern llvm_ostream llvm_cout; - extern llvm_ostream llvm_cerr; + typedef BaseStream OStream; + typedef BaseStream IStream; + typedef BaseStream StringStream; + + extern OStream NullStream; + extern OStream cout; + extern OStream cerr; + extern IStream cin; } // End llvm namespace diff --git a/include/llvm/Type.h b/include/llvm/Type.h index a69e751f78..4da8feb8a6 100644 --- a/include/llvm/Type.h +++ b/include/llvm/Type.h @@ -136,7 +136,7 @@ protected: /// mutable std::vector AbstractTypeUsers; public: - void print(llvm_ostream &O) const { + void print(OStream &O) const { if (O.stream()) print(*O.stream()); } void print(std::ostream &O) const; diff --git a/include/llvm/Value.h b/include/llvm/Value.h index 5dfe63f1b0..e8df7cd096 100644 --- a/include/llvm/Value.h +++ b/include/llvm/Value.h @@ -75,7 +75,7 @@ public: /// print - Implement operator<< on Value... /// - void print(llvm_ostream &O) const { + void print(OStream &O) const { if (O.stream()) print(*O.stream()); } virtual void print(std::ostream &O) const = 0; diff --git a/lib/Analysis/AliasAnalysisCounter.cpp b/lib/Analysis/AliasAnalysisCounter.cpp index d563c13c10..b2b6739ae1 100644 --- a/lib/Analysis/AliasAnalysisCounter.cpp +++ b/lib/Analysis/AliasAnalysisCounter.cpp @@ -39,37 +39,33 @@ namespace { } void printLine(const char *Desc, unsigned Val, unsigned Sum) { - llvm_cerr << " " << Val << " " << Desc << " responses (" - << Val*100/Sum << "%)\n"; + cerr << " " << Val << " " << Desc << " responses (" + << Val*100/Sum << "%)\n"; } ~AliasAnalysisCounter() { unsigned AASum = No+May+Must; unsigned MRSum = NoMR+JustRef+JustMod+MR; if (AASum + MRSum) { // Print a report if any counted queries occurred... - llvm_cerr - << "\n===== Alias Analysis Counter Report =====\n" - << " Analysis counted: " << Name << "\n" - << " " << AASum << " Total Alias Queries Performed\n"; + cerr << "\n===== Alias Analysis Counter Report =====\n" + << " Analysis counted: " << Name << "\n" + << " " << AASum << " Total Alias Queries Performed\n"; if (AASum) { printLine("no alias", No, AASum); printLine("may alias", May, AASum); printLine("must alias", Must, AASum); - llvm_cerr - << " Alias Analysis Counter Summary: " << No*100/AASum << "%/" - << May*100/AASum << "%/" << Must*100/AASum<<"%\n\n"; + cerr << " Alias Analysis Counter Summary: " << No*100/AASum << "%/" + << May*100/AASum << "%/" << Must*100/AASum<<"%\n\n"; } - llvm_cerr - << " " << MRSum << " Total Mod/Ref Queries Performed\n"; + cerr << " " << MRSum << " Total Mod/Ref Queries Performed\n"; if (MRSum) { printLine("no mod/ref", NoMR, MRSum); printLine("ref", JustRef, MRSum); printLine("mod", JustMod, MRSum); printLine("mod/ref", MR, MRSum); - llvm_cerr - << " Mod/Ref Analysis Counter Summary: " << NoMR*100/MRSum<< "%/" - << JustRef*100/MRSum << "%/" << JustMod*100/MRSum << "%/" - << MR*100/MRSum <<"%\n\n"; + cerr << " Mod/Ref Analysis Counter Summary: " <" << *CS.getInstruction(); + cerr << "\t<->" << *CS.getInstruction(); } return R; } diff --git a/lib/Analysis/AliasAnalysisEvaluator.cpp b/lib/Analysis/AliasAnalysisEvaluator.cpp index d64394a879..31875f8710 100644 --- a/lib/Analysis/AliasAnalysisEvaluator.cpp +++ b/lib/Analysis/AliasAnalysisEvaluator.cpp @@ -79,7 +79,7 @@ FunctionPass *llvm::createAAEvalPass() { return new AAEval(); } static inline void PrintResults(const char *Msg, bool P, Value *V1, Value *V2, Module *M) { if (P) { - llvm_cerr << " " << Msg << ":\t"; + cerr << " " << Msg << ":\t"; WriteAsOperand(std::cerr, V1, true, M) << ", "; WriteAsOperand(std::cerr, V2, true, M) << "\n"; } @@ -89,9 +89,9 @@ static inline void PrintModRefResults(const char *Msg, bool P, Instruction *I, Value *Ptr, Module *M) { if (P) { - llvm_cerr << " " << Msg << ": Ptr: "; + cerr << " " << Msg << ": Ptr: "; WriteAsOperand(std::cerr, Ptr, true, M); - llvm_cerr << "\t<->" << *I; + cerr << "\t<->" << *I; } } @@ -125,8 +125,8 @@ bool AAEval::runOnFunction(Function &F) { if (PrintNoAlias || PrintMayAlias || PrintMustAlias || PrintNoModRef || PrintMod || PrintRef || PrintModRef) - llvm_cerr << "Function: " << F.getName() << ": " << Pointers.size() - << " pointers, " << CallSites.size() << " call sites\n"; + cerr << "Function: " << F.getName() << ": " << Pointers.size() + << " pointers, " << CallSites.size() << " call sites\n"; // iterate over the worklist, and run the full (n^2)/2 disambiguations for (std::set::iterator I1 = Pointers.begin(), E = Pointers.end(); @@ -151,7 +151,7 @@ bool AAEval::runOnFunction(Function &F) { PrintResults("MustAlias", PrintMustAlias, *I1, *I2, F.getParent()); ++MustAlias; break; default: - llvm_cerr << "Unknown alias query result!\n"; + cerr << "Unknown alias query result!\n"; } } } @@ -181,7 +181,7 @@ bool AAEval::runOnFunction(Function &F) { PrintModRefResults(" ModRef", PrintModRef, I, *V, F.getParent()); ++ModRef; break; default: - llvm_cerr << "Unknown alias query result!\n"; + cerr << "Unknown alias query result!\n"; } } } @@ -190,45 +190,45 @@ bool AAEval::runOnFunction(Function &F) { } static void PrintPercent(unsigned Num, unsigned Sum) { - llvm_cerr << "(" << Num*100ULL/Sum << "." + cerr << "(" << Num*100ULL/Sum << "." << ((Num*1000ULL/Sum) % 10) << "%)\n"; } bool AAEval::doFinalization(Module &M) { unsigned AliasSum = NoAlias + MayAlias + MustAlias; - llvm_cerr << "===== Alias Analysis Evaluator Report =====\n"; + cerr << "===== Alias Analysis Evaluator Report =====\n"; if (AliasSum == 0) { - llvm_cerr << " Alias Analysis Evaluator Summary: No pointers!\n"; + cerr << " Alias Analysis Evaluator Summary: No pointers!\n"; } else { - llvm_cerr << " " << AliasSum << " Total Alias Queries Performed\n"; - llvm_cerr << " " << NoAlias << " no alias responses "; + cerr << " " << AliasSum << " Total Alias Queries Performed\n"; + cerr << " " << NoAlias << " no alias responses "; PrintPercent(NoAlias, AliasSum); - llvm_cerr << " " << MayAlias << " may alias responses "; + cerr << " " << MayAlias << " may alias responses "; PrintPercent(MayAlias, AliasSum); - llvm_cerr << " " << MustAlias << " must alias responses "; + cerr << " " << MustAlias << " must alias responses "; PrintPercent(MustAlias, AliasSum); - llvm_cerr << " Alias Analysis Evaluator Pointer Alias Summary: " - << NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/" - << MustAlias*100/AliasSum << "%\n"; + cerr << " Alias Analysis Evaluator Pointer Alias Summary: " + << NoAlias*100/AliasSum << "%/" << MayAlias*100/AliasSum << "%/" + << MustAlias*100/AliasSum << "%\n"; } // Display the summary for mod/ref analysis unsigned ModRefSum = NoModRef + Mod + Ref + ModRef; if (ModRefSum == 0) { - llvm_cerr << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n"; + cerr << " Alias Analysis Mod/Ref Evaluator Summary: no mod/ref!\n"; } else { - llvm_cerr << " " << ModRefSum << " Total ModRef Queries Performed\n"; - llvm_cerr << " " << NoModRef << " no mod/ref responses "; + cerr << " " << ModRefSum << " Total ModRef Queries Performed\n"; + cerr << " " << NoModRef << " no mod/ref responses "; PrintPercent(NoModRef, ModRefSum); - llvm_cerr << " " << Mod << " mod responses "; + cerr << " " << Mod << " mod responses "; PrintPercent(Mod, ModRefSum); - llvm_cerr << " " << Ref << " ref responses "; + cerr << " " << Ref << " ref responses "; PrintPercent(Ref, ModRefSum); - llvm_cerr << " " << ModRef << " mod & ref responses "; + cerr << " " << ModRef << " mod & ref responses "; PrintPercent(ModRef, ModRefSum); - llvm_cerr << " Alias Analysis Evaluator Mod/Ref Summary: " - << NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/" - << Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n"; + cerr << " Alias Analysis Evaluator Mod/Ref Summary: " + << NoModRef*100/ModRefSum << "%/" << Mod*100/ModRefSum << "%/" + << Ref*100/ModRefSum << "%/" << ModRef*100/ModRefSum << "%\n"; } return false; diff --git a/lib/Analysis/AliasSetTracker.cpp b/lib/Analysis/AliasSetTracker.cpp index f07ff6f867..9ab2b8ad26 100644 --- a/lib/Analysis/AliasSetTracker.cpp +++ b/lib/Analysis/AliasSetTracker.cpp @@ -543,8 +543,8 @@ void AliasSetTracker::print(std::ostream &OS) const { OS << "\n"; } -void AliasSet::dump() const { print (llvm_cerr); } -void AliasSetTracker::dump() const { print(llvm_cerr); } +void AliasSet::dump() const { print (cerr); } +void AliasSetTracker::dump() const { print(cerr); } //===----------------------------------------------------------------------===// // AliasSetPrinter Pass @@ -564,7 +564,7 @@ namespace { for (inst_iterator I = inst_begin(F), E = inst_end(F); I != E; ++I) Tracker->add(&*I); - Tracker->print(llvm_cerr); + Tracker->print(cerr); delete Tracker; return false; } diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 26bcb438a2..ce55b4de42 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -745,8 +745,8 @@ BasicAliasAnalysis::CheckGEPInstructions( assert(Offset1= SizeMax) { - //llvm_cerr << "Determined that these two GEP's don't alias [" - // << SizeMax << " bytes]: \n" << *GEP1 << *GEP2; + //cerr << "Determined that these two GEP's don't alias [" + // << SizeMax << " bytes]: \n" << *GEP1 << *GEP2; return NoAlias; } } diff --git a/lib/Analysis/CFGPrinter.cpp b/lib/Analysis/CFGPrinter.cpp index bfc71c6686..f16dca833c 100644 --- a/lib/Analysis/CFGPrinter.cpp +++ b/lib/Analysis/CFGPrinter.cpp @@ -92,14 +92,14 @@ namespace { struct CFGPrinter : public FunctionPass { virtual bool runOnFunction(Function &F) { std::string Filename = "cfg." + F.getName() + ".dot"; - llvm_cerr << "Writing '" << Filename << "'..."; + cerr << "Writing '" << Filename << "'..."; std::ofstream File(Filename.c_str()); if (File.good()) WriteGraph(File, (const Function*)&F); else - llvm_cerr << " error opening file for writing!"; - llvm_cerr << "\n"; + cerr << " error opening file for writing!"; + cerr << "\n"; return false; } diff --git a/lib/Analysis/ConstantRange.cpp b/lib/Analysis/ConstantRange.cpp index 1f1a1b5757..2c215866c6 100644 --- a/lib/Analysis/ConstantRange.cpp +++ b/lib/Analysis/ConstantRange.cpp @@ -370,5 +370,5 @@ void ConstantRange::print(std::ostream &OS) const { /// dump - Allow printing from a debugger easily... /// void ConstantRange::dump() const { - print(llvm_cerr); + print(cerr); } diff --git a/lib/Analysis/DataStructure/BottomUpClosure.cpp b/lib/Analysis/DataStructure/BottomUpClosure.cpp index f5ca5fd6f5..e8592b13b6 100644 --- a/lib/Analysis/DataStructure/BottomUpClosure.cpp +++ b/lib/Analysis/DataStructure/BottomUpClosure.cpp @@ -501,7 +501,7 @@ DSGraph &BUDataStructures::CreateGraphForExternalFunction(const Function &Fn) { DSG->getNodeForValue(F->arg_begin()).mergeWith(N); } else { - llvm_cerr << "Unrecognized external function: " << F->getName() << "\n"; + cerr << "Unrecognized external function: " << F->getName() << "\n"; abort(); } @@ -588,21 +588,21 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { ++NumBUInlines; } else { if (!Printed) - llvm_cerr << "In Fns: " << Graph.getFunctionNames() << "\n"; - llvm_cerr << " calls " << CalledFuncs.size() - << " fns from site: " << CS.getCallSite().getInstruction() - << " " << *CS.getCallSite().getInstruction(); - llvm_cerr << " Fns ="; + cerr << "In Fns: " << Graph.getFunctionNames() << "\n"; + cerr << " calls " << CalledFuncs.size() + << " fns from site: " << CS.getCallSite().getInstruction() + << " " << *CS.getCallSite().getInstruction(); + cerr << " Fns ="; unsigned NumPrinted = 0; for (std::vector::iterator I = CalledFuncs.begin(), E = CalledFuncs.end(); I != E; ++I) { - if (NumPrinted++ < 8) llvm_cerr << " " << (*I)->getName(); + if (NumPrinted++ < 8) cerr << " " << (*I)->getName(); // Add the call edges to the call graph. ActualCallees.insert(std::make_pair(TheCall, *I)); } - llvm_cerr << "\n"; + cerr << "\n"; // See if we already computed a graph for this set of callees. std::sort(CalledFuncs.begin(), CalledFuncs.end()); @@ -645,7 +645,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { // Clean up the final graph! GI->removeDeadNodes(DSGraph::KeepUnreachableGlobals); } else { - llvm_cerr << "***\n*** RECYCLED GRAPH ***\n***\n"; + cerr << "***\n*** RECYCLED GRAPH ***\n***\n"; } GI = IndCallGraph.first; @@ -685,7 +685,7 @@ void BUDataStructures::calculateGraph(DSGraph &Graph) { E = MainSM.global_end(); I != E; ++I) RC.getClonedNH(MainSM[*I]); - //Graph.writeGraphToFile(llvm_cerr, "bu_" + F.getName()); + //Graph.writeGraphToFile(cerr, "bu_" + F.getName()); } static const Function *getFnForValue(const Value *V) { @@ -746,8 +746,8 @@ void BUDataStructures::copyValue(Value *From, Value *To) { return; } - llvm_cerr << *From; - llvm_cerr << *To; + cerr << *From; + cerr << *To; assert(0 && "Do not know how to copy this yet!"); abort(); } diff --git a/lib/Analysis/DataStructure/CallTargets.cpp b/lib/Analysis/DataStructure/CallTargets.cpp index 5ed4457418..bae866fd34 100644 --- a/lib/Analysis/DataStructure/CallTargets.cpp +++ b/lib/Analysis/DataStructure/CallTargets.cpp @@ -17,15 +17,15 @@ // //===----------------------------------------------------------------------===// +#include "llvm/Analysis/DataStructure/CallTargets.h" #include "llvm/Module.h" #include "llvm/Instructions.h" #include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Analysis/DataStructure/DSGraph.h" -#include "llvm/Analysis/DataStructure/CallTargets.h" #include "llvm/ADT/Statistic.h" #include "llvm/Support/Streams.h" -#include #include "llvm/Constants.h" +#include using namespace llvm; namespace { @@ -58,11 +58,11 @@ void CallTargetFinder::findIndTargets(Module &M) } if (N->isComplete() && !IndMap[cs].size()) { ++CompleteEmpty; - llvm_cerr << "Call site empty: '" - << cs.getInstruction()->getName() - << "' In '" - << cs.getInstruction()->getParent()->getParent()->getName() - << "'\n"; + cerr << "Call site empty: '" + << cs.getInstruction()->getName() + << "' In '" + << cs.getInstruction()->getParent()->getParent()->getName() + << "'\n"; } } else { ++DirCall; diff --git a/lib/Analysis/DataStructure/DataStructure.cpp b/lib/Analysis/DataStructure/DataStructure.cpp index 80237c4f0b..c81fd6ad34 100644 --- a/lib/Analysis/DataStructure/DataStructure.cpp +++ b/lib/Analysis/DataStructure/DataStructure.cpp @@ -25,7 +25,6 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/SCCIterator.h" #include "llvm/ADT/Statistic.h" -#include "llvm/Support/Streams.h" #include "llvm/Support/Timer.h" #include #include @@ -1263,7 +1262,7 @@ DSGraph::~DSGraph() { } // dump - Allow inspection of graph in a debugger. -void DSGraph::dump() const { print(llvm_cerr); } +void DSGraph::dump() const { print(cerr); } /// remapLinks - Change all of the Links in the current node according to the diff --git a/lib/Analysis/DataStructure/DataStructureStats.cpp b/lib/Analysis/DataStructure/DataStructureStats.cpp index f7fbe3b33c..1357a334eb 100644 --- a/lib/Analysis/DataStructure/DataStructureStats.cpp +++ b/lib/Analysis/DataStructure/DataStructureStats.cpp @@ -92,18 +92,18 @@ void DSGraphStats::countCallees(const Function& F) { totalNumCallees += Callees.size(); ++numIndirectCalls; } else - llvm_cerr << "WARNING: No callee in Function '" << F.getName() - << "' at call: \n" - << *I->getCallSite().getInstruction(); + cerr << "WARNING: No callee in Function '" << F.getName() + << "' at call: \n" + << *I->getCallSite().getInstruction(); } TotalNumCallees += totalNumCallees; NumIndirectCalls += numIndirectCalls; if (numIndirectCalls) - llvm_cout << " In function " << F.getName() << ": " - << (totalNumCallees / (double) numIndirectCalls) - << " average callees per indirect call\n"; + cout << " In function " << F.getName() << ": " + << (totalNumCallees / (double) numIndirectCalls) + << " average callees per indirect call\n"; } DSNode *DSGraphStats::getNodeForValue(Value *V) { diff --git a/lib/Analysis/DataStructure/EquivClassGraphs.cpp b/lib/Analysis/DataStructure/EquivClassGraphs.cpp index 49c93ffc4f..2813b943ad 100644 --- a/lib/Analysis/DataStructure/EquivClassGraphs.cpp +++ b/lib/Analysis/DataStructure/EquivClassGraphs.cpp @@ -90,7 +90,7 @@ bool EquivClassGraphs::runOnModule(Module &M) { if (MainFunc && !MainFunc->isExternal()) { processSCC(getOrCreateGraph(*MainFunc), Stack, NextID, ValMap); } else { - llvm_cerr << "Fold Graphs: No 'main' function found!\n"; + cerr << "Fold Graphs: No 'main' function found!\n"; } for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) diff --git a/lib/Analysis/DataStructure/GraphChecker.cpp b/lib/Analysis/DataStructure/GraphChecker.cpp index cef3efed8f..8e4d3fce87 100644 --- a/lib/Analysis/DataStructure/GraphChecker.cpp +++ b/lib/Analysis/DataStructure/GraphChecker.cpp @@ -84,8 +84,8 @@ FunctionPass *llvm::createDataStructureGraphCheckerPass() { DSGC::DSGC() { if (!AbortIfAnyCollapsed && AbortIfCollapsed.empty() && CheckFlags.empty() && AbortIfMerged.empty()) { - llvm_cerr << "The -datastructure-gc is useless if you don't specify any" - " -dsgc-* options. See the -help-hidden output for a list.\n"; + cerr << "The -datastructure-gc is useless if you don't specify any" + << " -dsgc-* options. See the -help-hidden output for a list.\n"; abort(); } } @@ -123,8 +123,8 @@ void DSGC::verify(const DSGraph &G) { for (DSGraph::node_const_iterator I = G.node_begin(), E = G.node_end(); I != E; ++I) if (I->isNodeCompletelyFolded()) { - llvm_cerr << "Node is collapsed: "; - I->print(llvm_cerr, &G); + cerr << "Node is collapsed: "; + I->print(cerr, &G); abort(); } } @@ -142,8 +142,8 @@ void DSGC::verify(const DSGraph &G) { E = CheckFlags.end(); I != E; ++I) { std::string::size_type ColonPos = I->rfind(':'); if (ColonPos == std::string::npos) { - llvm_cerr << "Error: '" << *I - << "' is an invalid value for the --dsgc-check-flags option!\n"; + cerr << "Error: '" << *I + << "' is an invalid value for the --dsgc-check-flags option!\n"; abort(); } @@ -158,7 +158,7 @@ void DSGC::verify(const DSGraph &G) { case 'M': Flags |= DSNode::Modified; break; case 'R': Flags |= DSNode::Read; break; case 'A': Flags |= DSNode::Array; break; - default: llvm_cerr << "Invalid DSNode flag!\n"; abort(); + default: cerr << "Invalid DSNode flag!\n"; abort(); } CheckFlagsM[std::string(I->begin(), I->begin()+ColonPos)] = Flags; } @@ -176,25 +176,25 @@ void DSGC::verify(const DSGraph &G) { // Verify it is not collapsed if it is not supposed to be... if (N->isNodeCompletelyFolded() && AbortIfCollapsedS.count(Name)) { - llvm_cerr << "Node for value '%" << Name << "' is collapsed: "; - N->print(llvm_cerr, &G); + cerr << "Node for value '%" << Name << "' is collapsed: "; + N->print(cerr, &G); abort(); } if (CheckFlagsM.count(Name) && CheckFlagsM[Name] != N->getNodeFlags()) { - llvm_cerr << "Node flags are not as expected for node: " << Name - << " (" << CheckFlagsM[Name] << ":" <getNodeFlags() - << ")\n"; - N->print(llvm_cerr, &G); + cerr << "Node flags are not as expected for node: " << Name + << " (" << CheckFlagsM[Name] << ":" <getNodeFlags() + << ")\n"; + N->print(cerr, &G); abort(); } // Verify that it is not merged if it is not supposed to be... if (AbortIfMergedS.count(Name)) { if (AbortIfMergedNodes.count(N)) { - llvm_cerr << "Nodes for values '%" << Name << "' and '%" - << AbortIfMergedNodes[N] << "' is merged: "; - N->print(llvm_cerr, &G); + cerr << "Nodes for values '%" << Name << "' and '%" + << AbortIfMergedNodes[N] << "' is merged: "; + N->print(cerr, &G); abort(); } AbortIfMergedNodes[N] = Name; diff --git a/lib/Analysis/DataStructure/Local.cpp b/lib/Analysis/DataStructure/Local.cpp index 436218be9e..66ca33d876 100644 --- a/lib/Analysis/DataStructure/Local.cpp +++ b/lib/Analysis/DataStructure/Local.cpp @@ -434,7 +434,7 @@ void GraphBuilder::visitGetElementPtrInst(User &GEP) { // Variable index into a node. We must merge all of the elements of the // sequential type here. if (isa(STy)) - llvm_cerr << "Pointer indexing not handled yet!\n"; + cerr << "Pointer indexing not handled yet!\n"; else { const ArrayType *ATy = cast(STy); unsigned ElSize = TD.getTypeSize(CurTy); @@ -1061,7 +1061,7 @@ void GraphBuilder::visitCallSite(CallSite CS) { if (DisableDirectCallOpt || !isa(Callee)) { CalleeNode = getValueDest(*Callee).getNode(); if (CalleeNode == 0) { - llvm_cerr << "WARNING: Program is calling through a null pointer?\n"<< *I; + cerr << "WARNING: Program is calling through a null pointer?\n"<< *I; return; // Calling a null pointer? } } diff --git a/lib/Analysis/DataStructure/Printer.cpp b/lib/Analysis/DataStructure/Printer.cpp index 2e86bda548..21d75c08bc 100644 --- a/lib/Analysis/DataStructure/Printer.cpp +++ b/lib/Analysis/DataStructure/Printer.cpp @@ -37,7 +37,7 @@ namespace { Statistic NumFoldedNodes ("dsa", "Number of folded nodes (in final graph)"); } -void DSNode::dump() const { print(llvm_cerr, 0); } +void DSNode::dump() const { print(cerr, 0); } static std::string getCaption(const DSNode *N, const DSGraph *G) { std::stringstream OS; diff --git a/lib/Analysis/DataStructure/Steensgaard.cpp b/lib/Analysis/DataStructure/Steensgaard.cpp index 292dfffa0d..5ff3c3f852 100644 --- a/lib/Analysis/DataStructure/Steensgaard.cpp +++ b/lib/Analysis/DataStructure/Steensgaard.cpp @@ -53,7 +53,7 @@ namespace { } // print - Implement the Pass::print method... - void print(llvm_ostream O, const Module *M) const { + void print(OStream O, const Module *M) const { if (O.stream()) print(*O.stream(), M); } void print(std::ostream &O, const Module *M) const { diff --git a/lib/Analysis/IPA/Andersens.cpp b/lib/Analysis/IPA/Andersens.cpp index 2887503041..69462279a9 100644 --- a/lib/Analysis/IPA/Andersens.cpp +++ b/lib/Analysis/IPA/Andersens.cpp @@ -533,7 +533,7 @@ Andersens::Node *Andersens::getNodeForConstantPointer(Constant *C) { case Instruction::BitCast: return getNodeForConstantPointer(CE->getOperand(0)); default: - llvm_cerr << "Constant Expr not yet handled: " << *CE << "\n"; + cerr << "Constant Expr not yet handled: " << *CE << "\n"; assert(0); } } else { @@ -560,7 +560,7 @@ Andersens::Node *Andersens::getNodeForConstantPointerTarget(Constant *C) { case Instruction::BitCast: return getNodeForConstantPointerTarget(CE->getOperand(0)); default: - llvm_cerr << "Constant Expr not yet handled: " << *CE << "\n"; + cerr << "Constant Expr not yet handled: " << *CE << "\n"; assert(0); } } else { @@ -786,7 +786,7 @@ void Andersens::visitInstruction(Instruction &I) { return; default: // Is this something we aren't handling yet? - llvm_cerr << "Unknown instruction: " << I; + cerr << "Unknown instruction: " << I; abort(); } } @@ -1104,13 +1104,13 @@ void Andersens::SolveConstraints() { void Andersens::PrintNode(Node *N) { if (N == &GraphNodes[UniversalSet]) { - llvm_cerr << ""; + cerr << ""; return; } else if (N == &GraphNodes[NullPtr]) { - llvm_cerr << ""; + cerr << ""; return; } else if (N == &GraphNodes[NullObject]) { - llvm_cerr << ""; + cerr << ""; return; } @@ -1119,56 +1119,56 @@ void Andersens::PrintNode(Node *N) { if (Function *F = dyn_cast(V)) { if (isa(F->getFunctionType()->getReturnType()) && N == getReturnNode(F)) { - llvm_cerr << F->getName() << ":retval"; + cerr << F->getName() << ":retval"; return; } else if (F->getFunctionType()->isVarArg() && N == getVarargNode(F)) { - llvm_cerr << F->getName() << ":vararg"; + cerr << F->getName() << ":vararg"; return; } } if (Instruction *I = dyn_cast(V)) - llvm_cerr << I->getParent()->getParent()->getName() << ":"; + cerr << I->getParent()->getParent()->getName() << ":"; else if (Argument *Arg = dyn_cast(V)) - llvm_cerr << Arg->getParent()->getName() << ":"; + cerr << Arg->getParent()->getName() << ":"; if (V->hasName()) - llvm_cerr << V->getName(); + cerr << V->getName(); else - llvm_cerr << "(unnamed)"; + cerr << "(unnamed)"; if (isa(V) || isa(V)) if (N == getObject(V)) - llvm_cerr << ""; + cerr << ""; } void Andersens::PrintConstraints() { - llvm_cerr << "Constraints:\n"; + cerr << "Constraints:\n"; for (unsigned i = 0, e = Constraints.size(); i != e; ++i) { - llvm_cerr << " #" << i << ": "; + cerr << " #" << i << ": "; Constraint &C = Constraints[i]; if (C.Type == Constraint::Store) - llvm_cerr << "*"; + cerr << "*"; PrintNode(C.Dest); - llvm_cerr << " = "; + cerr << " = "; if (C.Type == Constraint::Load) - llvm_cerr << "*"; + cerr << "*"; PrintNode(C.Src); - llvm_cerr << "\n"; + cerr << "\n"; } } void Andersens::PrintPointsToGraph() { - llvm_cerr << "Points-to graph:\n"; + cerr << "Points-to graph:\n"; for (unsigned i = 0, e = GraphNodes.size(); i != e; ++i) { Node *N = &GraphNodes[i]; - llvm_cerr << "[" << (N->end() - N->begin()) << "] "; + cerr << "[" << (N->end() - N->begin()) << "] "; PrintNode(N); - llvm_cerr << "\t--> "; + cerr << "\t--> "; for (Node::iterator I = N->begin(), E = N->end(); I != E; ++I) { - if (I != N->begin()) llvm_cerr << ", "; + if (I != N->begin()) cerr << ", "; PrintNode(*I); } - llvm_cerr << "\n"; + cerr << "\n"; } } diff --git a/lib/Analysis/IPA/CallGraph.cpp b/lib/Analysis/IPA/CallGraph.cpp index 128e11ebd7..6e8ca184b4 100644 --- a/lib/Analysis/IPA/CallGraph.cpp +++ b/lib/Analysis/IPA/CallGraph.cpp @@ -74,7 +74,7 @@ public: AU.setPreservesAll(); } - void print(llvm_ostream &o, const Module *M) const { + void print(OStream &o, const Module *M) const { if (o.stream()) print(*o.stream(), M); } @@ -95,7 +95,7 @@ public: /// dump - Print out this call graph. /// inline void dump() const { - print(llvm_cerr, Mod); + print(cerr, Mod); } CallGraphNode* getExternalCallingNode() const { return ExternalCallingNode; } @@ -212,7 +212,7 @@ void CallGraph::print(std::ostream &OS, const Module *M) const { } void CallGraph::dump() const { - print(llvm_cerr, 0); + print(cerr, 0); } //===----------------------------------------------------------------------===// @@ -275,7 +275,7 @@ void CallGraphNode::print(std::ostream &OS) const { OS << "\n"; } -void CallGraphNode::dump() const { print(llvm_cerr); } +void CallGraphNode::dump() const { print(cerr); } void CallGraphNode::removeCallEdgeTo(CallGraphNode *Callee) { for (unsigned i = CalledFunctions.size(); ; --i) { diff --git a/lib/Analysis/InstCount.cpp b/lib/Analysis/InstCount.cpp index 38f0bbaa9a..04dfbf4cf9 100644 --- a/lib/Analysis/InstCount.cpp +++ b/lib/Analysis/InstCount.cpp @@ -43,7 +43,7 @@ namespace { #include "llvm/Instruction.def" void visitInstruction(Instruction &I) { - llvm_cerr << "Instruction Count does not know about " << I; + cerr << "Instruction Count does not know about " << I; abort(); } public: diff --git a/lib/Analysis/LoopInfo.cpp b/lib/Analysis/LoopInfo.cpp index 18957607ff..b33e414bf0 100644 --- a/lib/Analysis/LoopInfo.cpp +++ b/lib/Analysis/LoopInfo.cpp @@ -80,7 +80,7 @@ void Loop::print(std::ostream &OS, unsigned Depth) const { } void Loop::dump() const { - print(llvm_cerr); + print(cerr); } diff --git a/lib/Analysis/ProfileInfoLoader.cpp b/lib/Analysis/ProfileInfoLoader.cpp index 3c19f5e9b9..b1ed235c10 100644 --- a/lib/Analysis/ProfileInfoLoader.cpp +++ b/lib/Analysis/ProfileInfoLoader.cpp @@ -37,7 +37,7 @@ static void ReadProfilingBlock(const char *ToolName, FILE *F, // Read the number of entries... unsigned NumEntries; if (fread(&NumEntries, sizeof(unsigned), 1, F) != 1) { - llvm_cerr << ToolName << ": data packet truncated!\n"; + cerr << ToolName << ": data packet truncated!\n"; perror(0); exit(1); } @@ -48,7 +48,7 @@ static void ReadProfilingBlock(const char *ToolName, FILE *F, // Read in the block of data... if (fread(&TempSpace[0], sizeof(unsigned)*NumEntries, 1, F) != 1) { - llvm_cerr << ToolName << ": data packet truncated!\n"; + cerr << ToolName << ": data packet truncated!\n"; perror(0); exit(1); } @@ -75,7 +75,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName, Module &TheModule) : M(TheModule) { FILE *F = fopen(Filename.c_str(), "r"); if (F == 0) { - llvm_cerr << ToolName << ": Error opening '" << Filename << "': "; + cerr << ToolName << ": Error opening '" << Filename << "': "; perror(0); exit(1); } @@ -93,7 +93,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName, case ArgumentInfo: { unsigned ArgLength; if (fread(&ArgLength, sizeof(unsigned), 1, F) != 1) { - llvm_cerr << ToolName << ": arguments packet truncated!\n"; + cerr << ToolName << ": arguments packet truncated!\n"; perror(0); exit(1); } @@ -104,7 +104,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName, if (ArgLength) if (fread(&Chars[0], (ArgLength+3) & ~3, 1, F) != 1) { - llvm_cerr << ToolName << ": arguments packet truncated!\n"; + cerr << ToolName << ": arguments packet truncated!\n"; perror(0); exit(1); } @@ -129,7 +129,7 @@ ProfileInfoLoader::ProfileInfoLoader(const char *ToolName, break; default: - llvm_cerr << ToolName << ": Unknown packet type #" << PacketType << "!\n"; + cerr << ToolName << ": Unknown packet type #" << PacketType << "!\n"; exit(1); } } @@ -156,7 +156,7 @@ void ProfileInfoLoader::getFunctionCounts(std::vectorgetParent(), BlockCounts[i].second)); } else { - llvm_cerr << "Function counts are not available!\n"; + cerr << "Function counts are not available!\n"; } return; } @@ -200,8 +200,8 @@ void ProfileInfoLoader::getBlockCounts(std::vector= TI->getNumSuccessors()) { static bool Warned = false; if (!Warned) { - llvm_cerr << "WARNING: profile info doesn't seem to match" - << " the program!\n"; + cerr << "WARNING: profile info doesn't seem to match" + << " the program!\n"; Warned = true; } } else { @@ -226,7 +226,7 @@ void ProfileInfoLoader::getBlockCounts(std::vector > &Counts) { if (EdgeCounts.empty()) { - llvm_cerr << "Edge counts not available, and no synthesis " - << "is implemented yet!\n"; + cerr << "Edge counts not available, and no synthesis " + << "is implemented yet!\n"; return; } @@ -268,9 +268,8 @@ void ProfileInfoLoader::getEdgeCounts(std::vector &Trace) { if (BBTrace.empty ()) { - llvm_cerr << "Basic block trace is not available!\n"; + cerr << "Basic block trace is not available!\n"; return; } - llvm_cerr << "Basic block trace loading is not implemented yet!\n"; + cerr << "Basic block trace loading is not implemented yet!\n"; } - diff --git a/lib/Analysis/ProfileInfoLoaderPass.cpp b/lib/Analysis/ProfileInfoLoaderPass.cpp index 08a45c62c5..426bd18746 100644 --- a/lib/Analysis/ProfileInfoLoaderPass.cpp +++ b/lib/Analysis/ProfileInfoLoaderPass.cpp @@ -76,8 +76,8 @@ bool LoaderPass::runOnModule(Module &M) { TerminatorInst *TI = BB->getTerminator(); if (SuccNum >= TI->getNumSuccessors()) { if (!PrintedWarning) { - llvm_cerr << "WARNING: profile information is inconsistent with " - << "the current program!\n"; + cerr << "WARNING: profile information is inconsistent with " + << "the current program!\n"; PrintedWarning = true; } } else { diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index ba903e0140..9fc0c76b0e 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -118,7 +118,7 @@ namespace { // SCEV::~SCEV() {} void SCEV::dump() const { - print(llvm_cerr); + print(cerr); } /// getValueRange - Return the tightest constant bounds that this value is @@ -1558,11 +1558,11 @@ SCEVHandle ScalarEvolutionsImpl::ComputeIterationCount(const Loop *L) { break; default: #if 0 - llvm_cerr << "ComputeIterationCount "; + cerr << "ComputeIterationCount "; if (ExitCond->getOperand(0)->getType()->isUnsigned()) - llvm_cerr << "[unsigned] "; - llvm_cerr << *LHS << " " - << Instruction::getOpcodeName(Cond) << " " << *RHS << "\n"; + cerr << "[unsigned] "; + cerr << *LHS << " " + << Instruction::getOpcodeName(Cond) << " " << *RHS << "\n"; #endif break; } @@ -1678,9 +1678,9 @@ ComputeLoadConstantCompareIterationCount(LoadInst *LI, Constant *RHS, if (!isa(Result)) break; // Couldn't decide for sure if (cast(Result)->getValue() == false) { #if 0 - llvm_cerr << "\n***\n*** Computed loop count " << *ItCst - << "\n*** From global " << *GV << "*** BB: " << *L->getHeader() - << "***\n"; + cerr << "\n***\n*** Computed loop count " << *ItCst + << "\n*** From global " << *GV << "*** BB: " << *L->getHeader() + << "***\n"; #endif ++NumArrayLenItCounts; return SCEVConstant::get(ItCst); // Found terminating iteration! @@ -2147,8 +2147,8 @@ SCEVHandle ScalarEvolutionsImpl::HowFarToZero(SCEV *V, const Loop *L) { SCEVConstant *R2 = dyn_cast(Roots.second); if (R1) { #if 0 - llvm_cerr << "HFTZ: " << *V << " - sol#1: " << *R1 - << " sol#2: " << *R2 << "\n"; + cerr << "HFTZ: " << *V << " - sol#1: " << *R1 + << " sol#2: " << *R2 << "\n"; #endif // Pick the smallest positive root value. assert(R1->getType()->isUnsigned()&&"Didn't canonicalize to unsigned?"); @@ -2276,8 +2276,8 @@ HowManyLessThans(SCEV *LHS, SCEV *RHS, const Loop *L) { default: break; } - //llvm_cerr << "Computed Loop Trip Count as: " << - // *SCEV::getMinusSCEV(RHS, AddRec->getOperand(0)) << "\n"; + //cerr << "Computed Loop Trip Count as: " + // << *SCEV::getMinusSCEV(RHS, AddRec->getOperand(0)) << "\n"; return SCEV::getMinusSCEV(RHS, AddRec->getOperand(0)); } @@ -2492,20 +2492,20 @@ static void PrintLoopInfo(std::ostream &OS, const ScalarEvolution *SE, for (Loop::iterator I = L->begin(), E = L->end(); I != E; ++I) PrintLoopInfo(OS, SE, *I); - llvm_cerr << "Loop " << L->getHeader()->getName() << ": "; + cerr << "Loop " << L->getHeader()->getName() << ": "; std::vector ExitBlocks; L->getExitBlocks(ExitBlocks); if (ExitBlocks.size() != 1) - llvm_cerr << " "; + cerr << " "; if (SE->hasLoopInvariantIterationCount(L)) { - llvm_cerr << *SE->getIterationCount(L) << " iterations! "; + cerr << *SE->getIterationCount(L) << " iterations! "; } else { - llvm_cerr << "Unpredictable iteration count. "; + cerr << "Unpredictable iteration count. "; } - llvm_cerr << "\n"; + cerr << "\n"; } void ScalarEvolution::print(std::ostream &OS, const Module* ) const { diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 2698ace5b3..9432cc278b 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -13,9 +13,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/LoopInfo.h" #include "llvm/Analysis/ScalarEvolutionExpander.h" - +#include "llvm/Analysis/LoopInfo.h" using namespace llvm; /// InsertCastOfTo - Insert a cast of V to the specified type, doing what @@ -175,7 +174,7 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) { SCEVHandle IH = SCEVUnknown::get(I); // Get I as a "symbolic" SCEV. SCEVHandle V = S->evaluateAtIteration(IH); - //llvm_cerr << "Evaluated: " << *this << "\n to: " << *V << "\n"; + //cerr << "Evaluated: " << *this << "\n to: " << *V << "\n"; return expandInTy(V, Ty); } diff --git a/lib/Analysis/Trace.cpp b/lib/Analysis/Trace.cpp index d0457557c8..a0aa955ebe 100644 --- a/lib/Analysis/Trace.cpp +++ b/lib/Analysis/Trace.cpp @@ -25,14 +25,13 @@ Function *Trace::getFunction() const { return getEntryBasicBlock()->getParent(); } - Module *Trace::getModule() const { return getFunction()->getParent(); } /// print - Write trace to output stream. /// -void Trace::print(llvm_ostream &O) const { +void Trace::print(OStream &O) const { Function *F = getFunction (); O << "; Trace from function " << F->getName() << ", blocks:\n"; for (const_iterator i = begin(), e = end(); i != e; ++i) { @@ -48,5 +47,5 @@ void Trace::print(llvm_ostream &O) const { /// output stream. /// void Trace::dump() const { - print(llvm_cerr); + print(cerr); } diff --git a/lib/AsmParser/llvmAsmParser.cpp.cvs b/lib/AsmParser/llvmAsmParser.cpp.cvs index 84d6bada7c..681990382f 100644 --- a/lib/AsmParser/llvmAsmParser.cpp.cvs +++ b/lib/AsmParser/llvmAsmParser.cpp.cvs @@ -1,7 +1,9 @@ -/* A Bison parser, made by GNU Bison 2.1. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Skeleton implementation for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,13 +20,21 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ -/* Written by Richard Stallman by simplifying the original so called - ``semantic'' parser. */ +/* C LALR(1) parser skeleton written by Richard Stallman, by + simplifying the original so-called "semantic" parser. */ /* All symbols defined below should begin with yy or YY, to avoid infringing on user name space. This should be done even for local @@ -37,7 +47,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.1" +#define YYBISON_VERSION "2.3" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -356,7 +366,7 @@ /* Copy the first part of user declarations. */ -#line 14 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 14 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" #include "ParserInternals.h" #include "llvm/CallingConv.h" @@ -403,7 +413,7 @@ static Module *ParserResult; // //#define DEBUG_UPREFS 1 #ifdef DEBUG_UPREFS -#define UR_OUT(X) llvm_cerr << X +#define UR_OUT(X) cerr << X #else #define UR_OUT(X) #endif @@ -1216,9 +1226,10 @@ Module *llvm::RunVMAsmParser(const char * AsmString, Module * M) { # define YYTOKEN_TABLE 0 #endif -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 855 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" -typedef union YYSTYPE { +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 855 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" +{ llvm::Module *ModuleVal; llvm::Function *FunctionVal; std::pair *ArgVal; @@ -1259,9 +1270,10 @@ typedef union YYSTYPE { llvm::Module::Endianness Endianness; llvm::ICmpInst::Predicate IPredicate; llvm::FCmpInst::Predicate FPredicate; -} YYSTYPE; -/* Line 196 of yacc.c. */ -#line 1265 "llvmAsmParser.tab.c" +} +/* Line 193 of yacc.c. */ +#line 1276 "llvmAsmParser.tab.c" + YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -1272,23 +1284,56 @@ typedef union YYSTYPE { /* Copy the second part of user declarations. */ -/* Line 219 of yacc.c. */ -#line 1277 "llvmAsmParser.tab.c" +/* Line 216 of yacc.c. */ +#line 1289 "llvmAsmParser.tab.c" -#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__) -# define YYSIZE_T __SIZE_TYPE__ +#ifdef short +# undef short #endif -#if ! defined (YYSIZE_T) && defined (size_t) -# define YYSIZE_T size_t + +#ifdef YYTYPE_UINT8 +typedef YYTYPE_UINT8 yytype_uint8; +#else +typedef unsigned char yytype_uint8; #endif -#if ! defined (YYSIZE_T) && (defined (__STDC__) || defined (__cplusplus)) -# include /* INFRINGES ON USER NAME SPACE */ -# define YYSIZE_T size_t + +#ifdef YYTYPE_INT8 +typedef YYTYPE_INT8 yytype_int8; +#elif (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +typedef signed char yytype_int8; +#else +typedef short int yytype_int8; +#endif + +#ifdef YYTYPE_UINT16 +typedef YYTYPE_UINT16 yytype_uint16; +#else +typedef unsigned short int yytype_uint16; +#endif + +#ifdef YYTYPE_INT16 +typedef YYTYPE_INT16 yytype_int16; +#else +typedef short int yytype_int16; #endif -#if ! defined (YYSIZE_T) -# define YYSIZE_T unsigned int + +#ifndef YYSIZE_T +# ifdef __SIZE_TYPE__ +# define YYSIZE_T __SIZE_TYPE__ +# elif defined size_t +# define YYSIZE_T size_t +# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +# include /* INFRINGES ON USER NAME SPACE */ +# define YYSIZE_T size_t +# else +# define YYSIZE_T unsigned int +# endif #endif +#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) + #ifndef YY_ # if YYENABLE_NLS # if ENABLE_NLS @@ -1301,7 +1346,32 @@ typedef union YYSTYPE { # endif #endif -#if ! defined (yyoverflow) || YYERROR_VERBOSE +/* Suppress unused-variable warnings by "using" E. */ +#if ! defined lint || defined __GNUC__ +# define YYUSE(e) ((void) (e)) +#else +# define YYUSE(e) /* empty */ +#endif + +/* Identity function, used to suppress warnings about constant conditions. */ +#ifndef lint +# define YYID(n) (n) +#else +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static int +YYID (int i) +#else +static int +YYID (i) + int i; +#endif +{ + return i; +} +#endif + +#if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -1309,64 +1379,76 @@ typedef union YYSTYPE { # if YYSTACK_USE_ALLOCA # ifdef __GNUC__ # define YYSTACK_ALLOC __builtin_alloca +# elif defined __BUILTIN_VA_ARG_INCR +# include /* INFRINGES ON USER NAME SPACE */ +# elif defined _AIX +# define YYSTACK_ALLOC __alloca +# elif defined _MSC_VER +# include /* INFRINGES ON USER NAME SPACE */ +# define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if defined (__STDC__) || defined (__cplusplus) +# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# define YYINCLUDED_STDLIB_H +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif # endif # endif # endif # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) + /* Pacify GCC's `empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely invoke alloca (N) if N exceeds 4096. Use a slightly smaller number to allow for a few compiler-allocated temporary stack slots. */ -# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2005 */ +# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */ # endif # else # define YYSTACK_ALLOC YYMALLOC # define YYSTACK_FREE YYFREE # ifndef YYSTACK_ALLOC_MAXIMUM -# define YYSTACK_ALLOC_MAXIMUM ((YYSIZE_T) -1) +# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# ifdef __cplusplus -extern "C" { +# if (defined __cplusplus && ! defined _STDLIB_H \ + && ! ((defined YYMALLOC || defined malloc) \ + && (defined YYFREE || defined free))) +# include /* INFRINGES ON USER NAME SPACE */ +# ifndef _STDLIB_H +# define _STDLIB_H 1 +# endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if (! defined (malloc) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if (! defined (free) && ! defined (YYINCLUDED_STDLIB_H) \ - && (defined (__STDC__) || defined (__cplusplus))) +# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif -# ifdef __cplusplus -} -# endif # endif -#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */ +#endif /* ! defined yyoverflow || YYERROR_VERBOSE */ -#if (! defined (yyoverflow) \ - && (! defined (__cplusplus) \ - || (defined (YYSTYPE_IS_TRIVIAL) && YYSTYPE_IS_TRIVIAL))) +#if (! defined yyoverflow \ + && (! defined __cplusplus \ + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc { - short int yyss; + yytype_int16 yyss; YYSTYPE yyvs; }; @@ -1376,13 +1458,13 @@ union yyalloc /* The size of an array large to enough to hold all stacks, each with N elements. */ # define YYSTACK_BYTES(N) \ - ((N) * (sizeof (short int) + sizeof (YYSTYPE)) \ + ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) /* Copy COUNT objects from FROM to TO. The source and destination do not overlap. */ # ifndef YYCOPY -# if defined (__GNUC__) && 1 < __GNUC__ +# if defined __GNUC__ && 1 < __GNUC__ # define YYCOPY(To, From, Count) \ __builtin_memcpy (To, From, (Count) * sizeof (*(From))) # else @@ -1393,7 +1475,7 @@ union yyalloc for (yyi = 0; yyi < (Count); yyi++) \ (To)[yyi] = (From)[yyi]; \ } \ - while (0) + while (YYID (0)) # endif # endif @@ -1411,28 +1493,22 @@ union yyalloc yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ yyptr += yynewbytes / sizeof (*yyptr); \ } \ - while (0) + while (YYID (0)) #endif -#if defined (__STDC__) || defined (__cplusplus) - typedef signed char yysigned_char; -#else - typedef short int yysigned_char; -#endif - -/* YYFINAL -- State number of the termination state. */ +/* YYFINAL -- State number of the termination state. */ #define YYFINAL 4 /* YYLAST -- Last index in YYTABLE. */ #define YYLAST 1509 -/* YYNTOKENS -- Number of terminals. */ +/* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 159 -/* YYNNTS -- Number of nonterminals. */ +/* YYNNTS -- Number of nonterminals. */ #define YYNNTS 78 -/* YYNRULES -- Number of rules. */ +/* YYNRULES -- Number of rules. */ #define YYNRULES 297 -/* YYNRULES -- Number of states. */ +/* YYNRULES -- Number of states. */ #define YYNSTATES 578 /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ @@ -1443,7 +1519,7 @@ union yyalloc ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ -static const unsigned char yytranslate[] = +static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -1490,7 +1566,7 @@ static const unsigned char yytranslate[] = #if YYDEBUG /* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in YYRHS. */ -static const unsigned short int yyprhs[] = +static const yytype_uint16 yyprhs[] = { 0, 0, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 37, @@ -1524,8 +1600,8 @@ static const unsigned short int yyprhs[] = 884, 888, 895, 899, 906, 909, 914, 921 }; -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const short int yyrhs[] = +/* YYRHS -- A `-1'-separated list of the rules' RHS. */ +static const yytype_int16 yyrhs[] = { 193, 0, -1, 5, -1, 6, -1, 3, -1, 4, -1, 78, -1, 79, -1, 80, -1, 81, -1, 82, @@ -1623,7 +1699,7 @@ static const short int yyrhs[] = }; /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ -static const unsigned short int yyrline[] = +static const yytype_uint16 yyrline[] = { 0, 990, 990, 991, 999, 1000, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1010, 1011, 1011, 1011, 1012, 1012, @@ -1660,7 +1736,7 @@ static const unsigned short int yyrline[] = #if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. - First, the terminals, then, starting at YYNTOKENS, nonterminals. */ + First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "ESINT64VAL", "EUINT64VAL", "SINTVAL", @@ -1708,7 +1784,7 @@ static const char *const yytname[] = # ifdef YYPRINT /* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to token YYLEX-NUM. */ -static const unsigned short int yytoknum[] = +static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, @@ -1730,7 +1806,7 @@ static const unsigned short int yytoknum[] = # endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ -static const unsigned char yyr1[] = +static const yytype_uint8 yyr1[] = { 0, 159, 160, 160, 161, 161, 162, 162, 162, 162, 162, 162, 162, 162, 162, 163, 163, 163, 164, 164, @@ -1765,7 +1841,7 @@ static const unsigned char yyr1[] = }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ -static const unsigned char yyr2[] = +static const yytype_uint8 yyr2[] = { 0, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -1802,7 +1878,7 @@ static const unsigned char yyr2[] = /* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state STATE-NUM when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ -static const unsigned short int yydefact[] = +static const yytype_uint16 yydefact[] = { 191, 0, 86, 177, 1, 176, 224, 79, 80, 81, 82, 83, 84, 85, 0, 87, 248, 173, 174, 248, @@ -1864,8 +1940,8 @@ static const unsigned short int yydefact[] = 0, 0, 0, 260, 0, 0, 259, 256 }; -/* YYDEFGOTO[NTERM-NUM]. */ -static const short int yydefgoto[] = +/* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = { -1, 86, 299, 316, 317, 318, 319, 320, 253, 270, 211, 212, 241, 213, 25, 15, 37, 497, 355, 436, @@ -1880,7 +1956,7 @@ static const short int yydefgoto[] = /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing STATE-NUM. */ #define YYPACT_NINF -517 -static const short int yypact[] = +static const yytype_int16 yypact[] = { -517, 40, 69, 528, -517, -517, -517, -517, -517, -517, -517, -517, -517, -517, 16, 90, 76, -517, -517, 5, @@ -1943,7 +2019,7 @@ static const short int yypact[] = }; /* YYPGOTO[NTERM-NUM]. */ -static const short int yypgoto[] = +static const yytype_int16 yypgoto[] = { -517, -517, -517, 286, 288, 291, 317, 320, 134, 80, -127, -125, -502, -517, 340, 391, -114, -517, -265, 14, @@ -1960,7 +2036,7 @@ static const short int yypgoto[] = number is the opposite. If zero, do what YYDEFACT says. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -173 -static const short int yytable[] = +static const yytype_int16 yytable[] = { 89, 225, 106, 239, 228, 240, 26, 357, 414, 377, 378, 94, 400, 416, 434, 123, 89, 242, 215, 119, @@ -2115,7 +2191,7 @@ static const short int yytable[] = 0, 82, 0, 0, 83, 0, 0, 84, 0, 85 }; -static const short int yycheck[] = +static const yytype_int16 yycheck[] = { 37, 125, 53, 130, 128, 130, 3, 272, 15, 293, 294, 29, 154, 15, 34, 157, 53, 131, 112, 85, @@ -2272,7 +2348,7 @@ static const short int yycheck[] = /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing symbol of state STATE-NUM. */ -static const unsigned char yystos[] = +static const yytype_uint8 yystos[] = { 0, 193, 194, 195, 0, 25, 31, 41, 42, 43, 44, 45, 46, 47, 62, 174, 212, 214, 216, 223, @@ -2359,7 +2435,7 @@ do \ yychar = (Token); \ yylval = (Value); \ yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK; \ + YYPOPSTACK (1); \ goto yybackup; \ } \ else \ @@ -2367,7 +2443,7 @@ do \ yyerror (YY_("syntax error: cannot back up")); \ YYERROR; \ } \ -while (0) +while (YYID (0)) #define YYTERROR 1 @@ -2382,7 +2458,7 @@ while (0) #ifndef YYLLOC_DEFAULT # define YYLLOC_DEFAULT(Current, Rhs, N) \ do \ - if (N) \ + if (YYID (N)) \ { \ (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ @@ -2396,7 +2472,7 @@ while (0) (Current).first_column = (Current).last_column = \ YYRHSLOC (Rhs, 0).last_column; \ } \ - while (0) + while (YYID (0)) #endif @@ -2408,8 +2484,8 @@ while (0) # if YYLTYPE_IS_TRIVIAL # define YY_LOCATION_PRINT(File, Loc) \ fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) + (Loc).first_line, (Loc).first_column, \ + (Loc).last_line, (Loc).last_column) # else # define YY_LOCATION_PRINT(File, Loc) ((void) 0) # endif @@ -2436,36 +2512,96 @@ while (0) do { \ if (yydebug) \ YYFPRINTF Args; \ -} while (0) +} while (YYID (0)) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yysymprint (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (0) +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (YYID (0)) + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_value_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (!yyvaluep) + return; +# ifdef YYPRINT + if (yytype < YYNTOKENS) + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); +# else + YYUSE (yyoutput); +# endif + switch (yytype) + { + default: + break; + } +} + + +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ + +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +static void +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) +#else +static void +yy_symbol_print (yyoutput, yytype, yyvaluep) + FILE *yyoutput; + int yytype; + YYSTYPE const * const yyvaluep; +#endif +{ + if (yytype < YYNTOKENS) + YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + else + YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); +} /*------------------------------------------------------------------. | yy_stack_print -- Print the state stack from its BOTTOM up to its | | TOP (included). | `------------------------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_stack_print (short int *bottom, short int *top) +yy_stack_print (yytype_int16 *bottom, yytype_int16 *top) #else static void yy_stack_print (bottom, top) - short int *bottom; - short int *top; + yytype_int16 *bottom; + yytype_int16 *top; #endif { YYFPRINTF (stderr, "Stack now"); - for (/* Nothing. */; bottom <= top; ++bottom) + for (; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); } @@ -2474,37 +2610,45 @@ yy_stack_print (bottom, top) do { \ if (yydebug) \ yy_stack_print ((Bottom), (Top)); \ -} while (0) +} while (YYID (0)) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (int yyrule) +yy_reduce_print (YYSTYPE *yyvsp, int yyrule) #else static void -yy_reduce_print (yyrule) +yy_reduce_print (yyvsp, yyrule) + YYSTYPE *yyvsp; int yyrule; #endif { + int yynrhs = yyr2[yyrule]; int yyi; unsigned long int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu), ", - yyrule - 1, yylno); - /* Print the symbols being reduced, and their result. */ - for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) - YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]); - YYFPRINTF (stderr, "-> %s\n", yytname[yyr1[yyrule]]); + YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", + yyrule - 1, yylno); + /* The symbols being reduced. */ + for (yyi = 0; yyi < yynrhs; yyi++) + { + fprintf (stderr, " $%d = ", yyi + 1); + yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); + fprintf (stderr, "\n"); + } } # define YY_REDUCE_PRINT(Rule) \ do { \ if (yydebug) \ - yy_reduce_print (Rule); \ -} while (0) + yy_reduce_print (yyvsp, Rule); \ +} while (YYID (0)) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -2538,42 +2682,44 @@ int yydebug; #if YYERROR_VERBOSE # ifndef yystrlen -# if defined (__GLIBC__) && defined (_STRING_H) +# if defined __GLIBC__ && defined _STRING_H # define yystrlen strlen # else /* Return the length of YYSTR. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static YYSIZE_T -# if defined (__STDC__) || defined (__cplusplus) yystrlen (const char *yystr) -# else +#else +static YYSIZE_T yystrlen (yystr) - const char *yystr; -# endif + const char *yystr; +#endif { - const char *yys = yystr; - - while (*yys++ != '\0') + YYSIZE_T yylen; + for (yylen = 0; yystr[yylen]; yylen++) continue; - - return yys - yystr - 1; + return yylen; } # endif # endif # ifndef yystpcpy -# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE) +# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE # define yystpcpy stpcpy # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static char * -# if defined (__STDC__) || defined (__cplusplus) yystpcpy (char *yydest, const char *yysrc) -# else +#else +static char * yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -# endif + char *yydest; + const char *yysrc; +#endif { char *yyd = yydest; const char *yys = yysrc; @@ -2599,7 +2745,7 @@ yytnamerr (char *yyres, const char *yystr) { if (*yystr == '"') { - size_t yyn = 0; + YYSIZE_T yyn = 0; char const *yyp = yystr; for (;;) @@ -2634,53 +2780,123 @@ yytnamerr (char *yyres, const char *yystr) } # endif -#endif /* YYERROR_VERBOSE */ - - - -#if YYDEBUG -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ - -#if defined (__STDC__) || defined (__cplusplus) -static void -yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep) -#else -static void -yysymprint (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE *yyvaluep; -#endif +/* Copy into YYRESULT an error message about the unexpected token + YYCHAR while in state YYSTATE. Return the number of bytes copied, + including the terminating null byte. If YYRESULT is null, do not + copy anything; just return the number of bytes that would be + copied. As a special case, return 0 if an ordinary "syntax error" + message will do. Return YYSIZE_MAXIMUM if overflow occurs during + size calculation. */ +static YYSIZE_T +yysyntax_error (char *yyresult, int yystate, int yychar) { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + int yyn = yypact[yystate]; - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); + if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) + return 0; else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + { + int yytype = YYTRANSLATE (yychar); + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + int yysize_overflow = 0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + int yyx; + +# if 0 + /* This is so xgettext sees the translatable formats that are + constructed on the fly. */ + YY_("syntax error, unexpected %s"); + YY_("syntax error, unexpected %s, expecting %s"); + YY_("syntax error, unexpected %s, expecting %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s"); + YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); +# endif + char *yyfmt; + char const *yyf; + static char const yyunexpected[] = "syntax error, unexpected %s"; + static char const yyexpecting[] = ", expecting %s"; + static char const yyor[] = " or %s"; + char yyformat[sizeof yyunexpected + + sizeof yyexpecting - 1 + + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) + * (sizeof yyor - 1))]; + char const *yyprefix = yyexpecting; + + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yycount = 1; + + yyarg[0] = yytname[yytype]; + yyfmt = yystpcpy (yyformat, yyunexpected); + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + yyformat[sizeof yyunexpected - 1] = '\0'; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; + yyfmt = yystpcpy (yyfmt, yyprefix); + yyprefix = yyor; + } + yyf = YY_(yyformat); + yysize1 = yysize + yystrlen (yyf); + yysize_overflow |= (yysize1 < yysize); + yysize = yysize1; -# ifdef YYPRINT - if (yytype < YYNTOKENS) - YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# endif - switch (yytype) - { - default: - break; + if (yysize_overflow) + return YYSIZE_MAXIMUM; + + if (yyresult) + { + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + char *yyp = yyresult; + int yyi = 0; + while ((*yyp = *yyf) != '\0') + { + if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyf += 2; + } + else + { + yyp++; + yyf++; + } + } + } + return yysize; } - YYFPRINTF (yyoutput, ")"); } +#endif /* YYERROR_VERBOSE */ + -#endif /* ! YYDEBUG */ /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -#if defined (__STDC__) || defined (__cplusplus) +/*ARGSUSED*/ +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) #else @@ -2691,8 +2907,7 @@ yydestruct (yymsg, yytype, yyvaluep) YYSTYPE *yyvaluep; #endif { - /* Pacify ``unused variable'' warnings. */ - (void) yyvaluep; + YYUSE (yyvaluep); if (!yymsg) yymsg = "Deleting"; @@ -2702,7 +2917,7 @@ yydestruct (yymsg, yytype, yyvaluep) { default: - break; + break; } } @@ -2710,13 +2925,13 @@ yydestruct (yymsg, yytype, yyvaluep) /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void *YYPARSE_PARAM); -# else +#else int yyparse (); -# endif +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if defined __STDC__ || defined __cplusplus int yyparse (void); #else int yyparse (); @@ -2741,14 +2956,18 @@ int yynerrs; `----------*/ #ifdef YYPARSE_PARAM -# if defined (__STDC__) || defined (__cplusplus) -int yyparse (void *YYPARSE_PARAM) -# else -int yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -# endif +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) +int +yyparse (void *YYPARSE_PARAM) +#else +int +yyparse (YYPARSE_PARAM) + void *YYPARSE_PARAM; +#endif #else /* ! YYPARSE_PARAM */ -#if defined (__STDC__) || defined (__cplusplus) +#if (defined __STDC__ || defined __C99__FUNC__ \ + || defined __cplusplus || defined _MSC_VER) int yyparse (void) #else @@ -2766,6 +2985,12 @@ yyparse () int yyerrstatus; /* Look-ahead token as an internal (translated) token number. */ int yytoken = 0; +#if YYERROR_VERBOSE + /* Buffer for error messages, and its allocated size. */ + char yymsgbuf[128]; + char *yymsg = yymsgbuf; + YYSIZE_T yymsg_alloc = sizeof yymsgbuf; +#endif /* Three stacks and their tools: `yyss': related to states, @@ -2776,9 +3001,9 @@ yyparse () to reallocate them elsewhere. */ /* The state stack. */ - short int yyssa[YYINITDEPTH]; - short int *yyss = yyssa; - short int *yyssp; + yytype_int16 yyssa[YYINITDEPTH]; + yytype_int16 *yyss = yyssa; + yytype_int16 *yyssp; /* The semantic value stack. */ YYSTYPE yyvsa[YYINITDEPTH]; @@ -2787,7 +3012,7 @@ yyparse () -#define YYPOPSTACK (yyvsp--, yyssp--) +#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N)) YYSIZE_T yystacksize = YYINITDEPTH; @@ -2796,9 +3021,9 @@ yyparse () YYSTYPE yyval; - /* When reducing, the number of symbols on the RHS of the reduced - rule. */ - int yylen; + /* The number of symbols on the RHS of the reduced rule. + Keep to zero when no symbol should be popped. */ + int yylen = 0; YYDPRINTF ((stderr, "Starting parse\n")); @@ -2822,8 +3047,7 @@ yyparse () `------------------------------------------------------------*/ yynewstate: /* In all cases, when you get here, the value and location stacks - have just been pushed. so pushing a state here evens the stacks. - */ + have just been pushed. So pushing a state here evens the stacks. */ yyssp++; yysetstate: @@ -2836,11 +3060,11 @@ yyparse () #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of + /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into memory. */ YYSTYPE *yyvs1 = yyvs; - short int *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; /* Each stack pointer address is followed by the size of the @@ -2868,7 +3092,7 @@ yyparse () yystacksize = YYMAXDEPTH; { - short int *yyss1 = yyss; + yytype_int16 *yyss1 = yyss; union yyalloc *yyptr = (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); if (! yyptr) @@ -2903,12 +3127,10 @@ yyparse () `-----------*/ yybackup: -/* Do appropriate processing given the current state. */ -/* Read a look-ahead token if we need one and don't already have one. */ -/* yyresume: */ + /* Do appropriate processing given the current state. Read a + look-ahead token if we need one and don't already have one. */ /* First try to decide what to do without reference to look-ahead token. */ - yyn = yypact[yystate]; if (yyn == YYPACT_NINF) goto yydefault; @@ -2950,22 +3172,21 @@ yybackup: if (yyn == YYFINAL) YYACCEPT; + /* Count tokens shifted since error; after three, turn off error + status. */ + if (yyerrstatus) + yyerrstatus--; + /* Shift the look-ahead token. */ YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc); - /* Discard the token being shifted unless it is eof. */ + /* Discard the shifted token unless it is eof. */ if (yychar != YYEOF) yychar = YYEMPTY; + yystate = yyn; *++yyvsp = yylval; - - /* Count tokens shifted since error; after three, turn off error - status. */ - if (yyerrstatus) - yyerrstatus--; - - yystate = yyn; goto yynewstate; @@ -3001,165 +3222,165 @@ yyreduce: switch (yyn) { case 3: -#line 991 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 991 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[0].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! + if ((yyvsp[(1) - (1)].UIntVal) > (uint32_t)INT32_MAX) // Outside of my range! GEN_ERROR("Value too large for type!"); - (yyval.SIntVal) = (int32_t)(yyvsp[0].UIntVal); + (yyval.SIntVal) = (int32_t)(yyvsp[(1) - (1)].UIntVal); CHECK_FOR_ERROR ;} break; case 5: -#line 1000 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1000 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[0].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! + if ((yyvsp[(1) - (1)].UInt64Val) > (uint64_t)INT64_MAX) // Outside of my range! GEN_ERROR("Value too large for type!"); - (yyval.SInt64Val) = (int64_t)(yyvsp[0].UInt64Val); + (yyval.SInt64Val) = (int64_t)(yyvsp[(1) - (1)].UInt64Val); CHECK_FOR_ERROR ;} break; case 39: -#line 1017 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1017 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_EQ; ;} break; case 40: -#line 1017 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1017 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_NE; ;} break; case 41: -#line 1018 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1018 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SLT; ;} break; case 42: -#line 1018 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1018 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SGT; ;} break; case 43: -#line 1019 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1019 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SLE; ;} break; case 44: -#line 1019 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1019 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_SGE; ;} break; case 45: -#line 1020 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1020 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_ULT; ;} break; case 46: -#line 1020 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1020 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_UGT; ;} break; case 47: -#line 1021 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1021 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_ULE; ;} break; case 48: -#line 1021 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1021 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.IPredicate) = ICmpInst::ICMP_UGE; ;} break; case 49: -#line 1025 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1025 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OEQ; ;} break; case 50: -#line 1025 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1025 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ONE; ;} break; case 51: -#line 1026 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1026 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OLT; ;} break; case 52: -#line 1026 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1026 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OGT; ;} break; case 53: -#line 1027 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1027 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OLE; ;} break; case 54: -#line 1027 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1027 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_OGE; ;} break; case 55: -#line 1028 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1028 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ORD; ;} break; case 56: -#line 1028 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1028 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UNO; ;} break; case 57: -#line 1029 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1029 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UEQ; ;} break; case 58: -#line 1029 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1029 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UNE; ;} break; case 59: -#line 1030 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1030 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ULT; ;} break; case 60: -#line 1030 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1030 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UGT; ;} break; case 61: -#line 1031 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1031 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_ULE; ;} break; case 62: -#line 1031 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1031 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_UGE; ;} break; case 63: -#line 1032 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1032 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_TRUE; ;} break; case 64: -#line 1033 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1033 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FPredicate) = FCmpInst::FCMP_FALSE; ;} break; case 77: -#line 1044 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1044 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.StrVal) = (yyvsp[-1].StrVal); + (yyval.StrVal) = (yyvsp[(1) - (2)].StrVal); CHECK_FOR_ERROR ;} break; case 78: -#line 1048 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1048 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; CHECK_FOR_ERROR @@ -3167,99 +3388,99 @@ yyreduce: break; case 79: -#line 1053 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1053 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::InternalLinkage; ;} break; case 80: -#line 1054 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1054 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::LinkOnceLinkage; ;} break; case 81: -#line 1055 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1055 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::WeakLinkage; ;} break; case 82: -#line 1056 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1056 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::AppendingLinkage; ;} break; case 83: -#line 1057 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1057 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLImportLinkage; ;} break; case 84: -#line 1058 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1058 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::DLLExportLinkage; ;} break; case 85: -#line 1059 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1059 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalWeakLinkage; ;} break; case 86: -#line 1060 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1060 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Linkage) = GlobalValue::ExternalLinkage; ;} break; case 87: -#line 1062 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1062 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::C; ;} break; case 88: -#line 1063 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1063 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::C; ;} break; case 89: -#line 1064 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1064 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::CSRet; ;} break; case 90: -#line 1065 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1065 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::Fast; ;} break; case 91: -#line 1066 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1066 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::Cold; ;} break; case 92: -#line 1067 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1067 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::X86_StdCall; ;} break; case 93: -#line 1068 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1068 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = CallingConv::X86_FastCall; ;} break; case 94: -#line 1069 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1069 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((unsigned)(yyvsp[0].UInt64Val) != (yyvsp[0].UInt64Val)) + if ((unsigned)(yyvsp[(2) - (2)].UInt64Val) != (yyvsp[(2) - (2)].UInt64Val)) GEN_ERROR("Calling conv too large!"); - (yyval.UIntVal) = (yyvsp[0].UInt64Val); + (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); CHECK_FOR_ERROR ;} break; case 95: -#line 1078 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1078 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = 0; ;} break; case 96: -#line 1079 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1079 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.UIntVal) = (yyvsp[0].UInt64Val); + (yyval.UIntVal) = (yyvsp[(2) - (2)].UInt64Val); if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) GEN_ERROR("Alignment must be a power of two!"); CHECK_FOR_ERROR @@ -3267,14 +3488,14 @@ yyreduce: break; case 97: -#line 1085 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1085 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.UIntVal) = 0; ;} break; case 98: -#line 1086 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1086 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.UIntVal) = (yyvsp[0].UInt64Val); + (yyval.UIntVal) = (yyvsp[(3) - (3)].UInt64Val); if ((yyval.UIntVal) != 0 && !isPowerOf2_32((yyval.UIntVal))) GEN_ERROR("Alignment must be a power of two!"); CHECK_FOR_ERROR @@ -3282,77 +3503,77 @@ yyreduce: break; case 99: -#line 1094 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1094 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - for (unsigned i = 0, e = strlen((yyvsp[0].StrVal)); i != e; ++i) - if ((yyvsp[0].StrVal)[i] == '"' || (yyvsp[0].StrVal)[i] == '\\') + for (unsigned i = 0, e = strlen((yyvsp[(2) - (2)].StrVal)); i != e; ++i) + if ((yyvsp[(2) - (2)].StrVal)[i] == '"' || (yyvsp[(2) - (2)].StrVal)[i] == '\\') GEN_ERROR("Invalid character in section name!"); - (yyval.StrVal) = (yyvsp[0].StrVal); + (yyval.StrVal) = (yyvsp[(2) - (2)].StrVal); CHECK_FOR_ERROR ;} break; case 100: -#line 1102 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1102 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; ;} break; case 101: -#line 1103 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.StrVal) = (yyvsp[0].StrVal); ;} +#line 1103 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" + { (yyval.StrVal) = (yyvsp[(1) - (1)].StrVal); ;} break; case 102: -#line 1108 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1108 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" {;} break; case 103: -#line 1109 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1109 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" {;} break; case 104: -#line 1110 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1110 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurGV->setSection((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); + CurGV->setSection((yyvsp[(1) - (1)].StrVal)); + free((yyvsp[(1) - (1)].StrVal)); CHECK_FOR_ERROR ;} break; case 105: -#line 1115 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1115 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[0].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[0].UInt64Val))) + if ((yyvsp[(2) - (2)].UInt64Val) != 0 && !isPowerOf2_32((yyvsp[(2) - (2)].UInt64Val))) GEN_ERROR("Alignment must be a power of two!"); - CurGV->setAlignment((yyvsp[0].UInt64Val)); + CurGV->setAlignment((yyvsp[(2) - (2)].UInt64Val)); CHECK_FOR_ERROR ;} break; case 107: -#line 1129 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} +#line 1129 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" + { (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType)); ;} break; case 109: -#line 1130 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" - { (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); ;} +#line 1130 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" + { (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType)); ;} break; case 110: -#line 1132 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1132 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { if (!UpRefs.empty()) - GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[0].TypeVal))->getDescription()); - (yyval.TypeVal) = (yyvsp[0].TypeVal); + GEN_ERROR("Invalid upreference in type: " + (*(yyvsp[(1) - (1)].TypeVal))->getDescription()); + (yyval.TypeVal) = (yyvsp[(1) - (1)].TypeVal); CHECK_FOR_ERROR ;} break; case 124: -#line 1144 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1144 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeVal) = new PATypeHolder(OpaqueType::get()); CHECK_FOR_ERROR @@ -3360,28 +3581,28 @@ yyreduce: break; case 125: -#line 1148 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1148 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.TypeVal) = new PATypeHolder((yyvsp[0].PrimType)); + (yyval.TypeVal) = new PATypeHolder((yyvsp[(1) - (1)].PrimType)); CHECK_FOR_ERROR ;} break; case 126: -#line 1152 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1152 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Named types are also simple types... - const Type* tmp = getTypeVal((yyvsp[0].ValIDVal)); + const Type* tmp = getTypeVal((yyvsp[(1) - (1)].ValIDVal)); CHECK_FOR_ERROR (yyval.TypeVal) = new PATypeHolder(tmp); ;} break; case 127: -#line 1160 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1160 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Type UpReference - if ((yyvsp[0].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!"); + if ((yyvsp[(2) - (2)].UInt64Val) > (uint64_t)~0U) GEN_ERROR("Value out of range!"); OpaqueType *OT = OpaqueType::get(); // Use temporary placeholder - UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[0].UInt64Val), OT)); // Add to vector... + UpRefs.push_back(UpRefRecord((unsigned)(yyvsp[(2) - (2)].UInt64Val), OT)); // Add to vector... (yyval.TypeVal) = new PATypeHolder(OT); UR_OUT("New Upreference!\n"); CHECK_FOR_ERROR @@ -3389,63 +3610,63 @@ yyreduce: break; case 128: -#line 1168 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1168 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Function derived type? std::vector Params; - for (std::list::iterator I = (yyvsp[-1].TypeList)->begin(), - E = (yyvsp[-1].TypeList)->end(); I != E; ++I) + for (std::list::iterator I = (yyvsp[(3) - (4)].TypeList)->begin(), + E = (yyvsp[(3) - (4)].TypeList)->end(); I != E; ++I) Params.push_back(*I); bool isVarArg = Params.size() && Params.back() == Type::VoidTy; if (isVarArg) Params.pop_back(); - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[-3].TypeVal),Params,isVarArg))); - delete (yyvsp[-1].TypeList); // Delete the argument list - delete (yyvsp[-3].TypeVal); // Delete the return type handle + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(FunctionType::get(*(yyvsp[(1) - (4)].TypeVal),Params,isVarArg))); + delete (yyvsp[(3) - (4)].TypeList); // Delete the argument list + delete (yyvsp[(1) - (4)].TypeVal); // Delete the return type handle CHECK_FOR_ERROR ;} break; case 129: -#line 1181 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1181 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Sized array type? - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); - delete (yyvsp[-1].TypeVal); + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(ArrayType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val)))); + delete (yyvsp[(4) - (5)].TypeVal); CHECK_FOR_ERROR ;} break; case 130: -#line 1186 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1186 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Packed array type? - const llvm::Type* ElemTy = (yyvsp[-1].TypeVal)->get(); - if ((unsigned)(yyvsp[-3].UInt64Val) != (yyvsp[-3].UInt64Val)) + const llvm::Type* ElemTy = (yyvsp[(4) - (5)].TypeVal)->get(); + if ((unsigned)(yyvsp[(2) - (5)].UInt64Val) != (yyvsp[(2) - (5)].UInt64Val)) GEN_ERROR("Unsigned result not equal to signed result"); if (!ElemTy->isPrimitiveType()) GEN_ERROR("Elemental type of a PackedType must be primitive"); - if (!isPowerOf2_32((yyvsp[-3].UInt64Val))) + if (!isPowerOf2_32((yyvsp[(2) - (5)].UInt64Val))) GEN_ERROR("Vector length should be a power of 2!"); - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[-1].TypeVal), (unsigned)(yyvsp[-3].UInt64Val)))); - delete (yyvsp[-1].TypeVal); + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PackedType::get(*(yyvsp[(4) - (5)].TypeVal), (unsigned)(yyvsp[(2) - (5)].UInt64Val)))); + delete (yyvsp[(4) - (5)].TypeVal); CHECK_FOR_ERROR ;} break; case 131: -#line 1198 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1198 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Structure type? std::vector Elements; - for (std::list::iterator I = (yyvsp[-1].TypeList)->begin(), - E = (yyvsp[-1].TypeList)->end(); I != E; ++I) + for (std::list::iterator I = (yyvsp[(2) - (3)].TypeList)->begin(), + E = (yyvsp[(2) - (3)].TypeList)->end(); I != E; ++I) Elements.push_back(*I); (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(StructType::get(Elements))); - delete (yyvsp[-1].TypeList); + delete (yyvsp[(2) - (3)].TypeList); CHECK_FOR_ERROR ;} break; case 132: -#line 1208 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1208 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Empty structure type? (yyval.TypeVal) = new PATypeHolder(StructType::get(std::vector())); CHECK_FOR_ERROR @@ -3453,43 +3674,43 @@ yyreduce: break; case 133: -#line 1212 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1212 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Pointer type? - if (*(yyvsp[-1].TypeVal) == Type::LabelTy) + if (*(yyvsp[(1) - (2)].TypeVal) == Type::LabelTy) GEN_ERROR("Cannot form a pointer to a basic block"); - (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[-1].TypeVal)))); - delete (yyvsp[-1].TypeVal); + (yyval.TypeVal) = new PATypeHolder(HandleUpRefs(PointerType::get(*(yyvsp[(1) - (2)].TypeVal)))); + delete (yyvsp[(1) - (2)].TypeVal); CHECK_FOR_ERROR ;} break; case 134: -#line 1223 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1223 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeList) = new std::list(); - (yyval.TypeList)->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); + (yyval.TypeList)->push_back(*(yyvsp[(1) - (1)].TypeVal)); delete (yyvsp[(1) - (1)].TypeVal); CHECK_FOR_ERROR ;} break; case 135: -#line 1228 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1228 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(*(yyvsp[0].TypeVal)); delete (yyvsp[0].TypeVal); + ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(*(yyvsp[(3) - (3)].TypeVal)); delete (yyvsp[(3) - (3)].TypeVal); CHECK_FOR_ERROR ;} break; case 137: -#line 1235 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1235 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - ((yyval.TypeList)=(yyvsp[-2].TypeList))->push_back(Type::VoidTy); + ((yyval.TypeList)=(yyvsp[(1) - (3)].TypeList))->push_back(Type::VoidTy); CHECK_FOR_ERROR ;} break; case 138: -#line 1239 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1239 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { ((yyval.TypeList) = new std::list())->push_back(Type::VoidTy); CHECK_FOR_ERROR @@ -3497,7 +3718,7 @@ yyreduce: break; case 139: -#line 1243 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1243 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.TypeList) = new std::list(); CHECK_FOR_ERROR @@ -3505,186 +3726,186 @@ yyreduce: break; case 140: -#line 1254 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1254 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized arr - const ArrayType *ATy = dyn_cast((yyvsp[-3].TypeVal)->get()); + const ArrayType *ATy = dyn_cast((yyvsp[(1) - (4)].TypeVal)->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); + (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'!"); const Type *ETy = ATy->getElementType(); int NumElements = ATy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) + if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) GEN_ERROR("Type mismatch: constant sized array initialized with " + - utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + + utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + itostr(NumElements) + "!"); // Verify all elements are correct type! - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) + for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { + if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '"+ - (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); + (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'."); } - (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[-1].ConstVector)); - delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); + (yyval.ConstVal) = ConstantArray::get(ATy, *(yyvsp[(3) - (4)].ConstVector)); + delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); CHECK_FOR_ERROR ;} break; case 141: -#line 1280 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1280 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal)->get()); + const ArrayType *ATy = dyn_cast((yyvsp[(1) - (3)].TypeVal)->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); + (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'!"); int NumElements = ATy->getNumElements(); if (NumElements != -1 && NumElements != 0) GEN_ERROR("Type mismatch: constant sized array initialized with 0" " arguments, but has size of " + itostr(NumElements) +"!"); (yyval.ConstVal) = ConstantArray::get(ATy, std::vector()); - delete (yyvsp[-2].TypeVal); + delete (yyvsp[(1) - (3)].TypeVal); CHECK_FOR_ERROR ;} break; case 142: -#line 1294 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1294 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const ArrayType *ATy = dyn_cast((yyvsp[-2].TypeVal)->get()); + const ArrayType *ATy = dyn_cast((yyvsp[(1) - (3)].TypeVal)->get()); if (ATy == 0) GEN_ERROR("Cannot make array constant with type: '" + - (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); + (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'!"); int NumElements = ATy->getNumElements(); const Type *ETy = ATy->getElementType(); - char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); - if (NumElements != -1 && NumElements != (EndStr-(yyvsp[0].StrVal))) + char *EndStr = UnEscapeLexed((yyvsp[(3) - (3)].StrVal), true); + if (NumElements != -1 && NumElements != (EndStr-(yyvsp[(3) - (3)].StrVal))) GEN_ERROR("Can't build string constant of size " + - itostr((int)(EndStr-(yyvsp[0].StrVal))) + + itostr((int)(EndStr-(yyvsp[(3) - (3)].StrVal))) + " when array has size " + itostr(NumElements) + "!"); std::vector Vals; if (ETy == Type::SByteTy) { - for (signed char *C = (signed char *)(yyvsp[0].StrVal); C != (signed char *)EndStr; ++C) + for (signed char *C = (signed char *)(yyvsp[(3) - (3)].StrVal); C != (signed char *)EndStr; ++C) Vals.push_back(ConstantInt::get(ETy, *C)); } else if (ETy == Type::UByteTy) { - for (unsigned char *C = (unsigned char *)(yyvsp[0].StrVal); + for (unsigned char *C = (unsigned char *)(yyvsp[(3) - (3)].StrVal); C != (unsigned char*)EndStr; ++C) Vals.push_back(ConstantInt::get(ETy, *C)); } else { - free((yyvsp[0].StrVal)); + free((yyvsp[(3) - (3)].StrVal)); GEN_ERROR("Cannot build string arrays of non byte sized elements!"); } - free((yyvsp[0].StrVal)); + free((yyvsp[(3) - (3)].StrVal)); (yyval.ConstVal) = ConstantArray::get(ATy, Vals); - delete (yyvsp[-2].TypeVal); + delete (yyvsp[(1) - (3)].TypeVal); CHECK_FOR_ERROR ;} break; case 143: -#line 1324 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1324 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized arr - const PackedType *PTy = dyn_cast((yyvsp[-3].TypeVal)->get()); + const PackedType *PTy = dyn_cast((yyvsp[(1) - (4)].TypeVal)->get()); if (PTy == 0) GEN_ERROR("Cannot make packed constant with type: '" + - (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); + (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'!"); const Type *ETy = PTy->getElementType(); int NumElements = PTy->getNumElements(); // Verify that we have the correct size... - if (NumElements != -1 && NumElements != (int)(yyvsp[-1].ConstVector)->size()) + if (NumElements != -1 && NumElements != (int)(yyvsp[(3) - (4)].ConstVector)->size()) GEN_ERROR("Type mismatch: constant sized packed initialized with " + - utostr((yyvsp[-1].ConstVector)->size()) + " arguments, but has size of " + + utostr((yyvsp[(3) - (4)].ConstVector)->size()) + " arguments, but has size of " + itostr(NumElements) + "!"); // Verify all elements are correct type! - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) + for (unsigned i = 0; i < (yyvsp[(3) - (4)].ConstVector)->size(); i++) { + if (ETy != (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '"+ - (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); + (*(yyvsp[(3) - (4)].ConstVector))[i]->getType()->getDescription() + "'."); } - (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[-1].ConstVector)); - delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); + (yyval.ConstVal) = ConstantPacked::get(PTy, *(yyvsp[(3) - (4)].ConstVector)); + delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); CHECK_FOR_ERROR ;} break; case 144: -#line 1350 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1350 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const StructType *STy = dyn_cast((yyvsp[-3].TypeVal)->get()); + const StructType *STy = dyn_cast((yyvsp[(1) - (4)].TypeVal)->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*(yyvsp[-3].TypeVal))->getDescription() + "'!"); + (*(yyvsp[(1) - (4)].TypeVal))->getDescription() + "'!"); - if ((yyvsp[-1].ConstVector)->size() != STy->getNumContainedTypes()) + if ((yyvsp[(3) - (4)].ConstVector)->size() != STy->getNumContainedTypes()) GEN_ERROR("Illegal number of initializers for structure type!"); // Check to ensure that constants are compatible with the type initializer! - for (unsigned i = 0, e = (yyvsp[-1].ConstVector)->size(); i != e; ++i) - if ((*(yyvsp[-1].ConstVector))[i]->getType() != STy->getElementType(i)) + for (unsigned i = 0, e = (yyvsp[(3) - (4)].ConstVector)->size(); i != e; ++i) + if ((*(yyvsp[(3) - (4)].ConstVector))[i]->getType() != STy->getElementType(i)) GEN_ERROR("Expected type '" + STy->getElementType(i)->getDescription() + "' for element #" + utostr(i) + " of structure initializer!"); - (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[-1].ConstVector)); - delete (yyvsp[-3].TypeVal); delete (yyvsp[-1].ConstVector); + (yyval.ConstVal) = ConstantStruct::get(STy, *(yyvsp[(3) - (4)].ConstVector)); + delete (yyvsp[(1) - (4)].TypeVal); delete (yyvsp[(3) - (4)].ConstVector); CHECK_FOR_ERROR ;} break; case 145: -#line 1371 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1371 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const StructType *STy = dyn_cast((yyvsp[-2].TypeVal)->get()); + const StructType *STy = dyn_cast((yyvsp[(1) - (3)].TypeVal)->get()); if (STy == 0) GEN_ERROR("Cannot make struct constant with type: '" + - (*(yyvsp[-2].TypeVal))->getDescription() + "'!"); + (*(yyvsp[(1) - (3)].TypeVal))->getDescription() + "'!"); if (STy->getNumContainedTypes() != 0) GEN_ERROR("Illegal number of initializers for structure type!"); (yyval.ConstVal) = ConstantStruct::get(STy, std::vector()); - delete (yyvsp[-2].TypeVal); + delete (yyvsp[(1) - (3)].TypeVal); CHECK_FOR_ERROR ;} break; case 146: -#line 1384 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1384 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const PointerType *PTy = dyn_cast((yyvsp[-1].TypeVal)->get()); + const PointerType *PTy = dyn_cast((yyvsp[(1) - (2)].TypeVal)->get()); if (PTy == 0) GEN_ERROR("Cannot make null pointer constant with type: '" + - (*(yyvsp[-1].TypeVal))->getDescription() + "'!"); + (*(yyvsp[(1) - (2)].TypeVal))->getDescription() + "'!"); (yyval.ConstVal) = ConstantPointerNull::get(PTy); - delete (yyvsp[-1].TypeVal); + delete (yyvsp[(1) - (2)].TypeVal); CHECK_FOR_ERROR ;} break; case 147: -#line 1394 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1394 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ConstVal) = UndefValue::get((yyvsp[-1].TypeVal)->get()); - delete (yyvsp[-1].TypeVal); + (yyval.ConstVal) = UndefValue::get((yyvsp[(1) - (2)].TypeVal)->get()); + delete (yyvsp[(1) - (2)].TypeVal); CHECK_FOR_ERROR ;} break; case 148: -#line 1399 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1399 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const PointerType *Ty = dyn_cast((yyvsp[-1].TypeVal)->get()); + const PointerType *Ty = dyn_cast((yyvsp[(1) - (2)].TypeVal)->get()); if (Ty == 0) GEN_ERROR("Global const reference must be a pointer type!"); @@ -3698,7 +3919,7 @@ yyreduce: Function *SavedCurFn = CurFun.CurrentFunction; CurFun.CurrentFunction = 0; - Value *V = getValNonImprovising(Ty, (yyvsp[0].ValIDVal)); + Value *V = getValNonImprovising(Ty, (yyvsp[(2) - (2)].ValIDVal)); CHECK_FOR_ERROR CurFun.CurrentFunction = SavedCurFn; @@ -3713,14 +3934,14 @@ yyreduce: // First check to see if the forward references value is already created! PerModuleInfo::GlobalRefsType::iterator I = - CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[0].ValIDVal))); + CurModule.GlobalRefs.find(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal))); if (I != CurModule.GlobalRefs.end()) { V = I->second; // Placeholder already exists, use it... - (yyvsp[0].ValIDVal).destroy(); + (yyvsp[(2) - (2)].ValIDVal).destroy(); } else { std::string Name; - if ((yyvsp[0].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[0].ValIDVal).Name; + if ((yyvsp[(2) - (2)].ValIDVal).Type == ValID::NameVal) Name = (yyvsp[(2) - (2)].ValIDVal).Name; // Create the forward referenced global. GlobalValue *GV; @@ -3735,62 +3956,62 @@ yyreduce: } // Keep track of the fact that we have a forward ref to recycle it - CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[0].ValIDVal)), GV)); + CurModule.GlobalRefs.insert(std::make_pair(std::make_pair(PT, (yyvsp[(2) - (2)].ValIDVal)), GV)); V = GV; } } (yyval.ConstVal) = cast(V); - delete (yyvsp[-1].TypeVal); // Free the type handle + delete (yyvsp[(1) - (2)].TypeVal); // Free the type handle CHECK_FOR_ERROR ;} break; case 149: -#line 1460 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1460 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-1].TypeVal)->get() != (yyvsp[0].ConstVal)->getType()) + if ((yyvsp[(1) - (2)].TypeVal)->get() != (yyvsp[(2) - (2)].ConstVal)->getType()) GEN_ERROR("Mismatched types for constant expression!"); - (yyval.ConstVal) = (yyvsp[0].ConstVal); - delete (yyvsp[-1].TypeVal); + (yyval.ConstVal) = (yyvsp[(2) - (2)].ConstVal); + delete (yyvsp[(1) - (2)].TypeVal); CHECK_FOR_ERROR ;} break; case 150: -#line 1467 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1467 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const Type *Ty = (yyvsp[-1].TypeVal)->get(); + const Type *Ty = (yyvsp[(1) - (2)].TypeVal)->get(); if (isa(Ty) || Ty == Type::LabelTy || isa(Ty)) GEN_ERROR("Cannot create a null initialized value of this type!"); (yyval.ConstVal) = Constant::getNullValue(Ty); - delete (yyvsp[-1].TypeVal); + delete (yyvsp[(1) - (2)].TypeVal); CHECK_FOR_ERROR ;} break; case 151: -#line 1475 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1475 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // integral constants - if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val))) + if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val))) GEN_ERROR("Constant value doesn't fit in type!"); - (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].SInt64Val)); + (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].SInt64Val)); CHECK_FOR_ERROR ;} break; case 152: -#line 1481 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1481 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // integral constants - if (!ConstantInt::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val))) + if (!ConstantInt::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val))) GEN_ERROR("Constant value doesn't fit in type!"); - (yyval.ConstVal) = ConstantInt::get((yyvsp[-1].PrimType), (yyvsp[0].UInt64Val)); + (yyval.ConstVal) = ConstantInt::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].UInt64Val)); CHECK_FOR_ERROR ;} break; case 153: -#line 1487 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1487 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Boolean constants (yyval.ConstVal) = ConstantBool::getTrue(); CHECK_FOR_ERROR @@ -3798,7 +4019,7 @@ yyreduce: break; case 154: -#line 1491 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1491 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Boolean constants (yyval.ConstVal) = ConstantBool::getFalse(); CHECK_FOR_ERROR @@ -3806,235 +4027,235 @@ yyreduce: break; case 155: -#line 1495 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1495 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Float & Double constants - if (!ConstantFP::isValueValidForType((yyvsp[-1].PrimType), (yyvsp[0].FPVal))) + if (!ConstantFP::isValueValidForType((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal))) GEN_ERROR("Floating point constant invalid for type!!"); - (yyval.ConstVal) = ConstantFP::get((yyvsp[-1].PrimType), (yyvsp[0].FPVal)); + (yyval.ConstVal) = ConstantFP::get((yyvsp[(1) - (2)].PrimType), (yyvsp[(2) - (2)].FPVal)); CHECK_FOR_ERROR ;} break; case 156: -#line 1503 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1503 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - Constant *Val = (yyvsp[-3].ConstVal); - const Type *Ty = (yyvsp[-1].TypeVal)->get(); + Constant *Val = (yyvsp[(3) - (6)].ConstVal); + const Type *Ty = (yyvsp[(5) - (6)].TypeVal)->get(); if (!Val->getType()->isFirstClassType()) GEN_ERROR("cast constant expression from a non-primitive type: '" + Val->getType()->getDescription() + "'!"); if (!Ty->isFirstClassType()) GEN_ERROR("cast constant expression to a non-primitive type: '" + Ty->getDescription() + "'!"); - (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[-5].CastOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].TypeVal)->get()); - delete (yyvsp[-1].TypeVal); + (yyval.ConstVal) = ConstantExpr::getCast((yyvsp[(1) - (6)].CastOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].TypeVal)->get()); + delete (yyvsp[(5) - (6)].TypeVal); ;} break; case 157: -#line 1515 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1515 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!isa((yyvsp[-2].ConstVal)->getType())) + if (!isa((yyvsp[(3) - (5)].ConstVal)->getType())) GEN_ERROR("GetElementPtr requires a pointer operand!"); const Type *IdxTy = - GetElementPtrInst::getIndexedType((yyvsp[-2].ConstVal)->getType(), *(yyvsp[-1].ValueList), true); + GetElementPtrInst::getIndexedType((yyvsp[(3) - (5)].ConstVal)->getType(), *(yyvsp[(4) - (5)].ValueList), true); if (!IdxTy) GEN_ERROR("Index list invalid for constant getelementptr!"); std::vector IdxVec; - for (unsigned i = 0, e = (yyvsp[-1].ValueList)->size(); i != e; ++i) - if (Constant *C = dyn_cast((*(yyvsp[-1].ValueList))[i])) + for (unsigned i = 0, e = (yyvsp[(4) - (5)].ValueList)->size(); i != e; ++i) + if (Constant *C = dyn_cast((*(yyvsp[(4) - (5)].ValueList))[i])) IdxVec.push_back(C); else GEN_ERROR("Indices to constant getelementptr must be constants!"); - delete (yyvsp[-1].ValueList); + delete (yyvsp[(4) - (5)].ValueList); - (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[-2].ConstVal), IdxVec); + (yyval.ConstVal) = ConstantExpr::getGetElementPtr((yyvsp[(3) - (5)].ConstVal), IdxVec); CHECK_FOR_ERROR ;} break; case 158: -#line 1536 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1536 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-5].ConstVal)->getType() != Type::BoolTy) + if ((yyvsp[(3) - (8)].ConstVal)->getType() != Type::BoolTy) GEN_ERROR("Select condition must be of boolean type!"); - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + if ((yyvsp[(5) - (8)].ConstVal)->getType() != (yyvsp[(7) - (8)].ConstVal)->getType()) GEN_ERROR("Select operand types must match!"); - (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::getSelect((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)); CHECK_FOR_ERROR ;} break; case 159: -#line 1544 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1544 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) GEN_ERROR("Binary operator types must match!"); CHECK_FOR_ERROR; - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); ;} break; case 160: -#line 1550 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1550 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) GEN_ERROR("Logical operator types must match!"); - if (!(yyvsp[-3].ConstVal)->getType()->isIntegral()) { - if (!isa((yyvsp[-3].ConstVal)->getType()) || - !cast((yyvsp[-3].ConstVal)->getType())->getElementType()->isIntegral()) + if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isIntegral()) { + if (!isa((yyvsp[(3) - (6)].ConstVal)->getType()) || + !cast((yyvsp[(3) - (6)].ConstVal)->getType())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); CHECK_FOR_ERROR ;} break; case 161: -#line 1561 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1561 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + if ((yyvsp[(3) - (6)].ConstVal)->getType() != (yyvsp[(5) - (6)].ConstVal)->getType()) GEN_ERROR("setcc operand types must match!"); - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].BinaryOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].BinaryOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); CHECK_FOR_ERROR ;} break; case 162: -#line 1567 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1567 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) GEN_ERROR("icmp operand types must match!"); - (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[-5].IPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::getICmp((yyvsp[(2) - (7)].IPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal)); ;} break; case 163: -#line 1572 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1572 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-3].ConstVal)->getType() != (yyvsp[-1].ConstVal)->getType()) + if ((yyvsp[(4) - (7)].ConstVal)->getType() != (yyvsp[(6) - (7)].ConstVal)->getType()) GEN_ERROR("fcmp operand types must match!"); - (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[-5].FPredicate), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::getFCmp((yyvsp[(2) - (7)].FPredicate), (yyvsp[(4) - (7)].ConstVal), (yyvsp[(6) - (7)].ConstVal)); ;} break; case 164: -#line 1577 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1577 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-1].ConstVal)->getType() != Type::UByteTy) + if ((yyvsp[(5) - (6)].ConstVal)->getType() != Type::UByteTy) GEN_ERROR("Shift count for shift constant must be unsigned byte!"); - if (!(yyvsp[-3].ConstVal)->getType()->isInteger()) + if (!(yyvsp[(3) - (6)].ConstVal)->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); CHECK_FOR_ERROR; - (yyval.ConstVal) = ConstantExpr::get((yyvsp[-5].OtherOpVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::get((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); CHECK_FOR_ERROR ;} break; case 165: -#line 1586 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1586 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!ExtractElementInst::isValidOperands((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) + if (!ExtractElementInst::isValidOperands((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal))) GEN_ERROR("Invalid extractelement operands!"); - (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::getExtractElement((yyvsp[(3) - (6)].ConstVal), (yyvsp[(5) - (6)].ConstVal)); CHECK_FOR_ERROR ;} break; case 166: -#line 1592 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1592 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!InsertElementInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) + if (!InsertElementInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) GEN_ERROR("Invalid insertelement operands!"); - (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::getInsertElement((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)); CHECK_FOR_ERROR ;} break; case 167: -#line 1598 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1598 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!ShuffleVectorInst::isValidOperands((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal))) + if (!ShuffleVectorInst::isValidOperands((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal))) GEN_ERROR("Invalid shufflevector operands!"); - (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[-5].ConstVal), (yyvsp[-3].ConstVal), (yyvsp[-1].ConstVal)); + (yyval.ConstVal) = ConstantExpr::getShuffleVector((yyvsp[(3) - (8)].ConstVal), (yyvsp[(5) - (8)].ConstVal), (yyvsp[(7) - (8)].ConstVal)); CHECK_FOR_ERROR ;} break; case 168: -#line 1607 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1607 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - ((yyval.ConstVector) = (yyvsp[-2].ConstVector))->push_back((yyvsp[0].ConstVal)); + ((yyval.ConstVector) = (yyvsp[(1) - (3)].ConstVector))->push_back((yyvsp[(3) - (3)].ConstVal)); CHECK_FOR_ERROR ;} break; case 169: -#line 1611 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1611 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ConstVector) = new std::vector(); - (yyval.ConstVector)->push_back((yyvsp[0].ConstVal)); + (yyval.ConstVector)->push_back((yyvsp[(1) - (1)].ConstVal)); CHECK_FOR_ERROR ;} break; case 170: -#line 1619 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1619 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; ;} break; case 171: -#line 1619 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1619 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; ;} break; case 172: -#line 1629 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1629 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ModuleVal) = ParserResult = (yyvsp[0].ModuleVal); + (yyval.ModuleVal) = ParserResult = (yyvsp[(1) - (1)].ModuleVal); CurModule.ModuleDone(); CHECK_FOR_ERROR; ;} break; case 173: -#line 1637 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1637 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); + (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CurFun.FunctionDone(); CHECK_FOR_ERROR ;} break; case 174: -#line 1642 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1642 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); + (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CHECK_FOR_ERROR ;} break; case 175: -#line 1646 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1646 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ModuleVal) = (yyvsp[-3].ModuleVal); + (yyval.ModuleVal) = (yyvsp[(1) - (4)].ModuleVal); CHECK_FOR_ERROR ;} break; case 176: -#line 1650 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1650 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ModuleVal) = (yyvsp[-1].ModuleVal); + (yyval.ModuleVal) = (yyvsp[(1) - (2)].ModuleVal); CHECK_FOR_ERROR ;} break; case 177: -#line 1654 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1654 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ModuleVal) = CurModule.CurrentModule; // Emit an error if there are any unresolved types left. @@ -4051,7 +4272,7 @@ yyreduce: break; case 178: -#line 1669 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1669 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Eagerly resolve types. This is not an optimization, this is a // requirement that is due to the fact that we could have this: @@ -4062,62 +4283,62 @@ yyreduce: // If types are not resolved eagerly, then the two types will not be // determined to be the same type! // - ResolveTypeTo((yyvsp[-2].StrVal), *(yyvsp[0].TypeVal)); + ResolveTypeTo((yyvsp[(2) - (4)].StrVal), *(yyvsp[(4) - (4)].TypeVal)); - if (!setTypeName(*(yyvsp[0].TypeVal), (yyvsp[-2].StrVal)) && !(yyvsp[-2].StrVal)) { + if (!setTypeName(*(yyvsp[(4) - (4)].TypeVal), (yyvsp[(2) - (4)].StrVal)) && !(yyvsp[(2) - (4)].StrVal)) { CHECK_FOR_ERROR // If this is a named type that is not a redefinition, add it to the slot // table. - CurModule.Types.push_back(*(yyvsp[0].TypeVal)); + CurModule.Types.push_back(*(yyvsp[(4) - (4)].TypeVal)); } - delete (yyvsp[0].TypeVal); + delete (yyvsp[(4) - (4)].TypeVal); CHECK_FOR_ERROR ;} break; case 179: -#line 1691 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1691 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Function prototypes can be in const pool CHECK_FOR_ERROR ;} break; case 180: -#line 1694 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1694 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Asm blocks can be in the const pool CHECK_FOR_ERROR ;} break; case 181: -#line 1697 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1697 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[0].ConstVal) == 0) + if ((yyvsp[(5) - (5)].ConstVal) == 0) GEN_ERROR("Global value initializer is not a constant!"); - CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), (yyvsp[-2].Linkage), (yyvsp[-1].BoolVal), (yyvsp[0].ConstVal)->getType(), (yyvsp[0].ConstVal)); + CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), (yyvsp[(3) - (5)].Linkage), (yyvsp[(4) - (5)].BoolVal), (yyvsp[(5) - (5)].ConstVal)->getType(), (yyvsp[(5) - (5)].ConstVal)); CHECK_FOR_ERROR ;} break; case 182: -#line 1702 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1702 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; ;} break; case 183: -#line 1705 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1705 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); + CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalLinkage, (yyvsp[(4) - (5)].BoolVal), *(yyvsp[(5) - (5)].TypeVal), 0); CHECK_FOR_ERROR - delete (yyvsp[0].TypeVal); + delete (yyvsp[(5) - (5)].TypeVal); ;} break; case 184: -#line 1709 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1709 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; CHECK_FOR_ERROR @@ -4125,16 +4346,16 @@ yyreduce: break; case 185: -#line 1713 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1713 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurGV = ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); + CurGV = ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::DLLImportLinkage, (yyvsp[(4) - (5)].BoolVal), *(yyvsp[(5) - (5)].TypeVal), 0); CHECK_FOR_ERROR - delete (yyvsp[0].TypeVal); + delete (yyvsp[(5) - (5)].TypeVal); ;} break; case 186: -#line 1717 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1717 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; CHECK_FOR_ERROR @@ -4142,17 +4363,17 @@ yyreduce: break; case 187: -#line 1721 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1721 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurGV = - ParseGlobalVariable((yyvsp[-3].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[-1].BoolVal), *(yyvsp[0].TypeVal), 0); + ParseGlobalVariable((yyvsp[(2) - (5)].StrVal), GlobalValue::ExternalWeakLinkage, (yyvsp[(4) - (5)].BoolVal), *(yyvsp[(5) - (5)].TypeVal), 0); CHECK_FOR_ERROR - delete (yyvsp[0].TypeVal); + delete (yyvsp[(5) - (5)].TypeVal); ;} break; case 188: -#line 1726 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1726 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurGV = 0; CHECK_FOR_ERROR @@ -4160,32 +4381,32 @@ yyreduce: break; case 189: -#line 1730 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1730 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 190: -#line 1733 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1733 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 191: -#line 1736 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1736 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { ;} break; case 192: -#line 1740 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1740 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { const std::string &AsmSoFar = CurModule.CurrentModule->getModuleInlineAsm(); - char *EndStr = UnEscapeLexed((yyvsp[0].StrVal), true); - std::string NewAsm((yyvsp[0].StrVal), EndStr); - free((yyvsp[0].StrVal)); + char *EndStr = UnEscapeLexed((yyvsp[(1) - (1)].StrVal), true); + std::string NewAsm((yyvsp[(1) - (1)].StrVal), EndStr); + free((yyvsp[(1) - (1)].StrVal)); if (AsmSoFar.empty()) CurModule.CurrentModule->setModuleInlineAsm(NewAsm); @@ -4196,124 +4417,124 @@ yyreduce: break; case 193: -#line 1753 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1753 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Endianness) = Module::BigEndian; ;} break; case 194: -#line 1754 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1754 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.Endianness) = Module::LittleEndian; ;} break; case 195: -#line 1756 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1756 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurModule.CurrentModule->setEndianness((yyvsp[0].Endianness)); + CurModule.CurrentModule->setEndianness((yyvsp[(3) - (3)].Endianness)); CHECK_FOR_ERROR ;} break; case 196: -#line 1760 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1760 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[0].UInt64Val) == 32) + if ((yyvsp[(3) - (3)].UInt64Val) == 32) CurModule.CurrentModule->setPointerSize(Module::Pointer32); - else if ((yyvsp[0].UInt64Val) == 64) + else if ((yyvsp[(3) - (3)].UInt64Val) == 64) CurModule.CurrentModule->setPointerSize(Module::Pointer64); else - GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[0].UInt64Val)) + "'!"); + GEN_ERROR("Invalid pointer size: '" + utostr((yyvsp[(3) - (3)].UInt64Val)) + "'!"); CHECK_FOR_ERROR ;} break; case 197: -#line 1769 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1769 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurModule.CurrentModule->setTargetTriple((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); + CurModule.CurrentModule->setTargetTriple((yyvsp[(3) - (3)].StrVal)); + free((yyvsp[(3) - (3)].StrVal)); ;} break; case 198: -#line 1773 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1773 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurModule.CurrentModule->setDataLayout((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); + CurModule.CurrentModule->setDataLayout((yyvsp[(3) - (3)].StrVal)); + free((yyvsp[(3) - (3)].StrVal)); ;} break; case 200: -#line 1780 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1780 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); + CurModule.CurrentModule->addLibrary((yyvsp[(3) - (3)].StrVal)); + free((yyvsp[(3) - (3)].StrVal)); CHECK_FOR_ERROR ;} break; case 201: -#line 1785 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1785 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - CurModule.CurrentModule->addLibrary((yyvsp[0].StrVal)); - free((yyvsp[0].StrVal)); + CurModule.CurrentModule->addLibrary((yyvsp[(1) - (1)].StrVal)); + free((yyvsp[(1) - (1)].StrVal)); CHECK_FOR_ERROR ;} break; case 202: -#line 1790 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1790 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CHECK_FOR_ERROR ;} break; case 206: -#line 1800 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1800 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.StrVal) = 0; ;} break; case 207: -#line 1802 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1802 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (*(yyvsp[-1].TypeVal) == Type::VoidTy) + if (*(yyvsp[(1) - (2)].TypeVal) == Type::VoidTy) GEN_ERROR("void typed arguments are invalid!"); - (yyval.ArgVal) = new std::pair((yyvsp[-1].TypeVal), (yyvsp[0].StrVal)); + (yyval.ArgVal) = new std::pair((yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].StrVal)); CHECK_FOR_ERROR ;} break; case 208: -#line 1809 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1809 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ArgList) = (yyvsp[-2].ArgList); - (yyvsp[-2].ArgList)->push_back(*(yyvsp[0].ArgVal)); - delete (yyvsp[0].ArgVal); + (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList); + (yyvsp[(1) - (3)].ArgList)->push_back(*(yyvsp[(3) - (3)].ArgVal)); + delete (yyvsp[(3) - (3)].ArgVal); CHECK_FOR_ERROR ;} break; case 209: -#line 1815 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1815 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = new std::vector >(); - (yyval.ArgList)->push_back(*(yyvsp[0].ArgVal)); - delete (yyvsp[0].ArgVal); + (yyval.ArgList)->push_back(*(yyvsp[(1) - (1)].ArgVal)); + delete (yyvsp[(1) - (1)].ArgVal); CHECK_FOR_ERROR ;} break; case 210: -#line 1822 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1822 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ArgList) = (yyvsp[0].ArgList); + (yyval.ArgList) = (yyvsp[(1) - (1)].ArgList); CHECK_FOR_ERROR ;} break; case 211: -#line 1826 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1826 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ArgList) = (yyvsp[-2].ArgList); + (yyval.ArgList) = (yyvsp[(1) - (3)].ArgList); (yyval.ArgList)->push_back(std::pair(new PATypeHolder(Type::VoidTy), 0)); CHECK_FOR_ERROR @@ -4321,7 +4542,7 @@ yyreduce: break; case 212: -#line 1832 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1832 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = new std::vector >(); (yyval.ArgList)->push_back(std::make_pair(new PATypeHolder(Type::VoidTy), (char*)0)); @@ -4330,7 +4551,7 @@ yyreduce: break; case 213: -#line 1837 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1837 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ArgList) = 0; CHECK_FOR_ERROR @@ -4338,28 +4559,28 @@ yyreduce: break; case 214: -#line 1843 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1843 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - UnEscapeLexed((yyvsp[-5].StrVal)); - std::string FunctionName((yyvsp[-5].StrVal)); - free((yyvsp[-5].StrVal)); // Free strdup'd memory! + UnEscapeLexed((yyvsp[(3) - (8)].StrVal)); + std::string FunctionName((yyvsp[(3) - (8)].StrVal)); + free((yyvsp[(3) - (8)].StrVal)); // Free strdup'd memory! - if (!(*(yyvsp[-6].TypeVal))->isFirstClassType() && *(yyvsp[-6].TypeVal) != Type::VoidTy) + if (!(*(yyvsp[(2) - (8)].TypeVal))->isFirstClassType() && *(yyvsp[(2) - (8)].TypeVal) != Type::VoidTy) GEN_ERROR("LLVM functions cannot return aggregate types!"); std::vector ParamTypeList; - if ((yyvsp[-3].ArgList)) { // If there are arguments... - for (std::vector >::iterator I = (yyvsp[-3].ArgList)->begin(); - I != (yyvsp[-3].ArgList)->end(); ++I) + if ((yyvsp[(5) - (8)].ArgList)) { // If there are arguments... + for (std::vector >::iterator I = (yyvsp[(5) - (8)].ArgList)->begin(); + I != (yyvsp[(5) - (8)].ArgList)->end(); ++I) ParamTypeList.push_back(I->first->get()); } bool isVarArg = ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy; if (isVarArg) ParamTypeList.pop_back(); - const FunctionType *FT = FunctionType::get(*(yyvsp[-6].TypeVal), ParamTypeList, isVarArg); + const FunctionType *FT = FunctionType::get(*(yyvsp[(2) - (8)].TypeVal), ParamTypeList, isVarArg); const PointerType *PFT = PointerType::get(FT); - delete (yyvsp[-6].TypeVal); + delete (yyvsp[(2) - (8)].TypeVal); ValID ID; if (!FunctionName.empty()) { @@ -4403,24 +4624,24 @@ yyreduce: // another function. Fn->setLinkage(CurFun.Linkage); } - Fn->setCallingConv((yyvsp[-7].UIntVal)); - Fn->setAlignment((yyvsp[0].UIntVal)); - if ((yyvsp[-1].StrVal)) { - Fn->setSection((yyvsp[-1].StrVal)); - free((yyvsp[-1].StrVal)); + Fn->setCallingConv((yyvsp[(1) - (8)].UIntVal)); + Fn->setAlignment((yyvsp[(8) - (8)].UIntVal)); + if ((yyvsp[(7) - (8)].StrVal)) { + Fn->setSection((yyvsp[(7) - (8)].StrVal)); + free((yyvsp[(7) - (8)].StrVal)); } // Add all of the arguments we parsed to the function... - if ((yyvsp[-3].ArgList)) { // Is null if empty... + if ((yyvsp[(5) - (8)].ArgList)) { // Is null if empty... if (isVarArg) { // Nuke the last entry - assert((yyvsp[-3].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[-3].ArgList)->back().second == 0&& + assert((yyvsp[(5) - (8)].ArgList)->back().first->get() == Type::VoidTy && (yyvsp[(5) - (8)].ArgList)->back().second == 0&& "Not a varargs marker!"); - delete (yyvsp[-3].ArgList)->back().first; - (yyvsp[-3].ArgList)->pop_back(); // Delete the last entry + delete (yyvsp[(5) - (8)].ArgList)->back().first; + (yyvsp[(5) - (8)].ArgList)->pop_back(); // Delete the last entry } Function::arg_iterator ArgIt = Fn->arg_begin(); - for (std::vector >::iterator I = (yyvsp[-3].ArgList)->begin(); - I != (yyvsp[-3].ArgList)->end(); ++I, ++ArgIt) { + for (std::vector >::iterator I = (yyvsp[(5) - (8)].ArgList)->begin(); + I != (yyvsp[(5) - (8)].ArgList)->end(); ++I, ++ArgIt) { delete I->first; // Delete the typeholder... setValueName(ArgIt, I->second); // Insert arg into symtab... @@ -4428,48 +4649,48 @@ yyreduce: InsertValue(ArgIt); } - delete (yyvsp[-3].ArgList); // We're now done with the argument list + delete (yyvsp[(5) - (8)].ArgList); // We're now done with the argument list } CHECK_FOR_ERROR ;} break; case 217: -#line 1939 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1939 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = CurFun.CurrentFunction; // Make sure that we keep track of the linkage type even if there was a // previous "declare". - (yyval.FunctionVal)->setLinkage((yyvsp[-2].Linkage)); + (yyval.FunctionVal)->setLinkage((yyvsp[(1) - (3)].Linkage)); ;} break; case 220: -#line 1949 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1949 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); + (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); CHECK_FOR_ERROR ;} break; case 222: -#line 1955 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1955 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurFun.Linkage = GlobalValue::DLLImportLinkage; ;} break; case 223: -#line 1956 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1956 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurFun.Linkage = GlobalValue::ExternalWeakLinkage; ;} break; case 224: -#line 1958 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1958 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { CurFun.isDeclare = true; ;} break; case 225: -#line 1958 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1958 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.FunctionVal) = CurFun.CurrentFunction; CurFun.FunctionDone(); @@ -4478,7 +4699,7 @@ yyreduce: break; case 226: -#line 1968 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1968 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR @@ -4486,7 +4707,7 @@ yyreduce: break; case 227: -#line 1972 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1972 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR @@ -4494,31 +4715,31 @@ yyreduce: break; case 228: -#line 1977 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1977 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // A reference to a direct constant - (yyval.ValIDVal) = ValID::create((yyvsp[0].SInt64Val)); + (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SInt64Val)); CHECK_FOR_ERROR ;} break; case 229: -#line 1981 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1981 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ValIDVal) = ValID::create((yyvsp[0].UInt64Val)); + (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].UInt64Val)); CHECK_FOR_ERROR ;} break; case 230: -#line 1985 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1985 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Perhaps it's an FP constant? - (yyval.ValIDVal) = ValID::create((yyvsp[0].FPVal)); + (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].FPVal)); CHECK_FOR_ERROR ;} break; case 231: -#line 1989 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1989 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create(ConstantBool::getTrue()); CHECK_FOR_ERROR @@ -4526,7 +4747,7 @@ yyreduce: break; case 232: -#line 1993 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1993 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::create(ConstantBool::getFalse()); CHECK_FOR_ERROR @@ -4534,7 +4755,7 @@ yyreduce: break; case 233: -#line 1997 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 1997 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createNull(); CHECK_FOR_ERROR @@ -4542,7 +4763,7 @@ yyreduce: break; case 234: -#line 2001 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2001 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ValIDVal) = ValID::createUndef(); CHECK_FOR_ERROR @@ -4550,7 +4771,7 @@ yyreduce: break; case 235: -#line 2005 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2005 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // A vector zero constant. (yyval.ValIDVal) = ValID::createZeroInit(); CHECK_FOR_ERROR @@ -4558,10 +4779,10 @@ yyreduce: break; case 236: -#line 2009 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2009 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Nonempty unsized packed vector - const Type *ETy = (*(yyvsp[-1].ConstVector))[0]->getType(); - int NumElements = (yyvsp[-1].ConstVector)->size(); + const Type *ETy = (*(yyvsp[(2) - (3)].ConstVector))[0]->getType(); + int NumElements = (yyvsp[(2) - (3)].ConstVector)->size(); PackedType* pt = PackedType::get(ETy, NumElements); PATypeHolder* PTy = new PATypeHolder( @@ -4573,110 +4794,110 @@ yyreduce: ); // Verify all elements are correct type! - for (unsigned i = 0; i < (yyvsp[-1].ConstVector)->size(); i++) { - if (ETy != (*(yyvsp[-1].ConstVector))[i]->getType()) + for (unsigned i = 0; i < (yyvsp[(2) - (3)].ConstVector)->size(); i++) { + if (ETy != (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()) GEN_ERROR("Element #" + utostr(i) + " is not of type '" + ETy->getDescription() +"' as required!\nIt is of type '" + - (*(yyvsp[-1].ConstVector))[i]->getType()->getDescription() + "'."); + (*(yyvsp[(2) - (3)].ConstVector))[i]->getType()->getDescription() + "'."); } - (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[-1].ConstVector))); - delete PTy; delete (yyvsp[-1].ConstVector); + (yyval.ValIDVal) = ValID::create(ConstantPacked::get(pt, *(yyvsp[(2) - (3)].ConstVector))); + delete PTy; delete (yyvsp[(2) - (3)].ConstVector); CHECK_FOR_ERROR ;} break; case 237: -#line 2034 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2034 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ValIDVal) = ValID::create((yyvsp[0].ConstVal)); + (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].ConstVal)); CHECK_FOR_ERROR ;} break; case 238: -#line 2038 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2038 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - char *End = UnEscapeLexed((yyvsp[-2].StrVal), true); - std::string AsmStr = std::string((yyvsp[-2].StrVal), End); - End = UnEscapeLexed((yyvsp[0].StrVal), true); - std::string Constraints = std::string((yyvsp[0].StrVal), End); - (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[-3].BoolVal)); - free((yyvsp[-2].StrVal)); - free((yyvsp[0].StrVal)); + char *End = UnEscapeLexed((yyvsp[(3) - (5)].StrVal), true); + std::string AsmStr = std::string((yyvsp[(3) - (5)].StrVal), End); + End = UnEscapeLexed((yyvsp[(5) - (5)].StrVal), true); + std::string Constraints = std::string((yyvsp[(5) - (5)].StrVal), End); + (yyval.ValIDVal) = ValID::createInlineAsm(AsmStr, Constraints, (yyvsp[(2) - (5)].BoolVal)); + free((yyvsp[(3) - (5)].StrVal)); + free((yyvsp[(5) - (5)].StrVal)); CHECK_FOR_ERROR ;} break; case 239: -#line 2052 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2052 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Is it an integer reference...? - (yyval.ValIDVal) = ValID::create((yyvsp[0].SIntVal)); + (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].SIntVal)); CHECK_FOR_ERROR ;} break; case 240: -#line 2056 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2056 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Is it a named reference...? - (yyval.ValIDVal) = ValID::create((yyvsp[0].StrVal)); + (yyval.ValIDVal) = ValID::create((yyvsp[(1) - (1)].StrVal)); CHECK_FOR_ERROR ;} break; case 243: -#line 2068 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2068 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ValueVal) = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); delete (yyvsp[-1].TypeVal); + (yyval.ValueVal) = getVal(*(yyvsp[(1) - (2)].TypeVal), (yyvsp[(2) - (2)].ValIDVal)); delete (yyvsp[(1) - (2)].TypeVal); CHECK_FOR_ERROR ;} break; case 244: -#line 2073 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2073 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); + (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); CHECK_FOR_ERROR ;} break; case 245: -#line 2077 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2077 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Do not allow functions with 0 basic blocks - (yyval.FunctionVal) = (yyvsp[-1].FunctionVal); + (yyval.FunctionVal) = (yyvsp[(1) - (2)].FunctionVal); CHECK_FOR_ERROR ;} break; case 246: -#line 2086 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2086 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - setValueName((yyvsp[0].TermInstVal), (yyvsp[-1].StrVal)); + setValueName((yyvsp[(3) - (3)].TermInstVal), (yyvsp[(2) - (3)].StrVal)); CHECK_FOR_ERROR - InsertValue((yyvsp[0].TermInstVal)); + InsertValue((yyvsp[(3) - (3)].TermInstVal)); - (yyvsp[-2].BasicBlockVal)->getInstList().push_back((yyvsp[0].TermInstVal)); - InsertValue((yyvsp[-2].BasicBlockVal)); - (yyval.BasicBlockVal) = (yyvsp[-2].BasicBlockVal); + (yyvsp[(1) - (3)].BasicBlockVal)->getInstList().push_back((yyvsp[(3) - (3)].TermInstVal)); + InsertValue((yyvsp[(1) - (3)].BasicBlockVal)); + (yyval.BasicBlockVal) = (yyvsp[(1) - (3)].BasicBlockVal); CHECK_FOR_ERROR ;} break; case 247: -#line 2097 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2097 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (CastInst *CI1 = dyn_cast((yyvsp[0].InstVal))) + if (CastInst *CI1 = dyn_cast((yyvsp[(2) - (2)].InstVal))) if (CastInst *CI2 = dyn_cast(CI1->getOperand(0))) if (CI2->getParent() == 0) - (yyvsp[-1].BasicBlockVal)->getInstList().push_back(CI2); - (yyvsp[-1].BasicBlockVal)->getInstList().push_back((yyvsp[0].InstVal)); - (yyval.BasicBlockVal) = (yyvsp[-1].BasicBlockVal); + (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back(CI2); + (yyvsp[(1) - (2)].BasicBlockVal)->getInstList().push_back((yyvsp[(2) - (2)].InstVal)); + (yyval.BasicBlockVal) = (yyvsp[(1) - (2)].BasicBlockVal); CHECK_FOR_ERROR ;} break; case 248: -#line 2106 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2106 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BasicBlockVal) = getBBVal(ValID::create((int)CurFun.NextBBNum++), true); CHECK_FOR_ERROR @@ -4692,9 +4913,9 @@ yyreduce: break; case 249: -#line 2118 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2118 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[0].StrVal)), true); + (yyval.BasicBlockVal) = getBBVal(ValID::create((yyvsp[(1) - (1)].StrVal)), true); CHECK_FOR_ERROR // Make sure to move the basic block to the correct location in the @@ -4708,15 +4929,15 @@ yyreduce: break; case 250: -#line 2131 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2131 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Return with a result... - (yyval.TermInstVal) = new ReturnInst((yyvsp[0].ValueVal)); + (yyval.TermInstVal) = new ReturnInst((yyvsp[(2) - (2)].ValueVal)); CHECK_FOR_ERROR ;} break; case 251: -#line 2135 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2135 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Return with no result... (yyval.TermInstVal) = new ReturnInst(); CHECK_FOR_ERROR @@ -4724,56 +4945,56 @@ yyreduce: break; case 252: -#line 2139 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2139 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Unconditional Branch... - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock* tmpBB = getBBVal((yyvsp[(3) - (3)].ValIDVal)); CHECK_FOR_ERROR (yyval.TermInstVal) = new BranchInst(tmpBB); ;} break; case 253: -#line 2144 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2144 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - BasicBlock* tmpBBA = getBBVal((yyvsp[-3].ValIDVal)); + BasicBlock* tmpBBA = getBBVal((yyvsp[(6) - (9)].ValIDVal)); CHECK_FOR_ERROR - BasicBlock* tmpBBB = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock* tmpBBB = getBBVal((yyvsp[(9) - (9)].ValIDVal)); CHECK_FOR_ERROR - Value* tmpVal = getVal(Type::BoolTy, (yyvsp[-6].ValIDVal)); + Value* tmpVal = getVal(Type::BoolTy, (yyvsp[(3) - (9)].ValIDVal)); CHECK_FOR_ERROR (yyval.TermInstVal) = new BranchInst(tmpBBA, tmpBBB, tmpVal); ;} break; case 254: -#line 2153 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2153 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - Value* tmpVal = getVal((yyvsp[-7].PrimType), (yyvsp[-6].ValIDVal)); + Value* tmpVal = getVal((yyvsp[(2) - (9)].PrimType), (yyvsp[(3) - (9)].ValIDVal)); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-3].ValIDVal)); + BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (9)].ValIDVal)); CHECK_FOR_ERROR - SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[-1].JumpTable)->size()); + SwitchInst *S = new SwitchInst(tmpVal, tmpBB, (yyvsp[(8) - (9)].JumpTable)->size()); (yyval.TermInstVal) = S; - std::vector >::iterator I = (yyvsp[-1].JumpTable)->begin(), - E = (yyvsp[-1].JumpTable)->end(); + std::vector >::iterator I = (yyvsp[(8) - (9)].JumpTable)->begin(), + E = (yyvsp[(8) - (9)].JumpTable)->end(); for (; I != E; ++I) { if (ConstantInt *CI = dyn_cast(I->first)) S->addCase(CI, I->second); else GEN_ERROR("Switch case is constant, but not a simple integer!"); } - delete (yyvsp[-1].JumpTable); + delete (yyvsp[(8) - (9)].JumpTable); CHECK_FOR_ERROR ;} break; case 255: -#line 2172 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2172 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - Value* tmpVal = getVal((yyvsp[-6].PrimType), (yyvsp[-5].ValIDVal)); + Value* tmpVal = getVal((yyvsp[(2) - (8)].PrimType), (yyvsp[(3) - (8)].ValIDVal)); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-2].ValIDVal)); + BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (8)].ValIDVal)); CHECK_FOR_ERROR SwitchInst *S = new SwitchInst(tmpVal, tmpBB, 0); (yyval.TermInstVal) = S; @@ -4782,17 +5003,17 @@ yyreduce: break; case 256: -#line 2182 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2182 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { const PointerType *PFTy; const FunctionType *Ty; - if (!(PFTy = dyn_cast((yyvsp[-10].TypeVal)->get())) || + if (!(PFTy = dyn_cast((yyvsp[(3) - (13)].TypeVal)->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; - if ((yyvsp[-7].ValueList)) { - for (std::vector::iterator I = (yyvsp[-7].ValueList)->begin(), E = (yyvsp[-7].ValueList)->end(); + if ((yyvsp[(6) - (13)].ValueList)) { + for (std::vector::iterator I = (yyvsp[(6) - (13)].ValueList)->begin(), E = (yyvsp[(6) - (13)].ValueList)->end(); I != E; ++I) ParamTypes.push_back((*I)->getType()); } @@ -4800,19 +5021,19 @@ yyreduce: bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - Ty = FunctionType::get((yyvsp[-10].TypeVal)->get(), ParamTypes, isVarArg); + Ty = FunctionType::get((yyvsp[(3) - (13)].TypeVal)->get(), ParamTypes, isVarArg); PFTy = PointerType::get(Ty); } - Value *V = getVal(PFTy, (yyvsp[-9].ValIDVal)); // Get the function we're calling... + Value *V = getVal(PFTy, (yyvsp[(4) - (13)].ValIDVal)); // Get the function we're calling... CHECK_FOR_ERROR - BasicBlock *Normal = getBBVal((yyvsp[-3].ValIDVal)); + BasicBlock *Normal = getBBVal((yyvsp[(10) - (13)].ValIDVal)); CHECK_FOR_ERROR - BasicBlock *Except = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock *Except = getBBVal((yyvsp[(13) - (13)].ValIDVal)); CHECK_FOR_ERROR // Create the call node... - if (!(yyvsp[-7].ValueList)) { // Has no arguments? + if (!(yyvsp[(6) - (13)].ValueList)) { // Has no arguments? (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, std::vector()); } else { // Has arguments? // Loop through FunctionType's arguments and ensure they are specified @@ -4820,7 +5041,7 @@ yyreduce: // FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator E = Ty->param_end(); - std::vector::iterator ArgI = (yyvsp[-7].ValueList)->begin(), ArgE = (yyvsp[-7].ValueList)->end(); + std::vector::iterator ArgI = (yyvsp[(6) - (13)].ValueList)->begin(), ArgE = (yyvsp[(6) - (13)].ValueList)->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) if ((*ArgI)->getType() != *I) @@ -4830,18 +5051,18 @@ yyreduce: if (I != E || (ArgI != ArgE && !Ty->isVarArg())) GEN_ERROR("Invalid number of parameters detected!"); - (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[-7].ValueList)); + (yyval.TermInstVal) = new InvokeInst(V, Normal, Except, *(yyvsp[(6) - (13)].ValueList)); } - cast((yyval.TermInstVal))->setCallingConv((yyvsp[-11].UIntVal)); + cast((yyval.TermInstVal))->setCallingConv((yyvsp[(2) - (13)].UIntVal)); - delete (yyvsp[-10].TypeVal); - delete (yyvsp[-7].ValueList); + delete (yyvsp[(3) - (13)].TypeVal); + delete (yyvsp[(6) - (13)].ValueList); CHECK_FOR_ERROR ;} break; case 257: -#line 2237 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2237 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.TermInstVal) = new UnwindInst(); CHECK_FOR_ERROR @@ -4849,7 +5070,7 @@ yyreduce: break; case 258: -#line 2241 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2241 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.TermInstVal) = new UnreachableInst(); CHECK_FOR_ERROR @@ -4857,97 +5078,97 @@ yyreduce: break; case 259: -#line 2248 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2248 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.JumpTable) = (yyvsp[-5].JumpTable); - Constant *V = cast(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); + (yyval.JumpTable) = (yyvsp[(1) - (6)].JumpTable); + Constant *V = cast(getValNonImprovising((yyvsp[(2) - (6)].PrimType), (yyvsp[(3) - (6)].ValIDVal))); CHECK_FOR_ERROR if (V == 0) GEN_ERROR("May only switch on a constant pool value!"); - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (6)].ValIDVal)); CHECK_FOR_ERROR (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); ;} break; case 260: -#line 2259 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2259 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.JumpTable) = new std::vector >(); - Constant *V = cast(getValNonImprovising((yyvsp[-4].PrimType), (yyvsp[-3].ValIDVal))); + Constant *V = cast(getValNonImprovising((yyvsp[(1) - (5)].PrimType), (yyvsp[(2) - (5)].ValIDVal))); CHECK_FOR_ERROR if (V == 0) GEN_ERROR("May only switch on a constant pool value!"); - BasicBlock* tmpBB = getBBVal((yyvsp[0].ValIDVal)); + BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (5)].ValIDVal)); CHECK_FOR_ERROR (yyval.JumpTable)->push_back(std::make_pair(V, tmpBB)); ;} break; case 261: -#line 2272 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2272 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Is this definition named?? if so, assign the name... - setValueName((yyvsp[0].InstVal), (yyvsp[-1].StrVal)); + setValueName((yyvsp[(2) - (2)].InstVal), (yyvsp[(1) - (2)].StrVal)); CHECK_FOR_ERROR - InsertValue((yyvsp[0].InstVal)); - (yyval.InstVal) = (yyvsp[0].InstVal); + InsertValue((yyvsp[(2) - (2)].InstVal)); + (yyval.InstVal) = (yyvsp[(2) - (2)].InstVal); CHECK_FOR_ERROR ;} break; case 262: -#line 2281 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2281 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Used for PHI nodes (yyval.PHIList) = new std::list >(); - Value* tmpVal = getVal(*(yyvsp[-5].TypeVal), (yyvsp[-3].ValIDVal)); + Value* tmpVal = getVal(*(yyvsp[(1) - (6)].TypeVal), (yyvsp[(3) - (6)].ValIDVal)); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); + BasicBlock* tmpBB = getBBVal((yyvsp[(5) - (6)].ValIDVal)); CHECK_FOR_ERROR (yyval.PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); - delete (yyvsp[-5].TypeVal); + delete (yyvsp[(1) - (6)].TypeVal); ;} break; case 263: -#line 2290 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2290 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.PHIList) = (yyvsp[-6].PHIList); - Value* tmpVal = getVal((yyvsp[-6].PHIList)->front().first->getType(), (yyvsp[-3].ValIDVal)); + (yyval.PHIList) = (yyvsp[(1) - (7)].PHIList); + Value* tmpVal = getVal((yyvsp[(1) - (7)].PHIList)->front().first->getType(), (yyvsp[(4) - (7)].ValIDVal)); CHECK_FOR_ERROR - BasicBlock* tmpBB = getBBVal((yyvsp[-1].ValIDVal)); + BasicBlock* tmpBB = getBBVal((yyvsp[(6) - (7)].ValIDVal)); CHECK_FOR_ERROR - (yyvsp[-6].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); + (yyvsp[(1) - (7)].PHIList)->push_back(std::make_pair(tmpVal, tmpBB)); ;} break; case 264: -#line 2300 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2300 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { // Used for call statements, and memory insts... (yyval.ValueList) = new std::vector(); - (yyval.ValueList)->push_back((yyvsp[0].ValueVal)); + (yyval.ValueList)->push_back((yyvsp[(1) - (1)].ValueVal)); ;} break; case 265: -#line 2304 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2304 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ValueList) = (yyvsp[-2].ValueList); - (yyvsp[-2].ValueList)->push_back((yyvsp[0].ValueVal)); + (yyval.ValueList) = (yyvsp[(1) - (3)].ValueList); + (yyvsp[(1) - (3)].ValueList)->push_back((yyvsp[(3) - (3)].ValueVal)); CHECK_FOR_ERROR ;} break; case 267: -#line 2311 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2311 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = 0; ;} break; case 268: -#line 2313 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2313 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR @@ -4955,7 +5176,7 @@ yyreduce: break; case 269: -#line 2317 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2317 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR @@ -4963,106 +5184,106 @@ yyreduce: break; case 270: -#line 2322 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2322 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!(*(yyvsp[-3].TypeVal))->isInteger() && !(*(yyvsp[-3].TypeVal))->isFloatingPoint() && - !isa((*(yyvsp[-3].TypeVal)).get())) + if (!(*(yyvsp[(2) - (5)].TypeVal))->isInteger() && !(*(yyvsp[(2) - (5)].TypeVal))->isFloatingPoint() && + !isa((*(yyvsp[(2) - (5)].TypeVal)).get())) GEN_ERROR( "Arithmetic operator requires integer, FP, or packed operands!"); - if (isa((*(yyvsp[-3].TypeVal)).get()) && - ((yyvsp[-4].BinaryOpVal) == Instruction::URem || - (yyvsp[-4].BinaryOpVal) == Instruction::SRem || - (yyvsp[-4].BinaryOpVal) == Instruction::FRem)) + if (isa((*(yyvsp[(2) - (5)].TypeVal)).get()) && + ((yyvsp[(1) - (5)].BinaryOpVal) == Instruction::URem || + (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::SRem || + (yyvsp[(1) - (5)].BinaryOpVal) == Instruction::FRem)) GEN_ERROR("U/S/FRem not supported on packed types!"); - Value* val1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + Value* val1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal)); CHECK_FOR_ERROR - Value* val2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* val2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), val1, val2); + (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), val1, val2); if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); - delete (yyvsp[-3].TypeVal); + delete (yyvsp[(2) - (5)].TypeVal); ;} break; case 271: -#line 2341 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2341 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!(*(yyvsp[-3].TypeVal))->isIntegral()) { - if (!isa((yyvsp[-3].TypeVal)->get()) || - !cast((yyvsp[-3].TypeVal)->get())->getElementType()->isIntegral()) + if (!(*(yyvsp[(2) - (5)].TypeVal))->isIntegral()) { + if (!isa((yyvsp[(2) - (5)].TypeVal)->get()) || + !cast((yyvsp[(2) - (5)].TypeVal)->get())->getElementType()->isIntegral()) GEN_ERROR("Logical operator requires integral operands!"); } - Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal)); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = BinaryOperator::create((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); + (yyval.InstVal) = BinaryOperator::create((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2); if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); - delete (yyvsp[-3].TypeVal); + delete (yyvsp[(2) - (5)].TypeVal); ;} break; case 272: -#line 2356 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2356 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if(isa((*(yyvsp[-3].TypeVal)).get())) { + if(isa((*(yyvsp[(2) - (5)].TypeVal)).get())) { GEN_ERROR( "PackedTypes currently not supported in setcc instructions!"); } - Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + Value* tmpVal1 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(3) - (5)].ValIDVal)); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal2 = getVal(*(yyvsp[(2) - (5)].TypeVal), (yyvsp[(5) - (5)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = new SetCondInst((yyvsp[-4].BinaryOpVal), tmpVal1, tmpVal2); + (yyval.InstVal) = new SetCondInst((yyvsp[(1) - (5)].BinaryOpVal), tmpVal1, tmpVal2); if ((yyval.InstVal) == 0) GEN_ERROR("binary operator returned null!"); - delete (yyvsp[-3].TypeVal); + delete (yyvsp[(2) - (5)].TypeVal); ;} break; case 273: -#line 2370 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2370 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (isa((*(yyvsp[-3].TypeVal)).get())) + if (isa((*(yyvsp[(3) - (6)].TypeVal)).get())) GEN_ERROR("Packed types not supported by icmp instruction"); - Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal)); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].IPredicate), tmpVal1, tmpVal2); + (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].IPredicate), tmpVal1, tmpVal2); if ((yyval.InstVal) == 0) GEN_ERROR("icmp operator returned null!"); ;} break; case 274: -#line 2381 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2381 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (isa((*(yyvsp[-3].TypeVal)).get())) + if (isa((*(yyvsp[(3) - (6)].TypeVal)).get())) GEN_ERROR("Packed types not supported by fcmp instruction"); - Value* tmpVal1 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[-2].ValIDVal)); + Value* tmpVal1 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(4) - (6)].ValIDVal)); CHECK_FOR_ERROR - Value* tmpVal2 = getVal(*(yyvsp[-3].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal2 = getVal(*(yyvsp[(3) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = CmpInst::create((yyvsp[-5].OtherOpVal), (yyvsp[-4].FPredicate), tmpVal1, tmpVal2); + (yyval.InstVal) = CmpInst::create((yyvsp[(1) - (6)].OtherOpVal), (yyvsp[(2) - (6)].FPredicate), tmpVal1, tmpVal2); if ((yyval.InstVal) == 0) GEN_ERROR("fcmp operator returned null!"); ;} break; case 275: -#line 2392 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2392 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - llvm_cerr << "WARNING: Use of eliminated 'not' instruction:" - << " Replacing with 'xor'.\n"; + cerr << "WARNING: Use of eliminated 'not' instruction:" + << " Replacing with 'xor'.\n"; - Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[0].ValueVal)->getType()); + Value *Ones = ConstantIntegral::getAllOnesValue((yyvsp[(2) - (2)].ValueVal)->getType()); if (Ones == 0) GEN_ERROR("Expected integral type for not instruction!"); - (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[0].ValueVal), Ones); + (yyval.InstVal) = BinaryOperator::create(Instruction::Xor, (yyvsp[(2) - (2)].ValueVal), Ones); if ((yyval.InstVal) == 0) GEN_ERROR("Could not create a xor instruction!"); CHECK_FOR_ERROR @@ -5070,115 +5291,115 @@ yyreduce: break; case 276: -#line 2405 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2405 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[0].ValueVal)->getType() != Type::UByteTy) + if ((yyvsp[(4) - (4)].ValueVal)->getType() != Type::UByteTy) GEN_ERROR("Shift amount must be ubyte!"); - if (!(yyvsp[-2].ValueVal)->getType()->isInteger()) + if (!(yyvsp[(2) - (4)].ValueVal)->getType()->isInteger()) GEN_ERROR("Shift constant expression requires integer operand!"); CHECK_FOR_ERROR; - (yyval.InstVal) = new ShiftInst((yyvsp[-3].OtherOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + (yyval.InstVal) = new ShiftInst((yyvsp[(1) - (4)].OtherOpVal), (yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)); CHECK_FOR_ERROR ;} break; case 277: -#line 2414 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2414 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - Value* Val = (yyvsp[-2].ValueVal); - const Type* Ty = (yyvsp[0].TypeVal)->get(); + Value* Val = (yyvsp[(2) - (4)].ValueVal); + const Type* Ty = (yyvsp[(4) - (4)].TypeVal)->get(); if (!Val->getType()->isFirstClassType()) GEN_ERROR("cast from a non-primitive type: '" + Val->getType()->getDescription() + "'!"); if (!Ty->isFirstClassType()) GEN_ERROR("cast to a non-primitive type: '" + Ty->getDescription() +"'!"); - (yyval.InstVal) = CastInst::create((yyvsp[-3].CastOpVal), (yyvsp[-2].ValueVal), (yyvsp[0].TypeVal)->get()); - delete (yyvsp[0].TypeVal); + (yyval.InstVal) = CastInst::create((yyvsp[(1) - (4)].CastOpVal), (yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].TypeVal)->get()); + delete (yyvsp[(4) - (4)].TypeVal); ;} break; case 278: -#line 2425 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2425 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if ((yyvsp[-4].ValueVal)->getType() != Type::BoolTy) + if ((yyvsp[(2) - (6)].ValueVal)->getType() != Type::BoolTy) GEN_ERROR("select condition must be boolean!"); - if ((yyvsp[-2].ValueVal)->getType() != (yyvsp[0].ValueVal)->getType()) + if ((yyvsp[(4) - (6)].ValueVal)->getType() != (yyvsp[(6) - (6)].ValueVal)->getType()) GEN_ERROR("select value types should match!"); - (yyval.InstVal) = new SelectInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + (yyval.InstVal) = new SelectInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)); CHECK_FOR_ERROR ;} break; case 279: -#line 2433 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2433 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.InstVal) = new VAArgInst((yyvsp[-2].ValueVal), *(yyvsp[0].TypeVal)); - delete (yyvsp[0].TypeVal); + (yyval.InstVal) = new VAArgInst((yyvsp[(2) - (4)].ValueVal), *(yyvsp[(4) - (4)].TypeVal)); + delete (yyvsp[(4) - (4)].TypeVal); CHECK_FOR_ERROR ;} break; case 280: -#line 2438 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2438 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!ExtractElementInst::isValidOperands((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) + if (!ExtractElementInst::isValidOperands((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal))) GEN_ERROR("Invalid extractelement operands!"); - (yyval.InstVal) = new ExtractElementInst((yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + (yyval.InstVal) = new ExtractElementInst((yyvsp[(2) - (4)].ValueVal), (yyvsp[(4) - (4)].ValueVal)); CHECK_FOR_ERROR ;} break; case 281: -#line 2444 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2444 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!InsertElementInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) + if (!InsertElementInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) GEN_ERROR("Invalid insertelement operands!"); - (yyval.InstVal) = new InsertElementInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + (yyval.InstVal) = new InsertElementInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)); CHECK_FOR_ERROR ;} break; case 282: -#line 2450 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2450 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!ShuffleVectorInst::isValidOperands((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal))) + if (!ShuffleVectorInst::isValidOperands((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal))) GEN_ERROR("Invalid shufflevector operands!"); - (yyval.InstVal) = new ShuffleVectorInst((yyvsp[-4].ValueVal), (yyvsp[-2].ValueVal), (yyvsp[0].ValueVal)); + (yyval.InstVal) = new ShuffleVectorInst((yyvsp[(2) - (6)].ValueVal), (yyvsp[(4) - (6)].ValueVal), (yyvsp[(6) - (6)].ValueVal)); CHECK_FOR_ERROR ;} break; case 283: -#line 2456 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2456 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const Type *Ty = (yyvsp[0].PHIList)->front().first->getType(); + const Type *Ty = (yyvsp[(2) - (2)].PHIList)->front().first->getType(); if (!Ty->isFirstClassType()) GEN_ERROR("PHI node operands must be of first class type!"); (yyval.InstVal) = new PHINode(Ty); - ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[0].PHIList)->size()); - while ((yyvsp[0].PHIList)->begin() != (yyvsp[0].PHIList)->end()) { - if ((yyvsp[0].PHIList)->front().first->getType() != Ty) + ((PHINode*)(yyval.InstVal))->reserveOperandSpace((yyvsp[(2) - (2)].PHIList)->size()); + while ((yyvsp[(2) - (2)].PHIList)->begin() != (yyvsp[(2) - (2)].PHIList)->end()) { + if ((yyvsp[(2) - (2)].PHIList)->front().first->getType() != Ty) GEN_ERROR("All elements of a PHI node must be of the same type!"); - cast((yyval.InstVal))->addIncoming((yyvsp[0].PHIList)->front().first, (yyvsp[0].PHIList)->front().second); - (yyvsp[0].PHIList)->pop_front(); + cast((yyval.InstVal))->addIncoming((yyvsp[(2) - (2)].PHIList)->front().first, (yyvsp[(2) - (2)].PHIList)->front().second); + (yyvsp[(2) - (2)].PHIList)->pop_front(); } - delete (yyvsp[0].PHIList); // Free the list... + delete (yyvsp[(2) - (2)].PHIList); // Free the list... CHECK_FOR_ERROR ;} break; case 284: -#line 2471 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2471 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { const PointerType *PFTy = 0; const FunctionType *Ty = 0; - if (!(PFTy = dyn_cast((yyvsp[-4].TypeVal)->get())) || + if (!(PFTy = dyn_cast((yyvsp[(3) - (7)].TypeVal)->get())) || !(Ty = dyn_cast(PFTy->getElementType()))) { // Pull out the types of all of the arguments... std::vector ParamTypes; - if ((yyvsp[-1].ValueList)) { - for (std::vector::iterator I = (yyvsp[-1].ValueList)->begin(), E = (yyvsp[-1].ValueList)->end(); + if ((yyvsp[(6) - (7)].ValueList)) { + for (std::vector::iterator I = (yyvsp[(6) - (7)].ValueList)->begin(), E = (yyvsp[(6) - (7)].ValueList)->end(); I != E; ++I) ParamTypes.push_back((*I)->getType()); } @@ -5186,18 +5407,18 @@ yyreduce: bool isVarArg = ParamTypes.size() && ParamTypes.back() == Type::VoidTy; if (isVarArg) ParamTypes.pop_back(); - if (!(*(yyvsp[-4].TypeVal))->isFirstClassType() && *(yyvsp[-4].TypeVal) != Type::VoidTy) + if (!(*(yyvsp[(3) - (7)].TypeVal))->isFirstClassType() && *(yyvsp[(3) - (7)].TypeVal) != Type::VoidTy) GEN_ERROR("LLVM functions cannot return aggregate types!"); - Ty = FunctionType::get((yyvsp[-4].TypeVal)->get(), ParamTypes, isVarArg); + Ty = FunctionType::get((yyvsp[(3) - (7)].TypeVal)->get(), ParamTypes, isVarArg); PFTy = PointerType::get(Ty); } - Value *V = getVal(PFTy, (yyvsp[-3].ValIDVal)); // Get the function we're calling... + Value *V = getVal(PFTy, (yyvsp[(4) - (7)].ValIDVal)); // Get the function we're calling... CHECK_FOR_ERROR // Create the call node... - if (!(yyvsp[-1].ValueList)) { // Has no arguments? + if (!(yyvsp[(6) - (7)].ValueList)) { // Has no arguments? // Make sure no arguments is a good thing! if (Ty->getNumParams() != 0) GEN_ERROR("No arguments passed to a function that " @@ -5210,7 +5431,7 @@ yyreduce: // FunctionType::param_iterator I = Ty->param_begin(); FunctionType::param_iterator E = Ty->param_end(); - std::vector::iterator ArgI = (yyvsp[-1].ValueList)->begin(), ArgE = (yyvsp[-1].ValueList)->end(); + std::vector::iterator ArgI = (yyvsp[(6) - (7)].ValueList)->begin(), ArgE = (yyvsp[(6) - (7)].ValueList)->end(); for (; ArgI != ArgE && I != E; ++ArgI, ++I) if ((*ArgI)->getType() != *I) @@ -5220,34 +5441,34 @@ yyreduce: if (I != E || (ArgI != ArgE && !Ty->isVarArg())) GEN_ERROR("Invalid number of parameters detected!"); - (yyval.InstVal) = new CallInst(V, *(yyvsp[-1].ValueList)); + (yyval.InstVal) = new CallInst(V, *(yyvsp[(6) - (7)].ValueList)); } - cast((yyval.InstVal))->setTailCall((yyvsp[-6].BoolVal)); - cast((yyval.InstVal))->setCallingConv((yyvsp[-5].UIntVal)); - delete (yyvsp[-4].TypeVal); - delete (yyvsp[-1].ValueList); + cast((yyval.InstVal))->setTailCall((yyvsp[(1) - (7)].BoolVal)); + cast((yyval.InstVal))->setCallingConv((yyvsp[(2) - (7)].UIntVal)); + delete (yyvsp[(3) - (7)].TypeVal); + delete (yyvsp[(6) - (7)].ValueList); CHECK_FOR_ERROR ;} break; case 285: -#line 2530 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2530 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.InstVal) = (yyvsp[0].InstVal); + (yyval.InstVal) = (yyvsp[(1) - (1)].InstVal); CHECK_FOR_ERROR ;} break; case 286: -#line 2537 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2537 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.ValueList) = (yyvsp[0].ValueList); + (yyval.ValueList) = (yyvsp[(2) - (2)].ValueList); CHECK_FOR_ERROR ;} break; case 287: -#line 2540 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2540 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.ValueList) = new std::vector(); CHECK_FOR_ERROR @@ -5255,7 +5476,7 @@ yyreduce: break; case 288: -#line 2545 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2545 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = true; CHECK_FOR_ERROR @@ -5263,7 +5484,7 @@ yyreduce: break; case 289: -#line 2549 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2549 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { (yyval.BoolVal) = false; CHECK_FOR_ERROR @@ -5271,117 +5492,115 @@ yyreduce: break; case 290: -#line 2556 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2556 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.InstVal) = new MallocInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); - delete (yyvsp[-1].TypeVal); + (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal)); + delete (yyvsp[(2) - (3)].TypeVal); CHECK_FOR_ERROR ;} break; case 291: -#line 2561 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2561 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); + Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = new MallocInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); - delete (yyvsp[-4].TypeVal); + (yyval.InstVal) = new MallocInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal)); + delete (yyvsp[(2) - (6)].TypeVal); ;} break; case 292: -#line 2567 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2567 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - (yyval.InstVal) = new AllocaInst(*(yyvsp[-1].TypeVal), 0, (yyvsp[0].UIntVal)); - delete (yyvsp[-1].TypeVal); + (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (3)].TypeVal), 0, (yyvsp[(3) - (3)].UIntVal)); + delete (yyvsp[(2) - (3)].TypeVal); CHECK_FOR_ERROR ;} break; case 293: -#line 2572 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2572 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - Value* tmpVal = getVal((yyvsp[-2].PrimType), (yyvsp[-1].ValIDVal)); + Value* tmpVal = getVal((yyvsp[(4) - (6)].PrimType), (yyvsp[(5) - (6)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = new AllocaInst(*(yyvsp[-4].TypeVal), tmpVal, (yyvsp[0].UIntVal)); - delete (yyvsp[-4].TypeVal); + (yyval.InstVal) = new AllocaInst(*(yyvsp[(2) - (6)].TypeVal), tmpVal, (yyvsp[(6) - (6)].UIntVal)); + delete (yyvsp[(2) - (6)].TypeVal); ;} break; case 294: -#line 2578 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2578 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!isa((yyvsp[0].ValueVal)->getType())) + if (!isa((yyvsp[(2) - (2)].ValueVal)->getType())) GEN_ERROR("Trying to free nonpointer type " + - (yyvsp[0].ValueVal)->getType()->getDescription() + "!"); - (yyval.InstVal) = new FreeInst((yyvsp[0].ValueVal)); + (yyvsp[(2) - (2)].ValueVal)->getType()->getDescription() + "!"); + (yyval.InstVal) = new FreeInst((yyvsp[(2) - (2)].ValueVal)); CHECK_FOR_ERROR ;} break; case 295: -#line 2586 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2586 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!isa((yyvsp[-1].TypeVal)->get())) + if (!isa((yyvsp[(3) - (4)].TypeVal)->get())) GEN_ERROR("Can't load from nonpointer type: " + - (*(yyvsp[-1].TypeVal))->getDescription()); - if (!cast((yyvsp[-1].TypeVal)->get())->getElementType()->isFirstClassType()) + (*(yyvsp[(3) - (4)].TypeVal))->getDescription()); + if (!cast((yyvsp[(3) - (4)].TypeVal)->get())->getElementType()->isFirstClassType()) GEN_ERROR("Can't load from pointer of non-first-class type: " + - (*(yyvsp[-1].TypeVal))->getDescription()); - Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); + (*(yyvsp[(3) - (4)].TypeVal))->getDescription()); + Value* tmpVal = getVal(*(yyvsp[(3) - (4)].TypeVal), (yyvsp[(4) - (4)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[-3].BoolVal)); - delete (yyvsp[-1].TypeVal); + (yyval.InstVal) = new LoadInst(tmpVal, "", (yyvsp[(1) - (4)].BoolVal)); + delete (yyvsp[(3) - (4)].TypeVal); ;} break; case 296: -#line 2598 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2598 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - const PointerType *PT = dyn_cast((yyvsp[-1].TypeVal)->get()); + const PointerType *PT = dyn_cast((yyvsp[(5) - (6)].TypeVal)->get()); if (!PT) GEN_ERROR("Can't store to a nonpointer type: " + - (*(yyvsp[-1].TypeVal))->getDescription()); + (*(yyvsp[(5) - (6)].TypeVal))->getDescription()); const Type *ElTy = PT->getElementType(); - if (ElTy != (yyvsp[-3].ValueVal)->getType()) - GEN_ERROR("Can't store '" + (yyvsp[-3].ValueVal)->getType()->getDescription() + + if (ElTy != (yyvsp[(3) - (6)].ValueVal)->getType()) + GEN_ERROR("Can't store '" + (yyvsp[(3) - (6)].ValueVal)->getType()->getDescription() + "' into space of type '" + ElTy->getDescription() + "'!"); - Value* tmpVal = getVal(*(yyvsp[-1].TypeVal), (yyvsp[0].ValIDVal)); + Value* tmpVal = getVal(*(yyvsp[(5) - (6)].TypeVal), (yyvsp[(6) - (6)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = new StoreInst((yyvsp[-3].ValueVal), tmpVal, (yyvsp[-5].BoolVal)); - delete (yyvsp[-1].TypeVal); + (yyval.InstVal) = new StoreInst((yyvsp[(3) - (6)].ValueVal), tmpVal, (yyvsp[(1) - (6)].BoolVal)); + delete (yyvsp[(5) - (6)].TypeVal); ;} break; case 297: -#line 2613 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2613 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" { - if (!isa((yyvsp[-2].TypeVal)->get())) + if (!isa((yyvsp[(2) - (4)].TypeVal)->get())) GEN_ERROR("getelementptr insn requires pointer operand!"); - if (!GetElementPtrInst::getIndexedType(*(yyvsp[-2].TypeVal), *(yyvsp[0].ValueList), true)) + if (!GetElementPtrInst::getIndexedType(*(yyvsp[(2) - (4)].TypeVal), *(yyvsp[(4) - (4)].ValueList), true)) GEN_ERROR("Invalid getelementptr indices for type '" + - (*(yyvsp[-2].TypeVal))->getDescription()+ "'!"); - Value* tmpVal = getVal(*(yyvsp[-2].TypeVal), (yyvsp[-1].ValIDVal)); + (*(yyvsp[(2) - (4)].TypeVal))->getDescription()+ "'!"); + Value* tmpVal = getVal(*(yyvsp[(2) - (4)].TypeVal), (yyvsp[(3) - (4)].ValIDVal)); CHECK_FOR_ERROR - (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[0].ValueList)); - delete (yyvsp[-2].TypeVal); - delete (yyvsp[0].ValueList); + (yyval.InstVal) = new GetElementPtrInst(tmpVal, *(yyvsp[(4) - (4)].ValueList)); + delete (yyvsp[(2) - (4)].TypeVal); + delete (yyvsp[(4) - (4)].ValueList); ;} break; +/* Line 1267 of yacc.c. */ +#line 5598 "llvmAsmParser.tab.c" default: break; } + YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); -/* Line 1126 of yacc.c. */ -#line 5380 "llvmAsmParser.tab.c" - - yyvsp -= yylen; - yyssp -= yylen; - - + YYPOPSTACK (yylen); + yylen = 0; YY_STACK_PRINT (yyss, yyssp); *++yyvsp = yyval; @@ -5410,110 +5629,41 @@ yyerrlab: if (!yyerrstatus) { ++yynerrs; -#if YYERROR_VERBOSE - yyn = yypact[yystate]; - - if (YYPACT_NINF < yyn && yyn < YYLAST) - { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - char *yymsg = 0; -# define YYERROR_VERBOSE_ARGS_MAXIMUM 5 - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -#if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -#endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) +#if ! YYERROR_VERBOSE + yyerror (YY_("syntax error")); +#else + { + YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); + if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) + { + YYSIZE_T yyalloc = 2 * yysize; + if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) + yyalloc = YYSTACK_ALLOC_MAXIMUM; + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yyalloc); + if (yymsg) + yymsg_alloc = yyalloc; + else { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; } + } - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= yysize1 < yysize; - yysize = yysize1; - - if (!yysize_overflow && yysize <= YYSTACK_ALLOC_MAXIMUM) - yymsg = (char *) YYSTACK_ALLOC (yysize); - if (yymsg) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yymsg; - int yyi = 0; - while ((*yyp = *yyf)) - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - yyerror (yymsg); - YYSTACK_FREE (yymsg); - } - else - { - yyerror (YY_("syntax error")); + if (0 < yysize && yysize <= yymsg_alloc) + { + (void) yysyntax_error (yymsg, yystate, yychar); + yyerror (yymsg); + } + else + { + yyerror (YY_("syntax error")); + if (yysize != 0) goto yyexhaustedlab; - } - } - else -#endif /* YYERROR_VERBOSE */ - yyerror (YY_("syntax error")); + } + } +#endif } @@ -5524,14 +5674,15 @@ yyerrlab: error, discard it. */ if (yychar <= YYEOF) - { + { /* Return failure if at end of input. */ if (yychar == YYEOF) YYABORT; - } + } else { - yydestruct ("Error: discarding", yytoken, &yylval); + yydestruct ("Error: discarding", + yytoken, &yylval); yychar = YYEMPTY; } } @@ -5549,11 +5700,14 @@ yyerrorlab: /* Pacify compilers like GCC when the user code never invokes YYERROR and the label yyerrorlab therefore never appears in user code. */ - if (0) + if (/*CONSTCOND*/ 0) goto yyerrorlab; -yyvsp -= yylen; - yyssp -= yylen; + /* Do not reclaim the symbols of the rule which action triggered + this YYERROR. */ + YYPOPSTACK (yylen); + yylen = 0; + YY_STACK_PRINT (yyss, yyssp); yystate = *yyssp; goto yyerrlab1; @@ -5583,8 +5737,9 @@ yyerrlab1: YYABORT; - yydestruct ("Error: popping", yystos[yystate], yyvsp); - YYPOPSTACK; + yydestruct ("Error: popping", + yystos[yystate], yyvsp); + YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } @@ -5595,7 +5750,7 @@ yyerrlab1: *++yyvsp = yylval; - /* Shift the error token. */ + /* Shift the error token. */ YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp); yystate = yyn; @@ -5630,21 +5785,30 @@ yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) yydestruct ("Cleanup: discarding lookahead", yytoken, &yylval); + /* Do not reclaim the symbols of the rule which action triggered + this YYABORT or YYACCEPT. */ + YYPOPSTACK (yylen); + YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", yystos[*yyssp], yyvsp); - YYPOPSTACK; + YYPOPSTACK (1); } #ifndef yyoverflow if (yyss != yyssa) YYSTACK_FREE (yyss); #endif - return yyresult; +#if YYERROR_VERBOSE + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); +#endif + /* Make sure YYID is used. */ + return YYID (yyresult); } -#line 2628 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" +#line 2628 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" void llvm::GenerateError(const std::string &message, int LineNo) { diff --git a/lib/AsmParser/llvmAsmParser.h.cvs b/lib/AsmParser/llvmAsmParser.h.cvs index 4661132712..5e539625f3 100644 --- a/lib/AsmParser/llvmAsmParser.h.cvs +++ b/lib/AsmParser/llvmAsmParser.h.cvs @@ -1,7 +1,9 @@ -/* A Bison parser, made by GNU Bison 2.1. */ +/* A Bison parser, made by GNU Bison 2.3. */ -/* Skeleton parser for Yacc-like parsing with Bison, - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. +/* Skeleton interface for Bison's Yacc-like parsers in C + + Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -18,10 +20,18 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ -/* As a special exception, when this file is copied by Bison into a - Bison output file, you may use that output file without restriction. - This special exception was added by the Free Software Foundation - in version 1.24 of Bison. */ +/* As a special exception, you may create a larger work that contains + part or all of the Bison parser skeleton and distribute that work + under terms of your choice, so long as that work isn't itself a + parser generator using the skeleton or a modified version thereof + as a parser skeleton. Alternatively, if you modify or redistribute + the parser skeleton itself, you may (at your option) remove this + special exception, which will cause the skeleton and the resulting + Bison output files to be licensed under the GNU General Public + License without this special exception. + + This special exception was added by the Free Software Foundation in + version 2.2 of Bison. */ /* Tokens. */ #ifndef YYTOKENTYPE @@ -320,9 +330,10 @@ -#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED) -#line 855 "/proj/llvm/llvm-1/lib/AsmParser/llvmAsmParser.y" -typedef union YYSTYPE { +#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED +typedef union YYSTYPE +#line 855 "/Volumes/Gir/devel/llvm/llvm.src/lib/AsmParser/llvmAsmParser.y" +{ llvm::Module *ModuleVal; llvm::Function *FunctionVal; std::pair *ArgVal; @@ -363,9 +374,10 @@ typedef union YYSTYPE { llvm::Module::Endianness Endianness; llvm::ICmpInst::Predicate IPredicate; llvm::FCmpInst::Predicate FPredicate; -} YYSTYPE; -/* Line 1447 of yacc.c. */ -#line 369 "llvmAsmParser.tab.h" +} +/* Line 1529 of yacc.c. */ +#line 380 "llvmAsmParser.tab.h" + YYSTYPE; # define yystype YYSTYPE /* obsolescent; will be withdrawn */ # define YYSTYPE_IS_DECLARED 1 # define YYSTYPE_IS_TRIVIAL 1 @@ -373,5 +385,3 @@ typedef union YYSTYPE { extern YYSTYPE llvmAsmlval; - - diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 31306c2744..15524baf86 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -57,7 +57,7 @@ static Module *ParserResult; // //#define DEBUG_UPREFS 1 #ifdef DEBUG_UPREFS -#define UR_OUT(X) llvm_cerr << X +#define UR_OUT(X) cerr << X #else #define UR_OUT(X) #endif @@ -2390,8 +2390,8 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { GEN_ERROR("fcmp operator returned null!"); } | NOT ResolvedVal { - llvm_cerr << "WARNING: Use of eliminated 'not' instruction:" - << " Replacing with 'xor'.\n"; + cerr << "WARNING: Use of eliminated 'not' instruction:" + << " Replacing with 'xor'.\n"; Value *Ones = ConstantIntegral::getAllOnesValue($2->getType()); if (Ones == 0) diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs index 31306c2744..15524baf86 100644 --- a/lib/AsmParser/llvmAsmParser.y.cvs +++ b/lib/AsmParser/llvmAsmParser.y.cvs @@ -57,7 +57,7 @@ static Module *ParserResult; // //#define DEBUG_UPREFS 1 #ifdef DEBUG_UPREFS -#define UR_OUT(X) llvm_cerr << X +#define UR_OUT(X) cerr << X #else #define UR_OUT(X) #endif @@ -2390,8 +2390,8 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef { GEN_ERROR("fcmp operator returned null!"); } | NOT ResolvedVal { - llvm_cerr << "WARNING: Use of eliminated 'not' instruction:" - << " Replacing with 'xor'.\n"; + cerr << "WARNING: Use of eliminated 'not' instruction:" + << " Replacing with 'xor'.\n"; Value *Ones = ConstantIntegral::getAllOnesValue($2->getType()); if (Ones == 0) diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index efb6c436cd..9e096ee6eb 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -32,7 +32,7 @@ using namespace llvm; #if 0 #include "llvm/Support/Streams.h" -#define SC_DEBUG(X) llvm_cerr << X +#define SC_DEBUG(X) cerr << X #else #define SC_DEBUG(X) #endif diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 37c6321e33..b69c1ad8b3 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -276,8 +276,8 @@ void BytecodeWriter::outputType(const Type *T) { break; default: - llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" - << " Type '" << T->getDescription() << "'\n"; + cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" + << " Type '" << T->getDescription() << "'\n"; break; } } @@ -387,8 +387,8 @@ void BytecodeWriter::outputConstant(const Constant *CPV) { case Type::VoidTyID: case Type::LabelTyID: default: - llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" - << " type '" << *CPV->getType() << "'\n"; + cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" + << " type '" << *CPV->getType() << "'\n"; break; } return; @@ -1239,13 +1239,13 @@ void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) { } } -void llvm::WriteBytecodeToFile(const Module *M, llvm_ostream &Out, +void llvm::WriteBytecodeToFile(const Module *M, OStream &Out, bool compress) { assert(M && "You can't write a null module!!"); // Make sure that std::cout is put into binary mode for systems // that care. - if (Out == llvm_cout) + if (Out == cout) sys::Program::ChangeStdoutToBinary(); // Create a vector of unsigned char for the bytecode output. We diff --git a/lib/CodeGen/AsmPrinter.cpp b/lib/CodeGen/AsmPrinter.cpp index 1b25b015fa..4caa2c1be1 100644 --- a/lib/CodeGen/AsmPrinter.cpp +++ b/lib/CodeGen/AsmPrinter.cpp @@ -25,7 +25,6 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetMachine.h" -#include #include using namespace llvm; @@ -668,8 +667,8 @@ void AsmPrinter::PrintSpecial(const MachineInstr *MI, const char *Code) { if (LastMI != MI) { ++Counter; LastMI = MI; } O << Counter; } else { - llvm_cerr << "Unknown special formatter '" << Code - << "' for machine instr: " << *MI; + cerr << "Unknown special formatter '" << Code + << "' for machine instr: " << *MI; exit(1); } } @@ -737,8 +736,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { case '(': // $( -> same as GCC's { character. ++LastEmitted; // Consume '(' character. if (CurVariant != -1) { - llvm_cerr << "Nested variants found in inline asm string: '" - << AsmStr << "'\n"; + cerr << "Nested variants found in inline asm string: '" + << AsmStr << "'\n"; exit(1); } CurVariant = 0; // We're in the first variant now. @@ -746,8 +745,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { case '|': ++LastEmitted; // consume '|' character. if (CurVariant == -1) { - llvm_cerr << "Found '|' character outside of variant in inline asm " - << "string: '" << AsmStr << "'\n"; + cerr << "Found '|' character outside of variant in inline asm " + << "string: '" << AsmStr << "'\n"; exit(1); } ++CurVariant; // We're in the next variant. @@ -755,8 +754,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { case ')': // $) -> same as GCC's } char. ++LastEmitted; // consume ')' character. if (CurVariant == -1) { - llvm_cerr << "Found '}' character outside of variant in inline asm " - << "string: '" << AsmStr << "'\n"; + cerr << "Found '}' character outside of variant in inline asm " + << "string: '" << AsmStr << "'\n"; exit(1); } CurVariant = -1; @@ -774,8 +773,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { char *IDEnd; long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs. if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) { - llvm_cerr << "Bad $ operand number in inline asm string: '" - << AsmStr << "'\n"; + cerr << "Bad $ operand number in inline asm string: '" + << AsmStr << "'\n"; exit(1); } LastEmitted = IDEnd; @@ -788,8 +787,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { if (*LastEmitted == ':') { ++LastEmitted; // Consume ':' character. if (*LastEmitted == 0) { - llvm_cerr << "Bad ${:} expression in inline asm string: '" - << AsmStr << "'\n"; + cerr << "Bad ${:} expression in inline asm string: '" + << AsmStr << "'\n"; exit(1); } @@ -798,16 +797,16 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { } if (*LastEmitted != '}') { - llvm_cerr << "Bad ${} expression in inline asm string: '" - << AsmStr << "'\n"; + cerr << "Bad ${} expression in inline asm string: '" + << AsmStr << "'\n"; exit(1); } ++LastEmitted; // Consume '}' character. } if ((unsigned)Val >= NumOperands-1) { - llvm_cerr << "Invalid $ operand number in inline asm string: '" - << AsmStr << "'\n"; + cerr << "Invalid $ operand number in inline asm string: '" + << AsmStr << "'\n"; exit(1); } @@ -841,8 +840,8 @@ void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { } } if (Error) { - llvm_cerr << "Invalid operand found in inline asm: '" - << AsmStr << "'\n"; + cerr << "Invalid operand found in inline asm: '" + << AsmStr << "'\n"; MI->dump(); exit(1); } diff --git a/lib/CodeGen/DwarfWriter.cpp b/lib/CodeGen/DwarfWriter.cpp index ac6987b0f0..8f62396218 100644 --- a/lib/CodeGen/DwarfWriter.cpp +++ b/lib/CodeGen/DwarfWriter.cpp @@ -31,10 +31,8 @@ #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetFrameInfo.h" - #include #include - using namespace llvm; using namespace llvm::dwarf; @@ -139,7 +137,7 @@ public: } #ifndef NDEBUG - void print(llvm_ostream &O) const { + void print(OStream &O) const { if (O.stream()) print(*O.stream()); } void print(std::ostream &O) const { @@ -247,7 +245,7 @@ public: void Emit(const Dwarf &DW) const; #ifndef NDEBUG - void print(llvm_ostream &O) { + void print(OStream &O) { if (O.stream()) print(*O.stream()); } void print(std::ostream &O); @@ -337,7 +335,7 @@ public: void Profile(FoldingSetNodeID &ID) ; #ifndef NDEBUG - void print(llvm_ostream &O, unsigned IncIndent = 0) { + void print(OStream &O, unsigned IncIndent = 0) { if (O.stream()) print(*O.stream(), IncIndent); } void print(std::ostream &O, unsigned IncIndent = 0); @@ -388,7 +386,7 @@ public: virtual void Profile(FoldingSetNodeID &ID) = 0; #ifndef NDEBUG - void print(llvm_ostream &O) { + void print(OStream &O) { if (O.stream()) print(*O.stream()); } virtual void print(std::ostream &O) = 0; @@ -2861,14 +2859,14 @@ void DIEAbbrev::print(std::ostream &O) { << "\n"; } } -void DIEAbbrev::dump() { print(llvm_cerr); } +void DIEAbbrev::dump() { print(cerr); } #endif //===----------------------------------------------------------------------===// #ifndef NDEBUG void DIEValue::dump() { - print(llvm_cerr); + print(cerr); } #endif @@ -3079,7 +3077,7 @@ void DIE::print(std::ostream &O, unsigned IncIndent) { } void DIE::dump() { - print(llvm_cerr); + print(cerr); } #endif diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 702102f2cd..ee9cecd579 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -39,7 +39,6 @@ #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Mangler.h" #include "llvm/Support/Streams.h" -#include using namespace llvm; //===----------------------------------------------------------------------===// @@ -104,9 +103,9 @@ void ELFCodeEmitter::startFunction(MachineFunction &F) { ELFWriter::ELFSection::SHF_EXECINSTR | ELFWriter::ELFSection::SHF_ALLOC); OutBuffer = &ES->SectionData; - llvm_cerr << "FIXME: This code needs to be updated for changes in the" - << " CodeEmitter interfaces. In particular, this should set " - << "BufferBegin/BufferEnd/CurBufferPtr, not deal with OutBuffer!"; + cerr << "FIXME: This code needs to be updated for changes in the" + << " CodeEmitter interfaces. In particular, this should set " + << "BufferBegin/BufferEnd/CurBufferPtr, not deal with OutBuffer!"; abort(); // Upgrade the section alignment if required. diff --git a/lib/CodeGen/IntrinsicLowering.cpp b/lib/CodeGen/IntrinsicLowering.cpp index d70a277f6d..753f4591c6 100644 --- a/lib/CodeGen/IntrinsicLowering.cpp +++ b/lib/CodeGen/IntrinsicLowering.cpp @@ -274,12 +274,12 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { switch (Callee->getIntrinsicID()) { case Intrinsic::not_intrinsic: - llvm_cerr << "Cannot lower a call to a non-intrinsic function '" - << Callee->getName() << "'!\n"; + cerr << "Cannot lower a call to a non-intrinsic function '" + << Callee->getName() << "'!\n"; abort(); default: - llvm_cerr << "Error: Code generator does not support intrinsic function '" - << Callee->getName() << "'!\n"; + cerr << "Error: Code generator does not support intrinsic function '" + << Callee->getName() << "'!\n"; abort(); // The setjmp/longjmp intrinsics should only exist in the code if it was @@ -356,9 +356,9 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::stackrestore: { static bool Warned = false; if (!Warned) - llvm_cerr << "WARNING: this target does not support the llvm.stack" - << (Callee->getIntrinsicID() == Intrinsic::stacksave ? - "save" : "restore") << " intrinsic.\n"; + cerr << "WARNING: this target does not support the llvm.stack" + << (Callee->getIntrinsicID() == Intrinsic::stacksave ? + "save" : "restore") << " intrinsic.\n"; Warned = true; if (Callee->getIntrinsicID() == Intrinsic::stacksave) CI->replaceAllUsesWith(Constant::getNullValue(CI->getType())); @@ -367,9 +367,9 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::returnaddress: case Intrinsic::frameaddress: - llvm_cerr << "WARNING: this target does not support the llvm." - << (Callee->getIntrinsicID() == Intrinsic::returnaddress ? - "return" : "frame") << "address intrinsic.\n"; + cerr << "WARNING: this target does not support the llvm." + << (Callee->getIntrinsicID() == Intrinsic::returnaddress ? + "return" : "frame") << "address intrinsic.\n"; CI->replaceAllUsesWith(ConstantPointerNull::get( cast(CI->getType()))); break; @@ -380,8 +380,8 @@ void IntrinsicLowering::LowerIntrinsicCall(CallInst *CI) { case Intrinsic::pcmarker: break; // Simply strip out pcmarker on unsupported architectures case Intrinsic::readcyclecounter: { - llvm_cerr << "WARNING: this target does not support the llvm.readcyclecoun" - << "ter intrinsic. It is being lowered to a constant 0\n"; + cerr << "WARNING: this target does not support the llvm.readcyclecoun" + << "ter intrinsic. It is being lowered to a constant 0\n"; CI->replaceAllUsesWith(ConstantInt::get(Type::ULongTy, 0)); break; } diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp index d178a6f444..e2a3bbaaf0 100644 --- a/lib/CodeGen/LiveInterval.cpp +++ b/lib/CodeGen/LiveInterval.cpp @@ -23,7 +23,6 @@ #include "llvm/Support/Streams.h" #include "llvm/Target/MRegisterInfo.h" #include -#include #include using namespace llvm; @@ -472,10 +471,10 @@ std::ostream& llvm::operator<<(std::ostream& os, const LiveRange &LR) { } void LiveRange::dump() const { - llvm_cerr << *this << "\n"; + cerr << *this << "\n"; } -void LiveInterval::print(llvm_ostream OS, const MRegisterInfo *MRI) const { +void LiveInterval::print(OStream OS, const MRegisterInfo *MRI) const { if (MRI && MRegisterInfo::isPhysicalRegister(reg)) OS << MRI->getName(reg); else @@ -508,5 +507,5 @@ void LiveInterval::print(llvm_ostream OS, const MRegisterInfo *MRI) const { } void LiveInterval::dump() const { - llvm_cerr << *this << "\n"; + cerr << *this << "\n"; } diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp index eeabbd1c05..2175d35848 100644 --- a/lib/CodeGen/LiveIntervalAnalysis.cpp +++ b/lib/CodeGen/LiveIntervalAnalysis.cpp @@ -419,9 +419,9 @@ addIntervalsForSpills(const LiveInterval &li, VirtRegMap &vrm, int slot) { void LiveIntervals::printRegName(unsigned reg) const { if (MRegisterInfo::isPhysicalRegister(reg)) - llvm_cerr << mri_->getName(reg); + cerr << mri_->getName(reg); else - llvm_cerr << "%reg" << reg; + cerr << "%reg" << reg; } /// isReDefinedByTwoAddr - Returns true if the Reg re-definition is due to diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp index 04bd265228..716b40fbf1 100644 --- a/lib/CodeGen/MachineInstr.cpp +++ b/lib/CodeGen/MachineInstr.cpp @@ -18,7 +18,6 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/Support/LeakDetector.h" #include "llvm/Support/Streams.h" -#include using namespace llvm; /// MachineInstr ctor - This constructor creates a dummy MachineInstr with @@ -201,7 +200,7 @@ void MachineInstr::copyKillDeadInfo(const MachineInstr *MI) { } void MachineInstr::dump() const { - llvm_cerr << " " << *this; + cerr << " " << *this; } static inline void OutputReg(std::ostream &os, unsigned RegNo, diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index 186072c01a..79d3b647fb 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/lib/CodeGen/VirtRegMap.cpp @@ -112,11 +112,11 @@ void VirtRegMap::virtFolded(unsigned VirtReg, MachineInstr *OldMI, } void VirtRegMap::print(std::ostream &OS) const { - llvm_ostream LOS(OS); + OStream LOS(OS); print(LOS); } -void VirtRegMap::print(llvm_ostream &OS) const { +void VirtRegMap::print(OStream &OS) const { const MRegisterInfo* MRI = MF.getTarget().getRegisterInfo(); OS << "********** REGISTER MAP **********\n"; @@ -135,7 +135,7 @@ void VirtRegMap::print(llvm_ostream &OS) const { } void VirtRegMap::dump() const { - llvm_ostream OS = DOUT; + OStream OS = DOUT; print(OS); } diff --git a/lib/CodeGen/VirtRegMap.h b/lib/CodeGen/VirtRegMap.h index c3fe951b37..342d800242 100644 --- a/lib/CodeGen/VirtRegMap.h +++ b/lib/CodeGen/VirtRegMap.h @@ -19,12 +19,12 @@ #include "llvm/Target/MRegisterInfo.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/Support/Streams.h" #include namespace llvm { class MachineInstr; class TargetInstrInfo; - class llvm_ostream; class VirtRegMap { public: @@ -145,7 +145,7 @@ namespace llvm { } void print(std::ostream &OS) const; - void print(llvm_ostream &OS) const; + void print(OStream &OS) const; void dump() const; }; diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp index ff312f08a1..8aaf0eda2e 100644 --- a/lib/ExecutionEngine/ExecutionEngine.cpp +++ b/lib/ExecutionEngine/ExecutionEngine.cpp @@ -402,7 +402,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { default: break; } - llvm_cerr << "ConstantExpr not handled as global var init: " << *CE << "\n"; + cerr << "ConstantExpr not handled as global var init: " << *CE << "\n"; abort(); } @@ -432,7 +432,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) { assert(0 && "Unknown constant pointer type!"); break; default: - llvm_cerr << "ERROR: Constant unimp for type: " << *C->getType() << "\n"; + cerr << "ERROR: Constant unimp for type: " << *C->getType() << "\n"; abort(); } return Result; @@ -477,7 +477,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr, Ptr->Untyped[7] = (unsigned char)(Val.ULongVal >> 56); break; default: - llvm_cerr << "Cannot store value of type " << *Ty << "!\n"; + cerr << "Cannot store value of type " << *Ty << "!\n"; } } else { switch (Ty->getTypeID()) { @@ -511,7 +511,7 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr, Ptr->Untyped[0] = (unsigned char)(Val.ULongVal >> 56); break; default: - llvm_cerr << "Cannot store value of type " << *Ty << "!\n"; + cerr << "Cannot store value of type " << *Ty << "!\n"; } } } @@ -552,7 +552,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, ((uint64_t)Ptr->Untyped[7] << 56); break; default: - llvm_cerr << "Cannot load value of type " << *Ty << "!\n"; + cerr << "Cannot load value of type " << *Ty << "!\n"; abort(); } } else { @@ -586,7 +586,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr, ((uint64_t)Ptr->Untyped[0] << 56); break; default: - llvm_cerr << "Cannot load value of type " << *Ty << "!\n"; + cerr << "Cannot load value of type " << *Ty << "!\n"; abort(); } } @@ -634,7 +634,7 @@ void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) { } default: - llvm_cerr << "Bad Type: " << *Init->getType() << "\n"; + cerr << "Bad Type: " << *Init->getType() << "\n"; assert(0 && "Unknown constant type to initialize memory with!"); } } @@ -718,8 +718,8 @@ void ExecutionEngine::emitGlobals() { sys::DynamicLibrary::SearchForAddressOfSymbol(I->getName().c_str())) addGlobalMapping(I, SymAddr); else { - llvm_cerr << "Could not resolve external global address: " - << I->getName() << "\n"; + cerr << "Could not resolve external global address: " + << I->getName() << "\n"; abort(); } } diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 964435d380..f7400e9ac9 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -188,7 +188,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE, getOperandValue(CE->getOperand(1), SF), getOperandValue(CE->getOperand(2), SF)); default: - llvm_cerr << "Unhandled ConstantExpr: " << *CE << "\n"; + cerr << "Unhandled ConstantExpr: " << *CE << "\n"; abort(); return GenericValue(); } @@ -236,7 +236,7 @@ static GenericValue executeAddInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(+, Float); IMPLEMENT_BINARY_OPERATOR(+, Double); default: - llvm_cerr << "Unhandled type for Add instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Add instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -257,7 +257,7 @@ static GenericValue executeSubInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(-, Float); IMPLEMENT_BINARY_OPERATOR(-, Double); default: - llvm_cerr << "Unhandled type for Sub instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Sub instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -278,7 +278,7 @@ static GenericValue executeMulInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(*, Float); IMPLEMENT_BINARY_OPERATOR(*, Double); default: - llvm_cerr << "Unhandled type for Mul instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Mul instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -296,7 +296,7 @@ static GenericValue executeUDivInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SIGNLESS_BINOP(/, UInt, Int); IMPLEMENT_SIGNLESS_BINOP(/, ULong, Long); default: - llvm_cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n"; + cerr << "Unhandled type for UDiv instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -311,7 +311,7 @@ static GenericValue executeSDivInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SIGNLESS_BINOP(/, Int, UInt); IMPLEMENT_SIGNLESS_BINOP(/, Long, ULong); default: - llvm_cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n"; + cerr << "Unhandled type for SDiv instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -324,7 +324,7 @@ static GenericValue executeFDivInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(/, Float); IMPLEMENT_BINARY_OPERATOR(/, Double); default: - llvm_cerr << "Unhandled type for Div instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Div instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -339,7 +339,7 @@ static GenericValue executeURemInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SIGNLESS_BINOP(%, UInt, Int); IMPLEMENT_SIGNLESS_BINOP(%, ULong, Long); default: - llvm_cerr << "Unhandled type for URem instruction: " << *Ty << "\n"; + cerr << "Unhandled type for URem instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -354,7 +354,7 @@ static GenericValue executeSRemInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SIGNLESS_BINOP(%, Int, UInt); IMPLEMENT_SIGNLESS_BINOP(%, Long, ULong); default: - llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Rem instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -371,7 +371,7 @@ static GenericValue executeFRemInst(GenericValue Src1, GenericValue Src2, Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal); break; default: - llvm_cerr << "Unhandled type for Rem instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Rem instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -391,7 +391,7 @@ static GenericValue executeAndInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(&, ULong); IMPLEMENT_BINARY_OPERATOR(&, Long); default: - llvm_cerr << "Unhandled type for And instruction: " << *Ty << "\n"; + cerr << "Unhandled type for And instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -411,7 +411,7 @@ static GenericValue executeOrInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(|, ULong); IMPLEMENT_BINARY_OPERATOR(|, Long); default: - llvm_cerr << "Unhandled type for Or instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Or instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -431,7 +431,7 @@ static GenericValue executeXorInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_BINARY_OPERATOR(^, ULong); IMPLEMENT_BINARY_OPERATOR(^, Long); default: - llvm_cerr << "Unhandled type for Xor instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Xor instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -465,7 +465,7 @@ static GenericValue executeSetEQInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(==, Double); IMPLEMENT_POINTERSETCC(==); default: - llvm_cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n"; + cerr << "Unhandled type for SetEQ instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -488,7 +488,7 @@ static GenericValue executeSetNEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_POINTERSETCC(!=); default: - llvm_cerr << "Unhandled type for SetNE instruction: " << *Ty << "\n"; + cerr << "Unhandled type for SetNE instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -510,7 +510,7 @@ static GenericValue executeSetLEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(<=, Double); IMPLEMENT_POINTERSETCC(<=); default: - llvm_cerr << "Unhandled type for SetLE instruction: " << *Ty << "\n"; + cerr << "Unhandled type for SetLE instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -532,7 +532,7 @@ static GenericValue executeSetGEInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(>=, Double); IMPLEMENT_POINTERSETCC(>=); default: - llvm_cerr << "Unhandled type for SetGE instruction: " << *Ty << "\n"; + cerr << "Unhandled type for SetGE instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -554,7 +554,7 @@ static GenericValue executeSetLTInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(<, Double); IMPLEMENT_POINTERSETCC(<); default: - llvm_cerr << "Unhandled type for SetLT instruction: " << *Ty << "\n"; + cerr << "Unhandled type for SetLT instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -576,7 +576,7 @@ static GenericValue executeSetGTInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SETCC(>, Double); IMPLEMENT_POINTERSETCC(>); default: - llvm_cerr << "Unhandled type for SetGT instruction: " << *Ty << "\n"; + cerr << "Unhandled type for SetGT instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -609,7 +609,7 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) { case Instruction::SetLT: R = executeSetLTInst(Src1, Src2, Ty); break; case Instruction::SetGT: R = executeSetGTInst(Src1, Src2, Ty); break; default: - llvm_cerr << "Don't know how to handle this binary operator!\n-->" << I; + cerr << "Don't know how to handle this binary operator!\n-->" << I; abort(); } @@ -710,7 +710,7 @@ void Interpreter::visitUnwindInst(UnwindInst &I) { } void Interpreter::visitUnreachableInst(UnreachableInst &I) { - llvm_cerr << "ERROR: Program executed an 'unreachable' instruction!\n"; + cerr << "ERROR: Program executed an 'unreachable' instruction!\n"; abort(); } @@ -978,7 +978,7 @@ static GenericValue executeShlInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SHIFT(<<, ULong); IMPLEMENT_SHIFT(<<, Long); default: - llvm_cerr << "Unhandled type for Shl instruction: " << *Ty << "\n"; + cerr << "Unhandled type for Shl instruction: " << *Ty << "\n"; } return Dest; } @@ -992,7 +992,7 @@ static GenericValue executeLShrInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SIGNLESS_SHIFT(>>, UInt, Int); IMPLEMENT_SIGNLESS_SHIFT(>>, ULong, Long); default: - llvm_cerr << "Unhandled type for LShr instruction: " << *Ty << "\n"; + cerr << "Unhandled type for LShr instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -1007,7 +1007,7 @@ static GenericValue executeAShrInst(GenericValue Src1, GenericValue Src2, IMPLEMENT_SIGNLESS_SHIFT(>>, Int, UInt); IMPLEMENT_SIGNLESS_SHIFT(>>, Long, ULong); default: - llvm_cerr << "Unhandled type for AShr instruction: " << *Ty << "\n"; + cerr << "Unhandled type for AShr instruction: " << *Ty << "\n"; abort(); } return Dest; @@ -1065,14 +1065,14 @@ void Interpreter::visitAShr(ShiftInst &I) { IMPLEMENT_CAST(DESTTY, DESTCTY, Float); \ IMPLEMENT_CAST(DESTTY, DESTCTY, Double) \ default: \ - llvm_cerr << "Unhandled cast: " \ + cerr << "Unhandled cast: " \ << *SrcTy << " to " << *DstTy << "\n"; \ abort(); \ } \ break #define IMPLEMENT_CAST_END \ - default: llvm_cerr \ + default: cerr \ << "Unhandled dest type for cast instruction: " \ << *DstTy << "\n"; \ abort(); \ @@ -1226,8 +1226,7 @@ GenericValue Interpreter::executeCastOperation(Instruction::CastOps opcode, IMPLEMENT_CAST_END break; default: - llvm_cerr - << "Invalid cast opcode for cast instruction: " << opcode << "\n"; + cerr << "Invalid cast opcode for cast instruction: " << opcode << "\n"; abort(); } return Dest; @@ -1266,7 +1265,7 @@ void Interpreter::visitVAArgInst(VAArgInst &I) { IMPLEMENT_VAARG(Double); IMPLEMENT_VAARG(Bool); default: - llvm_cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n"; + cerr << "Unhandled dest type for vaarg instruction: " << *Ty << "\n"; abort(); } diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 161873c2c8..a1c43175da 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -93,8 +93,8 @@ GenericValue Interpreter::callExternalFunction(Function *F, std::map::iterator FI = Functions.find(F); ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second; if (Fn == 0) { - llvm_cerr << "Tried to execute an unknown external function: " - << F->getType()->getDescription() << " " << F->getName() << "\n"; + cerr << "Tried to execute an unknown external function: " + << F->getType()->getDescription() << " " << F->getName() << "\n"; if (F->getName() == "__main") return GenericValue(); abort(); @@ -114,19 +114,19 @@ extern "C" { // Don't add C++ manglings to llvm mangling :) // void putchar(sbyte) GenericValue lle_Vb_putchar(FunctionType *M, const vector &Args) { - llvm_cout << Args[0].SByteVal; + cout << Args[0].SByteVal; return GenericValue(); } // int putchar(int) GenericValue lle_ii_putchar(FunctionType *M, const vector &Args) { - llvm_cout << ((char)Args[0].IntVal) << std::flush; + cout << ((char)Args[0].IntVal) << std::flush; return Args[0]; } // void putchar(ubyte) GenericValue lle_VB_putchar(FunctionType *M, const vector &Args) { - llvm_cout << Args[0].SByteVal << std::flush; + cout << Args[0].SByteVal << std::flush; return Args[0]; } @@ -332,7 +332,7 @@ GenericValue lle_X_sprintf(FunctionType *M, const vector &Args) { sprintf(Buffer, FmtBuf, (void*)GVTOP(Args[ArgNo++])); break; case 's': sprintf(Buffer, FmtBuf, (char*)GVTOP(Args[ArgNo++])); break; - default: llvm_cerr << ""; + default: cerr << ""; ArgNo++; break; } strcpy(OutputBuffer, Buffer); @@ -350,7 +350,7 @@ GenericValue lle_X_printf(FunctionType *M, const vector &Args) { NewArgs.push_back(PTOGV(Buffer)); NewArgs.insert(NewArgs.end(), Args.begin(), Args.end()); GenericValue GV = lle_X_sprintf(M, NewArgs); - llvm_cout << Buffer; + cout << Buffer; return GV; } diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index b09fd656f2..71239f7439 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -25,7 +25,6 @@ #include "llvm/Assembly/Writer.h" #include "llvm/Support/Streams.h" #include "llvm/System/Path.h" -#include using namespace llvm; // Error - Simple wrapper function to conditionally assign to E and return true. @@ -251,11 +250,11 @@ static bool LinkTypes(Module *Dest, const Module *Src, std::string *Err) { static void PrintMap(const std::map &M) { for (std::map::const_iterator I = M.begin(), E =M.end(); I != E; ++I) { - llvm_cerr << " Fr: " << (void*)I->first << " "; + cerr << " Fr: " << (void*)I->first << " "; I->first->dump(); - llvm_cerr << " To: " << (void*)I->second << " "; + cerr << " To: " << (void*)I->second << " "; I->second->dump(); - llvm_cerr << "\n"; + cerr << "\n"; } } @@ -313,10 +312,10 @@ static Value *RemapOperand(const Value *In, } - llvm_cerr << "LinkModules ValueMap: \n"; + cerr << "LinkModules ValueMap: \n"; PrintMap(ValueMap); - llvm_cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n"; + cerr << "Couldn't remap value: " << (void*)In << " " << *In << "\n"; assert(0 && "Couldn't remap value!"); return 0; } @@ -844,13 +843,13 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) { if (Src->getEndianness() != Module::AnyEndianness && Dest->getEndianness() != Src->getEndianness()) - llvm_cerr << "WARNING: Linking two modules of different endianness!\n"; + cerr << "WARNING: Linking two modules of different endianness!\n"; if (Src->getPointerSize() != Module::AnyPointerSize && Dest->getPointerSize() != Src->getPointerSize()) - llvm_cerr << "WARNING: Linking two modules of different pointer size!\n"; + cerr << "WARNING: Linking two modules of different pointer size!\n"; if (!Src->getTargetTriple().empty() && Dest->getTargetTriple() != Src->getTargetTriple()) - llvm_cerr << "WARNING: Linking two modules of different target triples!\n"; + cerr << "WARNING: Linking two modules of different target triples!\n"; if (!Src->getModuleInlineAsm().empty()) { if (Dest->getModuleInlineAsm().empty()) diff --git a/lib/Linker/Linker.cpp b/lib/Linker/Linker.cpp index bf33196090..71905109ea 100644 --- a/lib/Linker/Linker.cpp +++ b/lib/Linker/Linker.cpp @@ -45,7 +45,7 @@ bool Linker::error(const std::string& message) { Error = message; if (!(Flags&QuietErrors)) - llvm_cerr << ProgramName << ": error: " << message << "\n"; + cerr << ProgramName << ": error: " << message << "\n"; return true; } @@ -53,14 +53,14 @@ bool Linker::warning(const std::string& message) { Error = message; if (!(Flags&QuietErrors)) - llvm_cerr << ProgramName << ": warning: " << message << "\n"; + cerr << ProgramName << ": warning: " << message << "\n"; return false; } void Linker::verbose(const std::string& message) { if (Flags&Verbose) - llvm_cerr << " " << message << "\n"; + cerr << " " << message << "\n"; } void diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 96f0743f3d..632b5f7a22 100644 --- a/lib/Support/Allocator.cpp +++ b/lib/Support/Allocator.cpp @@ -102,6 +102,6 @@ void BumpPtrAllocator::PrintStats() const { for (; R; R = R->getNext(), ++NumRegions) BytesUsed += R->getNumBytesAllocated(); - llvm_cerr << "\nNumber of memory regions: " << NumRegions << "\n"; - llvm_cerr << "Bytes allocated: " << BytesUsed << "\n"; + cerr << "\nNumber of memory regions: " << NumRegions << "\n"; + cerr << "Bytes allocated: " << BytesUsed << "\n"; } diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 3b75f478af..920811a06c 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -84,8 +84,8 @@ static Option *getOption(const std::string &Str) { static void AddArgument(const char *ArgName, Option *Opt) { if (getOption(ArgName)) { - llvm_cerr << ProgramName << ": CommandLine Error: Argument '" - << ArgName << "' defined more than once!\n"; + cerr << ProgramName << ": CommandLine Error: Argument '" + << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! (*Options)[ArgName] = Opt; @@ -129,9 +129,9 @@ static inline bool ProvideOption(Option *Handler, const char *ArgName, case ValueOptional: break; default: - llvm_cerr << ProgramName - << ": Bad ValueMask flag! CommandLine usage error:" - << Handler->getValueExpectedFlag() << "\n"; + cerr << ProgramName + << ": Bad ValueMask flag! CommandLine usage error:" + << Handler->getValueExpectedFlag() << "\n"; abort(); break; } @@ -468,8 +468,8 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } if (Handler == 0) { - llvm_cerr << ProgramName << ": Unknown command line argument '" - << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; + cerr << ProgramName << ": Unknown command line argument '" + << argv[i] << "'. Try: '" << argv[0] << " --help'\n"; ErrorParsing = true; continue; } @@ -505,18 +505,18 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // Check and handle positional arguments now... if (NumPositionalRequired > PositionalVals.size()) { - llvm_cerr << ProgramName - << ": Not enough positional command line arguments specified!\n" - << "Must specify at least " << NumPositionalRequired - << " positional arguments: See: " << argv[0] << " --help\n"; + cerr << ProgramName + << ": Not enough positional command line arguments specified!\n" + << "Must specify at least " << NumPositionalRequired + << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; } else if (!HasUnlimitedPositionals && PositionalVals.size() > PositionalOpts.size()) { - llvm_cerr << ProgramName - << ": Too many positional arguments specified!\n" - << "Can specify at most " << PositionalOpts.size() - << " positional arguments: See: " << argv[0] << " --help\n"; + cerr << ProgramName + << ": Too many positional arguments specified!\n" + << "Can specify at most " << PositionalOpts.size() + << " positional arguments: See: " << argv[0] << " --help\n"; ErrorParsing = true; } else if (ConsumeAfterOpt == 0) { @@ -617,11 +617,11 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, bool Option::error(std::string Message, const char *ArgName) { if (ArgName == 0) ArgName = ArgStr; if (ArgName[0] == 0) - llvm_cerr << HelpStr; // Be nice for positional arguments + cerr << HelpStr; // Be nice for positional arguments else - llvm_cerr << ProgramName << ": for the -" << ArgName; + cerr << ProgramName << ": for the -" << ArgName; - llvm_cerr << " option: " << Message << "\n"; + cerr << " option: " << Message << "\n"; return true; } @@ -701,8 +701,8 @@ unsigned alias::getOptionWidth() const { // Print out the option for the alias. void alias::printOptionInfo(unsigned GlobalWidth) const { unsigned L = std::strlen(ArgStr); - llvm_cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " - << HelpStr << "\n"; + cout << " -" << ArgStr << std::string(GlobalWidth-L-6, ' ') << " - " + << HelpStr << "\n"; } @@ -728,13 +728,13 @@ unsigned basic_parser_impl::getOptionWidth(const Option &O) const { // void basic_parser_impl::printOptionInfo(const Option &O, unsigned GlobalWidth) const { - llvm_cout << " -" << O.ArgStr; + cout << " -" << O.ArgStr; if (const char *ValName = getValueName()) - llvm_cout << "=<" << getValueStr(O, ValName) << ">"; + cout << "=<" << getValueStr(O, ValName) << ">"; - llvm_cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " - << O.HelpStr << "\n"; + cout << std::string(GlobalWidth-getOptionWidth(O), ' ') << " - " + << O.HelpStr << "\n"; } @@ -850,21 +850,21 @@ void generic_parser_base::printOptionInfo(const Option &O, unsigned GlobalWidth) const { if (O.hasArgStr()) { unsigned L = std::strlen(O.ArgStr); - llvm_cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') - << " - " << O.HelpStr << "\n"; + cout << " -" << O.ArgStr << std::string(GlobalWidth-L-6, ' ') + << " - " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned NumSpaces = GlobalWidth-strlen(getOption(i))-8; - llvm_cout << " =" << getOption(i) << std::string(NumSpaces, ' ') - << " - " << getDescription(i) << "\n"; + cout << " =" << getOption(i) << std::string(NumSpaces, ' ') + << " - " << getDescription(i) << "\n"; } } else { if (O.HelpStr[0]) - llvm_cout << " " << O.HelpStr << "\n"; + cout << " " << O.HelpStr << "\n"; for (unsigned i = 0, e = getNumOptions(); i != e; ++i) { unsigned L = std::strlen(getOption(i)); - llvm_cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') - << " - " << getDescription(i) << "\n"; + cout << " -" << getOption(i) << std::string(GlobalWidth-L-8, ' ') + << " - " << getDescription(i) << "\n"; } } } @@ -917,9 +917,9 @@ public: } if (ProgramOverview) - llvm_cout << "OVERVIEW:" << ProgramOverview << "\n"; + cout << "OVERVIEW:" << ProgramOverview << "\n"; - llvm_cout << "USAGE: " << ProgramName << " [options]"; + cout << "USAGE: " << ProgramName << " [options]"; // Print out the positional options. std::vector &PosOpts = *PositionalOptions; @@ -929,28 +929,28 @@ public: for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { if (PosOpts[i]->ArgStr[0]) - llvm_cout << " --" << PosOpts[i]->ArgStr; - llvm_cout << " " << PosOpts[i]->HelpStr; + cout << " --" << PosOpts[i]->ArgStr; + cout << " " << PosOpts[i]->HelpStr; } // Print the consume after option info if it exists... - if (CAOpt) llvm_cout << " " << CAOpt->HelpStr; + if (CAOpt) cout << " " << CAOpt->HelpStr; - llvm_cout << "\n\n"; + cout << "\n\n"; // Compute the maximum argument length... MaxArgLen = 0; for (unsigned i = 0, e = Opts.size(); i != e; ++i) MaxArgLen = std::max(MaxArgLen, Opts[i].second->getOptionWidth()); - llvm_cout << "OPTIONS:\n"; + cout << "OPTIONS:\n"; for (unsigned i = 0, e = Opts.size(); i != e; ++i) Opts[i].second->printOptionInfo(MaxArgLen); // Print any extra help the user has declared. for (std::vector::iterator I = MoreHelp->begin(), E = MoreHelp->end(); I != E; ++I) - llvm_cout << *I; + cout << *I; MoreHelp->clear(); // Halt the program since help information was printed @@ -982,21 +982,21 @@ public: void operator=(bool OptionWasSpecified) { if (OptionWasSpecified) { if (OverrideVersionPrinter == 0) { - llvm_cout << "Low Level Virtual Machine (http://llvm.org/):\n"; - llvm_cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION; + cout << "Low Level Virtual Machine (http://llvm.org/):\n"; + cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION; #ifdef LLVM_VERSION_INFO - llvm_cout << LLVM_VERSION_INFO; + cout << LLVM_VERSION_INFO; #endif - llvm_cout << "\n "; + cout << "\n "; #ifndef __OPTIMIZE__ - llvm_cout << "DEBUG build"; + cout << "DEBUG build"; #else - llvm_cout << "Optimized build"; + cout << "Optimized build"; #endif #ifndef NDEBUG - llvm_cout << " with assertions"; + cout << " with assertions"; #endif - llvm_cout << ".\n"; + cout << ".\n"; Options->clear(); // Don't bother making option dtors remove from map. exit(1); } else { diff --git a/lib/Support/ConstantRange.cpp b/lib/Support/ConstantRange.cpp index 1f1a1b5757..2c215866c6 100644 --- a/lib/Support/ConstantRange.cpp +++ b/lib/Support/ConstantRange.cpp @@ -370,5 +370,5 @@ void ConstantRange::print(std::ostream &OS) const { /// dump - Allow printing from a debugger easily... /// void ConstantRange::dump() const { - print(llvm_cerr); + print(cerr); } diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index 9cea94c547..949e3d932a 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -68,9 +68,9 @@ bool llvm::isCurrentDebugType(const char *DebugType) { // 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. // -llvm_ostream llvm::getErrorOutputStream(const char *DebugType) { +OStream llvm::getErrorOutputStream(const char *DebugType) { if (DebugFlag && isCurrentDebugType(DebugType)) - return llvm_cerr; + return cerr; else - return llvm_null; + return NullStream; } diff --git a/lib/Support/GraphWriter.cpp b/lib/Support/GraphWriter.cpp index 01da2e13c5..ecf2bfdb91 100644 --- a/lib/Support/GraphWriter.cpp +++ b/lib/Support/GraphWriter.cpp @@ -28,9 +28,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) { args.push_back(Filename.c_str()); args.push_back(0); - llvm_cerr << "Running 'Graphviz' program... " << std::flush; + cerr << "Running 'Graphviz' program... " << std::flush; if (sys::Program::ExecuteAndWait(Graphviz, &args[0],0,0,0,&ErrMsg)) { - llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; + cerr << "Error viewing graph: " << ErrMsg << "\n"; } #elif (HAVE_GV && HAVE_DOT) sys::Path PSFilename = Filename; @@ -48,11 +48,11 @@ void llvm::DisplayGraph(const sys::Path &Filename) { args.push_back(PSFilename.c_str()); args.push_back(0); - llvm_cerr << "Running 'dot' program... " << std::flush; + cerr << "Running 'dot' program... " << std::flush; if (sys::Program::ExecuteAndWait(dot, &args[0],0,0,0,&ErrMsg)) { - llvm_cerr << "Error viewing graph: '" << ErrMsg << "\n"; + cerr << "Error viewing graph: '" << ErrMsg << "\n"; } else { - llvm_cerr << " done. \n"; + cerr << " done. \n"; sys::Path gv(LLVM_PATH_GV); args.clear(); @@ -62,7 +62,7 @@ void llvm::DisplayGraph(const sys::Path &Filename) { ErrMsg.clear(); if (sys::Program::ExecuteAndWait(gv, &args[0],0,0,0,&ErrMsg)) { - llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; + cerr << "Error viewing graph: " << ErrMsg << "\n"; } } PSFilename.eraseFromDisk(); @@ -73,9 +73,9 @@ void llvm::DisplayGraph(const sys::Path &Filename) { args.push_back(Filename.c_str()); args.push_back(0); - llvm_cerr << "Running 'dotty' program... " << std::flush; + cerr << "Running 'dotty' program... " << std::flush; if (sys::Program::ExecuteAndWait(dotty, &args[0],0,0,0,&ErrMsg)) { - llvm_cerr << "Error viewing graph: " << ErrMsg << "\n"; + cerr << "Error viewing graph: " << ErrMsg << "\n"; } else { #ifdef __MINGW32__ // Dotty spawns another app and doesn't wait until it returns return; diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index abd5e7af7a..97b253e4eb 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -26,8 +26,8 @@ void PluginLoader::operator=(const std::string &Filename) { std::string Error; if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) { - llvm_cerr << "Error opening '" << Filename << "': " << Error - << "\n -load request ignored.\n"; + cerr << "Error opening '" << Filename << "': " << Error + << "\n -load request ignored.\n"; } else { Plugins->push_back(Filename); } diff --git a/lib/Support/SlowOperationInformer.cpp b/lib/Support/SlowOperationInformer.cpp index 806e7a47cb..a7bdf12fd0 100644 --- a/lib/Support/SlowOperationInformer.cpp +++ b/lib/Support/SlowOperationInformer.cpp @@ -28,8 +28,8 @@ SlowOperationInformer::~SlowOperationInformer() { if (LastPrintAmount) { // If we have printed something, make _sure_ we print the 100% amount, and // also print a newline. - llvm_cout << std::string(LastPrintAmount, '\b') << "Progress " - << OperationName << ": 100% \n"; + cout << std::string(LastPrintAmount, '\b') << "Progress " + << OperationName << ": 100% \n"; } } @@ -40,7 +40,7 @@ SlowOperationInformer::~SlowOperationInformer() { bool SlowOperationInformer::progress(unsigned Amount) { int status = sys::AlarmStatus(); if (status == -1) { - llvm_cout << "\n"; + cout << "\n"; LastPrintAmount = 0; return true; } @@ -61,6 +61,6 @@ bool SlowOperationInformer::progress(unsigned Amount) { OS << "% "; LastPrintAmount = OS.str().size(); - llvm_cout << ToPrint+OS.str() << std::flush; + cout << ToPrint+OS.str() << std::flush; return false; } diff --git a/lib/Support/Streams.cpp b/lib/Support/Streams.cpp index 9ca7590e37..02aec1fff8 100644 --- a/lib/Support/Streams.cpp +++ b/lib/Support/Streams.cpp @@ -16,6 +16,7 @@ #include using namespace llvm; -llvm_ostream llvm::llvm_null; -llvm_ostream llvm::llvm_cout(std::cout); -llvm_ostream llvm::llvm_cerr(std::cerr); +OStream llvm::NullStream; +OStream llvm::cout(std::cout); +OStream llvm::cerr(std::cerr); +IStream llvm::cin(std::cin); diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index d4dbaeecc4..124251165d 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -23,10 +23,10 @@ bool llvm::CheckBytecodeOutputToConsole(std::ostream* stream_to_check, bool print_warning) { if (stream_to_check == &std::cout && sys::Process::StandardOutIsDisplayed()) { if (print_warning) { - llvm_cerr << "WARNING: You're attempting to print out a bytecode file.\n" - << "This is inadvisable as it may cause display problems. If\n" - << "you REALLY want to taste LLVM bytecode first-hand, you\n" - << "can force output with the `-f' option.\n\n"; + cerr << "WARNING: You're attempting to print out a bytecode file.\n" + << "This is inadvisable as it may cause display problems. If\n" + << "you REALLY want to taste LLVM bytecode first-hand, you\n" + << "can force output with the `-f' option.\n\n"; } return true; } diff --git a/lib/Transforms/ExprTypeConvert.cpp b/lib/Transforms/ExprTypeConvert.cpp index 39f21ead85..1ce6eedbee 100644 --- a/lib/Transforms/ExprTypeConvert.cpp +++ b/lib/Transforms/ExprTypeConvert.cpp @@ -693,8 +693,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal, I->setName(""); Instruction *Res; // Result of conversion - //llvm_cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I - // << "BB Before: " << BB << endl; + //cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I + // << "BB Before: " << BB << endl; // Prevent I from being removed... ValueHandle IHandle(VMC, I); diff --git a/lib/Transforms/Hello/Hello.cpp b/lib/Transforms/Hello/Hello.cpp index 8324cbb6cb..0b0010df0f 100644 --- a/lib/Transforms/Hello/Hello.cpp +++ b/lib/Transforms/Hello/Hello.cpp @@ -30,7 +30,7 @@ namespace { HelloCounter++; std::string fname = F.getName(); EscapeString(fname); - llvm_cerr << "Hello: " << fname << "\n"; + cerr << "Hello: " << fname << "\n"; return false; } }; @@ -43,7 +43,7 @@ namespace { HelloCounter++; std::string fname = F.getName(); EscapeString(fname); - llvm_cerr << "Hello: " << fname << "\n"; + cerr << "Hello: " << fname << "\n"; return false; } diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index a0dc9373d6..764205baaa 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/lib/Transforms/IPO/GlobalOpt.cpp @@ -494,17 +494,17 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V) { // Will trap. } else if (StoreInst *SI = dyn_cast(*UI)) { if (SI->getOperand(0) == V) { - //llvm_cerr << "NONTRAPPING USE: " << **UI; + //cerr << "NONTRAPPING USE: " << **UI; return false; // Storing the value. } } else if (CallInst *CI = dyn_cast(*UI)) { if (CI->getOperand(0) != V) { - //llvm_cerr << "NONTRAPPING USE: " << **UI; + //cerr << "NONTRAPPING USE: " << **UI; return false; // Not calling the ptr } } else if (InvokeInst *II = dyn_cast(*UI)) { if (II->getOperand(0) != V) { - //llvm_cerr << "NONTRAPPING USE: " << **UI; + //cerr << "NONTRAPPING USE: " << **UI; return false; // Not calling the ptr } } else if (CastInst *CI = dyn_cast(*UI)) { @@ -515,7 +515,7 @@ static bool AllUsesOfValueWillTrapIfNull(Value *V) { isa(UI->getOperand(1))) { // Ignore setcc X, null } else { - //llvm_cerr << "NONTRAPPING USE: " << **UI; + //cerr << "NONTRAPPING USE: " << **UI; return false; } return true; @@ -533,7 +533,7 @@ static bool AllUsesOfLoadedValueWillTrapIfNull(GlobalVariable *GV) { // Ignore stores to the global. } else { // We don't know or understand this user, bail out. - //llvm_cerr << "UNKNOWN USER OF GLOBAL!: " << **UI; + //cerr << "UNKNOWN USER OF GLOBAL!: " << **UI; return false; } @@ -1206,25 +1206,25 @@ bool GlobalOpt::ProcessInternalGlobal(GlobalVariable *GV, if (!AnalyzeGlobal(GV, GS, PHIUsers)) { #if 0 - llvm_cerr << "Global: " << *GV; - llvm_cerr << " isLoaded = " << GS.isLoaded << "\n"; - llvm_cerr << " StoredType = "; + cerr << "Global: " << *GV; + cerr << " isLoaded = " << GS.isLoaded << "\n"; + cerr << " StoredType = "; switch (GS.StoredType) { - case GlobalStatus::NotStored: llvm_cerr << "NEVER STORED\n"; break; - case GlobalStatus::isInitializerStored: llvm_cerr << "INIT STORED\n"; break; - case GlobalStatus::isStoredOnce: llvm_cerr << "STORED ONCE\n"; break; - case GlobalStatus::isStored: llvm_cerr << "stored\n"; break; + case GlobalStatus::NotStored: cerr << "NEVER STORED\n"; break; + case GlobalStatus::isInitializerStored: cerr << "INIT STORED\n"; break; + case GlobalStatus::isStoredOnce: cerr << "STORED ONCE\n"; break; + case GlobalStatus::isStored: cerr << "stored\n"; break; } if (GS.StoredType == GlobalStatus::isStoredOnce && GS.StoredOnceValue) - llvm_cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n"; + cerr << " StoredOnceValue = " << *GS.StoredOnceValue << "\n"; if (GS.AccessingFunction && !GS.HasMultipleAccessingFunctions) - llvm_cerr << " AccessingFunction = " << GS.AccessingFunction->getName() + cerr << " AccessingFunction = " << GS.AccessingFunction->getName() << "\n"; - llvm_cerr << " HasMultipleAccessingFunctions = " + cerr << " HasMultipleAccessingFunctions = " << GS.HasMultipleAccessingFunctions << "\n"; - llvm_cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n"; - llvm_cerr << " isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n"; - llvm_cerr << "\n"; + cerr << " HasNonInstructionUser = " << GS.HasNonInstructionUser<<"\n"; + cerr << " isNotSuitableForSRA = " << GS.isNotSuitableForSRA << "\n"; + cerr << "\n"; #endif // If this is a first class global and has only one accessing function diff --git a/lib/Transforms/IPO/Internalize.cpp b/lib/Transforms/IPO/Internalize.cpp index 3e7dcc67ae..f43a27f698 100644 --- a/lib/Transforms/IPO/Internalize.cpp +++ b/lib/Transforms/IPO/Internalize.cpp @@ -74,8 +74,7 @@ void InternalizePass::LoadFile(const char *Filename) { // Load the APIFile... std::ifstream In(Filename); if (!In.good()) { - llvm_cerr << "WARNING: Internalize couldn't load file '" << Filename - << "'!\n"; + cerr << "WARNING: Internalize couldn't load file '" << Filename << "'!\n"; return; // Do not internalize anything... } while (In) { diff --git a/lib/Transforms/Instrumentation/BlockProfiling.cpp b/lib/Transforms/Instrumentation/BlockProfiling.cpp index af2928b0fc..af438f9655 100644 --- a/lib/Transforms/Instrumentation/BlockProfiling.cpp +++ b/lib/Transforms/Instrumentation/BlockProfiling.cpp @@ -47,8 +47,8 @@ ModulePass *llvm::createFunctionProfilerPass() { bool FunctionProfiler::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { - llvm_cerr << "WARNING: cannot insert function profiling into a module" - << " with no main function!\n"; + cerr << "WARNING: cannot insert function profiling into a module" + << " with no main function!\n"; return false; // No main, no instrumentation! } @@ -90,8 +90,8 @@ ModulePass *llvm::createBlockProfilerPass() { return new BlockProfiler(); } bool BlockProfiler::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { - llvm_cerr << "WARNING: cannot insert block profiling into a module" - << " with no main function!\n"; + cerr << "WARNING: cannot insert block profiling into a module" + << " with no main function!\n"; return false; // No main, no instrumentation! } diff --git a/lib/Transforms/Instrumentation/EdgeProfiling.cpp b/lib/Transforms/Instrumentation/EdgeProfiling.cpp index 40a8faaf50..36cf3e9430 100644 --- a/lib/Transforms/Instrumentation/EdgeProfiling.cpp +++ b/lib/Transforms/Instrumentation/EdgeProfiling.cpp @@ -17,6 +17,7 @@ // //===----------------------------------------------------------------------===// +#include "ProfilingUtils.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -24,7 +25,6 @@ #include "llvm/Support/Streams.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Instrumentation.h" -#include "ProfilingUtils.h" #include using namespace llvm; @@ -42,8 +42,8 @@ ModulePass *llvm::createEdgeProfilerPass() { return new EdgeProfiler(); } bool EdgeProfiler::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { - llvm_cerr << "WARNING: cannot insert edge profiling into a module" - << " with no main function!\n"; + cerr << "WARNING: cannot insert edge profiling into a module" + << " with no main function!\n"; return false; // No main, no instrumentation! } diff --git a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp index 076fa81074..10b3641978 100644 --- a/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp +++ b/lib/Transforms/Instrumentation/TraceBasicBlocks.cpp @@ -13,6 +13,7 @@ // //===----------------------------------------------------------------------===// +#include "ProfilingUtils.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -20,7 +21,6 @@ #include "llvm/Transforms/Utils/BasicBlockUtils.h" #include "llvm/Transforms/Instrumentation.h" #include "llvm/Instructions.h" -#include "ProfilingUtils.h" #include "llvm/Support/Debug.h" #include using namespace llvm; @@ -61,8 +61,8 @@ static void InsertInstrumentationCall (BasicBlock *BB, bool TraceBasicBlocks::runOnModule(Module &M) { Function *Main = M.getMainFunction(); if (Main == 0) { - llvm_cerr << "WARNING: cannot insert basic-block trace instrumentation" - << " into a module with no main function!\n"; + cerr << "WARNING: cannot insert basic-block trace instrumentation" + << " into a module with no main function!\n"; return false; // No main, no instrumentation! } diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 5073bde0ba..4c0bbf4316 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7018,8 +7018,8 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { // If we are removing arguments to the function, emit an obnoxious warning... if (FT->getNumParams() < NumActualArgs) if (!FT->isVarArg()) { - llvm_cerr << "WARNING: While resolving call to function '" - << Callee->getName() << "' arguments were dropped!\n"; + cerr << "WARNING: While resolving call to function '" + << Callee->getName() << "' arguments were dropped!\n"; } else { // Add all of the arguments in their promoted form to the arg list... for (unsigned i = FT->getNumParams(); i != NumActualArgs; ++i, ++AI) { diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index a262cf79fb..66b595fd7f 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -507,12 +507,12 @@ namespace { } void BasedUser::dump() const { - llvm_cerr << " Base=" << *Base; - llvm_cerr << " Imm=" << *Imm; + cerr << " Base=" << *Base; + cerr << " Imm=" << *Imm; if (EmittedBase) - llvm_cerr << " EB=" << *EmittedBase; + cerr << " EB=" << *EmittedBase; - llvm_cerr << " Inst: " << *Inst; + cerr << " Inst: " << *Inst; } Value *BasedUser::InsertCodeForBaseAtPosition(const SCEVHandle &NewBase, diff --git a/lib/Transforms/Scalar/LowerPacked.cpp b/lib/Transforms/Scalar/LowerPacked.cpp index f02c40f4d8..25de5fb24c 100644 --- a/lib/Transforms/Scalar/LowerPacked.cpp +++ b/lib/Transforms/Scalar/LowerPacked.cpp @@ -73,8 +73,7 @@ public: /// @param I the unhandled instruction void visitInstruction(Instruction &I) { if (isa(I.getType())) - llvm_cerr << "Unhandled Instruction with Packed ReturnType: " - << I << '\n'; + cerr << "Unhandled Instruction with Packed ReturnType: " << I << '\n'; } private: /// @brief Retrieves lowered values for a packed value. diff --git a/lib/Transforms/Scalar/SCCP.cpp b/lib/Transforms/Scalar/SCCP.cpp index a5f7db8f6e..5d928c145d 100644 --- a/lib/Transforms/Scalar/SCCP.cpp +++ b/lib/Transforms/Scalar/SCCP.cpp @@ -350,7 +350,7 @@ private: void visitInstruction(Instruction &I) { // If a new instruction is added to LLVM that we don't handle... - llvm_cerr << "SCCP: Don't know how to handle: " << I; + cerr << "SCCP: Don't know how to handle: " << I; markOverdefined(&I); // Just in case } }; @@ -400,7 +400,7 @@ void SCCPSolver::getFeasibleSuccessors(TerminatorInst &TI, Succs[0] = true; } } else { - llvm_cerr << "SCCP: Don't know how to handle: " << TI; + cerr << "SCCP: Don't know how to handle: " << TI; Succs.assign(TI.getNumSuccessors(), true); } } @@ -459,7 +459,7 @@ bool SCCPSolver::isEdgeFeasible(BasicBlock *From, BasicBlock *To) { } return false; } else { - llvm_cerr << "Unknown terminator instruction: " << *TI; + cerr << "Unknown terminator instruction: " << *TI; abort(); } } diff --git a/lib/Transforms/Utils/CodeExtractor.cpp b/lib/Transforms/Utils/CodeExtractor.cpp index 52d53d53e9..a63e4e0407 100644 --- a/lib/Transforms/Utils/CodeExtractor.cpp +++ b/lib/Transforms/Utils/CodeExtractor.cpp @@ -699,10 +699,10 @@ ExtractCodeRegion(const std::vector &code) { } } - //llvm_cerr << "NEW FUNCTION: " << *newFunction; + //cerr << "NEW FUNCTION: " << *newFunction; // verifyFunction(*newFunction); - // llvm_cerr << "OLD FUNCTION: " << *oldFunction; + // cerr << "OLD FUNCTION: " << *oldFunction; // verifyFunction(*oldFunction); DEBUG(if (verifyFunction(*newFunction)) abort()); diff --git a/lib/Transforms/Utils/LowerSwitch.cpp b/lib/Transforms/Utils/LowerSwitch.cpp index 4ad12b9c25..2adfb3ef30 100644 --- a/lib/Transforms/Utils/LowerSwitch.cpp +++ b/lib/Transforms/Utils/LowerSwitch.cpp @@ -96,8 +96,7 @@ bool LowerSwitch::runOnFunction(Function &F) { // operator<< - Used for debugging purposes. // -llvm_ostream& operator<<(llvm_ostream &O, - const std::vector &C) { +OStream& operator<<(OStream &O, const std::vector &C) { O << "["; for (std::vector::const_iterator B = C.begin(), diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 30baed4c64..072fc51d22 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -829,7 +829,7 @@ void AssemblyWriter::printGlobal(const GlobalVariable *GV) { case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; case GlobalValue::ExternalLinkage: break; case GlobalValue::GhostLinkage: - llvm_cerr << "GhostLinkage not allowed in AsmWriter!\n"; + cerr << "GhostLinkage not allowed in AsmWriter!\n"; abort(); } @@ -928,7 +928,7 @@ void AssemblyWriter::printFunction(const Function *F) { case GlobalValue::ExternalWeakLinkage: Out << "extern_weak "; break; case GlobalValue::ExternalLinkage: break; case GlobalValue::GhostLinkage: - llvm_cerr << "GhostLinkage not allowed in AsmWriter!\n"; + cerr << "GhostLinkage not allowed in AsmWriter!\n"; abort(); } @@ -1328,18 +1328,18 @@ void Argument::print(std::ostream &o) const { // Value::dump - allow easy printing of Values from the debugger. // Located here because so much of the needed functionality is here. -void Value::dump() const { print(std::cerr); llvm_cerr << '\n'; } +void Value::dump() const { print(std::cerr); cerr << '\n'; } // Type::dump - allow easy printing of Values from the debugger. // Located here because so much of the needed functionality is here. -void Type::dump() const { print(std::cerr); llvm_cerr << '\n'; } +void Type::dump() const { print(std::cerr); cerr << '\n'; } //===----------------------------------------------------------------------===// // SlotMachine Implementation //===----------------------------------------------------------------------===// #if 0 -#define SC_DEBUG(X) llvm_cerr << X +#define SC_DEBUG(X) cerr << X #else #define SC_DEBUG(X) #endif diff --git a/lib/VMCore/LeakDetector.cpp b/lib/VMCore/LeakDetector.cpp index 4c9f125807..68bf161699 100644 --- a/lib/VMCore/LeakDetector.cpp +++ b/lib/VMCore/LeakDetector.cpp @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Support/Compiler.h" #include "llvm/Support/LeakDetector.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Streams.h" #include "llvm/Value.h" #include @@ -21,12 +21,12 @@ using namespace llvm; namespace { template struct VISIBILITY_HIDDEN PrinterTrait { - static void print(const T* P) { llvm_cerr << P; } + static void print(const T* P) { cerr << P; } }; template<> struct VISIBILITY_HIDDEN PrinterTrait { - static void print(const Value* P) { llvm_cerr << *P; } + static void print(const Value* P) { cerr << *P; } }; template @@ -59,15 +59,14 @@ namespace { assert(Cache == 0 && "No value should be cached anymore!"); if (!Ts.empty()) { - llvm_cerr - << "Leaked " << Name << " objects found: " << Message << ":\n"; + cerr << "Leaked " << Name << " objects found: " << Message << ":\n"; for (typename std::set::iterator I = Ts.begin(), E = Ts.end(); I != E; ++I) { - llvm_cerr << "\t"; + cerr << "\t"; PrinterTrait::print(*I); - llvm_cerr << "\n"; + cerr << "\n"; } - llvm_cerr << '\n'; + cerr << '\n'; return true; } @@ -123,8 +122,8 @@ void LeakDetector::checkForGarbageImpl(const std::string &Message) { // use non-short-circuit version so that both checks are performed if (getObjects().hasGarbage(Message) | getLLVMObjects().hasGarbage(Message)) - llvm_cerr << "\nThis is probably because you removed an object, but didn't " - << "delete it. Please check your code for memory leaks.\n"; + cerr << "\nThis is probably because you removed an object, but didn't " + << "delete it. Please check your code for memory leaks.\n"; // Clear out results so we don't get duplicate warnings on // next call... diff --git a/lib/VMCore/PassManager.cpp b/lib/VMCore/PassManager.cpp index d01ef3e4a7..7fdc62a9ea 100644 --- a/lib/VMCore/PassManager.cpp +++ b/lib/VMCore/PassManager.cpp @@ -442,7 +442,7 @@ bool FunctionPassManager_New::runOnModule(Module &M) { bool FunctionPassManager_New::run(Function &F) { std::string errstr; if (MP->materializeFunction(&F, &errstr)) { - llvm_cerr << "Error reading bytecode file: " << errstr << "\n"; + cerr << "Error reading bytecode file: " << errstr << "\n"; abort(); } return FPM->runOnFunction(F); diff --git a/lib/VMCore/TypeSymbolTable.cpp b/lib/VMCore/TypeSymbolTable.cpp index 7af7bea407..cfd8cbf935 100644 --- a/lib/VMCore/TypeSymbolTable.cpp +++ b/lib/VMCore/TypeSymbolTable.cpp @@ -66,7 +66,7 @@ Type* TypeSymbolTable::erase(iterator Entry) { #if DEBUG_SYMBOL_TABLE dump(); - llvm_cerr << " Removing Value: " << Result->getName() << "\n"; + cerr << " Removing Value: " << Result->getName() << "\n"; #endif tmap.erase(Entry); @@ -75,7 +75,7 @@ Type* TypeSymbolTable::erase(iterator Entry) { // list... if (Result->isAbstract()) { #if DEBUG_ABSTYPE - llvm_cerr << "Removing abstract type from symtab" << Result->getDescription()<<"\n"; + cerr << "Removing abstract type from symtab" << Result->getDescription()<<"\n"; #endif cast(Result)->removeAbstractTypeUser(this); } @@ -95,8 +95,8 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) { #if DEBUG_SYMBOL_TABLE dump(); - llvm_cerr << " Inserting type: " << UniqueName << ": " - << T->getDescription() << "\n"; + cerr << " Inserting type: " << UniqueName << ": " + << T->getDescription() << "\n"; #endif // Insert the tmap entry @@ -106,7 +106,7 @@ void TypeSymbolTable::insert(const std::string& Name, const Type* T) { if (T->isAbstract()) { cast(T)->addAbstractTypeUser(this); #if DEBUG_ABSTYPE - llvm_cerr << "Added abstract type to ST: " << T->getDescription() << "\n"; + cerr << "Added abstract type to ST: " << T->getDescription() << "\n"; #endif } } @@ -152,14 +152,14 @@ void TypeSymbolTable::refineAbstractType(const DerivedType *OldType, for (iterator I = begin(), E = end(); I != E; ++I) { if (I->second == (Type*)OldType) { // FIXME when Types aren't const. #if DEBUG_ABSTYPE - llvm_cerr << "Removing type " << OldType->getDescription() << "\n"; + cerr << "Removing type " << OldType->getDescription() << "\n"; #endif OldType->removeAbstractTypeUser(this); I->second = (Type*)NewType; // TODO FIXME when types aren't const if (NewType->isAbstract()) { #if DEBUG_ABSTYPE - llvm_cerr << "Added type " << NewType->getDescription() << "\n"; + cerr << "Added type " << NewType->getDescription() << "\n"; #endif cast(NewType)->addAbstractTypeUser(this); } @@ -179,13 +179,13 @@ void TypeSymbolTable::typeBecameConcrete(const DerivedType *AbsTy) { } static void DumpTypes(const std::pair& T ) { - llvm_cerr << " '" << T.first << "' = "; + cerr << " '" << T.first << "' = "; T.second->dump(); - llvm_cerr << "\n"; + cerr << "\n"; } void TypeSymbolTable::dump() const { - llvm_cerr << "TypeSymbolPlane: "; + cerr << "TypeSymbolPlane: "; for_each(tmap.begin(), tmap.end(), DumpTypes); } diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 4e43a0cf07..cf812a8fff 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -60,7 +60,6 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" #include -#include #include using namespace llvm; @@ -156,11 +155,11 @@ namespace { // Anonymous namespace for class switch (action) { case AbortProcessAction: msgs << "compilation aborted!\n"; - llvm_cerr << msgs.str(); + cerr << msgs.str(); abort(); case PrintMessageAction: msgs << "verification continues.\n"; - llvm_cerr << msgs.str(); + cerr << msgs.str(); return false; case ReturnStatusAction: msgs << "compilation terminated.\n"; diff --git a/projects/Stacker/tools/stkrc/stkrc.cpp b/projects/Stacker/tools/stkrc/stkrc.cpp index f468330e62..38ed78e02d 100644 --- a/projects/Stacker/tools/stkrc/stkrc.cpp +++ b/projects/Stacker/tools/stkrc/stkrc.cpp @@ -115,7 +115,7 @@ int main(int argc, char **argv) } if (DumpAsm) - llvm_cerr << "Here's the assembly:" << M.get(); + cerr << "Here's the assembly:" << M.get(); if (OutputFilename != "") { // Specified an output filename? if (OutputFilename != "-") { // Not stdout? @@ -163,15 +163,15 @@ int main(int argc, char **argv) throw std::string("error opening ") + OutputFilename + "!"; } - llvm_ostream L(*Out); + OStream L(*Out); WriteBytecodeToFile(M.get(), L); } catch (const ParseError &E) { - llvm_cerr << argv[0] << ": " << E.getMessage() << "\n"; + cerr << argv[0] << ": " << E.getMessage() << "\n"; return 1; } } catch (const std::string& msg ) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; return 1; } diff --git a/tools/bugpoint/OptimizerDriver.cpp b/tools/bugpoint/OptimizerDriver.cpp index 0ec66baddf..8a19739e28 100644 --- a/tools/bugpoint/OptimizerDriver.cpp +++ b/tools/bugpoint/OptimizerDriver.cpp @@ -56,7 +56,7 @@ bool BugDriver::writeProgramToFile(const std::string &Filename, std::ofstream Out(Filename.c_str(), io_mode); if (!Out.good()) return true; try { - llvm_ostream L(Out); + OStream L(Out); WriteBytecodeToFile(M ? M : Program, L, /*compression=*/true); } catch (...) { return true; @@ -74,15 +74,15 @@ void BugDriver::EmitProgressBytecode(const std::string &ID, bool NoFlyer) { // std::string Filename = "bugpoint-" + ID + ".bc"; if (writeProgramToFile(Filename)) { - llvm_cerr << "Error opening file '" << Filename << "' for writing!\n"; + cerr << "Error opening file '" << Filename << "' for writing!\n"; return; } - llvm_cout << "Emitted bytecode to '" << Filename << "'\n"; + cout << "Emitted bytecode to '" << Filename << "'\n"; if (NoFlyer || PassesToRun.empty()) return; - llvm_cout << "\n*** You can reproduce the problem with: "; - llvm_cout << "opt " << Filename << " "; - llvm_cout << getPassesString(PassesToRun) << "\n"; + cout << "\n*** You can reproduce the problem with: "; + cout << "opt " << Filename << " "; + cout << getPassesString(PassesToRun) << "\n"; } int BugDriver::runPassesAsChild(const std::vector &Passes) { @@ -91,7 +91,7 @@ int BugDriver::runPassesAsChild(const std::vector &Passes) { std::ios::binary; std::ofstream OutFile(ChildOutput.c_str(), io_mode); if (!OutFile.good()) { - llvm_cerr << "Error opening bytecode file: " << ChildOutput << "\n"; + cerr << "Error opening bytecode file: " << ChildOutput << "\n"; return 1; } @@ -103,14 +103,13 @@ int BugDriver::runPassesAsChild(const std::vector &Passes) { if (Passes[i]->getNormalCtor()) PM.add(Passes[i]->getNormalCtor()()); else - llvm_cerr << "Cannot create pass yet: " << Passes[i]->getPassName() - << "\n"; + cerr << "Cannot create pass yet: " << Passes[i]->getPassName() << "\n"; } // Check that the module is well formed on completion of optimization PM.add(createVerifierPass()); // Write bytecode out to disk as the last step... - llvm_ostream L(OutFile); + OStream L(OutFile); PM.add(new WriteBytecodePass(&L)); // Run all queued passes. @@ -131,12 +130,12 @@ bool BugDriver::runPasses(const std::vector &Passes, std::string &OutputFilename, bool DeleteOutput, bool Quiet) const { // setup the output file name - llvm_cout << std::flush; + cout << std::flush; sys::Path uniqueFilename("bugpoint-output.bc"); std::string ErrMsg; if (uniqueFilename.makeUnique(true, &ErrMsg)) { - llvm_cerr << getToolName() << ": Error making unique filename: " - << ErrMsg << "\n"; + cerr << getToolName() << ": Error making unique filename: " + << ErrMsg << "\n"; return(1); } OutputFilename = uniqueFilename.toString(); @@ -144,18 +143,18 @@ bool BugDriver::runPasses(const std::vector &Passes, // set up the input file name sys::Path inputFilename("bugpoint-input.bc"); if (inputFilename.makeUnique(true, &ErrMsg)) { - llvm_cerr << getToolName() << ": Error making unique filename: " - << ErrMsg << "\n"; + cerr << getToolName() << ": Error making unique filename: " + << ErrMsg << "\n"; return(1); } std::ios::openmode io_mode = std::ios::out | std::ios::trunc | std::ios::binary; std::ofstream InFile(inputFilename.c_str(), io_mode); if (!InFile.good()) { - llvm_cerr << "Error opening bytecode file: " << inputFilename << "\n"; + cerr << "Error opening bytecode file: " << inputFilename << "\n"; return(1); } - llvm_ostream L(InFile); + OStream L(InFile); WriteBytecodeToFile(Program,L,false); InFile.close(); @@ -207,17 +206,17 @@ bool BugDriver::runPasses(const std::vector &Passes, if (!Quiet) { if (result == 0) - llvm_cout << "Success!\n"; + cout << "Success!\n"; else if (result > 0) - llvm_cout << "Exited with error code '" << result << "'\n"; + cout << "Exited with error code '" << result << "'\n"; else if (result < 0) { if (result == -1) - llvm_cout << "Execute failed: " << ErrMsg << "\n"; + cout << "Execute failed: " << ErrMsg << "\n"; else - llvm_cout << "Crashed with signal #" << abs(result) << "\n"; + cout << "Crashed with signal #" << abs(result) << "\n"; } if (result & 0x01000000) - llvm_cout << "Dumped core\n"; + cout << "Dumped core\n"; } // Was the child successful? @@ -235,8 +234,8 @@ Module *BugDriver::runPassesOn(Module *M, std::string BytecodeResult; if (runPasses(Passes, BytecodeResult, false/*delete*/, true/*quiet*/)) { if (AutoDebugCrashes) { - llvm_cerr << " Error running this sequence of passes" - << " on the input program!\n"; + cerr << " Error running this sequence of passes" + << " on the input program!\n"; delete OldProgram; EmitProgressBytecode("pass-error", false); exit(debugOptimizerCrash()); @@ -250,8 +249,8 @@ Module *BugDriver::runPassesOn(Module *M, Module *Ret = ParseInputFile(BytecodeResult); if (Ret == 0) { - llvm_cerr << getToolName() << ": Error reading bytecode file '" - << BytecodeResult << "'!\n"; + cerr << getToolName() << ": Error reading bytecode file '" + << BytecodeResult << "'!\n"; exit(1); } sys::Path(BytecodeResult).eraseFromDisk(); // No longer need the file on disk diff --git a/tools/gccas/gccas.cpp b/tools/gccas/gccas.cpp index a898d4cd77..2d08f36cc8 100644 --- a/tools/gccas/gccas.cpp +++ b/tools/gccas/gccas.cpp @@ -143,7 +143,7 @@ int main(int argc, char **argv) { ParseError Err; std::auto_ptr M(ParseAssemblyFile(InputFilename,&Err)); if (M.get() == 0) { - llvm_cerr << argv[0] << ": " << Err.getMessage() << "\n"; + cerr << argv[0] << ": " << Err.getMessage() << "\n"; return 1; } @@ -178,7 +178,7 @@ int main(int argc, char **argv) { if (!Out->good()) { - llvm_cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; return 1; } @@ -197,7 +197,7 @@ int main(int argc, char **argv) { Passes.add(createVerifierPass()); // Write bytecode to file... - llvm_ostream L(*Out); + OStream L(*Out); Passes.add(new WriteBytecodePass(&L,false,!NoCompress)); // Run our queue of passes all at once now, efficiently. @@ -206,9 +206,9 @@ int main(int argc, char **argv) { if (Out != &std::cout) delete Out; return 0; } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; } return 1; } diff --git a/tools/gccld/GenerateCode.cpp b/tools/gccld/GenerateCode.cpp index c84c7d3640..13bda75b42 100644 --- a/tools/gccld/GenerateCode.cpp +++ b/tools/gccld/GenerateCode.cpp @@ -123,10 +123,10 @@ static void RemoveEnv(const char * name, char ** const envp) { } static void dumpArgs(const char **args) { - llvm_cerr << *args++; + cerr << *args++; while (*args) - llvm_cerr << ' ' << *args++; - llvm_cerr << '\n' << std::flush; + cerr << ' ' << *args++; + cerr << '\n' << std::flush; } static inline void addPass(PassManager &PM, Pass *P) { @@ -283,7 +283,7 @@ int llvm::GenerateBytecode(Module *M, int StripLevel, bool Internalize, Passes.add(createVerifierPass()); // Add the pass that writes bytecode to the output file... - llvm_ostream L(*Out); + OStream L(*Out); addPass(Passes, new WriteBytecodePass(&L, false, !NoCompress)); // Run our queue of passes all at once now, efficiently. diff --git a/tools/gccld/gccld.cpp b/tools/gccld/gccld.cpp index 46ffac1122..77ab03c027 100644 --- a/tools/gccld/gccld.cpp +++ b/tools/gccld/gccld.cpp @@ -127,7 +127,7 @@ namespace { /// Message - The message to print to standard error. /// static int PrintAndReturn(const char *progname, const std::string &Message) { - llvm_cerr << progname << ": " << Message << "\n"; + cerr << progname << ": " << Message << "\n"; return 1; } @@ -141,11 +141,11 @@ static void EmitShellScript(char **argv) { std::string ErrMsg; sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0]); if (llvmstub.isEmpty()) { - llvm_cerr << "Could not find llvm-stub.exe executable!\n"; + cerr << "Could not find llvm-stub.exe executable!\n"; exit(1); } if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; exit(1); } @@ -326,18 +326,18 @@ int main(int argc, char **argv, char **envp ) { return PrintAndReturn(argv[0], "Failed to find gcc"); // Generate an assembly language file for the bytecode. - if (Verbose) llvm_cout << "Generating Assembly Code\n"; + if (Verbose) cout << "Generating Assembly Code\n"; std::string ErrMsg; if (0 != GenerateAssembly( AssemblyFile.toString(), RealBytecodeOutput, llc, ErrMsg, Verbose)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 2; } - if (Verbose) llvm_cout << "Generating Native Code\n"; + if (Verbose) cout << "Generating Native Code\n"; if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(), LibPaths, Libraries, gcc, envp, LinkAsLibrary, NoInternalize, RPath, SOName, ErrMsg, Verbose) ) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 2; } @@ -366,18 +366,18 @@ int main(int argc, char **argv, char **envp ) { return PrintAndReturn(argv[0], "Failed to find gcc"); // Generate an assembly language file for the bytecode. - if (Verbose) llvm_cout << "Generating C Source Code\n"; + if (Verbose) cout << "Generating C Source Code\n"; std::string ErrMsg; if (0 != GenerateCFile( CFile.toString(), RealBytecodeOutput, llc, ErrMsg, Verbose)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 2; } - if (Verbose) llvm_cout << "Generating Native Code\n"; + if (Verbose) cout << "Generating Native Code\n"; if (0 != GenerateNative(OutputFilename, CFile.toString(), LibPaths, Libraries, gcc, envp, LinkAsLibrary, NoInternalize, RPath, SOName, ErrMsg, Verbose)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 2; } @@ -394,11 +394,11 @@ int main(int argc, char **argv, char **envp ) { // Make the bytecode file readable and directly executable in LLEE std::string ErrMsg; if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } } @@ -406,18 +406,18 @@ int main(int argc, char **argv, char **envp ) { // Make the output, whether native or script, executable as well... std::string ErrMsg; if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } } catch (const char*msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; exitCode = 1; } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; exitCode = 2; } catch (...) { // This really shouldn't happen, but just in case .... - llvm_cerr << argv[0] << ": An unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": An unexpected unknown exception occurred.\n"; exitCode = 3; } diff --git a/tools/llvm-as/llvm-as.cpp b/tools/llvm-as/llvm-as.cpp index c1c0a0c4a9..dd29bc19e8 100644 --- a/tools/llvm-as/llvm-as.cpp +++ b/tools/llvm-as/llvm-as.cpp @@ -62,29 +62,29 @@ int main(int argc, char **argv) { ParseError Err; std::auto_ptr M(ParseAssemblyFile(InputFilename,&Err)); if (M.get() == 0) { - llvm_cerr << argv[0] << ": " << Err.getMessage() << "\n"; + cerr << argv[0] << ": " << Err.getMessage() << "\n"; return 1; } if (!DisableVerify) { std::string Err; if (verifyModule(*M.get(), ReturnStatusAction, &Err)) { - llvm_cerr << argv[0] - << ": assembly parsed, but does not verify as correct!\n"; - llvm_cerr << Err; + cerr << argv[0] + << ": assembly parsed, but does not verify as correct!\n"; + cerr << Err; return 1; } } - if (DumpAsm) llvm_cerr << "Here's the assembly:\n" << *M.get(); + if (DumpAsm) cerr << "Here's the assembly:\n" << *M.get(); if (OutputFilename != "") { // Specified an output filename? if (OutputFilename != "-") { // Not stdout? if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } Out = new std::ofstream(OutputFilename.c_str(), std::ios::out | @@ -110,9 +110,9 @@ int main(int argc, char **argv) { if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } @@ -125,19 +125,19 @@ int main(int argc, char **argv) { } if (!Out->good()) { - llvm_cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; return 1; } if (Force || !CheckBytecodeOutputToConsole(Out,true)) { - llvm_ostream L(*Out); + OStream L(*Out); WriteBytecodeToFile(M.get(), L, !NoCompress); } } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; exitCode = 1; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; exitCode = 1; } diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp index 8d9e9aace0..d2022fd9f8 100644 --- a/tools/llvm-dis/llvm-dis.cpp +++ b/tools/llvm-dis/llvm-dis.cpp @@ -50,11 +50,11 @@ int main(int argc, char **argv) { std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage)); if (M.get() == 0) { - llvm_cerr << argv[0] << ": "; + cerr << argv[0] << ": "; if (ErrorMessage.size()) - llvm_cerr << ErrorMessage << "\n"; + cerr << ErrorMessage << "\n"; else - llvm_cerr << "bytecode didn't read correctly.\n"; + cerr << "bytecode didn't read correctly.\n"; return 1; } @@ -62,8 +62,8 @@ int main(int argc, char **argv) { if (OutputFilename != "-") { // Not stdout? if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists! Sending to standard output.\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists! Sending to standard output.\n"; } else { Out = new std::ofstream(OutputFilename.c_str()); } @@ -83,8 +83,8 @@ int main(int argc, char **argv) { if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists! Sending to standard output.\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists! Sending to standard output.\n"; } else { Out = new std::ofstream(OutputFilename.c_str()); @@ -96,14 +96,14 @@ int main(int argc, char **argv) { } if (!Out->good()) { - llvm_cerr << argv[0] << ": error opening " << OutputFilename - << ": sending to stdout instead!\n"; + cerr << argv[0] << ": error opening " << OutputFilename + << ": sending to stdout instead!\n"; Out = &std::cout; } // All that llvm-dis does is write the assembly to a file. PassManager Passes; - llvm_ostream L(*Out); + OStream L(*Out); Passes.add(new PrintModulePass(&L)); Passes.run(*M.get()); @@ -113,9 +113,9 @@ int main(int argc, char **argv) { } return 0; } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; } return 1; diff --git a/tools/llvm-extract/llvm-extract.cpp b/tools/llvm-extract/llvm-extract.cpp index a6edc721c9..882455fc27 100644 --- a/tools/llvm-extract/llvm-extract.cpp +++ b/tools/llvm-extract/llvm-extract.cpp @@ -55,15 +55,15 @@ int main(int argc, char **argv) { std::auto_ptr M(ParseBytecodeFile(InputFilename)); if (M.get() == 0) { - llvm_cerr << argv[0] << ": bytecode didn't read correctly.\n"; + cerr << argv[0] << ": bytecode didn't read correctly.\n"; return 1; } // Figure out which function we should extract Function *F = M.get()->getNamedFunction(ExtractFunc); if (F == 0) { - llvm_cerr << argv[0] << ": program doesn't contain function named '" - << ExtractFunc << "'!\n"; + cerr << argv[0] << ": program doesn't contain function named '" + << ExtractFunc << "'!\n"; return 1; } @@ -82,9 +82,9 @@ int main(int argc, char **argv) { if (OutputFilename != "-") { // Not stdout? if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } std::ios::openmode io_mode = std::ios::out | std::ios::trunc | @@ -95,7 +95,7 @@ int main(int argc, char **argv) { Out = &std::cout; } - llvm_ostream L(*Out); + OStream L(*Out); Passes.add(new WriteBytecodePass(&L)); // Write bytecode to file... Passes.run(*M.get()); @@ -103,9 +103,9 @@ int main(int argc, char **argv) { delete Out; return 0; } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; } return 1; } diff --git a/tools/llvm-ld/llvm-ld.cpp b/tools/llvm-ld/llvm-ld.cpp index 20ea463633..2e599064a5 100644 --- a/tools/llvm-ld/llvm-ld.cpp +++ b/tools/llvm-ld/llvm-ld.cpp @@ -109,7 +109,7 @@ static std::string progname; /// Message - The message to print to standard error. /// static int PrintAndReturn(const std::string &Message) { - llvm_cerr << progname << ": " << Message << "\n"; + cerr << progname << ": " << Message << "\n"; return 1; } @@ -208,7 +208,7 @@ void GenerateBytecode(Module* M, const std::string& FileName) { sys::RemoveFileOnSignal(sys::Path(FileName)); // Write it out - llvm_ostream L(Out); + OStream L(Out); WriteBytecodeToFile(M, L, !DisableCompression); // Close the bytecode file. @@ -352,12 +352,12 @@ static void EmitShellScript(char **argv) { std::string ErrMsg; sys::Path llvmstub = FindExecutable("llvm-stub.exe", argv[0]); if (llvmstub.isEmpty()) { - llvm_cerr << "Could not find llvm-stub.exe executable!\n"; + cerr << "Could not find llvm-stub.exe executable!\n"; exit(1); } if (0 != sys::CopyFile(sys::Path(OutputFilename), llvmstub, &ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; exit(1); } @@ -520,14 +520,14 @@ int main(int argc, char **argv, char **envp) { sys::Path target(RealBytecodeOutput); target.eraseFromDisk(); if (tmp_output.renamePathOnDisk(target, &ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 2; } } else return PrintAndReturn( "Post-link optimization output is not bytecode"); } else { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 2; } } @@ -556,18 +556,18 @@ int main(int argc, char **argv, char **envp) { return PrintAndReturn("Failed to find gcc"); // Generate an assembly language file for the bytecode. - if (Verbose) llvm_cout << "Generating Assembly Code\n"; + if (Verbose) cout << "Generating Assembly Code\n"; std::string ErrMsg; if (0 != GenerateAssembly(AssemblyFile.toString(), RealBytecodeOutput, llc, ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } - if (Verbose) llvm_cout << "Generating Native Code\n"; + if (Verbose) cout << "Generating Native Code\n"; if (0 != GenerateNative(OutputFilename, AssemblyFile.toString(), LinkItems,gcc,envp,ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } @@ -591,18 +591,18 @@ int main(int argc, char **argv, char **envp) { return PrintAndReturn("Failed to find gcc"); // Generate an assembly language file for the bytecode. - if (Verbose) llvm_cout << "Generating Assembly Code\n"; + if (Verbose) cout << "Generating Assembly Code\n"; std::string ErrMsg; if (0 != GenerateCFile( CFile.toString(), RealBytecodeOutput, llc, ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } - if (Verbose) llvm_cout << "Generating Native Code\n"; + if (Verbose) cout << "Generating Native Code\n"; if (0 != GenerateNative(OutputFilename, CFile.toString(), LinkItems, gcc, envp, ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } @@ -616,26 +616,26 @@ int main(int argc, char **argv, char **envp) { // Make the script executable... std::string ErrMsg; if (sys::Path(OutputFilename).makeExecutableOnDisk(&ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } // Make the bytecode file readable and directly executable in LLEE as well if (sys::Path(RealBytecodeOutput).makeExecutableOnDisk(&ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } if (sys::Path(RealBytecodeOutput).makeReadableOnDisk(&ErrMsg)) { - llvm_cerr << argv[0] << ": " << ErrMsg << "\n"; + cerr << argv[0] << ": " << ErrMsg << "\n"; return 1; } } return 0; } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; } return 1; } diff --git a/tools/llvm-link/llvm-link.cpp b/tools/llvm-link/llvm-link.cpp index 35fce1e1c5..be556d1ed2 100644 --- a/tools/llvm-link/llvm-link.cpp +++ b/tools/llvm-link/llvm-link.cpp @@ -52,24 +52,23 @@ static cl::opt NoCompress("disable-compression", cl::init(false), static inline std::auto_ptr LoadFile(const std::string &FN) { sys::Path Filename; if (!Filename.set(FN)) { - llvm_cerr << "Invalid file name: '" << FN << "'\n"; + cerr << "Invalid file name: '" << FN << "'\n"; return std::auto_ptr(); } std::string ErrorMessage; if (Filename.exists()) { - if (Verbose) llvm_cerr << "Loading '" << Filename.c_str() << "'\n"; + if (Verbose) cerr << "Loading '" << Filename.c_str() << "'\n"; Module* Result = ParseBytecodeFile(Filename.toString(), &ErrorMessage); if (Result) return std::auto_ptr(Result); // Load successful! if (Verbose) { - llvm_cerr << "Error opening bytecode file: '" << Filename.c_str() << "'"; - if (ErrorMessage.size()) llvm_cerr << ": " << ErrorMessage; - llvm_cerr << "\n"; + cerr << "Error opening bytecode file: '" << Filename.c_str() << "'"; + if (ErrorMessage.size()) cerr << ": " << ErrorMessage; + cerr << "\n"; } } else { - llvm_cerr << "Bytecode file: '" << Filename.c_str() - << "' does not exist.\n"; + cerr << "Bytecode file: '" << Filename.c_str() << "' does not exist.\n"; } return std::auto_ptr(); @@ -87,24 +86,23 @@ int main(int argc, char **argv) { std::auto_ptr Composite(LoadFile(InputFilenames[BaseArg])); if (Composite.get() == 0) { - llvm_cerr << argv[0] << ": error loading file '" - << InputFilenames[BaseArg] << "'\n"; + cerr << argv[0] << ": error loading file '" + << InputFilenames[BaseArg] << "'\n"; return 1; } for (unsigned i = BaseArg+1; i < InputFilenames.size(); ++i) { std::auto_ptr M(LoadFile(InputFilenames[i])); if (M.get() == 0) { - llvm_cerr << argv[0] << ": error loading file '" - << InputFilenames[i] << "'\n"; + cerr << argv[0] << ": error loading file '" <good()) { - llvm_cerr << argv[0] << ": error opening '" << OutputFilename << "'!\n"; + cerr << argv[0] << ": error opening '" << OutputFilename << "'!\n"; return 1; } @@ -138,20 +136,20 @@ int main(int argc, char **argv) { } if (verifyModule(*Composite.get())) { - llvm_cerr << argv[0] << ": linked module is broken!\n"; + cerr << argv[0] << ": linked module is broken!\n"; return 1; } - if (Verbose) llvm_cerr << "Writing bytecode...\n"; - llvm_ostream L(*Out); + if (Verbose) cerr << "Writing bytecode...\n"; + OStream L(*Out); WriteBytecodeToFile(Composite.get(), L, !NoCompress); if (Out != &std::cout) delete Out; return 0; } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; } return 1; } diff --git a/tools/llvm-upgrade/llvm-upgrade.cpp b/tools/llvm-upgrade/llvm-upgrade.cpp index d39aa92d12..65ee452e1c 100644 --- a/tools/llvm-upgrade/llvm-upgrade.cpp +++ b/tools/llvm-upgrade/llvm-upgrade.cpp @@ -57,9 +57,9 @@ int main(int argc, char **argv) { if (OutputFilename != "-") { // Not stdout? if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } Out = new std::ofstream(OutputFilename.c_str(), std::ios::out | @@ -84,9 +84,9 @@ int main(int argc, char **argv) { if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } @@ -106,22 +106,22 @@ int main(int argc, char **argv) { } if (!Out->good()) { - llvm_cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; return 1; } if (!In->good()) { - llvm_cerr << argv[0] << ": error opening " << InputFilename << "!\n"; + cerr << argv[0] << ": error opening " << InputFilename << "!\n"; return 1; } UpgradeAssembly(InputFilename, *In, *Out, Debug); } catch (const std::string& caught_message) { - llvm_cerr << argv[0] << ": " << caught_message << "\n"; + cerr << argv[0] << ": " << caught_message << "\n"; exitCode = 1; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; exitCode = 1; } diff --git a/tools/lto/lto.cpp b/tools/lto/lto.cpp index 65fcef62d0..430829712c 100644 --- a/tools/lto/lto.cpp +++ b/tools/lto/lto.cpp @@ -361,7 +361,7 @@ LTO::optimizeModules(const std::string &OutputFilename, std::string tempFileName(FinalOutputPath.c_str()); tempFileName += "0.bc"; std::ofstream Out(tempFileName.c_str(), io_mode); - llvm_ostream L(Out); + OStream L(Out); WriteBytecodeToFile(bigOne, L, true); } @@ -378,17 +378,17 @@ LTO::optimizeModules(const std::string &OutputFilename, std::string ErrMsg; sys::Path TempDir = sys::Path::GetTemporaryDirectory(&ErrMsg); if (TempDir.isEmpty()) { - llvm_cerr << "lto: " << ErrMsg << "\n"; + cerr << "lto: " << ErrMsg << "\n"; return LTO_WRITE_FAILURE; } sys::Path tmpAsmFilePath(TempDir); if (!tmpAsmFilePath.appendComponent("lto")) { - llvm_cerr << "lto: " << ErrMsg << "\n"; + cerr << "lto: " << ErrMsg << "\n"; TempDir.eraseFromDisk(true); return LTO_WRITE_FAILURE; } if (tmpAsmFilePath.createTemporaryFileOnDisk(&ErrMsg)) { - llvm_cerr << "lto: " << ErrMsg << "\n"; + cerr << "lto: " << ErrMsg << "\n"; TempDir.eraseFromDisk(true); return LTO_WRITE_FAILURE; } @@ -415,7 +415,7 @@ LTO::optimizeModules(const std::string &OutputFilename, std::string tempFileName(FinalOutputPath.c_str()); tempFileName += "1.bc"; std::ofstream Out(tempFileName.c_str(), io_mode); - llvm_ostream L(Out); + OStream L(Out); WriteBytecodeToFile(bigOne, L, true); } @@ -445,7 +445,7 @@ LTO::optimizeModules(const std::string &OutputFilename, args.push_back(0); if (sys::Program::ExecuteAndWait(gcc, &args[0], 0, 0, 1, &ErrMsg)) { - llvm_cerr << "lto: " << ErrMsg << "\n"; + cerr << "lto: " << ErrMsg << "\n"; return LTO_ASM_FAILURE; } diff --git a/tools/opt/opt.cpp b/tools/opt/opt.cpp index 6afdc6834a..7d5dd2113d 100644 --- a/tools/opt/opt.cpp +++ b/tools/opt/opt.cpp @@ -87,9 +87,8 @@ struct ModulePassPrinter : public ModulePass { virtual bool runOnModule(Module &M) { if (!Quiet) { - llvm_cout << "Printing analysis '" << PassToPrint->getPassName() - << "':\n"; - getAnalysisID(PassToPrint).print(llvm_cout, &M); + cout << "Printing analysis '" << PassToPrint->getPassName() << "':\n"; + getAnalysisID(PassToPrint).print(cout, &M); } // Get and print pass... @@ -110,11 +109,11 @@ struct FunctionPassPrinter : public FunctionPass { virtual bool runOnFunction(Function &F) { if (!Quiet) { - llvm_cout << "Printing analysis '" << PassToPrint->getPassName() - << "' for function '" << F.getName() << "':\n"; + cout << "Printing analysis '" << PassToPrint->getPassName() + << "' for function '" << F.getName() << "':\n"; } // Get and print pass... - getAnalysisID(PassToPrint).print(llvm_cout, F.getParent()); + getAnalysisID(PassToPrint).print(cout, F.getParent()); return false; } @@ -132,13 +131,12 @@ struct BasicBlockPassPrinter : public BasicBlockPass { virtual bool runOnBasicBlock(BasicBlock &BB) { if (!Quiet) { - llvm_cout << "Printing Analysis info for BasicBlock '" << BB.getName() - << "': Pass " << PassToPrint->getPassName() << ":\n"; + cout << "Printing Analysis info for BasicBlock '" << BB.getName() + << "': Pass " << PassToPrint->getPassName() << ":\n"; } // Get and print pass... - getAnalysisID(PassToPrint).print( - llvm_cout, BB.getParent()->getParent()); + getAnalysisID(PassToPrint).print(cout, BB.getParent()->getParent()); return false; } @@ -172,11 +170,11 @@ int main(int argc, char **argv) { // Load the input module... std::auto_ptr M(ParseBytecodeFile(InputFilename, &ErrorMessage)); if (M.get() == 0) { - llvm_cerr << argv[0] << ": "; + cerr << argv[0] << ": "; if (ErrorMessage.size()) - llvm_cerr << ErrorMessage << "\n"; + cerr << ErrorMessage << "\n"; else - llvm_cerr << "bytecode didn't read correctly.\n"; + cerr << "bytecode didn't read correctly.\n"; return 1; } @@ -186,9 +184,9 @@ int main(int argc, char **argv) { if (OutputFilename != "-") { if (!Force && std::ifstream(OutputFilename.c_str())) { // If force is not specified, make sure not to overwrite a file! - llvm_cerr << argv[0] << ": error opening '" << OutputFilename - << "': file exists!\n" - << "Use -f command line argument to force output\n"; + cerr << argv[0] << ": error opening '" << OutputFilename + << "': file exists!\n" + << "Use -f command line argument to force output\n"; return 1; } std::ios::openmode io_mode = std::ios::out | std::ios::trunc | @@ -196,7 +194,7 @@ int main(int argc, char **argv) { Out = new std::ofstream(OutputFilename.c_str(), io_mode); if (!Out->good()) { - llvm_cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; + cerr << argv[0] << ": error opening " << OutputFilename << "!\n"; return 1; } @@ -227,8 +225,8 @@ int main(int argc, char **argv) { if (PassInf->getNormalCtor()) P = PassInf->getNormalCtor()(); else - llvm_cerr << argv[0] << ": cannot create pass: " - << PassInf->getPassName() << "\n"; + cerr << argv[0] << ": cannot create pass: " + << PassInf->getPassName() << "\n"; if (P) { Passes.add(P); @@ -243,7 +241,7 @@ int main(int argc, char **argv) { } if (PrintEachXForm) - Passes.add(new PrintModulePass(&llvm_cerr)); + Passes.add(new PrintModulePass(&cerr)); } // Check that the module is well formed on completion of optimization @@ -251,7 +249,7 @@ int main(int argc, char **argv) { Passes.add(createVerifierPass()); // Write bytecode out to disk or cout as the last step... - llvm_ostream L(*Out); + OStream L(*Out); if (!NoOutput && !AnalyzeOnly) Passes.add(new WriteBytecodePass(&L, false, !NoCompress)); @@ -261,9 +259,9 @@ int main(int argc, char **argv) { return 0; } catch (const std::string& msg) { - llvm_cerr << argv[0] << ": " << msg << "\n"; + cerr << argv[0] << ": " << msg << "\n"; } catch (...) { - llvm_cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; + cerr << argv[0] << ": Unexpected unknown exception occurred.\n"; } return 1; } -- cgit v1.2.3-70-g09d2 From 1a097e30d39e60303ae2b19f7a56e813f3e3c18e Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 7 Dec 2006 23:41:45 +0000 Subject: Don't use in Streams.h but instead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32340 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Streams.h | 2 +- lib/Debugger/SourceLanguage-Unknown.cpp | 1 + lib/Linker/LinkModules.cpp | 1 + lib/Support/Allocator.cpp | 1 + lib/Support/CommandLine.cpp | 1 + lib/Support/PluginLoader.cpp | 1 + lib/Support/Statistic.cpp | 1 + lib/Support/SystemUtils.cpp | 1 + lib/Target/CBackend/CBackend.cpp | 2 +- lib/Target/CBackend/Writer.cpp | 2 +- lib/Target/SubtargetFeature.cpp | 1 + lib/VMCore/Verifier.cpp | 1 + 12 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/Streams.h b/include/llvm/Support/Streams.h index c4afc86baa..82ffeeb41b 100644 --- a/include/llvm/Support/Streams.h +++ b/include/llvm/Support/Streams.h @@ -15,7 +15,7 @@ #ifndef LLVM_SUPPORT_STREAMS_H #define LLVM_SUPPORT_STREAMS_H -#include +#include namespace llvm { diff --git a/lib/Debugger/SourceLanguage-Unknown.cpp b/lib/Debugger/SourceLanguage-Unknown.cpp index 276ae9fcaf..c5d912adc8 100644 --- a/lib/Debugger/SourceLanguage-Unknown.cpp +++ b/lib/Debugger/SourceLanguage-Unknown.cpp @@ -17,6 +17,7 @@ #include "llvm/Debugger/ProgramInfo.h" #include "llvm/Support/Streams.h" #include +#include using namespace llvm; //===----------------------------------------------------------------------===// diff --git a/lib/Linker/LinkModules.cpp b/lib/Linker/LinkModules.cpp index 71239f7439..8f8aec1abd 100644 --- a/lib/Linker/LinkModules.cpp +++ b/lib/Linker/LinkModules.cpp @@ -25,6 +25,7 @@ #include "llvm/Assembly/Writer.h" #include "llvm/Support/Streams.h" #include "llvm/System/Path.h" +#include using namespace llvm; // Error - Simple wrapper function to conditionally assign to E and return true. diff --git a/lib/Support/Allocator.cpp b/lib/Support/Allocator.cpp index 632b5f7a22..a31b80fcf3 100644 --- a/lib/Support/Allocator.cpp +++ b/lib/Support/Allocator.cpp @@ -14,6 +14,7 @@ #include "llvm/Support/Allocator.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Streams.h" +#include using namespace llvm; //===----------------------------------------------------------------------===// diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 920811a06c..012f759d4f 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include diff --git a/lib/Support/PluginLoader.cpp b/lib/Support/PluginLoader.cpp index 97b253e4eb..3c9de89a42 100644 --- a/lib/Support/PluginLoader.cpp +++ b/lib/Support/PluginLoader.cpp @@ -15,6 +15,7 @@ #include "llvm/Support/PluginLoader.h" #include "llvm/Support/Streams.h" #include "llvm/System/DynamicLibrary.h" +#include #include using namespace llvm; diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index 8c08271235..1b28eed49a 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -26,6 +26,7 @@ #include "llvm/Support/Streams.h" #include "llvm/ADT/StringExtras.h" #include +#include using namespace llvm; // GetLibSupportInfoOutputFile - Return a file stream to print our output on... diff --git a/lib/Support/SystemUtils.cpp b/lib/Support/SystemUtils.cpp index 1d2c1086ae..30b9f8d43d 100644 --- a/lib/Support/SystemUtils.cpp +++ b/lib/Support/SystemUtils.cpp @@ -16,6 +16,7 @@ #include "llvm/Support/SystemUtils.h" #include "llvm/System/Process.h" #include "llvm/System/Program.h" +#include using namespace llvm; bool llvm::CheckBytecodeOutputToConsole(std::ostream* stream_to_check, diff --git a/lib/Target/CBackend/CBackend.cpp b/lib/Target/CBackend/CBackend.cpp index 7c0d433676..3cfd6d0386 100644 --- a/lib/Target/CBackend/CBackend.cpp +++ b/lib/Target/CBackend/CBackend.cpp @@ -42,7 +42,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Config/config.h" #include -#include +#include using namespace llvm; namespace { diff --git a/lib/Target/CBackend/Writer.cpp b/lib/Target/CBackend/Writer.cpp index 7c0d433676..3cfd6d0386 100644 --- a/lib/Target/CBackend/Writer.cpp +++ b/lib/Target/CBackend/Writer.cpp @@ -42,7 +42,7 @@ #include "llvm/Support/MathExtras.h" #include "llvm/Config/config.h" #include -#include +#include using namespace llvm; namespace { diff --git a/lib/Target/SubtargetFeature.cpp b/lib/Target/SubtargetFeature.cpp index 80621232c9..4669e0fdc3 100644 --- a/lib/Target/SubtargetFeature.cpp +++ b/lib/Target/SubtargetFeature.cpp @@ -15,6 +15,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/Support/Streams.h" #include +#include #include #include using namespace llvm; diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index cf812a8fff..2b9bb6b18b 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -60,6 +60,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" #include +#include #include using namespace llvm; -- cgit v1.2.3-70-g09d2 From aed293dfba04b07a867491c11dfff4bf3eb6bddd Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Thu, 1 Feb 2007 01:43:37 +0000 Subject: Add PrintVersionMessage() that tools can use to print version number without exiting program. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33737 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 1 + lib/Support/CommandLine.cpp | 14 +++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 662c935c44..f9cf3be994 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -1281,6 +1281,7 @@ struct extrahelp { extrahelp(const char* help); }; +void PrintVersionMessage(); // This function just prints the help message, exactly the same way as if the // --help option had been given on the command line. // NOTE: THIS FUNCTION TERMINATES THE PROGRAM! diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 012f759d4f..e556d76f96 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -980,9 +980,7 @@ static void (*OverrideVersionPrinter)() = 0; namespace { class VersionPrinter { public: - void operator=(bool OptionWasSpecified) { - if (OptionWasSpecified) { - if (OverrideVersionPrinter == 0) { + void print() { cout << "Low Level Virtual Machine (http://llvm.org/):\n"; cout << " " << PACKAGE_NAME << " version " << PACKAGE_VERSION; #ifdef LLVM_VERSION_INFO @@ -998,6 +996,11 @@ public: cout << " with assertions"; #endif cout << ".\n"; + } + void operator=(bool OptionWasSpecified) { + if (OptionWasSpecified) { + if (OverrideVersionPrinter == 0) { + print(); Options->clear(); // Don't bother making option dtors remove from map. exit(1); } else { @@ -1028,6 +1031,11 @@ void cl::PrintHelpMessage() { NormalPrinter = true; } +/// Utility function for printing version number. +void cl::PrintVersionMessage() { + VersionPrinterInstance.print(); +} + void cl::SetVersionPrinter(void (*func)()) { OverrideVersionPrinter = func; } -- cgit v1.2.3-70-g09d2 From af035f3460f7d758f73987c3f692faf8d6cae062 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 5 Apr 2007 21:58:17 +0000 Subject: remove the dead removeArgument method, rename Options to OptionsMap. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35690 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 1 - lib/Support/CommandLine.cpp | 91 +++++++++++++------------------------- 2 files changed, 30 insertions(+), 62 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index f9cf3be994..8440c97602 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -219,7 +219,6 @@ public: // occurrences of -ArgStr on the command line. // void addArgument(const char *ArgStr); - void removeArgument(const char *ArgStr); // Return the width of the option tag for printing... virtual unsigned getOptionWidth() const = 0; diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index e556d76f96..5fa65d82ba 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -75,12 +75,12 @@ extrahelp::extrahelp(const char *Help) // Basic, shared command line option processing machinery. // -static ManagedStatic > Options; +static ManagedStatic > OptionsMap; static ManagedStatic > PositionalOptions; static Option *getOption(const std::string &Str) { - std::map::iterator I = Options->find(Str); - return I != Options->end() ? I->second : 0; + std::map::iterator I = OptionsMap->find(Str); + return I != OptionsMap->end() ? I->second : 0; } static void AddArgument(const char *ArgName, Option *Opt) { @@ -89,23 +89,31 @@ static void AddArgument(const char *ArgName, Option *Opt) { << ArgName << "' defined more than once!\n"; } else { // Add argument to the argument map! - (*Options)[ArgName] = Opt; + (*OptionsMap)[ArgName] = Opt; } } -// RemoveArgument - It's possible that the argument is no longer in the map if -// options have already been processed and the map has been deleted! -// -static void RemoveArgument(const char *ArgName, Option *Opt) { - if (Options->empty()) return; - -#ifndef NDEBUG - // This disgusting HACK is brought to you courtesy of GCC 3.3.2, which ICE's - // If we pass ArgName directly into getOption here. - std::string Tmp = ArgName; - assert(getOption(Tmp) == Opt && "Arg not in map!"); -#endif - Options->erase(ArgName); +/// LookupOption - Lookup the option specified by the specified option on the +/// command line. If there is a value specified (after an equal sign) return +/// that as well. +static Option *LookupOption(const char *&Arg, const char *&Value) { + while (*Arg == '-') ++Arg; // Eat leading dashes + + const char *ArgEnd = Arg; + while (*ArgEnd && *ArgEnd != '=') + ++ArgEnd; // Scan till end of argument name. + + if (*ArgEnd == '=') // If we have an equals sign... + Value = ArgEnd+1; // Get the value, not the equals + + + if (*Arg == 0) return 0; + + // Look up the option. + std::map &Opts = *OptionsMap; + std::map::iterator I = + Opts.find(std::string(Arg, ArgEnd)); + return (I != Opts.end()) ? I->second : 0; } static inline bool ProvideOption(Option *Handler, const char *ArgName, @@ -276,32 +284,9 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, free (*i); } -/// LookupOption - Lookup the option specified by the specified option on the -/// command line. If there is a value specified (after an equal sign) return -/// that as well. -static Option *LookupOption(const char *&Arg, const char *&Value) { - while (*Arg == '-') ++Arg; // Eat leading dashes - - const char *ArgEnd = Arg; - while (*ArgEnd && *ArgEnd != '=') - ++ArgEnd; // Scan till end of argument name. - - if (*ArgEnd == '=') // If we have an equals sign... - Value = ArgEnd+1; // Get the value, not the equals - - - if (*Arg == 0) return 0; - - // Look up the option. - std::map &Opts = *Options; - std::map::iterator I = - Opts.find(std::string(Arg, ArgEnd)); - return (I != Opts.end()) ? I->second : 0; -} - void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview) { - assert((!Options->empty() || !PositionalOptions->empty()) && + assert((!OptionsMap->empty() || !PositionalOptions->empty()) && "No options specified, or ParseCommandLineOptions called more" " than once!"); sys::Path progname(argv[0]); @@ -314,7 +299,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ProgramOverview = Overview; bool ErrorParsing = false; - std::map &Opts = *Options; + std::map &Opts = *OptionsMap; std::vector &PositionalOpts = *PositionalOptions; // Check out the positional arguments to collect information about them. @@ -665,22 +650,6 @@ void Option::addArgument(const char *ArgStr) { } } -void Option::removeArgument(const char *ArgStr) { - if (ArgStr[0]) - RemoveArgument(ArgStr, this); - - if (getFormattingFlag() == Positional) { - std::vector::iterator I = - std::find(PositionalOptions->begin(), PositionalOptions->end(), this); - assert(I != PositionalOptions->end() && "Arg not registered!"); - PositionalOptions->erase(I); - } else if (getNumOccurrencesFlag() == ConsumeAfter) { - assert(!PositionalOptions->empty() && (*PositionalOptions)[0] == this && - "Arg not registered correctly!"); - PositionalOptions->erase(PositionalOptions->begin()); - } -} - // getValueStr - Get the value description string, using "DefaultMsg" if nothing // has been specified yet. @@ -900,7 +869,7 @@ public: // Copy Options into a vector so we can sort them as we like... std::vector > Opts; - copy(Options->begin(), Options->end(), std::back_inserter(Opts)); + copy(OptionsMap->begin(), OptionsMap->end(), std::back_inserter(Opts)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden Opts.erase(std::remove_if(Opts.begin(), Opts.end(), @@ -955,7 +924,7 @@ public: MoreHelp->clear(); // Halt the program since help information was printed - Options->clear(); // Don't bother making option dtors remove from map. + OptionsMap->clear(); // Don't bother making option dtors remove from map. exit(1); } }; @@ -1001,7 +970,7 @@ public: if (OptionWasSpecified) { if (OverrideVersionPrinter == 0) { print(); - Options->clear(); // Don't bother making option dtors remove from map. + OptionsMap->clear();// Don't bother making option dtors remove from map. exit(1); } else { (*OverrideVersionPrinter)(); -- cgit v1.2.3-70-g09d2 From 9878d6ae3a535e421f69e0c08e27b259ad1bdbdc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 6 Apr 2007 21:06:55 +0000 Subject: rearchitect the registration mechanism used by the command line option stuff. This dramatically reduce the amount of memory allocated by the commandline stuff at static init time, changing it to build local data structures when ParseCommandLineOptions is called. In a dummy empty program that links some llvm libraries, this reduces the number of malloc'd bytes from 4864 to 3360 on entry to main. Most of that memory is now allocated by non-commandline related stuff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35701 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 56 ++++++++----- include/llvm/Support/PassNameParser.h | 1 - lib/Support/CommandLine.cpp | 149 +++++++++++++++++++--------------- 3 files changed, 121 insertions(+), 85 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 4758ff5b39..328aae1c98 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -142,16 +142,18 @@ class Option { virtual enum ValueExpected getValueExpectedFlagDefault() const { return ValueOptional; } + // Out of line virtual function to provide home for the class. virtual void anchor(); - int NumOccurrences; // The number of times specified - int Flags; // Flags for the argument - unsigned Position; // Position of last occurrence of the option + int NumOccurrences; // The number of times specified + int Flags; // Flags for the argument + unsigned Position; // Position of last occurrence of the option + Option *NextRegistered; // Singly linked list of registered options. public: - const char *ArgStr; // The argument string itself (ex: "help", "o") - const char *HelpStr; // The descriptive text message for --help - const char *ValueStr; // String describing what the value of this option is + const char *ArgStr; // The argument string itself (ex: "help", "o") + const char *HelpStr; // The descriptive text message for --help + const char *ValueStr; // String describing what the value of this option is inline enum NumOccurrences getNumOccurrencesFlag() const { return static_cast(Flags & OccurrencesMask); @@ -198,16 +200,17 @@ public: protected: Option(unsigned DefaultFlags) : NumOccurrences(0), Flags(DefaultFlags | NormalFormatting), Position(0), - ArgStr(""), HelpStr(""), ValueStr("") { + NextRegistered(0), ArgStr(""), HelpStr(""), ValueStr("") { assert(getNumOccurrencesFlag() != 0 && getOptionHiddenFlag() != 0 && "Not all default flags specified!"); } public: - // addArgument - Tell the system that this Option subclass will handle all - // occurrences of -ArgStr on the command line. + // addArgument - Register this argument with the commandline system. // - void addArgument(const char *ArgStr); + void addArgument(); + + Option *getNextRegisteredOption() const { return NextRegistered; } // Return the width of the option tag for printing... virtual unsigned getOptionWidth() const = 0; @@ -217,6 +220,8 @@ public: // virtual void printOptionInfo(unsigned GlobalWidth) const = 0; + virtual void getExtraOptionNames(std::vector &OptionNames) {} + // addOccurrence - Wrapper around handleOccurrence that enforces Flags // bool addOccurrence(unsigned pos, const char *ArgName, @@ -379,16 +384,18 @@ struct generic_parser_base { // argstr field should be stable, copy it down now. // hasArgStr = O.hasArgStr(); - + } + + void getExtraOptionNames(std::vector &OptionNames) { // If there has been no argstr specified, that means that we need to add an // argument for every possible option. This ensures that our options are // vectored to us. - // if (!hasArgStr) for (unsigned i = 0, e = getNumOptions(); i != e; ++i) - O.addArgument(getOption(i)); + OptionNames.push_back(getOption(i)); } + enum ValueExpected getValueExpectedFlagDefault() const { // If there is an ArgStr specified, then we are of the form: // @@ -483,6 +490,8 @@ struct basic_parser_impl { // non-template implementation of basic_parser return ValueRequired; } + void getExtraOptionNames(std::vector &OptionNames) {} + void initialize(Option &O) {} // Return the width of the option tag for printing... @@ -772,6 +781,9 @@ class opt : public Option, virtual enum ValueExpected getValueExpectedFlagDefault() const { return Parser.getValueExpectedFlagDefault(); } + virtual void getExtraOptionNames(std::vector &OptionNames) { + return Parser.getExtraOptionNames(OptionNames); + } // Forward printing stuff to the parser... virtual unsigned getOptionWidth() const {return Parser.getOptionWidth(*this);} @@ -780,7 +792,7 @@ class opt : public Option, } void done() { - addArgument(ArgStr); + addArgument(); Parser.initialize(*this); } public: @@ -923,7 +935,10 @@ class list : public Option, public list_storage { virtual enum ValueExpected getValueExpectedFlagDefault() const { return Parser.getValueExpectedFlagDefault(); } - + virtual void getExtraOptionNames(std::vector &OptionNames) { + return Parser.getExtraOptionNames(OptionNames); + } + virtual bool handleOccurrence(unsigned pos, const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val = @@ -943,7 +958,7 @@ class list : public Option, public list_storage { } void done() { - addArgument(ArgStr); + addArgument(); Parser.initialize(*this); } public: @@ -1106,7 +1121,10 @@ class bits : public Option, public bits_storage { virtual enum ValueExpected getValueExpectedFlagDefault() const { return Parser.getValueExpectedFlagDefault(); } - + virtual void getExtraOptionNames(std::vector &OptionNames) { + return Parser.getExtraOptionNames(OptionNames); + } + virtual bool handleOccurrence(unsigned pos, const char *ArgName, const std::string &Arg) { typename ParserClass::parser_data_type Val = @@ -1126,7 +1144,7 @@ class bits : public Option, public bits_storage { } void done() { - addArgument(ArgStr); + addArgument(); Parser.initialize(*this); } public: @@ -1221,7 +1239,7 @@ class alias : public Option { error(": cl::alias must have argument name specified!"); if (AliasFor == 0) error(": cl::alias must have an cl::aliasopt(option) specified!"); - addArgument(ArgStr); + addArgument(); } public: void setAliasFor(Option &O) { diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index 83653aa745..e87e16a21b 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -70,7 +70,6 @@ public: abort(); } addLiteralOption(P->getPassArgument(), P, P->getPassName()); - Opt->addArgument(P->getPassArgument()); } virtual void passEnumerate(const PassInfo *P) { passRegistered(P); } diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 5fa65d82ba..e349eaa514 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -71,32 +71,63 @@ extrahelp::extrahelp(const char *Help) MoreHelp->push_back(Help); } +/// RegisteredOptionList - This is the list of the command line options that +/// have statically constructed themselves. +static Option *RegisteredOptionList = 0; + +void Option::addArgument() { + assert(NextRegistered == 0 && "argument multiply registered!"); + + NextRegistered = RegisteredOptionList; + RegisteredOptionList = this; +} + //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery. // -static ManagedStatic > OptionsMap; -static ManagedStatic > PositionalOptions; - -static Option *getOption(const std::string &Str) { - std::map::iterator I = OptionsMap->find(Str); - return I != OptionsMap->end() ? I->second : 0; -} - -static void AddArgument(const char *ArgName, Option *Opt) { - if (getOption(ArgName)) { - cerr << ProgramName << ": CommandLine Error: Argument '" - << ArgName << "' defined more than once!\n"; - } else { - // Add argument to the argument map! - (*OptionsMap)[ArgName] = Opt; +/// GetOptionInfo - Scan the list of registered options, turning them into data +/// structures that are easier to handle. +static void GetOptionInfo(std::vector &PositionalOpts, + std::map &OptionsMap) { + std::vector OptionNames; + for (Option *O = RegisteredOptionList; O; O = O->getNextRegisteredOption()) { + // If this option wants to handle multiple option names, get the full set. + // This handles enum options like "-O1 -O2" etc. + O->getExtraOptionNames(OptionNames); + if (O->ArgStr[0]) + OptionNames.push_back(O->ArgStr); + + // Handle named options. + for (unsigned i = 0, e = OptionNames.size(); i != e; ++i) { + // Add argument to the argument map! + if (!OptionsMap.insert(std::pair(OptionNames[i], + O)).second) { + cerr << ProgramName << ": CommandLine Error: Argument '" + << OptionNames[0] << "' defined more than once!\n"; + } + } + + OptionNames.clear(); + + // Remember information about positional options. + if (O->getFormattingFlag() == cl::Positional) + PositionalOpts.push_back(O); + else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) { + if (!PositionalOpts.empty() && + PositionalOpts.front()->getNumOccurrencesFlag() == cl::ConsumeAfter) + O->error("Cannot specify more than one option with cl::ConsumeAfter!"); + PositionalOpts.insert(PositionalOpts.begin(), O); + } } } + /// LookupOption - Lookup the option specified by the specified option on the /// command line. If there is a value specified (after an equal sign) return /// that as well. -static Option *LookupOption(const char *&Arg, const char *&Value) { +static Option *LookupOption(const char *&Arg, const char *&Value, + std::map &OptionsMap) { while (*Arg == '-') ++Arg; // Eat leading dashes const char *ArgEnd = Arg; @@ -110,10 +141,9 @@ static Option *LookupOption(const char *&Arg, const char *&Value) { if (*Arg == 0) return 0; // Look up the option. - std::map &Opts = *OptionsMap; std::map::iterator I = - Opts.find(std::string(Arg, ArgEnd)); - return (I != Opts.end()) ? I->second : 0; + OptionsMap.find(std::string(Arg, ArgEnd)); + return I != OptionsMap.end() ? I->second : 0; } static inline bool ProvideOption(Option *Handler, const char *ArgName, @@ -171,27 +201,28 @@ static inline bool isPrefixedOrGrouping(const Option *O) { // otherwise return null. // static Option *getOptionPred(std::string Name, unsigned &Length, - bool (*Pred)(const Option*)) { + bool (*Pred)(const Option*), + std::map &OptionsMap) { - Option *Op = getOption(Name); - if (Op && Pred(Op)) { + std::map::iterator OMI = OptionsMap.find(Name); + if (OMI != OptionsMap.end() && Pred(OMI->second)) { Length = Name.length(); - return Op; + return OMI->second; } if (Name.size() == 1) return 0; do { Name.erase(Name.end()-1, Name.end()); // Chop off the last character... - Op = getOption(Name); + OMI = OptionsMap.find(Name); // Loop while we haven't found an option and Name still has at least two // characters in it (so that the next iteration will not be the empty // string... - } while ((Op == 0 || !Pred(Op)) && Name.size() > 1); + } while ((OMI == OptionsMap.end() || !Pred(OMI->second)) && Name.size() > 1); - if (Op && Pred(Op)) { + if (OMI != OptionsMap.end() && Pred(OMI->second)) { Length = Name.length(); - return Op; // Found one! + return OMI->second; // Found one! } return 0; // No option found! } @@ -286,9 +317,13 @@ void cl::ParseEnvironmentOptions(const char *progName, const char *envVar, void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Overview) { - assert((!OptionsMap->empty() || !PositionalOptions->empty()) && - "No options specified, or ParseCommandLineOptions called more" - " than once!"); + // Process all registered options. + std::vector PositionalOpts; + std::map Opts; + GetOptionInfo(PositionalOpts, Opts); + + assert((!Opts.empty() || !PositionalOpts.empty()) && + "No options specified!"); sys::Path progname(argv[0]); // Copy the program name into ProgName, making sure not to overflow it. @@ -299,9 +334,6 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, ProgramOverview = Overview; bool ErrorParsing = false; - std::map &Opts = *OptionsMap; - std::vector &PositionalOpts = *PositionalOptions; - // Check out the positional arguments to collect information about them. unsigned NumPositionalRequired = 0; @@ -398,7 +430,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // option is another positional argument. If so, treat it as an argument, // otherwise feed it to the eating positional. ArgName = argv[i]+1; - Handler = LookupOption(ArgName, Value); + Handler = LookupOption(ArgName, Value, Opts); if (!Handler || Handler->getFormattingFlag() != cl::Positional) { ProvidePositionalOption(ActivePositionalArg, argv[i], i); continue; // We are done! @@ -406,14 +438,15 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, } else { // We start with a '-', must be an argument... ArgName = argv[i]+1; - Handler = LookupOption(ArgName, Value); + Handler = LookupOption(ArgName, Value, Opts); // Check to see if this "option" is really a prefixed or grouped argument. if (Handler == 0) { std::string RealName(ArgName); if (RealName.size() > 1) { unsigned Length = 0; - Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping); + Option *PGOpt = getOptionPred(RealName, Length, isPrefixedOrGrouping, + Opts); // If the option is a prefixed option, then the value is simply the // rest of the name... so fall through to later processing, by @@ -444,7 +477,7 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, 0, 0, 0, Dummy); // Get the next grouping option... - PGOpt = getOptionPred(RealName, Length, isGrouping); + PGOpt = getOptionPred(RealName, Length, isGrouping, Opts); } while (PGOpt && Length != RealName.size()); Handler = PGOpt; // Ate all of the options. @@ -633,23 +666,6 @@ bool Option::addOccurrence(unsigned pos, const char *ArgName, return handleOccurrence(pos, ArgName, Value); } -// addArgument - Tell the system that this Option subclass will handle all -// occurrences of -ArgStr on the command line. -// -void Option::addArgument(const char *ArgStr) { - if (ArgStr[0]) - AddArgument(ArgStr, this); - - if (getFormattingFlag() == Positional) - PositionalOptions->push_back(this); - else if (getNumOccurrencesFlag() == ConsumeAfter) { - if (!PositionalOptions->empty() && - PositionalOptions->front()->getNumOccurrencesFlag() == ConsumeAfter) - error("Cannot specify more than one option with cl::ConsumeAfter!"); - PositionalOptions->insert(PositionalOptions->begin(), this); - } -} - // getValueStr - Get the value description string, using "DefaultMsg" if nothing // has been specified yet. @@ -867,9 +883,14 @@ public: void operator=(bool Value) { if (Value == false) return; + // Get all the options. + std::vector PositionalOpts; + std::map OptMap; + GetOptionInfo(PositionalOpts, OptMap); + // Copy Options into a vector so we can sort them as we like... std::vector > Opts; - copy(OptionsMap->begin(), OptionsMap->end(), std::back_inserter(Opts)); + copy(OptMap.begin(), OptMap.end(), std::back_inserter(Opts)); // Eliminate Hidden or ReallyHidden arguments, depending on ShowHidden Opts.erase(std::remove_if(Opts.begin(), Opts.end(), @@ -892,15 +913,15 @@ public: cout << "USAGE: " << ProgramName << " [options]"; // Print out the positional options. - std::vector &PosOpts = *PositionalOptions; Option *CAOpt = 0; // The cl::ConsumeAfter option, if it exists... - if (!PosOpts.empty() && PosOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) - CAOpt = PosOpts[0]; - - for (unsigned i = CAOpt != 0, e = PosOpts.size(); i != e; ++i) { - if (PosOpts[i]->ArgStr[0]) - cout << " --" << PosOpts[i]->ArgStr; - cout << " " << PosOpts[i]->HelpStr; + if (!PositionalOpts.empty() && + PositionalOpts[0]->getNumOccurrencesFlag() == ConsumeAfter) + CAOpt = PositionalOpts[0]; + + for (unsigned i = CAOpt != 0, e = PositionalOpts.size(); i != e; ++i) { + if (PositionalOpts[i]->ArgStr[0]) + cout << " --" << PositionalOpts[i]->ArgStr; + cout << " " << PositionalOpts[i]->HelpStr; } // Print the consume after option info if it exists... @@ -924,7 +945,6 @@ public: MoreHelp->clear(); // Halt the program since help information was printed - OptionsMap->clear(); // Don't bother making option dtors remove from map. exit(1); } }; @@ -970,7 +990,6 @@ public: if (OptionWasSpecified) { if (OverrideVersionPrinter == 0) { print(); - OptionsMap->clear();// Don't bother making option dtors remove from map. exit(1); } else { (*OverrideVersionPrinter)(); -- cgit v1.2.3-70-g09d2 From ee2b32082eff7366621ed2ab119deb96b7c26cec Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 7 Apr 2007 05:38:53 +0000 Subject: Fix a bug in my earlier commit which exposed positional options backwards. This fixes llvm-ar. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35727 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index e349eaa514..768bd6c05b 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -91,6 +91,7 @@ void Option::addArgument() { static void GetOptionInfo(std::vector &PositionalOpts, std::map &OptionsMap) { std::vector OptionNames; + Option *CAOpt = 0; // The ConsumeAfter option if it exists. for (Option *O = RegisteredOptionList; O; O = O->getNextRegisteredOption()) { // If this option wants to handle multiple option names, get the full set. // This handles enum options like "-O1 -O2" etc. @@ -114,12 +115,17 @@ static void GetOptionInfo(std::vector &PositionalOpts, if (O->getFormattingFlag() == cl::Positional) PositionalOpts.push_back(O); else if (O->getNumOccurrencesFlag() == cl::ConsumeAfter) { - if (!PositionalOpts.empty() && - PositionalOpts.front()->getNumOccurrencesFlag() == cl::ConsumeAfter) + if (CAOpt) O->error("Cannot specify more than one option with cl::ConsumeAfter!"); - PositionalOpts.insert(PositionalOpts.begin(), O); + CAOpt = O; } } + + if (CAOpt) + PositionalOpts.push_back(CAOpt); + + // Make sure that they are in order of registration not backwards. + std::reverse(PositionalOpts.begin(), PositionalOpts.end()); } -- cgit v1.2.3-70-g09d2 From 159b0a43408e2521110e22e445ec126aaab16788 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 11 Apr 2007 15:35:18 +0000 Subject: Fix PR1318 by reacting appropriately to a mutating option list. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35905 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Support/CommandLine.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'lib/Support/CommandLine.cpp') diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 768bd6c05b..3d30e7a9f5 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -394,6 +394,10 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // the positional args into the PositionalVals list... Option *ActivePositionalArg = 0; + // Keep track of the option list so far so that we can tell if it is ever + // extended. + Option *CurOptionList = RegisteredOptionList; + // Loop over all of the arguments... processing them. bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { @@ -401,6 +405,16 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Value = 0; const char *ArgName = ""; + // If the head of the option list changed, this means that some command line + // option has just been registered or deregistered. This can occur in + // response to things like -load, etc. If this happens, rescan the options. + if (CurOptionList != RegisteredOptionList) { + PositionalOpts.clear(); + Opts.clear(); + GetOptionInfo(PositionalOpts, Opts); + CurOptionList = RegisteredOptionList; + } + // Check to see if this is a positional argument. This argument is // considered to be positional if it doesn't start with '-', if it is "-" // itself, or if we have seen "--" already. -- cgit v1.2.3-70-g09d2 From 69d6f1358ca8c442a65fd8d5900f7296fbb2762d Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 12 Apr 2007 00:36:29 +0000 Subject: improve the patch for PR1318 to also support grouped options with custom handlers (like the pass list). My previous fix only supported *new* command line options, not additions to old ones. This fixes test/Feature/load_module.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35935 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CommandLine.h | 5 +++++ lib/Support/CommandLine.cpp | 19 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 328aae1c98..c31d79f4e6 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -57,6 +57,10 @@ void ParseEnvironmentOptions(const char *progName, const char *envvar, /// CommandLine utilities to print their own version string. void SetVersionPrinter(void (*func)()); + +// MarkOptionsChanged - Internal helper function. +void MarkOptionsChanged(); + //===----------------------------------------------------------------------===// // Flags permitted to be passed to command line arguments // @@ -469,6 +473,7 @@ public: assert(findOption(Name) == Values.size() && "Option already exists!"); Values.push_back(std::make_pair(Name, std::make_pair(static_cast(V),HelpStr))); + MarkOptionsChanged(); } /// removeLiteralOption - Remove the specified option. diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 3d30e7a9f5..2b0798aa77 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -71,6 +71,13 @@ extrahelp::extrahelp(const char *Help) MoreHelp->push_back(Help); } +static bool OptionListChanged = false; + +// MarkOptionsChanged - Internal helper function. +void cl::MarkOptionsChanged() { + OptionListChanged = true; +} + /// RegisteredOptionList - This is the list of the command line options that /// have statically constructed themselves. static Option *RegisteredOptionList = 0; @@ -80,8 +87,10 @@ void Option::addArgument() { NextRegistered = RegisteredOptionList; RegisteredOptionList = this; + MarkOptionsChanged(); } + //===----------------------------------------------------------------------===// // Basic, shared command line option processing machinery. // @@ -394,10 +403,6 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, // the positional args into the PositionalVals list... Option *ActivePositionalArg = 0; - // Keep track of the option list so far so that we can tell if it is ever - // extended. - Option *CurOptionList = RegisteredOptionList; - // Loop over all of the arguments... processing them. bool DashDashFound = false; // Have we read '--'? for (int i = 1; i < argc; ++i) { @@ -405,14 +410,14 @@ void cl::ParseCommandLineOptions(int &argc, char **argv, const char *Value = 0; const char *ArgName = ""; - // If the head of the option list changed, this means that some command line + // If the option list changed, this means that some command line // option has just been registered or deregistered. This can occur in // response to things like -load, etc. If this happens, rescan the options. - if (CurOptionList != RegisteredOptionList) { + if (OptionListChanged) { PositionalOpts.clear(); Opts.clear(); GetOptionInfo(PositionalOpts, Opts); - CurOptionList = RegisteredOptionList; + OptionListChanged = false; } // Check to see if this is a positional argument. This argument is -- cgit v1.2.3-70-g09d2 From 81da02b553b86868637f27b89c6e919c31ed5b51 Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Tue, 22 May 2007 17:14:46 +0000 Subject: Make tail merging the default, except on powerPC. There was no prior art for a target-dependent default with a command-line override; this way should be generally usable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37285 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/Passes.h | 2 +- include/llvm/Support/CommandLine.h | 22 ++++++++++++++++++++++ include/llvm/Target/TargetMachine.h | 8 ++++++++ lib/CodeGen/BranchFolding.cpp | 17 +++++++++++++---- lib/CodeGen/LLVMTargetMachine.cpp | 4 ++-- lib/Support/CommandLine.cpp | 18 ++++++++++++++++++ lib/Target/PowerPC/PPCTargetMachine.cpp | 4 ++++ lib/Target/PowerPC/PPCTargetMachine.h | 1 + 8 files changed, 69 insertions(+), 7 deletions(-) (limited to 'lib/Support/CommandLine.cpp') diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index bd13664852..e7a97cf6bd 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -79,7 +79,7 @@ namespace llvm { /// optimizations to delete branches to branches, eliminate branches to /// successor blocks (creating fall throughs), and eliminating branches over /// branches. - FunctionPass *createBranchFoldingPass(); + FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge); /// IfConverter Pass - This pass performs machine code if conversion. FunctionPass *createIfConverterPass(); diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index c31d79f4e6..08aca8160a 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -544,6 +544,28 @@ public: EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); +//-------------------------------------------------- +// parser +enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE }; +template<> +class parser : public basic_parser { +public: + // parse - Return true on error. + bool parse(Option &O, const char *ArgName, const std::string &Arg, + boolOrDefault &Val); + + enum ValueExpected getValueExpectedFlagDefault() const { + return ValueOptional; + } + + // getValueName - Do not print = at all. + virtual const char *getValueName() const { return 0; } + + // An out-of-line virtual method to provide a 'home' for this class. + virtual void anchor(); +}; + +EXTERN_TEMPLATE_INSTANTIATION(class basic_parser); //-------------------------------------------------- // parser diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index e5fceba522..faf3c35c49 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -185,6 +185,10 @@ public: AssemblyFile, ObjectFile, DynamicLibrary }; + /// DoTailMergeDefault - Whether it is generally a good idea to do this + /// on this target. User flag overrides. + virtual const bool DoTailMergeDefault() const { return true; } + /// addPassesToEmitFile - Add passes to the specified pass manager to get the /// specified file emitted. Typically this will involve several steps of code /// generation. If Fast is set to true, the code generator should emit code @@ -315,6 +319,10 @@ public: MachineCodeEmitter &MCE) { return true; } + + /// DoTailMergeDefault - Whether it is generally a good idea to do this + /// on this target. User flag overrides. + virtual const bool DoTailMergeDefault() const { return true; } }; } // End llvm namespace diff --git a/lib/CodeGen/BranchFolding.cpp b/lib/CodeGen/BranchFolding.cpp index d8ec340692..7cc4c2db79 100644 --- a/lib/CodeGen/BranchFolding.cpp +++ b/lib/CodeGen/BranchFolding.cpp @@ -35,12 +35,19 @@ using namespace llvm; STATISTIC(NumDeadBlocks, "Number of dead blocks removed"); STATISTIC(NumBranchOpts, "Number of branches optimized"); STATISTIC(NumTailMerge , "Number of block tails merged"); -static cl::opt EnableTailMerge("enable-tail-merge", cl::Hidden); - +static cl::opt FlagEnableTailMerge("enable-tail-merge", + cl::init(cl::BOU_UNSET), cl::Hidden); namespace { struct BranchFolder : public MachineFunctionPass { static char ID; - BranchFolder() : MachineFunctionPass((intptr_t)&ID) {} + BranchFolder(bool defaultEnableTailMerge) : + MachineFunctionPass((intptr_t)&ID) { + switch (FlagEnableTailMerge) { + case cl::BOU_UNSET: EnableTailMerge = defaultEnableTailMerge; break; + case cl::BOU_TRUE: EnableTailMerge = true; break; + case cl::BOU_FALSE: EnableTailMerge = false; break; + } + } virtual bool runOnMachineFunction(MachineFunction &MF); virtual const char *getPassName() const { return "Control Flow Optimizer"; } @@ -49,6 +56,7 @@ namespace { bool MadeChange; private: // Tail Merging. + bool EnableTailMerge; bool TailMergeBlocks(MachineFunction &MF); bool TryMergeBlocks(MachineBasicBlock* SuccBB, MachineBasicBlock* PredBB); @@ -79,7 +87,8 @@ static bool CorrectExtraCFGEdges(MachineBasicBlock &MBB, bool isCond, MachineFunction::iterator FallThru); -FunctionPass *llvm::createBranchFoldingPass() { return new BranchFolder(); } +FunctionPass *llvm::createBranchFoldingPass(bool DefaultEnableTailMerge) { + return new BranchFolder(DefaultEnableTailMerge); } /// RemoveDeadBlock - Remove the specified dead machine basic block from the /// function, updating the CFG. diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index 34c45f3135..41f7e199a0 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -78,7 +78,7 @@ LLVMTargetMachine::addPassesToEmitFile(FunctionPassManager &PM, // Branch folding must be run after regalloc and prolog/epilog insertion. if (!Fast) - PM.add(createBranchFoldingPass()); + PM.add(createBranchFoldingPass(DoTailMergeDefault())); // Fold redundant debug labels. PM.add(createDebugLabelFoldingPass()); @@ -181,7 +181,7 @@ bool LLVMTargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM, // Branch folding must be run after regalloc and prolog/epilog insertion. if (!Fast) - PM.add(createBranchFoldingPass()); + PM.add(createBranchFoldingPass(DoTailMergeDefault())); if (addPreEmitPass(PM, Fast) && PrintMachineCode) PM.add(createMachineFunctionPrinterPass(cerr)); diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp index 2b0798aa77..1f5008a3fa 100644 --- a/lib/Support/CommandLine.cpp +++ b/lib/Support/CommandLine.cpp @@ -36,6 +36,7 @@ using namespace cl; // Template instantiations and anchors. // TEMPLATE_INSTANTIATION(class basic_parser); +TEMPLATE_INSTANTIATION(class basic_parser); TEMPLATE_INSTANTIATION(class basic_parser); TEMPLATE_INSTANTIATION(class basic_parser); TEMPLATE_INSTANTIATION(class basic_parser); @@ -50,6 +51,7 @@ TEMPLATE_INSTANTIATION(class opt); void Option::anchor() {} void basic_parser_impl::anchor() {} void parser::anchor() {} +void parser::anchor() {} void parser::anchor() {} void parser::anchor() {} void parser::anchor() {} @@ -767,6 +769,22 @@ bool parser::parse(Option &O, const char *ArgName, return false; } +// parser implementation +// +bool parser::parse(Option &O, const char *ArgName, + const std::string &Arg, boolOrDefault &Value) { + if (Arg == "" || Arg == "true" || Arg == "TRUE" || Arg == "True" || + Arg == "1") { + Value = BOU_TRUE; + } else if (Arg == "false" || Arg == "FALSE" || Arg == "False" || Arg == "0") { + Value = BOU_FALSE; + } else { + return O.error(": '" + Arg + + "' is invalid value for boolean argument! Try 0 or 1"); + } + return false; +} + // parser implementation // bool parser::parse(Option &O, const char *ArgName, diff --git a/lib/Target/PowerPC/PPCTargetMachine.cpp b/lib/Target/PowerPC/PPCTargetMachine.cpp index df3e3d2257..6d5e050773 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.cpp +++ b/lib/Target/PowerPC/PPCTargetMachine.cpp @@ -96,6 +96,10 @@ PPCTargetMachine::PPCTargetMachine(const Module &M, const std::string &FS, setRelocationModel(Reloc::Static); } +/// Override this for PowerPC. Tail merging happily breaks up instruction issue +/// groups, which typically degrades performance. +const bool PPCTargetMachine::DoTailMergeDefault() const { return false; } + PPC32TargetMachine::PPC32TargetMachine(const Module &M, const std::string &FS) : PPCTargetMachine(M, FS, false) { } diff --git a/lib/Target/PowerPC/PPCTargetMachine.h b/lib/Target/PowerPC/PPCTargetMachine.h index a249952aa1..fdf9d35e57 100644 --- a/lib/Target/PowerPC/PPCTargetMachine.h +++ b/lib/Target/PowerPC/PPCTargetMachine.h @@ -73,6 +73,7 @@ public: MachineCodeEmitter &MCE); virtual bool addSimpleCodeEmitter(FunctionPassManager &PM, bool Fast, MachineCodeEmitter &MCE); + virtual const bool DoTailMergeDefault() const; }; /// PPC32TargetMachine - PowerPC 32-bit target machine. -- cgit v1.2.3-70-g09d2