-
Notifications
You must be signed in to change notification settings - Fork 42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adjust Operand encoding #13
Conversation
The encoding for OperandConstraint is adjusted to free up 2 bits which allows for 2^21 vregs and 2^6 pregs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this!
Just a request for an additional comment below but otherwise LGTM.
src/lib.rs
Outdated
/// | ||
/// The value returned by `index()`, in contrast, is in a single index | ||
/// space shared by all classes, in order to enable uniform reasoning | ||
/// about physical registers. This is done by putting the class bit at | ||
/// the MSB, or equivalently, declaring that indices 0..31 are the 32 | ||
/// integer registers and indices 32..63 are the 32 float registers. | ||
/// the MSB, or equivalently, declaring that indices 0..63 are the 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pre-existing but a pedantic nit on my own comment: could you adjust to either 0..=63
or 0..64
(and likewise for the second range)? Inconsistency w.r.t. Rust open/cosed-range syntax is bothering me :-)
OperandConstraint::Any => (0, 0), | ||
OperandConstraint::Reg => (0, 1), | ||
OperandConstraint::Stack => (0, 2), | ||
let constraint_field = match constraint { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a block comment here describing the bit encoding?
src/lib.rs
Outdated
@@ -383,15 +383,15 @@ pub enum OperandPos { | |||
/// that the conflict (overlap) is properly accounted for. See | |||
/// comments on the constructors below for more. | |||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] | |||
//#[repr(packed)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a stray comment ?
//#[repr(packed)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops that's from an old test I was doing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Large parts of the code in regalloc2 are currently licensed under the Mozilla Public License (MPL) 2.0, because they derive in meaningful ways from the register allocator in IonMonkey, which is part of Firefox. The relevant source files are marked as such, with references to the files in the Firefox source tree. The intent of the regalloc2 project was to port the register allocator from Firefox to use in Cranelift, borrowing good technology and improving on it in the spirit of open source. However, Several use-cases of Cranelift require, or at least strongly prefer, the Apache-2.0 license with the LLVM exception (matching the license of Cranelift itself, and Bytecode Alliance projects generally). While using this license is not strictly necessary for regalloc2 to be usable (The MPL is an excellent open-source license!), relicensing fully under this license to harmonize with the rest of Cranelift and Bytecode Alliance codebases significantly widens possibilities and reduces friction; then regalloc2 is "just another part of Cranelift" and doesn't have to be treated specially. The source in `src/ion/` specifically began as a fairly direct port of the algorithms in the following files in the `mozilla-central` repository (Firefox codebase): * The bulk of the "backtracking allocator" algorithm: * `js/src/jit/BacktrackingAllocator.{cpp,h}` * Helpers and definitions in the surrounding infrastructure: * `js/src/jit/RegisterAllocator.h` * `js/src/jit/RegisterAllocator.cpp` * `js/src/jit/StackSlotAllocator.h` * `js/src/jit/LIR.h` * A few data structure implementations: * `js/src/ds/SplayTree.h` * `js/src/ds/PriorityQueue.h` Subsequent work in improving regalloc2 has caused it to drift from the direct port -- for example, it no longer uses splay trees or the direct port of the priority queue above -- but it is of course very clearly still a derivative work. Analysis of the contributors to these files indicates that we need signoff from the following folks: * Mozilla Corp, for contributions made by Mozilla employees (the majority of the code). Communications with Mozilla (thanks @tschneidereit and @bholley for doing the work here!) indicate that @ekr is able to sign off when ready here. * Andy Wingo, specifically for the work done in [Bug 1620197](https://bugzilla.mozilla.org/show_bug.cgi?id=1620197) and [Bug 1609057](https://bugzilla.mozilla.org/show_bug.cgi?id=1609057) to generalize the stack allocator for a Wasm feature (multiple returns). Additionally, since the initial port, we have had three contributions from @Amanieu: [bytecodealliance#9](bytecodealliance#9), [bytecodealliance#11](bytecodealliance#11), [bytecodealliance#13](bytecodealliance#13). So, if everyone applicable is happy with this relicensing, this PR removes the MPL-2.0 license in `src/ion/` and marks all files as covered under `Apache-2.0 WITH LLVM-exception`. Please let us know if this is OK! Signoffs: - [ ] @ekr, for Mozilla's contributions - [ ] @Awingo, for contributions to original code in `mozilla-central` - [ ] @Amanieu, for the three PRs linked above Thanks!
Large parts of the code in regalloc2 are currently licensed under the Mozilla Public License (MPL) 2.0, because they derive in meaningful ways from the register allocator in IonMonkey, which is part of Firefox. The relevant source files are marked as such, with references to the files in the Firefox source tree. The intent of the regalloc2 project was to port the register allocator from Firefox to use in Cranelift, borrowing good technology and improving on it in the spirit of open source. However, Several use-cases of Cranelift require, or at least strongly prefer, the Apache-2.0 license with the LLVM exception (matching the license of Cranelift itself, and Bytecode Alliance projects generally). While using this license is not strictly necessary for regalloc2 to be usable (The MPL is an excellent open-source license!), relicensing fully under this license to harmonize with the rest of Cranelift and Bytecode Alliance codebases significantly widens possibilities and reduces friction; then regalloc2 is "just another part of Cranelift" and doesn't have to be treated specially. The source in `src/ion/` specifically began as a fairly direct port of the algorithms in the following files in the `mozilla-central` repository (Firefox codebase): * The bulk of the "backtracking allocator" algorithm: * `js/src/jit/BacktrackingAllocator.{cpp,h}` * Helpers and definitions in the surrounding infrastructure: * `js/src/jit/RegisterAllocator.h` * `js/src/jit/RegisterAllocator.cpp` * `js/src/jit/StackSlotAllocator.h` * `js/src/jit/LIR.h` * A few data structure implementations: * `js/src/ds/SplayTree.h` * `js/src/ds/PriorityQueue.h` Subsequent work in improving regalloc2 has caused it to drift from the direct port -- for example, it no longer uses splay trees or the direct port of the priority queue above -- but it is of course very clearly still a derivative work. Analysis of the contributors to these files indicates that we need signoff from the following folks: * Mozilla Corp, for contributions made by Mozilla employees (the majority of the code). Communications with Mozilla (thanks @tschneidereit and @bholley for doing the work here!) indicate that @ekr is able to sign off when ready here. * Andy Wingo, specifically for the work done in [Bug 1620197](https://bugzilla.mozilla.org/show_bug.cgi?id=1620197) and [Bug 1609057](https://bugzilla.mozilla.org/show_bug.cgi?id=1609057) to generalize the stack allocator for a Wasm feature (multiple returns). Additionally, since the initial port, we have had three contributions from @Amanieu: [bytecodealliance#9](bytecodealliance#9), [bytecodealliance#11](bytecodealliance#11), [bytecodealliance#13](bytecodealliance#13). So, if everyone applicable is happy with this relicensing, this PR removes the MPL-2.0 license in `src/ion/` and marks all files as covered under `Apache-2.0 WITH LLVM-exception`. Please let us know if this is OK! Signoffs: - [ ] @ekr, for Mozilla's contributions - [ ] @Awingo, for contributions to original code in `mozilla-central` - [ ] @Amanieu, for the three PRs linked above Thanks!
Large parts of the code in regalloc2 are currently licensed under the Mozilla Public License (MPL) 2.0, because they derive in meaningful ways from the register allocator in IonMonkey, which is part of Firefox. The relevant source files are marked as such, with references to the files in the Firefox source tree. The intent of the regalloc2 project was to port the register allocator from Firefox to use in Cranelift, borrowing good technology and improving on it in the spirit of open source. However, Several use-cases of Cranelift require, or at least strongly prefer, the Apache-2.0 license with the LLVM exception (matching the license of Cranelift itself, and Bytecode Alliance projects generally). While using this license is not strictly necessary for regalloc2 to be usable (The MPL is an excellent open-source license!), relicensing fully under this license to harmonize with the rest of Cranelift and Bytecode Alliance codebases significantly widens possibilities and reduces friction; then regalloc2 is "just another part of Cranelift" and doesn't have to be treated specially. The source in `src/ion/` specifically began as a fairly direct port of the algorithms in the following files in the `mozilla-central` repository (Firefox codebase): * The bulk of the "backtracking allocator" algorithm: * `js/src/jit/BacktrackingAllocator.{cpp,h}` * Helpers and definitions in the surrounding infrastructure: * `js/src/jit/RegisterAllocator.h` * `js/src/jit/RegisterAllocator.cpp` * `js/src/jit/StackSlotAllocator.h` * `js/src/jit/LIR.h` * A few data structure implementations: * `js/src/ds/SplayTree.h` * `js/src/ds/PriorityQueue.h` Subsequent work in improving regalloc2 has caused it to drift from the direct port -- for example, it no longer uses splay trees or the direct port of the priority queue above -- but it is of course very clearly still a derivative work. Analysis of the contributors to these files indicates that we need signoff from the following folks: * Mozilla Corp, for contributions made by Mozilla employees (the majority of the code). Communications with Mozilla (thanks @tschneidereit and @bholley for doing the work here!) indicate that @ekr is able to sign off when ready here. * Andy Wingo, specifically for the work done in [Bug 1620197](https://bugzilla.mozilla.org/show_bug.cgi?id=1620197) and [Bug 1609057](https://bugzilla.mozilla.org/show_bug.cgi?id=1609057) to generalize the stack allocator for a Wasm feature (multiple returns). Additionally, since the initial port, we have had three contributions from @Amanieu: [bytecodealliance#9](bytecodealliance#9), [bytecodealliance#11](bytecodealliance#11), [bytecodealliance#13](bytecodealliance#13). So, if everyone applicable is happy with this relicensing, this PR removes the MPL-2.0 license in `src/ion/` and marks all files as covered under `Apache-2.0 WITH LLVM-exception`. Please let us know if this is OK! Signoffs: - [ ] @ekr, for Mozilla's contributions - [ ] @wingo, for contributions to original code in `mozilla-central` - [ ] @Amanieu, for the three PRs linked above Thanks!
The encoding for OperandConstraint is adjusted to free up 2 bits which
allows for 2^21 vregs and 2^6 pregs.