]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_codegen_ssa/interfaces/builder.rs
All Builder methods now take &mut self instead of &self
[rust.git] / src / librustc_codegen_ssa / interfaces / builder.rs
index 38ab019343adaaf929a3e5d4bb153eb5693f66bf..c80eb27191140d4c7137bd726d3fb551b5fc9f0d 100644 (file)
@@ -53,98 +53,115 @@ fn cond_br(
         then_llbb: Self::BasicBlock,
         else_llbb: Self::BasicBlock,
     );
-    fn switch(&self, v: Self::Value, else_llbb: Self::BasicBlock, num_cases: usize) -> Self::Value;
+    fn switch(
+        &mut self,
+        v: Self::Value,
+        else_llbb: Self::BasicBlock,
+        num_cases: usize,
+    ) -> Self::Value;
     fn invoke(
-        &self,
+        &mut self,
         llfn: Self::Value,
         args: &[Self::Value],
         then: Self::BasicBlock,
         catch: Self::BasicBlock,
         funclet: Option<&Self::Funclet>,
     ) -> Self::Value;
-    fn unreachable(&self);
-    fn add(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fadd(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fadd_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn sub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fsub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fsub_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn mul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fmul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fmul_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn udiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn exactudiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn sdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn exactsdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fdiv_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn urem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn srem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn frem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn frem_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn shl(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn lshr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn ashr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn and(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn or(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn xor(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn neg(&self, v: Self::Value) -> Self::Value;
-    fn fneg(&self, v: Self::Value) -> Self::Value;
-    fn not(&self, v: Self::Value) -> Self::Value;
+    fn unreachable(&mut self);
+    fn add(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fadd_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn sub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fsub(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fsub_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn mul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fmul(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fmul_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn udiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn exactudiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn sdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn exactsdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fdiv(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fdiv_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn urem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn srem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn frem(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn frem_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn shl(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn lshr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn ashr(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn and(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn or(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn xor(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn neg(&mut self, v: Self::Value) -> Self::Value;
+    fn fneg(&mut self, v: Self::Value) -> Self::Value;
+    fn not(&mut self, v: Self::Value) -> Self::Value;
 
-    fn alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value;
-    fn dynamic_alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value;
+    fn alloca(&mut self, ty: Self::Type, name: &str, align: Align) -> Self::Value;
+    fn dynamic_alloca(&mut self, ty: Self::Type, name: &str, align: Align) -> Self::Value;
     fn array_alloca(
-        &self,
+        &mut self,
         ty: Self::Type,
         len: Self::Value,
         name: &str,
         align: Align,
     ) -> Self::Value;
 
-    fn load(&self, ptr: Self::Value, align: Align) -> Self::Value;
-    fn volatile_load(&self, ptr: Self::Value) -> Self::Value;
-    fn atomic_load(&self, ptr: Self::Value, order: AtomicOrdering, size: Size) -> Self::Value;
-    fn load_operand(&self, place: PlaceRef<'tcx, Self::Value>) -> OperandRef<'tcx, Self::Value>;
+    fn load(&mut self, ptr: Self::Value, align: Align) -> Self::Value;
+    fn volatile_load(&mut self, ptr: Self::Value) -> Self::Value;
+    fn atomic_load(&mut self, ptr: Self::Value, order: AtomicOrdering, size: Size) -> Self::Value;
+    fn load_operand(&mut self, place: PlaceRef<'tcx, Self::Value>)
+        -> OperandRef<'tcx, Self::Value>;
 
-    fn range_metadata(&self, load: Self::Value, range: Range<u128>);
-    fn nonnull_metadata(&self, load: Self::Value);
+    fn range_metadata(&mut self, load: Self::Value, range: Range<u128>);
+    fn nonnull_metadata(&mut self, load: Self::Value);
 
-    fn store(&self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value;
+    fn store(&mut self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value;
     fn store_with_flags(
-        &self,
+        &mut self,
         val: Self::Value,
         ptr: Self::Value,
         align: Align,
         flags: MemFlags,
     ) -> Self::Value;
-    fn atomic_store(&self, val: Self::Value, ptr: Self::Value, order: AtomicOrdering, size: Size);
+    fn atomic_store(
+        &mut self,
+        val: Self::Value,
+        ptr: Self::Value,
+        order: AtomicOrdering,
+        size: Size,
+    );
 
-    fn gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value;
-    fn inbounds_gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value;
-    fn struct_gep(&self, ptr: Self::Value, idx: u64) -> Self::Value;
+    fn gep(&mut self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value;
+    fn inbounds_gep(&mut self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value;
+    fn struct_gep(&mut self, ptr: Self::Value, idx: u64) -> Self::Value;
 
-    fn trunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn sext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn fptoui(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn fptosi(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn uitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn sitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn fptrunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn fpext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn ptrtoint(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn inttoptr(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn bitcast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
-    fn intcast(&self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value;
-    fn pointercast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn trunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn sext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn fptoui(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn fptosi(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn uitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn sitofp(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn fptrunc(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn fpext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn ptrtoint(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn inttoptr(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn bitcast(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn intcast(&mut self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value;
+    fn pointercast(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
 
-    fn icmp(&self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn fcmp(&self, op: RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn icmp(&mut self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn fcmp(&mut self, op: RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
 
-    fn empty_phi(&self, ty: Self::Type) -> Self::Value;
-    fn phi(&self, ty: Self::Type, vals: &[Self::Value], bbs: &[Self::BasicBlock]) -> Self::Value;
+    fn empty_phi(&mut self, ty: Self::Type) -> Self::Value;
+    fn phi(
+        &mut self,
+        ty: Self::Type,
+        vals: &[Self::Value],
+        bbs: &[Self::BasicBlock],
+    ) -> Self::Value;
     fn inline_asm_call(
-        &self,
+        &mut self,
         asm: *const c_char,
         cons: *const c_char,
         inputs: &[Self::Value],
@@ -155,7 +172,7 @@ fn inline_asm_call(
     ) -> Option<Self::Value>;
 
     fn memcpy(
-        &self,
+        &mut self,
         dst: Self::Value,
         dst_align: Align,
         src: Self::Value,
@@ -164,7 +181,7 @@ fn memcpy(
         flags: MemFlags,
     );
     fn memmove(
-        &self,
+        &mut self,
         dst: Self::Value,
         dst_align: Align,
         src: Self::Value,
@@ -173,7 +190,7 @@ fn memmove(
         flags: MemFlags,
     );
     fn memset(
-        &self,
+        &mut self,
         ptr: Self::Value,
         fill_byte: Self::Value,
         size: Self::Value,
@@ -181,56 +198,74 @@ fn memset(
         flags: MemFlags,
     );
 
-    fn minnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
-    fn maxnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn minnum(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
+    fn maxnum(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value;
     fn select(
-        &self,
+        &mut self,
         cond: Self::Value,
         then_val: Self::Value,
         else_val: Self::Value,
     ) -> Self::Value;
 
-    fn va_arg(&self, list: Self::Value, ty: Self::Type) -> Self::Value;
-    fn extract_element(&self, vec: Self::Value, idx: Self::Value) -> Self::Value;
-    fn insert_element(&self, vec: Self::Value, elt: Self::Value, idx: Self::Value) -> Self::Value;
-    fn shuffle_vector(&self, v1: Self::Value, v2: Self::Value, mask: Self::Value) -> Self::Value;
-    fn vector_splat(&self, num_elts: usize, elt: Self::Value) -> Self::Value;
-    fn vector_reduce_fadd_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value;
-    fn vector_reduce_fmul_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value;
-    fn vector_reduce_add(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_mul(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_and(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_or(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_xor(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_fmin(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_fmax(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_fmin_fast(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_fmax_fast(&self, src: Self::Value) -> Self::Value;
-    fn vector_reduce_min(&self, src: Self::Value, is_signed: bool) -> Self::Value;
-    fn vector_reduce_max(&self, src: Self::Value, is_signed: bool) -> Self::Value;
-    fn extract_value(&self, agg_val: Self::Value, idx: u64) -> Self::Value;
-    fn insert_value(&self, agg_val: Self::Value, elt: Self::Value, idx: u64) -> Self::Value;
+    fn va_arg(&mut self, list: Self::Value, ty: Self::Type) -> Self::Value;
+    fn extract_element(&mut self, vec: Self::Value, idx: Self::Value) -> Self::Value;
+    fn insert_element(
+        &mut self,
+        vec: Self::Value,
+        elt: Self::Value,
+        idx: Self::Value,
+    ) -> Self::Value;
+    fn shuffle_vector(
+        &mut self,
+        v1: Self::Value,
+        v2: Self::Value,
+        mask: Self::Value,
+    ) -> Self::Value;
+    fn vector_splat(&mut self, num_elts: usize, elt: Self::Value) -> Self::Value;
+    fn vector_reduce_fadd_fast(&mut self, acc: Self::Value, src: Self::Value) -> Self::Value;
+    fn vector_reduce_fmul_fast(&mut self, acc: Self::Value, src: Self::Value) -> Self::Value;
+    fn vector_reduce_add(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_mul(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_and(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_or(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_xor(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_fmin(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_fmax(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_fmin_fast(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_fmax_fast(&mut self, src: Self::Value) -> Self::Value;
+    fn vector_reduce_min(&mut self, src: Self::Value, is_signed: bool) -> Self::Value;
+    fn vector_reduce_max(&mut self, src: Self::Value, is_signed: bool) -> Self::Value;
+    fn extract_value(&mut self, agg_val: Self::Value, idx: u64) -> Self::Value;
+    fn insert_value(&mut self, agg_val: Self::Value, elt: Self::Value, idx: u64) -> Self::Value;
 
-    fn landing_pad(&self, ty: Self::Type, pers_fn: Self::Value, num_clauses: usize) -> Self::Value;
-    fn add_clause(&self, landing_pad: Self::Value, clause: Self::Value);
-    fn set_cleanup(&self, landing_pad: Self::Value);
-    fn resume(&self, exn: Self::Value) -> Self::Value;
-    fn cleanup_pad(&self, parent: Option<Self::Value>, args: &[Self::Value]) -> Self::Funclet;
-    fn cleanup_ret(&self, funclet: &Self::Funclet, unwind: Option<Self::BasicBlock>)
-        -> Self::Value;
-    fn catch_pad(&self, parent: Self::Value, args: &[Self::Value]) -> Self::Funclet;
-    fn catch_ret(&self, funclet: &Self::Funclet, unwind: Self::BasicBlock) -> Self::Value;
+    fn landing_pad(
+        &mut self,
+        ty: Self::Type,
+        pers_fn: Self::Value,
+        num_clauses: usize,
+    ) -> Self::Value;
+    fn add_clause(&mut self, landing_pad: Self::Value, clause: Self::Value);
+    fn set_cleanup(&mut self, landing_pad: Self::Value);
+    fn resume(&mut self, exn: Self::Value) -> Self::Value;
+    fn cleanup_pad(&mut self, parent: Option<Self::Value>, args: &[Self::Value]) -> Self::Funclet;
+    fn cleanup_ret(
+        &mut self,
+        funclet: &Self::Funclet,
+        unwind: Option<Self::BasicBlock>,
+    ) -> Self::Value;
+    fn catch_pad(&mut self, parent: Self::Value, args: &[Self::Value]) -> Self::Funclet;
+    fn catch_ret(&mut self, funclet: &Self::Funclet, unwind: Self::BasicBlock) -> Self::Value;
     fn catch_switch(
-        &self,
+        &mut self,
         parent: Option<Self::Value>,
         unwind: Option<Self::BasicBlock>,
         num_handlers: usize,
     ) -> Self::Value;
-    fn add_handler(&self, catch_switch: Self::Value, handler: Self::BasicBlock);
-    fn set_personality_fn(&self, personality: Self::Value);
+    fn add_handler(&mut self, catch_switch: Self::Value, handler: Self::BasicBlock);
+    fn set_personality_fn(&mut self, personality: Self::Value);
 
     fn atomic_cmpxchg(
-        &self,
+        &mut self,
         dst: Self::Value,
         cmp: Self::Value,
         src: Self::Value,
@@ -239,31 +274,31 @@ fn atomic_cmpxchg(
         weak: bool,
     ) -> Self::Value;
     fn atomic_rmw(
-        &self,
+        &mut self,
         op: AtomicRmwBinOp,
         dst: Self::Value,
         src: Self::Value,
         order: AtomicOrdering,
     ) -> Self::Value;
-    fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope);
-    fn add_case(&self, s: Self::Value, on_val: Self::Value, dest: Self::BasicBlock);
-    fn add_incoming_to_phi(&self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock);
-    fn set_invariant_load(&self, load: Self::Value);
+    fn atomic_fence(&mut self, order: AtomicOrdering, scope: SynchronizationScope);
+    fn add_case(&mut self, s: Self::Value, on_val: Self::Value, dest: Self::BasicBlock);
+    fn add_incoming_to_phi(&mut self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock);
+    fn set_invariant_load(&mut self, load: Self::Value);
 
     /// Returns the ptr value that should be used for storing `val`.
-    fn check_store(&self, val: Self::Value, ptr: Self::Value) -> Self::Value;
+    fn check_store(&mut self, val: Self::Value, ptr: Self::Value) -> Self::Value;
 
     /// Returns the args that should be used for a call to `llfn`.
     fn check_call<'b>(
-        &self,
+        &mut self,
         typ: &str,
         llfn: Self::Value,
         args: &'b [Self::Value],
     ) -> Cow<'b, [Self::Value]>
     where
         [Self::Value]: ToOwned;
-    fn lifetime_start(&self, ptr: Self::Value, size: Size);
-    fn lifetime_end(&self, ptr: Self::Value, size: Size);
+    fn lifetime_start(&mut self, ptr: Self::Value, size: Size);
+    fn lifetime_end(&mut self, ptr: Self::Value, size: Size);
 
     /// If LLVM lifetime intrinsic support is enabled (i.e. optimizations
     /// on), and `ptr` is nonzero-sized, then extracts the size of `ptr`
@@ -273,16 +308,16 @@ fn check_call<'b>(
     ///
     /// If LLVM lifetime intrinsic support is disabled (i.e.  optimizations
     /// off) or `ptr` is zero-sized, then no-op (does not call `emit`).
-    fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: Self::Value, size: Size);
+    fn call_lifetime_intrinsic(&mut self, intrinsic: &str, ptr: Self::Value, size: Size);
 
     fn call(
-        &self,
+        &mut self,
         llfn: Self::Value,
         args: &[Self::Value],
         funclet: Option<&Self::Funclet>,
     ) -> Self::Value;
-    fn zext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
+    fn zext(&mut self, val: Self::Value, dest_ty: Self::Type) -> Self::Value;
 
-    fn delete_basic_block(&self, bb: Self::BasicBlock);
-    fn do_not_inline(&self, llret: Self::Value);
+    fn delete_basic_block(&mut self, bb: Self::BasicBlock);
+    fn do_not_inline(&mut self, llret: Self::Value);
 }