diff --git a/docs/content/en/docs/getting_started.md b/docs/content/en/docs/getting_started.md index 94e41b840..752438450 100644 --- a/docs/content/en/docs/getting_started.md +++ b/docs/content/en/docs/getting_started.md @@ -64,3 +64,45 @@ To run them manually, run ```bash pre-commit run --all-files ``` + +## Creating a New Pass + +The `templates` folder contains Python scripts to create boilerplate for new conversion or (dialect-specific) transform passes. + +### Conversion Pass + +To create a new conversion pass, run a command similar to the following: + +``` +python templates/templates.py new_conversion_pass \ +--source_dialect_name=CGGI \ +--source_dialect_namespace=cggi \ +--source_dialect_mnemonic=cggi \ +--target_dialect_name=TfheRust \ +--target_dialect_namespace=tfhe_rust \ +--target_dialect_mnemonic=tfhe_rust +``` + +In order to build the resulting code, you must fix the labeled `FIXME`s in the type converter and the op conversion patterns. + +### Transform Passes + +To create a transform or rewrite pass that operates on a dialect, run a command similar to the following: + +``` +python templates/templates.py new_dialect_transform \ +--pass_name=ForgetSecrets \ +--pass_flag=forget-secrets \ +--dialect_name=Secret \ +--dialect_namespace=secret \ +--force=false +``` + +If the transform does not operate from and to a specific dialect, use + +``` +python templates/templates.py new_transform \ +--pass_name=ForgetSecrets \ +--pass_flag=forget-secrets \ +--force=false +``` diff --git a/requirements-dev.txt b/requirements-dev.txt index 58c6c0866..39fdb77c8 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,2 +1,3 @@ fire==0.5.0 +jinja2==3.1.2 pre-commit==v3.3.3