diff options
| author | Misha Brukman <brukman+llvm@gmail.com> | 2003-06-02 05:24:46 +0000 | 
|---|---|---|
| committer | Misha Brukman <brukman+llvm@gmail.com> | 2003-06-02 05:24:46 +0000 | 
| commit | 55c63316376848d5e3747b0c468f5c901d84fea4 (patch) | |
| tree | 6fc4dc2dcf78e6eda473ba3cb7529b2d4a4e247e /llvm/lib/Target/Sparc | |
| parent | 7b66a726f8856b905852f2aef532a8ca9719f644 (diff) | |
| download | bcm5719-llvm-55c63316376848d5e3747b0c468f5c901d84fea4.tar.gz bcm5719-llvm-55c63316376848d5e3747b0c468f5c901d84fea4.zip | |
Clean up after merging in SparcEmitter.cpp; branches and return work again.
llvm-svn: 6536
Diffstat (limited to 'llvm/lib/Target/Sparc')
| -rw-r--r-- | llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp | 51 | 
1 files changed, 40 insertions, 11 deletions
| diff --git a/llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp b/llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp index 6385a278275..6db466f3b33 100644 --- a/llvm/lib/Target/Sparc/SparcV9CodeEmitter.cpp +++ b/llvm/lib/Target/Sparc/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()) { | 

