1*9880d681SAndroid Build Coastguard Worker@ RUN: llvm-mc %s -triple=armv7-unknown-linux-gnueabi -filetype=obj -o - \ 2*9880d681SAndroid Build Coastguard Worker@ RUN: | llvm-readobj -s -sd | FileCheck %s 3*9880d681SAndroid Build Coastguard Worker 4*9880d681SAndroid Build Coastguard Worker@ Check for different stack pointer offsets. 5*9880d681SAndroid Build Coastguard Worker 6*9880d681SAndroid Build Coastguard Worker@ The .pad directive will track the stack pointer offsets. There are several 7*9880d681SAndroid Build Coastguard Worker@ ways to encode the stack offsets. We have to test: 8*9880d681SAndroid Build Coastguard Worker@ 9*9880d681SAndroid Build Coastguard Worker@ offset < 0x00 10*9880d681SAndroid Build Coastguard Worker@ offset == 0x00 11*9880d681SAndroid Build Coastguard Worker@ 0x04 <= offset <= 0x100 12*9880d681SAndroid Build Coastguard Worker@ 0x104 <= offset <= 0x200 13*9880d681SAndroid Build Coastguard Worker@ 0x204 <= offset 14*9880d681SAndroid Build Coastguard Worker 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard Worker .syntax unified 17*9880d681SAndroid Build Coastguard Worker 18*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 19*9880d681SAndroid Build Coastguard Worker@ TEST1 20*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 21*9880d681SAndroid Build Coastguard Worker .section .TEST1 22*9880d681SAndroid Build Coastguard Worker .globl func1 23*9880d681SAndroid Build Coastguard Worker .align 2 24*9880d681SAndroid Build Coastguard Worker .type func1,%function 25*9880d681SAndroid Build Coastguard Worker .fnstart 26*9880d681SAndroid Build Coastguard Workerfunc1: 27*9880d681SAndroid Build Coastguard Worker .pad #0 28*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0 29*9880d681SAndroid Build Coastguard Worker add sp, sp, #0 30*9880d681SAndroid Build Coastguard Worker bx lr 31*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 32*9880d681SAndroid Build Coastguard Worker .handlerdata 33*9880d681SAndroid Build Coastguard Worker .fnend 34*9880d681SAndroid Build Coastguard Worker 35*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 36*9880d681SAndroid Build Coastguard Worker@ The assembler should emit nothing (will be filled up with finish opcode). 37*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 38*9880d681SAndroid Build Coastguard Worker@ CHECK: Section { 39*9880d681SAndroid Build Coastguard Worker@ CHECK: Name: .ARM.extab.TEST1 40*9880d681SAndroid Build Coastguard Worker@ CHECK: SectionData ( 41*9880d681SAndroid Build Coastguard Worker@ CHECK: 0000: 00000000 B0B0B000 |........| 42*9880d681SAndroid Build Coastguard Worker@ CHECK: ) 43*9880d681SAndroid Build Coastguard Worker@ CHECK: } 44*9880d681SAndroid Build Coastguard Worker 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 48*9880d681SAndroid Build Coastguard Worker@ TEST2 49*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 50*9880d681SAndroid Build Coastguard Worker .section .TEST2 51*9880d681SAndroid Build Coastguard Worker .globl func2a 52*9880d681SAndroid Build Coastguard Worker .align 2 53*9880d681SAndroid Build Coastguard Worker .type func2a,%function 54*9880d681SAndroid Build Coastguard Worker .fnstart 55*9880d681SAndroid Build Coastguard Workerfunc2a: 56*9880d681SAndroid Build Coastguard Worker .pad #0x4 57*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x4 58*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x4 59*9880d681SAndroid Build Coastguard Worker bx lr 60*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 61*9880d681SAndroid Build Coastguard Worker .handlerdata 62*9880d681SAndroid Build Coastguard Worker .fnend 63*9880d681SAndroid Build Coastguard Worker 64*9880d681SAndroid Build Coastguard Worker .globl func2b 65*9880d681SAndroid Build Coastguard Worker .align 2 66*9880d681SAndroid Build Coastguard Worker .type func2b,%function 67*9880d681SAndroid Build Coastguard Worker .fnstart 68*9880d681SAndroid Build Coastguard Workerfunc2b: 69*9880d681SAndroid Build Coastguard Worker .pad #0x100 70*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x100 71*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x100 72*9880d681SAndroid Build Coastguard Worker bx lr 73*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 74*9880d681SAndroid Build Coastguard Worker .handlerdata 75*9880d681SAndroid Build Coastguard Worker .fnend 76*9880d681SAndroid Build Coastguard Worker 77*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 78*9880d681SAndroid Build Coastguard Worker@ The assembler should emit ((offset - 4) >> 2). 79*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 80*9880d681SAndroid Build Coastguard Worker@ CHECK: Section { 81*9880d681SAndroid Build Coastguard Worker@ CHECK: Name: .ARM.extab.TEST2 82*9880d681SAndroid Build Coastguard Worker@ CHECK: SectionData ( 83*9880d681SAndroid Build Coastguard Worker@ CHECK: 0000: 00000000 B0B00000 00000000 B0B03F00 |..............?.| 84*9880d681SAndroid Build Coastguard Worker@ CHECK: ) 85*9880d681SAndroid Build Coastguard Worker@ CHECK: } 86*9880d681SAndroid Build Coastguard Worker 87*9880d681SAndroid Build Coastguard Worker 88*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 89*9880d681SAndroid Build Coastguard Worker@ TEST3 90*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 91*9880d681SAndroid Build Coastguard Worker .section .TEST3 92*9880d681SAndroid Build Coastguard Worker .globl func3a 93*9880d681SAndroid Build Coastguard Worker .align 2 94*9880d681SAndroid Build Coastguard Worker .type func3a,%function 95*9880d681SAndroid Build Coastguard Worker .fnstart 96*9880d681SAndroid Build Coastguard Workerfunc3a: 97*9880d681SAndroid Build Coastguard Worker .pad #0x104 98*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x104 99*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x104 100*9880d681SAndroid Build Coastguard Worker bx lr 101*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 102*9880d681SAndroid Build Coastguard Worker .handlerdata 103*9880d681SAndroid Build Coastguard Worker .fnend 104*9880d681SAndroid Build Coastguard Worker 105*9880d681SAndroid Build Coastguard Worker .globl func3b 106*9880d681SAndroid Build Coastguard Worker .align 2 107*9880d681SAndroid Build Coastguard Worker .type func3b,%function 108*9880d681SAndroid Build Coastguard Worker .fnstart 109*9880d681SAndroid Build Coastguard Workerfunc3b: 110*9880d681SAndroid Build Coastguard Worker .pad #0x200 111*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x200 112*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x200 113*9880d681SAndroid Build Coastguard Worker bx lr 114*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 115*9880d681SAndroid Build Coastguard Worker .handlerdata 116*9880d681SAndroid Build Coastguard Worker .fnend 117*9880d681SAndroid Build Coastguard Worker 118*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 119*9880d681SAndroid Build Coastguard Worker@ The assembler should emit 0x3F and ((offset - 0x104) >> 2). 120*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 121*9880d681SAndroid Build Coastguard Worker@ CHECK: Section { 122*9880d681SAndroid Build Coastguard Worker@ CHECK: Name: .ARM.extab.TEST3 123*9880d681SAndroid Build Coastguard Worker@ CHECK: SectionData ( 124*9880d681SAndroid Build Coastguard Worker@ CHECK: 0000: 00000000 B03F0000 00000000 B03F3F00 |.....?.......??.| 125*9880d681SAndroid Build Coastguard Worker@ CHECK: ) 126*9880d681SAndroid Build Coastguard Worker@ CHECK: } 127*9880d681SAndroid Build Coastguard Worker 128*9880d681SAndroid Build Coastguard Worker 129*9880d681SAndroid Build Coastguard Worker 130*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 131*9880d681SAndroid Build Coastguard Worker@ TEST4 132*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 133*9880d681SAndroid Build Coastguard Worker .section .TEST4 134*9880d681SAndroid Build Coastguard Worker .globl func4a 135*9880d681SAndroid Build Coastguard Worker .align 2 136*9880d681SAndroid Build Coastguard Worker .type func4a,%function 137*9880d681SAndroid Build Coastguard Worker .fnstart 138*9880d681SAndroid Build Coastguard Workerfunc4a: 139*9880d681SAndroid Build Coastguard Worker .pad #0x204 140*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x204 141*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x204 142*9880d681SAndroid Build Coastguard Worker bx lr 143*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 144*9880d681SAndroid Build Coastguard Worker .handlerdata 145*9880d681SAndroid Build Coastguard Worker .fnend 146*9880d681SAndroid Build Coastguard Worker 147*9880d681SAndroid Build Coastguard Worker .globl func4b 148*9880d681SAndroid Build Coastguard Worker .align 2 149*9880d681SAndroid Build Coastguard Worker .type func4b,%function 150*9880d681SAndroid Build Coastguard Worker .fnstart 151*9880d681SAndroid Build Coastguard Workerfunc4b: 152*9880d681SAndroid Build Coastguard Worker .pad #0x580 153*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x580 154*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x580 155*9880d681SAndroid Build Coastguard Worker bx lr 156*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 157*9880d681SAndroid Build Coastguard Worker .handlerdata 158*9880d681SAndroid Build Coastguard Worker .fnend 159*9880d681SAndroid Build Coastguard Worker 160*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 161*9880d681SAndroid Build Coastguard Worker@ The assembler should emit 0xB2 and the ULEB128 encoding of 162*9880d681SAndroid Build Coastguard Worker@ ((offset - 0x204) >> 2). 163*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 164*9880d681SAndroid Build Coastguard Worker@ CHECK: Section { 165*9880d681SAndroid Build Coastguard Worker@ CHECK: Name: .ARM.extab.TEST4 166*9880d681SAndroid Build Coastguard Worker@ CHECK: SectionData ( 167*9880d681SAndroid Build Coastguard Worker@ CHECK: 0000: 00000000 B000B200 00000000 01DFB200 |................| 168*9880d681SAndroid Build Coastguard Worker@ CHECK: ) 169*9880d681SAndroid Build Coastguard Worker@ CHECK: } 170*9880d681SAndroid Build Coastguard Worker 171*9880d681SAndroid Build Coastguard Worker 172*9880d681SAndroid Build Coastguard Worker 173*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 174*9880d681SAndroid Build Coastguard Worker@ TEST5 175*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 176*9880d681SAndroid Build Coastguard Worker .section .TEST5 177*9880d681SAndroid Build Coastguard Worker .globl func4a 178*9880d681SAndroid Build Coastguard Worker .align 2 179*9880d681SAndroid Build Coastguard Worker .type func4a,%function 180*9880d681SAndroid Build Coastguard Worker .fnstart 181*9880d681SAndroid Build Coastguard Workerfunc5a: 182*9880d681SAndroid Build Coastguard Worker .pad #-0x4 183*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x4 184*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x4 185*9880d681SAndroid Build Coastguard Worker bx lr 186*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 187*9880d681SAndroid Build Coastguard Worker .handlerdata 188*9880d681SAndroid Build Coastguard Worker .fnend 189*9880d681SAndroid Build Coastguard Worker 190*9880d681SAndroid Build Coastguard Worker .globl func5b 191*9880d681SAndroid Build Coastguard Worker .align 2 192*9880d681SAndroid Build Coastguard Worker .type func5b,%function 193*9880d681SAndroid Build Coastguard Worker .fnstart 194*9880d681SAndroid Build Coastguard Workerfunc5b: 195*9880d681SAndroid Build Coastguard Worker .pad #-0x104 196*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x104 197*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x4 198*9880d681SAndroid Build Coastguard Worker bx lr 199*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 200*9880d681SAndroid Build Coastguard Worker .handlerdata 201*9880d681SAndroid Build Coastguard Worker .fnend 202*9880d681SAndroid Build Coastguard Worker 203*9880d681SAndroid Build Coastguard Worker .globl func5c 204*9880d681SAndroid Build Coastguard Worker .align 2 205*9880d681SAndroid Build Coastguard Worker .type func5c,%function 206*9880d681SAndroid Build Coastguard Worker .fnstart 207*9880d681SAndroid Build Coastguard Workerfunc5c: 208*9880d681SAndroid Build Coastguard Worker .pad #-0x204 209*9880d681SAndroid Build Coastguard Worker add sp, sp, #0x204 210*9880d681SAndroid Build Coastguard Worker sub sp, sp, #0x4 211*9880d681SAndroid Build Coastguard Worker bx lr 212*9880d681SAndroid Build Coastguard Worker .personality __gxx_personality_v0 213*9880d681SAndroid Build Coastguard Worker .handlerdata 214*9880d681SAndroid Build Coastguard Worker .fnend 215*9880d681SAndroid Build Coastguard Worker 216*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 217*9880d681SAndroid Build Coastguard Worker@ The assembler should emit (0x40 | (-offset - 4)) >> 2. When (-offset - 4) 218*9880d681SAndroid Build Coastguard Worker@ is greater than 0x3f, then multiple 0x7f should be emitted. 219*9880d681SAndroid Build Coastguard Worker@------------------------------------------------------------------------------- 220*9880d681SAndroid Build Coastguard Worker@ CHECK: Section { 221*9880d681SAndroid Build Coastguard Worker@ CHECK: Name: .ARM.extab.TEST5 222*9880d681SAndroid Build Coastguard Worker@ CHECK: SectionData ( 223*9880d681SAndroid Build Coastguard Worker@ CHECK: 0000: 00000000 B0B04000 00000000 B07F4000 |......@.......@.| 224*9880d681SAndroid Build Coastguard Worker@ CHECK: 0010: 00000000 7F7F4000 |......@.| 225*9880d681SAndroid Build Coastguard Worker@ CHECK: ) 226*9880d681SAndroid Build Coastguard Worker@ CHECK: } 227