Can now modify called_function of CallOrInvokeInstruction
This commit is contained in:
parent
507ff73061
commit
b9d05bb6fe
4 changed files with 19 additions and 3 deletions
|
|
@ -772,7 +772,7 @@ _wrap_objintint2none(LLVMSetInstrParamAlignment, LLVMValueRef)
|
||||||
_wrap_obj2obj(LLVMIsTailCall, LLVMValueRef, int)
|
_wrap_obj2obj(LLVMIsTailCall, LLVMValueRef, int)
|
||||||
_wrap_objint2none(LLVMSetTailCall, LLVMValueRef)
|
_wrap_objint2none(LLVMSetTailCall, LLVMValueRef)
|
||||||
_wrap_obj2obj(LLVMInstGetCalledFunction, LLVMValueRef, LLVMValueRef)
|
_wrap_obj2obj(LLVMInstGetCalledFunction, LLVMValueRef, LLVMValueRef)
|
||||||
|
_wrap_objobj2none(LLVMInstSetCalledFunction, LLVMValueRef, LLVMValueRef)
|
||||||
|
|
||||||
/*===-- PHI Nodes --------------------------------------------------------===*/
|
/*===-- PHI Nodes --------------------------------------------------------===*/
|
||||||
|
|
||||||
|
|
@ -1867,6 +1867,7 @@ static PyMethodDef core_methods[] = {
|
||||||
_method( LLVMRemoveInstrAttribute )
|
_method( LLVMRemoveInstrAttribute )
|
||||||
_method( LLVMSetInstrParamAlignment )
|
_method( LLVMSetInstrParamAlignment )
|
||||||
_method( LLVMInstGetCalledFunction )
|
_method( LLVMInstGetCalledFunction )
|
||||||
|
_method( LLVMInstSetCalledFunction )
|
||||||
|
|
||||||
/* PHI Nodes */
|
/* PHI Nodes */
|
||||||
_method( LLVMAddIncoming1 )
|
_method( LLVMAddIncoming1 )
|
||||||
|
|
|
||||||
|
|
@ -1670,12 +1670,16 @@ class CallOrInvokeInstruction(Instruction):
|
||||||
def set_parameter_alignment(self, idx, align):
|
def set_parameter_alignment(self, idx, align):
|
||||||
_core.LLVMSetInstrParamAlignment(self.ptr, idx, align)
|
_core.LLVMSetInstrParamAlignment(self.ptr, idx, align)
|
||||||
|
|
||||||
@property
|
def _get_called_function(self):
|
||||||
def called_function(self):
|
|
||||||
function = _core.LLVMInstGetCalledFunction(self.ptr)
|
function = _core.LLVMInstGetCalledFunction(self.ptr)
|
||||||
if function: # Return value can be None on indirect call/invoke
|
if function: # Return value can be None on indirect call/invoke
|
||||||
return _make_value(function)
|
return _make_value(function)
|
||||||
|
|
||||||
|
def _set_called_function(self, function):
|
||||||
|
_core.LLVMInstSetCalledFunction(self.ptr, function.ptr)
|
||||||
|
|
||||||
|
called_function = property(_get_called_function, _set_called_function)
|
||||||
|
|
||||||
# tail call is valid only for 'call', not 'invoke'
|
# tail call is valid only for 'call', not 'invoke'
|
||||||
# disabled for now
|
# disabled for now
|
||||||
#def _get_tc(self): return _core.LLVMIsTailCall(self.ptr)
|
#def _get_tc(self): return _core.LLVMIsTailCall(self.ptr)
|
||||||
|
|
|
||||||
|
|
@ -855,6 +855,13 @@ LLVMValueRef LLVMInstGetCalledFunction(LLVMValueRef inst)
|
||||||
return llvm::wrap(CallSite(instp).getCalledFunction());
|
return llvm::wrap(CallSite(instp).getCalledFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LLVMInstSetCalledFunction(LLVMValueRef inst, LLVMValueRef fn)
|
||||||
|
{
|
||||||
|
using namespace llvm;
|
||||||
|
Instruction *instp = unwrap<Instruction>(inst);
|
||||||
|
CallSite(instp).setCalledFunction(unwrap(fn));
|
||||||
|
}
|
||||||
|
|
||||||
///* llvm::unwrap a set of `n' wrapped objects starting at `values',
|
///* llvm::unwrap a set of `n' wrapped objects starting at `values',
|
||||||
// * into a vector of pointers to llvm::unwrapped objects `out'. */
|
// * into a vector of pointers to llvm::unwrapped objects `out'. */
|
||||||
//template <typename W, typename UW>
|
//template <typename W, typename UW>
|
||||||
|
|
|
||||||
|
|
@ -488,6 +488,10 @@ unsigned LLVMCmpInstGetPredicate(LLVMValueRef cmpinst);
|
||||||
*/
|
*/
|
||||||
LLVMValueRef LLVMInstGetCalledFunction(LLVMValueRef inst);
|
LLVMValueRef LLVMInstGetCalledFunction(LLVMValueRef inst);
|
||||||
|
|
||||||
|
/* Wraps llvm::CallSite::setCalledFunction.
|
||||||
|
*/
|
||||||
|
void LLVMInstSetCalledFunction(LLVMValueRef inst, LLVMValueRef fn);
|
||||||
|
|
||||||
/* Wraps llvm::ParseAssemblyString(). Returns a module reference or NULL (with
|
/* Wraps llvm::ParseAssemblyString(). Returns a module reference or NULL (with
|
||||||
* `out' pointing to an error message). Dispose error message after use, via
|
* `out' pointing to an error message). Dispose error message after use, via
|
||||||
* LLVMDisposeMessage(). */
|
* LLVMDisposeMessage(). */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue