-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
6ca39f7
commit f3b727b
Showing
10 changed files
with
174 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import llvmlite.ir as ll | ||
|
||
from artiq.py2llvm.values import VGeneric | ||
|
||
|
||
class VList(VGeneric): | ||
def __init__(self, el_type, alloc_count): | ||
VGeneric.__init__(self) | ||
self.el_type = el_type | ||
self.alloc_count = 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)]) | ||
|
||
def __repr__(self): | ||
return "<VList:{} x{}>".format( | ||
repr(self.el_type), | ||
"?" if self.alloc_count is None else self.alloc_count) | ||
|
||
def same_type(self, other): | ||
return (isinstance(other, VList) | ||
and self.el_type.same_type(other.el_type)) | ||
|
||
def merge(self, other): | ||
if isinstance(other, VList): | ||
self.el_type.merge(other.el_type) | ||
else: | ||
raise TypeError("Incompatible types: {} and {}" | ||
.format(repr(self), repr(other))) | ||
|
||
def merge_subscript(self, other): | ||
self.el_type.merge(other) | ||
|
||
def set_count(self, builder, count): | ||
count_ptr = builder.gep(self.llvm_value, [ | ||
ll.Constant(ll.IntType(32), 0), | ||
ll.Constant(ll.IntType(32), 0)]) | ||
builder.store(ll.Constant(ll.IntType(32), count), count_ptr) | ||
|
||
def o_subscript(self, index, builder): | ||
r = self.el_type.new() | ||
if builder is not None: | ||
index = index.o_int(builder).auto_load(builder) | ||
ssa_r = builder.gep(self.llvm_value, [ | ||
ll.Constant(ll.IntType(32), 0), | ||
ll.Constant(ll.IntType(32), 1), | ||
index]) | ||
r.auto_store(builder, ssa_r) | ||
return r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.