1c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===-- MachineFunctionPass.h - Pass for MachineFunctions --------*-C++ -*-===//
2c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
3c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//                     The LLVM Compiler Infrastructure
4c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
5c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file is distributed under the University of Illinois Open Source
6c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// License. See LICENSE.TXT for details.
7c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
8c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
9c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
10c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// This file defines the MachineFunctionPass class.  MachineFunctionPass's are
11c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// just FunctionPass's, except they operate on machine code as part of a code
12c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// generator.  Because they operate on machine code, not the LLVM
13c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// representation, MachineFunctionPass's are not allowed to modify the LLVM
14c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// representation.  Due to this limitation, the MachineFunctionPass class takes
15c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot// care of declaring that no LLVM passes are invalidated.
16c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//
17c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot//===----------------------------------------------------------------------===//
18c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
19c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#ifndef LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
20c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#define LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
21c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
22c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/CodeGen/MachineFunction.h"
23c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#include "llvm/Pass.h"
24c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
25c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotnamespace llvm {
26c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
27c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// MachineFunctionPass - This class adapts the FunctionPass interface to
28c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// allow convenient creation of passes that operate on the MachineFunction
29c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// representation. Instead of overriding runOnFunction, subclasses
30c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot/// override runOnMachineFunction.
31c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotclass MachineFunctionPass : public FunctionPass {
32c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotpublic:
33c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool doInitialization(Module&) override {
34c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // Cache the properties info at module-init time so we don't have to
35c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    // construct them for every function.
36c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    RequiredProperties = getRequiredProperties();
37c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    SetProperties = getSetProperties();
38c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    ClearedProperties = getClearedProperties();
39c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return false;
40c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
41c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprotected:
42c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  explicit MachineFunctionPass(char &ID) : FunctionPass(ID) {}
43c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
44c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// runOnMachineFunction - This method must be overloaded to perform the
45c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// desired machine code transformation or analysis.
46c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
47c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual bool runOnMachineFunction(MachineFunction &MF) = 0;
48c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
49c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// getAnalysisUsage - Subclasses that override getAnalysisUsage
50c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// must call this.
51c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
52c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// For MachineFunctionPasses, calling AU.preservesCFG() indicates that
53c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// the pass does not modify the MachineBasicBlock CFG.
54c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  ///
55c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  void getAnalysisUsage(AnalysisUsage &AU) const override;
56c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
57c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MachineFunctionProperties getRequiredProperties() const {
58c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MachineFunctionProperties();
59c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
60c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MachineFunctionProperties getSetProperties() const {
61c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MachineFunctionProperties();
62c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
63c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  virtual MachineFunctionProperties getClearedProperties() const {
64c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot    return MachineFunctionProperties();
65c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  }
66c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
67c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robotprivate:
68c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MachineFunctionProperties RequiredProperties;
69c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MachineFunctionProperties SetProperties;
70c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  MachineFunctionProperties ClearedProperties;
71c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
72c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  /// createPrinterPass - Get a machine function printer pass.
73c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  Pass *createPrinterPass(raw_ostream &O,
74c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot                          const std::string &Banner) const override;
75c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
76c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot  bool runOnFunction(Function &F) override;
77c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot};
78c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
79c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot} // End llvm namespace
80c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot
81c9cc9e7d29b8970d8ddb734c88fb62d01e0b727android-build-team Robot#endif
82