diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:01:22 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-04-16 16:01:22 +0000 | 
| commit | 71d5a2540a98c81f5bcaeb48805e0e2881f530ef (patch) | |
| tree | 5343938942df402b49ec7300a1c25a2d4ccd5821 /include/llvm/MC/MCParser | |
| parent | 31bbf64f3a4974a2d6c8b3b27ad2f519caf74057 (diff) | |
Diffstat (limited to 'include/llvm/MC/MCParser')
| -rw-r--r-- | include/llvm/MC/MCParser/AsmCond.h | 10 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/AsmLexer.h | 19 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/MCAsmLexer.h | 30 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/MCAsmParser.h | 41 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/MCAsmParserExtension.h | 26 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/MCAsmParserUtils.h | 5 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/MCParsedAsmOperand.h | 14 | ||||
| -rw-r--r-- | include/llvm/MC/MCParser/MCTargetAsmParser.h | 34 | 
8 files changed, 96 insertions, 83 deletions
diff --git a/include/llvm/MC/MCParser/AsmCond.h b/include/llvm/MC/MCParser/AsmCond.h index a918b5600ed5..8e7bfc521556 100644 --- a/include/llvm/MC/MCParser/AsmCond.h +++ b/include/llvm/MC/MCParser/AsmCond.h @@ -28,13 +28,13 @@ public:      ElseCond    // inside else conditional    }; -  ConditionalAssemblyType TheCond; -  bool CondMet; -  bool Ignore; +  ConditionalAssemblyType TheCond = NoCond; +  bool CondMet = false; +  bool Ignore = false; -  AsmCond() : TheCond(NoCond), CondMet(false), Ignore(false) {} +  AsmCond() = default;  };  } // end namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_ASMCOND_H diff --git a/include/llvm/MC/MCParser/AsmLexer.h b/include/llvm/MC/MCParser/AsmLexer.h index 029598c013d3..207183a69b0e 100644 --- a/include/llvm/MC/MCParser/AsmLexer.h +++ b/include/llvm/MC/MCParser/AsmLexer.h @@ -16,25 +16,22 @@  #include "llvm/ADT/StringRef.h"  #include "llvm/MC/MCParser/MCAsmLexer.h" -#include "llvm/Support/DataTypes.h"  #include <string>  namespace llvm { -class MemoryBuffer; +  class MCAsmInfo;  /// AsmLexer - Lexer class for assembly files.  class AsmLexer : public MCAsmLexer {    const MCAsmInfo &MAI; -  const char *CurPtr; +  const char *CurPtr = nullptr;    StringRef CurBuf; -  bool IsAtStartOfLine; -  bool IsAtStartOfStatement; -  bool IsParsingMSInlineAsm; -  bool IsPeeking; -  void operator=(const AsmLexer&) = delete; -  AsmLexer(const AsmLexer&) = delete; +  bool IsAtStartOfLine = true; +  bool IsAtStartOfStatement = true; +  bool IsParsingMSInlineAsm = false; +  bool IsPeeking = false;  protected:    /// LexToken - Read the next token and return its code. @@ -42,6 +39,8 @@ protected:  public:    AsmLexer(const MCAsmInfo &MAI); +  AsmLexer(const AsmLexer &) = delete; +  AsmLexer &operator=(const AsmLexer &) = delete;    ~AsmLexer() override;    void setBuffer(StringRef Buf, const char *ptr = nullptr); @@ -74,4 +73,4 @@ private:  } // end namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_ASMLEXER_H diff --git a/include/llvm/MC/MCParser/MCAsmLexer.h b/include/llvm/MC/MCParser/MCAsmLexer.h index 56da6f85c199..7ddc7722e512 100644 --- a/include/llvm/MC/MCParser/MCAsmLexer.h +++ b/include/llvm/MC/MCParser/MCAsmLexer.h @@ -1,4 +1,4 @@ -//===-- llvm/MC/MCAsmLexer.h - Abstract Asm Lexer Interface -----*- C++ -*-===// +//===- llvm/MC/MCAsmLexer.h - Abstract Asm Lexer Interface ------*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -14,10 +14,12 @@  #include "llvm/ADT/ArrayRef.h"  #include "llvm/ADT/SmallVector.h"  #include "llvm/ADT/StringRef.h" -#include "llvm/Support/Compiler.h" -#include "llvm/Support/DataTypes.h"  #include "llvm/Support/SMLoc.h" -#include <utility> +#include <algorithm> +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <string>  namespace llvm { @@ -76,7 +78,7 @@ private:    APInt IntVal;  public: -  AsmToken() {} +  AsmToken() = default;    AsmToken(TokenKind Kind, StringRef Str, APInt IntVal)        : Kind(Kind), Str(Str), IntVal(std::move(IntVal)) {}    AsmToken(TokenKind Kind, StringRef Str, int64_t IntVal = 0) @@ -132,7 +134,7 @@ public:  /// it is lexed.  class AsmCommentConsumer {  public: -  virtual ~AsmCommentConsumer() {}; +  virtual ~AsmCommentConsumer() = default;    /// Callback function for when a comment is lexed. Loc is the start of the    /// comment text (excluding the comment-start marker). CommentText is the text @@ -152,14 +154,12 @@ class MCAsmLexer {    SMLoc ErrLoc;    std::string Err; -  MCAsmLexer(const MCAsmLexer &) = delete; -  void operator=(const MCAsmLexer &) = delete;  protected: // Can only create subclasses. -  const char *TokStart; -  bool SkipSpace; +  const char *TokStart = nullptr; +  bool SkipSpace = true;    bool AllowAtInIdentifier; -  bool IsAtStartOfStatement; -  AsmCommentConsumer *CommentConsumer; +  bool IsAtStartOfStatement = true; +  AsmCommentConsumer *CommentConsumer = nullptr;    MCAsmLexer(); @@ -171,6 +171,8 @@ protected: // Can only create subclasses.    }  public: +  MCAsmLexer(const MCAsmLexer &) = delete; +  MCAsmLexer &operator=(const MCAsmLexer &) = delete;    virtual ~MCAsmLexer();    /// Consume the next token from the input stream and return it. @@ -255,6 +257,6 @@ public:    }  }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_MCASMLEXER_H diff --git a/include/llvm/MC/MCParser/MCAsmParser.h b/include/llvm/MC/MCParser/MCAsmParser.h index eb85a3a30963..6763374185ec 100644 --- a/include/llvm/MC/MCParser/MCAsmParser.h +++ b/include/llvm/MC/MCParser/MCAsmParser.h @@ -1,4 +1,4 @@ -//===-- llvm/MC/MCAsmParser.h - Abstract Asm Parser Interface ---*- C++ -*-===// +//===- llvm/MC/MCAsmParser.h - Abstract Asm Parser Interface ----*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -10,16 +10,21 @@  #ifndef LLVM_MC_MCPARSER_MCASMPARSER_H  #define LLVM_MC_MCPARSER_MCASMPARSER_H -#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h"  #include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/STLExtras.h"  #include "llvm/ADT/StringRef.h"  #include "llvm/ADT/Twine.h" -#include "llvm/MC/MCParser/AsmLexer.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/MC/MCParser/MCAsmLexer.h" +#include "llvm/Support/SMLoc.h" +#include <cstdint> +#include <string> +#include <utility>  namespace llvm { +  class MCAsmInfo; -class MCAsmLexer;  class MCAsmParserExtension;  class MCContext;  class MCExpr; @@ -27,10 +32,7 @@ class MCInstPrinter;  class MCInstrInfo;  class MCStreamer;  class MCTargetAsmParser; -class SMLoc; -class SMRange;  class SourceMgr; -class Twine;  class InlineAsmIdentifierInfo {  public: @@ -51,12 +53,12 @@ public:  class MCAsmParserSemaCallback {  public:    virtual ~MCAsmParserSemaCallback(); +    virtual void *LookupInlineAsmIdentifier(StringRef &LineBuf,                                            InlineAsmIdentifierInfo &Info,                                            bool IsUnevaluatedContext) = 0;    virtual StringRef LookupInlineAsmLabel(StringRef Identifier, SourceMgr &SM,                                           SMLoc Location, bool Create) = 0; -    virtual bool LookupInlineAsmField(StringRef Base, StringRef Member,                                      unsigned &Offset) = 0;  }; @@ -76,22 +78,21 @@ public:    };  private: -  MCAsmParser(const MCAsmParser &) = delete; -  void operator=(const MCAsmParser &) = delete; - -  MCTargetAsmParser *TargetParser; +  MCTargetAsmParser *TargetParser = nullptr;    unsigned ShowParsedOperands : 1;  protected: // Can only create subclasses.    MCAsmParser(); -  bool HadError; +  bool HadError = false;    SmallVector<MCPendingError, 1> PendingErrors;    /// Flag tracking whether any errors have been encountered.  public: +  MCAsmParser(const MCAsmParser &) = delete; +  MCAsmParser &operator=(const MCAsmParser &) = delete;    virtual ~MCAsmParser();    virtual void addDirectiveHandler(StringRef Directive, @@ -186,12 +187,12 @@ public:    bool parseEOL(const Twine &ErrMsg); -  bool parseMany(std::function<bool()> parseOne, bool hasComma = true); +  bool parseMany(function_ref<bool()> parseOne, bool hasComma = true);    bool parseIntToken(int64_t &V, const Twine &ErrMsg); -  bool check(bool P, const llvm::Twine &Msg); -  bool check(bool P, SMLoc Loc, const llvm::Twine &Msg); +  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    /// Res to the identifier contents. @@ -258,8 +259,8 @@ public:  /// \brief Create an MCAsmParser instance.  MCAsmParser *createMCAsmParser(SourceMgr &, MCContext &, MCStreamer &, -                               const MCAsmInfo &); +                               const MCAsmInfo &, unsigned CB = 0); -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_MCASMPARSER_H diff --git a/include/llvm/MC/MCParser/MCAsmParserExtension.h b/include/llvm/MC/MCParser/MCAsmParserExtension.h index dabda0ab9485..ffb8d7a4a26a 100644 --- a/include/llvm/MC/MCParser/MCAsmParserExtension.h +++ b/include/llvm/MC/MCParser/MCAsmParserExtension.h @@ -1,4 +1,4 @@ -//===-- llvm/MC/MCAsmParserExtension.h - Asm Parser Hooks -------*- C++ -*-===// +//===- llvm/MC/MCAsmParserExtension.h - Asm Parser Hooks --------*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -10,20 +10,20 @@  #ifndef LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H  #define LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H +#include "llvm/ADT/STLExtras.h"  #include "llvm/ADT/StringRef.h" +#include "llvm/MC/MCParser/MCAsmLexer.h"  #include "llvm/MC/MCParser/MCAsmParser.h"  #include "llvm/Support/SMLoc.h"  namespace llvm { +  class Twine;  /// \brief Generic interface for extending the MCAsmParser,  /// which is implemented by target and object file assembly parser  /// implementations.  class MCAsmParserExtension { -  MCAsmParserExtension(const MCAsmParserExtension &) = delete; -  void operator=(const MCAsmParserExtension &) = delete; -    MCAsmParser *Parser;  protected: @@ -38,9 +38,11 @@ protected:      return (Obj->*Handler)(Directive, DirectiveLoc);    } -  bool BracketExpressionsSupported; +  bool BracketExpressionsSupported = false;  public: +  MCAsmParserExtension(const MCAsmParserExtension &) = delete; +  MCAsmParserExtension &operator=(const MCAsmParserExtension &) = delete;    virtual ~MCAsmParserExtension();    /// \brief Initialize the extension for parsing using the given \p Parser. @@ -65,15 +67,19 @@ public:    SourceMgr &getSourceManager() { return getParser().getSourceManager(); }    MCStreamer &getStreamer() { return getParser().getStreamer(); } +    bool Warning(SMLoc L, const Twine &Msg) {      return getParser().Warning(L, Msg);    } +    bool Error(SMLoc L, const Twine &Msg, SMRange Range = SMRange()) {      return getParser().Error(L, Msg, Range);    } +    void Note(SMLoc L, const Twine &Msg) {      getParser().Note(L, Msg);    } +    bool TokError(const Twine &Msg) {      return getParser().TokError(Msg);    } @@ -85,7 +91,7 @@ public:      return getParser().parseToken(T, Msg);    } -  bool parseMany(std::function<bool()> parseOne, bool hasComma = true) { +  bool parseMany(function_ref<bool()> parseOne, bool hasComma = true) {      return getParser().parseMany(parseOne, hasComma);    } @@ -93,11 +99,11 @@ public:      return getParser().parseOptionalToken(T);    } -  bool check(bool P, const llvm::Twine &Msg) { +  bool check(bool P, const Twine &Msg) {      return getParser().check(P, Msg);    } -  bool check(bool P, SMLoc Loc, const llvm::Twine &Msg) { +  bool check(bool P, SMLoc Loc, const Twine &Msg) {      return getParser().check(P, Loc, Msg);    } @@ -110,6 +116,6 @@ public:    /// @}  }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_MCASMPARSEREXTENSION_H diff --git a/include/llvm/MC/MCParser/MCAsmParserUtils.h b/include/llvm/MC/MCParser/MCAsmParserUtils.h index 9834fe96307b..84173bb9cb8e 100644 --- a/include/llvm/MC/MCParser/MCAsmParserUtils.h +++ b/include/llvm/MC/MCParser/MCAsmParserUtils.h @@ -1,4 +1,4 @@ -//===------ llvm/MC/MCAsmParserUtils.h - Asm Parser Utilities ---*- C++ -*-===// +//===- llvm/MC/MCAsmParserUtils.h - Asm Parser Utilities --------*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -28,6 +28,7 @@ bool parseAssignmentExpression(StringRef Name, bool allow_redef,                                 const MCExpr *&Value);  } // namespace MCParserUtils +  } // namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_MCASMPARSERUTILS_H diff --git a/include/llvm/MC/MCParser/MCParsedAsmOperand.h b/include/llvm/MC/MCParser/MCParsedAsmOperand.h index a90d280c240c..4af76ac2a858 100644 --- a/include/llvm/MC/MCParser/MCParsedAsmOperand.h +++ b/include/llvm/MC/MCParser/MCParsedAsmOperand.h @@ -1,4 +1,4 @@ -//===-- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand -------*- C++ -*-===// +//===- llvm/MC/MCParsedAsmOperand.h - Asm Parser Operand --------*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -10,11 +10,12 @@  #ifndef LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H  #define LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H -#include <string>  #include "llvm/ADT/StringRef.h"  #include "llvm/Support/SMLoc.h" +#include <string>  namespace llvm { +  class raw_ostream;  /// MCParsedAsmOperand - This abstract class represents a source-level assembly @@ -35,12 +36,12 @@ protected:    // lots of members and MSVC doesn't support defaulted move ops, so to avoid    // that verbosity, just rely on defaulted copy ops. It's only the Constraint    // string member that would benefit from movement anyway. +  MCParsedAsmOperand() = default;    MCParsedAsmOperand(const MCParsedAsmOperand &RHS) = default;    MCParsedAsmOperand &operator=(const MCParsedAsmOperand &) = default; -  MCParsedAsmOperand() = default;  public: -  virtual ~MCParsedAsmOperand() {} +  virtual ~MCParsedAsmOperand() = default;    void setConstraint(StringRef C) { Constraint = C.str(); }    StringRef getConstraint() { return Constraint; } @@ -81,6 +82,7 @@ public:    /// print - Print a debug representation of the operand to the given stream.    virtual void print(raw_ostream &OS) const = 0; +    /// dump - Print to the debug stream.    virtual void dump() const;  }; @@ -93,6 +95,6 @@ inline raw_ostream& operator<<(raw_ostream &OS, const MCParsedAsmOperand &MO) {    return OS;  } -} // end namespace llvm. +} // end namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_MCPARSEDASMOPERAND_H diff --git a/include/llvm/MC/MCParser/MCTargetAsmParser.h b/include/llvm/MC/MCParser/MCTargetAsmParser.h index 70cd60c9a112..c81a7624011f 100644 --- a/include/llvm/MC/MCParser/MCTargetAsmParser.h +++ b/include/llvm/MC/MCParser/MCTargetAsmParser.h @@ -1,4 +1,4 @@ -//===-- llvm/MC/MCTargetAsmParser.h - Target Assembly Parser ----*- C++ -*-===// +//===- llvm/MC/MCTargetAsmParser.h - Target Assembly Parser -----*- C++ -*-===//  //  //                     The LLVM Compiler Infrastructure  // @@ -10,19 +10,21 @@  #ifndef LLVM_MC_MCPARSER_MCTARGETASMPARSER_H  #define LLVM_MC_MCPARSER_MCTARGETASMPARSER_H +#include "llvm/ADT/StringRef.h"  #include "llvm/MC/MCExpr.h" +#include "llvm/MC/MCParser/MCAsmLexer.h"  #include "llvm/MC/MCParser/MCAsmParserExtension.h"  #include "llvm/MC/MCTargetOptions.h" +#include "llvm/Support/SMLoc.h" +#include <cstdint>  #include <memory>  namespace llvm { -class AsmToken; +  class MCInst;  class MCParsedAsmOperand;  class MCStreamer;  class MCSubtargetInfo; -class SMLoc; -class StringRef;  template <typename T> class SmallVectorImpl;  typedef SmallVectorImpl<std::unique_ptr<MCParsedAsmOperand>> OperandVector; @@ -66,6 +68,7 @@ struct AsmRewrite {    unsigned Len;    unsigned Val;    StringRef Label; +  public:    AsmRewrite(AsmRewriteKind kind, SMLoc loc, unsigned len = 0, unsigned val = 0)      : Kind(kind), Loc(loc), Len(len), Val(val) {} @@ -74,10 +77,9 @@ public:  };  struct ParseInstructionInfo { +  SmallVectorImpl<AsmRewrite> *AsmRewrites = nullptr; -  SmallVectorImpl<AsmRewrite> *AsmRewrites; - -  ParseInstructionInfo() : AsmRewrites(nullptr) {} +  ParseInstructionInfo() = default;    ParseInstructionInfo(SmallVectorImpl<AsmRewrite> *rewrites)      : AsmRewrites(rewrites) {}  }; @@ -99,9 +101,6 @@ public:      FIRST_TARGET_MATCH_RESULT_TY    }; -private: -  MCTargetAsmParser(const MCTargetAsmParser &) = delete; -  void operator=(const MCTargetAsmParser &) = delete;  protected: // Can only create subclasses.    MCTargetAsmParser(MCTargetOptions const &, const MCSubtargetInfo &STI); @@ -109,10 +108,10 @@ protected: // Can only create subclasses.    MCSubtargetInfo ©STI();    /// AvailableFeatures - The current set of available features. -  uint64_t AvailableFeatures; +  uint64_t AvailableFeatures = 0;    /// ParsingInlineAsm - Are we parsing ms-style inline assembly? -  bool ParsingInlineAsm; +  bool ParsingInlineAsm = false;    /// SemaCallback - The Sema callback implementation.  Must be set when parsing    /// ms-style inline assembly. @@ -125,6 +124,9 @@ protected: // Can only create subclasses.    const MCSubtargetInfo *STI;  public: +  MCTargetAsmParser(const MCTargetAsmParser &) = delete; +  MCTargetAsmParser &operator=(const MCTargetAsmParser &) = delete; +    ~MCTargetAsmParser() override;    const MCSubtargetInfo &getSTI() const; @@ -229,11 +231,11 @@ public:      return nullptr;    } -  virtual void onLabelParsed(MCSymbol *Symbol) { } +  virtual void onLabelParsed(MCSymbol *Symbol) {}    /// Ensure that all previously parsed instructions have been emitted to the    /// output streamer, if the target does not emit them immediately. -  virtual void flushPendingInstructions(MCStreamer &Out) { } +  virtual void flushPendingInstructions(MCStreamer &Out) {}    virtual const MCExpr *createTargetUnaryExpr(const MCExpr *E,                                                AsmToken::TokenKind OperatorToken, @@ -242,6 +244,6 @@ public:    }  }; -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_MC_MCPARSER_MCTARGETASMPARSER_H  | 
