summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
diff options
context:
space:
mode:
authorDjordje Todorovic <djordje.todorovic@rt-rk.com>2019-11-08 11:19:58 +0100
committerDjordje Todorovic <djordje.todorovic@rt-rk.com>2019-11-08 13:00:39 +0100
commit8d2ccd1ac32ca5c96fc17e265fec5e1fc94a0520 (patch)
tree47d5d4208f93b04b62dbcb6113764d68b1a033ac /llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
parent5a1bac4d1daee2bcbf13365a8254a26d242d8c46 (diff)
downloadbcm5719-llvm-8d2ccd1ac32ca5c96fc17e265fec5e1fc94a0520.tar.gz
bcm5719-llvm-8d2ccd1ac32ca5c96fc17e265fec5e1fc94a0520.zip
Reland: [TII] Use optional destination and source pair as a return value; NFC
Refactor usage of isCopyInstrImpl, isCopyInstr and isAddImmediate methods to return optional machine operand pair of destination and source registers. Patch by Nikola Prica Differential Revision: https://reviews.llvm.org/D69622
Diffstat (limited to 'llvm/lib/Target/AArch64/AArch64InstrInfo.cpp')
-rw-r--r--llvm/lib/Target/AArch64/AArch64InstrInfo.cpp30
1 files changed, 11 insertions, 19 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
index 96a58cea77c..3cd20794f61 100644
--- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
+++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
@@ -5702,39 +5702,33 @@ bool AArch64InstrInfo::shouldOutlineFromFunctionByDefault(
return MF.getFunction().hasMinSize();
}
-bool AArch64InstrInfo::isCopyInstrImpl(
- const MachineInstr &MI, const MachineOperand *&Source,
- const MachineOperand *&Destination) const {
+Optional<DestSourcePair>
+AArch64InstrInfo::isCopyInstrImpl(const MachineInstr &MI) const {
// AArch64::ORRWrs and AArch64::ORRXrs with WZR/XZR reg
// and zero immediate operands used as an alias for mov instruction.
if (MI.getOpcode() == AArch64::ORRWrs &&
MI.getOperand(1).getReg() == AArch64::WZR &&
MI.getOperand(3).getImm() == 0x0) {
- Destination = &MI.getOperand(0);
- Source = &MI.getOperand(2);
- return true;
+ return DestSourcePair{MI.getOperand(0), MI.getOperand(2)};
}
if (MI.getOpcode() == AArch64::ORRXrs &&
MI.getOperand(1).getReg() == AArch64::XZR &&
MI.getOperand(3).getImm() == 0x0) {
- Destination = &MI.getOperand(0);
- Source = &MI.getOperand(2);
- return true;
+ return DestSourcePair{MI.getOperand(0), MI.getOperand(2)};
}
- return false;
+ return None;
}
-bool AArch64InstrInfo::isAddImmediate(const MachineInstr &MI,
- const MachineOperand *&Destination,
- const MachineOperand *&Source,
- int64_t &Offset) const {
+Optional<DestSourcePair>
+AArch64InstrInfo::isAddImmediate(const MachineInstr &MI,
+ int64_t &Offset) const {
int Sign = 1;
switch (MI.getOpcode()) {
default:
- return false;
+ return None;
case AArch64::SUBWri:
case AArch64::SUBXri:
case AArch64::SUBSWri:
@@ -5748,16 +5742,14 @@ bool AArch64InstrInfo::isAddImmediate(const MachineInstr &MI,
// TODO: Third operand can be global address (usually some string).
if (!MI.getOperand(0).isReg() || !MI.getOperand(1).isReg() ||
!MI.getOperand(2).isImm())
- return false;
- Source = &MI.getOperand(1);
+ return None;
Offset = MI.getOperand(2).getImm() * Sign;
int Shift = MI.getOperand(3).getImm();
assert((Shift == 0 || Shift == 12) && "Shift can be either 0 or 12");
Offset = Offset << Shift;
}
}
- Destination = &MI.getOperand(0);
- return true;
+ return DestSourcePair{MI.getOperand(0), MI.getOperand(1)};
}
Optional<ParamLoadedValue>
OpenPOWER on IntegriCloud