From cb00dcc52c4ddf390a3ef51b33726babbf5e769c Mon Sep 17 00:00:00 2001 From: Siu Kwan Lam Date: Wed, 13 Feb 2013 18:12:45 -0600 Subject: [PATCH] Fix a bug in CreatInsertValue and one in ConstantInt. --- llvm/core.py | 3 +-- llvmpy/src/Constant.py | 2 +- llvmpy/src/IRBuilder.py | 11 +++++++---- llvmpy/test_binding.py | 5 +++++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/llvm/core.py b/llvm/core.py index f2af943..60c05fa 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -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)) diff --git a/llvmpy/src/Constant.py b/llvmpy/src/Constant.py index 0a79bd3..3cbb40b 100644 --- a/llvmpy/src/Constant.py +++ b/llvmpy/src/Constant.py @@ -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), diff --git a/llvmpy/src/IRBuilder.py b/llvmpy/src/IRBuilder.py index 8590430..efdf453 100644 --- a/llvmpy/src/IRBuilder.py +++ b/llvmpy/src/IRBuilder.py @@ -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 + 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), diff --git a/llvmpy/test_binding.py b/llvmpy/test_binding.py index 01e6c38..8eb56f6 100644 --- a/llvmpy/test_binding.py +++ b/llvmpy/test_binding.py @@ -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)