diff options
author | Anders Carlsson <andersca@mac.com> | 2008-08-30 19:51:14 +0000 |
---|---|---|
committer | Anders Carlsson <andersca@mac.com> | 2008-08-30 19:51:14 +0000 |
commit | 3d8400d9a61aa4b63ff35e5cede405b32a41425e (patch) | |
tree | b342d74378b17f4cba0a86ad7875f13aa624586f | |
parent | bd4c1ada2e8668f43a865dc2c662085cf61940c4 (diff) |
Stub out CodeGenFunction::EmitObjCForCollectionStmt.
Add CodeGenFunction::EmitMemSetToZero and make AggExprEmitter::EmitAggregateClear use it.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@55573 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 19 | ||||
-rw-r--r-- | lib/CodeGen/CGObjC.cpp | 6 | ||||
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 4 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.cpp | 20 | ||||
-rw-r--r-- | lib/CodeGen/CodeGenFunction.h | 5 |
5 files changed, 34 insertions, 20 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 13c07c9596..c007cc0ae9 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -114,24 +114,7 @@ public: void AggExprEmitter::EmitAggregateClear(llvm::Value *DestPtr, QualType Ty) { assert(!Ty->isAnyComplexType() && "Shouldn't happen for complex"); - // Aggregate assignment turns into llvm.memset. - const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); - if (DestPtr->getType() != BP) - DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp"); - - // Get size and alignment info for this aggregate. - std::pair<uint64_t, unsigned> TypeInfo = CGF.getContext().getTypeInfo(Ty); - - // FIXME: Handle variable sized types. - const llvm::Type *IntPtr = llvm::IntegerType::get(CGF.LLVMPointerWidth); - - Builder.CreateCall4(CGF.CGM.getMemSetFn(), - DestPtr, - llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty), - // TypeInfo.first describes size in bits. - llvm::ConstantInt::get(IntPtr, TypeInfo.first/8), - llvm::ConstantInt::get(llvm::Type::Int32Ty, - TypeInfo.second/8)); + CGF.EmitMemSetToZero(DestPtr, Ty); } void AggExprEmitter::EmitAggregateCopy(llvm::Value *DestPtr, diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp index 79b50114b7..3b7e3a13c9 100644 --- a/lib/CodeGen/CGObjC.cpp +++ b/lib/CodeGen/CGObjC.cpp @@ -16,6 +16,7 @@ #include "CodeGenModule.h" #include "clang/AST/ASTContext.h" #include "clang/AST/DeclObjC.h" +#include "llvm/ADT/STLExtras.h" using namespace clang; using namespace CodeGen; @@ -260,4 +261,9 @@ void CodeGenFunction::EmitObjCPropertySet(const ObjCPropertyRefExpr *E, false, Args); } +void CodeGenFunction::EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S) +{ + ErrorUnsupported(&S, "for ... in statement"); +} + CGObjCRuntime::~CGObjCRuntime() {} diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 6d3bd43d5b..b766fe8a64 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -92,8 +92,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S) { case Stmt::ObjCAtSynchronizedStmtClass: ErrorUnsupported(S, "@synchronized statement"); break; - case Stmt::ObjCForCollectionStmtClass: - ErrorUnsupported(S, "for ... in statement"); + case Stmt::ObjCForCollectionStmtClass: + EmitObjCForCollectionStmt(cast<ObjCForCollectionStmt>(*S)); break; } } diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 909486a6d1..09f3140773 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -201,6 +201,26 @@ unsigned CodeGenFunction::GetIDForAddrOfLabel(const LabelStmt *L) { return LabelIDs.insert(std::make_pair(L, LabelIDs.size())).first->second; } +void CodeGenFunction::EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty) +{ + const llvm::Type *BP = llvm::PointerType::getUnqual(llvm::Type::Int8Ty); + if (DestPtr->getType() != BP) + DestPtr = Builder.CreateBitCast(DestPtr, BP, "tmp"); + + // Get size and alignment info for this aggregate. + std::pair<uint64_t, unsigned> TypeInfo = getContext().getTypeInfo(Ty); + + // FIXME: Handle variable sized types. + const llvm::Type *IntPtr = llvm::IntegerType::get(LLVMPointerWidth); + + Builder.CreateCall4(CGM.getMemSetFn(), DestPtr, + llvm::ConstantInt::getNullValue(llvm::Type::Int8Ty), + // TypeInfo.first describes size in bits. + llvm::ConstantInt::get(IntPtr, TypeInfo.first/8), + llvm::ConstantInt::get(llvm::Type::Int32Ty, + TypeInfo.second/8)); +} + void CodeGenFunction::EmitIndirectSwitches() { llvm::BasicBlock *Default; diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h index c8421e609a..e43b2d3961 100644 --- a/lib/CodeGen/CodeGenFunction.h +++ b/lib/CodeGen/CodeGenFunction.h @@ -193,6 +193,9 @@ public: unsigned GetIDForAddrOfLabel(const LabelStmt *L); + /// EmitMemSetToZero - Generate code to memset a value of the given type to 0; + void EmitMemSetToZero(llvm::Value *DestPtr, QualType Ty); + //===--------------------------------------------------------------------===// // Declaration Emission //===--------------------------------------------------------------------===// @@ -230,6 +233,8 @@ public: void EmitCaseStmtRange(const CaseStmt &S); void EmitAsmStmt(const AsmStmt &S); + void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S); + //===--------------------------------------------------------------------===// // LValue Expression Emission //===--------------------------------------------------------------------===// |