enum ID {
not_intrinsic = 0, // Must be zero
+ // Varargs handling intrinsics...
va_start, // Used to represent a va_start call in C
va_end, // Used to represent a va_end call in C
va_copy, // Used to represent a va_copy call in C
+ // Exception handling intrinsics...
+ exc_throw, // Throw an exception
+ exc_rethrow, // Rethrow a caught exception
+ exc_getcurrent, // Get the current pending exception
+
+ // Setjmp/Longjmp intrinsics...
setjmp, // Used to represent a setjmp call in C
longjmp, // Used to represent a longjmp call in C
sigsetjmp, // Used to represent a sigsetjmp call in C
switch (getName()[5]) {
case 'a':
- for (unsigned i = 0; i < num_alpha_intrinsics; ++i) {
- if (getName() == alpha_intrinsics[i].name)
- return alpha_intrinsics[i].id;
- }
+ if (getName().size() > 11 &&
+ std::string(getName().begin()+4, getName().begin()+11) == ".alpha.")
+ for (unsigned i = 0; i < num_alpha_intrinsics; ++i)
+ if (getName() == alpha_intrinsics[i].name)
+ return alpha_intrinsics[i].id;
+ break;
+ case 'e':
+ if (getName() == "llvm.exc.getcurrent")return LLVMIntrinsic::exc_getcurrent;
+ if (getName() == "llvm.exc.rethrow") return LLVMIntrinsic::exc_getcurrent;
+ if (getName() == "llvm.exc.throw") return LLVMIntrinsic::exc_getcurrent;
break;
case 'l':
if (getName() == "llvm.longjmp") return LLVMIntrinsic::longjmp;
Assert1(IF->isExternal(), "Intrinsic functions should never be defined!", IF);
unsigned NumArgs = 0;
+ // FIXME: this should check the return type of each intrinsic as well, also
+ // arguments!
switch (ID) {
case LLVMIntrinsic::va_start:
Assert1(CI.getParent()->getParent()->getFunctionType()->isVarArg(),
break;
case LLVMIntrinsic::va_end: NumArgs = 1; break;
case LLVMIntrinsic::va_copy: NumArgs = 2; break;
+
+ case LLVMIntrinsic::exc_throw: NumArgs = 1; break;
+ case LLVMIntrinsic::exc_rethrow: NumArgs = 0; break;
+ case LLVMIntrinsic::exc_getcurrent: NumArgs = 0; break;
+
case LLVMIntrinsic::setjmp: NumArgs = 1; break;
case LLVMIntrinsic::longjmp: NumArgs = 2; break;
case LLVMIntrinsic::sigsetjmp: NumArgs = 2; break;