diff options
Diffstat (limited to 'include/clang/CodeGen')
-rw-r--r-- | include/clang/CodeGen/BackendUtil.h | 44 | ||||
-rw-r--r-- | include/clang/CodeGen/CGFunctionInfo.h | 538 | ||||
-rw-r--r-- | include/clang/CodeGen/CodeGenABITypes.h | 91 | ||||
-rw-r--r-- | include/clang/CodeGen/CodeGenAction.h | 107 | ||||
-rw-r--r-- | include/clang/CodeGen/ModuleBuilder.h | 54 | ||||
-rw-r--r-- | include/clang/CodeGen/ObjectFilePCHContainerOperations.h | 43 |
6 files changed, 0 insertions, 877 deletions
diff --git a/include/clang/CodeGen/BackendUtil.h b/include/clang/CodeGen/BackendUtil.h deleted file mode 100644 index ba5dc39..0000000 --- a/include/clang/CodeGen/BackendUtil.h +++ /dev/null @@ -1,44 +0,0 @@ -//===--- 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_BACKENDUTIL_H -#define LLVM_CLANG_CODEGEN_BACKENDUTIL_H - -#include "clang/Basic/LLVM.h" -#include "llvm/IR/FunctionInfo.h" -#include <memory> - -namespace llvm { - class Module; -} - -namespace clang { - class DiagnosticsEngine; - class CodeGenOptions; - class TargetOptions; - class LangOptions; - - 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(DiagnosticsEngine &Diags, const CodeGenOptions &CGOpts, - const TargetOptions &TOpts, const LangOptions &LOpts, - StringRef TDesc, llvm::Module *M, BackendAction Action, - raw_pwrite_stream *OS, - std::unique_ptr<llvm::FunctionInfoIndex> Index = nullptr); -} - -#endif diff --git a/include/clang/CodeGen/CGFunctionInfo.h b/include/clang/CodeGen/CGFunctionInfo.h deleted file mode 100644 index bb6ceb4..0000000 --- a/include/clang/CodeGen/CGFunctionInfo.h +++ /dev/null @@ -1,538 +0,0 @@ -//==-- CGFunctionInfo.h - Representation of function argument/return types -==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Defines CGFunctionInfo and associated types used in representing the -// LLVM source types and ABI-coerced types for function arguments and -// return values. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H -#define LLVM_CLANG_CODEGEN_CGFUNCTIONINFO_H - -#include "clang/AST/CanonicalType.h" -#include "clang/AST/CharUnits.h" -#include "clang/AST/Type.h" -#include "llvm/ADT/FoldingSet.h" -#include <cassert> - -namespace llvm { - class Type; - class StructType; -} - -namespace clang { -class Decl; - -namespace CodeGen { - -/// ABIArgInfo - Helper class to encapsulate information about how a -/// specific C type should be passed to or returned from a function. -class ABIArgInfo { -public: - enum Kind : uint8_t { - /// Direct - Pass the argument directly using the normal converted LLVM - /// type, or by coercing to another specified type stored in - /// 'CoerceToType'). If an offset is specified (in UIntData), then the - /// argument passed is offset by some number of bytes in the memory - /// representation. A dummy argument is emitted before the real argument - /// if the specified type stored in "PaddingType" is not zero. - Direct, - - /// Extend - Valid only for integer argument types. Same as 'direct' - /// but also emit a zero/sign extension attribute. - Extend, - - /// Indirect - Pass the argument indirectly via a hidden pointer - /// with the specified alignment (0 indicates default alignment). - Indirect, - - /// Ignore - Ignore the argument (treat as void). Useful for void and - /// empty structs. - Ignore, - - /// Expand - Only valid for aggregate argument types. The structure should - /// be expanded into consecutive arguments for its constituent fields. - /// Currently expand is only allowed on structures whose fields - /// are all scalar types or are themselves expandable types. - Expand, - - /// InAlloca - Pass the argument directly using the LLVM inalloca attribute. - /// This is similar to indirect with byval, except it only applies to - /// arguments stored in memory and forbids any implicit copies. When - /// applied to a return type, it means the value is returned indirectly via - /// an implicit sret parameter stored in the argument struct. - InAlloca, - KindFirst = Direct, - KindLast = InAlloca - }; - -private: - llvm::Type *TypeData; // isDirect() || isExtend() - llvm::Type *PaddingType; - union { - unsigned DirectOffset; // isDirect() || isExtend() - unsigned IndirectAlign; // isIndirect() - unsigned AllocaFieldIndex; // isInAlloca() - }; - Kind TheKind; - bool PaddingInReg : 1; - bool InAllocaSRet : 1; // isInAlloca() - bool IndirectByVal : 1; // isIndirect() - bool IndirectRealign : 1; // isIndirect() - bool SRetAfterThis : 1; // isIndirect() - bool InReg : 1; // isDirect() || isExtend() || isIndirect() - bool CanBeFlattened: 1; // isDirect() - - ABIArgInfo(Kind K) - : PaddingType(nullptr), TheKind(K), PaddingInReg(false), InReg(false) {} - -public: - ABIArgInfo() - : TypeData(nullptr), PaddingType(nullptr), DirectOffset(0), - TheKind(Direct), PaddingInReg(false), InReg(false) {} - - static ABIArgInfo getDirect(llvm::Type *T = nullptr, unsigned Offset = 0, - llvm::Type *Padding = nullptr, - bool CanBeFlattened = true) { - auto AI = ABIArgInfo(Direct); - AI.setCoerceToType(T); - AI.setDirectOffset(Offset); - AI.setPaddingType(Padding); - AI.setCanBeFlattened(CanBeFlattened); - return AI; - } - static ABIArgInfo getDirectInReg(llvm::Type *T = nullptr) { - auto AI = getDirect(T); - AI.setInReg(true); - return AI; - } - static ABIArgInfo getExtend(llvm::Type *T = nullptr) { - auto AI = ABIArgInfo(Extend); - AI.setCoerceToType(T); - AI.setDirectOffset(0); - return AI; - } - static ABIArgInfo getExtendInReg(llvm::Type *T = nullptr) { - auto AI = getExtend(T); - AI.setInReg(true); - return AI; - } - static ABIArgInfo getIgnore() { - return ABIArgInfo(Ignore); - } - static ABIArgInfo getIndirect(CharUnits Alignment, bool ByVal = true, - bool Realign = false, - llvm::Type *Padding = nullptr) { - auto AI = ABIArgInfo(Indirect); - AI.setIndirectAlign(Alignment); - AI.setIndirectByVal(ByVal); - AI.setIndirectRealign(Realign); - AI.setSRetAfterThis(false); - AI.setPaddingType(Padding); - return AI; - } - static ABIArgInfo getIndirectInReg(CharUnits Alignment, bool ByVal = true, - bool Realign = false) { - auto AI = getIndirect(Alignment, ByVal, Realign); - AI.setInReg(true); - return AI; - } - static ABIArgInfo getInAlloca(unsigned FieldIndex) { - auto AI = ABIArgInfo(InAlloca); - AI.setInAllocaFieldIndex(FieldIndex); - return AI; - } - static ABIArgInfo getExpand() { - return ABIArgInfo(Expand); - } - static ABIArgInfo getExpandWithPadding(bool PaddingInReg, - llvm::Type *Padding) { - auto AI = getExpand(); - AI.setPaddingInReg(PaddingInReg); - AI.setPaddingType(Padding); - return AI; - } - - Kind getKind() const { return TheKind; } - bool isDirect() const { return TheKind == Direct; } - bool isInAlloca() const { return TheKind == InAlloca; } - bool isExtend() const { return TheKind == Extend; } - bool isIgnore() const { return TheKind == Ignore; } - bool isIndirect() const { return TheKind == Indirect; } - bool isExpand() const { return TheKind == Expand; } - - bool canHaveCoerceToType() const { return isDirect() || isExtend(); } - - // Direct/Extend accessors - unsigned getDirectOffset() const { - assert((isDirect() || isExtend()) && "Not a direct or extend kind"); - return DirectOffset; - } - void setDirectOffset(unsigned Offset) { - assert((isDirect() || isExtend()) && "Not a direct or extend kind"); - DirectOffset = Offset; - } - - llvm::Type *getPaddingType() const { return PaddingType; } - - void setPaddingType(llvm::Type *T) { PaddingType = T; } - - bool getPaddingInReg() const { - return PaddingInReg; - } - void setPaddingInReg(bool PIR) { - PaddingInReg = PIR; - } - - llvm::Type *getCoerceToType() const { - assert(canHaveCoerceToType() && "Invalid kind!"); - return TypeData; - } - - void setCoerceToType(llvm::Type *T) { - assert(canHaveCoerceToType() && "Invalid kind!"); - TypeData = T; - } - - bool getInReg() const { - assert((isDirect() || isExtend() || isIndirect()) && "Invalid kind!"); - return InReg; - } - - void setInReg(bool IR) { - assert((isDirect() || isExtend() || isIndirect()) && "Invalid kind!"); - InReg = IR; - } - - // Indirect accessors - CharUnits getIndirectAlign() const { - assert(isIndirect() && "Invalid kind!"); - return CharUnits::fromQuantity(IndirectAlign); - } - void setIndirectAlign(CharUnits IA) { - assert(isIndirect() && "Invalid kind!"); - IndirectAlign = IA.getQuantity(); - } - - bool getIndirectByVal() const { - assert(isIndirect() && "Invalid kind!"); - return IndirectByVal; - } - void setIndirectByVal(bool IBV) { - assert(isIndirect() && "Invalid kind!"); - IndirectByVal = IBV; - } - - bool getIndirectRealign() const { - assert(isIndirect() && "Invalid kind!"); - return IndirectRealign; - } - void setIndirectRealign(bool IR) { - assert(isIndirect() && "Invalid kind!"); - IndirectRealign = IR; - } - - bool isSRetAfterThis() const { - assert(isIndirect() && "Invalid kind!"); - return SRetAfterThis; - } - void setSRetAfterThis(bool AfterThis) { - assert(isIndirect() && "Invalid kind!"); - SRetAfterThis = AfterThis; - } - - unsigned getInAllocaFieldIndex() const { - assert(isInAlloca() && "Invalid kind!"); - return AllocaFieldIndex; - } - void setInAllocaFieldIndex(unsigned FieldIndex) { - assert(isInAlloca() && "Invalid kind!"); - AllocaFieldIndex = FieldIndex; - } - - /// \brief Return true if this field of an inalloca struct should be returned - /// to implement a struct return calling convention. - bool getInAllocaSRet() const { - assert(isInAlloca() && "Invalid kind!"); - return InAllocaSRet; - } - - void setInAllocaSRet(bool SRet) { - assert(isInAlloca() && "Invalid kind!"); - InAllocaSRet = SRet; - } - - bool getCanBeFlattened() const { - assert(isDirect() && "Invalid kind!"); - return CanBeFlattened; - } - - void setCanBeFlattened(bool Flatten) { - assert(isDirect() && "Invalid kind!"); - CanBeFlattened = Flatten; - } - - void dump() const; -}; - -/// A class for recording the number of arguments that a function -/// signature requires. -class RequiredArgs { - /// The number of required arguments, or ~0 if the signature does - /// not permit optional arguments. - unsigned NumRequired; -public: - enum All_t { All }; - - RequiredArgs(All_t _) : NumRequired(~0U) {} - explicit RequiredArgs(unsigned n) : NumRequired(n) { - assert(n != ~0U); - } - - /// Compute the arguments required by the given formal prototype, - /// given that there may be some additional, non-formal arguments - /// in play. - static RequiredArgs forPrototypePlus(const FunctionProtoType *prototype, - unsigned additional) { - if (!prototype->isVariadic()) return All; - return RequiredArgs(prototype->getNumParams() + additional); - } - - static RequiredArgs forPrototype(const FunctionProtoType *prototype) { - return forPrototypePlus(prototype, 0); - } - - static RequiredArgs forPrototype(CanQual<FunctionProtoType> prototype) { - return forPrototype(prototype.getTypePtr()); - } - - static RequiredArgs forPrototypePlus(CanQual<FunctionProtoType> prototype, - unsigned additional) { - return forPrototypePlus(prototype.getTypePtr(), additional); - } - - bool allowsOptionalArgs() const { return NumRequired != ~0U; } - unsigned getNumRequiredArgs() const { - assert(allowsOptionalArgs()); - return NumRequired; - } - - unsigned getOpaqueData() const { return NumRequired; } - static RequiredArgs getFromOpaqueData(unsigned value) { - if (value == ~0U) return All; - return RequiredArgs(value); - } -}; - -/// CGFunctionInfo - Class to encapsulate the information about a -/// function definition. -class CGFunctionInfo : public llvm::FoldingSetNode { - struct ArgInfo { - CanQualType type; - ABIArgInfo info; - }; - - /// The LLVM::CallingConv to use for this function (as specified by the - /// user). - unsigned CallingConvention : 8; - - /// The LLVM::CallingConv to actually use for this function, which may - /// depend on the ABI. - unsigned EffectiveCallingConvention : 8; - - /// The clang::CallingConv that this was originally created with. - unsigned ASTCallingConvention : 8; - - /// Whether this is an instance method. - unsigned InstanceMethod : 1; - - /// Whether this is a chain call. - unsigned ChainCall : 1; - - /// Whether this function is noreturn. - unsigned NoReturn : 1; - - /// Whether this function is returns-retained. - unsigned ReturnsRetained : 1; - - /// How many arguments to pass inreg. - unsigned HasRegParm : 1; - unsigned RegParm : 3; - - RequiredArgs Required; - - /// The struct representing all arguments passed in memory. Only used when - /// passing non-trivial types with inalloca. Not part of the profile. - llvm::StructType *ArgStruct; - unsigned ArgStructAlign; - - unsigned NumArgs; - ArgInfo *getArgsBuffer() { - return reinterpret_cast<ArgInfo*>(this+1); - } - const ArgInfo *getArgsBuffer() const { - return reinterpret_cast<const ArgInfo*>(this + 1); - } - - CGFunctionInfo() : Required(RequiredArgs::All) {} - -public: - static CGFunctionInfo *create(unsigned llvmCC, - bool instanceMethod, - bool chainCall, - const FunctionType::ExtInfo &extInfo, - CanQualType resultType, - ArrayRef<CanQualType> argTypes, - RequiredArgs required); - - typedef const ArgInfo *const_arg_iterator; - typedef ArgInfo *arg_iterator; - - typedef llvm::iterator_range<arg_iterator> arg_range; - typedef llvm::iterator_range<const_arg_iterator> arg_const_range; - - arg_range arguments() { return arg_range(arg_begin(), arg_end()); } - arg_const_range arguments() const { - return arg_const_range(arg_begin(), arg_end()); - } - - const_arg_iterator arg_begin() const { return getArgsBuffer() + 1; } - const_arg_iterator arg_end() const { return getArgsBuffer() + 1 + NumArgs; } - arg_iterator arg_begin() { return getArgsBuffer() + 1; } - arg_iterator arg_end() { return getArgsBuffer() + 1 + NumArgs; } - - unsigned arg_size() const { return NumArgs; } - - bool isVariadic() const { return Required.allowsOptionalArgs(); } - RequiredArgs getRequiredArgs() const { return Required; } - unsigned getNumRequiredArgs() const { - return isVariadic() ? getRequiredArgs().getNumRequiredArgs() : arg_size(); - } - - bool isInstanceMethod() const { return InstanceMethod; } - - bool isChainCall() const { return ChainCall; } - - bool isNoReturn() const { return NoReturn; } - - /// In ARC, whether this function retains its return value. This - /// is not always reliable for call sites. - bool isReturnsRetained() const { return ReturnsRetained; } - - /// getASTCallingConvention() - Return the AST-specified calling - /// convention. - CallingConv getASTCallingConvention() const { - return CallingConv(ASTCallingConvention); - } - - /// getCallingConvention - Return the user specified calling - /// convention, which has been translated into an LLVM CC. - unsigned getCallingConvention() const { return CallingConvention; } - - /// getEffectiveCallingConvention - Return the actual calling convention to - /// use, which may depend on the ABI. - unsigned getEffectiveCallingConvention() const { - return EffectiveCallingConvention; - } - void setEffectiveCallingConvention(unsigned Value) { - EffectiveCallingConvention = Value; - } - - bool getHasRegParm() const { return HasRegParm; } - unsigned getRegParm() const { return RegParm; } - - FunctionType::ExtInfo getExtInfo() const { - return FunctionType::ExtInfo(isNoReturn(), - getHasRegParm(), getRegParm(), - getASTCallingConvention(), - isReturnsRetained()); - } - - CanQualType getReturnType() const { return getArgsBuffer()[0].type; } - - ABIArgInfo &getReturnInfo() { return getArgsBuffer()[0].info; } - const ABIArgInfo &getReturnInfo() const { return getArgsBuffer()[0].info; } - - /// \brief Return true if this function uses inalloca arguments. - bool usesInAlloca() const { return ArgStruct; } - - /// \brief Get the struct type used to represent all the arguments in memory. - llvm::StructType *getArgStruct() const { return ArgStruct; } - CharUnits getArgStructAlignment() const { - return CharUnits::fromQuantity(ArgStructAlign); - } - void setArgStruct(llvm::StructType *Ty, CharUnits Align) { - ArgStruct = Ty; - ArgStructAlign = Align.getQuantity(); - } - - void Profile(llvm::FoldingSetNodeID &ID) { - ID.AddInteger(getASTCallingConvention()); - ID.AddBoolean(InstanceMethod); - ID.AddBoolean(ChainCall); - ID.AddBoolean(NoReturn); - ID.AddBoolean(ReturnsRetained); - ID.AddBoolean(HasRegParm); - ID.AddInteger(RegParm); - ID.AddInteger(Required.getOpaqueData()); - getReturnType().Profile(ID); - for (const auto &I : arguments()) - I.type.Profile(ID); - } - static void Profile(llvm::FoldingSetNodeID &ID, - bool InstanceMethod, - bool ChainCall, - const FunctionType::ExtInfo &info, - RequiredArgs required, - CanQualType resultType, - ArrayRef<CanQualType> argTypes) { - ID.AddInteger(info.getCC()); - ID.AddBoolean(InstanceMethod); - ID.AddBoolean(ChainCall); - ID.AddBoolean(info.getNoReturn()); - ID.AddBoolean(info.getProducesResult()); - ID.AddBoolean(info.getHasRegParm()); - ID.AddInteger(info.getRegParm()); - ID.AddInteger(required.getOpaqueData()); - resultType.Profile(ID); - for (ArrayRef<CanQualType>::iterator - i = argTypes.begin(), e = argTypes.end(); i != e; ++i) { - i->Profile(ID); - } - } -}; - -/// CGCalleeInfo - Class to encapsulate the information about a callee to be -/// used during the generation of call/invoke instructions. -class CGCalleeInfo { - /// \brief The function proto type of the callee. - const FunctionProtoType *CalleeProtoTy; - /// \brief The function declaration of the callee. - const Decl *CalleeDecl; - -public: - explicit CGCalleeInfo() : CalleeProtoTy(nullptr), CalleeDecl(nullptr) {} - CGCalleeInfo(const FunctionProtoType *calleeProtoTy, const Decl *calleeDecl) - : CalleeProtoTy(calleeProtoTy), CalleeDecl(calleeDecl) {} - CGCalleeInfo(const FunctionProtoType *calleeProtoTy) - : CalleeProtoTy(calleeProtoTy), CalleeDecl(nullptr) {} - CGCalleeInfo(const Decl *calleeDecl) - : CalleeProtoTy(nullptr), CalleeDecl(calleeDecl) {} - - const FunctionProtoType *getCalleeFunctionProtoType() { - return CalleeProtoTy; - } - const Decl *getCalleeDecl() { return CalleeDecl; } -}; - -} // end namespace CodeGen -} // end namespace clang - -#endif diff --git a/include/clang/CodeGen/CodeGenABITypes.h b/include/clang/CodeGen/CodeGenABITypes.h deleted file mode 100644 index 9d9504a..0000000 --- a/include/clang/CodeGen/CodeGenABITypes.h +++ /dev/null @@ -1,91 +0,0 @@ -//==---- CodeGenABITypes.h - Convert Clang types to LLVM types for ABI -----==// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// CodeGenABITypes is a simple interface for getting LLVM types for -// the parameters and the return value of a function given the Clang -// types. -// -// The class is implemented as a public wrapper around the private -// CodeGenTypes class in lib/CodeGen. -// -// It allows other clients, like LLDB, to determine the LLVM types that are -// actually used in function calls, which makes it possible to then determine -// the acutal ABI locations (e.g. registers, stack locations, etc.) that -// these parameters are stored in. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_CODEGEN_CODEGENABITYPES_H -#define LLVM_CLANG_CODEGEN_CODEGENABITYPES_H - -#include "clang/AST/CanonicalType.h" -#include "clang/AST/Type.h" -#include "clang/CodeGen/CGFunctionInfo.h" - -namespace llvm { - class DataLayout; - class Module; -} - -namespace clang { -class ASTContext; -class CXXRecordDecl; -class CXXMethodDecl; -class CodeGenOptions; -class CoverageSourceInfo; -class DiagnosticsEngine; -class HeaderSearchOptions; -class ObjCMethodDecl; -class PreprocessorOptions; - -namespace CodeGen { -class CGFunctionInfo; -class CodeGenModule; - -class CodeGenABITypes -{ -public: - CodeGenABITypes(ASTContext &C, llvm::Module &M, - CoverageSourceInfo *CoverageInfo = nullptr); - ~CodeGenABITypes(); - - /// These methods all forward to methods in the private implementation class - /// CodeGenTypes. - - const CGFunctionInfo &arrangeObjCMessageSendSignature( - const ObjCMethodDecl *MD, - QualType receiverType); - const CGFunctionInfo &arrangeFreeFunctionType(CanQual<FunctionProtoType> Ty, - const FunctionDecl *FD); - const CGFunctionInfo &arrangeFreeFunctionType( - CanQual<FunctionNoProtoType> Ty); - const CGFunctionInfo &arrangeCXXMethodType(const CXXRecordDecl *RD, - const FunctionProtoType *FTP, - const CXXMethodDecl *MD); - const CGFunctionInfo &arrangeFreeFunctionCall(CanQualType returnType, - ArrayRef<CanQualType> argTypes, - FunctionType::ExtInfo info, - RequiredArgs args); - -private: - /// Default CodeGenOptions object used to initialize the - /// CodeGenModule and otherwise not used. More specifically, it is - /// not used in ABI type generation, so none of the options matter. - std::unique_ptr<CodeGenOptions> CGO; - std::unique_ptr<HeaderSearchOptions> HSO; - std::unique_ptr<PreprocessorOptions> PPO; - - /// The CodeGenModule we use get to the CodeGenTypes object. - std::unique_ptr<CodeGen::CodeGenModule> CGM; -}; - -} // end namespace CodeGen -} // end namespace clang - -#endif diff --git a/include/clang/CodeGen/CodeGenAction.h b/include/clang/CodeGen/CodeGenAction.h deleted file mode 100644 index cc38e24..0000000 --- a/include/clang/CodeGen/CodeGenAction.h +++ /dev/null @@ -1,107 +0,0 @@ -//===--- 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_CODEGENACTION_H -#define LLVM_CLANG_CODEGEN_CODEGENACTION_H - -#include "clang/Frontend/FrontendAction.h" -#include <memory> - -namespace llvm { - class LLVMContext; - class Module; -} - -namespace clang { -class BackendConsumer; - -class CodeGenAction : public ASTFrontendAction { -private: - unsigned Act; - std::unique_ptr<llvm::Module> TheModule; - // Vector of {Linker::Flags, Module*} pairs to specify bitcode - // modules to link in using corresponding linker flags. - SmallVector<std::pair<unsigned, llvm::Module *>, 4> LinkModules; - llvm::LLVMContext *VMContext; - bool OwnsVMContext; - -protected: - /// Create a new code generation action. If the optional \p _VMContext - /// parameter is supplied, the action uses it without taking ownership, - /// otherwise it creates a fresh LLVM context and takes ownership. - CodeGenAction(unsigned _Act, llvm::LLVMContext *_VMContext = nullptr); - - bool hasIRSupport() const override; - - std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) override; - - void ExecuteAction() override; - - void EndSourceFileAction() override; - -public: - ~CodeGenAction() override; - - /// setLinkModule - Set the link module to be used by this action. If a link - /// module is not provided, and CodeGenOptions::LinkBitcodeFile is non-empty, - /// the action will load it from the specified file. - void addLinkModule(llvm::Module *Mod, unsigned LinkFlags) { - LinkModules.push_back(std::make_pair(LinkFlags, Mod)); - } - - /// Take the generated LLVM module, for use after the action has been run. - /// The result may be null on failure. - std::unique_ptr<llvm::Module> takeModule(); - - /// Take the LLVM context used by this action. - llvm::LLVMContext *takeLLVMContext(); - - BackendConsumer *BEConsumer; -}; - -class EmitAssemblyAction : public CodeGenAction { - virtual void anchor(); -public: - EmitAssemblyAction(llvm::LLVMContext *_VMContext = nullptr); -}; - -class EmitBCAction : public CodeGenAction { - virtual void anchor(); -public: - EmitBCAction(llvm::LLVMContext *_VMContext = nullptr); -}; - -class EmitLLVMAction : public CodeGenAction { - virtual void anchor(); -public: - EmitLLVMAction(llvm::LLVMContext *_VMContext = nullptr); -}; - -class EmitLLVMOnlyAction : public CodeGenAction { - virtual void anchor(); -public: - EmitLLVMOnlyAction(llvm::LLVMContext *_VMContext = nullptr); -}; - -class EmitCodeGenOnlyAction : public CodeGenAction { - virtual void anchor(); -public: - EmitCodeGenOnlyAction(llvm::LLVMContext *_VMContext = nullptr); -}; - -class EmitObjAction : public CodeGenAction { - virtual void anchor(); -public: - EmitObjAction(llvm::LLVMContext *_VMContext = nullptr); -}; - -} - -#endif diff --git a/include/clang/CodeGen/ModuleBuilder.h b/include/clang/CodeGen/ModuleBuilder.h deleted file mode 100644 index 52497d9..0000000 --- a/include/clang/CodeGen/ModuleBuilder.h +++ /dev/null @@ -1,54 +0,0 @@ -//===--- CodeGen/ModuleBuilder.h - Build LLVM from ASTs ---------*- 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 ModuleBuilder interface. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_CLANG_CODEGEN_MODULEBUILDER_H -#define LLVM_CLANG_CODEGEN_MODULEBUILDER_H - -#include "clang/AST/ASTConsumer.h" -#include <string> - -namespace llvm { - class LLVMContext; - class Module; -} - -namespace clang { - class DiagnosticsEngine; - class CoverageSourceInfo; - class LangOptions; - class HeaderSearchOptions; - class PreprocessorOptions; - class CodeGenOptions; - class Decl; - - class CodeGenerator : public ASTConsumer { - virtual void anchor(); - public: - virtual llvm::Module* GetModule() = 0; - virtual llvm::Module* ReleaseModule() = 0; - virtual const Decl *GetDeclForMangledName(llvm::StringRef MangledName) = 0; - }; - - /// CreateLLVMCodeGen - Create a CodeGenerator instance. - /// It is the responsibility of the caller to call delete on - /// the allocated CodeGenerator instance. - CodeGenerator *CreateLLVMCodeGen(DiagnosticsEngine &Diags, - const std::string &ModuleName, - const HeaderSearchOptions &HeaderSearchOpts, - const PreprocessorOptions &PreprocessorOpts, - const CodeGenOptions &CGO, - llvm::LLVMContext& C, - CoverageSourceInfo *CoverageInfo = nullptr); -} - -#endif diff --git a/include/clang/CodeGen/ObjectFilePCHContainerOperations.h b/include/clang/CodeGen/ObjectFilePCHContainerOperations.h deleted file mode 100644 index 15132ac..0000000 --- a/include/clang/CodeGen/ObjectFilePCHContainerOperations.h +++ /dev/null @@ -1,43 +0,0 @@ -//===-- CodeGen/ObjectFilePCHContainerOperations.h - ------------*- 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_OBJECT_FILE_PCH_CONTAINER_OPERATIONS_H -#define LLVM_CLANG_CODEGEN_OBJECT_FILE_PCH_CONTAINER_OPERATIONS_H - -#include "clang/Frontend/PCHContainerOperations.h" - -namespace clang { - -/// A PCHContainerWriter implementation that uses LLVM to -/// wraps Clang modules inside a COFF, ELF, or Mach-O container. -class ObjectFilePCHContainerWriter : public PCHContainerWriter { - StringRef getFormat() const override { return "obj"; } - - /// Return an ASTConsumer that can be chained with a - /// PCHGenerator that produces a wrapper file format - /// that also contains full debug info for the module. - std::unique_ptr<ASTConsumer> CreatePCHContainerGenerator( - CompilerInstance &CI, const std::string &MainFileName, - const std::string &OutputFileName, llvm::raw_pwrite_stream *OS, - std::shared_ptr<PCHBuffer> Buffer) const override; -}; - -/// A PCHContainerReader implementation that uses LLVM to -/// wraps Clang modules inside a COFF, ELF, or Mach-O container. -class ObjectFilePCHContainerReader : public PCHContainerReader { - StringRef getFormat() const override { return "obj"; } - - /// Initialize an llvm::BitstreamReader with the serialized - /// AST inside the PCH container Buffer. - void ExtractPCH(llvm::MemoryBufferRef Buffer, - llvm::BitstreamReader &StreamFile) const override; -}; -} - -#endif |