diff options
| author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2017-07-10 18:38:52 +0000 |
|---|---|---|
| committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2017-07-10 18:38:52 +0000 |
| commit | df4a05d6fb1b205a82916a32b1c8f4d55ad53c5d (patch) | |
| tree | cba3039c8c1cb4e8d9b2ebbd5ebbc2f0d566d26e | |
| parent | b03c2b4b0984ce2ea131fb1f06aae6938222498f (diff) | |
| download | bcm5719-llvm-df4a05d6fb1b205a82916a32b1c8f4d55ad53c5d.tar.gz bcm5719-llvm-df4a05d6fb1b205a82916a32b1c8f4d55ad53c5d.zip | |
[Hexagon] Fix check for HMOTF_ConstExtend operand flag
This fixes https://llvm.org/PR33718.
llvm-svn: 307566
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp | 11 | ||||
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp | 10 | ||||
| -rw-r--r-- | llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp | 12 | ||||
| -rw-r--r-- | llvm/test/CodeGen/Hexagon/target-flag-ext.mir | 24 |
4 files changed, 38 insertions, 19 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp index da4e5fbb8c0..ff99a104739 100644 --- a/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp +++ b/llvm/lib/Target/Hexagon/HexagonInstrInfo.cpp @@ -1830,7 +1830,7 @@ bool HexagonInstrInfo::isConstExtended(const MachineInstr &MI) const { const MachineOperand &MO = MI.getOperand(ExtOpNum); // Use MO operand flags to determine if MO // has the HMOTF_ConstExtended flag set. - if (MO.getTargetFlags() && HexagonII::HMOTF_ConstExtended) + if (MO.getTargetFlags() & HexagonII::HMOTF_ConstExtended) return true; // If this is a Machine BB address we are talking about, and it is // not marked as extended, say so. @@ -1840,9 +1840,6 @@ bool HexagonInstrInfo::isConstExtended(const MachineInstr &MI) const { // We could be using an instruction with an extendable immediate and shoehorn // a global address into it. If it is a global address it will be constant // extended. We do this for COMBINE. - // We currently only handle isGlobal() because it is the only kind of - // object we are going to end up with here for now. - // In the future we probably should add isSymbol(), etc. if (MO.isGlobal() || MO.isSymbol() || MO.isBlockAddress() || MO.isJTI() || MO.isCPI() || MO.isFPImm()) return true; @@ -1994,11 +1991,9 @@ bool HexagonInstrInfo::isExtended(const MachineInstr &MI) const { return true; // Use MO operand flags to determine if one of MI's operands // has HMOTF_ConstExtended flag set. - for (MachineInstr::const_mop_iterator I = MI.operands_begin(), - E = MI.operands_end(); I != E; ++I) { - if (I->getTargetFlags() && HexagonII::HMOTF_ConstExtended) + for (const MachineOperand &MO : MI.operands()) + if (MO.getTargetFlags() & HexagonII::HMOTF_ConstExtended) return true; - } return false; } diff --git a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp index 76d9b31b005..7d88b51f32d 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp @@ -110,10 +110,11 @@ SchedCustomRegistry("hexagon", "Run Hexagon's custom scheduler", namespace llvm { extern char &HexagonExpandCondsetsID; void initializeHexagonExpandCondsetsPass(PassRegistry&); - void initializeHexagonLoopIdiomRecognizePass(PassRegistry&); void initializeHexagonGenMuxPass(PassRegistry&); - void initializeHexagonOptAddrModePass(PassRegistry&); + void initializeHexagonLoopIdiomRecognizePass(PassRegistry&); void initializeHexagonNewValueJumpPass(PassRegistry&); + void initializeHexagonOptAddrModePass(PassRegistry&); + void initializeHexagonPacketizerPass(PassRegistry&); Pass *createHexagonLoopIdiomPass(); FunctionPass *createHexagonBitSimplify(); @@ -156,10 +157,11 @@ extern "C" void LLVMInitializeHexagonTarget() { RegisterTargetMachine<HexagonTargetMachine> X(getTheHexagonTarget()); PassRegistry &PR = *PassRegistry::getPassRegistry(); - initializeHexagonLoopIdiomRecognizePass(PR); initializeHexagonGenMuxPass(PR); - initializeHexagonOptAddrModePass(PR); + initializeHexagonLoopIdiomRecognizePass(PR); initializeHexagonNewValueJumpPass(PR); + initializeHexagonOptAddrModePass(PR); + initializeHexagonPacketizerPass(PR); } HexagonTargetMachine::HexagonTargetMachine(const Target &T, const Triple &TT, diff --git a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp index 7667bfb7a0e..a3021e3dfe4 100644 --- a/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp +++ b/llvm/lib/Target/Hexagon/HexagonVLIWPacketizer.cpp @@ -60,9 +60,7 @@ namespace { class HexagonPacketizer : public MachineFunctionPass { public: static char ID; - HexagonPacketizer() : MachineFunctionPass(ID) { - initializeHexagonPacketizerPass(*PassRegistry::getPassRegistry()); - } + HexagonPacketizer() : MachineFunctionPass(ID) {} void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); @@ -89,14 +87,14 @@ namespace { char HexagonPacketizer::ID = 0; } -INITIALIZE_PASS_BEGIN(HexagonPacketizer, "packets", "Hexagon Packetizer", - false, false) +INITIALIZE_PASS_BEGIN(HexagonPacketizer, "hexagon-packetizer", + "Hexagon Packetizer", false, false) INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree) INITIALIZE_PASS_DEPENDENCY(MachineBranchProbabilityInfo) INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo) INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) -INITIALIZE_PASS_END(HexagonPacketizer, "packets", "Hexagon Packetizer", - false, false) +INITIALIZE_PASS_END(HexagonPacketizer, "hexagon-packetizer", + "Hexagon Packetizer", false, false) HexagonPacketizerList::HexagonPacketizerList(MachineFunction &MF, MachineLoopInfo &MLI, AliasAnalysis *AA, diff --git a/llvm/test/CodeGen/Hexagon/target-flag-ext.mir b/llvm/test/CodeGen/Hexagon/target-flag-ext.mir new file mode 100644 index 00000000000..49e0d2870e0 --- /dev/null +++ b/llvm/test/CodeGen/Hexagon/target-flag-ext.mir @@ -0,0 +1,24 @@ +# RUN: llc -march=hexagon -run-pass hexagon-packetizer -o - %s | FileCheck %s +--- +name: fred +tracksRegLiveness: true + +body: | + bb.0: + ; Check that all these instructions go in the same packet. This is to + ; make sure that a target flag (other than HMOTF_ConstExtend) on an + ; operand will not be interpreted as a constant-extender flag. + ; The combination used below (pcrel + 0) does not technically make sense, + ; but combinations that do make sense require constant extending, so + ; testing this is not possible otherwise. + + ; CHECK: BUNDLE + ; CHECK-DAG: %r0 = A2_tfrsi + ; CHECK-DAG: %r1 = A2_tfrsi + ; CHECK-DAG: %r2 = A2_tfrsi + ; CHECK: } + %r0 = A2_tfrsi target-flags (hexagon-pcrel) 0 + %r1 = A2_tfrsi target-flags (hexagon-pcrel) 0 + %r2 = A2_tfrsi target-flags (hexagon-pcrel) 0 +... + |

