public:
virtual ~MCTargetStreamer();
void setStreamer(MCStreamer *S) { Streamer = S; }
+
+ // Allow a target to add behavior to the EmitLabel of MCStreamer.
+ virtual void emitLabel(MCSymbol *Symbol);
};
// FIXME: declared here because it is used from
// Pin the vtables to this file.
MCTargetStreamer::~MCTargetStreamer() {}
+void MCTargetStreamer::emitLabel(MCSymbol *Symbol) {}
void ARMTargetStreamer::anchor() {}
MCStreamer::MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer)
assert(getCurrentSection().first && "Cannot emit before setting section!");
AssignSection(Symbol, getCurrentSection().first);
LastSymbol = Symbol;
+
+ MCTargetStreamer *TS = getTargetStreamer();
+ if (TS)
+ TS->emitLabel(Symbol);
}
void MCStreamer::EmitDebugLabel(MCSymbol *Symbol) {
bool isEvaluated(const MCExpr *Expr);
bool parseDirectiveSet();
- bool parseDirectiveMipsHackStocg();
bool parseDirectiveMipsHackELFFlags();
bool parseDirectiveOption();
Parser.eatToEndOfStatement();
return false;
} else if (Tok.getString() == "nomicromips") {
- // Ignore this directive for now.
+ getTargetStreamer().emitDirectiveSetNoMicroMips();
+ Parser.eatToEndOfStatement();
+ return false;
+ } else if (Tok.getString() == "micromips") {
+ getTargetStreamer().emitDirectiveSetMicroMips();
Parser.eatToEndOfStatement();
return false;
} else {
return true;
}
-bool MipsAsmParser::parseDirectiveMipsHackStocg() {
- MCAsmParser &Parser = getParser();
- StringRef Name;
- if (Parser.parseIdentifier(Name))
- reportParseError("expected identifier");
-
- MCSymbol *Sym = getContext().GetOrCreateSymbol(Name);
- if (getLexer().isNot(AsmToken::Comma)) {
- TokError("unexpected token");
- return false;
- }
- Lex();
-
- int64_t Flags = 0;
- if (Parser.parseAbsoluteExpression(Flags)) {
- TokError("unexpected token");
- return false;
- }
-
- getTargetStreamer().emitMipsHackSTOCG(Sym, Flags);
- return false;
-}
-
bool MipsAsmParser::parseDirectiveMipsHackELFFlags() {
int64_t Flags = 0;
if (Parser.parseAbsoluteExpression(Flags)) {
return false;
}
- if (IDVal == ".mips_hack_stocg")
- return parseDirectiveMipsHackStocg();
-
if (IDVal == ".mips_hack_elf_flags")
return parseDirectiveMipsHackELFFlags();
OS.write_hex(Flags);
OS << '\n';
}
-void MipsTargetAsmStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) {
- if (!PrintHackDirectives)
- return;
- OS << "\t.mips_hack_stocg ";
- OS << Sym->getName();
- OS << ", ";
- OS << Val;
- OS << '\n';
+void MipsTargetAsmStreamer::emitDirectiveSetMicroMips() {
+ OS << "\t.set\tmicromips\n";
+}
+
+void MipsTargetAsmStreamer::emitDirectiveSetNoMicroMips() {
+ OS << "\t.set\tnomicromips\n";
}
+
void MipsTargetAsmStreamer::emitDirectiveAbiCalls() { OS << "\t.abicalls\n"; }
void MipsTargetAsmStreamer::emitDirectiveOptionPic0() {
OS << "\t.option\tpic0\n";
// This part is for ELF object output.
MipsTargetELFStreamer::MipsTargetELFStreamer() {}
+void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
+ MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Symbol);
+ // The "other" values are stored in the last 6 bits of the second byte
+ // The traditional defines for STO values assume the full byte and thus
+ // the shift to pack it.
+ if (isMicroMipsEnabled())
+ MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
+}
+
MCELFStreamer &MipsTargetELFStreamer::getStreamer() {
return static_cast<MCELFStreamer &>(*Streamer);
}
MCA.setELFHeaderEFlags(Flags);
}
-// Set a symbol's STO flags.
-void MipsTargetELFStreamer::emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) {
- MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Sym);
- // The "other" values are stored in the last 6 bits of the second byte
- // The traditional defines for STO values assume the full byte and thus
- // the shift to pack it.
- MCELF::setOther(Data, Val >> 2);
+void MipsTargetELFStreamer::emitDirectiveSetMicroMips() {
+ MicroMipsEnabled = true;
+}
+
+void MipsTargetELFStreamer::emitDirectiveSetNoMicroMips() {
+ MicroMipsEnabled = false;
}
+
void MipsTargetELFStreamer::emitDirectiveAbiCalls() {
MCAssembler &MCA = getStreamer().getAssembler();
unsigned Flags = MCA.getELFHeaderEFlags();
}
void MipsAsmPrinter::EmitFunctionEntryLabel() {
+ if (Subtarget->inMicroMipsMode())
+ getTargetStreamer().emitDirectiveSetMicroMips();
+
if (OutStreamer.hasRawTextSupport()) {
if (Subtarget->inMips16Mode())
OutStreamer.EmitRawText(StringRef("\t.set\tmips16"));
OutStreamer.EmitRawText("\t.ent\t" + Twine(CurrentFnSym->getName()));
}
- if (Subtarget->inMicroMipsMode())
- getTargetStreamer().emitMipsHackSTOCG(CurrentFnSym,
- (unsigned)ELF::STO_MIPS_MICROMIPS);
OutStreamer.EmitLabel(CurrentFnSym);
}
public:
virtual void emitMipsHackELFFlags(unsigned Flags) = 0;
- virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val) = 0;
+ virtual void emitDirectiveSetMicroMips() = 0;
+ virtual void emitDirectiveSetNoMicroMips() = 0;
virtual void emitDirectiveAbiCalls() = 0;
virtual void emitDirectiveOptionPic0() = 0;
};
public:
MipsTargetAsmStreamer(formatted_raw_ostream &OS);
virtual void emitMipsHackELFFlags(unsigned Flags);
- virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val);
+ virtual void emitDirectiveSetMicroMips();
+ virtual void emitDirectiveSetNoMicroMips();
virtual void emitDirectiveAbiCalls();
virtual void emitDirectiveOptionPic0();
};
// This part is for ELF object output
class MipsTargetELFStreamer : public MipsTargetStreamer {
+ bool MicroMipsEnabled;
public:
+ bool isMicroMipsEnabled() const { return MicroMipsEnabled; }
MCELFStreamer &getStreamer();
MipsTargetELFStreamer();
+
+ virtual void emitLabel(MCSymbol *Symbol) LLVM_OVERRIDE;
+
// FIXME: emitMipsHackELFFlags() will be removed from this class.
virtual void emitMipsHackELFFlags(unsigned Flags);
- virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val);
+ virtual void emitDirectiveSetMicroMips();
+ virtual void emitDirectiveSetNoMicroMips();
virtual void emitDirectiveAbiCalls();
virtual void emitDirectiveOptionPic0();
};
ret i32 0
}
-; CHECK: .mips_hack_stocg main, 128
+; CHECK: .set micromips
+; CHECK: main:
// RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o -| llvm-readobj -t | FileCheck %s
- .text
- .globl main
- .align 2
- .type main,@function
- .set nomips16 # @main
- .ent main
- .mips_hack_stocg main, 128
-main:
-
-// CHECK: Name: main
-// CHECK: Other: 128
+
+.globl f1
+.set micromips
+f1:
+ nop
+
+.globl f2
+.set nomicromips
+f2:
+ nop
+
+// CHECK-LABEL: Name: f1
+// CHECK: Other: 128
+// CHECK-LABEL: Name: f2
+// CHECK: Other: 0