12
12
13
13
// FIXME: Someone needs to smear multipattern goodness all over this file.
14
14
15
- let Defs = [EFLAGS] in {
15
+ let Defs = [EFLAGS], hasSideEffects = 0 in {
16
16
17
17
let Constraints = "$src1 = $dst" in {
18
18
let Uses = [CL], SchedRW = [WriteShiftCL] in {
@@ -50,9 +50,6 @@ def SHL64ri : RIi8<0xC1, MRM4r, (outs GR64:$dst),
50
50
[(set GR64:$dst, (shl GR64:$src1, (i8 imm:$src2)))]>;
51
51
} // isConvertibleToThreeAddress = 1
52
52
53
- // NOTE: We don't include patterns for shifts of a register by one, because
54
- // 'add reg,reg' is cheaper (and we have a Pat pattern for shift-by-one).
55
- let hasSideEffects = 0 in {
56
53
def SHL8r1 : I<0xD0, MRM4r, (outs GR8:$dst), (ins GR8:$src1),
57
54
"shl{b}\t$dst", []>;
58
55
def SHL16r1 : I<0xD1, MRM4r, (outs GR16:$dst), (ins GR16:$src1),
@@ -61,7 +58,6 @@ def SHL32r1 : I<0xD1, MRM4r, (outs GR32:$dst), (ins GR32:$src1),
61
58
"shl{l}\t$dst", []>, OpSize32;
62
59
def SHL64r1 : RI<0xD1, MRM4r, (outs GR64:$dst), (ins GR64:$src1),
63
60
"shl{q}\t$dst", []>;
64
- } // hasSideEffects = 0
65
61
} // SchedRW
66
62
} // Constraints = "$src = $dst"
67
63
@@ -85,7 +81,7 @@ def SHL64mCL : RI<0xD3, MRM4m, (outs), (ins i64mem:$dst),
85
81
Requires<[In64BitMode]>;
86
82
} // Uses, SchedRW
87
83
88
- let SchedRW = [WriteShiftLd, WriteRMW] in {
84
+ let SchedRW = [WriteShiftLd, WriteRMW], mayLoad = 1, mayStore = 1 in {
89
85
def SHL8mi : Ii8<0xC0, MRM4m, (outs), (ins i8mem :$dst, u8imm:$src),
90
86
"shl{b}\t{$src, $dst|$dst, $src}",
91
87
[(store (shl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
@@ -104,21 +100,14 @@ def SHL64mi : RIi8<0xC1, MRM4m, (outs), (ins i64mem:$dst, u8imm:$src),
104
100
105
101
// Shift by 1
106
102
def SHL8m1 : I<0xD0, MRM4m, (outs), (ins i8mem :$dst),
107
- "shl{b}\t$dst",
108
- [(store (shl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
103
+ "shl{b}\t$dst", []>;
109
104
def SHL16m1 : I<0xD1, MRM4m, (outs), (ins i16mem:$dst),
110
- "shl{w}\t$dst",
111
- [(store (shl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
112
- OpSize16;
105
+ "shl{w}\t$dst", []>, OpSize16;
113
106
def SHL32m1 : I<0xD1, MRM4m, (outs), (ins i32mem:$dst),
114
- "shl{l}\t$dst",
115
- [(store (shl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>,
116
- OpSize32;
107
+ "shl{l}\t$dst", []>, OpSize32;
117
108
def SHL64m1 : RI<0xD1, MRM4m, (outs), (ins i64mem:$dst),
118
- "shl{q}\t$dst",
119
- [(store (shl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>,
120
- Requires<[In64BitMode]>;
121
- } // SchedRW
109
+ "shl{q}\t$dst", []>, Requires<[In64BitMode]>;
110
+ } // SchedRW, mayLoad, mayStore
122
111
123
112
let Constraints = "$src1 = $dst" in {
124
113
let Uses = [CL], SchedRW = [WriteShiftCL] in {
@@ -154,17 +143,13 @@ def SHR64ri : RIi8<0xC1, MRM5r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$src2),
154
143
155
144
// Shift right by 1
156
145
def SHR8r1 : I<0xD0, MRM5r, (outs GR8:$dst), (ins GR8:$src1),
157
- "shr{b}\t$dst",
158
- [(set GR8:$dst, (srl GR8:$src1, (i8 1)))]>;
146
+ "shr{b}\t$dst", []>;
159
147
def SHR16r1 : I<0xD1, MRM5r, (outs GR16:$dst), (ins GR16:$src1),
160
- "shr{w}\t$dst",
161
- [(set GR16:$dst, (srl GR16:$src1, (i8 1)))]>, OpSize16;
148
+ "shr{w}\t$dst", []>, OpSize16;
162
149
def SHR32r1 : I<0xD1, MRM5r, (outs GR32:$dst), (ins GR32:$src1),
163
- "shr{l}\t$dst",
164
- [(set GR32:$dst, (srl GR32:$src1, (i8 1)))]>, OpSize32;
150
+ "shr{l}\t$dst", []>, OpSize32;
165
151
def SHR64r1 : RI<0xD1, MRM5r, (outs GR64:$dst), (ins GR64:$src1),
166
- "shr{q}\t$dst",
167
- [(set GR64:$dst, (srl GR64:$src1, (i8 1)))]>;
152
+ "shr{q}\t$dst", []>;
168
153
} // SchedRW
169
154
} // Constraints = "$src = $dst"
170
155
@@ -187,7 +172,7 @@ def SHR64mCL : RI<0xD3, MRM5m, (outs), (ins i64mem:$dst),
187
172
Requires<[In64BitMode]>;
188
173
} // Uses, SchedRW
189
174
190
- let SchedRW = [WriteShiftLd, WriteRMW] in {
175
+ let SchedRW = [WriteShiftLd, WriteRMW], mayLoad = 1, mayStore = 1 in {
191
176
def SHR8mi : Ii8<0xC0, MRM5m, (outs), (ins i8mem :$dst, u8imm:$src),
192
177
"shr{b}\t{$src, $dst|$dst, $src}",
193
178
[(store (srl (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
@@ -206,21 +191,15 @@ def SHR64mi : RIi8<0xC1, MRM5m, (outs), (ins i64mem:$dst, u8imm:$src),
206
191
207
192
// Shift by 1
208
193
def SHR8m1 : I<0xD0, MRM5m, (outs), (ins i8mem :$dst),
209
- "shr{b}\t$dst",
210
- [(store (srl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
194
+ "shr{b}\t$dst", []>;
211
195
def SHR16m1 : I<0xD1, MRM5m, (outs), (ins i16mem:$dst),
212
- "shr{w}\t$dst",
213
- [(store (srl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
214
- OpSize16;
196
+ "shr{w}\t$dst", []>, OpSize16;
215
197
def SHR32m1 : I<0xD1, MRM5m, (outs), (ins i32mem:$dst),
216
- "shr{l}\t$dst",
217
- [(store (srl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>,
218
- OpSize32;
198
+ "shr{l}\t$dst", []>, OpSize32;
219
199
def SHR64m1 : RI<0xD1, MRM5m, (outs), (ins i64mem:$dst),
220
- "shr{q}\t$dst",
221
- [(store (srl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>,
222
- Requires<[In64BitMode]>;
223
- } // SchedRW
200
+ "shr{q}\t$dst", []>, Requires<[In64BitMode]>;
201
+ } // SchedRW, mayLoad, mayStore
202
+
224
203
225
204
let Constraints = "$src1 = $dst" in {
226
205
let Uses = [CL], SchedRW = [WriteShiftCL] in {
@@ -259,17 +238,13 @@ def SAR64ri : RIi8<0xC1, MRM7r, (outs GR64:$dst),
259
238
260
239
// Shift by 1
261
240
def SAR8r1 : I<0xD0, MRM7r, (outs GR8 :$dst), (ins GR8 :$src1),
262
- "sar{b}\t$dst",
263
- [(set GR8:$dst, (sra GR8:$src1, (i8 1)))]>;
241
+ "sar{b}\t$dst", []>;
264
242
def SAR16r1 : I<0xD1, MRM7r, (outs GR16:$dst), (ins GR16:$src1),
265
- "sar{w}\t$dst",
266
- [(set GR16:$dst, (sra GR16:$src1, (i8 1)))]>, OpSize16;
243
+ "sar{w}\t$dst", []>, OpSize16;
267
244
def SAR32r1 : I<0xD1, MRM7r, (outs GR32:$dst), (ins GR32:$src1),
268
- "sar{l}\t$dst",
269
- [(set GR32:$dst, (sra GR32:$src1, (i8 1)))]>, OpSize32;
245
+ "sar{l}\t$dst", []>, OpSize32;
270
246
def SAR64r1 : RI<0xD1, MRM7r, (outs GR64:$dst), (ins GR64:$src1),
271
- "sar{q}\t$dst",
272
- [(set GR64:$dst, (sra GR64:$src1, (i8 1)))]>;
247
+ "sar{q}\t$dst", []>;
273
248
} // SchedRW
274
249
} // Constraints = "$src = $dst"
275
250
@@ -292,7 +267,7 @@ def SAR64mCL : RI<0xD3, MRM7m, (outs), (ins i64mem:$dst),
292
267
Requires<[In64BitMode]>;
293
268
} // Uses, SchedRW
294
269
295
- let SchedRW = [WriteShiftLd, WriteRMW] in {
270
+ let SchedRW = [WriteShiftLd, WriteRMW], mayLoad = 1, mayStore = 1 in {
296
271
def SAR8mi : Ii8<0xC0, MRM7m, (outs), (ins i8mem :$dst, u8imm:$src),
297
272
"sar{b}\t{$src, $dst|$dst, $src}",
298
273
[(store (sra (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
@@ -311,27 +286,19 @@ def SAR64mi : RIi8<0xC1, MRM7m, (outs), (ins i64mem:$dst, u8imm:$src),
311
286
312
287
// Shift by 1
313
288
def SAR8m1 : I<0xD0, MRM7m, (outs), (ins i8mem :$dst),
314
- "sar{b}\t$dst",
315
- [(store (sra (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
289
+ "sar{b}\t$dst", []>;
316
290
def SAR16m1 : I<0xD1, MRM7m, (outs), (ins i16mem:$dst),
317
- "sar{w}\t$dst",
318
- [(store (sra (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
319
- OpSize16;
291
+ "sar{w}\t$dst", []>, OpSize16;
320
292
def SAR32m1 : I<0xD1, MRM7m, (outs), (ins i32mem:$dst),
321
- "sar{l}\t$dst",
322
- [(store (sra (loadi32 addr:$dst), (i8 1)), addr:$dst)]>,
323
- OpSize32;
293
+ "sar{l}\t$dst", []>, OpSize32;
324
294
def SAR64m1 : RI<0xD1, MRM7m, (outs), (ins i64mem:$dst),
325
- "sar{q}\t$dst",
326
- [(store (sra (loadi64 addr:$dst), (i8 1)), addr:$dst)]>,
327
- Requires<[In64BitMode]>;
295
+ "sar{q}\t$dst", []>, Requires<[In64BitMode]>;
328
296
} // SchedRW
329
297
330
298
//===----------------------------------------------------------------------===//
331
299
// Rotate instructions
332
300
//===----------------------------------------------------------------------===//
333
301
334
- let hasSideEffects = 0 in {
335
302
let Constraints = "$src1 = $dst" in {
336
303
337
304
let Uses = [CL, EFLAGS], SchedRW = [WriteRotateCL] in {
@@ -393,7 +360,6 @@ def RCR64r1 : RI<0xD1, MRM3r, (outs GR64:$dst), (ins GR64:$src1),
393
360
def RCR64ri : RIi8<0xC1, MRM3r, (outs GR64:$dst), (ins GR64:$src1, u8imm:$cnt),
394
361
"rcr{q}\t{$cnt, $dst|$dst, $cnt}", []>;
395
362
} // Uses = [EFLAGS], SchedRW
396
-
397
363
} // Constraints = "$src = $dst"
398
364
399
365
let mayLoad = 1, mayStore = 1 in {
@@ -457,7 +423,6 @@ def RCR64mCL : RI<0xD3, MRM3m, (outs), (ins i64mem:$dst),
457
423
Requires<[In64BitMode]>;
458
424
} // Uses = [CL, EFLAGS], SchedRW
459
425
} // mayLoad, mayStore
460
- } // hasSideEffects = 0
461
426
462
427
let Constraints = "$src1 = $dst" in {
463
428
// FIXME: provide shorter instructions when imm8 == 1
@@ -495,17 +460,13 @@ def ROL64ri : RIi8<0xC1, MRM0r, (outs GR64:$dst),
495
460
496
461
// Rotate by 1
497
462
def ROL8r1 : I<0xD0, MRM0r, (outs GR8 :$dst), (ins GR8 :$src1),
498
- "rol{b}\t$dst",
499
- [(set GR8:$dst, (rotl GR8:$src1, (i8 1)))]>;
463
+ "rol{b}\t$dst", []>;
500
464
def ROL16r1 : I<0xD1, MRM0r, (outs GR16:$dst), (ins GR16:$src1),
501
- "rol{w}\t$dst",
502
- [(set GR16:$dst, (rotl GR16:$src1, (i8 1)))]>, OpSize16;
465
+ "rol{w}\t$dst", []>, OpSize16;
503
466
def ROL32r1 : I<0xD1, MRM0r, (outs GR32:$dst), (ins GR32:$src1),
504
- "rol{l}\t$dst",
505
- [(set GR32:$dst, (rotl GR32:$src1, (i8 1)))]>, OpSize32;
467
+ "rol{l}\t$dst", []>, OpSize32;
506
468
def ROL64r1 : RI<0xD1, MRM0r, (outs GR64:$dst), (ins GR64:$src1),
507
- "rol{q}\t$dst",
508
- [(set GR64:$dst, (rotl GR64:$src1, (i8 1)))]>;
469
+ "rol{q}\t$dst", []>;
509
470
} // SchedRW
510
471
} // Constraints = "$src = $dst"
511
472
@@ -525,7 +486,7 @@ def ROL64mCL : RI<0xD3, MRM0m, (outs), (ins i64mem:$dst),
525
486
Requires<[In64BitMode]>;
526
487
} // Uses, SchedRW
527
488
528
- let SchedRW = [WriteRotateLd, WriteRMW] in {
489
+ let SchedRW = [WriteRotateLd, WriteRMW], mayLoad = 1, mayStore = 1 in {
529
490
def ROL8mi : Ii8<0xC0, MRM0m, (outs), (ins i8mem :$dst, u8imm:$src1),
530
491
"rol{b}\t{$src1, $dst|$dst, $src1}",
531
492
[(store (rotl (loadi8 addr:$dst), (i8 imm:$src1)), addr:$dst)]>;
@@ -544,21 +505,14 @@ def ROL64mi : RIi8<0xC1, MRM0m, (outs), (ins i64mem:$dst, u8imm:$src1),
544
505
545
506
// Rotate by 1
546
507
def ROL8m1 : I<0xD0, MRM0m, (outs), (ins i8mem :$dst),
547
- "rol{b}\t$dst",
548
- [(store (rotl (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
508
+ "rol{b}\t$dst", []>;
549
509
def ROL16m1 : I<0xD1, MRM0m, (outs), (ins i16mem:$dst),
550
- "rol{w}\t$dst",
551
- [(store (rotl (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
552
- OpSize16;
510
+ "rol{w}\t$dst", []>, OpSize16;
553
511
def ROL32m1 : I<0xD1, MRM0m, (outs), (ins i32mem:$dst),
554
- "rol{l}\t$dst",
555
- [(store (rotl (loadi32 addr:$dst), (i8 1)), addr:$dst)]>,
556
- OpSize32;
512
+ "rol{l}\t$dst", []>, OpSize32;
557
513
def ROL64m1 : RI<0xD1, MRM0m, (outs), (ins i64mem:$dst),
558
- "rol{q}\t$dst",
559
- [(store (rotl (loadi64 addr:$dst), (i8 1)), addr:$dst)]>,
560
- Requires<[In64BitMode]>;
561
- } // SchedRW
514
+ "rol{q}\t$dst", []>, Requires<[In64BitMode]>;
515
+ } // SchedRW, mayLoad, mayStore
562
516
563
517
let Constraints = "$src1 = $dst" in {
564
518
let Uses = [CL], SchedRW = [WriteRotateCL] in {
@@ -595,17 +549,13 @@ def ROR64ri : RIi8<0xC1, MRM1r, (outs GR64:$dst),
595
549
596
550
// Rotate by 1
597
551
def ROR8r1 : I<0xD0, MRM1r, (outs GR8 :$dst), (ins GR8 :$src1),
598
- "ror{b}\t$dst",
599
- [(set GR8:$dst, (rotr GR8:$src1, (i8 1)))]>;
552
+ "ror{b}\t$dst", []>;
600
553
def ROR16r1 : I<0xD1, MRM1r, (outs GR16:$dst), (ins GR16:$src1),
601
- "ror{w}\t$dst",
602
- [(set GR16:$dst, (rotr GR16:$src1, (i8 1)))]>, OpSize16;
554
+ "ror{w}\t$dst", []>, OpSize16;
603
555
def ROR32r1 : I<0xD1, MRM1r, (outs GR32:$dst), (ins GR32:$src1),
604
- "ror{l}\t$dst",
605
- [(set GR32:$dst, (rotr GR32:$src1, (i8 1)))]>, OpSize32;
556
+ "ror{l}\t$dst", []>, OpSize32;
606
557
def ROR64r1 : RI<0xD1, MRM1r, (outs GR64:$dst), (ins GR64:$src1),
607
- "ror{q}\t$dst",
608
- [(set GR64:$dst, (rotr GR64:$src1, (i8 1)))]>;
558
+ "ror{q}\t$dst", []>;
609
559
} // SchedRW
610
560
} // Constraints = "$src = $dst", SchedRW
611
561
@@ -625,7 +575,7 @@ def ROR64mCL : RI<0xD3, MRM1m, (outs), (ins i64mem:$dst),
625
575
Requires<[In64BitMode]>;
626
576
} // Uses, SchedRW
627
577
628
- let SchedRW = [WriteRotateLd, WriteRMW] in {
578
+ let SchedRW = [WriteRotateLd, WriteRMW], mayLoad = 1, mayStore =1 in {
629
579
def ROR8mi : Ii8<0xC0, MRM1m, (outs), (ins i8mem :$dst, u8imm:$src),
630
580
"ror{b}\t{$src, $dst|$dst, $src}",
631
581
[(store (rotr (loadi8 addr:$dst), (i8 imm:$src)), addr:$dst)]>;
@@ -644,21 +594,15 @@ def ROR64mi : RIi8<0xC1, MRM1m, (outs), (ins i64mem:$dst, u8imm:$src),
644
594
645
595
// Rotate by 1
646
596
def ROR8m1 : I<0xD0, MRM1m, (outs), (ins i8mem :$dst),
647
- "ror{b}\t$dst",
648
- [(store (rotr (loadi8 addr:$dst), (i8 1)), addr:$dst)]>;
597
+ "ror{b}\t$dst", []>;
649
598
def ROR16m1 : I<0xD1, MRM1m, (outs), (ins i16mem:$dst),
650
- "ror{w}\t$dst",
651
- [(store (rotr (loadi16 addr:$dst), (i8 1)), addr:$dst)]>,
652
- OpSize16;
599
+ "ror{w}\t$dst", []>, OpSize16;
653
600
def ROR32m1 : I<0xD1, MRM1m, (outs), (ins i32mem:$dst),
654
- "ror{l}\t$dst",
655
- [(store (rotr (loadi32 addr:$dst), (i8 1)), addr:$dst)]>,
601
+ "ror{l}\t$dst", []>,
656
602
OpSize32;
657
603
def ROR64m1 : RI<0xD1, MRM1m, (outs), (ins i64mem:$dst),
658
- "ror{q}\t$dst",
659
- [(store (rotr (loadi64 addr:$dst), (i8 1)), addr:$dst)]>,
660
- Requires<[In64BitMode]>;
661
- } // SchedRW
604
+ "ror{q}\t$dst", []>, Requires<[In64BitMode]>;
605
+ } // SchedRW, mayLoad, mayStore
662
606
663
607
664
608
//===----------------------------------------------------------------------===//
@@ -816,7 +760,7 @@ def SHRD64mri8 : RIi8<0xAC, MRMDestMem,
816
760
TB;
817
761
} // SchedRW
818
762
819
- } // Defs = [EFLAGS]
763
+ } // Defs = [EFLAGS], hasSideEffects
820
764
821
765
// Use the opposite rotate if allows us to use the rotate by 1 instruction.
822
766
def : Pat<(rotl GR8:$src1, (i8 7)), (ROR8r1 GR8:$src1)>;
0 commit comments