1818public class RegisterFormat {
1919
2020 public static final RegisterFormat NONE ;
21- public static final RegisterFormat READ ;
22- public static final RegisterFormat WRITE ;
23- public static final RegisterFormat READ_READ ;
24- public static final RegisterFormat READ_WRITE ;
25- public static final RegisterFormat READ_READ_READ ;
26- public static final RegisterFormat WRITE_READ ;
27- public static final RegisterFormat WRITE_READ_READ ;
21+
22+ public static final RegisterFormat READ8 ;
23+ public static final RegisterFormat READ8W ;
24+ public static final RegisterFormat READ16 ;
25+ public static final RegisterFormat WRITE4 ;
26+ public static final RegisterFormat WRITE8 ;
27+ public static final RegisterFormat WRITE8W ;
28+
29+ public static final RegisterFormat READ4_READ4 ;
30+ public static final RegisterFormat READ4W_READ4 ;
31+
32+ public static final RegisterFormat READ8_READ8_READ8 ;
33+ public static final RegisterFormat READ8W_READ8_READ8 ;
34+
35+ public static final RegisterFormat RW4_READ4 ;
36+ public static final RegisterFormat RW4W_READ4 ;
37+ public static final RegisterFormat RW4W_READ4W ;
38+
39+ public static final RegisterFormat WRITE4_READ4 ;
40+ public static final RegisterFormat WRITE4_READ4W ;
41+ public static final RegisterFormat WRITE4W_READ4 ;
42+ public static final RegisterFormat WRITE4W_READ4W ;
43+
44+ public static final RegisterFormat WRITE8_READ8 ;
45+ public static final RegisterFormat WRITE8_READ16 ;
46+ public static final RegisterFormat WRITE8W_READ16W ;
47+ public static final RegisterFormat WRITE16_READ16 ;
48+ public static final RegisterFormat WRITE16W_READ16W ;
49+
50+ public static final RegisterFormat WRITE8_READ8_READ8 ;
51+ public static final RegisterFormat WRITE8_READ8W_READ8W ;
52+ public static final RegisterFormat WRITE8W_READ8_READ8 ;
53+ public static final RegisterFormat WRITE8W_READ8W_READ8 ;
54+ public static final RegisterFormat WRITE8W_READ8W_READ8W ;
55+
2856 public static final RegisterFormat OUT ;
2957 public static final RegisterFormat OUT_RANGE ;
3058
3159 static {
3260
33- NONE = new RegisterFormat ("NONE" , new RegisterType [0 ]);
34- READ = new RegisterFormat ("READ" , new RegisterType []{RegisterType .READ });
35- WRITE = new RegisterFormat ("WRITE" , new RegisterType []{RegisterType .WRITE });
36- READ_READ = new RegisterFormat ("READ_READ" , new RegisterType []{RegisterType .READ , RegisterType .READ });
37- READ_WRITE = new RegisterFormat ("READ_WRITE" , new RegisterType []{RegisterType .READ , RegisterType .WRITE });
38- READ_READ_READ = new RegisterFormat ("READ_READ_READ" , new RegisterType []{RegisterType .READ , RegisterType .READ , RegisterType .READ });
39- WRITE_READ = new RegisterFormat ("WRITE_READ" , new RegisterType []{RegisterType .WRITE , RegisterType .READ });
40- WRITE_READ_READ = new RegisterFormat ("WRITE_READ_READ" , new RegisterType []{RegisterType .WRITE , RegisterType .READ , RegisterType .READ });
61+ RegisterType [] read = new RegisterType []{RegisterType .READ };
62+ RegisterType [] readRead = new RegisterType []{RegisterType .READ , RegisterType .READ };
63+ RegisterType [] readReadRead = new RegisterType []{RegisterType .READ , RegisterType .READ , RegisterType .READ };
64+
65+ RegisterType [] rwRead = new RegisterType []{RegisterType .RW , RegisterType .READ };
66+
67+ RegisterType [] write = new RegisterType []{ RegisterType .WRITE };
68+ RegisterType [] writeRead = new RegisterType []{RegisterType .WRITE , RegisterType .READ };
69+ RegisterType [] writeReadRead = new RegisterType []{RegisterType .WRITE , RegisterType .READ , RegisterType .READ };
70+
71+ int [] limits_f = new int []{0x0f };
72+ int [] limits_ff = new int []{0xff };
73+ int [] limits_f_f = new int []{0x0f , 0x0f };
74+ int [] limits_ff_ff = new int []{0xff , 0xff };
75+ int [] limits_ff_ffff = new int []{0xff , 0xffff };
76+ int [] limits_ffff_ffff = new int []{0xffff , 0xffff };
77+ int [] limits_ff_ff_ff = new int []{0xff , 0xff , 0xff };
78+
79+ boolean [] wide_t = new boolean [] {true };
80+ boolean [] wide_t_f = new boolean [] {true , false };
81+ boolean [] wide_f_t = new boolean [] {false , true };
82+ boolean [] wide_t_t = new boolean [] {true , true };
83+ boolean [] wide_f_t_t = new boolean [] {false , true , true };
84+ boolean [] wide_t_f_f = new boolean [] {true , false , false };
85+ boolean [] wide_t_t_f = new boolean [] {true , true , false };
86+ boolean [] wide_t_t_t = new boolean [] {true , true , true };
87+
88+ NONE = new RegisterFormat ("NONE" , null , null );
89+ READ8 = new RegisterFormat ("READ8" , read , limits_ff );
90+ READ8W = new RegisterFormat ("READ8W" , read , limits_ff , wide_t );
91+ READ16 = new RegisterFormat ("READ16" , read , new int []{0xffff });
92+ WRITE4 = new RegisterFormat ("WRITE4" , write , limits_f );
93+ WRITE8 = new RegisterFormat ("WRITE8" , write , limits_ff );
94+ WRITE8W = new RegisterFormat ("WRITE8W" , write , limits_ff , wide_t );
95+
96+ READ4_READ4 = new RegisterFormat ("READ4_READ4" , readRead , limits_f_f );
97+ READ4W_READ4 = new RegisterFormat ("READ4W_READ4" , readRead , limits_f_f , wide_t_f );
98+ READ8_READ8_READ8 = new RegisterFormat ("READ8_READ8_READ8" , readReadRead , limits_ff_ff_ff );
99+ READ8W_READ8_READ8 = new RegisterFormat ("READ8W_READ8_READ8" ,
100+ readReadRead , limits_ff_ff_ff , wide_t_f_f );
101+
102+ RW4_READ4 = new RegisterFormat ("RW4_READ4" , rwRead , limits_f_f );
103+ RW4W_READ4 = new RegisterFormat ("RW4W_READ4" , rwRead , limits_f_f , wide_t_f );
104+ RW4W_READ4W = new RegisterFormat ("RW4W_READ4W" , rwRead , limits_f_f , wide_t_t );
105+
106+ WRITE4_READ4 = new RegisterFormat ("WRITE4_READ4" , writeRead , limits_f_f );
107+ WRITE4_READ4W = new RegisterFormat ("WRITE4_READ4W" , writeRead , limits_f_f , wide_f_t );
108+ WRITE4W_READ4 = new RegisterFormat ("WRITE4W_READ4" , writeRead , limits_f_f , wide_t_f );
109+ WRITE4W_READ4W = new RegisterFormat ("WRITE4W_READ4W" , writeRead , limits_f_f , wide_t_t );
110+
111+ WRITE8_READ8 = new RegisterFormat ("WRITE8_READ8" , writeRead , limits_ff_ff );
112+ WRITE8_READ16 = new RegisterFormat ("WRITE8_READ16" , writeRead , limits_ff_ffff );
113+ WRITE8W_READ16W = new RegisterFormat ("WRITE8W_READ16W" ,
114+ writeRead , limits_ff_ffff , wide_t_t );
115+ WRITE16_READ16 = new RegisterFormat ("WRITE16_READ16" , writeRead , limits_ffff_ffff );
116+ WRITE16W_READ16W = new RegisterFormat ("WRITE16W_READ16W" ,
117+ writeRead , limits_ffff_ffff , wide_t_t );
41118
42- OUT = new RegisterFormat ("OUT" , new RegisterType [0 ]){
119+ WRITE8_READ8_READ8 = new RegisterFormat ("WRITE8_READ8_READ8" , writeReadRead , limits_ff_ff_ff );
120+ WRITE8_READ8W_READ8W = new RegisterFormat ("WRITE8_READ8W_READ8W" ,
121+ writeReadRead , limits_ff_ff_ff , wide_f_t_t );
122+ WRITE8W_READ8_READ8 = new RegisterFormat ("WRITE8W_READ8_READ8" ,
123+ writeReadRead , limits_ff_ff_ff , wide_t_f_f );
124+ WRITE8W_READ8W_READ8 = new RegisterFormat ("WRITE8W_READ8W_READ8" ,
125+ writeReadRead , limits_ff_ff_ff , wide_t_t_f );
126+ WRITE8W_READ8W_READ8W = new RegisterFormat ("WRITE8W_READ8W_READ8W" ,
127+ writeReadRead , limits_ff_ff_ff , wide_t_t_t );
128+
129+ OUT = new RegisterFormat ("OUT" , null , null ) {
43130 @ Override
44131 public RegisterType get (int i ) {
45132 return RegisterType .READ ;
@@ -48,8 +135,20 @@ public RegisterType get(int i) {
48135 public boolean isOut () {
49136 return true ;
50137 }
138+ @ Override
139+ public int limit (int i ) {
140+ return 0xf ;
141+ }
142+ @ Override
143+ public boolean isWide (int i ) {
144+ return false ;
145+ }
51146 };
52- OUT_RANGE = new RegisterFormat ("OUT_RANGE" , new RegisterType []{RegisterType .READ , RegisterType .READ }){
147+ OUT_RANGE = new RegisterFormat ("OUT_RANGE" , null , null ) {
148+ @ Override
149+ public RegisterType get (int i ) {
150+ return RegisterType .READ ;
151+ }
53152 @ Override
54153 public boolean isOut () {
55154 return true ;
@@ -58,41 +157,64 @@ public boolean isOut() {
58157 public boolean isRange () {
59158 return true ;
60159 }
160+ @ Override
161+ public int limit (int i ) {
162+ return 0xffff ;
163+ }
164+ @ Override
165+ public boolean isWide (int i ) {
166+ return false ;
167+ }
61168 };
62169 }
63170
64171 private final String name ;
65172 private final RegisterType [] types ;
66- private final int hash ;
173+ private final int [] limits ;
174+ private final boolean [] wide ;
67175
68- private RegisterFormat (String name , RegisterType [] types ){
176+ RegisterFormat (String name , RegisterType [] types , int [] limits ) {
177+ this (name , types , limits , null );
178+ }
179+ RegisterFormat (String name , RegisterType [] types , int [] limits , boolean [] wide ) {
69180 this .name = name ;
70181 this .types = types ;
71- int h = 1 ;
72- if (types != null ){
73- h = h + 31 * types .length ;
74- }
75- h = h + 31 * name .hashCode ();
76- this .hash = h ;
182+ this .limits = limits ;
183+ this .wide = wide ;
77184 }
78185
79- public RegisterType get (int i ){
80- if (isOut ()){
81- return RegisterType .READ ;
186+ public RegisterType get (int i ) {
187+ RegisterType [] types = this .types ;
188+ if (types != null && i >= 0 && i < types .length ) {
189+ return types [i ];
82190 }
83- return types [ i ] ;
191+ return null ;
84192 }
85- public int size (){
193+ public int size () {
86194 RegisterType [] types = this .types ;
87- if (types != null ){
195+ if (types != null ) {
88196 return types .length ;
89197 }
90198 return 0 ;
91199 }
92- public boolean isOut (){
200+ public boolean isOut () {
93201 return false ;
94202 }
95- public boolean isRange (){
203+ public boolean isRange () {
204+ return false ;
205+ }
206+ public int limit (int i ) {
207+ int [] limits = this .limits ;
208+ if (limits != null && i >= 0 && i <= limits .length ) {
209+ return limits [i ];
210+ }
211+ return 0 ;
212+ }
213+ public boolean isWide (int i ) {
214+ boolean [] wide = this .wide ;
215+ if (wide != null && i >= 0 && i <= wide .length ) {
216+ return wide [i ];
217+ }
96218 return false ;
97219 }
98220 @ Override
@@ -101,7 +223,13 @@ public boolean equals(Object obj) {
101223 }
102224 @ Override
103225 public int hashCode () {
104- return hash ;
226+ int h = 31 ;
227+ RegisterType [] types = this .types ;
228+ if (types != null ) {
229+ h = h * 31 + types .length ;
230+ }
231+ h = h * 31 + name .hashCode ();
232+ return h ;
105233 }
106234
107235 @ Override
0 commit comments