configure: Add --enable-runtime-subnormal option
This makes it possible for runtime implementations to disable
subnormal handling at runtime.
When this flag is enabled, decisions about how to handle subnormals
in the library will be controlled by an external variable called
__CLC_SUBNORMAL_DISABLE.
Function implementations should use these new helpers for querying subnormal
support:
__clc_fp16_subnormals_supported();
__clc_fp32_subnormals_supported();
__clc_fp64_subnormals_supported();
In order for the library to link correctly with this feature,
users will be required to either:
1. Insert this variable into the module (if using the LLVM/Clang C++/C APIs).
2. Pass either subnormal_disable.bc or subnormal_use_default.bc to the
linker. These files are distributed with liblclc and installed to
$(installdir). e.g.:
llvm-link -o kernel-out.bc kernel.bc builtins-nosubnormal.bc subnormal_disable.bc
or
llvm-link -o kernel-out.bc kernel.bc builtins-nosubnormal.bc subnormal_use_default.bc
If you do not supply the --enable-runtime-subnormal then the library
behaves the same as it did before this commit.
In addition to these changes, the patch adds helper functions that
should be used when implementing library functions that need
special handling for denormals:
__clc_fp16_subnormals_supported();
__clc_fp32_subnormals_supported();
__clc_fp64_subnormals_supported();
llvm-svn: 235329
diff --git a/libclc/configure.py b/libclc/configure.py
index 602165b..7d4b537 100755
--- a/libclc/configure.py
+++ b/libclc/configure.py
@@ -34,6 +34,8 @@
help='install clc.pc to given dir')
p.add_option('-g', metavar='GENERATOR', default='make',
help='use given generator (default: make)')
+p.add_option('--enable-runtime-subnormal', action="store_true", default=False,
+ help='Allow runtimes to choose subnormal support')
(options, args) = p.parse_args()
llvm_config_exe = options.with_llvm_config or "llvm-config"
@@ -133,6 +135,16 @@
install_files_bc = []
install_deps = []
+# Create rules for subnormal helper objects
+for src in ['subnormal_disable.ll', 'subnormal_use_default.ll']:
+ obj_name = src[:-2] + 'bc'
+ obj = os.path.join('generic--', 'lib', obj_name)
+ src_file = os.path.join('generic', 'lib', src)
+ b.build(obj, 'LLVM_AS', src_file)
+ b.default(obj)
+ install_files_bc.append((obj, obj))
+ install_deps.append(obj)
+
# Create libclc.pc
clc = open('libclc.pc', 'w')
clc.write('includedir=%(inc)s\nlibexecdir=%(lib)s\n\nName: libclc\nDescription: Library requirements of the OpenCL C programming language\nVersion: %(maj)s.%(min)s.%(pat)s\nCflags: -I${includedir}\nLibs: -L${libexecdir}' %
@@ -209,6 +221,10 @@
else:
b.build(obj, clang_bc_rule, src_file)
+ obj = os.path.join('generic--', 'lib', 'subnormal_use_default.bc')
+ if not options.enable_runtime_subnormal:
+ objects.append(obj)
+
builtins_link_bc = os.path.join(target, 'lib', 'builtins.link' + obj_suffix + '.bc')
builtins_opt_bc = os.path.join(target, 'lib', 'builtins.opt' + obj_suffix + '.bc')
builtins_bc = os.path.join('built_libs', full_target_name + '.bc')