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 pub inner_dmax: u32,
27}
28
29#[derive(Clone, Debug, PartialEq, Eq)]
31pub struct ArithStep {
32 pub target: PlaceId,
33 pub expr: ExprId,
34 pub mode: Mode,
35 pub store: StorePlan,
36 pub rounded: bool,
37 pub probe: Vec<PlaceId>,
38}
39
40#[derive(Clone, Copy, Debug, PartialEq, Eq)]
41pub enum Mode {
42 Fixed,
43 Float(Precision),
44}
45
46#[derive(Clone, Copy, Debug, PartialEq, Eq)]
47pub enum StorePlan {
48 Zoned { digits: u32, scale: u32, signed: bool, sign: Option<SignClause> },
49 Packed { digits: u32, scale: u32, signed: bool },
50 Binary { digits: u32, scale: u32, signed: bool, native: bool, name: SymId },
52 NumericEdited { edit: u32, digits: u32, scale: u32, blank_when_zero: bool },
53 Float(Precision),
54 Index,
55 Refused(AbendId),
56}
57
58#[derive(Clone, Copy, Debug, PartialEq, Eq)]
59pub struct RemainderPlan {
60 pub target: PlaceId,
61 pub dividend: ExprId,
62 pub divisor: ExprId,
63 pub quotient_scale: u32,
64 pub store: StorePlan,
65}
66
67#[derive(Clone, Copy, Debug, PartialEq, Eq)]
69pub struct StepPlan {
70 pub dmax: u32,
71 pub store: StorePlan,
72}
73
74#[derive(Clone, Copy, Debug, PartialEq, Eq)]
78pub enum UpDown {
79 Pointer,
80 Number(StepPlan),
81 Refused(AbendId),
82}
83
84codec_struct!(ArithPlan { dmax, arith, prepass, steps, remainder, handled, per_receiver, inner_dmax });
85codec_struct!(ArithStep { target, expr, mode, store, rounded, probe });
86codec_enum!(Mode { Fixed = 0, Float(precision) = 1 });
87codec_enum!(StorePlan {
88 Zoned { digits, scale, signed, sign } = 0,
89 Packed { digits, scale, signed } = 1,
90 Binary { digits, scale, signed, native, name } = 2,
91 NumericEdited { edit, digits, scale, blank_when_zero } = 3,
92 Float(precision) = 4,
93 Index = 5,
94 Refused(abend) = 6,
95});
96codec_struct!(RemainderPlan { target, dividend, divisor, quotient_scale, store });
97codec_struct!(StepPlan { dmax, store });
98codec_enum!(UpDown { Pointer = 0, Number(plan) = 1, Refused(abend) = 2 });