1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

[AArch64] Use a static function and other minor cleanup for readability. NFC.

llvm-svn: 244233
This commit is contained in:
Chad Rosier 2015-08-06 17:37:18 +00:00
parent 766ef3c94f
commit 9a57801f77

View File

@ -134,9 +134,6 @@ struct AArch64LoadStoreOpt : public MachineFunctionPass {
const char *getPassName() const override { const char *getPassName() const override {
return AARCH64_LOAD_STORE_OPT_NAME; return AARCH64_LOAD_STORE_OPT_NAME;
} }
private:
int getMemSize(MachineInstr *MemMI);
}; };
char AArch64LoadStoreOpt::ID = 0; char AArch64LoadStoreOpt::ID = 0;
} // namespace } // namespace
@ -144,7 +141,7 @@ char AArch64LoadStoreOpt::ID = 0;
INITIALIZE_PASS(AArch64LoadStoreOpt, "aarch64-ldst-opt", INITIALIZE_PASS(AArch64LoadStoreOpt, "aarch64-ldst-opt",
AARCH64_LOAD_STORE_OPT_NAME, false, false) AARCH64_LOAD_STORE_OPT_NAME, false, false)
static bool isUnscaledLdst(unsigned Opc) { static bool isUnscaledLdSt(unsigned Opc) {
switch (Opc) { switch (Opc) {
default: default:
return false; return false;
@ -163,9 +160,13 @@ static bool isUnscaledLdst(unsigned Opc) {
} }
} }
static bool isUnscaledLdSt(MachineInstr *MI) {
return isUnscaledLdSt(MI->getOpcode());
}
// Size in bytes of the data moved by an unscaled load or store // Size in bytes of the data moved by an unscaled load or store
int AArch64LoadStoreOpt::getMemSize(MachineInstr *MemMI) { static int getMemSize(MachineInstr *MI) {
switch (MemMI->getOpcode()) { switch (MI->getOpcode()) {
default: default:
llvm_unreachable("Opcode has unknown size!"); llvm_unreachable("Opcode has unknown size!");
case AArch64::STRSui: case AArch64::STRSui:
@ -367,7 +368,7 @@ AArch64LoadStoreOpt::mergePairedInsns(MachineBasicBlock::iterator I,
int SExtIdx = Flags.getSExtIdx(); int SExtIdx = Flags.getSExtIdx();
unsigned Opc = unsigned Opc =
SExtIdx == -1 ? I->getOpcode() : getMatchingNonSExtOpcode(I->getOpcode()); SExtIdx == -1 ? I->getOpcode() : getMatchingNonSExtOpcode(I->getOpcode());
bool IsUnscaled = isUnscaledLdst(Opc); bool IsUnscaled = isUnscaledLdSt(Opc);
int OffsetStride = int OffsetStride =
IsUnscaled && EnableAArch64UnscaledMemOp ? getMemSize(I) : 1; IsUnscaled && EnableAArch64UnscaledMemOp ? getMemSize(I) : 1;
@ -547,7 +548,7 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
unsigned Opc = FirstMI->getOpcode(); unsigned Opc = FirstMI->getOpcode();
bool MayLoad = FirstMI->mayLoad(); bool MayLoad = FirstMI->mayLoad();
bool IsUnscaled = isUnscaledLdst(Opc); bool IsUnscaled = isUnscaledLdSt(FirstMI);
unsigned Reg = getLdStRegOp(FirstMI).getReg(); unsigned Reg = getLdStRegOp(FirstMI).getReg();
unsigned BaseReg = getLdStBaseOp(FirstMI).getReg(); unsigned BaseReg = getLdStBaseOp(FirstMI).getReg();
int Offset = getLdStOffsetOp(FirstMI).getImm(); int Offset = getLdStOffsetOp(FirstMI).getImm();
@ -618,7 +619,7 @@ AArch64LoadStoreOpt::findMatchingInsn(MachineBasicBlock::iterator I,
return E; return E;
// If the resultant immediate offset of merging these instructions // If the resultant immediate offset of merging these instructions
// is out of range for a pairwise instruction, bail and keep looking. // is out of range for a pairwise instruction, bail and keep looking.
bool MIIsUnscaled = isUnscaledLdst(MI->getOpcode()); bool MIIsUnscaled = isUnscaledLdSt(MI);
if (!inBoundsForPair(MIIsUnscaled, MinOffset, OffsetStride)) { if (!inBoundsForPair(MIIsUnscaled, MinOffset, OffsetStride)) {
trackRegDefsUses(MI, ModifiedRegs, UsedRegs, TRI); trackRegDefsUses(MI, ModifiedRegs, UsedRegs, TRI);
if (MI->mayLoadOrStore()) if (MI->mayLoadOrStore())
@ -995,7 +996,7 @@ bool AArch64LoadStoreOpt::optimizeBlock(MachineBasicBlock &MBB) {
Modified = true; Modified = true;
++NumPairCreated; ++NumPairCreated;
if (isUnscaledLdst(MI->getOpcode())) if (isUnscaledLdSt(MI))
++NumUnscaledPairCreated; ++NumUnscaledPairCreated;
break; break;
} }
@ -1055,7 +1056,7 @@ bool AArch64LoadStoreOpt::optimizeBlock(MachineBasicBlock &MBB) {
} }
// Don't know how to handle pre/post-index versions, so move to the next // Don't know how to handle pre/post-index versions, so move to the next
// instruction. // instruction.
if (isUnscaledLdst(Opc)) { if (isUnscaledLdSt(Opc)) {
++MBBI; ++MBBI;
break; break;
} }