summaryrefslogtreecommitdiff
path: root/utils/TableGen/LLVMCConfigurationEmitter.cpp
diff options
context:
space:
mode:
authorDavid Greene <greened@obbligato.org>2011-07-11 18:25:51 +0000
committerDavid Greene <greened@obbligato.org>2011-07-11 18:25:51 +0000
commitd4a9066c93da9a5aab47ca228d82e796fdec70c0 (patch)
treef4533e3a9fe75aa310bd4682b254a053af0bfd73 /utils/TableGen/LLVMCConfigurationEmitter.cpp
parent7ae0df41422193e65231a0f9526bfe66067c6532 (diff)
downloadllvm-d4a9066c93da9a5aab47ca228d82e796fdec70c0.tar.gz
llvm-d4a9066c93da9a5aab47ca228d82e796fdec70c0.tar.bz2
llvm-d4a9066c93da9a5aab47ca228d82e796fdec70c0.tar.xz
[AVX] Make Inits Foldable
Manage Inits in a FoldingSet. This provides several benefits: - Memory for Inits is properly managed - Duplicate Inits are folded into Flyweights, saving memory - It enforces const-correctness, protecting against certain classes of bugs The above benefits allow Inits to be used in more contexts, which in turn provides more dynamism to TableGen. This enhanced capability will be used by the AVX code generator to a fold common patterns together. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134907 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/TableGen/LLVMCConfigurationEmitter.cpp')
-rw-r--r--utils/TableGen/LLVMCConfigurationEmitter.cpp46
1 files changed, 23 insertions, 23 deletions
diff --git a/utils/TableGen/LLVMCConfigurationEmitter.cpp b/utils/TableGen/LLVMCConfigurationEmitter.cpp
index 090faf5085..91803309cb 100644
--- a/utils/TableGen/LLVMCConfigurationEmitter.cpp
+++ b/utils/TableGen/LLVMCConfigurationEmitter.cpp
@@ -245,7 +245,7 @@ struct OptionDescription {
unsigned Flags;
std::string Help;
unsigned MultiVal;
- Init* InitVal;
+ const Init* InitVal;
OptionDescription(OptionType::OptionType t = OptionType::Switch,
const std::string& n = "",
@@ -589,7 +589,7 @@ Handler GetHandler(FunctionObject* Obj, const DagInit& Dag) {
}
template <class FunctionObject>
-void InvokeDagInitHandler(FunctionObject* Obj, Init* I) {
+void InvokeDagInitHandler(FunctionObject* Obj, const Init* I) {
typedef void (FunctionObject::*Handler) (const DagInit&);
const DagInit& Dag = InitPtrToDag(I);
@@ -658,7 +658,7 @@ public:
/// operator() - Just forwards to the corresponding property
/// handler.
- void operator() (Init* I) {
+ void operator() (const Init* I) {
InvokeDagInitHandler(this, I);
}
@@ -705,10 +705,10 @@ private:
void onInit (const DagInit& d) {
CheckNumberOfArguments(d, 1);
- Init* i = d.getArg(0);
+ const Init* i = d.getArg(0);
const std::string& str = i->getAsString();
- bool correct = optDesc_.isParameter() && dynamic_cast<StringInit*>(i);
+ bool correct = optDesc_.isParameter() && dynamic_cast<const StringInit*>(i);
correct |= (optDesc_.isSwitch() && (str == "true" || str == "false"));
if (!correct)
@@ -821,7 +821,7 @@ void CollectOptionDescriptions (const RecordVector& V,
for (RecordVector::const_iterator B = V.begin(), E = V.end(); B!=E; ++B)
{
// Throws an exception if the value does not exist.
- ListInit* PropList = (*B)->getValueAsListInit("options");
+ const ListInit* PropList = (*B)->getValueAsListInit("options");
// For every option description in this list: invoke AddOption.
std::for_each(PropList->begin(), PropList->end(), AddOption(OptDescs));
@@ -836,8 +836,8 @@ namespace ToolFlags {
struct ToolDescription : public RefCountedBase<ToolDescription> {
std::string Name;
- Init* CmdLine;
- Init* Actions;
+ const Init* CmdLine;
+ const Init* Actions;
StrVector InLanguage;
std::string InFileOption;
std::string OutFileOption;
@@ -903,7 +903,7 @@ public:
}
}
- void operator() (Init* I) {
+ void operator() (const Init* I) {
InvokeDagInitHandler(this, I);
}
@@ -915,9 +915,9 @@ private:
void onActions (const DagInit& d) {
CheckNumberOfArguments(d, 1);
- Init* Case = d.getArg(0);
+ const Init* Case = d.getArg(0);
if (typeid(*Case) != typeid(DagInit) ||
- GetOperatorName(static_cast<DagInit&>(*Case)) != "case")
+ GetOperatorName(static_cast<const DagInit&>(*Case)) != "case")
throw "The argument to (actions) should be a 'case' construct!";
toolDesc_.Actions = Case;
}
@@ -954,7 +954,7 @@ private:
isReallyJoin = true;
}
else {
- Init* I = d.getArg(0);
+ const Init* I = d.getArg(0);
isReallyJoin = InitPtrToBool(I);
}
@@ -1007,7 +1007,7 @@ void CollectToolDescriptions (const RecordVector& Tools,
E = Tools.end(); B!=E; ++B) {
const Record* T = *B;
// Throws an exception if the value does not exist.
- ListInit* PropList = T->getValueAsListInit("properties");
+ const ListInit* PropList = T->getValueAsListInit("properties");
IntrusiveRefCntPtr<ToolDescription>
ToolDesc(new ToolDescription(T->getName()));
@@ -1163,7 +1163,7 @@ void WalkCase(const Init* Case, F1 TestCallback, F2 StatementCallback,
unsigned i = 1;
for (DagInit::const_arg_iterator B = d.arg_begin(), E = d.arg_end();
B != E; ++B) {
- Init* arg = *B;
+ const Init* arg = *B;
if (!even)
{
@@ -1181,8 +1181,8 @@ void WalkCase(const Init* Case, F1 TestCallback, F2 StatementCallback,
}
else
{
- if (dynamic_cast<DagInit*>(arg)
- && GetOperatorName(static_cast<DagInit&>(*arg)) == "case") {
+ if (dynamic_cast<const DagInit*>(arg)
+ && GetOperatorName(static_cast<const DagInit&>(*arg)) == "case") {
// Nested 'case'.
WalkCase(arg, TestCallback, StatementCallback, IndentLevel + Indent1);
}
@@ -1210,7 +1210,7 @@ class ExtractOptionNames {
ActionName == "parameter_equals" || ActionName == "element_in_list") {
CheckNumberOfArguments(Stmt, 1);
- Init* Arg = Stmt.getArg(0);
+ const Init* Arg = Stmt.getArg(0);
if (typeid(*Arg) == typeid(StringInit))
OptionNames_.insert(InitPtrToString(Arg));
}
@@ -1218,7 +1218,7 @@ class ExtractOptionNames {
ActionName == "any_not_empty" || ActionName == "any_empty" ||
ActionName == "not_empty" || ActionName == "empty") {
for (unsigned i = 0, NumArgs = Stmt.getNumArgs(); i < NumArgs; ++i) {
- Init* Arg = Stmt.getArg(i);
+ const Init* Arg = Stmt.getArg(i);
if (typeid(*Arg) == typeid(StringInit))
OptionNames_.insert(InitPtrToString(Arg));
}
@@ -2613,7 +2613,7 @@ void EmitPreprocessOptions (const RecordKeeper& Records,
for (RecordVector::const_iterator B = OptionPreprocessors.begin(),
E = OptionPreprocessors.end(); B!=E; ++B) {
- DagInit* Case = (*B)->getValueAsDag("preprocessor");
+ const DagInit* Case = (*B)->getValueAsDag("preprocessor");
EmitCaseConstructHandler(Case, Indent1,
EmitPreprocessOptionsCallback(OptDecs),
false, OptDecs, O);
@@ -2645,7 +2645,7 @@ public:
}
}
- void operator() (Init* I) {
+ void operator() (const Init* I) {
InvokeDagInitHandler(this, I);
}
@@ -2655,7 +2655,7 @@ private:
CheckNumberOfArguments(d, 2);
const std::string& Lang = InitPtrToString(d.getArg(0));
- Init* Suffixes = d.getArg(1);
+ const Init* Suffixes = d.getArg(1);
// Second argument to lang_to_suffixes is either a single string...
if (typeid(*Suffixes) == typeid(StringInit)) {
@@ -2688,7 +2688,7 @@ void EmitPopulateLanguageMap (const RecordKeeper& Records, raw_ostream& O)
// Call DoEmitPopulateLanguageMap.
for (RecordVector::const_iterator B = LangMaps.begin(),
E = LangMaps.end(); B!=E; ++B) {
- ListInit* LangMap = (*B)->getValueAsListInit("map");
+ const ListInit* LangMap = (*B)->getValueAsListInit("map");
std::for_each(LangMap->begin(), LangMap->end(),
DoEmitPopulateLanguageMap(O));
}
@@ -2947,7 +2947,7 @@ void FillInHookNames(const ToolDescriptions& ToolDescs,
// Look for hook invocations in 'cmd_line'.
if (!D.CmdLine)
continue;
- if (dynamic_cast<StringInit*>(D.CmdLine))
+ if (dynamic_cast<const StringInit*>(D.CmdLine))
// This is a string.
ExtractHookNames(HookNames, OptDescs).operator()(D.CmdLine);
else