]> granicus.if.org Git - llvm/commitdiff
[mips] Align the stack to 16-bytes for mfp64.
authorAkira Hatanaka <ahatanaka@mips.com>
Tue, 29 Oct 2013 19:29:03 +0000 (19:29 +0000)
committerAkira Hatanaka <ahatanaka@mips.com>
Tue, 29 Oct 2013 19:29:03 +0000 (19:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193641 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/Mips/Mips.td
lib/Target/Mips/Mips16FrameLowering.h
lib/Target/Mips/MipsSEFrameLowering.h
lib/Target/Mips/MipsSubtarget.cpp
lib/Target/Mips/MipsSubtarget.h
test/CodeGen/Mips/stack-alignment.ll [new file with mode: 0644]

index b8e3f39256da07d123a975adbe5d4443f7ccfcc0..0581d84a054e6a591eb6e725dfe966fa0fd24b45 100644 (file)
@@ -30,10 +30,12 @@ def MipsInstrInfo : InstrInfo;
 // Mips Subtarget features                                                    //
 //===----------------------------------------------------------------------===//
 
+def StackAlign16 : SubtargetFeature<"stackalign16", "StackAlignment", "16",
+                                    "Set stack alignment to 16-bytes.">;
 def FeatureGP64Bit     : SubtargetFeature<"gp64", "IsGP64bit", "true",
                                 "General Purpose Registers are 64-bit wide.">;
 def FeatureFP64Bit     : SubtargetFeature<"fp64", "IsFP64bit", "true",
-                                "Support 64-bit FP registers.">;
+                                "Support 64-bit FP registers.", [StackAlign16]>;
 def FeatureSingleFloat : SubtargetFeature<"single-float", "IsSingleFloat",
                                 "true", "Only supports single precision float">;
 def FeatureO32         : SubtargetFeature<"o32", "MipsABI", "O32",
index 54fdb7871466461ffbd9cb9ef54f7f0bb2718f31..8ce2ceda7c74bf19f91b06b43faac5403a684cd1 100644 (file)
@@ -20,7 +20,7 @@ namespace llvm {
 class Mips16FrameLowering : public MipsFrameLowering {
 public:
   explicit Mips16FrameLowering(const MipsSubtarget &STI)
-    : MipsFrameLowering(STI, 8) {}
+    : MipsFrameLowering(STI, STI.stackAlignment()) {}
 
   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
   /// the function.
index 193a66cc65a7cfc20d592daea1a9fe0ac4d59eea..8fa9e469887d60cea864b0828673c3938a864188 100644 (file)
@@ -21,7 +21,7 @@ namespace llvm {
 class MipsSEFrameLowering : public MipsFrameLowering {
 public:
   explicit MipsSEFrameLowering(const MipsSubtarget &STI)
-    : MipsFrameLowering(STI, STI.hasMips64() ? 16 : 8) {}
+    : MipsFrameLowering(STI, STI.stackAlignment()) {}
 
   /// emitProlog/emitEpilog - These methods insert prolog and epilog code into
   /// the function.
index 0a81072b085817d4fe8f37716c5b3709af2c76f0..07957ef61bedffc56dcf22d1f06ad9fa1fc7ed32 100644 (file)
@@ -72,7 +72,7 @@ MipsSubtarget::MipsSubtarget(const std::string &TT, const std::string &CPU,
   InMips16Mode(false), InMips16HardFloat(Mips16HardFloat),
   InMicroMipsMode(false), HasDSP(false), HasDSPR2(false),
   AllowMixed16_32(Mixed16_32 | Mips_Os16), Os16(Mips_Os16), HasMSA(false),
-  RM(_RM), OverrideMode(NoOverride), TM(_TM)
+  StackAlignment(8), RM(_RM), OverrideMode(NoOverride), TM(_TM)
 {
   std::string CPUName = CPU;
   if (CPUName.empty())
index 30100656fe02dec7e88b26a3e95b0b8d824c6620..378fc00f4527721e9f946d6836844dea144eb607 100644 (file)
@@ -116,6 +116,8 @@ protected:
   // HasMSA -- supports MSA ASE.
   bool HasMSA;
 
+  unsigned StackAlignment;
+
   InstrItineraryData InstrItins;
 
   // The instance to the register info section object
@@ -216,6 +218,9 @@ public:
 // really use them if in addition we are in mips16 mode
 //
 static bool useConstantIslands();
+
+  unsigned stackAlignment() const { return StackAlignment; }
+
   // Grab MipsRegInfo object
   const MipsReginfo &getMReginfo() const { return MRI; }
 
diff --git a/test/CodeGen/Mips/stack-alignment.ll b/test/CodeGen/Mips/stack-alignment.ll
new file mode 100644 (file)
index 0000000..403a106
--- /dev/null
@@ -0,0 +1,14 @@
+; RUN: llc -march=mipsel < %s | FileCheck %s -check-prefix=32
+; RUN: llc -march=mipsel -mattr=+fp64 < %s | FileCheck %s -check-prefix=32-FP64
+; RUN: llc -march=mips64el -mcpu=mips64 < %s | FileCheck %s -check-prefix=64
+
+; 32:      addiu  $sp, $sp, -8
+; 32-FP64: addiu  $sp, $sp, -16
+; 64:      addiu  $sp, $sp, -16
+
+define i32 @foo1() #0 {
+entry:
+  ret i32 14
+}
+
+attributes #0 = { "no-frame-pointer-elim"="true" }