diff options
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp | 23 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMBaseInstrInfo.h | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstrInfo.td | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstrThumb2.td | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/README.txt | 5 | 
5 files changed, 30 insertions, 5 deletions
| diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp index 56cd6e56e71..c6280f819a4 100644 --- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp +++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp @@ -1500,6 +1500,29 @@ int llvm::getMatchingCondBranchOpcode(int Opc) {    llvm_unreachable("Unknown unconditional branch opcode!");  } +/// commuteInstruction - Handle commutable instructions. +MachineInstr * +ARMBaseInstrInfo::commuteInstruction(MachineInstr *MI, bool NewMI) const { +  switch (MI->getOpcode()) { +  case ARM::MOVCCr: +  case ARM::t2MOVCCr: { +    // MOVCC can be commuted by inverting the condition. +    unsigned PredReg = 0; +    ARMCC::CondCodes CC = getInstrPredicate(MI, PredReg); +    // MOVCC AL can't be inverted. Shouldn't happen. +    if (CC == ARMCC::AL || PredReg != ARM::CPSR) +      return NULL; +    MI = TargetInstrInfoImpl::commuteInstruction(MI, NewMI); +    if (!MI) +      return NULL; +    // After swapping the MOVCC operands, also invert the condition. +    MI->getOperand(MI->findFirstPredOperandIdx()) +      .setImm(ARMCC::getOppositeCondition(CC)); +    return MI; +  } +  } +  return TargetInstrInfoImpl::commuteInstruction(MI, NewMI); +}  /// Map pseudo instructions that imply an 'S' bit onto real opcodes. Whether the  /// instruction is encoded with an 'S' bit is determined by the optional CPSR diff --git a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h index 314e3177bec..2fe85072a33 100644 --- a/llvm/lib/Target/ARM/ARMBaseInstrInfo.h +++ b/llvm/lib/Target/ARM/ARMBaseInstrInfo.h @@ -139,6 +139,8 @@ public:    MachineInstr *duplicate(MachineInstr *Orig, MachineFunction &MF) const; +  MachineInstr *commuteInstruction(MachineInstr*, bool=false) const; +    virtual bool produceSameValue(const MachineInstr *MI0,                                  const MachineInstr *MI1,                                  const MachineRegisterInfo *MRI) const; diff --git a/llvm/lib/Target/ARM/ARMInstrInfo.td b/llvm/lib/Target/ARM/ARMInstrInfo.td index c0bd237f2ed..37d53b09a79 100644 --- a/llvm/lib/Target/ARM/ARMInstrInfo.td +++ b/llvm/lib/Target/ARM/ARMInstrInfo.td @@ -4044,10 +4044,13 @@ def BCCZi64 : PseudoInst<(outs),  // FIXME: should be able to write a pattern for ARMcmov, but can't use  // a two-value operand where a dag node expects two operands. :(  let neverHasSideEffects = 1 in { + +let isCommutable = 1 in  def MOVCCr : ARMPseudoInst<(outs GPR:$Rd), (ins GPR:$false, GPR:$Rm, pred:$p),                             4, IIC_iCMOVr,    [/*(set GPR:$Rd, (ARMcmov GPR:$false, GPR:$Rm, imm:$cc, CCR:$ccr))*/]>,        RegConstraint<"$false = $Rd">; +  def MOVCCsi : ARMPseudoInst<(outs GPR:$Rd),                             (ins GPR:$false, so_reg_imm:$shift, pred:$p),                             4, IIC_iCMOVsr, diff --git a/llvm/lib/Target/ARM/ARMInstrThumb2.td b/llvm/lib/Target/ARM/ARMInstrThumb2.td index 63d3a63c737..41d4e206491 100644 --- a/llvm/lib/Target/ARM/ARMInstrThumb2.td +++ b/llvm/lib/Target/ARM/ARMInstrThumb2.td @@ -2872,6 +2872,8 @@ defm t2TEQ  : T2I_cmp_irs<0b0100, "teq",  // FIXME: should be able to write a pattern for ARMcmov, but can't use  // a two-value operand where a dag node expects two operands. :(  let neverHasSideEffects = 1 in { + +let isCommutable = 1 in  def t2MOVCCr : t2PseudoInst<(outs rGPR:$Rd),                              (ins rGPR:$false, rGPR:$Rm, pred:$p),                              4, IIC_iCMOVr, diff --git a/llvm/lib/Target/ARM/README.txt b/llvm/lib/Target/ARM/README.txt index 4fcaecfcb23..3eddda812f8 100644 --- a/llvm/lib/Target/ARM/README.txt +++ b/llvm/lib/Target/ARM/README.txt @@ -501,11 +501,6 @@ those operations and the ARMv6 scalar versions.  //===---------------------------------------------------------------------===// -ARM::MOVCCr is commutable (by flipping the condition). But we need to implement -ARMInstrInfo::commuteInstruction() to support it. - -//===---------------------------------------------------------------------===// -  Split out LDR (literal) from normal ARM LDR instruction. Also consider spliting  LDR into imm12 and so_reg forms. This allows us to clean up some code. e.g.  ARMLoadStoreOptimizer does not need to look at LDR (literal) and LDR (so_reg) | 

