diospyros

rules

  • vector rules

    • expand-zero-get: 0 -> (Get 0 0)
    • op -> vectorized op
    • litvec
  • is_all_same_memory_or_zero: 全ての変数が同一か

  • Custom SearcherApplyer 使っている

pub fn build_litvec_rule() -> Rewrite<VecLang, ()> {
	// ?a0  ?a1 ...
    let mem_vars = ids_with_prefix(&"a".to_string(), vector_width());
    let mut gets: Vec<String> = Vec::with_capacity(vector_width());
    for i in 0..vector_width() {
        gets.push(format!("(Get {} ?{}{})", mem_vars[i], "i", i))
    }
	// (Get ?a0 ?i0) (Get ?a1 ?i1) ...
    let all_gets = gets.join(" ");
 
    let searcher: Pattern<VecLang> = format!("(Vec {})", all_gets).parse().unwrap();
 
    let applier: Pattern<VecLang> = format!("(LitVec {})", all_gets).parse().unwrap();
 
    rw!("litvec"; { searcher } => { applier }
        if is_all_same_memory_or_zero(&mem_vars))
}
  • build_binop_rule: `(Vec (# ?a0 ?b0) (# ?a1 ?b1) …) -> (vec_# (Vec ?a0 ?a1 …) (Vec ?b0 ?b1 …))
  • build_unop_rule: (Vec (# ?a0) (# ?a1) ...) -> (vec_# ?a0 ?a1 ...)
  • build_binop_or_zero_rule
    • searcher: BinOpSearcher
      • match:
[src/binopsearcher.rs:43] &left_var.to_string() = "a"
[src/binopsearcher.rs:43] &right_var.to_string() = "b"
[src/binopsearcher.rs:43] &full_pattern.to_string() = "(Vec (+ ?a0 ?b0) (+ ?a1 ?b1) (+ ?a2 ?b2) (+ ?a3 ?b3))"
[src/binopsearcher.rs:43] &vec_pattern.to_string() = "(Vec ?x0 ?x1 ?x2 ?x3)"
[src/binopsearcher.rs:43] &op_pattern.to_string() = "(+ ?a ?b)"
[src/binopsearcher.rs:43] &zero_pattern.to_string() = "0"