Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 1 | //===--- HexagonRDF.cpp ---------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #include "HexagonRDF.h" |
| 11 | #include "HexagonInstrInfo.h" |
| 12 | #include "HexagonRegisterInfo.h" |
| 13 | |
| 14 | #include "llvm/CodeGen/MachineInstr.h" |
| 15 | |
| 16 | using namespace llvm; |
| 17 | using namespace rdf; |
| 18 | |
Krzysztof Parzyszek | 29e93f3 | 2016-09-22 21:01:24 +0000 | [diff] [blame^] | 19 | bool HexagonRegisterAliasInfo::covers(RegisterRef RA, RegisterRef RB, |
| 20 | const DataFlowGraph &DFG) const { |
Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 21 | if (RA == RB) |
| 22 | return true; |
| 23 | |
| 24 | if (TargetRegisterInfo::isVirtualRegister(RA.Reg) && |
| 25 | TargetRegisterInfo::isVirtualRegister(RB.Reg)) { |
| 26 | // Hexagon-specific cases. |
| 27 | if (RA.Reg == RB.Reg) { |
| 28 | if (RA.Sub == 0) |
| 29 | return true; |
| 30 | if (RB.Sub == 0) |
| 31 | return false; |
| 32 | } |
| 33 | } |
| 34 | |
Krzysztof Parzyszek | 29e93f3 | 2016-09-22 21:01:24 +0000 | [diff] [blame^] | 35 | return RegisterAliasInfo::covers(RA, RB, DFG); |
Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 36 | } |
| 37 | |
Krzysztof Parzyszek | 29e93f3 | 2016-09-22 21:01:24 +0000 | [diff] [blame^] | 38 | bool HexagonRegisterAliasInfo::covers(const RegisterSet &RRs, RegisterRef RR, |
| 39 | const DataFlowGraph &DFG) const { |
Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 40 | if (RRs.count(RR)) |
| 41 | return true; |
| 42 | |
Krzysztof Parzyszek | 29e93f3 | 2016-09-22 21:01:24 +0000 | [diff] [blame^] | 43 | // The exact reference RR is not in the set. |
| 44 | |
| 45 | if (TargetRegisterInfo::isVirtualRegister(RR.Reg)) { |
| 46 | // Check if the there are references in RRs of the same register, |
| 47 | // with both covering subregisters. |
Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 48 | bool HasLo = RRs.count({RR.Reg, Hexagon::subreg_loreg}); |
| 49 | bool HasHi = RRs.count({RR.Reg, Hexagon::subreg_hireg}); |
| 50 | if (HasLo && HasHi) |
| 51 | return true; |
| 52 | } |
| 53 | |
Krzysztof Parzyszek | 29e93f3 | 2016-09-22 21:01:24 +0000 | [diff] [blame^] | 54 | if (TargetRegisterInfo::isPhysicalRegister(RR.Reg)) { |
| 55 | // Check if both covering subregisters are present with full |
| 56 | // lane masks. |
Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 57 | unsigned Lo = TRI.getSubReg(RR.Reg, Hexagon::subreg_loreg); |
| 58 | unsigned Hi = TRI.getSubReg(RR.Reg, Hexagon::subreg_hireg); |
| 59 | if (RRs.count({Lo, 0}) && RRs.count({Hi, 0})) |
| 60 | return true; |
| 61 | } |
| 62 | |
Krzysztof Parzyszek | 29e93f3 | 2016-09-22 21:01:24 +0000 | [diff] [blame^] | 63 | return RegisterAliasInfo::covers(RRs, RR, DFG); |
Krzysztof Parzyszek | 1279881 | 2016-01-12 19:09:01 +0000 | [diff] [blame] | 64 | } |