Home | History | Annotate | Download | only in GlobalISel
      1 # RUN: llc -O0 -mtriple=aarch64-apple-ios -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=IOS
      2 # RUN: llc -O0 -mtriple=aarch64-linux-gnu -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LINUX-DEFAULT
      3 # RUN: llc -O0 -mtriple=aarch64-linux-gnu -relocation-model=pic -run-pass=instruction-select -verify-machineinstrs %s -o - | FileCheck %s -check-prefix=CHECK -check-prefix=LINUX-PIC
      4 
      5 --- |
      6   target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
      7 
      8   define void @frame_index() {
      9     %ptr0 = alloca i64
     10     ret void
     11   }
     12 
     13   define i8* @gep(i8* %in) { ret i8* undef }
     14 
     15   define i8* @ptr_mask(i8* %in) { ret i8* undef }
     16 
     17   @var_local = global i8 0
     18   define i8* @global_local() { ret i8* undef }
     19 
     20   @var_got = external global i8
     21   define i8* @global_got() { ret i8* undef }
     22 
     23   define void @icmp() { ret void }
     24   define void @fcmp() { ret void }
     25 
     26   define void @phi() { ret void }
     27 
     28   define void @select() { ret void }
     29 ...
     30 
     31 ---
     32 # CHECK-LABEL: name: frame_index
     33 name:            frame_index
     34 legalized:       true
     35 regBankSelected: true
     36 
     37 # CHECK:      registers:
     38 # CHECK-NEXT:  - { id: 0, class: gpr64sp, preferred-register: '' }
     39 registers:
     40   - { id: 0, class: gpr }
     41 
     42 stack:
     43   - { id: 0, name: ptr0, offset: 0, size: 8, alignment: 8 }
     44 
     45 # CHECK:  body:
     46 # CHECK: %0:gpr64sp = ADDXri %stack.0.ptr0, 0, 0
     47 body:             |
     48   bb.0:
     49     %0(p0) = G_FRAME_INDEX %stack.0.ptr0
     50     $x0 = COPY %0(p0)
     51 ...
     52 
     53 ---
     54 # CHECK-LABEL: name: gep
     55 name:            gep
     56 legalized:       true
     57 regBankSelected: true
     58 registers:
     59   - { id: 0, class: gpr }
     60   - { id: 1, class: gpr }
     61   - { id: 2, class: gpr }
     62 
     63 # CHECK:  body:
     64 # CHECK: %1:gpr64 = MOVi64imm 42
     65 # CHECK: %2:gpr64 = ADDXrr %0, %1
     66 body:             |
     67   bb.0:
     68       liveins: $x0
     69     %0(p0) = COPY $x0
     70     %1(s64) = G_CONSTANT i64 42
     71     %2(p0) = G_GEP %0, %1(s64)
     72     $x0 = COPY %2(p0)
     73 ...
     74 
     75 ---
     76 # CHECK-LABEL: name: ptr_mask
     77 name:            ptr_mask
     78 legalized:       true
     79 regBankSelected: true
     80 
     81 # CHECK:  body:
     82 # CHECK: %1:gpr64sp = ANDXri %0, 8060
     83 body:             |
     84   bb.0:
     85       liveins: $x0
     86     %0:gpr(p0) = COPY $x0
     87     %1:gpr(p0) = G_PTR_MASK %0, 3
     88     $x0 = COPY %1(p0)
     89 ...
     90 
     91 ---
     92 # Global defined in the same linkage unit so no GOT is needed
     93 # CHECK-LABEL: name: global_local
     94 name:            global_local
     95 legalized:       true
     96 regBankSelected: true
     97 registers:
     98   - { id: 0, class: gpr }
     99 
    100 # CHECK:  body:
    101 # IOS: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
    102 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_local, target-flags(aarch64-pageoff, aarch64-nc) @var_local
    103 # LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_local
    104 body:             |
    105   bb.0:
    106     %0(p0) = G_GLOBAL_VALUE @var_local
    107     $x0 = COPY %0(p0)
    108 ...
    109 
    110 ---
    111 # CHECK-LABEL: name: global_got
    112 name:            global_got
    113 legalized:       true
    114 regBankSelected: true
    115 registers:
    116   - { id: 0, class: gpr }
    117 
    118 # CHECK:  body:
    119 # IOS: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
    120 # LINUX-DEFAULT: %0:gpr64 = MOVaddr target-flags(aarch64-page) @var_got, target-flags(aarch64-pageoff, aarch64-nc) @var_got
    121 # LINUX-PIC: %0:gpr64 = LOADgot target-flags(aarch64-got) @var_got
    122 body:             |
    123   bb.0:
    124     %0(p0) = G_GLOBAL_VALUE @var_got
    125     $x0 = COPY %0(p0)
    126 ...
    127 
    128 ---
    129 # CHECK-LABEL: name: icmp
    130 name:            icmp
    131 legalized:       true
    132 regBankSelected: true
    133 
    134 # CHECK:      registers:
    135 # CHECK-NEXT:  - { id: 0, class: gpr32, preferred-register: '' }
    136 # CHECK-NEXT:  - { id: 1, class: gpr32, preferred-register: '' }
    137 # CHECK-NEXT:  - { id: 2, class: gpr64, preferred-register: '' }
    138 # CHECK-NEXT:  - { id: 3, class: gpr32, preferred-register: '' }
    139 # CHECK-NEXT:  - { id: 4, class: gpr64, preferred-register: '' }
    140 # CHECK-NEXT:  - { id: 5, class: gpr32, preferred-register: '' }
    141 registers:
    142   - { id: 0, class: gpr }
    143   - { id: 1, class: gpr }
    144   - { id: 2, class: gpr }
    145   - { id: 3, class: gpr }
    146   - { id: 4, class: gpr }
    147   - { id: 5, class: gpr }
    148   - { id: 6, class: gpr }
    149   - { id: 7, class: gpr }
    150   - { id: 8, class: gpr }
    151   - { id: 9, class: gpr }
    152   - { id: 10, class: gpr }
    153   - { id: 11, class: gpr }
    154 
    155 # CHECK:  body:
    156 # CHECK:    $wzr = SUBSWrr %0, %0, implicit-def $nzcv
    157 # CHECK:    %1:gpr32 = CSINCWr $wzr, $wzr, 1, implicit $nzcv
    158 
    159 # CHECK:    $xzr = SUBSXrr %2, %2, implicit-def $nzcv
    160 # CHECK:    %3:gpr32 = CSINCWr $wzr, $wzr, 3, implicit $nzcv
    161 
    162 # CHECK:    $xzr = SUBSXrr %4, %4, implicit-def $nzcv
    163 # CHECK:    %5:gpr32 = CSINCWr $wzr, $wzr, 0, implicit $nzcv
    164 
    165 body:             |
    166   bb.0:
    167     liveins: $w0, $x0
    168 
    169     %0(s32) = COPY $w0
    170     %1(s32) = G_ICMP intpred(eq), %0, %0
    171     %6(s1) = G_TRUNC %1(s32)
    172     %9(s32) = G_ANYEXT %6
    173     $w0 = COPY %9(s32)
    174 
    175     %2(s64) = COPY $x0
    176     %3(s32) = G_ICMP intpred(uge), %2, %2
    177     %7(s1) = G_TRUNC %3(s32)
    178     %10(s32) = G_ANYEXT %7
    179     $w0 = COPY %10(s32)
    180 
    181     %4(p0) = COPY $x0
    182     %5(s32) = G_ICMP intpred(ne), %4, %4
    183     %8(s1) = G_TRUNC %5(s32)
    184     %11(s32) = G_ANYEXT %8
    185     $w0 = COPY %11(s32)
    186 ...
    187 
    188 ---
    189 # CHECK-LABEL: name: fcmp
    190 name:            fcmp
    191 legalized:       true
    192 regBankSelected: true
    193 
    194 # CHECK:      registers:
    195 # CHECK-NEXT:  - { id: 0, class: fpr32, preferred-register: '' }
    196 # CHECK-NEXT:  - { id: 1, class: gpr32, preferred-register: '' }
    197 # CHECK-NEXT:  - { id: 2, class: fpr64, preferred-register: '' }
    198 # CHECK-NEXT:  - { id: 3, class: gpr32, preferred-register: '' }
    199 # CHECK-NEXT:  - { id: 4, class: gpr32, preferred-register: '' }
    200 # CHECK-NEXT:  - { id: 5, class: gpr32, preferred-register: '' }
    201 registers:
    202   - { id: 0, class: fpr }
    203   - { id: 1, class: gpr }
    204   - { id: 2, class: fpr }
    205   - { id: 3, class: gpr }
    206   - { id: 4, class: gpr }
    207   - { id: 5, class: gpr }
    208   - { id: 6, class: gpr }
    209   - { id: 7, class: gpr }
    210 
    211 # CHECK:  body:
    212 # CHECK:    FCMPSrr %0, %0, implicit-def $nzcv
    213 # CHECK:    [[TST_MI:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 5, implicit $nzcv
    214 # CHECK:    [[TST_GT:%[0-9]+]]:gpr32 = CSINCWr $wzr, $wzr, 13, implicit $nzcv
    215 # CHECK:    %1:gpr32 = ORRWrr [[TST_MI]], [[TST_GT]]
    216 
    217 # CHECK:    FCMPDrr %2, %2, implicit-def $nzcv
    218 # CHECK:    %3:gpr32 = CSINCWr $wzr, $wzr, 4, implicit $nzcv
    219 
    220 body:             |
    221   bb.0:
    222     liveins: $w0, $x0
    223 
    224     %0(s32) = COPY $s0
    225     %1(s32) = G_FCMP floatpred(one), %0, %0
    226     %4(s1) = G_TRUNC %1(s32)
    227     %6(s32) = G_ANYEXT %4
    228     $w0 = COPY %6(s32)
    229 
    230     %2(s64) = COPY $d0
    231     %3(s32) = G_FCMP floatpred(uge), %2, %2
    232     %5(s1) = G_TRUNC %3(s32)
    233     %7(s32) = G_ANYEXT %5
    234     $w0 = COPY %7(s32)
    235 
    236 ...
    237 
    238 ---
    239 # CHECK-LABEL: name: phi
    240 name:            phi
    241 legalized:       true
    242 regBankSelected: true
    243 tracksRegLiveness: true
    244 
    245 # CHECK:      registers:
    246 # CHECK-NEXT:  - { id: 0, class: fpr32, preferred-register: '' }
    247 # CHECK-NEXT:  - { id: 1, class: gpr32, preferred-register: '' }
    248 # CHECK-NEXT:  - { id: 2, class: fpr32, preferred-register: '' }
    249 registers:
    250   - { id: 0, class: fpr }
    251   - { id: 1, class: gpr }
    252   - { id: 2, class: fpr }
    253 
    254 # CHECK:  body:
    255 # CHECK:    bb.1:
    256 # CHECK:      %2:fpr32 = PHI %0, %bb.0, %2, %bb.1
    257 
    258 body:             |
    259   bb.0:
    260     liveins: $s0, $w0
    261     successors: %bb.1
    262     %0(s32) = COPY $s0
    263     %3:gpr(s32) = COPY $w0
    264     %1(s1) = G_TRUNC %3
    265 
    266   bb.1:
    267     successors: %bb.1, %bb.2
    268     %2(s32) = PHI %0, %bb.0, %2, %bb.1
    269     G_BRCOND %1, %bb.1
    270 
    271   bb.2:
    272     $s0 = COPY %2
    273     RET_ReallyLR implicit $s0
    274 ...
    275 
    276 ---
    277 # CHECK-LABEL: name: select
    278 name:            select
    279 legalized:       true
    280 regBankSelected: true
    281 tracksRegLiveness: true
    282 
    283 # CHECK:      registers:
    284 # CHECK-NEXT:  - { id: 0, class: gpr32, preferred-register: '' }
    285 # CHECK-NEXT:  - { id: 1, class: gpr32, preferred-register: '' }
    286 # CHECK-NEXT:  - { id: 2, class: gpr32, preferred-register: '' }
    287 # CHECK-NEXT:  - { id: 3, class: gpr32, preferred-register: '' }
    288 # CHECK-NEXT:  - { id: 4, class: gpr64, preferred-register: '' }
    289 # CHECK-NEXT:  - { id: 5, class: gpr64, preferred-register: '' }
    290 # CHECK-NEXT:  - { id: 6, class: gpr64, preferred-register: '' }
    291 # CHECK-NEXT:  - { id: 7, class: gpr64, preferred-register: '' }
    292 # CHECK-NEXT:  - { id: 8, class: gpr64, preferred-register: '' }
    293 # CHECK-NEXT:  - { id: 9, class: gpr64, preferred-register: '' }
    294 registers:
    295   - { id: 0, class: gpr }
    296   - { id: 1, class: gpr }
    297   - { id: 2, class: gpr }
    298   - { id: 3, class: gpr }
    299   - { id: 4, class: gpr }
    300   - { id: 5, class: gpr }
    301   - { id: 6, class: gpr }
    302   - { id: 7, class: gpr }
    303   - { id: 8, class: gpr }
    304   - { id: 9, class: gpr }
    305 
    306 # CHECK:  body:
    307 # CHECK:      $wzr = ANDSWri %10, 0, implicit-def $nzcv
    308 # CHECK:      %3:gpr32 = CSELWr %1, %2, 1, implicit $nzcv
    309 # CHECK:      $wzr = ANDSWri %10, 0, implicit-def $nzcv
    310 # CHECK:      %6:gpr64 = CSELXr %4, %5, 1, implicit $nzcv
    311 # CHECK:      $wzr = ANDSWri %10, 0, implicit-def $nzcv
    312 # CHECK:      %9:gpr64 = CSELXr %7, %8, 1, implicit $nzcv
    313 body:             |
    314   bb.0:
    315     liveins: $w0, $w1, $w2
    316     %10:gpr(s32) = COPY $w0
    317     %0(s1) = G_TRUNC %10
    318 
    319     %1(s32) = COPY $w1
    320     %2(s32) = COPY $w2
    321     %3(s32) = G_SELECT %0, %1, %2
    322     $w0 = COPY %3(s32)
    323 
    324     %4(s64) = COPY $x0
    325     %5(s64) = COPY $x1
    326     %6(s64) = G_SELECT %0, %4, %5
    327     $x0 = COPY %6(s64)
    328 
    329     %7(p0) = COPY $x0
    330     %8(p0) = COPY $x1
    331     %9(p0) = G_SELECT %0, %7, %8
    332     $x0 = COPY %9(p0)
    333 ...
    334