Skip to content

Commit

Permalink
Change MCStreamer EmitInstruction interface to take subtarget info
Browse files Browse the repository at this point in the history
llvm-svn: 200345
  • Loading branch information
dwmw2 committed Jan 28, 2014
1 parent 1fd6dd3 commit e6c13e4
Show file tree
Hide file tree
Showing 31 changed files with 184 additions and 159 deletions.
6 changes: 6 additions & 0 deletions llvm/include/llvm/CodeGen/AsmPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace llvm {
class MCAsmInfo;
class MCCFIInstruction;
class MCContext;
class MCInst;
class MCInstrInfo;
class MCSection;
class MCStreamer;
Expand Down Expand Up @@ -149,6 +150,11 @@ namespace llvm {
/// getDataLayout - Return information about data layout.
const DataLayout &getDataLayout() const;

/// getSubtargetInfo - Return information about subtarget.
const MCSubtargetInfo &getSubtargetInfo() const;

void EmitToStreamer(MCStreamer &S, const MCInst &Inst);

/// getTargetTriple - Return the target triple string.
StringRef getTargetTriple() const;

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCObjectStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class MCObjectStreamer : public MCStreamer {
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
virtual void ChangeSection(const MCSection *Section,
const MCExpr *Subsection);
virtual void EmitInstruction(const MCInst &Inst);
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo& STI);

/// \brief Emit an instruction to a special fragment, because this instruction
/// can change its size during relaxation.
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/MC/MCStreamer.h
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ class MCStreamer {

/// EmitInstruction - Emit the given @p Instruction into the current
/// section.
virtual void EmitInstruction(const MCInst &Inst) = 0;
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) = 0;

/// \brief Set the bundle alignment mode from now on in the section.
/// The argument is the power of 2 to which the alignment is set. The
Expand Down
11 changes: 10 additions & 1 deletion llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "llvm/Target/TargetLoweringObjectFile.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Target/TargetSubtargetInfo.h"
#include "llvm/Transforms/Utils/GlobalStatus.h"
#include "WinCodeViewLineTables.h"
using namespace llvm;
Expand Down Expand Up @@ -137,6 +138,14 @@ const DataLayout &AsmPrinter::getDataLayout() const {
return *TM.getDataLayout();
}

const MCSubtargetInfo &AsmPrinter::getSubtargetInfo() const {
return TM.getSubtarget<MCSubtargetInfo>();
}

void AsmPrinter::EmitToStreamer(MCStreamer &S, const MCInst &Inst) {
S.EmitInstruction(Inst, getSubtargetInfo());
}

StringRef AsmPrinter::getTargetTriple() const {
return TM.getTargetTriple();
}
Expand Down Expand Up @@ -789,7 +798,7 @@ void AsmPrinter::EmitFunctionBody() {
TM.getInstrInfo()->getNoopForMachoTarget(Noop);
if (Noop.getOpcode()) {
OutStreamer.AddComment("avoids zero-length function");
OutStreamer.EmitInstruction(Noop);
OutStreamer.EmitInstruction(Noop, getSubtargetInfo());
} else // Target not mc-ized yet.
OutStreamer.EmitRawText(StringRef("\tnop\n"));
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/LTO/LTOModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ namespace {

RecordStreamer(MCContext &Context) : MCStreamer(Context) {}

virtual void EmitInstruction(const MCInst &Inst) {
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) {
// Scan for values.
for (unsigned i = Inst.getNumOperands(); i--; )
if (Inst.getOperand(i).isExpr())
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/MC/MCAsmStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ class MCAsmStreamer : public MCStreamer {
virtual void EmitWin64EHPushFrame(bool Code);
virtual void EmitWin64EHEndProlog();

virtual void EmitInstruction(const MCInst &Inst);
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI);

virtual void EmitBundleAlignMode(unsigned AlignPow2);
virtual void EmitBundleLock(bool AlignToEnd);
Expand Down Expand Up @@ -1318,7 +1318,7 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst) {
}
}

void MCAsmStreamer::EmitInstruction(const MCInst &Inst) {
void MCAsmStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) {
assert(getCurrentSection().first &&
"Cannot emit contents before setting section!");

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/MC/MCNullStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace {
unsigned Column, unsigned Flags,
unsigned Isa, unsigned Discriminator,
StringRef FileName) {}
virtual void EmitInstruction(const MCInst &Inst) {}
virtual void EmitInstruction(const MCInst &Inst, const MCSubtargetInfo&) {}

virtual void EmitBundleAlignMode(unsigned AlignPow2) {}
virtual void EmitBundleLock(bool AlignToEnd) {}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/MC/MCObjectStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void MCObjectStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
Symbol->setVariableValue(AddValueSymbols(Value));
}

void MCObjectStreamer::EmitInstruction(const MCInst &Inst) {
void MCObjectStreamer::EmitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI) {
// Scan for values.
for (unsigned i = Inst.getNumOperands(); i--; )
if (Inst.getOperand(i).isExpr())
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ void AArch64AsmPrinter::EmitInstruction(const MachineInstr *MI) {

MCInst TmpInst;
LowerAArch64MachineInstrToMCInst(MI, TmpInst, *this);
OutStreamer.EmitInstruction(TmpInst);
EmitToStreamer(OutStreamer, TmpInst);
}

void AArch64AsmPrinter::EmitEndOfAsmFile(Module &M) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2375,7 +2375,7 @@ bool AArch64AsmParser::ParseDirectiveTLSDescCall(SMLoc L) {
Inst.setOpcode(AArch64::TLSDESCCALL);
Inst.addOperand(MCOperand::CreateExpr(Expr));

getParser().getStreamer().EmitInstruction(Inst);
getParser().getStreamer().EmitInstruction(Inst, STI);
return false;
}

Expand All @@ -2398,7 +2398,7 @@ bool AArch64AsmParser::MatchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
if (validateInstruction(Inst, Operands))
return true;

Out.EmitInstruction(Inst);
Out.EmitInstruction(Inst, STI);
return false;
case Match_MissingFeature:
Error(IDLoc, "instruction requires a CPU feature not currently enabled");
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Target/AArch64/MCTargetDesc/AArch64ELFStreamer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ class AArch64ELFStreamer : public MCELFStreamer {
/// This function is the one used to emit instruction data into the ELF
/// streamer. We override it to add the appropriate mapping symbol if
/// necessary.
virtual void EmitInstruction(const MCInst& Inst) {
virtual void EmitInstruction(const MCInst& Inst, const MCSubtargetInfo &STI) {
EmitA64MappingSymbol();
MCELFStreamer::EmitInstruction(Inst);
MCELFStreamer::EmitInstruction(Inst, STI);
}

/// This is one of the functions used to emit data into an ELF section, so the
Expand Down
Loading

0 comments on commit e6c13e4

Please sign in to comment.