MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / load_addr

Function load_addr

cranelift/codegen/src/legalizer/globalvalue.rs:120–147  ·  view source on GitHub ↗

Expand a `global_value` instruction for a load global.

(
    inst: ir::Inst,
    func: &mut ir::Function,
    base: ir::GlobalValue,
    offset: ir::immediates::Offset32,
    global_type: ir::Type,
    flags: ir::MemFlagsData,
    isa: &dyn TargetIsa,
)

Source from the content-addressed store, hash-verified

118
119/// Expand a `global_value` instruction for a load global.
120fn load_addr(
121 inst: ir::Inst,
122 func: &mut ir::Function,
123 base: ir::GlobalValue,
124 offset: ir::immediates::Offset32,
125 global_type: ir::Type,
126 flags: ir::MemFlagsData,
127 isa: &dyn TargetIsa,
128) -> WalkCommand {
129 // We need to load a pointer from the `base` global value, so insert a new `global_value`
130 // instruction. This depends on the iterative legalization loop. Note that the IR verifier
131 // detects any cycles in the `load` globals.
132 let ptr_ty = isa.pointer_type();
133
134 let mut pos = FuncCursor::new(func).at_inst(inst);
135 pos.use_srcloc(inst);
136
137 // Get the value for the base.
138 let base_addr = pos.ins().global_value(ptr_ty, base);
139
140 // Perform the load.
141 pos.func
142 .replace(inst)
143 .load(global_type, flags, base_addr, offset);
144
145 // Need to legalize the `global_value` for the base address.
146 WalkCommand::Revisit
147}
148
149/// Expand a `global_value` instruction for a symbolic name global.
150fn symbol(

Callers 1

expand_global_valueFunction · 0.85

Calls 7

at_instMethod · 0.80
use_srclocMethod · 0.80
newFunction · 0.50
pointer_typeMethod · 0.45
insMethod · 0.45
loadMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected