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