]> granicus.if.org Git - llvm/commitdiff
[mips] Set microMIPS ASE flag
authorAleksandar Beserminji <Aleksandar.Beserminji@mips.com>
Fri, 24 Nov 2017 14:00:47 +0000 (14:00 +0000)
committerAleksandar Beserminji <Aleksandar.Beserminji@mips.com>
Fri, 24 Nov 2017 14:00:47 +0000 (14:00 +0000)
This patch fixes an issue where microMIPS ASE flag is not set
when a function has micromips attribute or when .set micromips
directive is used.

Differential Revision: https://reviews.llvm.org/D40316

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@318948 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/AsmParser/MipsAsmParser.cpp
lib/Target/Mips/MipsAsmPrinter.cpp
test/CodeGen/Mips/micromips-ase-function-attribute.ll [new file with mode: 0644]
test/MC/Mips/micromips-ase-directive.s [new file with mode: 0644]

index 8da7dfbd4de317fc97d49d1f8456266920b81245..4db5e3c8cca5d7c7806c79069f7e45c5e5d4201c 100644 (file)
@@ -2273,8 +2273,10 @@ bool MipsAsmParser::processInstruction(MCInst &Inst, SMLoc IDLoc,
 
   // 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.
index c2869bd7ecb01a0b763582c73aba04f012943805..fbf7b5e28b7c0fc631429f26f2fa779fa051a00e 100644 (file)
@@ -361,6 +361,7 @@ void MipsAsmPrinter::EmitFunctionEntryLabel() {
   if (Subtarget->inMicroMipsMode()) {
     TS.emitDirectiveSetMicroMips();
     TS.setUsesMicroMips();
+    TS.updateABIInfo(*Subtarget);
   } else
     TS.emitDirectiveSetNoMicroMips();
 
diff --git a/test/CodeGen/Mips/micromips-ase-function-attribute.ll b/test/CodeGen/Mips/micromips-ase-function-attribute.ll
new file mode 100644 (file)
index 0000000..bbb6ff5
--- /dev/null
@@ -0,0 +1,11 @@
+; RUN: llc -mtriple=mips-unknown-linux -filetype=obj %s -o - | \
+; RUN:   llvm-readobj -mips-abi-flags | \
+; RUN:   FileCheck --check-prefix=ASE-MICROMIPS %s
+
+define void @_Z3foov() #0 {
+entry:
+  ret void
+}
+attributes #0 = { "micromips" }
+
+; ASE-MICROMIPS: microMIPS (0x800)
diff --git a/test/MC/Mips/micromips-ase-directive.s b/test/MC/Mips/micromips-ase-directive.s
new file mode 100644 (file)
index 0000000..8cdcdcc
--- /dev/null
@@ -0,0 +1,10 @@
+# RUN: llvm-mc -triple=mips-unknown-linux -filetype=obj %s -o - | \
+# RUN:   llvm-readobj -mips-abi-flags | \
+# RUN:   FileCheck --check-prefix=ASE-MICROMIPS %s
+
+       .set    micromips
+       .ent    _Z3foov
+_Z3foov:
+       addiu   $sp, $sp, -8
+
+# ASE-MICROMIPS: microMIPS (0x800)