bytecodealliance / bytecodealliance/wasmtime
x64 Assembler: Refactor `Location` to distinguish name/kind
- Dominant language
- Rust
- Stars
- 18.6k
- Forks
- 1.8k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 121
Description
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:
```rust
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
Contributor guide
Assessment
This issue has not been assessed yet.