summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2008-09-09 10:10:21 +0000
committerAnders Carlsson <andersca@mac.com>2008-09-09 10:10:21 +0000
commit9ff22483fd776d0f7d9983d8c10cb79b9cf008eb (patch)
treec84f94a0e7490d848d1cc30276f85d3b37c01e75 /clang/lib/CodeGen
parent1963b0c38feaa6a5c98484305b7a858478ac4755 (diff)
downloadbcm5719-llvm-9ff22483fd776d0f7d9983d8c10cb79b9cf008eb.tar.gz
bcm5719-llvm-9ff22483fd776d0f7d9983d8c10cb79b9cf008eb.zip
Add types and functions related to exceptions.
llvm-svn: 55984
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp93
1 files changed, 93 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index f0e70978f7b..ea34d11318c 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -132,6 +132,28 @@ public:
const llvm::Type *MethodListPtrTy;
llvm::Function *EnumerationMutationFn;
+
+ /// ExceptionDataTy - LLVM type for struct _objc_exception_data.
+ const llvm::Type *ExceptionDataTy;
+
+ /// ExceptionThrowFn - LLVM objc_exception_throw function.
+ llvm::Function *ExceptionThrowFn;
+
+ /// ExceptionTryEnterFn - LLVM objc_exception_try_enter function.
+ llvm::Function *ExceptionTryEnterFn;
+
+ /// ExceptionTryExitFn - LLVM objc_exception_try_exit function.
+ llvm::Function *ExceptionTryExitFn;
+
+ /// ExceptionExtractFn - LLVM objc_exception_extract function.
+ llvm::Function *ExceptionExtractFn;
+
+ /// ExceptionMatchFn - LLVM objc_exception_match function.
+ llvm::Function *ExceptionMatchFn;
+
+ /// SetJmpFn - LLVM _setjmp function.
+ llvm::Function *SetJmpFn;
+
public:
ObjCTypesHelper(CodeGen::CodeGenModule &cgm);
~ObjCTypesHelper();
@@ -1977,6 +1999,77 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
llvm::Function::ExternalLinkage,
"objc_enumerationMutation",
&CGM.getModule());
+
+ // FIXME: This is the size of the setjmp buffer and should be
+ // target specific. 18 is what's used on 32-bit X86.
+ uint64_t SetJmpBufferSize = 18;
+
+ // Exceptions
+ const llvm::Type *StackPtrTy =
+ llvm::PointerType::getUnqual(llvm::ArrayType::get(llvm::Type::Int8Ty, 4));
+
+ ExceptionDataTy =
+ llvm::StructType::get(llvm::ArrayType::get(llvm::Type::Int32Ty,
+ SetJmpBufferSize),
+ StackPtrTy, NULL);
+ CGM.getModule().addTypeName("struct._objc_exception_data",
+ ExceptionDataTy);
+
+ Params.clear();
+ Params.push_back(ObjectPtrTy);
+ ExceptionThrowFn =
+ llvm::Function::Create(llvm::FunctionType::get(llvm::Type::VoidTy,
+ Params,
+ false),
+ llvm::Function::ExternalLinkage,
+ "objc_exception_throw",
+ &CGM.getModule());
+
+ Params.clear();
+ Params.push_back(llvm::PointerType::getUnqual(ExceptionDataTy));
+ ExceptionTryEnterFn =
+ llvm::Function::Create(llvm::FunctionType::get(llvm::Type::VoidTy,
+ Params,
+ false),
+ llvm::Function::ExternalLinkage,
+ "objc_exception_try_enter",
+ &CGM.getModule());
+ ExceptionTryExitFn =
+ llvm::Function::Create(llvm::FunctionType::get(llvm::Type::VoidTy,
+ Params,
+ false),
+ llvm::Function::ExternalLinkage,
+ "objc_exception_try_exit",
+ &CGM.getModule());
+ ExceptionExtractFn =
+ llvm::Function::Create(llvm::FunctionType::get(ObjectPtrTy,
+ Params,
+ false),
+ llvm::Function::ExternalLinkage,
+ "objc_exception_extract",
+ &CGM.getModule());
+
+ Params.clear();
+ Params.push_back(ClassPtrTy);
+ Params.push_back(ObjectPtrTy);
+ ExceptionMatchFn =
+ llvm::Function::Create(llvm::FunctionType::get(llvm::Type::Int32Ty,
+ Params,
+ false),
+ llvm::Function::ExternalLinkage,
+ "objc_exception_match",
+ &CGM.getModule());
+
+ Params.clear();
+ Params.push_back(llvm::PointerType::getUnqual(llvm::Type::Int32Ty));
+ SetJmpFn =
+ llvm::Function::Create(llvm::FunctionType::get(llvm::Type::Int32Ty,
+ Params,
+ false),
+ llvm::Function::ExternalLinkage,
+ "_setjmp",
+ &CGM.getModule());
+
}
ObjCTypesHelper::~ObjCTypesHelper() {
OpenPOWER on IntegriCloud