Skip to content

Commit

Permalink
py2llvm/VNone: bugfixes
Browse files Browse the repository at this point in the history
sbourdeauducq committed Dec 19, 2014
1 parent f31386d commit 44e7b99
Showing 2 changed files with 15 additions and 5 deletions.
7 changes: 7 additions & 0 deletions artiq/py2llvm/base_types.py
Original file line number Diff line number Diff line change
@@ -10,6 +10,13 @@ def get_llvm_type(self):
def alloca(self, builder, name):
pass

def set_const_value(self, builder, v):
assert v is None

def set_value(self, builder, other):
if not isinstance(other, VNone):
raise TypeError

def o_bool(self, builder):
r = VBool()
if builder is not None:
13 changes: 8 additions & 5 deletions artiq/py2llvm/lists.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import llvmlite.ir as ll

from artiq.py2llvm.values import VGeneric
from artiq.py2llvm.base_types import VInt
from artiq.py2llvm.base_types import VInt, VNone


class VList(VGeneric):
@@ -12,9 +12,12 @@ def __init__(self, el_type, alloc_count):

def get_llvm_type(self):
count = 0 if self.alloc_count is None else self.alloc_count
return ll.LiteralStructType([ll.IntType(32),
ll.ArrayType(self.el_type.get_llvm_type(),
count)])
if isinstance(self.el_type, VNone):
return ll.LiteralStructType([ll.IntType(32)])
else:
return ll.LiteralStructType([
ll.IntType(32), ll.ArrayType(self.el_type.get_llvm_type(),
count)])

def __repr__(self):
return "<VList:{} x{}>".format(
@@ -52,7 +55,7 @@ def o_len(self, builder):

def o_subscript(self, index, builder):
r = self.el_type.new()
if builder is not None:
if builder is not None and not isinstance(r, VNone):
index = index.o_int(builder).auto_load(builder)
ssa_r = builder.gep(self.llvm_value, [
ll.Constant(ll.IntType(32), 0),

0 comments on commit 44e7b99

Please sign in to comment.