1 use super::abi::AbiBuilderMethods;
2 use super::asm::AsmBuilderMethods;
3 use super::debuginfo::DebugInfoBuilderMethods;
4 use super::intrinsic::IntrinsicCallMethods;
5 use super::type_::ArgTypeMethods;
6 use super::{HasCodegen, StaticBuilderMethods};
7 use common::{AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope};
8 use mir::operand::OperandRef;
9 use mir::place::PlaceRef;
11 use rustc::ty::layout::{Align, Size};
17 use syntax::ast::AsmDialect;
19 #[derive(Copy, Clone)]
26 pub trait BuilderMethods<'a, 'tcx: 'a>:
28 + DebugInfoBuilderMethods<'tcx>
29 + ArgTypeMethods<'tcx>
30 + AbiBuilderMethods<'tcx>
31 + IntrinsicCallMethods<'tcx>
32 + AsmBuilderMethods<'tcx>
33 + StaticBuilderMethods<'tcx>
35 fn new_block<'b>(cx: &'a Self::CodegenCx, llfn: Self::Value, name: &'b str) -> Self;
36 fn with_cx(cx: &'a Self::CodegenCx) -> Self;
37 fn build_sibling_block<'b>(&self, name: &'b str) -> Self;
38 fn cx(&self) -> &Self::CodegenCx;
39 fn llfn(&self) -> Self::Value;
40 fn llbb(&self) -> Self::BasicBlock;
41 fn count_insn(&self, category: &str);
43 fn set_value_name(&mut self, value: Self::Value, name: &str);
44 fn position_at_end(&mut self, llbb: Self::BasicBlock);
45 fn position_at_start(&mut self, llbb: Self::BasicBlock);
46 fn ret_void(&mut self);
47 fn ret(&mut self, v: Self::Value);
48 fn br(&mut self, dest: Self::BasicBlock);
52 then_llbb: Self::BasicBlock,
53 else_llbb: Self::BasicBlock,
58 else_llbb: Self::BasicBlock,
65 then: Self::BasicBlock,
66 catch: Self::BasicBlock,
67 funclet: Option<&Self::Funclet>,
69 fn unreachable(&mut self);
70 fn add(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
71 fn fadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
72 fn fadd_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
73 fn sub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
74 fn fsub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
75 fn fsub_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
76 fn mul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
77 fn fmul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
78 fn fmul_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
79 fn udiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
80 fn exactudiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
81 fn sdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
82 fn exactsdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
83 fn fdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
84 fn fdiv_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
85 fn urem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
86 fn srem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
87 fn frem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
88 fn frem_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
89 fn shl(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
90 fn lshr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
91 fn ashr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
92 fn and(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
93 fn or(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
94 fn xor(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
95 fn neg(&mut self, v: Self::Value) -> Self::Value;
96 fn fneg(&mut self, v: Self::Value) -> Self::Value;
97 fn not(&mut self, v: Self::Value) -> Self::Value;
105 ) -> (Self::Value, Self::Value);
107 fn alloca(&mut self, ty: Self::Type, name: &str, align: Align) -> Self::Value;
108 fn dynamic_alloca(&mut self, ty: Self::Type, name: &str, align: Align) -> Self::Value;
117 fn load(&mut self, ptr: Self::Value, align: Align) -> Self::Value;
118 fn volatile_load(&mut self, ptr: Self::Value) -> Self::Value;
119 fn atomic_load(&mut self, ptr: Self::Value, order: AtomicOrdering, size: Size) -> Self::Value;
120 fn load_operand(&mut self, place: PlaceRef<'tcx, Self::Value>)
121 -> OperandRef<'tcx, Self::Value>;
123 fn range_metadata(&mut self, load: Self::Value, range: Range<u128>);
124 fn nonnull_metadata(&mut self, load: Self::Value);
126 fn store(&mut self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value;
138 order: AtomicOrdering,
142 fn gep(&mut self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value;
143 fn inbounds_gep(&mut self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value;
144 fn struct_gep(&mut self, ptr: Self::Value, idx: u64) -> Self::Value;
146 fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
147 fn sext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
148 fn fptoui(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
149 fn fptosi(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
150 fn uitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
151 fn sitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
152 fn fptrunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
153 fn fpext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
154 fn ptrtoint(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
155 fn inttoptr(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
156 fn bitcast(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
157 fn intcast(&mut self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value;
158 fn pointercast(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
160 fn icmp(&mut self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
161 fn fcmp(&mut self, op: RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
163 fn empty_phi(&mut self, ty: Self::Type) -> Self::Value;
167 vals: &[Self::Value],
168 bbs: &[Self::BasicBlock],
174 inputs: &[Self::Value],
179 ) -> Option<Self::Value>;
202 fill_byte: Self::Value,
208 fn minnum(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
209 fn maxnum(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
213 then_val: Self::Value,
214 else_val: Self::Value,
217 fn va_arg(&mut self, list: Self::Value, ty: Self::Type) -> Self::Value;
218 fn extract_element(&mut self, vec: Self::Value, idx: Self::Value) -> Self::Value;
231 fn vector_splat(&mut self, num_elts: usize, elt: Self::Value) -> Self::Value;
232 fn vector_reduce_fadd_fast(&mut self, acc: Self::Value, src: Self::Value) -> Self::Value;
233 fn vector_reduce_fmul_fast(&mut self, acc: Self::Value, src: Self::Value) -> Self::Value;
234 fn vector_reduce_add(&mut self, src: Self::Value) -> Self::Value;
235 fn vector_reduce_mul(&mut self, src: Self::Value) -> Self::Value;
236 fn vector_reduce_and(&mut self, src: Self::Value) -> Self::Value;
237 fn vector_reduce_or(&mut self, src: Self::Value) -> Self::Value;
238 fn vector_reduce_xor(&mut self, src: Self::Value) -> Self::Value;
239 fn vector_reduce_fmin(&mut self, src: Self::Value) -> Self::Value;
240 fn vector_reduce_fmax(&mut self, src: Self::Value) -> Self::Value;
241 fn vector_reduce_fmin_fast(&mut self, src: Self::Value) -> Self::Value;
242 fn vector_reduce_fmax_fast(&mut self, src: Self::Value) -> Self::Value;
243 fn vector_reduce_min(&mut self, src: Self::Value, is_signed: bool) -> Self::Value;
244 fn vector_reduce_max(&mut self, src: Self::Value, is_signed: bool) -> Self::Value;
245 fn extract_value(&mut self, agg_val: Self::Value, idx: u64) -> Self::Value;
246 fn insert_value(&mut self, agg_val: Self::Value, elt: Self::Value, idx: u64) -> Self::Value;
251 pers_fn: Self::Value,
254 fn add_clause(&mut self, landing_pad: Self::Value, clause: Self::Value);
255 fn set_cleanup(&mut self, landing_pad: Self::Value);
256 fn resume(&mut self, exn: Self::Value) -> Self::Value;
257 fn cleanup_pad(&mut self, parent: Option<Self::Value>, args: &[Self::Value]) -> Self::Funclet;
260 funclet: &Self::Funclet,
261 unwind: Option<Self::BasicBlock>,
263 fn catch_pad(&mut self, parent: Self::Value, args: &[Self::Value]) -> Self::Funclet;
264 fn catch_ret(&mut self, funclet: &Self::Funclet, unwind: Self::BasicBlock) -> Self::Value;
267 parent: Option<Self::Value>,
268 unwind: Option<Self::BasicBlock>,
271 fn add_handler(&mut self, catch_switch: Self::Value, handler: Self::BasicBlock);
272 fn set_personality_fn(&mut self, personality: Self::Value);
279 order: AtomicOrdering,
280 failure_order: AtomicOrdering,
288 order: AtomicOrdering,
290 fn atomic_fence(&mut self, order: AtomicOrdering, scope: SynchronizationScope);
291 fn add_case(&mut self, s: Self::Value, on_val: Self::Value, dest: Self::BasicBlock);
292 fn add_incoming_to_phi(&mut self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock);
293 fn set_invariant_load(&mut self, load: Self::Value);
295 /// Returns the ptr value that should be used for storing `val`.
296 fn check_store(&mut self, val: Self::Value, ptr: Self::Value) -> Self::Value;
298 /// Returns the args that should be used for a call to `llfn`.
303 args: &'b [Self::Value],
304 ) -> Cow<'b, [Self::Value]>
306 [Self::Value]: ToOwned;
308 /// Called for `StorageLive`
309 fn lifetime_start(&mut self, ptr: Self::Value, size: Size);
311 /// Called for `StorageDead`
312 fn lifetime_end(&mut self, ptr: Self::Value, size: Size);
317 args: &[Self::Value],
318 funclet: Option<&Self::Funclet>,
320 fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
322 unsafe fn delete_basic_block(&mut self, bb: Self::BasicBlock);
323 fn do_not_inline(&mut self, llret: Self::Value);