brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.6 KiB · d8b1aeb Raw
85 lines · plain
1; RUN: llc < %s -mtriple=avr -mattr=avr6 | FileCheck %s2 3declare i16 @allocate(ptr, ptr)4 5; Test taking an address of an alloca with a small offset (adiw)6define i16 @alloca_addressof_small() {7entry:8; CHECK-LABEL: alloca_addressof_small:9; Test that Y is saved10; CHECK: push r2811; CHECK: push r2912; CHECK: movw r24, r2813; CHECK: adiw r24, 1714; CHECK: movw {{.*}}, r2815; CHECK: adiw {{.*}}, 3916; CHECK: movw r22, {{.*}}17; CHECK: pop r2918; CHECK: pop r2819  %p = alloca [18 x i16]20  %k = alloca [14 x i16]21  %arrayidx = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 822  %arrayidx1 = getelementptr inbounds [18 x i16], ptr %p, i16 0, i16 523  %call = call i16 @allocate(ptr %arrayidx, ptr %arrayidx1)24  ret i16 %call25}26 27; Test taking an address of an alloca with a big offset (subi/sbci pair)28define i16 @alloca_addressof_big() {29entry:30; CHECK-LABEL: alloca_addressof_big:31; CHECK: movw r24, r2832; CHECK: adiw r24, 1733; CHECK: movw r22, r2834; CHECK: subi r22, 14535; CHECK: sbci r23, 25536  %p = alloca [55 x i16]37  %k = alloca [14 x i16]38  %arrayidx = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 839  %arrayidx1 = getelementptr inbounds [55 x i16], ptr %p, i16 0, i16 4140  %call = call i16 @allocate(ptr %arrayidx, ptr %arrayidx1)41  ret i16 %call42}43 44; Test writing to an allocated variable with a small and a big offset45define i16 @alloca_write(i16 %x) {46entry:47; CHECK-LABEL: alloca_write:48; Small offset here49; CHECK: std Y+24, {{.*}}50; CHECK: std Y+23, {{.*}}51; Big offset here52; CHECK: adiw r28, 5753; CHECK: std Y+63, {{.*}}54; CHECK: std Y+62, {{.*}}55; CHECK: sbiw r28, 5756  %p = alloca [15 x i16]57  %k = alloca [14 x i16]58  %arrayidx = getelementptr inbounds [15 x i16], ptr %p, i16 0, i16 4559  store i16 22, ptr %arrayidx60  %arrayidx1 = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 1161  store i16 42, ptr %arrayidx162  %arrayidx2 = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 063  %arrayidx3 = getelementptr inbounds [15 x i16], ptr %p, i16 0, i16 064  %call = call i16 @allocate(ptr %arrayidx2, ptr %arrayidx3)65  ret i16 %call66}67 68; Test writing to an allocated variable with a huge offset that cant be69; materialized with adiw/sbiw but with a subi/sbci pair.70define void @alloca_write_huge() {71; CHECK-LABEL: alloca_write_huge:72; CHECK: subi r28, 4173; CHECK: sbci r29, 25574; CHECK: std Y+63, {{.*}}75; CHECK: std Y+62, {{.*}}76; CHECK: subi r28, 21577; CHECK: sbci r29, 078  %k = alloca [140 x i16]79  %arrayidx = getelementptr inbounds [140 x i16], ptr %k, i16 0, i16 13880  store i16 22, ptr %arrayidx81  %arraydecay = getelementptr inbounds [140 x i16], ptr %k, i16 0, i16 082  call i16 @allocate(ptr %arraydecay, ptr null)83  ret void84}85