Ready for numba/llnumba -> llvmpy/llpython

This commit is contained in:
Travis E. Oliphant 2012-11-07 12:08:32 -06:00
commit bbc7a4ddf0
15 changed files with 0 additions and 0 deletions

View file

42
llpython/tests/llfuncs.py Normal file
View file

@ -0,0 +1,42 @@
#! /usr/bin/env python
# ______________________________________________________________________
def doslice (in_string, lower, upper):
l = strlen(in_string)
if lower < lc_size_t(0):
lower += l
if upper < lc_size_t(0):
upper += l
temp_len = upper - lower
if temp_len < lc_size_t(0):
temp_len = lc_size_t(0)
ret_val = alloca_array(li8, temp_len + lc_size_t(1))
strncpy(ret_val, in_string + lower, temp_len)
ret_val[temp_len] = li8(0)
return ret_val
def ipow (val, exp):
ret_val = 1
temp = val
w = exp
while w > 0:
if (w & 1) != 0:
ret_val *= temp
# TODO: Overflow check on ret_val
w >>= 1
if w == 0: break
temp *= temp
# TODO: Overflow check on temp
return ret_val
def pymod (arg1, arg2):
ret_val = arg1 % arg2
if ret_val < 0:
if arg2 > 0:
ret_val += arg2
elif arg2 < 0:
ret_val += arg2
return ret_val
# ______________________________________________________________________
# End of llfuncs.py

View file

@ -0,0 +1,23 @@
#! /usr/bin/env python
# ______________________________________________________________________
import llvm.core as lc
try:
from llnumba import bytetype
except ImportError:
from numba.llnumba import bytetype
# ______________________________________________________________________
doslice = lc.Type.function(bytetype.li8_ptr, (
bytetype.li8_ptr, bytetype.lc_size_t, bytetype.lc_size_t))
ipow = lc.Type.function(bytetype.li32, (bytetype.li32,
bytetype.li32))
pymod = lc.Type.function(bytetype.li32, (bytetype.li32,
bytetype.li32))
# ______________________________________________________________________
# End of llfunctys.py