Last change for mips16 prolog/epilog cleanup and optimization.
authorReed Kotler <rkotler@mips.com>
Sun, 15 Dec 2013 20:49:30 +0000 (20:49 +0000)
committerReed Kotler <rkotler@mips.com>
Sun, 15 Dec 2013 20:49:30 +0000 (20:49 +0000)
Some tiny cosmetic code changes to follow. Because of the wide
ranging nature of the patch a full 24 test cycle was needed to
check against regression. This was the smallest patch I could
make to progress from the earlier ones in the series.

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

21 files changed:
lib/Target/Mips/Mips16FrameLowering.cpp
lib/Target/Mips/Mips16InstrInfo.cpp
lib/Target/Mips/Mips16InstrInfo.td
lib/Target/Mips/MipsCallingConv.td
test/CodeGen/Mips/align16.ll
test/CodeGen/Mips/alloca16.ll
test/CodeGen/Mips/ex2.ll
test/CodeGen/Mips/fp16mix.ll
test/CodeGen/Mips/helloworld.ll
test/CodeGen/Mips/largefr1.ll [deleted file]
test/CodeGen/Mips/mips16_32_1.ll
test/CodeGen/Mips/mips16_32_10.ll
test/CodeGen/Mips/mips16_32_3.ll
test/CodeGen/Mips/mips16_32_4.ll
test/CodeGen/Mips/mips16_32_5.ll
test/CodeGen/Mips/mips16_32_6.ll
test/CodeGen/Mips/mips16_32_7.ll
test/CodeGen/Mips/mips16_32_8.ll
test/CodeGen/Mips/mips16_32_9.ll
test/CodeGen/Mips/s2rem.ll
test/CodeGen/Mips/sr1.ll

index ae6be05cdfbb07ee95aced7aee84b6e26329a6bb..9994e1c820f85feeb8a7eb3d0c93626b2cfe27f2 100644 (file)
@@ -54,35 +54,24 @@ void Mips16FrameLowering::emitPrologue(MachineFunction &MF) const {
   MMI.addFrameInst(
       MCCFIInstruction::createDefCfaOffset(AdjustSPLabel, -StackSize));
 
+  const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
+
+  if (CSI.size()) {
   MCSymbol *CSLabel = MMI.getContext().CreateTempSymbol();
   BuildMI(MBB, MBBI, dl,
           TII.get(TargetOpcode::PROLOG_LABEL)).addSym(CSLabel);
 
 
-  const MipsRegisterInfo &RI = TII.getRegisterInfo();
-  const BitVector Reserved = RI.getReservedRegs(MF);
-  bool SaveS2 = Reserved[Mips::S2];
-  int Offset=-4;
-  unsigned RA = MRI->getDwarfRegNum(Mips::RA, true);
-  MMI.addFrameInst(MCCFIInstruction::createOffset(CSLabel, RA, Offset));
-  Offset -= 4;
-
-  if (SaveS2) {
-    unsigned S2 = MRI->getDwarfRegNum(Mips::S2, true);
-    MMI.addFrameInst(MCCFIInstruction::createOffset(CSLabel, S2, Offset));
-    Offset -= 4;
-  }
-
-
-  unsigned S1 = MRI->getDwarfRegNum(Mips::S1, true);
-  MMI.addFrameInst(MCCFIInstruction::createOffset(CSLabel, S1, Offset));
-  Offset -= 4;
-
-  unsigned S0 = MRI->getDwarfRegNum(Mips::S0, true);
-  MMI.addFrameInst(MCCFIInstruction::createOffset(CSLabel, S0, Offset));
-
-
+  const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
 
+  for (std::vector<CalleeSavedInfo>::const_iterator I = CSI.begin(),
+         E = CSI.end(); I != E; ++I) {
+    int64_t Offset = MFI->getObjectOffset(I->getFrameIdx());
+    unsigned Reg = I->getReg();
+    unsigned DReg = MRI->getDwarfRegNum(Reg, true);
+    MMI.addFrameInst(MCCFIInstruction::createOffset(CSLabel, DReg, Offset));
+  }
+  }
   if (hasFP(MF))
     BuildMI(MBB, MBBI, dl, TII.get(Mips::MoveR3216), Mips::S0)
       .addReg(Mips::SP);
@@ -183,10 +172,15 @@ Mips16FrameLowering::hasReservedCallFrame(const MachineFunction &MF) const {
 void Mips16FrameLowering::
 processFunctionBeforeCalleeSavedScan(MachineFunction &MF,
                                      RegScavenger *RS) const {
-  MF.getRegInfo().setPhysRegUsed(Mips::RA);
-  MF.getRegInfo().setPhysRegUsed(Mips::S0);
-  MF.getRegInfo().setPhysRegUsed(Mips::S1);
-  MF.getRegInfo().setPhysRegUsed(Mips::S2);
+  const Mips16InstrInfo &TII =
+    *static_cast<const Mips16InstrInfo*>(MF.getTarget().getInstrInfo());
+  const MipsRegisterInfo &RI = TII.getRegisterInfo();
+  const BitVector Reserved = RI.getReservedRegs(MF);
+  bool SaveS2 = Reserved[Mips::S2];
+  if (SaveS2)
+    MF.getRegInfo().setPhysRegUsed(Mips::S2);
+  if (hasFP(MF))
+    MF.getRegInfo().setPhysRegUsed(Mips::S0);
 }
 
 const MipsFrameLowering *
index 7a3f9d2842cfbd48feb4b68d29e41b6ba1c3012a..17d13925c0f5adfbd96b446bb8fca2ee0a7079be 100644 (file)
@@ -169,35 +169,59 @@ unsigned Mips16InstrInfo::getOppositeBranchOpc(unsigned Opc) const {
   return 0;
 }
 
+static void addSaveRestoreRegs(MachineInstrBuilder &MIB,
+                          const std::vector<CalleeSavedInfo> &CSI, unsigned Flags=0) {
+  if (CSI.size()==0) return;
+  for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
+    // Add the callee-saved register as live-in. Do not add if the register is
+    // RA and return address is taken, because it has already been added in
+    // method MipsTargetLowering::LowerRETURNADDR.
+    // It's killed at the spill, unless the register is RA and return address
+    // is taken.
+    unsigned Reg = CSI[e-i-1].getReg();
+    switch (Reg) {
+    case Mips::RA:
+    case Mips::S0:
+    case Mips::S1:
+      MIB.addReg(Reg, Flags);
+      break;
+    case Mips::S2:
+      break;
+    default:
+      llvm_unreachable("unexpected mips16 callee saved register");
+
+    }
+  }
+
+}
 // Adjust SP by FrameSize bytes. Save RA, S0, S1
 void Mips16InstrInfo::makeFrame(unsigned SP, int64_t FrameSize,
                     MachineBasicBlock &MBB,
                     MachineBasicBlock::iterator I) const {
   DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc();
-  const BitVector Reserved = RI.getReservedRegs(*MBB.getParent());
+  MachineFunction &MF = *MBB.getParent();
+  MachineFrameInfo *MFI    = MF.getFrameInfo();
+  const BitVector Reserved = RI.getReservedRegs(MF);
   bool SaveS2 = Reserved[Mips::S2];
   MachineInstrBuilder MIB;
   unsigned Opc = ((FrameSize <= 128) && !SaveS2)? Mips::Save16:Mips::SaveX16;
+  MIB = BuildMI(MBB, I, DL, get(Opc));
+  const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
+  addSaveRestoreRegs(MIB, CSI);
+  if (SaveS2)
+    MIB.addReg(Mips::S2);
   if (isUInt<11>(FrameSize))
-    MIB = BuildMI(
-            MBB, I, DL, get(Opc)).addReg(Mips::RA).
-            addReg(Mips::S0).
-            addReg(Mips::S1).addImm(FrameSize);
+    MIB.addImm(FrameSize);
   else {
     int Base = 2040; // should create template function like isUInt that
                      // returns largest possible n bit unsigned integer
     int64_t Remainder = FrameSize - Base;
-    MIB = BuildMI(
-            MBB, I, DL, get(Opc)).addReg(Mips::RA).
-            addReg(Mips::S0).
-            addReg(Mips::S1).addImm(Base);
+    MIB.addImm(Base);
     if (isInt<16>(-Remainder))
       BuildAddiuSpImm(MBB, I, -Remainder);
     else
       adjustStackPtrBig(SP, -Remainder, MBB, I, Mips::V0, Mips::V1);
   }
-  if (SaveS2)
-    MIB.addReg(Mips::S2);
 }
 
 // Adjust SP by FrameSize bytes. Restore RA, S0, S1
@@ -205,35 +229,31 @@ void Mips16InstrInfo::restoreFrame(unsigned SP, int64_t FrameSize,
                                    MachineBasicBlock &MBB,
                                    MachineBasicBlock::iterator I) const {
   DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc();
-  const BitVector Reserved = RI.getReservedRegs(*MBB.getParent());
+  MachineFunction *MF = MBB.getParent();
+  MachineFrameInfo *MFI    = MF->getFrameInfo();
+  const BitVector Reserved = RI.getReservedRegs(*MF);
   bool SaveS2 = Reserved[Mips::S2];
   MachineInstrBuilder MIB;
   unsigned Opc = ((FrameSize <= 128) && !SaveS2)?
     Mips::Restore16:Mips::RestoreX16;
-  if (isUInt<11>(FrameSize))
-    MIB = BuildMI(
-            MBB, I, DL, get(Opc)).
-            addReg(Mips::RA, RegState::Define).
-            addReg(Mips::S0, RegState::Define).
-            addReg(Mips::S1, RegState::Define).
-            addImm(FrameSize);
-  else {
-    int Base = 2040; // should create template function like isUInt that
-                     // returns largest possible n bit unsigned integer
+
+  if (!isUInt<11>(FrameSize)) {
+    unsigned Base = 2040;
     int64_t Remainder = FrameSize - Base;
+    FrameSize = Base; // should create template function like isUInt that
+                     // returns largest possible n bit unsigned integer
+
     if (isInt<16>(Remainder))
       BuildAddiuSpImm(MBB, I, Remainder);
     else
       adjustStackPtrBig(SP, Remainder, MBB, I, Mips::A0, Mips::A1);
-    MIB = BuildMI(
-            MBB, I, DL, get(Opc)).
-            addReg(Mips::RA, RegState::Define).
-            addReg(Mips::S0, RegState::Define).
-            addReg(Mips::S1, RegState::Define).
-            addImm(Base);
   }
+  MIB = BuildMI(MBB, I, DL, get(Opc));
+  const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
+  addSaveRestoreRegs(MIB, CSI, RegState::Define);
   if (SaveS2)
     MIB.addReg(Mips::S2, RegState::Define);
+  MIB.addImm(FrameSize);
 }
 
 // Adjust SP by Amount bytes where bytes can be up to 32bit number.
index 7879d4d73eb3f34d36155837a37b0db87f5e29f5..fbaa59db54c12078de94bd34172766d9f9427612 100644 (file)
@@ -1376,7 +1376,9 @@ def: Mips16Pat<
 let isCall=1, hasDelaySlot=0 in
 def JumpLinkReg16:
   FRR16_JALRC<0, 0, 0, (outs), (ins CPU16Regs:$rs),
-              "jalrc \t$rs", [(MipsJmpLink CPU16Regs:$rs)], IIBranch>;
+              "jalrc \t$rs", [(MipsJmpLink CPU16Regs:$rs)], IIBranch> {
+  let Defs = [RA];
+}
 
 // Mips16 pseudos
 let isReturn=1, isTerminator=1, hasDelaySlot=1, isBarrier=1, hasCtrlDep=1,
@@ -1892,7 +1894,7 @@ def GotPrologue16:
   MipsPseudo16<
     (outs CPU16Regs:$rh, CPU16Regs:$rl),
     (ins simm16:$immHi, simm16:$immLo),
-    ".align 2\n\tli\t$rh, $immHi\n\taddiu\t$rl, $$pc, $immLo\n ",[]> ;
+    "\tli\t$rh, $immHi\n\taddiu\t$rl, $$pc, $immLo\n ",[]> ;
 
 // An operand for the CONSTPOOL_ENTRY pseudo-instruction.
 def cpinst_operand : Operand<i32> {
index 66391cb9cb1e88d91d7f24022e117ced5958db60..bf7162f224bde73f8ec39ad33e444920d526cca6 100644 (file)
@@ -246,4 +246,6 @@ def CSR_N64 : CalleeSavedRegs<(add (sequence "D%u_64", 31, 24), RA_64, FP_64,
                                    GP_64, (sequence "S%u_64", 7, 0))>;
 
 def CSR_Mips16RetHelper :
-  CalleeSavedRegs<(add V0, V1, (sequence "A%u", 3, 0), S0, S1)>;
+  CalleeSavedRegs<(add V0, V1, FP,
+                   (sequence "A%u", 3, 0), (sequence "S%u", 7, 0),
+                   (sequence "D%u", 15, 10))>;
index 32ec94bd20c12c850f7d4adba13beaef095cbef0..689ae8307f572b8e2b41196e7945125bb4c6aea5 100644 (file)
@@ -25,7 +25,7 @@ entry:
   call void @p(i32* %arrayidx1)
   ret void
 }
-; 16:  save    $ra, $16, $17, 2040
-; 16:  addiu   $sp, -56 # 16 bit inst
-; 16:  addiu   $sp, 56 # 16 bit inst
-; 16:  restore $ra,  $16, $17, 2040
+; 16:  save    $ra, 2040
+; 16:  addiu   $sp, -40 # 16 bit inst
+; 16:  addiu   $sp, 40 # 16 bit inst
+; 16:  restore $ra, 2040
index 5bdf4dd7835b0acd43363658181b5114d46b5c08..4f6059878c3bd165553f5e4a8673fa915a574706 100644 (file)
@@ -19,8 +19,8 @@ entry:
 
 define void @test() nounwind {
 entry:
-; 16:  .frame  $sp,24,$ra
-; 16:  save    $ra, $16, $17, 24
+; 16:  .frame  $sp,8,$ra
+; 16:  save    8 # 16 bit inst
 ; 16:  move    $16, $sp
 ; 16:  move    ${{[0-9]+}}, $sp
 ; 16:  subu    $[[REGISTER:[0-9]+]], ${{[0-9]+}}, ${{[0-9]+}}
index 75562156cf0e79ba52fc76600849095623455992..6d024c209c2622e20d12d6359c3786ec6e30a666 100644 (file)
@@ -6,11 +6,11 @@
 define i32 @main() {
 ; 16-LABEL: main:
 ; 16:  .cfi_startproc
-; 16:  save    $ra, $16, $17, 40
-; 16:   .cfi_def_cfa_offset 40
+; 16:  save    $16, $17, $ra, 32 # 16 bit inst
+; 16:   .cfi_def_cfa_offset 32
 ; 16:  .cfi_offset 31, -4
-; 16:   .cfi_offset 17, -8
-; 16:  .cfi_offset 16, -12
+; 16:  .cfi_offset 17, -8
+; 16:   .cfi_offset 16, -12
 ; 16:   .cfi_endproc
 entry:
   %retval = alloca i32, align 4
index 5fbf4ffc58ddc8eed96fc9f0e24a08752e2ed911..a94f838fb675c87082825f2944afd20c6f08d4bb 100644 (file)
@@ -17,7 +17,7 @@ entry:
 ; fmask1: .set reorder
 ; fmask1: .end foo1
 ; fmask2: .ent foo1
-; fmask2: save {{.*}}
+; fmask2: jrc $ra
 ; fmask2: .end foo1
 ; fmask1nr: .ent foo1
 ; fmask1nr: .set       noreorder
@@ -42,10 +42,10 @@ entry:
 ; fmask2: .set reorder
 ; fmask2: .end foo2
 ; fmask1: .ent foo2
-; fmask1: save {{.*}}
+; fmask1: jrc $ra
 ; fmask1: .end foo2
 ; fmask1nr: .ent       foo2
-; fmask1nr: save       {{.*}}
+; fmask1nr: jrc $ra
 ; fmask1nr: .end       foo2
 }
 
@@ -62,10 +62,10 @@ entry:
 ; fmask1: .set reorder
 ; fmask1: .end foo3
 ; fmask2:  .ent        foo3
-; fmask2:  save        {{.*}}
+; fmask2:  jrc $ra
 ; fmask2:  .end        foo3
 ; fmask1r:  .ent       foo3
-; fmask1r:  save       {{.*}}
+; fmask1r:  jrc $ra
 ; fmask1r:  .end       foo3
 }
 
@@ -82,10 +82,10 @@ entry:
 ; fmask2: .set reorder
 ; fmask2: .end foo4
 ; fmask1: .ent foo4
-; fmask1: save {{.*}}
+; fmask1: jrc $ra
 ; fmask1: .end foo4
 ; fmask1nr: .ent       foo4
-; fmask1nr: save       {{.*}}
+; fmask1nr: jrc $ra
 ; fmask1nr: .end       foo4
 }
 
index d363006a550481baccb5199de48f0d996922f4dd..709c12e1c67f2121827489a9687779a3f36925a2 100644 (file)
@@ -25,10 +25,9 @@ entry:
 ; SR32:  .set noreorder
 ; SR32:  .set nomacro
 ; SR32:  .set noat
-; SR:  save    $ra, $16, $17, [[FS:[0-9]+]]
+; SR:  save    $ra, 24 # 16 bit inst
 ; PE:    .ent main
-; PE:    .align  2
-; PE-NEXT:     li      $[[T1:[0-9]+]], %hi(_gp_disp)
+; PE:  li      $[[T1:[0-9]+]], %hi(_gp_disp)
 ; PE-NEXT:     addiu   $[[T2:[0-9]+]], $pc, %lo(_gp_disp)
 ; PE:          sll     $[[T3:[0-9]+]], $[[T1]], 16
 ; C1:  lw      ${{[0-9]+}}, %got($.str)(${{[0-9]+}})
@@ -37,7 +36,7 @@ entry:
 ; C2:  move    $25, ${{[0-9]+}}
 ; C1:  move    $gp, ${{[0-9]+}}
 ; C1:  jalrc   ${{[0-9]+}}
-; SR:  restore         $ra, $16, $17, [[FS]]
+; SR:  restore $ra,    24 # 16 bit inst
 ; PE:  li      $2, 0
 ; PE:  jrc     $ra
 
diff --git a/test/CodeGen/Mips/largefr1.ll b/test/CodeGen/Mips/largefr1.ll
deleted file mode 100644 (file)
index 4fb6286..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=static -mips16-constant-islands=false < %s | FileCheck %s -check-prefix=1
-
-; RUN: llc -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -soft-float -mips16-hard-float -relocation-model=pic   < %s | FileCheck %s -check-prefix=ci
-
-@i = common global i32 0, align 4
-@j = common global i32 0, align 4
-@.str = private unnamed_addr constant [8 x i8] c"%i %i \0A\00", align 1
-
-define void @foo(i32* %p, i32 %i, i32 %j) nounwind {
-entry:
-  %p.addr = alloca i32*, align 4
-  %i.addr = alloca i32, align 4
-  %j.addr = alloca i32, align 4
-  store i32* %p, i32** %p.addr, align 4
-  store i32 %i, i32* %i.addr, align 4
-  store i32 %j, i32* %j.addr, align 4
-  %0 = load i32* %j.addr, align 4
-  %1 = load i32** %p.addr, align 4
-  %2 = load i32* %i.addr, align 4
-  %add.ptr = getelementptr inbounds i32* %1, i32 %2
-  store i32 %0, i32* %add.ptr, align 4
-  ret void
-}
-
-define i32 @main() nounwind {
-entry:
-; 1-LABEL: main:
-; 1: 1:        .word   -798000
-; 1:            lw ${{[0-9]+}}, 1f
-; 1:            b 2f
-; 1:            .align 2
-; 1:            .word  800020
-
-; 1:            b 2f
-; 1:            .align 2
-; 1:            .word  400020
-
-; 1:            move ${{[0-9]+}}, $sp
-; 1:            addu ${{[0-9]+}}, ${{[0-9]+}}, ${{[0-9]+}}
-; 1:            addiu ${{[0-9]+}}, ${{[0-9]+}}, 0
-
-
-
-; 1:            b 2f
-; 1:            .align 2
-; 1:            .word  400220
-
-; 1:            move ${{[0-9]+}}, $sp
-; 1:            addu ${{[0-9]+}}, ${{[0-9]+}}, ${{[0-9]+}}
-; 1:                   lw      ${{[0-9]+}}, 0(${{[0-9]+}})
-
-
-
-
-  %retval = alloca i32, align 4
-  %one = alloca [100000 x i32], align 4
-  %two = alloca [100000 x i32], align 4
-  store i32 0, i32* %retval
-  %arrayidx = getelementptr inbounds [100000 x i32]* %one, i32 0, i32 0
-  call void @foo(i32* %arrayidx, i32 50, i32 9999)
-  %arrayidx1 = getelementptr inbounds [100000 x i32]* %two, i32 0, i32 0
-  call void @foo(i32* %arrayidx1, i32 99999, i32 5555)
-  %arrayidx2 = getelementptr inbounds [100000 x i32]* %one, i32 0, i32 50
-  %0 = load i32* %arrayidx2, align 4
-  store i32 %0, i32* @i, align 4
-  %arrayidx3 = getelementptr inbounds [100000 x i32]* %two, i32 0, i32 99999
-  %1 = load i32* %arrayidx3, align 4
-  store i32 %1, i32* @j, align 4
-  %2 = load i32* @i, align 4
-  %3 = load i32* @j, align 4
-  %call = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([8 x i8]* @.str, i32 0, i32 0), i32 %2, i32 %3)
-  ret i32 0
-}
-
-; ci: lw       ${{[0-9]+}}, $CPI{{[0-9]+}}_{{[0-9]+}}
-declare i32 @printf(i8*, ...)
index e156641d4e508638cc67194c490b6d1a057f0b9f..a72cfc84875dbc7cdc9c312e900257e8313847fc 100644 (file)
@@ -8,7 +8,6 @@ entry:
 
 ; CHECK:       .set    mips16                  # @foo
 ; CHECK:       .ent    foo
-; CHECK:       save    {{.+}}
-; CHECK:       restore {{.+}} 
+; CHECK:       jrc $ra
 ; CHECK:       .end    foo
 attributes #0 = { nounwind "less-precise-fpmad"="false" "mips16" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "unsafe-fp-math"="false" "use-soft-float"="false" }
index 7c017b8e4b755ff00702e411d32a9a92cca91eac..686faa718e08942a859efb37c0ff578d8a1cfdf6 100644 (file)
@@ -24,8 +24,7 @@ entry:
 ; 16:  .set    mips16                  # @nofoo
 ; 16:  .ent    nofoo
 
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    nofoo
 
 define i32 @main() #2 {
index dd94ec1ce80af8cf5a424b63d97ff5cff4df3225..4ad427f0df7fc9b6e2eb1de9a0b9897c6d158ccd 100644 (file)
@@ -8,13 +8,11 @@ entry:
 
 ; 16:  .set    mips16                  # @foo
 ; 16:  .ent    foo
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    foo
 ; 32:  .set    mips16                  # @foo
 ; 32:  .ent    foo
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    foo
 define void @nofoo() #1 {
 entry:
@@ -50,8 +48,7 @@ entry:
 
 ; 16:  .set    mips16                  # @main
 ; 16:  .ent    main
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    main
 ; 32:  .set    nomips16                  # @main
 ; 32:  .ent    main
index 5e4907139445805f40eec5983f7f8ea23c40b926..e8100e8237a195dcffec77dc2aea383d5fea26c6 100644 (file)
@@ -8,13 +8,11 @@ entry:
 
 ; 16:  .set    mips16                  # @foo
 ; 16:  .ent    foo
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    foo
 ; 32:  .set    mips16                  # @foo
 ; 32:  .ent    foo
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    foo
 define void @nofoo() #1 {
 entry:
@@ -50,13 +48,11 @@ entry:
 
 ; 16:  .set    mips16                  # @main
 ; 16:  .ent    main
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    main
 ; 32:  .set    mips16                  # @main
 ; 32:  .ent    main
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    main
 
 
index 17900a2dc75fb8e4d265157051910f8c780f0a3d..5bdeede5c66d4d95cd15d0041ee0c933cd5a718d 100644 (file)
@@ -8,13 +8,11 @@ entry:
 
 ; 16:  .set    mips16                  # @foo
 ; 16:  .ent    foo
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    foo
 ; 32:  .set    mips16                  # @foo
 ; 32:  .ent    foo
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    foo
 define void @nofoo() #1 {
 entry:
index a77031af8be6d8dc2a2f35524d8f0c8d522ebb30..45f71f01ec6553c42eef577aaf7c21d489b0a11e 100644 (file)
@@ -8,8 +8,7 @@ entry:
 
 ; 16:  .set    mips16                  # @foo
 ; 16:  .ent    foo
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    foo
 ; 32:  .set    nomips16                  # @foo
 ; 32:  .ent    foo
index 895b5d4346a81331696de67483ca15296b5d8890..e171b367c47e2d409756f84cbefe5de42212fe40 100644 (file)
@@ -8,8 +8,7 @@ entry:
 
 ; 16:  .set    mips16                  # @foo
 ; 16:  .ent    foo
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    foo
 ; 32:  .set    nomips16                  # @foo
 ; 32:  .ent    foo
@@ -56,14 +55,12 @@ entry:
 
 ; 16:  .set    mips16                  # @main
 ; 16:  .ent    main
-; 16:  save    {{.+}}
-; 16:  restore {{.+}} 
+; 16:  jrc $ra
 ; 16:  .end    main
 
 ; 32:  .set    mips16                  # @main
 ; 32:  .ent    main
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    main
 
 
index 4152d687093e94958a5ab4a9ed20acfa37175de4..3c8cc5a4e281949e61659960c08e4783e68a2ab4 100644 (file)
@@ -16,8 +16,7 @@ entry:
 
 ; 32:  .set    mips16                  # @foo
 ; 32:  .ent    foo
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    foo
 
 define void @nofoo() #1 {
index c9b494f2a89046e49dd13fed7c9cb823661f7c26..585a4e8408b48e6698f229000949846a6307437a 100644 (file)
@@ -7,8 +7,7 @@ entry:
 
 ; 32:  .set    mips16                  # @foo
 ; 32:  .ent    foo
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    foo
 define void @nofoo() #1 {
 entry:
@@ -33,8 +32,7 @@ entry:
 
 ; 32:  .set    mips16                  # @main
 ; 32:  .ent    main
-; 32:  save    {{.+}}
-; 32:  restore {{.+}} 
+; 32:  jrc $ra
 ; 32:  .end    main
 
 
index 0f0b3edade0a2975ce8b5cf204553cf927292a6f..9edb5be2771ea94631a85084ae881ea3f3a9cbc1 100644 (file)
@@ -1,10 +1,7 @@
-; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=pic  < %s | FileCheck %s -check-prefix=NEG
+; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=pic  < %s | FileCheck %s -check-prefix=PIC
 
-; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=static  < %s | FileCheck %s -check-prefix=NEG
+; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=static  < %s | FileCheck %s -check-prefix=STATIC
 
-; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=pic  < %s | FileCheck %s 
-
-; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=static  < %s | FileCheck %s 
 
 @xi = common global i32 0, align 4
 @x = common global float 0.000000e+00, align 4
@@ -16,14 +13,14 @@ entry:
   %call = call i32 @i(i32 1)
   store i32 %call, i32* @xi, align 4
   ret void
-; CHECK:       .ent    it
-; NEG:         .ent    it
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]]
-; NEG-NOT:      save   $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       restore $ra, $16, $17, [[FS]]
-; NEG-NOT:      restore        $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       .end    it
-; NEG:         .end    it
+; PIC:         .ent    it
+; STATIC:      .ent    it
+; PIC:         save    $16, $17, $ra, [[FS:[0-9]+]]
+; STATIC:      save    $16, $ra, [[FS:[0-9]+]]
+; PIC:         restore $16, $17, $ra, [[FS]]
+; STATIC:      restore $16, $ra, [[FS]]
+; PIC:         .end    it
+; STATIC:      .end    it
 }
 
 declare i32 @i(i32) #1
@@ -34,10 +31,10 @@ entry:
   %call = call float @f()
   store float %call, float* @x, align 4
   ret void
-; CHECK:       .ent    ft
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       restore $ra, $16, $17, [[FS]], $18
-; CHECK:       .end    ft
+; PIC:         .ent    ft
+; PIC:         save    $16, $17, $ra, $18, [[FS:[0-9]+]]
+; PIC:         restore $16, $17, $ra, $18, [[FS]]
+; PIC:         .end    ft
 }
 
 declare float @f() #1
@@ -48,10 +45,10 @@ entry:
   %call = call double @d()
   store double %call, double* @xd, align 8
   ret void
-; CHECK:       .ent    dt
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       restore $ra, $16, $17, [[FS]], $18
-; CHECK:       .end    dt
+; PIC:         .ent    dt
+; PIC:         save    $16, $17, $ra, $18, [[FS:[0-9]+]]
+; PIC:         restore $16, $17, $ra, $18, [[FS]]
+; PIC:         .end    dt
 }
 
 declare double @d() #1
@@ -63,10 +60,10 @@ entry:
   %call = call float @ff(float %0)
   store float %call, float* @x, align 4
   ret void
-; CHECK:       .ent    fft
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       restore $ra, $16, $17, [[FS]], $18
-; CHECK:       .end    fft
+; PIC:         .ent    fft
+; PIC:         save    $16, $17, $ra, $18, [[FS:[0-9]+]]
+; PIC:         restore $16, $17, $ra, $18, [[FS]]
+; PIC:         .end    fft
 }
 
 declare float @ff(float) #1
@@ -77,14 +74,14 @@ entry:
   %0 = load float* @x, align 4
   call void @vf(float %0)
   ret void
-; CHECK:       .ent    vft
-; NEG:         .ent    vft
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]]
-; NEG-NOT:      save   $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       restore $ra, $16, $17, [[FS]]
-; NEG-NOT:      restore        $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       .end    vft
-; NEG:         .end    vft
+; PIC:         .ent    vft
+; STATIC:      .ent    vft
+; PIC:         save    $16, $ra, [[FS:[0-9]+]]
+; STATIC:      save    $16, $ra, [[FS:[0-9]+]]
+; PIC:         restore $16, $ra, [[FS]]
+; STATIC:      restore $16, $ra, [[FS]]
+; PIC:         .end    vft
+; STATIC:      .end    vft
 }
 
 declare void @vf(float) #1
index 53036612ff652648ec642029061041f079ebea33..610693d58b3ff81d088f5a709ffc436c18420a90 100644 (file)
@@ -1,7 +1,7 @@
-; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=static  < %s | FileCheck %s -check-prefix=NEG
-
 ; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=static  < %s | FileCheck %s 
 
+; RUN: llc  -mtriple=mipsel-linux-gnu -march=mipsel -mcpu=mips16 -relocation-model=static  < %s | FileCheck %s -check-prefix=NEG
+
 @f = common global float 0.000000e+00, align 4
 
 ; Function Attrs: nounwind
@@ -14,8 +14,8 @@ entry:
   call void @x(i8* %arraydecay1)
   ret void
 ; CHECK:       .ent    foo1
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]] # 16 bit inst
-; CHECK:       restore $ra, $16, $17, [[FS]]
+; CHECK:       save    $16, $17, $ra, [[FS:[0-9]+]]  # 16 bit inst
+; CHECK:       restore $16, $17, $ra, [[FS]] # 16 bit inst
 ; CHECK:       .end    foo1
 }
 
@@ -31,13 +31,9 @@ entry:
   call void @x(i8* %arraydecay1)
   ret void
 ; CHECK:       .ent    foo2
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]]
-; CHECK:       restore $ra, $16, $17, [[FS]]
+; CHECK:       save    $16, $17, $ra, [[FS:[0-9]+]] 
+; CHECK:       restore $16, $17, $ra, [[FS]] 
 ; CHECK:       .end    foo2
-; NEG:         .ent    foo2
-; NEG-NOT:     save    $ra, $16, $17, [[FS:[0-9]+]]  # 16 bit inst
-; NEG-NOT:     restore $ra, $16, $17, [[FS]]  # 16 bit inst
-; NEG:         .end    foo2
 }
 
 ; Function Attrs: nounwind
@@ -47,12 +43,12 @@ entry:
   store float %call, float* @f, align 4
   ret void
 ; CHECK:       .ent    foo3
-; CHECK:       save    $ra, $16, $17, [[FS:[0-9]+]], $18
-; CHECK:       restore $ra, $16, $17, [[FS]], $18
+; CHECK:       save    $16, $17, $ra, $18, [[FS:[0-9]+]]
+; CHECK:       restore $16, $17, $ra, $18, [[FS]]
 ; CHECK:       .end    foo3
 ; NEG:         .ent    foo3
-; NEG-NOT:     save    $ra, $16, $17, [[FS:[0-9]+]], $18  # 16 bit inst
-; NEG-NOT:     restore $ra, $16, $17, [[FS]], $18  # 16 bit inst
+; NEG-NOT:     save    $16, $17, $ra, $18, [[FS:[0-9]+]] # 16 bit inst
+; NEG-NOT:     restore $16, $17, $ra, $18, [[FS]] # 16 bit inst
 ; NEG:         .end    foo3
 }