xref: /llvm-project/llvm/test/CodeGen/AVR/sections.ll (revision 5712e293fb317b50166766ba86b969eb13fcd069)
1; RUN: llc < %s -mtriple=avr --mcpu=atxmega384d3 \
2; RUN:     | FileCheck --check-prefixes=CHECK,NOSECTIONS %s
3; RUN: llc -function-sections -data-sections < %s -mtriple=avr --mcpu=atxmega384d3 \
4; RUN:     | FileCheck --check-prefixes=CHECK,SECTIONS %s
5; RUN: not llc -function-sections -data-sections < %s -mtriple=avr --mcpu=at90s8515 2>&1 \
6; RUN:     | FileCheck --check-prefixes=CHECK-8515 %s
7; RUN: not llc -function-sections -data-sections < %s -mtriple=avr --mcpu=attiny40 2>&1 \
8; RUN:     | FileCheck --check-prefixes=CHECK-tiny40 %s
9
10; Test that functions (in address space 1) are not considered .progmem data.
11
12; SECTIONS: .text.somefunc,"ax",@progbits
13; CHECK-LABEL: somefunc:
14define void @somefunc() addrspace(1) {
15  ret void
16}
17
18
19; Test whether global variables are placed in the correct section.
20
21; Note: avr-gcc would place this global in .progmem.data.flash with
22; -fdata-sections. The AVR backend does not yet respect -fdata-sections in this
23; case.
24
25; CHECK: .section .progmem.data,"a",@progbits
26; CHECK-LABEL: flash:
27@flash = addrspace(1) constant i16 3
28
29; CHECK: .section .progmem1.data,"a",@progbits
30; CHECK-LABEL: flash1:
31; CHECK-8515: error: Current AVR subtarget does not support accessing extended program memory
32; CHECK-tiny40: error: Current AVR subtarget does not support accessing program memory
33@flash1 = addrspace(2) constant i16 4
34
35; CHECK: .section .progmem2.data,"a",@progbits
36; CHECK-LABEL: flash2:
37; CHECK-8515: error: Current AVR subtarget does not support accessing extended program memory
38; CHECK-tiny40: error: Current AVR subtarget does not support accessing program memory
39@flash2 = addrspace(3) constant i16 5
40
41; CHECK: .section .progmem3.data,"a",@progbits
42; CHECK-LABEL: flash3:
43; CHECK-8515: error: Current AVR subtarget does not support accessing extended program memory
44; CHECK-tiny40: error: Current AVR subtarget does not support accessing program memory
45@flash3 = addrspace(4) constant i16 6
46
47; CHECK: .section .progmem4.data,"a",@progbits
48; CHECK-LABEL: flash4:
49; CHECK-8515: error: Current AVR subtarget does not support accessing extended program memory
50; CHECK-tiny40: error: Current AVR subtarget does not support accessing program memory
51@flash4 = addrspace(5) constant i16 7
52
53; CHECK: .section .progmem5.data,"a",@progbits
54; CHECK-LABEL: flash5:
55; CHECK-8515: error: Current AVR subtarget does not support accessing extended program memory
56; CHECK-tiny40: error: Current AVR subtarget does not support accessing program memory
57@flash5 = addrspace(6) constant i16 8
58
59; NOSECTIONS: .section .rodata,"a",@progbits
60; SECTIONS:   .section .rodata.ram1,"a",@progbits
61; CHECK-LABEL: ram1:
62@ram1 = constant i16 3
63
64; NOSECTIONS: .data
65; SECTIONS:   .section .data.ram2,"aw",@progbits
66; CHECK-LABEL: ram2:
67@ram2 = global i16 3
68