diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:12:57 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-05-08 17:12:57 +0000 |
| commit | c46e6a5940c50058e00c0c5f9123fd82e338d29a (patch) | |
| tree | 89a719d723035c54a190b1f81d329834f1f93336 /lib/MC | |
| parent | 148779df305667b6942fee7e758fdf81a6498f38 (diff) | |
Diffstat (limited to 'lib/MC')
| -rw-r--r-- | lib/MC/ConstantPools.cpp | 11 | ||||
| -rw-r--r-- | lib/MC/MCParser/AsmParser.cpp | 42 |
2 files changed, 49 insertions, 4 deletions
diff --git a/lib/MC/ConstantPools.cpp b/lib/MC/ConstantPools.cpp index 8c94e2780998f..ca5440237e498 100644 --- a/lib/MC/ConstantPools.cpp +++ b/lib/MC/ConstantPools.cpp @@ -57,6 +57,10 @@ const MCExpr *ConstantPool::addEntry(const MCExpr *Value, MCContext &Context, bool ConstantPool::empty() { return Entries.empty(); } +void ConstantPool::clearCache() { + CachedEntries.clear(); +} + // // AssemblerConstantPools implementation // @@ -98,6 +102,13 @@ void AssemblerConstantPools::emitForCurrentSection(MCStreamer &Streamer) { } } +void AssemblerConstantPools::clearCacheForCurrentSection(MCStreamer &Streamer) { + MCSection *Section = Streamer.getCurrentSectionOnly(); + if (ConstantPool *CP = getConstantPool(Section)) { + CP->clearCache(); + } +} + const MCExpr *AssemblerConstantPools::addEntry(MCStreamer &Streamer, const MCExpr *Expr, unsigned Size, SMLoc Loc) { diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index f36a21bf1121e..66ba853da2fe9 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -287,6 +287,7 @@ public: /// } private: + bool isAltmacroString(SMLoc &StrLoc, SMLoc &EndLoc); bool parseStatement(ParseStatementInfo &Info, MCAsmParserSemaCallback *SI); bool parseCurlyBlockScope(SmallVectorImpl<AsmRewrite>& AsmStrRewrites); @@ -1192,6 +1193,31 @@ AsmParser::applyModifierToExpr(const MCExpr *E, llvm_unreachable("Invalid expression kind!"); } +/// This function checks if the next token is <string> type or arithmetic. +/// string that begin with character '<' must end with character '>'. +/// otherwise it is arithmetics. +/// If the function returns a 'true' value, +/// the End argument will be filled with the last location pointed to the '>' +/// character. + +/// There is a gap between the AltMacro's documentation and the single quote implementation. +/// GCC does not fully support this feature and so we will not support it. +/// TODO: Adding single quote as a string. +bool AsmParser::isAltmacroString(SMLoc &StrLoc, SMLoc &EndLoc) { + assert((StrLoc.getPointer() != NULL) && + "Argument to the function cannot be a NULL value"); + const char *CharPtr = StrLoc.getPointer(); + while ((*CharPtr != '>') && (*CharPtr != '\n') && + (*CharPtr != '\r') && (*CharPtr != '\0')){ + CharPtr++; + } + if (*CharPtr == '>') { + EndLoc = StrLoc.getFromPointer(CharPtr + 1); + return true; + } + return false; +} + /// \brief Parse an expression and return it. /// /// expr ::= expr &&,|| expr -> lowest. @@ -2461,9 +2487,9 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M, if (NamedParametersFound && FA.Name.empty()) return Error(IDLoc, "cannot mix positional and keyword arguments"); + SMLoc StrLoc = Lexer.getLoc(); + SMLoc EndLoc; if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Percent)) { - SMLoc StrLoc = Lexer.getLoc(); - SMLoc EndLoc; const MCExpr *AbsoluteExp; int64_t Value; /// Eat '%' @@ -2476,8 +2502,16 @@ bool AsmParser::parseMacroArguments(const MCAsmMacro *M, const char *EndChar = EndLoc.getPointer(); AsmToken newToken(AsmToken::Integer, StringRef(StrChar , EndChar - StrChar), Value); FA.Value.push_back(newToken); - } - else if(parseMacroArgument(FA.Value, Vararg)) + } else if (Lexer.IsaAltMacroMode() && Lexer.is(AsmToken::Less) && + isAltmacroString(StrLoc, EndLoc)) { + const char *StrChar = StrLoc.getPointer(); + const char *EndChar = EndLoc.getPointer(); + jumpToLoc(EndLoc, CurBuffer); + /// Eat from '<' to '>' + Lex(); + AsmToken newToken(AsmToken::String, StringRef(StrChar, EndChar - StrChar)); + FA.Value.push_back(newToken); + } else if(parseMacroArgument(FA.Value, Vararg)) return true; unsigned PI = Parameter; |
