Hello community,

here is the log from the commit of package python-llvmlite for openSUSE:Factory 
checked in at 2019-10-21 12:31:46
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-llvmlite (Old)
 and      /work/SRC/openSUSE:Factory/.python-llvmlite.new.2352 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python-llvmlite"

Mon Oct 21 12:31:46 2019 rev:14 rq:741414 version:0.30.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python-llvmlite/python-llvmlite.changes  
2019-06-19 21:14:58.258897411 +0200
+++ 
/work/SRC/openSUSE:Factory/.python-llvmlite.new.2352/python-llvmlite.changes    
    2019-10-21 12:31:53.236197840 +0200
@@ -1,0 +2,20 @@
+Sat Oct 19 17:02:55 UTC 2019 - Arun Persaud <[email protected]>
+
+- update to version 0.30.0:
+  This release adds support for half-precision float and
+  schedulesthe deprecation of memset/memcpy accepting 5 arguments
+  (cf. LLVM change).
+  * PR #518: Fix use of -fPIC flag in wheels
+  * PR #513: Remove restriction on sphinx version from Anaconda distro
+  * PR #512: fix for block labels which contain "interesting"
+    characters
+  * PR #511: Deprecate the use of memset/memcpy with alias
+  * PR #510: Add fp16 Intrinsics
+  * PR #509: Add Half-Precision Type
+  * PR #502: Add -fPIC flag for manylinux1 wheel building
+  * PR #491: Fix incorrect hierarchy in the documentation for
+    ir.Constant.
+  * PR #474: Update docs
+  * PR #470: Fix leak on string returning APIs.
+
+-------------------------------------------------------------------

Old:
----
  llvmlite-0.29.0.tar.gz

New:
----
  llvmlite-0.30.0.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python-llvmlite.spec ++++++
--- /var/tmp/diff_new_pack.m80POM/_old  2019-10-21 12:31:54.840199659 +0200
+++ /var/tmp/diff_new_pack.m80POM/_new  2019-10-21 12:31:54.852199672 +0200
@@ -24,11 +24,10 @@
 %define         llvm_major 8
 %endif
 Name:           python-llvmlite
-Version:        0.29.0
+Version:        0.30.0
 Release:        0
 Summary:        Lightweight wrapper around basic LLVM functionality
 License:        BSD-2-Clause
-Group:          Development/Languages/Python
 URL:            http://llvmlite.pydata.org
 Source:         
https://github.com/numba/llvmlite/archive/v%{version}.tar.gz#/llvmlite-%{version}.tar.gz
 BuildRequires:  %{python_module devel}

++++++ llvmlite-0.29.0.tar.gz -> llvmlite-0.30.0.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/CHANGE_LOG 
new/llvmlite-0.30.0/CHANGE_LOG
--- old/llvmlite-0.29.0/CHANGE_LOG      2019-05-29 17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/CHANGE_LOG      2019-10-09 16:00:33.000000000 +0200
@@ -1,3 +1,21 @@
+v0.30.0 (Oct 9, 2019)
+---------------------
+
+This release adds support for half-precision float and schedules the
+deprecation of memset/memcpy accepting 5 arguments (cf. LLVM change).
+
+* PR #518: Fix use of -fPIC flag in wheels
+* PR #513: Remove restriction on sphinx version from Anaconda distro
+* PR #512: fix for block labels which contain "interesting" characters
+* PR #511: Deprecate the use of memset/memcpy with alias
+* PR #510: Add fp16 Intrinsics
+* PR #509: Add Half-Precision Type
+* PR #502: Add -fPIC flag for manylinux1 wheel building
+* PR #491: Fix incorrect hierarchy in the documentation for ir.Constant.
+* PR #474: Update docs
+* PR #470: Fix leak on string returning APIs.
+
+
 v0.29.0 (May 29, 2019)
 ----------------------
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/llvmlite-0.29.0/buildscripts/incremental/setup_conda_environment.sh 
new/llvmlite-0.30.0/buildscripts/incremental/setup_conda_environment.sh
--- old/llvmlite-0.29.0/buildscripts/incremental/setup_conda_environment.sh     
2019-05-29 17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/buildscripts/incremental/setup_conda_environment.sh     
2019-10-09 16:00:33.000000000 +0200
@@ -36,14 +36,15 @@
 fi
 
 # Install enum34 for Python < 3.4 and PyPy, and install dependencies for
-# building the docs. Sphinx 1.5.4 has a bug.
+# building the docs.
 if [ "$PYTHON" == "pypy" ]; then
   $CONDA_INSTALL zlib # pypy has no conda-level zlib linkage
   python -m ensurepip
   $PIP_INSTALL enum34
+  # Sphinx 1.5.4 has a bug.
   $PIP_INSTALL sphinx==1.5.1 sphinx_rtd_theme pygments
 else
-  $CONDA_INSTALL sphinx=1.5.1 sphinx_rtd_theme pygments
+  $CONDA_INSTALL sphinx sphinx_rtd_theme pygments
   if [ "x$PYTHON" != "x" -a "$PYTHON" \< "3.4" -a "$WHEEL" != "yes" ]; then
     $CONDA_INSTALL enum34
   fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/docs/source/conf.py 
new/llvmlite-0.30.0/docs/source/conf.py
--- old/llvmlite-0.29.0/docs/source/conf.py     2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/docs/source/conf.py     2019-10-09 16:00:33.000000000 
+0200
@@ -16,11 +16,16 @@
 import sys
 import os
 import shlex
+from datetime import datetime
+
+on_rtd = os.environ.get('READTHEDOCS') == 'True'
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
 # documentation root, use os.path.abspath to make it absolute, like shown here.
 #sys.path.insert(0, os.path.abspath('.'))
+sys.path.append(os.path.abspath(os.path.join('..', '..')))
+
 
 # -- General configuration ------------------------------------------------
 
@@ -53,14 +58,19 @@
 copyright = '2015, Continuum Analytics'
 author = 'Continuum Analytics'
 
+if on_rtd:
+    # RTD replaces the last update date.  So we need to hack it in here.
+    copyright += '. Last updated on {}'.format(datetime.utcnow().strftime('%b 
%d, %Y'))
+
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
+import llvmlite
 # The short X.Y version.
-version = '0.27.0'
+version = llvmlite.__version__.split('-', 1)[0]
 # The full version, including alpha/beta/rc tags.
-release = '0.27.0'
+release = llvmlite.__version__
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
@@ -160,7 +170,7 @@
 
 # If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
 # using the given strftime format.
-#html_last_updated_fmt = '%b %d, %Y'
+html_last_updated_fmt = '%b %d, %Y'
 
 # If true, SmartyPants will be used to convert quotes and dashes to
 # typographically correct entities.
@@ -301,5 +311,5 @@
 # Example configuration for intersphinx: refer to the Python standard library.
 intersphinx_mapping = {
     'python': ('https://docs.python.org/3', None),
-    'llvm': ('http://llvm.org/releases/7.0.0/docs', None),
+    'llvm': ('http://llvm.org/releases/8.0.0/docs', None),
     }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/llvmlite-0.29.0/docs/source/user-guide/deprecation.rst 
new/llvmlite-0.30.0/docs/source/user-guide/deprecation.rst
--- old/llvmlite-0.29.0/docs/source/user-guide/deprecation.rst  1970-01-01 
01:00:00.000000000 +0100
+++ new/llvmlite-0.30.0/docs/source/user-guide/deprecation.rst  2019-10-09 
16:00:33.000000000 +0200
@@ -0,0 +1,112 @@
+.. _deprecation:
+
+===================
+Deprecation Notices
+===================
+
+This section contains information about deprecation of behaviours, features and
+APIs that have become undesirable/obsolete. Any information about the schedule
+for their deprecation and reasoning behind the changes, along with examples, is
+provided.
+
+Deprecation of use of memset/memcpy llvm intrinsic with specified alignment
+===========================================================================
+From LLVM 7 onward the `memset 
<https://releases.llvm.org/7.0.0/docs/LangRef.html#llvm-memset-intrinsics>`_
+and `memcpy 
<https://releases.llvm.org/7.0.0/docs/LangRef.html#llvm-memcpy-intrinsic>`_
+intrinsics dropped the use of an alignment, specified as the third argument, 
and
+instead use the alignment of the first argument for this purpose. Specifying
+the alignment in third argument continued to work as LLVM auto-updates this use
+case.
+
+Reason for deprecation
+----------------------
+LLVM has changed the behaviour of the previously mentioned intrinsics, and so 
as
+to increase compatibility with future releases of LLVM, llvmlite is adapting to
+match.
+
+Example(s) of the impact
+------------------------
+
+At present the following works::
+
+    from llvmlite import ir
+
+    bit = ir.IntType(1)
+    int8 = ir.IntType(8)
+    int32 = ir.IntType(32)
+    int64 = ir.IntType(64)
+    int8ptr = int8.as_pointer()
+
+    mod = ir.Module()
+    fnty = ir.FunctionType(int32, ())
+    func = ir.Function(mod, fnty, "some_function")
+    block = func.append_basic_block('some_block')
+    builder = ir.IRBuilder(block)
+
+    some_address = int64(0xdeaddead)
+    dest = builder.bitcast(some_address, int8ptr)
+    value = int8(0xa5)
+    memset = mod.declare_intrinsic('llvm.memset', [int8ptr, int32])
+    memcpy = mod.declare_intrinsic('llvm.memcpy', [int8ptr, int8ptr, int32])
+
+    # NOTE: 5 argument call site (dest, value, length, align, isvolatile)
+    builder.call(memset, [dest, value, int32(10), int32(0), bit(0)])
+
+    some_other_address = int64(0xcafecafe)
+    src = builder.bitcast(some_other_address, int8ptr)
+
+    # NOTE: 5 argument call site (dest, src, length, align, isvolatile)
+    builder.call(memcpy, [dest, src, int32(10), int32(0), bit(0)])
+
+    builder.ret(int32(0))
+    print(str(mod))
+
+
+In future only the following will work::
+
+    from llvmlite import ir
+
+    bit = ir.IntType(1)
+    int8 = ir.IntType(8)
+    int32 = ir.IntType(32)
+    int64 = ir.IntType(64)
+    int8ptr = int8.as_pointer()
+
+    mod = ir.Module()
+    fnty = ir.FunctionType(int32, ())
+    func = ir.Function(mod, fnty, "some_function")
+    block = func.append_basic_block('some_block')
+    builder = ir.IRBuilder(block)
+
+    some_address = int64(0xdeaddead)
+    dest = builder.bitcast(some_address, int8ptr)
+    value = int8(0xa5)
+    memset = mod.declare_intrinsic('llvm.memset', [int8ptr, int32])
+    memcpy = mod.declare_intrinsic('llvm.memcpy', [int8ptr, int8ptr, int32])
+
+    # NOTE: 4 argument call site (dest, value, length, isvolatile)
+    builder.call(memset, [dest, value, int32(10), bit(0)])
+
+    some_other_address = int64(0xcafecafe)
+    src = builder.bitcast(some_other_address, int8ptr)
+
+    # NOTE: 4 argument call site (dest, src, length, isvolatile)
+    builder.call(memcpy, [dest, src, int32(10), bit(0)])
+
+    builder.ret(int32(0))
+    print(str(mod))
+
+
+Schedule
+--------
+This feature will be removed with respect to this schedule:
+
+* v0.30 will be the last release to support an alignment specified as the third
+  argument (5 argument style).
+* v0.31 will support the 4 argument style call only.
+
+
+Recommendations
+---------------
+Projects that need/rely on the deprecated behaviour should pin their dependency
+on llvmlite to a version prior to removal of this behaviour.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/docs/source/user-guide/index.rst 
new/llvmlite-0.30.0/docs/source/user-guide/index.rst
--- old/llvmlite-0.29.0/docs/source/user-guide/index.rst        2019-05-29 
17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/docs/source/user-guide/index.rst        2019-10-09 
16:00:33.000000000 +0200
@@ -7,3 +7,4 @@
 
    ir/index
    binding/index
+   deprecation.rst
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/docs/source/user-guide/ir/types.rst 
new/llvmlite-0.30.0/docs/source/user-guide/ir/types.rst
--- old/llvmlite-0.29.0/docs/source/user-guide/ir/types.rst     2019-05-29 
17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/docs/source/user-guide/ir/types.rst     2019-10-09 
16:00:33.000000000 +0200
@@ -84,6 +84,16 @@
 
       The width in bits.
 
+.. class:: HalfType()
+
+   The type of half-precision, floating-point, real numbers.
+
+   NOTE: On Python 3.5 and earlier, constants won't be rounded
+   to valid fp16 numbers, and so may generate invalid IR. In this
+   case, use rounding code like ``float(np.float16(1.12312321e-2))``
+   before calling :class:`IRBuilder` methods.
+
+
 .. class:: FloatType()
 
    The type of single-precision, floating-point, real numbers.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/docs/source/user-guide/ir/values.rst 
new/llvmlite-0.30.0/docs/source/user-guide/ir/values.rst
--- old/llvmlite-0.29.0/docs/source/user-guide/ir/values.rst    2019-05-29 
17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/docs/source/user-guide/ir/values.rst    2019-10-09 
16:00:33.000000000 +0200
@@ -71,24 +71,24 @@
         otherwise. Returns a constant struct containing the
         *elements* in order.
 
-      * .. method:: bitcast(typ)
+   .. method:: bitcast(typ)
 
-           Convert this pointer constant to a constant of the
-           given pointer type.
+      Convert this pointer constant to a constant of the
+      given pointer type.
 
-      * .. method:: gep(indices)
+   .. method:: gep(indices)
 
-           Compute the address of the inner element given by the
-           sequence of *indices*. The constant must have a pointer
-           type.
+      Compute the address of the inner element given by the
+      sequence of *indices*. The constant must have a pointer
+      type.
 
-      * .. method:: inttoptr(typ)
+   .. method:: inttoptr(typ)
 
-           Convert this integer constant to a constant of the
-           given pointer type.
+      Convert this integer constant to a constant of the
+      given pointer type.
 
-      NOTE: You cannot define constant functions. Use a
-      :ref:`function declaration` instead.
+   NOTE: You cannot define constant functions. Use a
+   :ref:`function declaration` instead.
 
 .. class:: Argument
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/ffi/Makefile.linux 
new/llvmlite-0.30.0/ffi/Makefile.linux
--- old/llvmlite-0.29.0/ffi/Makefile.linux      2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/ffi/Makefile.linux      2019-10-09 16:00:33.000000000 
+0200
@@ -5,7 +5,7 @@
 CXX_FLTO_FLAGS ?= -flto
 LD_FLTO_FLAGS ?= -flto -Wl,--exclude-libs=ALL
 
-CXXFLAGS = $(LLVM_CXXFLAGS) $(CXX_FLTO_FLAGS)
+CXXFLAGS := $(CPPFLAGS) $(CXXFLAGS) $(LLVM_CXXFLAGS) $(CXX_FLTO_FLAGS)
 LDFLAGS := $(LDFLAGS) $(LLVM_LDFLAGS) $(LD_FLTO_FLAGS)
 LIBS = $(LLVM_LIBS)
 INCLUDE = core.h
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/ffi/dylib.cpp 
new/llvmlite-0.30.0/ffi/dylib.cpp
--- old/llvmlite-0.29.0/ffi/dylib.cpp   2019-05-29 17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/ffi/dylib.cpp   2019-10-09 16:00:33.000000000 +0200
@@ -19,12 +19,12 @@
 }
 
 API_EXPORT(bool)
-LLVMPY_LoadLibraryPermanently(const char *filename, char **OutError)
+LLVMPY_LoadLibraryPermanently(const char *filename, const char **OutError)
 {
     std::string error;
     bool failed = llvm::sys::DynamicLibrary::LoadLibraryPermanently(filename, 
&error);
     if (failed) {
-      *OutError = strdup(error.c_str());
+      *OutError = LLVMPY_CreateString(error.c_str());
     }
     return failed;
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/ffi/executionengine.cpp 
new/llvmlite-0.30.0/ffi/executionengine.cpp
--- old/llvmlite-0.29.0/ffi/executionengine.cpp 2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/ffi/executionengine.cpp 2019-10-09 16:00:33.000000000 
+0200
@@ -76,7 +76,7 @@
 LLVMExecutionEngineRef
 create_execution_engine(LLVMModuleRef M,
                         LLVMTargetMachineRef TM,
-                        char **OutError
+                        const char **OutError
                         )
 {
     LLVMExecutionEngineRef ee = nullptr;
@@ -91,7 +91,7 @@
 
 
     if (!engine)
-        *OutError = strdup(err.c_str());
+        *OutError = LLVMPY_CreateString(err.c_str());
     else
         ee = llvm::wrap(engine);
     return ee;
@@ -100,7 +100,7 @@
 API_EXPORT(LLVMExecutionEngineRef)
 LLVMPY_CreateMCJITCompiler(LLVMModuleRef M,
                            LLVMTargetMachineRef TM,
-                           char **OutError)
+                           const char **OutError)
 {
     return create_execution_engine(M, TM, OutError);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/ffi/value.cpp 
new/llvmlite-0.30.0/ffi/value.cpp
--- old/llvmlite-0.29.0/ffi/value.cpp   2019-05-29 17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/ffi/value.cpp   2019-10-09 16:00:33.000000000 +0200
@@ -253,7 +253,7 @@
     using namespace llvm;
     AttributeListIterator* iter = unwrap(GI);
     if (iter->cur != iter->end) {
-        return strdup((&*iter->cur++)->getAsString().c_str());
+        return LLVMPY_CreateString((&*iter->cur++)->getAsString().c_str());
     } else {
       return NULL;
     }
@@ -265,7 +265,7 @@
     using namespace llvm;
     AttributeSetIterator* iter = unwrap(GI);
     if (iter->cur != iter->end) {
-        return strdup((&*iter->cur++)->getAsString().c_str());
+        return LLVMPY_CreateString((&*iter->cur++)->getAsString().c_str());
     } else {
       return NULL;
     }
@@ -389,7 +389,10 @@
 API_EXPORT(const char *)
 LLVMPY_PrintType(LLVMTypeRef type)
 {
-    return LLVMPrintTypeToString(type);
+    char *str = LLVMPrintTypeToString(type);
+    const char *out = LLVMPY_CreateString(str);
+    LLVMDisposeMessage(str);
+    return out;
 }
 
 API_EXPORT(const char *)
@@ -400,9 +403,9 @@
     llvm::Type* unwrapped = llvm::unwrap(type);
     llvm::StructType* ty = llvm::dyn_cast<llvm::StructType>(unwrapped);
     if (ty && !ty->isLiteral()) {
-        return strdup(ty->getStructName().str().c_str());
+        return LLVMPY_CreateString(ty->getStructName().str().c_str());
     }
-    return strdup("");
+    return LLVMPY_CreateString("");
 }
 
 API_EXPORT(bool)
@@ -501,9 +504,9 @@
     llvm::Value* unwrapped = llvm::unwrap(Val);
     llvm::Instruction* inst = llvm::dyn_cast<llvm::Instruction>(unwrapped);
     if (inst) {
-        return strdup(inst->getOpcodeName());
+        return LLVMPY_CreateString(inst->getOpcodeName());
     }
-    return strdup("");
+    return LLVMPY_CreateString("");
 }
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/_version.py 
new/llvmlite-0.30.0/llvmlite/_version.py
--- old/llvmlite-0.29.0/llvmlite/_version.py    2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/llvmlite/_version.py    2019-10-09 16:00:33.000000000 
+0200
@@ -9,8 +9,8 @@
 # versioneer-0.12 (https://github.com/warner/python-versioneer)
 
 # these strings will be replaced by git during git-archive
-git_refnames = " (tag: v0.29.0, release0.29)"
-git_full = "491dcbaa0a995686da65da9c84774b552b738a9e"
+git_refnames = " (tag: v0.30.0, release0.30)"
+git_full = "3cad106e2f727bc400f1b426ce306b1e30e34b72"
 
 # these strings are filled in when 'setup.py versioneer' creates _version.py
 tag_prefix = "v"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/binding/ffi.py 
new/llvmlite-0.30.0/llvmlite/binding/ffi.py
--- old/llvmlite-0.29.0/llvmlite/binding/ffi.py 2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/llvmlite/binding/ffi.py 2019-10-09 16:00:33.000000000 
+0200
@@ -169,8 +169,20 @@
     """
     _as_parameter_ = _DeadPointer()
 
-    def __init__(self, owned=True):
-        self._ptr = ctypes.c_char_p(None)
+    @classmethod
+    def from_return(cls, ptr):
+        """Constructing from a pointer returned from the C-API.
+        The pointer must be allocated with LLVMPY_CreateString.
+
+        Note
+        ----
+        Because ctypes auto-converts *restype* of *c_char_p* into a python
+        string, we must use *c_void_p* to obtain the raw pointer.
+        """
+        return cls(init=ctypes.cast(ptr, ctypes.c_char_p))
+
+    def __init__(self, owned=True, init=None):
+        self._ptr = init if init is not None else ctypes.c_char_p(None)
         self._as_parameter_ = ctypes.byref(self._ptr)
         self._owned = owned
 
@@ -206,6 +218,27 @@
 
     __nonzero__ = __bool__
 
+    @property
+    def bytes(self):
+        """Get the raw bytes of content of the char pointer.
+        """
+        return self._ptr.value
+
+
+def ret_string(ptr):
+    """To wrap string return-value from C-API.
+    """
+    if ptr is not None:
+        return str(OutputString.from_return(ptr))
+
+def ret_bytes(ptr):
+    """To wrap bytes return-value from C-API.
+    """
+    if ptr is not None:
+        return OutputString.from_return(ptr).bytes
+
+
+
 
 class ObjectRef(object):
     """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/binding/value.py 
new/llvmlite-0.30.0/llvmlite/binding/value.py
--- old/llvmlite-0.29.0/llvmlite/binding/value.py       2019-05-29 
17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/llvmlite/binding/value.py       2019-10-09 
16:00:33.000000000 +0200
@@ -1,4 +1,4 @@
-from ctypes import POINTER, c_char_p, c_int, c_size_t, c_uint, c_bool
+from ctypes import POINTER, c_char_p, c_int, c_size_t, c_uint, c_bool, c_void_p
 import enum
 
 from . import ffi
@@ -51,7 +51,7 @@
         """
         Get type name
         """
-        return _decode_string(ffi.lib.LLVMPY_GetTypeName(self))
+        return ffi.ret_string(ffi.lib.LLVMPY_GetTypeName(self))
 
     @property
     def is_pointer(self):
@@ -71,7 +71,7 @@
         return TypeRef(ffi.lib.LLVMPY_GetElementType(self))
 
     def __str__(self):
-        return _decode_string(ffi.lib.LLVMPY_PrintType(self))
+        return ffi.ret_string(ffi.lib.LLVMPY_PrintType(self))
 
 
 class ValueRef(ffi.ObjectRef):
@@ -297,7 +297,7 @@
         if not self.is_instruction:
             raise ValueError('expected instruction value, got %s'
                              % (self._kind,))
-        return _decode_string(ffi.lib.LLVMPY_GetOpcodeName(self))
+        return ffi.ret_string(ffi.lib.LLVMPY_GetOpcodeName(self))
 
 
 class _ValueIterator(ffi.ObjectRef):
@@ -347,7 +347,7 @@
         self._capi.LLVMPY_DisposeAttributeListIter(self)
 
     def _next(self):
-        return ffi.lib.LLVMPY_AttributeListIterNext(self)
+        return ffi.ret_bytes(ffi.lib.LLVMPY_AttributeListIterNext(self))
 
 
 class _AttributeSetIterator(_AttributeIterator):
@@ -356,7 +356,7 @@
         self._capi.LLVMPY_DisposeAttributeSetIter(self)
 
     def _next(self):
-        return ffi.lib.LLVMPY_AttributeSetIterNext(self)
+        return ffi.ret_bytes(ffi.lib.LLVMPY_AttributeSetIterNext(self))
 
 
 class _BlocksIterator(_ValueIterator):
@@ -421,8 +421,9 @@
 ffi.lib.LLVMPY_TypeOf.argtypes = [ffi.LLVMValueRef]
 ffi.lib.LLVMPY_TypeOf.restype = ffi.LLVMTypeRef
 
+
 ffi.lib.LLVMPY_PrintType.argtypes = [ffi.LLVMTypeRef]
-ffi.lib.LLVMPY_PrintType.restype = c_char_p
+ffi.lib.LLVMPY_PrintType.restype = c_void_p
 
 ffi.lib.LLVMPY_TypeIsPointer.argtypes = [ffi.LLVMTypeRef]
 ffi.lib.LLVMPY_TypeIsPointer.restype = c_bool
@@ -432,7 +433,7 @@
 
 
 ffi.lib.LLVMPY_GetTypeName.argtypes = [ffi.LLVMTypeRef]
-ffi.lib.LLVMPY_GetTypeName.restype = c_char_p
+ffi.lib.LLVMPY_GetTypeName.restype = c_void_p
 
 ffi.lib.LLVMPY_GetLinkage.argtypes = [ffi.LLVMValueRef]
 ffi.lib.LLVMPY_GetLinkage.restype = c_int
@@ -495,10 +496,10 @@
 ffi.lib.LLVMPY_DisposeOperandsIter.argtypes = [ffi.LLVMOperandsIterator]
 
 ffi.lib.LLVMPY_AttributeListIterNext.argtypes = [ffi.LLVMAttributeListIterator]
-ffi.lib.LLVMPY_AttributeListIterNext.restype = c_char_p
+ffi.lib.LLVMPY_AttributeListIterNext.restype = c_void_p
 
 ffi.lib.LLVMPY_AttributeSetIterNext.argtypes = [ffi.LLVMAttributeSetIterator]
-ffi.lib.LLVMPY_AttributeSetIterNext.restype = c_char_p
+ffi.lib.LLVMPY_AttributeSetIterNext.restype = c_void_p
 
 ffi.lib.LLVMPY_BlocksIterNext.argtypes = [ffi.LLVMBlocksIterator]
 ffi.lib.LLVMPY_BlocksIterNext.restype = ffi.LLVMValueRef
@@ -513,4 +514,4 @@
 ffi.lib.LLVMPY_OperandsIterNext.restype = ffi.LLVMValueRef
 
 ffi.lib.LLVMPY_GetOpcodeName.argtypes = [ffi.LLVMValueRef]
-ffi.lib.LLVMPY_GetOpcodeName.restype = c_char_p
+ffi.lib.LLVMPY_GetOpcodeName.restype = c_void_p
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/ir/builder.py 
new/llvmlite-0.30.0/llvmlite/ir/builder.py
--- old/llvmlite-0.29.0/llvmlite/ir/builder.py  2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/llvmlite/ir/builder.py  2019-10-09 16:00:33.000000000 
+0200
@@ -69,7 +69,7 @@
     return wrap
 
 
-def _uniop_intrinsic(opname):
+def _uniop_intrinsic_int(opname):
     def wrap(fn):
         @functools.wraps(fn)
         def wrapped(self, operand, name=''):
@@ -83,6 +83,20 @@
     return wrap
 
 
+def _uniop_intrinsic_float(opname):
+    def wrap(fn):
+        @functools.wraps(fn)
+        def wrapped(self, operand, name=''):
+            if not isinstance(operand.type, (types.FloatType, 
types.DoubleType)):
+                raise TypeError("expected a float type, got %s" % operand.type)
+            fn = self.module.declare_intrinsic(opname, [operand.type])
+            return self.call(fn, [operand], name)
+
+        return wrapped
+
+    return wrap
+
+
 def _uniop_intrinsic_with_flag(opname):
     def wrap(fn):
         @functools.wraps(fn)
@@ -109,7 +123,9 @@
                         a.type,
                         b.type,
                         c.type))
-            elif not isinstance(a.type, (types.FloatType, types.DoubleType)):
+            elif not isinstance(
+                    a.type,
+                    (types.HalfType, types.FloatType, types.DoubleType)):
                 raise TypeError("expected an floating point type, got %s" % 
a.type)
             fn = self.module.declare_intrinsic(opname, [a.type, b.type, 
c.type])
             return self.call(fn, [a, b, c], name)
@@ -981,19 +997,19 @@
         self._insert(inst)
         return inst
 
-    @_uniop_intrinsic("llvm.bswap")
+    @_uniop_intrinsic_int("llvm.bswap")
     def bswap(self, cond):
         """
         Used to byte swap integer values with an even number of bytes 
(positive multiple of 16 bits)
         """
 
-    @_uniop_intrinsic("llvm.bitreverse")
+    @_uniop_intrinsic_int("llvm.bitreverse")
     def bitreverse(self, cond):
         """
         Reverse the bitpattern of an integer value; for example 0b10110110 
becomes 0b01101101.
         """
 
-    @_uniop_intrinsic("llvm.ctpop")
+    @_uniop_intrinsic_int("llvm.ctpop")
     def ctpop(self, cond):
         """
         Counts the number of bits set in a value.
@@ -1016,3 +1032,24 @@
         """
         Perform the fused multiply-add operation.
         """
+
+    def convert_from_fp16(self, a, to=None, name=''):
+        """
+        Convert from an i16 to the given FP type
+        """
+        if not to:
+            raise TypeError("expected a float return type")
+        if not isinstance(to, (types.FloatType, types.DoubleType)):
+            raise TypeError("expected a float type, got %s" % to)
+        if a.type != types.IntType(16):
+            raise TypeError("expected an i16 type, got %s" % a.type)
+
+        opname = 'llvm.convert.from.fp16'
+        fn = self.module.declare_intrinsic(opname, [to])
+        return self.call(fn, [a], name)
+
+    @_uniop_intrinsic_float("llvm.convert.to.fp16")
+    def convert_to_fp16(self, a):
+        """
+        Convert the given FP number to an i16
+        """
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/ir/module.py 
new/llvmlite-0.30.0/llvmlite/ir/module.py
--- old/llvmlite-0.29.0/llvmlite/ir/module.py   2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/llvmlite/ir/module.py   2019-10-09 16:00:33.000000000 
+0200
@@ -174,6 +174,10 @@
                 fnty = types.FunctionType(tys[0], [tys[0], types.IntType(32)])
             elif intrinsic == 'llvm.pow':
                 fnty = types.FunctionType(tys[0], tys*2)
+            elif intrinsic == 'llvm.convert.from.fp16':
+                fnty = types.FunctionType(tys[0], [types.IntType(16)])
+            elif intrinsic == 'llvm.convert.to.fp16':
+                fnty = types.FunctionType(types.IntType(16), tys)
             else:
                 fnty = types.FunctionType(tys[0], tys)
         elif len(tys) == 2:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/ir/types.py 
new/llvmlite-0.30.0/llvmlite/ir/types.py
--- old/llvmlite-0.29.0/llvmlite/ir/types.py    2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/llvmlite/ir/types.py    2019-10-09 16:00:33.000000000 
+0200
@@ -257,6 +257,17 @@
     return struct.unpack('f', struct.pack('f', value))[0]
 
 
+def _as_half(value):
+    """
+    Truncate to half-precision float.
+    """
+    try:
+        return struct.unpack('e', struct.pack('e', value))[0]
+    except struct.error:
+        # 'e' only added in Python 3.6+
+        return _as_float(value)
+
+
 def _format_float_as_hex(value, packfmt, unpackfmt, numdigits):
     raw = struct.pack(packfmt, float(value))
     intrep = struct.unpack(unpackfmt, raw)[0]
@@ -288,6 +299,20 @@
         cls._instance_cache = super(_BaseFloatType, cls).__new__(cls)
 
 
+class HalfType(_BaseFloatType):
+    """
+    The type for single-precision floats.
+    """
+    null = '0.0'
+    intrinsic_name = 'f16'
+
+    def __str__(self):
+        return 'half'
+
+    def format_constant(self, value):
+        return _format_double(_as_half(value))
+
+
 class FloatType(_BaseFloatType):
     """
     The type for single-precision floats.
@@ -316,7 +341,7 @@
         return _format_double(value)
 
 
-for _cls in (FloatType, DoubleType):
+for _cls in (HalfType, FloatType, DoubleType):
     _cls._create_instance()
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/ir/values.py 
new/llvmlite-0.30.0/llvmlite/ir/values.py
--- old/llvmlite-0.29.0/llvmlite/ir/values.py   2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/llvmlite/ir/values.py   2019-10-09 16:00:33.000000000 
+0200
@@ -6,6 +6,7 @@
 from __future__ import print_function, absolute_import
 
 import string
+import re
 
 from .. import six
 from . import types, _utils
@@ -16,6 +17,8 @@
                 frozenset(map(ord, string.digits)) |
                 frozenset(map(ord, ' !#$%&\'()*+,-./:;<=>?@[]^_`{|}~')))
 
+_SIMPLE_IDENTIFIER_RE = re.compile(r"[-a-zA-Z$._][-a-zA-Z$._0-9]*$")
+
 
 def _escape_string(text, _map={}):
     """
@@ -790,7 +793,7 @@
         return self.parent.module
 
     def descr(self, buf):
-        buf.append("{0}:\n".format(self.name))
+        buf.append("{0}:\n".format(self._format_name()))
         buf += ["  {0}\n".format(instr) for instr in self.instructions]
 
     def replace(self, old, new):
@@ -804,6 +807,16 @@
         for bb in self.parent.basic_blocks:
             for instr in bb.instructions:
                 instr.replace_usage(old, new)
+    
+    def _format_name(self):
+        # Per the LLVM Language Ref on identifiers, names matching the 
following 
+        # regex do not need to be quoted: [%@][-a-zA-Z$._][-a-zA-Z$._0-9]*
+        # Otherwise, the identifier must be quoted and escaped.
+        name = self.name
+        if not _SIMPLE_IDENTIFIER_RE.match(name):
+            name = name.replace('\\', '\\5c').replace('"', '\\22')
+            name = '"{0}"'.format(name)
+        return name
 
 
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/llvmpy/core.py 
new/llvmlite-0.30.0/llvmlite/llvmpy/core.py
--- old/llvmlite-0.29.0/llvmlite/llvmpy/core.py 2019-05-29 17:43:46.000000000 
+0200
+++ new/llvmlite-0.30.0/llvmlite/llvmpy/core.py 2019-10-09 16:00:33.000000000 
+0200
@@ -66,6 +66,10 @@
         return ir.FloatType()
 
     @staticmethod
+    def half():
+        return ir.HalfType()
+
+    @staticmethod
     def double():
         return ir.DoubleType()
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/tests/test_binding.py 
new/llvmlite-0.30.0/llvmlite/tests/test_binding.py
--- old/llvmlite-0.29.0/llvmlite/tests/test_binding.py  2019-05-29 
17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/llvmlite/tests/test_binding.py  2019-10-09 
16:00:33.000000000 +0200
@@ -155,6 +155,19 @@
     @llvm.global_dtors = appending global [1 x {{i32, void ()*, i8*}}] [{{i32, 
void ()*, i8*}} {{i32 0, void ()* @dtor_A, i8* null}}]
     """
 
+
+asm_nonalphanum_blocklabel = """; ModuleID = ""
+target triple = "unknown-unknown-unknown"
+target datalayout = ""
+
+define i32 @"foo"() 
+{
+"<>!*''#":
+  ret i32 12345
+}
+"""
+
+
 asm_attributes = r"""
 declare void @a_readonly_func(i8 *) readonly
 
@@ -250,6 +263,16 @@
         self.assertIn("parsing error", s)
         self.assertIn("invalid operand type", s)
 
+    def test_nonalphanum_block_name(self):
+        mod = ir.Module()
+        ft  = ir.FunctionType(ir.IntType(32), [])
+        fn  = ir.Function(mod, ft, "foo")
+        bd  = ir.IRBuilder(fn.append_basic_block(name="<>!*''#"))
+        bd.ret(ir.Constant(ir.IntType(32), 12345))
+        asm = str(mod)
+        binding_mod = llvm.parse_assembly(asm)
+        self.assertEqual(asm, asm_nonalphanum_blocklabel)
+
     def test_global_context(self):
         gcontext1 = llvm.context.get_global_context()
         gcontext2 = llvm.context.get_global_context()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/tests/test_ir.py 
new/llvmlite-0.30.0/llvmlite/tests/test_ir.py
--- old/llvmlite-0.29.0/llvmlite/tests/test_ir.py       2019-05-29 
17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/llvmlite/tests/test_ir.py       2019-10-09 
16:00:33.000000000 +0200
@@ -22,6 +22,7 @@
 int16 = ir.IntType(16)
 int32 = ir.IntType(32)
 int64 = ir.IntType(64)
+hlf = ir.HalfType()
 flt = ir.FloatType()
 dbl = ir.DoubleType()
 
@@ -1141,10 +1142,13 @@
         a, b = builder.function.args[:2]
         tp_f = ir.FunctionType(flt, (int32, int32))
         tp_g = ir.FunctionType(dbl, (int32,), var_arg=True)
+        tp_h = ir.FunctionType(hlf, (int32, int32))
         f = ir.Function(builder.function.module, tp_f, 'f')
         g = ir.Function(builder.function.module, tp_g, 'g')
+        h = ir.Function(builder.function.module, tp_h, 'h')
         builder.call(f, (a, b), 'res_f')
         builder.call(g, (b, a), 'res_g')
+        builder.call(h, (a, b), 'res_h')
         builder.call(f, (a, b), 'res_f_fast', cconv='fastcc')
         res_f_readonly = builder.call(f, (a, b), 'res_f_readonly')
         res_f_readonly.attributes.add('readonly')
@@ -1154,6 +1158,7 @@
             my_block:
                 %"res_f" = call float @"f"(i32 %".1", i32 %".2")
                 %"res_g" = call double (i32, ...) @"g"(i32 %".2", i32 %".1")
+                %"res_h" = call half @"h"(i32 %".1", i32 %".2")
                 %"res_f_fast" = call fastcc float @"f"(i32 %".1", i32 %".2")
                 %"res_f_readonly" = call float @"f"(i32 %".1", i32 %".2") 
readonly
                 %"res_fast" = call fast float @"f"(i32 %".1", i32 %".2")
@@ -1367,6 +1372,75 @@
                 ret i16 %"c"
             """)
 
+    def test_convert_to_fp16_f32(self):
+        block = self.block(name='my_block')
+        builder = ir.IRBuilder(block)
+        a = ir.Constant(flt, 5.0)
+        b = builder.convert_to_fp16(a, name='b')
+        builder.ret(b)
+        self.check_block(block, """\
+            my_block:
+                %"b" = call i16 @"llvm.convert.to.fp16.f32"(float 
0x4014000000000000)
+                ret i16 %"b"
+            """)
+
+    def test_convert_to_fp16_f32_wrongtype(self):
+        block = self.block(name='my_block')
+        builder = ir.IRBuilder(block)
+        a = ir.Constant(int16, 5)
+
+        with self.assertRaises(TypeError) as raises:
+            builder.convert_to_fp16(a, name='b')
+        self.assertIn(
+            "expected a float type, got i16",
+            str(raises.exception))
+
+    def test_convert_from_fp16_f32(self):
+        block = self.block(name='my_block')
+        builder = ir.IRBuilder(block)
+        a = ir.Constant(int16, 5)
+        b = builder.convert_from_fp16(a, name='b', to=flt)
+        builder.ret(b)
+        self.check_block(block, """\
+            my_block:
+                %"b" = call float @"llvm.convert.from.fp16.f32"(i16 5)
+                ret float %"b"
+            """)
+
+    def test_convert_from_fp16_f32_notype(self):
+        block = self.block(name='my_block')
+        builder = ir.IRBuilder(block)
+        a = ir.Constant(flt, 5.5)
+
+        with self.assertRaises(TypeError) as raises:
+            builder.convert_from_fp16(a, name='b')
+        self.assertIn(
+            "expected a float return type",
+            str(raises.exception))
+
+
+    def test_convert_from_fp16_f32_wrongtype(self):
+        block = self.block(name='my_block')
+        builder = ir.IRBuilder(block)
+        a = ir.Constant(flt, 5.5)
+
+        with self.assertRaises(TypeError) as raises:
+            builder.convert_from_fp16(a, name='b', to=flt)
+        self.assertIn(
+            "expected an i16 type, got float",
+            str(raises.exception))
+
+    def test_convert_from_fp16_f32_wrongtype2(self):
+        block = self.block(name='my_block')
+        builder = ir.IRBuilder(block)
+        a = ir.Constant(flt, 5.5)
+
+        with self.assertRaises(TypeError) as raises:
+            builder.convert_from_fp16(a, name='b', to=int16)
+        self.assertIn(
+            "expected a float type, got i16",
+            str(raises.exception))
+
     def test_cttz(self):
         block = self.block(name='my_block')
         builder = ir.IRBuilder(block)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/llvmlite/tests/test_valuerepr.py 
new/llvmlite-0.30.0/llvmlite/tests/test_valuerepr.py
--- old/llvmlite-0.29.0/llvmlite/tests/test_valuerepr.py        2019-05-29 
17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/llvmlite/tests/test_valuerepr.py        2019-10-09 
16:00:33.000000000 +0200
@@ -1,11 +1,12 @@
 from __future__ import print_function, absolute_import
 
 import math
+import sys
 import unittest
 
 from llvmlite.ir import (
     Constant, FloatType, DoubleType, LiteralStructType, IntType,
-    ArrayType)
+    ArrayType, HalfType)
 from . import TestCase
 
 
@@ -13,6 +14,9 @@
 int16 = IntType(16)
 
 
+PY36_OR_LATER = sys.version_info[:2] >= (3, 6)
+
+
 class TestValueRepr(TestCase):
 
     def test_double_repr(self):
@@ -31,6 +35,15 @@
         check_repr(float('inf'), "float 0x7ff0000000000000")
         check_repr(float('-inf'), "float 0xfff0000000000000")
 
+    @unittest.skipUnless(PY36_OR_LATER, 'py36+ only')
+    def test_half_repr(self):
+        def check_repr(val, expected):
+            c = Constant(HalfType(), val)
+            self.assertEqual(str(c), expected)
+        check_repr(math.pi, "half 0x4009200000000000")
+        check_repr(float('inf'), "half 0x7ff0000000000000")
+        check_repr(float('-inf'), "half 0xfff0000000000000")
+
     def test_struct_repr(self):
         tp = LiteralStructType([int8, int16])
         c = Constant(tp, (Constant(int8, 100), Constant(int16, 1000)))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/llvmlite-0.29.0/setup.py new/llvmlite-0.30.0/setup.py
--- old/llvmlite-0.29.0/setup.py        2019-05-29 17:43:46.000000000 +0200
+++ new/llvmlite-0.30.0/setup.py        2019-10-09 16:00:33.000000000 +0200
@@ -42,8 +42,10 @@
 build_ext = cmdclass.get('build_ext', build_ext)
 
 
-def build_library_files(dry_run):
+def build_library_files(dry_run, pic=False):
     cmd = [sys.executable, os.path.join(here_dir, 'ffi', 'build.py')]
+    if pic:
+        os.environ['CXXFLAGS'] = os.environ.get('CXXFLAGS', '') + ' -fPIC'
     spawn(cmd, dry_run=dry_run)
 
 
@@ -124,7 +126,9 @@
         def run(self):
             # Ensure the binding file exist when running wheel build
             from llvmlite.utils import get_library_files
-            build_library_files(self.dry_run)
+            # Turn on -fPIC for wheel building on Linux
+            pic = sys.platform.startswith('linux')
+            build_library_files(self.dry_run, pic=pic)
             self.distribution.package_data.update({
                 "llvmlite.binding": get_library_files(),
             })


Reply via email to