aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Target/SparcV9
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-06-02 05:24:46 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-06-02 05:24:46 +0000
commiteaaf8ad3cce94d2fb5a65b73e80c20e69f71d9d8 (patch)
tree6a610d99fc686def60429330bf798281449d3cb2 /lib/Target/SparcV9
parent4954f049147c88a1a6bb294fa7e6accee3006e68 (diff)
downloadexternal_llvm-eaaf8ad3cce94d2fb5a65b73e80c20e69f71d9d8.zip
external_llvm-eaaf8ad3cce94d2fb5a65b73e80c20e69f71d9d8.tar.gz
external_llvm-eaaf8ad3cce94d2fb5a65b73e80c20e69f71d9d8.tar.bz2
Clean up after merging in SparcEmitter.cpp; branches and return work again.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6536 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/SparcV9')
-rw-r--r--lib/Target/SparcV9/SparcV9CodeEmitter.cpp51
1 files changed, 40 insertions, 11 deletions
diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
index 6385a27..6db466f 100644
--- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
+++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp
@@ -184,7 +184,27 @@ int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI,
int64_t rv = 0; // Return value; defaults to 0 for unhandled cases
// or things that get fixed up later by the JIT.
- if (MO.isPhysicalRegister()) {
+ if (MO.isVirtualRegister()) {
+ std::cerr << "ERROR: virtual register found in machine code.\n";
+ abort();
+ } else if (MO.isPCRelativeDisp()) {
+ Value *V = MO.getVRegValue();
+ if (BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
+ std::cerr << "Saving reference to BB (VReg)\n";
+ unsigned* CurrPC = (unsigned*)(intptr_t)MCE->getCurrentPCValue();
+ BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
+ } else if (Constant *C = dyn_cast<Constant>(V)) {
+ if (ConstantMap.find(C) != ConstantMap.end())
+ rv = (int64_t)(intptr_t)ConstantMap[C];
+ else {
+ std::cerr << "ERROR: constant not in map:" << MO << "\n";
+ abort();
+ }
+ } else {
+ std::cerr << "ERROR: PC relative disp unhandled:" << MO << "\n";
+ abort();
+ }
+ } else if (MO.isPhysicalRegister()) {
// This is necessary because the Sparc doesn't actually lay out registers
// in the real fashion -- it skips those that it chooses not to allocate,
// i.e. those that are the SP, etc.
@@ -198,25 +218,33 @@ int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI,
rv = realReg;
} else if (MO.isImmediate()) {
rv = MO.getImmedValue();
- } else if (MO.isPCRelativeDisp()) { // this is not always a call!! (fp const)
- std::cerr << "Saving reference to func (call - PCRelDisp)\n";
+ } else if (MO.isGlobalAddress()) {
rv = (int64_t)
(intptr_t)getGlobalAddress(cast<GlobalValue>(MO.getVRegValue()),
- MI,true);
+ MI, MO.isPCRelative());
} else if (MO.isMachineBasicBlock()) {
+ // Duplicate code of the above case for VirtualRegister, BasicBlock...
+ // It should really hit this case, but Sparc backend uses VRegs instead
std::cerr << "Saving reference to MBB\n";
- BBRefs.push_back(std::make_pair(MO.getMachineBasicBlock()->getBasicBlock(),
- std::make_pair((unsigned*)(intptr_t)MCE->getCurrentPCValue(),&MI)));
+ BasicBlock *BB = MO.getMachineBasicBlock()->getBasicBlock();
+ unsigned* CurrPC = (unsigned*)(intptr_t)MCE->getCurrentPCValue();
+ BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI)));
+ } else if (MO.isExternalSymbol()) {
+ // Sparc backend doesn't generate this (yet...)
+ std::cerr << "ERROR: External symbol unhandled: " << MO << "\n";
+ abort();
} else if (MO.isFrameIndex()) {
+ // Sparc backend doesn't generate this (yet...)
+ int FrameIndex = MO.getFrameIndex();
std::cerr << "ERROR: Frame index unhandled.\n";
+ abort();
} else if (MO.isConstantPoolIndex()) {
+ // Sparc backend doesn't generate this (yet...)
std::cerr << "ERROR: Constant Pool index unhandled.\n";
- } else if (MO.isGlobalAddress()) {
- std::cerr << "ERROR: Global addr unhandled.\n";
- } else if (MO.isExternalSymbol()) {
- std::cerr << "ERROR: External symbol unhandled.\n";
+ abort();
} else {
std::cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
+ abort();
}
// Finally, deal with the various bitfield-extracting functions that
@@ -357,7 +385,8 @@ void* SparcV9CodeEmitter::getGlobalAddress(GlobalValue *V, MachineInstr &MI,
TheJITResolver->addFunctionReference(MCE->getCurrentPCValue(),
cast<Function>(V));
// Delayed resolution...
- return (void*)TheJITResolver->getLazyResolver(cast<Function>(V));
+ return
+ (void*)(intptr_t)TheJITResolver->getLazyResolver(cast<Function>(V));
} else if (Constant *C = ConstantPointerRef::get(V)) {
if (ConstantMap.find(C) != ConstantMap.end()) {