llvm.org GIT mirror llvm / 9dd7d1c
Initial support for recognizing LLVM exception handling intrinsics git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8102 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
3 changed file(s) with 24 addition(s) and 4 deletion(s). Raw diff Collapse all Expand all
1616 enum ID {
1717 not_intrinsic = 0, // Must be zero
1818
19 // Varargs handling intrinsics...
1920 va_start, // Used to represent a va_start call in C
2021 va_end, // Used to represent a va_end call in C
2122 va_copy, // Used to represent a va_copy call in C
2223
24 // Exception handling intrinsics...
25 exc_throw, // Throw an exception
26 exc_rethrow, // Rethrow a caught exception
27 exc_getcurrent, // Get the current pending exception
28
29 // Setjmp/Longjmp intrinsics...
2330 setjmp, // Used to represent a setjmp call in C
2431 longjmp, // Used to represent a longjmp call in C
2532 sigsetjmp, // Used to represent a sigsetjmp call in C
188188
189189 switch (getName()[5]) {
190190 case 'a':
191 for (unsigned i = 0; i < num_alpha_intrinsics; ++i) {
192 if (getName() == alpha_intrinsics[i].name)
193 return alpha_intrinsics[i].id;
194 }
191 if (getName().size() > 11 &&
192 std::string(getName().begin()+4, getName().begin()+11) == ".alpha.")
193 for (unsigned i = 0; i < num_alpha_intrinsics; ++i)
194 if (getName() == alpha_intrinsics[i].name)
195 return alpha_intrinsics[i].id;
196 break;
197 case 'e':
198 if (getName() == "llvm.exc.getcurrent")return LLVMIntrinsic::exc_getcurrent;
199 if (getName() == "llvm.exc.rethrow") return LLVMIntrinsic::exc_getcurrent;
200 if (getName() == "llvm.exc.throw") return LLVMIntrinsic::exc_getcurrent;
195201 break;
196202 case 'l':
197203 if (getName() == "llvm.longjmp") return LLVMIntrinsic::longjmp;
509509 Assert1(IF->isExternal(), "Intrinsic functions should never be defined!", IF);
510510 unsigned NumArgs = 0;
511511
512 // FIXME: this should check the return type of each intrinsic as well, also
513 // arguments!
512514 switch (ID) {
513515 case LLVMIntrinsic::va_start:
514516 Assert1(CI.getParent()->getParent()->getFunctionType()->isVarArg(),
518520 break;
519521 case LLVMIntrinsic::va_end: NumArgs = 1; break;
520522 case LLVMIntrinsic::va_copy: NumArgs = 2; break;
523
524 case LLVMIntrinsic::exc_throw: NumArgs = 1; break;
525 case LLVMIntrinsic::exc_rethrow: NumArgs = 0; break;
526 case LLVMIntrinsic::exc_getcurrent: NumArgs = 0; break;
527
521528 case LLVMIntrinsic::setjmp: NumArgs = 1; break;
522529 case LLVMIntrinsic::longjmp: NumArgs = 2; break;
523530 case LLVMIntrinsic::sigsetjmp: NumArgs = 2; break;