Ejemplo n.º 1
0
 def codegen(context: CodegenContext, builder: ir.IRBuilder,
             signature: Signature, args: Sequence[ir.Value]):
     # llvm IRBuilder code here
     map_fn_ty, _ = signature.args
     funcs = (context.get_function(map_fn_ty, sig) for sig in fn_sigs)
     _, tuples = args
     tuples = cgutils.unpack_tuple(builder, tuples)
     elems = (func(builder,
                   [builder.extract_value(t, i) for t in tuples])
              for i, func in enumerate(funcs))
     return context.make_tuple(builder, signature.return_type, elems)
Ejemplo n.º 2
0
def impl_construct_dtype_on_stack(context: BaseContext, builder: ir.IRBuilder, sig, args):
    ty = sig.args[0].dtype_as_type()
    containing_size = find_size_for_dtype(sig.args[0].dtype)
    ptr = builder.alloca(ir.IntType(8), containing_size)
    for i, (name, mem_ty) in enumerate(ty.members):
        llvm_mem_ty = context.get_value_type(mem_ty)
        offset = ty.offset(name)
        v = builder.extract_value(args[1], i)
        v = context.cast(builder, v, sig.args[1][i], mem_ty)
        v_ptr_byte = builder.gep(ptr, (ir.Constant(ir.IntType(32), offset),), True)
        v_ptr = builder.bitcast(v_ptr_byte, llvm_mem_ty.as_pointer())
        builder.store(v, v_ptr)
    return ptr
Ejemplo n.º 3
0
 def codegen(self, builder: ir.IRBuilder, ctx: CodegenContext) -> ir.Value:
     struct = self.struct.codegen(builder, ctx)
     assert self.idx is not None
     return builder.extract_value(struct, self.idx)