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 binding import *
|
||||||
from namespace import llvm
|
from namespace import llvm
|
||||||
from User import User
|
from Value import Constant
|
||||||
|
|
||||||
@llvm.Class(User)
|
@Constant
|
||||||
class Constant:
|
class Constant:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
from binding import *
|
from binding import *
|
||||||
from namespace import llvm
|
from namespace import llvm
|
||||||
from GlobalValue import GlobalValue
|
from Value import GlobalValue, Constant, Function
|
||||||
from Constant import Constant
|
|
||||||
from Type import Type
|
from Type import Type
|
||||||
from DerivedTypes import FunctionType
|
from DerivedTypes import FunctionType
|
||||||
from LLVMContext import LLVMContext
|
from LLVMContext import LLVMContext
|
||||||
|
|
||||||
@llvm.Class(GlobalValue)
|
@Function
|
||||||
class Function:
|
class Function:
|
||||||
_include_ = 'llvm/Function.h'
|
_include_ = 'llvm/Function.h'
|
||||||
_downcast_ = GlobalValue, Constant
|
_downcast_ = GlobalValue, Constant
|
||||||
|
|
@ -17,3 +16,4 @@ class Function:
|
||||||
isVarArg = Method(cast(Bool, bool))
|
isVarArg = Method(cast(Bool, bool))
|
||||||
getIntrinsicID = Method(cast(Unsigned, int))
|
getIntrinsicID = Method(cast(Unsigned, int))
|
||||||
isIntrinsic = Method(cast(Bool, bool))
|
isIntrinsic = Method(cast(Bool, bool))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
from binding import *
|
from binding import *
|
||||||
from namespace import llvm
|
from namespace import llvm
|
||||||
from Constant import Constant
|
from Value import GlobalValue
|
||||||
|
|
||||||
@llvm.Class(Constant)
|
@GlobalValue
|
||||||
class GlobalValue:
|
class GlobalValue:
|
||||||
_include_ = 'llvm/GlobalValue.h'
|
_include_ = 'llvm/GlobalValue.h'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
from binding import *
|
from binding import *
|
||||||
from namespace import llvm
|
from namespace import llvm
|
||||||
from Value import Value
|
from Value import User
|
||||||
|
|
||||||
@llvm.Class(Value)
|
@User
|
||||||
class User:
|
class User:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,12 @@ from LLVMContext import LLVMContext
|
||||||
from StringRef import StringRef
|
from StringRef import StringRef
|
||||||
|
|
||||||
Value = llvm.Class()
|
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
|
@Value
|
||||||
class Value:
|
class Value:
|
||||||
|
|
@ -25,3 +31,10 @@ class Value:
|
||||||
setName = Method(Void, cast(str, StringRef))
|
setName = Method(Void, cast(str, StringRef))
|
||||||
|
|
||||||
replaceAllUsesWith = Method(Void, ptr(Value))
|
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.isVarArg() == False
|
||||||
assert fn.getIntrinsicID() == 0
|
assert fn.getIntrinsicID() == 0
|
||||||
assert not fn.isIntrinsic()
|
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