}
void printMachineInstruction(const MachineInstr *MI);
- void printOp(const MachineOperand &MO, bool elideOffsetKeyword = false);
+ void printOp(const MachineOperand &MO, bool LoadAddrOp = false);
void printImmOp(const MachineOperand &MO, unsigned ArgType);
void printConstantPool(MachineConstantPool *MCP);
bool runOnMachineFunction(MachineFunction &F);
}
void Printer::printOp(const MachineOperand &MO,
- bool elideOffsetKeyword /* = false */) {
+ bool LoadAddrOp /* = false */) {
const MRegisterInfo &RI = *TM.getRegisterInfo();
int new_symbol;
O << MO.getSymbolName();
return;
- case MachineOperand::MO_GlobalAddress:
- if (!elideOffsetKeyword) {
- GlobalValue *GV = MO.getGlobal();
- std::string Name = Mang->getValueName(GV);
-
- // Dynamically-resolved functions need a stub for the function
- Function *F = dyn_cast<Function>(GV);
- if (F && F->isExternal() &&
- TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
- FnStubs.insert(Name);
- O << "L" << Name << "$stub";
- return;
- }
-
- // External global variables need a non-lazily-resolved stub
- if (!GV->hasInternalLinkage() &&
- TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
- GVStubs.insert(Name);
- O << "L" << Name << "$non_lazy_ptr";
- return;
- }
+ case MachineOperand::MO_GlobalAddress: {
+ GlobalValue *GV = MO.getGlobal();
+ std::string Name = Mang->getValueName(GV);
+
+ // Dynamically-resolved functions need a stub for the function. Be
+ // wary however not to output $stub for external functions whose addresses
+ // are taken. Those should be emitted as $non_lazy_ptr below.
+ Function *F = dyn_cast<Function>(GV);
+ if (F && F->isExternal() && !LoadAddrOp &&
+ TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
+ FnStubs.insert(Name);
+ O << "L" << Name << "$stub";
+ return;
+ }
- O << Mang->getValueName(GV);
+ // External global variables need a non-lazily-resolved stub
+ if (!GV->hasInternalLinkage() &&
+ TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
+ GVStubs.insert(Name);
+ O << "L" << Name << "$non_lazy_ptr";
+ return;
}
+
+ O << Mang->getValueName(GV);
return;
+ }
default:
O << "<unknown operand type: " << MO.getType() << ">";
if (Opcode == PPC::LOADLoDirect || Opcode == PPC::LOADLoIndirect) {
printOp(MI->getOperand(0));
O << ", lo16(";
- printOp(MI->getOperand(2));
+ printOp(MI->getOperand(2), true /* LoadAddrOp */);
O << "-\"L0000" << LabelNumber << "$pb\")";
O << "(";
if (MI->getOperand(1).getReg() == PPC::R0)
else
printOp(MI->getOperand(1));
O << ", ha16(" ;
- printOp(MI->getOperand(2));
+ printOp(MI->getOperand(2), true /* LoadAddrOp */);
O << "-\"L0000" << LabelNumber << "$pb\")\n";
} else if (ArgCount == 3 && ArgType[1] == PPCII::Disimm16) {
printOp(MI->getOperand(0));
// getClassB - Just like getClass, but treat boolean values as ints.
static inline TypeClass getClassB(const Type *Ty) {
- if (Ty == Type::BoolTy) return cInt;
+ if (Ty == Type::BoolTy) return cByte;
return getClass(Ty);
}
}
void printMachineInstruction(const MachineInstr *MI);
- void printOp(const MachineOperand &MO, bool elideOffsetKeyword = false);
+ void printOp(const MachineOperand &MO, bool LoadAddrOp = false);
void printImmOp(const MachineOperand &MO, unsigned ArgType);
void printConstantPool(MachineConstantPool *MCP);
bool runOnMachineFunction(MachineFunction &F);
}
void Printer::printOp(const MachineOperand &MO,
- bool elideOffsetKeyword /* = false */) {
+ bool LoadAddrOp /* = false */) {
const MRegisterInfo &RI = *TM.getRegisterInfo();
int new_symbol;
O << MO.getSymbolName();
return;
- case MachineOperand::MO_GlobalAddress:
- if (!elideOffsetKeyword) {
- GlobalValue *GV = MO.getGlobal();
- std::string Name = Mang->getValueName(GV);
-
- // Dynamically-resolved functions need a stub for the function
- Function *F = dyn_cast<Function>(GV);
- if (F && F->isExternal() &&
- TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
- FnStubs.insert(Name);
- O << "L" << Name << "$stub";
- return;
- }
-
- // External global variables need a non-lazily-resolved stub
- if (!GV->hasInternalLinkage() &&
- TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
- GVStubs.insert(Name);
- O << "L" << Name << "$non_lazy_ptr";
- return;
- }
+ case MachineOperand::MO_GlobalAddress: {
+ GlobalValue *GV = MO.getGlobal();
+ std::string Name = Mang->getValueName(GV);
+
+ // Dynamically-resolved functions need a stub for the function. Be
+ // wary however not to output $stub for external functions whose addresses
+ // are taken. Those should be emitted as $non_lazy_ptr below.
+ Function *F = dyn_cast<Function>(GV);
+ if (F && F->isExternal() && !LoadAddrOp &&
+ TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
+ FnStubs.insert(Name);
+ O << "L" << Name << "$stub";
+ return;
+ }
- O << Mang->getValueName(GV);
+ // External global variables need a non-lazily-resolved stub
+ if (!GV->hasInternalLinkage() &&
+ TM.AddressTaken.find(GV) != TM.AddressTaken.end()) {
+ GVStubs.insert(Name);
+ O << "L" << Name << "$non_lazy_ptr";
+ return;
}
+
+ O << Mang->getValueName(GV);
return;
+ }
default:
O << "<unknown operand type: " << MO.getType() << ">";
if (Opcode == PPC::LOADLoDirect || Opcode == PPC::LOADLoIndirect) {
printOp(MI->getOperand(0));
O << ", lo16(";
- printOp(MI->getOperand(2));
+ printOp(MI->getOperand(2), true /* LoadAddrOp */);
O << "-\"L0000" << LabelNumber << "$pb\")";
O << "(";
if (MI->getOperand(1).getReg() == PPC::R0)
else
printOp(MI->getOperand(1));
O << ", ha16(" ;
- printOp(MI->getOperand(2));
+ printOp(MI->getOperand(2), true /* LoadAddrOp */);
O << "-\"L0000" << LabelNumber << "$pb\")\n";
} else if (ArgCount == 3 && ArgType[1] == PPCII::Disimm16) {
printOp(MI->getOperand(0));