Skip to content

Commit 9b6229c

Browse files
committed
Hexagon: Move RuntimeLibcall setting out of TargetLowering
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.
1 parent de3a9ea commit 9b6229c

File tree

2 files changed

+43
-43
lines changed

2 files changed

+43
-43
lines changed

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "llvm/IR/RuntimeLibcalls.h"
10+
#include "llvm/Support/CommandLine.h"
1011

1112
using namespace llvm;
1213
using namespace RTLIB;
1314

15+
static cl::opt<bool>
16+
HexagonEnableFastMathRuntimeCalls("hexagon-fast-math", cl::Hidden,
17+
cl::desc("Enable Fast Math processing"));
18+
1419
/// Set default libcall names. If a target wants to opt-out of a libcall it
1520
/// should be placed here.
1621
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
@@ -309,4 +314,42 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
309314
for (auto &E : RTLibCallCommon)
310315
setLibcallName(E.Code, E.Name);
311316
}
317+
318+
if (TT.getArch() == Triple::ArchType::hexagon) {
319+
setLibcallName(RTLIB::SDIV_I32, "__hexagon_divsi3");
320+
setLibcallName(RTLIB::SDIV_I64, "__hexagon_divdi3");
321+
setLibcallName(RTLIB::UDIV_I32, "__hexagon_udivsi3");
322+
setLibcallName(RTLIB::UDIV_I64, "__hexagon_udivdi3");
323+
setLibcallName(RTLIB::SREM_I32, "__hexagon_modsi3");
324+
setLibcallName(RTLIB::SREM_I64, "__hexagon_moddi3");
325+
setLibcallName(RTLIB::UREM_I32, "__hexagon_umodsi3");
326+
setLibcallName(RTLIB::UREM_I64, "__hexagon_umoddi3");
327+
328+
const bool FastMath = HexagonEnableFastMathRuntimeCalls;
329+
// This is the only fast library function for sqrtd.
330+
if (FastMath)
331+
setLibcallName(RTLIB::SQRT_F64, "__hexagon_fast2_sqrtdf2");
332+
333+
// Prefix is: nothing for "slow-math",
334+
// "fast2_" for V5+ fast-math double-precision
335+
// (actually, keep fast-math and fast-math2 separate for now)
336+
if (FastMath) {
337+
setLibcallName(RTLIB::ADD_F64, "__hexagon_fast_adddf3");
338+
setLibcallName(RTLIB::SUB_F64, "__hexagon_fast_subdf3");
339+
setLibcallName(RTLIB::MUL_F64, "__hexagon_fast_muldf3");
340+
setLibcallName(RTLIB::DIV_F64, "__hexagon_fast_divdf3");
341+
setLibcallName(RTLIB::DIV_F32, "__hexagon_fast_divsf3");
342+
} else {
343+
setLibcallName(RTLIB::ADD_F64, "__hexagon_adddf3");
344+
setLibcallName(RTLIB::SUB_F64, "__hexagon_subdf3");
345+
setLibcallName(RTLIB::MUL_F64, "__hexagon_muldf3");
346+
setLibcallName(RTLIB::DIV_F64, "__hexagon_divdf3");
347+
setLibcallName(RTLIB::DIV_F32, "__hexagon_divsf3");
348+
}
349+
350+
if (FastMath)
351+
setLibcallName(RTLIB::SQRT_F32, "__hexagon_fast2_sqrtf");
352+
else
353+
setLibcallName(RTLIB::SQRT_F32, "__hexagon_sqrtf");
354+
}
312355
}

llvm/lib/Target/Hexagon/HexagonISelLowering.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ static cl::opt<bool>
7373
EnableHexSDNodeSched("enable-hexagon-sdnode-sched", cl::Hidden,
7474
cl::desc("Enable Hexagon SDNode scheduling"));
7575

76-
static cl::opt<bool> EnableFastMath("ffast-math", cl::Hidden,
77-
cl::desc("Enable Fast Math processing"));
78-
7976
static cl::opt<int> MinimumJumpTables("minimum-jump-tables", cl::Hidden,
8077
cl::init(5),
8178
cl::desc("Set minimum jump tables"));
@@ -1850,46 +1847,6 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
18501847
initializeHVXLowering();
18511848

18521849
computeRegisterProperties(&HRI);
1853-
1854-
//
1855-
// Library calls for unsupported operations
1856-
//
1857-
bool FastMath = EnableFastMath;
1858-
1859-
setLibcallName(RTLIB::SDIV_I32, "__hexagon_divsi3");
1860-
setLibcallName(RTLIB::SDIV_I64, "__hexagon_divdi3");
1861-
setLibcallName(RTLIB::UDIV_I32, "__hexagon_udivsi3");
1862-
setLibcallName(RTLIB::UDIV_I64, "__hexagon_udivdi3");
1863-
setLibcallName(RTLIB::SREM_I32, "__hexagon_modsi3");
1864-
setLibcallName(RTLIB::SREM_I64, "__hexagon_moddi3");
1865-
setLibcallName(RTLIB::UREM_I32, "__hexagon_umodsi3");
1866-
setLibcallName(RTLIB::UREM_I64, "__hexagon_umoddi3");
1867-
1868-
// This is the only fast library function for sqrtd.
1869-
if (FastMath)
1870-
setLibcallName(RTLIB::SQRT_F64, "__hexagon_fast2_sqrtdf2");
1871-
1872-
// Prefix is: nothing for "slow-math",
1873-
// "fast2_" for V5+ fast-math double-precision
1874-
// (actually, keep fast-math and fast-math2 separate for now)
1875-
if (FastMath) {
1876-
setLibcallName(RTLIB::ADD_F64, "__hexagon_fast_adddf3");
1877-
setLibcallName(RTLIB::SUB_F64, "__hexagon_fast_subdf3");
1878-
setLibcallName(RTLIB::MUL_F64, "__hexagon_fast_muldf3");
1879-
setLibcallName(RTLIB::DIV_F64, "__hexagon_fast_divdf3");
1880-
setLibcallName(RTLIB::DIV_F32, "__hexagon_fast_divsf3");
1881-
} else {
1882-
setLibcallName(RTLIB::ADD_F64, "__hexagon_adddf3");
1883-
setLibcallName(RTLIB::SUB_F64, "__hexagon_subdf3");
1884-
setLibcallName(RTLIB::MUL_F64, "__hexagon_muldf3");
1885-
setLibcallName(RTLIB::DIV_F64, "__hexagon_divdf3");
1886-
setLibcallName(RTLIB::DIV_F32, "__hexagon_divsf3");
1887-
}
1888-
1889-
if (FastMath)
1890-
setLibcallName(RTLIB::SQRT_F32, "__hexagon_fast2_sqrtf");
1891-
else
1892-
setLibcallName(RTLIB::SQRT_F32, "__hexagon_sqrtf");
18931850
}
18941851

18951852
const char* HexagonTargetLowering::getTargetNodeName(unsigned Opcode) const {

0 commit comments

Comments
 (0)