OLD | NEW |
(Empty) | |
| 1 ; TODO(kschimpf): Show that we can handle global variable loads/stores. |
| 2 |
| 3 ; REQUIRES: allow_dump |
| 4 |
| 5 ; RUN: %p2i --filetype=asm -i %s --target=arm32 --args -O2 \ |
| 6 ; RUN: | FileCheck %s --check-prefix=ASM |
| 7 ; RUN: %p2i --filetype=hasm -i %s --target=arm32 --args -O2 \ |
| 8 ; RUN: | FileCheck %s --check-prefix=IASM |
| 9 |
| 10 @global1 = internal global [4 x i8] zeroinitializer, align 4 |
| 11 |
| 12 ; ASM-LABEL: global1: |
| 13 ; ASM-NEXT: .zero 4 |
| 14 ; ASM-NEXT: .size global1, 4 |
| 15 ; ASM-NEXT: .text |
| 16 ; ASM-NEXT: .p2alignl 4,0xe7fedef0 |
| 17 |
| 18 ; IASM-LABEL:global1: |
| 19 ; IASM-NEXT: .zero 4 |
| 20 ; IASM-NEXT: .size global1, 4 |
| 21 ; IASM-NEXT: .text |
| 22 ; IASM-NEXT: .p2alignl 4,0xe7fedef0 |
| 23 |
| 24 define internal i32 @load() { |
| 25 %addr = bitcast [4 x i8]* @global1 to i32* |
| 26 %v = load i32, i32* %addr, align 1 |
| 27 ret i32 %v |
| 28 } |
| 29 |
| 30 ; ASM-LABEL: load: |
| 31 ; ASM-NEXT: .Lload$__0: |
| 32 ; ASM-NEXT: movw r0, #:lower16:global1 |
| 33 ; ASM-NEXT: movt r0, #:upper16:global1 |
| 34 ; ASM-NEXT: ldr r0, [r0] |
| 35 ; ASM-NEXT: bx lr |
| 36 |
| 37 ; IASM-LABEL:load: |
| 38 ; IASM-NEXT: movw r0, #:lower16:global1 |
| 39 ; IASM-NEXT: movt r0, #:upper16:global1 |
| 40 ; IASM-NEXT: ldr r0, [r0] |
| 41 ; IASM-NEXT: .byte 0x1e |
| 42 ; IASM-NEXT: .byte 0xff |
| 43 ; IASM-NEXT: .byte 0x2f |
| 44 ; IASM-NEXT: .byte 0xe1 |
| 45 |
| 46 define internal void @store(i32 %v) { |
| 47 %addr = bitcast [4 x i8]* @global1 to i32* |
| 48 store i32 %v, i32* %addr, align 1 |
| 49 ret void |
| 50 } |
| 51 |
| 52 ; ASM-LABEL:store: |
| 53 ; ASM-NEXT: .Lstore$__0: |
| 54 ; ASM-NEXT: movw r1, #:lower16:global1 |
| 55 ; ASM-NEXT: movt r1, #:upper16:global1 |
| 56 ; ASM-NEXT: str r0, [r1] |
| 57 ; ASM-NEXT: bx lr |
| 58 |
| 59 ; IASM-LABEL:store: |
| 60 ; IASM-NEXT: movw r1, #:lower16:global1 |
| 61 ; IASM-NEXT: movt r1, #:upper16:global1 |
| 62 ; IASM-NEXT: str r0, [r1] |
| 63 ; IASM-NEXT: .byte 0x1e |
| 64 ; IASM-NEXT: .byte 0xff |
| 65 ; IASM-NEXT: .byte 0x2f |
| 66 ; IASM-NEXT: .byte 0xe1 |
OLD | NEW |