1use super::{AbendId, ExprId, PlaceId, SymId};
4use crate::vocab::SignClause;
5use crate::{codec_enum, codec_struct};
6use numeric::Arith;
7use zarch::hfp::Precision;
8
9#[derive(Clone, Debug, PartialEq, Eq)]
10pub struct ArithPlan {
11 pub dmax: u32,
12 pub arith: Arith,
13 pub prepass: Vec<PlaceId>,
15 pub steps: Vec<ArithStep>,
16 pub remainder: Option<RemainderPlan>,
17 pub handled: bool,
19 pub per_receiver: bool,
23}
24
25#[derive(Clone, Debug, PartialEq, Eq)]
27pub struct ArithStep {
28 pub target: PlaceId,
29 pub expr: ExprId,
30 pub mode: Mode,
31 pub store: StorePlan,
32 pub rounded: bool,
33 pub probe: Vec<PlaceId>,
34}
35
36#[derive(Clone, Copy, Debug, PartialEq, Eq)]
37pub enum Mode {
38 Fixed,
39 Float(Precision),
40}
41
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43pub enum StorePlan {
44 Zoned { digits: u32, scale: u32, signed: bool, sign: Option<SignClause> },
45 Packed { digits: u32, scale: u32, signed: bool },
46 Binary { digits: u32, scale: u32, signed: bool, native: bool, name: SymId },
48 NumericEdited { edit: u32, digits: u32, scale: u32, blank_when_zero: bool },
49 Float(Precision),
50 Index,
51 Refused(AbendId),
52}
53
54#[derive(Clone, Copy, Debug, PartialEq, Eq)]
55pub struct RemainderPlan {
56 pub target: PlaceId,
57 pub dividend: ExprId,
58 pub divisor: ExprId,
59 pub quotient_scale: u32,
60 pub store: StorePlan,
61}
62
63#[derive(Clone, Copy, Debug, PartialEq, Eq)]
65pub struct StepPlan {
66 pub dmax: u32,
67 pub store: StorePlan,
68}
69
70#[derive(Clone, Copy, Debug, PartialEq, Eq)]
74pub enum UpDown {
75 Pointer,
76 Number(StepPlan),
77 Refused(AbendId),
78}
79
80codec_struct!(ArithPlan { dmax, arith, prepass, steps, remainder, handled, per_receiver });
81codec_struct!(ArithStep { target, expr, mode, store, rounded, probe });
82codec_enum!(Mode { Fixed = 0, Float(precision) = 1 });
83codec_enum!(StorePlan {
84 Zoned { digits, scale, signed, sign } = 0,
85 Packed { digits, scale, signed } = 1,
86 Binary { digits, scale, signed, native, name } = 2,
87 NumericEdited { edit, digits, scale, blank_when_zero } = 3,
88 Float(precision) = 4,
89 Index = 5,
90 Refused(abend) = 6,
91});
92codec_struct!(RemainderPlan { target, dividend, divisor, quotient_scale, store });
93codec_struct!(StepPlan { dmax, store });
94codec_enum!(UpDown { Pointer = 0, Number(plan) = 1, Refused(abend) = 2 });