1; NOTE: This test case generates a jump table on PowerPC big and little endian 2; NOTE: then verifies that the command line option to enable absolute jump 3; NOTE: table works correctly. 4; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 5; RUN: -ppc-use-absolute-jumptables -ppc-asm-full-reg-names \ 6; RUN: -verify-machineinstrs %s | FileCheck %s -check-prefix=CHECK-LE 7; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 8; RUN: -ppc-use-absolute-jumptables -ppc-asm-full-reg-names \ 9; RUN: -verify-machineinstrs %s | FileCheck %s -check-prefix=CHECK-BE 10; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-min-jump-table-entries=4 -o - \ 11; RUN: -ppc-use-absolute-jumptables -ppc-asm-full-reg-names \ 12; RUN: -verify-machineinstrs %s | FileCheck %s -check-prefix=CHECK-AIX 13; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 14; RUN: -ppc-use-absolute-jumptables=true --relocation-model=pic < %s | FileCheck %s \ 15; RUN: -check-prefix=CHECK-A-PIC-LE 16; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 17; RUN: -ppc-use-absolute-jumptables=false --relocation-model=pic < %s | FileCheck %s \ 18; RUN: -check-prefix=CHECK-R-PIC-LE 19; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 20; RUN: -ppc-use-absolute-jumptables=true --relocation-model=pic < %s | FileCheck %s \ 21; RUN: -check-prefix=CHECK-A-PIC-BE 22; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 23; RUN: -ppc-use-absolute-jumptables=false --relocation-model=pic < %s | FileCheck %s \ 24; RUN: -check-prefix=CHECK-R-PIC-BE 25; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-min-jump-table-entries=4 -o - \ 26; RUN: -ppc-use-absolute-jumptables=true --relocation-model=pic < %s | FileCheck %s \ 27; RUN: -check-prefix=CHECK-A-PIC-AIX 28; RUN: llc -mtriple=powerpc64-ibm-aix-xcoff -ppc-min-jump-table-entries=4 -o - \ 29; RUN: -ppc-use-absolute-jumptables=false --relocation-model=pic < %s | FileCheck %s \ 30; RUN: -check-prefix=CHECK-R-PIC-AIX 31; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 32; RUN: -ppc-use-absolute-jumptables=true --relocation-model=static < %s | FileCheck %s \ 33; RUN: -check-prefix=CHECK-A-STATIC-LE 34; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 35; RUN: -ppc-use-absolute-jumptables=false --relocation-model=static < %s | FileCheck %s \ 36; RUN: -check-prefix=CHECK-R-STATIC-LE 37; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 38; RUN: -ppc-use-absolute-jumptables=true --relocation-model=static < %s | FileCheck %s \ 39; RUN: -check-prefix=CHECK-A-STATIC-BE 40; RUN: llc -mtriple=powerpc64-unknown-linux-gnu -ppc-min-jump-table-entries=4 -o - \ 41; RUN: -ppc-use-absolute-jumptables=false --relocation-model=static < %s | FileCheck %s \ 42; RUN: -check-prefix=CHECK-R-STATIC-BE 43 44%struct.node = type { i8, ptr } 45 46; Function Attrs: norecurse nounwind readonly 47define zeroext i32 @jumpTableTest(ptr readonly %list) { 48; CHECK-LE-LABEL: jumpTableTest: 49; CHECK-LE: # %bb.0: # %entry 50; CHECK-LE: rldic r[[REG:[0-9]+]], r[[REG]], 3, 29 51; CHECK-LE: ldx r[[REG]], r[[REG]], r[[REG1:[0-9]+]] 52; CHECK-LE: mtctr r[[REG]] 53; CHECK-LE: bctr 54; CHECK-LE: blr 55; 56; CHECK-BE-LABEL: jumpTableTest: 57; CHECK-BE: # %bb.0: # %entry 58; CHECK-BE: rldic r[[REG:[0-9]+]], r[[REG]], 2, 30 59; CHECK-BE: lwax r[[REG]], r[[REG]], r[[REG1:[0-9]+]] 60; CHECK-BE: mtctr r[[REG]] 61; CHECK-BE: bctr 62; CHECK-BE: blr 63; 64; CHECK-AIX-LABEL: jumpTableTest: 65; CHECK-AIX: # %bb.0: # %entry 66; CHECK-AIX: rldic r[[REG:[0-9]+]], r[[REG]], 2, 30 67; CHECK-AIX: lwax r[[REG]], r[[REG]], r[[REG1:[0-9]+]] 68; CHECK-AIX: mtctr r[[REG]] 69; CHECK-AIX: bctr 70; CHECK-AIX: blr 71; 72; CHECK-A-PIC-LE-LABEL: .LJTI0_0: 73; CHECK-A-PIC-LE: .long .LBB0_6-.LJTI0_0 74; 75; CHECK-R-PIC-LE-LABEL: .LJTI0_0: 76; CHECK-R-PIC-LE: .long .LBB0_6-.LJTI0_0 77; 78; CHECK-A-PIC-BE-LABEL: .LJTI0_0: 79; CHECK-A-PIC-BE: .long .LBB0_9-.LJTI0_0 80; 81; CHECK-R-PIC-BE-LABEL: .LJTI0_0: 82; CHECK-R-PIC-BE: .long .LBB0_9-.LJTI0_0 83; 84; CHECK-A-PIC-AIX-LABEL: L..JTI0_0: 85; CHECK-A-PIC-AIX: .vbyte 4, L..BB0_9-L..JTI0_0 86; 87; CHECK-R-PIC-AIX-LABEL: L..JTI0_0: 88; CHECK-R-PIC-AIX: .vbyte 4, L..BB0_9-L..JTI0_0 89; 90; CHECK-A-STATIC-LE-LABEL: .LJTI0_0: 91; CHECK-A-STATIC-LE: .quad .LBB0_6 92; 93; CHECK-R-STATIC-LE-LABEL: .LJTI0_0: 94; CHECK-R-STATIC-LE: .long .LBB0_6-.LJTI0_0 95; 96; CHECK-A-STATIC-BE-LABEL: .LJTI0_0: 97; CHECK-A-STATIC-BE: .quad .LBB0_9 98; 99; CHECK-R-STATIC-BE-LABEL: .LJTI0_0: 100; CHECK-R-STATIC-BE: .long .LBB0_9-.LJTI0_0 101entry: 102 %cmp36 = icmp eq ptr %list, null 103 br i1 %cmp36, label %while.end, label %while.body 104 105while.body: ; preds = %entry, %sw.epilog 106 %result.038 = phi i32 [ %result.1, %sw.epilog ], [ 0, %entry ] 107 %current.037 = phi ptr [ %spec.store.select, %sw.epilog ], [ %list, %entry ] 108 %next1 = getelementptr inbounds %struct.node, ptr %current.037, i64 0, i32 1 109 %0 = load ptr, ptr %next1, align 8 110 %cmp2 = icmp eq ptr %0, %current.037 111 %spec.store.select = select i1 %cmp2, ptr null, ptr %0 112 %1 = load i8, ptr %current.037, align 8 113 switch i8 %1, label %sw.epilog [ 114 i8 1, label %sw.bb 115 i8 2, label %sw.bb3 116 i8 3, label %sw.bb5 117 i8 4, label %sw.bb7 118 i8 5, label %sw.bb9 119 i8 6, label %sw.bb11 120 i8 7, label %sw.bb13 121 i8 8, label %sw.bb15 122 i8 9, label %sw.bb17 123 ] 124 125sw.bb: ; preds = %while.body 126 %add = add nsw i32 %result.038, 13 127 br label %sw.epilog 128 129sw.bb3: ; preds = %while.body 130 %add4 = add nsw i32 %result.038, 5 131 br label %sw.epilog 132 133sw.bb5: ; preds = %while.body 134 %add6 = add nsw i32 %result.038, 2 135 br label %sw.epilog 136 137sw.bb7: ; preds = %while.body 138 %add8 = add nsw i32 %result.038, 7 139 br label %sw.epilog 140 141sw.bb9: ; preds = %while.body 142 %add10 = add nsw i32 %result.038, 11 143 br label %sw.epilog 144 145sw.bb11: ; preds = %while.body 146 %add12 = add nsw i32 %result.038, 17 147 br label %sw.epilog 148 149sw.bb13: ; preds = %while.body 150 %add14 = add nsw i32 %result.038, 16 151 br label %sw.epilog 152 153sw.bb15: ; preds = %while.body 154 %add16 = add nsw i32 %result.038, 81 155 br label %sw.epilog 156 157sw.bb17: ; preds = %while.body 158 %add18 = add nsw i32 %result.038, 72 159 br label %sw.epilog 160 161sw.epilog: ; preds = %while.body, %sw.bb17, %sw.bb15, %sw.bb13, %sw.bb11, %sw.bb9, %sw.bb7, %sw.bb5, %sw.bb3, %sw.bb 162 %result.1 = phi i32 [ %result.038, %while.body ], [ %add18, %sw.bb17 ], [ %add16, %sw.bb15 ], [ %add14, %sw.bb13 ], [ %add12, %sw.bb11 ], [ %add10, %sw.bb9 ], [ %add8, %sw.bb7 ], [ %add6, %sw.bb5 ], [ %add4, %sw.bb3 ], [ %add, %sw.bb ] 163 %cmp = icmp eq ptr %spec.store.select, null 164 br i1 %cmp, label %while.end, label %while.body 165 166while.end: ; preds = %sw.epilog, %entry 167 %result.0.lcssa = phi i32 [ 0, %entry ], [ %result.1, %sw.epilog ] 168 ret i32 %result.0.lcssa 169} 170 171