-
Notifications
You must be signed in to change notification settings - Fork 0
/
C65InstrInfo.td
1577 lines (1429 loc) · 66.1 KB
/
C65InstrInfo.td
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
//===-- C65InstrInfo.td - Main C65 Instruction Definition --*- tablegen -*-===//
//===----------------------------------------------------------------------===//
// C65 predicates
//===----------------------------------------------------------------------===//
def Has65C02 : Predicate<"Subtarget->has65C02()">;
def Has65802 : Predicate<"Subtarget->has65802()">;
def Has65816 : Predicate<"Subtarget->has65816()">;
def IsAcc8Bit : Predicate<"Subtarget->isAcc8Bit()">,
AssemblerPredicate<"ModeAcc8Bit",
"8-bit accumulator mode">;
def IsAcc16Bit : Predicate<"Subtarget->isAcc16Bit()">,
AssemblerPredicate<"ModeAcc16Bit",
"16-bit accumulator mode">;
def IsIx8Bit : Predicate<"Subtarget->isIx8Bit()">,
AssemblerPredicate<"ModeIx8Bit",
"8-bit index mode">;
def IsIx16Bit : Predicate<"Subtarget->isIx16Bit()">,
AssemblerPredicate<"ModeIx16Bit",
"16-bit index mode">;
//===----------------------------------------------------------------------===//
// C65 basic instruction formats
//===----------------------------------------------------------------------===//
// Basic instruction format
class InstC65<dag outs, dag ins, string asmstr, list<dag> pattern>
: Instruction {
field bits<8> Inst = 0;
let Namespace = "C65";
let Size = 1;
dag OutOperandList = outs;
dag InOperandList = ins;
let AsmString = asmstr;
let Pattern = pattern;
let DecoderNamespace = "C65";
bits<2> AccSize = 0;
bits<2> IxSize = 0;
bit is_ZRInstr = 0;
bits<2> ZRSize = 0;
bits<2> OpSize = 0;
bit OpPCRel = 0;
let TSFlags{1-0} = AccSize;
let TSFlags{3-2} = IxSize;
let TSFlags{4} = is_ZRInstr;
let TSFlags{6-5} = ZRSize;
let TSFlags{8-7} = OpSize;
let TSFlags{16-9} = Inst;
let TSFlags{17} = OpPCRel;
}
class ZROpSize8 { bits<2> ZRSize = 0; }
class ZROpSize16 { bits<2> ZRSize = 1; }
class ZROpSize32 { bits<2> ZRSize = 2; }
class ZROpSize64 { bits<2> ZRSize = 3; }
class Acc8Bit { bits<2> AccSize = 0b10; }
class Acc16Bit { bits<2> AccSize = 0b11; }
class Ix8Bit { bits<2> IxSize = 0b10; }
class Ix16Bit { bits<2> IxSize = 0b11; }
class OpSize8 { bits<2> OpSize = 1; }
class OpSize16 { bits<2> OpSize = 2; }
class OpSize24 { bits<2> OpSize = 3; }
class OpPCRel { bit OpPCRel = 1; }
// Format cc instructions
// 6502 instruction format generally follows: aaabbbcc
class Fcc<bits<3> op, bits<3> addrmode, bits<2> cc,
dag outs, dag ins, string asmstr, list<dag> pattern>
: InstC65<outs, ins, asmstr, pattern> {
let Inst{7-5} = op;
let Inst{4-2} = addrmode;
let Inst{1-0} = cc;
}
class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
: InstC65<outs, ins, asmstr, pattern> {
let isPseudo = 1;
}
//===----------------------------------------------------------------------===//
// C65-specific node definitions
//===----------------------------------------------------------------------===//
def SDTC65CMP : SDTypeProfile<0, 2, [SDTCisInt<0>,
SDTCisSameAs<0, 1>]>;
def SDTC65FRAME_ADDR : SDTypeProfile<1, 1, [SDTCisPtrTy<0>,
SDTCisVT<1, i8>]>;
def SDTC65BR_CC : SDTypeProfile<0, 4, [SDTCisVT<0, i32>,
SDTCisSameAs<1, 2>,
SDTCisVT<3, OtherVT>]>;
def SDTC65SELECT_CC : SDTypeProfile<1, 5, [SDTCisSameAs<0, 3>,
SDTCisSameAs<0, 4>,
SDTCisSameAs<1, 2>,
SDTCisVT<5, i32>]>;
def SDTC65CALL : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>;
def SDTC65PUSH : SDTypeProfile<0, 1, []>;
def SDTC65PULL : SDTypeProfile<1, 0, []>;
def SDTC65Wrapper : SDTypeProfile<1, 1, [SDTCisSameAs<0, 1>,
SDTCisPtrTy<0>]>;
def C65CMP : SDNode<"C65ISD::CMP", SDTC65CMP,
[SDNPOutGlue]>;
def C65FRAME_ADDR : SDNode<"C65ISD::FRAME_ADDR", SDTC65FRAME_ADDR>;
def C65BR_CC : SDNode<"C65ISD::BR_CC", SDTC65BR_CC,
[SDNPHasChain, SDNPInGlue]>;
def C65SELECT_CC : SDNode<"C65ISD::SELECT_CC", SDTC65SELECT_CC,
[SDNPInGlue]>;
def C65CALL : SDNode<"C65ISD::CALL", SDTC65CALL,
[SDNPHasChain, SDNPOutGlue, SDNPOptInGlue,
SDNPVariadic]>;
def C65RET : SDNode<"C65ISD::RET", SDTNone,
[SDNPHasChain, SDNPOptInGlue, SDNPVariadic]>;
def C65PUSH : SDNode<"C65ISD::PUSH", SDTC65PUSH,
[SDNPHasChain, SDNPOutGlue]>;
def C65PULL : SDNode<"C65ISD::PULL", SDTC65PULL,
[SDNPHasChain, SDNPOutGlue]>;
def C65Wrapper : SDNode<"C65ISD::Wrapper", SDTC65Wrapper>;
def C65FarWrapper : SDNode<"C65ISD::FarWrapper", SDTC65Wrapper>;
// These are target-independent nodes, but have target-specific formats.
def SDTC65CALLSEQ_START : SDCallSeqStart<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
def SDTC65CALLSEQ_END : SDCallSeqEnd<[SDTCisVT<0, i32>, SDTCisVT<1, i32>]>;
def C65CALLSEQ_START : SDNode<"ISD::CALLSEQ_START", SDTC65CALLSEQ_START,
[SDNPHasChain, SDNPOutGlue]>;
def C65CALLSEQ_END : SDNode<"ISD::CALLSEQ_END", SDTC65CALLSEQ_END,
[SDNPHasChain, SDNPOptInGlue, SDNPOutGlue]>;
//===----------------------------------------------------------------------===//
// C65 assembler operand definitions
//===----------------------------------------------------------------------===//
// Immediate operand
// LDA #123 ; 8-bit (6502, 65C02, 65802, 65816)
// LDA #12345 ; 16-bit (65802, 65816)
def asmop_imm : AsmOperandClass {
let Name = "asmop_imm";
let RenderMethod = "addImmOperands";
let ParserMethod = "parseImmOperand";
}
// Program Counter Relative Addressing (6502, 65C02, 65802, 65816)
// BRA label
def asmop_pcrel8 : AsmOperandClass {
let Name = "asmop_pcrel8";
let RenderMethod = "addMemOperands";
let ParserMethod = "parsePCRel8Operand";
}
// Program Counter Relative Long Addressing (65802, 65816)
// BRL label
def asmop_pcrel16 : AsmOperandClass {
let Name = "asmop_pcrel16";
let RenderMethod = "addMemOperands";
let ParserMethod = "parsePCRel16Operand";
}
// Absolute Addressing (6502, 65C02, 65802, 65816)
// LDA $1245 ; With DBR
// JMP $1245 ; With PBR
def asmop_abs : AsmOperandClass {
let Name = "asmop_abs";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsOperand";
}
// Absolute Indexed X (6502, 65C02, 65802, 65816)
// LDA $1245,X
def asmop_absx : AsmOperandClass {
let Name = "asmop_absx";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsXOperand";
}
// Absolute Indexed Y (6502, 65C02, 65802, 65816)
// LDA $1245,Y
def asmop_absy : AsmOperandClass {
let Name = "asmop_absy";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsYOperand";
}
// Absolute Indexed Indirect Addressing (Absolute X Preindexed) (65816)
// JMP ($1000,X) ; With PBR (65C02, 65802, 65816)
// JSR ($1000,X) ; With PBR (65802, 65816)
def asmop_abspreix : AsmOperandClass {
let Name = "asmop_abspreix";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsPreIXOperand";
}
// Absolute Indirect Addressing (6502, 65C02, 65802)
// Direct Page Indirect (65816)
// JMP ($1000)
def asmop_absind : AsmOperandClass {
let Name = "asmop_absind";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsIndOperand";
}
// Absolute Indirect Long Addressing (65802, 65816)
// JMP [$1245] ; Indirect from bank 0
def asmop_absindl : AsmOperandClass {
let Name = "asmop_absindl";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsIndLOperand";
}
// Absolute Long Addressing (65802, 65816)
// LDA $112233
// JMP $112233
// (65802: Data bank value is not propagated to bus)
def asmop_absl : AsmOperandClass {
let Name = "asmop_absl";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsLOperand";
}
// Absolute Long Indexed, X Addressing (65802, 65816)
// LDA $112233,X
// (65802: Data bank value is not propagated to bus)
def asmop_absxl : AsmOperandClass {
let Name = "asmop_absxl";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseAbsXLOperand";
}
// Zero Page Addressing (6502, 65C02)
// Direct Page Addressing (65816)
// LDA $21
def asmop_zp : AsmOperandClass {
let Name = "asmop_zp";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseZPOperand";
}
// Zero Page Indexed with X Addressing (6502, 65C02)
// Direct Page Indexed with X Addressing (65816)
// LDA $21,X
def asmop_zpx : AsmOperandClass {
let Name = "asmop_zpx";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseZPXOperand";
}
// Zero Page Indexed with Y Addressing (6502, 65C02)
// Direct Page Indexed with Y Addressing (65816)
// LDA $21,Y
def asmop_zpy : AsmOperandClass {
let Name = "asmop_zpy";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseZPYOperand";
}
// Zero Page Indexing Indirect X Addressing
// Direct Page Indexing Indirect X Addressing
// (Direct Page Preindexing)
// STA ($50,X)
def asmop_zppreix : AsmOperandClass {
let Name = "asmop_zppreix";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseZPPreIXOperand";
}
// Zero Page Indirect (65C02)
// Direct Page Indirect (65816)
// STA ($10)
def asmop_zpind : AsmOperandClass {
let Name = "asmop_zpind";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseZPIndOperand";
}
// Direct Page Indirect Long (65802, 65816)
// LDA [$15]
def asmop_dpindl : AsmOperandClass {
let Name = "asmop_dpindl";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseDPIndLOperand";
}
// Zero Page Indirect Indexed with Y Addressing (6502, 65C02, 65802)
// Direct Page Indirect Indexed with Y Addressing
// (Direct Page Y Postindexed) (65816)
// LDA ($15),Y
def asmop_zppostiy : AsmOperandClass {
let Name = "asmop_zppostiy";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseZPPostIYOperand";
}
// Direct Page Indirect Long Indexed with Y Addressing
// (Direct Page Y Postindexed Long) (65802, 65816)
// LDA [$15],Y
// (65802: Data bank value is not propagated to bus)
def asmop_dppostiyl : AsmOperandClass {
let Name = "asmop_dppostiyl";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseDPPostIYLOperand";
}
// Stack Relative Addressing (65802, 65816)
// LDA 3,S
def asmop_srel : AsmOperandClass {
let Name = "asmop_srel";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseSRelOperand";
}
// Stack Relative Indirect Indexed, Y Addressing
// (Stack Postindexed) (65802, 65816)
// LDA (1,S),Y ; With DBR
def asmop_spostiy : AsmOperandClass {
let Name = "asmop_spostiy";
let RenderMethod = "addMemOperands";
let ParserMethod = "parseSPostIYOperand";
}
//===----------------------------------------------------------------------===//
// C65 complex pattern definitions
//===----------------------------------------------------------------------===//
def addr_zp : ComplexPattern<iPTR, 1, "SelectAddrZP", [], []>;
def addr_abs : ComplexPattern<iPTR, 1, "SelectAddrAbs", [], []>;
def addr_absl : ComplexPattern<iPTR, 1, "SelectAddrAbsL", [], []>;
def addr_rr : ComplexPattern<iPTR, 2, "SelectAddrRR", [], []>;
def addr_ri : ComplexPattern<iPTR, 2, "SelectAddrRI", [], []>;
def addr_rrf : ComplexPattern<iPTR, 2, "SelectAddrRRF", [], []>;
def addr_rif : ComplexPattern<iPTR, 2, "SelectAddrRIF", [], []>;
def addr_s : ComplexPattern<iPTR, 2, "SelectAddrS", [frameindex], []>;
//===----------------------------------------------------------------------===//
// C65 operand class definitions
//===----------------------------------------------------------------------===//
// Immediate operands
def imm8 : Operand<i8> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeImm8Operand";
let PrintMethod = "printImmOperand";
let ParserMatchClass = asmop_imm;
}
def imm16 : Operand<i16> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeImm16Operand";
let PrintMethod = "printImmOperand";
let ParserMatchClass = asmop_imm;
}
// Branch target operands
def brtarget_pcrel8 : Operand<OtherVT> {
let PrintMethod = "printPCRel8Operand";
let DecoderMethod = "decodePCRel8Operand";
let MIOperandInfo = (ops i8imm);
let ParserMatchClass = asmop_pcrel8;
}
def brtarget_pcrel16 : Operand<OtherVT> {
let PrintMethod = "printPCRel16Operand";
let DecoderMethod = "decodePCRel16Operand";
let MIOperandInfo = (ops i16imm);
let ParserMatchClass = asmop_pcrel16;
}
def brtarget_abs : Operand<OtherVT> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsOperand";
let PrintMethod = "printAbsOperand";
let ParserMatchClass = asmop_abs;
}
def brtarget_abspreix : Operand<OtherVT> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodePreIXOperand";
let PrintMethod = "printAbsPreIXOperand";
let ParserMatchClass = asmop_abspreix;
}
def brtarget_absind : Operand<OtherVT> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsIndOperand";
let PrintMethod = "printAbsIndOperand";
let ParserMatchClass = asmop_absind;
}
def brtarget_absindl : Operand<OtherVT> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsIndLOperand";
let PrintMethod = "printAbsIndLOperand";
let ParserMatchClass = asmop_absindl;
}
def brtarget_absl : Operand<OtherVT> {
let MIOperandInfo = (ops i32imm);
let DecoderMethod = "decodeAbsLOperand";
let PrintMethod = "printAbsLOperand";
let ParserMatchClass = asmop_absl;
}
// Memory operands
def mem_abs : Operand<iPTR> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsOperand";
let PrintMethod = "printAbsOperand";
let ParserMatchClass = asmop_abs;
}
def mem_absx : Operand<iPTR> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsXOperand";
let PrintMethod = "printAbsXOperand";
let ParserMatchClass = asmop_absx;
}
def mem_absy : Operand<iPTR> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsYOperand";
let PrintMethod = "printAbsYOperand";
let ParserMatchClass = asmop_absy;
}
def mem_abspreix : Operand<iPTR> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodePreIXOperand";
let PrintMethod = "printAbsPreIXOperand";
let ParserMatchClass = asmop_abspreix;
}
def mem_absind : Operand<iPTR> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsIndOperand";
let PrintMethod = "printAbsIndOperand";
let ParserMatchClass = asmop_absind;
}
def mem_absindl : Operand<iPTR> {
let MIOperandInfo = (ops i16imm);
let DecoderMethod = "decodeAbsIndLOperand";
let PrintMethod = "printAbsIndLOperand";
let ParserMatchClass = asmop_absindl;
}
def mem_absl : Operand<iPTR> {
let MIOperandInfo = (ops i32imm);
let DecoderMethod = "decodeAbsLOperand";
let PrintMethod = "printAbsLOperand";
let ParserMatchClass = asmop_absl;
}
def mem_absxl : Operand<iPTR> {
let MIOperandInfo = (ops i32imm);
let DecoderMethod = "decodeAbsXLOperand";
let PrintMethod = "printAbsXLOperand";
let ParserMatchClass = asmop_absxl;
}
def mem_zp : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeZPOperand";
let PrintMethod = "printZPOperand";
let ParserMatchClass = asmop_zp;
}
def mem_zpx : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeZPXOperand";
let PrintMethod = "printZPXOperand";
let ParserMatchClass = asmop_zpx;
}
def mem_zpy : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeZPYOperand";
let PrintMethod = "printZPYOperand";
let ParserMatchClass = asmop_zpy;
}
def mem_zppreix : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeZPPreIXOperand";
let PrintMethod = "printZPPreIXOperand";
let ParserMatchClass = asmop_zppreix;
}
def mem_zpind : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeZPIndOperand";
let PrintMethod = "printZPIndOperand";
let ParserMatchClass = asmop_zpind;
}
def mem_dpindl : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeDPIndLOperand";
let PrintMethod = "printDPIndLOperand";
let ParserMatchClass = asmop_dpindl;
}
def mem_zppostiy : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeZPPostIYOperand";
let PrintMethod = "printZPPostIYOperand";
let ParserMatchClass = asmop_zppostiy;
}
def mem_dppostiyl : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeDPPostIYLOperand";
let PrintMethod = "printDPPostIYLOperand";
let ParserMatchClass = asmop_dppostiyl;
}
def mem_srel : Operand<iPTR> {
let MIOperandInfo = (ops i8imm, i8imm);
let DecoderMethod = "decodeSRelOperand";
let PrintMethod = "printSRelOperand";
let ParserMatchClass = asmop_srel;
}
def mem_spostiy : Operand<iPTR> {
let MIOperandInfo = (ops i8imm);
let DecoderMethod = "decodeSPostIYOperand";
let PrintMethod = "printSPostIYOperand";
let ParserMatchClass = asmop_spostiy;
}
// Zero-page register memory operands
def mem_ri : Operand<iPTR> {
let MIOperandInfo = (ops ZRC16, i16imm);
}
def mem_rr : Operand<iPTR> {
let MIOperandInfo = (ops ZRC16, ZRC16);
}
def mem_rif : Operand<iPTR> {
let MIOperandInfo = (ops ZRC32, i16imm);
}
def mem_rrf : Operand<iPTR> {
let MIOperandInfo = (ops ZRC32, ZRC16);
}
//===----------------------------------------------------------------------===//
// Format 01 instructions : ora, and, eor, adc, sta, lda, cmp, sbc
//===----------------------------------------------------------------------===//
class F01<bits<3> op, bits<3> addrmode, dag outs, dag ins,
string asmstr, list<dag> pattern>
: Fcc<op, addrmode, 0b01, outs, ins, asmstr, pattern> {
let hasSideEffects = 1;
}
multiclass F01_noimm_sized<bits<3> op, string asmstr,
list<Predicate> preds = []> {
let Predicates = preds in {
def zp : F01<op, 0b001, (outs), (ins mem_zp:$addr),
!strconcat(asmstr, " $addr"), []>, OpSize8;
def abs : F01<op, 0b011, (outs), (ins mem_abs:$addr),
!strconcat(asmstr, " $addr"), []>, OpSize16;
}
let Predicates = !listconcat(preds, [IsIx8Bit]) in {
def zppreix8 : F01<op, 0b000, (outs), (ins mem_zppreix:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8;
def zppostiy8 : F01<op, 0b100, (outs), (ins mem_zppostiy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8;
def zpx8 : F01<op, 0b101, (outs), (ins mem_zpx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8;
def absy8 : F01<op, 0b110, (outs), (ins mem_absy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize16;
def absx8 : F01<op, 0b111, (outs), (ins mem_absx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize16;
}
let Predicates = !listconcat(preds, [IsIx16Bit]) in {
def zppreix16 : F01<op, 0b000, (outs), (ins mem_zppreix:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8;
def zppostiy16 : F01<op, 0b100, (outs), (ins mem_zppostiy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8;
def zpx16 : F01<op, 0b101, (outs), (ins mem_zpx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8;
def absy16 : F01<op, 0b110, (outs), (ins mem_absy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize16;
def absx16 : F01<op, 0b111, (outs), (ins mem_absx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize16;
}
}
multiclass F01_noimm<bits<3> op, string asmstr> {
defm NAME#8 : F01_noimm_sized<op, asmstr, [IsAcc8Bit]>, Acc8Bit;
defm NAME#16 : F01_noimm_sized<op, asmstr, [IsAcc16Bit]>, Acc16Bit;
}
multiclass F01_all<bits<3> op, string asmstr>
: F01_noimm<op, asmstr> {
def NAME#8imm : F01<op, 0b010, (outs), (ins imm8:$imm),
!strconcat(asmstr, " $imm"), []>, Acc8Bit, OpSize8,
Requires<[IsAcc8Bit]>;
def NAME#16imm : F01<op, 0b010, (outs), (ins imm16:$imm),
!strconcat(asmstr, " $imm"), []>, Acc16Bit, OpSize16,
Requires<[IsAcc16Bit]>;
}
defm ORA : F01_all<0b000, "ora">;
defm AND : F01_all<0b001, "and">;
defm EOR : F01_all<0b010, "eor">;
defm ADC : F01_all<0b011, "adc">;
defm STA : F01_noimm<0b100, "sta">;
defm LDA : F01_all<0b101, "lda">;
defm CMP : F01_all<0b110, "cmp">;
defm SBC : F01_all<0b111, "sbc">;
//===----------------------------------------------------------------------===//
// Format 10 instructions : asl, rol, lsr, ror, stx, ldx, dec, inc
//===----------------------------------------------------------------------===//
class F10<bits<3> op, bits<3> addrmode, dag outs, dag ins,
string asmstr, list<dag> pattern>
: Fcc<op, addrmode, 0b10, outs, ins, asmstr, pattern> {
let hasSideEffects = 1;
}
multiclass F10_acc<bits<3> op, string asmstr> {
def NAME#8acc : F10<op, 0b010, (outs), (ins),
!strconcat(asmstr, "a"), []>, Acc8Bit,
Requires<[IsAcc8Bit]>;
def NAME#16acc : F10<op, 0b010, (outs), (ins),
!strconcat(asmstr, "a"), []>, Acc16Bit,
Requires<[IsAcc16Bit]>;
}
multiclass F10_zp_abs_sized<bits<3> op, string asmstr> {
def zp : F10<op, 0b001, (outs), (ins mem_zp:$addr),
!strconcat(asmstr, " $addr"), []>, OpSize8;
def abs : F10<op, 0b011, (outs), (ins mem_abs:$addr),
!strconcat(asmstr, " $addr"), []>, OpSize16;
}
multiclass F10_zp_abs<bits<3> op, string asmstr> {
let Predicates = [IsAcc8Bit] in
defm NAME#8 : F10_zp_abs_sized<op, asmstr>, Acc8Bit;
let Predicates = [IsAcc16Bit] in
defm NAME#16 : F10_zp_abs_sized<op, asmstr>, Acc16Bit;
}
multiclass F10_zpx_absx_sized<bits<3> op, string asmstr,
list<Predicate> preds> {
let Predicates = !listconcat(preds, [IsIx8Bit]) in {
def zpx8 : F10<op, 0b101, (outs), (ins mem_zpx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8;
def absx8 : F10<op, 0b111, (outs), (ins mem_absx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize16;
}
let Predicates = !listconcat(preds, [IsIx16Bit]) in {
def zpx16 : F10<op, 0b101, (outs), (ins mem_zpx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8;
def absx16 : F10<op, 0b111, (outs), (ins mem_absx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize16;
}
}
multiclass F10_zpx_absx<bits<3> op, string asmstr> {
defm NAME#8 : F10_zpx_absx_sized<op, asmstr, [IsAcc8Bit]>, Acc8Bit;
defm NAME#16 : F10_zpx_absx_sized<op, asmstr, [IsAcc16Bit]>, Acc16Bit;
}
multiclass F10_zpy_sized<bits<3> op, string asmstr,
list<Predicate> preds> {
let Predicates = !listconcat(preds, [IsIx8Bit]) in
def zpy8 : F10<op, 0b101, (outs), (ins mem_zpy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8;
let Predicates = !listconcat(preds, [IsIx16Bit]) in
def zpy16 : F10<op, 0b101, (outs), (ins mem_zpy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8;
}
multiclass F10_zpy<bits<3> op, string asmstr> {
defm NAME#8 : F10_zpy_sized<op, asmstr, [IsAcc8Bit]>, Acc8Bit;
defm NAME#16 : F10_zpy_sized<op, asmstr, [IsAcc16Bit]>, Acc16Bit;
}
multiclass F10_absy_sized<bits<3> op, string asmstr,
list<Predicate> preds> {
let Predicates = !listconcat(preds, [IsIx8Bit]) in
def absy8 : F10<op, 0b111, (outs), (ins mem_absy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize16;
let Predicates = !listconcat(preds, [IsIx16Bit]) in
def absy16 : F10<op, 0b111, (outs), (ins mem_absy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize16;
}
multiclass F10_absy<bits<3> op, string asmstr> {
defm NAME#8 : F10_absy_sized<op, asmstr, [IsAcc8Bit]>, Acc8Bit;
defm NAME#16 : F10_absy_sized<op, asmstr, [IsAcc16Bit]>, Acc16Bit;
}
defm ASL : F10_acc<0b000, "asl">;
defm ASL : F10_zp_abs<0b000, "asl">;
defm ASL : F10_zpx_absx<0b000, "asl">;
defm ROL : F10_acc<0b001, "rol">;
defm ROL : F10_zp_abs<0b001, "rol">;
defm ROL : F10_zpx_absx<0b001, "rol">;
defm LSR : F10_acc<0b010, "lsr">;
defm LSR : F10_zp_abs<0b010, "lsr">;
defm LSR : F10_zpx_absx<0b010, "lsr">;
defm ROR : F10_acc<0b011, "ror">;
defm ROR : F10_zp_abs<0b011, "ror">;
defm ROR : F10_zpx_absx<0b011, "ror">;
defm STX : F10_zp_abs<0b100, "stx">;
defm STX : F10_zpy<0b100, "stx">;
def LDX8imm : F10<0b101, 0b000, (outs), (ins imm8:$imm),
"ldx $imm", []>, Ix8Bit, OpSize8,
Requires<[IsIx8Bit]>;
def LDX16imm : F10<0b101, 0b000, (outs), (ins imm16:$imm),
"ldx $imm", []>, Ix16Bit, OpSize16,
Requires<[IsIx16Bit]>;
defm LDX : F10_zp_abs<0b101, "ldx">;
defm LDX : F10_zpy<0b101, "ldx">;
defm LDX : F10_absy<0b101, "ldx">;
defm DEC : F10_zp_abs<0b110, "dec">;
defm DEC : F10_zpx_absx<0b110, "dec">;
defm INC : F10_zp_abs<0b111, "inc">;
defm INC : F10_zpx_absx<0b111, "inc">;
// 65C02 added addressing modes for ora, and, eor, adc, sta, lda, cmp, sbc
multiclass F10_zpind<bits<3> op, string asmstr> {
def NAME#8zpind : F10<op, 0b100, (outs), (ins mem_zpind:$addr),
!strconcat(asmstr, " $addr"), []>, Acc8Bit, OpSize8,
Requires<[Has65C02, IsAcc8Bit]>;
def NAME#16zpind : F10<op, 0b100, (outs), (ins mem_zpind:$addr),
!strconcat(asmstr, " $addr"), []>, Acc16Bit, OpSize8,
Requires<[Has65C02, IsAcc16Bit]>;
}
defm ORA : F10_zpind<0b000, "ora">;
defm AND : F10_zpind<0b001, "and">;
defm EOR : F10_zpind<0b010, "eor">;
defm ADC : F10_zpind<0b011, "adc">;
defm STA : F10_zpind<0b100, "sta">;
defm LDA : F10_zpind<0b101, "lda">;
defm CMP : F10_zpind<0b110, "cmp">;
defm SBC : F10_zpind<0b111, "sbc">;
//===----------------------------------------------------------------------===//
// Format 00 instructions : bit, (jmp), sty, ldy, cpy, cpx
//===----------------------------------------------------------------------===//
class F00<bits<3> op, bits<3> addrmode, dag outs, dag ins,
string asmstr, list<dag> pattern>
: Fcc<op, addrmode, 0b00, outs, ins, asmstr, pattern> {
let hasSideEffects = 1;
}
multiclass F00_imm<bits<3> op, string asmstr> {
def NAME#8imm : F00<op, 0b000, (outs), (ins imm8:$imm),
!strconcat(asmstr, " $imm"), []>, Ix8Bit, OpSize8,
Requires<[IsIx8Bit]>;
def NAME#16imm : F00<op, 0b000, (outs), (ins imm16:$imm),
!strconcat(asmstr, " $imm"), []>, Ix16Bit, OpSize16,
Requires<[IsIx16Bit]>;
}
multiclass F00_zp_abs<bits<3> op, string asmstr> {
def NAME#8zp : F00<op, 0b001, (outs), (ins mem_zp:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8,
Requires<[IsIx8Bit]>;
def NAME#8abs : F00<op, 0b011, (outs), (ins mem_abs:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize16,
Requires<[IsIx8Bit]>;
def NAME#16zp : F00<op, 0b001, (outs), (ins mem_zp:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8,
Requires<[IsIx16Bit]>;
def NAME#16abs : F00<op, 0b011, (outs), (ins mem_abs:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize16,
Requires<[IsIx16Bit]>;
}
multiclass F00_zpx<bits<3> op, string asmstr> {
def NAME#8zpx : F00<op, 0b101, (outs), (ins mem_zpx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8,
Requires<[IsIx8Bit]>;
def NAME#16zpx : F00<op, 0b101, (outs), (ins mem_zpx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8,
Requires<[IsIx16Bit]>;
}
multiclass F00_absx<bits<3> op, string asmstr> {
def NAME#8absx : F00<op, 0b111, (outs), (ins mem_absx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize16,
Requires<[IsIx8Bit]>;
def NAME#16absx : F00<op, 0b111, (outs), (ins mem_absx:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize16,
Requires<[IsIx16Bit]>;
}
// The F00 multiclasses above are only for index registers. Since BIT
// uses the accumulator, we cannot use them.
def BIT8zp : F00<0b001, 0b001, (outs), (ins mem_zp:$addr),
"bit $addr", []>, Acc8Bit, OpSize8,
Requires<[IsAcc8Bit]>;
def BIT16zp : F00<0b001, 0b001, (outs), (ins mem_zp:$addr),
"bit $addr", []>, Acc16Bit, OpSize8,
Requires<[IsAcc16Bit]>;
def BIT8abs : F00<0b001, 0b011, (outs), (ins mem_abs:$addr),
"bit $addr", []>, Acc8Bit, OpSize16,
Requires<[IsAcc8Bit]>;
def BIT16abs : F00<0b001, 0b011, (outs), (ins mem_abs:$addr),
"bit $addr", []>, Acc16Bit, OpSize16,
Requires<[IsAcc16Bit]>;
defm STY : F00_zp_abs<0b100, "sty">;
defm STY : F00_zpx<0b100, "sty">;
defm LDY : F00_imm<0b101, "ldy">;
defm LDY : F00_zp_abs<0b101, "ldy">;
defm LDY : F00_zpx<0b101, "ldy">;
defm LDY : F00_absx<0b101, "ldy">;
defm CPY : F00_imm<0b110, "cpy">;
defm CPY : F00_zp_abs<0b110, "cpy">;
defm CPX : F00_imm<0b111, "cpx">;
defm CPX : F00_zp_abs<0b111, "cpx">;
//===----------------------------------------------------------------------===//
// Format 11 instructions : Extended ora, and, eor, adc, sta, lda, cmp, sbc
//===----------------------------------------------------------------------===//
class F11<bits<3> op, bits<3> addrmode, dag outs, dag ins,
string asmstr, list<dag> pattern>
: Fcc<op, addrmode, 0b11, outs, ins, asmstr, pattern> {
let hasSideEffects = 1;
}
multiclass F11_binary_sized<bits<3> op, string asmstr,
list<Predicate> preds> {
let Predicates = preds in
def srel : F11<op, 0b000, (outs), (ins mem_srel:$addr),
!strconcat(asmstr, " $addr"), []>, OpSize8;
let Predicates = !listconcat(preds, [IsIx8Bit]) in
def spostiy8 : F11<op, 0b100, (outs), (ins mem_spostiy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8;
let Predicates = !listconcat(preds, [IsIx16Bit]) in
def spostiy16 : F11<op, 0b100, (outs), (ins mem_spostiy:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8;
let Predicates = !listconcat(preds, [Has65816]) in {
def absl : F11<op, 0b011, (outs), (ins mem_absl:$addr),
!strconcat(asmstr, " $addr"), []>, OpSize24;
def dpindl : F11<op, 0b001, (outs), (ins mem_dpindl:$addr),
!strconcat(asmstr, " $addr"), []>, OpSize8;
}
let Predicates = !listconcat(preds, [Has65816, IsIx8Bit]) in {
def dppostiyl8 : F11<op, 0b101, (outs), (ins mem_dppostiyl:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize8;
def absxl8 : F11<op, 0b111, (outs), (ins mem_absxl:$addr),
!strconcat(asmstr, " $addr"), []>, Ix8Bit, OpSize24;
}
let Predicates = !listconcat(preds, [Has65816, IsIx16Bit]) in {
def dppostiyl16 : F11<op, 0b101, (outs), (ins mem_dppostiyl:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize8;
def absxl16 : F11<op, 0b111, (outs), (ins mem_absxl:$addr),
!strconcat(asmstr, " $addr"), []>, Ix16Bit, OpSize24;
}
}
multiclass F11_binary<bits<3> op, string asmstr> {
defm NAME#8 : F11_binary_sized<op, asmstr, [Has65802, IsAcc8Bit]>, Acc8Bit;
defm NAME#16 : F11_binary_sized<op, asmstr, [Has65802, IsAcc16Bit]>, Acc16Bit;
}
defm ORA : F11_binary<0b000, "ora">;
defm AND : F11_binary<0b001, "and">;
defm EOR : F11_binary<0b010, "eor">;
defm ADC : F11_binary<0b011, "adc">;
defm STA : F11_binary<0b100, "sta">;
defm LDA : F11_binary<0b101, "lda">;
defm CMP : F11_binary<0b110, "cmp">;
defm SBC : F11_binary<0b111, "sbc">;
//===----------------------------------------------------------------------===//
// Conditional branch instructions : bpl, bmi, bvc, bvs, bcc, bcs, bne, beq
//===----------------------------------------------------------------------===//
class CondFlag<bits<2> ix> { bits<2> flagIndex = ix; }
def CondNegative : CondFlag<0b00>;
def CondOverflow : CondFlag<0b01>;
def CondCarry : CondFlag<0b10>;
def CondZero : CondFlag<0b11>;
// Branch if the value of the flag 'cf' equals 'value'
class FC<CondFlag cf, bit value, string asmstr>
: InstC65<(outs), (ins brtarget_pcrel8:$dst),
!strconcat(asmstr, " $dst"), []>, OpSize8, OpPCRel {
let Inst{7-6} = cf.flagIndex;
let Inst{5} = value;
let Inst{4-0} = 0b10000;
let isBranch = 1;
let isTerminator = 1;
}
let Uses = [P] in {
def BPL : FC<CondNegative, 0, "bpl">;
def BMI : FC<CondNegative, 1, "bmi">;
def BVC : FC<CondOverflow, 0, "bvc">;
def BVS : FC<CondOverflow, 1, "bvs">;
def BCC : FC<CondCarry, 0, "bcc">;
def BCS : FC<CondCarry, 1, "bcs">;
def BNE : FC<CondZero, 0, "bne">;
def BEQ : FC<CondZero, 1, "beq">;
}
//===----------------------------------------------------------------------===//
// Free format instructions
//===----------------------------------------------------------------------===//
class FF<bits<8> op, dag outs, dag ins,
string asmstr, list<dag> pattern>
: InstC65<outs, ins, asmstr, pattern> {
let Inst = op;
let hasSideEffects = 1;
}
def NOP : FF<0xea, (outs), (ins), "nop", []>;
def BIT8imm : FF<0x89, (outs), (ins imm8:$imm), "bit $imm", []>,
Acc8Bit, OpSize8,
Requires<[Has65C02, IsAcc8Bit]>;
def BIT16imm : FF<0x89, (outs), (ins imm16:$imm), "bit $imm", []>,
Acc16Bit, OpSize16,
Requires<[Has65C02, IsAcc16Bit]>;
def BIT8zpx8 : FF<0x34, (outs), (ins mem_zpx:$addr), "bit $addr", []>,
Acc8Bit, Ix8Bit, OpSize8,
Requires<[Has65C02, IsAcc8Bit, IsIx8Bit]>;
def BIT8zpx16 : FF<0x34, (outs), (ins mem_zpx:$addr), "bit $addr", []>,
Acc8Bit, Ix16Bit, OpSize8,
Requires<[Has65C02, IsAcc8Bit, IsIx16Bit]>;
def BIT16zpx8 : FF<0x34, (outs), (ins mem_zpx:$addr), "bit $addr", []>,
Acc16Bit, Ix8Bit, OpSize8,
Requires<[Has65C02, IsAcc16Bit, IsIx8Bit]>;
def BIT16zpx16 : FF<0x34, (outs), (ins mem_zpx:$addr), "bit $addr", []>,
Acc16Bit, Ix16Bit, OpSize8,
Requires<[Has65C02, IsAcc16Bit, IsIx16Bit]>;
def BIT8absx8 : FF<0x3c, (outs), (ins mem_absx:$addr), "bit $addr", []>,
Acc8Bit, Ix8Bit, OpSize16,
Requires<[Has65C02, IsAcc8Bit, IsIx8Bit]>;
def BIT8absx16 : FF<0x3c, (outs), (ins mem_absx:$addr), "bit $addr", []>,
Acc8Bit, Ix16Bit, OpSize16,
Requires<[Has65C02, IsAcc8Bit, IsIx16Bit]>;
def BIT16absx8 : FF<0x3c, (outs), (ins mem_absx:$addr), "bit $addr", []>,
Acc16Bit, Ix8Bit, OpSize16,
Requires<[Has65C02, IsAcc16Bit, IsIx8Bit]>;
def BIT16absx16 : FF<0x3c, (outs), (ins mem_absx:$addr), "bit $addr", []>,
Acc16Bit, Ix16Bit, OpSize16,
Requires<[Has65C02, IsAcc16Bit, IsIx16Bit]>;
def STZ8zp : FF<0x64, (outs), (ins mem_zp:$addr), "stz $addr", []>,
Acc8Bit, OpSize8,
Requires<[IsAcc8Bit]>;
def STZ8abs : FF<0x9c, (outs), (ins mem_abs:$addr), "stz $addr", []>,
Acc8Bit, OpSize16,
Requires<[IsAcc8Bit]>;
def STZ16zp : FF<0x64, (outs), (ins mem_zp:$addr), "stz $addr", []>,
Acc16Bit, OpSize8,
Requires<[IsAcc16Bit]>;
def STZ16abs : FF<0x9c, (outs), (ins mem_abs:$addr), "stz $addr", []>,
Acc16Bit, OpSize16,
Requires<[IsAcc16Bit]>;
def STZ8zpx8 : FF<0x74, (outs), (ins mem_zpx:$addr), "stz $addr", []>,
Acc8Bit, Ix8Bit, OpSize8,
Requires<[Has65802, IsAcc8Bit, IsIx8Bit]>;
def STZ8zpx16 : FF<0x74, (outs), (ins mem_zpx:$addr), "stz $addr", []>,
Acc8Bit, Ix16Bit, OpSize8,
Requires<[Has65802, IsAcc8Bit, IsIx16Bit]>;
def STZ16zpx8 : FF<0x74, (outs), (ins mem_zpx:$addr), "stz $addr", []>,
Acc16Bit, Ix8Bit, OpSize8,
Requires<[Has65802, IsAcc16Bit, IsIx8Bit]>;
def STZ16zpx16 : FF<0x74, (outs), (ins mem_zpx:$addr), "stz $addr", []>,
Acc16Bit, Ix16Bit, OpSize8,
Requires<[Has65802, IsAcc16Bit, IsIx16Bit]>;
def STZ8absx8 : FF<0x9e, (outs), (ins mem_absx:$addr), "stz $addr", []>,
Acc8Bit, Ix8Bit, OpSize16,
Requires<[Has65802, IsAcc8Bit, IsIx8Bit]>;
def STZ8absx16 : FF<0x9e, (outs), (ins mem_absx:$addr), "stz $addr", []>,
Acc8Bit, Ix16Bit, OpSize16,
Requires<[Has65802, IsAcc8Bit, IsIx16Bit]>;
def STZ16absx8 : FF<0x9e, (outs), (ins mem_absx:$addr), "stz $addr", []>,
Acc16Bit, Ix8Bit, OpSize16,
Requires<[Has65802, IsAcc16Bit, IsIx8Bit]>;
def STZ16absx16 : FF<0x9e, (outs), (ins mem_absx:$addr), "stz $addr", []>,
Acc16Bit, Ix16Bit, OpSize16,
Requires<[Has65802, IsAcc16Bit, IsIx16Bit]>;
def PHA8 : FF<0x48, (outs), (ins), "pha", []>, Acc8Bit,
Requires<[IsAcc8Bit]>;
def PLA8 : FF<0x68, (outs), (ins), "pla", []>, Acc8Bit,
Requires<[IsAcc8Bit]>;
def PHX8 : FF<0xda, (outs), (ins), "phx", []>, Ix8Bit,
Requires<[IsIx8Bit]>;
def PLX8 : FF<0xfa, (outs), (ins), "plx", []>, Ix8Bit,
Requires<[IsIx8Bit]>;
def PHY8 : FF<0x5a, (outs), (ins), "phy", []>, Ix8Bit,
Requires<[IsIx8Bit]>;
def PLY8 : FF<0x7a, (outs), (ins), "ply", []>, Ix8Bit,
Requires<[IsIx8Bit]>;
def PHA16 : FF<0x48, (outs), (ins), "pha", []>, Acc16Bit,
Requires<[IsAcc16Bit]>;
def PLA16 : FF<0x68, (outs), (ins), "pla", []>, Acc16Bit,
Requires<[IsAcc16Bit]>;
def PHX16 : FF<0xda, (outs), (ins), "phx", []>, Ix16Bit,
Requires<[IsIx16Bit]>;
def PLX16 : FF<0xfa, (outs), (ins), "plx", []>, Ix16Bit,
Requires<[IsIx16Bit]>;
def PHY16 : FF<0x5a, (outs), (ins), "phy", []>, Ix16Bit,
Requires<[IsIx16Bit]>;
def PLY16 : FF<0x7a, (outs), (ins), "ply", []>, Ix16Bit,
Requires<[IsIx16Bit]>;
def PHP : FF<0x08, (outs), (ins), "php", []>;
def PLP : FF<0x28, (outs), (ins), "plp", []>;
def PHD : FF<0x0b, (outs), (ins), "phd", []>, Requires<[Has65802]>;
def PLD : FF<0x2b, (outs), (ins), "pld", []>, Requires<[Has65802]>;
def PHK : FF<0x4b, (outs), (ins), "phk", []>, Requires<[Has65816]>;
def RTL : FF<0x6b, (outs), (ins), "rtl", []>, Requires<[Has65816]>;
def PHB : FF<0x8b, (outs), (ins), "phb", []>, Requires<[Has65816]>;
def PLB : FF<0xab, (outs), (ins), "plb", []>, Requires<[Has65816]>;
def PEA : FF<0xf4, (outs), (ins mem_abs:$addr), "pea $addr", []>,
OpSize16, Requires<[Has65802]>;