[PATCH] D70018: [mips][test] Check if the subtarget can support the requested triple width

Miloš Stojanović via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 10:26:42 PST 2019


mstojanovic created this revision.
mstojanovic added reviewers: atanasyan, Petar.Avramovic, petarj.
Herald added subscribers: hiraditya, arichardson, sdardis.
Herald added a project: LLVM.

When a 64-bit triple is used emit an error if the CPU only supports 32-bit code.


https://reviews.llvm.org/D70018

Files:
  llvm/lib/Target/Mips/MipsSubtarget.cpp
  llvm/test/CodeGen/Mips/cpus-no-mips64.ll


Index: llvm/test/CodeGen/Mips/cpus-no-mips64.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Mips/cpus-no-mips64.ll
@@ -0,0 +1,15 @@
+; Check that we reject 64-bit mode on 32-bit only CPUs.
+; CHECK-ERROR64: LLVM ERROR: 64-bit code requested on a subtarget that doesn't support it!
+
+; RUN: not llc < %s -o /dev/null -mtriple=mips64-unknown-unknown -mcpu=mips1 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR64
+; RUN: not llc < %s -o /dev/null -mtriple=mips64-unknown-unknown -mcpu=mips2 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR64
+
+; RUN: not llc < %s -o /dev/null -mtriple=mips64-unknown-unknown -mcpu=mips32 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR64
+; RUN: not llc < %s -o /dev/null -mtriple=mips64-unknown-unknown -mcpu=mips32r2 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR64
+; RUN: not llc < %s -o /dev/null -mtriple=mips64-unknown-unknown -mcpu=mips32r3 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR64
+; RUN: not llc < %s -o /dev/null -mtriple=mips64-unknown-unknown -mcpu=mips32r5 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR64
+; RUN: not llc < %s -o /dev/null -mtriple=mips64-unknown-unknown -mcpu=mips32r6 2>&1 | FileCheck %s --check-prefix=CHECK-ERROR64
+
+define void @foo() {
+  ret void
+}
Index: llvm/lib/Target/Mips/MipsSubtarget.cpp
===================================================================
--- llvm/lib/Target/Mips/MipsSubtarget.cpp
+++ llvm/lib/Target/Mips/MipsSubtarget.cpp
@@ -256,6 +256,10 @@
     stackAlignment = Align(8);
   }
 
+  if ((isABI_N32() || isABI_N64()) && !isGP64bit())
+    report_fatal_error("64-bit code requested on a subtarget that doesn't "
+                       "support it!");
+
   return *this;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70018.228489.patch
Type: text/x-patch
Size: 1740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191108/5845a33c/attachment.bin>


More information about the llvm-commits mailing list