From 02e6c64a046eaaed36944888b7f01a508cb31669 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Wed, 12 Jan 2022 00:00:00 +0000 Subject: [PATCH] Migrate inline assembly incremental tests to asm! --- src/test/incremental/hashes/inline_asm.rs | 130 +++++++++------------- 1 file changed, 53 insertions(+), 77 deletions(-) diff --git a/src/test/incremental/hashes/inline_asm.rs b/src/test/incremental/hashes/inline_asm.rs index 1ddb345e5664c..bb836f203f5c0 100644 --- a/src/test/incremental/hashes/inline_asm.rs +++ b/src/test/incremental/hashes/inline_asm.rs @@ -18,23 +18,19 @@ #![allow(warnings)] #![feature(rustc_attrs)] -#![feature(llvm_asm)] #![crate_type="rlib"] - +use std::arch::asm; // Change template #[cfg(any(cfail1,cfail4))] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub fn change_template(a: i32) -> i32 { +pub fn change_template(_a: i32) -> i32 { let c: i32; unsafe { - llvm_asm!("add 1, $0" - : "=r"(c) - : "0"(a) - : - : - ); + asm!("mov {0}, 1", + out(reg) c + ); } c } @@ -45,15 +41,12 @@ pub fn change_template(a: i32) -> i32 { #[rustc_clean(cfg="cfail5", except="hir_owner_nodes, optimized_mir")] #[rustc_clean(cfg="cfail6")] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] -pub fn change_template(a: i32) -> i32 { +pub fn change_template(_a: i32) -> i32 { let c: i32; unsafe { - llvm_asm!("add 2, $0" - : "=r"(c) - : "0"(a) - : - : - ); + asm!("mov {0}, 2", + out(reg) c + ); } c } @@ -67,12 +60,10 @@ pub fn change_output(a: i32) -> i32 { let mut _out1: i32 = 0; let mut _out2: i32 = 0; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out1) - : "0"(a) - : - : - ); + asm!("mov {0}, {1}", + out(reg) _out1, + in(reg) a + ); } _out1 } @@ -87,12 +78,10 @@ pub fn change_output(a: i32) -> i32 { let mut _out1: i32 = 0; let mut _out2: i32 = 0; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out2) - : "0"(a) - : - : - ); + asm!("mov {0}, {1}", + out(reg) _out2, + in(reg) a + ); } _out1 } @@ -105,12 +94,10 @@ pub fn change_output(a: i32) -> i32 { pub fn change_input(_a: i32, _b: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "0"(_a) - : - : - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _a + ); } _out } @@ -124,12 +111,10 @@ pub fn change_input(_a: i32, _b: i32) -> i32 { pub fn change_input(_a: i32, _b: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "0"(_b) - : - : - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _b + ); } _out } @@ -142,12 +127,10 @@ pub fn change_input(_a: i32, _b: i32) -> i32 { pub fn change_input_constraint(_a: i32, _b: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "0"(_a), "r"(_b) - : - : - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _a, + in("eax") _b); } _out } @@ -161,30 +144,26 @@ pub fn change_input_constraint(_a: i32, _b: i32) -> i32 { pub fn change_input_constraint(_a: i32, _b: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "r"(_a), "0"(_b) - : - : - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _a, + in("ecx") _b); } _out } - // Change clobber #[cfg(any(cfail1,cfail4))] #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] pub fn change_clobber(_a: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "0"(_a) - :/*--*/ - : - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _a, + lateout("ecx") _ + ); } _out } @@ -198,12 +177,11 @@ pub fn change_clobber(_a: i32) -> i32 { pub fn change_clobber(_a: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "0"(_a) - : "eax" - : - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _a, + lateout("edx") _ + ); } _out } @@ -216,12 +194,11 @@ pub fn change_clobber(_a: i32) -> i32 { pub fn change_options(_a: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "0"(_a) - : - :/*-------*/ - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _a, + options(readonly), + ); } _out } @@ -235,12 +212,11 @@ pub fn change_options(_a: i32) -> i32 { pub fn change_options(_a: i32) -> i32 { let _out; unsafe { - llvm_asm!("add 1, $0" - : "=r"(_out) - : "0"(_a) - : - : "volatile" - ); + asm!("mov {0}, {1}", + out(reg) _out, + in(reg) _a, + options(nomem ), + ); } _out }