diff options
author | Chris Lattner <sabre@nondot.org> | 2010-03-11 22:53:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2010-03-11 22:53:35 +0000 |
commit | c18409aed80ba1c6c5998befd3c3c8edc865c423 (patch) | |
tree | 85297b9076d8810b736b0bb046e8bde24e7dc436 | |
parent | 42263e2e407ab7d1d805e7b41cffd7217134d3b6 (diff) | |
download | external_llvm-c18409aed80ba1c6c5998befd3c3c8edc865c423.zip external_llvm-c18409aed80ba1c6c5998befd3c3c8edc865c423.tar.gz external_llvm-c18409aed80ba1c6c5998befd3c3c8edc865c423.tar.bz2 |
change MCContext to always have an MCAsmInfo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98293 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/MC/MCContext.h | 12 | ||||
-rw-r--r-- | lib/CodeGen/ELFWriter.cpp | 2 | ||||
-rw-r--r-- | lib/CodeGen/LLVMTargetMachine.cpp | 4 | ||||
-rw-r--r-- | lib/MC/MCContext.cpp | 2 | ||||
-rw-r--r-- | tools/edis/EDDisassembler.cpp | 10 | ||||
-rw-r--r-- | tools/llvm-mc/llvm-mc.cpp | 9 |
6 files changed, 24 insertions, 15 deletions
diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index f2f1456..c4f009f 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -15,6 +15,7 @@ #include "llvm/Support/Allocator.h" namespace llvm { + class MCAsmInfo; class MCExpr; class MCSection; class MCSymbol; @@ -28,20 +29,29 @@ namespace llvm { MCContext(const MCContext&); // DO NOT IMPLEMENT MCContext &operator=(const MCContext&); // DO NOT IMPLEMENT + /// The MCAsmInfo for this target. + const MCAsmInfo &MAI; + /// Sections - Bindings of names to allocated sections. StringMap<MCSection*> Sections; /// Symbols - Bindings of names to symbols. StringMap<MCSymbol*> Symbols; + /// NextUniqueID - The next ID to dole out to an unnamed assembler temporary + /// symbol. + unsigned NextUniqueID; + /// Allocator - Allocator object used for creating machine code objects. /// /// We use a bump pointer allocator to avoid the need to track all allocated /// objects. BumpPtrAllocator Allocator; public: - MCContext(); + MCContext(const MCAsmInfo &MAI); ~MCContext(); + + const MCAsmInfo &getAsmInfo() const { return MAI; } /// @name Symbol Managment /// @{ diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp index 0979c04..a748b8b 100644 --- a/lib/CodeGen/ELFWriter.cpp +++ b/lib/CodeGen/ELFWriter.cpp @@ -64,7 +64,7 @@ char ELFWriter::ID = 0; ELFWriter::ELFWriter(raw_ostream &o, TargetMachine &tm) : MachineFunctionPass(&ID), O(o), TM(tm), - OutContext(*new MCContext()), + OutContext(*new MCContext(*TM.getMCAsmInfo())), TLOF(TM.getTargetLowering()->getObjFileLowering()), is64Bit(TM.getTargetData()->getPointerSizeInBits() == 64), isLittleEndian(TM.getTargetData()->isLittleEndian()), diff --git a/lib/CodeGen/LLVMTargetMachine.cpp b/lib/CodeGen/LLVMTargetMachine.cpp index 23ef8ba..0174d55 100644 --- a/lib/CodeGen/LLVMTargetMachine.cpp +++ b/lib/CodeGen/LLVMTargetMachine.cpp @@ -121,14 +121,14 @@ bool LLVMTargetMachine::addPassesToEmitFile(PassManagerBase &PM, if (addCommonCodeGenPasses(PM, OptLevel, DisableVerify)) return true; - OwningPtr<MCContext> Context(new MCContext()); + const MCAsmInfo &MAI = *getMCAsmInfo(); + OwningPtr<MCContext> Context(new MCContext(MAI)); OwningPtr<MCStreamer> AsmStreamer; formatted_raw_ostream *LegacyOutput; switch (FileType) { default: return true; case CGFT_AssemblyFile: { - const MCAsmInfo &MAI = *getMCAsmInfo(); MCInstPrinter *InstPrinter = getTarget().createMCInstPrinter(MAI.getAssemblerDialect(), MAI, Out); AsmStreamer.reset(createAsmStreamer(*Context, Out, MAI, diff --git a/lib/MC/MCContext.cpp b/lib/MC/MCContext.cpp index cf8177c..46eb02f 100644 --- a/lib/MC/MCContext.cpp +++ b/lib/MC/MCContext.cpp @@ -14,7 +14,7 @@ #include "llvm/ADT/Twine.h" using namespace llvm; -MCContext::MCContext() { +MCContext::MCContext(const MCAsmInfo &mai) : MAI(mai), NextUniqueID(0) { } MCContext::~MCContext() { diff --git a/tools/edis/EDDisassembler.cpp b/tools/edis/EDDisassembler.cpp index 99864fb..f2b2f91 100644 --- a/tools/edis/EDDisassembler.cpp +++ b/tools/edis/EDDisassembler.cpp @@ -341,19 +341,17 @@ int EDDisassembler::parseInst(SmallVectorImpl<MCParsedAsmOperand*> &operands, SourceMgr sourceMgr; sourceMgr.AddNewSourceBuffer(buf, SMLoc()); // ownership of buf handed over - MCContext context; - OwningPtr<MCStreamer> streamer - (createNullStreamer(context)); + MCContext context(*AsmInfo); + OwningPtr<MCStreamer> streamer(createNullStreamer(context)); AsmParser genericParser(sourceMgr, context, *streamer, *AsmInfo); - OwningPtr<TargetAsmParser> specificParser - (Tgt->createAsmParser(genericParser)); + OwningPtr<TargetAsmParser> TargetParser(Tgt->createAsmParser(genericParser)); AsmToken OpcodeToken = genericParser.Lex(); if(OpcodeToken.is(AsmToken::Identifier)) { instName = OpcodeToken.getString(); instLoc = OpcodeToken.getLoc(); - if (specificParser->ParseInstruction(instName, instLoc, operands)) + if (TargetParser->ParseInstruction(instName, instLoc, operands)) ret = -1; } else { diff --git a/tools/llvm-mc/llvm-mc.cpp b/tools/llvm-mc/llvm-mc.cpp index fa87238..b3c442e 100644 --- a/tools/llvm-mc/llvm-mc.cpp +++ b/tools/llvm-mc/llvm-mc.cpp @@ -242,7 +242,11 @@ static int AssembleInput(const char *ProgName) { // it later. SrcMgr.setIncludeDirs(IncludeDirs); - MCContext Ctx; + + const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName); + assert(MAI && "Unable to create target asm info!"); + + MCContext Ctx(*MAI); formatted_raw_ostream *Out = GetOutputStream(); if (!Out) return 1; @@ -262,9 +266,6 @@ static int AssembleInput(const char *ProgName) { OwningPtr<MCStreamer> Str; OwningPtr<TargetAsmBackend> TAB; - const MCAsmInfo *MAI = TheTarget->createAsmInfo(TripleName); - assert(MAI && "Unable to create target asm info!"); - if (FileType == OFT_AssemblyFile) { IP.reset(TheTarget->createMCInstPrinter(OutputAsmVariant, *MAI, *Out)); if (ShowEncoding) |