-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
0055-Xtensa-Implement-rest-part-of-FP-instructions.patch
606 lines (578 loc) · 20.3 KB
/
0055-Xtensa-Implement-rest-part-of-FP-instructions.patch
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
From 28cea9125427e9cc6b28344c6f98f5decda2adde Mon Sep 17 00:00:00 2001
From: Andrei Safronov <safronov@espressif.com>
Date: Wed, 5 Apr 2023 00:59:05 +0300
Subject: [PATCH 055/158] [Xtensa] Implement rest part of FP instructions.
Add FP instructions test, format FP instruction descriptions.
---
.../MCTargetDesc/XtensaMCCodeEmitter.cpp | 6 +-
llvm/lib/Target/Xtensa/XtensaISelLowering.cpp | 10 +-
llvm/lib/Target/Xtensa/XtensaInstrInfo.cpp | 4 +-
llvm/lib/Target/Xtensa/XtensaInstrInfo.td | 263 ++++++++++++------
llvm/test/MC/Xtensa/xtensa-valid-float.s | 178 ++++++++++++
5 files changed, 366 insertions(+), 95 deletions(-)
create mode 100644 llvm/test/MC/Xtensa/xtensa-valid-float.s
diff --git a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
index c204e0866e44..8d30edafb54a 100644
--- a/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
+++ b/llvm/lib/Target/Xtensa/MCTargetDesc/XtensaMCCodeEmitter.cpp
@@ -280,8 +280,10 @@ XtensaMCCodeEmitter::getMemRegEncoding(const MCInst &MI, unsigned OpNo,
case Xtensa::L32I:
case Xtensa::S32I_N:
case Xtensa::L32I_N:
- case Xtensa::S32F:
- case Xtensa::L32F:
+ case Xtensa::SSI:
+ case Xtensa::SSIP:
+ case Xtensa::LSI:
+ case Xtensa::LSIP:
case Xtensa::S32C1I:
if (Res & 0x3) {
report_fatal_error("Unexpected operand value!");
diff --git a/llvm/lib/Target/Xtensa/XtensaISelLowering.cpp b/llvm/lib/Target/Xtensa/XtensaISelLowering.cpp
index a45cb71ad11c..73a56363493a 100644
--- a/llvm/lib/Target/Xtensa/XtensaISelLowering.cpp
+++ b/llvm/lib/Target/Xtensa/XtensaISelLowering.cpp
@@ -3185,13 +3185,19 @@ MachineBasicBlock *XtensaTargetLowering::EmitInstrWithCustomInserter(
case Xtensa::S16I:
case Xtensa::S32I:
case Xtensa::S32I_N:
- case Xtensa::S32F:
+ case Xtensa::SSI:
+ case Xtensa::SSIP:
+ case Xtensa::SSX:
+ case Xtensa::SSXP:
case Xtensa::L8UI:
case Xtensa::L16SI:
case Xtensa::L16UI:
case Xtensa::L32I:
case Xtensa::L32I_N:
- case Xtensa::L32F: {
+ case Xtensa::LSI:
+ case Xtensa::LSIP:
+ case Xtensa::LSX:
+ case Xtensa::LSXP: {
const MachineMemOperand &MMO = **MI.memoperands_begin();
if (MMO.isVolatile()) {
BuildMI(*MBB, MI, DL, TII.get(Xtensa::MEMW));
diff --git a/llvm/lib/Target/Xtensa/XtensaInstrInfo.cpp b/llvm/lib/Target/Xtensa/XtensaInstrInfo.cpp
index e957609c337d..6aea91163420 100644
--- a/llvm/lib/Target/Xtensa/XtensaInstrInfo.cpp
+++ b/llvm/lib/Target/Xtensa/XtensaInstrInfo.cpp
@@ -146,8 +146,8 @@ void XtensaInstrInfo::getLoadStoreOpcodes(const TargetRegisterClass *RC,
LoadOpcode = Xtensa::L32I;
StoreOpcode = Xtensa::S32I;
} else if (RC == &Xtensa::FPRRegClass) {
- LoadOpcode = Xtensa::L32F;
- StoreOpcode = Xtensa::S32F;
+ LoadOpcode = Xtensa::LSI;
+ StoreOpcode = Xtensa::SSI;
} else
llvm_unreachable("Unsupported regclass to load or store");
}
diff --git a/llvm/lib/Target/Xtensa/XtensaInstrInfo.td b/llvm/lib/Target/Xtensa/XtensaInstrInfo.td
index 38e8fac327cb..743d1c4a7573 100644
--- a/llvm/lib/Target/Xtensa/XtensaInstrInfo.td
+++ b/llvm/lib/Target/Xtensa/XtensaInstrInfo.td
@@ -962,85 +962,63 @@ def ADD_S : FPArith_RRR<0x00, 0x0A, "add.s", fadd, 1>;
def SUB_S : FPArith_RRR<0x01, 0x0A, "sub.s", fsub>;
def MUL_S : FPArith_RRR<0x02, 0x0A, "mul.s", fmul, 1>;
-def ABS_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
- "abs.s\t$r, $s",
- [(set FPR:$r, (fabs FPR:$s))]> {
- let t = 0x01;
-}
-
-def NEG_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
- "neg.s\t$r, $s",
- [(set FPR:$r, (fneg FPR:$s))]> {
- let t = 0x06;
-}
+// FP load instructions
+let mayLoad = 1, usesCustomInserter = 1, Predicates = [HasSingleFloat] in {
+ def LSI : RRI8_Inst<0x03, (outs FPR:$t), (ins mem32:$addr),
+ "lsi\t$t, $addr", []> {
+ bits<12> addr;
-def TRUNC_S : RRR_Inst<0x00, 0x0A, 0x09, (outs AR:$r), (ins FPR:$s),
- "trunc.s\t$r, $s, 0",
- [(set AR:$r, (fp_to_sint FPR:$s))]> {
- let t = 0x00;
-}
+ let r = 0x00;
+ let imm8{7-0} = addr{11-4};
+ let s{3-0} = addr{3-0};
+ }
-def UTRUNC_S : RRR_Inst<0x00, 0x0A, 0x0e, (outs AR:$r), (ins FPR:$s),
- "utrunc.s\t$r, $s, 0",
- [(set AR:$r, (fp_to_uint FPR:$s))]> {
- let t = 0x00;
-}
+ def LSIP : RRI8_Inst<0x03, (outs FPR:$t), (ins mem32:$addr),
+ "lsip\t$t, $addr", []> {
+ bits<12> addr;
-def FLOAT_S : RRR_Inst<0x00, 0x0A, 0x0c, (outs FPR:$r), (ins AR:$s),
- "float.s\t$r, $s, 0",
- [(set FPR:$r, (sint_to_fp AR:$s))]> {
- let t = 0x00;
-}
+ let r = 0x08;
+ let imm8{7-0} = addr{11-4};
+ let s{3-0} = addr{3-0};
+ }
-def UFLOAT_S : RRR_Inst<0x00, 0x0A, 0x0D, (outs FPR:$r), (ins AR:$s),
- "ufloat.s\t$r, $s, 0",
- [(set FPR:$r, (uint_to_fp AR:$s))]> {
- let t = 0x00;
-}
+ def LSX : RRR_Inst<0x00, 0x08, 0x00, (outs), (ins FPR:$r, AR:$s, AR:$t),
+ "lsx\t$r, $s, $t", []>;
-def RFR : RRR_Inst<0x00, 0x0A, 0x0f, (outs AR:$r), (ins FPR:$s),
- "rfr\t$r, $s",
- [(set AR:$r, (bitconvert FPR:$s))]> {
- let t = 0x04;
+ def LSXP : RRR_Inst<0x00, 0x08, 0x01, (outs), (ins FPR:$r, AR:$s, AR:$t),
+ "lsxp\t$r, $s, $t", []>;
}
-def WFR : RRR_Inst<0x00, 0x0A, 0x0f, (outs FPR:$r), (ins AR:$s),
- "wfr\t$r, $s",
- [(set FPR:$r, (bitconvert AR:$s))]> {
- let t = 0x05;
-}
+def : Pat<(f32 (load addr_ish4:$addr)), (f32 (LSI mem32:$addr))>;
-// FP load instructions
-let mayLoad = 1, usesCustomInserter = 1, Predicates = [HasSingleFloat] in {
- class LoadF_RRI8<bits<4> oper, string instrAsm, SDPatternOperator opNode,
- ComplexPattern addrOp,Operand memOp>: RRI8_Inst<0x03, (outs FPR:$t), (ins memOp:$addr),
- instrAsm#"\t$t, $addr",
- [(set FPR:$t, (opNode addrOp:$addr))]> {
+// FP store instructions
+let mayStore = 1, usesCustomInserter = 1, Predicates = [HasSingleFloat] in {
+ def SSI : RRI8_Inst<0x03, (outs), (ins FPR:$t, mem32:$addr),
+ "ssi\t$t, $addr", []> {
bits<12> addr;
- let r = oper;
+ let r = 0x04;
let imm8{7-0} = addr{11-4};
let s{3-0} = addr{3-0};
}
-}
-
-def L32F : LoadF_RRI8<0x00, "lsi", load, addr_ish4, mem32>, Requires<[]>;
-// FP store instructions
-let mayStore = 1, usesCustomInserter = 1, Predicates = [HasSingleFloat] in {
- class StoreF_RRI8<bits<4> oper, string instrAsm, SDPatternOperator opNode,
- ComplexPattern addrOp, Operand memOp>: RRI8_Inst<0x03, (outs), (ins FPR:$t, memOp:$addr),
- instrAsm#"\t$t, $addr",
- [(opNode FPR:$t, addrOp:$addr)]> {
+ def SSIP : RRI8_Inst<0x03, (outs), (ins FPR:$t, mem32:$addr),
+ "ssip\t$t, $addr", []> {
bits<12> addr;
- let r = oper;
+ let r = 0x0C;
let imm8{7-0} = addr{11-4};
let s{3-0} = addr{3-0};
}
+
+ def SSX: RRR_Inst<0x00, 0x08, 0x04, (outs), (ins FPR:$r, AR:$s, AR:$t),
+ "ssx\t$r, $s, $t", []>;
+
+ def SSXP: RRR_Inst<0x00, 0x08, 0x05, (outs), (ins FPR:$r, AR:$s, AR:$t),
+ "ssxp\t$r, $s, $t", []>;
}
-def S32F : StoreF_RRI8<0x04, "ssi", store, addr_ish4, mem32>;
+def : Pat<(store FPR:$t, addr_ish4:$addr), (SSI FPR:$t, mem32:$addr)>;
// FP compare instructions
let isCompare = 1, Predicates = [HasSingleFloat] in {
@@ -1064,31 +1042,27 @@ def ULT_S : FCompare<0x05, 0x0b, "ult.s", Xtensa_cmpult, 0>;
def ULE_S : FCompare<0x07, 0x0b, "ule.s", Xtensa_cmpule, 0>;
def UN_S : FCompare<0x01, 0x0b, "un.s", Xtensa_cmpuo, 1>;
-//FP complex operations
-def MADD_S : RRR_Inst<0x00, 0x0A, 0x04, (outs FPR:$r), (ins FPR:$a, FPR:$s, FPR:$t),
- "madd.s\t$r, $s, $t",
- [(set FPR:$r, (Xtensa_madd FPR:$a, FPR:$s, FPR:$t))]>,
- Requires<[HasSingleFloat]> {
- let isCommutable = 0;
- let isReMaterializable = 0;
- let Constraints = "$r = $a";
+def ABS_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
+ "abs.s\t$r, $s",
+ [(set FPR:$r, (fabs FPR:$s))]> {
+ let t = 0x01;
}
-def MSUB_S : RRR_Inst<0x00, 0x0A, 0x05, (outs FPR:$r), (ins FPR:$a, FPR:$s, FPR:$t),
- "msub.s\t$r, $s, $t",
- [(set FPR:$r, (Xtensa_msub FPR:$a, FPR:$s, FPR:$t))]>,
- Requires<[HasSingleFloat]> {
- let isCommutable = 0;
- let isReMaterializable = 0;
- let Constraints = "$r = $a";
+def ADDEXP_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
+ "addexp.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
+ let t = 0x0E;
}
-//FP move operations
-def MOV_S : RRR_Inst<0x00, 0x0A, 0x0f, (outs FPR:$r), (ins FPR:$s),
- "mov.s\t$r, $s",
- [(set FPR:$r, (Xtensa_movs FPR:$s))]>, Requires<[HasSingleFloat]>
-{
- let t = 0x00;
+def ADDEXPM_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
+ "addexpm.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
+ let t = 0x0F;
+}
+
+def CEIL_S : RRR_Inst<0x00, 0x0A, 0x0B, (outs AR:$r), (ins FPR:$s, uimm4:$imm),
+ "ceil.s\t$r, $s, $imm", []>, Requires<[HasSingleFloat]> {
+ bits<4> imm;
+
+ let t = imm;
}
def CONST_S : RRR_Inst<0x00, 0x0a, 0x0f, (outs FPR:$r), (ins uimm4:$imm),
@@ -1104,11 +1078,40 @@ def DIV0_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
let t = 0x7;
}
+def DIVN_S : RRR_Inst<0x00, 0x0A, 0x07, (outs FPR:$r), (ins FPR:$s, FPR:$t),
+ "divn.s\t$r, $s, $t", []>, Requires<[HasSingleFloat]>;
+
+def FLOAT_S : RRR_Inst<0x00, 0x0A, 0x0c, (outs FPR:$r), (ins AR:$s, uimm4:$imm),
+ "float.s\t$r, $s, $imm", []> {
+ bits<4> imm;
+
+ let t = imm;
+}
+
+def : Pat<(f32 (sint_to_fp AR:$s)), (FLOAT_S AR:$s, 0)>;
+
+def FLOOR_S : RRR_Inst<0x00, 0x0A, 0x0A, (outs AR:$r), (ins FPR:$s, uimm4:$imm),
+ "floor.s\t$r, $s, $imm", []>, Requires<[HasSingleFloat]> {
+ bits<4> imm;
+
+ let t = imm;
+}
+
def MADDN_S : RRR_Inst<0x00, 0x0A, 0x06, (outs FPR:$r), (ins FPR:$s, FPR:$t),
"maddn.s\t$r, $s, $t", []>, Requires<[HasSingleFloat]> {
let isCommutable = 0;
}
+// FP multipy-add
+def MADD_S : RRR_Inst<0x00, 0x0A, 0x04, (outs FPR:$r), (ins FPR:$a, FPR:$s, FPR:$t),
+ "madd.s\t$r, $s, $t",
+ [(set FPR:$r, (Xtensa_madd FPR:$a, FPR:$s, FPR:$t))]>,
+ Requires<[HasSingleFloat]> {
+ let isCommutable = 0;
+ let isReMaterializable = 0;
+ let Constraints = "$r = $a";
+}
+
def MKDADJ_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
"mkdadj.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
let t = 0x0D;
@@ -1119,29 +1122,112 @@ def MKSADJ_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
let t = 0x0C;
}
-def ADDEXP_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
- "addexp.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
- let t = 0x0E;
+// FP move instructions
+def MOV_S : RRR_Inst<0x00, 0x0A, 0x0f, (outs FPR:$r), (ins FPR:$s),
+ "mov.s\t$r, $s",
+ [(set FPR:$r, (Xtensa_movs FPR:$s))]>, Requires<[HasSingleFloat]> {
+ let t = 0x00;
}
-def ADDEXPM_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
- "addexpm.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
- let t = 0x0F;
-}
+def MOVEQZ_S : RRR_Inst<0x00, 0x0B, 0x08, (outs FPR:$r), (ins FPR:$s, AR:$t),
+ "moveqz.s\t$r, $s, $t", []>, Requires<[HasSingleFloat]>;
-def DIVN_S : RRR_Inst<0x00, 0x0A, 0x07, (outs FPR:$r), (ins FPR:$s, FPR:$t),
- "divn.s\t$r, $s, $t", []>, Requires<[HasSingleFloat]>;
+def MOVF_S : RRR_Inst<0x00, 0x0B, 0x0C, (outs FPR:$r), (ins FPR:$s, BR:$t),
+ "movf.s\t$r, $s, $t", []>, Requires<[HasBoolean, HasSingleFloat]>;
+
+def MOVGEZ_S : RRR_Inst<0x00, 0x0B, 0x0B, (outs FPR:$r), (ins FPR:$s, AR:$t),
+ "movgez.s\t$r, $s, $t", []>, Requires<[HasSingleFloat]>;
+
+def MOVLTZ_S : RRR_Inst<0x00, 0x0B, 0x0A, (outs FPR:$r), (ins FPR:$s, AR:$t),
+ "movltz.s\t$r, $s, $t", []>, Requires<[HasSingleFloat]>;
+
+def MOVNEZ_S : RRR_Inst<0x00, 0x0B, 0x09, (outs FPR:$r), (ins FPR:$s, AR:$t),
+ "movnez.s\t$r, $s, $t", []>, Requires<[HasSingleFloat]>;
+
+def MOVT_S : RRR_Inst<0x00, 0x0B, 0x0D, (outs FPR:$r), (ins FPR:$s, BR:$t),
+ "movt.s\t$r, $s, $t", []>, Requires<[HasBoolean, HasSingleFloat]>;
+
+// FP multipy-sub
+def MSUB_S : RRR_Inst<0x00, 0x0A, 0x05, (outs FPR:$r), (ins FPR:$a, FPR:$s, FPR:$t),
+ "msub.s\t$r, $s, $t",
+ [(set FPR:$r, (Xtensa_msub FPR:$a, FPR:$s, FPR:$t))]>, Requires<[HasSingleFloat]> {
+ let isCommutable = 0;
+ let isReMaterializable = 0;
+ let Constraints = "$r = $a";
+}
def NEXP01_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
"nexp01.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
let t = 0x0B;
}
+def NEG_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
+ "neg.s\t$r, $s",
+ [(set FPR:$r, (fneg FPR:$s))]> {
+ let t = 0x06;
+}
+
+def RECIP0_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
+ "recip0.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
+ let t = 0x08;
+}
+
+def RFR : RRR_Inst<0x00, 0x0A, 0x0f, (outs AR:$r), (ins FPR:$s),
+ "rfr\t$r, $s",
+ [(set AR:$r, (bitconvert FPR:$s))]> {
+ let t = 0x04;
+}
+
+def ROUND_S : RRR_Inst<0x00, 0x0A, 0x08, (outs AR:$r), (ins FPR:$s, uimm4:$imm),
+ "round.s\t$r, $s, $imm", []>, Requires<[HasSingleFloat]> {
+ bits<4> imm;
+
+ let t = imm;
+}
+
+def RSQRT0_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
+ "rsqrt0.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
+ let t = 0x0A;
+}
+
def SQRT0_S : RRR_Inst<0x00, 0x0A, 0x0F, (outs FPR:$r), (ins FPR:$s),
"sqrt0.s\t$r, $s", []>, Requires<[HasSingleFloat]> {
let t = 0x09;
}
+def TRUNC_S : RRR_Inst<0x00, 0x0A, 0x09, (outs AR:$r), (ins FPR:$s, uimm4:$imm),
+ "trunc.s\t$r, $s, $imm", []> {
+ bits<4> imm;
+
+ let t = imm;
+}
+
+def : Pat<(i32 (fp_to_sint FPR:$s)), (TRUNC_S FPR:$s, 0)>;
+
+def UFLOAT_S : RRR_Inst<0x00, 0x0A, 0x0D, (outs FPR:$r), (ins AR:$s, uimm4:$imm),
+ "ufloat.s\t$r, $s, $imm", []> {
+ bits<4> imm;
+
+ let t = imm;
+}
+
+def : Pat<(f32 (uint_to_fp AR:$s)), (UFLOAT_S AR:$s, 0)>;
+
+def UTRUNC_S : RRR_Inst<0x00, 0x0A, 0x0e, (outs AR:$r), (ins FPR:$s, uimm4:$imm),
+ "utrunc.s\t$r, $s, $imm", []> {
+ bits<4> imm;
+
+ let t = imm;
+}
+
+def : Pat<(i32 (fp_to_uint FPR:$s)), (UTRUNC_S FPR:$s, 0)>;
+
+def WFR : RRR_Inst<0x00, 0x0A, 0x0f, (outs FPR:$r), (ins AR:$s),
+ "wfr\t$r, $s",
+ [(set FPR:$r, (bitconvert AR:$s))]> {
+ let t = 0x05;
+}
+
// FP select operations
let usesCustomInserter = 1 in {
def SELECT_CC_FP_INT : Pseudo<(outs AR:$dst), (ins FPR:$lhs, FPR:$rhs, AR:$t, AR:$f, i32imm:$cond),
@@ -1154,7 +1240,6 @@ let usesCustomInserter = 1 in {
"!select_cc_fp_fp $dst, $lhs, $rhs, $t, $f, $cond",
[(set FPR:$dst, (Xtensa_select_cc_fp FPR:$lhs, FPR:$rhs, FPR:$t, FPR:$f, imm:$cond))]>;
}
-
//===----------------------------------------------------------------------===//
// Loop Instructions
//===----------------------------------------------------------------------===//
diff --git a/llvm/test/MC/Xtensa/xtensa-valid-float.s b/llvm/test/MC/Xtensa/xtensa-valid-float.s
new file mode 100644
index 000000000000..40405e93c584
--- /dev/null
+++ b/llvm/test/MC/Xtensa/xtensa-valid-float.s
@@ -0,0 +1,178 @@
+# RUN: llvm-mc %s -triple=xtensa -mattr=+fp -mattr=+bool -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
+
+.align 4
+LBL0:
+
+# CHECK-INST: abs.s f2, f3
+# CHECK: encoding: [0x10,0x23,0xfa]
+ abs.s f2, f3
+# CHECK-INST: add.s f2, f3, f4
+# CHECK: encoding: [0x40,0x23,0x0a]
+ add.s f2, f3, f4
+# CHECK-INST: addexp.s f2, f3
+# CHECK: encoding: [0xe0,0x23,0xfa]
+ addexp.s f2, f3
+# CHECK-INST: addexpm.s f2, f3
+# CHECK: encoding: [0xf0,0x23,0xfa]
+ addexpm.s f2, f3
+
+# CHECK-INST: ceil.s a2, f3, 5
+# CHECK: encoding: [0x50,0x23,0xba]
+ ceil.s a2, f3, 5
+# CHECK-INST: const.s f3, 5
+# CHECK: encoding: [0x30,0x35,0xfa]
+ const.s f3, 5
+
+# CHECK-INST: div0.s f2, f3
+# CHECK: encoding: [0x70,0x23,0xfa]
+ div0.s f2, f3
+# CHECK-INST: divn.s f2, f3, f4
+# CHECK: encoding: [0x40,0x23,0x7a]
+ divn.s f2, f3, f4
+
+# CHECK-INST: float.s f2, a3, 5
+# CHECK: encoding: [0x50,0x23,0xca]
+ float.s f2, a3, 5
+# CHECK-INST: floor.s a2, f3, 5
+# CHECK: encoding: [0x50,0x23,0xaa]
+ floor.s a2, f3, 5
+
+# CHECK-INST: lsi f2, a3, 8
+# CHECK: encoding: [0x23,0x03,0x02]
+ lsi f2, a3, 8
+# CHECK-INST: lsip f2, a3, 8
+# CHECK: encoding: [0x23,0x83,0x02]
+ lsip f2, a3, 8
+# CHECK-INST: lsx f2, a3, a4
+# CHECK: encoding: [0x40,0x23,0x08]
+ lsx f2, a3, a4
+# CHECK-INST: lsxp f2, a3, a4
+# CHECK: encoding: [0x40,0x23,0x18]
+ lsxp f2, a3, a4
+
+# CHECK-INST: madd.s f2, f3, f4
+# CHECK: encoding: [0x40,0x23,0x4a]
+ madd.s f2, f3, f4
+# CHECK-INST: maddn.s f2, f3, f4
+# CHECK: encoding: [0x40,0x23,0x6a]
+ maddn.s f2, f3, f4
+# CHECK-INST: mkdadj.s f2, f3
+# CHECK: encoding: [0xd0,0x23,0xfa]
+ mkdadj.s f2, f3
+# CHECK-INST: mksadj.s f2, f3
+# CHECK: encoding: [0xc0,0x23,0xfa]
+ mksadj.s f2, f3
+
+# CHECK-INST: mov.s f2, f3
+# CHECK: encoding: [0x00,0x23,0xfa]
+ mov.s f2, f3
+
+# CHECK-INST: moveqz.s f2, f3, a4
+# CHECK: encoding: [0x40,0x23,0x8b]
+ moveqz.s f2, f3, a4
+# CHECK-INST: movf.s f2, f3, b0
+# CHECK: encoding: [0x00,0x23,0xcb]
+ movf.s f2, f3, b0
+# CHECK-INST: movgez.s f2, f3, a4
+# CHECK: encoding: [0x40,0x23,0xbb]
+ movgez.s f2, f3, a4
+# CHECK-INST: movltz.s f2, f3, a4
+# CHECK: encoding: [0x40,0x23,0xab]
+ movltz.s f2, f3, a4
+# CHECK-INST: movnez.s f2, f3, a4
+# CHECK: encoding: [0x40,0x23,0x9b]
+ movnez.s f2, f3, a4
+# CHECK-INST: movt.s f2, f3, b0
+# CHECK: encoding: [0x00,0x23,0xdb]
+ movt.s f2, f3, b0
+
+# CHECK-INST: msub.s f2, f3, f4
+# CHECK: encoding: [0x40,0x23,0x5a]
+ msub.s f2, f3, f4
+# CHECK-INST: mul.s f2, f3, f4
+# CHECK: encoding: [0x40,0x23,0x2a]
+ mul.s f2, f3, f4
+# CHECK-INST: neg.s f2, f3
+# CHECK: encoding: [0x60,0x23,0xfa]
+ neg.s f2, f3
+
+# CHECK-INST: nexp01.s f2, f3
+# CHECK: encoding: [0xb0,0x23,0xfa]
+ nexp01.s f2, f3
+
+# CHECK-INST: oeq.s b0, f2, f3
+# CHECK: encoding: [0x30,0x02,0x2b]
+ oeq.s b0, f2, f3
+# CHECK-INST: ole.s b0, f2, f3
+# CHECK: encoding: [0x30,0x02,0x6b]
+ ole.s b0, f2, f3
+# CHECK-INST: olt.s b0, f2, f3
+# CHECK: encoding: [0x30,0x02,0x4b]
+ olt.s b0, f2, f3
+
+# CHECK-INST: recip0.s f2, f3
+# CHECK: encoding: [0x80,0x23,0xfa]
+ recip0.s f2, f3
+
+# CHECK-INST: rfr a2, f3
+# CHECK: encoding: [0x40,0x23,0xfa]
+ rfr a2, f3
+
+# CHECK-INST: round.s a2, f3, 5
+# CHECK: encoding: [0x50,0x23,0x8a]
+ round.s a2, f3, 5
+# CHECK-INST: rsqrt0.s f2, f3
+# CHECK: encoding: [0xa0,0x23,0xfa]
+ rsqrt0.s f2, f3
+# CHECK-INST: sqrt0.s f2, f3
+# CHECK: encoding: [0x90,0x23,0xfa]
+ sqrt0.s f2, f3
+
+# CHECK-INST: ssi f2, a3, 8
+# CHECK: encoding: [0x23,0x43,0x02]
+ ssi f2, a3, 8
+# CHECK-INST: ssip f2, a3, 8
+# CHECK: encoding: [0x23,0xc3,0x02]
+ ssip f2, a3, 8
+# CHECK-INST: ssx f2, a3, a4
+# CHECK: encoding: [0x40,0x23,0x48]
+ ssx f2, a3, a4
+# CHECK-INST: ssxp f2, a3, a4
+# CHECK: encoding: [0x40,0x23,0x58]
+ ssxp f2, a3, a4
+
+# CHECK-INST: sub.s f2, f3, f4
+# CHECK: encoding: [0x40,0x23,0x1a]
+ sub.s f2, f3, f4
+
+# CHECK-INST: trunc.s a2, f3, 5
+# CHECK: encoding: [0x50,0x23,0x9a]
+ trunc.s a2, f3, 5
+
+# CHECK-INST: ueq.s b0, f2, f3
+# CHECK: encoding: [0x30,0x02,0x3b]
+ ueq.s b0, f2, f3
+
+# CHECK-INST: ufloat.s f2, a3, 5
+# CHECK: encoding: [0x50,0x23,0xda]
+ ufloat.s f2, a3, 5
+
+# CHECK-INST: ule.s b0, f2, f3
+# CHECK: encoding: [0x30,0x02,0x7b]
+ ule.s b0, f2, f3
+# CHECK-INST: ult.s b0, f2, f3
+# CHECK: encoding: [0x30,0x02,0x5b]
+ ult.s b0, f2, f3
+# CHECK-INST: un.s b0, f2, f3
+# CHECK: encoding: [0x30,0x02,0x1b]
+ un.s b0, f2, f3
+
+# CHECK-INST: utrunc.s a2, f3, 5
+# CHECK: encoding: [0x50,0x23,0xea]
+ utrunc.s a2, f3, 5
+
+# CHECK-INST: wfr f2, a3
+# CHECK: encoding: [0x50,0x23,0xfa]
+ wfr f2, a3
+
--
2.40.1