Add a PredicateView type to abstract the predicate bit vector a bit.
The encoding tables contain references to numbered ISA predicates. - Give the ISA Flags types a predicate_view() method which returns a PredicateView. - Delete the old predicate_bytes() method which returned a raw &[u8]. - Use a 'static lifetime for the encoding list slice in the Encodings iterator, and a single 'a lifetime for everything else.
This commit is contained in:
@@ -162,6 +162,28 @@ pub enum Error {
|
||||
/// A result returned when changing a setting.
|
||||
pub type Result<T> = result::Result<T, Error>;
|
||||
|
||||
/// A reference to just the boolean predicates of a settings object.
|
||||
///
|
||||
/// The settings objects themselves are generated and appear in the `isa/*/settings.rs` modules.
|
||||
/// Each settings object provides a `predicate_view()` method that makes it possible to query
|
||||
/// ISA predicates by number.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct PredicateView<'a>(&'a [u8]);
|
||||
|
||||
impl<'a> PredicateView<'a> {
|
||||
/// Create a new view of a precomputed predicate vector.
|
||||
///
|
||||
/// See the `predicate_view()` method on the various `Flags` types defined for each ISA.
|
||||
pub fn new(bits: &'a [u8]) -> PredicateView {
|
||||
PredicateView(bits)
|
||||
}
|
||||
|
||||
/// Check a numbered predicate.
|
||||
pub fn test(self, p: usize) -> bool {
|
||||
self.0[p / 8] & (1 << (p % 8)) != 0
|
||||
}
|
||||
}
|
||||
|
||||
/// Implementation details for generated code.
|
||||
///
|
||||
/// This module holds definitions that need to be public so the can be instantiated by generated
|
||||
|
||||
Reference in New Issue
Block a user