diff options
| author | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-06-12 10:44:10 +0000 | 
|---|---|---|
| committer | Daniel Sanders <daniel.sanders@imgtec.com> | 2014-06-12 10:44:10 +0000 | 
| commit | 308181eaa00c3eb20ca56c8235b438529d62d817 (patch) | |
| tree | 5460884d6aaef9c2f28995e4a067293d94a0352a /llvm/lib/Target/Mips/MipsISelLowering.cpp | |
| parent | f77acce0594a052ab69518294dea552ed0150f1d (diff) | |
| download | bcm5719-llvm-308181eaa00c3eb20ca56c8235b438529d62d817.tar.gz bcm5719-llvm-308181eaa00c3eb20ca56c8235b438529d62d817.zip  | |
[mips][mips64r6] Replace m[tf]hi, m[tf]lo, mult, multu, dmult, dmultu, div, ddiv, divu, ddivu for MIPS32r6/MIPS64.
Summary:
The accumulator-based (HI/LO) multiplies and divides from earlier ISA's have
been removed and replaced with GPR-based equivalents. For example:
  div $1, $2
  mflo $3
is now:
  div $3, $1, $2
This patch disables the accumulator-based multiplies and divides for
MIPS32r6/MIPS64r6 and uses the GPR-based equivalents instead.
Renamed expandPseudoDiv to insertDivByZeroTrap to better describe the
behaviour of the function.
MipsDelaySlotFiller now invalidates the liveness information when moving
instructions to the delay slot. Without this, divrem.ll will abort since
%GP ends up used before it is defined.
Reviewers: vmedic, zoran.jovanovic, jkolek
Reviewed By: jkolek
Differential Revision: http://reviews.llvm.org/D3896
llvm-svn: 210760
Diffstat (limited to 'llvm/lib/Target/Mips/MipsISelLowering.cpp')
| -rw-r--r-- | llvm/lib/Target/Mips/MipsISelLowering.cpp | 26 | 
1 files changed, 20 insertions, 6 deletions
diff --git a/llvm/lib/Target/Mips/MipsISelLowering.cpp b/llvm/lib/Target/Mips/MipsISelLowering.cpp index 910189a51c8..d830cc14f20 100644 --- a/llvm/lib/Target/Mips/MipsISelLowering.cpp +++ b/llvm/lib/Target/Mips/MipsISelLowering.cpp @@ -816,10 +816,10 @@ addLiveIn(MachineFunction &MF, unsigned PReg, const TargetRegisterClass *RC)    return VReg;  } -static MachineBasicBlock *expandPseudoDIV(MachineInstr *MI, -                                          MachineBasicBlock &MBB, -                                          const TargetInstrInfo &TII, -                                          bool Is64Bit) { +static MachineBasicBlock *insertDivByZeroTrap(MachineInstr *MI, +                                              MachineBasicBlock &MBB, +                                              const TargetInstrInfo &TII, +                                              bool Is64Bit) {    if (NoZeroDivCheck)      return &MBB; @@ -837,6 +837,10 @@ static MachineBasicBlock *expandPseudoDIV(MachineInstr *MI,    // Clear Divisor's kill flag.    Divisor.setIsKill(false); + +  // We would normally delete the original instruction here but in this case +  // we only needed to inject an additional instruction rather than replace it. +    return &MBB;  } @@ -919,10 +923,20 @@ MipsTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI,      return emitAtomicCmpSwap(MI, BB, 8);    case Mips::PseudoSDIV:    case Mips::PseudoUDIV: -    return expandPseudoDIV(MI, *BB, *getTargetMachine().getInstrInfo(), false); +  case Mips::DIV: +  case Mips::DIVU: +  case Mips::MOD: +  case Mips::MODU: +    return insertDivByZeroTrap(MI, *BB, *getTargetMachine().getInstrInfo(), +                               false);    case Mips::PseudoDSDIV:    case Mips::PseudoDUDIV: -    return expandPseudoDIV(MI, *BB, *getTargetMachine().getInstrInfo(), true); +  case Mips::DDIV: +  case Mips::DDIVU: +  case Mips::DMOD: +  case Mips::DMODU: +    return insertDivByZeroTrap(MI, *BB, *getTargetMachine().getInstrInfo(), +                               true);    }  }  | 

