OpenASIP 2.2
Loading...
Searching...
No Matches
VirtRegIndependenceGraph.hh
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2010 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file VirtRegIndependenceGraph.hh
26 *
27 * Declaration of VirtRegIndependence class.
28 *
29 * @author Pekka Jääskeläinen 2010
30 * @note rating: red
31 */
32
33#ifndef TCE_VIRT_REG_IND_GRAPH_HH
34#define TCE_VIRT_REG_IND_GRAPH_HH
35
36#include <set>
37
38#include "hash_set.hh"
39#include "boost/graph/adjacency_list.hpp"
40#include "MachineInstrDDG.hh"
41
42namespace llvm {
43 class LiveInterval;
44 class MachineFunction;
45 class VirtRegMap;
46}
47
48/**
49 * Virtual register independence graph AKA False Dependence Prevention
50 * Graph (FDPG).
51 *
52 * Nodes in the graph are virtual registers. They have edges between if the
53 * live ranges could be scheduled in parallel or reordered if there were no
54 * false dependencies. In other words, two virtual registers / live ranges /
55 * variables are considered independent in case they do not have real
56 * data dependencies between them.
57 *
58 * @todo This approach has at least the following unsolved problems:
59 *
60 * - The data is not updated during the register allocation. In case
61 * a register needed to be shared and an false dep was added, the
62 * independence graph does not reflect this new dependence. This results
63 * in too greedy assignments because register sharing might not hurt
64 * after one register sharing has added a new antidependence. The DDG height
65 * delta-based allocator helped for this.
66 *
67 * - Actual schedulability is not taken in account. Even in case the nodes
68 * were independent, they could have min cycles such that it forces the
69 * ordering anyways. For example, a branch in DDG with node N1
70 * of height 4 and another independent branch with node N2 with height 2.
71 * N1 cannot be scheduled above N2 anyhow, regardless if there was an
72 * extra N2->N1 edge or not due to the register sharing. Currently the FDPG
73 * method blindly avoids sharing the reg between N2 and N1, thus increasing
74 * the register pressure for no benefit.
75 *
76 * - Memory dependencies are not taken in account. This results in a too
77 * free DDG thus too many falsely independent live ranges, ending with a too
78 * greedy allocation.
79 */
81public:
82 VirtRegIndependenceGraph(llvm::MachineFunction& mf, llvm::VirtRegMap& vrm);
83
85 llvm::LiveInterval* interval,
87
89 void addEdge(
92
93 std::set<MachineInstrDDG::Register> adjacentNodes(
95
96private:
97 typedef boost::adjacency_list<
98 boost::vecS, boost::vecS, boost::undirectedS,
99 boost::property<boost::vertex_name_t, MachineInstrDDG::Register> > FDPG;
100
101 // VRM used to track phys to virt reg assignments during the register alloc
102 llvm::VirtRegMap& vrm_;
103
105
106 std::map<MachineInstrDDG::Register, FDPG::vertex_descriptor> vertexMap_;
107 std::map<FDPG::vertex_descriptor, MachineInstrDDG::Register> vregMap_;
108};
109
110#endif
111
void addEdge(MachineInstrDDG::Register nodeA, MachineInstrDDG::Register nodeB)
int newFalseDepsFromAssign(llvm::LiveInterval *interval, MachineInstrDDG::Register physReg)
boost::adjacency_list< boost::vecS, boost::vecS, boost::undirectedS, boost::property< boost::vertex_name_t, MachineInstrDDG::Register > > FDPG
void addNode(MachineInstrDDG::Register virtReg)
std::map< MachineInstrDDG::Register, FDPG::vertex_descriptor > vertexMap_
std::set< MachineInstrDDG::Register > adjacentNodes(MachineInstrDDG::Register node)
std::map< FDPG::vertex_descriptor, MachineInstrDDG::Register > vregMap_