mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-29 08:31:13 +00:00
[AArch64] Match FI+offset in STNP addressing mode.
First, we need to teach isFrameOffsetLegal about STNP. It already knew about the STP/LDP variants, but those were probably never exercised, because it's only the load/store optimizer that generates STP/LDP, and the only user of the method is frame lowering, which runs earlier. The STP/LDP cases were wrong: they didn't take into account the fact that they return two results, not one, so the immediate offset will be the 4th operand, not the 3rd. Follow-up to r247234. llvm-svn: 247236
This commit is contained in:
parent
ddedd7255a
commit
05541459fa
@ -630,6 +630,15 @@ bool AArch64DAGToDAGISel::SelectAddrModeIndexed7S(SDValue N, unsigned Size,
|
||||
SDValue &Base,
|
||||
SDValue &OffImm) {
|
||||
SDLoc dl(N);
|
||||
const DataLayout &DL = CurDAG->getDataLayout();
|
||||
const TargetLowering *TLI = getTargetLowering();
|
||||
if (N.getOpcode() == ISD::FrameIndex) {
|
||||
int FI = cast<FrameIndexSDNode>(N)->getIndex();
|
||||
Base = CurDAG->getTargetFrameIndex(FI, TLI->getPointerTy(DL));
|
||||
OffImm = CurDAG->getTargetConstant(0, dl, MVT::i64);
|
||||
return true;
|
||||
}
|
||||
|
||||
// As opposed to the (12-bit) Indexed addressing mode below, the 7-bit signed
|
||||
// selected here doesn't support labels/immediates, only base+offset.
|
||||
|
||||
@ -640,6 +649,10 @@ bool AArch64DAGToDAGISel::SelectAddrModeIndexed7S(SDValue N, unsigned Size,
|
||||
if ((RHSC & (Size - 1)) == 0 && RHSC >= (-0x40 << Scale) &&
|
||||
RHSC < (0x40 << Scale)) {
|
||||
Base = N.getOperand(0);
|
||||
if (Base.getOpcode() == ISD::FrameIndex) {
|
||||
int FI = cast<FrameIndexSDNode>(Base)->getIndex();
|
||||
Base = CurDAG->getTargetFrameIndex(FI, TLI->getPointerTy(DL));
|
||||
}
|
||||
OffImm = CurDAG->getTargetConstant(RHSC >> Scale, dl, MVT::i64);
|
||||
return true;
|
||||
}
|
||||
|
@ -2260,11 +2260,19 @@ int llvm::isAArch64FrameOffsetLegal(const MachineInstr &MI, int &Offset,
|
||||
case AArch64::LDPDi:
|
||||
case AArch64::STPXi:
|
||||
case AArch64::STPDi:
|
||||
case AArch64::LDNPXi:
|
||||
case AArch64::LDNPDi:
|
||||
case AArch64::STNPXi:
|
||||
case AArch64::STNPDi:
|
||||
ImmIdx = 3;
|
||||
IsSigned = true;
|
||||
Scale = 8;
|
||||
break;
|
||||
case AArch64::LDPQi:
|
||||
case AArch64::STPQi:
|
||||
case AArch64::LDNPQi:
|
||||
case AArch64::STNPQi:
|
||||
ImmIdx = 3;
|
||||
IsSigned = true;
|
||||
Scale = 16;
|
||||
break;
|
||||
@ -2272,6 +2280,11 @@ int llvm::isAArch64FrameOffsetLegal(const MachineInstr &MI, int &Offset,
|
||||
case AArch64::LDPSi:
|
||||
case AArch64::STPWi:
|
||||
case AArch64::STPSi:
|
||||
case AArch64::LDNPWi:
|
||||
case AArch64::LDNPSi:
|
||||
case AArch64::STNPWi:
|
||||
case AArch64::STNPSi:
|
||||
ImmIdx = 3;
|
||||
IsSigned = true;
|
||||
Scale = 4;
|
||||
break;
|
||||
|
@ -313,9 +313,7 @@ declare void @dummy(<4 x float>*)
|
||||
|
||||
define void @test_stnp_v4f32_offset_alloca(<4 x float> %v) #0 {
|
||||
; CHECK-LABEL: test_stnp_v4f32_offset_alloca:
|
||||
; CHECK: mov x29, sp
|
||||
; CHECK: mov x[[PTR:[0-9]+]], sp
|
||||
; CHECK-NEXT: stnp d0, d{{.*}}, [x[[PTR]]]
|
||||
; CHECK: stnp d0, d{{.*}}, [sp]
|
||||
; CHECK-NEXT: mov x0, sp
|
||||
; CHECK-NEXT: bl _dummy
|
||||
%tmp0 = alloca <4 x float>
|
||||
@ -326,9 +324,7 @@ define void @test_stnp_v4f32_offset_alloca(<4 x float> %v) #0 {
|
||||
|
||||
define void @test_stnp_v4f32_offset_alloca_2(<4 x float> %v) #0 {
|
||||
; CHECK-LABEL: test_stnp_v4f32_offset_alloca_2:
|
||||
; CHECK: mov x29, sp
|
||||
; CHECK: mov x[[PTR:[0-9]+]], sp
|
||||
; CHECK-NEXT: stnp d0, d{{.*}}, [x[[PTR]], #16]
|
||||
; CHECK: stnp d0, d{{.*}}, [sp, #16]
|
||||
; CHECK-NEXT: mov x0, sp
|
||||
; CHECK-NEXT: bl _dummy
|
||||
%tmp0 = alloca <4 x float>, i32 2
|
||||
|
Loading…
Reference in New Issue
Block a user