mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-21 03:53:04 +02:00
Emit .global @function and .global @object entries so the Intel ias
assembler may be used; identify LLVM output as such. llvm-svn: 20892
This commit is contained in:
parent
47fcba56f8
commit
7b5f67baf9
@ -36,7 +36,7 @@ namespace {
|
|||||||
|
|
||||||
struct IA64SharedAsmPrinter : public AsmPrinter {
|
struct IA64SharedAsmPrinter : public AsmPrinter {
|
||||||
|
|
||||||
std::set<std::string> ExternalFunctionNames;
|
std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
|
||||||
|
|
||||||
IA64SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
|
IA64SharedAsmPrinter(std::ostream &O, TargetMachine &TM)
|
||||||
: AsmPrinter(O, TM) { }
|
: AsmPrinter(O, TM) { }
|
||||||
@ -84,7 +84,8 @@ void IA64SharedAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
|
|||||||
|
|
||||||
if (CP.empty()) return;
|
if (CP.empty()) return;
|
||||||
|
|
||||||
O << "\n\t.section .data\n"; // would be nice to have this rodata? hmmm
|
O << "\n\t.section .data, \"aw\", \"progbits\"\n";
|
||||||
|
// FIXME: would be nice to have rodata (no 'w') when appropriate?
|
||||||
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
for (unsigned i = 0, e = CP.size(); i != e; ++i) {
|
||||||
emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
|
emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
|
||||||
O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString
|
O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString
|
||||||
@ -112,7 +113,7 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
|
I->hasWeakLinkage() /* FIXME: Verify correct */)) {
|
||||||
SwitchSection(O, CurSection, ".data");
|
SwitchSection(O, CurSection, ".data");
|
||||||
if (I->hasInternalLinkage())
|
if (I->hasInternalLinkage())
|
||||||
O << "\t.local " << name << "\n";
|
// FIXME O << "\t.local " << name << "\n";
|
||||||
|
|
||||||
O << "\t.common " << name << "," << TD.getTypeSize(C->getType())
|
O << "\t.common " << name << "," << TD.getTypeSize(C->getType())
|
||||||
<< "," << (1 << Align);
|
<< "," << (1 << Align);
|
||||||
@ -169,6 +170,14 @@ bool IA64SharedAsmPrinter::doFinalization(Module &M) {
|
|||||||
}
|
}
|
||||||
O << "\n\n";
|
O << "\n\n";
|
||||||
|
|
||||||
|
// we print out ".global X \n .type X, @object" for each external object
|
||||||
|
O << "\n\n// (external) symbols referenced (and not defined) above: \n";
|
||||||
|
for (std::set<std::string>::iterator i = ExternalObjectNames.begin(),
|
||||||
|
e = ExternalObjectNames.end(); i!=e; ++i) {
|
||||||
|
O << "\t.global " << *i << "\n\t.type " << *i << ", @object\n";
|
||||||
|
}
|
||||||
|
O << "\n\n";
|
||||||
|
|
||||||
AsmPrinter::doFinalization(M);
|
AsmPrinter::doFinalization(M);
|
||||||
return false; // success
|
return false; // success
|
||||||
}
|
}
|
||||||
@ -265,7 +274,7 @@ bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
|
|||||||
// Print out labels for the function.
|
// Print out labels for the function.
|
||||||
O << "\n\t.section .text, \"ax\", \"progbits\"\n";
|
O << "\n\t.section .text, \"ax\", \"progbits\"\n";
|
||||||
// ^^ means "Allocated instruXions in mem, initialized"
|
// ^^ means "Allocated instruXions in mem, initialized"
|
||||||
emitAlignment(4);
|
emitAlignment(5);
|
||||||
O << "\t.global\t" << CurrentFnName << "\n";
|
O << "\t.global\t" << CurrentFnName << "\n";
|
||||||
O << "\t.type\t" << CurrentFnName << ", @function\n";
|
O << "\t.type\t" << CurrentFnName << ", @function\n";
|
||||||
O << CurrentFnName << ":\n";
|
O << CurrentFnName << ":\n";
|
||||||
@ -343,9 +352,12 @@ void IA64AsmPrinter::printOp(const MachineOperand &MO,
|
|||||||
// the function somewhere (GNU gas has no problem without this, but
|
// the function somewhere (GNU gas has no problem without this, but
|
||||||
// Intel ias rightly complains of an 'undefined symbol')
|
// Intel ias rightly complains of an 'undefined symbol')
|
||||||
|
|
||||||
if(F && isBRCALLinsn && F->isExternal())
|
if(F /*&& isBRCALLinsn*/ && F->isExternal())
|
||||||
ExternalFunctionNames.insert(Mang->getValueName(MO.getGlobal()));
|
ExternalFunctionNames.insert(Mang->getValueName(MO.getGlobal()));
|
||||||
|
else
|
||||||
|
if(GV->isExternal()) // e.g. stuff like 'stdin'
|
||||||
|
ExternalObjectNames.insert(Mang->getValueName(MO.getGlobal()));
|
||||||
|
|
||||||
if (!isBRCALLinsn)
|
if (!isBRCALLinsn)
|
||||||
O << "@ltoff(";
|
O << "@ltoff(";
|
||||||
if (Needfptr)
|
if (Needfptr)
|
||||||
@ -364,6 +376,7 @@ void IA64AsmPrinter::printOp(const MachineOperand &MO,
|
|||||||
}
|
}
|
||||||
case MachineOperand::MO_ExternalSymbol:
|
case MachineOperand::MO_ExternalSymbol:
|
||||||
O << MO.getSymbolName();
|
O << MO.getSymbolName();
|
||||||
|
ExternalFunctionNames.insert(MO.getSymbolName());
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
O << "<AsmPrinter: unknown operand type: " << MO.getType() << " >"; return;
|
O << "<AsmPrinter: unknown operand type: " << MO.getType() << " >"; return;
|
||||||
@ -384,7 +397,8 @@ void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
|
|||||||
bool IA64AsmPrinter::doInitialization(Module &M) {
|
bool IA64AsmPrinter::doInitialization(Module &M) {
|
||||||
AsmPrinter::doInitialization(M);
|
AsmPrinter::doInitialization(M);
|
||||||
|
|
||||||
O << "\t.psr lsb\n" // should be "msb" on HP-UX, for starters
|
O << "\n.ident \"LLVM-ia64\"\n\n"
|
||||||
|
<< "\t.psr lsb\n" // should be "msb" on HP-UX, for starters
|
||||||
<< "\t.radix C\n"
|
<< "\t.radix C\n"
|
||||||
<< "\t.psr abi64\n"; // we only support 64 bits for now
|
<< "\t.psr abi64\n"; // we only support 64 bits for now
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user