LLVM  6.0.0svn
RegisterUsageInfo.h
Go to the documentation of this file.
1 //==- RegisterUsageInfo.h - Register Usage Informartion Storage --*- C++ -*-==//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 /// \file
10 /// This pass is required to take advantage of the interprocedural register
11 /// allocation infrastructure.
12 ///
13 /// This pass is simple immutable pass which keeps RegMasks (calculated based on
14 /// actual register allocation) for functions in a module and provides simple
15 /// API to query this information.
16 ///
17 //===----------------------------------------------------------------------===//
18 
19 #ifndef LLVM_CODEGEN_PHYSICALREGISTERUSAGEINFO_H
20 #define LLVM_CODEGEN_PHYSICALREGISTERUSAGEINFO_H
21 
22 #include "llvm/ADT/DenseMap.h"
23 #include "llvm/IR/Instructions.h"
24 #include "llvm/Pass.h"
25 #include <cstdint>
26 #include <vector>
27 
28 namespace llvm {
29 
30 class Function;
31 class TargetMachine;
32 
34  virtual void anchor();
35 
36 public:
37  static char ID;
38 
42  }
43 
44  void getAnalysisUsage(AnalysisUsage &AU) const override {
45  AU.setPreservesAll();
46  }
47 
48  /// To set TargetMachine *, which is used to print
49  /// analysis when command line option -print-regusage is used.
50  void setTargetMachine(const TargetMachine *TM_) { TM = TM_; }
51 
52  bool doInitialization(Module &M) override;
53 
54  bool doFinalization(Module &M) override;
55 
56  /// To store RegMask for given Function *.
57  void storeUpdateRegUsageInfo(const Function *FP,
58  std::vector<uint32_t> RegMask);
59 
60  /// To query stored RegMask for given Function *, it will return nullptr if
61  /// function is not known.
62  const std::vector<uint32_t> *getRegUsageInfo(const Function *FP);
63 
64  void print(raw_ostream &OS, const Module *M = nullptr) const override;
65 
66 private:
67  /// A Dense map from Function * to RegMask.
68  /// In RegMask 0 means register used (clobbered) by function.
69  /// and 1 means content of register will be preserved around function call.
71 
72  const TargetMachine *TM;
73 };
74 
75 } // end namespace llvm
76 
77 #endif // LLVM_CODEGEN_PHYSICALREGISTERUSAGEINFO_H
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
A Module instance is used to store all the information related to an LLVM module. ...
Definition: Module.h:63
A global registry used in conjunction with static constructors to make pluggable components (like tar...
Definition: Registry.h:45
void storeUpdateRegUsageInfo(const Function *FP, std::vector< uint32_t > RegMask)
To store RegMask for given Function *.
void print(raw_ostream &OS, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
bool doInitialization(Module &M) override
doInitialization - Virtual method overridden by subclasses to do any necessary initialization before ...
bool doFinalization(Module &M) override
doFinalization - Virtual method overriden by subclasses to do any necessary clean up after all passes...
void setTargetMachine(const TargetMachine *TM_)
To set TargetMachine *, which is used to print analysis when command line option -print-regusage is u...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
void initializePhysicalRegisterUsageInfoPass(PassRegistry &)
Represent the analysis usage information of a pass.
ImmutablePass class - This class is used to provide information that does not need to be run...
Definition: Pass.h:256
void setPreservesAll()
Set by analyses that do not transform their input at all.
const std::vector< uint32_t > * getRegUsageInfo(const Function *FP)
To query stored RegMask for given Function *, it will return nullptr if function is not known...
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:44
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:57
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
Definition: PassRegistry.h:39