diff options
| author | Petar Avramovic <Petar.Avramovic@rt-rk.com> | 2019-10-24 10:15:07 +0200 |
|---|---|---|
| committer | Petar Avramovic <Petar.Avramovic@rt-rk.com> | 2019-10-24 10:15:07 +0200 |
| commit | 914ce66413e9de560a4546e87cacbbecad4d63bb (patch) | |
| tree | 4580a9af04f420b437b2aeb99bb0fdf5bd6dec71 /llvm/lib | |
| parent | 1d7f79c0171df921e5519c7f19a94d9a53c7d248 (diff) | |
| download | bcm5719-llvm-914ce66413e9de560a4546e87cacbbecad4d63bb.tar.gz bcm5719-llvm-914ce66413e9de560a4546e87cacbbecad4d63bb.zip | |
[MIPS GlobalISel] MSA vector generic and builtin fadd, fsub, fmul, fdiv
Select vector G_FADD, G_FSUB, G_FMUL and G_FDIV for MIPS32 with MSA. We
have to set bank for vector operands to fprb and selectImpl will do the
rest. __builtin_msa_fadd_<format>, __builtin_msa_fsub_<format>,
__builtin_msa_fmul_<format> and __builtin_msa_fdiv_<format> will be
transformed into G_FADD, G_FSUB, G_FMUL and G_FDIV in legalizeIntrinsic
respectively and selected in the same way.
Differential Revision: https://reviews.llvm.org/D69340
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsLegalizerInfo.cpp | 23 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp | 8 |
2 files changed, 28 insertions, 3 deletions
diff --git a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp index e44f5e7d1ce..f820da3dbc7 100644 --- a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp +++ b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp @@ -188,9 +188,18 @@ MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) { getActionDefinitionsBuilder(G_FCONSTANT) .legalFor({s32, s64}); - getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV, G_FABS, G_FSQRT}) + getActionDefinitionsBuilder({G_FABS, G_FSQRT}) .legalFor({s32, s64}); + getActionDefinitionsBuilder({G_FADD, G_FSUB, G_FMUL, G_FDIV}) + .legalIf([=, &ST](const LegalityQuery &Query) { + if (CheckTyN(0, Query, {s32, s64})) + return true; + if (ST.hasMSA() && CheckTyN(0, Query, {v16s8, v8s16, v4s32, v2s64})) + return true; + return false; + }); + getActionDefinitionsBuilder(G_FCMP) .legalFor({{s32, s32}, {s32, s64}}) .minScalar(0, s32); @@ -404,6 +413,18 @@ bool MipsLegalizerInfo::legalizeIntrinsic(MachineInstr &MI, case Intrinsic::mips_mod_u_w: case Intrinsic::mips_mod_u_d: return MSA3OpIntrinsicToGeneric(MI, TargetOpcode::G_UREM, MIRBuilder, ST); + case Intrinsic::mips_fadd_w: + case Intrinsic::mips_fadd_d: + return MSA3OpIntrinsicToGeneric(MI, TargetOpcode::G_FADD, MIRBuilder, ST); + case Intrinsic::mips_fsub_w: + case Intrinsic::mips_fsub_d: + return MSA3OpIntrinsicToGeneric(MI, TargetOpcode::G_FSUB, MIRBuilder, ST); + case Intrinsic::mips_fmul_w: + case Intrinsic::mips_fmul_d: + return MSA3OpIntrinsicToGeneric(MI, TargetOpcode::G_FMUL, MIRBuilder, ST); + case Intrinsic::mips_fdiv_w: + case Intrinsic::mips_fdiv_d: + return MSA3OpIntrinsicToGeneric(MI, TargetOpcode::G_FDIV, MIRBuilder, ST); default: break; } diff --git a/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp b/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp index c8700c86373..8af360a33e3 100644 --- a/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp +++ b/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp @@ -539,13 +539,17 @@ MipsRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const { &Mips::ValueMappings[Mips::GPRIdx]}); MappingID = CustomMappingID; break; + case G_FABS: + case G_FSQRT: + OperandsMapping = getFprbMapping(Op0Size); + break; case G_FADD: case G_FSUB: case G_FMUL: case G_FDIV: - case G_FABS: - case G_FSQRT: OperandsMapping = getFprbMapping(Op0Size); + if (Op0Size == 128) + OperandsMapping = getMSAMapping(MF); break; case G_FCONSTANT: OperandsMapping = getOperandsMapping({getFprbMapping(Op0Size), nullptr}); |

