From 95121115d3f1c479c1da0859ac6c038488fc4cb8 Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Sun, 14 Oct 2012 05:09:15 +0200 Subject: [PATCH] gen_gccbuiltins cleanup. --- CMakeLists.txt | 7 +++---- runtime/CMakeLists.txt | 2 +- utils/gen_gccbuiltins.cpp | 38 +++++++++++++++++++------------------- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 71d5efe9..08a64e8f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,14 +293,13 @@ set_target_properties( ) target_link_libraries(${LDC_EXE} ${LDC_LIB} ${LIBCONFIG++_LIBRARY}) -add_executable(GEN_GCCBUILTINS utils/gen_gccbuiltins.cpp) +add_executable(gen_gccbuiltins utils/gen_gccbuiltins.cpp) set_target_properties( - GEN_GCCBUILTINS PROPERTIES - OUTPUT_NAME gen_gccbuiltins + gen_gccbuiltins PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin COMPILE_FLAGS "${LLVM_CXXFLAGS}" ) -target_link_libraries(GEN_GCCBUILTINS "-lLLVMTableGen -lLLVMSupport -ldl ${LLVM_LDFLAGS}" ${LLVM_LIBRARIES}) +target_link_libraries(gen_gccbuiltins "-lLLVMTableGen -lLLVMSupport -ldl ${LLVM_LDFLAGS}" ${LLVM_LIBRARIES}) # For use by the druntime/Phobos build system. get_target_property(LDC_LOC ${LDC_EXE} LOCATION) diff --git a/runtime/CMakeLists.txt b/runtime/CMakeLists.txt index bbcf5a5e..97e1545a 100644 --- a/runtime/CMakeLists.txt +++ b/runtime/CMakeLists.txt @@ -265,7 +265,7 @@ macro(build_runtime d_flags c_flags ld_flags lib_suffix path_suffix) endforeach(f) if(EXISTS ${RUNTIME_DIR}) - set(GCCBUILTINS "${PROJECT_BINARY_DIR}/gccbuiltins_x86.di") + set(GCCBUILTINS "${PROJECT_BINARY_DIR}/gccbuiltins_x86.di") add_custom_command( OUTPUT ${GCCBUILTINS} COMMAND ${PROJECT_BINARY_DIR}/../bin/gen_gccbuiltins ${GCCBUILTINS} "x86" diff --git a/utils/gen_gccbuiltins.cpp b/utils/gen_gccbuiltins.cpp index 228ce9b4..d5aaf485 100644 --- a/utils/gen_gccbuiltins.cpp +++ b/utils/gen_gccbuiltins.cpp @@ -20,14 +20,14 @@ using namespace llvm; string dtype(Record* rec) { Init* typeInit = rec->getValueInit("VT"); - if(!typeInit) + if(!typeInit) return ""; string type = typeInit->getAsString(); if(type == "iPTR") return "void*"; - + string vec = ""; if(type[0] == 'v') @@ -35,7 +35,7 @@ string dtype(Record* rec) size_t i = 1; while(i != type.size() && type[i] <= '9' && type[i] >= '0') i++; - + vec = type.substr(1, i - 1); type = type.substr(i); } @@ -59,7 +59,7 @@ string dtype(Record* rec) void processRecord(raw_ostream& os, Record& rec, string arch) { if(!rec.getValue("GCCBuiltinName")) - return; + return; string builtinName = rec.getValueAsString("GCCBuiltinName"); string name = rec.getName(); @@ -71,14 +71,14 @@ void processRecord(raw_ostream& os, Record& rec, string arch) replace(name.begin(), name.end(), '_', '.'); name = string("llvm.") + name; - ListInit* paramsList = rec.getValueAsListInit("ParamTypes"); + ListInit* paramsList = rec.getValueAsListInit("ParamTypes"); vector params; for(int i = 0; i < paramsList->getSize(); i++) { string t = dtype(paramsList->getElementAsRecord(i)); - if(t == "") - return; - + if(t == "") + return; + params.push_back(t); } @@ -93,21 +93,21 @@ void processRecord(raw_ostream& os, Record& rec, string arch) return; } else - return; + return; os << "pragma(intrinsic, \"" + name + "\")\n "; os << ret + " " + builtinName + "("; - + if(params.size()) os << params[0]; - + for(int i = 1; i < params.size(); i++) os << ", " << params[i]; os << ");\n\n"; } -struct ActionImpl : TableGenAction +struct ActionImpl : TableGenAction { string arch; ActionImpl(string arch_): arch(arch_) {} @@ -115,18 +115,18 @@ struct ActionImpl : TableGenAction bool operator()(raw_ostream& os, RecordKeeper& records) { os << "module ldc.gccbuiltins_"; - os << arch; + os << arch; os << "; \n\nimport core.simd;\n\n"; map defs = records.getDefs(); - + for( - map::iterator it = defs.begin(); - it != defs.end(); + map::iterator it = defs.begin(); + it != defs.end(); it++) { processRecord(os, *(*it).second, arch); - } + } return false; } @@ -144,7 +144,7 @@ int main(int argc, char** argv) file.appendComponent("llvm"); file.appendComponent("Intrinsics.td"); - string iStr = string("-I=") + string(LLVM_INCLUDEDIR); + string iStr = string("-I=") + string(LLVM_INCLUDEDIR); string oStr = string("-o=") + argv[1]; vector args2(argv, argv + 1); @@ -154,5 +154,5 @@ int main(int argc, char** argv) cl::ParseCommandLineOptions(args2.size(), &args2[0]); ActionImpl act(argv[2]); - return TableGenMain(argv[0], act); + return TableGenMain(argv[0], act); }