1 2; RUN: not llc < %s -march=xcore -code-model=medium 2>&1 | FileCheck %s -check-prefix=BAD_CM 3; RUN: not llc < %s -march=xcore -code-model=kernel 2>&1 | FileCheck %s -check-prefix=BAD_CM 4; BAD_CM: Target only supports CodeModel Small or Large 5 6 7; RUN: llc < %s -march=xcore -code-model=default | FileCheck %s 8; RUN: llc < %s -march=xcore -code-model=small | FileCheck %s 9; RUN: llc < %s -march=xcore -code-model=large | FileCheck %s -check-prefix=LARGE 10 11 12; CHECK-LABEL: test: 13; CHECK: zext r0, 1 14; CHECK: bt r0, [[JUMP:.LBB[0-9_]*]] 15; CHECK: ldaw r0, dp[A2] 16; CHECK: retsp 0 17; CHECK: [[JUMP]] 18; CHECK: ldaw r0, dp[A1] 19; CHECK: retsp 0 20; LARGE-LABEL: test: 21; LARGE: zext r0, 1 22; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}] 23; LARGE: mov r1, r11 24; LARGE: ldaw r11, cp[.LCPI{{[0-9_]*}}] 25; LARGE: bt r0, [[JUMP:.LBB[0-9_]*]] 26; LARGE: mov r11, r1 27; LARGE: [[JUMP]] 28; LARGE: ldw r0, r11[0] 29; LARGE: retsp 0 30@A1 = external global [50000 x i32] 31@A2 = external global [50000 x i32] 32define [50000 x i32]* @test(i1 %bool) nounwind { 33entry: 34 %Addr = select i1 %bool, [50000 x i32]* @A1, [50000 x i32]* @A2 35 ret [50000 x i32]* %Addr 36} 37 38 39; CHECK: .section .cp.rodata.cst4,"aMc",@progbits,4 40; CHECK: .long 65536 41; CHECK: .text 42; CHECK-LABEL: f: 43; CHECK: ldc r1, 65532 44; CHECK: add r1, r0, r1 45; CHECK: ldw r1, r1[0] 46; CHECK: ldw r2, cp[.LCPI{{[0-9_]*}}] 47; CHECK: add r0, r0, r2 48; CHECK: ldw r0, r0[0] 49; CHECK: add r0, r1, r0 50; CHECK: ldw r1, dp[l] 51; CHECK: add r0, r0, r1 52; CHECK: ldw r1, dp[l+4] 53; CHECK: add r0, r0, r1 54; CHECK: ldw r1, dp[l+392] 55; CHECK: add r0, r0, r1 56; CHECK: ldw r1, dp[l+396] 57; CHECK: add r0, r0, r1 58; CHECK: ldw r1, dp[s] 59; CHECK: add r0, r0, r1 60; CHECK: ldw r1, dp[s+36] 61; CHECK: add r0, r0, r1 62; CHECK: retsp 0 63; 64; LARGE: .section .cp.rodata.cst4,"aMc",@progbits,4 65; LARGE: .long 65536 66; LARGE: .section .cp.rodata,"ac",@progbits 67; LARGE: .long l 68; LARGE: .long l+4 69; LARGE: .long l+392 70; LARGE: .long l+396 71; LARGE: .text 72; LARGE-LABEL: f: 73; LARGE: ldc r1, 65532 74; LARGE: add r1, r0, r1 75; LARGE: ldw r1, r1[0] 76; LARGE: ldw r2, cp[.LCPI{{[0-9_]*}}] 77; LARGE: add r0, r0, r2 78; LARGE: ldw r0, r0[0] 79; LARGE: add r0, r1, r0 80; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}] 81; LARGE: ldw r1, r1[0] 82; LARGE: add r0, r0, r1 83; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}] 84; LARGE: ldw r1, r1[0] 85; LARGE: add r0, r0, r1 86; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}] 87; LARGE: ldw r1, r1[0] 88; LARGE: add r0, r0, r1 89; LARGE: ldw r1, cp[.LCPI{{[0-9_]*}}] 90; LARGE: ldw r1, r1[0] 91; LARGE: add r0, r0, r1 92; LARGE: ldw r1, dp[s] 93; LARGE: add r0, r0, r1 94; LARGE: ldw r1, dp[s+36] 95; LARGE: add r0, r0, r1 96; LARGE: retsp 0 97define i32 @f(i32* %i) { 98entry: 99 %0 = getelementptr inbounds i32, i32* %i, i32 16383 100 %1 = load i32, i32* %0 101 %2 = getelementptr inbounds i32, i32* %i, i32 16384 102 %3 = load i32, i32* %2 103 %4 = add nsw i32 %1, %3 104 %5 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 0) 105 %6 = add nsw i32 %4, %5 106 %7 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 1) 107 %8 = add nsw i32 %6, %7 108 %9 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 98) 109 %10 = add nsw i32 %8, %9 110 %11 = load i32, i32* getelementptr inbounds ([100 x i32], [100 x i32]* @l, i32 0, i32 99) 111 %12 = add nsw i32 %10, %11 112 %13 = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @s, i32 0, i32 0) 113 %14 = add nsw i32 %12, %13 114 %15 = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @s, i32 0, i32 9) 115 %16 = add nsw i32 %14, %15 116 ret i32 %16 117} 118 119 120; CHECK-LABEL: UnknownSize: 121; CHECK: ldw r0, dp[NoSize+40] 122; CHECK-NEXT: retsp 0 123; 124; LARGE: .section .cp.rodata,"ac",@progbits 125; LARGE: .LCPI{{[0-9_]*}} 126; LARGE-NEXT: .long NoSize 127; LARGE-NEXT: .text 128; LARGE-LABEL: UnknownSize: 129; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}] 130; LARGE-NEXT: ldw r0, r0[0] 131; LARGE-NEXT: retsp 0 132@NoSize = external global [0 x i32] 133define i32 @UnknownSize() nounwind { 134entry: 135 %0 = load i32, i32* getelementptr inbounds ([0 x i32], [0 x i32]* @NoSize, i32 0, i32 10) 136 ret i32 %0 137} 138 139 140; CHECK-LABEL: UnknownStruct: 141; CHECK: ldaw r0, dp[Unknown] 142; CHECK-NEXT: retsp 0 143; 144; LARGE: .section .cp.rodata,"ac",@progbits 145; LARGE: .LCPI{{[0-9_]*}} 146; LARGE-NEXT: .long Unknown 147; LARGE-NEXT: .text 148; LARGE-LABEL: UnknownStruct: 149; LARGE: ldw r0, cp[.LCPI{{[0-9_]*}}] 150; LARGE-NEXT: retsp 0 151%Struct = type opaque 152@Unknown = external global %Struct 153define %Struct* @UnknownStruct() nounwind { 154entry: 155 ret %Struct* @Unknown 156} 157 158 159; CHECK: .section .dp.bss,"awd",@nobits 160; CHECK-LABEL: l: 161; CHECK: .space 400 162; LARGE: .section .dp.bss.large,"awd",@nobits 163; LARGE-LABEL: l: 164; LARGE: .space 400 165@l = global [100 x i32] zeroinitializer 166 167; CHECK-LABEL: s: 168; CHECK: .space 40 169; LARGE: .section .dp.bss,"awd",@nobits 170; LARGE-LABEL: s: 171; LARGE: .space 40 172@s = global [10 x i32] zeroinitializer 173 174; CHECK: .section .dp.rodata,"awd",@progbits 175; CHECK-LABEL: cl: 176; CHECK: .space 400 177; LARGE: .section .dp.rodata.large,"awd",@progbits 178; LARGE-LABEL: cl: 179; LARGE: .space 400 180@cl = constant [100 x i32] zeroinitializer 181 182; CHECK-LABEL: cs: 183; CHECK: .space 40 184; LARGE: .section .dp.rodata,"awd",@progbits 185; LARGE-LABEL: cs: 186; LARGE: .space 40 187@cs = constant [10 x i32] zeroinitializer 188 189; CHECK: .section .cp.rodata,"ac",@progbits 190; CHECK-LABEL: icl: 191; CHECK: .space 400 192; LARGE: .section .cp.rodata.large,"ac",@progbits 193; LARGE-LABEL: icl: 194; LARGE: .space 400 195@icl = internal constant [100 x i32] zeroinitializer 196 197; CHECK-LABEL: cs: 198; CHECK: .space 40 199; LARGE: .section .cp.rodata,"ac",@progbits 200; LARGE-LABEL: cs: 201; LARGE: .space 40 202@ics = internal constant [10 x i32] zeroinitializer 203 204; CHECK: .section .cp.namedsection,"ac",@progbits 205; CHECK-LABEL: cpsec: 206; CHECK: .long 0 207@cpsec = constant i32 0, section ".cp.namedsection" 208 209; CHECK: .section .dp.namedsection,"awd",@progbits 210; CHECK-LABEL: dpsec: 211; CHECK: .long 0 212@dpsec = global i32 0, section ".dp.namedsection" 213 214