From 093ec70b1e4da3d814a137f5aea6f4ff75ad3399 Mon Sep 17 00:00:00 2001 From: roblabla Date: Thu, 24 Oct 2019 15:29:29 +0000 Subject: Add new EFIAPI ABI Adds a new ABI for the EFIAPI calls. This ABI should reflect the latest version of the UEFI specification at the time of commit (UEFI spec 2.8, URL below). The specification says that for x86_64, we should follow the win64 ABI, while on all other supported platforms (ia32, itanium, arm, arm64 and risc-v), we should follow the C ABI. To simplify the implementation, we will simply follow the C ABI on all platforms except x86_64, even those technically unsupported by the UEFI specification. https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf --- src/test/codegen/abi-efiapi.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/test/codegen/abi-efiapi.rs (limited to 'src/test/codegen') diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs new file mode 100644 index 00000000000..471f572375a --- /dev/null +++ b/src/test/codegen/abi-efiapi.rs @@ -0,0 +1,20 @@ +// Checks if the correct annotation for the efiapi ABI is passed to llvm. + +// compile-flags: -C no-prepopulate-passes + +#![crate_type = "lib"] +#![feature(abi_efiapi)] + +// CHECK: define win64 i64 @has_efiapi +#[no_mangle] +#[cfg(target_arch = "x86_64")] +pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { + a * 2 +} + +// CHECK: define c i64 @has_efiapi +#[no_mangle] +#[cfg(not(target_arch = "x86_64"))] +pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { + a * 2 +} -- cgit 1.4.1-3-g733a5 From 61732804e215d251f12802445edc43861c1f55e7 Mon Sep 17 00:00:00 2001 From: roblabla Date: Fri, 25 Oct 2019 14:44:21 +0000 Subject: Fix EFIABI test Use revisions to run the EFIABI in multiple configurations, compiling for each supported UEFI platform, and checking the ABI generated in the LLVM IR is correct. Use no_core to make it easier to test. --- src/test/codegen/abi-efiapi.rs | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'src/test/codegen') diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs index 471f572375a..cfd31ef1a31 100644 --- a/src/test/codegen/abi-efiapi.rs +++ b/src/test/codegen/abi-efiapi.rs @@ -1,20 +1,29 @@ // Checks if the correct annotation for the efiapi ABI is passed to llvm. +// revisions:x86_64 i686 aarch64 arm riscv + +//[x86_64] compile-flags: --target x86_64-unknown-uefi +//[i686] compile-flags: --target i686-unknown-linux-musl +//[aarch64] compile-flags: --target aarch64-unknown-none +//[arm] compile-flags: --target armv7r-none-eabi +//[riscv] compile-flags: --target riscv64gc-unknown-none-elf // compile-flags: -C no-prepopulate-passes #![crate_type = "lib"] -#![feature(abi_efiapi)] +#![feature(no_core, lang_items, abi_efiapi)] +#![no_core] -// CHECK: define win64 i64 @has_efiapi -#[no_mangle] -#[cfg(target_arch = "x86_64")] -pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { - a * 2 -} +#[lang="sized"] +trait Sized { } +#[lang="freeze"] +trait Freeze { } +#[lang="copy"] +trait Copy { } -// CHECK: define c i64 @has_efiapi +//x86_64: define win64cc void @has_efiapi +//i686: define void @has_efiapi +//aarch64: define void @has_efiapi +//arm: define void @has_efiapi +//riscv: define void @has_efiapi #[no_mangle] -#[cfg(not(target_arch = "x86_64"))] -pub extern "efiapi" fn has_efiapi(a: i64) -> i64 { - a * 2 -} +pub extern "efiapi" fn has_efiapi() {} -- cgit 1.4.1-3-g733a5 From 1099826efa725b5de7833d42f2b96a53881e2118 Mon Sep 17 00:00:00 2001 From: roblabla Date: Sat, 26 Oct 2019 21:05:13 +0000 Subject: Only run efiapi test on llvm 9.0+ --- src/test/codegen/abi-efiapi.rs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/test/codegen') diff --git a/src/test/codegen/abi-efiapi.rs b/src/test/codegen/abi-efiapi.rs index cfd31ef1a31..72adb95e96a 100644 --- a/src/test/codegen/abi-efiapi.rs +++ b/src/test/codegen/abi-efiapi.rs @@ -2,6 +2,8 @@ // revisions:x86_64 i686 aarch64 arm riscv +// min-llvm-version 9.0 + //[x86_64] compile-flags: --target x86_64-unknown-uefi //[i686] compile-flags: --target i686-unknown-linux-musl //[aarch64] compile-flags: --target aarch64-unknown-none -- cgit 1.4.1-3-g733a5