mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-19 19:29:31 +00:00
Fix siod by switching BoolTy to byte rather than int until CFE changes for
Darwin. Also, change asm printer to output proper stubs for external functions whose address is passed as an argument to aid in bugpointing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15721 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
293d88ca8b
commit
b73a711ed7
@ -74,7 +74,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printMachineInstruction(const MachineInstr *MI);
|
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 printImmOp(const MachineOperand &MO, unsigned ArgType);
|
||||||
void printConstantPool(MachineConstantPool *MCP);
|
void printConstantPool(MachineConstantPool *MCP);
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
@ -401,7 +401,7 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Printer::printOp(const MachineOperand &MO,
|
void Printer::printOp(const MachineOperand &MO,
|
||||||
bool elideOffsetKeyword /* = false */) {
|
bool LoadAddrOp /* = false */) {
|
||||||
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
||||||
int new_symbol;
|
int new_symbol;
|
||||||
|
|
||||||
@ -444,31 +444,32 @@ void Printer::printOp(const MachineOperand &MO,
|
|||||||
O << MO.getSymbolName();
|
O << MO.getSymbolName();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
if (!elideOffsetKeyword) {
|
GlobalValue *GV = MO.getGlobal();
|
||||||
GlobalValue *GV = MO.getGlobal();
|
std::string Name = Mang->getValueName(GV);
|
||||||
std::string Name = Mang->getValueName(GV);
|
|
||||||
|
|
||||||
// Dynamically-resolved functions need a stub for the function
|
// Dynamically-resolved functions need a stub for the function. Be
|
||||||
Function *F = dyn_cast<Function>(GV);
|
// wary however not to output $stub for external functions whose addresses
|
||||||
if (F && F->isExternal() &&
|
// are taken. Those should be emitted as $non_lazy_ptr below.
|
||||||
TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
|
Function *F = dyn_cast<Function>(GV);
|
||||||
FnStubs.insert(Name);
|
if (F && F->isExternal() && !LoadAddrOp &&
|
||||||
O << "L" << Name << "$stub";
|
TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
|
||||||
return;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
O << "<unknown operand type: " << MO.getType() << ">";
|
O << "<unknown operand type: " << MO.getType() << ">";
|
||||||
@ -548,7 +549,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
if (Opcode == PPC::LOADLoDirect || Opcode == PPC::LOADLoIndirect) {
|
if (Opcode == PPC::LOADLoDirect || Opcode == PPC::LOADLoIndirect) {
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", lo16(";
|
O << ", lo16(";
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2), true /* LoadAddrOp */);
|
||||||
O << "-\"L0000" << LabelNumber << "$pb\")";
|
O << "-\"L0000" << LabelNumber << "$pb\")";
|
||||||
O << "(";
|
O << "(";
|
||||||
if (MI->getOperand(1).getReg() == PPC::R0)
|
if (MI->getOperand(1).getReg() == PPC::R0)
|
||||||
@ -564,7 +565,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
else
|
else
|
||||||
printOp(MI->getOperand(1));
|
printOp(MI->getOperand(1));
|
||||||
O << ", ha16(" ;
|
O << ", ha16(" ;
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2), true /* LoadAddrOp */);
|
||||||
O << "-\"L0000" << LabelNumber << "$pb\")\n";
|
O << "-\"L0000" << LabelNumber << "$pb\")\n";
|
||||||
} else if (ArgCount == 3 && ArgType[1] == PPCII::Disimm16) {
|
} else if (ArgCount == 3 && ArgType[1] == PPCII::Disimm16) {
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
|
@ -68,7 +68,7 @@ static inline TypeClass getClass(const Type *Ty) {
|
|||||||
|
|
||||||
// getClassB - Just like getClass, but treat boolean values as ints.
|
// getClassB - Just like getClass, but treat boolean values as ints.
|
||||||
static inline TypeClass getClassB(const Type *Ty) {
|
static inline TypeClass getClassB(const Type *Ty) {
|
||||||
if (Ty == Type::BoolTy) return cInt;
|
if (Ty == Type::BoolTy) return cByte;
|
||||||
return getClass(Ty);
|
return getClass(Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ namespace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void printMachineInstruction(const MachineInstr *MI);
|
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 printImmOp(const MachineOperand &MO, unsigned ArgType);
|
||||||
void printConstantPool(MachineConstantPool *MCP);
|
void printConstantPool(MachineConstantPool *MCP);
|
||||||
bool runOnMachineFunction(MachineFunction &F);
|
bool runOnMachineFunction(MachineFunction &F);
|
||||||
@ -401,7 +401,7 @@ bool Printer::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Printer::printOp(const MachineOperand &MO,
|
void Printer::printOp(const MachineOperand &MO,
|
||||||
bool elideOffsetKeyword /* = false */) {
|
bool LoadAddrOp /* = false */) {
|
||||||
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
const MRegisterInfo &RI = *TM.getRegisterInfo();
|
||||||
int new_symbol;
|
int new_symbol;
|
||||||
|
|
||||||
@ -444,31 +444,32 @@ void Printer::printOp(const MachineOperand &MO,
|
|||||||
O << MO.getSymbolName();
|
O << MO.getSymbolName();
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
if (!elideOffsetKeyword) {
|
GlobalValue *GV = MO.getGlobal();
|
||||||
GlobalValue *GV = MO.getGlobal();
|
std::string Name = Mang->getValueName(GV);
|
||||||
std::string Name = Mang->getValueName(GV);
|
|
||||||
|
|
||||||
// Dynamically-resolved functions need a stub for the function
|
// Dynamically-resolved functions need a stub for the function. Be
|
||||||
Function *F = dyn_cast<Function>(GV);
|
// wary however not to output $stub for external functions whose addresses
|
||||||
if (F && F->isExternal() &&
|
// are taken. Those should be emitted as $non_lazy_ptr below.
|
||||||
TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
|
Function *F = dyn_cast<Function>(GV);
|
||||||
FnStubs.insert(Name);
|
if (F && F->isExternal() && !LoadAddrOp &&
|
||||||
O << "L" << Name << "$stub";
|
TM.CalledFunctions.find(F) != TM.CalledFunctions.end()) {
|
||||||
return;
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
O << "<unknown operand type: " << MO.getType() << ">";
|
O << "<unknown operand type: " << MO.getType() << ">";
|
||||||
@ -548,7 +549,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
if (Opcode == PPC::LOADLoDirect || Opcode == PPC::LOADLoIndirect) {
|
if (Opcode == PPC::LOADLoDirect || Opcode == PPC::LOADLoIndirect) {
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
O << ", lo16(";
|
O << ", lo16(";
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2), true /* LoadAddrOp */);
|
||||||
O << "-\"L0000" << LabelNumber << "$pb\")";
|
O << "-\"L0000" << LabelNumber << "$pb\")";
|
||||||
O << "(";
|
O << "(";
|
||||||
if (MI->getOperand(1).getReg() == PPC::R0)
|
if (MI->getOperand(1).getReg() == PPC::R0)
|
||||||
@ -564,7 +565,7 @@ void Printer::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
else
|
else
|
||||||
printOp(MI->getOperand(1));
|
printOp(MI->getOperand(1));
|
||||||
O << ", ha16(" ;
|
O << ", ha16(" ;
|
||||||
printOp(MI->getOperand(2));
|
printOp(MI->getOperand(2), true /* LoadAddrOp */);
|
||||||
O << "-\"L0000" << LabelNumber << "$pb\")\n";
|
O << "-\"L0000" << LabelNumber << "$pb\")\n";
|
||||||
} else if (ArgCount == 3 && ArgType[1] == PPCII::Disimm16) {
|
} else if (ArgCount == 3 && ArgType[1] == PPCII::Disimm16) {
|
||||||
printOp(MI->getOperand(0));
|
printOp(MI->getOperand(0));
|
||||||
|
Loading…
Reference in New Issue
Block a user