Add early-stage optimization crate (#556)
* Add simple constant folding and folding tests
This commit is contained in:
committed by
Dan Gohman
parent
bdcc06eb15
commit
3409af7c07
@@ -22,11 +22,11 @@ use licm::do_licm;
|
||||
use loop_analysis::LoopAnalysis;
|
||||
use nan_canonicalization::do_nan_canonicalization;
|
||||
use postopt::do_postopt;
|
||||
use preopt::do_preopt;
|
||||
use regalloc;
|
||||
use result::CodegenResult;
|
||||
use settings::{FlagsOrIsa, OptLevel};
|
||||
use simple_gvn::do_simple_gvn;
|
||||
use simple_preopt::do_preopt;
|
||||
use std::vec::Vec;
|
||||
use timing;
|
||||
use unreachable_code::eliminate_unreachable_code;
|
||||
|
||||
@@ -104,12 +104,12 @@ mod nan_canonicalization;
|
||||
mod partition_slice;
|
||||
mod postopt;
|
||||
mod predicates;
|
||||
mod preopt;
|
||||
mod ref_slice;
|
||||
mod regalloc;
|
||||
mod result;
|
||||
mod scoped_hash_map;
|
||||
mod simple_gvn;
|
||||
mod simple_preopt;
|
||||
mod stack_layout;
|
||||
mod topo_order;
|
||||
mod unreachable_code;
|
||||
|
||||
@@ -124,7 +124,7 @@ mod details {
|
||||
}
|
||||
|
||||
/// Accumulated timing information for a single pass.
|
||||
#[derive(Default)]
|
||||
#[derive(Default, Copy, Clone)]
|
||||
struct PassTime {
|
||||
/// Total time spent running this pass including children.
|
||||
total: Duration,
|
||||
@@ -134,17 +134,24 @@ mod details {
|
||||
}
|
||||
|
||||
/// Accumulated timing for all passes.
|
||||
#[derive(Default)]
|
||||
pub struct PassTimes {
|
||||
pass: [PassTime; NUM_PASSES],
|
||||
}
|
||||
|
||||
impl Default for PassTimes {
|
||||
fn default() -> Self {
|
||||
PassTimes {
|
||||
pass: [Default::default(); NUM_PASSES],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for PassTimes {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
writeln!(f, "======== ======== ==================================")?;
|
||||
writeln!(f, " Total Self Pass")?;
|
||||
writeln!(f, "-------- -------- ----------------------------------")?;
|
||||
for (time, desc) in self.pass.iter().zip(&DESCRIPTIONS) {
|
||||
for (time, desc) in self.pass.iter().zip(&DESCRIPTIONS[..]) {
|
||||
// Omit passes that haven't run.
|
||||
if time.total == Duration::default() {
|
||||
continue;
|
||||
@@ -212,7 +219,7 @@ mod details {
|
||||
/// Add `timings` to the accumulated timings for the current thread.
|
||||
pub fn add_to_current(times: &PassTimes) {
|
||||
PASS_TIME.with(|rc| {
|
||||
for (a, b) in rc.borrow_mut().pass.iter_mut().zip(×.pass) {
|
||||
for (a, b) in rc.borrow_mut().pass.iter_mut().zip(×.pass[..]) {
|
||||
a.total += b.total;
|
||||
a.child += b.child;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user