diff --git a/lib/cretonne/meta/base/settings.py b/lib/cretonne/meta/base/settings.py index 1f7e21668b..186c808524 100644 --- a/lib/cretonne/meta/base/settings.py +++ b/lib/cretonne/meta/base/settings.py @@ -18,6 +18,14 @@ opt_level = EnumSetting( """, 'default', 'best', 'fastest') +enable_verifier = BoolSetting( + """ + Run the Cretonne IL verifier at strategic times during compilation. + + This makes compilation slower but catches many bugs. The verifier is + disabled by default, except when reading Cretonne IL from a text file. + """) + is_64bit = BoolSetting("Enable 64-bit code generation") is_compressed = BoolSetting("Enable compressed instructions") diff --git a/lib/cretonne/src/settings.rs b/lib/cretonne/src/settings.rs index 23ff7d688d..204588c7c1 100644 --- a/lib/cretonne/src/settings.rs +++ b/lib/cretonne/src/settings.rs @@ -271,6 +271,7 @@ mod tests { assert_eq!(f.to_string(), "[shared]\n\ opt_level = \"default\"\n\ + enable_verifier = false\n\ is_64bit = false\n\ is_compressed = false\n\ enable_float = true\n\ diff --git a/lib/reader/src/parser.rs b/lib/reader/src/parser.rs index f96d60518a..eae8c925b0 100644 --- a/lib/reader/src/parser.rs +++ b/lib/reader/src/parser.rs @@ -17,7 +17,7 @@ use cretonne::ir::immediates::{Imm64, Offset32, Uoffset32, Ieee32, Ieee64}; use cretonne::ir::entities::AnyEntity; use cretonne::ir::instructions::{InstructionFormat, InstructionData, VariableArgs}; use cretonne::isa::{self, TargetIsa, Encoding}; -use cretonne::settings; +use cretonne::settings::{self, Configurable}; use testfile::{TestFile, Details, Comment}; use error::{Location, Error, Result}; use lexer::{self, Lexer, Token}; @@ -577,6 +577,13 @@ impl<'a> Parser<'a> { let mut isas = Vec::new(); let mut flag_builder = settings::builder(); + // Change the default for `enable_verifier` to `true`. It defaults to `false` because it + // would slow down normal compilation, but when we're reading IL from a text file we're + // either testing or debugging Cretonne, and verification makes sense. + flag_builder + .set_bool("enable_verifier", true) + .expect("Missing enable_verifier setting"); + while let Some(Token::Identifier(command)) = self.token() { match command { "set" => { @@ -1849,7 +1856,10 @@ mod tests { assert_eq!(tf.commands[0].command, "cfg"); assert_eq!(tf.commands[1].command, "verify"); match tf.isa_spec { - IsaSpec::None(s) => assert!(!s.enable_float()), + IsaSpec::None(s) => { + assert!(s.enable_verifier()); + assert!(!s.enable_float()); + } _ => panic!("unexpected ISAs"), } assert_eq!(tf.preamble_comments.len(), 2);