Struct cranelift_codegen::ir::function::FunctionParameters
source · pub struct FunctionParameters { /* private fields */ }
Expand description
Function parameters used when creating this function, and that will become applied after
compilation to materialize the final CompiledCode
.
Implementations§
source§impl FunctionParameters
impl FunctionParameters
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new FunctionParameters
with the given name.
Examples found in repository?
src/ir/function.rs (line 458)
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
pub fn with_name_signature(name: UserFuncName, sig: Signature) -> Self {
Self {
name,
stencil: FunctionStencil {
version_marker: VersionMarker,
signature: sig,
sized_stack_slots: StackSlots::new(),
dynamic_stack_slots: DynamicStackSlots::new(),
global_values: PrimaryMap::new(),
heaps: PrimaryMap::new(),
tables: PrimaryMap::new(),
jump_tables: PrimaryMap::new(),
dfg: DataFlowGraph::new(),
layout: Layout::new(),
srclocs: SecondaryMap::new(),
stack_limit: None,
},
params: FunctionParameters::new(),
}
}
sourcepub fn base_srcloc(&self) -> SourceLoc
pub fn base_srcloc(&self) -> SourceLoc
Returns the base SourceLoc
.
If it was never explicitly set with ensure_base_srcloc
, will return an invalid
SourceLoc
.
Examples found in repository?
More examples
src/legalizer/heap.rs (line 401)
380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408
fn cast_index_to_pointer_ty(
index: ir::Value,
index_ty: ir::Type,
pointer_ty: ir::Type,
pos: &mut FuncCursor,
) -> ir::Value {
if index_ty == pointer_ty {
return index;
}
// Note that using 64-bit heaps on a 32-bit host is not currently supported,
// would require at least a bounds check here to ensure that the truncation
// from 64-to-32 bits doesn't lose any upper bits. For now though we're
// mostly interested in the 32-bit-heaps-on-64-bit-hosts cast.
assert!(index_ty.bits() < pointer_ty.bits());
// Convert `index` to `addr_ty`.
let extended_index = pos.ins().uextend(pointer_ty, index);
// Add debug value-label alias so that debuginfo can name the extended
// value as the address
let loc = pos.srcloc();
let loc = RelSourceLoc::from_base_offset(pos.func.params.base_srcloc(), loc);
pos.func
.stencil
.dfg
.add_value_label_alias(extended_index, loc, index);
extended_index
}
sourcepub fn ensure_base_srcloc(&mut self, srcloc: SourceLoc) -> SourceLoc
pub fn ensure_base_srcloc(&mut self, srcloc: SourceLoc) -> SourceLoc
Sets the base SourceLoc
, if not set yet, and returns the base value.
Examples found in repository?
More examples
sourcepub fn ensure_user_func_name(
&mut self,
name: UserExternalName
) -> UserExternalNameRef
pub fn ensure_user_func_name(
&mut self,
name: UserExternalName
) -> UserExternalNameRef
Retrieve a UserExternalNameRef
for the given name, or add a new one.
This method internally deduplicates same UserExternalName
so they map to the same
reference.
sourcepub fn reset_user_func_name(
&mut self,
index: UserExternalNameRef,
name: UserExternalName
)
pub fn reset_user_func_name(
&mut self,
index: UserExternalNameRef,
name: UserExternalName
)
Resets an already existing user function name to a new value.
sourcepub fn user_named_funcs(
&self
) -> &PrimaryMap<UserExternalNameRef, UserExternalName>
pub fn user_named_funcs(
&self
) -> &PrimaryMap<UserExternalNameRef, UserExternalName>
Returns the internal mapping of UserExternalNameRef
to UserExternalName
.
Examples found in repository?
src/ir/extname.rs (line 191)
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.name {
ExternalName::User(func_ref) => {
if let Some(params) = self.params {
let name = ¶ms.user_named_funcs()[*func_ref];
write!(f, "u{}:{}", name.namespace, name.index)
} else {
// Best effort.
write!(f, "{}", *func_ref)
}
}
ExternalName::TestCase(testcase) => testcase.fmt(f),
ExternalName::LibCall(lc) => write!(f, "%{}", lc),
ExternalName::KnownSymbol(ks) => write!(f, "%{}", ks),
}
}
Trait Implementations§
source§impl Clone for FunctionParameters
impl Clone for FunctionParameters
source§fn clone(&self) -> FunctionParameters
fn clone(&self) -> FunctionParameters
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more