-
Notifications
You must be signed in to change notification settings - Fork 10.9k
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
[LoongArch] Enable all -target-abi options #92222
Merged
wangleiat
merged 2 commits into
main
from
users/wangleiat/spr/loongarch-enable-all-target-abi-options
May 16, 2024
Merged
[LoongArch] Enable all -target-abi options #92222
wangleiat
merged 2 commits into
main
from
users/wangleiat/spr/loongarch-enable-all-target-abi-options
May 16, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Created using spr 1.3.5-bogner
@llvm/pr-subscribers-backend-loongarch Author: wanglei (wangleiat) ChangesThis is a pre-commit for modifying This patch will provide warning prompts when using those ABIs that have Full diff: https://github.com/llvm/llvm-project/pull/92222.diff 3 Files Affected:
diff --git a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
index 21d520656091c..6740563b90b45 100644
--- a/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
+++ b/llvm/lib/Target/LoongArch/LoongArchISelLowering.cpp
@@ -3575,15 +3575,14 @@ static bool CC_LoongArch(const DataLayout &DL, LoongArchABI::ABI ABI,
switch (ABI) {
default:
llvm_unreachable("Unexpected ABI");
- case LoongArchABI::ABI_ILP32S:
+ break;
case LoongArchABI::ABI_ILP32F:
case LoongArchABI::ABI_LP64F:
- report_fatal_error("Unimplemented ABI");
- break;
case LoongArchABI::ABI_ILP32D:
case LoongArchABI::ABI_LP64D:
UseGPRForFloat = !IsFixed;
break;
+ case LoongArchABI::ABI_ILP32S:
case LoongArchABI::ABI_LP64S:
break;
}
diff --git a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
index 928adb03f0989..7fd2526a57c94 100644
--- a/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
+++ b/llvm/lib/Target/LoongArch/MCTargetDesc/LoongArchBaseInfo.cpp
@@ -14,6 +14,7 @@
#include "LoongArchBaseInfo.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/TargetParser/Triple.h"
@@ -21,6 +22,36 @@ namespace llvm {
namespace LoongArchABI {
+// Check if ABI has been standardized; issue a warning if it hasn't.
+// FIXME: Once all ABIs are standardized, this will be removed.
+static ABI checkABIStandardized(ABI Abi) {
+ bool IsStandardized = false;
+ StringRef ABIName;
+ switch (Abi) {
+ case ABI_ILP32S:
+ ABIName = "ilp32s";
+ break;
+ case ABI_ILP32F:
+ ABIName = "ilp32f";
+ break;
+ case ABI_ILP32D:
+ ABIName = "ilp32d";
+ break;
+ case ABI_LP64F:
+ ABIName = "lp64f";
+ break;
+ case ABI_LP64S:
+ case ABI_LP64D:
+ IsStandardized = true;
+ break;
+ default:
+ llvm_unreachable("");
+ }
+ if (!IsStandardized)
+ errs() << "warning: '" << ABIName << "' has not been standardized\n";
+ return Abi;
+}
+
ABI computeTargetABI(const Triple &TT, StringRef ABIName) {
ABI ArgProvidedABI = getTargetABI(ABIName);
bool Is64Bit = TT.isArch64Bit();
@@ -50,7 +81,7 @@ ABI computeTargetABI(const Triple &TT, StringRef ABIName) {
errs() << "'" << ABIName
<< "' is not a recognized ABI for this target, ignoring and using "
"triple-implied ABI\n";
- return TripleABI;
+ return checkABIStandardized(TripleABI);
case LoongArchABI::ABI_ILP32S:
case LoongArchABI::ABI_ILP32F:
@@ -58,7 +89,7 @@ ABI computeTargetABI(const Triple &TT, StringRef ABIName) {
if (Is64Bit) {
errs() << "32-bit ABIs are not supported for 64-bit targets, ignoring "
"target-abi and using triple-implied ABI\n";
- return TripleABI;
+ return checkABIStandardized(TripleABI);
}
break;
@@ -68,7 +99,7 @@ ABI computeTargetABI(const Triple &TT, StringRef ABIName) {
if (!Is64Bit) {
errs() << "64-bit ABIs are not supported for 32-bit targets, ignoring "
"target-abi and using triple-implied ABI\n";
- return TripleABI;
+ return checkABIStandardized(TripleABI);
}
break;
}
@@ -77,7 +108,7 @@ ABI computeTargetABI(const Triple &TT, StringRef ABIName) {
errs() << "warning: triple-implied ABI conflicts with provided target-abi '"
<< ABIName << "', using target-abi\n";
- return ArgProvidedABI;
+ return checkABIStandardized(ArgProvidedABI);
}
ABI getTargetABI(StringRef ABIName) {
diff --git a/llvm/test/CodeGen/LoongArch/target-abi.ll b/llvm/test/CodeGen/LoongArch/target-abi.ll
new file mode 100644
index 0000000000000..de834c152b180
--- /dev/null
+++ b/llvm/test/CodeGen/LoongArch/target-abi.ll
@@ -0,0 +1,26 @@
+; RUN: llc --mtriple=loongarch32 --mattr=+d --target-abi=ilp32s < %s 2>&1 \
+; RUN: | FileCheck %s -DABI=ilp32s --check-prefixes=CHECK,WARNING
+; RUN: llc --mtriple=loongarch32 --mattr=+d --target-abi=ilp32f < %s 2>&1 \
+; RUN: | FileCheck %s -DABI=ilp32f --check-prefixes=CHECK,WARNING
+; RUN: llc --mtriple=loongarch32 --mattr=+d --target-abi=ilp32d < %s 2>&1 \
+; RUN: | FileCheck %s -DABI=ilp32d --check-prefixes=CHECK,WARNING
+; RUN: llc --mtriple=loongarch64 --mattr=+d --target-abi=lp64f < %s 2>&1 \
+; RUN: | FileCheck %s -DABI=lp64f --check-prefixes=CHECK,WARNING
+
+; RUN: llc --mtriple=loongarch64 --mattr=+d --target-abi=lp64s < %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK,NO-WARNING
+; RUN: llc --mtriple=loongarch64 --mattr=+d --target-abi=lp64d < %s 2>&1 \
+; RUN: | FileCheck %s --check-prefixes=CHECK,NO-WARNING
+
+;; Check if the ABI has been standardized; issue a warning if it hasn't.
+
+; WARNING: warning: '[[ABI]]' has not been standardized
+
+; NO-WARNING-NOT: warning
+
+define void @nothing() nounwind {
+; CHECK-LABEL: nothing:
+; CHECK: # %bb.0:
+; CHECK-NEXT: ret
+ ret void
+}
|
xen0n
reviewed
May 15, 2024
Created using spr 1.3.5-bogner
xen0n
approved these changes
May 15, 2024
SixWeining
approved these changes
May 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a pre-commit for modifying
computeTargetABI
logic.This patch will provide warning prompts when using those ABIs that have
not yet been standardized.