[hexagon] Remove setHexLibcallName, it leaks memory.

Just spell out the full names, it's not that much more code.
No functional change intended.

llvm-svn: 235801
This commit is contained in:
Benjamin Kramer 2015-04-25 14:46:46 +00:00
parent aedd3c5160
commit a37c809ce5
2 changed files with 82 additions and 78 deletions

View File

@ -1262,15 +1262,6 @@ HexagonTargetLowering::LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const {
// TargetLowering Implementation // TargetLowering Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void HexagonTargetLowering::setHexLibcallName(RTLIB::Libcall Call, Twine Name) {
std::string EmulationPrefix = "__hexagon_";
std::string N = EmulationPrefix + Name.str();
unsigned S = N.size()+1;
char *p = new char[S];
memcpy(p, N.c_str(), S);
setLibcallName(Call, p);
}
HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM, HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
const HexagonSubtarget &STI) const HexagonSubtarget &STI)
: TargetLowering(TM), HTM(static_cast<const HexagonTargetMachine&>(TM)), : TargetLowering(TM), HTM(static_cast<const HexagonTargetMachine&>(TM)),
@ -1630,88 +1621,104 @@ HexagonTargetLowering::HexagonTargetLowering(const TargetMachine &TM,
// //
bool FastMath = EnableFastMath; bool FastMath = EnableFastMath;
setHexLibcallName(RTLIB::SDIV_I32, "divsi3"); setLibcallName(RTLIB::SDIV_I32, "__hexagon_divsi3");
setHexLibcallName(RTLIB::SDIV_I64, "divdi3"); setLibcallName(RTLIB::SDIV_I64, "__hexagon_divdi3");
setHexLibcallName(RTLIB::UDIV_I32, "udivsi3"); setLibcallName(RTLIB::UDIV_I32, "__hexagon_udivsi3");
setHexLibcallName(RTLIB::UDIV_I64, "udivdi3"); setLibcallName(RTLIB::UDIV_I64, "__hexagon_udivdi3");
setHexLibcallName(RTLIB::SREM_I32, "modsi3"); setLibcallName(RTLIB::SREM_I32, "__hexagon_modsi3");
setHexLibcallName(RTLIB::SREM_I64, "moddi3"); setLibcallName(RTLIB::SREM_I64, "__hexagon_moddi3");
setHexLibcallName(RTLIB::UREM_I32, "umodsi3"); setLibcallName(RTLIB::UREM_I32, "__hexagon_umodsi3");
setHexLibcallName(RTLIB::UREM_I64, "umoddi3"); setLibcallName(RTLIB::UREM_I64, "__hexagon_umoddi3");
setHexLibcallName(RTLIB::SINTTOFP_I128_F64, "floattidf"); setLibcallName(RTLIB::SINTTOFP_I128_F64, "__hexagon_floattidf");
setHexLibcallName(RTLIB::SINTTOFP_I128_F32, "floattisf"); setLibcallName(RTLIB::SINTTOFP_I128_F32, "__hexagon_floattisf");
setHexLibcallName(RTLIB::FPTOUINT_F32_I128, "fixunssfti"); setLibcallName(RTLIB::FPTOUINT_F32_I128, "__hexagon_fixunssfti");
setHexLibcallName(RTLIB::FPTOUINT_F64_I128, "fixunsdfti"); setLibcallName(RTLIB::FPTOUINT_F64_I128, "__hexagon_fixunsdfti");
setHexLibcallName(RTLIB::FPTOSINT_F32_I128, "fixsfti"); setLibcallName(RTLIB::FPTOSINT_F32_I128, "__hexagon_fixsfti");
setHexLibcallName(RTLIB::FPTOSINT_F64_I128, "fixdfti"); setLibcallName(RTLIB::FPTOSINT_F64_I128, "__hexagon_fixdfti");
if (IsV4) { if (IsV4) {
// Handle single-precision floating point operations on V4. // Handle single-precision floating point operations on V4.
Twine Pref = (FastMath ? "fast_" : ""); if (FastMath) {
setHexLibcallName(RTLIB::ADD_F32, Pref+"addsf3"); setLibcallName(RTLIB::ADD_F32, "__hexagon_fast_addsf3");
setHexLibcallName(RTLIB::SUB_F32, Pref+"subsf3"); setLibcallName(RTLIB::SUB_F32, "__hexagon_fast_subsf3");
setHexLibcallName(RTLIB::MUL_F32, Pref+"mulsf3"); setLibcallName(RTLIB::MUL_F32, "__hexagon_fast_mulsf3");
setHexLibcallName(RTLIB::OGT_F32, Pref+"gtsf2"); setLibcallName(RTLIB::OGT_F32, "__hexagon_fast_gtsf2");
setHexLibcallName(RTLIB::OLT_F32, Pref+"ltsf2"); setLibcallName(RTLIB::OLT_F32, "__hexagon_fast_ltsf2");
// Double-precision compares. // Double-precision compares.
setHexLibcallName(RTLIB::OGT_F64, Pref+"gtdf2"); setLibcallName(RTLIB::OGT_F64, "__hexagon_fast_gtdf2");
setHexLibcallName(RTLIB::OLT_F64, Pref+"ltdf2"); setLibcallName(RTLIB::OLT_F64, "__hexagon_fast_ltdf2");
} else {
setLibcallName(RTLIB::ADD_F32, "__hexagon_addsf3");
setLibcallName(RTLIB::SUB_F32, "__hexagon_subsf3");
setLibcallName(RTLIB::MUL_F32, "__hexagon_mulsf3");
setLibcallName(RTLIB::OGT_F32, "__hexagon_gtsf2");
setLibcallName(RTLIB::OLT_F32, "__hexagon_ltsf2");
// Double-precision compares.
setLibcallName(RTLIB::OGT_F64, "__hexagon_gtdf2");
setLibcallName(RTLIB::OLT_F64, "__hexagon_ltdf2");
}
} }
// This is the only fast library function for sqrtd. // This is the only fast library function for sqrtd.
if (FastMath) if (FastMath)
setHexLibcallName(RTLIB::SQRT_F64, "fast2_sqrtdf2"); setLibcallName(RTLIB::SQRT_F64, "__hexagon_fast2_sqrtdf2");
// PrefFP = nothing for "slow-math", // Prefix is: nothing for "slow-math",
// = "fast2_" for V4 fast-math and V5+ fast-math double-precision // "fast2_" for V4 fast-math and V5+ fast-math double-precision
// (actually, keep fast-math and fast-math2 separate for now) // (actually, keep fast-math and fast-math2 separate for now)
Twine PrefFP = (FastMath ? "fast_" : ""); if (FastMath) {
setLibcallName(RTLIB::ADD_F64, "__hexagon_fast_adddf3");
setHexLibcallName(RTLIB::ADD_F64, PrefFP+"adddf3"); setLibcallName(RTLIB::SUB_F64, "__hexagon_fast_subdf3");
setHexLibcallName(RTLIB::SUB_F64, PrefFP+"subdf3"); setLibcallName(RTLIB::MUL_F64, "__hexagon_fast_muldf3");
setHexLibcallName(RTLIB::MUL_F64, PrefFP+"muldf3"); setLibcallName(RTLIB::DIV_F64, "__hexagon_fast_divdf3");
setHexLibcallName(RTLIB::DIV_F64, PrefFP+"divdf3"); // Calling __hexagon_fast2_divsf3 with fast-math on V5 (ok).
// Calling __hexagon_fast2_divsf3 with fast-math on V5 (ok). setLibcallName(RTLIB::DIV_F32, "__hexagon_fast_divsf3");
setHexLibcallName(RTLIB::DIV_F32, PrefFP+"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 (Subtarget.hasV5TOps()) { if (Subtarget.hasV5TOps()) {
if (FastMath) if (FastMath)
setHexLibcallName(RTLIB::SQRT_F32, "fast2_sqrtf"); setLibcallName(RTLIB::SQRT_F32, "__hexagon_fast2_sqrtf");
else else
setHexLibcallName(RTLIB::SQRT_F32, "sqrtf"); setLibcallName(RTLIB::SQRT_F32, "__hexagon_sqrtf");
} else { } else {
// V4 // V4
setHexLibcallName(RTLIB::SINTTOFP_I32_F32, "floatsisf"); setLibcallName(RTLIB::SINTTOFP_I32_F32, "__hexagon_floatsisf");
setHexLibcallName(RTLIB::SINTTOFP_I32_F64, "floatsidf"); setLibcallName(RTLIB::SINTTOFP_I32_F64, "__hexagon_floatsidf");
setHexLibcallName(RTLIB::SINTTOFP_I64_F32, "floatdisf"); setLibcallName(RTLIB::SINTTOFP_I64_F32, "__hexagon_floatdisf");
setHexLibcallName(RTLIB::SINTTOFP_I64_F64, "floatdidf"); setLibcallName(RTLIB::SINTTOFP_I64_F64, "__hexagon_floatdidf");
setHexLibcallName(RTLIB::UINTTOFP_I32_F32, "floatunsisf"); setLibcallName(RTLIB::UINTTOFP_I32_F32, "__hexagon_floatunsisf");
setHexLibcallName(RTLIB::UINTTOFP_I32_F64, "floatunsidf"); setLibcallName(RTLIB::UINTTOFP_I32_F64, "__hexagon_floatunsidf");
setHexLibcallName(RTLIB::UINTTOFP_I64_F32, "floatundisf"); setLibcallName(RTLIB::UINTTOFP_I64_F32, "__hexagon_floatundisf");
setHexLibcallName(RTLIB::UINTTOFP_I64_F64, "floatundidf"); setLibcallName(RTLIB::UINTTOFP_I64_F64, "__hexagon_floatundidf");
setHexLibcallName(RTLIB::FPTOUINT_F32_I32, "fixunssfsi"); setLibcallName(RTLIB::FPTOUINT_F32_I32, "__hexagon_fixunssfsi");
setHexLibcallName(RTLIB::FPTOUINT_F32_I64, "fixunssfdi"); setLibcallName(RTLIB::FPTOUINT_F32_I64, "__hexagon_fixunssfdi");
setHexLibcallName(RTLIB::FPTOUINT_F64_I32, "fixunsdfsi"); setLibcallName(RTLIB::FPTOUINT_F64_I32, "__hexagon_fixunsdfsi");
setHexLibcallName(RTLIB::FPTOUINT_F64_I64, "fixunsdfdi"); setLibcallName(RTLIB::FPTOUINT_F64_I64, "__hexagon_fixunsdfdi");
setHexLibcallName(RTLIB::FPTOSINT_F32_I32, "fixsfsi"); setLibcallName(RTLIB::FPTOSINT_F32_I32, "__hexagon_fixsfsi");
setHexLibcallName(RTLIB::FPTOSINT_F32_I64, "fixsfdi"); setLibcallName(RTLIB::FPTOSINT_F32_I64, "__hexagon_fixsfdi");
setHexLibcallName(RTLIB::FPTOSINT_F64_I32, "fixdfsi"); setLibcallName(RTLIB::FPTOSINT_F64_I32, "__hexagon_fixdfsi");
setHexLibcallName(RTLIB::FPTOSINT_F64_I64, "fixdfdi"); setLibcallName(RTLIB::FPTOSINT_F64_I64, "__hexagon_fixdfdi");
setHexLibcallName(RTLIB::FPEXT_F32_F64, "extendsfdf2"); setLibcallName(RTLIB::FPEXT_F32_F64, "__hexagon_extendsfdf2");
setHexLibcallName(RTLIB::FPROUND_F64_F32, "truncdfsf2"); setLibcallName(RTLIB::FPROUND_F64_F32, "__hexagon_truncdfsf2");
setHexLibcallName(RTLIB::OEQ_F32, "eqsf2"); setLibcallName(RTLIB::OEQ_F32, "__hexagon_eqsf2");
setHexLibcallName(RTLIB::OEQ_F64, "eqdf2"); setLibcallName(RTLIB::OEQ_F64, "__hexagon_eqdf2");
setHexLibcallName(RTLIB::OGE_F32, "gesf2"); setLibcallName(RTLIB::OGE_F32, "__hexagon_gesf2");
setHexLibcallName(RTLIB::OGE_F64, "gedf2"); setLibcallName(RTLIB::OGE_F64, "__hexagon_gedf2");
setHexLibcallName(RTLIB::OLE_F32, "lesf2"); setLibcallName(RTLIB::OLE_F32, "__hexagon_lesf2");
setHexLibcallName(RTLIB::OLE_F64, "ledf2"); setLibcallName(RTLIB::OLE_F64, "__hexagon_ledf2");
setHexLibcallName(RTLIB::UNE_F32, "nesf2"); setLibcallName(RTLIB::UNE_F32, "__hexagon_nesf2");
setHexLibcallName(RTLIB::UNE_F64, "nedf2"); setLibcallName(RTLIB::UNE_F64, "__hexagon_nedf2");
setHexLibcallName(RTLIB::UO_F32, "unordsf2"); setLibcallName(RTLIB::UO_F32, "__hexagon_unordsf2");
setHexLibcallName(RTLIB::UO_F64, "unorddf2"); setLibcallName(RTLIB::UO_F64, "__hexagon_unorddf2");
setHexLibcallName(RTLIB::O_F32, "unordsf2"); setLibcallName(RTLIB::O_F32, "__hexagon_unordsf2");
setHexLibcallName(RTLIB::O_F64, "unorddf2"); setLibcallName(RTLIB::O_F64, "__hexagon_unorddf2");
} }
// These cause problems when the shift amount is non-constant. // These cause problems when the shift amount is non-constant.

View File

@ -206,9 +206,6 @@ bool isPositiveHalfWord(SDNode *N);
/// compare a register against the immediate without having to materialize /// compare a register against the immediate without having to materialize
/// the immediate into a register. /// the immediate into a register.
bool isLegalICmpImmediate(int64_t Imm) const override; bool isLegalICmpImmediate(int64_t Imm) const override;
private:
void setHexLibcallName(RTLIB::Libcall Call, Twine Name);
}; };
} // end namespace llvm } // end namespace llvm