diff options
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 87 |
1 files changed, 68 insertions, 19 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index 6cb0b3304e..0155f033e6 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -78,6 +78,17 @@ namespace CodeGen { class BlockFlags; class BlockFieldFlags; +/// The kind of evaluation to perform on values of a particular +/// type. Basically, is the code in CGExprScalar, CGExprComplex, or +/// CGExprAgg? +/// +/// TODO: should vectors maybe be split out into their own thing? +enum TypeEvaluationKind { + TEK_Scalar, + TEK_Complex, + TEK_Aggregate +}; + /// A branch fixup. These are required when emitting a goto to a /// label which hasn't been emitted yet. The goto is optimistically /// emitted as a branch to the basic block for the label, and (if it @@ -796,7 +807,9 @@ public: class RunCleanupsScope { EHScopeStack::stable_iterator CleanupStackDepth; bool OldDidCallStackSave; + protected: bool PerformCleanup; + private: RunCleanupsScope(const RunCleanupsScope &) LLVM_DELETED_FUNCTION; void operator=(const RunCleanupsScope &) LLVM_DELETED_FUNCTION; @@ -840,7 +853,6 @@ public: class LexicalScope: protected RunCleanupsScope { SourceRange Range; - bool PopDebugStack; LexicalScope(const LexicalScope &) LLVM_DELETED_FUNCTION; void operator=(const LexicalScope &) LLVM_DELETED_FUNCTION; @@ -848,7 +860,7 @@ public: public: /// \brief Enter a new cleanup scope. explicit LexicalScope(CodeGenFunction &CGF, SourceRange Range) - : RunCleanupsScope(CGF), Range(Range), PopDebugStack(true) { + : RunCleanupsScope(CGF), Range(Range) { if (CGDebugInfo *DI = CGF.getDebugInfo()) DI->EmitLexicalBlockStart(CGF.Builder, Range.getBegin()); } @@ -856,20 +868,20 @@ public: /// \brief Exit this cleanup scope, emitting any accumulated /// cleanups. ~LexicalScope() { - if (PopDebugStack) { - CGDebugInfo *DI = CGF.getDebugInfo(); - if (DI) DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd()); - } + if (PerformCleanup) endLexicalScope(); } /// \brief Force the emission of cleanups now, instead of waiting /// until this object is destroyed. void ForceCleanup() { RunCleanupsScope::ForceCleanup(); - if (CGDebugInfo *DI = CGF.getDebugInfo()) { + endLexicalScope(); + } + + private: + void endLexicalScope() { + if (CGDebugInfo *DI = CGF.getDebugInfo()) DI->EmitLexicalBlockEnd(CGF.Builder, Range.getEnd()); - PopDebugStack = false; - } } }; @@ -1202,6 +1214,9 @@ private: /// Add a kernel metadata node to the named metadata node 'opencl.kernels'. /// In the kernel metadata node, reference the kernel function and metadata /// nodes for its optional attribute qualifiers (OpenCL 1.1 6.7.2): + /// - A node for the vec_type_hint(<type>) qualifier contains string + /// "vec_type_hint", an undefined value of the <type> data type, + /// and a Boolean that is true if the <type> is integer and signed. /// - A node for the work_group_size_hint(X,Y,Z) qualifier contains string /// "work_group_size_hint", and three 32-bit integers X, Y and Z. /// - A node for the reqd_work_group_size(X,Y,Z) qualifier contains string @@ -1514,7 +1529,15 @@ public: /// hasAggregateLLVMType - Return true if the specified AST type will map into /// an aggregate LLVM type or is void. - static bool hasAggregateLLVMType(QualType T); + static TypeEvaluationKind getEvaluationKind(QualType T); + + static bool hasScalarEvaluationKind(QualType T) { + return getEvaluationKind(T) == TEK_Scalar; + } + + static bool hasAggregateEvaluationKind(QualType T) { + return getEvaluationKind(T) == TEK_Aggregate; + } /// createBasicBlock - Create an LLVM basic block. llvm::BasicBlock *createBasicBlock(const Twine &name = "", @@ -2127,6 +2150,15 @@ public: /// that the address will be used to access the object. LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK); + RValue convertTempToRValue(llvm::Value *addr, QualType type); + + void EmitAtomicInit(Expr *E, LValue lvalue); + + RValue EmitAtomicLoad(LValue lvalue, + AggValueSlot slot = AggValueSlot::ignored()); + + void EmitAtomicStore(RValue rvalue, LValue lvalue, bool isInit); + /// EmitToMemory - Change a scalar value from its value /// representation to its in-memory representation. llvm::Value *EmitToMemory(llvm::Value *Value, QualType Ty); @@ -2301,11 +2333,29 @@ public: RValue EmitCallExpr(const CallExpr *E, ReturnValueSlot ReturnValue = ReturnValueSlot()); + llvm::CallInst *EmitRuntimeCall(llvm::Value *callee, + const Twine &name = ""); + llvm::CallInst *EmitRuntimeCall(llvm::Value *callee, + ArrayRef<llvm::Value*> args, + const Twine &name = ""); + llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee, + const Twine &name = ""); + llvm::CallInst *EmitNounwindRuntimeCall(llvm::Value *callee, + ArrayRef<llvm::Value*> args, + const Twine &name = ""); + llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee, ArrayRef<llvm::Value *> Args, const Twine &Name = ""); llvm::CallSite EmitCallOrInvoke(llvm::Value *Callee, const Twine &Name = ""); + llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, + ArrayRef<llvm::Value*> args, + const Twine &name = ""); + llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, + const Twine &name = ""); + void EmitNoreturnRuntimeCallOrInvoke(llvm::Value *callee, + ArrayRef<llvm::Value*> args); llvm::Value *BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *This, llvm::Type *Ty); @@ -2485,16 +2535,15 @@ public: bool IgnoreReal = false, bool IgnoreImag = false); - /// EmitComplexExprIntoAddr - Emit the computation of the specified expression - /// of complex type, storing into the specified Value*. - void EmitComplexExprIntoAddr(const Expr *E, llvm::Value *DestAddr, - bool DestIsVolatile); + /// EmitComplexExprIntoLValue - Emit the given expression of complex + /// type and place its result into the specified l-value. + void EmitComplexExprIntoLValue(const Expr *E, LValue dest, bool isInit); + + /// EmitStoreOfComplex - Store a complex number into the specified l-value. + void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit); - /// StoreComplexToAddr - Store a complex number into the specified address. - void StoreComplexToAddr(ComplexPairTy V, llvm::Value *DestAddr, - bool DestIsVolatile); - /// LoadComplexFromAddr - Load a complex number from the specified address. - ComplexPairTy LoadComplexFromAddr(llvm::Value *SrcAddr, bool SrcIsVolatile); + /// EmitLoadOfComplex - Load a complex number from the specified l-value. + ComplexPairTy EmitLoadOfComplex(LValue src); /// CreateStaticVarDecl - Create a zero-initialized LLVM global for /// a static local variable. |