[llvm-branch-commits] [LoongArch] Refactor LoongArchABI::computeTargetABI (PR #92223)
WÁNG Xuěruì via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed May 15 02:24:25 PDT 2024
================
@@ -52,63 +53,129 @@ static ABI checkABIStandardized(ABI Abi) {
return Abi;
}
-ABI computeTargetABI(const Triple &TT, StringRef ABIName) {
- ABI ArgProvidedABI = getTargetABI(ABIName);
+static ABI getTripleABI(const Triple &TT) {
bool Is64Bit = TT.isArch64Bit();
ABI TripleABI;
-
- // Figure out the ABI explicitly requested via the triple's environment type.
switch (TT.getEnvironment()) {
case llvm::Triple::EnvironmentType::GNUSF:
- TripleABI = Is64Bit ? LoongArchABI::ABI_LP64S : LoongArchABI::ABI_ILP32S;
+ TripleABI = Is64Bit ? ABI_LP64S : ABI_ILP32S;
break;
case llvm::Triple::EnvironmentType::GNUF32:
- TripleABI = Is64Bit ? LoongArchABI::ABI_LP64F : LoongArchABI::ABI_ILP32F;
+ TripleABI = Is64Bit ? ABI_LP64F : ABI_ILP32F;
break;
-
// Let the fallback case behave like {ILP32,LP64}D.
case llvm::Triple::EnvironmentType::GNUF64:
default:
- TripleABI = Is64Bit ? LoongArchABI::ABI_LP64D : LoongArchABI::ABI_ILP32D;
+ TripleABI = Is64Bit ? ABI_LP64D : ABI_ILP32D;
break;
}
+ return TripleABI;
+}
+
+ABI computeTargetABI(const Triple &TT, const FeatureBitset &FeatureBits,
+ StringRef ABIName) {
+ bool Is64Bit = TT.isArch64Bit();
+ ABI ArgProvidedABI = getTargetABI(ABIName);
+ ABI TripleABI = getTripleABI(TT);
+
+ auto GetFeatureABI = [=]() {
+ if (FeatureBits[LoongArch::FeatureBasicD])
+ return Is64Bit ? ABI_LP64D : ABI_ILP32D;
+ if (FeatureBits[LoongArch::FeatureBasicF])
+ return Is64Bit ? ABI_LP64F : ABI_ILP32F;
+ return Is64Bit ? ABI_LP64S : ABI_ILP32S;
+ };
+ auto IsValidABI = [=](ABI Abi) {
----------------
xen0n wrote:
name this `IsABIValidForFeature` for extra clarity?
https://github.com/llvm/llvm-project/pull/92223
More information about the llvm-branch-commits
mailing list