LocSet now allows multiple reg_lens simultaneously
[bigint-presentation-code.git] / register_allocator / src / loc.rs
index e6473ef52213e9fdd21cbd266736642f8dc3c5a0..08e81fc2fa7ef89d158b01e2b7126d640f3b3640 100644 (file)
@@ -185,9 +185,9 @@ validated_fields! {
     #[fields_ty = LocFields]
     #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
     pub struct Loc {
+        pub reg_len: NonZeroU32,
         pub kind: LocKind,
         pub start: u32,
-        pub reg_len: NonZeroU32,
     }
 }
 
@@ -258,6 +258,9 @@ impl Loc {
     pub const fn ty(self) -> Ty {
         const_unwrap_res!(self.0.ty(), "Loc can only be constructed with valid fields")
     }
+    /// does all `Loc` validation except checking `start`, returns the maximum
+    /// value `start` can have, so a `Loc` is valid if
+    /// `start < Loc::max_start(kind, reg_len)?`
     pub const fn max_start(kind: LocKind, reg_len: NonZeroU32) -> Result<u32, Error> {
         // validate Ty
         const_try!(Ty::new(TyFields {