2003-08-01 22:19:03 +00:00
|
|
|
//===-- SparcV9CodeEmitter.cpp --------------------------------------------===//
|
2003-10-20 19:43:21 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2003-05-30 20:17:33 +00:00
|
|
|
//
|
2003-10-13 19:51:20 +00:00
|
|
|
// SPARC-specific backend for emitting machine code to memory.
|
|
|
|
//
|
|
|
|
// This module also contains the code for lazily resolving the targets
|
|
|
|
// of call instructions, including the callback used to redirect calls
|
|
|
|
// to functions for which the code has not yet been generated into the
|
|
|
|
// JIT compiler.
|
|
|
|
//
|
|
|
|
// This file #includes SparcV9CodeEmitter.inc, which contains the code
|
|
|
|
// for getBinaryCodeForInstr(), a method that converts a MachineInstr
|
|
|
|
// into the corresponding binary machine code word.
|
2003-05-30 20:17:33 +00:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2003-06-02 04:12:39 +00:00
|
|
|
#include "llvm/Constants.h"
|
|
|
|
#include "llvm/Function.h"
|
|
|
|
#include "llvm/GlobalVariable.h"
|
2003-05-27 20:07:58 +00:00
|
|
|
#include "llvm/PassManager.h"
|
|
|
|
#include "llvm/CodeGen/MachineCodeEmitter.h"
|
2003-06-04 20:01:13 +00:00
|
|
|
#include "llvm/CodeGen/MachineConstantPool.h"
|
2003-05-27 20:07:58 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunctionPass.h"
|
|
|
|
#include "llvm/CodeGen/MachineInstr.h"
|
2003-05-30 20:17:33 +00:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2003-06-02 04:12:39 +00:00
|
|
|
#include "llvm/Target/TargetData.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
2004-02-25 18:44:15 +00:00
|
|
|
#include "SparcV9Internals.h"
|
|
|
|
#include "SparcV9TargetMachine.h"
|
|
|
|
#include "SparcV9RegInfo.h"
|
2003-05-27 21:45:05 +00:00
|
|
|
#include "SparcV9CodeEmitter.h"
|
2004-11-22 20:25:10 +00:00
|
|
|
#include "SparcV9Relocations.h"
|
2004-08-16 21:55:02 +00:00
|
|
|
#include "MachineFunctionInfo.h"
|
2004-11-22 20:25:10 +00:00
|
|
|
using namespace llvm;
|
2003-09-05 22:59:31 +00:00
|
|
|
|
2004-02-25 18:44:15 +00:00
|
|
|
bool SparcV9TargetMachine::addPassesToEmitMachineCode(FunctionPassManager &PM,
|
2004-08-04 21:48:00 +00:00
|
|
|
MachineCodeEmitter &MCE) {
|
2004-07-27 19:37:37 +00:00
|
|
|
PM.add(new SparcV9CodeEmitter(*this, MCE));
|
2004-08-04 21:48:00 +00:00
|
|
|
PM.add(createSparcV9MachineCodeDestructionPass());
|
2003-05-27 20:07:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-06-04 20:01:13 +00:00
|
|
|
SparcV9CodeEmitter::SparcV9CodeEmitter(TargetMachine &tm,
|
2004-11-22 20:25:10 +00:00
|
|
|
MachineCodeEmitter &M): TM(tm), MCE(M) {}
|
2003-06-02 04:12:39 +00:00
|
|
|
|
2003-06-04 20:01:13 +00:00
|
|
|
void SparcV9CodeEmitter::emitWord(unsigned Val) {
|
2004-04-23 17:11:15 +00:00
|
|
|
MCE.emitWord(Val);
|
2003-05-30 20:17:33 +00:00
|
|
|
}
|
|
|
|
|
2003-06-05 20:52:06 +00:00
|
|
|
unsigned
|
2003-07-14 23:26:03 +00:00
|
|
|
SparcV9CodeEmitter::getRealRegNum(unsigned fakeReg,
|
2003-08-15 00:26:50 +00:00
|
|
|
MachineInstr &MI) {
|
2004-06-03 02:45:09 +00:00
|
|
|
const SparcV9RegInfo &RI = *TM.getRegInfo();
|
2003-07-14 23:26:03 +00:00
|
|
|
unsigned regClass, regType = RI.getRegType(fakeReg);
|
|
|
|
// At least map fakeReg into its class
|
|
|
|
fakeReg = RI.getClassRegNum(fakeReg, regClass);
|
|
|
|
|
2003-07-03 18:36:47 +00:00
|
|
|
switch (regClass) {
|
2004-02-25 18:44:15 +00:00
|
|
|
case SparcV9RegInfo::IntRegClassID: {
|
|
|
|
// SparcV9 manual, p31
|
2003-07-03 18:36:47 +00:00
|
|
|
static const unsigned IntRegMap[] = {
|
|
|
|
// "o0", "o1", "o2", "o3", "o4", "o5", "o7",
|
|
|
|
8, 9, 10, 11, 12, 13, 15,
|
|
|
|
// "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
|
|
|
|
16, 17, 18, 19, 20, 21, 22, 23,
|
|
|
|
// "i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7",
|
|
|
|
24, 25, 26, 27, 28, 29, 30, 31,
|
|
|
|
// "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
|
|
|
|
0, 1, 2, 3, 4, 5, 6, 7,
|
|
|
|
// "o6"
|
|
|
|
14
|
|
|
|
};
|
|
|
|
|
|
|
|
return IntRegMap[fakeReg];
|
|
|
|
break;
|
|
|
|
}
|
2004-02-25 18:44:15 +00:00
|
|
|
case SparcV9RegInfo::FloatRegClassID: {
|
2003-07-03 18:36:47 +00:00
|
|
|
DEBUG(std::cerr << "FP reg: " << fakeReg << "\n");
|
2004-02-25 18:44:15 +00:00
|
|
|
if (regType == SparcV9RegInfo::FPSingleRegType) {
|
2003-07-14 23:26:03 +00:00
|
|
|
// only numbered 0-31, hence can already fit into 5 bits (and 6)
|
|
|
|
DEBUG(std::cerr << "FP single reg, returning: " << fakeReg << "\n");
|
2004-02-25 18:44:15 +00:00
|
|
|
} else if (regType == SparcV9RegInfo::FPDoubleRegType) {
|
2003-10-10 17:57:28 +00:00
|
|
|
// FIXME: This assumes that we only have 5-bit register fields!
|
2004-02-25 18:44:15 +00:00
|
|
|
// From SparcV9 Manual, page 40.
|
2003-07-14 23:26:03 +00:00
|
|
|
// The bit layout becomes: b[4], b[3], b[2], b[1], b[5]
|
|
|
|
fakeReg |= (fakeReg >> 5) & 1;
|
|
|
|
fakeReg &= 0x1f;
|
|
|
|
DEBUG(std::cerr << "FP double reg, returning: " << fakeReg << "\n");
|
|
|
|
}
|
2003-07-03 18:36:47 +00:00
|
|
|
return fakeReg;
|
|
|
|
}
|
2004-02-25 18:44:15 +00:00
|
|
|
case SparcV9RegInfo::IntCCRegClassID: {
|
2003-07-16 20:30:40 +00:00
|
|
|
/* xcc, icc, ccr */
|
|
|
|
static const unsigned IntCCReg[] = { 6, 4, 2 };
|
2003-07-03 18:36:47 +00:00
|
|
|
|
2003-07-16 20:30:40 +00:00
|
|
|
assert(fakeReg < sizeof(IntCCReg)/sizeof(IntCCReg[0])
|
|
|
|
&& "CC register out of bounds for IntCCReg map");
|
|
|
|
DEBUG(std::cerr << "IntCC reg: " << IntCCReg[fakeReg] << "\n");
|
|
|
|
return IntCCReg[fakeReg];
|
2003-07-03 18:36:47 +00:00
|
|
|
}
|
2004-02-25 18:44:15 +00:00
|
|
|
case SparcV9RegInfo::FloatCCRegClassID: {
|
2003-07-03 18:36:47 +00:00
|
|
|
/* These are laid out %fcc0 - %fcc3 => 0 - 3, so are correct */
|
|
|
|
DEBUG(std::cerr << "FP CC reg: " << fakeReg << "\n");
|
|
|
|
return fakeReg;
|
|
|
|
}
|
2004-06-09 21:54:59 +00:00
|
|
|
case SparcV9RegInfo::SpecialRegClassID: {
|
|
|
|
// Currently only "special" reg is %fsr, which is encoded as 1 in
|
|
|
|
// instructions and 0 in SparcV9SpecialRegClass.
|
|
|
|
static const unsigned SpecialReg[] = { 1 };
|
|
|
|
assert(fakeReg < sizeof(SpecialReg)/sizeof(SpecialReg[0])
|
|
|
|
&& "Special register out of bounds for SpecialReg map");
|
|
|
|
DEBUG(std::cerr << "Special reg: " << SpecialReg[fakeReg] << "\n");
|
|
|
|
return SpecialReg[fakeReg];
|
|
|
|
}
|
2003-07-03 18:36:47 +00:00
|
|
|
default:
|
2004-06-09 20:44:42 +00:00
|
|
|
assert(0 && "Invalid unified register number in getRealRegNum");
|
2003-07-03 18:36:47 +00:00
|
|
|
return fakeReg;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-07-15 19:09:43 +00:00
|
|
|
|
2003-05-30 20:17:33 +00:00
|
|
|
int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI,
|
|
|
|
MachineOperand &MO) {
|
2003-06-02 02:13:26 +00:00
|
|
|
int64_t rv = 0; // Return value; defaults to 0 for unhandled cases
|
|
|
|
// or things that get fixed up later by the JIT.
|
2004-11-22 20:25:10 +00:00
|
|
|
if (MO.isPCRelativeDisp() || MO.isGlobalAddress()) {
|
2003-06-06 00:26:11 +00:00
|
|
|
DEBUG(std::cerr << "PCRelativeDisp: ");
|
2003-06-02 05:24:46 +00:00
|
|
|
Value *V = MO.getVRegValue();
|
|
|
|
if (BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
|
2003-06-06 00:26:11 +00:00
|
|
|
DEBUG(std::cerr << "Saving reference to BB (VReg)\n");
|
2003-06-04 20:01:13 +00:00
|
|
|
unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
|
2003-06-02 05:24:46 +00:00
|
|
|
BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
|
2004-05-19 21:30:01 +00:00
|
|
|
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
|
2004-05-20 07:43:40 +00:00
|
|
|
// The real target of the branch is CI = PC + (rv * 4)
|
|
|
|
// So undo that: give the instruction (CI - PC) / 4
|
|
|
|
rv = (CI->getRawValue() - MCE.getCurrentPCValue()) / 4;
|
2003-06-04 20:01:13 +00:00
|
|
|
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) {
|
2004-11-23 15:57:01 +00:00
|
|
|
unsigned Reloc = 0;
|
2003-06-04 20:01:13 +00:00
|
|
|
if (MI.getOpcode() == V9::CALL) {
|
2004-11-22 20:25:10 +00:00
|
|
|
Reloc = V9::reloc_pcrel_call;
|
|
|
|
} else if (MI.getOpcode() == V9::SETHI) {
|
|
|
|
if (MO.isHiBits64())
|
|
|
|
Reloc = V9::reloc_sethi_hh;
|
|
|
|
else if (MO.isHiBits32())
|
|
|
|
Reloc = V9::reloc_sethi_lm;
|
|
|
|
else
|
|
|
|
assert(0 && "Unknown relocation!");
|
|
|
|
} else if (MI.getOpcode() == V9::ORi) {
|
|
|
|
if (MO.isLoBits32())
|
|
|
|
Reloc = V9::reloc_or_lo;
|
|
|
|
else if (MO.isLoBits64())
|
|
|
|
Reloc = V9::reloc_or_hm;
|
|
|
|
else
|
|
|
|
assert(0 && "Unknown relocation!");
|
|
|
|
} else {
|
|
|
|
assert(0 && "Unknown relocation!");
|
2003-06-04 20:01:13 +00:00
|
|
|
}
|
2004-11-22 20:25:10 +00:00
|
|
|
|
2004-11-22 21:42:40 +00:00
|
|
|
MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(), Reloc, GV));
|
2004-11-22 20:25:10 +00:00
|
|
|
rv = 0;
|
2003-06-02 05:24:46 +00:00
|
|
|
} else {
|
|
|
|
std::cerr << "ERROR: PC relative disp unhandled:" << MO << "\n";
|
|
|
|
abort();
|
|
|
|
}
|
2004-02-11 05:55:00 +00:00
|
|
|
} else if (MO.isRegister() || MO.getType() == MachineOperand::MO_CCRegister)
|
2003-06-05 20:52:06 +00:00
|
|
|
{
|
2004-02-25 18:44:15 +00:00
|
|
|
// This is necessary because the SparcV9 backend doesn't actually lay out
|
2003-07-03 18:36:47 +00:00
|
|
|
// registers in the real fashion -- it skips those that it chooses not to
|
|
|
|
// allocate, i.e. those that are the FP, SP, etc.
|
2004-02-13 21:01:20 +00:00
|
|
|
unsigned fakeReg = MO.getReg();
|
2003-07-14 23:26:03 +00:00
|
|
|
unsigned realRegByClass = getRealRegNum(fakeReg, MI);
|
|
|
|
DEBUG(std::cerr << MO << ": Reg[" << std::dec << fakeReg << "] => "
|
2003-07-16 20:30:40 +00:00
|
|
|
<< realRegByClass << " (LLC: "
|
2004-06-02 05:55:25 +00:00
|
|
|
<< TM.getRegInfo()->getUnifiedRegName(fakeReg) << ")\n");
|
2003-07-03 18:36:47 +00:00
|
|
|
rv = realRegByClass;
|
2003-05-27 20:07:58 +00:00
|
|
|
} else if (MO.isImmediate()) {
|
2003-06-02 02:13:26 +00:00
|
|
|
rv = MO.getImmedValue();
|
2003-06-06 00:26:11 +00:00
|
|
|
DEBUG(std::cerr << "immed: " << rv << "\n");
|
2003-05-30 20:17:33 +00:00
|
|
|
} else if (MO.isMachineBasicBlock()) {
|
2003-06-02 05:24:46 +00:00
|
|
|
// Duplicate code of the above case for VirtualRegister, BasicBlock...
|
2004-02-25 18:44:15 +00:00
|
|
|
// It should really hit this case, but SparcV9 backend uses VRegs instead
|
2003-06-06 00:26:11 +00:00
|
|
|
DEBUG(std::cerr << "Saving reference to MBB\n");
|
2003-07-26 23:04:00 +00:00
|
|
|
const BasicBlock *BB = MO.getMachineBasicBlock()->getBasicBlock();
|
2003-06-04 20:01:13 +00:00
|
|
|
unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
|
2003-06-02 05:24:46 +00:00
|
|
|
BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
|
|
|
|
} else if (MO.isExternalSymbol()) {
|
2004-02-25 18:44:15 +00:00
|
|
|
// SparcV9 backend doesn't generate this (yet...)
|
2003-06-02 05:24:46 +00:00
|
|
|
std::cerr << "ERROR: External symbol unhandled: " << MO << "\n";
|
|
|
|
abort();
|
2003-05-30 20:17:33 +00:00
|
|
|
} else if (MO.isFrameIndex()) {
|
2004-02-25 18:44:15 +00:00
|
|
|
// SparcV9 backend doesn't generate this (yet...)
|
2003-06-02 05:24:46 +00:00
|
|
|
int FrameIndex = MO.getFrameIndex();
|
2003-05-30 20:17:33 +00:00
|
|
|
std::cerr << "ERROR: Frame index unhandled.\n";
|
2003-06-02 05:24:46 +00:00
|
|
|
abort();
|
2003-05-30 20:17:33 +00:00
|
|
|
} else if (MO.isConstantPoolIndex()) {
|
2003-11-07 18:06:26 +00:00
|
|
|
unsigned Index = MO.getConstantPoolIndex();
|
|
|
|
rv = MCE.getConstantPoolEntryAddress(Index);
|
2003-05-27 20:07:58 +00:00
|
|
|
} else {
|
2003-05-30 20:17:33 +00:00
|
|
|
std::cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
|
2003-06-02 05:24:46 +00:00
|
|
|
abort();
|
2003-06-02 02:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Finally, deal with the various bitfield-extracting functions that
|
|
|
|
// are used in SPARC assembly. (Some of these make no sense in combination
|
|
|
|
// with some of the above; we'll trust that the instruction selector
|
|
|
|
// will not produce nonsense, and not check for valid combinations here.)
|
2004-02-25 18:44:15 +00:00
|
|
|
if (MO.isLoBits32()) { // %lo(val) == %lo() in SparcV9 ABI doc
|
2003-06-02 02:13:26 +00:00
|
|
|
return rv & 0x03ff;
|
2004-02-25 18:44:15 +00:00
|
|
|
} else if (MO.isHiBits32()) { // %lm(val) == %hi() in SparcV9 ABI doc
|
2003-06-02 02:13:26 +00:00
|
|
|
return (rv >> 10) & 0x03fffff;
|
2004-02-25 18:44:15 +00:00
|
|
|
} else if (MO.isLoBits64()) { // %hm(val) == %ulo() in SparcV9 ABI doc
|
2003-06-02 02:13:26 +00:00
|
|
|
return (rv >> 32) & 0x03ff;
|
2004-02-25 18:44:15 +00:00
|
|
|
} else if (MO.isHiBits64()) { // %hh(val) == %uhi() in SparcV9 ABI doc
|
2003-06-02 02:13:26 +00:00
|
|
|
return rv >> 42;
|
|
|
|
} else { // (unadorned) val
|
|
|
|
return rv;
|
2003-05-27 20:07:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned SparcV9CodeEmitter::getValueBit(int64_t Val, unsigned bit) {
|
|
|
|
Val >>= bit;
|
|
|
|
return (Val & 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool SparcV9CodeEmitter::runOnMachineFunction(MachineFunction &MF) {
|
2003-06-04 20:01:13 +00:00
|
|
|
MCE.startFunction(MF);
|
2003-06-06 00:26:11 +00:00
|
|
|
DEBUG(std::cerr << "Starting function " << MF.getFunction()->getName()
|
2003-06-02 04:12:39 +00:00
|
|
|
<< ", address: " << "0x" << std::hex
|
2003-06-06 00:26:11 +00:00
|
|
|
<< (long)MCE.getCurrentPCValue() << "\n");
|
2003-06-02 04:12:39 +00:00
|
|
|
|
2003-11-07 18:06:26 +00:00
|
|
|
MCE.emitConstantPool(MF.getConstantPool());
|
2003-05-27 20:07:58 +00:00
|
|
|
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
|
|
|
|
emitBasicBlock(*I);
|
2003-06-04 20:01:13 +00:00
|
|
|
MCE.finishFunction(MF);
|
2003-06-02 04:12:39 +00:00
|
|
|
|
2003-07-03 18:36:47 +00:00
|
|
|
DEBUG(std::cerr << "Finishing fn " << MF.getFunction()->getName() << "\n");
|
2003-06-02 04:12:39 +00:00
|
|
|
|
|
|
|
// Resolve branches to BasicBlocks for the entire function
|
|
|
|
for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) {
|
|
|
|
long Location = BBLocations[BBRefs[i].first];
|
|
|
|
unsigned *Ref = BBRefs[i].second.first;
|
|
|
|
MachineInstr *MI = BBRefs[i].second.second;
|
2003-07-03 18:36:47 +00:00
|
|
|
DEBUG(std::cerr << "Fixup @ " << std::hex << Ref << " to 0x" << Location
|
|
|
|
<< " in instr: " << std::dec << *MI);
|
2003-06-02 04:12:39 +00:00
|
|
|
for (unsigned ii = 0, ee = MI->getNumOperands(); ii != ee; ++ii) {
|
|
|
|
MachineOperand &op = MI->getOperand(ii);
|
|
|
|
if (op.isPCRelativeDisp()) {
|
|
|
|
// the instruction's branch target is made such that it branches to
|
2003-07-03 18:36:47 +00:00
|
|
|
// PC + (branchTarget * 4), so undo that arithmetic here:
|
2003-06-02 04:12:39 +00:00
|
|
|
// Location is the target of the branch
|
|
|
|
// Ref is the location of the instruction, and hence the PC
|
2003-07-03 18:36:47 +00:00
|
|
|
int64_t branchTarget = (Location - (long)Ref) >> 2;
|
2003-06-02 04:12:39 +00:00
|
|
|
// Save the flags.
|
|
|
|
bool loBits32=false, hiBits32=false, loBits64=false, hiBits64=false;
|
2003-12-14 13:24:17 +00:00
|
|
|
if (op.isLoBits32()) { loBits32=true; }
|
|
|
|
if (op.isHiBits32()) { hiBits32=true; }
|
|
|
|
if (op.isLoBits64()) { loBits64=true; }
|
|
|
|
if (op.isHiBits64()) { hiBits64=true; }
|
2003-06-02 04:12:39 +00:00
|
|
|
MI->SetMachineOperandConst(ii, MachineOperand::MO_SignExtendedImmed,
|
|
|
|
branchTarget);
|
2004-07-19 07:52:35 +00:00
|
|
|
if (loBits32) { MI->getOperand(ii).markLo32(); }
|
|
|
|
else if (hiBits32) { MI->getOperand(ii).markHi32(); }
|
|
|
|
else if (loBits64) { MI->getOperand(ii).markLo64(); }
|
|
|
|
else if (hiBits64) { MI->getOperand(ii).markHi64(); }
|
2003-06-06 00:26:11 +00:00
|
|
|
DEBUG(std::cerr << "Rewrote BB ref: ");
|
2003-06-02 04:12:39 +00:00
|
|
|
unsigned fixedInstr = SparcV9CodeEmitter::getBinaryCodeForInstr(*MI);
|
2004-04-23 17:11:15 +00:00
|
|
|
MCE.emitWordAt (fixedInstr, Ref);
|
2003-06-02 04:12:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
BBRefs.clear();
|
|
|
|
BBLocations.clear();
|
|
|
|
|
2003-05-27 20:07:58 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void SparcV9CodeEmitter::emitBasicBlock(MachineBasicBlock &MBB) {
|
2003-05-27 22:41:44 +00:00
|
|
|
currBB = MBB.getBasicBlock();
|
2003-06-04 20:01:13 +00:00
|
|
|
BBLocations[currBB] = MCE.getCurrentPCValue();
|
2004-11-22 20:25:10 +00:00
|
|
|
for (MachineBasicBlock::iterator I = MBB.begin(), E = MBB.end(); I != E; ++I)
|
2004-11-22 21:25:10 +00:00
|
|
|
if (I->getOpcode() != V9::RDCCR) {
|
|
|
|
emitWord(getBinaryCodeForInstr(*I));
|
|
|
|
} else {
|
|
|
|
// FIXME: The tblgen produced code emitter cannot deal with the fact that
|
|
|
|
// machine operand #0 of the RDCCR instruction should be ignored. This is
|
|
|
|
// really a bug in the representation of the RDCCR instruction (which has
|
|
|
|
// no need to explicitly represent the CCR dest), but we hack around it
|
|
|
|
// here.
|
|
|
|
unsigned RegNo = getMachineOpValue(*I, I->getOperand(1));
|
|
|
|
RegNo &= (1<<5)-1;
|
|
|
|
emitWord((RegNo << 25) | 2168487936U);
|
|
|
|
}
|
2003-05-27 20:07:58 +00:00
|
|
|
}
|
|
|
|
|
2003-11-13 00:23:05 +00:00
|
|
|
#include "SparcV9CodeEmitter.inc"
|
2003-11-11 22:41:34 +00:00
|
|
|
|