Fix a bug in CreatInsertValue and one in ConstantInt.

This commit is contained in:
Siu Kwan Lam 2013-02-13 18:12:45 -06:00
commit cb00dcc52c
4 changed files with 14 additions and 7 deletions

View file

@ -2041,8 +2041,7 @@ class Builder(llvm.Wrapper):
def alloca(self, ty, name=""):
intty = Type.int()
zero = api.llvm.ConstantInt.get(intty._ptr, 0)
return _make_value(self._ptr.CreateAlloca(ty._ptr, zero, name))
return _make_value(self._ptr.CreateAlloca(ty._ptr, None, name))
def alloca_array(self, ty, size, name=""):
return _make_value(self._ptr.CreateAlloca(ty._ptr, size._ptr, name))

View file

@ -76,7 +76,7 @@ class ConstantInt:
get = StaticMethod(ptr(ConstantInt),
ptr(IntegerType),
cast(int, Unsigned),
cast(int, Uint64),
cast(bool, Bool),
).require_only(2)
isValueValidForType = StaticMethod(cast(Bool, bool),

View file

@ -288,9 +288,12 @@ class IRBuilder:
args[1] = extra.make_small_vector_from_unsigned(*valuelist)
return self._CreateExtractValue(*args)
_CreateInsertValue = Method(ptr(Value), ptr(Value), ptr(Value),
ref(SmallVector_Unsigned), cast(str, StringRef))
_CreateInsertValue.require_only(3)
_CreateInsertValue = Method(ptr(Value),
ptr(Value), # Agg
ptr(Value), # Val
ref(SmallVector_Unsigned), # ArrayRef<unsigned>
cast(str, StringRef), # name
).require_only(3)
_CreateInsertValue.realname = 'CreateInsertValue'
@CustomPythonMethod
@ -298,7 +301,7 @@ class IRBuilder:
from llvmpy import extra
args = list(args)
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)
CreateLandingPad = Method(ptr(LandingPadInst), ptr(Type), ptr(Value),

View file

@ -323,6 +323,11 @@ def test_constants():
aryconst = llvm.ConstantArray.get(ary_int32x4, [intconst] * 4)
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():
context = llvm.getGlobalContext()
m = llvm.Module.new("modname", context)