Skip to content

Commit

Permalink
x64: Add memory operand support to EVEX instructions (bytecodeallianc…
Browse files Browse the repository at this point in the history
…e#6416)

* x64: Add memory operand support to EVEX instructions

Currently load-sinking is enabled for EVEX instructions (aka AVX512
instructions) but the encoding of these instructions is a `todo!()`
which can cause a panic for some wasms if the right features are
enabled. This commit fills out the support for memory operands in the
same manner as VEX-encoded instructions. The main stickler here was that
EVEX instructions always use a scaled 8-bit offset which needed extra
handling to ensure that the correct offset is emitted.

* Pass scaling to `Imm` construction

* Review comments

* Fix tests

* Fix evex benchmark
  • Loading branch information
alexcrichton authored May 24, 2023
1 parent afde47c commit 797e769
Show file tree
Hide file tree
Showing 7 changed files with 506 additions and 108 deletions.
5 changes: 2 additions & 3 deletions cranelift/codegen/benches/x64-evex-encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ mod x86 {
fn x64_evex_encoding_benchmarks(c: &mut Criterion) {
let mut group = c.benchmark_group("x64 EVEX encoding");
let rax = Register::from(0);
let rdx = Register::from(2);
let rdx = 2;

group.bench_function("EvexInstruction (builder pattern)", |b| {
let mut sink = vec![];
b.iter(|| {
sink.clear();
let mut sink = cranelift_codegen::MachBuffer::new();
EvexInstruction::new()
.prefix(LegacyPrefixes::_66)
.map(OpcodeMap::_0F38)
Expand Down
Loading

0 comments on commit 797e769

Please sign in to comment.