|
1 | 1 | use std::borrow::Cow;
|
2 | 2 |
|
3 |
| -use gccjit::CType; |
| 3 | +use gccjit::{CType, Context}; |
4 | 4 | use gccjit::{Function, FunctionPtrType, RValue, ToRValue, UnaryOp};
|
5 | 5 | use rustc_codegen_ssa::traits::BuilderMethods;
|
6 | 6 |
|
7 | 7 | use crate::builder::Builder;
|
8 | 8 | use crate::context::CodegenCx;
|
9 | 9 |
|
| 10 | +pub fn adjust_function<'gcc>( |
| 11 | + context: &'gcc Context<'gcc>, |
| 12 | + func_name: &str, |
| 13 | + func_ptr: RValue<'gcc>, |
| 14 | + args: &[RValue<'gcc>], |
| 15 | +) -> RValue<'gcc> { |
| 16 | + // FIXME: we should not need this hack: this is required because both _mm_fcmadd_sch |
| 17 | + // and _mm_mask3_fcmadd_round_sch calls llvm.x86.avx512fp16.mask.vfcmadd.csh and we |
| 18 | + // seem to need to map this one LLVM intrinsic to 2 different GCC builtins. |
| 19 | + match func_name { |
| 20 | + "__builtin_ia32_vfcmaddcsh_mask3_round" => { |
| 21 | + if format!("{:?}", args[3]).ends_with("255") { |
| 22 | + return context |
| 23 | + .get_target_builtin_function("__builtin_ia32_vfcmaddcsh_mask_round") |
| 24 | + .get_address(None); |
| 25 | + } |
| 26 | + } |
| 27 | + "__builtin_ia32_vfmaddcsh_mask3_round" => { |
| 28 | + if format!("{:?}", args[3]).ends_with("255") { |
| 29 | + return context |
| 30 | + .get_target_builtin_function("__builtin_ia32_vfmaddcsh_mask_round") |
| 31 | + .get_address(None); |
| 32 | + } |
| 33 | + } |
| 34 | + _ => (), |
| 35 | + } |
| 36 | + |
| 37 | + func_ptr |
| 38 | +} |
| 39 | + |
10 | 40 | pub fn adjust_intrinsic_arguments<'a, 'b, 'gcc, 'tcx>(
|
11 | 41 | builder: &Builder<'a, 'gcc, 'tcx>,
|
12 | 42 | gcc_func: FunctionPtrType<'gcc>,
|
@@ -1198,7 +1228,7 @@ pub fn intrinsic<'gcc, 'tcx>(name: &str, cx: &CodegenCx<'gcc, 'tcx>) -> Function
|
1198 | 1228 | "llvm.x86.avx512fp16.mask.vfcmul.csh" => "__builtin_ia32_vfcmulcsh_mask_round",
|
1199 | 1229 | "llvm.x86.avx512fp16.mask.vfmadd.cph.512" => "__builtin_ia32_vfmaddcph512_mask3_round",
|
1200 | 1230 | "llvm.x86.avx512fp16.maskz.vfmadd.cph.512" => "__builtin_ia32_vfmaddcph512_maskz_round",
|
1201 |
| - "llvm.x86.avx512fp16.mask.vfmadd.csh" => "__builtin_ia32_vfmaddcsh_mask_round", |
| 1231 | + "llvm.x86.avx512fp16.mask.vfmadd.csh" => "__builtin_ia32_vfmaddcsh_mask3_round", |
1202 | 1232 | "llvm.x86.avx512fp16.maskz.vfmadd.csh" => "__builtin_ia32_vfmaddcsh_maskz_round",
|
1203 | 1233 | "llvm.x86.avx512fp16.mask.vfcmadd.cph.512" => "__builtin_ia32_vfcmaddcph512_mask3_round",
|
1204 | 1234 | "llvm.x86.avx512fp16.maskz.vfcmadd.cph.512" => "__builtin_ia32_vfcmaddcph512_maskz_round",
|
|
0 commit comments