1# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s 2# This test ensures that the MIR parser parses the jump table info and jump 3# table operands correctly. 4 5--- | 6 7 define i32 @test_jumptable(i32 %in) { 8 entry: 9 switch i32 %in, label %def [ 10 i32 0, label %lbl1 11 i32 1, label %lbl2 12 i32 2, label %lbl3 13 i32 3, label %lbl4 14 ] 15 16 def: 17 ret i32 0 18 19 lbl1: 20 ret i32 1 21 22 lbl2: 23 ret i32 2 24 25 lbl3: 26 ret i32 4 27 28 lbl4: 29 ret i32 8 30 } 31 32 define i32 @test_jumptable2(i32 %in) { 33 entry: 34 switch i32 %in, label %def [ 35 i32 0, label %lbl1 36 i32 1, label %lbl2 37 i32 2, label %lbl3 38 i32 3, label %lbl4 39 ] 40 41 def: 42 ret i32 0 43 44 lbl1: 45 ret i32 1 46 47 lbl2: 48 ret i32 2 49 50 lbl3: 51 ret i32 4 52 53 lbl4: 54 ret i32 8 55 } 56 57... 58--- 59name: test_jumptable 60# CHECK: jumpTable: 61# CHECK-NEXT: kind: label-difference32 62# CHECK-NEXT: entries: 63# CHECK-NEXT: - id: 0 64# CHECK-NEXT: blocks: [ '%bb.3', '%bb.4', '%bb.5', '%bb.6' ] 65# CHECK-NEXT: body: 66jumpTable: 67 kind: label-difference32 68 entries: 69 - id: 0 70 blocks: [ '%bb.3', '%bb.4', '%bb.5', '%bb.6' ] 71body: | 72 bb.0.entry: 73 successors: %bb.2, %bb.1 74 75 $eax = MOV32rr $edi, implicit-def $rax 76 CMP32ri8 $edi, 3, implicit-def $eflags 77 JA_1 %bb.2, implicit $eflags 78 79 bb.1.entry: 80 successors: %bb.3, %bb.4, %bb.5, %bb.6 81 ; CHECK: $rcx = LEA64r $rip, 1, $noreg, %jump-table.0, $noreg 82 $rcx = LEA64r $rip, 1, _, %jump-table.0, _ 83 $rax = MOVSX64rm32 $rcx, 4, $rax, 0, _ 84 $rax = ADD64rr $rax, $rcx, implicit-def $eflags 85 JMP64r $rax 86 87 bb.2.def: 88 $eax = MOV32r0 implicit-def $eflags 89 RETQ $eax 90 91 bb.3.lbl1: 92 $eax = MOV32ri 1 93 RETQ $eax 94 95 bb.4.lbl2: 96 $eax = MOV32ri 2 97 RETQ $eax 98 99 bb.5.lbl3: 100 $eax = MOV32ri 4 101 RETQ $eax 102 103 bb.6.lbl4: 104 $eax = MOV32ri 8 105 RETQ $eax 106... 107--- 108name: test_jumptable2 109jumpTable: 110 kind: label-difference32 111 entries: 112 - id: 1 113 blocks: [ '%bb.3', '%bb.4', '%bb.5', '%bb.6' ] 114body: | 115 bb.0.entry: 116 successors: %bb.2, %bb.1 117 118 $eax = MOV32rr $edi, implicit-def $rax 119 CMP32ri8 $edi, 3, implicit-def $eflags 120 JA_1 %bb.2, implicit $eflags 121 122 bb.1.entry: 123 successors: %bb.3, %bb.4, %bb.5, %bb.6 124 ; Verify that the printer will use an id of 0 for this jump table: 125 ; CHECK: $rcx = LEA64r $rip, 1, $noreg, %jump-table.0, $noreg 126 $rcx = LEA64r $rip, 1, _, %jump-table.1, _ 127 $rax = MOVSX64rm32 $rcx, 4, $rax, 0, _ 128 $rax = ADD64rr $rax, $rcx, implicit-def $eflags 129 JMP64r $rax 130 131 bb.2.def: 132 $eax = MOV32r0 implicit-def $eflags 133 RETQ $eax 134 135 bb.3.lbl1: 136 $eax = MOV32ri 1 137 RETQ $eax 138 139 bb.4.lbl2: 140 $eax = MOV32ri 2 141 RETQ $eax 142 143 bb.5.lbl3: 144 $eax = MOV32ri 4 145 RETQ $eax 146 147 bb.6.lbl4: 148 $eax = MOV32ri 8 149 RETQ $eax 150... 151