mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-26 12:43:36 +01:00
Add support for setjmp/longjmp primitives
Patch checked in for Bill Wendling :) llvm-svn: 6241
This commit is contained in:
parent
e8cd1e362c
commit
435e5592a9
@ -12,9 +12,13 @@
|
||||
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
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -543,6 +543,7 @@ void CWriter::printModule(Module *M) {
|
||||
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.
|
||||
@ -1022,7 +1023,6 @@ void CWriter::visitCallInst(CallInst &I) {
|
||||
writeOperand(&I.getParent()->getParent()->aback());
|
||||
Out << ")";
|
||||
return;
|
||||
|
||||
case LLVMIntrinsic::va_end:
|
||||
Out << "va_end((va_list)*";
|
||||
writeOperand(I.getOperand(1));
|
||||
@ -1035,6 +1035,19 @@ void CWriter::visitCallInst(CallInst &I) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,20 +164,16 @@ unsigned Function::getIntrinsicID() const {
|
||||
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!
|
||||
|
@ -517,8 +517,10 @@ void Verifier::visitIntrinsicFunctionCall(LLVMIntrinsic::ID ID, CallInst &CI) {
|
||||
" 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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user