1#![allow(non_camel_case_types)]
2
3use std::fmt;
4
5#[derive(Debug, PartialEq)]
6pub struct add {
7 pub rd: &'static str,
8 pub rs1: &'static str,
9 pub rs2: &'static str,
10}
11
12#[derive(Debug, PartialEq)]
13pub struct sub {
14 pub rd: &'static str,
15 pub rs1: &'static str,
16 pub rs2: &'static str,
17}
18
19#[derive(Debug, PartialEq)]
20pub struct xor {
21 pub rd: &'static str,
22 pub rs1: &'static str,
23 pub rs2: &'static str,
24}
25
26#[derive(Debug, PartialEq)]
27pub struct or {
28 pub rd: &'static str,
29 pub rs1: &'static str,
30 pub rs2: &'static str,
31}
32
33#[derive(Debug, PartialEq)]
34pub struct and {
35 pub rd: &'static str,
36 pub rs1: &'static str,
37 pub rs2: &'static str,
38}
39
40#[derive(Debug, PartialEq)]
41pub struct sll {
42 pub rd: &'static str,
43 pub rs1: &'static str,
44 pub rs2: &'static str,
45}
46
47#[derive(Debug, PartialEq)]
48pub struct srl {
49 pub rd: &'static str,
50 pub rs1: &'static str,
51 pub rs2: &'static str,
52}
53
54#[derive(Debug, PartialEq)]
55pub struct sra {
56 pub rd: &'static str,
57 pub rs1: &'static str,
58 pub rs2: &'static str,
59}
60
61#[derive(Debug, PartialEq)]
62pub struct slt {
63 pub rd: &'static str,
64 pub rs1: &'static str,
65 pub rs2: &'static str,
66}
67
68#[derive(Debug, PartialEq)]
69pub struct sltu {
70 pub rd: &'static str,
71 pub rs1: &'static str,
72 pub rs2: &'static str,
73}
74
75#[derive(Debug, PartialEq)]
76pub struct addi {
77 pub rd: &'static str,
78 pub rs1: &'static str,
79 pub imm: i32,
80}
81
82#[derive(Debug, PartialEq)]
83pub struct xori {
84 pub rd: &'static str,
85 pub rs1: &'static str,
86 pub imm: i32,
87}
88
89#[derive(Debug, PartialEq)]
90pub struct ori {
91 pub rd: &'static str,
92 pub rs1: &'static str,
93 pub imm: i32,
94}
95
96#[derive(Debug, PartialEq)]
97pub struct andi {
98 pub rd: &'static str,
99 pub rs1: &'static str,
100 pub imm: i32,
101}
102
103#[derive(Debug, PartialEq)]
104pub struct slli {
105 pub rd: &'static str,
106 pub rs1: &'static str,
107 pub shamt: u8,
108}
109
110#[derive(Debug, PartialEq)]
111pub struct srli {
112 pub rd: &'static str,
113 pub rs1: &'static str,
114 pub shamt: u8,
115}
116
117#[derive(Debug, PartialEq)]
118pub struct srai {
119 pub rd: &'static str,
120 pub rs1: &'static str,
121 pub shamt: u8,
122}
123
124#[derive(Debug, PartialEq)]
125pub struct slti {
126 pub rd: &'static str,
127 pub rs1: &'static str,
128 pub imm: i32,
129}
130
131#[derive(Debug, PartialEq)]
132pub struct sltiu {
133 pub rd: &'static str,
134 pub rs1: &'static str,
135 pub imm: i32,
136}
137
138#[derive(Debug, PartialEq)]
139pub struct lb {
140 pub rd: &'static str,
141 pub rs1: &'static str,
142 pub imm: i32,
143}
144
145#[derive(Debug, PartialEq)]
146pub struct lh {
147 pub rd: &'static str,
148 pub rs1: &'static str,
149 pub imm: i32,
150}
151
152#[derive(Debug, PartialEq)]
153pub struct lw {
154 pub rd: &'static str,
155 pub rs1: &'static str,
156 pub imm: i32,
157}
158
159#[derive(Debug, PartialEq)]
160pub struct lbu {
161 pub rd: &'static str,
162 pub rs1: &'static str,
163 pub imm: i32,
164}
165
166#[derive(Debug, PartialEq)]
167pub struct lhu {
168 pub rd: &'static str,
169 pub rs1: &'static str,
170 pub imm: i32,
171}
172
173#[derive(Debug, PartialEq)]
174pub struct sb {
175 pub rs1: &'static str,
176 pub rs2: &'static str,
177 pub imm: i32,
178}
179
180#[derive(Debug, PartialEq)]
181pub struct sh {
182 pub rs1: &'static str,
183 pub rs2: &'static str,
184 pub imm: i32,
185}
186
187#[derive(Debug, PartialEq)]
188pub struct sw {
189 pub rs1: &'static str,
190 pub rs2: &'static str,
191 pub imm: i32,
192}
193
194#[derive(Debug, PartialEq)]
195pub struct beq {
196 pub rs1: &'static str,
197 pub rs2: &'static str,
198 pub imm: i32,
199}
200
201#[derive(Debug, PartialEq)]
202pub struct bne {
203 pub rs1: &'static str,
204 pub rs2: &'static str,
205 pub imm: i32,
206}
207
208#[derive(Debug, PartialEq)]
209pub struct blt {
210 pub rs1: &'static str,
211 pub rs2: &'static str,
212 pub imm: i32,
213}
214
215#[derive(Debug, PartialEq)]
216pub struct bge {
217 pub rs1: &'static str,
218 pub rs2: &'static str,
219 pub imm: i32,
220}
221
222#[derive(Debug, PartialEq)]
223pub struct bltu {
224 pub rs1: &'static str,
225 pub rs2: &'static str,
226 pub imm: i32,
227}
228
229#[derive(Debug, PartialEq)]
230pub struct bgeu {
231 pub rs1: &'static str,
232 pub rs2: &'static str,
233 pub imm: i32,
234}
235
236#[derive(Debug, PartialEq)]
237pub struct jal {
238 pub rd: &'static str,
239 pub imm: i32,
240}
241
242#[derive(Debug, PartialEq)]
243pub struct jalr {
244 pub rd: &'static str,
245 pub rs1: &'static str,
246 pub imm: i32,
247}
248
249#[derive(Debug, PartialEq)]
250pub struct lui {
251 pub rd: &'static str,
252 pub imm: i32,
253}
254
255#[derive(Debug, PartialEq)]
256pub struct auipc {
257 pub rd: &'static str,
258 pub imm: i32,
259}
260
261#[derive(Debug, PartialEq)]
262pub struct ecall {}
263
264#[derive(Debug, PartialEq)]
265pub struct ebreak {}
266
267impl fmt::Display for add {
268 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
269 write!(f, "add {}, {}, {}", self.rd, self.rs1, self.rs2)
270 }
271}
272
273impl fmt::Display for sub {
274 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
275 write!(f, "sub {}, {}, {}", self.rd, self.rs1, self.rs2)
276 }
277}
278
279impl fmt::Display for xor {
280 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
281 write!(f, "xor {}, {}, {}", self.rd, self.rs1, self.rs2)
282 }
283}
284
285impl fmt::Display for or {
286 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
287 write!(f, "or {}, {}, {}", self.rd, self.rs1, self.rs2)
288 }
289}
290
291impl fmt::Display for and {
292 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
293 write!(f, "and {}, {}, {}", self.rd, self.rs1, self.rs2)
294 }
295}
296
297impl fmt::Display for sll {
298 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
299 write!(f, "sll {}, {}, {}", self.rd, self.rs1, self.rs2)
300 }
301}
302
303impl fmt::Display for srl {
304 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
305 write!(f, "srl {}, {}, {}", self.rd, self.rs1, self.rs2)
306 }
307}
308
309impl fmt::Display for sra {
310 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
311 write!(f, "sra {}, {}, {}", self.rd, self.rs1, self.rs2)
312 }
313}
314
315impl fmt::Display for slt {
316 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
317 write!(f, "slt {}, {}, {}", self.rd, self.rs1, self.rs2)
318 }
319}
320
321impl fmt::Display for sltu {
322 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
323 write!(f, "sltu {}, {}, {}", self.rd, self.rs1, self.rs2)
324 }
325}
326
327impl fmt::Display for addi {
328 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
329 write!(f, "addi {}, {}, {}", self.rd, self.rs1, self.imm)
330 }
331}
332
333impl fmt::Display for xori {
334 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
335 write!(f, "xori {}, {}, {}", self.rd, self.rs1, self.imm)
336 }
337}
338
339impl fmt::Display for ori {
340 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
341 write!(f, "ori {}, {}, {}", self.rd, self.rs1, self.imm)
342 }
343}
344
345impl fmt::Display for andi {
346 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
347 write!(f, "andi {}, {}, {}", self.rd, self.rs1, self.imm)
348 }
349}
350
351impl fmt::Display for slli {
352 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
353 write!(f, "slli {}, {}, {}", self.rd, self.rs1, self.shamt)
354 }
355}
356
357impl fmt::Display for srli {
358 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
359 write!(f, "srli {}, {}, {}", self.rd, self.rs1, self.shamt)
360 }
361}
362
363impl fmt::Display for srai {
364 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
365 write!(f, "srai {}, {}, {}", self.rd, self.rs1, self.shamt)
366 }
367}
368
369impl fmt::Display for slti {
370 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
371 write!(f, "slti {}, {}, {}", self.rd, self.rs1, self.imm)
372 }
373}
374
375impl fmt::Display for sltiu {
376 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
377 write!(f, "sltiu {}, {}, {}", self.rd, self.rs1, self.imm)
378 }
379}
380
381impl fmt::Display for lb {
382 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
383 write!(f, "lb {}, {}({})", self.rd, self.imm, self.rs1)
384 }
385}
386
387impl fmt::Display for lh {
388 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
389 write!(f, "lh {}, {}({})", self.rd, self.imm, self.rs1)
390 }
391}
392
393impl fmt::Display for lw {
394 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
395 write!(f, "lw {}, {}({})", self.rd, self.imm, self.rs1)
396 }
397}
398
399impl fmt::Display for lbu {
400 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
401 write!(f, "lbu {}, {}({})", self.rd, self.imm, self.rs1)
402 }
403}
404
405impl fmt::Display for lhu {
406 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
407 write!(f, "lhu {}, {}({})", self.rd, self.imm, self.rs1)
408 }
409}
410
411impl fmt::Display for sb {
412 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
413 write!(f, "sb {}, {}({})", self.rs2, self.imm, self.rs1)
414 }
415}
416
417impl fmt::Display for sh {
418 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
419 write!(f, "sh {}, {}({})", self.rs2, self.imm, self.rs1)
420 }
421}
422
423impl fmt::Display for sw {
424 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
425 write!(f, "sw {}, {}({})", self.rs2, self.imm, self.rs1)
426 }
427}
428
429impl fmt::Display for beq {
430 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
431 write!(f, "beq {}, {}, {}", self.rs1, self.rs2, self.imm)
432 }
433}
434
435impl fmt::Display for bne {
436 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
437 write!(f, "bne {}, {}, {}", self.rs1, self.rs2, self.imm)
438 }
439}
440
441impl fmt::Display for blt {
442 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
443 write!(f, "blt {}, {}, {}", self.rs1, self.rs2, self.imm)
444 }
445}
446
447impl fmt::Display for bge {
448 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
449 write!(f, "bge {}, {}, {}", self.rs1, self.rs2, self.imm)
450 }
451}
452
453impl fmt::Display for bltu {
454 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
455 write!(f, "bltu {}, {}, {}", self.rs1, self.rs2, self.imm)
456 }
457}
458
459impl fmt::Display for bgeu {
460 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
461 write!(f, "bgeu {}, {}, {}", self.rs1, self.rs2, self.imm)
462 }
463}
464
465impl fmt::Display for jal {
466 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
467 write!(f, "jal {}, {}", self.rd, self.imm)
468 }
469}
470
471impl fmt::Display for jalr {
472 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
473 write!(f, "jalr {}, {}({})", self.rd, self.imm, self.rs1)
474 }
475}
476
477impl fmt::Display for lui {
478 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
479 write!(f, "lui {}, {}", self.rd, self.imm)
480 }
481}
482
483impl fmt::Display for auipc {
484 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
485 write!(f, "auipc {}, {}", self.rd, self.imm)
486 }
487}
488
489impl fmt::Display for ecall {
490 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
491 write!(f, "ecall")
492 }
493}
494
495impl fmt::Display for ebreak {
496 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
497 write!(f, "ebreak")
498 }
499}