blob: 431d3201dc8955b24dfe7904526b25c466b7d821 [file] [log] [blame]
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -verify-machineinstrs -csky-no-aliases < %s -mtriple=csky -mattr=+2e3 | FileCheck %s
; RUN: llc -verify-machineinstrs -csky-no-aliases < %s -mtriple=csky -relocation-model=pic -code-model=small -mattr=+2e3 | FileCheck %s --check-prefix=CHECK-PIC-SMALL
; RUN: llc -verify-machineinstrs -csky-no-aliases < %s -mtriple=csky -relocation-model=pic -code-model=large -mattr=+2e3 | FileCheck %s --check-prefix=CHECK-PIC-LARGE
@f.a = private unnamed_addr constant [2 x i8*] [i8* blockaddress(@f, %return), i8* blockaddress(@f, %l2)], align 16
define i32 @f(i32 %x) #0 {
; CHECK-LABEL: f:
; CHECK: # %bb.0: # %entry
; CHECK-NEXT: lrw32 a1, [.LCPI0_0]
; CHECK-NEXT: ldr32.w a0, (a1, a0 << 2)
; CHECK-NEXT: jmp32 a0
; CHECK-NEXT: .Ltmp0: # Block address taken
; CHECK-NEXT: .LBB0_1: # %return
; CHECK-NEXT: movi16 a0, 1
; CHECK-NEXT: rts16
; CHECK-NEXT: .Ltmp1: # Block address taken
; CHECK-NEXT: .LBB0_2: # %l2
; CHECK-NEXT: movi16 a0, 2
; CHECK-NEXT: rts16
; CHECK-NEXT: .p2align 1
; CHECK-NEXT: # %bb.3:
; CHECK-NEXT: .p2align 2
; CHECK-NEXT: .LCPI0_0:
; CHECK-NEXT: .long .Lf.a
;
; CHECK-PIC-SMALL-LABEL: f:
; CHECK-PIC-SMALL: # %bb.0: # %entry
; CHECK-PIC-SMALL-NEXT: subi16 sp, sp, 4
; CHECK-PIC-SMALL-NEXT: .cfi_def_cfa_offset 4
; CHECK-PIC-SMALL-NEXT: st32.w rgb, (sp, 0) # 4-byte Folded Spill
; CHECK-PIC-SMALL-NEXT: .cfi_offset rgb, -4
; CHECK-PIC-SMALL-NEXT: .cfi_def_cfa_offset 4
; CHECK-PIC-SMALL-NEXT: lrw32 rgb, [.LCPI0_0]
; CHECK-PIC-SMALL-NEXT: lrw32 a1, [.LCPI0_1]
; CHECK-PIC-SMALL-NEXT: addu32 a1, rgb, a1
; CHECK-PIC-SMALL-NEXT: ldr32.w a0, (a1, a0 << 2)
; CHECK-PIC-SMALL-NEXT: jmp32 a0
; CHECK-PIC-SMALL-NEXT: .Ltmp0: # Block address taken
; CHECK-PIC-SMALL-NEXT: .LBB0_1: # %return
; CHECK-PIC-SMALL-NEXT: movi16 a0, 1
; CHECK-PIC-SMALL-NEXT: br32 .LBB0_3
; CHECK-PIC-SMALL-NEXT: .Ltmp1: # Block address taken
; CHECK-PIC-SMALL-NEXT: .LBB0_2: # %l2
; CHECK-PIC-SMALL-NEXT: movi16 a0, 2
; CHECK-PIC-SMALL-NEXT: .LBB0_3: # %.split
; CHECK-PIC-SMALL-NEXT: ld32.w rgb, (sp, 0) # 4-byte Folded Reload
; CHECK-PIC-SMALL-NEXT: addi16 sp, sp, 4
; CHECK-PIC-SMALL-NEXT: rts16
; CHECK-PIC-SMALL-NEXT: .p2align 1
; CHECK-PIC-SMALL-NEXT: # %bb.4:
; CHECK-PIC-SMALL-NEXT: .p2align 2
; CHECK-PIC-SMALL-NEXT: .LCPI0_0:
; CHECK-PIC-SMALL-NEXT: .long _GLOBAL_OFFSET_TABLE_
; CHECK-PIC-SMALL-NEXT: .LCPI0_1:
; CHECK-PIC-SMALL-NEXT: .long .Lf.a@GOTOFF
;
; CHECK-PIC-LARGE-LABEL: f:
; CHECK-PIC-LARGE: # %bb.0: # %entry
; CHECK-PIC-LARGE-NEXT: subi16 sp, sp, 4
; CHECK-PIC-LARGE-NEXT: .cfi_def_cfa_offset 4
; CHECK-PIC-LARGE-NEXT: st32.w rgb, (sp, 0) # 4-byte Folded Spill
; CHECK-PIC-LARGE-NEXT: .cfi_offset rgb, -4
; CHECK-PIC-LARGE-NEXT: .cfi_def_cfa_offset 4
; CHECK-PIC-LARGE-NEXT: lrw32 rgb, [.LCPI0_0]
; CHECK-PIC-LARGE-NEXT: lrw32 a1, [.LCPI0_1]
; CHECK-PIC-LARGE-NEXT: addu32 a1, rgb, a1
; CHECK-PIC-LARGE-NEXT: ldr32.w a0, (a1, a0 << 2)
; CHECK-PIC-LARGE-NEXT: jmp32 a0
; CHECK-PIC-LARGE-NEXT: .Ltmp0: # Block address taken
; CHECK-PIC-LARGE-NEXT: .LBB0_1: # %return
; CHECK-PIC-LARGE-NEXT: movi16 a0, 1
; CHECK-PIC-LARGE-NEXT: br32 .LBB0_3
; CHECK-PIC-LARGE-NEXT: .Ltmp1: # Block address taken
; CHECK-PIC-LARGE-NEXT: .LBB0_2: # %l2
; CHECK-PIC-LARGE-NEXT: movi16 a0, 2
; CHECK-PIC-LARGE-NEXT: .LBB0_3: # %.split
; CHECK-PIC-LARGE-NEXT: ld32.w rgb, (sp, 0) # 4-byte Folded Reload
; CHECK-PIC-LARGE-NEXT: addi16 sp, sp, 4
; CHECK-PIC-LARGE-NEXT: rts16
; CHECK-PIC-LARGE-NEXT: .p2align 1
; CHECK-PIC-LARGE-NEXT: # %bb.4:
; CHECK-PIC-LARGE-NEXT: .p2align 2
; CHECK-PIC-LARGE-NEXT: .LCPI0_0:
; CHECK-PIC-LARGE-NEXT: .long _GLOBAL_OFFSET_TABLE_
; CHECK-PIC-LARGE-NEXT: .LCPI0_1:
; CHECK-PIC-LARGE-NEXT: .long .Lf.a@GOTOFF
entry:
%idxprom = sext i32 %x to i64
%arrayidx = getelementptr inbounds [2 x i8*], [2 x i8*]* @f.a, i64 0, i64 %idxprom
%0 = load i8*, i8** %arrayidx, align 8
indirectbr i8* %0, [label %return, label %l2]
l2: ; preds = %entry
br label %return
return: ; preds = %entry, %l2
%retval.0 = phi i32 [ 2, %l2 ], [ 1, %entry ]
ret i32 %retval.0
}