2012-02-18 12:03:15 +00:00
|
|
|
//===-- SparcRegisterInfo.cpp - SPARC Register Information ----------------===//
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-02-25 19:28:19 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:36:04 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 23:30:14 +00:00
|
|
|
//
|
2004-02-25 19:28:19 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
2008-02-10 18:45:23 +00:00
|
|
|
// This file contains the SPARC implementation of the TargetRegisterInfo class.
|
2004-02-25 19:28:19 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2006-02-05 05:50:24 +00:00
|
|
|
#include "SparcRegisterInfo.h"
|
2012-03-17 18:46:09 +00:00
|
|
|
#include "Sparc.h"
|
2006-02-05 05:50:24 +00:00
|
|
|
#include "SparcSubtarget.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/ADT/BitVector.h"
|
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2004-04-02 20:53:37 +00:00
|
|
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
2012-12-03 16:50:05 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2013-01-02 11:36:10 +00:00
|
|
|
#include "llvm/IR/Type.h"
|
2009-07-11 20:10:48 +00:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2006-11-27 23:37:22 +00:00
|
|
|
#include "llvm/Target/TargetInstrInfo.h"
|
2011-06-27 18:32:37 +00:00
|
|
|
|
|
|
|
#define GET_REGINFO_TARGET_DESC
|
2011-06-24 01:44:41 +00:00
|
|
|
#include "SparcGenRegisterInfo.inc"
|
2011-06-27 18:32:37 +00:00
|
|
|
|
2004-02-25 19:28:19 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2006-11-13 23:36:35 +00:00
|
|
|
SparcRegisterInfo::SparcRegisterInfo(SparcSubtarget &st,
|
|
|
|
const TargetInstrInfo &tii)
|
2011-07-18 20:57:22 +00:00
|
|
|
: SparcGenRegisterInfo(SP::I7), Subtarget(st), TII(tii) {
|
2006-02-04 06:58:46 +00:00
|
|
|
}
|
2004-02-25 19:28:19 +00:00
|
|
|
|
2012-03-04 03:33:22 +00:00
|
|
|
const uint16_t* SparcRegisterInfo::getCalleeSavedRegs(const MachineFunction *MF)
|
2007-07-14 14:06:15 +00:00
|
|
|
const {
|
2012-03-04 03:33:22 +00:00
|
|
|
static const uint16_t CalleeSavedRegs[] = { 0 };
|
2007-01-02 21:33:40 +00:00
|
|
|
return CalleeSavedRegs;
|
2006-05-18 00:12:58 +00:00
|
|
|
}
|
|
|
|
|
2007-02-19 21:49:54 +00:00
|
|
|
BitVector SparcRegisterInfo::getReservedRegs(const MachineFunction &MF) const {
|
|
|
|
BitVector Reserved(getNumRegs());
|
2011-06-09 16:56:59 +00:00
|
|
|
// FIXME: G1 reserved for now for large imm generation by frame code.
|
|
|
|
Reserved.set(SP::G1);
|
2007-02-19 21:49:54 +00:00
|
|
|
Reserved.set(SP::G2);
|
|
|
|
Reserved.set(SP::G3);
|
|
|
|
Reserved.set(SP::G4);
|
|
|
|
Reserved.set(SP::O6);
|
|
|
|
Reserved.set(SP::I6);
|
|
|
|
Reserved.set(SP::I7);
|
|
|
|
Reserved.set(SP::G0);
|
|
|
|
Reserved.set(SP::G5);
|
|
|
|
Reserved.set(SP::G6);
|
|
|
|
Reserved.set(SP::G7);
|
|
|
|
return Reserved;
|
|
|
|
}
|
|
|
|
|
2013-04-02 04:08:54 +00:00
|
|
|
const TargetRegisterClass*
|
|
|
|
SparcRegisterInfo::getPointerRegClass(const MachineFunction &MF,
|
|
|
|
unsigned Kind) const {
|
|
|
|
return Subtarget.is64Bit() ? &SP::I64RegsRegClass : &SP::IntRegsRegClass;
|
|
|
|
}
|
|
|
|
|
2010-08-26 23:32:16 +00:00
|
|
|
void
|
2009-10-07 17:12:56 +00:00
|
|
|
SparcRegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
|
2013-01-31 20:02:54 +00:00
|
|
|
int SPAdj, unsigned FIOperandNum,
|
|
|
|
RegScavenger *RS) const {
|
2007-05-01 09:13:03 +00:00
|
|
|
assert(SPAdj == 0 && "Unexpected");
|
|
|
|
|
2004-04-02 20:53:37 +00:00
|
|
|
MachineInstr &MI = *II;
|
2009-02-13 02:31:35 +00:00
|
|
|
DebugLoc dl = MI.getDebugLoc();
|
2013-01-31 20:02:54 +00:00
|
|
|
int FrameIndex = MI.getOperand(FIOperandNum).getIndex();
|
2004-04-02 20:53:37 +00:00
|
|
|
|
2004-04-06 22:10:22 +00:00
|
|
|
// Addressable stack objects are accessed using neg. offsets from %fp
|
2004-08-14 22:57:22 +00:00
|
|
|
MachineFunction &MF = *MI.getParent()->getParent();
|
2013-04-06 21:38:57 +00:00
|
|
|
int64_t Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
|
|
|
|
MI.getOperand(FIOperandNum + 1).getImm() +
|
|
|
|
Subtarget.getStackPointerBias();
|
Reserve G1 for frame offset stuff and use it to handle large stack frames.
For example, instead of emitting this:
test:
save -40112, %o6, %o6 ;; imm too large
add %i6, -40016, %o0 ;; imm too large
call caller
nop
restore %g0, %g0, %g0
retl
nop
emit this:
test:
sethi 4194264, %g1
or %g1, 848, %g1
save %o6, %g1, %o6
sethi 4194264, %g1
add %g1, %i6, %g1
add %i1, 944, %o0
call caller
nop
restore %g0, %g0, %g0
retl
nop
which doesn't cause the assembler to barf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-20 07:56:31 +00:00
|
|
|
|
|
|
|
// Replace frame index with a frame pointer reference.
|
|
|
|
if (Offset >= -4096 && Offset <= 4095) {
|
|
|
|
// If the offset is small enough to fit in the immediate field, directly
|
|
|
|
// encode it.
|
2013-01-31 20:02:54 +00:00
|
|
|
MI.getOperand(FIOperandNum).ChangeToRegister(SP::I6, false);
|
|
|
|
MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset);
|
Reserve G1 for frame offset stuff and use it to handle large stack frames.
For example, instead of emitting this:
test:
save -40112, %o6, %o6 ;; imm too large
add %i6, -40016, %o0 ;; imm too large
call caller
nop
restore %g0, %g0, %g0
retl
nop
emit this:
test:
sethi 4194264, %g1
or %g1, 848, %g1
save %o6, %g1, %o6
sethi 4194264, %g1
add %g1, %i6, %g1
add %i1, 944, %o0
call caller
nop
restore %g0, %g0, %g0
retl
nop
which doesn't cause the assembler to barf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-20 07:56:31 +00:00
|
|
|
} else {
|
|
|
|
// Otherwise, emit a G1 = SETHI %hi(offset). FIXME: it would be better to
|
|
|
|
// scavenge a register here instead of reserving G1 all of the time.
|
|
|
|
unsigned OffHi = (unsigned)Offset >> 10U;
|
2009-02-13 02:31:35 +00:00
|
|
|
BuildMI(*MI.getParent(), II, dl, TII.get(SP::SETHIi), SP::G1).addImm(OffHi);
|
Reserve G1 for frame offset stuff and use it to handle large stack frames.
For example, instead of emitting this:
test:
save -40112, %o6, %o6 ;; imm too large
add %i6, -40016, %o0 ;; imm too large
call caller
nop
restore %g0, %g0, %g0
retl
nop
emit this:
test:
sethi 4194264, %g1
or %g1, 848, %g1
save %o6, %g1, %o6
sethi 4194264, %g1
add %g1, %i6, %g1
add %i1, 944, %o0
call caller
nop
restore %g0, %g0, %g0
retl
nop
which doesn't cause the assembler to barf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-20 07:56:31 +00:00
|
|
|
// Emit G1 = G1 + I6
|
2009-02-13 02:31:35 +00:00
|
|
|
BuildMI(*MI.getParent(), II, dl, TII.get(SP::ADDrr), SP::G1).addReg(SP::G1)
|
2006-11-27 23:37:22 +00:00
|
|
|
.addReg(SP::I6);
|
Reserve G1 for frame offset stuff and use it to handle large stack frames.
For example, instead of emitting this:
test:
save -40112, %o6, %o6 ;; imm too large
add %i6, -40016, %o0 ;; imm too large
call caller
nop
restore %g0, %g0, %g0
retl
nop
emit this:
test:
sethi 4194264, %g1
or %g1, 848, %g1
save %o6, %g1, %o6
sethi 4194264, %g1
add %g1, %i6, %g1
add %i1, 944, %o0
call caller
nop
restore %g0, %g0, %g0
retl
nop
which doesn't cause the assembler to barf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-20 07:56:31 +00:00
|
|
|
// Insert: G1+%lo(offset) into the user.
|
2013-01-31 20:02:54 +00:00
|
|
|
MI.getOperand(FIOperandNum).ChangeToRegister(SP::G1, false);
|
|
|
|
MI.getOperand(FIOperandNum + 1).ChangeToImmediate(Offset & ((1 << 10)-1));
|
Reserve G1 for frame offset stuff and use it to handle large stack frames.
For example, instead of emitting this:
test:
save -40112, %o6, %o6 ;; imm too large
add %i6, -40016, %o0 ;; imm too large
call caller
nop
restore %g0, %g0, %g0
retl
nop
emit this:
test:
sethi 4194264, %g1
or %g1, 848, %g1
save %o6, %g1, %o6
sethi 4194264, %g1
add %g1, %i6, %g1
add %i1, 944, %o0
call caller
nop
restore %g0, %g0, %g0
retl
nop
which doesn't cause the assembler to barf.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24880 91177308-0d34-0410-b5e6-96231b3b80d8
2005-12-20 07:56:31 +00:00
|
|
|
}
|
2004-02-25 19:28:19 +00:00
|
|
|
}
|
|
|
|
|
2009-11-12 21:00:03 +00:00
|
|
|
unsigned SparcRegisterInfo::getFrameRegister(const MachineFunction &MF) const {
|
2009-09-08 12:47:30 +00:00
|
|
|
return SP::I6;
|
2006-03-23 18:12:57 +00:00
|
|
|
}
|
|
|
|
|
2007-02-21 22:54:50 +00:00
|
|
|
unsigned SparcRegisterInfo::getEHExceptionRegister() const {
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("What is the exception register");
|
2007-02-21 22:54:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned SparcRegisterInfo::getEHHandlerRegister() const {
|
2009-07-14 16:55:14 +00:00
|
|
|
llvm_unreachable("What is the exception handler register");
|
2007-02-21 22:54:50 +00:00
|
|
|
}
|