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