1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

change MCContext to always have an MCAsmInfo.

llvm-svn: 98293
This commit is contained in:
Chris Lattner 2010-03-11 22:53:35 +00:00
parent 5aefaeb42e
commit debc026df2
6 changed files with 24 additions and 15 deletions

View File

@ -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
/// @{

View File

@ -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()),

View File

@ -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,

View File

@ -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() {

View File

@ -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 {

View File

@ -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)