Skip to content

Commit a3aaa1a

Browse files
authored
DAG: Use RuntimeLibcalls to legalize vector frem calls (#170719)
This continues the replacement of TargetLibraryInfo uses in codegen with RuntimeLibcallsInfo started in 821d282. The series there handled all of the multiple result calls. This extends for the other handled case, which happened to be frem. For some reason the Libcall for these are prefixed with "REM_", for the instruction "frem", which maps to the libcall "fmod".
1 parent 7c328d8 commit a3aaa1a

File tree

7 files changed

+166
-120
lines changed

7 files changed

+166
-120
lines changed

llvm/include/llvm/CodeGen/RuntimeLibcallUtil.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ LLVM_ABI Libcall getSINCOS_STRET(EVT RetVT);
132132
/// UNKNOWN_LIBCALL if there is none.
133133
LLVM_ABI Libcall getMODF(EVT VT);
134134

135+
/// \return the REM_* value for the given types, or UNKNOWN_LIBCALL if there is
136+
/// none.
137+
LLVM_ABI Libcall getREM(EVT VT);
138+
135139
/// \return the LROUND_* value for the given types, or UNKNOWN_LIBCALL if there
136140
/// is none.
137141
LLVM_ABI Libcall getLROUND(EVT VT);

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ foreach S = !listconcat(F32VectorSuffixes, F64VectorSuffixes) in {
227227
def FMA_#S : RuntimeLibcall;
228228
def FMAX_#S : RuntimeLibcall;
229229
def FMIN_#S : RuntimeLibcall;
230-
def FMOD_#S : RuntimeLibcall;
230+
def REM_#S : RuntimeLibcall; // "fmod"
231231
def HYPOT_#S : RuntimeLibcall;
232232
def ILOGB_#S : RuntimeLibcall;
233233
def LDEXP_#S : RuntimeLibcall;
@@ -3919,7 +3919,7 @@ defset list<RuntimeLibcallImpl> SLEEFGNUABI_VF2_VECFUNCS = {
39193919
def _ZGVnN2vv_fdim : RuntimeLibcallImpl<FDIM_V2F64>;
39203920
def _ZGVnN2vv_fmax : RuntimeLibcallImpl<FMAX_V2F64>;
39213921
def _ZGVnN2vv_fmin : RuntimeLibcallImpl<FMIN_V2F64>;
3922-
def _ZGVnN2vv_fmod : RuntimeLibcallImpl<FMOD_V2F64>;
3922+
def _ZGVnN2vv_fmod : RuntimeLibcallImpl<REM_V2F64>;
39233923
def _ZGVnN2vv_hypot : RuntimeLibcallImpl<HYPOT_V2F64>;
39243924
def _ZGVnN2vv_ldexp : RuntimeLibcallImpl<LDEXP_V2F64>;
39253925
def _ZGVnN2vv_nextafter : RuntimeLibcallImpl<NEXTAFTER_V2F64>;
@@ -3965,7 +3965,7 @@ defset list<RuntimeLibcallImpl> SLEEFGNUABI_VF4_VECFUNCS = {
39653965
def _ZGVnN4vv_fdimf : RuntimeLibcallImpl<FDIM_V4F32>;
39663966
def _ZGVnN4vv_fmaxf : RuntimeLibcallImpl<FMAX_V4F32>;
39673967
def _ZGVnN4vv_fminf : RuntimeLibcallImpl<FMIN_V4F32>;
3968-
def _ZGVnN4vv_fmodf : RuntimeLibcallImpl<FMOD_V4F32>;
3968+
def _ZGVnN4vv_fmodf : RuntimeLibcallImpl<REM_V4F32>;
39693969
def _ZGVnN4vv_hypotf : RuntimeLibcallImpl<HYPOT_V4F32>;
39703970
def _ZGVnN4vv_ldexpf : RuntimeLibcallImpl<LDEXP_V4F32>;
39713971
def _ZGVnN4vv_nextafterf : RuntimeLibcallImpl<NEXTAFTER_V4F32>;
@@ -4042,8 +4042,8 @@ defset list<RuntimeLibcallImpl> SLEEFGNUABI_SCALABLE_VECFUNCS = {
40424042
def _ZGVsMxvv_fmaxf : RuntimeLibcallImpl<FMAX_NXV4F32>;
40434043
def _ZGVsMxvv_fmin : RuntimeLibcallImpl<FMIN_NXV2F64>;
40444044
def _ZGVsMxvv_fminf : RuntimeLibcallImpl<FMIN_NXV4F32>;
4045-
def _ZGVsMxvv_fmod : RuntimeLibcallImpl<FMOD_NXV2F64>;
4046-
def _ZGVsMxvv_fmodf : RuntimeLibcallImpl<FMOD_NXV4F32>;
4045+
def _ZGVsMxvv_fmod : RuntimeLibcallImpl<REM_NXV2F64>;
4046+
def _ZGVsMxvv_fmodf : RuntimeLibcallImpl<REM_NXV4F32>;
40474047
def _ZGVsMxvv_hypot : RuntimeLibcallImpl<HYPOT_NXV2F64>;
40484048
def _ZGVsMxvv_hypotf : RuntimeLibcallImpl<HYPOT_NXV4F32>;
40494049
def _ZGVsMxvv_ldexp : RuntimeLibcallImpl<LDEXP_NXV2F64>;
@@ -4107,8 +4107,8 @@ defset list<RuntimeLibcallImpl> SLEEFGNUABI_SCALABLE_VECFUNCS_RISCV = {
41074107
def Sleef_fmaxfx_rvvm2 : RuntimeLibcallImpl<FMAX_NXV4F32>;
41084108
def Sleef_fmindx_u10rvvm2 : RuntimeLibcallImpl<FMIN_NXV2F64>;
41094109
def Sleef_fminfx_u10rvvm2 : RuntimeLibcallImpl<FMIN_NXV4F32>;
4110-
def Sleef_fmoddx_rvvm2 : RuntimeLibcallImpl<FMOD_NXV2F64>;
4111-
def Sleef_fmodfx_rvvm2 : RuntimeLibcallImpl<FMOD_NXV4F32>;
4110+
def Sleef_fmoddx_rvvm2 : RuntimeLibcallImpl<REM_NXV2F64>;
4111+
def Sleef_fmodfx_rvvm2 : RuntimeLibcallImpl<REM_NXV4F32>;
41124112
def Sleef_hypotdx_u05rvvm2 : RuntimeLibcallImpl<HYPOT_NXV2F64>;
41134113
def Sleef_hypotfx_u05rvvm2 : RuntimeLibcallImpl<HYPOT_NXV4F32>;
41144114
def Sleef_ilogbdx_rvvm2 : RuntimeLibcallImpl<ILOGB_NXV2F64>;
@@ -4200,8 +4200,8 @@ defset list<RuntimeLibcallImpl> ARMPL_VECFUNCS = {
42004200
def armpl_svfmax_f64_x : RuntimeLibcallImpl<FMAX_NXV2F64>;
42014201
def armpl_svfmin_f32_x : RuntimeLibcallImpl<FMIN_NXV4F32>;
42024202
def armpl_svfmin_f64_x : RuntimeLibcallImpl<FMIN_NXV2F64>;
4203-
def armpl_svfmod_f32_x : RuntimeLibcallImpl<FMOD_NXV4F32>;
4204-
def armpl_svfmod_f64_x : RuntimeLibcallImpl<FMOD_NXV2F64>;
4203+
def armpl_svfmod_f32_x : RuntimeLibcallImpl<REM_NXV4F32>;
4204+
def armpl_svfmod_f64_x : RuntimeLibcallImpl<REM_NXV2F64>;
42054205
def armpl_svhypot_f32_x : RuntimeLibcallImpl<HYPOT_NXV4F32>;
42064206
def armpl_svhypot_f64_x : RuntimeLibcallImpl<HYPOT_NXV2F64>;
42074207
def armpl_svilogb_f32_x : RuntimeLibcallImpl<ILOGB_NXV4F32>;
@@ -4286,8 +4286,8 @@ defset list<RuntimeLibcallImpl> ARMPL_VECFUNCS = {
42864286
def armpl_vfmaxq_f64 : RuntimeLibcallImpl<FMAX_V2F64>;
42874287
def armpl_vfminq_f32 : RuntimeLibcallImpl<FMIN_V4F32>;
42884288
def armpl_vfminq_f64 : RuntimeLibcallImpl<FMIN_V2F64>;
4289-
def armpl_vfmodq_f32 : RuntimeLibcallImpl<FMOD_V4F32>;
4290-
def armpl_vfmodq_f64 : RuntimeLibcallImpl<FMOD_V2F64>;
4289+
def armpl_vfmodq_f32 : RuntimeLibcallImpl<REM_V4F32>;
4290+
def armpl_vfmodq_f64 : RuntimeLibcallImpl<REM_V2F64>;
42914291
def armpl_vhypotq_f32 : RuntimeLibcallImpl<HYPOT_V4F32>;
42924292
def armpl_vhypotq_f64 : RuntimeLibcallImpl<HYPOT_V2F64>;
42934293
def armpl_vilogbq_f32 : RuntimeLibcallImpl<ILOGB_V4F32>;

llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp

Lines changed: 35 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,6 @@ class VectorLegalizer {
157157

158158
bool tryExpandVecMathCall(SDNode *Node, RTLIB::Libcall LC,
159159
SmallVectorImpl<SDValue> &Results);
160-
bool tryExpandVecMathCall(SDNode *Node, RTLIB::Libcall Call_F32,
161-
RTLIB::Libcall Call_F64, RTLIB::Libcall Call_F80,
162-
RTLIB::Libcall Call_F128,
163-
RTLIB::Libcall Call_PPCF128,
164-
SmallVectorImpl<SDValue> &Results);
165160

166161
void UnrollStrictFPOp(SDNode *Node, SmallVectorImpl<SDValue> &Results);
167162

@@ -1261,13 +1256,13 @@ void VectorLegalizer::Expand(SDNode *Node, SmallVectorImpl<SDValue> &Results) {
12611256
return;
12621257
}
12631258
break;
1264-
case ISD::FREM:
1265-
if (tryExpandVecMathCall(Node, RTLIB::REM_F32, RTLIB::REM_F64,
1266-
RTLIB::REM_F80, RTLIB::REM_F128,
1267-
RTLIB::REM_PPCF128, Results))
1259+
case ISD::FREM: {
1260+
RTLIB::Libcall LC = RTLIB::getREM(Node->getValueType(0));
1261+
if (tryExpandVecMathCall(Node, LC, Results))
12681262
return;
12691263

12701264
break;
1265+
}
12711266
case ISD::FSINCOS:
12721267
case ISD::FSINCOSPI: {
12731268
EVT VT = Node->getValueType(0);
@@ -2233,99 +2228,60 @@ bool VectorLegalizer::tryExpandVecMathCall(SDNode *Node, RTLIB::Libcall LC,
22332228
// converted to their none strict counterpart.
22342229
assert(!Node->isStrictFPOpcode() && "Unexpected strict fp operation!");
22352230

2236-
const char *LCName = TLI.getLibcallName(LC);
2237-
if (!LCName)
2231+
RTLIB::LibcallImpl LCImpl = TLI.getLibcallImpl(LC);
2232+
if (LCImpl == RTLIB::Unsupported)
22382233
return false;
2239-
LLVM_DEBUG(dbgs() << "Looking for vector variant of " << LCName << "\n");
22402234

22412235
EVT VT = Node->getValueType(0);
2242-
ElementCount VL = VT.getVectorElementCount();
2243-
2244-
// Lookup a vector function equivalent to the specified libcall. Prefer
2245-
// unmasked variants but we will generate a mask if need be.
2246-
const TargetLibraryInfo &TLibInfo = DAG.getLibInfo();
2247-
const VecDesc *VD = TLibInfo.getVectorMappingInfo(LCName, VL, false);
2248-
if (!VD)
2249-
VD = TLibInfo.getVectorMappingInfo(LCName, VL, /*Masked=*/true);
2250-
if (!VD)
2251-
return false;
2252-
2253-
LLVMContext *Ctx = DAG.getContext();
2254-
Type *Ty = VT.getTypeForEVT(*Ctx);
2255-
Type *ScalarTy = Ty->getScalarType();
2236+
const RTLIB::RuntimeLibcallsInfo &RTLCI = TLI.getRuntimeLibcallsInfo();
2237+
LLVMContext &Ctx = *DAG.getContext();
22562238

2257-
// Construct a scalar function type based on Node's operands.
2258-
SmallVector<Type *, 8> ArgTys;
2259-
for (unsigned i = 0; i < Node->getNumOperands(); ++i) {
2260-
assert(Node->getOperand(i).getValueType() == VT &&
2261-
"Expected matching vector types!");
2262-
ArgTys.push_back(ScalarTy);
2263-
}
2264-
FunctionType *ScalarFTy = FunctionType::get(ScalarTy, ArgTys, false);
2239+
auto [FuncTy, FuncAttrs] = RTLCI.getFunctionTy(
2240+
Ctx, DAG.getSubtarget().getTargetTriple(), DAG.getDataLayout(), LCImpl);
22652241

2266-
// Generate call information for the vector function.
2267-
const std::string MangledName = VD->getVectorFunctionABIVariantString();
2268-
auto OptVFInfo = VFABI::tryDemangleForVFABI(MangledName, ScalarFTy);
2269-
if (!OptVFInfo)
2270-
return false;
2242+
SDLoc DL(Node);
2243+
TargetLowering::ArgListTy Args;
22712244

2272-
LLVM_DEBUG(dbgs() << "Found vector variant " << VD->getVectorFnName()
2273-
<< "\n");
2245+
bool HasMaskArg = RTLCI.hasVectorMaskArgument(LCImpl);
22742246

2275-
// Sanity check just in case OptVFInfo has unexpected parameters.
2276-
if (OptVFInfo->Shape.Parameters.size() !=
2277-
Node->getNumOperands() + VD->isMasked())
2278-
return false;
2247+
// Sanity check just in case function has unexpected parameters.
2248+
assert(FuncTy->getNumParams() == Node->getNumOperands() + HasMaskArg &&
2249+
EVT::getEVT(FuncTy->getReturnType(), true) == VT &&
2250+
"mismatch in value type and call signature type");
22792251

2280-
// Collect vector call operands.
2252+
for (unsigned I = 0, E = FuncTy->getNumParams(); I != E; ++I) {
2253+
Type *ParamTy = FuncTy->getParamType(I);
22812254

2282-
SDLoc DL(Node);
2283-
TargetLowering::ArgListTy Args;
2284-
2285-
unsigned OpNum = 0;
2286-
for (auto &VFParam : OptVFInfo->Shape.Parameters) {
2287-
if (VFParam.ParamKind == VFParamKind::GlobalPredicate) {
2288-
EVT MaskVT = TLI.getSetCCResultType(DAG.getDataLayout(), *Ctx, VT);
2255+
if (HasMaskArg && I == E - 1) {
2256+
assert(cast<VectorType>(ParamTy)->getElementType()->isIntegerTy(1) &&
2257+
"unexpected vector mask type");
2258+
EVT MaskVT = TLI.getSetCCResultType(DAG.getDataLayout(), Ctx, VT);
22892259
Args.emplace_back(DAG.getBoolConstant(true, DL, MaskVT, VT),
2290-
MaskVT.getTypeForEVT(*Ctx));
2291-
continue;
2292-
}
2293-
2294-
// Only vector operands are supported.
2295-
if (VFParam.ParamKind != VFParamKind::Vector)
2296-
return false;
2260+
MaskVT.getTypeForEVT(Ctx));
22972261

2298-
Args.emplace_back(Node->getOperand(OpNum++), Ty);
2262+
} else {
2263+
SDValue Op = Node->getOperand(I);
2264+
assert(Op.getValueType() == EVT::getEVT(ParamTy, true) &&
2265+
"mismatch in value type and call argument type");
2266+
Args.emplace_back(Op, ParamTy);
2267+
}
22992268
}
23002269

23012270
// Emit a call to the vector function.
2302-
SDValue Callee = DAG.getExternalSymbol(VD->getVectorFnName().data(),
2303-
TLI.getPointerTy(DAG.getDataLayout()));
2271+
SDValue Callee =
2272+
DAG.getExternalSymbol(LCImpl, TLI.getPointerTy(DAG.getDataLayout()));
2273+
CallingConv::ID CC = RTLCI.getLibcallImplCallingConv(LCImpl);
2274+
23042275
TargetLowering::CallLoweringInfo CLI(DAG);
23052276
CLI.setDebugLoc(DL)
23062277
.setChain(DAG.getEntryNode())
2307-
.setLibCallee(CallingConv::C, Ty, Callee, std::move(Args));
2278+
.setLibCallee(CC, FuncTy->getReturnType(), Callee, std::move(Args));
23082279

23092280
std::pair<SDValue, SDValue> CallResult = TLI.LowerCallTo(CLI);
23102281
Results.push_back(CallResult.first);
23112282
return true;
23122283
}
23132284

2314-
/// Try to expand the node to a vector libcall based on the result type.
2315-
bool VectorLegalizer::tryExpandVecMathCall(
2316-
SDNode *Node, RTLIB::Libcall Call_F32, RTLIB::Libcall Call_F64,
2317-
RTLIB::Libcall Call_F80, RTLIB::Libcall Call_F128,
2318-
RTLIB::Libcall Call_PPCF128, SmallVectorImpl<SDValue> &Results) {
2319-
RTLIB::Libcall LC = RTLIB::getFPLibCall(
2320-
Node->getValueType(0).getVectorElementType(), Call_F32, Call_F64,
2321-
Call_F80, Call_F128, Call_PPCF128);
2322-
2323-
if (LC == RTLIB::UNKNOWN_LIBCALL)
2324-
return false;
2325-
2326-
return tryExpandVecMathCall(Node, LC, Results);
2327-
}
2328-
23292285
void VectorLegalizer::UnrollStrictFPOp(SDNode *Node,
23302286
SmallVectorImpl<SDValue> &Results) {
23312287
EVT VT = Node->getValueType(0);

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,28 @@ RTLIB::Libcall RTLIB::getSINCOS_STRET(EVT RetVT) {
593593
UNKNOWN_LIBCALL, UNKNOWN_LIBCALL, UNKNOWN_LIBCALL);
594594
}
595595

596+
RTLIB::Libcall RTLIB::getREM(EVT VT) {
597+
// TODO: Tablegen should generate this function
598+
if (VT.isVector()) {
599+
if (!VT.isSimple())
600+
return RTLIB::UNKNOWN_LIBCALL;
601+
switch (VT.getSimpleVT().SimpleTy) {
602+
case MVT::v4f32:
603+
return RTLIB::REM_V4F32;
604+
case MVT::v2f64:
605+
return RTLIB::REM_V2F64;
606+
case MVT::nxv4f32:
607+
return RTLIB::REM_NXV4F32;
608+
case MVT::nxv2f64:
609+
return RTLIB::REM_NXV2F64;
610+
default:
611+
return RTLIB::UNKNOWN_LIBCALL;
612+
}
613+
}
614+
615+
return getFPLibCall(VT, REM_F32, REM_F64, REM_F80, REM_F128, REM_PPCF128);
616+
}
617+
596618
RTLIB::Libcall RTLIB::getMODF(EVT RetVT) {
597619
// TODO: Tablegen should generate this function
598620
if (RetVT.isVector()) {

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT,
4444
switch (VecLib) {
4545
case VectorLibrary::SLEEFGNUABI:
4646
for (RTLIB::LibcallImpl Impl :
47-
{RTLIB::impl__ZGVnN2vl8_modf, RTLIB::impl__ZGVnN4vl4_modff,
47+
{RTLIB::impl__ZGVnN2vv_fmod, RTLIB::impl__ZGVnN4vv_fmodf,
48+
RTLIB::impl__ZGVsMxvv_fmod, RTLIB::impl__ZGVsMxvv_fmodf,
49+
RTLIB::impl__ZGVnN2vl8_modf, RTLIB::impl__ZGVnN4vl4_modff,
4850
RTLIB::impl__ZGVsNxvl8_modf, RTLIB::impl__ZGVsNxvl4_modff,
4951
RTLIB::impl__ZGVnN2vl8l8_sincos, RTLIB::impl__ZGVnN4vl4l4_sincosf,
5052
RTLIB::impl__ZGVsNxvl8l8_sincos, RTLIB::impl__ZGVsNxvl4l4_sincosf,
@@ -55,7 +57,9 @@ RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT,
5557
break;
5658
case VectorLibrary::ArmPL:
5759
for (RTLIB::LibcallImpl Impl :
58-
{RTLIB::impl_armpl_vmodfq_f64, RTLIB::impl_armpl_vmodfq_f32,
60+
{RTLIB::impl_armpl_svfmod_f32_x, RTLIB::impl_armpl_svfmod_f64_x,
61+
RTLIB::impl_armpl_vfmodq_f32, RTLIB::impl_armpl_vfmodq_f64,
62+
RTLIB::impl_armpl_vmodfq_f64, RTLIB::impl_armpl_vmodfq_f32,
5963
RTLIB::impl_armpl_svmodf_f64_x, RTLIB::impl_armpl_svmodf_f32_x,
6064
RTLIB::impl_armpl_vsincosq_f64, RTLIB::impl_armpl_vsincosq_f32,
6165
RTLIB::impl_armpl_svsincos_f64_x, RTLIB::impl_armpl_svsincos_f32_x,
@@ -65,9 +69,9 @@ RuntimeLibcallsInfo::RuntimeLibcallsInfo(const Triple &TT,
6569
setAvailable(Impl);
6670

6771
for (RTLIB::LibcallImpl Impl :
68-
{RTLIB::impl_armpl_vsincosq_f64, RTLIB::impl_armpl_vsincosq_f32})
72+
{RTLIB::impl_armpl_vfmodq_f32, RTLIB::impl_armpl_vfmodq_f64,
73+
RTLIB::impl_armpl_vsincosq_f64, RTLIB::impl_armpl_vsincosq_f32})
6974
setLibcallImplCallingConv(Impl, CallingConv::AArch64_VectorCall);
70-
7175
break;
7276
default:
7377
break;
@@ -277,6 +281,43 @@ RuntimeLibcallsInfo::getFunctionTy(LLVMContext &Ctx, const Triple &TT,
277281
fcNegNormal));
278282
return {FuncTy, Attrs};
279283
}
284+
case RTLIB::impl__ZGVnN2vv_fmod:
285+
case RTLIB::impl__ZGVnN4vv_fmodf:
286+
case RTLIB::impl__ZGVsMxvv_fmod:
287+
case RTLIB::impl__ZGVsMxvv_fmodf:
288+
case RTLIB::impl_armpl_vfmodq_f32:
289+
case RTLIB::impl_armpl_vfmodq_f64:
290+
case RTLIB::impl_armpl_svfmod_f32_x:
291+
case RTLIB::impl_armpl_svfmod_f64_x: {
292+
bool IsF32 = LibcallImpl == RTLIB::impl__ZGVnN4vv_fmodf ||
293+
LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
294+
LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
295+
LibcallImpl == RTLIB::impl_armpl_vfmodq_f32;
296+
297+
bool IsScalable = LibcallImpl == RTLIB::impl__ZGVsMxvv_fmod ||
298+
LibcallImpl == RTLIB::impl__ZGVsMxvv_fmodf ||
299+
LibcallImpl == RTLIB::impl_armpl_svfmod_f32_x ||
300+
LibcallImpl == RTLIB::impl_armpl_svfmod_f64_x;
301+
302+
AttrBuilder FuncAttrBuilder(Ctx);
303+
304+
for (Attribute::AttrKind Attr : CommonFnAttrs)
305+
FuncAttrBuilder.addAttribute(Attr);
306+
307+
AttributeList Attrs;
308+
Attrs = Attrs.addFnAttributes(Ctx, FuncAttrBuilder);
309+
310+
Type *ScalarTy = IsF32 ? Type::getFloatTy(Ctx) : Type::getDoubleTy(Ctx);
311+
unsigned EC = IsF32 ? 4 : 2;
312+
VectorType *VecTy = VectorType::get(ScalarTy, EC, IsScalable);
313+
314+
SmallVector<Type *, 3> ArgTys = {VecTy, VecTy};
315+
if (hasVectorMaskArgument(LibcallImpl))
316+
ArgTys.push_back(VectorType::get(Type::getInt1Ty(Ctx), EC, IsScalable));
317+
318+
FunctionType *FuncTy = FunctionType::get(VecTy, ArgTys, false);
319+
return {FuncTy, Attrs};
320+
}
280321
case RTLIB::impl__ZGVnN2vl8_modf:
281322
case RTLIB::impl__ZGVnN4vl4_modff:
282323
case RTLIB::impl__ZGVsNxvl8_modf:
@@ -397,12 +438,16 @@ bool RuntimeLibcallsInfo::hasVectorMaskArgument(RTLIB::LibcallImpl Impl) {
397438
/// FIXME: This should be generated by tablegen and support the argument at an
398439
/// arbitrary position
399440
switch (Impl) {
441+
case RTLIB::impl_armpl_svfmod_f32_x:
442+
case RTLIB::impl_armpl_svfmod_f64_x:
400443
case RTLIB::impl_armpl_svmodf_f64_x:
401444
case RTLIB::impl_armpl_svmodf_f32_x:
402445
case RTLIB::impl_armpl_svsincos_f32_x:
403446
case RTLIB::impl_armpl_svsincos_f64_x:
404447
case RTLIB::impl_armpl_svsincospi_f32_x:
405448
case RTLIB::impl_armpl_svsincospi_f64_x:
449+
case RTLIB::impl__ZGVsMxvv_fmod:
450+
case RTLIB::impl__ZGVsMxvv_fmodf:
406451
return true;
407452
default:
408453
return false;

0 commit comments

Comments
 (0)