Add support for setting presets.

Fixes #11.

Presets are groups of settings and values applied at once. This is used
as a shorthand in test files, so for example "isa intel nehalem" enables
all of the CPUID bits that the Nehalem micro-architecture provides.
This commit is contained in:
Jakob Stoklund Olesen
2017-07-13 14:49:17 -07:00
parent 130b7fa2fa
commit f91d747bda
10 changed files with 213 additions and 33 deletions

View File

@@ -7,3 +7,27 @@ use std::fmt;
// `Flags` struct with an impl for all of the settings defined in
// `lib/cretonne/meta/cretonne/settings.py`.
include!(concat!(env!("OUT_DIR"), "/settings-intel.rs"));
#[cfg(test)]
mod tests {
use super::{builder, Flags};
use settings::{self, Configurable};
#[test]
fn presets() {
let shared = settings::Flags::new(&settings::builder());
// Nehalem has SSE4.1 but not BMI1.
let mut b1 = builder();
b1.enable("nehalem").unwrap();
let f1 = Flags::new(&shared, &b1);
assert_eq!(f1.has_sse41(), true);
assert_eq!(f1.has_bmi1(), false);
let mut b2 = builder();
b2.enable("haswell").unwrap();
let f2 = Flags::new(&shared, &b2);
assert_eq!(f2.has_sse41(), true);
assert_eq!(f2.has_bmi1(), true);
}
}