Esempio n. 1
0
 def emit(builder):
     s = entry_alloca(builder, self.llvm_type, "s")
     # TODO support kwargs
     for i, v in enumerate(args):
         field = self.fields[i][0]
         self.emit_setattr(builder, s, field, v)
     return s, Reference(self)
Esempio n. 2
0
 def emit(builder):
     s = entry_alloca(builder, self.llvm_type, "s")
     # TODO support kwargs
     for i, v in enumerate(args):
         field = self.fields[i][0]
         self.emit_setattr(builder, s, field, v)
     return s, Reference(self)
Esempio n. 3
0
        def emit(builder):
            v = entry_alloca(builder, self.llvm_type, "v.array")
            if values is not None:
                for i in product(*(range(d) for d in self.shape)):
                    ii = tuple(const_index(j) for j in i)
                    vi = values
                    for k in i:
                        vi = vi[k]
                    self.emit_setitem(builder, v, ii, vi)

            return v, Reference(self)
Esempio n. 4
0
        def emit(builder):
            v = entry_alloca(builder, self.llvm_type, "v.array")
            if values is not None:
                for i in product(*(range(d) for d in self.shape)):
                    ii = tuple(const_index(j) for j in i)
                    vi = values
                    for k in i:
                        vi = vi[k]
                    self.emit_setitem(builder, v, ii, vi)

            return v, Reference(self)
Esempio n. 5
0
    def _emit_subslice(self, builder, v, i):
        """Emits a sub-slice based on partial index *i*"""
        from ..function import entry_alloca

        SSTy = Slice(self.element_type, self.shape[len(i):])
        ss = entry_alloca(builder, SSTy.llvm_type, "subslice")

        # Setting shape dimensions
        subshape, subshape_ty = SSTy._struct.emit_getattr(builder, ss, "shape")

        # shape is a reference
        shape, shape_ty = self.emit_getattr(builder, v, "shape")
        for j in range(len(self.shape) - len(i)):
            dim, _ = shape_ty.value_type.emit_getitem(builder, shape, (const_index(j + len(i)),))
            subshape_ty.value_type.emit_setitem(builder, subshape, (const_index(j),), dim)

        # Setting pointer to data sub-block.
        data_idx = i + (const_index(0),) * (len(self.shape) - len(i))
        SSTy._struct.emit_setattr(builder, ss, "data", self._item_gep(builder, v, data_idx))

        return ss, SSTy
Esempio n. 6
0
    def _emit_subslice(self, builder, v, i):
        """Emits a sub-slice based on partial index *i*"""
        from ..function import entry_alloca

        SSTy = Slice(self.element_type, self.shape[len(i):])
        ss = entry_alloca(builder, SSTy.llvm_type, "subslice")

        # Setting shape dimensions
        subshape, subshape_ty = SSTy._struct.emit_getattr(builder, ss, "shape")

        # shape is a reference
        shape, shape_ty = self.emit_getattr(builder, v, "shape")
        for j in range(len(self.shape) - len(i)):
            dim, _ = shape_ty.value_type.emit_getitem(
                builder, shape, (const_index(j + len(i)), ))
            subshape_ty.value_type.emit_setitem(builder, subshape,
                                                (const_index(j), ), dim)

        # Setting pointer to data sub-block.
        data_idx = i + (const_index(0), ) * (len(self.shape) - len(i))
        SSTy._struct.emit_setattr(builder, ss, "data",
                                  self._item_gep(builder, v, data_idx))

        return ss, SSTy