diff options
| author | Reid Kleckner <rnk@google.com> | 2018-10-24 20:23:57 +0000 | 
|---|---|---|
| committer | Reid Kleckner <rnk@google.com> | 2018-10-24 20:23:57 +0000 | 
| commit | 953bdce68db36f1fec5299f9525b1b87c491a8a8 (patch) | |
| tree | e640b62d318996512113fa1f58f0b3d1441618f9 /llvm/tools | |
| parent | 1c353419ab51f63235389b821c1e6ed02c3ccfb8 (diff) | |
| download | bcm5719-llvm-953bdce68db36f1fec5299f9525b1b87c491a8a8.tar.gz bcm5719-llvm-953bdce68db36f1fec5299f9525b1b87c491a8a8.zip | |
[MC] Separate masm integer literal lexer support from inline asm
Summary:
This renames the IsParsingMSInlineAsm member variable of AsmLexer to
LexMasmIntegers and moves it up to MCAsmLexer. This is the only behavior
controlled by that variable. I added a public setter, so that it can be
set from outside or from the llvm-mc command line. We may need to
arrange things so that users can get this behavior from clang, but
that's future work.
I also put additional hex literal lexing functionality under this flag
to fix PR32973. It appears that this hex literal parsing wasn't intended
to be enabled in non-masm-style blocks.
Now, masm integers (0b1101 and 0ABCh) work in __asm blocks from clang,
but 0b label references work when using .intel_syntax in standalone .s
files.
However, 0b label references will *not* work from __asm blocks in clang.
They will work from GCC inline asm blocks, which it sounds like is
important for Crypto++ as mentioned in PR36144.
Essentially, we only lex masm literals for inline asm blobs that use
intel syntax. If the .intel_syntax directive is used inside a gnu-style
inline asm statement, masm literals will not be lexed, which is
compatible with gas and llvm-mc standalone .s assembly.
This fixes PR36144 and PR32973.
Reviewers: Gerolf, avt77
Subscribers: eraman, hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D53535
llvm-svn: 345189
Diffstat (limited to 'llvm/tools')
| -rw-r--r-- | llvm/tools/llvm-mc/llvm-mc.cpp | 5 | 
1 files changed, 5 insertions, 0 deletions
| diff --git a/llvm/tools/llvm-mc/llvm-mc.cpp b/llvm/tools/llvm-mc/llvm-mc.cpp index 0263c866f77..c0976502f54 100644 --- a/llvm/tools/llvm-mc/llvm-mc.cpp +++ b/llvm/tools/llvm-mc/llvm-mc.cpp @@ -164,6 +164,10 @@ MainFileName("main-file-name",  static cl::opt<bool> SaveTempLabels("save-temp-labels",                                      cl::desc("Don't discard temporary labels")); +static cl::opt<bool> LexMasmIntegers( +    "masm-integers", +    cl::desc("Enable binary and hex masm integers (0b110 and 0ABCh)")); +  static cl::opt<bool> NoExecStack("no-exec-stack",                                   cl::desc("File doesn't need an exec stack")); @@ -293,6 +297,7 @@ static int AssembleInput(const char *ProgName, const Target *TheTarget,      return SymbolResult;    Parser->setShowParsedOperands(ShowInstOperands);    Parser->setTargetParser(*TAP); +  Parser->getLexer().setLexMasmIntegers(LexMasmIntegers);    int Res = Parser->Run(NoInitialTextSection); | 

