}
(_, _) => {
- match Intrinsic::find(tcx, &name) {
+ let intr = match Intrinsic::find(tcx, &name) {
+ Some(intr) => intr,
None => ccx.sess().span_bug(foreign_item.span, "unknown intrinsic"),
- Some(intr) => {
- fn ty_to_type(ccx: &CrateContext, t: &intrinsics::Type) -> Type {
- use intrinsics::Type::*;
- match *t {
- Integer(x) => Type::ix(ccx, x as u64),
- Float(x) => {
- match x {
- 32 => Type::f32(ccx),
- 64 => Type::f64(ccx),
- _ => unreachable!()
- }
- }
- Pointer(_) => unimplemented!(),
- Vector(ref t, length) => Type::vector(&ty_to_type(ccx, t),
- length as u64)
+ };
+ fn ty_to_type(ccx: &CrateContext, t: &intrinsics::Type) -> Type {
+ use intrinsics::Type::*;
+ match *t {
+ Integer(x) => Type::ix(ccx, x as u64),
+ Float(x) => {
+ match x {
+ 32 => Type::f32(ccx),
+ 64 => Type::f64(ccx),
+ _ => unreachable!()
}
}
+ Pointer(_) => unimplemented!(),
+ Vector(ref t, length) => Type::vector(&ty_to_type(ccx, t),
+ length as u64)
+ }
+ }
- let inputs = intr.inputs.iter().map(|t| ty_to_type(ccx, t)).collect::<Vec<_>>();
- let outputs = ty_to_type(ccx, &intr.output);
- match intr.definition {
- intrinsics::IntrinsicDef::Named(name) => {
- let f = declare::declare_cfn(ccx,
- name,
- Type::func(&inputs, &outputs),
- tcx.mk_nil());
- Call(bcx, f, &llargs, None, call_debug_location)
- }
- }
+ let inputs = intr.inputs.iter().map(|t| ty_to_type(ccx, t)).collect::<Vec<_>>();
+ let outputs = ty_to_type(ccx, &intr.output);
+ match intr.definition {
+ intrinsics::IntrinsicDef::Named(name) => {
+ let f = declare::declare_cfn(ccx,
+ name,
+ Type::func(&inputs, &outputs),
+ tcx.mk_nil());
+ Call(bcx, f, &llargs, None, call_debug_location)
}
}
}
call_debug_location: DebugLoc,
call_info: NodeIdAndSpan) -> ValueRef
{
+ macro_rules! require {
+ ($cond: expr, $($fmt: tt)*) => {
+ if !$cond {
+ bcx.sess().span_err(call_info.span, &format!($($fmt)*));
+ return C_null(llret_ty)
+ }
+ }
+ }
+
let tcx = bcx.tcx();
let arg_tys = match callee_ty.sty {
ty::TyBareFn(_, ref f) => {
_ => None
};
- macro_rules! require {
- ($cond: expr, $($fmt: tt)*) => {
- if !$cond {
- bcx.sess().span_err(call_info.span, &format!($($fmt)*));
- return C_null(llret_ty)
- }
- }
- }
-
if let Some(cmp_op) = comparison {
assert_eq!(arg_tys.len(), 2);
require!(arg_tys[0].is_simd(tcx),