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.
llvm-svn: 244982
diff --git a/llvm/test/CodeGen/MIR/Generic/basic-blocks.mir b/llvm/test/CodeGen/MIR/Generic/basic-blocks.mir
index 1731304..22f8d28 100644
--- a/llvm/test/CodeGen/MIR/Generic/basic-blocks.mir
+++ b/llvm/test/CodeGen/MIR/Generic/basic-blocks.mir
@@ -13,37 +13,37 @@
ret i32 0
}
+ define i32 @test() {
+ start:
+ ret i32 0
+ }
+
...
---
-# CHECK: name: foo
+# CHECK-LABEL: name: foo
# CHECK: body:
-# CHECK-NEXT: - id: 0
-# CHECK-NEXT: name: entry
-# CHECK-NEXT: alignment: 0
-# CHECK-NEXT: isLandingPad: false
-# CHECK-NEXT: addressTaken: false
+# CHECK-NEXT: bb.0.entry:
name: foo
-body:
- - id: 0
- name: entry
+body: |
+ bb.0.entry:
...
---
-# CHECK: name: bar
+# CHECK-LABEL: name: bar
# CHECK: body:
-# CHECK-NEXT: - id: 0
-# CHECK-NEXT: name: start
-# CHECK-NEXT: alignment: 4
-# CHECK-NEXT: isLandingPad: false
-# CHECK-NEXT: addressTaken: false
-# CHECK-NEXT: - id: 1
-# CHECK-NEXT: alignment: 0
-# CHECK-NEXT: isLandingPad: false
-# CHECK-NEXT: addressTaken: true
+# CHECK-NEXT: bb.0.start (align 4):
+# CHECK: bb.1 (address-taken):
name: bar
-body:
- - id: 0
- name: start
- alignment: 4
- - id: 1
- addressTaken: true
+body: |
+ bb.0.start (align 4):
+ bb.1 (address-taken):
+...
+---
+# CHECK-LABEL: name: test
+# CHECK: body:
+# CHECK-NEXT: bb.0.start (address-taken, align 4):
+# CHECK: bb.1 (address-taken, align 4):
+name: test
+body: |
+ bb.0.start (align 4, address-taken):
+ bb.1 (address-taken, align 4):
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-expected-ir-block.mir b/llvm/test/CodeGen/MIR/Generic/expected-colon-after-basic-block.mir
similarity index 64%
rename from llvm/test/CodeGen/MIR/Generic/machine-basic-block-expected-ir-block.mir
rename to llvm/test/CodeGen/MIR/Generic/expected-colon-after-basic-block.mir
index 2f3d40a..8922586 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-expected-ir-block.mir
+++ b/llvm/test/CodeGen/MIR/Generic/expected-colon-after-basic-block.mir
@@ -3,14 +3,14 @@
--- |
define i32 @foo() {
+ entry:
ret i32 0
}
...
---
name: foo
-body:
- - id: 0
-# CHECK: [[@LINE+1]]:19: expected an IR block reference
- ir-block: '0'
+body: |
+ ; CHECK: [[@LINE+1]]:13: expected ':'
+ bb.0.entry
...
diff --git a/llvm/test/CodeGen/MIR/Generic/expected-eof-after-successor-mbb.mir b/llvm/test/CodeGen/MIR/Generic/expected-eof-after-successor-mbb.mir
deleted file mode 100644
index 25ae511..0000000
--- a/llvm/test/CodeGen/MIR/Generic/expected-eof-after-successor-mbb.mir
+++ /dev/null
@@ -1,29 +0,0 @@
-# RUN: not llc -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
-
---- |
-
- define i32 @foo(i32 %a) {
- entry:
- %0 = icmp sle i32 %a, 10
- br i1 %0, label %less, label %exit
-
- less:
- ret i32 0
-
- exit:
- ret i32 %a
- }
-
-...
----
-name: foo
-body:
- - id: 0
- name: entry
- # CHECK: [[@LINE+1]]:46: expected end of string after the machine basic block reference
- successors: [ '%bb.1.less', '%bb.2.exit 2' ]
- - id: 1
- name: less
- - id: 2
- name: exit
-...
diff --git a/llvm/test/CodeGen/MIR/Generic/expected-mbb-reference-for-successor-mbb.mir b/llvm/test/CodeGen/MIR/Generic/expected-mbb-reference-for-successor-mbb.mir
index ce91929..a5e04f8 100644
--- a/llvm/test/CodeGen/MIR/Generic/expected-mbb-reference-for-successor-mbb.mir
+++ b/llvm/test/CodeGen/MIR/Generic/expected-mbb-reference-for-successor-mbb.mir
@@ -17,13 +17,12 @@
...
---
name: foo
-body:
- - id: 0
- name: entry
- # CHECK: [[@LINE+1]]:35: expected a machine basic block reference
- successors: [ '%bb.1.less', '2' ]
- - id: 1
- name: less
- - id: 2
- name: exit
+body: |
+ bb.0.entry:
+ ; CHECK: [[@LINE+1]]:29: expected a machine basic block reference
+ successors: %bb.1.less, 2
+
+ bb.1.less:
+
+ bb.2.exit:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/frame-info.mir b/llvm/test/CodeGen/MIR/Generic/frame-info.mir
index c5468f9..6e4e395 100644
--- a/llvm/test/CodeGen/MIR/Generic/frame-info.mir
+++ b/llvm/test/CodeGen/MIR/Generic/frame-info.mir
@@ -44,9 +44,8 @@
# CHECK: body
frameInfo:
maxAlignment: 4
-body:
- - id: 0
- name: entry
+body: |
+ bb.0.entry:
...
---
name: test2
@@ -84,8 +83,7 @@
hasOpaqueSPAdjustment: true
hasVAStart: true
hasMustTailInVarArgFunc: true
-body:
- - id: 0
- name: entry
+body: |
+ bb.0.entry:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/invalid-jump-table-kind.mir b/llvm/test/CodeGen/MIR/Generic/invalid-jump-table-kind.mir
index 4876f79..576de4b 100644
--- a/llvm/test/CodeGen/MIR/Generic/invalid-jump-table-kind.mir
+++ b/llvm/test/CodeGen/MIR/Generic/invalid-jump-table-kind.mir
@@ -36,19 +36,18 @@
entries:
- id: 0
blocks: [ '%bb.3.lbl1', '%bb.4.lbl2', '%bb.5.lbl3', '%bb.6.lbl4' ]
-body:
- - id: 0
- name: entry
- - id: 1
- name: entry
- - id: 2
- name: def
- - id: 3
- name: lbl1
- - id: 4
- name: lbl2
- - id: 5
- name: lbl3
- - id: 6
- name: lbl4
+body: |
+ bb.0.entry:
+
+ bb.1.entry:
+
+ bb.2.def:
+
+ bb.3.lbl1:
+
+ bb.4.lbl2:
+
+ bb.5.lbl3:
+
+ bb.6.lbl4:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/llvmIR.mir b/llvm/test/CodeGen/MIR/Generic/llvmIR.mir
index 3c084ad..c7a220a 100644
--- a/llvm/test/CodeGen/MIR/Generic/llvmIR.mir
+++ b/llvm/test/CodeGen/MIR/Generic/llvmIR.mir
@@ -32,6 +32,6 @@
...
---
name: foo
-body:
- - id: 0
+body: |
+ bb.0:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/llvmIRMissing.mir b/llvm/test/CodeGen/MIR/Generic/llvmIRMissing.mir
index 80cea5a..afa9601 100644
--- a/llvm/test/CodeGen/MIR/Generic/llvmIRMissing.mir
+++ b/llvm/test/CodeGen/MIR/Generic/llvmIRMissing.mir
@@ -4,6 +4,6 @@
---
# CHECK: name: foo
name: foo
-body:
- - id: 0
+body: |
+ bb.0:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ir-block-reference.mir b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ir-block-reference.mir
index ccbab53..d6ecd5d 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ir-block-reference.mir
+++ b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-ir-block-reference.mir
@@ -11,9 +11,7 @@
...
---
name: foo
-body:
-# CHECK: id: 0
-# CHECK: ir-block: '%ir-block.0'
- - id: 0
- ir-block: '%ir-block.0'
+body: |
+ ; CHECK: bb.0 (%ir-block.0):
+ bb.0 (%ir-block.0):
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-redefinition-error.mir b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-redefinition-error.mir
index deac3b0..4174753 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-redefinition-error.mir
+++ b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-redefinition-error.mir
@@ -10,8 +10,9 @@
...
---
name: foo
-body:
- # CHECK: redefinition of machine basic block with id #0
- - id: 0
- - id: 0
+body: |
+ ; CHECK: [[@LINE+3]]:3: redefinition of machine basic block with id #0
+ bb.0:
+
+ bb.0:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-undefined-ir-block.mir b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-undefined-ir-block.mir
index 76d561e..df559f8 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-undefined-ir-block.mir
+++ b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-undefined-ir-block.mir
@@ -9,8 +9,7 @@
...
---
name: foo
-body:
- - id: 0
-# CHECK: [[@LINE+1]]:19: use of undefined IR block '%ir-block.10'
- ir-block: '%ir-block.10'
+body: |
+ ; CHECK: [[@LINE+1]]:9: use of undefined IR block '%ir-block.10'
+ bb.0 (%ir-block.10):
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-unknown-name.mir b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-unknown-name.mir
index df8eee9..876947b 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-basic-block-unknown-name.mir
+++ b/llvm/test/CodeGen/MIR/Generic/machine-basic-block-unknown-name.mir
@@ -12,8 +12,7 @@
...
---
name: foo
-body:
- # CHECK: [[@LINE+2]]:18: basic block 'entrie' is not defined in the function 'foo'
- - id: 0
- name: entrie
+body: |
+ ; CHECK: [[@LINE+1]]:3: basic block 'entrie' is not defined in the function 'foo'
+ bb.0.entrie:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-function-missing-function.mir b/llvm/test/CodeGen/MIR/Generic/machine-function-missing-function.mir
index 424c34a..6800f87 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-function-missing-function.mir
+++ b/llvm/test/CodeGen/MIR/Generic/machine-function-missing-function.mir
@@ -12,12 +12,12 @@
...
---
name: foo
-body:
- - id: 0
+body: |
+ bb.0:
...
---
# CHECK: function 'faa' isn't defined in the provided LLVM IR
name: faa
-body:
- - id: 0
+body: |
+ bb.0:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-function-missing-name.mir b/llvm/test/CodeGen/MIR/Generic/machine-function-missing-name.mir
index a868a65..f65b778 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-function-missing-name.mir
+++ b/llvm/test/CodeGen/MIR/Generic/machine-function-missing-name.mir
@@ -16,11 +16,11 @@
---
# CHECK: [[@LINE+1]]:1: missing required key 'name'
nme: foo
-body:
- - id: 0
+body: |
+ bb.0:
...
---
name: bar
-body:
- - id: 0
+body: |
+ bb.0:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/machine-function.mir b/llvm/test/CodeGen/MIR/Generic/machine-function.mir
index afd10ab..1c4ca3d 100644
--- a/llvm/test/CodeGen/MIR/Generic/machine-function.mir
+++ b/llvm/test/CodeGen/MIR/Generic/machine-function.mir
@@ -27,8 +27,8 @@
# CHECK-NEXT: hasInlineAsm: false
# CHECK: ...
name: foo
-body:
- - id: 0
+body: |
+ bb.0:
...
---
# CHECK: name: bar
@@ -37,8 +37,8 @@
# CHECK-NEXT: hasInlineAsm: false
# CHECK: ...
name: bar
-body:
- - id: 0
+body: |
+ bb.0:
...
---
# CHECK: name: func
@@ -48,8 +48,8 @@
# CHECK: ...
name: func
alignment: 8
-body:
- - id: 0
+body: |
+ bb.0:
...
---
# CHECK: name: func2
@@ -61,6 +61,6 @@
alignment: 16
exposesReturnsTwice: true
hasInlineAsm: true
-body:
- - id: 0
+body: |
+ bb.0:
...
diff --git a/llvm/test/CodeGen/MIR/Generic/register-info.mir b/llvm/test/CodeGen/MIR/Generic/register-info.mir
index 9585faa..229cf0f 100644
--- a/llvm/test/CodeGen/MIR/Generic/register-info.mir
+++ b/llvm/test/CodeGen/MIR/Generic/register-info.mir
@@ -22,8 +22,8 @@
# CHECK-NEXT: tracksSubRegLiveness: false
# CHECK: ...
name: foo
-body:
- - id: 0
+body: |
+ bb.0:
...
---
# CHECK: name: bar
@@ -35,6 +35,6 @@
isSSA: false
tracksRegLiveness: true
tracksSubRegLiveness: true
-body:
- - id: 0
+body: |
+ bb.0:
...