Stream: git-wasmtime

Topic: wasmtime / Issue #1421 Only infer REX prefixes in i64 mode


view this post on Zulip Wasmtime GitHub notifications bot (Mar 27 2020 at 18:13):

abrown opened Issue #1421:

In looking over encodings.rs again in #1208, I noticed that I had allowed x86's 32-bit mode in cranelift-codegen-meta to infer REX prefixes. This should not be allowed since REX prefixes are only available in 64-bit mode.

Once this is changed in enc_both_inferred* (and after adding size calculator functions to the {g,f}pr{,disp8,disp32} recipes), a simplification is possible. Loads and stores could be simplified from:

            e.enc32_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            // REX-less encoding must come after REX encoding so we don't use it by
            // default. Otherwise reg-alloc would never use r8 and up.
            e.enc64_maybe_isap(inst.clone().bind(I32), template.clone().rex(), isap);
            e.enc64_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            // Similar to above; TODO some of this duplication can be cleaned up by infer_rex()
            // tracked in https://github.com/bytecodealliance/cranelift/issues/1090
            e.enc64_maybe_isap(inst.clone().bind(I64), template.clone().rex(), isap);
            e.enc64_maybe_isap(inst.bind(I64), template, isap);

to:

            e.enc_both_inferred_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            e.enc64_maybe_isap(inst.bind(I64), template.infer_rex(), isap);

view this post on Zulip Wasmtime GitHub notifications bot (Mar 27 2020 at 23:47):

abrown labeled Issue #1421:

In looking over encodings.rs again in #1208, I noticed that I had allowed x86's 32-bit mode in cranelift-codegen-meta to infer REX prefixes. This should not be allowed since REX prefixes are only available in 64-bit mode.

Once this is changed in enc_both_inferred* (and after adding size calculator functions to the {g,f}pr{,disp8,disp32} recipes), a simplification is possible. Loads and stores could be simplified from:

            e.enc32_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            // REX-less encoding must come after REX encoding so we don't use it by
            // default. Otherwise reg-alloc would never use r8 and up.
            e.enc64_maybe_isap(inst.clone().bind(I32), template.clone().rex(), isap);
            e.enc64_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            // Similar to above; TODO some of this duplication can be cleaned up by infer_rex()
            // tracked in https://github.com/bytecodealliance/cranelift/issues/1090
            e.enc64_maybe_isap(inst.clone().bind(I64), template.clone().rex(), isap);
            e.enc64_maybe_isap(inst.bind(I64), template, isap);

to:

            e.enc_both_inferred_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            e.enc64_maybe_isap(inst.bind(I64), template.infer_rex(), isap);

view this post on Zulip Wasmtime GitHub notifications bot (Apr 02 2020 at 18:28):

abrown closed Issue #1421:

In looking over encodings.rs again in #1208, I noticed that I had allowed x86's 32-bit mode in cranelift-codegen-meta to infer REX prefixes. This should not be allowed since REX prefixes are only available in 64-bit mode.

Once this is changed in enc_both_inferred* (and after adding size calculator functions to the {g,f}pr{,disp8,disp32} recipes), a simplification is possible. Loads and stores could be simplified from:

            e.enc32_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            // REX-less encoding must come after REX encoding so we don't use it by
            // default. Otherwise reg-alloc would never use r8 and up.
            e.enc64_maybe_isap(inst.clone().bind(I32), template.clone().rex(), isap);
            e.enc64_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            // Similar to above; TODO some of this duplication can be cleaned up by infer_rex()
            // tracked in https://github.com/bytecodealliance/cranelift/issues/1090
            e.enc64_maybe_isap(inst.clone().bind(I64), template.clone().rex(), isap);
            e.enc64_maybe_isap(inst.bind(I64), template, isap);

to:

            e.enc_both_inferred_maybe_isap(inst.clone().bind(I32), template.clone(), isap);
            e.enc64_maybe_isap(inst.bind(I64), template.infer_rex(), isap);

Last updated: Dec 23 2024 at 12:05 UTC