Skip to content

Commit 3fe8141

Browse files
authored
[clang][RISCV] Change default abi with f extension but without d extension (#73489)
Now we have default abi lp64 for rv64if and ilp32 for rv32if, which is different with riscv-gnu-toolchain. In https://github.com/riscv-collab/riscv-gnu-toolchain/blob/8e9fb09a0c4b1e566492ee6f42e8c1fa5ef7e0c2/configure#L3385 when have f and not d, it prefers lp64f/ilp32f but no soft float. This patch tries to make their behaviors consistent.
1 parent 9cdb825 commit 3fe8141

14 files changed

+45
-38
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,9 @@ RISC-V Support
968968
- Unaligned memory accesses can be toggled by ``-m[no-]unaligned-access`` or the
969969
aliases ``-m[no-]strict-align``.
970970

971+
- Default ABI with F but without D was changed to ilp32f for RV32 and to lp64f
972+
for RV64.
973+
971974
CUDA/HIP Language Changes
972975
^^^^^^^^^^^^^^^^^^^^^^^^^
973976

clang/test/Driver/riscv-abi.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
55
// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32imc 2>&1 \
66
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
7-
// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32imf 2>&1 \
8-
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
97
// RUN: %clang --target=riscv32-unknown-elf -x assembler %s -### 2>&1 \
108
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
119
// RUN: %clang --target=riscv32-unknown-elf -x assembler %s -### \
@@ -24,6 +22,10 @@
2422

2523
// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32if -mabi=ilp32f 2>&1 \
2624
// RUN: | FileCheck -check-prefix=CHECK-ILP32F %s
25+
// RUN: %clang --target=riscv32-unknown-elf %s -### -mabi=ilp32f 2>&1 \
26+
// RUN: | FileCheck -check-prefix=CHECK-ILP32F %s
27+
// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32if 2>&1 \
28+
// RUN: | FileCheck -check-prefix=CHECK-ILP32F %s
2729

2830
// CHECK-ILP32F: "-target-abi" "ilp32f"
2931

@@ -51,16 +53,18 @@
5153
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
5254
// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64imc 2>&1 \
5355
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
54-
// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64imf 2>&1 \
55-
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
5656
// RUN: %clang --target=riscv64-unknown-elf -x assembler %s -### 2>&1 \
5757
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
5858
// RUN: %clang --target=riscv64-unknown-elf -x assembler %s -### \
5959
// RUN: -mabi=lp64 2>&1 | FileCheck -check-prefix=CHECK-LP64 %s
6060

6161
// CHECK-LP64: "-target-abi" "lp64"
6262

63-
// RUN: not %clang --target=riscv64-unknown-elf %s -### -march=rv64f -mabi=lp64f 2>&1 \
63+
// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64if -mabi=lp64f 2>&1 \
64+
// RUN: | FileCheck -check-prefix=CHECK-LP64F %s
65+
// RUN: %clang --target=riscv64-unknown-elf %s -### -mabi=lp64f 2>&1 \
66+
// RUN: | FileCheck -check-prefix=CHECK-LP64F %s
67+
// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64if 2>&1 \
6468
// RUN: | FileCheck -check-prefix=CHECK-LP64F %s
6569

6670
// CHECK-LP64F: "-target-abi" "lp64f"

clang/test/Driver/riscv-cpus.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,15 @@
113113
// MCPU-SIFIVE-E24: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f"
114114
// MCPU-SIFIVE-E24: "-target-feature" "+c"
115115
// MCPU-SIFIVE-E24: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
116-
// MCPU-SIFIVE-E24: "-target-abi" "ilp32"
116+
// MCPU-SIFIVE-E24: "-target-abi" "ilp32f"
117117

118118
// mcpu with default march
119119
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-e34 | FileCheck -check-prefix=MCPU-SIFIVE-E34 %s
120120
// MCPU-SIFIVE-E34: "-nostdsysteminc" "-target-cpu" "sifive-e34"
121121
// MCPU-SIFIVE-E34: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f"
122122
// MCPU-SIFIVE-E34: "-target-feature" "+c"
123123
// MCPU-SIFIVE-E34: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
124-
// MCPU-SIFIVE-E34: "-target-abi" "ilp32"
124+
// MCPU-SIFIVE-E34: "-target-abi" "ilp32f"
125125

126126
// mcpu with mabi option
127127
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-s21 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-S21 %s
@@ -178,7 +178,7 @@
178178
// MCPU-SIFIVE-E76: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f"
179179
// MCPU-SIFIVE-E76: "-target-feature" "+c"
180180
// MCPU-SIFIVE-E76: "-target-feature" "+zicsr" "-target-feature" "+zifencei"
181-
// MCPU-SIFIVE-E76: "-target-abi" "ilp32"
181+
// MCPU-SIFIVE-E76: "-target-abi" "ilp32f"
182182

183183
// mcpu with mabi option
184184
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-u74 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U74 %s

llvm/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Changes to the RISC-V Backend
140140
* The Zfa extension version was upgraded to 1.0 and is no longer experimental.
141141
* Zihintntl extension version was upgraded to 1.0 and is no longer experimental.
142142
* Intrinsics were added for Zk*, Zbb, and Zbc. See https://github.com/riscv-non-isa/riscv-c-api-doc/blob/master/riscv-c-api.md#scalar-bit-manipulation-extension-intrinsics
143+
* Default ABI with F but without D was changed to ilp32f for RV32 and to lp64f for RV64.
143144

144145
Changes to the WebAssembly Backend
145146
----------------------------------

llvm/lib/Support/RISCVISAInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,12 +1292,16 @@ StringRef RISCVISAInfo::computeDefaultABI() const {
12921292
if (XLen == 32) {
12931293
if (hasExtension("d"))
12941294
return "ilp32d";
1295+
if (hasExtension("f"))
1296+
return "ilp32f";
12951297
if (hasExtension("e"))
12961298
return "ilp32e";
12971299
return "ilp32";
12981300
} else if (XLen == 64) {
12991301
if (hasExtension("d"))
13001302
return "lp64d";
1303+
if (hasExtension("f"))
1304+
return "lp64f";
13011305
if (hasExtension("e"))
13021306
return "lp64e";
13031307
return "lp64";

llvm/test/CodeGen/RISCV/callee-saved-fpr32s.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
2+
; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi ilp32 -verify-machineinstrs < %s \
33
; RUN: | FileCheck %s -check-prefix=ILP32
4-
; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
4+
; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi lp64 -verify-machineinstrs < %s \
55
; RUN: | FileCheck %s -check-prefix=LP64
66
; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi ilp32f -verify-machineinstrs < %s \
77
; RUN: | FileCheck %s -check-prefix=ILP32F

llvm/test/CodeGen/RISCV/calling-conv-half.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32I
33
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV64I
4-
; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32IF
5-
; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV64IF
4+
; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi=ilp32 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32IF
5+
; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi=lp64 -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV64IF
66
; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi=ilp32f -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32-ILP32F
77
; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi=lp64f -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV64-LP64F
88
; RUN: llc -mtriple=riscv32 -mattr=+f,+zfhmin -target-abi=ilp32f -verify-machineinstrs < %s | FileCheck %s -check-prefix=RV32-ILP32ZFHMIN

llvm/test/CodeGen/RISCV/calling-conv-rv32f-ilp32.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
2+
; RUN: llc -mtriple=riscv32 -mattr=+f -target-abi=ilp32 -verify-machineinstrs < %s \
33
; RUN: | FileCheck %s -check-prefix=RV32IF
44

55
; Exercises the ILP32 calling convention code in the case that f32 is a legal

llvm/test/CodeGen/RISCV/calling-conv-vector-float.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2-
; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
2+
; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi=lp64 -verify-machineinstrs < %s \
33
; RUN: | FileCheck -check-prefix=RV64 %s
44
; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi=lp64f -verify-machineinstrs < %s \
55
; RUN: | FileCheck -check-prefix=RV64LP64F %s

llvm/test/CodeGen/RISCV/float-bitmanip-dagcombines.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
33
; RUN: | FileCheck -check-prefix=RV32I %s
4-
; RUN: llc -mtriple=riscv32 -mattr=+f -verify-machineinstrs < %s \
4+
; RUN: llc -mtriple=riscv32 -target-abi ilp32 -mattr=+f -verify-machineinstrs < %s \
55
; RUN: | FileCheck -check-prefix=RV32IF %s
6-
; RUN: llc -mtriple=riscv32 -mattr=+zfinx -verify-machineinstrs < %s \
6+
; RUN: llc -mtriple=riscv32 -target-abi ilp32 -mattr=+zfinx -verify-machineinstrs < %s \
77
; RUN: | FileCheck -check-prefix=RV32IZFINX %s
88
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
99
; RUN: | FileCheck -check-prefix=RV64I %s
10-
; RUN: llc -mtriple=riscv64 -mattr=+f -verify-machineinstrs < %s \
10+
; RUN: llc -mtriple=riscv64 -target-abi lp64 -mattr=+f -verify-machineinstrs < %s \
1111
; RUN: | FileCheck -check-prefix=RV64IF %s
12-
; RUN: llc -mtriple=riscv64 -mattr=+zfinx -verify-machineinstrs < %s \
12+
; RUN: llc -mtriple=riscv64 -target-abi lp64 -mattr=+zfinx -verify-machineinstrs < %s \
1313
; RUN: | FileCheck -check-prefix=RV64IZFINX %s
1414

1515
; This file tests cases where simple floating point operations can be

llvm/test/CodeGen/RISCV/float-frem.ll

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,7 @@ define float @frem_f32(float %a, float %b) nounwind {
1919
;
2020
; RV64IF-LABEL: frem_f32:
2121
; RV64IF: # %bb.0:
22-
; RV64IF-NEXT: addi sp, sp, -16
23-
; RV64IF-NEXT: sd ra, 8(sp) # 8-byte Folded Spill
24-
; RV64IF-NEXT: call fmodf@plt
25-
; RV64IF-NEXT: ld ra, 8(sp) # 8-byte Folded Reload
26-
; RV64IF-NEXT: addi sp, sp, 16
27-
; RV64IF-NEXT: ret
22+
; RV64IF-NEXT: tail fmodf@plt
2823
;
2924
; RV32IZFINX-LABEL: frem_f32:
3025
; RV32IZFINX: # %bb.0:

llvm/test/CodeGen/RISCV/float-select-verify.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: llc -mtriple=riscv64 -mattr=+f -stop-after=finalize-isel < %s | FileCheck %s
2+
; RUN: llc -mtriple=riscv64 -mattr=+f -target-abi lp64 -stop-after=finalize-isel < %s | FileCheck %s
33

44
define dso_local void @buz(i1 %pred, float %a, float %b) {
55
; CHECK-LABEL: name: buz

llvm/test/CodeGen/RISCV/half-bitmanip-dagcombines.ll

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
22
; RUN: llc -mtriple=riscv32 -verify-machineinstrs < %s \
33
; RUN: | FileCheck -check-prefix=RV32I %s
4-
; RUN: llc -mtriple=riscv32 -mattr=+zfh -verify-machineinstrs \
4+
; RUN: llc -mtriple=riscv32 -target-abi ilp32 -mattr=+zfh -verify-machineinstrs \
55
; RUN: < %s | FileCheck -check-prefix=RV32IZFH %s
66
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
77
; RUN: | FileCheck -check-prefix=RV64I %s
8-
; RUN: llc -mtriple=riscv64 -mattr=+zfh -verify-machineinstrs \
8+
; RUN: llc -mtriple=riscv64 -target-abi lp64 -mattr=+zfh -verify-machineinstrs \
99
; RUN: < %s | FileCheck -check-prefix=RV64IZFH %s
10-
; RUN: llc -mtriple=riscv32 -mattr=+zhinx -verify-machineinstrs \
10+
; RUN: llc -mtriple=riscv32 -target-abi ilp32 -mattr=+zhinx -verify-machineinstrs \
1111
; RUN: < %s | FileCheck -check-prefix=RV32IZHINX %s
12-
; RUN: llc -mtriple=riscv64 -mattr=+zhinx -verify-machineinstrs \
12+
; RUN: llc -mtriple=riscv64 -target-abi lp64 -mattr=+zhinx -verify-machineinstrs \
1313
; RUN: < %s | FileCheck -check-prefix=RV64IZHINX %s
14-
; RUN: llc -mtriple=riscv32 -mattr=+zfhmin -verify-machineinstrs \
14+
; RUN: llc -mtriple=riscv32 -target-abi ilp32 -mattr=+zfhmin -verify-machineinstrs \
1515
; RUN: < %s | FileCheck -check-prefix=RV32IZFHMIN %s
16-
; RUN: llc -mtriple=riscv64 -verify-machineinstrs < %s \
16+
; RUN: llc -mtriple=riscv64 -target-abi lp64 -verify-machineinstrs < %s \
1717
; RUN: | FileCheck -check-prefix=RV64I %s
18-
; RUN: llc -mtriple=riscv64 -mattr=+zfhmin -verify-machineinstrs \
18+
; RUN: llc -mtriple=riscv64 -target-abi lp64 -mattr=+zfhmin -verify-machineinstrs \
1919
; RUN: < %s | FileCheck -check-prefix=RV64IZFHMIN %s
20-
; RUN: llc -mtriple=riscv32 -mattr=+zhinxmin -verify-machineinstrs \
20+
; RUN: llc -mtriple=riscv32 -target-abi ilp32 -mattr=+zhinxmin -verify-machineinstrs \
2121
; RUN: < %s | FileCheck --check-prefixes=RVIZHINXMIN,RV32IZHINXMIN %s
22-
; RUN: llc -mtriple=riscv64 -mattr=+zhinxmin -verify-machineinstrs \
22+
; RUN: llc -mtriple=riscv64 -target-abi lp64 -mattr=+zhinxmin -verify-machineinstrs \
2323
; RUN: < %s | FileCheck --check-prefixes=RVIZHINXMIN,RV64IZHINXMIN %s
2424

2525
; This file tests cases where simple floating point operations can be

llvm/test/CodeGen/RISCV/half-fcmp.ll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
; RUN: llc -mtriple=riscv64 -mattr=+zhinx -verify-machineinstrs \
99
; RUN: -target-abi lp64 < %s | FileCheck -check-prefix=CHECKIZHINX %s
1010
; RUN: llc -mtriple=riscv32 -mattr=+zfh -verify-machineinstrs \
11-
; RUN: < %s | FileCheck -check-prefix=RV32I %s
11+
; RUN: -target-abi ilp32 < %s | FileCheck -check-prefix=RV32I %s
1212
; RUN: llc -mtriple=riscv64 -mattr=+zfh -verify-machineinstrs \
13-
; RUN: < %s | FileCheck -check-prefix=RV64I %s
13+
; RUN: -target-abi lp64 < %s | FileCheck -check-prefix=RV64I %s
1414
; RUN: llc -mtriple=riscv32 -mattr=+zfhmin -verify-machineinstrs \
1515
; RUN: -target-abi ilp32f < %s | FileCheck -check-prefix=CHECKIZFHMIN-ILP32F-LP64F %s
1616
; RUN: llc -mtriple=riscv64 -mattr=+zfhmin -verify-machineinstrs \
1717
; RUN: -target-abi lp64f < %s | FileCheck -check-prefix=CHECKIZFHMIN-ILP32F-LP64F %s
1818
; RUN: llc -mtriple=riscv32 -mattr=+zfhmin -verify-machineinstrs \
19-
; RUN: < %s | FileCheck -check-prefix=CHECKIZFHMIN %s
19+
; RUN: -target-abi ilp32 < %s | FileCheck -check-prefix=CHECKIZFHMIN %s
2020
; RUN: llc -mtriple=riscv64 -mattr=+zfhmin -verify-machineinstrs \
21-
; RUN: < %s | FileCheck -check-prefix=CHECKIZFHMIN %s
21+
; RUN: -target-abi lp64 < %s | FileCheck -check-prefix=CHECKIZFHMIN %s
2222
; RUN: llc -mtriple=riscv32 -mattr=+zhinxmin -verify-machineinstrs \
2323
; RUN: -target-abi ilp32 < %s | FileCheck -check-prefix=CHECKIZHINXMIN %s
2424
; RUN: llc -mtriple=riscv64 -mattr=+zhinxmin -verify-machineinstrs \

0 commit comments

Comments
 (0)