@@ -21,11 +21,30 @@ use crate::{
21
21
EntityRef , Operation , OperationName , OperationRef ,
22
22
} ;
23
23
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.
29
48
#[ derive( Default ) ]
30
49
pub struct Print {
31
50
op_filter : Option < OpFilter > ,
0 commit comments