reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256
  257
  258
  259
  260
  261
  262
  263
  264
  265
  266
  267
  268
  269
  270
  271
  272
  273
  274
  275
  276
  277
  278
  279
  280
  281
  282
  283
  284
  285
  286
  287
  288
  289
  290
  291
  292
  293
  294
  295
  296
  297
  298
  299
  300
  301
  302
  303
  304
@ RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -show-encoding < %s | FileCheck %s

@------------------------------------------------------------------------------
@ unconditional branches accept narrow suffix and encode to short encodings
@------------------------------------------------------------------------------

         b.n    #-2048
         b.n    #2046

@ CHECK: b	#-2048                  @ encoding: [0x00,0xe4]
@ CHECK: b	#2046                   @ encoding: [0xff,0xe3]

@------------------------------------------------------------------------------
@ unconditional branches accept wide suffix and encode to wide encodings
@------------------------------------------------------------------------------

         b.w    #-2048
         b.w    #2046
         b.w    #-1677216
         b.w    #1677214

@ CHECK: b.w	#-2048                  @ encoding: [0xff,0xf7,0x00,0xbc]
@ CHECK: b.w	#2046                   @ encoding: [0x00,0xf0,0xff,0xbb]
@ CHECK: b.w	#-1677216               @ encoding: [0x66,0xf6,0x30,0xbc]
@ CHECK: b.w	#1677214                @ encoding: [0x99,0xf1,0xcf,0xbb]

@------------------------------------------------------------------------------
@ unconditional branches without width suffix encode depending of offset size
@------------------------------------------------------------------------------

         b      #-2048
         b      #2046
         b      #-2050
         b      #2048
         b      #-1677216
         b      #1677214

@ CHECK: b	#-2048                  @ encoding: [0x00,0xe4]
@ CHECK: b	#2046                   @ encoding: [0xff,0xe3]
@ CHECK: b.w	#-2050                  @ encoding: [0xff,0xf7,0xff,0xbb]
@ CHECK: b.w	#2048                   @ encoding: [0x00,0xf0,0x00,0xbc]
@ CHECK: b.w	#-1677216               @ encoding: [0x66,0xf6,0x30,0xbc]
@ CHECK: b.w	#1677214                @ encoding: [0x99,0xf1,0xcf,0xbb]

@------------------------------------------------------------------------------
@ unconditional branches with width narrow suffix in IT block 
@------------------------------------------------------------------------------

         it     eq
         beq.n  #-2048
         it     ne
         bne.n  #-2046

@ CHECK: it	eq                      @ encoding: [0x08,0xbf]
@ CHECK: beq	#-2048                  @ encoding: [0x00,0xe4] 
@ CHECK: it	ne                      @ encoding: [0x18,0xbf] 
@ CHECK: bne	#-2046                  @ encoding: [0x01,0xe4]

@------------------------------------------------------------------------------
@ unconditional branches with wide suffix in IT block
@------------------------------------------------------------------------------

         it     gt
         bgt.w  #-2048
         it     le
         ble.w  #2046
         it     ge
         bge.w  #-1677216
         it     lt
         blt.w  #1677214

@ CHECK: it	gt                      @ encoding: [0xc8,0xbf]
@ CHECK: bgt.w	#-2048                  @ encoding: [0xff,0xf7,0x00,0xbc]
@ CHECK: it	le                      @ encoding: [0xd8,0xbf]
@ CHECK: ble.w	#2046                   @ encoding: [0x00,0xf0,0xff,0xbb]
@ CHECK: it	ge                      @ encoding: [0xa8,0xbf]
@ CHECK: bge.w	#-1677216               @ encoding: [0x66,0xf6,0x30,0xbc]
@ CHECK: it	lt                      @ encoding: [0xb8,0xbf]
@ CHECK: blt.w	#1677214                @ encoding: [0x99,0xf1,0xcf,0xbb]

@------------------------------------------------------------------------------
@ conditional branches accept narrow suffix and encode to short encodings
@------------------------------------------------------------------------------

         beq.n    #-256
         bne.n    #254

@ CHECK: beq	#-256                   @ encoding: [0x80,0xd0]
@ CHECK: bne	#254                    @ encoding: [0x7f,0xd1]

@------------------------------------------------------------------------------
@ unconditional branches accept wide suffix and encode to wide encodings
@------------------------------------------------------------------------------

         bmi.w    #-256
         bne.w    #254
         blt.w    #-1048576
         bge.w    #1048574

@ CHECK: bmi.w	#-256                   @ encoding: [0x3f,0xf5,0x80,0xaf]
@ CHECK: bne.w	#254                    @ encoding: [0x40,0xf0,0x7f,0x80]
@ CHECK: blt.w	#-1048576               @ encoding: [0xc0,0xf6,0x00,0x80]
@ CHECK: bge.w	#1048574                @ encoding: [0xbf,0xf2,0xff,0xaf]

@------------------------------------------------------------------------------
@ unconditional branches without width suffix encode depending of offset size
@------------------------------------------------------------------------------

         bne     #-256
         bgt     #254
         bne     #-258
         bgt     #256
         bne     #-1048576
         bgt     #1048574

@ CHECK: bne	#-256                   @ encoding: [0x80,0xd1]
@ CHECK: bgt	#254                    @ encoding: [0x7f,0xdc]
@ CHECK: bne.w	#-258                   @ encoding: [0x7f,0xf4,0x7f,0xaf]
@ CHECK: bgt.w	#256                    @ encoding: [0x00,0xf3,0x80,0x80]
@ CHECK: bne.w	#-1048576               @ encoding: [0x40,0xf4,0x00,0x80]
@ CHECK: bgt.w	#1048574                @ encoding: [0x3f,0xf3,0xff,0xaf]

@------------------------------------------------------------------------------
@ same branch insturction encoding to conditional or unconditional depending
@ on whether it is in an IT block or not
@------------------------------------------------------------------------------

         it     eq
         addeq  r0, r1
         bne    #128

@ CHECK: it	eq                      @ encoding: [0x08,0xbf]
@ CHECK: addeq	r0, r1                  @ encoding: [0x08,0x44]
@ CHECK: bne	#128                    @ encoding: [0x40,0xd1]

         ite    eq
         addeq  r0, r1
         bne    #128

@ CHECK: ite	eq                      @ encoding: [0x0c,0xbf]
@ CHECK: addeq	r0, r1                  @ encoding: [0x08,0x44]
@ CHECK: bne	#128                    @ encoding: [0x40,0xe0]

@ RUN: llvm-mc -triple=thumbv7-apple-darwin -mcpu=cortex-a8 -show-encoding < %s | FileCheck %s

@------------------------------------------------------------------------------
@ unconditional branches accept narrow suffix and encode to short encodings
@------------------------------------------------------------------------------

         b.n    #-2048
         b.n    #2046

@ CHECK: b	#-2048                  @ encoding: [0x00,0xe4]
@ CHECK: b	#2046                   @ encoding: [0xff,0xe3]

@------------------------------------------------------------------------------
@ unconditional branches accept wide suffix and encode to wide encodings
@------------------------------------------------------------------------------

         b.w    #-2048
         b.w    #2046
         b.w    #-1677216
         b.w    #1677214

@ CHECK: b.w	#-2048                  @ encoding: [0xff,0xf7,0x00,0xbc]
@ CHECK: b.w	#2046                   @ encoding: [0x00,0xf0,0xff,0xbb]
@ CHECK: b.w	#-1677216               @ encoding: [0x66,0xf6,0x30,0xbc]
@ CHECK: b.w	#1677214                @ encoding: [0x99,0xf1,0xcf,0xbb]

@------------------------------------------------------------------------------
@ unconditional branches without width suffix encode depending of offset size
@------------------------------------------------------------------------------

         b      #-2048
         b      #2046
         b      #-2050
         b      #2048
         b      #-1677216
         b      #1677214

@ CHECK: b	#-2048                  @ encoding: [0x00,0xe4]
@ CHECK: b	#2046                   @ encoding: [0xff,0xe3]
@ CHECK: b.w	#-2050                  @ encoding: [0xff,0xf7,0xff,0xbb]
@ CHECK: b.w	#2048                   @ encoding: [0x00,0xf0,0x00,0xbc]
@ CHECK: b.w	#-1677216               @ encoding: [0x66,0xf6,0x30,0xbc]
@ CHECK: b.w	#1677214                @ encoding: [0x99,0xf1,0xcf,0xbb]

@------------------------------------------------------------------------------
@ unconditional branches with width narrow suffix in IT block 
@------------------------------------------------------------------------------

         it     eq
         beq.n  #-2048
         it     ne
         bne.n  #-2046

@ CHECK: it	eq                      @ encoding: [0x08,0xbf]
@ CHECK: beq	#-2048                  @ encoding: [0x00,0xe4] 
@ CHECK: it	ne                      @ encoding: [0x18,0xbf] 
@ CHECK: bne	#-2046                  @ encoding: [0x01,0xe4]

@------------------------------------------------------------------------------
@ unconditional branches with wide suffix in IT block
@------------------------------------------------------------------------------

         it     gt
         bgt.w  #-2048
         it     le
         ble.w  #2046
         it     ge
         bge.w  #-1677216
         it     lt
         blt.w  #1677214

@ CHECK: it	gt                      @ encoding: [0xc8,0xbf]
@ CHECK: bgt.w	#-2048                  @ encoding: [0xff,0xf7,0x00,0xbc]
@ CHECK: it	le                      @ encoding: [0xd8,0xbf]
@ CHECK: ble.w	#2046                   @ encoding: [0x00,0xf0,0xff,0xbb]
@ CHECK: it	ge                      @ encoding: [0xa8,0xbf]
@ CHECK: bge.w	#-1677216               @ encoding: [0x66,0xf6,0x30,0xbc]
@ CHECK: it	lt                      @ encoding: [0xb8,0xbf]
@ CHECK: blt.w	#1677214                @ encoding: [0x99,0xf1,0xcf,0xbb]

@------------------------------------------------------------------------------
@ conditional branches accept narrow suffix and encode to short encodings
@------------------------------------------------------------------------------

         beq.n    #-256
         bne.n    #254

@ CHECK: beq	#-256                   @ encoding: [0x80,0xd0]
@ CHECK: bne	#254                    @ encoding: [0x7f,0xd1]

@------------------------------------------------------------------------------
@ unconditional branches accept wide suffix and encode to wide encodings
@------------------------------------------------------------------------------

         bmi.w    #-256
         bne.w    #254
         blt.w    #-1048576
         bge.w    #1048574

@ CHECK: bmi.w	#-256                   @ encoding: [0x3f,0xf5,0x80,0xaf]
@ CHECK: bne.w	#254                    @ encoding: [0x40,0xf0,0x7f,0x80]
@ CHECK: blt.w	#-1048576               @ encoding: [0xc0,0xf6,0x00,0x80]
@ CHECK: bge.w	#1048574                @ encoding: [0xbf,0xf2,0xff,0xaf]

@------------------------------------------------------------------------------
@ unconditional branches without width suffix encode depending of offset size
@------------------------------------------------------------------------------

         bne     #-256
         bgt     #254
         bne     #-258
         bgt     #256
         bne     #-1048576
         bgt     #1048574

@ CHECK: bne	#-256                   @ encoding: [0x80,0xd1]
@ CHECK: bgt	#254                    @ encoding: [0x7f,0xdc]
@ CHECK: bne.w	#-258                   @ encoding: [0x7f,0xf4,0x7f,0xaf]
@ CHECK: bgt.w	#256                    @ encoding: [0x00,0xf3,0x80,0x80]
@ CHECK: bne.w	#-1048576               @ encoding: [0x40,0xf4,0x00,0x80]
@ CHECK: bgt.w	#1048574                @ encoding: [0x3f,0xf3,0xff,0xaf]

@------------------------------------------------------------------------------
@ same branch insturction encoding to conditional or unconditional depending
@ on whether it is in an IT block or not
@------------------------------------------------------------------------------

         it     eq
         addeq  r0, r1
         bne    #128

@ CHECK: it	eq                      @ encoding: [0x08,0xbf]
@ CHECK: addeq	r0, r1                  @ encoding: [0x08,0x44]
@ CHECK: bne	#128                    @ encoding: [0x40,0xd1]

         ite    eq
         addeq  r0, r1
         bne    #128

@ CHECK: ite	eq                      @ encoding: [0x0c,0xbf]
@ CHECK: addeq	r0, r1                  @ encoding: [0x08,0x44]
@ CHECK: bne	#128                    @ encoding: [0x40,0xe0]


@------------------------------------------------------------------------------
@ Branch targets destined for ARM mode must == 0 (mod 4), otherwise (mod 2).
@------------------------------------------------------------------------------

        b #2
        bl #2
        beq #2
        cbz r0, #2
        @ N.b. destination is "align(PC, 4) + imm" so imm is still 4-byte
        @ aligned even though current PC may not and destination must be.
        blx #4

@ CHECK: b	#2                      @ encoding: [0x01,0xe0]
@ CHECK: bl	#2                      @ encoding: [0x00,0xf0,0x01,0xf8]
@ CHECK: beq	#2                      @ encoding: [0x01,0xd0]
@ CHECK: cbz	r0, #2                  @ encoding: [0x08,0xb1]
@ CHECK: blx	#4                      @ encoding: [0x00,0xf0,0x02,0xe8]