OSDN Git Service

[MC] Change AsmParser to leverage Assembler during evaluation
authorNirav Dave <niravd@google.com>
Mon, 30 Apr 2018 19:22:40 +0000 (19:22 +0000)
committerNirav Dave <niravd@google.com>
Mon, 30 Apr 2018 19:22:40 +0000 (19:22 +0000)
commit4d344626681a31cd8993f97eceb68419bfcc4c54
tree30c41b97a76ffc0087966bc46331cc0c58c3bbf3
parentd3476a449966bf110889e5c9c0f7ad7fe6341158
[MC] Change AsmParser to leverage Assembler during evaluation

Teach AsmParser to check with Assembler for when evaluating constant
expressions.  This improves the handing of preprocessor expressions
that must be resolved at parse time. This idiom can be found as
assembling-time assertion checks in source-level assemblers. Note that
this relies on the MCStreamer to keep sufficient tabs on Section /
Fragment information which the MCAsmStreamer does not. As a result the
textual output may fail where the equivalent object generation would
pass. This can most easily be resolved by folding the MCAsmStreamer
and MCObjectStreamer together which is planned for in a separate
patch.

Currently, this feature is only enabled for assembly input, keeping IR
compilation consistent between assembly and object generation.

Reviewers: echristo, rnk, probinson, espindola, peter.smith

Reviewed By: peter.smith

Subscribers: eraman, peter.smith, arichardson, jyknight, hiraditya, llvm-commits

Differential Revision: https://reviews.llvm.org/D45164

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331218 91177308-0d34-0410-b5e6-96231b3b80d8
15 files changed:
include/llvm/MC/MCExpr.h
include/llvm/MC/MCObjectStreamer.h
include/llvm/MC/MCStreamer.h
include/llvm/MC/MCSymbol.h
lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp
lib/MC/MCAsmStreamer.cpp
lib/MC/MCExpr.cpp
lib/MC/MCObjectStreamer.cpp
lib/MC/MCParser/AsmParser.cpp
lib/MC/MCStreamer.cpp
test/MC/AsmParser/assembler-expressions-fail.s [new file with mode: 0644]
test/MC/AsmParser/assembler-expressions-inlineasm.ll [new file with mode: 0644]
test/MC/AsmParser/assembler-expressions.s [new file with mode: 0644]
test/MC/AsmParser/directive_fill.s
tools/llvm-mc/llvm-mc.cpp