Remove decl_macro usage

This reduces the amount of unstable features used by cg_clif
This commit is contained in:
bjorn3 2022-03-13 15:19:48 +01:00
parent e937265673
commit cfc1a2cd68
3 changed files with 39 additions and 37 deletions

View File

@ -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! {

View File

@ -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,

View File

@ -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)]