LLVM  14.0.0git
RegisterUsageInfo.h
Go to the documentation of this file.
1 //==- RegisterUsageInfo.h - Register Usage Informartion Storage --*- 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 /// \file
9 /// This pass is required to take advantage of the interprocedural register
10 /// allocation infrastructure.
11 ///
12 /// This pass is simple immutable pass which keeps RegMasks (calculated based on
13 /// actual register allocation) for functions in a module and provides simple
14 /// API to query this information.
15 ///
16 //===----------------------------------------------------------------------===//
17 
18 #ifndef LLVM_CODEGEN_REGISTERUSAGEINFO_H
19 #define LLVM_CODEGEN_REGISTERUSAGEINFO_H
20 
21 #include "llvm/ADT/ArrayRef.h"
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/IR/Instructions.h"
24 #include "llvm/InitializePasses.h"
25 #include "llvm/Pass.h"
26 #include <cstdint>
27 #include <vector>
28 
29 namespace llvm {
30 
31 class Function;
32 class LLVMTargetMachine;
33 
35 public:
36  static char ID;
37 
41  }
42 
43  /// Set TargetMachine which is used to print analysis.
44  void setTargetMachine(const LLVMTargetMachine &TM);
45 
46  bool doInitialization(Module &M) override;
47 
48  bool doFinalization(Module &M) override;
49 
50  /// To store RegMask for given Function *.
51  void storeUpdateRegUsageInfo(const Function &FP,
52  ArrayRef<uint32_t> RegMask);
53 
54  /// To query stored RegMask for given Function *, it will returns ane empty
55  /// array if function is not known.
57 
58  void print(raw_ostream &OS, const Module *M = nullptr) const override;
59 
60 private:
61  /// A Dense map from Function * to RegMask.
62  /// In RegMask 0 means register used (clobbered) by function.
63  /// and 1 means content of register will be preserved around function call.
65 
66  const LLVMTargetMachine *TM;
67 };
68 
69 } // end namespace llvm
70 
71 #endif // LLVM_CODEGEN_REGISTERUSAGEINFO_H
llvm::initializePhysicalRegisterUsageInfoPass
void initializePhysicalRegisterUsageInfoPass(PassRegistry &)
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AllocatorList.h:23
llvm::ImmutablePass
ImmutablePass class - This class is used to provide information that does not need to be run.
Definition: Pass.h:269
llvm::PhysicalRegisterUsageInfo::print
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
Definition: RegisterUsageInfo.cpp:72
llvm::Function
Definition: Function.h:62
Pass.h
DenseMap.h
llvm::PhysicalRegisterUsageInfo::ID
static char ID
Definition: RegisterUsageInfo.h:36
llvm::PhysicalRegisterUsageInfo::getRegUsageInfo
ArrayRef< uint32_t > getRegUsageInfo(const Function &FP)
To query stored RegMask for given Function *, it will returns ane empty array if function is not know...
Definition: RegisterUsageInfo.cpp:65
llvm::PhysicalRegisterUsageInfo::doFinalization
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
Definition: RegisterUsageInfo.cpp:51
llvm::PassRegistry::getPassRegistry
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Definition: PassRegistry.cpp:31
llvm::PhysicalRegisterUsageInfo::storeUpdateRegUsageInfo
void storeUpdateRegUsageInfo(const Function &FP, ArrayRef< uint32_t > RegMask)
To store RegMask for given Function *.
Definition: RegisterUsageInfo.cpp:59
llvm::PassRegistry
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:38
llvm::raw_ostream
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:53
llvm::DenseMap
Definition: DenseMap.h:714
ArrayRef.h
llvm::Module
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:67
llvm::PhysicalRegisterUsageInfo
Definition: RegisterUsageInfo.h:34
llvm::ArrayRef< uint32_t >
llvm::PhysicalRegisterUsageInfo::PhysicalRegisterUsageInfo
PhysicalRegisterUsageInfo()
Definition: RegisterUsageInfo.h:38
llvm::PhysicalRegisterUsageInfo::setTargetMachine
void setTargetMachine(const LLVMTargetMachine &TM)
Set TargetMachine which is used to print analysis.
llvm::LLVMTargetMachine
This class describes a target machine that is implemented with the LLVM target-independent code gener...
Definition: TargetMachine.h:406
llvm::PhysicalRegisterUsageInfo::doInitialization
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
Definition: RegisterUsageInfo.cpp:46
Instructions.h
llvm::Registry
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:44
InitializePasses.h
llvm::codeview::PublicSymFlags::Function
@ Function