[PATCH] D40316: [mips] Set microMIPS ASE flag

Aleksandar Beserminji via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 21 09:35:09 PST 2017


abeserminji created this revision.
Herald added a subscriber: arichardson.

If code contains a function that has  'micromips' attribute, and it's compiled without -mmicromips flag, the generated object file does not contain AFL_ASE_MICROMIPS flag in the MIPS.abiflags section. Same result occurs when assembly code contains '.set micromips' directive.

This patch corrects such behavior by updating ABI info when subtarget is in microMips mode.


Repository:
  rL LLVM

https://reviews.llvm.org/D40316

Files:
  lib/Target/Mips/AsmParser/MipsAsmParser.cpp
  lib/Target/Mips/MipsAsmPrinter.cpp
  test/CodeGen/Mips/micromips-ase-function-attribute.ll
  test/MC/Mips/micromips-ase-directive.s


Index: test/MC/Mips/micromips-ase-directive.s
===================================================================
--- /dev/null
+++ test/MC/Mips/micromips-ase-directive.s
@@ -0,0 +1,8 @@
+# RUN: llvm-mc -triple=mips-unknown-linux -filetype=obj %s -o - | llvm-readobj  -mips-abi-flags | FileCheck --check-prefix=ASE-MICROMIPS %s
+
+	.set	micromips
+	.ent	_Z3foov
+_Z3foov:
+	addiu	$sp, $sp, -8
+
+# ASE-MICROMIPS: microMIPS (0x800)
Index: test/CodeGen/Mips/micromips-ase-function-attribute.ll
===================================================================
--- /dev/null
+++ test/CodeGen/Mips/micromips-ase-function-attribute.ll
@@ -0,0 +1,9 @@
+; RUN: llc -mtriple=mips-unknown-linux -filetype=obj %s -o - | llvm-readobj  -mips-abi-flags | FileCheck --check-prefix=ASE-MICROMIPS %s
+
+define void @_Z3foov() #0 {
+entry:
+  ret void
+}
+attributes #0 = { "micromips" }
+
+; ASE-MICROMIPS: microMIPS (0x800)
Index: lib/Target/Mips/MipsAsmPrinter.cpp
===================================================================
--- lib/Target/Mips/MipsAsmPrinter.cpp
+++ lib/Target/Mips/MipsAsmPrinter.cpp
@@ -361,6 +361,7 @@
   if (Subtarget->inMicroMipsMode()) {
     TS.emitDirectiveSetMicroMips();
     TS.setUsesMicroMips();
+    TS.updateABIInfo(*Subtarget);
   } else
     TS.emitDirectiveSetNoMicroMips();
 
Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp
===================================================================
--- lib/Target/Mips/AsmParser/MipsAsmParser.cpp
+++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp
@@ -2273,8 +2273,10 @@
 
   // We know we emitted an instruction on the MER_NotAMacro or MER_Success path.
   // If we're in microMIPS mode then we must also set EF_MIPS_MICROMIPS.
-  if (inMicroMipsMode())
+  if (inMicroMipsMode()) {
     TOut.setUsesMicroMips();
+    TOut.updateABIInfo(*this);
+  }
 
   // If this instruction has a delay slot and .set reorder is active,
   // emit a NOP after it.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40316.123815.patch
Type: text/x-patch
Size: 1926 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171121/6f26cfe5/attachment.bin>


More information about the llvm-commits mailing list