-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[clang][RISCV] Change default abi with f extension but without d extension #73489
Conversation
@llvm/pr-subscribers-clang-driver @llvm/pr-subscribers-backend-risc-v Author: Jianjian Guan (jacquesguan) ChangesNow 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. Full diff: https://github.com/llvm/llvm-project/pull/73489.diff 2 Files Affected:
diff --git a/clang/test/Driver/riscv-abi.c b/clang/test/Driver/riscv-abi.c
index e67f790e0de0e59..16568271564c797 100644
--- a/clang/test/Driver/riscv-abi.c
+++ b/clang/test/Driver/riscv-abi.c
@@ -4,8 +4,6 @@
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32imc 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
-// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32imf 2>&1 \
-// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang --target=riscv32-unknown-elf -x assembler %s -### 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang --target=riscv32-unknown-elf -x assembler %s -### \
@@ -24,6 +22,10 @@
// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32if -mabi=ilp32f 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32F %s
+// RUN: %clang --target=riscv32-unknown-elf %s -### -mabi=ilp32f 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-ILP32F %s
+// RUN: %clang --target=riscv32-unknown-elf %s -### -march=rv32if 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-ILP32F %s
// CHECK-ILP32F: "-target-abi" "ilp32f"
@@ -51,8 +53,6 @@
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64imc 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
-// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64imf 2>&1 \
-// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang --target=riscv64-unknown-elf -x assembler %s -### 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang --target=riscv64-unknown-elf -x assembler %s -### \
@@ -60,7 +60,11 @@
// CHECK-LP64: "-target-abi" "lp64"
-// RUN: not %clang --target=riscv64-unknown-elf %s -### -march=rv64f -mabi=lp64f 2>&1 \
+// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64if -mabi=lp64f 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LP64F %s
+// RUN: %clang --target=riscv64-unknown-elf %s -### -mabi=lp64f 2>&1 \
+// RUN: | FileCheck -check-prefix=CHECK-LP64F %s
+// RUN: %clang --target=riscv64-unknown-elf %s -### -march=rv64if 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64F %s
// CHECK-LP64F: "-target-abi" "lp64f"
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp
index 6322748430063ce..24d0d40cbc74ebc 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -1292,12 +1292,16 @@ StringRef RISCVISAInfo::computeDefaultABI() const {
if (XLen == 32) {
if (hasExtension("d"))
return "ilp32d";
+ if (hasExtension("f"))
+ return "ilp32f";
if (hasExtension("e"))
return "ilp32e";
return "ilp32";
} else if (XLen == 64) {
if (hasExtension("d"))
return "lp64d";
+ if (hasExtension("f"))
+ return "lp64f";
if (hasExtension("e"))
return "lp64e";
return "lp64";
|
b41c0a9
to
e03da61
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have similar patch before: https://reviews.llvm.org/D125947, so it LGTM as GCC's default behavior has changed. :-)
But please wait for others' opinions.
e03da61
to
daaa69a
Compare
short version: GCC isn't change. But I don't have strong opinion on this change since I believe user should explicitly specify that, otherwise it's really to screw up to select multi-lib or portability issue between different compilers. |
So why is there a difference between GCC and riscv-gnu-toolchain? If we set
|
soft ping... Any more advice? |
clang/test/Driver/riscv-cpus.c
Outdated
@@ -1,4 +1,4 @@ | |||
// Check target CPUs are correctly passed. | |||
·// Check target CPUs are correctly passed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Stray .
? Please fix
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
This can be simplified to "w/ f extension but w/o d extension" |
daaa69a
to
ce22351
Compare
I think this is reasonable, even I myself made such a change months ago in Phabracator, but finally not approved. |
As @kito-cheng has pointed out, we should fix multilib issue before landing this. It seems we don't generate multilib for ilp32f and lp64f in riscv-gnu-toolchain? |
This is a user-facing change that definitely needs to be acknowledged in the release notes (clang/docs/ReleaseNotes.rst) I agree with you that it seems more intuitive that a -march=rv32imaf invocation should default to ilp32f just as -march=rv32imafd defaults to ilp32d. I slightly disagree that this patch aligns us to GCC, because as I understood Kito's comment the GCC behaviour is really depending on what default ABI the toolchain was configured with. For a toolchain that defaults to ilp32d, presumably -march=rv32imaf still ends up with ilp32? That said, with the GCC cross-compilation model being so different to clang I don't think we necessarily need to match precisely, so I'm not opposed to a more intuitive default. |
I think the conclusion from the LLVM sync-up call was that everyone happy to move in this direction, so please add the release note and we can do a final review. Thanks! |
ce22351
to
dcc7164
Compare
Done, added release note. |
Thanks! Sorry I wasn't specific about this, but we need a Clang release note as well. |
…nsion 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 but not, it prefers lp64f/ilp32f but no soft float. This patch tries to make their behaviors consistent.
dcc7164
to
4e54425
Compare
Done, added Clang release note too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.