Debian Codegraph @

gcc/testsuite/gnat.dg/opt107_pkg.ads

raw
1 with System;
2 with Unchecked_Conversion;
3
4 package Opt107_Pkg is
5
6 Word_Size : constant := 32;
7 type Word_Type is mod 2 ** Word_Size;
8 for Word_Type'Size use Word_Size;
9
10 Word : constant := Word_Size / System.Storage_Unit;
11
12 Halfword_Size : constant := Word_Size / 2;
13
14 type Halfword_Type is range 0 .. 2 ** Halfword_Size - 1;
15 for Halfword_Type'Size use Halfword_Size;
16
17 type One_Bit_Type is mod 2 ** 1;
18 for One_Bit_Type'Size use 1;
19
20 type Four_Bit_Type is mod 2 ** 4;
21 for Four_Bit_Type'Size use 4;
22
23 type Seven_Bit_Type is mod 2 ** 7;
24 for Seven_Bit_Type'Size use 7;
25
26 type Eight_Bit_Type is mod 2 ** 8;
27 for Eight_Bit_Type'Size use 8;
28
29 type Twelve_Bit_Type is mod 2 ** 12;
30 for Twelve_Bit_Type'Size use 12;
31
32 type Thirty_One_Bit_Type is mod 2 ** 31;
33 for Thirty_One_Bit_Type'Size use 31;
34
35 type W0_Type is record
36 A : Eight_Bit_Type;
37 B : Eight_Bit_Type;
38 C : Halfword_Type;
39 end record;
40
41 for W0_Type use record
42 A at Word * 0 range 24 .. 31;
43 B at Word * 0 range 16 .. 23;
44 C at Word * 0 range 0 .. 15;
45 end record;
46 for W0_Type'Size use Word_Size;
47
48 type A_Type is (A0, A1);
49 for A_Type use (A0 => 0, A1 => 1);
50 for A_Type'Size use 1;
51
52 type B_Type is (B_A_1,
53 B_A_2,
54 B_A_3,
55 B_A_4,
56 B_A_5,
57 B_A_6,
58 B_A_7,
59 B_A_8,
60 B_B_1,
61 B_B_2,
62 B_B_3,
63 B_B_4,
64 B_B_5,
65 B_B_6,
66 B_B_7,
67 B_B_8);
68
69 for B_Type use (B_A_1 => 8#00#,
70 B_A_2 => 8#01#,
71 B_A_3 => 8#02#,
72 B_A_4 => 8#03#,
73 B_A_5 => 8#04#,
74 B_A_6 => 8#05#,
75 B_A_7 => 8#06#,
76 B_A_8 => 8#07#,
77 B_B_1 => 8#10#,
78 B_B_2 => 8#11#,
79 B_B_3 => 8#12#,
80 B_B_4 => 8#13#,
81 B_B_5 => 8#14#,
82 B_B_6 => 8#15#,
83 B_B_7 => 8#16#,
84 B_B_8 => 8#17#);
85 for B_Type'Size use 8;
86
87 type C_Type is (C_A, C_B);
88 for C_Type use (C_A => 0, C_B => 2);
89 for C_Type'Size use 4;
90
91 type D_Type is record
92 Spare : Twelve_Bit_Type;
93 D_A : One_Bit_Type;
94 D_B : One_Bit_Type;
95 D_C : One_Bit_Type;
96 D_D : One_Bit_Type;
97 end record;
98
99 for D_Type use record
100 Spare at 0 range 4 .. 15;
101 D_A at 0 range 3 .. 3;
102 D_B at 0 range 2 .. 2;
103 D_C at 0 range 1 .. 1;
104 D_D at 0 range 0 .. 0;
105 end record;
106 for D_Type'Size use Halfword_Size;
107
108 type E_Type is record
109 Spare : Seven_Bit_Type;
110 E_A : One_Bit_Type;
111 E_B : One_Bit_Type;
112 E_C : One_Bit_Type;
113 E_D : One_Bit_Type;
114 E_E : One_Bit_Type;
115 E_F : One_Bit_Type;
116 E_G : One_Bit_Type;
117 E_H : One_Bit_Type;
118 end record;
119
120 for E_Type use record
121 Spare at 0 range 8 .. 14;
122 E_A at 0 range 7 .. 7;
123 E_B at 0 range 6 .. 6;
124 E_C at 0 range 5 .. 5;
125 E_D at 0 range 4 .. 4;
126 E_E at 0 range 3 .. 3;
127 E_F at 0 range 2 .. 2;
128 E_G at 0 range 1 .. 1;
129 E_H at 0 range 0 .. 0;
130 end record;
131 for E_Type'Size use 15;
132
133 type Rec is record
134 W0 : W0_Type;
135 W1A : B_Type;
136 W1B : Four_Bit_Type;
137 W1C : C_Type;
138 W1D : D_Type;
139 W2A : A_Type;
140 W2B : E_Type;
141 W2C : Halfword_Type;
142 end record;
143
144 for Rec use record
145 W0 at Word * 0 range 0 .. 31;
146 W1A at Word * 1 range 24 .. 31;
147 W1B at Word * 1 range 20 .. 23;
148 W1C at Word * 1 range 16 .. 19;
149 W1D at Word * 1 range 0 .. 15;
150 W2A at Word * 2 range 31 .. 31;
151 W2B at Word * 2 range 16 .. 30;
152 W2C at Word * 2 range 0 .. 15;
153 end record;
154 for Rec'Size use 6 * Halfword_Size;
155
156 end Opt107_Pkg;