- if (MO.isGlobalAddress())
- MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(),
- Reloc, MO.getGlobal(), 0));
- else
- MCE.addRelocation(MachineRelocation(MCE.getCurrentPCOffset(),
- Reloc, MO.getSymbolName(), 0));
- } else if (MO.isMachineBasicBlock()) {
- unsigned* CurrPC = (unsigned*)(intptr_t)MCE.getCurrentPCValue();
- BBRefs.push_back(std::make_pair(MO.getMachineBasicBlock(), CurrPC));
- } else if (MO.isConstantPoolIndex()) {
- unsigned index = MO.getConstantPoolIndex();
- unsigned Opcode = MI.getOpcode();
- rv = MCE.getConstantPoolEntryAddress(index);
- if (Opcode == PPC::LIS || Opcode == PPC::ADDIS) {
- // lis wants hi16(addr)
- if ((short)rv < 0) rv += 1 << 16;
- rv >>= 16;
- } else if (Opcode == PPC::LWZ || Opcode == PPC::LA ||
- Opcode == PPC::LI ||
- Opcode == PPC::LFS || Opcode == PPC::LFD) {
- // These load opcodes want lo16(addr)
- rv &= 0xffff;
+
+ MachineRelocation R;
+ if (MO.isGlobal()) {
+ R = MachineRelocation::getGV(MCE.getCurrentPCOffset(), Reloc,
+ const_cast<GlobalValue *>(MO.getGlobal()), 0,
+ isa<Function>(MO.getGlobal()));
+ } else if (MO.isSymbol()) {
+ R = MachineRelocation::getExtSym(MCE.getCurrentPCOffset(),
+ Reloc, MO.getSymbolName(), 0);
+ } else if (MO.isCPI()) {
+ R = MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
+ Reloc, MO.getIndex(), 0);