Update clang to r339409.
Change-Id: I800772d2d838223be1f6b40d490c4591b937fca2
diff --git a/linux-x64/clang/include/llvm/MC/MCParser/AsmCond.h b/linux-x64/clang/include/llvm/MC/MCParser/AsmCond.h
index 8e7bfc5..a6e0fbd 100644
--- a/linux-x64/clang/include/llvm/MC/MCParser/AsmCond.h
+++ b/linux-x64/clang/include/llvm/MC/MCParser/AsmCond.h
@@ -15,7 +15,7 @@
/// AsmCond - Class to support conditional assembly
///
/// The conditional assembly feature (.if, .else, .elseif and .endif) is
-/// implemented with AsmCond that tells us what we are in the middle of
+/// implemented with AsmCond that tells us what we are in the middle of
/// processing. Ignore can be either true or false. When true we are ignoring
/// the block of code in the middle of a conditional.
diff --git a/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParser.h b/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParser.h
index 0f79c47..0d56f36 100644
--- a/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParser.h
+++ b/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParser.h
@@ -91,7 +91,7 @@
IdKind Kind;
};
-/// \brief Generic Sema callback for assembly parser.
+/// Generic Sema callback for assembly parser.
class MCAsmParserSemaCallback {
public:
virtual ~MCAsmParserSemaCallback();
@@ -105,7 +105,7 @@
unsigned &Offset) = 0;
};
-/// \brief Generic assembler parser interface, for use by target specific
+/// Generic assembler parser interface, for use by target specific
/// assembly parsers.
class MCAsmParser {
public:
@@ -153,7 +153,7 @@
virtual MCContext &getContext() = 0;
- /// \brief Return the output streamer for the assembler.
+ /// Return the output streamer for the assembler.
virtual MCStreamer &getStreamer() = 0;
MCTargetAsmParser &getTargetParser() const { return *TargetParser; }
@@ -168,13 +168,13 @@
void setEnablePrintSchedInfo(bool Value) { EnablePrintSchedInfo = Value; }
bool shouldPrintSchedInfo() { return EnablePrintSchedInfo; }
- /// \brief Run the parser on the input source buffer.
+ /// Run the parser on the input source buffer.
virtual bool Run(bool NoInitialTextSection, bool NoFinalize = false) = 0;
virtual void setParsingInlineAsm(bool V) = 0;
virtual bool isParsingInlineAsm() = 0;
- /// \brief Parse MS-style inline assembly.
+ /// Parse MS-style inline assembly.
virtual bool parseMSInlineAsm(
void *AsmLoc, std::string &AsmString, unsigned &NumOutputs,
unsigned &NumInputs, SmallVectorImpl<std::pair<void *, bool>> &OpDecls,
@@ -182,22 +182,22 @@
SmallVectorImpl<std::string> &Clobbers, const MCInstrInfo *MII,
const MCInstPrinter *IP, MCAsmParserSemaCallback &SI) = 0;
- /// \brief Emit a note at the location \p L, with the message \p Msg.
+ /// Emit a note at the location \p L, with the message \p Msg.
virtual void Note(SMLoc L, const Twine &Msg, SMRange Range = None) = 0;
- /// \brief Emit a warning at the location \p L, with the message \p Msg.
+ /// Emit a warning at the location \p L, with the message \p Msg.
///
/// \return The return value is true, if warnings are fatal.
virtual bool Warning(SMLoc L, const Twine &Msg, SMRange Range = None) = 0;
- /// \brief Return an error at the location \p L, with the message \p Msg. This
+ /// Return an error at the location \p L, with the message \p Msg. This
/// may be modified before being emitted.
///
/// \return The return value is always true, as an idiomatic convenience to
/// clients.
bool Error(SMLoc L, const Twine &Msg, SMRange Range = None);
- /// \brief Emit an error at the location \p L, with the message \p Msg.
+ /// Emit an error at the location \p L, with the message \p Msg.
///
/// \return The return value is always true, as an idiomatic convenience to
/// clients.
@@ -214,21 +214,23 @@
return rv;
}
+ void clearPendingErrors() { PendingErrors.clear(); }
+
bool addErrorSuffix(const Twine &Suffix);
- /// \brief Get the next AsmToken in the stream, possibly handling file
+ /// Get the next AsmToken in the stream, possibly handling file
/// inclusion first.
virtual const AsmToken &Lex() = 0;
- /// \brief Get the current AsmToken from the stream.
+ /// Get the current AsmToken from the stream.
const AsmToken &getTok() const;
- /// \brief Report an error at the current lexer location.
+ /// Report an error at the current lexer location.
bool TokError(const Twine &Msg, SMRange Range = None);
bool parseTokenLoc(SMLoc &Loc);
bool parseToken(AsmToken::TokenKind T, const Twine &Msg = "unexpected token");
- /// \brief Attempt to parse and consume token, returning true on
+ /// Attempt to parse and consume token, returning true on
/// success.
bool parseOptionalToken(AsmToken::TokenKind T);
@@ -241,23 +243,23 @@
bool check(bool P, const Twine &Msg);
bool check(bool P, SMLoc Loc, const Twine &Msg);
- /// \brief Parse an identifier or string (as a quoted identifier) and set \p
+ /// Parse an identifier or string (as a quoted identifier) and set \p
/// Res to the identifier contents.
virtual bool parseIdentifier(StringRef &Res) = 0;
- /// \brief Parse up to the end of statement and return the contents from the
+ /// Parse up to the end of statement and return the contents from the
/// current token until the end of the statement; the current token on exit
/// will be either the EndOfStatement or EOF.
virtual StringRef parseStringToEndOfStatement() = 0;
- /// \brief Parse the current token as a string which may include escaped
+ /// Parse the current token as a string which may include escaped
/// characters and return the string contents.
virtual bool parseEscapedString(std::string &Data) = 0;
- /// \brief Skip to the end of the current statement, for error recovery.
+ /// Skip to the end of the current statement, for error recovery.
virtual void eatToEndOfStatement() = 0;
- /// \brief Parse an arbitrary expression.
+ /// Parse an arbitrary expression.
///
/// \param Res - The value of the expression. The result is undefined
/// on error.
@@ -265,14 +267,14 @@
virtual bool parseExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
bool parseExpression(const MCExpr *&Res);
- /// \brief Parse a primary expression.
+ /// Parse a primary expression.
///
/// \param Res - The value of the expression. The result is undefined
/// on error.
/// \return - False on success.
virtual bool parsePrimaryExpr(const MCExpr *&Res, SMLoc &EndLoc) = 0;
- /// \brief Parse an arbitrary expression, assuming that an initial '(' has
+ /// Parse an arbitrary expression, assuming that an initial '(' has
/// already been consumed.
///
/// \param Res - The value of the expression. The result is undefined
@@ -280,19 +282,19 @@
/// \return - False on success.
virtual bool parseParenExpression(const MCExpr *&Res, SMLoc &EndLoc) = 0;
- /// \brief Parse an expression which must evaluate to an absolute value.
+ /// Parse an expression which must evaluate to an absolute value.
///
/// \param Res - The value of the absolute expression. The result is undefined
/// on error.
/// \return - False on success.
virtual bool parseAbsoluteExpression(int64_t &Res) = 0;
- /// \brief Ensure that we have a valid section set in the streamer. Otherwise,
+ /// Ensure that we have a valid section set in the streamer. Otherwise,
/// report an error and switch to .text.
/// \return - False on success.
virtual bool checkForValidSection() = 0;
- /// \brief Parse an arbitrary expression of a specified parenthesis depth,
+ /// Parse an arbitrary expression of a specified parenthesis depth,
/// assuming that the initial '(' characters have already been consumed.
///
/// \param ParenDepth - Specifies how many trailing expressions outside the
@@ -304,7 +306,7 @@
SMLoc &EndLoc) = 0;
};
-/// \brief Create an MCAsmParser instance.
+/// Create an MCAsmParser instance.
MCAsmParser *createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &,
const MCAsmInfo &, unsigned CB = 0);
diff --git a/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserExtension.h b/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserExtension.h
index ffb8d7a..1a132bc 100644
--- a/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserExtension.h
+++ b/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserExtension.h
@@ -20,7 +20,7 @@
class Twine;
-/// \brief Generic interface for extending the MCAsmParser,
+/// Generic interface for extending the MCAsmParser,
/// which is implemented by target and object file assembly parser
/// implementations.
class MCAsmParserExtension {
@@ -45,7 +45,7 @@
MCAsmParserExtension &operator=(const MCAsmParserExtension &) = delete;
virtual ~MCAsmParserExtension();
- /// \brief Initialize the extension for parsing using the given \p Parser.
+ /// Initialize the extension for parsing using the given \p Parser.
/// The extension should use the AsmParser interfaces to register its
/// parsing routines.
virtual void Initialize(MCAsmParser &Parser);
diff --git a/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserUtils.h b/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserUtils.h
index 84173bb..259113b 100644
--- a/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserUtils.h
+++ b/linux-x64/clang/include/llvm/MC/MCParser/MCAsmParserUtils.h
@@ -25,7 +25,7 @@
/// On success, returns false and sets the Symbol and Value output parameters.
bool parseAssignmentExpression(StringRef Name, bool allow_redef,
MCAsmParser &Parser, MCSymbol *&Symbol,
- const MCExpr *&Value);
+ const MCExpr *&Value, bool AllowExtendedExpr = false);
} // namespace MCParserUtils
diff --git a/linux-x64/clang/include/llvm/MC/MCParser/MCTargetAsmParser.h b/linux-x64/clang/include/llvm/MC/MCParser/MCTargetAsmParser.h
index d628794..2d188a6 100644
--- a/linux-x64/clang/include/llvm/MC/MCParser/MCTargetAsmParser.h
+++ b/linux-x64/clang/include/llvm/MC/MCParser/MCTargetAsmParser.h
@@ -14,6 +14,7 @@
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCParser/MCAsmLexer.h"
+#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
#include "llvm/MC/MCParser/MCAsmParserExtension.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/Support/SMLoc.h"
@@ -133,6 +134,53 @@
MatchOperand_ParseFail // operand matched but had errors
};
+enum class DiagnosticPredicateTy {
+ Match,
+ NearMatch,
+ NoMatch,
+};
+
+// When an operand is parsed, the assembler will try to iterate through a set of
+// possible operand classes that the operand might match and call the
+// corresponding PredicateMethod to determine that.
+//
+// If there are two AsmOperands that would give a specific diagnostic if there
+// is no match, there is currently no mechanism to distinguish which operand is
+// a closer match. The DiagnosticPredicate distinguishes between 'completely
+// no match' and 'near match', so the assembler can decide whether to give a
+// specific diagnostic, or use 'InvalidOperand' and continue to find a
+// 'better matching' diagnostic.
+//
+// For example:
+// opcode opnd0, onpd1, opnd2
+//
+// where:
+// opnd2 could be an 'immediate of range [-8, 7]'
+// opnd2 could be a 'register + shift/extend'.
+//
+// If opnd2 is a valid register, but with a wrong shift/extend suffix, it makes
+// little sense to give a diagnostic that the operand should be an immediate
+// in range [-8, 7].
+//
+// This is a light-weight alternative to the 'NearMissInfo' approach
+// below which collects *all* possible diagnostics. This alternative
+// is optional and fully backward compatible with existing
+// PredicateMethods that return a 'bool' (match or no match).
+struct DiagnosticPredicate {
+ DiagnosticPredicateTy Type;
+
+ explicit DiagnosticPredicate(bool Match)
+ : Type(Match ? DiagnosticPredicateTy::Match
+ : DiagnosticPredicateTy::NearMatch) {}
+ DiagnosticPredicate(DiagnosticPredicateTy T) : Type(T) {}
+ DiagnosticPredicate(const DiagnosticPredicate &) = default;
+
+ operator bool() const { return Type == DiagnosticPredicateTy::Match; }
+ bool isMatch() const { return Type == DiagnosticPredicateTy::Match; }
+ bool isNearMatch() const { return Type == DiagnosticPredicateTy::NearMatch; }
+ bool isNoMatch() const { return Type == DiagnosticPredicateTy::NoMatch; }
+};
+
// When matching of an assembly instruction fails, there may be multiple
// encodings that are close to being a match. It's often ambiguous which one
// the programmer intended to use, so we want to report an error which mentions
@@ -324,6 +372,11 @@
SemaCallback = Callback;
}
+ // Target-specific parsing of assembler-level variable assignment.
+ virtual bool parseAssignmentExpression(const MCExpr *&Res, SMLoc &EndLoc) {
+ return getParser().parseExpression(Res, EndLoc);
+ }
+
virtual bool ParseRegister(unsigned &RegNo, SMLoc &StartLoc,
SMLoc &EndLoc) = 0;
@@ -401,6 +454,15 @@
virtual void convertToMapAndConstraints(unsigned Kind,
const OperandVector &Operands) = 0;
+ /// Returns whether two registers are equal and is used by the tied-operands
+ /// checks in the AsmMatcher. This method can be overridden allow e.g. a
+ /// sub- or super-register as the tied operand.
+ virtual bool regsEqual(const MCParsedAsmOperand &Op1,
+ const MCParsedAsmOperand &Op2) const {
+ assert(Op1.isReg() && Op2.isReg() && "Operands not all regs");
+ return Op1.getReg() == Op2.getReg();
+ }
+
// Return whether this parser uses assignment statements with equals tokens
virtual bool equalIsAsmAssignment() { return true; };
// Return whether this start of statement identifier is a label