From 0ebceb4e167a933d1f052210c1849aef8c7ec491 Mon Sep 17 00:00:00 2001 From: kai Date: Sun, 14 Oct 2012 21:42:17 +0200 Subject: [PATCH] Make gen_gccbuiltins compilable with LLVM 3.2. --- utils/gen_gccbuiltins.cpp | 51 ++++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index d5aaf485..c1948938 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -8,7 +8,9 @@ #include #include +#if LDC_LLVM_VER < 302 #include +#endif #include #include #include @@ -107,30 +109,36 @@ void processRecord(raw_ostream& os, Record& rec, string arch) os << ");\n\n"; } +std::string arch; + +bool emit(raw_ostream& os, RecordKeeper& records) +{ + os << "module ldc.gccbuiltins_"; + os << arch; + os << "; \n\nimport core.simd;\n\n"; + + map defs = records.getDefs(); + + for( + map::iterator it = defs.begin(); + it != defs.end(); + it++) + { + processRecord(os, *(*it).second, arch); + } + + return false; +} + +#if LDC_LLVM_VER < 302 struct ActionImpl : TableGenAction { - string arch; - ActionImpl(string arch_): arch(arch_) {} - bool operator()(raw_ostream& os, RecordKeeper& records) { - os << "module ldc.gccbuiltins_"; - os << arch; - os << "; \n\nimport core.simd;\n\n"; - - map defs = records.getDefs(); - - for( - map::iterator it = defs.begin(); - it != defs.end(); - it++) - { - processRecord(os, *(*it).second, arch); - } - - return false; + return emit(os, records); } }; +#endif int main(int argc, char** argv) { @@ -153,6 +161,11 @@ int main(int argc, char** argv) args2.push_back(const_cast(oStr.c_str())); cl::ParseCommandLineOptions(args2.size(), &args2[0]); - ActionImpl act(argv[2]); + arch = argv[2]; +#if LDC_LLVM_VER >= 302 + return TableGenMain(argv[0], emit); +#else + ActionImpl act; return TableGenMain(argv[0], act); +#endif }