diff --git a/artiq/compiler/prelude.py b/artiq/compiler/prelude.py index c1828b4ba..98dd02ff0 100644 --- a/artiq/compiler/prelude.py +++ b/artiq/compiler/prelude.py @@ -47,4 +47,5 @@ def globals(): # ARTIQ utility functions "rtio_log": builtins.fn_rtio_log(), + "core_log": builtins.fn_print(), } diff --git a/artiq/compiler/targets.py b/artiq/compiler/targets.py index dcd66a86a..de067d59c 100644 --- a/artiq/compiler/targets.py +++ b/artiq/compiler/targets.py @@ -73,6 +73,7 @@ class Target: triple = "unknown" data_layout = "" features = [] + print_function = "printf" def __init__(self): @@ -195,3 +196,4 @@ class OR1KTarget(Target): triple = "or1k-linux" data_layout = "E-m:e-p:32:32-i64:32-f64:32-v64:32-v128:32-a:0:32-n32" features = ["mul", "div", "ffl1", "cmov", "addc"] + print_function = "core_log" diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index c59e16689..e830235c1 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -358,7 +358,7 @@ class LLVMIRGenerator: llty = ll.FunctionType(llptr, []) elif name == "llvm.stackrestore": llty = ll.FunctionType(llvoid, [llptr]) - elif name == "printf": + elif name == self.target.print_function: llty = ll.FunctionType(llvoid, [llptr], var_arg=True) elif name == "rtio_log": llty = ll.FunctionType(llvoid, [lli64, llptr], var_arg=True) @@ -904,7 +904,8 @@ class LLVMIRGenerator: elif insn.op in ("printf", "rtio_log"): # We only get integers, floats, pointers and strings here. llargs = map(self.map, insn.operands) - return self.llbuilder.call(self.llbuiltin(insn.op), llargs, + func_name = self.target.print_function if insn.op == "printf" else insn.op + return self.llbuilder.call(self.llbuiltin(func_name), llargs, name=insn.name) elif insn.op == "exncast": # This is an identity cast at LLVM IR level. diff --git a/artiq/runtime/ksupport.c b/artiq/runtime/ksupport.c index b61f956ee..54f9213f7 100644 --- a/artiq/runtime/ksupport.c +++ b/artiq/runtime/ksupport.c @@ -97,6 +97,8 @@ static const struct symbol runtime_exports[] = { {"abort", &ksupport_abort}, /* proxified syscalls */ + {"core_log", &core_log}, + {"now", &now}, {"watchdog_set", &watchdog_set},