1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
11 use llvm::{self, ValueRef};
12 use rustc::ty::{self, Ty};
13 use rustc::ty::cast::{CastTy, IntTy};
14 use rustc::ty::layout::Layout;
15 use rustc::mir::tcx::LvalueTy;
17 use middle::lang_items::ExchangeMallocFnLangItem;
23 use common::{self, val_ty, C_bool, C_null, C_uint};
24 use common::{C_integral};
33 use super::MirContext;
34 use super::constant::const_scalar_checked_binop;
35 use super::operand::{OperandRef, OperandValue};
36 use super::lvalue::LvalueRef;
38 impl<'a, 'tcx> MirContext<'a, 'tcx> {
39 pub fn trans_rvalue(&mut self,
40 bcx: Builder<'a, 'tcx>,
41 dest: LvalueRef<'tcx>,
42 rvalue: &mir::Rvalue<'tcx>)
45 debug!("trans_rvalue(dest.llval={:?}, rvalue={:?})",
46 Value(dest.llval), rvalue);
49 mir::Rvalue::Use(ref operand) => {
50 let tr_operand = self.trans_operand(&bcx, operand);
51 // FIXME: consider not copying constants through stack. (fixable by translating
52 // constants into OperandValue::Ref, why don’t we do that yet if we don’t?)
53 self.store_operand(&bcx, dest.llval, dest.alignment.to_align(), tr_operand);
57 mir::Rvalue::Cast(mir::CastKind::Unsize, ref source, cast_ty) => {
58 let cast_ty = self.monomorphize(&cast_ty);
60 if common::type_is_fat_ptr(bcx.ccx, cast_ty) {
61 // into-coerce of a thin pointer to a fat pointer - just
62 // use the operand path.
63 let (bcx, temp) = self.trans_rvalue_operand(bcx, rvalue);
64 self.store_operand(&bcx, dest.llval, dest.alignment.to_align(), temp);
68 // Unsize of a nontrivial struct. I would prefer for
69 // this to be eliminated by MIR translation, but
70 // `CoerceUnsized` can be passed by a where-clause,
71 // so the (generic) MIR may not be able to expand it.
72 let operand = self.trans_operand(&bcx, source);
73 let operand = operand.pack_if_pair(&bcx);
74 let llref = match operand.val {
75 OperandValue::Pair(..) => bug!(),
76 OperandValue::Immediate(llval) => {
77 // unsize from an immediate structure. We don't
78 // really need a temporary alloca here, but
79 // avoiding it would require us to have
80 // `coerce_unsized_into` use extractvalue to
81 // index into the struct, and this case isn't
82 // important enough for it.
83 debug!("trans_rvalue: creating ugly alloca");
84 let scratch = LvalueRef::alloca(&bcx, operand.ty, "__unsize_temp");
85 base::store_ty(&bcx, llval, scratch.llval, scratch.alignment, operand.ty);
88 OperandValue::Ref(llref, align) => {
89 LvalueRef::new_sized_ty(llref, operand.ty, align)
92 base::coerce_unsized_into(&bcx, &llref, &dest);
96 mir::Rvalue::Repeat(ref elem, ref count) => {
97 let tr_elem = self.trans_operand(&bcx, elem);
98 let size = count.value.as_u64(bcx.tcx().sess.target.uint_type);
99 let size = C_uint(bcx.ccx, size);
100 let base = base::get_dataptr(&bcx, dest.llval);
101 tvec::slice_for_each(&bcx, base, tr_elem.ty, size, |bcx, llslot| {
102 self.store_operand(bcx, llslot, dest.alignment.to_align(), tr_elem);
106 mir::Rvalue::Aggregate(ref kind, ref operands) => {
108 mir::AggregateKind::Adt(adt_def, variant_index, substs, active_field_index) => {
109 let disr = Disr::from(adt_def.variants[variant_index].disr_val);
110 let dest_ty = dest.ty.to_ty(bcx.tcx());
111 adt::trans_set_discr(&bcx, dest_ty, dest.llval, Disr::from(disr));
112 for (i, operand) in operands.iter().enumerate() {
113 let op = self.trans_operand(&bcx, operand);
114 // Do not generate stores and GEPis for zero-sized fields.
115 if !common::type_is_zero_size(bcx.ccx, op.ty) {
116 let mut val = LvalueRef::new_sized(
117 dest.llval, dest.ty, dest.alignment);
118 let field_index = active_field_index.unwrap_or(i);
119 val.ty = LvalueTy::Downcast {
121 substs: self.monomorphize(&substs),
122 variant_index: disr.0 as usize,
124 let (lldest_i, align) = val.trans_field_ptr(&bcx, field_index);
125 self.store_operand(&bcx, lldest_i, align.to_align(), op);
130 // If this is a tuple or closure, we need to translate GEP indices.
131 let layout = bcx.ccx.layout_of(dest.ty.to_ty(bcx.tcx()));
132 let translation = if let Layout::Univariant { ref variant, .. } = *layout {
133 Some(&variant.memory_index)
137 let alignment = dest.alignment;
138 for (i, operand) in operands.iter().enumerate() {
139 let op = self.trans_operand(&bcx, operand);
140 // Do not generate stores and GEPis for zero-sized fields.
141 if !common::type_is_zero_size(bcx.ccx, op.ty) {
142 // Note: perhaps this should be StructGep, but
143 // note that in some cases the values here will
144 // not be structs but arrays.
145 let i = if let Some(ref t) = translation {
150 let dest = bcx.gepi(dest.llval, &[0, i]);
151 self.store_operand(&bcx, dest, alignment.to_align(), op);
159 mir::Rvalue::InlineAsm { ref asm, ref outputs, ref inputs } => {
160 let outputs = outputs.iter().map(|output| {
161 let lvalue = self.trans_lvalue(&bcx, output);
162 (lvalue.llval, lvalue.ty.to_ty(bcx.tcx()))
165 let input_vals = inputs.iter().map(|input| {
166 self.trans_operand(&bcx, input).immediate()
169 asm::trans_inline_asm(&bcx, asm, outputs, input_vals);
174 assert!(rvalue_creates_operand(rvalue));
175 let (bcx, temp) = self.trans_rvalue_operand(bcx, rvalue);
176 self.store_operand(&bcx, dest.llval, dest.alignment.to_align(), temp);
182 pub fn trans_rvalue_operand(&mut self,
183 bcx: Builder<'a, 'tcx>,
184 rvalue: &mir::Rvalue<'tcx>)
185 -> (Builder<'a, 'tcx>, OperandRef<'tcx>)
187 assert!(rvalue_creates_operand(rvalue), "cannot trans {:?} to operand", rvalue);
190 mir::Rvalue::Cast(ref kind, ref source, cast_ty) => {
191 let operand = self.trans_operand(&bcx, source);
192 debug!("cast operand is {:?}", operand);
193 let cast_ty = self.monomorphize(&cast_ty);
195 let val = match *kind {
196 mir::CastKind::ReifyFnPointer => {
197 match operand.ty.sty {
198 ty::TyFnDef(def_id, substs, _) => {
199 OperandValue::Immediate(
200 Callee::def(bcx.ccx, def_id, substs)
204 bug!("{} cannot be reified to a fn ptr", operand.ty)
208 mir::CastKind::UnsafeFnPointer => {
209 // this is a no-op at the LLVM level
212 mir::CastKind::Unsize => {
213 // unsize targets other than to a fat pointer currently
214 // can't be operands.
215 assert!(common::type_is_fat_ptr(bcx.ccx, cast_ty));
218 OperandValue::Pair(lldata, llextra) => {
219 // unsize from a fat pointer - this is a
220 // "trait-object-to-supertrait" coercion, for
222 // &'a fmt::Debug+Send => &'a fmt::Debug,
223 // So we need to pointercast the base to ensure
224 // the types match up.
225 let llcast_ty = type_of::fat_ptr_base_ty(bcx.ccx, cast_ty);
226 let lldata = bcx.pointercast(lldata, llcast_ty);
227 OperandValue::Pair(lldata, llextra)
229 OperandValue::Immediate(lldata) => {
231 let (lldata, llextra) = base::unsize_thin_ptr(&bcx, lldata,
232 operand.ty, cast_ty);
233 OperandValue::Pair(lldata, llextra)
235 OperandValue::Ref(..) => {
236 bug!("by-ref operand {:?} in trans_rvalue_operand",
241 mir::CastKind::Misc if common::type_is_fat_ptr(bcx.ccx, operand.ty) => {
242 let ll_cast_ty = type_of::immediate_type_of(bcx.ccx, cast_ty);
243 let ll_from_ty = type_of::immediate_type_of(bcx.ccx, operand.ty);
244 if let OperandValue::Pair(data_ptr, meta_ptr) = operand.val {
245 if common::type_is_fat_ptr(bcx.ccx, cast_ty) {
246 let ll_cft = ll_cast_ty.field_types();
247 let ll_fft = ll_from_ty.field_types();
248 let data_cast = bcx.pointercast(data_ptr, ll_cft[0]);
249 assert_eq!(ll_cft[1].kind(), ll_fft[1].kind());
250 OperandValue::Pair(data_cast, meta_ptr)
251 } else { // cast to thin-ptr
252 // Cast of fat-ptr to thin-ptr is an extraction of data-ptr and
253 // pointer-cast of that pointer to desired pointer type.
254 let llval = bcx.pointercast(data_ptr, ll_cast_ty);
255 OperandValue::Immediate(llval)
258 bug!("Unexpected non-Pair operand")
261 mir::CastKind::Misc => {
262 debug_assert!(common::type_is_immediate(bcx.ccx, cast_ty));
263 let r_t_in = CastTy::from_ty(operand.ty).expect("bad input type for cast");
264 let r_t_out = CastTy::from_ty(cast_ty).expect("bad output type for cast");
265 let ll_t_in = type_of::immediate_type_of(bcx.ccx, operand.ty);
266 let ll_t_out = type_of::immediate_type_of(bcx.ccx, cast_ty);
267 let llval = operand.immediate();
268 let l = bcx.ccx.layout_of(operand.ty);
269 let signed = if let Layout::CEnum { signed, min, max, .. } = *l {
271 // We want `table[e as usize]` to not
272 // have bound checks, and this is the most
273 // convenient place to put the `assume`.
275 base::call_assume(&bcx, bcx.icmp(
278 C_integral(common::val_ty(llval), max, false)
284 operand.ty.is_signed()
287 let newval = match (r_t_in, r_t_out) {
288 (CastTy::Int(_), CastTy::Int(_)) => {
289 let srcsz = ll_t_in.int_width();
290 let dstsz = ll_t_out.int_width();
292 bcx.bitcast(llval, ll_t_out)
293 } else if srcsz > dstsz {
294 bcx.trunc(llval, ll_t_out)
296 bcx.sext(llval, ll_t_out)
298 bcx.zext(llval, ll_t_out)
301 (CastTy::Float, CastTy::Float) => {
302 let srcsz = ll_t_in.float_width();
303 let dstsz = ll_t_out.float_width();
305 bcx.fpext(llval, ll_t_out)
306 } else if srcsz > dstsz {
307 bcx.fptrunc(llval, ll_t_out)
312 (CastTy::Ptr(_), CastTy::Ptr(_)) |
313 (CastTy::FnPtr, CastTy::Ptr(_)) |
314 (CastTy::RPtr(_), CastTy::Ptr(_)) =>
315 bcx.pointercast(llval, ll_t_out),
316 (CastTy::Ptr(_), CastTy::Int(_)) |
317 (CastTy::FnPtr, CastTy::Int(_)) =>
318 bcx.ptrtoint(llval, ll_t_out),
319 (CastTy::Int(_), CastTy::Ptr(_)) =>
320 bcx.inttoptr(llval, ll_t_out),
321 (CastTy::Int(_), CastTy::Float) if signed =>
322 bcx.sitofp(llval, ll_t_out),
323 (CastTy::Int(_), CastTy::Float) =>
324 bcx.uitofp(llval, ll_t_out),
325 (CastTy::Float, CastTy::Int(IntTy::I)) =>
326 bcx.fptosi(llval, ll_t_out),
327 (CastTy::Float, CastTy::Int(_)) =>
328 bcx.fptoui(llval, ll_t_out),
329 _ => bug!("unsupported cast: {:?} to {:?}", operand.ty, cast_ty)
331 OperandValue::Immediate(newval)
334 let operand = OperandRef {
341 mir::Rvalue::Ref(_, bk, ref lvalue) => {
342 let tr_lvalue = self.trans_lvalue(&bcx, lvalue);
344 let ty = tr_lvalue.ty.to_ty(bcx.tcx());
345 let ref_ty = bcx.tcx().mk_ref(
346 bcx.tcx().mk_region(ty::ReErased),
347 ty::TypeAndMut { ty: ty, mutbl: bk.to_mutbl_lossy() }
350 // Note: lvalues are indirect, so storing the `llval` into the
351 // destination effectively creates a reference.
352 let operand = if bcx.ccx.shared().type_is_sized(ty) {
354 val: OperandValue::Immediate(tr_lvalue.llval),
359 val: OperandValue::Pair(tr_lvalue.llval,
367 mir::Rvalue::Len(ref lvalue) => {
368 let tr_lvalue = self.trans_lvalue(&bcx, lvalue);
369 let operand = OperandRef {
370 val: OperandValue::Immediate(tr_lvalue.len(bcx.ccx)),
371 ty: bcx.tcx().types.usize,
376 mir::Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
377 let lhs = self.trans_operand(&bcx, lhs);
378 let rhs = self.trans_operand(&bcx, rhs);
379 let llresult = if common::type_is_fat_ptr(bcx.ccx, lhs.ty) {
380 match (lhs.val, rhs.val) {
381 (OperandValue::Pair(lhs_addr, lhs_extra),
382 OperandValue::Pair(rhs_addr, rhs_extra)) => {
383 self.trans_fat_ptr_binop(&bcx, op,
392 self.trans_scalar_binop(&bcx, op,
393 lhs.immediate(), rhs.immediate(),
396 let operand = OperandRef {
397 val: OperandValue::Immediate(llresult),
398 ty: op.ty(bcx.tcx(), lhs.ty, rhs.ty),
402 mir::Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
403 let lhs = self.trans_operand(&bcx, lhs);
404 let rhs = self.trans_operand(&bcx, rhs);
405 let result = self.trans_scalar_checked_binop(&bcx, op,
406 lhs.immediate(), rhs.immediate(),
408 let val_ty = op.ty(bcx.tcx(), lhs.ty, rhs.ty);
409 let operand_ty = bcx.tcx().intern_tup(&[val_ty, bcx.tcx().types.bool], false);
410 let operand = OperandRef {
418 mir::Rvalue::UnaryOp(op, ref operand) => {
419 let operand = self.trans_operand(&bcx, operand);
420 let lloperand = operand.immediate();
421 let is_float = operand.ty.is_fp();
422 let llval = match op {
423 mir::UnOp::Not => bcx.not(lloperand),
424 mir::UnOp::Neg => if is_float {
431 val: OperandValue::Immediate(llval),
436 mir::Rvalue::Box(content_ty) => {
437 let content_ty: Ty<'tcx> = self.monomorphize(&content_ty);
438 let llty = type_of::type_of(bcx.ccx, content_ty);
439 let llsize = machine::llsize_of(bcx.ccx, llty);
440 let align = type_of::align_of(bcx.ccx, content_ty);
441 let llalign = C_uint(bcx.ccx, align);
442 let llty_ptr = llty.ptr_to();
443 let box_ty = bcx.tcx().mk_box(content_ty);
446 let def_id = match bcx.tcx().lang_items.require(ExchangeMallocFnLangItem) {
449 bcx.sess().fatal(&format!("allocation of `{}` {}", box_ty, s));
452 let r = Callee::def(bcx.ccx, def_id, bcx.tcx().intern_substs(&[]))
454 let val = bcx.pointercast(bcx.call(r, &[llsize, llalign], None), llty_ptr);
456 let operand = OperandRef {
457 val: OperandValue::Immediate(val),
463 mir::Rvalue::Use(ref operand) => {
464 let operand = self.trans_operand(&bcx, operand);
467 mir::Rvalue::Repeat(..) |
468 mir::Rvalue::Aggregate(..) |
469 mir::Rvalue::InlineAsm { .. } => {
470 bug!("cannot generate operand from rvalue {:?}", rvalue);
476 pub fn trans_scalar_binop(&mut self,
477 bcx: &Builder<'a, 'tcx>,
481 input_ty: Ty<'tcx>) -> ValueRef {
482 let is_float = input_ty.is_fp();
483 let is_signed = input_ty.is_signed();
484 let is_nil = input_ty.is_nil();
485 let is_bool = input_ty.is_bool();
487 mir::BinOp::Add => if is_float {
492 mir::BinOp::Sub => if is_float {
497 mir::BinOp::Mul => if is_float {
502 mir::BinOp::Div => if is_float {
504 } else if is_signed {
509 mir::BinOp::Rem => if is_float {
511 } else if is_signed {
516 mir::BinOp::BitOr => bcx.or(lhs, rhs),
517 mir::BinOp::BitAnd => bcx.and(lhs, rhs),
518 mir::BinOp::BitXor => bcx.xor(lhs, rhs),
519 mir::BinOp::Shl => common::build_unchecked_lshift(bcx, lhs, rhs),
520 mir::BinOp::Shr => common::build_unchecked_rshift(bcx, input_ty, lhs, rhs),
521 mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt |
522 mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_nil {
523 C_bool(bcx.ccx, match op {
524 mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt => false,
525 mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => true,
530 base::bin_op_to_fcmp_predicate(op.to_hir_binop()),
534 let (lhs, rhs) = if is_bool {
535 // FIXME(#36856) -- extend the bools into `i8` because
536 // LLVM's i1 comparisons are broken.
537 (bcx.zext(lhs, Type::i8(bcx.ccx)),
538 bcx.zext(rhs, Type::i8(bcx.ccx)))
544 base::bin_op_to_icmp_predicate(op.to_hir_binop(), is_signed),
551 pub fn trans_fat_ptr_binop(&mut self,
552 bcx: &Builder<'a, 'tcx>,
563 bcx.icmp(llvm::IntEQ, lhs_addr, rhs_addr),
564 bcx.icmp(llvm::IntEQ, lhs_extra, rhs_extra)
569 bcx.icmp(llvm::IntNE, lhs_addr, rhs_addr),
570 bcx.icmp(llvm::IntNE, lhs_extra, rhs_extra)
573 mir::BinOp::Le | mir::BinOp::Lt |
574 mir::BinOp::Ge | mir::BinOp::Gt => {
575 // a OP b ~ a.0 STRICT(OP) b.0 | (a.0 == b.0 && a.1 OP a.1)
576 let (op, strict_op) = match op {
577 mir::BinOp::Lt => (llvm::IntULT, llvm::IntULT),
578 mir::BinOp::Le => (llvm::IntULE, llvm::IntULT),
579 mir::BinOp::Gt => (llvm::IntUGT, llvm::IntUGT),
580 mir::BinOp::Ge => (llvm::IntUGE, llvm::IntUGT),
585 bcx.icmp(strict_op, lhs_addr, rhs_addr),
587 bcx.icmp(llvm::IntEQ, lhs_addr, rhs_addr),
588 bcx.icmp(op, lhs_extra, rhs_extra)
593 bug!("unexpected fat ptr binop");
598 pub fn trans_scalar_checked_binop(&mut self,
599 bcx: &Builder<'a, 'tcx>,
603 input_ty: Ty<'tcx>) -> OperandValue {
604 // This case can currently arise only from functions marked
605 // with #[rustc_inherit_overflow_checks] and inlined from
606 // another crate (mostly core::num generic/#[inline] fns),
607 // while the current crate doesn't use overflow checks.
608 if !bcx.ccx.check_overflow() {
609 let val = self.trans_scalar_binop(bcx, op, lhs, rhs, input_ty);
610 return OperandValue::Pair(val, C_bool(bcx.ccx, false));
613 // First try performing the operation on constants, which
614 // will only succeed if both operands are constant.
615 // This is necessary to determine when an overflow Assert
616 // will always panic at runtime, and produce a warning.
617 if let Some((val, of)) = const_scalar_checked_binop(bcx.tcx(), op, lhs, rhs, input_ty) {
618 return OperandValue::Pair(val, C_bool(bcx.ccx, of));
621 let (val, of) = match op {
622 // These are checked using intrinsics
623 mir::BinOp::Add | mir::BinOp::Sub | mir::BinOp::Mul => {
625 mir::BinOp::Add => OverflowOp::Add,
626 mir::BinOp::Sub => OverflowOp::Sub,
627 mir::BinOp::Mul => OverflowOp::Mul,
630 let intrinsic = get_overflow_intrinsic(oop, bcx, input_ty);
631 let res = bcx.call(intrinsic, &[lhs, rhs], None);
633 (bcx.extract_value(res, 0),
634 bcx.extract_value(res, 1))
636 mir::BinOp::Shl | mir::BinOp::Shr => {
637 let lhs_llty = val_ty(lhs);
638 let rhs_llty = val_ty(rhs);
639 let invert_mask = common::shift_mask_val(&bcx, lhs_llty, rhs_llty, true);
640 let outer_bits = bcx.and(rhs, invert_mask);
642 let of = bcx.icmp(llvm::IntNE, outer_bits, C_null(rhs_llty));
643 let val = self.trans_scalar_binop(bcx, op, lhs, rhs, input_ty);
648 bug!("Operator `{:?}` is not a checkable operator", op)
652 OperandValue::Pair(val, of)
656 pub fn rvalue_creates_operand(rvalue: &mir::Rvalue) -> bool {
658 mir::Rvalue::Ref(..) |
659 mir::Rvalue::Len(..) |
660 mir::Rvalue::Cast(..) | // (*)
661 mir::Rvalue::BinaryOp(..) |
662 mir::Rvalue::CheckedBinaryOp(..) |
663 mir::Rvalue::UnaryOp(..) |
664 mir::Rvalue::Box(..) |
665 mir::Rvalue::Use(..) =>
667 mir::Rvalue::Repeat(..) |
668 mir::Rvalue::Aggregate(..) |
669 mir::Rvalue::InlineAsm { .. } =>
673 // (*) this is only true if the type is suitable
676 #[derive(Copy, Clone)]
681 fn get_overflow_intrinsic(oop: OverflowOp, bcx: &Builder, ty: Ty) -> ValueRef {
682 use syntax::ast::IntTy::*;
683 use syntax::ast::UintTy::*;
684 use rustc::ty::{TyInt, TyUint};
688 let new_sty = match ty.sty {
689 TyInt(Is) => match &tcx.sess.target.target.target_pointer_width[..] {
693 _ => panic!("unsupported target word size")
695 TyUint(Us) => match &tcx.sess.target.target.target_pointer_width[..] {
699 _ => panic!("unsupported target word size")
701 ref t @ TyUint(_) | ref t @ TyInt(_) => t.clone(),
702 _ => panic!("tried to get overflow intrinsic for op applied to non-int type")
705 let name = match oop {
706 OverflowOp::Add => match new_sty {
707 TyInt(I8) => "llvm.sadd.with.overflow.i8",
708 TyInt(I16) => "llvm.sadd.with.overflow.i16",
709 TyInt(I32) => "llvm.sadd.with.overflow.i32",
710 TyInt(I64) => "llvm.sadd.with.overflow.i64",
711 TyInt(I128) => "llvm.sadd.with.overflow.i128",
713 TyUint(U8) => "llvm.uadd.with.overflow.i8",
714 TyUint(U16) => "llvm.uadd.with.overflow.i16",
715 TyUint(U32) => "llvm.uadd.with.overflow.i32",
716 TyUint(U64) => "llvm.uadd.with.overflow.i64",
717 TyUint(U128) => "llvm.uadd.with.overflow.i128",
721 OverflowOp::Sub => match new_sty {
722 TyInt(I8) => "llvm.ssub.with.overflow.i8",
723 TyInt(I16) => "llvm.ssub.with.overflow.i16",
724 TyInt(I32) => "llvm.ssub.with.overflow.i32",
725 TyInt(I64) => "llvm.ssub.with.overflow.i64",
726 TyInt(I128) => "llvm.ssub.with.overflow.i128",
728 TyUint(U8) => "llvm.usub.with.overflow.i8",
729 TyUint(U16) => "llvm.usub.with.overflow.i16",
730 TyUint(U32) => "llvm.usub.with.overflow.i32",
731 TyUint(U64) => "llvm.usub.with.overflow.i64",
732 TyUint(U128) => "llvm.usub.with.overflow.i128",
736 OverflowOp::Mul => match new_sty {
737 TyInt(I8) => "llvm.smul.with.overflow.i8",
738 TyInt(I16) => "llvm.smul.with.overflow.i16",
739 TyInt(I32) => "llvm.smul.with.overflow.i32",
740 TyInt(I64) => "llvm.smul.with.overflow.i64",
741 TyInt(I128) => "llvm.smul.with.overflow.i128",
743 TyUint(U8) => "llvm.umul.with.overflow.i8",
744 TyUint(U16) => "llvm.umul.with.overflow.i16",
745 TyUint(U32) => "llvm.umul.with.overflow.i32",
746 TyUint(U64) => "llvm.umul.with.overflow.i64",
747 TyUint(U128) => "llvm.umul.with.overflow.i128",
753 bcx.ccx.get_intrinsic(&name)