forked from M-Labs/artiq
1
0
Fork 0

Bring back target print function.

This commit is contained in:
whitequark 2016-03-18 04:42:06 +00:00
parent ac5061c205
commit f4ab507ab2
4 changed files with 8 additions and 2 deletions

View File

@ -47,4 +47,5 @@ def globals():
# ARTIQ utility functions
"rtio_log": builtins.fn_rtio_log(),
"core_log": builtins.fn_print(),
}

View File

@ -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"

View File

@ -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.

View File

@ -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},