1use crate::api::*;
4
5impl OptimizationOptions {
7 pub fn reader_file_type(&mut self, value: FileType) -> &mut Self {
9 self.reader.file_type = value;
10 self
11 }
12
13 pub fn writer_file_type(&mut self, value: FileType) -> &mut Self {
15 self.writer.file_type = value;
16 self
17 }
18
19 pub fn set_converge(&mut self) -> &mut Self {
21 self.converge = true;
22 self
23 }
24
25 pub fn always_inline_max_size(&mut self, value: u32) -> &mut Self {
27 self.inlining.always_inline_max_size = value;
28 self
29 }
30
31 pub fn one_caller_inline_max_size(&mut self, value: u32) -> &mut Self {
33 self.inlining.one_caller_inline_max_size = value;
34 self
35 }
36
37 pub fn flexible_inline_max_size(&mut self, value: u32) -> &mut Self {
39 self.inlining.flexible_inline_max_size = value;
40 self
41 }
42
43 pub fn allow_functions_with_loops(&mut self, value: bool) -> &mut Self {
45 self.inlining.allow_functions_with_loops = value;
46 self
47 }
48
49 pub fn partial_inlining_ifs(&mut self, value: u32) -> &mut Self {
51 self.inlining.partial_inlining_ifs = value;
52 self
53 }
54
55 pub fn validate(&mut self, value: bool) -> &mut Self {
57 self.passopts.validate = value;
58 self
59 }
60
61 pub fn validate_globally(&mut self, value: bool) -> &mut Self {
63 self.passopts.validate_globally = value;
64 self
65 }
66
67 pub fn optimize_level(&mut self, value: OptimizeLevel) -> &mut Self {
69 self.passopts.optimize_level = value;
70 self
71 }
72
73 pub fn shrink_level(&mut self, value: ShrinkLevel) -> &mut Self {
75 self.passopts.shrink_level = value;
76 self
77 }
78
79 pub fn traps_never_happen(&mut self, value: bool) -> &mut Self {
81 self.passopts.traps_never_happen = value;
82 self
83 }
84
85 pub fn low_memory_unused(&mut self, value: bool) -> &mut Self {
87 self.passopts.low_memory_unused = value;
88 self
89 }
90
91 pub fn fast_math(&mut self, value: bool) -> &mut Self {
93 self.passopts.fast_math = value;
94 self
95 }
96
97 pub fn zero_filled_memory(&mut self, value: bool) -> &mut Self {
99 self.passopts.zero_filled_memory = value;
100 self
101 }
102
103 pub fn debug_info(&mut self, value: bool) -> &mut Self {
105 self.passopts.debug_info = value;
106 self
107 }
108
109 pub fn set_pass_arg(&mut self, key: &str, value: &str) -> &mut Self {
111 self.passopts
112 .arguments
113 .insert(key.to_string(), value.to_string());
114 self
115 }
116
117 pub fn add_default_passes(&mut self, value: bool) -> &mut Self {
119 self.passes.add_default_passes = value;
120 self
121 }
122
123 pub fn add_pass(&mut self, value: Pass) -> &mut Self {
125 self.passes.more_passes.push(value);
126 self
127 }
128
129 pub fn mvp_features_only(&mut self) -> &mut Self {
131 self.features.baseline = FeatureBaseline::MvpOnly;
132 self
133 }
134
135 pub fn all_features(&mut self) -> &mut Self {
137 self.features.baseline = FeatureBaseline::All;
138 self
139 }
140
141 pub fn enable_feature(&mut self, feature: Feature) -> &mut Self {
146 self.features.enabled.insert(feature);
147 self
148 }
149
150 pub fn disable_feature(&mut self, feature: Feature) -> &mut Self {
155 self.features.disabled.insert(feature);
156 self
157 }
158}