diff --git a/src/compiler/meson.build b/src/compiler/meson.build index e0ba2fe8207..9776320e940 100644 --- a/src/compiler/meson.build +++ b/src/compiler/meson.build @@ -70,3 +70,7 @@ if with_gallium subdir('glsl') endif subdir('isaspec') + +if with_nouveau_vk + subdir('rust') +endif diff --git a/src/compiler/rust/.rustfmt.toml b/src/compiler/rust/.rustfmt.toml new file mode 100644 index 00000000000..df99c69198f --- /dev/null +++ b/src/compiler/rust/.rustfmt.toml @@ -0,0 +1 @@ +max_width = 80 diff --git a/src/nouveau/compiler/nak/bitset.rs b/src/compiler/rust/bitset.rs similarity index 100% rename from src/nouveau/compiler/nak/bitset.rs rename to src/compiler/rust/bitset.rs diff --git a/src/compiler/rust/lib.rs b/src/compiler/rust/lib.rs new file mode 100644 index 00000000000..aad58286fc4 --- /dev/null +++ b/src/compiler/rust/lib.rs @@ -0,0 +1,4 @@ +// Copyright © 2024 Igalia S.L. +// SPDX-License-Identifier: MIT + +pub mod bitset; diff --git a/src/compiler/rust/meson.build b/src/compiler/rust/meson.build new file mode 100644 index 00000000000..5aae47685d7 --- /dev/null +++ b/src/compiler/rust/meson.build @@ -0,0 +1,23 @@ +# Copyright © 2024 Igalia S.L. +# SPDX-License-Identifier: MIT + +_compiler_rs_sources = [ + 'bitset.rs', +] + +_compiler_rs_sources = structured_sources([ + # lib.rs has to go first + 'lib.rs', + _compiler_rs_sources, +]) + +_libcompiler_rs = static_library( + 'compiler', + _compiler_rs_sources, + gnu_symbol_visibility : 'hidden', + rust_abi : 'rust', +) + +idep_compiler_rs = declare_dependency( + link_with : _libcompiler_rs, +) diff --git a/src/nouveau/compiler/meson.build b/src/nouveau/compiler/meson.build index 3dcd8bb591f..30f8e18d48a 100644 --- a/src/nouveau/compiler/meson.build +++ b/src/nouveau/compiler/meson.build @@ -143,6 +143,7 @@ _libnak_rs = static_library( ], dependencies : [ dep_paste, + idep_compiler_rs, idep_nvidia_headers_rs, ], link_with : [ diff --git a/src/nouveau/compiler/nak/assign_regs.rs b/src/nouveau/compiler/nak/assign_regs.rs index da9867c8420..eb1fad7f63e 100644 --- a/src/nouveau/compiler/nak/assign_regs.rs +++ b/src/nouveau/compiler/nak/assign_regs.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: MIT use crate::api::{GetDebugFlags, DEBUG}; -use crate::bitset::BitSet; use crate::ir::*; use crate::liveness::{BlockLiveness, Liveness, SimpleLiveness}; +use compiler::bitset::BitSet; use std::cmp::{max, Ordering}; use std::collections::{HashMap, HashSet}; diff --git a/src/nouveau/compiler/nak/cfg.rs b/src/nouveau/compiler/nak/cfg.rs index 8ca7323e319..a0e706d081f 100644 --- a/src/nouveau/compiler/nak/cfg.rs +++ b/src/nouveau/compiler/nak/cfg.rs @@ -1,8 +1,7 @@ // Copyright © 2023 Collabora, Ltd. // SPDX-License-Identifier: MIT -use crate::bitset::BitSet; - +use compiler::bitset::BitSet; use std::collections::HashMap; use std::hash::Hash; use std::ops::{Deref, DerefMut, Index, IndexMut}; diff --git a/src/nouveau/compiler/nak/lib.rs b/src/nouveau/compiler/nak/lib.rs index 3126aabaeb9..9748fbf551b 100644 --- a/src/nouveau/compiler/nak/lib.rs +++ b/src/nouveau/compiler/nak/lib.rs @@ -3,7 +3,6 @@ mod api; mod assign_regs; -mod bitset; mod builder; mod calc_instr_deps; mod cfg; diff --git a/src/nouveau/compiler/nak/liveness.rs b/src/nouveau/compiler/nak/liveness.rs index 18c59955be3..6dcc23dff9c 100644 --- a/src/nouveau/compiler/nak/liveness.rs +++ b/src/nouveau/compiler/nak/liveness.rs @@ -1,9 +1,9 @@ // Copyright © 2022 Collabora, Ltd. // SPDX-License-Identifier: MIT -use crate::bitset::BitSet; use crate::ir::*; +use compiler::bitset::BitSet; use std::cell::RefCell; use std::cmp::{max, Ord, Ordering}; use std::collections::{hash_set, HashMap, HashSet}; diff --git a/src/nouveau/compiler/nak/opt_bar_prop.rs b/src/nouveau/compiler/nak/opt_bar_prop.rs index 4ab319a375e..1c8100a5882 100644 --- a/src/nouveau/compiler/nak/opt_bar_prop.rs +++ b/src/nouveau/compiler/nak/opt_bar_prop.rs @@ -2,9 +2,9 @@ // SPDX-License-Identifier: MIT use crate::api::{GetDebugFlags, DEBUG}; -use crate::bitset::BitSet; use crate::ir::*; +use compiler::bitset::BitSet; use std::collections::HashMap; struct PhiMap { diff --git a/src/nouveau/compiler/nak/repair_ssa.rs b/src/nouveau/compiler/nak/repair_ssa.rs index b303a69eb07..c36930e1622 100644 --- a/src/nouveau/compiler/nak/repair_ssa.rs +++ b/src/nouveau/compiler/nak/repair_ssa.rs @@ -1,10 +1,10 @@ // Copyright © 2023 Collabora, Ltd. // SPDX-License-Identifier: MIT -use crate::bitset::BitSet; use crate::ir::*; use crate::union_find::UnionFind; +use compiler::bitset::BitSet; use std::cell::RefCell; use std::collections::HashMap; diff --git a/src/nouveau/compiler/nak/spill_values.rs b/src/nouveau/compiler/nak/spill_values.rs index 5de86c0d9da..7263dc3e08a 100644 --- a/src/nouveau/compiler/nak/spill_values.rs +++ b/src/nouveau/compiler/nak/spill_values.rs @@ -4,12 +4,12 @@ #![allow(unstable_name_collisions)] use crate::api::{GetDebugFlags, DEBUG}; -use crate::bitset::BitSet; use crate::ir::*; use crate::liveness::{ BlockLiveness, LiveSet, Liveness, NextUseBlockLiveness, NextUseLiveness, }; +use compiler::bitset::BitSet; use std::cell::RefCell; use std::cmp::{max, Ordering, Reverse}; use std::collections::{BinaryHeap, HashMap, HashSet};