mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
[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> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216143 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
824431f680
commit
7599acc2af
@ -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.
|
||||
|
@ -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;
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user