-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Hexagon: Move RuntimeLibcall setting out of TargetLowering #142543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hexagon: Move RuntimeLibcall setting out of TargetLowering #142543
Conversation
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-backend-hexagon Author: Matt Arsenault (arsenm) ChangesRuntimeLibcalls needs to be correct in non-codegen contexts, so Full diff: https://github.com/llvm/llvm-project/pull/142543.diff 2 Files Affected:
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 90c3bf0db0236..d1ed111d0ba8f 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -7,10 +7,15 @@
//===----------------------------------------------------------------------===//
#include "llvm/IR/RuntimeLibcalls.h"
+#include "llvm/Support/CommandLine.h"
using namespace llvm;
using namespace RTLIB;
+static cl::opt<bool>
+ HexagonEnableFastMathRuntimeCalls("hexagon-fast-math", cl::Hidden,
+ cl::desc("Enable Fast Math processing"));
+
/// Set default libcall names. If a target wants to opt-out of a libcall it
/// should be placed here.
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
@@ -253,4 +258,42 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
}
setLibcallName(RTLIB::MULO_I128, nullptr);
}
+
+ if (TT.getArch() == Triple::ArchType::hexagon) {
+ setLibcallName(RTLIB::SDIV_I32, "__hexagon_divsi3");
+ setLibcallName(RTLIB::SDIV_I64, "__hexagon_divdi3");
+ setLibcallName(RTLIB::UDIV_I32, "__hexagon_udivsi3");
+ setLibcallName(RTLIB::UDIV_I64, "__hexagon_udivdi3");
+ setLibcallName(RTLIB::SREM_I32, "__hexagon_modsi3");
+ setLibcallName(RTLIB::SREM_I64, "__hexagon_moddi3");
+ setLibcallName(RTLIB::UREM_I32, "__hexagon_umodsi3");
+ setLibcallName(RTLIB::UREM_I64, "__hexagon_umoddi3");
+
+ const bool FastMath = HexagonEnableFastMathRuntimeCalls;
+ // This is the only fast library function for sqrtd.
+ if (FastMath)
+ setLibcallName(RTLIB::SQRT_F64, "__hexagon_fast2_sqrtdf2");
+
+ // Prefix is: nothing for "slow-math",
+ // "fast2_" for V5+ fast-math double-precision
+ // (actually, keep fast-math and fast-math2 separate for now)
+ if (FastMath) {
+ setLibcallName(RTLIB::ADD_F64, "__hexagon_fast_adddf3");
+ setLibcallName(RTLIB::SUB_F64, "__hexagon_fast_subdf3");
+ setLibcallName(RTLIB::MUL_F64, "__hexagon_fast_muldf3");
+ setLibcallName(RTLIB::DIV_F64, "__hexagon_fast_divdf3");
+ setLibcallName(RTLIB::DIV_F32, "__hexagon_fast_divsf3");
+ } else {
+ setLibcallName(RTLIB::ADD_F64, "__hexagon_adddf3");
+ setLibcallName(RTLIB::SUB_F64, "__hexagon_subdf3");
+ setLibcallName(RTLIB::MUL_F64, "__hexagon_muldf3");
+ setLibcallName(RTLIB::DIV_F64, "__hexagon_divdf3");
+ setLibcallName(RTLIB::DIV_F32, "__hexagon_divsf3");
+ }
+
+ if (FastMath)
+ setLibcallName(RTLIB::SQRT_F32, "__hexagon_fast2_sqrtf");
+ else
+ setLibcallName(RTLIB::SQRT_F32, "__hexagon_sqrtf");
+ }
}
diff --git a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
index 01efcedebc808..078eccaa706a2 100644
--- a/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
@@ -73,9 +73,6 @@ static cl::opt<bool>
EnableHexSDNodeSched("enable-hexagon-sdnode-sched", cl::Hidden,
cl::desc("Enable Hexagon SDNode scheduling"));
-static cl::opt<bool> EnableFastMath("ffast-math", cl::Hidden,
- cl::desc("Enable Fast Math processing"));
-
static cl::opt<int> MinimumJumpTables("minimum-jump-tables", cl::Hidden,
cl::init(5),
cl::desc("Set minimum jump tables"));
@@ -1850,46 +1847,6 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
initializeHVXLowering();
computeRegisterProperties(&HRI);
-
- //
- // Library calls for unsupported operations
- //
- bool FastMath = EnableFastMath;
-
- setLibcallName(RTLIB::SDIV_I32, "__hexagon_divsi3");
- setLibcallName(RTLIB::SDIV_I64, "__hexagon_divdi3");
- setLibcallName(RTLIB::UDIV_I32, "__hexagon_udivsi3");
- setLibcallName(RTLIB::UDIV_I64, "__hexagon_udivdi3");
- setLibcallName(RTLIB::SREM_I32, "__hexagon_modsi3");
- setLibcallName(RTLIB::SREM_I64, "__hexagon_moddi3");
- setLibcallName(RTLIB::UREM_I32, "__hexagon_umodsi3");
- setLibcallName(RTLIB::UREM_I64, "__hexagon_umoddi3");
-
- // This is the only fast library function for sqrtd.
- if (FastMath)
- setLibcallName(RTLIB::SQRT_F64, "__hexagon_fast2_sqrtdf2");
-
- // Prefix is: nothing for "slow-math",
- // "fast2_" for V5+ fast-math double-precision
- // (actually, keep fast-math and fast-math2 separate for now)
- if (FastMath) {
- setLibcallName(RTLIB::ADD_F64, "__hexagon_fast_adddf3");
- setLibcallName(RTLIB::SUB_F64, "__hexagon_fast_subdf3");
- setLibcallName(RTLIB::MUL_F64, "__hexagon_fast_muldf3");
- setLibcallName(RTLIB::DIV_F64, "__hexagon_fast_divdf3");
- setLibcallName(RTLIB::DIV_F32, "__hexagon_fast_divsf3");
- } else {
- setLibcallName(RTLIB::ADD_F64, "__hexagon_adddf3");
- setLibcallName(RTLIB::SUB_F64, "__hexagon_subdf3");
- setLibcallName(RTLIB::MUL_F64, "__hexagon_muldf3");
- setLibcallName(RTLIB::DIV_F64, "__hexagon_divdf3");
- setLibcallName(RTLIB::DIV_F32, "__hexagon_divsf3");
- }
-
- if (FastMath)
- setLibcallName(RTLIB::SQRT_F32, "__hexagon_fast2_sqrtf");
- else
- setLibcallName(RTLIB::SQRT_F32, "__hexagon_sqrtf");
}
const char* HexagonTargetLowering::getTargetNodeName(unsigned Opcode) const {
|
RuntimeLibcalls needs to be correct in non-codegen contexts, so should not be configured in TargetLowering. Hexagon has this exotic, overly general sounding fast math flag which appear to be untested. I've renamed and moved it but this should probably be deleted and move to a combine based on fast math flags.
9a86895
to
9b6229c
Compare
|
||
using namespace llvm; | ||
using namespace RTLIB; | ||
|
||
static cl::opt<bool> | ||
HexagonEnableFastMathRuntimeCalls("hexagon-fast-math", cl::Hidden, | ||
cl::desc("Enable Fast Math processing")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this PR change the command line used for this option?
If so, I suppose it should get a mention in the release notes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not even tested nor documented so probably not worth it. Probably should just delete it altogether
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@aankit-ca can you discuss with the compiler team whether this feature is required or if maybe it's a feature that was incompletely upstreamed?
If it's the latter we can follow through with tests and documentation. If it's not used then we can delete it.
In either case I don't think it makes sense to hold up this PR though.
RuntimeLibcalls needs to be correct in non-codegen contexts, so
should not be configured in TargetLowering. Hexagon has this exotic,
overly general sounding fast math flag which appear to be untested. I've
renamed and moved it but this should probably be deleted and move to a
combine based on fast math flags.