@@ -255,8 +255,6 @@ multiclass RMm<string opcStr, bits<8>opc,
255
255
}
256
256
}
257
257
258
- // Multiclass for RR type instructions
259
-
260
258
multiclass RRmrr<string opcStr, bits<8>opc,
261
259
RegisterClass RCo, ValueType Tyo,
262
260
RegisterClass RCi, ValueType Tyi,
@@ -279,6 +277,16 @@ multiclass RRmri<string opcStr, bits<8>opc,
279
277
{ let cy = 0; let cz = 1; let hasSideEffects = 0; }
280
278
}
281
279
280
+ multiclass RRmir<string opcStr, bits<8>opc,
281
+ RegisterClass RCo, ValueType Tyo,
282
+ RegisterClass RCi, ValueType Tyi, Operand immOp,
283
+ SDPatternOperator OpNode=null_frag> {
284
+ def ri : RR<opc, (outs RCo:$sx), (ins immOp:$sy, RCi:$sz),
285
+ !strconcat(opcStr, " $sx, $sy, $sz"),
286
+ [(set Tyo:$sx, (OpNode (Tyi simm7:$sy), Tyi:$sz))]>
287
+ { let cy = 0; let cz = 1; let hasSideEffects = 0; }
288
+ }
289
+
282
290
multiclass RRmiz<string opcStr, bits<8>opc,
283
291
RegisterClass RCo, ValueType Tyo,
284
292
RegisterClass RCi, ValueType Tyi, Operand immOp,
@@ -324,7 +332,8 @@ multiclass RRNDmim<string opcStr, bits<8>opc,
324
332
// Used by add, mul, div, and similar commutative instructions
325
333
// The order of operands are "$sx, $sy, $sz"
326
334
327
- multiclass RRm<string opcStr, bits<8>opc, RegisterClass RC, ValueType Ty,
335
+ multiclass RRm<string opcStr, bits<8>opc,
336
+ RegisterClass RC, ValueType Ty,
328
337
Operand immOp, Operand immOp2,
329
338
SDPatternOperator OpNode=null_frag> :
330
339
RRmrr<opcStr, opc, RC, Ty, RC, Ty, OpNode>,
@@ -333,13 +342,34 @@ multiclass RRm<string opcStr, bits<8>opc, RegisterClass RC, ValueType Ty,
333
342
RRNDmrm<opcStr, opc, RC, Ty, RC, Ty, immOp2>,
334
343
RRNDmim<opcStr, opc, RC, Ty, RC, Ty, immOp, immOp2>;
335
344
345
+ // Used by sub, and similar not commutative instructions
346
+ // The order of operands are "$sx, $sy, $sz"
347
+
348
+ multiclass RRNCm<string opcStr, bits<8>opc,
349
+ RegisterClass RC, ValueType Ty, Operand immOp, Operand immOp2,
350
+ SDPatternOperator OpNode=null_frag> :
351
+ RRmrr<opcStr, opc, RC, Ty, RC, Ty, OpNode>,
352
+ RRmir<opcStr, opc, RC, Ty, RC, Ty, immOp, OpNode>,
353
+ RRmiz<opcStr, opc, RC, Ty, RC, Ty, immOp, OpNode>,
354
+ RRNDmrm<opcStr, opc, RC, Ty, RC, Ty, immOp2>,
355
+ RRNDmim<opcStr, opc, RC, Ty, RC, Ty, immOp, immOp2>;
336
356
337
357
// Multiclass for RR type instructions
338
358
// Used by sra, sla, sll, and similar instructions
339
359
// The order of operands are "$sx, $sz, $sy"
340
360
341
- multiclass RRIm<string opcStr, bits<8>opc, SDNode OpNode,
342
- RegisterClass RC, ValueType Ty, Operand immOp, Operand immOp2> {
361
+ multiclass RRIm<string opcStr, bits<8>opc,
362
+ RegisterClass RC, ValueType Ty,
363
+ Operand immOp, Operand immOp2,
364
+ SDPatternOperator OpNode=null_frag> {
365
+ def rr : RR<
366
+ opc, (outs RC:$sx), (ins RC:$sz, I32:$sy),
367
+ !strconcat(opcStr, " $sx, $sz, $sy"),
368
+ [(set Ty:$sx, (OpNode Ty:$sz, i32:$sy))]> {
369
+ let cy = 1;
370
+ let cz = 1;
371
+ let hasSideEffects = 0;
372
+ }
343
373
def ri : RR<
344
374
opc, (outs RC:$sx), (ins RC:$sz, immOp:$sy),
345
375
!strconcat(opcStr, " $sx, $sz, $sy"),
@@ -348,6 +378,104 @@ multiclass RRIm<string opcStr, bits<8>opc, SDNode OpNode,
348
378
let cz = 1;
349
379
let hasSideEffects = 0;
350
380
}
381
+ def rm0 : RR<
382
+ opc, (outs RC:$sx), (ins immOp2:$sz, I32:$sy),
383
+ !strconcat(opcStr, " $sx, (${sz})0, $sy")> {
384
+ let cy = 1;
385
+ let cz = 0;
386
+ let sz{6} = 1;
387
+ let hasSideEffects = 0;
388
+ }
389
+ def rm1 : RR<
390
+ opc, (outs RC:$sx), (ins immOp2:$sz, I32:$sy),
391
+ !strconcat(opcStr, " $sx, (${sz})1, $sy")> {
392
+ let cy = 1;
393
+ let cz = 0;
394
+ let hasSideEffects = 0;
395
+ }
396
+ def im0 : RR<
397
+ opc, (outs RC:$sx), (ins immOp2:$sz, immOp:$sy),
398
+ !strconcat(opcStr, " $sx, (${sz})0, $sy")> {
399
+ let cy = 0;
400
+ let cz = 0;
401
+ let sz{6} = 1;
402
+ let hasSideEffects = 0;
403
+ }
404
+ def im1 : RR<
405
+ opc, (outs RC:$sx), (ins immOp2:$sz, immOp:$sy),
406
+ !strconcat(opcStr, " $sx, (${sz})1, $sy")> {
407
+ let cy = 0;
408
+ let cz = 0;
409
+ let hasSideEffects = 0;
410
+ }
411
+ def zi : RR<
412
+ opc, (outs RC:$sx), (ins immOp:$sy),
413
+ !strconcat(opcStr, " $sx, $sy"),
414
+ [(set Ty:$sx, (OpNode 0, (i32 simm7:$sy)))]> {
415
+ let cy = 0;
416
+ let cz = 0;
417
+ let sz = 0;
418
+ let hasSideEffects = 0;
419
+ }
420
+ }
421
+
422
+ // Multiclass for RR type instructions without dag pattern
423
+ // Used by sra.w.zx, sla.w.zx, and others
424
+
425
+ multiclass RRINDm<string opcStr, bits<8>opc,
426
+ RegisterClass RC, ValueType Ty, Operand immOp, Operand immOp2> {
427
+ def rr : RR<
428
+ opc, (outs RC:$sx), (ins RC:$sz, I32:$sy),
429
+ !strconcat(opcStr, " $sx, $sz, $sy")> {
430
+ let cy = 1;
431
+ let cz = 1;
432
+ let hasSideEffects = 0;
433
+ }
434
+ def ri : RR<
435
+ opc, (outs RC:$sx), (ins RC:$sz, immOp:$sy),
436
+ !strconcat(opcStr, " $sx, $sz, $sy")> {
437
+ let cy = 0;
438
+ let cz = 1;
439
+ let hasSideEffects = 0;
440
+ }
441
+ def rm0 : RR<
442
+ opc, (outs RC:$sx), (ins immOp2:$sz, I32:$sy),
443
+ !strconcat(opcStr, " $sx, (${sz})0, $sy")> {
444
+ let cy = 1;
445
+ let cz = 0;
446
+ let sz{6} = 1;
447
+ let hasSideEffects = 0;
448
+ }
449
+ def rm1 : RR<
450
+ opc, (outs RC:$sx), (ins immOp2:$sz, I32:$sy),
451
+ !strconcat(opcStr, " $sx, (${sz})1, $sy")> {
452
+ let cy = 1;
453
+ let cz = 0;
454
+ let hasSideEffects = 0;
455
+ }
456
+ def im0 : RR<
457
+ opc, (outs RC:$sx), (ins immOp2:$sz, immOp:$sy),
458
+ !strconcat(opcStr, " $sx, (${sz})0, $sy")> {
459
+ let cy = 0;
460
+ let cz = 0;
461
+ let sz{6} = 1;
462
+ let hasSideEffects = 0;
463
+ }
464
+ def im1 : RR<
465
+ opc, (outs RC:$sx), (ins immOp2:$sz, immOp:$sy),
466
+ !strconcat(opcStr, " $sx, (${sz})1, $sy")> {
467
+ let cy = 0;
468
+ let cz = 0;
469
+ let hasSideEffects = 0;
470
+ }
471
+ def zi : RR<
472
+ opc, (outs RC:$sx), (ins immOp:$sy),
473
+ !strconcat(opcStr, " $sx, $sy")> {
474
+ let cy = 0;
475
+ let cz = 0;
476
+ let sz = 0;
477
+ let hasSideEffects = 0;
478
+ }
351
479
}
352
480
353
481
// Multiclass for RR type instructions
@@ -407,27 +535,49 @@ defm CMOVS : RRCMOVm<"cmov.s.${cf}", 0x3B, F32, f32, simm7Op64, uimm6Op32>;
407
535
408
536
// LEA and LEASL instruction (load 32 bit imm to low or high part)
409
537
let cx = 0 in
410
- defm LEA : RMm<"lea", 0x06, I64, i64, simm7Op64, simm32Op64>;
538
+ defm LEA : RMm<"lea", 0x06, I64, i64, simm7Op64, simm32Op64, add >;
411
539
let cx = 1 in
412
540
defm LEASL : RMm<"lea.sl", 0x06, I64, i64, simm7Op64, simm32Op64>;
413
541
let isCodeGenOnly = 1 in {
414
542
let cx = 0 in
415
- defm LEA32 : RMm<"lea", 0x06, I32, i32, simm7Op32, simm32Op32>;
543
+ defm LEA32 : RMm<"lea", 0x06, I32, i32, simm7Op32, simm32Op32, add >;
416
544
}
417
545
418
546
419
547
// 5.3.2.2. Fixed-Point Arithmetic Operation Instructions
420
548
549
+ // ADD instruction
550
+ let cx = 0 in
551
+ defm ADD : RRm<"addu.l", 0x48, I64, i64, simm7Op64, uimm6Op64>;
552
+ let cx = 1 in
553
+ defm ADDUW : RRm<"addu.w", 0x48, I32, i32, simm7Op32, uimm6Op32>;
554
+
421
555
// ADS instruction
422
556
let cx = 0 in
423
557
defm ADS : RRm<"adds.w.sx", 0x4A, I32, i32, simm7Op32, uimm6Op32, add>;
424
558
let cx = 1 in
425
- defm ADSU : RRm<"adds.w.zx", 0x4A, I32, i32, simm7Op32, uimm6Op32, add >;
559
+ defm ADSU : RRm<"adds.w.zx", 0x4A, I32, i32, simm7Op32, uimm6Op32>;
426
560
427
561
// ADX instruction
428
562
let cx = 0 in
429
563
defm ADX : RRm<"adds.l", 0x59, I64, i64, simm7Op64, uimm6Op64, add>;
430
564
565
+ // SUB instruction
566
+ let cx = 0 in
567
+ defm SUB : RRm<"subu.l", 0x58, I64, i64, simm7Op64, uimm6Op64>;
568
+ let cx = 1 in
569
+ defm SUBUW : RRm<"subu.w", 0x58, I32, i32, simm7Op32, uimm6Op32>;
570
+
571
+ // SBS instruction
572
+ let cx = 0 in
573
+ defm SBS : RRNCm<"subs.w.sx", 0x5A, I32, i32, simm7Op32, uimm6Op32, sub>;
574
+ let cx = 1 in
575
+ defm SBSU : RRm<"subs.w.zx", 0x5A, I32, i32, simm7Op32, uimm6Op32>;
576
+
577
+ // SBX instruction
578
+ let cx = 0 in
579
+ defm SBX : RRNCm<"subs.l", 0x5B, I64, i64, simm7Op64, uimm6Op64, sub>;
580
+
431
581
// CMP instruction
432
582
let cx = 0 in
433
583
defm CMP : RRm<"cmpu.l", 0x55, I64, i64, simm7Op64, uimm6Op64>;
@@ -463,6 +613,7 @@ let cx = 1, cw = 0 in defm CMSi :
463
613
let cx = 0 in {
464
614
defm AND : RRm<"and", 0x44, I64, i64, simm7Op64, uimm6Op64, and>;
465
615
defm OR : RRm<"or", 0x45, I64, i64, simm7Op64, uimm6Op64, or>;
616
+ defm XOR : RRm<"xor", 0x46, I64, i64, simm7Op64, uimm6Op64, xor>;
466
617
let isCodeGenOnly = 1 in {
467
618
defm AND32 : RRm<"and", 0x44, I32, i32, simm7Op32, uimm6Op32, and>;
468
619
defm OR32 : RRm<"or", 0x45, I32, i32, simm7Op32, uimm6Op32, or>;
@@ -474,15 +625,29 @@ let cx = 0 in {
474
625
// 5.3.2.4 Shift Instructions
475
626
476
627
let cx = 0 in
477
- defm SRAX : RRIm<"sra.l", 0x77, sra, I64, i64, simm7Op32, uimm6Op64>;
628
+ defm SRAX : RRIm<"sra.l", 0x77, I64, i64, simm7Op32, uimm6Op64, sra >;
478
629
let cx = 0 in
479
- defm SRA : RRIm<"sra.w.sx", 0x76, sra, I32, i32, simm7Op32, uimm6Op32>;
630
+ defm SRA : RRIm<"sra.w.sx", 0x76, I32, i32, simm7Op32, uimm6Op32, sra>;
631
+ let cx = 1 in
632
+ defm SRAU : RRINDm<"sra.w.zx", 0x76, I32, i32, simm7Op32, uimm6Op32>;
480
633
481
634
let cx = 0 in
482
- defm SLL : RRIm<"sll", 0x65, shl, I64, i64, simm7Op32, uimm6Op64>;
635
+ defm SLL : RRIm<"sll", 0x65, I64, i64, simm7Op32, uimm6Op64, shl >;
483
636
let cx = 0 in
484
- defm SLA : RRIm<"sla.w.sx", 0x66, shl, I32, i32, simm7Op32, uimm6Op32>;
637
+ defm SLA : RRIm<"sla.w.sx", 0x66, I32, i32, simm7Op32, uimm6Op32, shl>;
638
+ let cx = 1 in
639
+ defm SLAU : RRINDm<"sla.w.zx", 0x66, I32, i32, simm7Op32, uimm6Op32>;
640
+ let cx = 0 in
641
+ defm SRL : RRIm<"srl", 0x75, I64, i64, simm7Op32, uimm6Op64, srl>;
642
+
643
+ def : Pat<(i32 (srl i32:$src, (i32 simm7:$val))),
644
+ (EXTRACT_SUBREG (SRLri (ANDrm0 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
645
+ $src, sub_i32), 32), imm:$val), sub_i32)>;
646
+ def : Pat<(i32 (srl i32:$src, i32:$val)),
647
+ (EXTRACT_SUBREG (SRLrr (ANDrm0 (INSERT_SUBREG (i64 (IMPLICIT_DEF)),
648
+ $src, sub_i32), 32), $val), sub_i32)>;
485
649
650
+ // 5.3.2.5. Floating-point Arithmetic Operation Instructions
486
651
// FCP instruction
487
652
let cx = 0 in
488
653
defm FCP : RRm<"fcmp.d", 0x7E, I64, f64, simm7Op64, uimm6Op64>;
0 commit comments