How to use the llvmlite.llvmpy.core.Type.int function in llvmlite

To help you get started, we’ve selected a few llvmlite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github numba / numba / numba / targets / npyimpl.py View on Github external
def __init__(self, ctxt, bld, val, ty):
        self.context = ctxt
        self.builder = bld
        self.val = val
        self.base_type = ty
        intpty = ctxt.get_value_type(types.intp)
        self.shape = [lc.Constant.int(intpty, 1)]

        lty = ctxt.get_data_type(ty) if ty != types.boolean else lc.Type.int(1)
        self._ptr = cgutils.alloca_once(bld, lty)
github diana-hep / oamap / oamap / compiler.py View on Github external
def partitionedlist_len(context, builder, sig, args):
        partitionedlisttpe, = sig.args
        partitionedlistval, = args
        partitionedlist = numba.cgutils.create_struct_proxy(partitionedlisttpe)(context, builder, value=partitionedlistval)

        ptr = builder.inttoptr(
            builder.add(builder.ptrtoint(partitionedlist.offsets, llvmlite.llvmpy.core.Type.int(64)), builder.mul(partitionedlist.numpartitions, literal_int64(8))),
            llvmlite.llvmpy.core.Type.pointer(context.get_value_type(numba.types.int64)))
        return numba.targets.arrayobj.load_item(context, builder, numba.types.int64[:], ptr)
github numba / numba / numba / roc / hsaimpl.py View on Github external
def activelanepermute_wavewidth_impl(context, builder, sig, args):
    [src, laneid, identity, use_ident] = args
    assert sig.args[0] == sig.args[2]
    elem_type = sig.args[0]
    bitwidth = elem_type.bitwidth
    intbitwidth = Type.int(bitwidth)
    i32 = Type.int(32)
    i1 = Type.int(1)
    name = "__hsail_activelanepermute_wavewidth_b{0}".format(bitwidth)

    fnty = Type.function(intbitwidth, [intbitwidth, i32, intbitwidth, i1])
    fn = builder.module.get_or_insert_function(fnty, name=name)
    fn.calling_convention = target.CC_SPIR_FUNC

    def cast(val):
        return builder.bitcast(val, intbitwidth)

    result = builder.call(fn, [cast(src), laneid, cast(identity), use_ident])
    return builder.bitcast(result, context.get_value_type(elem_type))
github numba / numba / numba / targets / numbers.py View on Github external
def boolean_to_any(context, builder, fromty, toty, val):
    # Casting from boolean to anything first casts to int32
    asint = builder.zext(val, Type.int())
    return context.cast(builder, asint, types.int32, toty)
github numba / numba / numba / cuda / printimpl.py View on Github external
from __future__ import print_function, absolute_import, division

from llvmlite.llvmpy.core import Type, Constant

from numba import types, typing, cgutils, utils
from numba.targets.imputils import Registry
from . import nvvmutils

registry = Registry()
lower = registry.lower

voidptr = Type.pointer(Type.int(8))


# NOTE: we don't use @lower here since print_item() doesn't return a LLVM value

@utils.singledispatch
def print_item(ty, context, builder, val):
    """
    Handle printing of a single value of the given Numba type.
    A (format string, [list of arguments]) is returned that will allow
    forming the final printf()-like call.
    """
    raise NotImplementedError("printing unimplemented for values of type %s"
                              % (ty,))


@print_item.register(types.Integer)
github numba / llvmlite / bench.py View on Github external
def run_bench(verbose):
    t = time()

    int32 = lc.Type.int(32)
    fnty = lc.Type.function(int32, [lc.Type.pointer(int32), int32])
    module = lc.Module.new('foo')

    func = lc.Function.new(module, fnty, name="sum")

    bb_entry = func.append_basic_block('entry')
    bb_loop = func.append_basic_block('loop')
    bb_exit = func.append_basic_block('exit')

    builder = lc.Builder.new(bb_entry)
    builder.position_at_end(bb_entry)

    builder.branch(bb_loop)
    builder.position_at_end(bb_loop)

    index = builder.phi(int32)
github numba / numba / numba / targets / npyimpl.py View on Github external
def create_iter_indices(self):
        intpty = self.context.get_value_type(types.intp)
        ZERO = lc.Constant.int(lc.Type.int(intpty.width), 0)

        indices = []
        for i in range(self.ndim):
            x = cgutils.alloca_once(self.builder, lc.Type.int(intpty.width))
            self.builder.store(ZERO, x)
            indices.append(x)
        return _ArrayIndexingHelper(self, indices)
github diana-hep / oamap / oamap / compiler.py View on Github external
def cast_int(builder, value, itemsize):
        bitwidth = itemsize * 8
        if value.type.width < bitwidth:
            return builder.zext(value, llvmlite.llvmpy.core.Type.int(bitwidth))
        elif value.type.width > bitwidth:
            return builder.trunc(value, llvmlite.llvmpy.core.Type.int(bitwidth))
        else:
            return builder.bitcast(value, llvmlite.llvmpy.core.Type.int(bitwidth))