summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Hexagon/HexagonRDF.cpp
diff options
context:
space:
mode:
authorKrzysztof Parzyszek <kparzysz@codeaurora.org>2016-01-12 19:09:01 +0000
committerKrzysztof Parzyszek <kparzysz@codeaurora.org>2016-01-12 19:09:01 +0000
commit1279881315fbce28e3aacc40a3d19dd8be6cf927 (patch)
treecb53449b53bc3bd8f92e7aa034b5b9cfa0d9eb30 /llvm/lib/Target/Hexagon/HexagonRDF.cpp
parent53ba88dbb042132bbaf7e5ca6ccc2d5051272581 (diff)
downloadbcm5719-llvm-1279881315fbce28e3aacc40a3d19dd8be6cf927.tar.gz
bcm5719-llvm-1279881315fbce28e3aacc40a3d19dd8be6cf927.zip
[Hexagon] Implement RDF-based post-RA optimizations
- Handle simple cases of register copies (what current RDF CP allows). - Hexagon-specific dead code elimination: handles dead address updates in post-increment instructions. llvm-svn: 257504
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonRDF.cpp')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonRDF.cpp60
1 files changed, 60 insertions, 0 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonRDF.cpp b/llvm/lib/Target/Hexagon/HexagonRDF.cpp
new file mode 100644
index 00000000000..06719cddf4b
--- /dev/null
+++ b/llvm/lib/Target/Hexagon/HexagonRDF.cpp
@@ -0,0 +1,60 @@
+//===--- HexagonRDF.cpp ---------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "HexagonRDF.h"
+#include "HexagonInstrInfo.h"
+#include "HexagonRegisterInfo.h"
+
+#include "llvm/CodeGen/MachineInstr.h"
+
+using namespace llvm;
+using namespace rdf;
+
+bool HexagonRegisterAliasInfo::covers(RegisterRef RA, RegisterRef RB) const {
+ if (RA == RB)
+ return true;
+
+ if (TargetRegisterInfo::isVirtualRegister(RA.Reg) &&
+ TargetRegisterInfo::isVirtualRegister(RB.Reg)) {
+ // Hexagon-specific cases.
+ if (RA.Reg == RB.Reg) {
+ if (RA.Sub == 0)
+ return true;
+ if (RB.Sub == 0)
+ return false;
+ }
+ }
+
+ return RegisterAliasInfo::covers(RA, RB);
+}
+
+bool HexagonRegisterAliasInfo::covers(const RegisterSet &RRs, RegisterRef RR)
+ const {
+ if (RRs.count(RR))
+ return true;
+
+ if (!TargetRegisterInfo::isPhysicalRegister(RR.Reg)) {
+ assert(TargetRegisterInfo::isVirtualRegister(RR.Reg));
+ // Check if both covering subregisters are present.
+ bool HasLo = RRs.count({RR.Reg, Hexagon::subreg_loreg});
+ bool HasHi = RRs.count({RR.Reg, Hexagon::subreg_hireg});
+ if (HasLo && HasHi)
+ return true;
+ }
+
+ if (RR.Sub == 0) {
+ // Check if both covering subregisters are present.
+ unsigned Lo = TRI.getSubReg(RR.Reg, Hexagon::subreg_loreg);
+ unsigned Hi = TRI.getSubReg(RR.Reg, Hexagon::subreg_hireg);
+ if (RRs.count({Lo, 0}) && RRs.count({Hi, 0}))
+ return true;
+ }
+
+ return RegisterAliasInfo::covers(RRs, RR);
+}
OpenPOWER on IntegriCloud