diff options
author | Misha Brukman <brukman+llvm@gmail.com> | 2003-11-07 18:06:26 +0000 |
---|---|---|
committer | Misha Brukman <brukman+llvm@gmail.com> | 2003-11-07 18:06:26 +0000 |
commit | e5ad8155d3265860a0cab8cb08dfc4a20a926088 (patch) | |
tree | 9ae178601c63ec68c522b3c74d68e4a1465ebb6e /lib | |
parent | f905ed52049e6fecc9659e41b60a4db818418b9b (diff) | |
download | external_llvm-e5ad8155d3265860a0cab8cb08dfc4a20a926088.zip external_llvm-e5ad8155d3265860a0cab8cb08dfc4a20a926088.tar.gz external_llvm-e5ad8155d3265860a0cab8cb08dfc4a20a926088.tar.bz2 |
Switch to emitting MachineConstantPool the way it was meant to be done.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9777 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Target/SparcV9/SparcV9CodeEmitter.cpp | 53 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9CodeEmitter.h | 4 |
2 files changed, 8 insertions, 49 deletions
diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp index 15bb1bc..a674d8a 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.cpp +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.cpp @@ -593,13 +593,8 @@ int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI, unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue(); BBRefs.push_back(std::make_pair(BB, std::make_pair(CurrPC, &MI))); } else if (const Constant *C = dyn_cast<Constant>(V)) { - if (ConstantMap.find(C) != ConstantMap.end()) { - rv = (int64_t)MCE.getConstantPoolEntryAddress(ConstantMap[C]); - DEBUG(std::cerr << "const: 0x" << std::hex << rv << "\n"); - } else { - std::cerr << "ERROR: constant not in map:" << MO << "\n"; - abort(); - } + std::cerr << "ERROR: constants should not appear in PcRel:" << MO << "\n"; + abort(); } else if (GlobalValue *GV = dyn_cast<GlobalValue>(V)) { // same as MO.isGlobalAddress() DEBUG(std::cerr << "GlobalValue: "); @@ -623,17 +618,6 @@ int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI, } } else { rv = (int64_t)MCE.getGlobalValueAddress(GV); - if (rv == 0) { - if (Constant *C = ConstantPointerRef::get(GV)) { - if (ConstantMap.find(C) != ConstantMap.end()) { - rv = MCE.getConstantPoolEntryAddress(ConstantMap[C]); - } else { - std::cerr << "Constant: 0x" << std::hex << (intptr_t)C - << ", " << *V << " not found in ConstantMap!\n"; - abort(); - } - } - } DEBUG(std::cerr << "Global addr: 0x" << std::hex << rv << "\n"); } // The real target of the call is Addr = PC + (rv * 4) @@ -698,9 +682,8 @@ int64_t SparcV9CodeEmitter::getMachineOpValue(MachineInstr &MI, 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"; - abort(); + unsigned Index = MO.getConstantPoolIndex(); + rv = MCE.getConstantPoolEntryAddress(Index); } else { std::cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n"; abort(); @@ -734,27 +717,12 @@ bool SparcV9CodeEmitter::runOnMachineFunction(MachineFunction &MF) { << ", address: " << "0x" << std::hex << (long)MCE.getCurrentPCValue() << "\n"); - // The Sparc backend does not use MachineConstantPool; - // instead, it has its own constant pool implementation. - // We create a new MachineConstantPool here to be compatible with the emitter. - MachineConstantPool MCP; - const hash_set<const Constant*> &pool = MF.getInfo()->getConstantPoolValues(); - for (hash_set<const Constant*>::const_iterator I = pool.begin(), - E = pool.end(); I != E; ++I) - { - Constant *C = (Constant*)*I; - unsigned idx = MCP.getConstantPoolIndex(C); - DEBUG(std::cerr << "Constant[" << idx << "] = 0x" << (intptr_t)C << "\n"); - ConstantMap[C] = idx; - } - MCE.emitConstantPool(&MCP); - + MCE.emitConstantPool(MF.getConstantPool()); for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) emitBasicBlock(*I); MCE.finishFunction(MF); DEBUG(std::cerr << "Finishing fn " << MF.getFunction()->getName() << "\n"); - ConstantMap.clear(); // Resolve branches to BasicBlocks for the entire function for (unsigned i = 0, e = BBRefs.size(); i != e; ++i) { @@ -831,14 +799,9 @@ void* SparcV9CodeEmitter::getGlobalAddress(GlobalValue *V, MachineInstr &MI, (void*)(intptr_t)TheJITResolver->getLazyResolver(cast<Function>(V)); } else if (Constant *C = ConstantPointerRef::get(V)) { - if (ConstantMap.find(C) != ConstantMap.end()) { - return (void*) - (intptr_t)MCE.getConstantPoolEntryAddress(ConstantMap[C]); - } else { - std::cerr << "Constant: 0x" << std::hex << &*C << std::dec - << ", " << *V << " not found in ConstantMap!\n"; - abort(); - } + // no longer applicable + std::cerr << "Unhandled Constant: " << *C << "\n"; + abort(); } else { std::cerr << "Unhandled global: " << *V << "\n"; abort(); diff --git a/lib/Target/SparcV9/SparcV9CodeEmitter.h b/lib/Target/SparcV9/SparcV9CodeEmitter.h index 48bb673..7e19c44 100644 --- a/lib/Target/SparcV9/SparcV9CodeEmitter.h +++ b/lib/Target/SparcV9/SparcV9CodeEmitter.h @@ -34,10 +34,6 @@ class SparcV9CodeEmitter : public MachineFunctionPass { // Tracks where each BasicBlock starts std::map<const BasicBlock*, long> BBLocations; - // Tracks locations of Constants which are laid out in memory (e.g. FP) - // But we also need to map Constants to ConstantPool indices - std::map<const Constant*, unsigned> ConstantMap; - public: SparcV9CodeEmitter(TargetMachine &T, MachineCodeEmitter &M); ~SparcV9CodeEmitter(); |