forked from M-Labs/artiq
firmware, compiler: rename rpc functions to be more consistent.
This commit is contained in:
parent
13c6e96760
commit
d04e611232
|
@ -340,11 +340,11 @@ class LLVMIRGenerator:
|
||||||
llty = ll.FunctionType(llvoid, [])
|
llty = ll.FunctionType(llvoid, [])
|
||||||
elif name == "memcmp":
|
elif name == "memcmp":
|
||||||
llty = ll.FunctionType(lli32, [llptr, llptr, lli32])
|
llty = ll.FunctionType(lli32, [llptr, llptr, lli32])
|
||||||
elif name == "send_rpc":
|
elif name == "rpc_send":
|
||||||
llty = ll.FunctionType(llvoid, [lli32, llsliceptr, llptrptr])
|
llty = ll.FunctionType(llvoid, [lli32, llsliceptr, llptrptr])
|
||||||
elif name == "send_async_rpc":
|
elif name == "rpc_send_async":
|
||||||
llty = ll.FunctionType(llvoid, [lli32, llsliceptr, llptrptr])
|
llty = ll.FunctionType(llvoid, [lli32, llsliceptr, llptrptr])
|
||||||
elif name == "recv_rpc":
|
elif name == "rpc_recv":
|
||||||
llty = ll.FunctionType(lli32, [llptr])
|
llty = ll.FunctionType(lli32, [llptr])
|
||||||
elif name == "now":
|
elif name == "now":
|
||||||
llty = lli64
|
llty = lli64
|
||||||
|
@ -359,7 +359,7 @@ class LLVMIRGenerator:
|
||||||
llglobal = ll.Function(self.llmodule, llty, name)
|
llglobal = ll.Function(self.llmodule, llty, name)
|
||||||
if name in ("__artiq_raise", "__artiq_reraise", "llvm.trap"):
|
if name in ("__artiq_raise", "__artiq_reraise", "llvm.trap"):
|
||||||
llglobal.attributes.add("noreturn")
|
llglobal.attributes.add("noreturn")
|
||||||
if name in ("rtio_log", "send_rpc", "send_async_rpc",
|
if name in ("rtio_log", "rpc_send", "rpc_send_async",
|
||||||
"watchdog_set", "watchdog_clear",
|
"watchdog_set", "watchdog_clear",
|
||||||
self.target.print_function):
|
self.target.print_function):
|
||||||
llglobal.attributes.add("nounwind")
|
llglobal.attributes.add("nounwind")
|
||||||
|
@ -1242,10 +1242,10 @@ class LLVMIRGenerator:
|
||||||
self.llbuilder.store(llargslot, llargptr)
|
self.llbuilder.store(llargslot, llargptr)
|
||||||
|
|
||||||
if fun_type.async:
|
if fun_type.async:
|
||||||
self.llbuilder.call(self.llbuiltin("send_async_rpc"),
|
self.llbuilder.call(self.llbuiltin("rpc_send_async"),
|
||||||
[llservice, lltagptr, llargs])
|
[llservice, lltagptr, llargs])
|
||||||
else:
|
else:
|
||||||
self.llbuilder.call(self.llbuiltin("send_rpc"),
|
self.llbuilder.call(self.llbuiltin("rpc_send"),
|
||||||
[llservice, lltagptr, llargs])
|
[llservice, lltagptr, llargs])
|
||||||
|
|
||||||
# Don't waste stack space on saved arguments.
|
# Don't waste stack space on saved arguments.
|
||||||
|
@ -1257,7 +1257,7 @@ class LLVMIRGenerator:
|
||||||
# T result = {
|
# T result = {
|
||||||
# void *ret_ptr = alloca(sizeof(T));
|
# void *ret_ptr = alloca(sizeof(T));
|
||||||
# void *ptr = ret_ptr;
|
# void *ptr = ret_ptr;
|
||||||
# loop: int size = recv_rpc(ptr);
|
# loop: int size = rpc_recv(ptr);
|
||||||
# // Non-zero: Provide `size` bytes of extra storage for variable-length data.
|
# // Non-zero: Provide `size` bytes of extra storage for variable-length data.
|
||||||
# if(size) { ptr = alloca(size); goto loop; }
|
# if(size) { ptr = alloca(size); goto loop; }
|
||||||
# else *(T*)ret_ptr
|
# else *(T*)ret_ptr
|
||||||
|
@ -1278,12 +1278,12 @@ class LLVMIRGenerator:
|
||||||
llphi = self.llbuilder.phi(llslotgen.type, name="rpc.ptr")
|
llphi = self.llbuilder.phi(llslotgen.type, name="rpc.ptr")
|
||||||
llphi.add_incoming(llslotgen, llprehead)
|
llphi.add_incoming(llslotgen, llprehead)
|
||||||
if llunwindblock:
|
if llunwindblock:
|
||||||
llsize = self.llbuilder.invoke(self.llbuiltin("recv_rpc"), [llphi],
|
llsize = self.llbuilder.invoke(self.llbuiltin("rpc_recv"), [llphi],
|
||||||
llheadu, llunwindblock,
|
llheadu, llunwindblock,
|
||||||
name="rpc.size.next")
|
name="rpc.size.next")
|
||||||
self.llbuilder.position_at_end(llheadu)
|
self.llbuilder.position_at_end(llheadu)
|
||||||
else:
|
else:
|
||||||
llsize = self.llbuilder.call(self.llbuiltin("recv_rpc"), [llphi],
|
llsize = self.llbuilder.call(self.llbuiltin("rpc_recv"), [llphi],
|
||||||
name="rpc.size.next")
|
name="rpc.size.next")
|
||||||
lldone = self.llbuilder.icmp_unsigned('==', llsize, ll.Constant(llsize.type, 0),
|
lldone = self.llbuilder.icmp_unsigned('==', llsize, ll.Constant(llsize.type, 0),
|
||||||
name="rpc.done")
|
name="rpc.done")
|
||||||
|
|
|
@ -86,9 +86,9 @@ static mut API: &'static [(&'static str, *const ())] = &[
|
||||||
api!(watchdog_set = ::watchdog_set),
|
api!(watchdog_set = ::watchdog_set),
|
||||||
api!(watchdog_clear = ::watchdog_clear),
|
api!(watchdog_clear = ::watchdog_clear),
|
||||||
|
|
||||||
api!(send_rpc = ::send_rpc),
|
api!(rpc_send = ::rpc_send),
|
||||||
api!(send_async_rpc = ::send_async_rpc),
|
api!(rpc_send_async = ::rpc_send_async),
|
||||||
api!(recv_rpc = ::recv_rpc),
|
api!(rpc_recv = ::rpc_recv),
|
||||||
|
|
||||||
api!(cache_get = ::cache_get),
|
api!(cache_get = ::cache_get),
|
||||||
api!(cache_put = ::cache_put),
|
api!(cache_put = ::cache_put),
|
||||||
|
|
|
@ -121,7 +121,7 @@ extern fn abort() -> ! {
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn send_rpc(service: u32, tag: CSlice<u8>, data: *const *const ()) {
|
extern fn rpc_send(service: u32, tag: CSlice<u8>, data: *const *const ()) {
|
||||||
while !rpc_queue::empty() {}
|
while !rpc_queue::empty() {}
|
||||||
send(&RpcSend {
|
send(&RpcSend {
|
||||||
async: false,
|
async: false,
|
||||||
|
@ -131,7 +131,7 @@ extern fn send_rpc(service: u32, tag: CSlice<u8>, data: *const *const ()) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn send_async_rpc(service: u32, tag: CSlice<u8>, data: *const *const ()) {
|
extern fn rpc_send_async(service: u32, tag: CSlice<u8>, data: *const *const ()) {
|
||||||
while rpc_queue::full() {}
|
while rpc_queue::full() {}
|
||||||
rpc_queue::enqueue(|mut slice| {
|
rpc_queue::enqueue(|mut slice| {
|
||||||
let length = {
|
let length = {
|
||||||
|
@ -153,7 +153,7 @@ extern fn send_async_rpc(service: u32, tag: CSlice<u8>, data: *const *const ())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
extern fn recv_rpc(slot: *mut ()) -> usize {
|
extern fn rpc_recv(slot: *mut ()) -> usize {
|
||||||
send(&RpcRecvRequest(slot));
|
send(&RpcRecvRequest(slot));
|
||||||
recv!(&RpcRecvReply(ref result) => {
|
recv!(&RpcRecvReply(ref result) => {
|
||||||
match result {
|
match result {
|
||||||
|
@ -281,7 +281,7 @@ unsafe fn attribute_writeback(typeinfo: *const ()) {
|
||||||
attributes = attributes.offset(1);
|
attributes = attributes.offset(1);
|
||||||
|
|
||||||
if (*attribute).tag.len() > 0 {
|
if (*attribute).tag.len() > 0 {
|
||||||
send_async_rpc(0, (*attribute).tag, [
|
rpc_send_async(0, (*attribute).tag, [
|
||||||
&object as *const _ as *const (),
|
&object as *const _ as *const (),
|
||||||
&(*attribute).name as *const _ as *const (),
|
&(*attribute).name as *const _ as *const (),
|
||||||
(object as usize + (*attribute).offset) as *const ()
|
(object as usize + (*attribute).offset) as *const ()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
from artiq.language.core import *
|
from artiq.language.core import *
|
||||||
from artiq.language.types import *
|
from artiq.language.types import *
|
||||||
|
|
||||||
# CHECK: call void @send_async_rpc
|
# CHECK: call void @rpc_send_async
|
||||||
|
|
||||||
@rpc(flags={"async"})
|
@rpc(flags={"async"})
|
||||||
def foo():
|
def foo():
|
||||||
|
|
Loading…
Reference in New Issue