forked from M-Labs/artiq
1
0
Fork 0

Always load the personality library in JIT testbench, if available.

This commit is contained in:
whitequark 2015-07-27 04:44:40 +03:00
parent 14c7b15785
commit 47f13bf921
9 changed files with 20 additions and 16 deletions

View File

@ -1,5 +1,4 @@
import sys, fileinput import os, sys, fileinput, ctypes
from ctypes import CFUNCTYPE
from pythonparser import diagnostic from pythonparser import diagnostic
from llvmlite import binding as llvm from llvmlite import binding as llvm
from .. import Module from .. import Module
@ -10,10 +9,9 @@ llvm.initialize_native_asmprinter()
llvm.check_jit_execution() llvm.check_jit_execution()
def main(): def main():
while sys.argv[1].startswith("+"): libartiq_personality = os.getenv('LIBARTIQ_PERSONALITY')
if sys.argv[1] == "+load": if libartiq_personality is not None:
llvm.load_library_permanently(sys.argv[2]) llvm.load_library_permanently(libartiq_personality)
del sys.argv[1:3]
def process_diagnostic(diag): def process_diagnostic(diag):
print("\n".join(diag.render())) print("\n".join(diag.render()))
@ -34,7 +32,7 @@ def main():
lljit = llvm.create_mcjit_compiler(llparsedmod, llmachine) lljit = llvm.create_mcjit_compiler(llparsedmod, llmachine)
lljit.finalize_object() lljit.finalize_object()
llmain = lljit.get_pointer_to_global(llparsedmod.get_function(llmod.name + ".__modinit__")) llmain = lljit.get_pointer_to_global(llparsedmod.get_function(llmod.name + ".__modinit__"))
CFUNCTYPE(None)(llmain)() ctypes.CFUNCTYPE(None)(llmain)()
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -789,7 +789,7 @@ class ARTIQIRGenerator(algorithm.Visitor):
lambda: self.alloc_exn(builtins.TValueError(), lambda: self.alloc_exn(builtins.TValueError(),
ir.Constant("slice size {0} is larger than iterable length {1}", ir.Constant("slice size {0} is larger than iterable length {1}",
builtins.TStr()), builtins.TStr()),
slice_size, iterable_len)) slice_size, length))
if self.current_assign is None: if self.current_assign is None:
is_neg_size = self.append(ir.Compare(ast.Lt(loc=None), is_neg_size = self.append(ir.Compare(ast.Lt(loc=None),

View File

@ -103,6 +103,8 @@ class LLVMIRGenerator:
linkage = "private" linkage = "private"
unnamed_addr = True unnamed_addr = True
llconst = self.llmodule.get_global(name)
if llconst is None:
llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes)) llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes))
llconst = ll.GlobalVariable(self.llmodule, llstrty, name) llconst = ll.GlobalVariable(self.llmodule, llstrty, name)
llconst.global_constant = True llconst.global_constant = True

View File

@ -1,4 +1,4 @@
# RUN: %python -m artiq.compiler.testbench.jit +load %personality %s # RUN: %python -m artiq.compiler.testbench.jit %s
# REQUIRES: exceptions # REQUIRES: exceptions
1/0 1/0

View File

@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s # RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s # RUN: %python %s
# REQUIRES: exceptions
assert -(-1) == 1 assert -(-1) == 1
assert -(-1.0) == 1.0 assert -(-1.0) == 1.0

View File

@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s # RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s # RUN: %python %s
# REQUIRES: exceptions
assert bool() is False assert bool() is False
# bool(x) is tested in bool.py # bool(x) is tested in bool.py

View File

@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s # RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s # RUN: %python %s
# REQUIRES: exceptions
[x, y] = [1, 2] [x, y] = [1, 2]
assert (x, y) == (1, 2) assert (x, y) == (1, 2)

View File

@ -1,5 +1,6 @@
# RUN: %python -m artiq.compiler.testbench.jit %s # RUN: %python -m artiq.compiler.testbench.jit %s
# RUN: %python %s # RUN: %python %s
# REQUIRES: exceptions
lst = list(range(10)) lst = list(range(10))
assert lst[0] == 0 assert lst[0] == 0

View File

@ -18,6 +18,6 @@ if os.name == 'posix':
lit_config.fatal("Unable to build JIT support library") lit_config.fatal("Unable to build JIT support library")
personality_lib = os.path.join(personality_build, 'libartiq_personality.so') personality_lib = os.path.join(personality_build, 'libartiq_personality.so')
config.substitutions.append( ('%personality', personality_lib) ) config.environment['LIBARTIQ_PERSONALITY'] = personality_lib
config.available_features.add('exceptions') config.available_features.add('exceptions')