-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[AArch64][GlobalISel] Add support for pre-indexed loads/stores. #70185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5659,24 +5659,34 @@ bool AArch64InstructionSelector::selectIndexedLoad(MachineInstr &MI, | |
Register WriteBack = Ld.getWritebackReg(); | ||
Register Base = Ld.getBaseReg(); | ||
Register Offset = Ld.getOffsetReg(); | ||
|
||
if (Ld.isPre()) | ||
return false; // TODO: add pre-inc support | ||
|
||
unsigned Opc = 0; | ||
static constexpr unsigned GPROpcodes[] = { | ||
AArch64::LDRBBpost, AArch64::LDRHHpost, AArch64::LDRWpost, | ||
AArch64::LDRXpost}; | ||
static constexpr unsigned FPROpcodes[] = { | ||
AArch64::LDRBpost, AArch64::LDRHpost, AArch64::LDRSpost, | ||
AArch64::LDRDpost, AArch64::LDRQpost}; | ||
|
||
LLT Ty = MRI.getType(Dst); | ||
assert(Ty.getSizeInBits() <= 128 && "Unexpected type for indexed load"); | ||
unsigned MemSize = Ld.getMMO().getMemoryType().getSizeInBytes(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dumb question: are we guaranteed that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. We have separate opcodes for extending loads, |
||
if (RBI.getRegBank(Dst, MRI, TRI)->getID() == AArch64::FPRRegBankID) | ||
Opc = FPROpcodes[Log2_32(MemSize)]; | ||
else | ||
Opc = GPROpcodes[Log2_32(MemSize)]; | ||
|
||
unsigned Opc = 0; | ||
if (Ld.isPre()) { | ||
static constexpr unsigned GPROpcodes[] = { | ||
AArch64::LDRBBpre, AArch64::LDRHHpre, AArch64::LDRWpre, | ||
AArch64::LDRXpre}; | ||
static constexpr unsigned FPROpcodes[] = { | ||
AArch64::LDRBpre, AArch64::LDRHpre, AArch64::LDRSpre, AArch64::LDRDpre, | ||
AArch64::LDRQpre}; | ||
if (RBI.getRegBank(Dst, MRI, TRI)->getID() == AArch64::FPRRegBankID) | ||
Opc = FPROpcodes[Log2_32(MemSize)]; | ||
else | ||
Opc = GPROpcodes[Log2_32(MemSize)]; | ||
} else { | ||
static constexpr unsigned GPROpcodes[] = { | ||
AArch64::LDRBBpost, AArch64::LDRHHpost, AArch64::LDRWpost, | ||
AArch64::LDRXpost}; | ||
static constexpr unsigned FPROpcodes[] = { | ||
AArch64::LDRBpost, AArch64::LDRHpost, AArch64::LDRSpost, | ||
AArch64::LDRDpost, AArch64::LDRQpost}; | ||
if (RBI.getRegBank(Dst, MRI, TRI)->getID() == AArch64::FPRRegBankID) | ||
Opc = FPROpcodes[Log2_32(MemSize)]; | ||
else | ||
Opc = GPROpcodes[Log2_32(MemSize)]; | ||
} | ||
auto Cst = getIConstantVRegVal(Offset, MRI); | ||
if (!Cst) | ||
return false; // Shouldn't happen, but just in case. | ||
|
@@ -5695,23 +5705,34 @@ bool AArch64InstructionSelector::selectIndexedStore(GIndexedStore &I, | |
Register Base = I.getBaseReg(); | ||
Register Offset = I.getOffsetReg(); | ||
LLT ValTy = MRI.getType(Val); | ||
|
||
if (I.isPre()) | ||
return false; // TODO: add pre-inc support | ||
assert(ValTy.getSizeInBits() <= 128 && "Unexpected type for indexed store"); | ||
|
||
unsigned Opc = 0; | ||
static constexpr unsigned GPROpcodes[] = { | ||
AArch64::STRBBpost, AArch64::STRHHpost, AArch64::STRWpost, | ||
AArch64::STRXpost}; | ||
static constexpr unsigned FPROpcodes[] = { | ||
AArch64::STRBpost, AArch64::STRHpost, AArch64::STRSpost, | ||
AArch64::STRDpost, AArch64::STRQpost}; | ||
|
||
assert(ValTy.getSizeInBits() <= 128); | ||
if (RBI.getRegBank(Val, MRI, TRI)->getID() == AArch64::FPRRegBankID) | ||
Opc = FPROpcodes[Log2_32(ValTy.getSizeInBytes())]; | ||
else | ||
Opc = GPROpcodes[Log2_32(ValTy.getSizeInBytes())]; | ||
if (I.isPre()) { | ||
static constexpr unsigned GPROpcodes[] = { | ||
AArch64::STRBBpre, AArch64::STRHHpre, AArch64::STRWpre, | ||
AArch64::STRXpre}; | ||
static constexpr unsigned FPROpcodes[] = { | ||
AArch64::STRBpre, AArch64::STRHpre, AArch64::STRSpre, AArch64::STRDpre, | ||
AArch64::STRQpre}; | ||
|
||
if (RBI.getRegBank(Val, MRI, TRI)->getID() == AArch64::FPRRegBankID) | ||
Opc = FPROpcodes[Log2_32(ValTy.getSizeInBytes())]; | ||
else | ||
Opc = GPROpcodes[Log2_32(ValTy.getSizeInBytes())]; | ||
} else { | ||
static constexpr unsigned GPROpcodes[] = { | ||
AArch64::STRBBpost, AArch64::STRHHpost, AArch64::STRWpost, | ||
AArch64::STRXpost}; | ||
static constexpr unsigned FPROpcodes[] = { | ||
AArch64::STRBpost, AArch64::STRHpost, AArch64::STRSpost, | ||
AArch64::STRDpost, AArch64::STRQpost}; | ||
|
||
if (RBI.getRegBank(Val, MRI, TRI)->getID() == AArch64::FPRRegBankID) | ||
Opc = FPROpcodes[Log2_32(ValTy.getSizeInBytes())]; | ||
else | ||
Opc = GPROpcodes[Log2_32(ValTy.getSizeInBytes())]; | ||
} | ||
|
||
auto Cst = getIConstantVRegVal(Offset, MRI); | ||
if (!Cst) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Defer the dominance check until after you know the mode is foldable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The foldable check isn't an early exit, so we still need to do this for every use.