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

Function expand_binary

cranelift/codegen/src/legalizer/mod.rs:133–163  ·  view source on GitHub ↗
(
    func: &mut ir::Function,
    inst: ir::Inst,
    opcode: ir::Opcode,
    args: [ir::Value; 2],
)

Source from the content-addressed store, hash-verified

131}
132
133fn expand_binary(
134 func: &mut ir::Function,
135 inst: ir::Inst,
136 opcode: ir::Opcode,
137 args: [ir::Value; 2],
138) -> WalkCommand {
139 let mut pos = FuncCursor::new(func);
140 pos.goto_inst(inst);
141
142 // Legalize the fused bitwise-plus-not instructions into simpler
143 // instructions to assist with optimizations. Lowering will pattern match
144 // this sequence regardless when architectures support the instruction
145 // natively.
146 match opcode {
147 ir::Opcode::BandNot => {
148 let neg = pos.ins().bnot(args[1]);
149 pos.func.replace(inst).band(args[0], neg);
150 }
151 ir::Opcode::BorNot => {
152 let neg = pos.ins().bnot(args[1]);
153 pos.func.replace(inst).bor(args[0], neg);
154 }
155 ir::Opcode::BxorNot => {
156 let neg = pos.ins().bnot(args[1]);
157 pos.func.replace(inst).bxor(args[0], neg);
158 }
159 _ => {}
160 }
161
162 WalkCommand::Continue
163}
164
165fn expand_dynamic_stack_store(
166 isa: &dyn TargetIsa,

Callers 1

simple_legalizeFunction · 0.85

Calls 4

goto_instMethod · 0.80
newFunction · 0.50
insMethod · 0.45
replaceMethod · 0.45

Tested by

no test coverage detected