Index: clang/lib/Basic/Targets/Mips.cpp =================================================================== --- clang/lib/Basic/Targets/Mips.cpp +++ clang/lib/Basic/Targets/Mips.cpp @@ -238,12 +238,6 @@ 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 @@ 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"; Index: clang/test/Driver/mips-abi.c =================================================================== --- clang/test/Driver/mips-abi.c +++ 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 \ Index: clang/test/Driver/mips-cpu64abi32.c =================================================================== --- /dev/null +++ clang/test/Driver/mips-cpu64abi32.c @@ -0,0 +1,81 @@ +// 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 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-ABI-N32 %s +// CHECK-ABI-N32: abi2 +// +// abi-64 +// RUN: %clang -c %s -target mips-linux-gnu -mabi=64 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-ABI-64 %s +// CHECK-ABI-64: ELF64 +// +// +// -march=mips3 +// RUN: %clang -c %s -target mips-linux-gnu -march=mips3 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS3 %s +// CHECK-MIPS-MIPS3: o32, mips3 +// +// -march=mips4 +// RUN: %clang -c %s -target mips-linux-gnu -march=mips4 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS4 %s +// CHECK-MIPS-MIPS4: o32, mips4 +// +// FIXME: MIPS V is not implemented yet. +// +// -march=mips64 +/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS64 %s +// CHECK-MIPS-MIPS64: o32, mips64 +// +// -march=mips64r2 +/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r2 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS64R2 %s +// CHECK-MIPS-MIPS64R2: o32, mips64r2 +// +// -march=mips64r6 +/// RUN: %clang -c %s -target mips-linux-gnu -march=mips64r6 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPS64R6 %s +// CHECK-MIPS-MIPS64R6: o32, mips64r6 +// +// +// mipsisa3 +// RUN: %clang -c %s -target mips64-linux-gnu -march=mips3 -mabi=32 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA3 %s +// CHECK-MIPS-MIPSISA3: o32, mips3 +// +// mipsisa4 +// RUN: %clang -c %s -target mips64-linux-gnu -march=mips4 -mabi=32 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA4 %s +// CHECK-MIPS-MIPSISA4: o32, mips4 +// +// FIXME: MIPS V is not implemented yet. +// +// mipsisa64 +/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64 -mabi=32 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64 %s +// CHECK-MIPS-MIPSISA64: o32, mips64 +// +// mipsisa64r2 +/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r2 -mabi=32 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R2 %s +// CHECK-MIPS-MIPSISA64R2: o32, mips64r2 +// +// mipsisa64r6 +/// RUN: %clang -c %s -target mips64-linux-gnu -march=mips64r6 -mabi=32 -o - \ +// RUN: | llvm-readelf -h - \ +// RUN: | FileCheck --check-prefix=CHECK-MIPS-MIPSISA64R6 %s +// CHECK-MIPS-MIPSISA64R6: o32, mips64r6 +// Index: llvm/lib/Target/Mips/MipsSubtarget.cpp =================================================================== --- llvm/lib/Target/Mips/MipsSubtarget.cpp +++ llvm/lib/Target/Mips/MipsSubtarget.cpp @@ -104,8 +104,7 @@ 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())