//
string getID(const Value *V, const char *Prefix, const char *FPrefix = 0) {
string Result = FPrefix ? FPrefix : ""; // "Forced prefix"
-
+
Result += V->hasName() ? V->getName() : string(Prefix);
-
+
// Qualify all internal names with a unique id.
if (!isExternal(V)) {
int valId = idTable->Table.getValSlot(V);
valId = I->second;
}
Result = Result + "_" + itostr(valId);
+
+ // Replace or prefix problem characters in the name
+ Result = getValidSymbolName(Result);
}
-
- return getValidSymbolName(Result);
+
+ return Result;
}
// getID Wrappers - Ensure consistent usage...
void emitFunction(const Function &F);
private :
- void emitBasicBlock(const BasicBlock *BB);
+ void emitBasicBlock(const MachineBasicBlock &MBB);
void emitMachineInst(const MachineInstr *MI);
unsigned int printOperands(const MachineInstr *MI, unsigned int opNum);
{
unsigned Opcode = MI->getOpCode();
- if (TargetInstrDescriptors[Opcode].iclass & M_DUMMY_PHI_FLAG)
+ if (Target.getInstrInfo().isDummyPhiInstr(Opcode))
return; // IGNORE PHI NODES
- toAsm << "\t" << TargetInstrDescriptors[Opcode].opCodeString << "\t";
+ toAsm << "\t" << Target.getInstrInfo().getName(Opcode) << "\t";
unsigned Mask = getOperandMask(Opcode);
if (NeedComma) toAsm << ", "; // Handle comma outputing
NeedComma = true;
N = printOperands(MI, OpNum);
- }
- else
- N = 1;
+ } else
+ N = 1;
toAsm << "\n";
}
void
-SparcFunctionAsmPrinter::emitBasicBlock(const BasicBlock *BB)
+SparcFunctionAsmPrinter::emitBasicBlock(const MachineBasicBlock &MBB)
{
// Emit a label for the basic block
- toAsm << getID(BB) << ":\n";
-
- // Get the vector of machine instructions corresponding to this bb.
- const MachineBasicBlock &MIs = MachineBasicBlock::get(BB);
+ toAsm << getID(MBB.getBasicBlock()) << ":\n";
// Loop over all of the instructions in the basic block...
- for (MachineBasicBlock::const_iterator MII = MIs.begin(), MIE = MIs.end();
+ for (MachineBasicBlock::const_iterator MII = MBB.begin(), MIE = MBB.end();
MII != MIE; ++MII)
emitMachineInst(*MII);
toAsm << "\n"; // Seperate BB's with newlines
toAsm << methName << ":\n";
// Output code for all of the basic blocks in the function...
- for (Function::const_iterator I = F.begin(), E = F.end(); I != E; ++I)
- emitBasicBlock(I);
+ MachineFunction &MF = MachineFunction::get(&F);
+ for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I)
+ emitBasicBlock(*I);
// Output a .size directive so the debugger knows the extents of the function
toAsm << ".EndOf_" << methName << ":\n\t.size "