mirror of
https://github.com/RPCSX/llvm.git
synced 2025-04-09 03:31:15 +00:00
llvm-mc: Implement .abort fully in the front end
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77272 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
02efa786d4
commit
f9507ffa5b
@ -156,13 +156,6 @@ namespace llvm {
|
|||||||
virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = 0,
|
virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = 0,
|
||||||
unsigned Size = 0,unsigned Pow2Alignment = 0) = 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
|
/// @name Generating Data
|
||||||
/// @{
|
/// @{
|
||||||
|
@ -55,8 +55,6 @@ namespace {
|
|||||||
virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = NULL,
|
virtual void EmitZerofill(MCSection *Section, MCSymbol *Symbol = NULL,
|
||||||
unsigned Size = 0, unsigned Pow2Alignment = 0);
|
unsigned Size = 0, unsigned Pow2Alignment = 0);
|
||||||
|
|
||||||
virtual void AbortAssembly(const char *AbortReason = NULL);
|
|
||||||
|
|
||||||
virtual void EmitBytes(const StringRef &Data);
|
virtual void EmitBytes(const StringRef &Data);
|
||||||
|
|
||||||
virtual void EmitValue(const MCValue &Value, unsigned Size);
|
virtual void EmitValue(const MCValue &Value, unsigned Size);
|
||||||
@ -132,14 +130,6 @@ void MCAsmStreamer::EmitAssemblerFlag(AssemblerFlag Flag) {
|
|||||||
OS << '\n';
|
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,
|
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCValue &Value,
|
||||||
bool MakeAbsolute) {
|
bool MakeAbsolute) {
|
||||||
assert(!Symbol->getSection() && "Cannot assign to a label!");
|
assert(!Symbol->getSection() && "Cannot assign to a label!");
|
||||||
|
@ -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 "please stop assembing"
|
||||||
# CHECK: .abort
|
|
||||||
TEST0:
|
TEST0:
|
||||||
.abort "please stop assembing"
|
.abort "please stop assembing"
|
||||||
.abort
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include "AsmParser.h"
|
#include "AsmParser.h"
|
||||||
|
|
||||||
#include "AsmExpr.h"
|
#include "AsmExpr.h"
|
||||||
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
@ -23,12 +24,12 @@
|
|||||||
#include "llvm/Target/TargetAsmParser.h"
|
#include "llvm/Target/TargetAsmParser.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
void AsmParser::Warning(SMLoc L, const char *Msg) {
|
void AsmParser::Warning(SMLoc L, const Twine &Msg) {
|
||||||
Lexer.PrintMessage(L, Msg, "warning");
|
Lexer.PrintMessage(L, Msg.str(), "warning");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AsmParser::Error(SMLoc L, const char *Msg) {
|
bool AsmParser::Error(SMLoc L, const Twine &Msg) {
|
||||||
Lexer.PrintMessage(L, Msg, "error");
|
Lexer.PrintMessage(L, Msg.str(), "error");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1117,6 +1118,9 @@ bool AsmParser::ParseDirectiveDarwinSubsectionsViaSymbols() {
|
|||||||
/// ParseDirectiveAbort
|
/// ParseDirectiveAbort
|
||||||
/// ::= .abort [ "abort_string" ]
|
/// ::= .abort [ "abort_string" ]
|
||||||
bool AsmParser::ParseDirectiveAbort() {
|
bool AsmParser::ParseDirectiveAbort() {
|
||||||
|
// FIXME: Use loc from directive.
|
||||||
|
SMLoc Loc = Lexer.getLoc();
|
||||||
|
|
||||||
StringRef Str = "";
|
StringRef Str = "";
|
||||||
if (Lexer.isNot(asmtok::EndOfStatement)) {
|
if (Lexer.isNot(asmtok::EndOfStatement)) {
|
||||||
if (Lexer.isNot(asmtok::String))
|
if (Lexer.isNot(asmtok::String))
|
||||||
@ -1133,7 +1137,10 @@ bool AsmParser::ParseDirectiveAbort() {
|
|||||||
Lexer.Lex();
|
Lexer.Lex();
|
||||||
|
|
||||||
// FIXME: Handle here.
|
// 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ class MCInst;
|
|||||||
class MCStreamer;
|
class MCStreamer;
|
||||||
class MCValue;
|
class MCValue;
|
||||||
class TargetAsmParser;
|
class TargetAsmParser;
|
||||||
|
class Twine;
|
||||||
|
|
||||||
class AsmParser : MCAsmParser {
|
class AsmParser : MCAsmParser {
|
||||||
public:
|
public:
|
||||||
@ -52,8 +53,8 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool ParseStatement();
|
bool ParseStatement();
|
||||||
|
|
||||||
void Warning(SMLoc L, const char *Msg);
|
void Warning(SMLoc L, const Twine &Msg);
|
||||||
bool Error(SMLoc L, const char *Msg);
|
bool Error(SMLoc L, const Twine &Msg);
|
||||||
bool TokError(const char *Msg);
|
bool TokError(const char *Msg);
|
||||||
|
|
||||||
void EatToEndOfStatement();
|
void EatToEndOfStatement();
|
||||||
|
@ -13,6 +13,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "AsmParser.h"
|
#include "AsmParser.h"
|
||||||
|
#include "llvm/ADT/Twine.h"
|
||||||
#include "llvm/MC/MCInst.h"
|
#include "llvm/MC/MCInst.h"
|
||||||
#include "llvm/Support/SourceMgr.h"
|
#include "llvm/Support/SourceMgr.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user