[x86/MIR] Implement support for pre- and post-instruction symbols, as
commit07f63d5becfcde67be3da403d854e163b4a58ace
authorChandler Carruth <chandlerc@gmail.com>
Thu, 16 Aug 2018 23:11:05 +0000 (16 23:11 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 16 Aug 2018 23:11:05 +0000 (16 23:11 +0000)
tree2aeae18993fea2d670e7422a77eab0effb8388bb
parentf4e3ea870eb485d82b6338217fed3e33337887eb
[x86/MIR] Implement support for pre- and post-instruction symbols, as
well as MIR parsing support for `MCSymbol` `MachineOperand`s.

The only real way to test pre- and post-instruction symbol support is to
use them in operands, so I ended up implementing that within the patch
as well. I can split out the operand support if folks really want but it
doesn't really seem worth it.

The functional implementation of pre- and post-instruction symbols is
now *completely trivial*. Two tiny bits of code in the (misnamed)
AsmPrinter. It should be completely target independent as well. We emit
these exactly the same way as we emit basic block labels. Most of the
code here is to give full dumping, MIR printing, and MIR parsing support
so that we can write useful tests.

The MIR parsing of MC symbol operands still isn't 100%, as it forces the
symbols to be non-temporary and non-local symbols with names. However,
those names often can encode most (if not all) of the special semantics
desired, and unnamed symbols seem especially annoying to serialize and
de-serialize. While this isn't perfect or full support, it seems plenty
to write tests that exercise usage of these kinds of operands.

The MIR support for pre-and post-instruction symbols was quite
straightforward. I chose to print them out in an as-if-operand syntax
similar to debug locations as this seemed the cleanest way and let me
use nice introducer tokens rather than inventing more magic punctuation
like we use for memoperands.

However, supporting MIR-based parsing of these symbols caused me to
change the design of the symbol support to allow setting arbitrary
symbols. Without this, I don't see any reasonable way to test things
with MIR.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339962 91177308-0d34-0410-b5e6-96231b3b80d8
docs/MIRLangRef.rst
include/llvm/CodeGen/MachineInstr.h
lib/CodeGen/AsmPrinter/AsmPrinter.cpp
lib/CodeGen/MIRParser/MILexer.cpp
lib/CodeGen/MIRParser/MILexer.h
lib/CodeGen/MIRParser/MIParser.cpp
lib/CodeGen/MIRPrinter.cpp
lib/CodeGen/MachineInstr.cpp
test/CodeGen/MIR/X86/instr-symbols-and-mcsymbol-operands.mir [new file with mode: 0644]
test/CodeGen/X86/instr-symbols.mir [new file with mode: 0644]