#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Module.h"
+#include "llvm/MDNode.h"
#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/CodeGen/DwarfWriter.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetOptions.h"
+#include "llvm/Target/TargetRegistry.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/Mangler.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/MathExtras.h"
-#include "llvm/Support/raw_ostream.h"
#include <cctype>
using namespace llvm;
class VISIBILITY_HIDDEN MipsAsmPrinter : public AsmPrinter {
const MipsSubtarget *Subtarget;
public:
- explicit MipsAsmPrinter(raw_ostream &O, MipsTargetMachine &TM,
- const TargetAsmInfo *T, unsigned OL, bool V)
- : AsmPrinter(O, TM, T, OL, V) {
+ explicit MipsAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
+ const TargetAsmInfo *T, bool V)
+ : AsmPrinter(O, TM, T, V) {
Subtarget = &TM.getSubtarget<MipsSubtarget>();
}
/// assembly code for a MachineFunction to the given output stream,
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
-FunctionPass *llvm::createMipsCodePrinterPass(raw_ostream &o,
- MipsTargetMachine &tm,
- unsigned OptLevel, bool verbose) {
- return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose);
+FunctionPass *llvm::createMipsCodePrinterPass(formatted_raw_ostream &o,
+ TargetMachine &tm,
+ bool verbose) {
+ return new MipsAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
}
//===----------------------------------------------------------------------===//
default: break;
}
- assert(0 && "Unknown Mips ABI");
+ llvm_unreachable("Unknown Mips ABI");
return NULL;
}
SwitchToSection(TAI->SectionForGlobal(F));
// 2 bits aligned
- EmitAlignment(2, F);
+ EmitAlignment(MF.getAlignment(), F);
O << "\t.globl\t" << CurrentFnName << '\n';
O << "\t.ent\t" << CurrentFnName << '\n';
return;
case MachineOperand::MO_GlobalAddress:
- {
- const GlobalValue *GV = MO.getGlobal();
- O << Mang->getValueName(GV);
- }
+ O << Mang->getMangledName(MO.getGlobal());
break;
case MachineOperand::MO_ExternalSymbol:
break;
default:
- O << "<unknown operand type>"; abort (); break;
+ llvm_unreachable("<unknown operand type>");
}
if (closeP) O << ")";
return;
O << "\n\n";
- std::string name = Mang->getValueName(GVar);
+ std::string name = Mang->getMangledName(GVar);
Constant *C = GVar->getInitializer();
+ if (isa<MDNode>(C) || isa<MDString>(C))
+ return;
const Type *CTy = C->getType();
- unsigned Size = TD->getTypePaddedSize(CTy);
+ unsigned Size = TD->getTypeAllocSize(CTy);
const ConstantArray *CVA = dyn_cast<ConstantArray>(C);
bool printSizeAndType = true;
O << TAI->getGlobalDirective() << name << '\n';
// Fall Through
case GlobalValue::PrivateLinkage:
+ case GlobalValue::LinkerPrivateLinkage:
case GlobalValue::InternalLinkage:
if (CVA && CVA->isCString())
printSizeAndType = false;
break;
case GlobalValue::GhostLinkage:
- cerr << "Should not have any unmaterialized functions!\n";
- abort();
+ llvm_unreachable("Should not have any unmaterialized functions!");
case GlobalValue::DLLImportLinkage:
- cerr << "DLLImport linkage is not supported by this target!\n";
- abort();
+ llvm_unreachable("DLLImport linkage is not supported by this target!");
case GlobalValue::DLLExportLinkage:
- cerr << "DLLExport linkage is not supported by this target!\n";
- abort();
+ llvm_unreachable("DLLExport linkage is not supported by this target!");
default:
- assert(0 && "Unknown linkage type!");
+ llvm_unreachable("Unknown linkage type!");
}
EmitAlignment(Align, GVar);
return AsmPrinter::doFinalization(M);
}
+
+// Force static initialization.
+extern "C" void LLVMInitializeMipsAsmPrinter() {
+ TargetRegistry::RegisterAsmPrinter(TheMipsTarget, createMipsCodePrinterPass);
+
+ TargetRegistry::RegisterAsmPrinter(TheMipselTarget,
+ createMipsCodePrinterPass);
+}