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§

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(),
        }
    }

Returns the base SourceLoc.

If it was never explicitly set with ensure_base_srcloc, will return an invalid SourceLoc.

Examples found in repository?
src/ir/function.rs (line 497)
496
497
498
499
    pub fn srcloc(&self, inst: Inst) -> SourceLoc {
        let base = self.params.base_srcloc();
        self.stencil.srclocs[inst].expand(base)
    }
More examples
Hide additional examples
src/machinst/buffer.rs (line 1557)
1553
1554
1555
1556
1557
1558
1559
    fn apply_params(self, params: &FunctionParameters) -> MachSrcLoc<Final> {
        MachSrcLoc {
            start: self.start,
            end: self.end,
            loc: self.loc.expand(params.base_srcloc()),
        }
    }
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
}

Sets the base SourceLoc, if not set yet, and returns the base value.

Examples found in repository?
src/cursor.rs (line 615)
614
615
616
617
    fn set_srcloc(&mut self, srcloc: ir::SourceLoc) {
        self.func.params.ensure_base_srcloc(srcloc);
        self.srcloc = srcloc;
    }
More examples
Hide additional examples
src/ir/function.rs (line 491)
490
491
492
493
    pub fn set_srcloc(&mut self, inst: Inst, srcloc: SourceLoc) {
        let base = self.params.ensure_base_srcloc(srcloc);
        self.stencil.srclocs[inst] = RelSourceLoc::from_base_offset(base, srcloc);
    }

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.

Examples found in repository?
src/ir/function.rs (line 506)
502
503
504
505
506
507
    pub fn declare_imported_user_function(
        &mut self,
        name: UserExternalName,
    ) -> UserExternalNameRef {
        self.params.ensure_user_func_name(name)
    }

Resets an already existing user function name to a new value.

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 = &params.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§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.