summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp
diff options
context:
space:
mode:
authorEugene Zelenko <eugene.zelenko@gmail.com>2016-12-17 01:09:05 +0000
committerEugene Zelenko <eugene.zelenko@gmail.com>2016-12-17 01:09:05 +0000
commit58655bbc607c3eb1fedad52a254753a37351ce89 (patch)
treea0f9b6fb1408e98308051d6372d9537b7c0dd70c /llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp
parentaa0fd76be30cd18068345228c26f551ea3fbe093 (diff)
downloadbcm5719-llvm-58655bbc607c3eb1fedad52a254753a37351ce89.tar.gz
bcm5719-llvm-58655bbc607c3eb1fedad52a254753a37351ce89.zip
[Hexagon] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
llvm-svn: 290024
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp66
1 files changed, 29 insertions, 37 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp b/llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp
index b0bd09dc944..af1bf48b632 100644
--- a/llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonStoreWidening.cpp
@@ -23,33 +23,45 @@
#define DEBUG_TYPE "hexagon-widen-stores"
-#include "HexagonTargetMachine.h"
-
-#include "llvm/PassSupport.h"
+#include "HexagonInstrInfo.h"
+#include "HexagonRegisterInfo.h"
+#include "HexagonSubtarget.h"
+#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Analysis/AliasAnalysis.h"
-#include "llvm/CodeGen/Passes.h"
+#include "llvm/Analysis/MemoryLocation.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineMemOperand.h"
+#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
+#include "llvm/IR/DebugLoc.h"
#include "llvm/MC/MCInstrDesc.h"
+#include "llvm/Pass.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
+#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Target/TargetRegisterInfo.h"
-#include "llvm/Target/TargetInstrInfo.h"
-
#include <algorithm>
-
+#include <cassert>
+#include <cstdint>
+#include <iterator>
+#include <vector>
using namespace llvm;
namespace llvm {
+
FunctionPass *createHexagonStoreWidening();
void initializeHexagonStoreWideningPass(PassRegistry&);
-}
+
+} // end namespace llvm
namespace {
+
struct HexagonStoreWidening : public MachineFunctionPass {
const HexagonInstrInfo *TII;
const HexagonRegisterInfo *TRI;
@@ -59,6 +71,7 @@ namespace {
public:
static char ID;
+
HexagonStoreWidening() : MachineFunctionPass(ID) {
initializeHexagonStoreWideningPass(*PassRegistry::getPassRegistry());
}
@@ -96,19 +109,18 @@ namespace {
bool storesAreAdjacent(const MachineInstr *S1, const MachineInstr *S2);
};
-} // namespace
-
+char HexagonStoreWidening::ID = 0;
-namespace {
+} // end anonymous namespace
// Some local helper functions...
-unsigned getBaseAddressRegister(const MachineInstr *MI) {
+static unsigned getBaseAddressRegister(const MachineInstr *MI) {
const MachineOperand &MO = MI->getOperand(0);
assert(MO.isReg() && "Expecting register operand");
return MO.getReg();
}
-int64_t getStoreOffset(const MachineInstr *MI) {
+static int64_t getStoreOffset(const MachineInstr *MI) {
unsigned OpC = MI->getOpcode();
assert(HexagonStoreWidening::handledStoreType(MI) && "Unhandled opcode");
@@ -126,23 +138,17 @@ int64_t getStoreOffset(const MachineInstr *MI) {
return 0;
}
-const MachineMemOperand &getStoreTarget(const MachineInstr *MI) {
+static const MachineMemOperand &getStoreTarget(const MachineInstr *MI) {
assert(!MI->memoperands_empty() && "Expecting memory operands");
return **MI->memoperands_begin();
}
-} // namespace
-
-
-char HexagonStoreWidening::ID = 0;
-
INITIALIZE_PASS_BEGIN(HexagonStoreWidening, "hexagon-widen-stores",
"Hexason Store Widening", false, false)
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
INITIALIZE_PASS_END(HexagonStoreWidening, "hexagon-widen-stores",
"Hexagon Store Widening", false, false)
-
// Filtering function: any stores whose opcodes are not "approved" of by
// this function will not be subjected to widening.
inline bool HexagonStoreWidening::handledStoreType(const MachineInstr *MI) {
@@ -160,7 +166,6 @@ inline bool HexagonStoreWidening::handledStoreType(const MachineInstr *MI) {
}
}
-
// Check if the machine memory operand MMO is aliased with any of the
// stores in the store group Stores.
bool HexagonStoreWidening::instrAliased(InstrGroup &Stores,
@@ -183,7 +188,6 @@ bool HexagonStoreWidening::instrAliased(InstrGroup &Stores,
return false;
}
-
// Check if the machine instruction MI accesses any storage aliased with
// any store in the group Stores.
bool HexagonStoreWidening::instrAliased(InstrGroup &Stores,
@@ -194,7 +198,6 @@ bool HexagonStoreWidening::instrAliased(InstrGroup &Stores,
return false;
}
-
// Inspect a machine basic block, and generate store groups out of stores
// encountered in the block.
//
@@ -231,7 +234,6 @@ void HexagonStoreWidening::createStoreGroups(MachineBasicBlock &MBB,
}
}
-
// Create a single store group. The stores need to be independent between
// themselves, and also there cannot be other instructions between them
// that could read or modify storage being stored into.
@@ -261,7 +263,7 @@ void HexagonStoreWidening::createStoreGroup(MachineInstr *BaseStore,
unsigned BR = getBaseAddressRegister(MI);
if (BR == BaseReg) {
Group.push_back(MI);
- *I = 0;
+ *I = nullptr;
continue;
}
}
@@ -278,7 +280,6 @@ void HexagonStoreWidening::createStoreGroup(MachineInstr *BaseStore,
} // for
}
-
// Check if store instructions S1 and S2 are adjacent. More precisely,
// S2 has to access memory immediately following that accessed by S1.
bool HexagonStoreWidening::storesAreAdjacent(const MachineInstr *S1,
@@ -296,7 +297,6 @@ bool HexagonStoreWidening::storesAreAdjacent(const MachineInstr *S1,
: int(Off1+S1MO.getSize()) == Off2;
}
-
/// Given a sequence of adjacent stores, and a maximum size of a single wide
/// store, pick a group of stores that can be replaced by a single store
/// of size not exceeding MaxSize. The selected sequence will be recorded
@@ -388,7 +388,6 @@ bool HexagonStoreWidening::selectStores(InstrGroup::iterator Begin,
return true;
}
-
/// Given an "old group" OG of stores, create a "new group" NG of instructions
/// to replace them. Ideally, NG would only have a single instruction in it,
/// but that may only be possible for store-immediate.
@@ -417,7 +416,6 @@ bool HexagonStoreWidening::createWideStores(InstrGroup &OG, InstrGroup &NG,
Shift += NBits;
}
-
MachineInstr *FirstSt = OG.front();
DebugLoc DL = OG.back()->getDebugLoc();
const MachineMemOperand &OldM = getStoreTarget(FirstSt);
@@ -469,7 +467,6 @@ bool HexagonStoreWidening::createWideStores(InstrGroup &OG, InstrGroup &NG,
return true;
}
-
// Replace instructions from the old group OG with instructions from the
// new group NG. Conceptually, remove all instructions in OG, and then
// insert all instructions in NG, starting at where the first instruction
@@ -534,7 +531,6 @@ bool HexagonStoreWidening::replaceStores(InstrGroup &OG, InstrGroup &NG) {
return true;
}
-
// Break up the group into smaller groups, each of which can be replaced by
// a single wide store. Widen each such smaller group and replace the old
// instructions with the widened ones.
@@ -564,7 +560,6 @@ bool HexagonStoreWidening::processStoreGroup(InstrGroup &Group) {
return Changed;
}
-
// Process a single basic block: create the store groups, and replace them
// with the widened stores, if possible. Processing of each basic block
// is independent from processing of any other basic block. This transfor-
@@ -590,7 +585,6 @@ bool HexagonStoreWidening::processBasicBlock(MachineBasicBlock &MBB) {
return Changed;
}
-
bool HexagonStoreWidening::runOnMachineFunction(MachineFunction &MFn) {
if (skipFunction(*MFn.getFunction()))
return false;
@@ -610,8 +604,6 @@ bool HexagonStoreWidening::runOnMachineFunction(MachineFunction &MFn) {
return Changed;
}
-
FunctionPass *llvm::createHexagonStoreWidening() {
return new HexagonStoreWidening();
}
-
OpenPOWER on IntegriCloud