Home | History | Annotate | Download | only in Mips
      1 # RUN: llvm-mc %s -triple=mipsel -show-encoding -mattr=micromips | \
      2 # RUN: FileCheck -check-prefix=CHECK-EL %s
      3 # RUN: llvm-mc %s -triple=mips -show-encoding -mattr=micromips | \
      4 # RUN: FileCheck -check-prefix=CHECK-EB %s
      5 # Check that the assembler can handle the documented syntax
      6 # for arithmetic and logical instructions.
      7 #------------------------------------------------------------------------------
      8 # MicroMIPS 16-bit Instructions
      9 #------------------------------------------------------------------------------
     10 # Little endian
     11 #------------------------------------------------------------------------------
     12 # CHECK-EL: addu16  $6, $17, $4     # encoding: [0x42,0x07]
     13 # CHECK-EL: subu16  $5, $16, $3     # encoding: [0xb1,0x06]
     14 # CHECK-EL: andi16  $16, $2, 31     # encoding: [0x29,0x2c]
     15 # CHECK-EL: and16   $16, $2         # encoding: [0x82,0x44]
     16 # CHECK-EL: not16   $17, $3         # encoding: [0x0b,0x44]
     17 # CHECK-EL: or16    $16, $4         # encoding: [0xc4,0x44]
     18 # CHECK-EL: xor16   $17, $5         # encoding: [0x4d,0x44]
     19 # CHECK-EL: sll16   $3, $16, 5      # encoding: [0x8a,0x25]
     20 # CHECK-EL: srl16   $4, $17, 6      # encoding: [0x1d,0x26]
     21 # CHECK-EL: lbu16   $3, 4($17)      # encoding: [0x94,0x09]
     22 # CHECK-EL: lbu16   $3, -1($16)     # encoding: [0x8f,0x09]
     23 # CHECK-EL: lhu16   $3, 4($16)      # encoding: [0x82,0x29]
     24 # CHECK-EL: lw16    $4, 8($17)      # encoding: [0x12,0x6a]
     25 # CHECK-EL: sb16    $3, 4($16)      # encoding: [0x84,0x89]
     26 # CHECK-EL: sh16    $4, 8($17)      # encoding: [0x14,0xaa]
     27 # CHECK-EL: sw16    $4, 4($17)      # encoding: [0x11,0xea]
     28 # CHECK-EL: sw16    $zero, 4($17)   # encoding: [0x11,0xe8]
     29 # CHECK-EL: lw      $3, 32($gp)     # encoding: [0x88,0x65]
     30 # CHECK-EL: lw      $3, 32($sp)     # encoding: [0x68,0x48]
     31 # CHECK-EL: sw      $4, 124($sp)    # encoding: [0x9f,0xc8]
     32 # CHECK-EL: li16    $3, -1          # encoding: [0xff,0xed]
     33 # CHECK-EL: li16    $3, 126         # encoding: [0xfe,0xed]
     34 # CHECK-EL: addiur1sp $7, 4         # encoding: [0x83,0x6f]
     35 # CHECK-EL: addiur2 $6, $7, -1      # encoding: [0x7e,0x6f]
     36 # CHECK-EL: addiur2 $6, $7, 12      # encoding: [0x76,0x6f]
     37 # CHECK-EL: addius5 $7, -2          # encoding: [0xfc,0x4c]
     38 # CHECK-EL: addiusp -1028           # encoding: [0xff,0x4f]
     39 # CHECK-EL: addiusp -1032           # encoding: [0xfd,0x4f]
     40 # CHECK-EL: addiusp 1024            # encoding: [0x01,0x4c]
     41 # CHECK-EL: addiusp 1028            # encoding: [0x03,0x4c]
     42 # CHECK-EL: addiusp -16             # encoding: [0xf9,0x4f]
     43 # CHECK-EL: mfhi    $9              # encoding: [0x09,0x46]
     44 # CHECK-EL: mflo    $9              # encoding: [0x49,0x46]
     45 # CHECK-EL: move    $25, $1         # encoding: [0x21,0x0f]
     46 # CHECK-EL: movep   $5, $6, $2, $3  # encoding: [0x34,0x84]
     47 # CHECK-EL: jrc     $9              # encoding: [0xa9,0x45]
     48 # CHECK-NEXT: jalr    $9            # encoding: [0xc9,0x45]
     49 # CHECK-EL: jraddiusp 20            # encoding: [0x05,0x47]
     50 # CHECK-NEXT: jalrs16 $9            # encoding: [0xe9,0x45]
     51 # CHECK-EL: nop                     # encoding: [0x00,0x0c]
     52 # CHECK-EL: jr16    $9              # encoding: [0x89,0x45]
     53 # CHECK-EL: nop                     # encoding: [0x00,0x00,0x00,0x00]
     54 # CHECK-EL: beqz16 $6, 20           # encoding: [0x0a,0x8f]
     55 # CHECK-EL: nop                     # encoding: [0x00,0x00,0x00,0x00]
     56 # CHECK-EL: bnez16 $6, 20           # encoding: [0x0a,0xaf]
     57 # CHECK-EL: nop                     # encoding: [0x00,0x00,0x00,0x00]
     58 # CHECK-EL: b16 132                 # encoding: [0x42,0xcc]
     59 # CHECK-EL: nop
     60 # CHECK-EL: b16 132                 # encoding: [0x42,0xcc]
     61 # CHECK-EL: nop
     62 # CHECK-EL: break16 8               # encoding: [0x88,0x46]
     63 # CHECK-EL: sdbbp16 14              # encoding: [0xce,0x46]
     64 #------------------------------------------------------------------------------
     65 # Big endian
     66 #------------------------------------------------------------------------------
     67 # CHECK-EB: addu16  $6, $17, $4     # encoding: [0x07,0x42]
     68 # CHECK-EB: subu16  $5, $16, $3     # encoding: [0x06,0xb1]
     69 # CHECK-EB: andi16  $16, $2, 31     # encoding: [0x2c,0x29]
     70 # CHECK-EB: and16   $16, $2         # encoding: [0x44,0x82]
     71 # CHECK-EB: not16   $17, $3         # encoding: [0x44,0x0b]
     72 # CHECK-EB: or16    $16, $4         # encoding: [0x44,0xc4]
     73 # CHECK-EB: xor16   $17, $5         # encoding: [0x44,0x4d]
     74 # CHECK-EB: sll16   $3, $16, 5      # encoding: [0x25,0x8a]
     75 # CHECK-EB: srl16   $4, $17, 6      # encoding: [0x26,0x1d]
     76 # CHECK-EB: lbu16   $3, 4($17)      # encoding: [0x09,0x94]
     77 # CHECK-EB: lbu16   $3, -1($16)     # encoding: [0x09,0x8f]
     78 # CHECK-EB: lhu16   $3, 4($16)      # encoding: [0x29,0x82]
     79 # CHECK-EB: lw16    $4, 8($17)      # encoding: [0x6a,0x12]
     80 # CHECK-EB: sb16    $3, 4($16)      # encoding: [0x89,0x84]
     81 # CHECK-EB: sh16    $4, 8($17)      # encoding: [0xaa,0x14]
     82 # CHECK-EB: sw16    $4, 4($17)      # encoding: [0xea,0x11]
     83 # CHECK-EB: sw16    $zero, 4($17)   # encoding: [0xe8,0x11]
     84 # CHECK-EB: lw      $3, 32($gp)     # encoding: [0x65,0x88]
     85 # CHECK-EB: lw      $3, 32($sp)     # encoding: [0x48,0x68]
     86 # CHECK-EB: sw      $4, 124($sp)    # encoding: [0xc8,0x9f]
     87 # CHECK-EB: li16    $3, -1          # encoding: [0xed,0xff]
     88 # CHECK-EB: li16    $3, 126         # encoding: [0xed,0xfe]
     89 # CHECK-EB: addiur1sp $7, 4         # encoding: [0x6f,0x83]
     90 # CHECK-EB: addiur2 $6, $7, -1      # encoding: [0x6f,0x7e]
     91 # CHECK-EB: addiur2 $6, $7, 12      # encoding: [0x6f,0x76]
     92 # CHECK-EB: addius5 $7, -2          # encoding: [0x4c,0xfc]
     93 # CHECK-EB: addiusp -1028           # encoding: [0x4f,0xff]
     94 # CHECK-EB: addiusp -1032           # encoding: [0x4f,0xfd]
     95 # CHECK-EB: addiusp 1024            # encoding: [0x4c,0x01]
     96 # CHECK-EB: addiusp 1028            # encoding: [0x4c,0x03]
     97 # CHECK-EB: addiusp -16             # encoding: [0x4f,0xf9]
     98 # CHECK-EB: mfhi    $9              # encoding: [0x46,0x09]
     99 # CHECK-EB: mflo    $9              # encoding: [0x46,0x49]
    100 # CHECK-EB: move    $25, $1         # encoding: [0x0f,0x21]
    101 # CHECK-EB: movep   $5, $6, $2, $3  # encoding: [0x84,0x34]
    102 # CHECK-EB: jrc     $9              # encoding: [0x45,0xa9]
    103 # CHECK-NEXT: jalr    $9            # encoding: [0x45,0xc9]
    104 # CHECK-EB: jraddiusp 20            # encoding: [0x47,0x05]
    105 # CHECK-NEXT: jalrs16 $9            # encoding: [0x45,0xe9]
    106 # CHECK-EB: nop                     # encoding: [0x0c,0x00]
    107 # CHECK-EB: jr16    $9              # encoding: [0x45,0x89]
    108 # CHECK-EB: nop                     # encoding: [0x00,0x00,0x00,0x00]
    109 # CHECK-EB: beqz16 $6, 20           # encoding: [0x8f,0x0a]
    110 # CHECK-EB: nop                     # encoding: [0x00,0x00,0x00,0x00]
    111 # CHECK-EB: bnez16 $6, 20           # encoding: [0xaf,0x0a]
    112 # CHECK-EB: nop                     # encoding: [0x00,0x00,0x00,0x00]
    113 # CHECK-EB: b16 132                 # encoding: [0xcc,0x42]
    114 # CHECK-EB: nop
    115 # CHECK-EB: b16 132                 # encoding: [0xcc,0x42]
    116 # CHECK-EB: nop
    117 # CHECK-EB: break16 8               # encoding: [0x46,0x88]
    118 # CHECK-EB: sdbbp16 14              # encoding: [0x46,0xce]
    119 
    120     addu16  $6, $17, $4
    121     subu16  $5, $16, $3
    122     andi16  $16, $2, 31
    123     and16   $16, $2
    124     not16   $17, $3
    125     or16    $16, $4
    126     xor16   $17, $5
    127     sll16   $3, $16, 5
    128     srl16   $4, $17, 6
    129     lbu16   $3, 4($17)
    130     lbu16   $3, -1($16)
    131     lhu16   $3, 4($16)
    132     lw16    $4, 8($17)
    133     sb16    $3, 4($16)
    134     sh16    $4, 8($17)
    135     sw16    $4, 4($17)
    136     sw16    $0, 4($17)
    137     lw      $3, 32($gp)
    138     lw      $3, 32($sp)
    139     sw      $4, 124($sp)
    140     li16    $3, -1
    141     li16    $3, 126
    142     addiur1sp $7, 4
    143     addiur2 $6, $7, -1
    144     addiur2 $6, $7, 12
    145     addius5 $7, -2
    146     addiusp -1028
    147     addiusp -1032
    148     addiusp 1024
    149     addiusp 1028
    150     addiusp -16
    151     mfhi    $9
    152     mflo    $9
    153     move    $25, $1
    154     movep   $5, $6, $2, $3
    155     jrc     $9
    156     jalr    $9
    157     jraddiusp 20
    158     jalrs16 $9
    159     jr16    $9
    160     beqz16 $6, 20
    161     bnez16 $6, 20
    162     b   132
    163     b16 132
    164     break16 8
    165     sdbbp16 14
    166