r331218 - [MC] Change AsmParser to leverage Assembler during evaluation
Nirav Dave via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 30 12:22:40 PDT 2018
Author: niravd
Date: Mon Apr 30 12:22:40 2018
New Revision: 331218
URL: http://llvm.org/viewvc/llvm-project?rev=331218&view=rev
Log:
[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
Added:
cfe/trunk/test/CodeGen/asm-parser-info.S
Modified:
cfe/trunk/tools/driver/cc1as_main.cpp
Added: cfe/trunk/test/CodeGen/asm-parser-info.S
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/asm-parser-info.S?rev=331218&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/asm-parser-info.S (added)
+++ cfe/trunk/test/CodeGen/asm-parser-info.S Mon Apr 30 12:22:40 2018
@@ -0,0 +1,12 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang --target=x86_64-unknown-linux-gnu -c %s -o /dev/null
+
+// Check that cc1as can use assembler info in object generation.
+.data
+
+foo:
+.if . - foo == 0
+ .byte 0xaa
+.else
+ .byte 0x00
+.endif
Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=331218&r1=331217&r2=331218&view=diff
==============================================================================
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Mon Apr 30 12:22:40 2018
@@ -435,6 +435,9 @@ static bool ExecuteAssembler(AssemblerIn
Str.get()->InitSections(Opts.NoExecStack);
}
+ // Assembly to object compilation should leverage assembly info.
+ Str->setUseAssemblerInfoForParsing(true);
+
bool Failed = false;
std::unique_ptr<MCAsmParser> Parser(
More information about the cfe-commits
mailing list