Files
TheRock/compiler/amd-llvm/llvm/test/CodeGen/AVR/alloca.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

85 lines
2.6 KiB
LLVM

; RUN: llc < %s -mtriple=avr -mattr=avr6 | FileCheck %s
declare i16 @allocate(ptr, ptr)
; Test taking an address of an alloca with a small offset (adiw)
define i16 @alloca_addressof_small() {
entry:
; CHECK-LABEL: alloca_addressof_small:
; Test that Y is saved
; CHECK: push r28
; CHECK: push r29
; CHECK: movw r24, r28
; CHECK: adiw r24, 17
; CHECK: movw {{.*}}, r28
; CHECK: adiw {{.*}}, 39
; CHECK: movw r22, {{.*}}
; CHECK: pop r29
; CHECK: pop r28
%p = alloca [18 x i16]
%k = alloca [14 x i16]
%arrayidx = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 8
%arrayidx1 = getelementptr inbounds [18 x i16], ptr %p, i16 0, i16 5
%call = call i16 @allocate(ptr %arrayidx, ptr %arrayidx1)
ret i16 %call
}
; Test taking an address of an alloca with a big offset (subi/sbci pair)
define i16 @alloca_addressof_big() {
entry:
; CHECK-LABEL: alloca_addressof_big:
; CHECK: movw r24, r28
; CHECK: adiw r24, 17
; CHECK: movw r22, r28
; CHECK: subi r22, 145
; CHECK: sbci r23, 255
%p = alloca [55 x i16]
%k = alloca [14 x i16]
%arrayidx = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 8
%arrayidx1 = getelementptr inbounds [55 x i16], ptr %p, i16 0, i16 41
%call = call i16 @allocate(ptr %arrayidx, ptr %arrayidx1)
ret i16 %call
}
; Test writing to an allocated variable with a small and a big offset
define i16 @alloca_write(i16 %x) {
entry:
; CHECK-LABEL: alloca_write:
; Small offset here
; CHECK: std Y+24, {{.*}}
; CHECK: std Y+23, {{.*}}
; Big offset here
; CHECK: adiw r28, 57
; CHECK: std Y+63, {{.*}}
; CHECK: std Y+62, {{.*}}
; CHECK: sbiw r28, 57
%p = alloca [15 x i16]
%k = alloca [14 x i16]
%arrayidx = getelementptr inbounds [15 x i16], ptr %p, i16 0, i16 45
store i16 22, ptr %arrayidx
%arrayidx1 = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 11
store i16 42, ptr %arrayidx1
%arrayidx2 = getelementptr inbounds [14 x i16], ptr %k, i16 0, i16 0
%arrayidx3 = getelementptr inbounds [15 x i16], ptr %p, i16 0, i16 0
%call = call i16 @allocate(ptr %arrayidx2, ptr %arrayidx3)
ret i16 %call
}
; Test writing to an allocated variable with a huge offset that cant be
; materialized with adiw/sbiw but with a subi/sbci pair.
define void @alloca_write_huge() {
; CHECK-LABEL: alloca_write_huge:
; CHECK: subi r28, 41
; CHECK: sbci r29, 255
; CHECK: std Y+63, {{.*}}
; CHECK: std Y+62, {{.*}}
; CHECK: subi r28, 215
; CHECK: sbci r29, 0
%k = alloca [140 x i16]
%arrayidx = getelementptr inbounds [140 x i16], ptr %k, i16 0, i16 138
store i16 22, ptr %arrayidx
%arraydecay = getelementptr inbounds [140 x i16], ptr %k, i16 0, i16 0
call i16 @allocate(ptr %arraydecay, ptr null)
ret void
}