X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FAlpha%2FAlphaAsmPrinter.cpp;h=133f6c6039359f3fff485cc21b4f506f6439ebf0;hb=b8973bd8f50d7321635e1e07b81a880a0828d185;hp=5caa5d9f7726d8371f7fae7b19af60e656505694;hpb=98f0eee40692393ca4591b3a8988cc543bd691b5;p=oota-llvm.git diff --git a/lib/Target/Alpha/AlphaAsmPrinter.cpp b/lib/Target/Alpha/AlphaAsmPrinter.cpp index 5caa5d9f772..133f6c60393 100644 --- a/lib/Target/Alpha/AlphaAsmPrinter.cpp +++ b/lib/Target/Alpha/AlphaAsmPrinter.cpp @@ -14,26 +14,17 @@ #include "Alpha.h" #include "AlphaInstrInfo.h" +#include "AlphaTargetMachine.h" #include "llvm/Module.h" #include "llvm/Type.h" #include "llvm/Assembly/Writer.h" -#include "llvm/CodeGen/MachineConstantPool.h" -#include "llvm/CodeGen/ValueTypes.h" #include "llvm/CodeGen/AsmPrinter.h" - #include "llvm/Target/TargetMachine.h" - #include "llvm/Support/Mangler.h" #include "llvm/ADT/Statistic.h" -#include "llvm/Support/CommandLine.h" - +#include using namespace llvm; -namespace llvm { - extern cl::opt EnableAlphaFTOI; - extern cl::opt EnableAlphaCT; -} - namespace { Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed"); @@ -44,9 +35,9 @@ namespace { unsigned LabelNumber; AlphaAsmPrinter(std::ostream &o, TargetMachine &tm) - : AsmPrinter(o, tm), LabelNumber(0) - { + : AsmPrinter(o, tm), LabelNumber(0) { AlignmentIsInBytes = false; + PrivateGlobalPrefix = "$"; } /// We name each basic block in a Function with a unique number, so @@ -62,14 +53,12 @@ namespace { } bool printInstruction(const MachineInstr *MI); void printOp(const MachineOperand &MO, bool IsCallOp = false); - void printConstantPool(MachineConstantPool *MCP); - void printOperand(const MachineInstr *MI, int opNum, MVT::ValueType VT); + void printOperand(const MachineInstr *MI, int opNum); void printBaseOffsetPair (const MachineInstr *MI, int i, bool brackets=true); void printMachineInstruction(const MachineInstr *MI); bool runOnMachineFunction(MachineFunction &F); bool doInitialization(Module &M); bool doFinalization(Module &M); - void SwitchSection(std::ostream &OS, const char *NewSection); }; } // end of anonymous namespace @@ -85,7 +74,7 @@ FunctionPass *llvm::createAlphaCodePrinterPass (std::ostream &o, #include "AlphaGenAsmWriter.inc" -void AlphaAsmPrinter::printOperand(const MachineInstr *MI, int opNum, MVT::ValueType VT) +void AlphaAsmPrinter::printOperand(const MachineInstr *MI, int opNum) { const MachineOperand &MO = MI->getOperand(opNum); if (MO.getType() == MachineOperand::MO_MachineRegister) { @@ -128,14 +117,16 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) { case MachineOperand::MO_MachineBasicBlock: { MachineBasicBlock *MBBOp = MO.getMachineBasicBlock(); - O << "$LBB" << Mang->getValueName(MBBOp->getParent()->getFunction()) + O << PrivateGlobalPrefix << "LBB" + << Mang->getValueName(MBBOp->getParent()->getFunction()) << "_" << MBBOp->getNumber() << "\t" << CommentString << " " << MBBOp->getBasicBlock()->getName(); return; } case MachineOperand::MO_ConstantPoolIndex: - O << "$CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex(); + O << PrivateGlobalPrefix << "CPI" << getFunctionNumber() << "_" + << MO.getConstantPoolIndex(); return; case MachineOperand::MO_ExternalSymbol: @@ -145,9 +136,9 @@ void AlphaAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) { case MachineOperand::MO_GlobalAddress: //Abuse PCrel to specify pcrel calls //calls are the only thing that use this flag - if (MO.isPCRelative()) - O << "$" << Mang->getValueName(MO.getGlobal()) << "..ng"; - else +// if (MO.isPCRelative()) +// O << PrivateGlobalPrefix << Mang->getValueName(MO.getGlobal()) << "..ng"; +// else O << Mang->getValueName(MO.getGlobal()); return; @@ -175,15 +166,15 @@ void AlphaAsmPrinter::printMachineInstruction(const MachineInstr *MI) { /// method to print assembly for each instruction. /// bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) { - setupMachineFunction(MF); + SetupMachineFunction(MF); O << "\n\n"; // Print out constants referenced by the function - printConstantPool(MF.getConstantPool()); + EmitConstantPool(MF.getConstantPool()); // Print out labels for the function. - SwitchSection(O, "text"); - emitAlignment(4); + SwitchSection("\t.section .text", MF.getFunction()); + EmitAlignment(4); O << "\t.globl " << CurrentFnName << "\n"; O << "\t.ent " << CurrentFnName << "\n"; @@ -193,8 +184,8 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); I != E; ++I) { // Print a label for the basic block. - O << "$LBB" << CurrentFnName << "_" << I->getNumber() << ":\t" - << CommentString << " " << I->getBasicBlock()->getName() << "\n"; + O << PrivateGlobalPrefix << "LBB" << CurrentFnName << "_" << I->getNumber() + << ":\t" << CommentString << " " << I->getBasicBlock()->getName() << "\n"; for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); II != E; ++II) { // Print the assembly for the instruction. @@ -210,51 +201,18 @@ bool AlphaAsmPrinter::runOnMachineFunction(MachineFunction &MF) { return false; } - -/// printConstantPool - Print to the current output stream assembly -/// representations of the constants in the constant pool MCP. This is -/// used to print out constants which have been "spilled to memory" by -/// the code generator. -/// -void AlphaAsmPrinter::printConstantPool(MachineConstantPool *MCP) { - const std::vector &CP = MCP->getConstants(); - const TargetData &TD = TM.getTargetData(); - - if (CP.empty()) return; - - SwitchSection(O, "section .rodata"); - for (unsigned i = 0, e = CP.size(); i != e; ++i) { - // SwitchSection(O, "section .rodata, \"dr\""); - emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType())); - O << "$CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString - << *CP[i] << "\n"; - emitGlobalConstant(CP[i]); - } -} - bool AlphaAsmPrinter::doInitialization(Module &M) { AsmPrinter::doInitialization(M); - if(EnableAlphaFTOI || EnableAlphaCT) + if(TM.getSubtarget().hasF2I() + || TM.getSubtarget().hasCT()) O << "\t.arch ev6\n"; else O << "\t.arch ev56\n"; + O << "\t.set noat\n"; return false; } - -// SwitchSection - Switch to the specified section of the executable if we are -// not already in it! -// -void AlphaAsmPrinter::SwitchSection(std::ostream &OS, const char *NewSection) -{ - if (CurSection != NewSection) { - CurSection = NewSection; - if (!CurSection.empty()) - OS << "\t." << NewSection << "\n"; - } -} - bool AlphaAsmPrinter::doFinalization(Module &M) { const TargetData &TD = TM.getTargetData(); @@ -269,7 +227,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) { if (C->isNullValue() && (I->hasLinkOnceLinkage() || I->hasInternalLinkage() || I->hasWeakLinkage() /* FIXME: Verify correct */)) { - SwitchSection(O, "data"); + SwitchSection("\t.section .data", I); if (I->hasInternalLinkage()) O << "\t.local " << name << "\n"; @@ -284,8 +242,8 @@ bool AlphaAsmPrinter::doFinalization(Module &M) { case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak. // Nonnull linkonce -> weak O << "\t.weak " << name << "\n"; - SwitchSection(O, ""); O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n"; + SwitchSection("", I); break; case GlobalValue::AppendingLinkage: // FIXME: appending linkage variables should go into a section of @@ -295,17 +253,15 @@ bool AlphaAsmPrinter::doFinalization(Module &M) { O << "\t.globl " << name << "\n"; // FALL THROUGH case GlobalValue::InternalLinkage: - if (C->isNullValue()) - SwitchSection(O, "bss"); //was .bss - else - SwitchSection(O, "data"); + SwitchSection(C->isNullValue() ? "\t.section .bss" : + "\t.section .data", I); break; case GlobalValue::GhostLinkage: std::cerr << "GhostLinkage cannot appear in AlphaAsmPrinter!\n"; abort(); } - emitAlignment(Align); + EmitAlignment(Align); O << "\t.type " << name << ",@object\n"; O << "\t.size " << name << "," << Size << "\n"; O << name << ":\t\t\t\t# "; @@ -313,7 +269,7 @@ bool AlphaAsmPrinter::doFinalization(Module &M) { O << " = "; WriteAsOperand(O, C, false, false, &M); O << "\n"; - emitGlobalConstant(C); + EmitGlobalConstant(C); } }