Port #[rustc_offload_kernel] to attr parser
This commit is contained in:
parent
03b8b68073
commit
3e731f7e84
6 changed files with 19 additions and 4 deletions
|
|
@ -335,3 +335,12 @@ impl<S: Stage> NoArgsAttributeParser<S> for RustcNounwindParser {
|
|||
]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcNounwind;
|
||||
}
|
||||
|
||||
pub(crate) struct RustcOffloadKernelParser;
|
||||
|
||||
impl<S: Stage> NoArgsAttributeParser<S> for RustcOffloadKernelParser {
|
||||
const PATH: &[Symbol] = &[sym::rustc_offload_kernel];
|
||||
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
|
||||
const ALLOWED_TARGETS: AllowedTargets = AllowedTargets::AllowList(&[Allow(Target::Fn)]);
|
||||
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::RustcOffloadKernel;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ use crate::attributes::rustc_internal::{
|
|||
RustcLintQueryInstabilityParser, RustcLintUntrackedQueryInformationParser, RustcMainParser,
|
||||
RustcMustImplementOneOfParser, RustcNeverReturnsNullPointerParser,
|
||||
RustcNoImplicitAutorefsParser, RustcNounwindParser, RustcObjectLifetimeDefaultParser,
|
||||
RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser,
|
||||
RustcOffloadKernelParser, RustcScalableVectorParser, RustcSimdMonomorphizeLaneLimitParser,
|
||||
};
|
||||
use crate::attributes::semantics::MayDangleParser;
|
||||
use crate::attributes::stability::{
|
||||
|
|
@ -297,6 +297,7 @@ attribute_parsers!(
|
|||
Single<WithoutArgs<RustcNeverReturnsNullPointerParser>>,
|
||||
Single<WithoutArgs<RustcNoImplicitAutorefsParser>>,
|
||||
Single<WithoutArgs<RustcNounwindParser>>,
|
||||
Single<WithoutArgs<RustcOffloadKernelParser>>,
|
||||
Single<WithoutArgs<RustcPassIndirectlyInNonRusticAbisParser>>,
|
||||
Single<WithoutArgs<RustcReallocatorParser>>,
|
||||
Single<WithoutArgs<RustcShouldNotBeCalledOnConstItems>>,
|
||||
|
|
|
|||
|
|
@ -350,6 +350,9 @@ fn process_builtin_attrs(
|
|||
AttributeKind::RustcNounwind => {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NEVER_UNWIND
|
||||
}
|
||||
AttributeKind::RustcOffloadKernel => {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::OFFLOAD_KERNEL
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -363,9 +366,6 @@ fn process_builtin_attrs(
|
|||
codegen_fn_attrs.patchable_function_entry =
|
||||
parse_patchable_function_entry(tcx, attr);
|
||||
}
|
||||
sym::rustc_offload_kernel => {
|
||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::OFFLOAD_KERNEL
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -987,6 +987,9 @@ pub enum AttributeKind {
|
|||
/// Represents `#[rustc_object_lifetime_default]`.
|
||||
RustcObjectLifetimeDefault,
|
||||
|
||||
/// Represents `#[rustc_offload_kernel]`
|
||||
RustcOffloadKernel,
|
||||
|
||||
/// Represents `#[rustc_pass_indirectly_in_non_rustic_abis]`
|
||||
RustcPassIndirectlyInNonRusticAbis(Span),
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ impl AttributeKind {
|
|||
RustcNoImplicitAutorefs => Yes,
|
||||
RustcNounwind => No,
|
||||
RustcObjectLifetimeDefault => No,
|
||||
RustcOffloadKernel => Yes,
|
||||
RustcPassIndirectlyInNonRusticAbis(..) => No,
|
||||
RustcReallocator => No,
|
||||
RustcScalableVector { .. } => Yes,
|
||||
|
|
|
|||
|
|
@ -323,6 +323,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
|||
| AttributeKind::RustcDeallocator
|
||||
| AttributeKind::RustcReallocator
|
||||
| AttributeKind::RustcNounwind
|
||||
| AttributeKind::RustcOffloadKernel
|
||||
) => { /* do nothing */ }
|
||||
Attribute::Unparsed(attr_item) => {
|
||||
style = Some(attr_item.style);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue