mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Code refactoring, no functionality changes.
llvm-svn: 105775
This commit is contained in:
parent
3635f03b88
commit
bcd10b9321
@ -128,33 +128,19 @@ static void AddFlags(SDNode *N, SDValue Flag, bool AddFlag,
|
||||
/// offsets are not far apart (target specific), it add MVT::Flag inputs and
|
||||
/// outputs to ensure they are scheduled together and in order. This
|
||||
/// optimization may benefit some targets by improving cache locality.
|
||||
void ScheduleDAGSDNodes::ClusterNeighboringLoads() {
|
||||
SmallPtrSet<SDNode*, 16> Visited;
|
||||
SmallVector<int64_t, 4> Offsets;
|
||||
DenseMap<long long, SDNode*> O2SMap; // Map from offset to SDNode.
|
||||
for (SelectionDAG::allnodes_iterator NI = DAG->allnodes_begin(),
|
||||
E = DAG->allnodes_end(); NI != E; ++NI) {
|
||||
SDNode *Node = &*NI;
|
||||
if (!Node || !Node->isMachineOpcode())
|
||||
continue;
|
||||
|
||||
unsigned Opc = Node->getMachineOpcode();
|
||||
const TargetInstrDesc &TID = TII->get(Opc);
|
||||
if (!TID.mayLoad())
|
||||
continue;
|
||||
|
||||
void ScheduleDAGSDNodes::ClusterNeighboringLoads(SDNode *Node) {
|
||||
SDNode *Chain = 0;
|
||||
unsigned NumOps = Node->getNumOperands();
|
||||
if (Node->getOperand(NumOps-1).getValueType() == MVT::Other)
|
||||
Chain = Node->getOperand(NumOps-1).getNode();
|
||||
if (!Chain)
|
||||
continue;
|
||||
return;
|
||||
|
||||
// Look for other loads of the same chain. Find loads that are loading from
|
||||
// the same base pointer and different offsets.
|
||||
Visited.clear();
|
||||
Offsets.clear();
|
||||
O2SMap.clear();
|
||||
SmallPtrSet<SDNode*, 16> Visited;
|
||||
SmallVector<int64_t, 4> Offsets;
|
||||
DenseMap<long long, SDNode*> O2SMap; // Map from offset to SDNode.
|
||||
bool Cluster = false;
|
||||
SDNode *Base = Node;
|
||||
int64_t BaseOffset;
|
||||
@ -183,7 +169,7 @@ void ScheduleDAGSDNodes::ClusterNeighboringLoads() {
|
||||
}
|
||||
|
||||
if (!Cluster)
|
||||
continue;
|
||||
return;
|
||||
|
||||
// Sort them in increasing order.
|
||||
std::sort(Offsets.begin(), Offsets.end());
|
||||
@ -197,15 +183,14 @@ void ScheduleDAGSDNodes::ClusterNeighboringLoads() {
|
||||
for (unsigned i = 1, e = Offsets.size(); i != e; ++i) {
|
||||
int64_t Offset = Offsets[i];
|
||||
SDNode *Load = O2SMap[Offset];
|
||||
if (!TII->shouldScheduleLoadsNear(BaseLoad, Load, BaseOff, Offset,
|
||||
NumLoads))
|
||||
if (!TII->shouldScheduleLoadsNear(BaseLoad, Load, BaseOff, Offset,NumLoads))
|
||||
break; // Stop right here. Ignore loads that are further away.
|
||||
Loads.push_back(Load);
|
||||
++NumLoads;
|
||||
}
|
||||
|
||||
if (NumLoads == 0)
|
||||
continue;
|
||||
return;
|
||||
|
||||
// Cluster loads by adding MVT::Flag outputs and inputs. This also
|
||||
// ensure they are scheduled in order of increasing addresses.
|
||||
@ -221,6 +206,22 @@ void ScheduleDAGSDNodes::ClusterNeighboringLoads() {
|
||||
++LoadsClustered;
|
||||
}
|
||||
}
|
||||
|
||||
/// ClusterNodes - Cluster certain nodes which should be scheduled together.
|
||||
///
|
||||
void ScheduleDAGSDNodes::ClusterNodes() {
|
||||
for (SelectionDAG::allnodes_iterator NI = DAG->allnodes_begin(),
|
||||
E = DAG->allnodes_end(); NI != E; ++NI) {
|
||||
SDNode *Node = &*NI;
|
||||
if (!Node || !Node->isMachineOpcode())
|
||||
continue;
|
||||
|
||||
unsigned Opc = Node->getMachineOpcode();
|
||||
const TargetInstrDesc &TID = TII->get(Opc);
|
||||
if (TID.mayLoad())
|
||||
// Cluster loads from "near" addresses into combined SUnits.
|
||||
ClusterNeighboringLoads(Node);
|
||||
}
|
||||
}
|
||||
|
||||
void ScheduleDAGSDNodes::BuildSchedUnits() {
|
||||
@ -388,8 +389,8 @@ void ScheduleDAGSDNodes::AddSchedEdges() {
|
||||
/// excludes nodes that aren't interesting to scheduling, and represents
|
||||
/// flagged together nodes with a single SUnit.
|
||||
void ScheduleDAGSDNodes::BuildSchedGraph(AliasAnalysis *AA) {
|
||||
// Cluster loads from "near" addresses into combined SUnits.
|
||||
ClusterNeighboringLoads();
|
||||
// Cluster certain nodes which should be scheduled together.
|
||||
ClusterNodes();
|
||||
// Populate the SUnits array.
|
||||
BuildSchedUnits();
|
||||
// Compute all the scheduling dependencies between nodes.
|
||||
|
@ -108,7 +108,10 @@ namespace llvm {
|
||||
private:
|
||||
/// ClusterNeighboringLoads - Cluster loads from "near" addresses into
|
||||
/// combined SUnits.
|
||||
void ClusterNeighboringLoads();
|
||||
void ClusterNeighboringLoads(SDNode *Node);
|
||||
/// ClusterNodes - Cluster certain nodes which should be scheduled together.
|
||||
///
|
||||
void ClusterNodes();
|
||||
|
||||
/// BuildSchedUnits, AddSchedEdges - Helper functions for BuildSchedGraph.
|
||||
void BuildSchedUnits();
|
||||
|
Loading…
Reference in New Issue
Block a user