diff --git a/lib/cretonne/meta/cdsl/predicates.py b/lib/cretonne/meta/cdsl/predicates.py index 8ba4c8eb41..e75920d948 100644 --- a/lib/cretonne/meta/cdsl/predicates.py +++ b/lib/cretonne/meta/cdsl/predicates.py @@ -232,6 +232,21 @@ class FieldPredicate(object): return 'predicates::{}({})'.format(self.function, ', '.join(args)) +class IsEqual(FieldPredicate): + """ + Instruction predicate that checks if an immediate instruction format field + is equal to a constant value. + + :param field: `FormatField` to be checked. + :param value: The constant value to compare against. + """ + + def __init__(self, field, value): + # type: (FormatField, Any) -> None + super(IsEqual, self).__init__(field, 'is_equal', (value,)) + self.value = value + + class IsSignedInt(FieldPredicate): """ Instruction predicate that checks if an immediate instruction format field diff --git a/lib/cretonne/src/predicates.rs b/lib/cretonne/src/predicates.rs index 748a75e23a..770857d100 100644 --- a/lib/cretonne/src/predicates.rs +++ b/lib/cretonne/src/predicates.rs @@ -9,6 +9,12 @@ //! Some of these predicates may be unused in certain ISA configurations, so we suppress the //! dead_code warning. +/// Check that `x` is the same as `y`. +#[allow(dead_code)] +pub fn is_equal(x: T, y: T) -> bool { + x == y +} + /// Check that `x` can be represented as a `wd`-bit signed integer with `sc` low zero bits. #[allow(dead_code)] pub fn is_signed_int>(x: T, wd: u8, sc: u8) -> bool {