Skip to content

Commit 2454d72

Browse files
committed
Prevent over-large OperandConstraint::Limits
For consistency, internally and externally, we do not really want to handle limits that are larger that the maximum encodable register.
1 parent 6690122 commit 2454d72

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,10 @@ impl Operand {
670670
}
671671
OperandConstraint::Limit(max) => {
672672
assert!(max.is_power_of_two());
673+
assert!(
674+
max <= PReg::MAX + 1,
675+
"limit is larger than the allowed register encoding"
676+
);
673677
let log2 = max.ilog2();
674678
debug_assert!(log2 <= 0b1111);
675679
0b0010000 | log2 as u32

0 commit comments

Comments
 (0)