When used, these targets end up with calls to undefined functions for all of the various special vector stuff ispc needs to compile ispc programs (masked store, gather, min/max, sqrt, etc.). These targets are not yet useful for anything, but are a step toward having an option to C++ code with calls out to intrinsics. Reorganized the directory structure a bit and put the LLVM bitcode used to define target-specific stuff (as well as some generic built-ins stuff) into a builtins/ directory. Note that for building on Windows, it's now necessary to set a LLVM_VERSION environment variable (with values like LLVM_2_9, LLVM_3_0, LLVM_3_1svn, etc.)
42 lines
1008 B
Python
Executable File
42 lines
1008 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
import sys
|
|
import string
|
|
import re
|
|
import subprocess
|
|
import platform
|
|
import os
|
|
|
|
length=0
|
|
|
|
src=str(sys.argv[1])
|
|
|
|
target = re.sub("builtins/target-", "", src)
|
|
target = re.sub("builtins/", "", target)
|
|
target = re.sub("\.ll$", "", target)
|
|
target = re.sub("\.c$", "", target)
|
|
target = re.sub("-", "_", target)
|
|
|
|
llvm_as="llvm-as"
|
|
if platform.system() == 'Windows' or string.find(platform.system(), "CYGWIN_NT") != -1:
|
|
llvm_as = os.getenv("LLVM_INSTALL_DIR").replace("\\", "/") + "/bin/" + llvm_as
|
|
|
|
try:
|
|
as_out=subprocess.Popen([llvm_as, "-", "-o", "-"], stdout=subprocess.PIPE)
|
|
except IOError:
|
|
print >> sys.stderr, "Couldn't open " + src
|
|
sys.exit(1)
|
|
|
|
print "unsigned char builtins_bitcode_" + target + "[] = {"
|
|
for line in as_out.stdout.readlines():
|
|
length = length + len(line)
|
|
for c in line:
|
|
print ord(c)
|
|
print ", "
|
|
print " 0 };\n\n"
|
|
print "int builtins_bitcode_" + target + "_length = " + str(length) + ";\n"
|
|
|
|
as_out.wait()
|
|
|
|
sys.exit(as_out.returncode)
|