Start to work on IRBuilder
This commit is contained in:
parent
821e937837
commit
fa4927e1fb
6 changed files with 36 additions and 11 deletions
|
|
@ -1,7 +1,8 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from User import User
|
||||
from Value import Constant
|
||||
|
||||
@llvm.Class(User)
|
||||
@Constant
|
||||
class Constant:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from GlobalValue import GlobalValue
|
||||
from Constant import Constant
|
||||
from Value import GlobalValue, Constant, Function
|
||||
from Type import Type
|
||||
from DerivedTypes import FunctionType
|
||||
from LLVMContext import LLVMContext
|
||||
|
||||
@llvm.Class(GlobalValue)
|
||||
@Function
|
||||
class Function:
|
||||
_include_ = 'llvm/Function.h'
|
||||
_downcast_ = GlobalValue, Constant
|
||||
|
|
@ -16,4 +15,5 @@ class Function:
|
|||
getContext = Method(ref(LLVMContext))
|
||||
isVarArg = Method(cast(Bool, bool))
|
||||
getIntrinsicID = Method(cast(Unsigned, int))
|
||||
isIntrinsic = Method(cast(Bool, bool))
|
||||
isIntrinsic = Method(cast(Bool, bool))
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from Constant import Constant
|
||||
from Value import GlobalValue
|
||||
|
||||
@llvm.Class(Constant)
|
||||
@GlobalValue
|
||||
class GlobalValue:
|
||||
_include_ = 'llvm/GlobalValue.h'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
from binding import *
|
||||
from namespace import llvm
|
||||
from Value import Value
|
||||
from Value import User
|
||||
|
||||
@llvm.Class(Value)
|
||||
@User
|
||||
class User:
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,12 @@ from LLVMContext import LLVMContext
|
|||
from StringRef import StringRef
|
||||
|
||||
Value = llvm.Class()
|
||||
# forward declarations
|
||||
User = llvm.Class(Value)
|
||||
BasicBlock = llvm.Class(Value)
|
||||
Constant = llvm.Class(User)
|
||||
GlobalValue = llvm.Class(Constant)
|
||||
Function = llvm.Class(GlobalValue)
|
||||
|
||||
@Value
|
||||
class Value:
|
||||
|
|
@ -25,3 +31,10 @@ class Value:
|
|||
setName = Method(Void, cast(str, StringRef))
|
||||
|
||||
replaceAllUsesWith = Method(Void, ptr(Value))
|
||||
|
||||
list_use = IterToList(ptr(User), (), 'llvm::Value::use_iterator',
|
||||
'use_begin', 'use_end')
|
||||
|
||||
hasOneUse = Method(cast(Bool, bool))
|
||||
hasNUses = Method(cast(Bool, bool), cast(int, Unsigned))
|
||||
isUsedInBasicBlock = Method(cast(Bool, bool), BasicBlock)
|
||||
|
|
|
|||
|
|
@ -55,3 +55,15 @@ assert fnty is fn.getFunctionType()
|
|||
assert fn.isVarArg() == False
|
||||
assert fn.getIntrinsicID() == 0
|
||||
assert not fn.isIntrinsic()
|
||||
|
||||
print fn.list_use()
|
||||
|
||||
builder = api.IRBuilder.new(context)
|
||||
print builder
|
||||
|
||||
bb = api.BasicBlock.Create(context, "entry", fn, None)
|
||||
builder.SetInsertPoint(bb)
|
||||
|
||||
builder.CreateRetVoid()
|
||||
|
||||
fn.dump()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue