Home | History | Annotate | Download | only in AArch64
      1 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s
      2 ; RUN: llc -code-model=large -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu | FileCheck --check-prefix=CHECK-LARGE %s
      3 ; RUN: llc -verify-machineinstrs < %s -mtriple=aarch64-none-linux-gnu -filetype=obj | llvm-readobj -r | FileCheck %s -check-prefix=CHECK-ELF
      4 
      5 define i32 @test_jumptable(i32 %in) {
      6 ; CHECK: test_jumptable
      7 
      8   switch i32 %in, label %def [
      9     i32 0, label %lbl1
     10     i32 1, label %lbl2
     11     i32 2, label %lbl3
     12     i32 4, label %lbl4
     13   ]
     14 ; CHECK: adrp [[JTPAGE:x[0-9]+]], .LJTI0_0
     15 ; CHECK: add x[[JT:[0-9]+]], [[JTPAGE]], #:lo12:.LJTI0_0
     16 ; CHECK: ldr [[DEST:x[0-9]+]], [x[[JT]], {{x[0-9]+}}, lsl #3]
     17 ; CHECK: br [[DEST]]
     18 
     19 ; CHECK-LARGE: movz x[[JTADDR:[0-9]+]], #:abs_g3:.LJTI0_0
     20 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g2_nc:.LJTI0_0
     21 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g1_nc:.LJTI0_0
     22 ; CHECK-LARGE: movk x[[JTADDR]], #:abs_g0_nc:.LJTI0_0
     23 ; CHECK-LARGE: ldr [[DEST:x[0-9]+]], [x[[JTADDR]], {{x[0-9]+}}, lsl #3]
     24 ; CHECK-LARGE: br [[DEST]]
     25 
     26 def:
     27   ret i32 0
     28 
     29 lbl1:
     30   ret i32 1
     31 
     32 lbl2:
     33   ret i32 2
     34 
     35 lbl3:
     36   ret i32 4
     37 
     38 lbl4:
     39   ret i32 8
     40 
     41 }
     42 
     43 ; CHECK: .rodata
     44 
     45 ; CHECK: .LJTI0_0:
     46 ; CHECK-NEXT: .xword
     47 ; CHECK-NEXT: .xword
     48 ; CHECK-NEXT: .xword
     49 ; CHECK-NEXT: .xword
     50 ; CHECK-NEXT: .xword
     51 
     52 ; ELF tests:
     53 
     54 ; First make sure we get a page/lo12 pair in .text to pick up the jump-table
     55 
     56 ; CHECK-ELF:      Relocations [
     57 ; CHECK-ELF:        Section ({{[0-9]+}}) .rela.text {
     58 ; CHECK-ELF-NEXT:     0x{{[0-9,A-F]+}} R_AARCH64_ADR_PREL_PG_HI21 .rodata
     59 ; CHECK-ELF-NEXT:     0x{{[0-9,A-F]+}} R_AARCH64_ADD_ABS_LO12_NC .rodata
     60 ; CHECK-ELF:        }
     61 
     62 ; Also check the targets in .rodata are relocated
     63 ; CHECK-ELF:        Section ({{[0-9]+}}) .rela.rodata {
     64 ; CHECK-ELF-NEXT:     0x{{[0-9,A-F]+}} R_AARCH64_ABS64 .text
     65 ; CHECK-ELF:        }
     66 ; CHECK-ELF:      ]
     67