Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions examples/spv-lower-link-qptr-lift.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ fn main() -> std::io::Result<()> {
after_pass("", &module)?;

// HACK(eddyb) this is roughly what Rust-GPU would need.
let layout_config = &spirt::qptr::LayoutConfig {
let layout_config = &spirt::mem::LayoutConfig {
abstract_bool_size_align: (1, 1),
logical_ptr_size_align: (4, 4),
..spirt::qptr::LayoutConfig::VULKAN_SCALAR_LAYOUT
..spirt::mem::LayoutConfig::VULKAN_SCALAR_LAYOUT
};

eprint_duration(|| {
Expand All @@ -92,9 +92,11 @@ fn main() -> std::io::Result<()> {
eprintln!("qptr::lower_from_spv_ptrs");
after_pass("qptr::lower_from_spv_ptrs", &module)?;

eprint_duration(|| spirt::passes::qptr::analyze_uses(&mut module, layout_config));
eprintln!("qptr::analyze_uses");
after_pass("qptr::analyze_uses", &module)?;
eprint_duration(|| {
spirt::passes::qptr::analyze_mem_accesses(&mut module, layout_config)
});
eprintln!("mem::analyze_accesses");
after_pass("mem::analyze_accesses", &module)?;

eprint_duration(|| spirt::passes::qptr::lift_to_spv_ptrs(&mut module, layout_config));
eprintln!("qptr::lift_to_spv_ptrs");
Expand Down
9 changes: 2 additions & 7 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,19 +348,14 @@ pub struct EntityOrientedDenseMap<K: EntityOrientedMapKey<V>, V> {
// since the ideal state is one chunk per map, the slow case might never be hit,
// unless one `EntityOrientedDenseMap` is used with more than one `EntityDefs`,
// which could still maybe be implemented more efficiently than `FxHashMap`.
#[derive(Clone)]
#[derive(Clone, Default)]
enum SmallFxHashMap<K, V> {
#[default]
Empty,
One(K, V),
More(FxHashMap<K, V>),
}

impl<K, V> Default for SmallFxHashMap<K, V> {
fn default() -> Self {
Self::Empty
}
}

impl<K: Copy + Eq + Hash, V: Default> SmallFxHashMap<K, V> {
fn get_mut_or_insert_default(&mut self, k: K) -> &mut V {
// HACK(eddyb) to avoid borrowing issues, this is done in two stages:
Expand Down
16 changes: 12 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
clippy::dbg_macro,
clippy::debug_assert_with_mut_call,
clippy::doc_markdown,
clippy::empty_enum,
clippy::empty_enums,
clippy::enum_glob_use,
clippy::exit,
clippy::expl_impl_clone_on_copy,
Expand Down Expand Up @@ -121,7 +121,6 @@
clippy::string_add_assign,
clippy::string_add,
clippy::string_lit_as_bytes,
clippy::string_to_string,
clippy::todo,
clippy::trait_duplication_in_bounds,
clippy::unimplemented,
Expand Down Expand Up @@ -169,6 +168,7 @@ pub mod passes {
pub mod link;
pub mod qptr;
}
pub mod mem;
pub mod qptr;
pub mod spv;

Expand Down Expand Up @@ -397,6 +397,10 @@ pub enum Attr {
// of `AttrSetDef::{dbg_src_loc,set_dbg_src_loc}`.
DbgSrcLoc(OrdAssertEq<DbgSrcLoc>),

/// Memory-specific attributes (see [`mem::MemAttr`]).
#[from]
Mem(mem::MemAttr),

/// `QPtr`-specific attributes (see [`qptr::QPtrAttr`]).
#[from]
QPtr(qptr::QPtrAttr),
Expand Down Expand Up @@ -489,7 +493,7 @@ pub enum DiagMsgPart {
Attrs(AttrSet),
Type(Type),
Const(Const),
QPtrUsage(qptr::QPtrUsage),
MemAccesses(mem::MemAccesses),
}

/// Wrapper to limit `Ord` for interned index types (e.g. [`InternedStr`])
Expand Down Expand Up @@ -638,7 +642,7 @@ pub struct GlobalVarDecl {

/// When `type_of_ptr_to` is `QPtr`, `shape` must be used to describe the
/// global variable (see `GlobalVarShape`'s documentation for more details).
pub shape: Option<qptr::shapes::GlobalVarShape>,
pub shape: Option<mem::shapes::GlobalVarShape>,

/// The address space the global variable will be allocated into.
pub addr_space: AddrSpace,
Expand Down Expand Up @@ -947,6 +951,10 @@ pub enum DataInstKind {
// to avoid needing special handling for recursion where it's impossible.
FuncCall(Func),

/// Memory-specific operations (see [`mem::MemOp`]).
#[from]
Mem(mem::MemOp),

/// `QPtr`-specific operations (see [`qptr::QPtrOp`]).
#[from]
QPtr(qptr::QPtrOp),
Expand Down
Loading
Loading