1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
|
(*Generated by Sail from riscv.*)
Require Import Sail.Base.
Require Import Sail.Real.
Require Import riscv_types.
Import ListNotations.
Open Scope string.
Open Scope bool.
Open Scope Z.
Definition is_none {a : Type} (opt : option a) : bool :=
match opt with | Some _ => false | None => true end.
Definition is_some {a : Type} (opt : option a) : bool :=
match opt with | Some _ => true | None => false end.
Definition eq_unit (_ : unit) (_ : unit) : {_bool : bool & ArithFact (_bool)} := build_ex (true).
Definition neq_int (x : Z) (y : Z) : {_bool : bool & ArithFact (Bool.eqb (negb (x =? y)) _bool)} :=
build_ex (negb (Z.eqb x y)).
Definition neq_bool (x : bool) (y : bool) : bool := negb (Bool.eqb x y).
Definition __id (x : Z) : {_retval : Z & ArithFact (_retval =? x)} := build_ex (x).
Definition fdiv_int (n : Z) (m : Z) : Z :=
if sumbool_of_bool (andb (Z.ltb n 0) (Z.gtb m 0)) then Z.sub (Z.quot (Z.add n 1) m) 1
else if sumbool_of_bool (andb (Z.gtb n 0) (Z.ltb m 0)) then Z.sub (Z.quot (Z.sub n 1) m) 1
else Z.quot n m.
Definition fmod_int (n : Z) (m : Z) : Z := Z.sub n (Z.mul m (fdiv_int n m)).
Definition concat_str_bits {n : Z} (str : string) (x : mword n) : string :=
String.append str (string_of_bits x).
Definition concat_str_dec (str : string) (x : Z) : string := String.append str (dec_str x).
Definition sail_mask {v0 : Z} (len : Z) (v : mword v0) `{ArithFact ((len >=? 0) && (v0 >=? 0))}
: mword len :=
if sumbool_of_bool (Z.leb len (length_mword v)) then vector_truncate v len else zero_extend v len.
Definition sail_ones (n : Z) `{ArithFact (n >=? 0)} : mword n := not_vec (zeros n).
Definition slice_mask (n : Z) (i : Z) (l : Z) `{ArithFact (n >=? 0)} : mword n :=
if sumbool_of_bool (Z.geb l n) then shiftl (sail_ones n) i
else
let one : bits n := sail_mask n ('b"1" : bits 1) in
shiftl (sub_vec (shiftl one l) one) i.
Definition EXTS {n : Z} (m : Z) (v : mword n) `{ArithFact (m >=? n)} : mword m := sign_extend v m.
Definition EXTZ {n : Z} (m : Z) (v : mword n) `{ArithFact (m >=? n)} : mword m := zero_extend v m.
Definition zero_reg : regtype := EXTZ 64 (Ox"0" : mword 4).
Hint Unfold zero_reg : sail.
Definition regval_from_reg (r : mword 64) : mword 64 := r.
Definition regval_into_reg (v : mword 64) : mword 64 := v.
Definition rX (r : Z) `{ArithFact ((0 <=? r) && (r <? 32))} : M (mword 64) :=
let l__32 := r in
(if sumbool_of_bool (Z.eqb l__32 0) then returnm zero_reg
else if sumbool_of_bool (Z.eqb l__32 1) then ((read_reg x1_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 2) then ((read_reg x2_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 3) then ((read_reg x3_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 4) then ((read_reg x4_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 5) then ((read_reg x5_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 6) then ((read_reg x6_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 7) then ((read_reg x7_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 8) then ((read_reg x8_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 9) then ((read_reg x9_ref) : M (mword 64)) : M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 10) then
((read_reg x10_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 11) then
((read_reg x11_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 12) then
((read_reg x12_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 13) then
((read_reg x13_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 14) then
((read_reg x14_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 15) then
((read_reg x15_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 16) then
((read_reg x16_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 17) then
((read_reg x17_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 18) then
((read_reg x18_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 19) then
((read_reg x19_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 20) then
((read_reg x20_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 21) then
((read_reg x21_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 22) then
((read_reg x22_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 23) then
((read_reg x23_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 24) then
((read_reg x24_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 25) then
((read_reg x25_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 26) then
((read_reg x26_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 27) then
((read_reg x27_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 28) then
((read_reg x28_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 29) then
((read_reg x29_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 30) then
((read_reg x30_ref) : M (mword 64))
: M (mword 64)
else if sumbool_of_bool (Z.eqb l__32 31) then
((read_reg x31_ref) : M (mword 64))
: M (mword 64)
else assert_exp' false "invalid register number" >>= fun _ => exit tt) >>= fun v : regtype =>
returnm (regval_from_reg v).
Definition wX (r : Z) (in_v : mword 64) `{ArithFact ((0 <=? r) && (r <? 32))} : M (unit) :=
let v := regval_into_reg in_v in
let l__0 := r in
(if sumbool_of_bool (Z.eqb l__0 0) then returnm tt
else if sumbool_of_bool (Z.eqb l__0 1) then write_reg x1_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 2) then write_reg x2_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 3) then write_reg x3_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 4) then write_reg x4_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 5) then write_reg x5_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 6) then write_reg x6_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 7) then write_reg x7_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 8) then write_reg x8_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 9) then write_reg x9_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 10) then write_reg x10_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 11) then write_reg x11_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 12) then write_reg x12_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 13) then write_reg x13_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 14) then write_reg x14_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 15) then write_reg x15_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 16) then write_reg x16_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 17) then write_reg x17_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 18) then write_reg x18_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 19) then write_reg x19_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 20) then write_reg x20_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 21) then write_reg x21_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 22) then write_reg x22_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 23) then write_reg x23_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 24) then write_reg x24_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 25) then write_reg x25_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 26) then write_reg x26_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 27) then write_reg x27_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 28) then write_reg x28_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 29) then write_reg x29_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 30) then write_reg x30_ref v : M (unit)
else if sumbool_of_bool (Z.eqb l__0 31) then write_reg x31_ref v : M (unit)
else assert_exp' false "invalid register number" >>= fun _ => exit tt) : M (unit).
Definition rX_bits (i : mword 5) : M (mword 64) := (rX (projT1 (uint i))) : M (mword 64).
Definition wX_bits (i : mword 5) (data : mword 64) : M (unit) :=
(wX (projT1 (uint i)) data) : M (unit).
Definition reg_name_abi (r : mword 5) : M (string) :=
let b__0 := r in
(if eq_vec b__0 ('b"00000" : mword 5) then returnm "zero"
else if eq_vec b__0 ('b"00001" : mword 5) then returnm "ra"
else if eq_vec b__0 ('b"00010" : mword 5) then returnm "sp"
else if eq_vec b__0 ('b"00011" : mword 5) then returnm "gp"
else if eq_vec b__0 ('b"00100" : mword 5) then returnm "tp"
else if eq_vec b__0 ('b"00101" : mword 5) then returnm "t0"
else if eq_vec b__0 ('b"00110" : mword 5) then returnm "t1"
else if eq_vec b__0 ('b"00111" : mword 5) then returnm "t2"
else if eq_vec b__0 ('b"01000" : mword 5) then returnm "fp"
else if eq_vec b__0 ('b"01001" : mword 5) then returnm "s1"
else if eq_vec b__0 ('b"01010" : mword 5) then returnm "a0"
else if eq_vec b__0 ('b"01011" : mword 5) then returnm "a1"
else if eq_vec b__0 ('b"01100" : mword 5) then returnm "a2"
else if eq_vec b__0 ('b"01101" : mword 5) then returnm "a3"
else if eq_vec b__0 ('b"01110" : mword 5) then returnm "a4"
else if eq_vec b__0 ('b"01111" : mword 5) then returnm "a5"
else if eq_vec b__0 ('b"10000" : mword 5) then returnm "a6"
else if eq_vec b__0 ('b"10001" : mword 5) then returnm "a7"
else if eq_vec b__0 ('b"10010" : mword 5) then returnm "s2"
else if eq_vec b__0 ('b"10011" : mword 5) then returnm "s3"
else if eq_vec b__0 ('b"10100" : mword 5) then returnm "s4"
else if eq_vec b__0 ('b"10101" : mword 5) then returnm "s5"
else if eq_vec b__0 ('b"10110" : mword 5) then returnm "s6"
else if eq_vec b__0 ('b"10111" : mword 5) then returnm "s7"
else if eq_vec b__0 ('b"11000" : mword 5) then returnm "s8"
else if eq_vec b__0 ('b"11001" : mword 5) then returnm "s9"
else if eq_vec b__0 ('b"11010" : mword 5) then returnm "s10"
else if eq_vec b__0 ('b"11011" : mword 5) then returnm "s11"
else if eq_vec b__0 ('b"11100" : mword 5) then returnm "t3"
else if eq_vec b__0 ('b"11101" : mword 5) then returnm "t4"
else if eq_vec b__0 ('b"11110" : mword 5) then returnm "t5"
else if eq_vec b__0 ('b"11111" : mword 5) then returnm "t6"
else
assert_exp' false "Pattern match failure at riscv_regs.sail 160:2 - 193:3" >>= fun _ => exit tt)
: M (string).
Definition reg_name_forwards (arg_ : mword 5) : M (string) :=
let b__0 := arg_ in
(if eq_vec b__0 ('b"00000" : mword 5) then returnm "zero"
else if eq_vec b__0 ('b"00001" : mword 5) then returnm "ra"
else if eq_vec b__0 ('b"00010" : mword 5) then returnm "sp"
else if eq_vec b__0 ('b"00011" : mword 5) then returnm "gp"
else if eq_vec b__0 ('b"00100" : mword 5) then returnm "tp"
else if eq_vec b__0 ('b"00101" : mword 5) then returnm "t0"
else if eq_vec b__0 ('b"00110" : mword 5) then returnm "t1"
else if eq_vec b__0 ('b"00111" : mword 5) then returnm "t2"
else if eq_vec b__0 ('b"01000" : mword 5) then returnm "fp"
else if eq_vec b__0 ('b"01001" : mword 5) then returnm "s1"
else if eq_vec b__0 ('b"01010" : mword 5) then returnm "a0"
else if eq_vec b__0 ('b"01011" : mword 5) then returnm "a1"
else if eq_vec b__0 ('b"01100" : mword 5) then returnm "a2"
else if eq_vec b__0 ('b"01101" : mword 5) then returnm "a3"
else if eq_vec b__0 ('b"01110" : mword 5) then returnm "a4"
else if eq_vec b__0 ('b"01111" : mword 5) then returnm "a5"
else if eq_vec b__0 ('b"10000" : mword 5) then returnm "a6"
else if eq_vec b__0 ('b"10001" : mword 5) then returnm "a7"
else if eq_vec b__0 ('b"10010" : mword 5) then returnm "s2"
else if eq_vec b__0 ('b"10011" : mword 5) then returnm "s3"
else if eq_vec b__0 ('b"10100" : mword 5) then returnm "s4"
else if eq_vec b__0 ('b"10101" : mword 5) then returnm "s5"
else if eq_vec b__0 ('b"10110" : mword 5) then returnm "s6"
else if eq_vec b__0 ('b"10111" : mword 5) then returnm "s7"
else if eq_vec b__0 ('b"11000" : mword 5) then returnm "s8"
else if eq_vec b__0 ('b"11001" : mword 5) then returnm "s9"
else if eq_vec b__0 ('b"11010" : mword 5) then returnm "s10"
else if eq_vec b__0 ('b"11011" : mword 5) then returnm "s11"
else if eq_vec b__0 ('b"11100" : mword 5) then returnm "t3"
else if eq_vec b__0 ('b"11101" : mword 5) then returnm "t4"
else if eq_vec b__0 ('b"11110" : mword 5) then returnm "t5"
else if eq_vec b__0 ('b"11111" : mword 5) then returnm "t6"
else assert_exp' false "Pattern match failure at unknown location" >>= fun _ => exit tt)
: M (string).
Definition reg_name_backwards (arg_ : string) : M (mword 5) :=
let p0_ := arg_ in
(if generic_eq p0_ "zero" then returnm ('b"00000" : mword 5)
else if generic_eq p0_ "ra" then returnm ('b"00001" : mword 5)
else if generic_eq p0_ "sp" then returnm ('b"00010" : mword 5)
else if generic_eq p0_ "gp" then returnm ('b"00011" : mword 5)
else if generic_eq p0_ "tp" then returnm ('b"00100" : mword 5)
else if generic_eq p0_ "t0" then returnm ('b"00101" : mword 5)
else if generic_eq p0_ "t1" then returnm ('b"00110" : mword 5)
else if generic_eq p0_ "t2" then returnm ('b"00111" : mword 5)
else if generic_eq p0_ "fp" then returnm ('b"01000" : mword 5)
else if generic_eq p0_ "s1" then returnm ('b"01001" : mword 5)
else if generic_eq p0_ "a0" then returnm ('b"01010" : mword 5)
else if generic_eq p0_ "a1" then returnm ('b"01011" : mword 5)
else if generic_eq p0_ "a2" then returnm ('b"01100" : mword 5)
else if generic_eq p0_ "a3" then returnm ('b"01101" : mword 5)
else if generic_eq p0_ "a4" then returnm ('b"01110" : mword 5)
else if generic_eq p0_ "a5" then returnm ('b"01111" : mword 5)
else if generic_eq p0_ "a6" then returnm ('b"10000" : mword 5)
else if generic_eq p0_ "a7" then returnm ('b"10001" : mword 5)
else if generic_eq p0_ "s2" then returnm ('b"10010" : mword 5)
else if generic_eq p0_ "s3" then returnm ('b"10011" : mword 5)
else if generic_eq p0_ "s4" then returnm ('b"10100" : mword 5)
else if generic_eq p0_ "s5" then returnm ('b"10101" : mword 5)
else if generic_eq p0_ "s6" then returnm ('b"10110" : mword 5)
else if generic_eq p0_ "s7" then returnm ('b"10111" : mword 5)
else if generic_eq p0_ "s8" then returnm ('b"11000" : mword 5)
else if generic_eq p0_ "s9" then returnm ('b"11001" : mword 5)
else if generic_eq p0_ "s10" then returnm ('b"11010" : mword 5)
else if generic_eq p0_ "s11" then returnm ('b"11011" : mword 5)
else if generic_eq p0_ "t3" then returnm ('b"11100" : mword 5)
else if generic_eq p0_ "t4" then returnm ('b"11101" : mword 5)
else if generic_eq p0_ "t5" then returnm ('b"11110" : mword 5)
else if generic_eq p0_ "t6" then returnm ('b"11111" : mword 5)
else assert_exp' false "Pattern match failure at unknown location" >>= fun _ => exit tt)
: M (mword 5).
Definition reg_name_forwards_matches (arg_ : mword 5) : bool :=
let b__0 := arg_ in
if eq_vec b__0 ('b"00000" : mword 5) then true
else if eq_vec b__0 ('b"00001" : mword 5) then true
else if eq_vec b__0 ('b"00010" : mword 5) then true
else if eq_vec b__0 ('b"00011" : mword 5) then true
else if eq_vec b__0 ('b"00100" : mword 5) then true
else if eq_vec b__0 ('b"00101" : mword 5) then true
else if eq_vec b__0 ('b"00110" : mword 5) then true
else if eq_vec b__0 ('b"00111" : mword 5) then true
else if eq_vec b__0 ('b"01000" : mword 5) then true
else if eq_vec b__0 ('b"01001" : mword 5) then true
else if eq_vec b__0 ('b"01010" : mword 5) then true
else if eq_vec b__0 ('b"01011" : mword 5) then true
else if eq_vec b__0 ('b"01100" : mword 5) then true
else if eq_vec b__0 ('b"01101" : mword 5) then true
else if eq_vec b__0 ('b"01110" : mword 5) then true
else if eq_vec b__0 ('b"01111" : mword 5) then true
else if eq_vec b__0 ('b"10000" : mword 5) then true
else if eq_vec b__0 ('b"10001" : mword 5) then true
else if eq_vec b__0 ('b"10010" : mword 5) then true
else if eq_vec b__0 ('b"10011" : mword 5) then true
else if eq_vec b__0 ('b"10100" : mword 5) then true
else if eq_vec b__0 ('b"10101" : mword 5) then true
else if eq_vec b__0 ('b"10110" : mword 5) then true
else if eq_vec b__0 ('b"10111" : mword 5) then true
else if eq_vec b__0 ('b"11000" : mword 5) then true
else if eq_vec b__0 ('b"11001" : mword 5) then true
else if eq_vec b__0 ('b"11010" : mword 5) then true
else if eq_vec b__0 ('b"11011" : mword 5) then true
else if eq_vec b__0 ('b"11100" : mword 5) then true
else if eq_vec b__0 ('b"11101" : mword 5) then true
else if eq_vec b__0 ('b"11110" : mword 5) then true
else if eq_vec b__0 ('b"11111" : mword 5) then true
else false.
Definition reg_name_backwards_matches (arg_ : string) : bool :=
let p0_ := arg_ in
if generic_eq p0_ "zero" then true
else if generic_eq p0_ "ra" then true
else if generic_eq p0_ "sp" then true
else if generic_eq p0_ "gp" then true
else if generic_eq p0_ "tp" then true
else if generic_eq p0_ "t0" then true
else if generic_eq p0_ "t1" then true
else if generic_eq p0_ "t2" then true
else if generic_eq p0_ "fp" then true
else if generic_eq p0_ "s1" then true
else if generic_eq p0_ "a0" then true
else if generic_eq p0_ "a1" then true
else if generic_eq p0_ "a2" then true
else if generic_eq p0_ "a3" then true
else if generic_eq p0_ "a4" then true
else if generic_eq p0_ "a5" then true
else if generic_eq p0_ "a6" then true
else if generic_eq p0_ "a7" then true
else if generic_eq p0_ "s2" then true
else if generic_eq p0_ "s3" then true
else if generic_eq p0_ "s4" then true
else if generic_eq p0_ "s5" then true
else if generic_eq p0_ "s6" then true
else if generic_eq p0_ "s7" then true
else if generic_eq p0_ "s8" then true
else if generic_eq p0_ "s9" then true
else if generic_eq p0_ "s10" then true
else if generic_eq p0_ "s11" then true
else if generic_eq p0_ "t3" then true
else if generic_eq p0_ "t4" then true
else if generic_eq p0_ "t5" then true
else if generic_eq p0_ "t6" then true
else false.
Definition _s124_ (_s125_ : string) : option string :=
let _s126_ := _s125_ in
if string_startswith _s126_ "t6" then
match (string_drop _s126_ (projT1 (string_length "t6"))) with | s_ => Some s_ end
else None.
Definition _s120_ (_s121_ : string) : option string :=
let _s122_ := _s121_ in
if string_startswith _s122_ "t5" then
match (string_drop _s122_ (projT1 (string_length "t5"))) with | s_ => Some s_ end
else None.
Definition _s116_ (_s117_ : string) : option string :=
let _s118_ := _s117_ in
if string_startswith _s118_ "t4" then
match (string_drop _s118_ (projT1 (string_length "t4"))) with | s_ => Some s_ end
else None.
Definition _s112_ (_s113_ : string) : option string :=
let _s114_ := _s113_ in
if string_startswith _s114_ "t3" then
match (string_drop _s114_ (projT1 (string_length "t3"))) with | s_ => Some s_ end
else None.
Definition _s108_ (_s109_ : string) : option string :=
let _s110_ := _s109_ in
if string_startswith _s110_ "s11" then
match (string_drop _s110_ (projT1 (string_length "s11"))) with | s_ => Some s_ end
else None.
Definition _s104_ (_s105_ : string) : option string :=
let _s106_ := _s105_ in
if string_startswith _s106_ "s10" then
match (string_drop _s106_ (projT1 (string_length "s10"))) with | s_ => Some s_ end
else None.
Definition _s100_ (_s101_ : string) : option string :=
let _s102_ := _s101_ in
if string_startswith _s102_ "s9" then
match (string_drop _s102_ (projT1 (string_length "s9"))) with | s_ => Some s_ end
else None.
Definition _s96_ (_s97_ : string) : option string :=
let _s98_ := _s97_ in
if string_startswith _s98_ "s8" then
match (string_drop _s98_ (projT1 (string_length "s8"))) with | s_ => Some s_ end
else None.
Definition _s92_ (_s93_ : string) : option string :=
let _s94_ := _s93_ in
if string_startswith _s94_ "s7" then
match (string_drop _s94_ (projT1 (string_length "s7"))) with | s_ => Some s_ end
else None.
Definition _s88_ (_s89_ : string) : option string :=
let _s90_ := _s89_ in
if string_startswith _s90_ "s6" then
match (string_drop _s90_ (projT1 (string_length "s6"))) with | s_ => Some s_ end
else None.
Definition _s84_ (_s85_ : string) : option string :=
let _s86_ := _s85_ in
if string_startswith _s86_ "s5" then
match (string_drop _s86_ (projT1 (string_length "s5"))) with | s_ => Some s_ end
else None.
Definition _s80_ (_s81_ : string) : option string :=
let _s82_ := _s81_ in
if string_startswith _s82_ "s4" then
match (string_drop _s82_ (projT1 (string_length "s4"))) with | s_ => Some s_ end
else None.
Definition _s76_ (_s77_ : string) : option string :=
let _s78_ := _s77_ in
if string_startswith _s78_ "s3" then
match (string_drop _s78_ (projT1 (string_length "s3"))) with | s_ => Some s_ end
else None.
Definition _s72_ (_s73_ : string) : option string :=
let _s74_ := _s73_ in
if string_startswith _s74_ "s2" then
match (string_drop _s74_ (projT1 (string_length "s2"))) with | s_ => Some s_ end
else None.
Definition _s68_ (_s69_ : string) : option string :=
let _s70_ := _s69_ in
if string_startswith _s70_ "a7" then
match (string_drop _s70_ (projT1 (string_length "a7"))) with | s_ => Some s_ end
else None.
Definition _s64_ (_s65_ : string) : option string :=
let _s66_ := _s65_ in
if string_startswith _s66_ "a6" then
match (string_drop _s66_ (projT1 (string_length "a6"))) with | s_ => Some s_ end
else None.
Definition _s60_ (_s61_ : string) : option string :=
let _s62_ := _s61_ in
if string_startswith _s62_ "a5" then
match (string_drop _s62_ (projT1 (string_length "a5"))) with | s_ => Some s_ end
else None.
Definition _s56_ (_s57_ : string) : option string :=
let _s58_ := _s57_ in
if string_startswith _s58_ "a4" then
match (string_drop _s58_ (projT1 (string_length "a4"))) with | s_ => Some s_ end
else None.
Definition _s52_ (_s53_ : string) : option string :=
let _s54_ := _s53_ in
if string_startswith _s54_ "a3" then
match (string_drop _s54_ (projT1 (string_length "a3"))) with | s_ => Some s_ end
else None.
Definition _s48_ (_s49_ : string) : option string :=
let _s50_ := _s49_ in
if string_startswith _s50_ "a2" then
match (string_drop _s50_ (projT1 (string_length "a2"))) with | s_ => Some s_ end
else None.
Definition _s44_ (_s45_ : string) : option string :=
let _s46_ := _s45_ in
if string_startswith _s46_ "a1" then
match (string_drop _s46_ (projT1 (string_length "a1"))) with | s_ => Some s_ end
else None.
Definition _s40_ (_s41_ : string) : option string :=
let _s42_ := _s41_ in
if string_startswith _s42_ "a0" then
match (string_drop _s42_ (projT1 (string_length "a0"))) with | s_ => Some s_ end
else None.
Definition _s36_ (_s37_ : string) : option string :=
let _s38_ := _s37_ in
if string_startswith _s38_ "s1" then
match (string_drop _s38_ (projT1 (string_length "s1"))) with | s_ => Some s_ end
else None.
Definition _s32_ (_s33_ : string) : option string :=
let _s34_ := _s33_ in
if string_startswith _s34_ "fp" then
match (string_drop _s34_ (projT1 (string_length "fp"))) with | s_ => Some s_ end
else None.
Definition _s28_ (_s29_ : string) : option string :=
let _s30_ := _s29_ in
if string_startswith _s30_ "t2" then
match (string_drop _s30_ (projT1 (string_length "t2"))) with | s_ => Some s_ end
else None.
Definition _s24_ (_s25_ : string) : option string :=
let _s26_ := _s25_ in
if string_startswith _s26_ "t1" then
match (string_drop _s26_ (projT1 (string_length "t1"))) with | s_ => Some s_ end
else None.
Definition _s20_ (_s21_ : string) : option string :=
let _s22_ := _s21_ in
if string_startswith _s22_ "t0" then
match (string_drop _s22_ (projT1 (string_length "t0"))) with | s_ => Some s_ end
else None.
Definition _s16_ (_s17_ : string) : option string :=
let _s18_ := _s17_ in
if string_startswith _s18_ "tp" then
match (string_drop _s18_ (projT1 (string_length "tp"))) with | s_ => Some s_ end
else None.
Definition _s12_ (_s13_ : string) : option string :=
let _s14_ := _s13_ in
if string_startswith _s14_ "gp" then
match (string_drop _s14_ (projT1 (string_length "gp"))) with | s_ => Some s_ end
else None.
Definition _s8_ (_s9_ : string) : option string :=
let _s10_ := _s9_ in
if string_startswith _s10_ "sp" then
match (string_drop _s10_ (projT1 (string_length "sp"))) with | s_ => Some s_ end
else None.
Definition _s4_ (_s5_ : string) : option string :=
let _s6_ := _s5_ in
if string_startswith _s6_ "ra" then
match (string_drop _s6_ (projT1 (string_length "ra"))) with | s_ => Some s_ end
else None.
Definition _s0_ (_s1_ : string) : option string :=
let _s2_ := _s1_ in
if string_startswith _s2_ "zero" then
match (string_drop _s2_ (projT1 (string_length "zero"))) with | s_ => Some s_ end
else None.
Definition reg_name_matches_prefix (arg_ : string)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)}))) :=
let _s3_ := arg_ in
(if match (_s0_ _s3_) with | Some s_ => true | _ => false end then
(match (_s0_ _s3_) with
| Some s_ =>
returnm (Some
('b"00000"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s4_ _s3_) with | Some s_ => true | _ => false end then
(match (_s4_ _s3_) with
| Some s_ =>
returnm (Some
('b"00001"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s8_ _s3_) with | Some s_ => true | _ => false end then
(match (_s8_ _s3_) with
| Some s_ =>
returnm (Some
('b"00010"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s12_ _s3_) with | Some s_ => true | _ => false end then
(match (_s12_ _s3_) with
| Some s_ =>
returnm (Some
('b"00011"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s16_ _s3_) with | Some s_ => true | _ => false end then
(match (_s16_ _s3_) with
| Some s_ =>
returnm (Some
('b"00100"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s20_ _s3_) with | Some s_ => true | _ => false end then
(match (_s20_ _s3_) with
| Some s_ =>
returnm (Some
('b"00101"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s24_ _s3_) with | Some s_ => true | _ => false end then
(match (_s24_ _s3_) with
| Some s_ =>
returnm (Some
('b"00110"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s28_ _s3_) with | Some s_ => true | _ => false end then
(match (_s28_ _s3_) with
| Some s_ =>
returnm (Some
('b"00111"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s32_ _s3_) with | Some s_ => true | _ => false end then
(match (_s32_ _s3_) with
| Some s_ =>
returnm (Some
('b"01000"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s36_ _s3_) with | Some s_ => true | _ => false end then
(match (_s36_ _s3_) with
| Some s_ =>
returnm (Some
('b"01001"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s40_ _s3_) with | Some s_ => true | _ => false end then
(match (_s40_ _s3_) with
| Some s_ =>
returnm (Some
('b"01010"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s44_ _s3_) with | Some s_ => true | _ => false end then
(match (_s44_ _s3_) with
| Some s_ =>
returnm (Some
('b"01011"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s48_ _s3_) with | Some s_ => true | _ => false end then
(match (_s48_ _s3_) with
| Some s_ =>
returnm (Some
('b"01100"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s52_ _s3_) with | Some s_ => true | _ => false end then
(match (_s52_ _s3_) with
| Some s_ =>
returnm (Some
('b"01101"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s56_ _s3_) with | Some s_ => true | _ => false end then
(match (_s56_ _s3_) with
| Some s_ =>
returnm (Some
('b"01110"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s60_ _s3_) with | Some s_ => true | _ => false end then
(match (_s60_ _s3_) with
| Some s_ =>
returnm (Some
('b"01111"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s64_ _s3_) with | Some s_ => true | _ => false end then
(match (_s64_ _s3_) with
| Some s_ =>
returnm (Some
('b"10000"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s68_ _s3_) with | Some s_ => true | _ => false end then
(match (_s68_ _s3_) with
| Some s_ =>
returnm (Some
('b"10001"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s72_ _s3_) with | Some s_ => true | _ => false end then
(match (_s72_ _s3_) with
| Some s_ =>
returnm (Some
('b"10010"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s76_ _s3_) with | Some s_ => true | _ => false end then
(match (_s76_ _s3_) with
| Some s_ =>
returnm (Some
('b"10011"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s80_ _s3_) with | Some s_ => true | _ => false end then
(match (_s80_ _s3_) with
| Some s_ =>
returnm (Some
('b"10100"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s84_ _s3_) with | Some s_ => true | _ => false end then
(match (_s84_ _s3_) with
| Some s_ =>
returnm (Some
('b"10101"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s88_ _s3_) with | Some s_ => true | _ => false end then
(match (_s88_ _s3_) with
| Some s_ =>
returnm (Some
('b"10110"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s92_ _s3_) with | Some s_ => true | _ => false end then
(match (_s92_ _s3_) with
| Some s_ =>
returnm (Some
('b"10111"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s96_ _s3_) with | Some s_ => true | _ => false end then
(match (_s96_ _s3_) with
| Some s_ =>
returnm (Some
('b"11000"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s100_ _s3_) with | Some s_ => true | _ => false end then
(match (_s100_ _s3_) with
| Some s_ =>
returnm (Some
('b"11001"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s104_ _s3_) with | Some s_ => true | _ => false end then
(match (_s104_ _s3_) with
| Some s_ =>
returnm (Some
('b"11010"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s108_ _s3_) with | Some s_ => true | _ => false end then
(match (_s108_ _s3_) with
| Some s_ =>
returnm (Some
('b"11011"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s112_ _s3_) with | Some s_ => true | _ => false end then
(match (_s112_ _s3_) with
| Some s_ =>
returnm (Some
('b"11100"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s116_ _s3_) with | Some s_ => true | _ => false end then
(match (_s116_ _s3_) with
| Some s_ =>
returnm (Some
('b"11101"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s120_ _s3_) with | Some s_ => true | _ => false end then
(match (_s120_ _s3_) with
| Some s_ =>
returnm (Some
('b"11110"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s124_ _s3_) with | Some s_ => true | _ => false end then
(match (_s124_ _s3_) with
| Some s_ =>
returnm (Some
('b"11111"
: mword 5, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)})))
else returnm None) : M (option ((mword 5 * {n : Z & ArithFact (n >=? 0)}))).
Definition creg_name_forwards (arg_ : mword 3) : M (string) :=
let b__0 := arg_ in
(if eq_vec b__0 ('b"000" : mword 3) then returnm "s0"
else if eq_vec b__0 ('b"001" : mword 3) then returnm "s1"
else if eq_vec b__0 ('b"010" : mword 3) then returnm "a0"
else if eq_vec b__0 ('b"011" : mword 3) then returnm "a1"
else if eq_vec b__0 ('b"100" : mword 3) then returnm "a2"
else if eq_vec b__0 ('b"101" : mword 3) then returnm "a3"
else if eq_vec b__0 ('b"110" : mword 3) then returnm "a4"
else if eq_vec b__0 ('b"111" : mword 3) then returnm "a5"
else assert_exp' false "Pattern match failure at unknown location" >>= fun _ => exit tt)
: M (string).
Definition creg_name_backwards (arg_ : string) : M (mword 3) :=
let p0_ := arg_ in
(if generic_eq p0_ "s0" then returnm ('b"000" : mword 3)
else if generic_eq p0_ "s1" then returnm ('b"001" : mword 3)
else if generic_eq p0_ "a0" then returnm ('b"010" : mword 3)
else if generic_eq p0_ "a1" then returnm ('b"011" : mword 3)
else if generic_eq p0_ "a2" then returnm ('b"100" : mword 3)
else if generic_eq p0_ "a3" then returnm ('b"101" : mword 3)
else if generic_eq p0_ "a4" then returnm ('b"110" : mword 3)
else if generic_eq p0_ "a5" then returnm ('b"111" : mword 3)
else assert_exp' false "Pattern match failure at unknown location" >>= fun _ => exit tt)
: M (mword 3).
Definition creg_name_forwards_matches (arg_ : mword 3) : bool :=
let b__0 := arg_ in
if eq_vec b__0 ('b"000" : mword 3) then true
else if eq_vec b__0 ('b"001" : mword 3) then true
else if eq_vec b__0 ('b"010" : mword 3) then true
else if eq_vec b__0 ('b"011" : mword 3) then true
else if eq_vec b__0 ('b"100" : mword 3) then true
else if eq_vec b__0 ('b"101" : mword 3) then true
else if eq_vec b__0 ('b"110" : mword 3) then true
else if eq_vec b__0 ('b"111" : mword 3) then true
else false.
Definition creg_name_backwards_matches (arg_ : string) : bool :=
let p0_ := arg_ in
if generic_eq p0_ "s0" then true
else if generic_eq p0_ "s1" then true
else if generic_eq p0_ "a0" then true
else if generic_eq p0_ "a1" then true
else if generic_eq p0_ "a2" then true
else if generic_eq p0_ "a3" then true
else if generic_eq p0_ "a4" then true
else if generic_eq p0_ "a5" then true
else false.
Definition _s156_ (_s157_ : string) : option string :=
let _s158_ := _s157_ in
if string_startswith _s158_ "a5" then
match (string_drop _s158_ (projT1 (string_length "a5"))) with | s_ => Some s_ end
else None.
Definition _s152_ (_s153_ : string) : option string :=
let _s154_ := _s153_ in
if string_startswith _s154_ "a4" then
match (string_drop _s154_ (projT1 (string_length "a4"))) with | s_ => Some s_ end
else None.
Definition _s148_ (_s149_ : string) : option string :=
let _s150_ := _s149_ in
if string_startswith _s150_ "a3" then
match (string_drop _s150_ (projT1 (string_length "a3"))) with | s_ => Some s_ end
else None.
Definition _s144_ (_s145_ : string) : option string :=
let _s146_ := _s145_ in
if string_startswith _s146_ "a2" then
match (string_drop _s146_ (projT1 (string_length "a2"))) with | s_ => Some s_ end
else None.
Definition _s140_ (_s141_ : string) : option string :=
let _s142_ := _s141_ in
if string_startswith _s142_ "a1" then
match (string_drop _s142_ (projT1 (string_length "a1"))) with | s_ => Some s_ end
else None.
Definition _s136_ (_s137_ : string) : option string :=
let _s138_ := _s137_ in
if string_startswith _s138_ "a0" then
match (string_drop _s138_ (projT1 (string_length "a0"))) with | s_ => Some s_ end
else None.
Definition _s132_ (_s133_ : string) : option string :=
let _s134_ := _s133_ in
if string_startswith _s134_ "s1" then
match (string_drop _s134_ (projT1 (string_length "s1"))) with | s_ => Some s_ end
else None.
Definition _s128_ (_s129_ : string) : option string :=
let _s130_ := _s129_ in
if string_startswith _s130_ "s0" then
match (string_drop _s130_ (projT1 (string_length "s0"))) with | s_ => Some s_ end
else None.
Definition creg_name_matches_prefix (arg_ : string)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)}))) :=
let _s131_ := arg_ in
(if match (_s128_ _s131_) with | Some s_ => true | _ => false end then
(match (_s128_ _s131_) with
| Some s_ =>
returnm (Some
('b"000"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s132_ _s131_) with | Some s_ => true | _ => false end then
(match (_s132_ _s131_) with
| Some s_ =>
returnm (Some
('b"001"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s136_ _s131_) with | Some s_ => true | _ => false end then
(match (_s136_ _s131_) with
| Some s_ =>
returnm (Some
('b"010"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s140_ _s131_) with | Some s_ => true | _ => false end then
(match (_s140_ _s131_) with
| Some s_ =>
returnm (Some
('b"011"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s144_ _s131_) with | Some s_ => true | _ => false end then
(match (_s144_ _s131_) with
| Some s_ =>
returnm (Some
('b"100"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s148_ _s131_) with | Some s_ => true | _ => false end then
(match (_s148_ _s131_) with
| Some s_ =>
returnm (Some
('b"101"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s152_ _s131_) with | Some s_ => true | _ => false end then
(match (_s152_ _s131_) with
| Some s_ =>
returnm (Some
('b"110"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else if match (_s156_ _s131_) with | Some s_ => true | _ => false end then
(match (_s156_ _s131_) with
| Some s_ =>
returnm (Some
('b"111"
: mword 3, build_ex
(projT1
(sub_nat (projT1 (string_length arg_)) (projT1 (string_length s_))))))
| _ => exit tt : M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
end)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)})))
else returnm None)
: M (option ((mword 3 * {n : Z & ArithFact (n >=? 0)}))).
Definition init_base_regs '(tt : unit) : M (unit) :=
write_reg x1_ref zero_reg >>
write_reg x2_ref zero_reg >>
write_reg x3_ref zero_reg >>
write_reg x4_ref zero_reg >>
write_reg x5_ref zero_reg >>
write_reg x6_ref zero_reg >>
write_reg x7_ref zero_reg >>
write_reg x8_ref zero_reg >>
write_reg x9_ref zero_reg >>
write_reg x10_ref zero_reg >>
write_reg x11_ref zero_reg >>
write_reg x12_ref zero_reg >>
write_reg x13_ref zero_reg >>
write_reg x14_ref zero_reg >>
write_reg x15_ref zero_reg >>
write_reg x16_ref zero_reg >>
write_reg x17_ref zero_reg >>
write_reg x18_ref zero_reg >>
write_reg x19_ref zero_reg >>
write_reg x20_ref zero_reg >>
write_reg x21_ref zero_reg >>
write_reg x22_ref zero_reg >>
write_reg x23_ref zero_reg >>
write_reg x24_ref zero_reg >>
write_reg x25_ref zero_reg >>
write_reg x26_ref zero_reg >>
write_reg x27_ref zero_reg >>
write_reg x28_ref zero_reg >>
write_reg x29_ref zero_reg >>
write_reg x30_ref zero_reg >> write_reg x31_ref zero_reg : M (unit).
Definition initial_regstate : regstate :=
{| x31 := (Ox"0000000000000000" : mword 64);
x30 := (Ox"0000000000000000" : mword 64);
x29 := (Ox"0000000000000000" : mword 64);
x28 := (Ox"0000000000000000" : mword 64);
x27 := (Ox"0000000000000000" : mword 64);
x26 := (Ox"0000000000000000" : mword 64);
x25 := (Ox"0000000000000000" : mword 64);
x24 := (Ox"0000000000000000" : mword 64);
x23 := (Ox"0000000000000000" : mword 64);
x22 := (Ox"0000000000000000" : mword 64);
x21 := (Ox"0000000000000000" : mword 64);
x20 := (Ox"0000000000000000" : mword 64);
x19 := (Ox"0000000000000000" : mword 64);
x18 := (Ox"0000000000000000" : mword 64);
x17 := (Ox"0000000000000000" : mword 64);
x16 := (Ox"0000000000000000" : mword 64);
x15 := (Ox"0000000000000000" : mword 64);
x14 := (Ox"0000000000000000" : mword 64);
x13 := (Ox"0000000000000000" : mword 64);
x12 := (Ox"0000000000000000" : mword 64);
x11 := (Ox"0000000000000000" : mword 64);
x10 := (Ox"0000000000000000" : mword 64);
x9 := (Ox"0000000000000000" : mword 64);
x8 := (Ox"0000000000000000" : mword 64);
x7 := (Ox"0000000000000000" : mword 64);
x6 := (Ox"0000000000000000" : mword 64);
x5 := (Ox"0000000000000000" : mword 64);
x4 := (Ox"0000000000000000" : mword 64);
x3 := (Ox"0000000000000000" : mword 64);
x2 := (Ox"0000000000000000" : mword 64);
x1 := (Ox"0000000000000000" : mword 64);
instbits := (Ox"0000000000000000" : mword 64);
nextPC := (Ox"0000000000000000" : mword 64);
PC := (Ox"0000000000000000" : mword 64) |}.
Hint Unfold initial_regstate : sail.
|