summaryrefslogtreecommitdiff
path: root/include/clang/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'include/clang/CodeGen')
-rw-r--r--include/clang/CodeGen/BackendUtil.h37
-rw-r--r--include/clang/CodeGen/CodeGenAction.h79
-rw-r--r--include/clang/CodeGen/CodeGenOptions.h131
-rw-r--r--include/clang/CodeGen/ModuleBuilder.h3
4 files changed, 119 insertions, 131 deletions
diff --git a/include/clang/CodeGen/BackendUtil.h b/include/clang/CodeGen/BackendUtil.h
new file mode 100644
index 0000000000000..abcef8130dbc0
--- /dev/null
+++ b/include/clang/CodeGen/BackendUtil.h
@@ -0,0 +1,37 @@
+//===--- BackendUtil.h - LLVM Backend Utilities -----------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_CODEGEN_BACKEND_UTIL_H
+#define LLVM_CLANG_CODEGEN_BACKEND_UTIL_H
+
+namespace llvm {
+ class Module;
+ class raw_ostream;
+}
+
+namespace clang {
+ class Diagnostic;
+ class CodeGenOptions;
+ class TargetOptions;
+
+ enum BackendAction {
+ Backend_EmitAssembly, ///< Emit native assembly files
+ Backend_EmitBC, ///< Emit LLVM bitcode files
+ Backend_EmitLL, ///< Emit human-readable LLVM assembly
+ Backend_EmitNothing, ///< Don't emit anything (benchmarking mode)
+ Backend_EmitMCNull, ///< Run CodeGen, but don't emit anything
+ Backend_EmitObj ///< Emit native object files
+ };
+
+ void EmitBackendOutput(Diagnostic &Diags, const CodeGenOptions &CGOpts,
+ const TargetOptions &TOpts, llvm::Module *M,
+ BackendAction Action, llvm::raw_ostream *OS);
+}
+
+#endif
diff --git a/include/clang/CodeGen/CodeGenAction.h b/include/clang/CodeGen/CodeGenAction.h
new file mode 100644
index 0000000000000..cecfcda461bb9
--- /dev/null
+++ b/include/clang/CodeGen/CodeGenAction.h
@@ -0,0 +1,79 @@
+//===--- CodeGenAction.h - LLVM Code Generation Frontend Action -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_CODEGEN_CODE_GEN_ACTION_H
+#define LLVM_CLANG_CODEGEN_CODE_GEN_ACTION_H
+
+#include "clang/Frontend/FrontendAction.h"
+#include "llvm/ADT/OwningPtr.h"
+
+namespace llvm {
+ class Module;
+}
+
+namespace clang {
+
+class CodeGenAction : public ASTFrontendAction {
+private:
+ unsigned Act;
+ llvm::OwningPtr<llvm::Module> TheModule;
+
+protected:
+ CodeGenAction(unsigned _Act);
+
+ virtual bool hasIRSupport() const;
+
+ virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
+ llvm::StringRef InFile);
+
+ virtual void ExecuteAction();
+
+ virtual void EndSourceFileAction();
+
+public:
+ ~CodeGenAction();
+
+ /// takeModule - Take the generated LLVM module, for use after the action has
+ /// been run. The result may be null on failure.
+ llvm::Module *takeModule();
+};
+
+class EmitAssemblyAction : public CodeGenAction {
+public:
+ EmitAssemblyAction();
+};
+
+class EmitBCAction : public CodeGenAction {
+public:
+ EmitBCAction();
+};
+
+class EmitLLVMAction : public CodeGenAction {
+public:
+ EmitLLVMAction();
+};
+
+class EmitLLVMOnlyAction : public CodeGenAction {
+public:
+ EmitLLVMOnlyAction();
+};
+
+class EmitCodeGenOnlyAction : public CodeGenAction {
+public:
+ EmitCodeGenOnlyAction();
+};
+
+class EmitObjAction : public CodeGenAction {
+public:
+ EmitObjAction();
+};
+
+}
+
+#endif
diff --git a/include/clang/CodeGen/CodeGenOptions.h b/include/clang/CodeGen/CodeGenOptions.h
deleted file mode 100644
index 6241230ffb458..0000000000000
--- a/include/clang/CodeGen/CodeGenOptions.h
+++ /dev/null
@@ -1,131 +0,0 @@
-//===--- CodeGenOptions.h ---------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines the CodeGenOptions interface.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_CODEGEN_CODEGENOPTIONS_H
-#define LLVM_CLANG_CODEGEN_CODEGENOPTIONS_H
-
-#include <string>
-
-namespace clang {
-
-/// CodeGenOptions - Track various options which control how the code
-/// is optimized and passed to the backend.
-class CodeGenOptions {
-public:
- enum InliningMethod {
- NoInlining, // Perform no inlining whatsoever.
- NormalInlining, // Use the standard function inlining pass.
- OnlyAlwaysInlining // Only run the always inlining pass.
- };
-
- enum ObjCDispatchMethodKind {
- Legacy = 0,
- NonLegacy = 1,
- Mixed = 2
- };
-
- unsigned AsmVerbose : 1; /// -dA, -fverbose-asm.
- unsigned CXAAtExit : 1; /// Use __cxa_atexit for calling destructors.
- unsigned CXXCtorDtorAliases: 1; /// Emit complete ctors/dtors as linker
- /// aliases to base ctors when possible.
- unsigned DataSections : 1; /// Set when -fdata-sections is enabled
- unsigned DebugInfo : 1; /// Should generate deubg info (-g).
- unsigned DisableFPElim : 1; /// Set when -fomit-frame-pointer is enabled.
- unsigned DisableLLVMOpts : 1; /// Don't run any optimizations, for use in
- /// getting .bc files that correspond to the
- /// internal state before optimizations are
- /// done.
- unsigned DisableRedZone : 1; /// Set when -mno-red-zone is enabled.
- unsigned FunctionSections : 1; /// Set when -ffunction-sections is enabled
- unsigned MergeAllConstants : 1; /// Merge identical constants.
- unsigned NoCommon : 1; /// Set when -fno-common or C++ is enabled.
- unsigned NoImplicitFloat : 1; /// Set when -mno-implicit-float is enabled.
- unsigned NoZeroInitializedInBSS : 1; /// -fno-zero-initialized-in-bss
- unsigned ObjCDispatchMethod : 2; /// Method of Objective-C dispatch to use.
- unsigned OptimizationLevel : 3; /// The -O[0-4] option specified.
- unsigned OptimizeSize : 1; /// If -Os is specified.
- unsigned RelaxAll : 1; /// Relax all machine code instructions.
- unsigned SoftFloat : 1; /// -soft-float.
- unsigned TimePasses : 1; /// Set when -ftime-report is enabled.
- unsigned UnitAtATime : 1; /// Unused. For mirroring GCC optimization
- /// selection.
- unsigned UnrollLoops : 1; /// Control whether loops are unrolled.
- unsigned UnwindTables : 1; /// Emit unwind tables.
- unsigned VerifyModule : 1; /// Control whether the module should be run
- /// through the LLVM Verifier.
-
- /// The code model to use (-mcmodel).
- std::string CodeModel;
-
- /// Enable additional debugging information.
- std::string DebugPass;
-
- /// The string to embed in the debug information for the compile unit, if
- /// non-empty.
- std::string DwarfDebugFlags;
-
- /// The ABI to use for passing floating point arguments.
- std::string FloatABI;
-
- /// The float precision limit to use, if non-empty.
- std::string LimitFloatPrecision;
-
- /// The kind of inlining to perform.
- InliningMethod Inlining;
-
- /// The user provided name for the "main file", if non-empty. This is useful
- /// in situations where the input file name does not match the original input
- /// file, for example with -save-temps.
- std::string MainFileName;
-
- /// The name of the relocation model to use.
- std::string RelocationModel;
-
-public:
- CodeGenOptions() {
- AsmVerbose = 0;
- CXAAtExit = 1;
- CXXCtorDtorAliases = 0;
- DataSections = 0;
- DebugInfo = 0;
- DisableFPElim = 0;
- DisableLLVMOpts = 0;
- DisableRedZone = 0;
- FunctionSections = 0;
- MergeAllConstants = 1;
- NoCommon = 0;
- NoImplicitFloat = 0;
- NoZeroInitializedInBSS = 0;
- ObjCDispatchMethod = Legacy;
- OptimizationLevel = 0;
- OptimizeSize = 0;
- RelaxAll = 0;
- SoftFloat = 0;
- TimePasses = 0;
- UnitAtATime = 1;
- UnrollLoops = 0;
- UnwindTables = 0;
- VerifyModule = 1;
-
- Inlining = NoInlining;
- RelocationModel = "pic";
- }
-
- ObjCDispatchMethodKind getObjCDispatchMethod() const {
- return ObjCDispatchMethodKind(ObjCDispatchMethod);
- }
-};
-
-} // end namespace clang
-
-#endif
diff --git a/include/clang/CodeGen/ModuleBuilder.h b/include/clang/CodeGen/ModuleBuilder.h
index 2a3aa6a90404f..c45ad08716c66 100644
--- a/include/clang/CodeGen/ModuleBuilder.h
+++ b/include/clang/CodeGen/ModuleBuilder.h
@@ -33,6 +33,9 @@ namespace clang {
virtual llvm::Module* ReleaseModule() = 0;
};
+ /// CreateLLVMCodeGen - Create a CodeGenerator instance.
+ /// It is the responsibility of the caller to call delete on
+ /// the allocated CodeGenerator instance.
CodeGenerator *CreateLLVMCodeGen(Diagnostic &Diags,
const std::string &ModuleName,
const CodeGenOptions &CGO,