pub struct Call {
pub target: CallTarget,
pub args: Vec<Value>,
pub gc: Vec<Value>,
pub attrs: Attrs,
}Expand description
A call: target, arguments, the GC references it relocates, and call-site attributes.
A call is a safepoint unless it is nogc (at the site or by the callee’s
declaration). Every ref value (and every pointer derived from one) that is
needed after a safepoint must be listed in gc; the call then defines one
relocated ref per entry, after its return values. Using the old value after
the safepoint is invalid. A nogc call must have an empty gc list.
§Examples
use ir_lang::{Attrs, Call, FuncId, Value};
let c = Call::direct(FuncId::from_u32(1), &[Value::from_u32(0)]).with_attrs(Attrs::NOUNWIND);
assert_eq!(c.args.len(), 1);
assert!(c.gc.is_empty());Fields§
§target: CallTargetWhat is called.
args: Vec<Value>The arguments, matching the callee’s parameters.
gc: Vec<Value>The ref values relocated by this safepoint.
attrs: AttrsCall-site attributes.
Implementations§
Source§impl Call
impl Call
Sourcepub fn direct(func: FuncId, args: &[Value]) -> Call
pub fn direct(func: FuncId, args: &[Value]) -> Call
A direct call with no GC list and no attributes.
§Examples
use ir_lang::{Call, FuncId};
assert!(Call::direct(FuncId::from_u32(0), &[]).args.is_empty());Sourcepub fn indirect(sig: SigId, callee: Value, args: &[Value]) -> Call
pub fn indirect(sig: SigId, callee: Value, args: &[Value]) -> Call
An indirect call through callee with signature sig.
§Examples
use ir_lang::{Call, SigId, Value};
let c = Call::indirect(SigId::from_u32(0), Value::from_u32(2), &[]);
assert!(c.args.is_empty());Sourcepub fn with_gc(self, gc: &[Value]) -> Call
pub fn with_gc(self, gc: &[Value]) -> Call
The same call relocating the given ref values.
§Examples
use ir_lang::{Call, FuncId, Value};
let c = Call::direct(FuncId::from_u32(0), &[]).with_gc(&[Value::from_u32(3)]);
assert_eq!(c.gc.len(), 1);Sourcepub fn with_attrs(self, attrs: Attrs) -> Call
pub fn with_attrs(self, attrs: Attrs) -> Call
The same call with the given call-site attributes.
§Examples
use ir_lang::{Attrs, Call, FuncId};
let c = Call::direct(FuncId::from_u32(0), &[]).with_attrs(Attrs::COLD);
assert!(c.attrs.contains(Attrs::COLD));