Skip to content

Commit e73e603

Browse files
committed
Tests: change to use FFI syntax instead of command line
1 parent 278392b commit e73e603

8 files changed

Lines changed: 52 additions & 72 deletions

File tree

tests/backends/ffi_export_00.isa

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
// RUN: %aslrun %s --import=FFI_Call128 --export=FFI_Extract128_32 --extra-c=%S/ffi_export_00.c | filecheck %s
1+
// RUN: %aslrun %s --extra-c=%S/ffi_export_00.c | filecheck %s
22
// Copyright (C) 2025-2026 Intel Corporation
33

44
// UNSUPPORTED: interpreter
55

6+
foreign import function "FFI_Call128" = FFI_Call128 with {};
7+
foreign export function "FFI_Extract128_32" = FFI_Extract128_32 with {};
8+
69
// Function imported from C
710
function FFI_Call128(x : Bits(128)) -> Bits(32);
811

tests/backends/ffi_export_01.isa

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
1-
// RUN: %aslrun %s --configuration=%S/ffi_export_01.json --extra-c=%S/ffi_export_01.c | filecheck %s
1+
// RUN: %aslrun %s --extra-c=%S/ffi_export_01.c | filecheck %s
22
// Copyright (C) 2025-2026 Intel Corporation
33

44
// UNSUPPORTED: interpreter
55

6+
foreign export type "E" = E;
7+
foreign export function "FFI_bits8" = FFI_bits8 with {};
8+
foreign export function "FFI_bits16" = FFI_bits16 with {};
9+
foreign export function "FFI_bits32" = FFI_bits32 with {};
10+
foreign export function "FFI_bits64" = FFI_bits64 with {};
11+
foreign export function "FFI_bits2" = FFI_bits2 with {};
12+
foreign export function "FFI_bits17" = FFI_bits17 with {};
13+
foreign export function "FFI_bits65" = FFI_bits65 with {};
14+
foreign export function "FFI_bits127" = FFI_bits127 with {};
15+
foreign export function "FFI_bits128" = FFI_bits128 with {};
16+
foreign export function "FFI_string" = FFI_string with {};
17+
foreign export function "FFI_E" = FFI_E with {};
18+
foreign export function "FFI_Boolean" = FFI_Boolean with {};
19+
foreign export function "FFI_integer" = FFI_integer with {};
20+
foreign export function "FFI_sint17" = FFI_sint17 with {};
21+
foreign export function "FFI_int_bool" = FFI_int_bool with {};
22+
23+
foreign import function "FFI_test_exports" = FFI_test_exports with {};
24+
625
enumeration E = { A, B, C };
726

827
// to be exported

tests/backends/ffi_export_01.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

tests/backends/ffi_import_00.isa

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
1-
// RUN: %aslrun %s --import=FFI_Invert32 --import=FFI_Invert128 --extra-c=%S/ffi_import_00.c | filecheck %s
1+
// RUN: %aslrun %s --extra-c=%S/ffi_import_00.c | filecheck %s
22
// Copyright (C) 2025-2026 Intel Corporation
33

44
// UNSUPPORTED: interpreter
55

6+
foreign import function "FFI_Invert32" = FFI_Invert with { size => 32 };
7+
foreign import function "FFI_Invert128" = FFI_Invert with { size => 128 };
8+
69
// The following functions will be replaced by
710
// a version that is defined externally.
811
// Normally, the internal and external version have
912
// similar behaviour but, for testing purposes, the
1013
// internal version is the identity function
1114
// and the external version inverts its argument.
12-
function FFI_Invert32(x : Bits(32)) -> Bits(32)
13-
begin
14-
return x;
15-
end
16-
17-
function FFI_Invert128(x : Bits(128)) -> Bits(128)
18-
begin
19-
return x;
20-
end
15+
function FFI_Invert(implicit size : {0..}, x : Bits(size)) -> Bits(size);
2116

2217
function main() -> Builtin::Foreign::CInt
2318
begin
24-
Std::Print::Bits::Hex(FFI_Invert32(32'x3)); Print("\n");
19+
Std::Print::Bits::Hex(FFI_Invert(32'x3)); Print("\n");
2520
// CHECK: 32'xfffffffc
2621

27-
Std::Print::Bits::Hex(FFI_Invert128(128'x3)); Print("\n");
22+
Std::Print::Bits::Hex(FFI_Invert(128'x3)); Print("\n");
2823
// CHECK: 128'xfffffffffffffffffffffffffffffffc
2924

3025
return Builtin::Foreign::CInt::From_Integer(0);

tests/backends/ffi_import_01.isa

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
// RUN: %aslrun %s --configuration=%S/ffi_import_01.json --extra-c=%S/ffi_import_01.c | filecheck %s
1+
// RUN: %aslrun %s --extra-c=%S/ffi_import_01.c | filecheck %s
22
// Copyright (C) 2025-2026 Intel Corporation
33

44
// UNSUPPORTED: interpreter
55

6+
foreign export type "E" = E;
7+
foreign import function "FFI_null_bits8" = FFI_null_bits8 with {};
8+
foreign import function "FFI_null_bits16" = FFI_null_bits16 with {};
9+
foreign import function "FFI_null_bits32" = FFI_null_bits32 with {};
10+
foreign import function "FFI_null_bits64" = FFI_null_bits64 with {};
11+
foreign import function "FFI_null_bits2" = FFI_null_bits2 with {};
12+
foreign import function "FFI_null_bits17" = FFI_null_bits17 with {};
13+
foreign import function "FFI_null_bits65" = FFI_null_bits65 with {};
14+
foreign import function "FFI_null_bits127" = FFI_null_bits127 with {};
15+
foreign import function "FFI_null_bits128" = FFI_null_bits128 with {};
16+
foreign import function "FFI_null_string" = FFI_null_string with {};
17+
foreign import function "FFI_null_E" = FFI_null_E with {};
18+
foreign import function "FFI_null_Boolean" = FFI_null_Boolean with {};
19+
foreign import function "FFI_null_integer" = FFI_null_integer with {};
20+
foreign import function "FFI_null_sint17" = FFI_null_sint17 with {};
21+
foreign import function "FFI_int_bool" = FFI_int_bool with {};
22+
623
enumeration E = { A, B, C };
724

825
// to be defined externally

tests/backends/ffi_import_01.json

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/lit/check_monomorphization/config.json

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/lit/check_monomorphization/test_00.isa

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %iii --batchmode --configuration=%S/config.json --project=%S/iii.prj %s | filecheck %s
1+
// RUN: %iii --batchmode --project=%S/iii.prj %s | filecheck %s
22
// Copyright (C) 2024-2026 Intel Corporation
33

44
function C(x : Bits(N)) -> Integer
@@ -16,6 +16,8 @@ begin
1616
return B(0b0);
1717
end
1818

19+
foreign export function "A" = A with {};
20+
1921
// CHECK: WARNING: Bitwidth parameters are not statically known in the following definitions.
2022
// CHECK-NEXT: This will cause code generation to fail.
2123
//

0 commit comments

Comments
 (0)