Skip to content

Commit 4b92f1e

Browse files
committed
[SelectionDAG][RISCV] Support STACK/PATCHPOINT in SoftenFloatOperand.
Test float/double on RISC-V without F extension.
1 parent c528f60 commit 4b92f1e

File tree

3 files changed

+83
-3
lines changed

3 files changed

+83
-3
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1172,6 +1172,12 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
11721172
case ISD::FAKE_USE:
11731173
Res = SoftenFloatOp_FAKE_USE(N);
11741174
break;
1175+
case ISD::STACKMAP:
1176+
Res = SoftenFloatOp_STACKMAP(N, OpNo);
1177+
break;
1178+
case ISD::PATCHPOINT:
1179+
Res = SoftenFloatOp_PATCHPOINT(N, OpNo);
1180+
break;
11751181
}
11761182

11771183
// If the result is null, the sub-method took care of registering results etc.
@@ -1512,6 +1518,20 @@ SDValue DAGTypeLegalizer::SoftenFloatOp_FAKE_USE(SDNode *N) {
15121518
N->getOperand(0), Op1);
15131519
}
15141520

1521+
SDValue DAGTypeLegalizer::SoftenFloatOp_STACKMAP(SDNode *N, unsigned OpNo) {
1522+
assert(OpNo > 1); // Because the first two arguments are guaranteed legal.
1523+
SmallVector<SDValue> NewOps(N->ops());
1524+
NewOps[OpNo] = GetSoftenedFloat(NewOps[OpNo]);
1525+
return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
1526+
}
1527+
1528+
SDValue DAGTypeLegalizer::SoftenFloatOp_PATCHPOINT(SDNode *N, unsigned OpNo) {
1529+
assert(OpNo >= 7);
1530+
SmallVector<SDValue> NewOps(N->ops());
1531+
NewOps[OpNo] = GetSoftenedFloat(NewOps[OpNo]);
1532+
return SDValue(DAG.UpdateNodeOperands(N, NewOps), 0);
1533+
}
1534+
15151535
//===----------------------------------------------------------------------===//
15161536
// Float Result Expansion
15171537
//===----------------------------------------------------------------------===//

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,8 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
658658
SDValue SoftenFloatOp_ATOMIC_STORE(SDNode *N, unsigned OpNo);
659659
SDValue SoftenFloatOp_FCOPYSIGN(SDNode *N);
660660
SDValue SoftenFloatOp_FAKE_USE(SDNode *N);
661+
SDValue SoftenFloatOp_STACKMAP(SDNode *N, unsigned OpNo);
662+
SDValue SoftenFloatOp_PATCHPOINT(SDNode *N, unsigned OpNo);
661663

662664
//===--------------------------------------------------------------------===//
663665
// Float Expansion Support: LegalizeFloatTypes.cpp

llvm/test/CodeGen/RISCV/rv64-stackmap.ll

Lines changed: 61 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
; CHECK-NEXT: .byte 0
88
; CHECK-NEXT: .half 0
99
; Num Functions
10-
; CHECK-NEXT: .word 12
10+
; CHECK-NEXT: .word 13
1111
; Num LargeConstants
12-
; CHECK-NEXT: .word 2
12+
; CHECK-NEXT: .word 3
1313
; Num Callsites
14-
; CHECK-NEXT: .word 16
14+
; CHECK-NEXT: .word 17
1515

1616
; Functions and stack size
1717
; CHECK-NEXT: .quad constantargs
@@ -50,10 +50,14 @@
5050
; CHECK-NEXT: .quad needsStackRealignment
5151
; CHECK-NEXT: .quad -1
5252
; CHECK-NEXT: .quad 1
53+
; CHECK-NEXT: .quad floats
54+
; CHECK-NEXT: .quad 16
55+
; CHECK-NEXT: .quad 1
5356

5457
; Num LargeConstants
5558
; CHECK-NEXT: .quad 4294967295
5659
; CHECK-NEXT: .quad 4294967296
60+
; CHECK-NEXT: .quad 4609434218613702656
5761

5862
; Constant arguments
5963
;
@@ -379,6 +383,60 @@ define void @needsStackRealignment() {
379383
}
380384
declare void @escape_values(...)
381385

386+
; CHECK-LABEL: .word .L{{.*}}-floats
387+
; CHECK-NEXT: .half 0
388+
; Num Locations
389+
; CHECK-NEXT: .half 6
390+
; Loc 0: constant float as constant integer
391+
; CHECK-NEXT: .byte 4
392+
; CHECK-NEXT: .byte 0
393+
; CHECK-NEXT: .half 8
394+
; CHECK-NEXT: .half 0
395+
; CHECK-NEXT: .half 0
396+
; CHECK-NEXT: .word
397+
; Loc 0: constant double as large constant integer
398+
; CHECK-NEXT: .byte 5
399+
; CHECK-NEXT: .byte 0
400+
; CHECK-NEXT: .half 8
401+
; CHECK-NEXT: .half 0
402+
; CHECK-NEXT: .half 0
403+
; CHECK-NEXT: .word
404+
; Loc 1: float value in X register
405+
; CHECK-NEXT: .byte 1
406+
; CHECK-NEXT: .byte 0
407+
; CHECK-NEXT: .half 8
408+
; CHECK-NEXT: .half 10
409+
; CHECK-NEXT: .half 0
410+
; CHECK-NEXT: .word
411+
; Loc 2: double value in X register
412+
; CHECK-NEXT: .byte 1
413+
; CHECK-NEXT: .byte 0
414+
; CHECK-NEXT: .half 8
415+
; CHECK-NEXT: .half 11
416+
; CHECK-NEXT: .half 0
417+
; CHECK-NEXT: .word
418+
; Loc 3: float on stack
419+
; CHECK-NEXT: .byte 2
420+
; CHECK-NEXT: .byte 0
421+
; CHECK-NEXT: .half 8
422+
; CHECK-NEXT: .half 2
423+
; CHECK-NEXT: .half 0
424+
; CHECK-NEXT: .word
425+
; Loc 4: double on stack
426+
; CHECK-NEXT: .byte 2
427+
; CHECK-NEXT: .byte 0
428+
; CHECK-NEXT: .half 8
429+
; CHECK-NEXT: .half 2
430+
; CHECK-NEXT: .half 0
431+
; CHECK-NEXT: .word
432+
define void @floats(float %f, double %g) {
433+
%ff = alloca float
434+
%gg = alloca double
435+
call void (i64, i32, ...) @llvm.experimental.stackmap(i64 888, i32 0, float 1.25,
436+
double 1.5, float %f, double %g, ptr %ff, ptr %gg)
437+
ret void
438+
}
439+
382440
declare void @llvm.experimental.stackmap(i64, i32, ...)
383441
declare void @llvm.experimental.patchpoint.void(i64, i32, ptr, i32, ...)
384442
declare i64 @llvm.experimental.patchpoint.i64(i64, i32, ptr, i32, ...)

0 commit comments

Comments
 (0)