Returns a dictionary-like object indicating the CPU features for current
    architecture and whether they are enabled for this CPU.  The key-value pairs
    are the feature name as string and a boolean indicating whether the feature
    is available.  The returned value is an instance of ``FeatureMap`` class,
    which adds a new method ``.flatten()`` for returning a string suitable for
    use as the "features" argument to ``Target.create_target_machine()``.

    If LLVM has not implemented this feature or it fails to get the information,
    this function will raise a RuntimeError exception.

def get_host_cpu_features():
    """
    Returns a dictionary-like object indicating the CPU features for current
    architecture and whether they are enabled for this CPU.  The key-value pairs
    are the feature name as string and a boolean indicating whether the feature
    is available.  The returned value is an instance of ``FeatureMap`` class,
    which adds a new method ``.flatten()`` for returning a string suitable for
    use as the "features" argument to ``Target.create_target_machine()``.

    If LLVM has not implemented this feature or it fails to get the information,
    this function will raise a RuntimeError exception.
    """
    with ffi.OutputString() as out:
        outdict = FeatureMap()
        if not ffi.lib.LLVMPY_GetHostCPUFeatures(out):
            raise RuntimeError("failed to get host cpu features.")
        flag_map = {'+': True, '-': False}
        content = str(out)
        if content:  # protect against empty string
            for feat in content.split(','):
                if feat:  # protect against empty feature
                    outdict[feat[1:]] = flag_map[feat[0]]
        return outdict