LLVM 22.0.0git
BasicBlockMatchingAndInference.h
Go to the documentation of this file.
1//===- llvm/CodeGen/BasicBlockMatchingAndInference.h ------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// Infer weights for all basic blocks using matching and inference.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CODEGEN_BASIC_BLOCK_AND_INFERENCE_H
14#define LLVM_CODEGEN_BASIC_BLOCK_AND_INFERENCE_H
15
19
20namespace llvm {
21
23private:
24 using Edge = std::pair<const MachineBasicBlock *, const MachineBasicBlock *>;
26 using EdgeWeightMap = DenseMap<Edge, uint64_t>;
27 using BlockEdgeMap = DenseMap<const MachineBasicBlock *,
29
30 struct WeightInfo {
31 // Weight of basic blocks.
32 BlockWeightMap BlockWeights;
33 // Weight of edges.
34 EdgeWeightMap EdgeWeights;
35 };
36
37public:
38 static char ID;
40
41 StringRef getPassName() const override {
42 return "Basic Block Matching and Inference";
43 }
44
45 void getAnalysisUsage(AnalysisUsage &AU) const override;
46
48
49 std::optional<WeightInfo> getWeightInfo(StringRef FuncName) const;
50
51private:
52 StringMap<WeightInfo> ProgramWeightInfo;
53
54 WeightInfo initWeightInfoByMatching(MachineFunction &MF);
55
56 void generateWeightInfoByInference(MachineFunction &MF,
57 WeightInfo &MatchWeight);
58};
59
60} // end namespace llvm
61
62#endif // LLVM_CODEGEN_BASIC_BLOCK_AND_INFERENCE_H
#define F(x, y, z)
Definition MD5.cpp:54
This file provides the interface for the profile inference algorithm, profi.
Represent the analysis usage information of a pass.
std::optional< WeightInfo > getWeightInfo(StringRef FuncName) const
StringRef getPassName() const override
getPassName - Return a nice clean name for a pass.
bool runOnMachineFunction(MachineFunction &F) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.