Skip to content

Commit 01dae73

Browse files
Change Print struct documentation
Signed-off-by: Tomas Fabrizio Orsi <[email protected]>
1 parent 3838fb6 commit 01dae73

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

hir/src/pass.rs

+24-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,30 @@ use crate::{
2121
EntityRef, Operation, OperationName, OperationRef,
2222
};
2323

24-
/// Struct that handles IR printing, based on provided configuration.
25-
/// It is configured via the following CLI flags:
26-
/// -Z print-ir-after-all: Enable IR printing for every pass.
27-
/// -Z print-ir-after-pass: Enable IR printing only for some passes.
28-
/// -Z print-ir-after-modified.: Only print the IR if it has been been modified.
24+
/// Struct that handles IR printing, based on the IRPRintingConfig passed during creation. Currently,
25+
/// this struct is managed by the PassManager's PassInstrumentor, which calls the Print struct via
26+
/// its PassInstrumentation trait.
27+
///
28+
///Print currently implements the following PassInstrumentation functions:
29+
/// - run_before_pipeline: This gets called before the entire pass pipeline, but it will only
30+
/// display output if the "only_when_modified" option is set to true. This is done to showcase the
31+
/// IR before any pass gets applied.
32+
/// - run_before_pass: This is called before each pass. This function is used to display the IR
33+
/// right before a specific Pass gets applied. If "only_when_modified" is set to true, this
34+
/// function will not display output.
35+
/// - run_after_pass: This is called after each pass. This function is used to display the
36+
/// modifications done to the IR by a specific Pass.
37+
///
38+
/// NOTE: "only_when_modified" disables "run_before_pass" because it prints the IR before the pass
39+
/// is run, so there is no opportunity to check if the pass will actually modify the IR (since this
40+
/// is done later in the pipeline). So, in order to display the changes, "run_before_pipeline" is
41+
/// enabled. This has the effect of showing the IR before any passes, and then showing the IR only
42+
/// when it gets modified. the IR twice. All those functions call the [Print::print_ir] function,
43+
/// which handles IR printing based on Print's configuration.
44+
///
45+
/// It is important to note that the [Print::print_ir] function is only calling the Display
46+
/// implementation of the specified operation. This means, that the format in which the Operation is
47+
/// displayed is handled by each Operation.
2948
#[derive(Default)]
3049
pub struct Print {
3150
op_filter: Option<OpFilter>,

0 commit comments

Comments
 (0)