aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/Hexagon/HexagonInstrInfoV5.td
blob: 9da60745581125c48f5e6e48a3d3a6a7949f06a9 (plain)
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
def SDTHexagonFCONST32 : SDTypeProfile<1, 1, [
                                            SDTCisVT<0, f32>,
                                            SDTCisPtrTy<1>]>;
def HexagonFCONST32 : SDNode<"HexagonISD::FCONST32",     SDTHexagonFCONST32>;

let isReMaterializable = 1, isMoveImm = 1 in
def FCONST32_nsdata : LDInst<(outs IntRegs:$dst), (ins globaladdress:$global),
              "$dst = CONST32(#$global)",
              [(set (f32 IntRegs:$dst),
              (HexagonFCONST32 tglobaladdr:$global))]>,
               Requires<[HasV5T]>;

let isReMaterializable = 1, isMoveImm = 1 in
def CONST64_Float_Real : LDInst<(outs DoubleRegs:$dst), (ins f64imm:$src1),
                       "$dst = CONST64(#$src1)",
                       [(set DoubleRegs:$dst, fpimm:$src1)]>,
          Requires<[HasV5T]>;

let isReMaterializable = 1, isMoveImm = 1 in
def CONST32_Float_Real : LDInst<(outs IntRegs:$dst), (ins f32imm:$src1),
                       "$dst = CONST32(#$src1)",
                       [(set IntRegs:$dst, fpimm:$src1)]>,
          Requires<[HasV5T]>;

// Transfer immediate float.
// Only works with single precision fp value.
// For double precision, use CONST64_float_real, as 64bit transfer
// can only hold 40-bit values - 32 from const ext + 8 bit immediate.
// Make sure that complexity is more than the CONST32 pattern in
// HexagonInstrInfo.td patterns.
let isExtended = 1, opExtendable = 1, isMoveImm = 1, isReMaterializable = 1,
isPredicable = 1, AddedComplexity = 30, validSubTargets = HasV5SubT,
isCodeGenOnly = 1 in
def TFRI_f : ALU32_ri<(outs IntRegs:$dst), (ins f32Ext:$src1),
           "$dst = #$src1",
           [(set IntRegs:$dst, fpimm:$src1)]>,
          Requires<[HasV5T]>;

let isExtended = 1, opExtendable = 2, isPredicated = 1,
neverHasSideEffects = 1, validSubTargets = HasV5SubT in
def TFRI_cPt_f : ALU32_ri<(outs IntRegs:$dst),
                          (ins PredRegs:$src1, f32Ext:$src2),
           "if ($src1) $dst = #$src2",
           []>,
          Requires<[HasV5T]>;

let isExtended = 1, opExtendable = 2, isPredicated = 1, isPredicatedFalse = 1,
neverHasSideEffects = 1, validSubTargets = HasV5SubT in
def TFRI_cNotPt_f : ALU32_ri<(outs IntRegs:$dst),
                             (ins PredRegs:$src1, f32Ext:$src2),
           "if (!$src1) $dst =#$src2",
           []>,
          Requires<[HasV5T]>;

// Convert single precision to double precision and vice-versa.
def CONVERT_sf2df : ALU64_rr<(outs DoubleRegs:$dst), (ins IntRegs:$src),
                "$dst = convert_sf2df($src)",
                [(set DoubleRegs:$dst, (fextend IntRegs:$src))]>,
          Requires<[HasV5T]>;

def CONVERT_df2sf : ALU64_rr<(outs IntRegs:$dst), (ins DoubleRegs:$src),
                "$dst = convert_df2sf($src)",
                [(set IntRegs:$dst, (fround DoubleRegs:$src))]>,
          Requires<[HasV5T]>;


// Load.
def LDrid_f : LDInst<(outs DoubleRegs:$dst),
            (ins MEMri:$addr),
            "$dst = memd($addr)",
            [(set DoubleRegs:$dst, (f64 (load ADDRriS11_3:$addr)))]>,
          Requires<[HasV5T]>;


let AddedComplexity = 20 in
def LDrid_indexed_f : LDInst<(outs DoubleRegs:$dst),
            (ins IntRegs:$src1, s11_3Imm:$offset),
            "$dst = memd($src1+#$offset)",
            [(set DoubleRegs:$dst, (f64 (load (add IntRegs:$src1,
                                              s11_3ImmPred:$offset))))]>,
          Requires<[HasV5T]>;

def LDriw_f : LDInst<(outs IntRegs:$dst),
            (ins MEMri:$addr), "$dst = memw($addr)",
            [(set IntRegs:$dst, (f32 (load ADDRriS11_2:$addr)))]>,
          Requires<[HasV5T]>;


let AddedComplexity = 20 in
def LDriw_indexed_f : LDInst<(outs IntRegs:$dst),
            (ins IntRegs:$src1, s11_2Imm:$offset),
            "$dst = memw($src1+#$offset)",
            [(set IntRegs:$dst, (f32 (load (add IntRegs:$src1,
                                           s11_2ImmPred:$offset))))]>,
          Requires<[HasV5T]>;

// Store.
def STriw_f : STInst<(outs),
            (ins MEMri:$addr, IntRegs:$src1),
            "memw($addr) = $src1",
            [(store (f32 IntRegs:$src1), ADDRriS11_2:$addr)]>,
          Requires<[HasV5T]>;

let AddedComplexity = 10 in
def STriw_indexed_f : STInst<(outs),
            (ins IntRegs:$src1, s11_2Imm:$src2, IntRegs:$src3),
            "memw($src1+#$src2) = $src3",
            [(store (f32 IntRegs:$src3),
                (add IntRegs:$src1, s11_2ImmPred:$src2))]>,
          Requires<[HasV5T]>;

def STrid_f : STInst<(outs),
            (ins MEMri:$addr, DoubleRegs:$src1),
            "memd($addr) = $src1",
            [(store (f64 DoubleRegs:$src1), ADDRriS11_2:$addr)]>,
          Requires<[HasV5T]>;

// Indexed store double word.
let AddedComplexity = 10 in
def STrid_indexed_f : STInst<(outs),
            (ins IntRegs:$src1, s11_3Imm:$src2,  DoubleRegs:$src3),
            "memd($src1+#$src2) = $src3",
            [(store (f64 DoubleRegs:$src3),
                                (add IntRegs:$src1, s11_3ImmPred:$src2))]>,
          Requires<[HasV5T]>;


// Add
let isCommutable = 1 in
def fADD_rr : ALU64_rr<(outs IntRegs:$dst),
            (ins IntRegs:$src1, IntRegs:$src2),
            "$dst = sfadd($src1, $src2)",
            [(set IntRegs:$dst, (fadd IntRegs:$src1, IntRegs:$src2))]>,
          Requires<[HasV5T]>;

let isCommutable = 1 in
def fADD64_rr : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1,
                                                     DoubleRegs:$src2),
               "$dst = dfadd($src1, $src2)",
               [(set DoubleRegs:$dst, (fadd DoubleRegs:$src1,
                                           DoubleRegs:$src2))]>,
          Requires<[HasV5T]>;

def fSUB_rr : ALU64_rr<(outs IntRegs:$dst),
            (ins IntRegs:$src1, IntRegs:$src2),
            "$dst = sfsub($src1, $src2)",
            [(set IntRegs:$dst, (fsub IntRegs:$src1, IntRegs:$src2))]>,
          Requires<[HasV5T]>;

def fSUB64_rr : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1,
                                                     DoubleRegs:$src2),
               "$dst = dfsub($src1, $src2)",
               [(set DoubleRegs:$dst, (fsub DoubleRegs:$src1,
                                           DoubleRegs:$src2))]>,
               Requires<[HasV5T]>;

let isCommutable = 1 in
def fMUL_rr : ALU64_rr<(outs IntRegs:$dst),
            (ins IntRegs:$src1, IntRegs:$src2),
            "$dst = sfmpy($src1, $src2)",
            [(set IntRegs:$dst, (fmul IntRegs:$src1, IntRegs:$src2))]>,
            Requires<[HasV5T]>;

let isCommutable = 1 in
def fMUL64_rr : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src1,
                                                     DoubleRegs:$src2),
               "$dst = dfmpy($src1, $src2)",
               [(set DoubleRegs:$dst, (fmul DoubleRegs:$src1,
                                           DoubleRegs:$src2))]>,
               Requires<[HasV5T]>;

// Compare.
let isCompare = 1 in {
multiclass FCMP64_rr<string OpcStr, PatFrag OpNode> {
  def _rr : ALU64_rr<(outs PredRegs:$dst), (ins DoubleRegs:$b, DoubleRegs:$c),
                 !strconcat("$dst = ", !strconcat(OpcStr, "($b, $c)")),
                 [(set PredRegs:$dst,
                        (OpNode (f64 DoubleRegs:$b), (f64 DoubleRegs:$c)))]>,
                 Requires<[HasV5T]>;
}

multiclass FCMP32_rr<string OpcStr, PatFrag OpNode> {
  def _rr : ALU64_rr<(outs PredRegs:$dst), (ins IntRegs:$b, IntRegs:$c),
                 !strconcat("$dst = ", !strconcat(OpcStr, "($b, $c)")),
                 [(set PredRegs:$dst,
                        (OpNode (f32 IntRegs:$b), (f32 IntRegs:$c)))]>,
                 Requires<[HasV5T]>;
}
}

defm FCMPOEQ64 : FCMP64_rr<"dfcmp.eq", setoeq>;
defm FCMPUEQ64 : FCMP64_rr<"dfcmp.eq", setueq>;
defm FCMPOGT64 : FCMP64_rr<"dfcmp.gt", setogt>;
defm FCMPUGT64 : FCMP64_rr<"dfcmp.gt", setugt>;
defm FCMPOGE64 : FCMP64_rr<"dfcmp.ge", setoge>;
defm FCMPUGE64 : FCMP64_rr<"dfcmp.ge", setuge>;

defm FCMPOEQ32 : FCMP32_rr<"sfcmp.eq", setoeq>;
defm FCMPUEQ32 : FCMP32_rr<"sfcmp.eq", setueq>;
defm FCMPOGT32 : FCMP32_rr<"sfcmp.gt", setogt>;
defm FCMPUGT32 : FCMP32_rr<"sfcmp.gt", setugt>;
defm FCMPOGE32 : FCMP32_rr<"sfcmp.ge", setoge>;
defm FCMPUGE32 : FCMP32_rr<"sfcmp.ge", setuge>;

// olt.
def : Pat <(i1 (setolt (f32 IntRegs:$src1), (f32 IntRegs:$src2))),
      (i1 (FCMPOGT32_rr IntRegs:$src2, IntRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat <(i1 (setolt (f32 IntRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPOGT32_rr (f32 (TFRI_f fpimm:$src2)), (f32 IntRegs:$src1)))>,
      Requires<[HasV5T]>;

def : Pat <(i1 (setolt (f64 DoubleRegs:$src1), (f64 DoubleRegs:$src2))),
      (i1 (FCMPOGT64_rr DoubleRegs:$src2, DoubleRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat <(i1 (setolt (f64 DoubleRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPOGT64_rr (f64 (CONST64_Float_Real fpimm:$src2)),
                        (f64 DoubleRegs:$src1)))>,
      Requires<[HasV5T]>;

// gt.
def : Pat <(i1 (setugt (f64 DoubleRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPUGT64_rr (f64 DoubleRegs:$src1),
                        (f64 (CONST64_Float_Real fpimm:$src2))))>,
      Requires<[HasV5T]>;

def : Pat <(i1 (setugt (f32 IntRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPUGT32_rr (f32 IntRegs:$src1), (f32 (TFRI_f fpimm:$src2))))>,
      Requires<[HasV5T]>;

// ult.
def : Pat <(i1 (setult (f32 IntRegs:$src1), (f32 IntRegs:$src2))),
      (i1 (FCMPUGT32_rr IntRegs:$src2, IntRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat <(i1 (setult (f32 IntRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPUGT32_rr (f32 (TFRI_f fpimm:$src2)), (f32 IntRegs:$src1)))>,
      Requires<[HasV5T]>;

def : Pat <(i1 (setult (f64 DoubleRegs:$src1), (f64 DoubleRegs:$src2))),
      (i1 (FCMPUGT64_rr DoubleRegs:$src2, DoubleRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat <(i1 (setult (f64 DoubleRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPUGT64_rr (f64 (CONST64_Float_Real fpimm:$src2)),
                        (f64 DoubleRegs:$src1)))>,
      Requires<[HasV5T]>;

// le.
// rs <= rt -> rt >= rs.
def : Pat<(i1 (setole (f32 IntRegs:$src1), (f32 IntRegs:$src2))),
      (i1 (FCMPOGE32_rr IntRegs:$src2, IntRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setole (f32 IntRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPOGE32_rr (f32 (TFRI_f fpimm:$src2)), IntRegs:$src1))>,
      Requires<[HasV5T]>;


// Rss <= Rtt -> Rtt >= Rss.
def : Pat<(i1 (setole (f64 DoubleRegs:$src1), (f64 DoubleRegs:$src2))),
      (i1 (FCMPOGE64_rr DoubleRegs:$src2, DoubleRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setole (f64 DoubleRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPOGE64_rr (f64 (CONST64_Float_Real fpimm:$src2)),
                                DoubleRegs:$src1))>,
      Requires<[HasV5T]>;

// rs <= rt -> rt >= rs.
def : Pat<(i1 (setule (f32 IntRegs:$src1), (f32 IntRegs:$src2))),
      (i1 (FCMPUGE32_rr IntRegs:$src2, IntRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setule (f32 IntRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPUGE32_rr (f32 (TFRI_f fpimm:$src2)), IntRegs:$src1))>,
      Requires<[HasV5T]>;

// Rss <= Rtt -> Rtt >= Rss.
def : Pat<(i1 (setule (f64 DoubleRegs:$src1), (f64 DoubleRegs:$src2))),
      (i1 (FCMPUGE64_rr DoubleRegs:$src2, DoubleRegs:$src1))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setule (f64 DoubleRegs:$src1), (fpimm:$src2))),
      (i1 (FCMPUGE64_rr (f64 (CONST64_Float_Real fpimm:$src2)),
                                DoubleRegs:$src1))>,
      Requires<[HasV5T]>;

// ne.
def : Pat<(i1 (setone (f32 IntRegs:$src1), (f32 IntRegs:$src2))),
      (i1 (NOT_p (FCMPOEQ32_rr IntRegs:$src1, IntRegs:$src2)))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setone (f64 DoubleRegs:$src1), (f64 DoubleRegs:$src2))),
      (i1 (NOT_p (FCMPOEQ64_rr DoubleRegs:$src1, DoubleRegs:$src2)))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setune (f32 IntRegs:$src1), (f32 IntRegs:$src2))),
      (i1 (NOT_p (FCMPUEQ32_rr IntRegs:$src1, IntRegs:$src2)))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setune (f64 DoubleRegs:$src1), (f64 DoubleRegs:$src2))),
      (i1 (NOT_p (FCMPUEQ64_rr DoubleRegs:$src1, DoubleRegs:$src2)))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setone (f32 IntRegs:$src1), (fpimm:$src2))),
      (i1 (NOT_p (FCMPOEQ32_rr IntRegs:$src1, (f32 (TFRI_f fpimm:$src2)))))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setone (f64 DoubleRegs:$src1), (fpimm:$src2))),
      (i1 (NOT_p (FCMPOEQ64_rr DoubleRegs:$src1,
                              (f64 (CONST64_Float_Real fpimm:$src2)))))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setune (f32 IntRegs:$src1), (fpimm:$src2))),
      (i1 (NOT_p (FCMPUEQ32_rr IntRegs:$src1,  (f32 (TFRI_f fpimm:$src2)))))>,
      Requires<[HasV5T]>;

def : Pat<(i1 (setune (f64 DoubleRegs:$src1), (fpimm:$src2))),
      (i1 (NOT_p (FCMPUEQ64_rr DoubleRegs:$src1,
                              (f64 (CONST64_Float_Real fpimm:$src2)))))>,
      Requires<[HasV5T]>;

// Convert Integer to Floating Point.
def CONVERT_d2sf : ALU64_rr<(outs IntRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_d2sf($src)",
              [(set (f32 IntRegs:$dst), (sint_to_fp (i64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_ud2sf : ALU64_rr<(outs IntRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_ud2sf($src)",
              [(set (f32 IntRegs:$dst), (uint_to_fp (i64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_uw2sf : ALU64_rr<(outs IntRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_uw2sf($src)",
              [(set (f32 IntRegs:$dst), (uint_to_fp (i32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_w2sf : ALU64_rr<(outs IntRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_w2sf($src)",
              [(set (f32 IntRegs:$dst), (sint_to_fp (i32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_d2df : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_d2df($src)",
              [(set (f64 DoubleRegs:$dst), (sint_to_fp (i64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_ud2df : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_ud2df($src)",
              [(set (f64 DoubleRegs:$dst), (uint_to_fp (i64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_uw2df : ALU64_rr<(outs DoubleRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_uw2df($src)",
              [(set (f64 DoubleRegs:$dst), (uint_to_fp (i32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_w2df : ALU64_rr<(outs DoubleRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_w2df($src)",
              [(set (f64 DoubleRegs:$dst), (sint_to_fp (i32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

// Convert Floating Point to Integer - default.
def CONVERT_df2uw : ALU64_rr<(outs IntRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2uw($src):chop",
              [(set (i32 IntRegs:$dst), (fp_to_uint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_df2w : ALU64_rr<(outs IntRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2w($src):chop",
              [(set (i32 IntRegs:$dst), (fp_to_sint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_sf2uw : ALU64_rr<(outs IntRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2uw($src):chop",
              [(set (i32 IntRegs:$dst), (fp_to_uint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_sf2w : ALU64_rr<(outs IntRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2w($src):chop",
              [(set (i32 IntRegs:$dst), (fp_to_sint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_df2d : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2d($src):chop",
              [(set (i64 DoubleRegs:$dst), (fp_to_sint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_df2ud : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2ud($src):chop",
              [(set (i64 DoubleRegs:$dst), (fp_to_uint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_sf2d : ALU64_rr<(outs DoubleRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2d($src):chop",
              [(set (i64 DoubleRegs:$dst), (fp_to_sint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

def CONVERT_sf2ud : ALU64_rr<(outs DoubleRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2ud($src):chop",
              [(set (i64 DoubleRegs:$dst), (fp_to_uint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T]>;

// Convert Floating Point to Integer: non-chopped.
let AddedComplexity = 20 in
def CONVERT_df2uw_nchop : ALU64_rr<(outs IntRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2uw($src)",
              [(set (i32 IntRegs:$dst), (fp_to_uint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;

let AddedComplexity = 20 in
def CONVERT_df2w_nchop : ALU64_rr<(outs IntRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2w($src)",
              [(set (i32 IntRegs:$dst), (fp_to_sint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;

let AddedComplexity = 20 in
def CONVERT_sf2uw_nchop : ALU64_rr<(outs IntRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2uw($src)",
              [(set (i32 IntRegs:$dst), (fp_to_uint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;

let AddedComplexity = 20 in
def CONVERT_sf2w_nchop : ALU64_rr<(outs IntRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2w($src)",
              [(set (i32 IntRegs:$dst), (fp_to_sint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;

let AddedComplexity = 20 in
def CONVERT_df2d_nchop : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2d($src)",
              [(set (i64 DoubleRegs:$dst), (fp_to_sint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;

let AddedComplexity = 20 in
def CONVERT_df2ud_nchop : ALU64_rr<(outs DoubleRegs:$dst), (ins DoubleRegs:$src),
              "$dst = convert_df2ud($src)",
              [(set (i64 DoubleRegs:$dst), (fp_to_uint (f64 DoubleRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;

let AddedComplexity = 20 in
def CONVERT_sf2d_nchop : ALU64_rr<(outs DoubleRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2d($src)",
              [(set (i64 DoubleRegs:$dst), (fp_to_sint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;

let AddedComplexity = 20 in
def CONVERT_sf2ud_nchop : ALU64_rr<(outs DoubleRegs:$dst), (ins IntRegs:$src),
              "$dst = convert_sf2ud($src)",
              [(set (i64 DoubleRegs:$dst), (fp_to_uint (f32 IntRegs:$src)))]>,
              Requires<[HasV5T, IEEERndNearV5T]>;



// Bitcast is different than [fp|sint|uint]_to_[sint|uint|fp].
def : Pat <(i32 (bitconvert (f32 IntRegs:$src))),
           (i32 (TFR IntRegs:$src))>,
          Requires<[HasV5T]>;

def : Pat <(f32 (bitconvert (i32 IntRegs:$src))),
           (f32 (TFR IntRegs:$src))>,
          Requires<[HasV5T]>;

def : Pat <(i64 (bitconvert (f64 DoubleRegs:$src))),
           (i64 (TFR64 DoubleRegs:$src))>,
          Requires<[HasV5T]>;

def : Pat <(f64 (bitconvert (i64 DoubleRegs:$src))),
           (f64 (TFR64 DoubleRegs:$src))>,
          Requires<[HasV5T]>;

// Floating point fused multiply-add.
def FMADD_dp : ALU64_acc<(outs DoubleRegs:$dst),
                  (ins DoubleRegs:$src1, DoubleRegs:$src2, DoubleRegs:$src3),
              "$dst += dfmpy($src2, $src3)",
              [(set (f64 DoubleRegs:$dst),
                  (fma DoubleRegs:$src2, DoubleRegs:$src3, DoubleRegs:$src1))],
                  "$src1 = $dst">,
              Requires<[HasV5T]>;

def FMADD_sp : ALU64_acc<(outs IntRegs:$dst),
                  (ins IntRegs:$src1, IntRegs:$src2, IntRegs:$src3),
              "$dst += sfmpy($src2, $src3)",
              [(set (f32 IntRegs:$dst),
                  (fma IntRegs:$src2, IntRegs:$src3, IntRegs:$src1))],
                  "$src1 = $dst">,
              Requires<[HasV5T]>;


// Floating point max/min.
let AddedComplexity = 100 in
def FMAX_dp : ALU64_rr<(outs DoubleRegs:$dst),
                  (ins DoubleRegs:$src1, DoubleRegs:$src2),
              "$dst = dfmax($src1, $src2)",
              [(set DoubleRegs:$dst, (f64 (select (i1 (setolt DoubleRegs:$src2,
                                                        DoubleRegs:$src1)),
                                             DoubleRegs:$src1,
                                             DoubleRegs:$src2)))]>,
               Requires<[HasV5T]>;

let AddedComplexity = 100 in
def FMAX_sp : ALU64_rr<(outs IntRegs:$dst),
                  (ins IntRegs:$src1, IntRegs:$src2),
              "$dst = sfmax($src1, $src2)",
              [(set IntRegs:$dst, (f32 (select (i1 (setolt IntRegs:$src2,
                                                        IntRegs:$src1)),
                                             IntRegs:$src1,
                                             IntRegs:$src2)))]>,
               Requires<[HasV5T]>;

let AddedComplexity = 100 in
def FMIN_dp : ALU64_rr<(outs DoubleRegs:$dst),
                  (ins DoubleRegs:$src1, DoubleRegs:$src2),
              "$dst = dfmin($src1, $src2)",
              [(set DoubleRegs:$dst, (f64 (select (i1 (setogt DoubleRegs:$src2,
                                                        DoubleRegs:$src1)),
                                             DoubleRegs:$src1,
                                             DoubleRegs:$src2)))]>,
               Requires<[HasV5T]>;

let AddedComplexity = 100 in
def FMIN_sp : ALU64_rr<(outs IntRegs:$dst),
                  (ins IntRegs:$src1, IntRegs:$src2),
              "$dst = sfmin($src1, $src2)",
              [(set IntRegs:$dst, (f32 (select (i1 (setogt IntRegs:$src2,
                                                        IntRegs:$src1)),
                                             IntRegs:$src1,
                                             IntRegs:$src2)))]>,
               Requires<[HasV5T]>;

// Pseudo instruction to encode a set of conditional transfers.
// This instruction is used instead of a mux and trades-off codesize
// for performance. We conduct this transformation optimistically in
// the hope that these instructions get promoted to dot-new transfers.
let AddedComplexity = 100, isPredicated = 1 in
def TFR_condset_rr_f : ALU32_rr<(outs IntRegs:$dst), (ins PredRegs:$src1,
                                                        IntRegs:$src2,
                                                        IntRegs:$src3),
                     "Error; should not emit",
                     [(set IntRegs:$dst, (f32 (select PredRegs:$src1,
                                                 IntRegs:$src2,
                                                 IntRegs:$src3)))]>,
               Requires<[HasV5T]>;

let AddedComplexity = 100, isPredicated = 1 in
def TFR_condset_rr64_f : ALU32_rr<(outs DoubleRegs:$dst), (ins PredRegs:$src1,
                                                        DoubleRegs:$src2,
                                                        DoubleRegs:$src3),
                     "Error; should not emit",
                     [(set DoubleRegs:$dst, (f64 (select PredRegs:$src1,
                                                 DoubleRegs:$src2,
                                                 DoubleRegs:$src3)))]>,
               Requires<[HasV5T]>;



let AddedComplexity = 100, isPredicated = 1 in
def TFR_condset_ri_f : ALU32_rr<(outs IntRegs:$dst),
            (ins PredRegs:$src1, IntRegs:$src2, f32imm:$src3),
            "Error; should not emit",
            [(set IntRegs:$dst,
             (f32 (select PredRegs:$src1, IntRegs:$src2, fpimm:$src3)))]>,
               Requires<[HasV5T]>;

let AddedComplexity = 100, isPredicated = 1 in
def TFR_condset_ir_f : ALU32_rr<(outs IntRegs:$dst),
            (ins PredRegs:$src1, f32imm:$src2, IntRegs:$src3),
            "Error; should not emit",
            [(set IntRegs:$dst,
             (f32 (select PredRegs:$src1, fpimm:$src2, IntRegs:$src3)))]>,
               Requires<[HasV5T]>;

let AddedComplexity = 100, isPredicated = 1 in
def TFR_condset_ii_f : ALU32_rr<(outs IntRegs:$dst),
                              (ins PredRegs:$src1, f32imm:$src2, f32imm:$src3),
                     "Error; should not emit",
                     [(set IntRegs:$dst, (f32 (select PredRegs:$src1,
                                                 fpimm:$src2,
                                                 fpimm:$src3)))]>,
               Requires<[HasV5T]>;


def : Pat <(select (i1 (setult (f32 IntRegs:$src1), (f32 IntRegs:$src2))),
                   (f32 IntRegs:$src3),
                   (f32 IntRegs:$src4)),
    (TFR_condset_rr_f (FCMPUGT32_rr IntRegs:$src2, IntRegs:$src1), IntRegs:$src4,
                      IntRegs:$src3)>, Requires<[HasV5T]>;

def : Pat <(select (i1 (setult (f64 DoubleRegs:$src1), (f64 DoubleRegs:$src2))),
                   (f64 DoubleRegs:$src3),
                   (f64 DoubleRegs:$src4)),
      (TFR_condset_rr64_f (FCMPUGT64_rr DoubleRegs:$src2, DoubleRegs:$src1),
                DoubleRegs:$src4, DoubleRegs:$src3)>, Requires<[HasV5T]>;

// Map from p0 = pnot(p0); r0 = mux(p0, #i, #j) => r0 = mux(p0, #j, #i).
def : Pat <(select (not PredRegs:$src1), fpimm:$src2, fpimm:$src3),
      (TFR_condset_ii_f PredRegs:$src1, fpimm:$src3, fpimm:$src2)>;

// Map from p0 = pnot(p0); r0 = select(p0, #i, r1)
// => r0 = TFR_condset_ri(p0, r1, #i)
def : Pat <(select (not PredRegs:$src1), fpimm:$src2, IntRegs:$src3),
      (TFR_condset_ri_f PredRegs:$src1, IntRegs:$src3, fpimm:$src2)>;

// Map from p0 = pnot(p0); r0 = mux(p0, r1, #i)
// => r0 = TFR_condset_ir(p0, #i, r1)
def : Pat <(select (not PredRegs:$src1), IntRegs:$src2, fpimm:$src3),
      (TFR_condset_ir_f PredRegs:$src1, fpimm:$src3, IntRegs:$src2)>;

def : Pat <(i32 (fp_to_sint (f64 DoubleRegs:$src1))),
          (i32 (EXTRACT_SUBREG (i64 (CONVERT_df2d (f64 DoubleRegs:$src1))), subreg_loreg))>,
          Requires<[HasV5T]>;

def : Pat <(fabs (f32 IntRegs:$src1)),
           (CLRBIT_31 (f32 IntRegs:$src1), 31)>,
          Requires<[HasV5T]>;

def : Pat <(fneg (f32 IntRegs:$src1)),
           (TOGBIT_31 (f32 IntRegs:$src1), 31)>,
          Requires<[HasV5T]>;

/*
def : Pat <(fabs (f64 DoubleRegs:$src1)),
          (CLRBIT_31 (f32 (EXTRACT_SUBREG DoubleRegs:$src1, subreg_hireg)), 31)>,
          Requires<[HasV5T]>;

def : Pat <(fabs (f64 DoubleRegs:$src1)),
          (CLRBIT_31 (f32 (EXTRACT_SUBREG DoubleRegs:$src1, subreg_hireg)), 31)>,
          Requires<[HasV5T]>;
          */