Auto merge of #136751 - bjorn3:update_rustfmt, r=Mark-Simulacrum
Update bootstrap compiler and rustfmt The rustfmt version we previously used formats things differently from what the latest nightly rustfmt does. This causes issues for subtrees that get formatted both in-tree and in their own repo. Updating the rustfmt used in-tree solves those issues. Also bumped the bootstrap compiler as the stage0 update command always updates both at the same time.
This commit is contained in:
commit
124cc92199
289 changed files with 6351 additions and 5071 deletions
|
@ -447,11 +447,11 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
// LLVM also rejects full range.
|
||||
&& !scalar.is_always_valid(cx)
|
||||
{
|
||||
attributes::apply_to_llfn(llfn, idx, &[llvm::CreateRangeAttr(
|
||||
cx.llcx,
|
||||
scalar.size(cx),
|
||||
scalar.valid_range(cx),
|
||||
)]);
|
||||
attributes::apply_to_llfn(
|
||||
llfn,
|
||||
idx,
|
||||
&[llvm::CreateRangeAttr(cx.llcx, scalar.size(cx), scalar.valid_range(cx))],
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -471,10 +471,14 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
);
|
||||
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Argument(i), &[sret]);
|
||||
if cx.sess().opts.optimize != config::OptLevel::No {
|
||||
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Argument(i), &[
|
||||
llvm::AttributeKind::Writable.create_attr(cx.llcx),
|
||||
llvm::AttributeKind::DeadOnUnwind.create_attr(cx.llcx),
|
||||
]);
|
||||
attributes::apply_to_llfn(
|
||||
llfn,
|
||||
llvm::AttributePlace::Argument(i),
|
||||
&[
|
||||
llvm::AttributeKind::Writable.create_attr(cx.llcx),
|
||||
llvm::AttributeKind::DeadOnUnwind.create_attr(cx.llcx),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
PassMode::Cast { cast, pad_i32: _ } => {
|
||||
|
@ -592,9 +596,11 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
bx.cx.llcx,
|
||||
bx.cx.type_array(bx.cx.type_i8(), arg.layout.size.bytes()),
|
||||
);
|
||||
attributes::apply_to_callsite(callsite, llvm::AttributePlace::Argument(i), &[
|
||||
byval,
|
||||
]);
|
||||
attributes::apply_to_callsite(
|
||||
callsite,
|
||||
llvm::AttributePlace::Argument(i),
|
||||
&[byval],
|
||||
);
|
||||
}
|
||||
PassMode::Direct(attrs)
|
||||
| PassMode::Indirect { attrs, meta_attrs: None, on_stack: false } => {
|
||||
|
@ -626,9 +632,11 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||
// This will probably get ignored on all targets but those supporting the TrustZone-M
|
||||
// extension (thumbv8m targets).
|
||||
let cmse_nonsecure_call = llvm::CreateAttrString(bx.cx.llcx, "cmse_nonsecure_call");
|
||||
attributes::apply_to_callsite(callsite, llvm::AttributePlace::Function, &[
|
||||
cmse_nonsecure_call,
|
||||
]);
|
||||
attributes::apply_to_callsite(
|
||||
callsite,
|
||||
llvm::AttributePlace::Function,
|
||||
&[cmse_nonsecure_call],
|
||||
);
|
||||
}
|
||||
|
||||
// Some intrinsics require that an elementtype attribute (with the pointee type of a
|
||||
|
|
|
@ -291,20 +291,26 @@ pub(crate) fn differentiate<'ll>(
|
|||
let name = item.source.clone();
|
||||
let fn_def: Option<&llvm::Value> = cx.get_function(&name);
|
||||
let Some(fn_def) = fn_def else {
|
||||
return Err(llvm_err(diag_handler.handle(), LlvmError::PrepareAutoDiff {
|
||||
src: item.source.clone(),
|
||||
target: item.target.clone(),
|
||||
error: "could not find source function".to_owned(),
|
||||
}));
|
||||
return Err(llvm_err(
|
||||
diag_handler.handle(),
|
||||
LlvmError::PrepareAutoDiff {
|
||||
src: item.source.clone(),
|
||||
target: item.target.clone(),
|
||||
error: "could not find source function".to_owned(),
|
||||
},
|
||||
));
|
||||
};
|
||||
debug!(?item.target);
|
||||
let fn_target: Option<&llvm::Value> = cx.get_function(&item.target);
|
||||
let Some(fn_target) = fn_target else {
|
||||
return Err(llvm_err(diag_handler.handle(), LlvmError::PrepareAutoDiff {
|
||||
src: item.source.clone(),
|
||||
target: item.target.clone(),
|
||||
error: "could not find target function".to_owned(),
|
||||
}));
|
||||
return Err(llvm_err(
|
||||
diag_handler.handle(),
|
||||
LlvmError::PrepareAutoDiff {
|
||||
src: item.source.clone(),
|
||||
target: item.target.clone(),
|
||||
error: "could not find target function".to_owned(),
|
||||
},
|
||||
));
|
||||
};
|
||||
|
||||
generate_enzyme_call(&cx, fn_def, fn_target, item.attrs.clone());
|
||||
|
|
|
@ -548,14 +548,17 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
|
|||
}
|
||||
}
|
||||
|
||||
let scope = namespace::item_namespace(cx, DefId {
|
||||
krate: instance.def_id().krate,
|
||||
index: cx
|
||||
.tcx
|
||||
.def_key(instance.def_id())
|
||||
.parent
|
||||
.expect("get_containing_scope: missing parent?"),
|
||||
});
|
||||
let scope = namespace::item_namespace(
|
||||
cx,
|
||||
DefId {
|
||||
krate: instance.def_id().krate,
|
||||
index: cx
|
||||
.tcx
|
||||
.def_key(instance.def_id())
|
||||
.parent
|
||||
.expect("get_containing_scope: missing parent?"),
|
||||
},
|
||||
);
|
||||
(scope, false)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -333,12 +333,15 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
sym::prefetch_write_instruction => (1, 0),
|
||||
_ => bug!(),
|
||||
};
|
||||
self.call_intrinsic("llvm.prefetch", &[
|
||||
args[0].immediate(),
|
||||
self.const_i32(rw),
|
||||
args[1].immediate(),
|
||||
self.const_i32(cache_type),
|
||||
])
|
||||
self.call_intrinsic(
|
||||
"llvm.prefetch",
|
||||
&[
|
||||
args[0].immediate(),
|
||||
self.const_i32(rw),
|
||||
args[1].immediate(),
|
||||
self.const_i32(cache_type),
|
||||
],
|
||||
)
|
||||
}
|
||||
sym::carrying_mul_add => {
|
||||
let (size, signed) = fn_args.type_at(0).int_size_and_signed(self.tcx);
|
||||
|
@ -396,10 +399,10 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
match name {
|
||||
sym::ctlz | sym::cttz => {
|
||||
let y = self.const_bool(false);
|
||||
let ret = self.call_intrinsic(&format!("llvm.{name}.i{width}"), &[
|
||||
args[0].immediate(),
|
||||
y,
|
||||
]);
|
||||
let ret = self.call_intrinsic(
|
||||
&format!("llvm.{name}.i{width}"),
|
||||
&[args[0].immediate(), y],
|
||||
);
|
||||
|
||||
self.intcast(ret, llret_ty, false)
|
||||
}
|
||||
|
@ -416,24 +419,26 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
self.intcast(ret, llret_ty, false)
|
||||
}
|
||||
sym::ctpop => {
|
||||
let ret = self.call_intrinsic(&format!("llvm.ctpop.i{width}"), &[
|
||||
args[0].immediate()
|
||||
]);
|
||||
let ret = self.call_intrinsic(
|
||||
&format!("llvm.ctpop.i{width}"),
|
||||
&[args[0].immediate()],
|
||||
);
|
||||
self.intcast(ret, llret_ty, false)
|
||||
}
|
||||
sym::bswap => {
|
||||
if width == 8 {
|
||||
args[0].immediate() // byte swap a u8/i8 is just a no-op
|
||||
} else {
|
||||
self.call_intrinsic(&format!("llvm.bswap.i{width}"), &[
|
||||
args[0].immediate()
|
||||
])
|
||||
self.call_intrinsic(
|
||||
&format!("llvm.bswap.i{width}"),
|
||||
&[args[0].immediate()],
|
||||
)
|
||||
}
|
||||
}
|
||||
sym::bitreverse => self
|
||||
.call_intrinsic(&format!("llvm.bitreverse.i{width}"), &[
|
||||
args[0].immediate()
|
||||
]),
|
||||
sym::bitreverse => self.call_intrinsic(
|
||||
&format!("llvm.bitreverse.i{width}"),
|
||||
&[args[0].immediate()],
|
||||
),
|
||||
sym::rotate_left | sym::rotate_right => {
|
||||
let is_left = name == sym::rotate_left;
|
||||
let val = args[0].immediate();
|
||||
|
@ -500,11 +505,10 @@ impl<'ll, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||
|
||||
sym::compare_bytes => {
|
||||
// Here we assume that the `memcmp` provided by the target is a NOP for size 0.
|
||||
let cmp = self.call_intrinsic("memcmp", &[
|
||||
args[0].immediate(),
|
||||
args[1].immediate(),
|
||||
args[2].immediate(),
|
||||
]);
|
||||
let cmp = self.call_intrinsic(
|
||||
"memcmp",
|
||||
&[args[0].immediate(), args[1].immediate(), args[2].immediate()],
|
||||
);
|
||||
// Some targets have `memcmp` returning `i16`, but the intrinsic is always `i32`.
|
||||
self.sext(cmp, self.type_ix(32))
|
||||
}
|
||||
|
@ -1305,14 +1309,17 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
if let Some(cmp_op) = comparison {
|
||||
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
|
||||
|
||||
require!(in_len == out_len, InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
});
|
||||
require!(
|
||||
in_len == out_len,
|
||||
InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
}
|
||||
);
|
||||
require!(
|
||||
bx.type_kind(bx.element_type(llret_ty)) == TypeKind::Integer,
|
||||
InvalidMonomorphization::ReturnIntegerType { span, name, ret_ty, out_ty }
|
||||
|
@ -1333,21 +1340,14 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
let n = idx.len() as u64;
|
||||
|
||||
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
|
||||
require!(out_len == n, InvalidMonomorphization::ReturnLength {
|
||||
span,
|
||||
name,
|
||||
in_len: n,
|
||||
ret_ty,
|
||||
out_len
|
||||
});
|
||||
require!(in_elem == out_ty, InvalidMonomorphization::ReturnElement {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_ty
|
||||
});
|
||||
require!(
|
||||
out_len == n,
|
||||
InvalidMonomorphization::ReturnLength { span, name, in_len: n, ret_ty, out_len }
|
||||
);
|
||||
require!(
|
||||
in_elem == out_ty,
|
||||
InvalidMonomorphization::ReturnElement { span, name, in_elem, in_ty, ret_ty, out_ty }
|
||||
);
|
||||
|
||||
let total_len = in_len * 2;
|
||||
|
||||
|
@ -1392,21 +1392,14 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
};
|
||||
|
||||
let (out_len, out_ty) = require_simd!(ret_ty, SimdReturn);
|
||||
require!(out_len == n, InvalidMonomorphization::ReturnLength {
|
||||
span,
|
||||
name,
|
||||
in_len: n,
|
||||
ret_ty,
|
||||
out_len
|
||||
});
|
||||
require!(in_elem == out_ty, InvalidMonomorphization::ReturnElement {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_ty
|
||||
});
|
||||
require!(
|
||||
out_len == n,
|
||||
InvalidMonomorphization::ReturnLength { span, name, in_len: n, ret_ty, out_len }
|
||||
);
|
||||
require!(
|
||||
in_elem == out_ty,
|
||||
InvalidMonomorphization::ReturnElement { span, name, in_elem, in_ty, ret_ty, out_ty }
|
||||
);
|
||||
|
||||
let total_len = u128::from(in_len) * 2;
|
||||
|
||||
|
@ -1431,13 +1424,16 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
}
|
||||
|
||||
if name == sym::simd_insert {
|
||||
require!(in_elem == arg_tys[2], InvalidMonomorphization::InsertedType {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
out_ty: arg_tys[2]
|
||||
});
|
||||
require!(
|
||||
in_elem == arg_tys[2],
|
||||
InvalidMonomorphization::InsertedType {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
out_ty: arg_tys[2]
|
||||
}
|
||||
);
|
||||
let idx = bx
|
||||
.const_to_opt_u128(args[1].immediate(), false)
|
||||
.expect("typeck should have ensure that this is a const");
|
||||
|
@ -1456,13 +1452,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
));
|
||||
}
|
||||
if name == sym::simd_extract {
|
||||
require!(ret_ty == in_elem, InvalidMonomorphization::ReturnType {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
});
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
let idx = bx
|
||||
.const_to_opt_u128(args[1].immediate(), false)
|
||||
.expect("typeck should have ensure that this is a const");
|
||||
|
@ -1481,18 +1474,14 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
let m_elem_ty = in_elem;
|
||||
let m_len = in_len;
|
||||
let (v_len, _) = require_simd!(arg_tys[1], SimdArgument);
|
||||
require!(m_len == v_len, InvalidMonomorphization::MismatchedLengths {
|
||||
span,
|
||||
name,
|
||||
m_len,
|
||||
v_len
|
||||
});
|
||||
let in_elem_bitwidth =
|
||||
require_int_ty!(m_elem_ty.kind(), InvalidMonomorphization::MaskType {
|
||||
span,
|
||||
name,
|
||||
ty: m_elem_ty
|
||||
});
|
||||
require!(
|
||||
m_len == v_len,
|
||||
InvalidMonomorphization::MismatchedLengths { span, name, m_len, v_len }
|
||||
);
|
||||
let in_elem_bitwidth = require_int_ty!(
|
||||
m_elem_ty.kind(),
|
||||
InvalidMonomorphization::MaskType { span, name, ty: m_elem_ty }
|
||||
);
|
||||
let m_i1s = vector_mask_to_bitmask(bx, args[0].immediate(), in_elem_bitwidth, m_len);
|
||||
return Ok(bx.select(m_i1s, args[1].immediate(), args[2].immediate()));
|
||||
}
|
||||
|
@ -1510,13 +1499,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
let expected_bytes = in_len.div_ceil(8);
|
||||
|
||||
// Integer vector <i{in_bitwidth} x in_len>:
|
||||
let in_elem_bitwidth =
|
||||
require_int_or_uint_ty!(in_elem.kind(), InvalidMonomorphization::VectorArgument {
|
||||
span,
|
||||
name,
|
||||
in_ty,
|
||||
in_elem
|
||||
});
|
||||
let in_elem_bitwidth = require_int_or_uint_ty!(
|
||||
in_elem.kind(),
|
||||
InvalidMonomorphization::VectorArgument { span, name, in_ty, in_elem }
|
||||
);
|
||||
|
||||
let i1xn = vector_mask_to_bitmask(bx, args[0].immediate(), in_elem_bitwidth, in_len);
|
||||
// Bitcast <i1 x N> to iN:
|
||||
|
@ -1698,30 +1684,34 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
require_simd!(ret_ty, SimdReturn);
|
||||
|
||||
// Of the same length:
|
||||
require!(in_len == out_len, InvalidMonomorphization::SecondArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[1],
|
||||
out_len
|
||||
});
|
||||
require!(in_len == out_len2, InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[2],
|
||||
out_len: out_len2
|
||||
});
|
||||
require!(
|
||||
in_len == out_len,
|
||||
InvalidMonomorphization::SecondArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[1],
|
||||
out_len
|
||||
}
|
||||
);
|
||||
require!(
|
||||
in_len == out_len2,
|
||||
InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[2],
|
||||
out_len: out_len2
|
||||
}
|
||||
);
|
||||
|
||||
// The return type must match the first argument type
|
||||
require!(ret_ty == in_ty, InvalidMonomorphization::ExpectedReturnType {
|
||||
span,
|
||||
name,
|
||||
in_ty,
|
||||
ret_ty
|
||||
});
|
||||
require!(
|
||||
ret_ty == in_ty,
|
||||
InvalidMonomorphization::ExpectedReturnType { span, name, in_ty, ret_ty }
|
||||
);
|
||||
|
||||
require!(
|
||||
matches!(
|
||||
|
@ -1739,13 +1729,15 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
}
|
||||
);
|
||||
|
||||
let mask_elem_bitwidth =
|
||||
require_int_ty!(element_ty2.kind(), InvalidMonomorphization::ThirdArgElementType {
|
||||
let mask_elem_bitwidth = require_int_ty!(
|
||||
element_ty2.kind(),
|
||||
InvalidMonomorphization::ThirdArgElementType {
|
||||
span,
|
||||
name,
|
||||
expected_element: element_ty2,
|
||||
third_arg: arg_tys[2]
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Alignment of T, must be a constant integer value:
|
||||
let alignment_ty = bx.type_i32();
|
||||
|
@ -1805,22 +1797,23 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
require_simd!(ret_ty, SimdReturn);
|
||||
|
||||
// Of the same length:
|
||||
require!(values_len == mask_len, InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len: mask_len,
|
||||
in_ty: mask_ty,
|
||||
arg_ty: values_ty,
|
||||
out_len: values_len
|
||||
});
|
||||
require!(
|
||||
values_len == mask_len,
|
||||
InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len: mask_len,
|
||||
in_ty: mask_ty,
|
||||
arg_ty: values_ty,
|
||||
out_len: values_len
|
||||
}
|
||||
);
|
||||
|
||||
// The return type must match the last argument type
|
||||
require!(ret_ty == values_ty, InvalidMonomorphization::ExpectedReturnType {
|
||||
span,
|
||||
name,
|
||||
in_ty: values_ty,
|
||||
ret_ty
|
||||
});
|
||||
require!(
|
||||
ret_ty == values_ty,
|
||||
InvalidMonomorphization::ExpectedReturnType { span, name, in_ty: values_ty, ret_ty }
|
||||
);
|
||||
|
||||
require!(
|
||||
matches!(
|
||||
|
@ -1838,13 +1831,15 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
}
|
||||
);
|
||||
|
||||
let m_elem_bitwidth =
|
||||
require_int_ty!(mask_elem.kind(), InvalidMonomorphization::ThirdArgElementType {
|
||||
let m_elem_bitwidth = require_int_ty!(
|
||||
mask_elem.kind(),
|
||||
InvalidMonomorphization::ThirdArgElementType {
|
||||
span,
|
||||
name,
|
||||
expected_element: values_elem,
|
||||
third_arg: mask_ty,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
let mask = vector_mask_to_bitmask(bx, args[0].immediate(), m_elem_bitwidth, mask_len);
|
||||
let mask_ty = bx.type_vector(bx.type_i1(), mask_len);
|
||||
|
@ -1896,14 +1891,17 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
let (values_len, values_elem) = require_simd!(values_ty, SimdThird);
|
||||
|
||||
// Of the same length:
|
||||
require!(values_len == mask_len, InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len: mask_len,
|
||||
in_ty: mask_ty,
|
||||
arg_ty: values_ty,
|
||||
out_len: values_len
|
||||
});
|
||||
require!(
|
||||
values_len == mask_len,
|
||||
InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len: mask_len,
|
||||
in_ty: mask_ty,
|
||||
arg_ty: values_ty,
|
||||
out_len: values_len
|
||||
}
|
||||
);
|
||||
|
||||
// The second argument must be a mutable pointer type matching the element type
|
||||
require!(
|
||||
|
@ -1923,13 +1921,15 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
}
|
||||
);
|
||||
|
||||
let m_elem_bitwidth =
|
||||
require_int_ty!(mask_elem.kind(), InvalidMonomorphization::ThirdArgElementType {
|
||||
let m_elem_bitwidth = require_int_ty!(
|
||||
mask_elem.kind(),
|
||||
InvalidMonomorphization::ThirdArgElementType {
|
||||
span,
|
||||
name,
|
||||
expected_element: values_elem,
|
||||
third_arg: mask_ty,
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
let mask = vector_mask_to_bitmask(bx, args[0].immediate(), m_elem_bitwidth, mask_len);
|
||||
let mask_ty = bx.type_vector(bx.type_i1(), mask_len);
|
||||
|
@ -1976,22 +1976,28 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
let (element_len2, element_ty2) = require_simd!(arg_tys[2], SimdThird);
|
||||
|
||||
// Of the same length:
|
||||
require!(in_len == element_len1, InvalidMonomorphization::SecondArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[1],
|
||||
out_len: element_len1
|
||||
});
|
||||
require!(in_len == element_len2, InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[2],
|
||||
out_len: element_len2
|
||||
});
|
||||
require!(
|
||||
in_len == element_len1,
|
||||
InvalidMonomorphization::SecondArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[1],
|
||||
out_len: element_len1
|
||||
}
|
||||
);
|
||||
require!(
|
||||
in_len == element_len2,
|
||||
InvalidMonomorphization::ThirdArgumentLength {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
arg_ty: arg_tys[2],
|
||||
out_len: element_len2
|
||||
}
|
||||
);
|
||||
|
||||
require!(
|
||||
matches!(
|
||||
|
@ -2011,13 +2017,15 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
);
|
||||
|
||||
// The element type of the third argument must be a signed integer type of any width:
|
||||
let mask_elem_bitwidth =
|
||||
require_int_ty!(element_ty2.kind(), InvalidMonomorphization::ThirdArgElementType {
|
||||
let mask_elem_bitwidth = require_int_ty!(
|
||||
element_ty2.kind(),
|
||||
InvalidMonomorphization::ThirdArgElementType {
|
||||
span,
|
||||
name,
|
||||
expected_element: element_ty2,
|
||||
third_arg: arg_tys[2]
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
// Alignment of T, must be a constant integer value:
|
||||
let alignment_ty = bx.type_i32();
|
||||
|
@ -2058,13 +2066,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
($name:ident : $integer_reduce:ident, $float_reduce:ident, $ordered:expr, $op:ident,
|
||||
$identity:expr) => {
|
||||
if name == sym::$name {
|
||||
require!(ret_ty == in_elem, InvalidMonomorphization::ReturnType {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
});
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
return match in_elem.kind() {
|
||||
ty::Int(_) | ty::Uint(_) => {
|
||||
let r = bx.$integer_reduce(args[0].immediate());
|
||||
|
@ -2133,13 +2138,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
macro_rules! minmax_red {
|
||||
($name:ident: $int_red:ident, $float_red:ident) => {
|
||||
if name == sym::$name {
|
||||
require!(ret_ty == in_elem, InvalidMonomorphization::ReturnType {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
});
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
return match in_elem.kind() {
|
||||
ty::Int(_i) => Ok(bx.$int_red(args[0].immediate(), true)),
|
||||
ty::Uint(_u) => Ok(bx.$int_red(args[0].immediate(), false)),
|
||||
|
@ -2164,13 +2166,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
($name:ident : $red:ident, $boolean:expr) => {
|
||||
if name == sym::$name {
|
||||
let input = if !$boolean {
|
||||
require!(ret_ty == in_elem, InvalidMonomorphization::ReturnType {
|
||||
span,
|
||||
name,
|
||||
in_elem,
|
||||
in_ty,
|
||||
ret_ty
|
||||
});
|
||||
require!(
|
||||
ret_ty == in_elem,
|
||||
InvalidMonomorphization::ReturnType { span, name, in_elem, in_ty, ret_ty }
|
||||
);
|
||||
args[0].immediate()
|
||||
} else {
|
||||
let bitwidth = match in_elem.kind() {
|
||||
|
@ -2218,25 +2217,27 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
|
||||
if name == sym::simd_cast_ptr {
|
||||
let (out_len, out_elem) = require_simd!(ret_ty, SimdReturn);
|
||||
require!(in_len == out_len, InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
});
|
||||
require!(
|
||||
in_len == out_len,
|
||||
InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
}
|
||||
);
|
||||
|
||||
match in_elem.kind() {
|
||||
ty::RawPtr(p_ty, _) => {
|
||||
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
|
||||
bx.tcx.normalize_erasing_regions(bx.typing_env(), ty)
|
||||
});
|
||||
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
|
||||
span,
|
||||
name,
|
||||
ty: in_elem
|
||||
});
|
||||
require!(
|
||||
metadata.is_unit(),
|
||||
InvalidMonomorphization::CastWidePointer { span, name, ty: in_elem }
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: in_elem })
|
||||
|
@ -2247,11 +2248,10 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
let metadata = p_ty.ptr_metadata_ty(bx.tcx, |ty| {
|
||||
bx.tcx.normalize_erasing_regions(bx.typing_env(), ty)
|
||||
});
|
||||
require!(metadata.is_unit(), InvalidMonomorphization::CastWidePointer {
|
||||
span,
|
||||
name,
|
||||
ty: out_elem
|
||||
});
|
||||
require!(
|
||||
metadata.is_unit(),
|
||||
InvalidMonomorphization::CastWidePointer { span, name, ty: out_elem }
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
return_error!(InvalidMonomorphization::ExpectedPointer { span, name, ty: out_elem })
|
||||
|
@ -2263,14 +2263,17 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
|
||||
if name == sym::simd_expose_provenance {
|
||||
let (out_len, out_elem) = require_simd!(ret_ty, SimdReturn);
|
||||
require!(in_len == out_len, InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
});
|
||||
require!(
|
||||
in_len == out_len,
|
||||
InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
}
|
||||
);
|
||||
|
||||
match in_elem.kind() {
|
||||
ty::RawPtr(_, _) => {}
|
||||
|
@ -2288,14 +2291,17 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
|
||||
if name == sym::simd_with_exposed_provenance {
|
||||
let (out_len, out_elem) = require_simd!(ret_ty, SimdReturn);
|
||||
require!(in_len == out_len, InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
});
|
||||
require!(
|
||||
in_len == out_len,
|
||||
InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
}
|
||||
);
|
||||
|
||||
match in_elem.kind() {
|
||||
ty::Uint(ty::UintTy::Usize) => {}
|
||||
|
@ -2313,14 +2319,17 @@ fn generic_simd_intrinsic<'ll, 'tcx>(
|
|||
|
||||
if name == sym::simd_cast || name == sym::simd_as {
|
||||
let (out_len, out_elem) = require_simd!(ret_ty, SimdReturn);
|
||||
require!(in_len == out_len, InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
});
|
||||
require!(
|
||||
in_len == out_len,
|
||||
InvalidMonomorphization::ReturnLengthInputType {
|
||||
span,
|
||||
name,
|
||||
in_len,
|
||||
in_ty,
|
||||
ret_ty,
|
||||
out_len
|
||||
}
|
||||
);
|
||||
// casting cares about nominal type, not just structural type
|
||||
if in_elem == out_elem {
|
||||
return Ok(args[0].immediate());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue