/*
* List of LLVM intrinsics
*
- * INTRINS(id, llvm_id)
+ * INTRINS(id, llvm_id, llvm_argument_type)
* To define a simple intrinsic
- * INTRINS_OVR(id, llvm_id)
- * To define an overloaded intrinsic
+ * INTRINS_OVR(id, llvm_id, llvm_argument_type)
+ * To define an overloaded intrinsic with a single argument
+ * INTRINS_OVR_2_ARG(id, llvm_id, llvm_argument_type1, llvm_argument_type2)
+ * To define an overloaded intrinsic with two arguments
+ * INTRINS_OVR_3_ARG(id, llvm_id, llvm_argument_type1, llvm_argument_type2, llvm_argument_type3)
+ * To define an overloaded intrinsic with three arguments
*/
-INTRINS_OVR(MEMSET, memset)
-INTRINS_OVR(MEMCPY, memcpy)
-INTRINS_OVR(MEMMOVE, memmove)
-INTRINS_OVR(SADD_OVF_I32, sadd_with_overflow)
-INTRINS_OVR(UADD_OVF_I32, uadd_with_overflow)
-INTRINS_OVR(SSUB_OVF_I32, ssub_with_overflow)
-INTRINS_OVR(USUB_OVF_I32, usub_with_overflow)
-INTRINS_OVR(SMUL_OVF_I32, smul_with_overflow)
-INTRINS_OVR(UMUL_OVF_I32, umul_with_overflow)
-INTRINS_OVR(SADD_OVF_I64, sadd_with_overflow)
-INTRINS_OVR(UADD_OVF_I64, uadd_with_overflow)
-INTRINS_OVR(SSUB_OVF_I64, ssub_with_overflow)
-INTRINS_OVR(USUB_OVF_I64, usub_with_overflow)
-INTRINS_OVR(SMUL_OVF_I64, smul_with_overflow)
-INTRINS_OVR(UMUL_OVF_I64, umul_with_overflow)
-INTRINS_OVR(SIN, sin)
-INTRINS_OVR(COS, cos)
-INTRINS_OVR(SQRT, sqrt)
-INTRINS_OVR(FLOOR, floor)
-INTRINS_OVR(FLOORF, floor)
-INTRINS_OVR(CEIL, ceil)
-INTRINS_OVR(CEILF, ceil)
-INTRINS_OVR(FMA, fma)
-INTRINS_OVR(FMAF, fma)
+INTRINS_OVR_2_ARG(MEMSET, memset, LLVMPointerType (LLVMInt8Type (), 0), LLVMInt32Type ())
+INTRINS_OVR_3_ARG(MEMCPY, memcpy, LLVMPointerType (LLVMInt8Type (), 0), LLVMPointerType (LLVMInt8Type (), 0), LLVMInt32Type () )
+INTRINS_OVR_3_ARG(MEMMOVE, memmove, LLVMPointerType (LLVMInt8Type (), 0), LLVMPointerType (LLVMInt8Type (), 0), LLVMInt64Type ())
+INTRINS_OVR(SADD_OVF_I32, sadd_with_overflow, LLVMInt32Type ())
+INTRINS_OVR(UADD_OVF_I32, uadd_with_overflow, LLVMInt32Type ())
+INTRINS_OVR(SSUB_OVF_I32, ssub_with_overflow, LLVMInt32Type ())
+INTRINS_OVR(USUB_OVF_I32, usub_with_overflow, LLVMInt32Type ())
+INTRINS_OVR(SMUL_OVF_I32, smul_with_overflow, LLVMInt32Type ())
+INTRINS_OVR(UMUL_OVF_I32, umul_with_overflow, LLVMInt32Type ())
+INTRINS_OVR(SADD_OVF_I64, sadd_with_overflow, LLVMInt64Type ())
+INTRINS_OVR(UADD_OVF_I64, uadd_with_overflow, LLVMInt64Type ())
+INTRINS_OVR(SSUB_OVF_I64, ssub_with_overflow, LLVMInt64Type ())
+INTRINS_OVR(USUB_OVF_I64, usub_with_overflow, LLVMInt64Type ())
+INTRINS_OVR(SMUL_OVF_I64, smul_with_overflow, LLVMInt64Type ())
+INTRINS_OVR(UMUL_OVF_I64, umul_with_overflow, LLVMInt64Type ())
+INTRINS_OVR(SIN, sin, LLVMDoubleType ())
+INTRINS_OVR(COS, cos, LLVMDoubleType ())
+INTRINS_OVR(SQRT, sqrt, LLVMDoubleType ())
+INTRINS_OVR(FLOOR, floor, LLVMDoubleType ())
+INTRINS_OVR(FLOORF, floor, LLVMFloatType ())
+INTRINS_OVR(CEIL, ceil, LLVMDoubleType ())
+INTRINS_OVR(CEILF, ceil, LLVMFloatType ())
+INTRINS_OVR(FMA, fma, LLVMDoubleType ())
+INTRINS_OVR(FMAF, fma, LLVMFloatType ())
/* This isn't an intrinsic, instead llvm seems to special case it by name */
-INTRINS_OVR(FABS, fabs)
-INTRINS_OVR(ABSF, fabs)
-INTRINS_OVR(SINF, sin)
-INTRINS_OVR(COSF, cos)
-INTRINS_OVR(SQRTF, sqrt)
-INTRINS_OVR(POWF, pow)
-INTRINS_OVR(POW, pow)
-INTRINS_OVR(EXP, exp)
-INTRINS_OVR(EXPF, exp)
-INTRINS_OVR(LOG, log)
-INTRINS_OVR(LOG2, log2)
-INTRINS_OVR(LOG2F, log2)
-INTRINS_OVR(LOG10, log10)
-INTRINS_OVR(LOG10F, log10)
-INTRINS_OVR(TRUNC, trunc)
-INTRINS_OVR(TRUNCF, trunc)
-INTRINS_OVR(COPYSIGN, copysign)
-INTRINS_OVR(COPYSIGNF, copysign)
-INTRINS_OVR(EXPECT_I8, expect)
-INTRINS_OVR(EXPECT_I1, expect)
-INTRINS_OVR(CTPOP_I32, ctpop)
-INTRINS_OVR(CTPOP_I64, ctpop)
-INTRINS_OVR(CTLZ_I32, ctlz)
-INTRINS_OVR(CTLZ_I64, ctlz)
-INTRINS_OVR(CTTZ_I32, cttz)
-INTRINS_OVR(CTTZ_I64, cttz)
+INTRINS_OVR(FABS, fabs, LLVMDoubleType ())
+INTRINS_OVR(ABSF, fabs,LLVMFloatType ())
+INTRINS_OVR(SINF, sin, LLVMFloatType ())
+INTRINS_OVR(COSF, cos, LLVMFloatType ())
+INTRINS_OVR(SQRTF, sqrt, LLVMFloatType ())
+INTRINS_OVR(POWF, pow, LLVMFloatType ())
+INTRINS_OVR(POW, pow, LLVMDoubleType ())
+INTRINS_OVR(EXP, exp, LLVMDoubleType ())
+INTRINS_OVR(EXPF, exp, LLVMFloatType ())
+INTRINS_OVR(LOG, log, LLVMDoubleType ())
+INTRINS_OVR(LOG2, log2, LLVMDoubleType ())
+INTRINS_OVR(LOG2F, log2, LLVMFloatType ())
+INTRINS_OVR(LOG10, log10, LLVMDoubleType ())
+INTRINS_OVR(LOG10F, log10, LLVMFloatType ())
+INTRINS_OVR(TRUNC, trunc, LLVMDoubleType ())
+INTRINS_OVR(TRUNCF, trunc, LLVMFloatType ())
+INTRINS_OVR(COPYSIGN, copysign, LLVMDoubleType ())
+INTRINS_OVR(COPYSIGNF, copysign, LLVMFloatType ())
+INTRINS_OVR(EXPECT_I8, expect, LLVMInt8Type ())
+INTRINS_OVR(EXPECT_I1, expect, LLVMInt1Type ())
+INTRINS_OVR(CTPOP_I32, ctpop, LLVMInt32Type ())
+INTRINS_OVR(CTPOP_I64, ctpop, LLVMInt64Type ())
+INTRINS_OVR(CTLZ_I32, ctlz, LLVMInt32Type ())
+INTRINS_OVR(CTLZ_I64, ctlz, LLVMInt64Type ())
+INTRINS_OVR(CTTZ_I32, cttz, LLVMInt32Type ())
+INTRINS_OVR(CTTZ_I64, cttz, LLVMInt64Type ())
INTRINS(PREFETCH, prefetch)
INTRINS(BZHI_I32, x86_bmi_bzhi_32)
INTRINS(BZHI_I64, x86_bmi_bzhi_64)
INTRINS(SSE_SQRT_SD, x86_sse2_sqrt_sd)
INTRINS(SSE_PMULUDQ, x86_sse2_pmulu_dq)
#else
-INTRINS_OVR(SSE_SQRT_PD, sqrt)
-INTRINS_OVR(SSE_SQRT_PS, sqrt)
-INTRINS_OVR(SSE_SQRT_SD, sqrt)
-INTRINS_OVR(SSE_SQRT_SS, sqrt)
+INTRINS_OVR(SSE_SQRT_PD, sqrt, sse_r8_t)
+INTRINS_OVR(SSE_SQRT_PS, sqrt, sse_r4_t)
+INTRINS_OVR(SSE_SQRT_SD, sqrt, LLVMDoubleType ())
+INTRINS_OVR(SSE_SQRT_SS, sqrt, LLVMFloatType ())
#endif
INTRINS(SSE_RCP_PS, x86_sse_rcp_ps)
INTRINS(SSE_RSQRT_PS, x86_sse_rsqrt_ps)
INTRINS(AESNI_AESIMC, x86_aesni_aesimc)
#if LLVM_API_VERSION >= 800
// these intrinsics were renamed in LLVM 8
-INTRINS_OVR(SSE_SADD_SATI8, sadd_sat)
-INTRINS_OVR(SSE_UADD_SATI8, uadd_sat)
-INTRINS_OVR(SSE_SADD_SATI16, sadd_sat)
-INTRINS_OVR(SSE_UADD_SATI16, uadd_sat)
+INTRINS_OVR(SSE_SADD_SATI8, sadd_sat, sse_i1_t)
+INTRINS_OVR(SSE_UADD_SATI8, uadd_sat, sse_i1_t)
+INTRINS_OVR(SSE_SADD_SATI16, sadd_sat, sse_i1_t)
+INTRINS_OVR(SSE_UADD_SATI16, uadd_sat, sse_i1_t)
-INTRINS_OVR(SSE_SSUB_SATI8, ssub_sat)
-INTRINS_OVR(SSE_USUB_SATI8, usub_sat)
-INTRINS_OVR(SSE_SSUB_SATI16, ssub_sat)
-INTRINS_OVR(SSE_USUB_SATI16, usub_sat)
+INTRINS_OVR(SSE_SSUB_SATI8, ssub_sat, sse_i2_t)
+INTRINS_OVR(SSE_USUB_SATI8, usub_sat, sse_i2_t)
+INTRINS_OVR(SSE_SSUB_SATI16, ssub_sat, sse_i2_t)
+INTRINS_OVR(SSE_USUB_SATI16, usub_sat, sse_i2_t)
#else
INTRINS(SSE_SADD_SATI8, x86_sse2_padds_b)
INTRINS(SSE_UADD_SATI8, x86_sse2_paddus_b)
#endif
#endif
#if defined(TARGET_WASM) && LLVM_API_VERSION >= 800
-INTRINS_OVR(WASM_ANYTRUE_V16, wasm_anytrue)
-INTRINS_OVR(WASM_ANYTRUE_V8, wasm_anytrue)
-INTRINS_OVR(WASM_ANYTRUE_V4, wasm_anytrue)
-INTRINS_OVR(WASM_ANYTRUE_V2, wasm_anytrue)
+INTRINS_OVR(WASM_ANYTRUE_V16, wasm_anytrue, sse_i1_t)
+INTRINS_OVR(WASM_ANYTRUE_V8, wasm_anytrue, sse_i2_t)
+INTRINS_OVR(WASM_ANYTRUE_V4, wasm_anytrue, sse_i4_t)
+INTRINS_OVR(WASM_ANYTRUE_V2, wasm_anytrue, sse_i8_t)
#endif
#if defined(TARGET_ARM64)
-INTRINS_OVR(BITREVERSE_I32, bitreverse)
-INTRINS_OVR(BITREVERSE_I64, bitreverse)
+INTRINS_OVR(BITREVERSE_I32, bitreverse, LLVMInt32Type ())
+INTRINS_OVR(BITREVERSE_I64, bitreverse, LLVMInt64Type ())
INTRINS(AARCH64_CRC32B, aarch64_crc32b)
INTRINS(AARCH64_CRC32H, aarch64_crc32h)
INTRINS(AARCH64_CRC32W, aarch64_crc32w)
INTRINS(AARCH64_SHA256SU1, aarch64_crypto_sha256su1)
INTRINS(AARCH64_SHA256H, aarch64_crypto_sha256h)
INTRINS(AARCH64_SHA256H2, aarch64_crypto_sha256h2)
-INTRINS_OVR(AARCH64_ADV_SIMD_ABS_FLOAT, fabs)
-INTRINS_OVR(AARCH64_ADV_SIMD_ABS_DOUBLE, fabs)
-INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT8, aarch64_neon_abs)
-INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT16, aarch64_neon_abs)
-INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT32, aarch64_neon_abs)
-INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT64, aarch64_neon_abs)
+INTRINS_OVR(AARCH64_ADV_SIMD_ABS_FLOAT, fabs, sse_r4_t)
+INTRINS_OVR(AARCH64_ADV_SIMD_ABS_DOUBLE, fabs, sse_r8_t)
+INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT8, aarch64_neon_abs, sse_i1_t)
+INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT16, aarch64_neon_abs, sse_i2_t)
+INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT32, aarch64_neon_abs, sse_i4_t)
+INTRINS_OVR(AARCH64_ADV_SIMD_ABS_INT64, aarch64_neon_abs, sse_i8_t)
#endif
#undef INTRINS
#undef INTRINS_OVR
+#undef INTRINS_OVR_2_ARG
+#undef INTRINS_OVR_3_ARG
/* Register overloaded intrinsics */
switch (id) {
- case INTRINS_MEMSET:
- intrins = add_intrins2 (module, id, LLVMPointerType (LLVMInt8Type (), 0), LLVMInt32Type ());
- break;
- case INTRINS_MEMCPY:
- intrins = add_intrins3 (module, id, LLVMPointerType (LLVMInt8Type (), 0), LLVMPointerType (LLVMInt8Type (), 0), LLVMInt32Type ());
- break;
- case INTRINS_MEMMOVE:
- intrins = add_intrins3 (module, id, LLVMPointerType (LLVMInt8Type (), 0), LLVMPointerType (LLVMInt8Type (), 0), LLVMInt64Type ());
- break;
- case INTRINS_SADD_OVF_I32:
- case INTRINS_UADD_OVF_I32:
- case INTRINS_SSUB_OVF_I32:
- case INTRINS_USUB_OVF_I32:
- case INTRINS_SMUL_OVF_I32:
- case INTRINS_UMUL_OVF_I32:
- intrins = add_intrins1 (module, id, LLVMInt32Type ());
- break;
- case INTRINS_SADD_OVF_I64:
- case INTRINS_UADD_OVF_I64:
- case INTRINS_SSUB_OVF_I64:
- case INTRINS_USUB_OVF_I64:
- case INTRINS_SMUL_OVF_I64:
- case INTRINS_UMUL_OVF_I64:
- intrins = add_intrins1 (module, id, LLVMInt64Type ());
- break;
- case INTRINS_FMA:
- case INTRINS_EXP:
- case INTRINS_LOG:
- case INTRINS_LOG2:
- case INTRINS_LOG10:
- case INTRINS_TRUNC:
- case INTRINS_SIN:
- case INTRINS_COS:
- case INTRINS_SQRT:
- case INTRINS_FLOOR:
- case INTRINS_CEIL:
- case INTRINS_FABS:
- case INTRINS_COPYSIGN:
- case INTRINS_POW:
- intrins = add_intrins1 (module, id, LLVMDoubleType ());
- break;
- case INTRINS_FMAF:
- case INTRINS_EXPF:
- case INTRINS_LOG2F:
- case INTRINS_LOG10F:
- case INTRINS_TRUNCF:
- case INTRINS_SINF:
- case INTRINS_COSF:
- case INTRINS_SQRTF:
- case INTRINS_FLOORF:
- case INTRINS_CEILF:
- case INTRINS_ABSF:
- case INTRINS_COPYSIGNF:
- case INTRINS_POWF:
- intrins = add_intrins1 (module, id, LLVMFloatType ());
- break;
- case INTRINS_EXPECT_I8:
- intrins = add_intrins1 (module, id, LLVMInt8Type ());
- break;
- case INTRINS_EXPECT_I1:
- intrins = add_intrins1 (module, id, LLVMInt1Type ());
- break;
- case INTRINS_CTPOP_I32:
- case INTRINS_CTLZ_I32:
- case INTRINS_CTTZ_I32:
- case INTRINS_BEXTR_I32:
- case INTRINS_BZHI_I32:
- case INTRINS_PEXT_I32:
- case INTRINS_PDEP_I32:
- intrins = add_intrins1 (module, id, LLVMInt32Type ());
- break;
- case INTRINS_CTPOP_I64:
- case INTRINS_BEXTR_I64:
- case INTRINS_BZHI_I64:
- case INTRINS_PEXT_I64:
- case INTRINS_PDEP_I64:
- case INTRINS_CTLZ_I64:
- case INTRINS_CTTZ_I64:
- intrins = add_intrins1 (module, id, LLVMInt64Type ());
- break;
-#if defined(TARGET_AMD64) || defined(TARGET_X86)
- case INTRINS_SSE_SADD_SATI8:
- case INTRINS_SSE_UADD_SATI8:
- case INTRINS_SSE_SSUB_SATI8:
- case INTRINS_SSE_USUB_SATI8:
- intrins = add_intrins1 (module, id, sse_i1_t);
- break;
- case INTRINS_SSE_SADD_SATI16:
- case INTRINS_SSE_UADD_SATI16:
- case INTRINS_SSE_SSUB_SATI16:
- case INTRINS_SSE_USUB_SATI16:
- intrins = add_intrins1 (module, id, sse_i2_t);
- break;
-#if LLVM_API_VERSION >= 700
- case INTRINS_SSE_SQRT_PS:
- intrins = add_intrins1 (module, id, sse_r4_t);
- break;
- case INTRINS_SSE_SQRT_PD:
- intrins = add_intrins1 (module, id, sse_r8_t);
- break;
- case INTRINS_SSE_SQRT_SS:
- intrins = add_intrins1 (module, id, LLVMFloatType ());
- break;
- case INTRINS_SSE_SQRT_SD:
- intrins = add_intrins1 (module, id, LLVMDoubleType ());
- break;
-#endif /* LLVM_API_VERSION >= 700 */
-#endif /* AMD64 || X86 */
-#if defined(TARGET_WASM) && LLVM_API_VERSION >= 800
- case INTRINS_WASM_ANYTRUE_V16:
- intrins = add_intrins1 (module, id, sse_i1_t);
- break;
- case INTRINS_WASM_ANYTRUE_V8:
- intrins = add_intrins1 (module, id, sse_i2_t);
- break;
- case INTRINS_WASM_ANYTRUE_V4:
- intrins = add_intrins1 (module, id, sse_i4_t);
- break;
- case INTRINS_WASM_ANYTRUE_V2:
- intrins = add_intrins1 (module, id, sse_i8_t);
- break;
-#endif
-#ifdef TARGET_ARM64
- case INTRINS_BITREVERSE_I32:
- intrins = add_intrins1 (module, id, LLVMInt32Type ());
- break;
- case INTRINS_BITREVERSE_I64:
- intrins = add_intrins1 (module, id, LLVMInt64Type ());
- break;
- case INTRINS_AARCH64_ADV_SIMD_ABS_FLOAT:
- intrins = add_intrins1 (module, id, sse_r4_t);
- break;
- case INTRINS_AARCH64_ADV_SIMD_ABS_DOUBLE:
- intrins = add_intrins1 (module, id, sse_r8_t);
- break;
- case INTRINS_AARCH64_ADV_SIMD_ABS_INT8:
- intrins = add_intrins1 (module, id, sse_i1_t);
- break;
- case INTRINS_AARCH64_ADV_SIMD_ABS_INT16:
- intrins = add_intrins1 (module, id, sse_i2_t);
- break;
- case INTRINS_AARCH64_ADV_SIMD_ABS_INT32:
- intrins = add_intrins1 (module, id, sse_i4_t);
- break;
- case INTRINS_AARCH64_ADV_SIMD_ABS_INT64:
- intrins = add_intrins1 (module, id, sse_i8_t);
- break;
-#endif
+ #define INTRINS(intrin_name, llvm_id)
+ #define INTRINS_OVR(intrin_name, llvm_id, llvm_type) case INTRINS_ ## intrin_name: intrins = add_intrins1(module, id, llvm_type); break;
+ #define INTRINS_OVR_2_ARG(intrin_name, llvm_id, llvm_type1, llvm_type2) case INTRINS_ ## intrin_name: intrins = add_intrins2(module, id, llvm_type1, llvm_type2); break;
+ #define INTRINS_OVR_3_ARG(intrin_name, llvm_id, llvm_type1, llvm_type2, llvm_type3) case INTRINS_ ## intrin_name: intrins = add_intrins3(module, id, llvm_type1, llvm_type2, llvm_type3); break;
+ #include "llvm-intrinsics.h"
+
default:
g_assert_not_reached ();
break;