Skip to content

Commit aca8a5c

Browse files
authored
[libclc] Remove clspv-specific clc conversions (#128500)
The clc and clc+clspv modes produced the same conversions code, so this patch simplifies the process. It further simplifies the internal checks the script makes by assuming the mutual exclusivity.
1 parent 971fc42 commit aca8a5c

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

libclc/CMakeLists.txt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -258,13 +258,6 @@ if ( clspv-- IN_LIST LIBCLC_TARGETS_TO_BUILD OR clspv64-- IN_LIST LIBCLC_TARGETS
258258
DEPENDS ${script_loc} )
259259
add_custom_target( generate-clspv-convert.cl DEPENDS clspv-convert.cl )
260260
set_target_properties( generate-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )
261-
262-
add_custom_command(
263-
OUTPUT clc-clspv-convert.cl
264-
COMMAND ${Python3_EXECUTABLE} ${script_loc} --clc --clspv > clc-clspv-convert.cl
265-
DEPENDS ${script_loc} )
266-
add_custom_target( generate-clc-clspv-convert.cl DEPENDS clc-clspv-convert.cl )
267-
set_target_properties( generate-clc-clspv-convert.cl PROPERTIES FOLDER "libclc/Sourcegenning" )
268261
endif()
269262

270263
enable_testing()
@@ -314,12 +307,7 @@ foreach( t ${LIBCLC_TARGETS_TO_BUILD} )
314307
endif()
315308

316309
set( clc_lib_files )
317-
318-
if( ARCH STREQUAL clspv OR ARCH STREQUAL clspv64 )
319-
set( clc_gen_files clc-clspv-convert.cl )
320-
else()
321-
set( clc_gen_files clc-convert.cl )
322-
endif()
310+
set( clc_gen_files clc-convert.cl )
323311

324312
libclc_configure_lib_source(
325313
clc_lib_files

libclc/generic/lib/gen_convert.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
# convert_<destTypen><_sat><_roundingMode>(<sourceTypen>)
2929

3030
import argparse
31+
from sys import stderr
3132

3233
parser = argparse.ArgumentParser()
3334
parser.add_argument(
@@ -41,6 +42,14 @@
4142
clc = args.clc
4243
clspv = args.clspv
4344

45+
46+
# We don't generate clspv-specific code for clc conversions - don't allow this
47+
# accidentally (later checks rely on mutual exclusivity)
48+
if clc and clspv:
49+
print("Error: clc and clspv conversions are mutually exclusive", file=stderr)
50+
exit(1)
51+
52+
4453
types = [
4554
"char",
4655
"uchar",
@@ -308,7 +317,7 @@ def generate_default_conversion(src, dst, mode):
308317

309318
# Do not generate user-facing default conversions for clspv as they are handled
310319
# natively
311-
if clc or not clspv:
320+
if not clspv:
312321
for src in types:
313322
for dst in types:
314323
generate_default_conversion(src, dst, "")
@@ -318,7 +327,7 @@ def generate_default_conversion(src, dst, mode):
318327
for mode in rounding_modes:
319328
# Do not generate user-facing "_rte" conversions for clspv as they
320329
# are handled natively
321-
if clspv and not clc and mode == "_rte":
330+
if clspv and mode == "_rte":
322331
continue
323332
generate_default_conversion(src, dst, mode)
324333

@@ -560,6 +569,6 @@ def generate_float_conversion(src, dst, size, mode, sat):
560569
for mode in rounding_modes:
561570
# Do not generate user-facing "_rte" conversions for clspv as
562571
# they are handled natively
563-
if clspv and not clc and mode == "_rte":
572+
if clspv and mode == "_rte":
564573
continue
565574
generate_float_conversion(src, dst, size, mode, "")

0 commit comments

Comments
 (0)