1; TODO(kschimpf): Show that we can handle global variable loads/stores. 2 3; REQUIRES: allow_dump 4 5; Compile using standalone assembler. 6; RUN: %p2i --filetype=asm -i %s --target=arm32 --args -O2 \ 7; RUN: | FileCheck %s --check-prefix=ASM 8 9; Show bytes in assembled standalone code. 10; RUN: %p2i --filetype=asm -i %s --target=arm32 --assemble --disassemble \ 11; RUN: --args -O2 | FileCheck %s --check-prefix=DIS 12 13; Compile using integrated assembler. 14; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -O2 \ 15; RUN: | FileCheck %s --check-prefix=IASM 16 17; Show bytes in assembled integrated code. 18; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \ 19; RUN: --args -O2 | FileCheck %s --check-prefix=DIS 20 21@filler = internal global [128 x i8] zeroinitializer, align 4 22 23@global1 = internal global [4 x i8] zeroinitializer, align 4 24 25; ASM-LABEL: global1: 26; ASM-NEXT: .zero 4 27; ASM-NEXT: .size global1, 4 28; ASM-NEXT: .text 29; ASM-NEXT: .p2alignl 4,0xe7fedef0 30 31; IASM-LABEL:global1: 32; IASM-NEXT: .zero 4 33; IASM-NEXT: .size global1, 4 34; IASM-NEXT: .text 35; IASM-NEXT: .p2alignl 4,0xe7fedef0 36 37define internal i32 @load() { 38 %addr = bitcast [4 x i8]* @global1 to i32* 39 %v = load i32, i32* %addr, align 1 40 ret i32 %v 41} 42 43; ASM-LABEL: load: 44; ASM-NEXT: .Lload$__0: 45; ASM-NEXT: movw r0, #:lower16:global1 46; ASM-NEXT: movt r0, #:upper16:global1 47; ASM-NEXT: ldr r0, [r0] 48; ASM-NEXT: bx lr 49 50; DIS-LABEL:00000000 <load>: 51; DIS-NEXT: 0: e3000000 52; DIS-NEXT: 4: e3400000 53; DIS-NEXT: 8: e5900000 54; DIS-NEXT: c: e12fff1e 55 56; IASM-LABEL:load: 57; IASM-NEXT: .Lload$__0: 58; IASM-NEXT: movw r0, #:lower16:global1 @ .word e3000000 59; IASM-NEXT: movt r0, #:upper16:global1 @ .word e3400000 60; IASM-NEXT: .byte 0x0 61; IASM-NEXT: .byte 0x0 62; IASM-NEXT: .byte 0x90 63; IASM-NEXT: .byte 0xe5 64; IASM-NEXT: .byte 0x1e 65; IASM-NEXT: .byte 0xff 66; IASM-NEXT: .byte 0x2f 67; IASM-NEXT: .byte 0xe1 68 69define internal void @store(i32 %v) { 70 %addr = bitcast [4 x i8]* @global1 to i32* 71 store i32 %v, i32* %addr, align 1 72 ret void 73} 74 75; ASM-LABEL:store: 76; ASM-NEXT: .Lstore$__0: 77; ASM-NEXT: movw r1, #:lower16:global1 78; ASM-NEXT: movt r1, #:upper16:global1 79; ASM-NEXT: str r0, [r1] 80; ASM-NEXT: bx lr 81 82; DIS-LABEL:00000010 <store>: 83; DIS-NEXT: 10: e3001000 84; DIS-NEXT: 14: e3401000 85; DIS-NEXT: 18: e5810000 86; DIS-NEXT: 1c: e12fff1e 87 88; IASM-LABEL:store: 89; IASM-NEXT: .Lstore$__0: 90; IASM-NEXT: movw r1, #:lower16:global1 @ .word e3001000 91; IASM-NEXT: movt r1, #:upper16:global1 @ .word e3401000 92; IASM-NEXT: .byte 0x0 93; IASM-NEXT: .byte 0x0 94; IASM-NEXT: .byte 0x81 95; IASM-NEXT: .byte 0xe5 96; IASM-NEXT: .byte 0x1e 97; IASM-NEXT: .byte 0xff 98; IASM-NEXT: .byte 0x2f 99; IASM-NEXT: .byte 0xe1 100