blob: ec4823da61f4e82354f76cc258c0cc480d27cfdb [file] [log] [blame]
Krzysztof Parzyszek12798812016-01-12 19:09:01 +00001//===--- 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
16using namespace llvm;
17using namespace rdf;
18
Krzysztof Parzyszek29e93f32016-09-22 21:01:24 +000019bool HexagonRegisterAliasInfo::covers(RegisterRef RA, RegisterRef RB,
20 const DataFlowGraph &DFG) const {
Krzysztof Parzyszek12798812016-01-12 19:09:01 +000021 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 Parzyszek29e93f32016-09-22 21:01:24 +000035 return RegisterAliasInfo::covers(RA, RB, DFG);
Krzysztof Parzyszek12798812016-01-12 19:09:01 +000036}
37
Krzysztof Parzyszek29e93f32016-09-22 21:01:24 +000038bool HexagonRegisterAliasInfo::covers(const RegisterSet &RRs, RegisterRef RR,
39 const DataFlowGraph &DFG) const {
Krzysztof Parzyszek12798812016-01-12 19:09:01 +000040 if (RRs.count(RR))
41 return true;
42
Krzysztof Parzyszek29e93f32016-09-22 21:01:24 +000043 // 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 Parzyszek12798812016-01-12 19:09:01 +000048 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 Parzyszek29e93f32016-09-22 21:01:24 +000054 if (TargetRegisterInfo::isPhysicalRegister(RR.Reg)) {
55 // Check if both covering subregisters are present with full
56 // lane masks.
Krzysztof Parzyszek12798812016-01-12 19:09:01 +000057 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 Parzyszek29e93f32016-09-22 21:01:24 +000063 return RegisterAliasInfo::covers(RRs, RR, DFG);
Krzysztof Parzyszek12798812016-01-12 19:09:01 +000064}