Introduce the Cranelift IR instruction LoadSplat
It corresponds to WebAssembly's `load*_splat` operations, which were previously represented as a combination of `Load` and `Splat` instructions. However, there are architectures such as Armv8-A that have a single machine instruction equivalent to the Wasm operations. In order to generate it, it is necessary to merge the `Load` and the `Splat` in the backend, which is not possible because the load may have side effects. The new IR instruction works around this limitation. The AArch64 backend leverages the new instruction to improve code generation. Copyright (c) 2020, Arm Limited.
This commit is contained in:
@@ -4409,5 +4409,24 @@ pub(crate) fn define(
|
||||
.other_side_effects(true),
|
||||
);
|
||||
|
||||
let Offset = &Operand::new("Offset", &imm.offset32).with_doc("Byte offset from base address");
|
||||
let a = &Operand::new("a", TxN);
|
||||
|
||||
ig.push(
|
||||
Inst::new(
|
||||
"load_splat",
|
||||
r#"
|
||||
Load an element from memory at ``p + Offset`` and return a vector
|
||||
whose lanes are all set to that element.
|
||||
|
||||
This is equivalent to ``load`` followed by ``splat``.
|
||||
"#,
|
||||
&formats.load,
|
||||
)
|
||||
.operands_in(vec![MemFlags, p, Offset])
|
||||
.operands_out(vec![a])
|
||||
.can_load(true),
|
||||
);
|
||||
|
||||
ig.build()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user