diff options
author | Djordje Todorovic <djordje.todorovic@rt-rk.com> | 2019-10-31 14:48:32 +0100 |
---|---|---|
committer | Djordje Todorovic <djordje.todorovic@rt-rk.com> | 2019-10-31 15:34:49 +0100 |
commit | 57ee0435bd47f23f3939f402914c231b4f65ca5e (patch) | |
tree | b1a09511e8ebf15450eefbe30f85f6f2123a7abf /llvm/lib/Target/AArch64 | |
parent | 55314d323738e4a8c1890b6a6e5064e7f4e0da1c (diff) | |
download | bcm5719-llvm-57ee0435bd47f23f3939f402914c231b4f65ca5e.tar.gz bcm5719-llvm-57ee0435bd47f23f3939f402914c231b4f65ca5e.zip |
[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')
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.cpp | 30 | ||||
-rw-r--r-- | llvm/lib/Target/AArch64/AArch64InstrInfo.h | 16 |
2 files changed, 18 insertions, 28 deletions
diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp index d6578e3f4f9..c627ad4004b 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.cpp @@ -5936,39 +5936,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: @@ -5982,16 +5976,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> diff --git a/llvm/lib/Target/AArch64/AArch64InstrInfo.h b/llvm/lib/Target/AArch64/AArch64InstrInfo.h index ece79167468..11d2d7d74a2 100644 --- a/llvm/lib/Target/AArch64/AArch64InstrInfo.h +++ b/llvm/lib/Target/AArch64/AArch64InstrInfo.h @@ -265,10 +265,8 @@ public: /// on Windows. static bool isSEHInstruction(const MachineInstr &MI); - bool isAddImmediate(const MachineInstr &MI, - const MachineOperand *&Destination, - const MachineOperand *&Source, - int64_t &Offset) const override; + Optional<DestSourcePair> isAddImmediate(const MachineInstr &MI, + int64_t &Offset) const override; Optional<ParamLoadedValue> describeLoadedValue(const MachineInstr &MI) const override; @@ -277,11 +275,11 @@ public: #include "AArch64GenInstrInfo.inc" protected: - /// If the specific machine instruction is a instruction that moves/copies - /// value from one register to another register return true along with - /// @Source machine operand and @Destination machine operand. - bool isCopyInstrImpl(const MachineInstr &MI, const MachineOperand *&Source, - const MachineOperand *&Destination) const override; + /// If the specific machine instruction is an instruction that moves/copies + /// value from one register to another register return destination and source + /// registers as machine operands. + Optional<DestSourcePair> + isCopyInstrImpl(const MachineInstr &MI) const override; private: /// Sets the offsets on outlined instructions in \p MBB which use SP |