mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-20 10:55:14 +00:00
implement minmax intrinsics
This commit is contained in:
parent
184156ed97
commit
7d5343a670
@ -1247,6 +1247,9 @@ extern "C" {
|
||||
IsNaN: bool)
|
||||
-> ValueRef;
|
||||
|
||||
pub fn LLVMRustBuildMinNum(B: BuilderRef, LHS: ValueRef, LHS: ValueRef) -> ValueRef;
|
||||
pub fn LLVMRustBuildMaxNum(B: BuilderRef, LHS: ValueRef, LHS: ValueRef) -> ValueRef;
|
||||
|
||||
pub fn LLVMBuildIsNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
|
||||
pub fn LLVMBuildIsNotNull(B: BuilderRef, Val: ValueRef, Name: *const c_char) -> ValueRef;
|
||||
pub fn LLVMBuildPtrDiff(B: BuilderRef,
|
||||
|
@ -917,6 +917,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn minnum(&self, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||
self.count_insn("minnum");
|
||||
unsafe {
|
||||
llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs)
|
||||
}
|
||||
}
|
||||
pub fn maxnum(&self, lhs: ValueRef, rhs: ValueRef) -> ValueRef {
|
||||
self.count_insn("maxnum");
|
||||
unsafe {
|
||||
llvm::LLVMRustBuildMaxNum(self.llbuilder, lhs, rhs)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn select(&self, cond: ValueRef, then_val: ValueRef, else_val: ValueRef) -> ValueRef {
|
||||
self.count_insn("select");
|
||||
unsafe {
|
||||
|
@ -1432,6 +1432,8 @@ unsupported {} from `{}` with element `{}` of size `{}` to `{}`"#,
|
||||
simd_and: TyUint, TyInt => and;
|
||||
simd_or: TyUint, TyInt => or;
|
||||
simd_xor: TyUint, TyInt => xor;
|
||||
simd_fmax: TyFloat => maxnum;
|
||||
simd_fmin: TyFloat => minnum;
|
||||
}
|
||||
span_bug!(span, "unknown SIMD intrinsic");
|
||||
}
|
||||
|
@ -355,7 +355,8 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}
|
||||
"simd_add" | "simd_sub" | "simd_mul" | "simd_rem" |
|
||||
"simd_div" | "simd_shl" | "simd_shr" |
|
||||
"simd_and" | "simd_or" | "simd_xor" => {
|
||||
"simd_and" | "simd_or" | "simd_xor" |
|
||||
"simd_fmin" | "simd_fmax" => {
|
||||
(1, vec![param(0), param(0)], param(0))
|
||||
}
|
||||
"simd_insert" => (2, vec![param(0), tcx.types.u32, param(1)], param(0)),
|
||||
|
@ -1500,3 +1500,12 @@ LLVMBuildExactUDiv(LLVMBuilderRef B, LLVMValueRef LHS,
|
||||
return wrap(unwrap(B)->CreateExactUDiv(unwrap(LHS), unwrap(RHS), Name));
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" LLVMValueRef
|
||||
LLVMRustBuildMinNum(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS) {
|
||||
return wrap(unwrap(B)->CreateMinNum(unwrap(LHS),unwrap(RHS)));
|
||||
}
|
||||
extern "C" LLVMValueRef
|
||||
LLVMRustBuildMaxNum(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS) {
|
||||
return wrap(unwrap(B)->CreateMaxNum(unwrap(LHS),unwrap(RHS)));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user