2005-02-05 10:24:26 +08:00
|
|
|
//===- AlphaInstrInfo.cpp - Alpha Instruction Information -------*- C++ -*-===//
|
2005-04-22 07:13:11 +08:00
|
|
|
//
|
2005-01-23 07:41:55 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-30 04:36:04 +08:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 07:13:11 +08:00
|
|
|
//
|
2005-01-23 07:41:55 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file contains the Alpha implementation of the TargetInstrInfo class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "Alpha.h"
|
|
|
|
#include "AlphaInstrInfo.h"
|
2009-06-04 04:30:14 +08:00
|
|
|
#include "AlphaMachineFunctionInfo.h"
|
|
|
|
#include "llvm/CodeGen/MachineRegisterInfo.h"
|
2007-09-07 12:06:50 +08:00
|
|
|
#include "llvm/ADT/STLExtras.h"
|
2009-01-06 01:59:02 +08:00
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2005-01-23 07:41:55 +08:00
|
|
|
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
2009-07-09 03:04:27 +08:00
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2011-06-29 04:07:07 +08:00
|
|
|
|
|
|
|
#define GET_INSTRINFO_MC_DESC
|
2011-07-02 01:57:27 +08:00
|
|
|
#define GET_INSTRINFO_CTOR
|
2011-06-29 04:07:07 +08:00
|
|
|
#include "AlphaGenInstrInfo.inc"
|
2005-01-23 07:41:55 +08:00
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
AlphaInstrInfo::AlphaInstrInfo()
|
2011-07-02 01:57:27 +08:00
|
|
|
: AlphaGenInstrInfo(Alpha::ADJUSTSTACKDOWN, Alpha::ADJUSTSTACKUP),
|
|
|
|
RI(*this) {
|
|
|
|
}
|
2005-01-23 07:41:55 +08:00
|
|
|
|
|
|
|
|
2006-02-03 04:12:32 +08:00
|
|
|
unsigned
|
2008-11-19 03:49:32 +08:00
|
|
|
AlphaInstrInfo::isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const {
|
2006-02-03 04:12:32 +08:00
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
case Alpha::LDL:
|
|
|
|
case Alpha::LDQ:
|
|
|
|
case Alpha::LDBU:
|
|
|
|
case Alpha::LDWU:
|
|
|
|
case Alpha::LDS:
|
|
|
|
case Alpha::LDT:
|
2008-10-03 23:45:36 +08:00
|
|
|
if (MI->getOperand(1).isFI()) {
|
2007-12-31 07:10:15 +08:00
|
|
|
FrameIndex = MI->getOperand(1).getIndex();
|
2006-02-03 04:12:32 +08:00
|
|
|
return MI->getOperand(0).getReg();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-02-03 11:07:37 +08:00
|
|
|
unsigned
|
2008-11-19 03:49:32 +08:00
|
|
|
AlphaInstrInfo::isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const {
|
2006-02-03 11:07:37 +08:00
|
|
|
switch (MI->getOpcode()) {
|
|
|
|
case Alpha::STL:
|
|
|
|
case Alpha::STQ:
|
|
|
|
case Alpha::STB:
|
|
|
|
case Alpha::STW:
|
|
|
|
case Alpha::STS:
|
|
|
|
case Alpha::STT:
|
2008-10-03 23:45:36 +08:00
|
|
|
if (MI->getOperand(1).isFI()) {
|
2007-12-31 07:10:15 +08:00
|
|
|
FrameIndex = MI->getOperand(1).getIndex();
|
2006-02-03 11:07:37 +08:00
|
|
|
return MI->getOperand(0).getReg();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-11-01 00:49:55 +08:00
|
|
|
static bool isAlphaIntCondCode(unsigned Opcode) {
|
|
|
|
switch (Opcode) {
|
|
|
|
case Alpha::BEQ:
|
|
|
|
case Alpha::BNE:
|
|
|
|
case Alpha::BGE:
|
|
|
|
case Alpha::BGT:
|
|
|
|
case Alpha::BLE:
|
|
|
|
case Alpha::BLT:
|
|
|
|
case Alpha::BLBC:
|
|
|
|
case Alpha::BLBS:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-15 06:49:33 +08:00
|
|
|
unsigned AlphaInstrInfo::InsertBranch(MachineBasicBlock &MBB,
|
2009-02-12 08:02:55 +08:00
|
|
|
MachineBasicBlock *TBB,
|
|
|
|
MachineBasicBlock *FBB,
|
2010-06-18 06:43:56 +08:00
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
DebugLoc DL) const {
|
2006-11-01 00:49:55 +08:00
|
|
|
assert(TBB && "InsertBranch must not be told to insert a fallthrough");
|
|
|
|
assert((Cond.size() == 2 || Cond.size() == 0) &&
|
|
|
|
"Alpha branch conditions have two components!");
|
|
|
|
|
|
|
|
// One-way branch.
|
|
|
|
if (FBB == 0) {
|
|
|
|
if (Cond.empty()) // Unconditional branch
|
2010-06-18 06:43:56 +08:00
|
|
|
BuildMI(&MBB, DL, get(Alpha::BR)).addMBB(TBB);
|
2006-11-01 00:49:55 +08:00
|
|
|
else // Conditional branch
|
|
|
|
if (isAlphaIntCondCode(Cond[0].getImm()))
|
2010-06-18 06:43:56 +08:00
|
|
|
BuildMI(&MBB, DL, get(Alpha::COND_BRANCH_I))
|
2006-11-01 00:49:55 +08:00
|
|
|
.addImm(Cond[0].getImm()).addReg(Cond[1].getReg()).addMBB(TBB);
|
|
|
|
else
|
2010-06-18 06:43:56 +08:00
|
|
|
BuildMI(&MBB, DL, get(Alpha::COND_BRANCH_F))
|
2006-11-01 00:49:55 +08:00
|
|
|
.addImm(Cond[0].getImm()).addReg(Cond[1].getReg()).addMBB(TBB);
|
2007-05-18 08:05:48 +08:00
|
|
|
return 1;
|
2006-11-01 00:49:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Two-way Conditional Branch.
|
|
|
|
if (isAlphaIntCondCode(Cond[0].getImm()))
|
2010-06-18 06:43:56 +08:00
|
|
|
BuildMI(&MBB, DL, get(Alpha::COND_BRANCH_I))
|
2006-11-01 00:49:55 +08:00
|
|
|
.addImm(Cond[0].getImm()).addReg(Cond[1].getReg()).addMBB(TBB);
|
|
|
|
else
|
2010-06-18 06:43:56 +08:00
|
|
|
BuildMI(&MBB, DL, get(Alpha::COND_BRANCH_F))
|
2006-11-01 00:49:55 +08:00
|
|
|
.addImm(Cond[0].getImm()).addReg(Cond[1].getReg()).addMBB(TBB);
|
2010-06-18 06:43:56 +08:00
|
|
|
BuildMI(&MBB, DL, get(Alpha::BR)).addMBB(FBB);
|
2007-05-18 08:05:48 +08:00
|
|
|
return 2;
|
2006-11-01 00:49:55 +08:00
|
|
|
}
|
|
|
|
|
2010-07-11 09:08:23 +08:00
|
|
|
void AlphaInstrInfo::copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
bool KillSrc) const {
|
|
|
|
if (Alpha::GPRCRegClass.contains(DestReg, SrcReg)) {
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::BISr), DestReg)
|
|
|
|
.addReg(SrcReg)
|
2010-07-11 09:08:23 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(KillSrc));
|
|
|
|
} else if (Alpha::F4RCRegClass.contains(DestReg, SrcReg)) {
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::CPYSS), DestReg)
|
|
|
|
.addReg(SrcReg)
|
2010-07-11 09:08:23 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(KillSrc));
|
|
|
|
} else if (Alpha::F8RCRegClass.contains(DestReg, SrcReg)) {
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::CPYST), DestReg)
|
|
|
|
.addReg(SrcReg)
|
2010-07-11 09:08:23 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(KillSrc));
|
2007-12-31 14:32:00 +08:00
|
|
|
} else {
|
2010-07-11 09:08:23 +08:00
|
|
|
llvm_unreachable("Attempt to copy register that is not GPR or FPR");
|
2007-12-31 14:32:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-02 05:11:32 +08:00
|
|
|
void
|
|
|
|
AlphaInstrInfo::storeRegToStackSlot(MachineBasicBlock &MBB,
|
2009-02-12 08:02:55 +08:00
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIdx,
|
2010-05-07 03:06:44 +08:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2008-01-02 05:11:32 +08:00
|
|
|
//cerr << "Trying to store " << getPrettyName(SrcReg) << " to "
|
|
|
|
// << FrameIdx << "\n";
|
|
|
|
//BuildMI(MBB, MI, Alpha::WTF, 0).addReg(SrcReg);
|
2009-02-12 08:02:55 +08:00
|
|
|
|
2010-04-03 04:16:16 +08:00
|
|
|
DebugLoc DL;
|
2009-02-12 08:02:55 +08:00
|
|
|
if (MI != MBB.end()) DL = MI->getDebugLoc();
|
|
|
|
|
2008-01-02 05:11:32 +08:00
|
|
|
if (RC == Alpha::F4RCRegisterClass)
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::STS))
|
2009-05-14 05:33:08 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(isKill))
|
2008-01-02 05:11:32 +08:00
|
|
|
.addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
else if (RC == Alpha::F8RCRegisterClass)
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::STT))
|
2009-05-14 05:33:08 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(isKill))
|
2008-01-02 05:11:32 +08:00
|
|
|
.addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
else if (RC == Alpha::GPRCRegisterClass)
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::STQ))
|
2009-05-14 05:33:08 +08:00
|
|
|
.addReg(SrcReg, getKillRegState(isKill))
|
2008-01-02 05:11:32 +08:00
|
|
|
.addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
else
|
2009-07-15 00:55:14 +08:00
|
|
|
llvm_unreachable("Unhandled register class");
|
2008-01-02 05:11:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
AlphaInstrInfo::loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, int FrameIdx,
|
2010-05-07 03:06:44 +08:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2008-01-02 05:11:32 +08:00
|
|
|
//cerr << "Trying to load " << getPrettyName(DestReg) << " to "
|
|
|
|
// << FrameIdx << "\n";
|
2010-04-03 04:16:16 +08:00
|
|
|
DebugLoc DL;
|
2009-02-12 08:02:55 +08:00
|
|
|
if (MI != MBB.end()) DL = MI->getDebugLoc();
|
|
|
|
|
2008-01-02 05:11:32 +08:00
|
|
|
if (RC == Alpha::F4RCRegisterClass)
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::LDS), DestReg)
|
2008-01-02 05:11:32 +08:00
|
|
|
.addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
else if (RC == Alpha::F8RCRegisterClass)
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::LDT), DestReg)
|
2008-01-02 05:11:32 +08:00
|
|
|
.addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
else if (RC == Alpha::GPRCRegisterClass)
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::LDQ), DestReg)
|
2008-01-02 05:11:32 +08:00
|
|
|
.addFrameIndex(FrameIdx).addReg(Alpha::F31);
|
|
|
|
else
|
2009-07-15 00:55:14 +08:00
|
|
|
llvm_unreachable("Unhandled register class");
|
2008-01-02 05:11:32 +08:00
|
|
|
}
|
|
|
|
|
2006-11-01 00:49:55 +08:00
|
|
|
static unsigned AlphaRevCondCode(unsigned Opcode) {
|
|
|
|
switch (Opcode) {
|
|
|
|
case Alpha::BEQ: return Alpha::BNE;
|
|
|
|
case Alpha::BNE: return Alpha::BEQ;
|
|
|
|
case Alpha::BGE: return Alpha::BLT;
|
|
|
|
case Alpha::BGT: return Alpha::BLE;
|
|
|
|
case Alpha::BLE: return Alpha::BGT;
|
|
|
|
case Alpha::BLT: return Alpha::BGE;
|
|
|
|
case Alpha::BLBC: return Alpha::BLBS;
|
|
|
|
case Alpha::BLBS: return Alpha::BLBC;
|
|
|
|
case Alpha::FBEQ: return Alpha::FBNE;
|
|
|
|
case Alpha::FBNE: return Alpha::FBEQ;
|
|
|
|
case Alpha::FBGE: return Alpha::FBLT;
|
|
|
|
case Alpha::FBGT: return Alpha::FBLE;
|
|
|
|
case Alpha::FBLE: return Alpha::FBGT;
|
|
|
|
case Alpha::FBLT: return Alpha::FBGE;
|
|
|
|
default:
|
2009-07-15 00:55:14 +08:00
|
|
|
llvm_unreachable("Unknown opcode");
|
2006-11-01 00:49:55 +08:00
|
|
|
}
|
2008-03-31 02:22:13 +08:00
|
|
|
return 0; // Not reached
|
2006-11-01 00:49:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Branch analysis.
|
|
|
|
bool AlphaInstrInfo::AnalyzeBranch(MachineBasicBlock &MBB,MachineBasicBlock *&TBB,
|
2009-02-09 15:14:22 +08:00
|
|
|
MachineBasicBlock *&FBB,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify) const {
|
2006-11-01 00:49:55 +08:00
|
|
|
// If the block has no terminators, it just falls into the block after it.
|
|
|
|
MachineBasicBlock::iterator I = MBB.end();
|
2010-04-02 09:38:09 +08:00
|
|
|
if (I == MBB.begin())
|
|
|
|
return false;
|
|
|
|
--I;
|
|
|
|
while (I->isDebugValue()) {
|
|
|
|
if (I == MBB.begin())
|
|
|
|
return false;
|
|
|
|
--I;
|
|
|
|
}
|
|
|
|
if (!isUnpredicatedTerminator(I))
|
2006-11-01 00:49:55 +08:00
|
|
|
return false;
|
|
|
|
|
|
|
|
// Get the last instruction in the block.
|
|
|
|
MachineInstr *LastInst = I;
|
|
|
|
|
|
|
|
// If there is only one terminator instruction, process it.
|
2007-06-09 05:59:56 +08:00
|
|
|
if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
|
2006-11-01 00:49:55 +08:00
|
|
|
if (LastInst->getOpcode() == Alpha::BR) {
|
2007-12-31 07:10:15 +08:00
|
|
|
TBB = LastInst->getOperand(0).getMBB();
|
2006-11-01 00:49:55 +08:00
|
|
|
return false;
|
|
|
|
} else if (LastInst->getOpcode() == Alpha::COND_BRANCH_I ||
|
|
|
|
LastInst->getOpcode() == Alpha::COND_BRANCH_F) {
|
|
|
|
// Block ends with fall-through condbranch.
|
2007-12-31 07:10:15 +08:00
|
|
|
TBB = LastInst->getOperand(2).getMBB();
|
2006-11-01 00:49:55 +08:00
|
|
|
Cond.push_back(LastInst->getOperand(0));
|
|
|
|
Cond.push_back(LastInst->getOperand(1));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
// Otherwise, don't know what this is.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the instruction before it if it's a terminator.
|
|
|
|
MachineInstr *SecondLastInst = I;
|
|
|
|
|
|
|
|
// If there are three terminators, we don't know what sort of block this is.
|
|
|
|
if (SecondLastInst && I != MBB.begin() &&
|
2007-06-09 05:59:56 +08:00
|
|
|
isUnpredicatedTerminator(--I))
|
2006-11-01 00:49:55 +08:00
|
|
|
return true;
|
|
|
|
|
|
|
|
// If the block ends with Alpha::BR and Alpha::COND_BRANCH_*, handle it.
|
|
|
|
if ((SecondLastInst->getOpcode() == Alpha::COND_BRANCH_I ||
|
|
|
|
SecondLastInst->getOpcode() == Alpha::COND_BRANCH_F) &&
|
|
|
|
LastInst->getOpcode() == Alpha::BR) {
|
2007-12-31 07:10:15 +08:00
|
|
|
TBB = SecondLastInst->getOperand(2).getMBB();
|
2006-11-01 00:49:55 +08:00
|
|
|
Cond.push_back(SecondLastInst->getOperand(0));
|
|
|
|
Cond.push_back(SecondLastInst->getOperand(1));
|
2007-12-31 07:10:15 +08:00
|
|
|
FBB = LastInst->getOperand(0).getMBB();
|
2006-11-01 00:49:55 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-06-14 01:59:52 +08:00
|
|
|
// If the block ends with two Alpha::BRs, handle it. The second one is not
|
|
|
|
// executed, so remove it.
|
|
|
|
if (SecondLastInst->getOpcode() == Alpha::BR &&
|
|
|
|
LastInst->getOpcode() == Alpha::BR) {
|
2007-12-31 07:10:15 +08:00
|
|
|
TBB = SecondLastInst->getOperand(0).getMBB();
|
2007-06-14 01:59:52 +08:00
|
|
|
I = LastInst;
|
2009-02-09 15:14:22 +08:00
|
|
|
if (AllowModify)
|
|
|
|
I->eraseFromParent();
|
2007-06-14 01:59:52 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-11-01 00:49:55 +08:00
|
|
|
// Otherwise, can't handle this.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-05-18 08:05:48 +08:00
|
|
|
unsigned AlphaInstrInfo::RemoveBranch(MachineBasicBlock &MBB) const {
|
2006-11-01 00:49:55 +08:00
|
|
|
MachineBasicBlock::iterator I = MBB.end();
|
2007-05-18 08:05:48 +08:00
|
|
|
if (I == MBB.begin()) return 0;
|
2006-11-01 00:49:55 +08:00
|
|
|
--I;
|
2010-04-02 09:38:09 +08:00
|
|
|
while (I->isDebugValue()) {
|
|
|
|
if (I == MBB.begin())
|
|
|
|
return 0;
|
|
|
|
--I;
|
|
|
|
}
|
2006-11-01 00:49:55 +08:00
|
|
|
if (I->getOpcode() != Alpha::BR &&
|
|
|
|
I->getOpcode() != Alpha::COND_BRANCH_I &&
|
|
|
|
I->getOpcode() != Alpha::COND_BRANCH_F)
|
2007-05-18 08:05:48 +08:00
|
|
|
return 0;
|
2006-11-01 00:49:55 +08:00
|
|
|
|
|
|
|
// Remove the branch.
|
|
|
|
I->eraseFromParent();
|
|
|
|
|
|
|
|
I = MBB.end();
|
|
|
|
|
2007-05-18 08:05:48 +08:00
|
|
|
if (I == MBB.begin()) return 1;
|
2006-11-01 00:49:55 +08:00
|
|
|
--I;
|
|
|
|
if (I->getOpcode() != Alpha::COND_BRANCH_I &&
|
|
|
|
I->getOpcode() != Alpha::COND_BRANCH_F)
|
2007-05-18 08:05:48 +08:00
|
|
|
return 1;
|
2006-11-01 00:49:55 +08:00
|
|
|
|
|
|
|
// Remove the branch.
|
|
|
|
I->eraseFromParent();
|
2007-05-18 08:05:48 +08:00
|
|
|
return 2;
|
2006-11-01 00:49:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void AlphaInstrInfo::insertNoop(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI) const {
|
2010-04-03 04:16:16 +08:00
|
|
|
DebugLoc DL;
|
2009-02-12 08:02:55 +08:00
|
|
|
BuildMI(MBB, MI, DL, get(Alpha::BISr), Alpha::R31)
|
|
|
|
.addReg(Alpha::R31)
|
2006-11-01 00:49:55 +08:00
|
|
|
.addReg(Alpha::R31);
|
2006-10-25 01:07:11 +08:00
|
|
|
}
|
2006-11-01 00:49:55 +08:00
|
|
|
|
|
|
|
bool AlphaInstrInfo::
|
2008-08-15 06:49:33 +08:00
|
|
|
ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
|
2006-11-01 00:49:55 +08:00
|
|
|
assert(Cond.size() == 2 && "Invalid Alpha branch opcode!");
|
|
|
|
Cond[0].setImm(AlphaRevCondCode(Cond[0].getImm()));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-04 04:30:14 +08:00
|
|
|
/// getGlobalBaseReg - Return a virtual register initialized with the
|
|
|
|
/// the global base register value. Output instructions required to
|
|
|
|
/// initialize the register in the function entry block, if necessary.
|
|
|
|
///
|
|
|
|
unsigned AlphaInstrInfo::getGlobalBaseReg(MachineFunction *MF) const {
|
|
|
|
AlphaMachineFunctionInfo *AlphaFI = MF->getInfo<AlphaMachineFunctionInfo>();
|
|
|
|
unsigned GlobalBaseReg = AlphaFI->getGlobalBaseReg();
|
|
|
|
if (GlobalBaseReg != 0)
|
|
|
|
return GlobalBaseReg;
|
|
|
|
|
|
|
|
// Insert the set of GlobalBaseReg into the first MBB of the function
|
|
|
|
MachineBasicBlock &FirstMBB = MF->front();
|
|
|
|
MachineBasicBlock::iterator MBBI = FirstMBB.begin();
|
|
|
|
MachineRegisterInfo &RegInfo = MF->getRegInfo();
|
|
|
|
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
|
|
|
|
|
|
|
|
GlobalBaseReg = RegInfo.createVirtualRegister(&Alpha::GPRCRegClass);
|
2010-07-11 06:43:03 +08:00
|
|
|
BuildMI(FirstMBB, MBBI, DebugLoc(), TII->get(TargetOpcode::COPY),
|
|
|
|
GlobalBaseReg).addReg(Alpha::R29);
|
2009-06-04 04:30:14 +08:00
|
|
|
RegInfo.addLiveIn(Alpha::R29);
|
|
|
|
|
|
|
|
AlphaFI->setGlobalBaseReg(GlobalBaseReg);
|
|
|
|
return GlobalBaseReg;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getGlobalRetAddr - Return a virtual register initialized with the
|
|
|
|
/// the global base register value. Output instructions required to
|
|
|
|
/// initialize the register in the function entry block, if necessary.
|
|
|
|
///
|
|
|
|
unsigned AlphaInstrInfo::getGlobalRetAddr(MachineFunction *MF) const {
|
|
|
|
AlphaMachineFunctionInfo *AlphaFI = MF->getInfo<AlphaMachineFunctionInfo>();
|
|
|
|
unsigned GlobalRetAddr = AlphaFI->getGlobalRetAddr();
|
|
|
|
if (GlobalRetAddr != 0)
|
|
|
|
return GlobalRetAddr;
|
|
|
|
|
|
|
|
// Insert the set of GlobalRetAddr into the first MBB of the function
|
|
|
|
MachineBasicBlock &FirstMBB = MF->front();
|
|
|
|
MachineBasicBlock::iterator MBBI = FirstMBB.begin();
|
|
|
|
MachineRegisterInfo &RegInfo = MF->getRegInfo();
|
|
|
|
const TargetInstrInfo *TII = MF->getTarget().getInstrInfo();
|
|
|
|
|
|
|
|
GlobalRetAddr = RegInfo.createVirtualRegister(&Alpha::GPRCRegClass);
|
2010-07-11 06:43:03 +08:00
|
|
|
BuildMI(FirstMBB, MBBI, DebugLoc(), TII->get(TargetOpcode::COPY),
|
|
|
|
GlobalRetAddr).addReg(Alpha::R26);
|
2009-06-04 04:30:14 +08:00
|
|
|
RegInfo.addLiveIn(Alpha::R26);
|
|
|
|
|
|
|
|
AlphaFI->setGlobalRetAddr(GlobalRetAddr);
|
|
|
|
return GlobalRetAddr;
|
|
|
|
}
|