Allow specifying an import module using @wasm #1305.

This commit is contained in:
Christoffer Lerno
2024-09-24 21:31:48 +02:00
parent d067a31ce6
commit a258f2084f
8 changed files with 84 additions and 7 deletions

View File

@@ -0,0 +1,26 @@
// #target: macos-aarch64
module test;
def @Test(x) = { @extern("Foo" +++ x) };
fn void hello_world() @Test("Megaman")
{}
fn void ello_world() @Test("Pegasus")
{}
fn int main()
{
hello_world();
ello_world();
return 0;
}
/* #expect: test.ll
define i32 @main() #0 {
entry:
call void @FooMegaman()
call void @FooPegasus()
ret i32 0
}

View File

@@ -0,0 +1,8 @@
// #target: wasm32
module test;
extern fn void test() @wasm("hello", "world");
/* #expect: test.ll
declare void @world() #0
attributes #0 = { nounwind uwtable "no-trapping-math"="true" "stack-protector-buffer-size"="8" "wasm-export-name"="world" "wasm-import-module"="hello" "wasm-import-name"="world" }

View File

@@ -0,0 +1,5 @@
fn void test() @wasm("hello", "world") { } // #error: Specifying a wasm import module
extern fn void test2() @wasm("a", "b", "c"); // #error: Too many arguments to
extern fn void test3() @extern("hello") @wasm("a"); // #error: An external name
extern fn void test4() @extern("hello") @wasm("a", "b"); // #error: An external name