diff options
| author | Quentin Colombet <qcolombet@apple.com> | 2014-08-21 00:10:52 +0000 | 
|---|---|---|
| committer | Quentin Colombet <qcolombet@apple.com> | 2014-08-21 00:10:52 +0000 | 
| commit | 84f15bd1b05387e506cf2b49d3d40df193edce79 (patch) | |
| tree | a9bc2592768f8a9038f32c2e365e9e296cc15824 /llvm | |
| parent | 85f064bebfd39ad34e011492f8766d49f1942e1b (diff) | |
| download | bcm5719-llvm-84f15bd1b05387e506cf2b49d3d40df193edce79.tar.gz bcm5719-llvm-84f15bd1b05387e506cf2b49d3d40df193edce79.zip  | |
[ARM] Mark VSETLNi32 with the InsertSubreg property and implement the related
target hook.
This patch teaches the compiler that:
dX = VSETLNi32 dY, rZ, imm
is the same as:
dX = INSERT_SUBREG dY, rZ, translateImmToSubIdx(imm)
<rdar://problem/12702965>
llvm-svn: 216143
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstrInfo.cpp | 23 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstrInfo.h | 17 | ||||
| -rw-r--r-- | llvm/lib/Target/ARM/ARMInstrNEON.td | 3 | 
3 files changed, 43 insertions, 0 deletions
diff --git a/llvm/lib/Target/ARM/ARMInstrInfo.cpp b/llvm/lib/Target/ARM/ARMInstrInfo.cpp index 63008853e96..5acaa877a3e 100644 --- a/llvm/lib/Target/ARM/ARMInstrInfo.cpp +++ b/llvm/lib/Target/ARM/ARMInstrInfo.cpp @@ -144,6 +144,29 @@ bool ARMInstrInfo::getExtractSubregLikeInputs(    llvm_unreachable("Target dependent opcode missing");  } +bool ARMInstrInfo::getInsertSubregLikeInputs( +    const MachineInstr &MI, unsigned DefIdx, RegSubRegPair &BaseReg, +    RegSubRegPairAndIdx &InsertedReg) const { +  assert(DefIdx < MI.getDesc().getNumDefs() && "Invalid definition index"); +  assert(MI.isInsertSubregLike() && "Invalid kind of instruction"); + +  switch (MI.getOpcode()) { +  case ARM::VSETLNi32: +    // dX = VSETLNi32 dY, rZ, imm +    const MachineOperand &MOBaseReg = MI.getOperand(1); +    const MachineOperand &MOInsertedReg = MI.getOperand(2); +    const MachineOperand &MOIndex = MI.getOperand(3); +    BaseReg.Reg = MOBaseReg.getReg(); +    BaseReg.SubReg = MOBaseReg.getSubReg(); + +    InsertedReg.Reg = MOInsertedReg.getReg(); +    InsertedReg.SubReg = MOInsertedReg.getSubReg(); +    InsertedReg.SubIdx = MOIndex.getImm() == 0 ? ARM::ssub_0 : ARM::ssub_1; +    return true; +  } +  llvm_unreachable("Target dependent opcode missing"); +} +  namespace {    /// ARMCGBR - Create Global Base Reg pass. This initializes the PIC    /// global base register for ARM ELF. diff --git a/llvm/lib/Target/ARM/ARMInstrInfo.h b/llvm/lib/Target/ARM/ARMInstrInfo.h index e66e19bdace..659ddc0e5ed 100644 --- a/llvm/lib/Target/ARM/ARMInstrInfo.h +++ b/llvm/lib/Target/ARM/ARMInstrInfo.h @@ -68,6 +68,23 @@ public:    bool getExtractSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx,                                    RegSubRegPairAndIdx &InputReg) const override; +  /// Build the equivalent inputs of a INSERT_SUBREG for the given \p MI +  /// and \p DefIdx. +  /// \p [out] BaseReg and \p [out] InsertedReg contain +  /// the equivalent inputs of INSERT_SUBREG. +  /// E.g., INSERT_SUBREG vreg0:sub0, vreg1:sub1, sub3 would produce: +  /// - BaseReg: vreg0:sub0 +  /// - InsertedReg: vreg1:sub1, sub3 +  /// +  /// \returns true if it is possible to build such an input sequence +  /// with the pair \p MI, \p DefIdx. False otherwise. +  /// +  /// \pre MI.isInsertSubregLike(). +  bool +  getInsertSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx, +                            RegSubRegPair &BaseReg, +                            RegSubRegPairAndIdx &InsertedReg) const override; +  private:    void expandLoadStackGuard(MachineBasicBlock::iterator MI,                              Reloc::Model RM) const override; diff --git a/llvm/lib/Target/ARM/ARMInstrNEON.td b/llvm/lib/Target/ARM/ARMInstrNEON.td index ca0b05d3842..a276b92b297 100644 --- a/llvm/lib/Target/ARM/ARMInstrNEON.td +++ b/llvm/lib/Target/ARM/ARMInstrNEON.td @@ -5499,6 +5499,9 @@ def VSETLNi32 : NVSetLane<{1,1,1,0,0,0,?,0}, 0b1011, 0b00, (outs DPR:$V),                            [(set DPR:$V, (insertelt (v2i32 DPR:$src1),                                             GPR:$R, imm:$lane))]> {    let Inst{21} = lane{0}; +  // This instruction is equivalent as +  // $V = INSERT_SUBREG $src1, $R, translateImmToSubIdx($imm) +  let isInsertSubreg = 1;  }  }  def : Pat<(vector_insert (v16i8 QPR:$src1), GPR:$src2, imm:$lane),  | 

