does not throw property for Function (Andrew Straw)

git-svn-id: http://llvm-py.googlecode.com/svn/trunk@79 8d1e9007-1d4e-0410-b67e-1979fd6579aa
This commit is contained in:
mdevan.foobar 2009-09-20 09:25:14 +00:00
commit 6cb58c97d7
5 changed files with 33 additions and 1 deletions

View file

@ -505,6 +505,8 @@ _wrap_obj2obj(LLVMGetFunctionCallConv, LLVMValueRef, int)
_wrap_objint2none(LLVMSetFunctionCallConv, LLVMValueRef)
_wrap_obj2str(LLVMGetGC, LLVMValueRef)
_wrap_objstr2none(LLVMSetGC, LLVMValueRef)
_wrap_obj2obj(LLVMGetDoesNotThrow, LLVMValueRef, int)
_wrap_objint2none(LLVMSetDoesNotThrow, LLVMValueRef)
_wrap_obj2none(LLVMViewFunctionCFG, LLVMValueRef)
_wrap_obj2none(LLVMViewFunctionCFGOnly, LLVMValueRef)
@ -1324,6 +1326,8 @@ static PyMethodDef core_methods[] = {
_method( LLVMSetFunctionCallConv )
_method( LLVMGetGC )
_method( LLVMSetGC )
_method( LLVMGetDoesNotThrow )
_method( LLVMSetDoesNotThrow )
_method( LLVMVerifyFunction )
_method( LLVMViewFunctionCFG )
_method( LLVMViewFunctionCFGOnly )

View file

@ -1286,6 +1286,11 @@ class Function(GlobalValue):
def _set_coll(self, value): _core.LLVMSetGC(self.ptr, value)
collector = property(_get_coll, _set_coll)
# the nounwind attribute:
def _get_does_not_throw(self): return _core.LLVMGetDoesNotThrow(self.ptr)
def _set_does_not_throw(self,value): _core.LLVMSetDoesNotThrow(self.ptr, value)
does_not_throw = property(_get_does_not_throw, _set_does_not_throw)
@property
def args(self):
return _util.wrapiter(_core.LLVMGetFirstParam,
@ -1324,7 +1329,6 @@ class Function(GlobalValue):
# failure, it appears to print result to stderr and abort.
return _core.LLVMVerifyFunction(self.ptr) != 0
#===----------------------------------------------------------------------===
# Instruction
#===----------------------------------------------------------------------===

View file

@ -365,6 +365,22 @@ LLVMValueRef LLVMUserGetOperand(LLVMValueRef user, unsigned idx)
return llvm::wrap(operand);
}
unsigned LLVMGetDoesNotThrow(LLVMValueRef fn)
{
llvm::Function *fnp = llvm::unwrap<llvm::Function>(fn);
assert(fnp);
return fnp->doesNotThrow();
}
void LLVMSetDoesNotThrow(LLVMValueRef fn, int DoesNotThrow)
{
llvm::Function *fnp = llvm::unwrap<llvm::Function>(fn);
assert(fnp);
return fnp->setDoesNotThrow((bool)DoesNotThrow);
}
LLVMValueRef LLVMGetIntrinsic(LLVMModuleRef module, int id,
LLVMTypeRef *types, unsigned n_types)
{

View file

@ -107,6 +107,12 @@ LLVMValueRef LLVMBuildVFCmp(LLVMBuilderRef builder, LLVMRealPredicate predicate,
LLVMValueRef LLVMGetIntrinsic(LLVMModuleRef builder, int id,
LLVMTypeRef *types, unsigned n_types);
/* Wraps llvm::Function::doesNotThrow(). */
unsigned LLVMGetDoesNotThrow(LLVMValueRef fn);
/* Wraps llvm::Function::setDoesNotThrow(). */
void LLVMSetDoesNotThrow(LLVMValueRef fn, int DoesNotThrow);
/* Wraps llvm::Module::getPointerSize(). */
unsigned LLVMModuleGetPointerSize(LLVMModuleRef module);

View file

@ -282,6 +282,8 @@ def do_function():
f.delete()
ft = Type.function(ti, [ti]*20)
f = Function.new(m, ft, 'func2')
has_nounwind = f.does_not_throw
f.does_not_throw = True
f2 = Function.intrinsic(m, INTR_COS, [ti])
g = f.intrinsic_id
f.calling_convenion = CC_FASTCALL