Skip to content
Snippets Groups Projects
Commit eebd3cef authored by Russel Arbore's avatar Russel Arbore
Browse files

Skeleton SROA

parent e4acc826
No related branches found
No related tags found
1 merge request!25Misc. improvements
This commit is part of merge request !25. Comments created here will be created in the context of that merge request.
......@@ -226,6 +226,9 @@ impl<'a> PartitionContext<'a> {
// pointers to some memory at the LLVM IR level. This memory is passed
// in as a parameter for anything involving arrays, and is alloca-ed for
// product and summation types.
// TODO: actually do this ^ for products. Right now, products are still
// done at the LLVM struct level w/ GEP and so on. Apologies for anyone
// else reading this comment.
let mut generate_index_code = |collect: NodeID, indices: &[Index]| -> std::fmt::Result {
// Step 1: calculate the list of collection types corresponding to
// each index.
......
......@@ -5,15 +5,17 @@ pub mod dce;
pub mod fork_guard_elim;
pub mod forkify;
pub mod gvn;
pub mod phi_elim;
pub mod pass;
pub mod phi_elim;
pub mod pred;
pub mod sroa;
pub use crate::ccp::*;
pub use crate::dce::*;
pub use crate::fork_guard_elim::*;
pub use crate::forkify::*;
pub use crate::gvn::*;
pub use crate::phi_elim::*;
pub use crate::fork_guard_elim::*;
pub use crate::pass::*;
pub use crate::phi_elim::*;
pub use crate::pred::*;
pub use crate::sroa::*;
......@@ -29,6 +29,7 @@ pub enum Pass {
PhiElim,
ForkGuardElim,
Predication,
SROA,
Verify,
// Parameterized over whether analyses that aid visualization are necessary.
// Useful to set to false if displaying a potentially broken module.
......@@ -364,6 +365,11 @@ impl PassManager {
)
}
}
Pass::SROA => {
for idx in 0..self.module.functions.len() {
sroa(&mut self.module.functions[idx])
}
}
Pass::Verify => {
let (
def_uses,
......
extern crate hercules_ir;
use self::hercules_ir::ir::*;
/*
* Top level function to run SROA, intraprocedurally. Product values can be used
* and created by a relatively small number of nodes. Here are *all* of them:
*
* - Phi: can merge SSA values of products - these get broken up into phis on
* the individual fields
*
* - Reduce: similarly to phis, reduce nodes can cycle product values through
* reduction loops - these get broken up into reduces on the fields
*
* + Return: can return a product - these are untouched, and are the sinks for
* unbroken product values
*
* + Parameter: can introduce a product - these are untouched, and are the
* sources for unbroken product values
*
* - Constant: can introduce a product - these are broken up into constants for
* the individual fields
*
* - Ternary: the select ternary operator can select between products - these
* are broken up into ternary nodes for the individual fields
*
* + Call: the call node can use a product value as an argument to another
* function, and can produce a product value as a result - these are
* untouched, and are the sink and source for unbroken product values
*
* - Read: the read node reads primitive fields from product values - these get
* replaced by a direct use of the field value from the broken product value,
* but are retained when the product value is unbroken
*
* - Write: the write node writes primitive fields in product values - these get
* replaced by a direct def of the field value from the broken product value,
* but are retained when the product value is unbroken
*
* The nodes above with the list marker "+" are retained for maintaining API/ABI
* compatability with other Hercules functions and the host code.
*/
pub fn sroa(function: &mut Function) {}
......@@ -20,15 +20,15 @@ extern crate hercules_ir;
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
src_file : String,
src_file: String,
#[clap(short, long)]
verify : bool,
#[clap(long="verify-all")]
verify_all : bool,
#[arg(short, long="x-dot")]
x_dot : bool,
verify: bool,
#[clap(long = "verify-all")]
verify_all: bool,
#[arg(short, long = "x-dot")]
x_dot: bool,
#[arg(short, long, value_name = "OUTPUT")]
output : Option<String>,
output: Option<String>,
}
macro_rules! add_verified_pass {
......@@ -61,6 +61,7 @@ fn main() {
pm.add_pass(hercules_opt::pass::Pass::Verify);
}
add_verified_pass!(pm, args, PhiElim);
add_pass!(pm, args, SROA);
add_pass!(pm, args, CCP);
add_pass!(pm, args, DCE);
add_pass!(pm, args, GVN);
......@@ -80,16 +81,17 @@ fn main() {
let mut path = PathBuf::from(src_file);
path.set_extension("hbin");
println!("{:?}", path);
pm.add_pass(
hercules_opt::pass::Pass::Codegen(path.to_str().unwrap().to_string()));
},
pm.add_pass(hercules_opt::pass::Pass::Codegen(
path.to_str().unwrap().to_string(),
));
}
}
let _ = pm.run_passes();
},
}
Err(errs) => {
for err in errs{
for err in errs {
eprintln!("{}", err);
}
},
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment