Always require a Flags reference for verifying functions.
Add a settings::FlagsOrIsa struct which represents a flags reference and optionally the ISA it belongs to. Use this for passing flags/isa information to the verifier. The verify_function() and verify_context() functions are now generic so they accept either a &Flags or a &TargetISa argument. Fix the return_at_end verifier tests which no longer require an ISA specified. The signle "set return_at_end" flag setting now makes it to the verifier even when no ISA is present to carry it.
This commit is contained in:
@@ -20,11 +20,11 @@
|
||||
//! assert_eq!(f.opt_level(), settings::OptLevel::Fastest);
|
||||
//! ```
|
||||
|
||||
use constant_hash::{probe, simple_hash};
|
||||
use isa::TargetIsa;
|
||||
use std::fmt;
|
||||
use std::result;
|
||||
|
||||
use constant_hash::{probe, simple_hash};
|
||||
|
||||
/// A string-based configurator for settings groups.
|
||||
///
|
||||
/// The `Configurable` protocol allows settings to be modified by name before a finished `Flags`
|
||||
@@ -303,6 +303,34 @@ pub mod detail {
|
||||
// with an impl for all of the settings defined in `meta/cretonne/settings.py`.
|
||||
include!(concat!(env!("OUT_DIR"), "/settings.rs"));
|
||||
|
||||
/// Wrapper containing flags and optionally a `TargetIsa` trait object.
|
||||
///
|
||||
/// A few passes need to access the flags but only optionally a target ISA. The `FlagsOrIsa`
|
||||
/// wrapper can be used to pass either, and extract the flags so they are always accessible.
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct FlagsOrIsa<'a> {
|
||||
/// Flags are always present.
|
||||
pub flags: &'a Flags,
|
||||
|
||||
/// The ISA may not be present.
|
||||
pub isa: Option<&'a TargetIsa>,
|
||||
}
|
||||
|
||||
impl<'a> From<&'a Flags> for FlagsOrIsa<'a> {
|
||||
fn from(flags: &'a Flags) -> FlagsOrIsa {
|
||||
FlagsOrIsa { flags, isa: None }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a TargetIsa> for FlagsOrIsa<'a> {
|
||||
fn from(isa: &'a TargetIsa) -> FlagsOrIsa {
|
||||
FlagsOrIsa {
|
||||
flags: isa.flags(),
|
||||
isa: Some(isa),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{builder, Flags};
|
||||
|
||||
Reference in New Issue
Block a user