SparcV8AsmPrinter(std::ostream &O, TargetMachine &TM) : AsmPrinter(O, TM) {
Data16bitsDirective = "\t.half\t";
Data32bitsDirective = "\t.word\t";
- Data64bitsDirective = "\t.xword\t";
+ Data64bitsDirective = 0; // .xword is only supported by V9.
ZeroDirective = 0; // no .zero or .space!
+ CommentString = "!";
+ ConstantPoolSection = "\t.section \".rodata\",#alloc\n";
}
/// We name each basic block in a Function with a unique number, so
}
void printOperand(const MachineInstr *MI, int opNum);
+ void printMemOperand(const MachineInstr *MI, int opNum);
bool printInstruction(const MachineInstr *MI); // autogenerated.
bool runOnMachineFunction(MachineFunction &F);
bool doInitialization(Module &M);
for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
I != E; ++I) {
// Print a label for the basic block.
- O << ".LBB" << Mang->getValueName(MF.getFunction ())
- << "_" << I->getNumber () << ":\t! "
- << I->getBasicBlock ()->getName () << "\n";
+ if (I != MF.begin())
+ O << ".LBB" << Mang->getValueName(MF.getFunction ())
+ << "_" << I->getNumber () << ":\t! "
+ << I->getBasicBlock ()->getName () << "\n";
for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
II != E; ++II) {
// Print the assembly for the instruction.
if (MI->getOpcode() == V8::SETHIi && !MO.isRegister() && !MO.isImmediate()) {
O << "%hi(";
CloseParen = true;
- } else if (MI->getOpcode() ==V8::ORri &&!MO.isRegister() &&!MO.isImmediate())
- {
+ } else if ((MI->getOpcode() == V8::ORri || MI->getOpcode() == V8::ADDri)
+ && !MO.isRegister() && !MO.isImmediate()) {
O << "%lo(";
CloseParen = true;
}
if (CloseParen) O << ")";
}
+void SparcV8AsmPrinter::printMemOperand(const MachineInstr *MI, int opNum) {
+ printOperand(MI, opNum);
+ MachineOperand::MachineOperandType OpTy = MI->getOperand(opNum+1).getType();
+
+ if ((OpTy == MachineOperand::MO_VirtualRegister ||
+ OpTy == MachineOperand::MO_MachineRegister) &&
+ MI->getOperand(opNum+1).getReg() == V8::G0)
+ return; // don't print "+%g0"
+ if ((OpTy == MachineOperand::MO_SignExtendedImmed ||
+ OpTy == MachineOperand::MO_UnextendedImmed) &&
+ MI->getOperand(opNum+1).getImmedValue() == 0)
+ return; // don't print "+0"
+
+ O << "+";
+ if (OpTy == MachineOperand::MO_GlobalAddress ||
+ OpTy == MachineOperand::MO_ConstantPoolIndex) {
+ O << "%lo(";
+ printOperand(MI, opNum+1);
+ O << ")";
+ } else {
+ printOperand(MI, opNum+1);
+ }
+}
+
+
bool SparcV8AsmPrinter::doInitialization(Module &M) {
Mang = new Mangler(M);
return false; // success