]>
Commit | Line | Data |
---|---|---|
a1dfa0c6 XL |
1 | use super::abi::AbiBuilderMethods; |
2 | use super::asm::AsmBuilderMethods; | |
f035d41b | 3 | use super::coverageinfo::CoverageInfoBuilderMethods; |
a1dfa0c6 XL |
4 | use super::debuginfo::DebugInfoBuilderMethods; |
5 | use super::intrinsic::IntrinsicCallMethods; | |
60c5eb7d | 6 | use super::type_::ArgAbiMethods; |
a1dfa0c6 | 7 | use super::{HasCodegen, StaticBuilderMethods}; |
60c5eb7d | 8 | |
dfeec247 XL |
9 | use crate::common::{ |
10 | AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, | |
11 | }; | |
9fa01778 XL |
12 | use crate::mir::operand::OperandRef; |
13 | use crate::mir::place::PlaceRef; | |
14 | use crate::MemFlags; | |
60c5eb7d | 15 | |
1b1a35ee | 16 | use rustc_middle::ty::layout::{HasParamEnv, TyAndLayout}; |
ba9703b0 | 17 | use rustc_middle::ty::Ty; |
29967ef6 | 18 | use rustc_span::Span; |
c295e0f8 | 19 | use rustc_target::abi::{Abi, Align, Scalar, Size, WrappingRange}; |
60c5eb7d XL |
20 | use rustc_target::spec::HasTargetSpec; |
21 | ||
a1dfa0c6 XL |
22 | #[derive(Copy, Clone)] |
23 | pub enum OverflowOp { | |
24 | Add, | |
25 | Sub, | |
26 | Mul, | |
27 | } | |
28 | ||
dc9dc135 | 29 | pub trait BuilderMethods<'a, 'tcx>: |
a1dfa0c6 | 30 | HasCodegen<'tcx> |
f035d41b | 31 | + CoverageInfoBuilderMethods<'tcx> |
74b04a01 | 32 | + DebugInfoBuilderMethods |
60c5eb7d | 33 | + ArgAbiMethods<'tcx> |
a1dfa0c6 XL |
34 | + AbiBuilderMethods<'tcx> |
35 | + IntrinsicCallMethods<'tcx> | |
36 | + AsmBuilderMethods<'tcx> | |
dc9dc135 | 37 | + StaticBuilderMethods |
48663c56 XL |
38 | + HasParamEnv<'tcx> |
39 | + HasTargetSpec | |
a1dfa0c6 | 40 | { |
17df50a5 XL |
41 | fn build(cx: &'a Self::CodegenCx, llbb: Self::BasicBlock) -> Self; |
42 | ||
a1dfa0c6 | 43 | fn cx(&self) -> &Self::CodegenCx; |
a1dfa0c6 | 44 | fn llbb(&self) -> Self::BasicBlock; |
17df50a5 | 45 | |
29967ef6 | 46 | fn set_span(&mut self, span: Span); |
a1dfa0c6 | 47 | |
17df50a5 XL |
48 | // FIXME(eddyb) replace uses of this with `append_sibling_block`. |
49 | fn append_block(cx: &'a Self::CodegenCx, llfn: Self::Function, name: &str) -> Self::BasicBlock; | |
50 | ||
51 | fn append_sibling_block(&mut self, name: &str) -> Self::BasicBlock; | |
52 | ||
53 | // FIXME(eddyb) replace with callers using `append_sibling_block`. | |
54 | fn build_sibling_block(&mut self, name: &str) -> Self; | |
55 | ||
a1dfa0c6 XL |
56 | fn ret_void(&mut self); |
57 | fn ret(&mut self, v: Self::Value); | |
58 | fn br(&mut self, dest: Self::BasicBlock); | |
59 | fn cond_br( | |
60 | &mut self, | |
61 | cond: Self::Value, | |
62 | then_llbb: Self::BasicBlock, | |
63 | else_llbb: Self::BasicBlock, | |
64 | ); | |
65 | fn switch( | |
66 | &mut self, | |
67 | v: Self::Value, | |
68 | else_llbb: Self::BasicBlock, | |
1b1a35ee | 69 | cases: impl ExactSizeIterator<Item = (u128, Self::BasicBlock)>, |
532ac7d7 | 70 | ); |
a1dfa0c6 XL |
71 | fn invoke( |
72 | &mut self, | |
94222f64 | 73 | llty: Self::Type, |
a1dfa0c6 XL |
74 | llfn: Self::Value, |
75 | args: &[Self::Value], | |
76 | then: Self::BasicBlock, | |
77 | catch: Self::BasicBlock, | |
78 | funclet: Option<&Self::Funclet>, | |
79 | ) -> Self::Value; | |
80 | fn unreachable(&mut self); | |
532ac7d7 | 81 | |
a1dfa0c6 XL |
82 | fn add(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; |
83 | fn fadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
84 | fn fadd_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
85 | fn sub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
86 | fn fsub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
87 | fn fsub_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
88 | fn mul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
89 | fn fmul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
90 | fn fmul_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
91 | fn udiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
92 | fn exactudiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
93 | fn sdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
94 | fn exactsdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
95 | fn fdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
96 | fn fdiv_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
97 | fn urem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
98 | fn srem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
99 | fn frem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
100 | fn frem_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
101 | fn shl(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
102 | fn lshr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
103 | fn ashr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
dc9dc135 XL |
104 | fn unchecked_sadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; |
105 | fn unchecked_uadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
106 | fn unchecked_ssub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
107 | fn unchecked_usub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
108 | fn unchecked_smul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
109 | fn unchecked_umul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
a1dfa0c6 XL |
110 | fn and(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; |
111 | fn or(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
112 | fn xor(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
113 | fn neg(&mut self, v: Self::Value) -> Self::Value; | |
114 | fn fneg(&mut self, v: Self::Value) -> Self::Value; | |
115 | fn not(&mut self, v: Self::Value) -> Self::Value; | |
116 | ||
117 | fn checked_binop( | |
118 | &mut self, | |
119 | oop: OverflowOp, | |
9fa01778 | 120 | ty: Ty<'_>, |
a1dfa0c6 XL |
121 | lhs: Self::Value, |
122 | rhs: Self::Value, | |
123 | ) -> (Self::Value, Self::Value); | |
124 | ||
1b1a35ee XL |
125 | fn from_immediate(&mut self, val: Self::Value) -> Self::Value; |
126 | fn to_immediate(&mut self, val: Self::Value, layout: TyAndLayout<'_>) -> Self::Value { | |
c295e0f8 | 127 | if let Abi::Scalar(scalar) = layout.abi { |
1b1a35ee XL |
128 | self.to_immediate_scalar(val, scalar) |
129 | } else { | |
130 | val | |
131 | } | |
132 | } | |
c295e0f8 | 133 | fn to_immediate_scalar(&mut self, val: Self::Value, scalar: Scalar) -> Self::Value; |
1b1a35ee | 134 | |
e1599b0c XL |
135 | fn alloca(&mut self, ty: Self::Type, align: Align) -> Self::Value; |
136 | fn dynamic_alloca(&mut self, ty: Self::Type, align: Align) -> Self::Value; | |
dfeec247 | 137 | fn array_alloca(&mut self, ty: Self::Type, len: Self::Value, align: Align) -> Self::Value; |
a1dfa0c6 | 138 | |
136023e0 XL |
139 | fn load(&mut self, ty: Self::Type, ptr: Self::Value, align: Align) -> Self::Value; |
140 | fn volatile_load(&mut self, ty: Self::Type, ptr: Self::Value) -> Self::Value; | |
141 | fn atomic_load( | |
142 | &mut self, | |
143 | ty: Self::Type, | |
144 | ptr: Self::Value, | |
145 | order: AtomicOrdering, | |
146 | size: Size, | |
147 | ) -> Self::Value; | |
a1dfa0c6 | 148 | fn load_operand(&mut self, place: PlaceRef<'tcx, Self::Value>) |
dfeec247 | 149 | -> OperandRef<'tcx, Self::Value>; |
a1dfa0c6 | 150 | |
dfeec247 | 151 | /// Called for Rvalue::Repeat when the elem is neither a ZST nor optimizable using memset. |
532ac7d7 XL |
152 | fn write_operand_repeatedly( |
153 | self, | |
154 | elem: OperandRef<'tcx, Self::Value>, | |
155 | count: u64, | |
156 | dest: PlaceRef<'tcx, Self::Value>, | |
157 | ) -> Self; | |
158 | ||
c295e0f8 | 159 | fn range_metadata(&mut self, load: Self::Value, range: WrappingRange); |
a1dfa0c6 XL |
160 | fn nonnull_metadata(&mut self, load: Self::Value); |
161 | ||
162 | fn store(&mut self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value; | |
163 | fn store_with_flags( | |
164 | &mut self, | |
165 | val: Self::Value, | |
166 | ptr: Self::Value, | |
167 | align: Align, | |
168 | flags: MemFlags, | |
169 | ) -> Self::Value; | |
170 | fn atomic_store( | |
171 | &mut self, | |
172 | val: Self::Value, | |
173 | ptr: Self::Value, | |
174 | order: AtomicOrdering, | |
175 | size: Size, | |
176 | ); | |
177 | ||
94222f64 XL |
178 | fn gep(&mut self, ty: Self::Type, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value; |
179 | fn inbounds_gep( | |
180 | &mut self, | |
181 | ty: Self::Type, | |
182 | ptr: Self::Value, | |
183 | indices: &[Self::Value], | |
184 | ) -> Self::Value; | |
185 | fn struct_gep(&mut self, ty: Self::Type, ptr: Self::Value, idx: u64) -> Self::Value; | |
a1dfa0c6 XL |
186 | |
187 | fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
188 | fn sext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
f035d41b XL |
189 | fn fptoui_sat(&mut self, val: Self::Value, dest_ty: Self::Type) -> Option<Self::Value>; |
190 | fn fptosi_sat(&mut self, val: Self::Value, dest_ty: Self::Type) -> Option<Self::Value>; | |
a1dfa0c6 XL |
191 | fn fptoui(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; |
192 | fn fptosi(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
193 | fn uitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
194 | fn sitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
195 | fn fptrunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
196 | fn fpext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
197 | fn ptrtoint(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
198 | fn inttoptr(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
199 | fn bitcast(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
200 | fn intcast(&mut self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value; | |
201 | fn pointercast(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
202 | ||
203 | fn icmp(&mut self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
204 | fn fcmp(&mut self, op: RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; | |
205 | ||
a1dfa0c6 XL |
206 | fn memcpy( |
207 | &mut self, | |
208 | dst: Self::Value, | |
209 | dst_align: Align, | |
210 | src: Self::Value, | |
211 | src_align: Align, | |
212 | size: Self::Value, | |
213 | flags: MemFlags, | |
214 | ); | |
215 | fn memmove( | |
216 | &mut self, | |
217 | dst: Self::Value, | |
218 | dst_align: Align, | |
219 | src: Self::Value, | |
220 | src_align: Align, | |
221 | size: Self::Value, | |
222 | flags: MemFlags, | |
223 | ); | |
224 | fn memset( | |
225 | &mut self, | |
226 | ptr: Self::Value, | |
227 | fill_byte: Self::Value, | |
228 | size: Self::Value, | |
229 | align: Align, | |
230 | flags: MemFlags, | |
231 | ); | |
232 | ||
a1dfa0c6 XL |
233 | fn select( |
234 | &mut self, | |
235 | cond: Self::Value, | |
236 | then_val: Self::Value, | |
237 | else_val: Self::Value, | |
238 | ) -> Self::Value; | |
239 | ||
240 | fn va_arg(&mut self, list: Self::Value, ty: Self::Type) -> Self::Value; | |
241 | fn extract_element(&mut self, vec: Self::Value, idx: Self::Value) -> Self::Value; | |
a1dfa0c6 | 242 | fn vector_splat(&mut self, num_elts: usize, elt: Self::Value) -> Self::Value; |
a1dfa0c6 XL |
243 | fn extract_value(&mut self, agg_val: Self::Value, idx: u64) -> Self::Value; |
244 | fn insert_value(&mut self, agg_val: Self::Value, elt: Self::Value, idx: u64) -> Self::Value; | |
245 | ||
246 | fn landing_pad( | |
247 | &mut self, | |
248 | ty: Self::Type, | |
249 | pers_fn: Self::Value, | |
250 | num_clauses: usize, | |
251 | ) -> Self::Value; | |
a1dfa0c6 XL |
252 | fn set_cleanup(&mut self, landing_pad: Self::Value); |
253 | fn resume(&mut self, exn: Self::Value) -> Self::Value; | |
254 | fn cleanup_pad(&mut self, parent: Option<Self::Value>, args: &[Self::Value]) -> Self::Funclet; | |
255 | fn cleanup_ret( | |
256 | &mut self, | |
257 | funclet: &Self::Funclet, | |
258 | unwind: Option<Self::BasicBlock>, | |
259 | ) -> Self::Value; | |
260 | fn catch_pad(&mut self, parent: Self::Value, args: &[Self::Value]) -> Self::Funclet; | |
a1dfa0c6 XL |
261 | fn catch_switch( |
262 | &mut self, | |
263 | parent: Option<Self::Value>, | |
264 | unwind: Option<Self::BasicBlock>, | |
265 | num_handlers: usize, | |
266 | ) -> Self::Value; | |
267 | fn add_handler(&mut self, catch_switch: Self::Value, handler: Self::BasicBlock); | |
268 | fn set_personality_fn(&mut self, personality: Self::Value); | |
269 | ||
270 | fn atomic_cmpxchg( | |
271 | &mut self, | |
272 | dst: Self::Value, | |
273 | cmp: Self::Value, | |
274 | src: Self::Value, | |
275 | order: AtomicOrdering, | |
276 | failure_order: AtomicOrdering, | |
277 | weak: bool, | |
278 | ) -> Self::Value; | |
279 | fn atomic_rmw( | |
280 | &mut self, | |
281 | op: AtomicRmwBinOp, | |
282 | dst: Self::Value, | |
283 | src: Self::Value, | |
284 | order: AtomicOrdering, | |
285 | ) -> Self::Value; | |
286 | fn atomic_fence(&mut self, order: AtomicOrdering, scope: SynchronizationScope); | |
a1dfa0c6 XL |
287 | fn set_invariant_load(&mut self, load: Self::Value); |
288 | ||
a1dfa0c6 XL |
289 | /// Called for `StorageLive` |
290 | fn lifetime_start(&mut self, ptr: Self::Value, size: Size); | |
291 | ||
292 | /// Called for `StorageDead` | |
293 | fn lifetime_end(&mut self, ptr: Self::Value, size: Size); | |
294 | ||
f035d41b XL |
295 | fn instrprof_increment( |
296 | &mut self, | |
297 | fn_name: Self::Value, | |
298 | hash: Self::Value, | |
299 | num_counters: Self::Value, | |
300 | index: Self::Value, | |
3dfed10e | 301 | ); |
f035d41b | 302 | |
a1dfa0c6 XL |
303 | fn call( |
304 | &mut self, | |
94222f64 | 305 | llty: Self::Type, |
a1dfa0c6 XL |
306 | llfn: Self::Value, |
307 | args: &[Self::Value], | |
308 | funclet: Option<&Self::Funclet>, | |
309 | ) -> Self::Value; | |
310 | fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; | |
311 | ||
a1dfa0c6 XL |
312 | fn do_not_inline(&mut self, llret: Self::Value); |
313 | } |