namespace LLVMIntrinsic {
enum ID {
not_intrinsic = 0, // Must be zero
+
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
+
+ setjmp, // Used to represent a setjmp call in C
+ longjmp, // Used to represent a longjmp call in C
};
}
Out << "/* Provide Declarations */\n";
generateAllocaDecl(Out);
Out << "#include <stdarg.h>\n";
+ Out << "#include <setjmp.h>\n";
// Provide a definition for null if one does not already exist,
// and for `bool' if not compiling with a C++ compiler.
writeOperand(&I.getParent()->getParent()->aback());
Out << ")";
return;
-
case LLVMIntrinsic::va_end:
Out << "va_end((va_list)*";
writeOperand(I.getOperand(1));
writeOperand(I.getOperand(2));
Out << ")";
return;
+
+ case LLVMIntrinsic::setjmp:
+ Out << "setjmp((jmp_buf)";
+ writeOperand(I.getOperand(1));
+ Out << ")";
+ return;
+ case LLVMIntrinsic::longjmp:
+ Out << "longjmp((jmp_buf)";
+ writeOperand(I.getOperand(1));
+ Out << ", ";
+ writeOperand(I.getOperand(2));
+ Out << ")";
+ return;
}
}
Out << "/* Provide Declarations */\n";
generateAllocaDecl(Out);
Out << "#include <stdarg.h>\n";
+ Out << "#include <setjmp.h>\n";
// Provide a definition for null if one does not already exist,
// and for `bool' if not compiling with a C++ compiler.
writeOperand(&I.getParent()->getParent()->aback());
Out << ")";
return;
-
case LLVMIntrinsic::va_end:
Out << "va_end((va_list)*";
writeOperand(I.getOperand(1));
writeOperand(I.getOperand(2));
Out << ")";
return;
+
+ case LLVMIntrinsic::setjmp:
+ Out << "setjmp((jmp_buf)";
+ writeOperand(I.getOperand(1));
+ Out << ")";
+ return;
+ case LLVMIntrinsic::longjmp:
+ Out << "longjmp((jmp_buf)";
+ writeOperand(I.getOperand(1));
+ Out << ", ";
+ writeOperand(I.getOperand(2));
+ Out << ")";
+ return;
}
}
return 0; // All intrinsics start with 'llvm.'
switch (getName()[5]) {
+ case 'l':
+ if (getName() == "llvm.longjmp") return LLVMIntrinsic::longjmp;
+ break;
+ case 's':
+ if (getName() == "llvm.setjmp") return LLVMIntrinsic::setjmp;
+ break;
case 'v':
- if (getName().size() >= 9) {
- switch (getName()[8]) {
- case 's':
- if (getName() == "llvm.va_start") return LLVMIntrinsic::va_start;
- break;
- case 'e':
- if (getName() == "llvm.va_end") return LLVMIntrinsic::va_end;
- break;
- case 'c':
- if (getName() == "llvm.va_copy") return LLVMIntrinsic::va_copy;
- break;
- }
- }
+ if (getName() == "llvm.va_copy") return LLVMIntrinsic::va_copy;
+ if (getName() == "llvm.va_end") return LLVMIntrinsic::va_end;
+ if (getName() == "llvm.va_start") return LLVMIntrinsic::va_start;
break;
}
// The "llvm." namespace is reserved!
" args!", &CI);
NumArgs = 1;
break;
- case LLVMIntrinsic::va_end: NumArgs = 1; break;
+ case LLVMIntrinsic::va_end: NumArgs = 1; break;
case LLVMIntrinsic::va_copy: NumArgs = 2; break;
+ case LLVMIntrinsic::setjmp: NumArgs = 1; break;
+ case LLVMIntrinsic::longjmp: NumArgs = 2; break;
case LLVMIntrinsic::not_intrinsic:
assert(0 && "Invalid intrinsic!"); NumArgs = 0; break;
}