1 //! Tables.
2 
3 use crate::ir::immediates::Uimm64;
4 use crate::ir::{GlobalValue, Type};
5 use core::fmt;
6 
7 /// Information about a table declaration.
8 #[derive(Clone)]
9 pub struct TableData {
10     /// Global value giving the address of the start of the table.
11     pub base_gv: GlobalValue,
12 
13     /// Guaranteed minimum table size in elements. Table accesses before `min_size` don't need
14     /// bounds checking.
15     pub min_size: Uimm64,
16 
17     /// Global value giving the current bound of the table, in elements.
18     pub bound_gv: GlobalValue,
19 
20     /// The size of a table element, in bytes.
21     pub element_size: Uimm64,
22 
23     /// The index type for the table.
24     pub index_type: Type,
25 }
26 
27 impl fmt::Display for TableData {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result28     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
29         f.write_str("dynamic")?;
30         write!(
31             f,
32             " {}, min {}, bound {}, element_size {}, index_type {}",
33             self.base_gv, self.min_size, self.bound_gv, self.element_size, self.index_type
34         )
35     }
36 }
37