diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp index 078a8fe62ac23..cdf652c49f603 100644 --- a/clang/lib/Basic/Targets/Mips.cpp +++ b/clang/lib/Basic/Targets/Mips.cpp @@ -238,12 +238,6 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const { Diags.Report(diag::err_target_unsupported_cpu_for_micromips) << CPU; return false; } - // FIXME: It's valid to use O32 on a 64-bit CPU but the backend can't handle - // this yet. It's better to fail here than on the backend assertion. - if (processorSupportsGPR64() && ABI == "o32") { - Diags.Report(diag::err_target_unsupported_abi) << ABI << CPU; - return false; - } // 64-bit ABI's require 64-bit CPU's. if (!processorSupportsGPR64() && (ABI == "n32" || ABI == "n64")) { @@ -251,24 +245,6 @@ bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const { return false; } - // FIXME: It's valid to use O32 on a mips64/mips64el triple but the backend - // can't handle this yet. It's better to fail here than on the - // backend assertion. - if (getTriple().isMIPS64() && ABI == "o32") { - Diags.Report(diag::err_target_unsupported_abi_for_triple) - << ABI << getTriple().str(); - return false; - } - - // FIXME: It's valid to use N32/N64 on a mips/mipsel triple but the backend - // can't handle this yet. It's better to fail here than on the - // backend assertion. - if (getTriple().isMIPS32() && (ABI == "n32" || ABI == "n64")) { - Diags.Report(diag::err_target_unsupported_abi_for_triple) - << ABI << getTriple().str(); - return false; - } - // -fpxx is valid only for the o32 ABI if (FPMode == FPXX && (ABI == "n32" || ABI == "n64")) { Diags.Report(diag::err_unsupported_abi_for_opt) << "-mfpxx" << "o32"; diff --git a/clang/test/Driver/mips-abi.c b/clang/test/Driver/mips-abi.c index f0f678b42f608..98384ce8b3154 100644 --- a/clang/test/Driver/mips-abi.c +++ b/clang/test/Driver/mips-abi.c @@ -9,13 +9,6 @@ // MIPS32R2-O32: "-target-cpu" "mips32r2" // MIPS32R2-O32: "-target-abi" "o32" // -// FIXME: This is a valid combination of options but we reject it at the moment -// because the backend can't handle it. -// RUN: not %clang -target mips-linux-gnu -c %s \ -// RUN: -march=mips64r2 -mabi=32 2>&1 \ -// RUN: | FileCheck -check-prefix=MIPS64R2-O32 %s -// MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2' -// // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \ // RUN: | FileCheck -check-prefix=MIPS64R2-N64 %s // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \ diff --git a/clang/test/Driver/mips-cpu64abi32.c b/clang/test/Driver/mips-cpu64abi32.c new file mode 100644 index 0000000000000..d8c8e44f05dae --- /dev/null +++ b/clang/test/Driver/mips-cpu64abi32.c @@ -0,0 +1,68 @@ +/// Check handling the CPU is 64bit while ABI is O32. +/// when build for MIPS platforms. + +/// abi-n32 +// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=n32 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-ABI-N32 %s +// CHECK-ABI-N32: "-target-abi" "n32" + +/// abi-64 +// RUN: %clang -### -c %s --target=mips-linux-gnu -mabi=64 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-ABI-64 %s +// CHECK-ABI-64: "-target-abi" "n64" + + +/// -march=mips3 +// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips3 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s +// CHECK-MIPS-MIPS3: "-target-cpu" "mips3" {{.*}} "-target-abi" "o32" + +/// -march=mips4 +// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips4 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s +// CHECK-MIPS-MIPS4: "-target-cpu" "mips4" {{.*}} "-target-abi" "o32" + +/// FIXME: MIPS V is not implemented yet. + +/// -march=mips64 +/// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s +// CHECK-MIPS-MIPS64: "-target-cpu" "mips64" {{.*}} "-target-abi" "o32" + +/// -march=mips64r2 +/// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64r2 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s +// CHECK-MIPS-MIPS64R2: "-target-cpu" "mips64r2" {{.*}} "-target-abi" "o32" + +/// -march=mips64r6 +// RUN: %clang -### -c %s --target=mips-linux-gnu -march=mips64r6 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s +// CHECK-MIPS-MIPS64R6: "-target-cpu" "mips64r6" {{.*}} "-target-abi" "o32" + + +/// mipsisa3 +// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips3 -mabi=32 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s +// CHECK-MIPS-MIPSISA3: "-target-cpu" "mips3" {{.*}} "-target-abi" "o32" + +/// mipsisa4 +// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips4 -mabi=32 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s +// CHECK-MIPS-MIPSISA4: "-target-cpu" "mips4" {{.*}} "-target-abi" "o32" + +/// FIXME: MIPS V is not implemented yet. + +/// mipsisa64 +// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64 -mabi=32 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s +// CHECK-MIPS-MIPSISA64: "-target-cpu" "mips64" {{.*}} "-target-abi" "o32" + +/// mipsisa64r2 +// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64r2 -mabi=32 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s +// CHECK-MIPS-MIPSISA64R2: "-target-cpu" "mips64r2" {{.*}} "-target-abi" "o32" + +/// mipsisa64r6 +// RUN: %clang -### -c %s --target=mips64-linux-gnu -march=mips64r6 -mabi=32 2>&1 \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s +// CHECK-MIPS-MIPSISA64R6: "-target-cpu" "mips64r6" {{.*}} "-target-abi" "o32" diff --git a/llvm/lib/Target/Mips/MipsSubtarget.cpp b/llvm/lib/Target/Mips/MipsSubtarget.cpp index 10530cdafeed4..323e611207a2a 100644 --- a/llvm/lib/Target/Mips/MipsSubtarget.cpp +++ b/llvm/lib/Target/Mips/MipsSubtarget.cpp @@ -104,8 +104,7 @@ MipsSubtarget::MipsSubtarget(const Triple &TT, StringRef CPU, StringRef FS, report_fatal_error("Code generation for MIPS-V is not implemented", false); // Check if Architecture and ABI are compatible. - assert(((!isGP64bit() && isABI_O32()) || - (isGP64bit() && (isABI_N32() || isABI_N64()))) && + assert(((!isGP64bit() && isABI_O32()) || isGP64bit()) && "Invalid Arch & ABI pair."); if (hasMSA() && !isFP64bit())