mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-06-09 23:08:18 +02:00
kraid: Move proc/lib.rs to proc/macros.rs
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/41841>
This commit is contained in:
parent
7a1ee1b66f
commit
237b648d88
7 changed files with 80 additions and 57 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright © 2026 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use kraid_proc_macros::DataType;
|
||||
use std::num::NonZeroU8;
|
||||
|
||||
/// Numeric type
|
||||
|
|
@ -36,7 +37,7 @@ pub enum NumericType {
|
|||
}
|
||||
|
||||
/// Data type
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, kraid_proc::DataType)]
|
||||
#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq, DataType)]
|
||||
pub enum DataType {
|
||||
None,
|
||||
F16,
|
||||
|
|
|
|||
|
|
@ -61,10 +61,27 @@ _libkraid_bindings_rs = static_library(
|
|||
rust_abi : 'rust',
|
||||
)
|
||||
|
||||
_libkraid_proc_rs = rust.proc_macro(
|
||||
_libkraid_proc_rs = static_library(
|
||||
'kraid_proc',
|
||||
files('proc/lib.rs'),
|
||||
dependencies : [idep_compiler_proc_rs],
|
||||
gnu_symbol_visibility : 'hidden',
|
||||
dependencies : [
|
||||
dep_syn,
|
||||
dep_paste,
|
||||
],
|
||||
rust_args : rust_global_args,
|
||||
rust_abi : 'rust',
|
||||
)
|
||||
|
||||
_libkraid_proc_macros_rs = rust.proc_macro(
|
||||
'kraid_proc_macros',
|
||||
files('proc/macros.rs'),
|
||||
dependencies : [
|
||||
idep_compiler_proc_rs,
|
||||
],
|
||||
link_with : [
|
||||
_libkraid_proc_rs
|
||||
],
|
||||
rust_args : rust_global_args,
|
||||
)
|
||||
|
||||
|
|
@ -87,7 +104,7 @@ libpanfrost_kraid = static_library(
|
|||
],
|
||||
link_with : [
|
||||
_libkraid_bindings_rs,
|
||||
_libkraid_proc_rs,
|
||||
_libkraid_proc_macros_rs,
|
||||
],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
// SPDX-License-Identifier: MIT
|
||||
|
||||
use crate::ir::*;
|
||||
use kraid_proc::{variants, FromVariants, Opcode};
|
||||
use kraid_proc_macros::{variants, FromVariants, Opcode};
|
||||
use std::fmt;
|
||||
|
||||
macro_rules! bool_as_mod_str {
|
||||
|
|
|
|||
|
|
@ -7,53 +7,6 @@ extern crate proc_macro2;
|
|||
extern crate quote;
|
||||
extern crate syn;
|
||||
|
||||
use compiler_proc::as_slice::*;
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
mod data_type;
|
||||
mod ir;
|
||||
mod swizzle;
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn variants(attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
ir::variants(attr, item)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(Opcode, attributes(src_type, dst_type))]
|
||||
pub fn derive_opcode(input: TokenStream) -> TokenStream {
|
||||
let mut s = TokenStream::new();
|
||||
s.extend(derive_as_slice(
|
||||
input.clone(),
|
||||
"Src",
|
||||
"src_type",
|
||||
"DataType",
|
||||
));
|
||||
s.extend(derive_as_slice(
|
||||
input.clone(),
|
||||
"Dst",
|
||||
"dst_type",
|
||||
"DataType",
|
||||
));
|
||||
s.extend(ir::derive_opcode(input));
|
||||
s
|
||||
}
|
||||
|
||||
#[proc_macro_derive(DataType)]
|
||||
pub fn derive_data_type(input: TokenStream) -> TokenStream {
|
||||
data_type::derive_data_type(input)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(AsmSwizzleWiden)]
|
||||
pub fn derive_asm_swizzle_widen(input: TokenStream) -> TokenStream {
|
||||
swizzle::derive_asm_swizzle_widen(input)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(EnumAsU8)]
|
||||
pub fn derive_enum_as_u8(input: TokenStream) -> TokenStream {
|
||||
compiler_proc::enum_as_u8::derive_enum_as_u8(input)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(FromVariants)]
|
||||
pub fn derive_from_variants(input: TokenStream) -> TokenStream {
|
||||
compiler_proc::from_variants::derive_from_variants(input)
|
||||
}
|
||||
pub mod data_type;
|
||||
pub mod ir;
|
||||
pub mod swizzle;
|
||||
|
|
|
|||
52
src/panfrost/compiler/kraid/proc/macros.rs
Normal file
52
src/panfrost/compiler/kraid/proc/macros.rs
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
// Copyright © 2026 Collabora, Ltd.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
extern crate kraid_proc;
|
||||
|
||||
use compiler_proc::as_slice::*;
|
||||
use kraid_proc::*;
|
||||
use proc_macro::TokenStream;
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn variants(attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
ir::variants(attr, item)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(Opcode, attributes(src_type, dst_type))]
|
||||
pub fn derive_opcode(input: TokenStream) -> TokenStream {
|
||||
let mut s = TokenStream::new();
|
||||
s.extend(derive_as_slice(
|
||||
input.clone(),
|
||||
"Src",
|
||||
"src_type",
|
||||
"DataType",
|
||||
));
|
||||
s.extend(derive_as_slice(
|
||||
input.clone(),
|
||||
"Dst",
|
||||
"dst_type",
|
||||
"DataType",
|
||||
));
|
||||
s.extend(ir::derive_opcode(input));
|
||||
s
|
||||
}
|
||||
|
||||
#[proc_macro_derive(DataType)]
|
||||
pub fn derive_data_type(input: TokenStream) -> TokenStream {
|
||||
data_type::derive_data_type(input)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(AsmSwizzleWiden)]
|
||||
pub fn derive_asm_swizzle_widen(input: TokenStream) -> TokenStream {
|
||||
swizzle::derive_asm_swizzle_widen(input)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(EnumAsU8)]
|
||||
pub fn derive_enum_as_u8(input: TokenStream) -> TokenStream {
|
||||
compiler_proc::enum_as_u8::derive_enum_as_u8(input)
|
||||
}
|
||||
|
||||
#[proc_macro_derive(FromVariants)]
|
||||
pub fn derive_from_variants(input: TokenStream) -> TokenStream {
|
||||
compiler_proc::from_variants::derive_from_variants(input)
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
use crate::data_type::DataType;
|
||||
use compiler::enum_as_u8::EnumAsU8;
|
||||
use compiler::float16::F16;
|
||||
use kraid_proc::{AsmSwizzleWiden, EnumAsU8};
|
||||
use kraid_proc_macros::{AsmSwizzleWiden, EnumAsU8};
|
||||
use std::fmt;
|
||||
use std::num::NonZeroU16;
|
||||
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ libvulkan_panfrost = shared_library(
|
|||
)
|
||||
|
||||
# TODO: Re-enable the symbol check with Kraid
|
||||
if with_symbols_check and not with_panfrost_rust
|
||||
if with_symbols_check
|
||||
test(
|
||||
'panvk symbols check',
|
||||
symbols_check,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue