]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/tools/clang/include/clang/CodeGen/CodeGenAction.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / tools / clang / include / clang / CodeGen / CodeGenAction.h
1 //===--- CodeGenAction.h - LLVM Code Generation Frontend Action -*- 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
10 #ifndef LLVM_CLANG_CODEGEN_CODE_GEN_ACTION_H
11 #define LLVM_CLANG_CODEGEN_CODE_GEN_ACTION_H
12
13 #include "clang/Frontend/FrontendAction.h"
14 #include "llvm/ADT/OwningPtr.h"
15
16 namespace llvm {
17   class LLVMContext;
18   class Module;
19 }
20
21 namespace clang {
22 class BackendConsumer;
23
24 class CodeGenAction : public ASTFrontendAction {
25 private:
26   unsigned Act;
27   llvm::OwningPtr<llvm::Module> TheModule;
28   llvm::LLVMContext *VMContext;
29   bool OwnsVMContext;
30
31 protected:
32   /// Create a new code generation action.  If the optional \arg _VMContext
33   /// parameter is supplied, the action uses it without taking ownership,
34   /// otherwise it creates a fresh LLVM context and takes ownership.
35   CodeGenAction(unsigned _Act, llvm::LLVMContext *_VMContext = 0);
36
37   virtual bool hasIRSupport() const;
38
39   virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
40                                          StringRef InFile);
41
42   virtual void ExecuteAction();
43
44   virtual void EndSourceFileAction();
45
46 public:
47   ~CodeGenAction();
48
49   /// takeModule - Take the generated LLVM module, for use after the action has
50   /// been run. The result may be null on failure.
51   llvm::Module *takeModule();
52
53   /// Take the LLVM context used by this action.
54   llvm::LLVMContext *takeLLVMContext();
55
56   BackendConsumer *BEConsumer;
57 };
58
59 class EmitAssemblyAction : public CodeGenAction {
60 public:
61   EmitAssemblyAction(llvm::LLVMContext *_VMContext = 0);
62 };
63
64 class EmitBCAction : public CodeGenAction {
65 public:
66   EmitBCAction(llvm::LLVMContext *_VMContext = 0);
67 };
68
69 class EmitLLVMAction : public CodeGenAction {
70 public:
71   EmitLLVMAction(llvm::LLVMContext *_VMContext = 0);
72 };
73
74 class EmitLLVMOnlyAction : public CodeGenAction {
75 public:
76   EmitLLVMOnlyAction(llvm::LLVMContext *_VMContext = 0);
77 };
78
79 class EmitCodeGenOnlyAction : public CodeGenAction {
80 public:
81   EmitCodeGenOnlyAction(llvm::LLVMContext *_VMContext = 0);
82 };
83
84 class EmitObjAction : public CodeGenAction {
85 public:
86   EmitObjAction(llvm::LLVMContext *_VMContext = 0);
87 };
88
89 }
90
91 #endif