[llvm] Prepend all library intrinsics with `#` when building for Arm64EC (PR #87542)
Daniel Paoliello via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 4 12:48:53 PDT 2024
https://github.com/dpaoliello updated https://github.com/llvm/llvm-project/pull/87542
>From 972c264d6a9b2733563b0329f0dd99be53642847 Mon Sep 17 00:00:00 2001
From: Daniel Paoliello <danpao at microsoft.com>
Date: Wed, 3 Apr 2024 12:04:25 -0700
Subject: [PATCH] Prepend all intrinsics with # when building for Arm64EC
---
.../Target/AArch64/AArch64ISelLowering.cpp | 42 ++++---------------
llvm/lib/Target/AArch64/AArch64ISelLowering.h | 3 ++
2 files changed, 11 insertions(+), 34 deletions(-)
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 8218960406ec13..ad50deb8eac0bf 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1716,40 +1716,14 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
setMaxAtomicSizeInBitsSupported(128);
if (Subtarget->isWindowsArm64EC()) {
- // FIXME: are there other intrinsics we need to add here?
- setLibcallName(RTLIB::MEMCPY, "#memcpy");
- setLibcallName(RTLIB::MEMSET, "#memset");
- setLibcallName(RTLIB::MEMMOVE, "#memmove");
- setLibcallName(RTLIB::REM_F32, "#fmodf");
- setLibcallName(RTLIB::REM_F64, "#fmod");
- setLibcallName(RTLIB::FMA_F32, "#fmaf");
- setLibcallName(RTLIB::FMA_F64, "#fma");
- setLibcallName(RTLIB::SQRT_F32, "#sqrtf");
- setLibcallName(RTLIB::SQRT_F64, "#sqrt");
- setLibcallName(RTLIB::CBRT_F32, "#cbrtf");
- setLibcallName(RTLIB::CBRT_F64, "#cbrt");
- setLibcallName(RTLIB::LOG_F32, "#logf");
- setLibcallName(RTLIB::LOG_F64, "#log");
- setLibcallName(RTLIB::LOG2_F32, "#log2f");
- setLibcallName(RTLIB::LOG2_F64, "#log2");
- setLibcallName(RTLIB::LOG10_F32, "#log10f");
- setLibcallName(RTLIB::LOG10_F64, "#log10");
- setLibcallName(RTLIB::EXP_F32, "#expf");
- setLibcallName(RTLIB::EXP_F64, "#exp");
- setLibcallName(RTLIB::EXP2_F32, "#exp2f");
- setLibcallName(RTLIB::EXP2_F64, "#exp2");
- setLibcallName(RTLIB::EXP10_F32, "#exp10f");
- setLibcallName(RTLIB::EXP10_F64, "#exp10");
- setLibcallName(RTLIB::SIN_F32, "#sinf");
- setLibcallName(RTLIB::SIN_F64, "#sin");
- setLibcallName(RTLIB::COS_F32, "#cosf");
- setLibcallName(RTLIB::COS_F64, "#cos");
- setLibcallName(RTLIB::POW_F32, "#powf");
- setLibcallName(RTLIB::POW_F64, "#pow");
- setLibcallName(RTLIB::LDEXP_F32, "#ldexpf");
- setLibcallName(RTLIB::LDEXP_F64, "#ldexp");
- setLibcallName(RTLIB::FREXP_F32, "#frexpf");
- setLibcallName(RTLIB::FREXP_F64, "#frexp");
+ // FIXME: are there intrinsics we need to exclude from this?
+ for (int i = 0; i < RTLIB::UNKNOWN_LIBCALL; ++i) {
+ auto code = static_cast<RTLIB::Libcall>(i);
+ auto libcallName = getLibcallName(code);
+ if ((libcallName != nullptr) && (libcallName[0] != '#')) {
+ setLibcallName(code, Saver.save(Twine("#") + libcallName).data());
+ }
+ }
}
}
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.h b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
index 3465f3be887543..18439dc7f01020 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.h
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.h
@@ -1003,6 +1003,9 @@ class AArch64TargetLowering : public TargetLowering {
/// make the right decision when generating code for different targets.
const AArch64Subtarget *Subtarget;
+ llvm::BumpPtrAllocator BumpAlloc;
+ llvm::StringSaver Saver{BumpAlloc};
+
bool isExtFreeImpl(const Instruction *Ext) const override;
void addTypeForNEON(MVT VT);
More information about the llvm-commits
mailing list