Composing Source-to-Source Data-Flow Transformations with Rewriting Strategies and Dependent Dynamic...

download Composing Source-to-Source Data-Flow Transformations with Rewriting Strategies and Dependent Dynamic Rewrite Rules

of 72

  • date post

    05-Dec-2014
  • Category

    Technology

  • view

    665
  • download

    0

Embed Size (px)

description

Slides for talk at Compiler Construction 2005 in Edinburgh based on the paper with the same title by Karina Olmos and Eelco Visser

Transcript of Composing Source-to-Source Data-Flow Transformations with Rewriting Strategies and Dependent Dynamic...

  • 1. Composing Source-to-Source Data-Flow Transformations with Rewriting Strategies and Dependent Dynamic Rewrite Rules Karina Olmos & Eelco Visser Institute of Information & Computing Sciences Utrecht University The Netherlands April 5, 2005 CC05 Edinburgh
  • 2. Source-to-Source Transformations Goal: transformation tools for the working programmer Transformations on various programming languages General-purpose languages (Embedded) domain-specic languages Combine dierent types of transformations Program generation and meta-programming Simplication (Domain-specic) optimization Data-ow transformations Source-to-source Transformations on abstract syntax trees Concise and reusable http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 3. Source-to-Source Data-Flow Transformations Goal: transformation tools for the working programmer Transformations on various programming languages General-purpose languages (Embedded) domain-specic languages Combine dierent types of transformations Program generation and meta-programming Simplication (Domain-specic) optimization Data-ow transformations Source-to-source Transformations on abstract syntax trees Concise and reusable http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 4. Rewriting Strategies and Dynamic Rewrite Rules Stratego/XT: language + tools for program transformation XT: infrastructure for transformation systems Stratego: high-level language for program transformation Not tied to one type of transformation or language http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 5. Rewriting Strategies and Dynamic Rewrite Rules Stratego/XT: language + tools for program transformation XT: infrastructure for transformation systems Stratego: high-level language for program transformation Not tied to one type of transformation or language Stratego paradigm Rewrite rules for basic transformation steps Programmable rewriting strategies for controlling rules Dynamic rules for context-sensitive transformation Concrete syntax for patterns http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 6. Rewriting Strategies and Dynamic Rewrite Rules Stratego/XT: language + tools for program transformation XT: infrastructure for transformation systems Stratego: high-level language for program transformation Not tied to one type of transformation or language Stratego paradigm Rewrite rules for basic transformation steps Programmable rewriting strategies for controlling rules Dynamic rules for context-sensitive transformation Concrete syntax for patterns Contributions Dependent dynamic rules Generic data-ow strategies Combination of transformations http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 7. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) y := x * 7 Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 8. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) y := x * 7 Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 9. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 10. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 11. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 12. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 13. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 14. Rewrite Rules and Strategies Constant folding y := x * (3 + 4) Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 15. Rewrite Rules and Strategies Constant folding y := x * 7 Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 16. Rewrite Rules and Strategies Constant folding y := x * 7 Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i * j ] -> | k ] where (i, j) => k [ | [ | AddZero : | 0 + e ] -> | e ] [ | [ | Constant folding strategy (bottom-up) EvalBinOp = EvalAdd < AddZero < EvalMul < EvalOther + + + try(s) = s < id + constfold = all(constfold); try(EvalBinOp) http://www.strategoxt.org Dependent Dynamic Rewrite Rules
  • 17. Rewrite Rules and Strategies Constant folding y := x * 7 Constant folding rules EvalAdd : | i + j ] -> | k ] where (i, j) => k [ | [ | EvalMul : | i