OLD | NEW |
(Empty) | |
| 1 ; Show that we know how to translate push and pop. |
| 2 ; TODO(kschimpf) Translate pop instructions. |
| 3 |
| 4 ; NOTE: We use -O2 to get rid of memory stores. |
| 5 |
| 6 ; REQUIRES: allow_dump |
| 7 |
| 8 ; Compile using standalone assembler. |
| 9 ; RUN: %p2i --filetype=asm -i %s --target=arm32 --args -O2 -allow-extern \ |
| 10 ; RUN: | FileCheck %s --check-prefix=ASM |
| 11 |
| 12 ; Show bytes in assembled standalone code. |
| 13 ; RUN: %p2i --filetype=asm -i %s --target=arm32 --assemble --disassemble \ |
| 14 ; RUN: --args -O2 -allow-extern | FileCheck %s --check-prefix=DIS |
| 15 |
| 16 ; Compile using integrated assembler. |
| 17 ; RUN: %p2i --filetype=iasm -i %s --target=arm32 --args -O2 -unsafe-ias \ |
| 18 ; RUN: -allow-extern | FileCheck %s --check-prefix=IASM |
| 19 |
| 20 ; Show bytes in assembled integrated code. |
| 21 ; RUN: %p2i --filetype=iasm -i %s --target=arm32 --assemble --disassemble \ |
| 22 ; RUN: --args -O2 -unsafe-ias -allow-extern | FileCheck %s --check-prefix=DIS |
| 23 |
| 24 declare external void @DoSomething() |
| 25 |
| 26 define internal void @SinglePushPop() { |
| 27 call void @DoSomething(); |
| 28 ret void |
| 29 } |
| 30 |
| 31 ; ASM-LABEL:SinglePushPop: |
| 32 ; ASM-NEXT:.LSinglePushPop$__0: |
| 33 ; ASM-NEXT: push {lr} |
| 34 ; ASM: sub sp, sp, #12 |
| 35 ; ASM-NEXT: bl DoSomething |
| 36 ; ASM: add sp, sp, #12 |
| 37 ; ASM-NEXT: pop {lr} |
| 38 ; ASM: bx lr |
| 39 |
| 40 ; DIS-LABEL:00000000 <SinglePushPop>: |
| 41 ; DIS-NEXT: 0: e52de004 |
| 42 ; DIS-NEXT: 4: e24dd00c |
| 43 ; DIS-NEXT: 8: ebfffffe |
| 44 ; DIS-NEXT: c: e28dd00c |
| 45 ; DIS-NEXT: 10: e49de004 |
| 46 ; DIS-NEXT: 14: e12fff1e |
| 47 |
| 48 ; IASM-LABEL:SinglePushPop: |
| 49 ; IASM-NEXT:.LSinglePushPop$__0: |
| 50 ; IASM-NEXT: .byte 0x4 |
| 51 ; IASM-NEXT: .byte 0xe0 |
| 52 ; IASM-NEXT: .byte 0x2d |
| 53 ; IASM-NEXT: .byte 0xe5 |
| 54 |
| 55 ; IASM-NEXT: .byte 0xc |
| 56 ; IASM-NEXT: .byte 0xd0 |
| 57 ; IASM-NEXT: .byte 0x4d |
| 58 ; IASM-NEXT: .byte 0xe2 |
| 59 ; IASM-NEXT: bl DoSomething |
| 60 ; IASM-NEXT: .byte 0xc |
| 61 ; IASM-NEXT: .byte 0xd0 |
| 62 ; IASM-NEXT: .byte 0x8d |
| 63 ; IASM-NEXT: .byte 0xe2 |
| 64 ; IASM-NEXT: pop {lr} |
| 65 |
| 66 ; IASM: .byte 0x1e |
| 67 ; IASM-NEXT: .byte 0xff |
| 68 ; IASM-NEXT: .byte 0x2f |
| 69 ; IASM-NEXT: .byte 0xe1 |
| 70 |
| 71 ; This test is based on taking advantage of the over-eager -O2 |
| 72 ; register allocator that puts V1 and V2 into callee-save registers, |
| 73 ; since the call instruction kills the scratch registers. This |
| 74 ; requires the callee-save registers to be pushed/popped in the |
| 75 ; prolog/epilog. |
| 76 define internal i32 @MultPushPop(i32 %v1, i32 %v2) { |
| 77 call void @DoSomething(); |
| 78 %v3 = add i32 %v1, %v2 |
| 79 ret i32 %v3 |
| 80 } |
| 81 |
| 82 ; ASM-LABEL:MultPushPop: |
| 83 ; ASM-NEXT:.LMultPushPop$__0: |
| 84 ; ASM-NEXT: push {r4, r5, lr} |
| 85 ; ASM: sub sp, sp, #4 |
| 86 ; ASM-NEXT: mov r4, r0 |
| 87 ; ASM-NEXT: mov r5, r1 |
| 88 ; ASM-NEXT: bl DoSomething |
| 89 ; ASM: add r4, r4, r5 |
| 90 ; ASM-NEXT: mov r0, r4 |
| 91 ; ASM-NEXT: add sp, sp, #4 |
| 92 ; ASM-NEXT: pop {r4, r5, lr} |
| 93 ; ASM: bx lr |
| 94 |
| 95 ; DIS-LABEL:00000020 <MultPushPop>: |
| 96 ; DIS-NEXT: 20: e92d4030 |
| 97 ; DIS-NEXT: 24: e24dd004 |
| 98 ; DIS-NEXT: 28: e1a04000 |
| 99 ; DIS-NEXT: 2c: e1a05001 |
| 100 ; DIS-NEXT: 30: ebfffffe |
| 101 ; DIS-NEXT: 34: e0844005 |
| 102 ; DIS-NEXT: 38: e1a00004 |
| 103 ; DIS-NEXT: 3c: e28dd004 |
| 104 ; DIS-NEXT: 40: e8bd4030 |
| 105 ; DIS-NEXT: 44: e12fff1e |
| 106 |
| 107 ; IASM-LABEL:MultPushPop: |
| 108 ; IASM-NEXT:.LMultPushPop$__0: |
| 109 ; IASM-NEXT: .byte 0x30 |
| 110 ; IASM-NEXT: .byte 0x40 |
| 111 ; IASM-NEXT: .byte 0x2d |
| 112 ; IASM-NEXT: .byte 0xe9 |
| 113 |
| 114 ; IASM-NEXT: .byte 0x4 |
| 115 ; IASM-NEXT: .byte 0xd0 |
| 116 ; IASM-NEXT: .byte 0x4d |
| 117 ; IASM-NEXT: .byte 0xe2 |
| 118 |
| 119 ; IASM-NEXT: .byte 0x0 |
| 120 ; IASM-NEXT: .byte 0x40 |
| 121 ; IASM-NEXT: .byte 0xa0 |
| 122 ; IASM-NEXT: .byte 0xe1 |
| 123 |
| 124 ; IASM-NEXT: .byte 0x1 |
| 125 ; IASM-NEXT: .byte 0x50 |
| 126 ; IASM-NEXT: .byte 0xa0 |
| 127 ; IASM-NEXT: .byte 0xe1 |
| 128 |
| 129 ; IASM-NEXT: bl DoSomething |
| 130 ; IASM-NEXT: .byte 0x5 |
| 131 ; IASM-NEXT: .byte 0x40 |
| 132 ; IASM-NEXT: .byte 0x84 |
| 133 ; IASM-NEXT: .byte 0xe0 |
| 134 |
| 135 ; IASM-NEXT: .byte 0x4 |
| 136 ; IASM-NEXT: .byte 0x0 |
| 137 ; IASM-NEXT: .byte 0xa0 |
| 138 ; IASM-NEXT: .byte 0xe1 |
| 139 |
| 140 ; IASM-NEXT: .byte 0x4 |
| 141 ; IASM-NEXT: .byte 0xd0 |
| 142 ; IASM-NEXT: .byte 0x8d |
| 143 ; IASM-NEXT: .byte 0xe2 |
| 144 ; IASM-NEXT: pop {r4, r5, lr} |
| 145 |
| 146 ; IASM: .byte 0x1e |
| 147 ; IASM-NEXT: .byte 0xff |
| 148 ; IASM-NEXT: .byte 0x2f |
| 149 ; IASM-NEXT: .byte 0xe1 |
OLD | NEW |