[llvm] r344039 - [mips] Set pointer size to 4 bytes for N32 ABI

Simon Atanasyan via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 9 04:29:45 PDT 2018


Author: atanasyan
Date: Tue Oct  9 04:29:45 2018
New Revision: 344039

URL: http://llvm.org/viewvc/llvm-project?rev=344039&view=rev
Log:
[mips] Set pointer size to 4 bytes for N32 ABI

CodePointerSize and CalleeSaveStackSlotSize values are used in DWARF
generation. In case of MIPS it's incorrect 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 command
line option and is not a part of a target triple. So we check for
Triple::GNUABIN32 only. It's better than nothing.

Differential revision: https://reviews.llvm.org/D52874

Added:
    llvm/trunk/test/MC/Mips/ptr-size.s
Modified:
    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp

Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp?rev=344039&r1=344038&r2=344039&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsMCAsmInfo.cpp Tue Oct  9 04:29:45 2018
@@ -21,9 +21,8 @@ void MipsMCAsmInfo::anchor() { }
 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

Added: llvm/trunk/test/MC/Mips/ptr-size.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/ptr-size.s?rev=344039&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/ptr-size.s (added)
+++ llvm/trunk/test/MC/Mips/ptr-size.s Tue Oct  9 04:29:45 2018
@@ -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




More information about the llvm-commits mailing list