From cfc1a2cd6832f62aed7be6292a89e31dc29da056 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sun, 13 Mar 2022 15:19:48 +0100 Subject: [PATCH] Remove decl_macro usage This reduces the amount of unstable features used by cg_clif --- src/compiler_builtins.rs | 26 ++++++++++++---------- src/intrinsics/mod.rs | 48 ++++++++++++++++++++-------------------- src/lib.rs | 2 +- 3 files changed, 39 insertions(+), 37 deletions(-) diff --git a/src/compiler_builtins.rs b/src/compiler_builtins.rs index 100c3b43160..c6a247cf59e 100644 --- a/src/compiler_builtins.rs +++ b/src/compiler_builtins.rs @@ -1,16 +1,18 @@ -macro builtin_functions($register:ident; $(fn $name:ident($($arg_name:ident: $arg_ty:ty),*) -> $ret_ty:ty;)*) { - #[cfg(feature = "jit")] - #[allow(improper_ctypes)] - extern "C" { - $(fn $name($($arg_name: $arg_ty),*) -> $ret_ty;)* - } - - #[cfg(feature = "jit")] - pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) { - for (name, val) in [$((stringify!($name), $name as *const u8)),*] { - builder.symbol(name, val); +macro_rules! builtin_functions { + ($register:ident; $(fn $name:ident($($arg_name:ident: $arg_ty:ty),*) -> $ret_ty:ty;)*) => { + #[cfg(feature = "jit")] + #[allow(improper_ctypes)] + extern "C" { + $(fn $name($($arg_name: $arg_ty),*) -> $ret_ty;)* } - } + + #[cfg(feature = "jit")] + pub(crate) fn $register(builder: &mut cranelift_jit::JITBuilder) { + for (name, val) in [$((stringify!($name), $name as *const u8)),*] { + builder.symbol(name, val); + } + } + }; } builtin_functions! { diff --git a/src/intrinsics/mod.rs b/src/intrinsics/mod.rs index 6489b96be4b..8411ec0e035 100644 --- a/src/intrinsics/mod.rs +++ b/src/intrinsics/mod.rs @@ -1,46 +1,32 @@ //! Codegen of intrinsics. This includes `extern "rust-intrinsic"`, `extern "platform-intrinsic"` //! and LLVM intrinsics that have symbol names starting with `llvm.`. -mod cpuid; -mod llvm; -mod simd; - -pub(crate) use cpuid::codegen_cpuid_call; -pub(crate) use llvm::codegen_llvm_intrinsic_call; - -use rustc_middle::ty::print::with_no_trimmed_paths; -use rustc_middle::ty::subst::SubstsRef; -use rustc_span::symbol::{kw, sym, Symbol}; - -use crate::prelude::*; -use cranelift_codegen::ir::AtomicRmwOp; - -macro intrinsic_pat { +macro_rules! intrinsic_pat { (_) => { _ - }, + }; ($name:ident) => { sym::$name - }, + }; (kw.$name:ident) => { kw::$name - }, + }; ($name:literal) => { $name - }, + }; } -macro intrinsic_arg { - (o $fx:expr, $arg:ident) => {}, +macro_rules! intrinsic_arg { + (o $fx:expr, $arg:ident) => {}; (c $fx:expr, $arg:ident) => { let $arg = codegen_operand($fx, $arg); - }, + }; (v $fx:expr, $arg:ident) => { let $arg = codegen_operand($fx, $arg).load_scalar($fx); - } + }; } -macro intrinsic_match { +macro_rules! intrinsic_match { ($fx:expr, $intrinsic:expr, $args:expr, _ => $unknown:block; $( @@ -62,6 +48,20 @@ } } +mod cpuid; +mod llvm; +mod simd; + +pub(crate) use cpuid::codegen_cpuid_call; +pub(crate) use llvm::codegen_llvm_intrinsic_call; + +use rustc_middle::ty::print::with_no_trimmed_paths; +use rustc_middle::ty::subst::SubstsRef; +use rustc_span::symbol::{kw, sym, Symbol}; + +use crate::prelude::*; +use cranelift_codegen::ir::AtomicRmwOp; + fn report_atomic_type_validation_error<'tcx>( fx: &mut FunctionCx<'_, '_, 'tcx>, intrinsic: Symbol, diff --git a/src/lib.rs b/src/lib.rs index 5eab2b70f4e..8b517104df2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,4 @@ -#![feature(rustc_private, decl_macro)] +#![feature(rustc_private)] #![cfg_attr(feature = "jit", feature(never_type, vec_into_raw_parts, once_cell))] #![warn(rust_2018_idioms)] #![warn(unused_lifetimes)]