luaur_code_gen/records/
lowering_stats.rs1use crate::records::block_linearization_stats::BlockLinearizationStats;
2use crate::records::function_stats::FunctionStats;
3use alloc::vec::Vec;
4use core::ops::Add;
5
6#[derive(Debug, Clone)]
7pub struct LoweringStats {
8 pub total_functions: u32,
9 pub skipped_functions: u32,
10 pub spills_to_slot: i32,
11 pub spills_to_restore: i32,
12 pub max_spill_slots_used: u32,
13 pub blocks_pre_opt: u32,
14 pub blocks_post_opt: u32,
15 pub max_block_instructions: u32,
16 pub reg_alloc_errors: i32,
17 pub lowering_errors: i32,
18 pub block_linearization_stats: BlockLinearizationStats,
19 pub function_stats_flags: u32,
20 pub functions: Vec<FunctionStats>,
21}
22
23impl LoweringStats {
24 #[inline]
25 pub fn lowering_stats_operator_add(&self, other: &LoweringStats) -> LoweringStats {
26 let mut result: LoweringStats = self.clone();
27 result.lowering_stats_operator_add_assign(other);
28 result
29 }
30}
31
32impl Add for LoweringStats {
33 type Output = Self;
34
35 #[inline]
36 fn add(self, rhs: Self) -> Self::Output {
37 self.lowering_stats_operator_add(&rhs)
38 }
39}
40
41impl Add<&LoweringStats> for LoweringStats {
42 type Output = Self;
43
44 #[inline]
45 fn add(self, rhs: &LoweringStats) -> Self::Output {
46 self.lowering_stats_operator_add(rhs)
47 }
48}
49
50impl Add<&LoweringStats> for &LoweringStats {
51 type Output = LoweringStats;
52
53 #[inline]
54 fn add(self, rhs: &LoweringStats) -> Self::Output {
55 self.lowering_stats_operator_add(rhs)
56 }
57}
58
59impl Default for LoweringStats {
60 fn default() -> Self {
61 Self {
62 total_functions: 0,
63 skipped_functions: 0,
64 spills_to_slot: 0,
65 spills_to_restore: 0,
66 max_spill_slots_used: 0,
67 blocks_pre_opt: 0,
68 blocks_post_opt: 0,
69 max_block_instructions: 0,
70 reg_alloc_errors: 0,
71 lowering_errors: 0,
72 block_linearization_stats: BlockLinearizationStats {
73 const_prop_instruction_count: 0,
74 time_seconds: 0.0,
75 },
76 function_stats_flags: 0,
77 functions: Vec::new(),
78 }
79 }
80}
81
82pub const FunctionStats_Enable: u32 = 1 << 0;