1
Fork 0

Capitalize debugging opts and make them u64

This commit is contained in:
Alex Crichton 2014-01-20 13:55:10 -08:00
parent a8807771b2
commit 254e35c268
3 changed files with 91 additions and 90 deletions

View file

@ -126,7 +126,7 @@ pub mod write {
session::Default => lib::llvm::CodeGenLevelDefault, session::Default => lib::llvm::CodeGenLevelDefault,
session::Aggressive => lib::llvm::CodeGenLevelAggressive, session::Aggressive => lib::llvm::CodeGenLevelAggressive,
}; };
let use_softfp = sess.opts.debugging_opts & session::use_softfp != 0; let use_softfp = sess.opts.debugging_opts & session::USE_SOFTFP != 0;
let tm = sess.targ_cfg.target_strs.target_triple.with_c_str(|T| { let tm = sess.targ_cfg.target_strs.target_triple.with_c_str(|T| {
sess.opts.target_cpu.with_c_str(|CPU| { sess.opts.target_cpu.with_c_str(|CPU| {
@ -987,7 +987,7 @@ fn link_natively(sess: Session, dylib: bool, obj_filename: &Path,
let mut cc_args = sess.targ_cfg.target_strs.cc_args.clone(); let mut cc_args = sess.targ_cfg.target_strs.cc_args.clone();
cc_args.push_all_move(link_args(sess, dylib, tmpdir.path(), cc_args.push_all_move(link_args(sess, dylib, tmpdir.path(),
obj_filename, out_filename)); obj_filename, out_filename));
if (sess.opts.debugging_opts & session::print_link_args) != 0 { if (sess.opts.debugging_opts & session::PRINT_LINK_ARGS) != 0 {
println!("{} link args: '{}'", cc_prog, cc_args.connect("' '")); println!("{} link args: '{}'", cc_prog, cc_args.connect("' '"));
} }

View file

@ -759,22 +759,22 @@ pub fn build_session_options(binary: ~str,
} }
} }
let mut debugging_opts = 0u; let mut debugging_opts = 0;
let debug_flags = matches.opt_strs("Z"); let debug_flags = matches.opt_strs("Z");
let debug_map = session::debugging_opts_map(); let debug_map = session::debugging_opts_map();
for debug_flag in debug_flags.iter() { for debug_flag in debug_flags.iter() {
let mut this_bit = 0u; let mut this_bit = 0;
for tuple in debug_map.iter() { for tuple in debug_map.iter() {
let (name, bit) = match *tuple { (ref a, _, b) => (a, b) }; let (name, bit) = match *tuple { (ref a, _, b) => (a, b) };
if *name == *debug_flag { this_bit = bit; break; } if *name == *debug_flag { this_bit = bit; break; }
} }
if this_bit == 0u { if this_bit == 0 {
early_error(demitter, format!("unknown debug flag: {}", *debug_flag)) early_error(demitter, format!("unknown debug flag: {}", *debug_flag))
} }
debugging_opts |= this_bit; debugging_opts |= this_bit;
} }
if debugging_opts & session::debug_llvm != 0 { if debugging_opts & session::DEBUG_LLVM != 0 {
unsafe { llvm::LLVMSetDebug(1); } unsafe { llvm::LLVMSetDebug(1); }
} }
@ -797,7 +797,7 @@ pub fn build_session_options(binary: ~str,
let target_feature = matches.opt_str("target-feature").unwrap_or(~""); let target_feature = matches.opt_str("target-feature").unwrap_or(~"");
let save_temps = matches.opt_present("save-temps"); let save_temps = matches.opt_present("save-temps");
let opt_level = { let opt_level = {
if (debugging_opts & session::no_opt) != 0 { if (debugging_opts & session::NO_OPT) != 0 {
No No
} else if matches.opt_present("O") { } else if matches.opt_present("O") {
if matches.opt_present("opt-level") { if matches.opt_present("opt-level") {
@ -816,9 +816,9 @@ pub fn build_session_options(binary: ~str,
} }
} else { No } } else { No }
}; };
let gc = debugging_opts & session::gc != 0; let gc = debugging_opts & session::GC != 0;
let extra_debuginfo = debugging_opts & session::extra_debug_info != 0; let extra_debuginfo = debugging_opts & session::EXTRA_DEBUG_INFO != 0;
let debuginfo = debugging_opts & session::debug_info != 0 || let debuginfo = debugging_opts & session::DEBUG_INFO != 0 ||
extra_debuginfo; extra_debuginfo;
let addl_lib_search_paths = matches.opt_strs("L").map(|s| { let addl_lib_search_paths = matches.opt_strs("L").map(|s| {

View file

@ -41,88 +41,89 @@ pub struct Config {
macro_rules! debugging_opts( macro_rules! debugging_opts(
([ $opt:ident ] $cnt:expr ) => ( ([ $opt:ident ] $cnt:expr ) => (
pub static $opt: uint = 1 << $cnt; pub static $opt: u64 = 1 << $cnt;
); );
([ $opt:ident, $($rest:ident),* ] $cnt:expr ) => ( ([ $opt:ident, $($rest:ident),* ] $cnt:expr ) => (
pub static $opt: uint = 1 << $cnt; pub static $opt: u64 = 1 << $cnt;
debugging_opts!([ $($rest),* ] $cnt + 1) debugging_opts!([ $($rest),* ] $cnt + 1)
) )
) )
debugging_opts!( debugging_opts!(
[ [
verbose, VERBOSE,
time_passes, TIME_PASSES,
count_llvm_insns, COUNT_LLVM_INSNS,
time_llvm_passes, TIME_LLVM_PASSES,
trans_stats, TRANS_STATS,
asm_comments, ASM_COMMENTS,
no_verify, NO_VERIFY,
borrowck_stats, BORROWCK_STATS,
no_landing_pads, NO_LANDING_PADS,
debug_llvm, DEBUG_LLVM,
count_type_sizes, COUNT_TYPE_SIZES,
meta_stats, META_STATS,
no_opt, NO_OPT,
gc, GC,
debug_info, DEBUG_INFO,
extra_debug_info, EXTRA_DEBUG_INFO,
print_link_args, PRINT_LINK_ARGS,
print_llvm_passes, PRINT_LLVM_PASSES,
no_vectorize_loops, NO_VECTORIZE_LOOPS,
no_vectorize_slp, NO_VECTORIZE_SLP,
no_prepopulate_passes, NO_PREPOPULATE_PASSES,
use_softfp, USE_SOFTFP,
gen_crate_map, GEN_CRATE_MAP,
prefer_dynamic, PREFER_DYNAMIC,
no_integrated_as, NO_INTEGRATED_AS,
lto LTO
] ]
0 0
) )
pub fn debugging_opts_map() -> ~[(&'static str, &'static str, uint)] { pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] {
~[("verbose", "in general, enable more debug printouts", verbose), ~[("verbose", "in general, enable more debug printouts", VERBOSE),
("time-passes", "measure time of each rustc pass", time_passes), ("time-passes", "measure time of each rustc pass", TIME_PASSES),
("count-llvm-insns", "count where LLVM \ ("count-llvm-insns", "count where LLVM \
instrs originate", count_llvm_insns), instrs originate", COUNT_LLVM_INSNS),
("time-llvm-passes", "measure time of each LLVM pass", ("time-llvm-passes", "measure time of each LLVM pass",
time_llvm_passes), TIME_LLVM_PASSES),
("trans-stats", "gather trans statistics", trans_stats), ("trans-stats", "gather trans statistics", TRANS_STATS),
("asm-comments", "generate comments into the assembly (may change behavior)", asm_comments), ("asm-comments", "generate comments into the assembly (may change behavior)",
("no-verify", "skip LLVM verification", no_verify), ASM_COMMENTS),
("borrowck-stats", "gather borrowck statistics", borrowck_stats), ("no-verify", "skip LLVM verification", NO_VERIFY),
("borrowck-stats", "gather borrowck statistics", BORROWCK_STATS),
("no-landing-pads", "omit landing pads for unwinding", ("no-landing-pads", "omit landing pads for unwinding",
no_landing_pads), NO_LANDING_PADS),
("debug-llvm", "enable debug output from LLVM", debug_llvm), ("debug-llvm", "enable debug output from LLVM", DEBUG_LLVM),
("count-type-sizes", "count the sizes of aggregate types", ("count-type-sizes", "count the sizes of aggregate types",
count_type_sizes), COUNT_TYPE_SIZES),
("meta-stats", "gather metadata statistics", meta_stats), ("meta-stats", "gather metadata statistics", META_STATS),
("no-opt", "do not optimize, even if -O is passed", no_opt), ("no-opt", "do not optimize, even if -O is passed", NO_OPT),
("print-link-args", "Print the arguments passed to the linker", print_link_args), ("print-link-args", "Print the arguments passed to the linker",
("gc", "Garbage collect shared data (experimental)", gc), PRINT_LINK_ARGS),
("gc", "Garbage collect shared data (experimental)", GC),
("extra-debug-info", "Extra debugging info (experimental)", ("extra-debug-info", "Extra debugging info (experimental)",
extra_debug_info), EXTRA_DEBUG_INFO),
("debug-info", "Produce debug info (experimental)", debug_info), ("debug-info", "Produce debug info (experimental)", DEBUG_INFO),
("print-llvm-passes", ("print-llvm-passes",
"Prints the llvm optimization passes being run", "Prints the llvm optimization passes being run",
print_llvm_passes), PRINT_LLVM_PASSES),
("no-prepopulate-passes", ("no-prepopulate-passes",
"Don't pre-populate the pass managers with a list of passes, only use \ "Don't pre-populate the pass managers with a list of passes, only use \
the passes from --passes", the passes from --passes",
no_prepopulate_passes), NO_PREPOPULATE_PASSES),
("no-vectorize-loops", ("no-vectorize-loops",
"Don't run the loop vectorization optimization passes", "Don't run the loop vectorization optimization passes",
no_vectorize_loops), NO_VECTORIZE_LOOPS),
("no-vectorize-slp", ("no-vectorize-slp", "Don't run LLVM's SLP vectorization passes",
"Don't run LLVM's SLP vectorization passes", NO_VECTORIZE_SLP),
no_vectorize_slp), ("soft-float", "Generate software floating point library calls", USE_SOFTFP),
("soft-float", "Generate software floating point library calls", use_softfp), ("gen-crate-map", "Force generation of a toplevel crate map", GEN_CRATE_MAP),
("gen-crate-map", "Force generation of a toplevel crate map", gen_crate_map), ("prefer-dynamic", "Prefer dynamic linking to static linking", PREFER_DYNAMIC),
("prefer-dynamic", "Prefer dynamic linking to static linking", prefer_dynamic),
("no-integrated-as", ("no-integrated-as",
"Use external assembler rather than LLVM's integrated one", no_integrated_as), "Use external assembler rather than LLVM's integrated one", NO_INTEGRATED_AS),
("lto", "Perform LLVM link-time optimizations", lto), ("lto", "Perform LLVM link-time optimizations", LTO),
] ]
} }
@ -169,7 +170,7 @@ pub struct Options {
parse_only: bool, parse_only: bool,
no_trans: bool, no_trans: bool,
no_analysis: bool, no_analysis: bool,
debugging_opts: uint, debugging_opts: u64,
android_cross_path: Option<~str>, android_cross_path: Option<~str>,
/// Whether to write dependency files. It's (enabled, optional filename). /// Whether to write dependency files. It's (enabled, optional filename).
write_dependency_info: (bool, Option<Path>), write_dependency_info: (bool, Option<Path>),
@ -292,56 +293,56 @@ impl Session_ {
pub fn diagnostic(&self) -> @diagnostic::SpanHandler { pub fn diagnostic(&self) -> @diagnostic::SpanHandler {
self.span_diagnostic self.span_diagnostic
} }
pub fn debugging_opt(&self, opt: uint) -> bool { pub fn debugging_opt(&self, opt: u64) -> bool {
(self.opts.debugging_opts & opt) != 0u (self.opts.debugging_opts & opt) != 0
} }
// This exists to help with refactoring to eliminate impossible // This exists to help with refactoring to eliminate impossible
// cases later on // cases later on
pub fn impossible_case(&self, sp: Span, msg: &str) -> ! { pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
self.span_bug(sp, format!("Impossible case reached: {}", msg)); self.span_bug(sp, format!("Impossible case reached: {}", msg));
} }
pub fn verbose(&self) -> bool { self.debugging_opt(verbose) } pub fn verbose(&self) -> bool { self.debugging_opt(VERBOSE) }
pub fn time_passes(&self) -> bool { self.debugging_opt(time_passes) } pub fn time_passes(&self) -> bool { self.debugging_opt(TIME_PASSES) }
pub fn count_llvm_insns(&self) -> bool { pub fn count_llvm_insns(&self) -> bool {
self.debugging_opt(count_llvm_insns) self.debugging_opt(COUNT_LLVM_INSNS)
} }
pub fn count_type_sizes(&self) -> bool { pub fn count_type_sizes(&self) -> bool {
self.debugging_opt(count_type_sizes) self.debugging_opt(COUNT_TYPE_SIZES)
} }
pub fn time_llvm_passes(&self) -> bool { pub fn time_llvm_passes(&self) -> bool {
self.debugging_opt(time_llvm_passes) self.debugging_opt(TIME_LLVM_PASSES)
} }
pub fn trans_stats(&self) -> bool { self.debugging_opt(trans_stats) } pub fn trans_stats(&self) -> bool { self.debugging_opt(TRANS_STATS) }
pub fn meta_stats(&self) -> bool { self.debugging_opt(meta_stats) } pub fn meta_stats(&self) -> bool { self.debugging_opt(META_STATS) }
pub fn asm_comments(&self) -> bool { self.debugging_opt(asm_comments) } pub fn asm_comments(&self) -> bool { self.debugging_opt(ASM_COMMENTS) }
pub fn no_verify(&self) -> bool { self.debugging_opt(no_verify) } pub fn no_verify(&self) -> bool { self.debugging_opt(NO_VERIFY) }
pub fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) } pub fn borrowck_stats(&self) -> bool { self.debugging_opt(BORROWCK_STATS) }
pub fn print_llvm_passes(&self) -> bool { pub fn print_llvm_passes(&self) -> bool {
self.debugging_opt(print_llvm_passes) self.debugging_opt(PRINT_LLVM_PASSES)
} }
pub fn no_prepopulate_passes(&self) -> bool { pub fn no_prepopulate_passes(&self) -> bool {
self.debugging_opt(no_prepopulate_passes) self.debugging_opt(NO_PREPOPULATE_PASSES)
} }
pub fn no_vectorize_loops(&self) -> bool { pub fn no_vectorize_loops(&self) -> bool {
self.debugging_opt(no_vectorize_loops) self.debugging_opt(NO_VECTORIZE_LOOPS)
} }
pub fn no_vectorize_slp(&self) -> bool { pub fn no_vectorize_slp(&self) -> bool {
self.debugging_opt(no_vectorize_slp) self.debugging_opt(NO_VECTORIZE_SLP)
} }
pub fn gen_crate_map(&self) -> bool { pub fn gen_crate_map(&self) -> bool {
self.debugging_opt(gen_crate_map) self.debugging_opt(GEN_CRATE_MAP)
} }
pub fn prefer_dynamic(&self) -> bool { pub fn prefer_dynamic(&self) -> bool {
self.debugging_opt(prefer_dynamic) self.debugging_opt(PREFER_DYNAMIC)
} }
pub fn no_integrated_as(&self) -> bool { pub fn no_integrated_as(&self) -> bool {
self.debugging_opt(no_integrated_as) self.debugging_opt(NO_INTEGRATED_AS)
} }
pub fn lto(&self) -> bool { pub fn lto(&self) -> bool {
self.debugging_opt(lto) self.debugging_opt(LTO)
} }
pub fn no_landing_pads(&self) -> bool { pub fn no_landing_pads(&self) -> bool {
self.debugging_opt(no_landing_pads) self.debugging_opt(NO_LANDING_PADS)
} }
// pointless function, now... // pointless function, now...
@ -387,7 +388,7 @@ pub fn basic_options() -> @Options {
parse_only: false, parse_only: false,
no_trans: false, no_trans: false,
no_analysis: false, no_analysis: false,
debugging_opts: 0u, debugging_opts: 0,
android_cross_path: None, android_cross_path: None,
write_dependency_info: (false, None), write_dependency_info: (false, None),
print_metas: (false, false, false), print_metas: (false, false, false),