#include "SparcInternals.h"
#include "llvm/CodeGen/MachineInstr.h"
-#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
-#include "llvm/CodeGen/MachineCodeForMethod.h"
+#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
//
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);
else
needBitsFlag = false;
- switch (mop.getOperandType())
+ switch (mop.getType())
{
case MachineOperand::MO_VirtualRegister:
case MachineOperand::MO_CCRegister:
{
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 MachineCodeForBasicBlock &MIs = MachineCodeForBasicBlock::get(BB);
- MachineCodeForBasicBlock::const_iterator MII = MIs.begin(), MIE = MIs.end();
+ toAsm << getID(MBB.getBasicBlock()) << ":\n";
// Loop over all of the instructions in the basic block...
- for (; MII != MIE; ++MII)
+ 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 "
if (C == '"') {
Result += "\\\"";
+ } else if (C == '\\') {
+ Result += "\\\\";
} else if (isprint(C)) {
Result += C;
} else {
for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
if (!I->isExternal()) {
const hash_set<const Constant*> &pool =
- MachineCodeForMethod::get(I).getConstantPoolValues();
+ MachineFunction::get(I).getConstantPoolValues();
MC.insert(pool.begin(), pool.end());
}
}