[mips][microMIPS] Change register class for GP register

Differential Revision: http://reviews.llvm.org/D7934


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@230760 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Zoran Jovanovic 2015-02-27 15:03:50 +00:00
parent 27eab65932
commit 2846ef3680
2 changed files with 29 additions and 6 deletions

View File

@ -79,14 +79,19 @@ unsigned MipsFunctionInfo::getGlobalBaseReg() {
if (GlobalBaseReg)
return GlobalBaseReg;
MipsSubtarget const &STI =
static_cast<const MipsSubtarget &>(MF.getSubtarget());
const TargetRegisterClass *RC =
static_cast<const MipsSubtarget &>(MF.getSubtarget()).inMips16Mode()
STI.inMips16Mode()
? &Mips::CPU16RegsRegClass
: static_cast<const MipsTargetMachine &>(MF.getTarget())
.getABI()
.IsN64()
? &Mips::GPR64RegClass
: &Mips::GPR32RegClass;
: STI.inMicroMipsMode()
? &Mips::GPRMM16RegClass
: static_cast<const MipsTargetMachine &>(MF.getTarget())
.getABI()
.IsN64()
? &Mips::GPR64RegClass
: &Mips::GPR32RegClass;
return GlobalBaseReg = MF.getRegInfo().createVirtualRegister(RC);
}

View File

@ -0,0 +1,18 @@
; RUN: llc -march=mipsel -mcpu=mips32r2 -mattr=+micromips \
; RUN: -relocation-model=pic -O3 < %s | FileCheck %s
@g = external global i32
; Function Attrs: noreturn nounwind
define void @foo() #0 {
entry:
%0 = load i32* @g, align 4
tail call void @exit(i32 signext %0)
unreachable
}
; Function Attrs: noreturn
declare void @exit(i32 signext)
; CHECK: move $gp, ${{[0-9]+}}