Skip to content

Commit

Permalink
Testing/portability: re-enable most of the C23 tests
Browse files Browse the repository at this point in the history
The previous way of coping with platforms that only support
_BitInt up to 128 bits wide was to disable all of the C23 tests.

This commit changes the test to be much more precise.
A test is only disabled if it depends on wide _BitInt
support and wide _BitInts are not supported on this platform.
  • Loading branch information
alastairreid committed Jan 6, 2025
1 parent 929cf1d commit a8d316d
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 17 deletions.
4 changes: 0 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,7 @@ lit_test: build

WIDE_BITINT_SUPPORTED := `$(MAKE) -C runtime/test wide_bitint_supported`

ifeq (1, $(WIDE_BITINT_SUPPORTED))
BACKENDS := interpreter c23 ac fallback
else
BACKENDS := interpreter ac fallback
endif

test_backends: ${addprefix test_backend_, ${BACKENDS}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@ begin
print_bits_hex((-16384)[0 +: 70]); println();
// CHECK: 70'x3fffffffffffffc000

print_bits_hex(256'xff01020304050607_1011121314151617_2021222324252627_3031323334353637); println();
// CHECK: 256'xff01020304050607101112131415161720212223242526273031323334353637

return 0;
end
11 changes: 11 additions & 0 deletions tests/backends/bits_print_hex_01.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// RUN: %aslrun %s | filecheck %s
// REQUIRES: !c23 || wide_bitint
// Copyright (C) 2023-2024 Intel Corporation

func main() => integer
begin
print_bits_hex(256'xff01020304050607_1011121314151617_2021222324252627_3031323334353637); println();
// CHECK: 256'xff01020304050607101112131415161720212223242526273031323334353637

return 0;
end
10 changes: 0 additions & 10 deletions tests/backends/bits_sext_00.asl
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ begin
return asl_sign_extend_bits(x, 65);
end

func Test_70_140(x : bits(70)) => bits(140)
begin
return asl_sign_extend_bits(x, 140);
end

func main() => integer
begin
// Basic check
Expand Down Expand Up @@ -71,10 +66,5 @@ begin
print_bits_hex(Test4(64'xc123_4567_89ab_cdef)); println();
// CHECK: 65'x1c123456789abcdef

print_bits_hex(Test_70_140(16384[0 +: 70])); println();
// CHECK: 140'x4000
print_bits_hex(Test_70_140((-16384)[0 +: 70])); println();
// CHECK: 140'xfffffffffffffffffffffffffffffffc000

return 0;
end
18 changes: 18 additions & 0 deletions tests/backends/bits_sext_01.asl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// RUN: %aslrun %s | filecheck %s
// REQUIRES: !c23 || wide_bitint
// Copyright (C) 2023-2024 Intel Corporation

func Test_70_140(x : bits(70)) => bits(140)
begin
return asl_sign_extend_bits(x, 140);
end

func main() => integer
begin
print_bits_hex(Test_70_140(16384[0 +: 70])); println();
// CHECK: 140'x4000
print_bits_hex(Test_70_140((-16384)[0 +: 70])); println();
// CHECK: 140'xfffffffffffffffffffffffffffffffc000

return 0;
end
7 changes: 7 additions & 0 deletions tests/lit.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (C) 2023-2024 Intel Corporation
import lit.formats
import subprocess

lit_cfg_path = os.path.dirname(os.path.abspath(__file__))
asl_path = os.path.dirname(lit_cfg_path)
Expand All @@ -18,7 +19,13 @@ else:
config.test_format = lit.formats.ShTest("0")
config.suffixes = {".asl"}
config.target_triple = ""

config.available_features = [backend]

proc = subprocess.run(["make", f"-C{asl_path}/runtime/test", "wide_bitint_supported"], capture_output=True, encoding='latin_1')
if proc.returncode == 0 and "1" in proc.stdout:
config.available_features.add("wide_bitint")

config.substitutions.append(('%asli', asli_bin_path))
config.substitutions.append(('%aslrun', f"{asl2c_path} --backend={backend} -O0 --run"))
config.environment["ASLI_DIR"] = asl_path
Expand Down

0 comments on commit a8d316d

Please sign in to comment.