2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 19:28:26 +08:00

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

View File

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

View File

@ -103,12 +103,14 @@ class LLVMIRGenerator:
linkage = "private"
unnamed_addr = True
llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes))
llconst = ll.GlobalVariable(self.llmodule, llstrty, name)
llconst.global_constant = True
llconst.initializer = ll.Constant(llstrty, bytearray(as_bytes))
llconst.linkage = linkage
llconst.unnamed_addr = unnamed_addr
llconst = self.llmodule.get_global(name)
if llconst is None:
llstrty = ll.ArrayType(ll.IntType(8), len(as_bytes))
llconst = ll.GlobalVariable(self.llmodule, llstrty, name)
llconst.global_constant = True
llconst.initializer = ll.Constant(llstrty, bytearray(as_bytes))
llconst.linkage = linkage
llconst.unnamed_addr = unnamed_addr
return llconst.bitcast(ll.IntType(8).as_pointer())
else:

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
1/0

View File

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

View File

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

View File

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

View File

@ -18,6 +18,6 @@ if os.name == 'posix':
lit_config.fatal("Unable to build JIT support library")
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')