[llvm-commits] [llvm] r111620 - in /llvm/trunk: tools/llvmc/examples/mcc16/Hooks.cpp utils/TableGen/LLVMCConfigurationEmitter.cpp
Mikhail Glushenkov
foldr at codedgers.com
Fri Aug 20 04:24:51 PDT 2010
Author: foldr
Date: Fri Aug 20 06:24:51 2010
New Revision: 111620
URL: http://llvm.org/viewvc/llvm-project?rev=111620&view=rev
Log:
llvmc: Do not prefix option names with AutoGenerated.
Since they now live in the namespace 'autogenerated'.
Modified:
llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp
llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
Modified: llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp?rev=111620&r1=111619&r2=111620&view=diff
==============================================================================
--- llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp (original)
+++ llvm/trunk/tools/llvmc/examples/mcc16/Hooks.cpp Fri Aug 20 06:24:51 2010
@@ -8,7 +8,7 @@
extern char *ProgramName;
namespace autogenerated {
- extern llvm::cl::opt<std::string> AutoGeneratedParameter_p;
+ extern llvm::cl::opt<std::string> Parameter_p;
}
}
@@ -32,10 +32,10 @@
std::string
GetLowerCasePartDefine(void) {
std::string Partname;
- if (autogenerated::AutoGeneratedParameter_p.empty()) {
+ if (autogenerated::Parameter_p.empty()) {
Partname = "16f1xxx";
} else {
- Partname = autogenerated::AutoGeneratedParameter_p;
+ Partname = autogenerated::Parameter_p;
}
std::string LowerCase;
@@ -49,10 +49,10 @@
std::string
GetUpperCasePartDefine(void) {
std::string Partname;
- if (autogenerated::AutoGeneratedParameter_p.empty()) {
+ if (autogenerated::Parameter_p.empty()) {
Partname = "16f1xxx";
} else {
- Partname = autogenerated::AutoGeneratedParameter_p;
+ Partname = autogenerated::Parameter_p;
}
std::string UpperCase;
Modified: llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp?rev=111620&r1=111619&r2=111620&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/LLVMCConfigurationEmitter.cpp Fri Aug 20 06:24:51 2010
@@ -49,7 +49,7 @@
const char * const DefaultHelpString = "NO HELP MESSAGE PROVIDED";
// Name for the "sink" option.
-const char * const SinkOptionName = "AutoGeneratedSinkOption";
+const char * const SinkOptionName = "SinkOption";
//===----------------------------------------------------------------------===//
/// Helper functions
@@ -261,7 +261,13 @@
/// GenVariableName - Returns the variable name used in the
/// generated C++ code.
- std::string GenVariableName() const;
+ std::string GenVariableName() const
+ { return "autogenerated::" + GenOptionType() + EscapeVariableName(Name); }
+
+ /// GenPlainVariableName - Returns the variable name without the namespace
+ /// prefix.
+ std::string GenPlainVariableName() const
+ { return GenOptionType() + EscapeVariableName(Name); }
/// Merge - Merge two option descriptions.
void Merge (const OptionDescription& other);
@@ -315,6 +321,10 @@
{ return (OptionType::IsList(this->Type)
&& !OptionType::IsSwitchList(this->Type)); }
+private:
+
+ // GenOptionType - Helper function used by GenVariableName().
+ std::string GenOptionType() const;
};
void OptionDescription::CheckConsistency() const {
@@ -428,22 +438,21 @@
}
}
-std::string OptionDescription::GenVariableName() const {
- const std::string& EscapedName = EscapeVariableName(Name);
+std::string OptionDescription::GenOptionType() const {
switch (Type) {
case OptionType::Alias:
- return "AutoGeneratedAlias_" + EscapedName;
+ return "Alias_";
case OptionType::PrefixList:
case OptionType::ParameterList:
- return "AutoGeneratedList_" + EscapedName;
+ return "List_";
case OptionType::Switch:
- return "AutoGeneratedSwitch_" + EscapedName;
+ return "Switch_";
case OptionType::SwitchList:
- return "AutoGeneratedSwitchList_" + EscapedName;
+ return "SwitchList_";
case OptionType::Prefix:
case OptionType::Parameter:
default:
- return "AutoGeneratedParameter_" + EscapedName;
+ return "Parameter_";
}
}
@@ -2210,13 +2219,15 @@
O.indent(Indent2) << "}\n\n";
// Handle the Sink property.
+ std::string SinkOption("autogenerated::");
+ SinkOption += SinkOptionName;
if (D.isSink()) {
- O.indent(Indent2) << "if (!" << SinkOptionName << ".empty()) {\n";
+ O.indent(Indent2) << "if (!" << SinkOption << ".empty()) {\n";
O.indent(Indent3) << "for (cl::list<std::string>::iterator B = "
- << SinkOptionName << ".begin(), E = " << SinkOptionName
+ << SinkOption << ".begin(), E = " << SinkOption
<< ".end(); B != E; ++B)\n";
- O.indent(Indent4) << "vec.push_back(std::make_pair(" << SinkOptionName
- << ".getPosition(B - " << SinkOptionName
+ O.indent(Indent4) << "vec.push_back(std::make_pair(" << SinkOption
+ << ".getPosition(B - " << SinkOption
<< ".begin()), *B));\n";
O.indent(Indent2) << "}\n";
}
@@ -2365,7 +2376,7 @@
}
O << val.GenTypeDeclaration() << ' '
- << val.GenVariableName();
+ << val.GenPlainVariableName();
O << "(\"" << val.Name << "\"\n";
@@ -2427,7 +2438,7 @@
// Emit the sink option.
if (HasSink)
- O << "cl" << "::list<std::string> " << SinkOptionName << "(cl::Sink);\n";
+ O << "cl::list<std::string> " << SinkOptionName << "(cl::Sink);\n";
O << '\n';
}
More information about the llvm-commits
mailing list