llvm-mc: Implement .abort fully in the front end
authorDaniel Dunbar <daniel@zuster.org>
Mon, 27 Jul 2009 23:20:52 +0000 (23:20 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Mon, 27 Jul 2009 23:20:52 +0000 (23:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77272 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/MC/MCStreamer.h
lib/MC/MCAsmStreamer.cpp
test/MC/AsmParser/directive_abort.s
tools/llvm-mc/AsmParser.cpp
tools/llvm-mc/AsmParser.h
tools/llvm-mc/MC-X86Specific.cpp

index db658d2c4d68f8579319bf5406c2241c25bf4fa8..0f973eb7509873967fd5123fddc75d1a89ce833b 100644 (file)
@@ -156,13 +156,6 @@ namespace llvm {
     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
     /// @{
index b77e6efac39a4ab6240379ed79cfd43a74bc3d85..b67250383a09a3e2b5e1b28d4afcf743d2966df7 100644 (file)
@@ -55,8 +55,6 @@ namespace {
     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 StringRef &Data);
 
     virtual void EmitValue(const MCValue &Value, unsigned Size);
@@ -132,14 +130,6 @@ void MCAsmStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
   OS << '\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!");
index fefb8e24cc1a701f6d06849700868ce17da771a3..3eb8e96f2f887a9dbab21a0fb5319b5d2f956da3 100644 (file)
@@ -1,8 +1,6 @@
-# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
+# RUN: llvm-mc -triple i386-unknown-unknown %s 2> %t
+# RUN: FileCheck -input-file %t %s
 
-# CHECK: TEST0:
 # CHECK: .abort "please stop assembing"
-# CHECK: .abort
 TEST0:  
        .abort       "please stop assembing"
-.abort
index 371a58e6ca96a2d70589facb7a94b42dee0bfc0d..65d48b23cbda06753c8232b87fb5c953faf04c41 100644 (file)
@@ -14,6 +14,7 @@
 #include "AsmParser.h"
 
 #include "AsmExpr.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/Target/TargetAsmParser.h"
 using namespace llvm;
 
-void AsmParser::Warning(SMLoc L, const char *Msg) {
-  Lexer.PrintMessage(L, Msg, "warning");
+void AsmParser::Warning(SMLoc L, const Twine &Msg) {
+  Lexer.PrintMessage(L, Msg.str(), "warning");
 }
 
-bool AsmParser::Error(SMLoc L, const char *Msg) {
-  Lexer.PrintMessage(L, Msg, "error");
+bool AsmParser::Error(SMLoc L, const Twine &Msg) {
+  Lexer.PrintMessage(L, Msg.str(), "error");
   return true;
 }
 
@@ -1117,6 +1118,9 @@ bool AsmParser::ParseDirectiveDarwinSubsectionsViaSymbols() {
 /// ParseDirectiveAbort
 ///  ::= .abort [ "abort_string" ]
 bool AsmParser::ParseDirectiveAbort() {
+  // FIXME: Use loc from directive.
+  SMLoc Loc = Lexer.getLoc();
+
   StringRef Str = "";
   if (Lexer.isNot(asmtok::EndOfStatement)) {
     if (Lexer.isNot(asmtok::String))
@@ -1133,7 +1137,10 @@ bool AsmParser::ParseDirectiveAbort() {
   Lexer.Lex();
 
   // FIXME: Handle here.
-  Out.AbortAssembly(Str.str().c_str());
+  if (Str.empty())
+    Error(Loc, ".abort detected. Assembly stopping.");
+  else
+    Error(Loc, ".abort '" + Str + "' detected. Assembly stopping.");
 
   return false;
 }
index 3d9842e642beccdf6bb219a4c9f09318803085ca..dd6033847b43a12efe4fe29593b09b80a4ead6cb 100644 (file)
@@ -25,6 +25,7 @@ class MCInst;
 class MCStreamer;
 class MCValue;
 class TargetAsmParser;
+class Twine;
 
 class AsmParser : MCAsmParser {
 public:
@@ -52,8 +53,8 @@ public:
 private:
   bool ParseStatement();
 
-  void Warning(SMLoc L, const char *Msg);
-  bool Error(SMLoc L, const char *Msg);
+  void Warning(SMLoc L, const Twine &Msg);
+  bool Error(SMLoc L, const Twine &Msg);
   bool TokError(const char *Msg);
   
   void EatToEndOfStatement();
index d16bb15d38052e13906d839c6d128266352014fc..6e28b028c3fd942e3ef509d6c6ed0c51afb19078 100644 (file)
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "AsmParser.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/MC/MCInst.h"
 #include "llvm/Support/SourceMgr.h"
 using namespace llvm;