[ARM] Mark VMOVRRD with the ExtractSubreg property and implement the related

target hook.

This patch teaches the compiler that:
rX, rY = VMOVRRD dZ
is the same as:
rX = EXTRACT_SUBREG dZ, ssub_0
rY = EXTRACT_SUBREG dZ, ssub_1

<rdar://problem/12702965>

llvm-svn: 216132
This commit is contained in:
Quentin Colombet 2014-08-20 22:16:19 +00:00
parent fffd56ecdf
commit deb82eab3e
3 changed files with 39 additions and 0 deletions

View File

@ -123,6 +123,27 @@ bool ARMInstrInfo::getRegSequenceLikeInputs(
llvm_unreachable("Target dependent opcode missing"); llvm_unreachable("Target dependent opcode missing");
} }
bool ARMInstrInfo::getExtractSubregLikeInputs(
const MachineInstr &MI, unsigned DefIdx,
RegSubRegPairAndIdx &InputReg) const {
assert(DefIdx < MI.getDesc().getNumDefs() && "Invalid definition index");
assert(MI.isExtractSubregLike() && "Invalid kind of instruction");
switch (MI.getOpcode()) {
case ARM::VMOVRRD:
// rX, rY = VMOVRRD dZ
// is the same as:
// rX = EXTRACT_SUBREG dZ, ssub_0
// rY = EXTRACT_SUBREG dZ, ssub_1
const MachineOperand &MOReg = MI.getOperand(2);
InputReg.Reg = MOReg.getReg();
InputReg.SubReg = MOReg.getSubReg();
InputReg.SubIdx = DefIdx == 0 ? ARM::ssub_0 : ARM::ssub_1;
return true;
}
llvm_unreachable("Target dependent opcode missing");
}
namespace { namespace {
/// ARMCGBR - Create Global Base Reg pass. This initializes the PIC /// ARMCGBR - Create Global Base Reg pass. This initializes the PIC
/// global base register for ARM ELF. /// global base register for ARM ELF.

View File

@ -55,6 +55,19 @@ public:
const MachineInstr &MI, unsigned DefIdx, const MachineInstr &MI, unsigned DefIdx,
SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const override; SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const override;
/// Build the equivalent inputs of a EXTRACT_SUBREG for the given \p MI
/// and \p DefIdx.
/// \p [out] InputReg of the equivalent EXTRACT_SUBREG.
/// E.g., EXTRACT_SUBREG vreg1:sub1, sub0, sub1 would produce:
/// - vreg1:sub1, sub0
///
/// \returns true if it is possible to build such an input sequence
/// with the pair \p MI, \p DefIdx. False otherwise.
///
/// \pre MI.isExtractSubregLike().
bool getExtractSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx,
RegSubRegPairAndIdx &InputReg) const override;
private: private:
void expandLoadStackGuard(MachineBasicBlock::iterator MI, void expandLoadStackGuard(MachineBasicBlock::iterator MI,
Reloc::Model RM) const override; Reloc::Model RM) const override;

View File

@ -842,6 +842,11 @@ def VMOVRRD : AVConv3I<0b11000101, 0b1011,
// Some single precision VFP instructions may be executed on both NEON and VFP // Some single precision VFP instructions may be executed on both NEON and VFP
// pipelines. // pipelines.
let D = VFPNeonDomain; let D = VFPNeonDomain;
// This instruction is equivalent to
// $Rt = EXTRACT_SUBREG $Dm, ssub_0
// $Rt2 = EXTRACT_SUBREG $Dm, ssub_1
let isExtractSubreg = 1;
} }
def VMOVRRS : AVConv3I<0b11000101, 0b1010, def VMOVRRS : AVConv3I<0b11000101, 0b1010,