OSDN Git Service

MIR Serialization: Change MIR syntax - use custom syntax for MBBs.
authorAlex Lorenz <arphaman@gmail.com>
Thu, 13 Aug 2015 23:10:16 +0000 (23:10 +0000)
committerAlex Lorenz <arphaman@gmail.com>
Thu, 13 Aug 2015 23:10:16 +0000 (23:10 +0000)
commit5d09c2f25d766af6eff341545eca344beda55588
tree37147dda08321e60357d2b1c3a7e7f185035d616
parent9ce155daf1374d05204ef8e09704a788fe5a9bd7
MIR Serialization: Change MIR syntax - use custom syntax for MBBs.

This commit modifies the way the machine basic blocks are serialized - now the
machine basic blocks are serialized using a custom syntax instead of relying on
YAML primitives. Instead of using YAML mappings to represent the individual
machine basic blocks in a machine function's body, the new syntax uses a single
YAML block scalar which contains all of the machine basic blocks and
instructions for that function.

This is an example of a function's body that uses the old syntax:

    body:
      - id: 0
        name: entry
        instructions:
          - '%eax = MOV32r0 implicit-def %eflags'
          - 'RETQ %eax'
    ...

The same body is now written like this:

    body: |
      bb.0.entry:
        %eax = MOV32r0 implicit-def %eflags
        RETQ %eax
    ...

This syntax change is motivated by the fact that the bundled machine
instructions didn't map that well to the old syntax which was using a single
YAML sequence to store all of the machine instructions in a block. The bundled
machine instructions internally use flags like BundledPred and BundledSucc to
determine the bundles, and serializing them as MI flags using the old syntax
would have had a negative impact on the readability and the ease of editing
for MIR files. The new syntax allows me to serialize the bundled machine
instructions using a block construct without relying on the internal flags,
for example:

   BUNDLE implicit-def dead %itstate, implicit-def %s1 ... {
      t2IT 1, 24, implicit-def %itstate
      %s1 = VMOVS killed %s0, 1, killed %cpsr, implicit killed %itstate
   }

This commit also converts the MIR testcases to the new syntax. I developed
a script that can convert from the old syntax to the new one. I will post the
script on the llvm-commits mailing list in the thread for this commit.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244982 91177308-0d34-0410-b5e6-96231b3b80d8
154 files changed:
include/llvm/CodeGen/MIRYamlMapping.h
include/llvm/CodeGen/MachineBasicBlock.h
lib/CodeGen/MIRParser/MILexer.cpp
lib/CodeGen/MIRParser/MILexer.h
lib/CodeGen/MIRParser/MIParser.cpp
lib/CodeGen/MIRParser/MIParser.h
lib/CodeGen/MIRParser/MIRParser.cpp
lib/CodeGen/MIRPrinter.cpp
test/CodeGen/MIR/AArch64/cfi-def-cfa.mir
test/CodeGen/MIR/AArch64/multiple-lhs-operands.mir
test/CodeGen/MIR/AMDGPU/expected-target-index-name.mir
test/CodeGen/MIR/AMDGPU/invalid-target-index-operand.mir
test/CodeGen/MIR/AMDGPU/target-index-operands.mir
test/CodeGen/MIR/Generic/basic-blocks.mir
test/CodeGen/MIR/Generic/expected-colon-after-basic-block.mir [moved from test/CodeGen/MIR/Generic/machine-basic-block-expected-ir-block.mir with 64% similarity]
test/CodeGen/MIR/Generic/expected-eof-after-successor-mbb.mir [deleted file]
test/CodeGen/MIR/Generic/expected-mbb-reference-for-successor-mbb.mir
test/CodeGen/MIR/Generic/frame-info.mir
test/CodeGen/MIR/Generic/invalid-jump-table-kind.mir
test/CodeGen/MIR/Generic/llvmIR.mir
test/CodeGen/MIR/Generic/llvmIRMissing.mir
test/CodeGen/MIR/Generic/machine-basic-block-ir-block-reference.mir
test/CodeGen/MIR/Generic/machine-basic-block-redefinition-error.mir
test/CodeGen/MIR/Generic/machine-basic-block-undefined-ir-block.mir
test/CodeGen/MIR/Generic/machine-basic-block-unknown-name.mir
test/CodeGen/MIR/Generic/machine-function-missing-function.mir
test/CodeGen/MIR/Generic/machine-function-missing-name.mir
test/CodeGen/MIR/Generic/machine-function.mir
test/CodeGen/MIR/Generic/register-info.mir
test/CodeGen/MIR/NVPTX/expected-floating-point-literal.mir
test/CodeGen/MIR/NVPTX/floating-point-immediate-operands.mir
test/CodeGen/MIR/NVPTX/floating-point-invalid-type-error.mir
test/CodeGen/MIR/X86/basic-block-liveins.mir
test/CodeGen/MIR/X86/basic-block-not-at-start-of-line-error.mir [new file with mode: 0644]
test/CodeGen/MIR/X86/block-address-operands.mir
test/CodeGen/MIR/X86/callee-saved-info.mir
test/CodeGen/MIR/X86/cfi-def-cfa-offset.mir
test/CodeGen/MIR/X86/cfi-def-cfa-register.mir
test/CodeGen/MIR/X86/cfi-offset.mir
test/CodeGen/MIR/X86/constant-pool-item-redefinition-error.mir
test/CodeGen/MIR/X86/constant-pool.mir
test/CodeGen/MIR/X86/constant-value-error.mir
test/CodeGen/MIR/X86/dead-register-flag.mir
test/CodeGen/MIR/X86/duplicate-memory-operand-flag.mir
test/CodeGen/MIR/X86/duplicate-register-flag-error.mir
test/CodeGen/MIR/X86/early-clobber-register-flag.mir
test/CodeGen/MIR/X86/expected-align-in-memory-operand.mir
test/CodeGen/MIR/X86/expected-alignment-after-align-in-memory-operand.mir
test/CodeGen/MIR/X86/expected-basic-block-at-start-of-body.mir [new file with mode: 0644]
test/CodeGen/MIR/X86/expected-block-reference-in-blockaddress.mir
test/CodeGen/MIR/X86/expected-comma-after-cfi-register.mir
test/CodeGen/MIR/X86/expected-comma-after-memory-operand.mir
test/CodeGen/MIR/X86/expected-different-implicit-operand.mir
test/CodeGen/MIR/X86/expected-different-implicit-register-flag.mir
test/CodeGen/MIR/X86/expected-from-in-memory-operand.mir
test/CodeGen/MIR/X86/expected-function-reference-after-blockaddress.mir
test/CodeGen/MIR/X86/expected-global-value-after-blockaddress.mir
test/CodeGen/MIR/X86/expected-integer-after-offset-sign.mir
test/CodeGen/MIR/X86/expected-integer-in-successor-weight.mir [new file with mode: 0644]
test/CodeGen/MIR/X86/expected-load-or-store-in-memory-operand.mir
test/CodeGen/MIR/X86/expected-machine-operand.mir
test/CodeGen/MIR/X86/expected-metadata-node-after-debug-location.mir
test/CodeGen/MIR/X86/expected-metadata-node-after-exclaim.mir
test/CodeGen/MIR/X86/expected-named-register-in-allocation-hint.mir
test/CodeGen/MIR/X86/expected-named-register-in-callee-saved-register.mir
test/CodeGen/MIR/X86/expected-named-register-in-functions-livein.mir
test/CodeGen/MIR/X86/expected-named-register-livein.mir
test/CodeGen/MIR/X86/expected-newline-at-end-of-list.mir [new file with mode: 0644]
test/CodeGen/MIR/X86/expected-number-after-bb.mir
test/CodeGen/MIR/X86/expected-offset-after-cfi-operand.mir
test/CodeGen/MIR/X86/expected-pointer-value-in-memory-operand.mir
test/CodeGen/MIR/X86/expected-positive-alignment-after-align.mir
test/CodeGen/MIR/X86/expected-register-after-cfi-operand.mir
test/CodeGen/MIR/X86/expected-register-after-flags.mir
test/CodeGen/MIR/X86/expected-size-integer-after-memory-operation.mir
test/CodeGen/MIR/X86/expected-subregister-after-colon.mir
test/CodeGen/MIR/X86/expected-target-flag-name.mir
test/CodeGen/MIR/X86/expected-value-in-memory-operand.mir
test/CodeGen/MIR/X86/expected-virtual-register-in-functions-livein.mir
test/CodeGen/MIR/X86/external-symbol-operands.mir
test/CodeGen/MIR/X86/fixed-stack-memory-operands.mir
test/CodeGen/MIR/X86/fixed-stack-object-redefinition-error.mir
test/CodeGen/MIR/X86/fixed-stack-objects.mir
test/CodeGen/MIR/X86/frame-info-save-restore-points.mir
test/CodeGen/MIR/X86/frame-setup-instruction-flag.mir
test/CodeGen/MIR/X86/function-liveins.mir
test/CodeGen/MIR/X86/global-value-operands.mir
test/CodeGen/MIR/X86/immediate-operands.mir
test/CodeGen/MIR/X86/implicit-register-flag.mir
test/CodeGen/MIR/X86/instructions-debug-location.mir
test/CodeGen/MIR/X86/invalid-constant-pool-item.mir
test/CodeGen/MIR/X86/invalid-target-flag-name.mir
test/CodeGen/MIR/X86/jump-table-info.mir
test/CodeGen/MIR/X86/jump-table-redefinition-error.mir
test/CodeGen/MIR/X86/killed-register-flag.mir
test/CodeGen/MIR/X86/large-cfi-offset-number-error.mir
test/CodeGen/MIR/X86/large-immediate-operand-error.mir
test/CodeGen/MIR/X86/large-index-number-error.mir
test/CodeGen/MIR/X86/large-offset-number-error.mir
test/CodeGen/MIR/X86/large-size-in-memory-operand-error.mir
test/CodeGen/MIR/X86/liveout-register-mask.mir
test/CodeGen/MIR/X86/machine-basic-block-operands.mir
test/CodeGen/MIR/X86/machine-instructions.mir
test/CodeGen/MIR/X86/machine-verifier.mir
test/CodeGen/MIR/X86/memory-operands.mir
test/CodeGen/MIR/X86/metadata-operands.mir
test/CodeGen/MIR/X86/missing-closing-quote.mir
test/CodeGen/MIR/X86/missing-comma.mir
test/CodeGen/MIR/X86/missing-implicit-operand.mir
test/CodeGen/MIR/X86/missing-instruction.mir [deleted file]
test/CodeGen/MIR/X86/named-registers.mir
test/CodeGen/MIR/X86/newline-handling.mir [new file with mode: 0644]
test/CodeGen/MIR/X86/null-register-operands.mir
test/CodeGen/MIR/X86/register-mask-operands.mir
test/CodeGen/MIR/X86/register-operands-target-flag-error.mir
test/CodeGen/MIR/X86/simple-register-allocation-hints.mir
test/CodeGen/MIR/X86/spill-slot-fixed-stack-object-aliased.mir
test/CodeGen/MIR/X86/spill-slot-fixed-stack-object-immutable.mir
test/CodeGen/MIR/X86/spill-slot-fixed-stack-objects.mir
test/CodeGen/MIR/X86/stack-object-invalid-name.mir
test/CodeGen/MIR/X86/stack-object-operand-name-mismatch-error.mir
test/CodeGen/MIR/X86/stack-object-operands.mir
test/CodeGen/MIR/X86/stack-object-redefinition-error.mir
test/CodeGen/MIR/X86/stack-objects.mir
test/CodeGen/MIR/X86/subregister-operands.mir
test/CodeGen/MIR/X86/successor-basic-blocks-few-weights.mir [deleted file]
test/CodeGen/MIR/X86/successor-basic-blocks-many-weights.mir [deleted file]
test/CodeGen/MIR/X86/successor-basic-blocks-weights.mir
test/CodeGen/MIR/X86/successor-basic-blocks.mir
test/CodeGen/MIR/X86/undef-register-flag.mir
test/CodeGen/MIR/X86/undefined-fixed-stack-object.mir
test/CodeGen/MIR/X86/undefined-global-value.mir
test/CodeGen/MIR/X86/undefined-ir-block-in-blockaddress.mir
test/CodeGen/MIR/X86/undefined-ir-block-slot-in-blockaddress.mir
test/CodeGen/MIR/X86/undefined-jump-table-id.mir
test/CodeGen/MIR/X86/undefined-named-global-value.mir
test/CodeGen/MIR/X86/undefined-register-class.mir
test/CodeGen/MIR/X86/undefined-stack-object.mir
test/CodeGen/MIR/X86/undefined-value-in-memory-operand.mir
test/CodeGen/MIR/X86/undefined-virtual-register.mir
test/CodeGen/MIR/X86/unknown-instruction.mir
test/CodeGen/MIR/X86/unknown-machine-basic-block.mir
test/CodeGen/MIR/X86/unknown-metadata-node.mir
test/CodeGen/MIR/X86/unknown-named-machine-basic-block.mir
test/CodeGen/MIR/X86/unknown-register.mir
test/CodeGen/MIR/X86/unknown-subregister-index.mir
test/CodeGen/MIR/X86/unrecognized-character.mir
test/CodeGen/MIR/X86/used-physical-register-info.mir
test/CodeGen/MIR/X86/variable-sized-stack-object-size-error.mir
test/CodeGen/MIR/X86/variable-sized-stack-objects.mir
test/CodeGen/MIR/X86/virtual-register-redefinition-error.mir
test/CodeGen/MIR/X86/virtual-registers.mir
test/CodeGen/X86/expand-vr64-gr64-copy.mir
test/CodeGen/X86/patchpoint-verifiable.mir