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 define internal i32 @MultPushPop(i32 %v1, i32 %v2) { | |
72 call void @DoSomething(); | |
Jim Stichnoth
2015/11/06 00:59:09
Add a comment describing the trick: the over-eager
Karl
2015/11/06 17:14:30
Done.
| |
73 %v3 = add i32 %v1, %v2 | |
74 ret i32 %v3 | |
75 } | |
76 | |
77 ; ASM-LABEL:MultPushPop: | |
78 ; ASM-NEXT:.LMultPushPop$__0: | |
79 ; ASM-NEXT: push {r4, r5, lr} | |
80 ; ASM: sub sp, sp, #4 | |
81 ; ASM-NEXT: mov r4, r0 | |
82 ; ASM-NEXT: mov r5, r1 | |
83 ; ASM-NEXT: bl DoSomething | |
84 ; ASM: add r4, r4, r5 | |
85 ; ASM-NEXT: mov r0, r4 | |
86 ; ASM-NEXT: add sp, sp, #4 | |
87 ; ASM-NEXT: pop {r4, r5, lr} | |
88 ; ASM: bx lr | |
89 | |
90 ; DIS-LABEL:00000020 <MultPushPop>: | |
91 ; DIS-NEXT: 20: e92d4030 | |
92 ; DIS-NEXT: 24: e24dd004 | |
93 ; DIS-NEXT: 28: e1a04000 | |
94 ; DIS-NEXT: 2c: e1a05001 | |
95 ; DIS-NEXT: 30: ebfffffe | |
96 ; DIS-NEXT: 34: e0844005 | |
97 ; DIS-NEXT: 38: e1a00004 | |
98 ; DIS-NEXT: 3c: e28dd004 | |
99 ; DIS-NEXT: 40: e8bd4030 | |
100 ; DIS-NEXT: 44: e12fff1e | |
101 | |
102 ; IASM-LABEL:MultPushPop: | |
103 ; IASM-NEXT:.LMultPushPop$__0: | |
104 ; IASM-NEXT: .byte 0x30 | |
105 ; IASM-NEXT: .byte 0x40 | |
106 ; IASM-NEXT: .byte 0x2d | |
107 ; IASM-NEXT: .byte 0xe9 | |
108 | |
109 ; IASM-NEXT: .byte 0x4 | |
110 ; IASM-NEXT: .byte 0xd0 | |
111 ; IASM-NEXT: .byte 0x4d | |
112 ; IASM-NEXT: .byte 0xe2 | |
113 | |
114 ; IASM-NEXT: .byte 0x0 | |
115 ; IASM-NEXT: .byte 0x40 | |
116 ; IASM-NEXT: .byte 0xa0 | |
117 ; IASM-NEXT: .byte 0xe1 | |
118 | |
119 ; IASM-NEXT: .byte 0x1 | |
120 ; IASM-NEXT: .byte 0x50 | |
121 ; IASM-NEXT: .byte 0xa0 | |
122 ; IASM-NEXT: .byte 0xe1 | |
123 | |
124 ; IASM-NEXT: bl DoSomething | |
125 ; IASM-NEXT: .byte 0x5 | |
126 ; IASM-NEXT: .byte 0x40 | |
127 ; IASM-NEXT: .byte 0x84 | |
128 ; IASM-NEXT: .byte 0xe0 | |
129 | |
130 ; IASM-NEXT: .byte 0x4 | |
131 ; IASM-NEXT: .byte 0x0 | |
132 ; IASM-NEXT: .byte 0xa0 | |
133 ; IASM-NEXT: .byte 0xe1 | |
134 | |
135 ; IASM-NEXT: .byte 0x4 | |
136 ; IASM-NEXT: .byte 0xd0 | |
137 ; IASM-NEXT: .byte 0x8d | |
138 ; IASM-NEXT: .byte 0xe2 | |
139 ; IASM-NEXT: pop {r4, r5, lr} | |
140 | |
141 ; IASM: .byte 0x1e | |
142 ; IASM-NEXT: .byte 0xff | |
143 ; IASM-NEXT: .byte 0x2f | |
144 ; IASM-NEXT: .byte 0xe1 | |
OLD | NEW |