cqlib_core/compile/transform/canonicalize/
config.rs1#[derive(Debug, Clone, PartialEq, Eq)]
17pub struct CanonicalizeConfig {
18 round_limit: u8,
19 recurse_control_flow: bool,
20 fold_gphase: bool,
21 canonicalize_instruction_form: bool,
22 drop_noops: bool,
23 canonicalize_barriers: bool,
24}
25
26impl Default for CanonicalizeConfig {
27 fn default() -> Self {
28 Self::production()
29 }
30}
31
32impl CanonicalizeConfig {
33 pub const fn production() -> Self {
35 Self {
36 round_limit: 8,
37 recurse_control_flow: true,
38 fold_gphase: true,
39 canonicalize_instruction_form: true,
40 drop_noops: true,
41 canonicalize_barriers: true,
42 }
43 }
44
45 pub const fn new() -> Self {
47 Self::production()
48 }
49
50 pub const fn with_round_limit(mut self, round_limit: u8) -> Self {
52 self.round_limit = round_limit;
53 self
54 }
55
56 pub const fn recurse_control_flow(mut self, enabled: bool) -> Self {
58 self.recurse_control_flow = enabled;
59 self
60 }
61
62 pub const fn fold_gphase(mut self, enabled: bool) -> Self {
64 self.fold_gphase = enabled;
65 self
66 }
67
68 pub const fn canonicalize_instruction_form(mut self, enabled: bool) -> Self {
70 self.canonicalize_instruction_form = enabled;
71 self
72 }
73
74 pub const fn drop_noops(mut self, enabled: bool) -> Self {
76 self.drop_noops = enabled;
77 self
78 }
79
80 pub const fn canonicalize_barriers(mut self, enabled: bool) -> Self {
82 self.canonicalize_barriers = enabled;
83 self
84 }
85
86 pub const fn round_limit(&self) -> u8 {
88 self.round_limit
89 }
90
91 pub const fn recurses_control_flow(&self) -> bool {
93 self.recurse_control_flow
94 }
95
96 pub const fn folds_gphase(&self) -> bool {
98 self.fold_gphase
99 }
100
101 pub const fn canonicalizes_instruction_form(&self) -> bool {
103 self.canonicalize_instruction_form
104 }
105
106 pub const fn drops_noops(&self) -> bool {
108 self.drop_noops
109 }
110
111 pub const fn canonicalizes_barriers(&self) -> bool {
113 self.canonicalize_barriers
114 }
115}