diff options
| author | Petar Avramovic <Petar.Avramovic@rt-rk.com> | 2019-03-01 07:25:44 +0000 | 
|---|---|---|
| committer | Petar Avramovic <Petar.Avramovic@rt-rk.com> | 2019-03-01 07:25:44 +0000 | 
| commit | a48285a1900ed17b019ef291ecae743a91d2f8b6 (patch) | |
| tree | e6432165b2edfc21a45b3cb75910821d096e6e97 /llvm/lib/Target | |
| parent | 524b3c181012caf2197abdff8cf96d0d75873125 (diff) | |
| download | bcm5719-llvm-a48285a1900ed17b019ef291ecae743a91d2f8b6.tar.gz bcm5719-llvm-a48285a1900ed17b019ef291ecae743a91d2f8b6.zip | |
[MIPS GlobalISel] Select G_UMULH
Legalize G_UMULO and select G_UMULH for MIPS32.
Differential Revision: https://reviews.llvm.org/D58714
llvm-svn: 355177
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsInstructionSelector.cpp | 20 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsLegalizerInfo.cpp | 5 | ||||
| -rw-r--r-- | llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp | 1 | 
3 files changed, 25 insertions, 1 deletions
| diff --git a/llvm/lib/Target/Mips/MipsInstructionSelector.cpp b/llvm/lib/Target/Mips/MipsInstructionSelector.cpp index c97fac9d21b..92a62b5186b 100644 --- a/llvm/lib/Target/Mips/MipsInstructionSelector.cpp +++ b/llvm/lib/Target/Mips/MipsInstructionSelector.cpp @@ -139,6 +139,26 @@ bool MipsInstructionSelector::select(MachineInstr &I,    using namespace TargetOpcode;    switch (I.getOpcode()) { +  case G_UMULH: { +    unsigned PseudoMULTuReg = MRI.createVirtualRegister(&Mips::ACC64RegClass); +    MachineInstr *PseudoMULTu, *PseudoMove; + +    PseudoMULTu = BuildMI(MBB, I, I.getDebugLoc(), TII.get(Mips::PseudoMULTu)) +                      .addDef(PseudoMULTuReg) +                      .add(I.getOperand(1)) +                      .add(I.getOperand(2)); +    if (!constrainSelectedInstRegOperands(*PseudoMULTu, TII, TRI, RBI)) +      return false; + +    PseudoMove = BuildMI(MBB, I, I.getDebugLoc(), TII.get(Mips::PseudoMFHI)) +                     .addDef(I.getOperand(0).getReg()) +                     .addUse(PseudoMULTuReg); +    if (!constrainSelectedInstRegOperands(*PseudoMove, TII, TRI, RBI)) +      return false; + +    I.eraseFromParent(); +    return true; +  }    case G_GEP: {      MI = BuildMI(MBB, I, I.getDebugLoc(), TII.get(Mips::ADDu))               .add(I.getOperand(0)) diff --git a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp index dd87d01777e..1da43b0b6df 100644 --- a/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp +++ b/llvm/lib/Target/Mips/MipsLegalizerInfo.cpp @@ -32,9 +32,12 @@ MipsLegalizerInfo::MipsLegalizerInfo(const MipsSubtarget &ST) {        .legalFor({s32})        .minScalar(0, s32); -  getActionDefinitionsBuilder({G_UADDO, G_UADDE, G_USUBO, G_USUBE}) +  getActionDefinitionsBuilder({G_UADDO, G_UADDE, G_USUBO, G_USUBE, G_UMULO})        .lowerFor({{s32, s1}}); +  getActionDefinitionsBuilder(G_UMULH) +      .legalFor({s32}); +    getActionDefinitionsBuilder({G_LOAD, G_STORE})        .legalForTypesWithMemDesc({{s32, p0, 8, 8},                                   {s32, p0, 16, 8}, diff --git a/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp b/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp index c463ca11ea5..214dd106869 100644 --- a/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp +++ b/llvm/lib/Target/Mips/MipsRegisterBankInfo.cpp @@ -86,6 +86,7 @@ MipsRegisterBankInfo::getInstrMapping(const MachineInstr &MI) const {    case G_ADD:    case G_SUB:    case G_MUL: +  case G_UMULH:    case G_LOAD:    case G_STORE:    case G_ZEXTLOAD: | 

