diff options
| author | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-11-28 12:00:20 +0000 |
|---|---|---|
| committer | Francis Visoiu Mistrih <francisvm@yahoo.com> | 2018-11-28 12:00:20 +0000 |
| commit | d7eebd6d831fa80c3840f10120c235db65f650da (patch) | |
| tree | 367e04b77cabbb887e7e18a20c86dc0f6245af2b /llvm/lib/Target/Hexagon | |
| parent | dda6290f16075795a5700c29d1b990fff8e1261b (diff) | |
| download | bcm5719-llvm-d7eebd6d831fa80c3840f10120c235db65f650da.tar.gz bcm5719-llvm-d7eebd6d831fa80c3840f10120c235db65f650da.zip | |
[CodeGen][NFC] Make `TII::getMemOpBaseImmOfs` return a base operand
Currently, instructions doing memory accesses through a base operand that is
not a register can not be analyzed using `TII::getMemOpBaseRegImmOfs`.
This means that functions such as `TII::shouldClusterMemOps` will bail
out on instructions using an FI as a base instead of a register.
The goal of this patch is to refactor all this to return a base
operand instead of a base register.
Then in a separate patch, I will add FI support to the mem op clustering
in the MachineScheduler.
Differential Revision: https://reviews.llvm.org/D54846
llvm-svn: 347746
Diffstat (limited to 'llvm/lib/Target/Hexagon')
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 34 | ||||
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonInstrInfo.h | 10 | ||||
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonSubtarget.cpp | 13 |
3 files changed, 30 insertions, 27 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp index a3c160d01f8..ff3865b831a 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -2894,14 +2894,15 @@ bool HexagonInstrInfo::addLatencyToSchedule(const MachineInstr &MI1, } /// Get the base register and byte offset of a load/store instr. -bool HexagonInstrInfo::getMemOpBaseRegImmOfs(MachineInstr &LdSt, - unsigned &BaseReg, int64_t &Offset, const TargetRegisterInfo *TRI) - const { +bool HexagonInstrInfo::getMemOperandWithOffset( + MachineInstr &LdSt, MachineOperand *&BaseOp, int64_t &Offset, + const TargetRegisterInfo *TRI) const { unsigned AccessSize = 0; - int OffsetVal = 0; - BaseReg = getBaseAndOffset(LdSt, OffsetVal, AccessSize); - Offset = OffsetVal; - return BaseReg != 0; + BaseOp = getBaseAndOffset(LdSt, Offset, AccessSize); + assert(!BaseOp || BaseOp->isReg() && + "getMemOperandWithOffset only supports base " + "operands of type register."); + return BaseOp != nullptr; } /// Can these instructions execute at the same time in a bundle. @@ -3108,21 +3109,22 @@ unsigned HexagonInstrInfo::getAddrMode(const MachineInstr &MI) const { // Returns the base register in a memory access (load/store). The offset is // returned in Offset and the access size is returned in AccessSize. -// If the base register has a subregister or the offset field does not contain -// an immediate value, return 0. -unsigned HexagonInstrInfo::getBaseAndOffset(const MachineInstr &MI, - int &Offset, unsigned &AccessSize) const { +// If the base operand has a subregister or the offset field does not contain +// an immediate value, return nullptr. +MachineOperand *HexagonInstrInfo::getBaseAndOffset(const MachineInstr &MI, + int64_t &Offset, + unsigned &AccessSize) const { // Return if it is not a base+offset type instruction or a MemOp. if (getAddrMode(MI) != HexagonII::BaseImmOffset && getAddrMode(MI) != HexagonII::BaseLongOffset && !isMemOp(MI) && !isPostIncrement(MI)) - return 0; + return nullptr; AccessSize = getMemAccessSize(MI); unsigned BasePos = 0, OffsetPos = 0; if (!getBaseAndOffsetPosition(MI, BasePos, OffsetPos)) - return 0; + return nullptr; // Post increment updates its EA after the mem access, // so we need to treat its offset as zero. @@ -3131,14 +3133,14 @@ unsigned HexagonInstrInfo::getBaseAndOffset(const MachineInstr &MI, } else { const MachineOperand &OffsetOp = MI.getOperand(OffsetPos); if (!OffsetOp.isImm()) - return 0; + return nullptr; Offset = OffsetOp.getImm(); } const MachineOperand &BaseOp = MI.getOperand(BasePos); if (BaseOp.getSubReg() != 0) - return 0; - return BaseOp.getReg(); + return nullptr; + return &const_cast<MachineOperand&>(BaseOp); } /// Return the position of the base and offset operands for this instruction. diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h index fe4a2f3662e..9b840762e88 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.h +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.h @@ -216,9 +216,9 @@ public: bool expandPostRAPseudo(MachineInstr &MI) const override; /// Get the base register and byte offset of a load/store instr. - bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, - int64_t &Offset, - const TargetRegisterInfo *TRI) const override; + bool getMemOperandWithOffset(MachineInstr &LdSt, MachineOperand *&BaseOp, + int64_t &Offset, + const TargetRegisterInfo *TRI) const override; /// Reverses the branch condition of the specified condition list, /// returning false on success and true if it cannot be reversed. @@ -436,8 +436,8 @@ public: bool predOpcodeHasNot(ArrayRef<MachineOperand> Cond) const; unsigned getAddrMode(const MachineInstr &MI) const; - unsigned getBaseAndOffset(const MachineInstr &MI, int &Offset, - unsigned &AccessSize) const; + MachineOperand *getBaseAndOffset(const MachineInstr &MI, int64_t &Offset, + unsigned &AccessSize) const; SmallVector<MachineInstr*,2> getBranchingInstrs(MachineBasicBlock& MBB) const; unsigned getCExtOpNum(const MachineInstr &MI) const; HexagonII::CompoundGroup diff --git a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp index 68e276be0f6..88f63dedd8d 100644 --- a/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp +++ b/llvm/lib/Target/Hexagon/HexagonSubtarget.cpp @@ -275,11 +275,11 @@ void HexagonSubtarget::BankConflictMutation::apply(ScheduleDAGInstrs *DAG) { if (!L0.mayLoad() || L0.mayStore() || HII.getAddrMode(L0) != HexagonII::BaseImmOffset) continue; - int Offset0; + int64_t Offset0; unsigned Size0; - unsigned Base0 = HII.getBaseAndOffset(L0, Offset0, Size0); + MachineOperand *BaseOp0 = HII.getBaseAndOffset(L0, Offset0, Size0); // Is the access size is longer than the L1 cache line, skip the check. - if (Base0 == 0 || Size0 >= 32) + if (BaseOp0 == nullptr || !BaseOp0->isReg() || Size0 >= 32) continue; // Scan only up to 32 instructions ahead (to avoid n^2 complexity). for (unsigned j = i+1, m = std::min(i+32, e); j != m; ++j) { @@ -288,10 +288,11 @@ void HexagonSubtarget::BankConflictMutation::apply(ScheduleDAGInstrs *DAG) { if (!L1.mayLoad() || L1.mayStore() || HII.getAddrMode(L1) != HexagonII::BaseImmOffset) continue; - int Offset1; + int64_t Offset1; unsigned Size1; - unsigned Base1 = HII.getBaseAndOffset(L1, Offset1, Size1); - if (Base1 == 0 || Size1 >= 32 || Base0 != Base1) + MachineOperand *BaseOp1 = HII.getBaseAndOffset(L1, Offset1, Size1); + if (BaseOp1 == nullptr || !BaseOp1->isReg() || Size1 >= 32 || + BaseOp0->getReg() != BaseOp1->getReg()) continue; // Check bits 3 and 4 of the offset: if they differ, a bank conflict // is unlikely. |

