Browse files

gen_gccbuiltins cleanup.

  • Loading branch information...
1 parent b0878bf commit 95121115d3f1c479c1da0859ac6c038488fc4cb8 @klickverbot klickverbot committed Oct 14, 2012
Showing with 23 additions and 24 deletions.
  1. +3 −4 CMakeLists.txt
  2. +1 −1 runtime/CMakeLists.txt
  3. +19 −19 utils/gen_gccbuiltins.cpp
View
7 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)
View
2 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"
View
38 utils/gen_gccbuiltins.cpp
@@ -20,22 +20,22 @@ 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')
{
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<string> 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,40 +93,40 @@ 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_) {}
bool operator()(raw_ostream& os, RecordKeeper& records)
{
os << "module ldc.gccbuiltins_";
- os << arch;
+ os << arch;
os << "; \n\nimport core.simd;\n\n";
map<string, Record*> defs = records.getDefs();
-
+
for(
- map<string, Record* >::iterator it = defs.begin();
- it != defs.end();
+ map<string, Record* >::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<char*> 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);
}

0 comments on commit 9512111

Please sign in to comment.