Add binding for Intrinsics.

Add support for functions that free the resource but is not a destructor.
This commit is contained in:
Siu Kwan Lam 2013-02-07 13:27:03 -06:00
commit 11cc78d780
8 changed files with 92 additions and 4 deletions

View file

@ -1,6 +1,8 @@
from binding import *
from namespace import llvm
from Value import GlobalValue, Constant, Function, Argument
from BasicBlock import BasicBlock
from Attributes import Attributes
from Type import Type
from DerivedTypes import FunctionType
from LLVMContext import LLVMContext
@ -21,6 +23,33 @@ class Function:
getCallingConv = Method(CallingConv.ID)
setCallingConv = Method(Void, CallingConv.ID)
hasGC = Method(cast(bool, Bool))
getGC = Method(cast(ConstCharPtr, str))
setGC = Method(Void, cast(str, ConstCharPtr))
getArgumentList = CustomMethod('Function_getArgumentList', PyObjectPtr)
getBasicBlockList = CustomMethod('Function_getBasicBlockList', PyObjectPtr)
getEntryBlock = Method(ref(BasicBlock))
copyAttributesFrom = Method(Void, ptr(GlobalValue))
setDoesNotThrow = Method()
doesNotThrow = Method(cast(Bool, bool))
setDoesNotReturn = Method()
doesNotReturn = Method(cast(Bool, bool))
setOnlyReadsMemory = Method()
onlyReadsMemory = Method(cast(Bool, bool))
setDoesNotAccessMemory = Method()
doesNotAccessMemory = Method(cast(Bool, bool))
deleteBody = Method()
viewCFG = Method()
viewCFGOnly = Method()
addFnAttr = Method(Void, Attributes.AttrVal)
removeFnAttr = Method(Void, ref(Attributes))
eraseFromParent = Method()
eraseFromParent.disowning = True

View file

@ -44,4 +44,6 @@ class GlobalValue:
isDeclaration = Method(cast(Bool, bool))
removeFromParent = Method()
eraseFromParent = Method()
eraseFromParent.disowning = True
getParent = Method(ptr(Module))

View file

@ -45,5 +45,5 @@ class GlobalVariable:
# isExternallyInitialized = Method(cast(Bool, bool))
# setExternallyinitialized = Method(Void, cast(bool, Bool))
eraseFromParent = Method()

View file

@ -0,0 +1,17 @@
from binding import *
from namespace import llvm
from Module import Module
from Function import Function
Intrinsic = llvm.Class() # fake class (actually a namespace)
@Intrinsic
class Intrinsic:
getDeclaration = CustomStaticMethod('Intrinsic_getDeclaration',
PyObjectPtr, # Function*
ptr(Module),
cast(int, Unsigned), # intrinsic id
PyObjectPtr, # list of Type
).require_only(2)