llvm-mc: Tweak MCCodeEmitter skeleton.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80193 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Daniel Dunbar 2009-08-27 01:34:22 +00:00
parent 5b78d50cad
commit 04baf9094a
4 changed files with 25 additions and 10 deletions

View File

@ -26,7 +26,7 @@ public:
/// EncodeInstruction - Encode the given \arg Inst to bytes on the output /// EncodeInstruction - Encode the given \arg Inst to bytes on the output
/// stream \arg OS. /// stream \arg OS.
virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS) = 0; virtual void EncodeInstruction(const MCInst &Inst, raw_ostream &OS) const = 0;
}; };
} // End llvm namespace } // End llvm namespace

View File

@ -59,8 +59,7 @@ namespace llvm {
typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T, typedef TargetAsmParser *(*AsmParserCtorTy)(const Target &T,
MCAsmParser &P); MCAsmParser &P);
typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const Target &T, typedef MCCodeEmitter *(*CodeEmitterCtorTy)(const Target &T,
TargetMachine &TM, TargetMachine &TM);
const MCAsmInfo &MAI);
private: private:
/// Next - The next registered target in the linked list, maintained by the /// Next - The next registered target in the linked list, maintained by the
@ -180,11 +179,10 @@ namespace llvm {
} }
/// createCodeEmitter - Create a target specific code emitter. /// createCodeEmitter - Create a target specific code emitter.
MCCodeEmitter *createCodeEmitter(TargetMachine &TM, MCCodeEmitter *createCodeEmitter(TargetMachine &TM) const {
const MCAsmInfo *MAI) const {
if (!CodeEmitterCtorFn) if (!CodeEmitterCtorFn)
return 0; return 0;
return CodeEmitterCtorFn(*this, TM, *MAI); return CodeEmitterCtorFn(*this, TM);
} }
/// @} /// @}
@ -493,9 +491,8 @@ namespace llvm {
} }
private: private:
static MCCodeEmitter *Allocator(const Target &T, TargetMachine &TM, static MCCodeEmitter *Allocator(const Target &T, TargetMachine &TM) {
const MCAsmInfo &MAI) { return new CodeEmitterImpl(T, TM);
return new CodeEmitterImpl(T, TM, MAI);
} }
}; };

18
lib/MC/MCCodeEmitter.cpp Normal file
View File

@ -0,0 +1,18 @@
//===-- MCCodeEmitter.cpp - Instruction Encoding --------------------------===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
#include "llvm/MC/MCCodeEmitter.h"
using namespace llvm;
MCCodeEmitter::MCCodeEmitter() {
}
MCCodeEmitter::~MCCodeEmitter() {
}

View File

@ -244,7 +244,7 @@ static int AssembleInput(const char *ProgName) {
assert(TAI && "Unable to create target asm info!"); assert(TAI && "Unable to create target asm info!");
AP.reset(TheTarget->createAsmPrinter(*Out, *TM, TAI, true)); AP.reset(TheTarget->createAsmPrinter(*Out, *TM, TAI, true));
CE.reset(TheTarget->createCodeEmitter(*TM, TAI)); CE.reset(TheTarget->createCodeEmitter(*TM));
Str.reset(createAsmStreamer(Ctx, *Out, *TAI, AP.get(), CE.get())); Str.reset(createAsmStreamer(Ctx, *Out, *TAI, AP.get(), CE.get()));
} else { } else {
assert(FileType == OFT_ObjectFile && "Invalid file type!"); assert(FileType == OFT_ObjectFile && "Invalid file type!");