Skip to content

x64 Assembler: Refactor Location to distinguish name/kind #10922

Open
@alexcrichton

Description

@alexcrichton

We discussed this at today's Cranelift meeting but I wanted to write up my thoughts in an issue. @cfallin brought up that Location::xmm{1,2,3} are a bit odd in that they are all the same thing conceptually just different names of the same thing. I brought up that this is in contracts to Location::{eax, edx} for example which are two names for two different things, and this clashes because xmm{1,2,3} are both valid physical register names.

An alternative I think migth be possible is something like this:

struct Location {
    rust_field_name: &'static str,
    kind: LocationKind,
}

enum LocationKind {
    // ... everything we have today in `Location` minus r32a, r32b, xmm1/2/3 (collapsed to "xmm")
}

impl Location {
    const r32a: Location = Location { rust_field_name: "r32a", kind: LocationKind::r32 };
    const xmm1: Location = Location { rust_field_name: "xmm1", kind: LocationKind::xmm };
    // ...
}

That way we wouldn't actually need to change anything (r32a would still work as a location) and we could perhaps refactor how fixed physical registers work to be all-caps ro some sort of similar convention to distinguish fixed register usages from non-fixed-register-usages (e.g. xmm1 vs XMM0)

cc @abrown

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions