Fix a bug in CreatInsertValue and one in ConstantInt.
This commit is contained in:
parent
d2dc34cdd3
commit
cb00dcc52c
4 changed files with 14 additions and 7 deletions
|
|
@ -2041,8 +2041,7 @@ class Builder(llvm.Wrapper):
|
||||||
|
|
||||||
def alloca(self, ty, name=""):
|
def alloca(self, ty, name=""):
|
||||||
intty = Type.int()
|
intty = Type.int()
|
||||||
zero = api.llvm.ConstantInt.get(intty._ptr, 0)
|
return _make_value(self._ptr.CreateAlloca(ty._ptr, None, name))
|
||||||
return _make_value(self._ptr.CreateAlloca(ty._ptr, zero, name))
|
|
||||||
|
|
||||||
def alloca_array(self, ty, size, name=""):
|
def alloca_array(self, ty, size, name=""):
|
||||||
return _make_value(self._ptr.CreateAlloca(ty._ptr, size._ptr, name))
|
return _make_value(self._ptr.CreateAlloca(ty._ptr, size._ptr, name))
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,7 @@ class ConstantInt:
|
||||||
|
|
||||||
get = StaticMethod(ptr(ConstantInt),
|
get = StaticMethod(ptr(ConstantInt),
|
||||||
ptr(IntegerType),
|
ptr(IntegerType),
|
||||||
cast(int, Unsigned),
|
cast(int, Uint64),
|
||||||
cast(bool, Bool),
|
cast(bool, Bool),
|
||||||
).require_only(2)
|
).require_only(2)
|
||||||
isValueValidForType = StaticMethod(cast(Bool, bool),
|
isValueValidForType = StaticMethod(cast(Bool, bool),
|
||||||
|
|
|
||||||
|
|
@ -288,9 +288,12 @@ class IRBuilder:
|
||||||
args[1] = extra.make_small_vector_from_unsigned(*valuelist)
|
args[1] = extra.make_small_vector_from_unsigned(*valuelist)
|
||||||
return self._CreateExtractValue(*args)
|
return self._CreateExtractValue(*args)
|
||||||
|
|
||||||
_CreateInsertValue = Method(ptr(Value), ptr(Value), ptr(Value),
|
_CreateInsertValue = Method(ptr(Value),
|
||||||
ref(SmallVector_Unsigned), cast(str, StringRef))
|
ptr(Value), # Agg
|
||||||
_CreateInsertValue.require_only(3)
|
ptr(Value), # Val
|
||||||
|
ref(SmallVector_Unsigned), # ArrayRef<unsigned>
|
||||||
|
cast(str, StringRef), # name
|
||||||
|
).require_only(3)
|
||||||
_CreateInsertValue.realname = 'CreateInsertValue'
|
_CreateInsertValue.realname = 'CreateInsertValue'
|
||||||
|
|
||||||
@CustomPythonMethod
|
@CustomPythonMethod
|
||||||
|
|
@ -298,7 +301,7 @@ class IRBuilder:
|
||||||
from llvmpy import extra
|
from llvmpy import extra
|
||||||
args = list(args)
|
args = list(args)
|
||||||
valuelist = args[2]
|
valuelist = args[2]
|
||||||
args[1] = extra.make_small_vector_from_unsigned(*valuelist)
|
args[2] = extra.make_small_vector_from_unsigned(*valuelist)
|
||||||
return self._CreateInsertValue(*args)
|
return self._CreateInsertValue(*args)
|
||||||
|
|
||||||
CreateLandingPad = Method(ptr(LandingPadInst), ptr(Type), ptr(Value),
|
CreateLandingPad = Method(ptr(LandingPadInst), ptr(Type), ptr(Value),
|
||||||
|
|
|
||||||
|
|
@ -323,6 +323,11 @@ def test_constants():
|
||||||
aryconst = llvm.ConstantArray.get(ary_int32x4, [intconst] * 4)
|
aryconst = llvm.ConstantArray.get(ary_int32x4, [intconst] * 4)
|
||||||
assert str(aryconst.getAggregateElement(0)) == str(intconst)
|
assert str(aryconst.getAggregateElement(0)) == str(intconst)
|
||||||
|
|
||||||
|
bignum = 4415104608
|
||||||
|
int64ty = llvm.Type.getInt64Ty(context)
|
||||||
|
const_bignum = llvm.ConstantInt.get(int64ty, 4415104608)
|
||||||
|
assert str(bignum) in str(const_bignum)
|
||||||
|
|
||||||
def test_intrinsic():
|
def test_intrinsic():
|
||||||
context = llvm.getGlobalContext()
|
context = llvm.getGlobalContext()
|
||||||
m = llvm.Module.new("modname", context)
|
m = llvm.Module.new("modname", context)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue