2011-01-04 22:10:05 +01:00
|
|
|
//===-------- EdgeBundles.h - Bundles of CFG edges --------------*- c++ -*-===//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2011-01-04 22:10:05 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// The EdgeBundles analysis forms equivalence classes of CFG edges such that all
|
|
|
|
// edges leaving a machine basic block are in the same bundle, and all edges
|
2021-03-24 05:03:21 +01:00
|
|
|
// entering a machine basic block are in the same bundle.
|
2011-01-04 22:10:05 +01:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_EDGEBUNDLES_H
|
|
|
|
#define LLVM_CODEGEN_EDGEBUNDLES_H
|
|
|
|
|
2011-04-09 04:59:09 +02:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
2011-01-04 22:10:05 +01:00
|
|
|
#include "llvm/ADT/IntEqClasses.h"
|
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
class EdgeBundles : public MachineFunctionPass {
|
|
|
|
const MachineFunction *MF;
|
|
|
|
|
|
|
|
/// EC - Each edge bundle is an equivalence class. The keys are:
|
|
|
|
/// 2*BB->getNumber() -> Ingoing bundle.
|
|
|
|
/// 2*BB->getNumber()+1 -> Outgoing bundle.
|
|
|
|
IntEqClasses EC;
|
|
|
|
|
2011-04-09 04:59:09 +02:00
|
|
|
/// Blocks - Map each bundle to a list of basic block numbers.
|
|
|
|
SmallVector<SmallVector<unsigned, 8>, 4> Blocks;
|
|
|
|
|
2011-01-04 22:10:05 +01:00
|
|
|
public:
|
|
|
|
static char ID;
|
|
|
|
EdgeBundles() : MachineFunctionPass(ID) {}
|
|
|
|
|
|
|
|
/// getBundle - Return the ingoing (Out = false) or outgoing (Out = true)
|
|
|
|
/// bundle number for basic block #N
|
|
|
|
unsigned getBundle(unsigned N, bool Out) const { return EC[2 * N + Out]; }
|
|
|
|
|
2011-01-04 22:10:11 +01:00
|
|
|
/// getNumBundles - Return the total number of bundles in the CFG.
|
|
|
|
unsigned getNumBundles() const { return EC.getNumClasses(); }
|
|
|
|
|
2011-04-09 04:59:09 +02:00
|
|
|
/// getBlocks - Return an array of blocks that are connected to Bundle.
|
2012-05-21 05:11:23 +02:00
|
|
|
ArrayRef<unsigned> getBlocks(unsigned Bundle) const { return Blocks[Bundle]; }
|
2011-04-09 04:59:09 +02:00
|
|
|
|
2011-01-04 22:10:05 +01:00
|
|
|
/// getMachineFunction - Return the last machine function computed.
|
|
|
|
const MachineFunction *getMachineFunction() const { return MF; }
|
|
|
|
|
|
|
|
/// view - Visualize the annotated bipartite CFG with Graphviz.
|
|
|
|
void view() const;
|
|
|
|
|
|
|
|
private:
|
2014-03-07 10:26:03 +01:00
|
|
|
bool runOnMachineFunction(MachineFunction&) override;
|
|
|
|
void getAnalysisUsage(AnalysisUsage&) const override;
|
2011-01-04 22:10:05 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|