Enum cranelift_codegen::ir::LibCall
source · pub enum LibCall {
Show 17 variants
Probestack,
CeilF32,
CeilF64,
FloorF32,
FloorF64,
TruncF32,
TruncF64,
NearestF32,
NearestF64,
FmaF32,
FmaF64,
Memcpy,
Memset,
Memmove,
Memcmp,
ElfTlsGetAddr,
ElfTlsGetOffset,
}Expand description
The name of a runtime library routine.
Runtime library calls are generated for Cranelift IR instructions that don’t have an equivalent
ISA instruction or an easy macro expansion. A LibCall is used as a well-known name to refer to
the runtime library routine. This way, Cranelift doesn’t have to know about the naming
convention in the embedding VM’s runtime library.
This list is likely to grow over time.
Variants§
Probestack
probe for stack overflow. These are emitted for functions which need
when the enable_probestack setting is true.
CeilF32
ceil.f32
CeilF64
ceil.f64
FloorF32
floor.f32
FloorF64
floor.f64
TruncF32
trunc.f32
TruncF64
frunc.f64
NearestF32
nearest.f32
NearestF64
nearest.f64
FmaF32
fma.f32
FmaF64
fma.f64
Memcpy
libc.memcpy
Memset
libc.memset
Memmove
libc.memmove
Memcmp
libc.memcmp
ElfTlsGetAddr
Elf __tls_get_addr
ElfTlsGetOffset
Elf __tls_get_offset
Implementations§
source§impl LibCall
impl LibCall
sourcepub fn all_libcalls() -> &'static [LibCall]
pub fn all_libcalls() -> &'static [LibCall]
Get a list of all known LibCall’s.
sourcepub fn signature(&self, call_conv: CallConv) -> Signature
pub fn signature(&self, call_conv: CallConv) -> Signature
Examples found in repository?
src/isa/x64/lower/isle.rs (line 645)
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
fn libcall_1(&mut self, libcall: &LibCall, a: Reg) -> Reg {
let call_conv = self.lower_ctx.abi().call_conv(self.lower_ctx.sigs());
let ret_ty = libcall.signature(call_conv).returns[0].value_type;
let output_reg = self.lower_ctx.alloc_tmp(ret_ty).only_reg().unwrap();
emit_vm_call(
self.lower_ctx,
self.flags,
self.triple,
libcall.clone(),
&[a],
&[output_reg],
)
.expect("Failed to emit LibCall");
output_reg.to_reg()
}
fn libcall_3(&mut self, libcall: &LibCall, a: Reg, b: Reg, c: Reg) -> Reg {
let call_conv = self.lower_ctx.abi().call_conv(self.lower_ctx.sigs());
let ret_ty = libcall.signature(call_conv).returns[0].value_type;
let output_reg = self.lower_ctx.alloc_tmp(ret_ty).only_reg().unwrap();
emit_vm_call(
self.lower_ctx,
self.flags,
self.triple,
libcall.clone(),
&[a, b, c],
&[output_reg],
)
.expect("Failed to emit LibCall");
output_reg.to_reg()
}More examples
src/isa/x64/lower.rs (line 155)
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
fn emit_vm_call(
ctx: &mut Lower<Inst>,
flags: &Flags,
triple: &Triple,
libcall: LibCall,
inputs: &[Reg],
outputs: &[Writable<Reg>],
) -> CodegenResult<()> {
let extname = ExternalName::LibCall(libcall);
let dist = if flags.use_colocated_libcalls() {
RelocDistance::Near
} else {
RelocDistance::Far
};
// TODO avoid recreating signatures for every single Libcall function.
let call_conv = CallConv::for_libcall(flags, CallConv::triple_default(triple));
let sig = libcall.signature(call_conv);
let caller_conv = ctx.abi().call_conv(ctx.sigs());
if !ctx.sigs().have_abi_sig_for_signature(&sig) {
ctx.sigs_mut()
.make_abi_sig_from_ir_signature::<X64ABIMachineSpec>(sig.clone(), flags)?;
}
let mut abi =
X64Caller::from_libcall(ctx.sigs(), &sig, &extname, dist, caller_conv, flags.clone())?;
abi.emit_stack_pre_adjust(ctx);
assert_eq!(inputs.len(), abi.num_args(ctx.sigs()));
for (i, input) in inputs.iter().enumerate() {
for inst in abi.gen_arg(ctx, i, ValueRegs::one(*input)) {
ctx.emit(inst);
}
}
let mut retval_insts: SmallInstVec<_> = smallvec![];
for (i, output) in outputs.iter().enumerate() {
retval_insts.extend(abi.gen_retval(ctx, i, ValueRegs::one(*output)).into_iter());
}
abi.emit_call(ctx);
for inst in retval_insts {
ctx.emit(inst);
}
abi.emit_stack_post_adjust(ctx);
Ok(())
}Trait Implementations§
source§impl PartialEq<LibCall> for LibCall
impl PartialEq<LibCall> for LibCall
impl Copy for LibCall
impl Eq for LibCall
impl StructuralEq for LibCall
impl StructuralPartialEq for LibCall
Auto Trait Implementations§
impl RefUnwindSafe for LibCall
impl Send for LibCall
impl Sync for LibCall
impl Unpin for LibCall
impl UnwindSafe for LibCall
Blanket Implementations§
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.