[llvm-commits] [llvm] r98293 - in /llvm/trunk: include/llvm/MC/MCContext.h lib/CodeGen/ELFWriter.cpp lib/CodeGen/LLVMTargetMachine.cpp lib/MC/MCContext.cpp tools/edis/EDDisassembler.cpp tools/llvm-mc/llvm-mc.cpp
Chris Lattner
sabre at nondot.org
Thu Mar 11 14:53:35 PST 2010
Author: lattner
Date: Thu Mar 11 16:53:35 2010
New Revision: 98293
URL: http://llvm.org/viewvc/llvm-project?rev=98293&view=rev
Log:
change MCContext to always have an MCAsmInfo.
Modified:
llvm/trunk/include/llvm/MC/MCContext.h
llvm/trunk/lib/CodeGen/ELFWriter.cpp
llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
llvm/trunk/lib/MC/MCContext.cpp
llvm/trunk/tools/edis/EDDisassembler.cpp
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=98293&r1=98292&r2=98293&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Thu Mar 11 16:53:35 2010
@@ -15,6 +15,7 @@
#include "llvm/Support/Allocator.h"
namespace llvm {
+ class MCAsmInfo;
class MCExpr;
class MCSection;
class MCSymbol;
@@ -28,20 +29,29 @@
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
/// @{
Modified: llvm/trunk/lib/CodeGen/ELFWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ELFWriter.cpp?rev=98293&r1=98292&r2=98293&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ELFWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/ELFWriter.cpp Thu Mar 11 16:53:35 2010
@@ -64,7 +64,7 @@
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()),
Modified: llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp?rev=98293&r1=98292&r2=98293&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp (original)
+++ llvm/trunk/lib/CodeGen/LLVMTargetMachine.cpp Thu Mar 11 16:53:35 2010
@@ -121,14 +121,14 @@
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,
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=98293&r1=98292&r2=98293&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Thu Mar 11 16:53:35 2010
@@ -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() {
Modified: llvm/trunk/tools/edis/EDDisassembler.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/edis/EDDisassembler.cpp?rev=98293&r1=98292&r2=98293&view=diff
==============================================================================
--- llvm/trunk/tools/edis/EDDisassembler.cpp (original)
+++ llvm/trunk/tools/edis/EDDisassembler.cpp Thu Mar 11 16:53:35 2010
@@ -341,19 +341,17 @@
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 {
Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=98293&r1=98292&r2=98293&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Thu Mar 11 16:53:35 2010
@@ -242,7 +242,11 @@
// 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 @@
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)
More information about the llvm-commits
mailing list