virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = 0,
unsigned Size = 0,unsigned Pow2Alignment = 0) = 0;
+ /// AbortAssembly - Stop and don't produce output, printing @param
+ /// AbortReason if non-NULL to indicate the reason the assembly is
+ /// terminated.
+ ///
+ /// @param AbortReason - The reason assembly is terminated, if non-NULL.
+ virtual void AbortAssembly(const char *AbortReason) = 0;
+
/// @}
/// @name Generating Data
/// @{
virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = NULL,
unsigned Size = 0, unsigned Pow2Alignment = 0);
+ virtual void AbortAssembly(const char *AbortReason = NULL);
+
virtual void EmitBytes(const char *Data, unsigned Length);
virtual void EmitValue(const MCValue &Value, unsigned Size);
OS << ".subsections_via_symbols\n";
}
+void MCAsmStreamer::AbortAssembly(const char *AbortReason) {
+ OS << ".abort";
+ if (AbortReason != NULL)
+ OS << ' ' << AbortReason;
+ OS << '\n';
+
+}
+
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
bool MakeAbsolute) {
assert(!Symbol->getSection() && "Cannot assign to a label!");
--- /dev/null
+# RUN: llvm-mc %s | FileCheck %s
+
+# CHECK: TEST0:
+# CHECK: .abort "please stop assembing"
+# CHECK: .abort
+TEST0:
+ .abort "please stop assembing"
+.abort
if (!strcmp(IDVal, ".subsections_via_symbols"))
return ParseDirectiveDarwinSubsectionsViaSymbols();
+ if (!strcmp(IDVal, ".abort"))
+ return ParseDirectiveAbort();
Warning(IDLoc, "ignoring directive for now");
EatToEndOfStatement();
return false;
}
+
+/// ParseDirectiveAbort
+/// ::= .abort [ "abort_string" ]
+bool AsmParser::ParseDirectiveAbort() {
+ const char *Str = NULL;
+ if (Lexer.isNot(asmtok::EndOfStatement)) {
+ if (Lexer.isNot(asmtok::String))
+ return TokError("expected string in '.abort' directive");
+
+ Str = Lexer.getCurStrVal();
+
+ Lexer.Lex();
+ }
+
+ if (Lexer.isNot(asmtok::EndOfStatement))
+ return TokError("unexpected token in '.abort' directive");
+
+ Lexer.Lex();
+
+ Out.AbortAssembly(Str);
+
+ return false;
+}
// Darwin specific ".subsections_via_symbols"
bool ParseDirectiveDarwinSubsectionsViaSymbols();
+
+ bool ParseDirectiveAbort(); // ".abort"
};
} // end namespace llvm