[PATCH] D52874: [mips] Set pointer size to 4 bytes for N32 ABI

Simon Atanasyan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 4 03:38:04 PDT 2018


atanasyan created this revision.
atanasyan added reviewers: abeserminji, petarj, smaksimovic.
Herald added subscribers: jrtc27, JDevlieghere, arichardson, aprantl, sdardis.

CodePointerSize and CalleeSaveStackSlotSize values are used in DWARF generation. In case of MIPS it's icorrect to check for Triple::isMIPS64() only this function returns true for N32 ABI too.

Now we do not have a method to recognize N32 if it's specified by a comand line option and is not a part of a target triple. So we check for Triple::GNUABIN32 only. It's better than nothing.


Repository:
  rL LLVM

https://reviews.llvm.org/D52874

Files:
  lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
  test/MC/Mips/ptr-size.s


Index: test/MC/Mips/ptr-size.s
===================================================================
--- /dev/null
+++ test/MC/Mips/ptr-size.s
@@ -0,0 +1,13 @@
+# RUN: llvm-mc -filetype=obj -triple mips--gnu -g %s \
+# RUN:   | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=O32 %s
+# RUN: llvm-mc -filetype=obj -triple mips64--gnuabin32 -g %s \
+# RUN:   | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=N32 %s
+# RUN: llvm-mc -filetype=obj -triple mips64--gnuabi64 -g %s \
+# RUN:   | llvm-dwarfdump -debug-info - | FileCheck --check-prefix=N64 %s
+
+# O32: addr_size = 0x04
+# N32: addr_size = 0x04
+# N64: addr_size = 0x08
+
+foo:
+  nop
Index: lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
===================================================================
--- lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
+++ lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
@@ -21,9 +21,8 @@
 MipsMCAsmInfo::MipsMCAsmInfo(const Triple &TheTriple) {
   IsLittleEndian = TheTriple.isLittleEndian();
 
-  if (TheTriple.isMIPS64()) {
+  if (TheTriple.isMIPS64() && TheTriple.getEnvironment() != Triple::GNUABIN32)
     CodePointerSize = CalleeSaveStackSlotSize = 8;
-  }
 
   // FIXME: This condition isn't quite right but it's the best we can do until
   //        this object can identify the ABI. It will misbehave when using O32


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52874.168258.patch
Type: text/x-patch
Size: 1337 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181004/e052ea3f/attachment.bin>


More information about the llvm-commits mailing list