1 # RUN: llvm-mc %s -triple=mips64el-unknown-linux -show-encoding -mcpu=mips64r2 | FileCheck %s 2 # Check that the assembler can handle the documented syntax 3 # for arithmetic and logical instructions. 4 #------------------------------------------------------------------------------ 5 # Logical instructions 6 #------------------------------------------------------------------------------ 7 # CHECK: and $9, $6, $7 # encoding: [0x24,0x48,0xc7,0x00] 8 # CHECK: andi $9, $6, 17767 # encoding: [0x67,0x45,0xc9,0x30] 9 # CHECK: andi $9, $6, 17767 # encoding: [0x67,0x45,0xc9,0x30] 10 # CHECK: clo $6, $7 # encoding: [0x21,0x30,0xe6,0x70] 11 # CHECK: clz $6, $7 # encoding: [0x20,0x30,0xe6,0x70] 12 # CHECK: ins $19, $9, 6, 7 # encoding: [0x84,0x61,0x33,0x7d] 13 # CHECK: nor $9, $6, $7 # encoding: [0x27,0x48,0xc7,0x00] 14 # CHECK: or $3, $3, $5 # encoding: [0x25,0x18,0x65,0x00] 15 # CHECK: ori $4, $5, 17767 # encoding: [0x67,0x45,0xa4,0x34] 16 # CHECK: ori $9, $6, 17767 # encoding: [0x67,0x45,0xc9,0x34] 17 # CHECK: rotr $9, $6, 7 # encoding: [0xc2,0x49,0x26,0x00] 18 # CHECK: rotrv $9, $6, $7 # encoding: [0x46,0x48,0xe6,0x00] 19 # CHECK: sll $4, $3, 7 # encoding: [0xc0,0x21,0x03,0x00] 20 # CHECK: sllv $2, $3, $5 # encoding: [0x04,0x10,0xa3,0x00] 21 # CHECK: slt $3, $3, $5 # encoding: [0x2a,0x18,0x65,0x00] 22 # CHECK: slti $3, $3, 103 # encoding: [0x67,0x00,0x63,0x28] 23 # CHECK: slti $3, $3, 103 # encoding: [0x67,0x00,0x63,0x28] 24 # CHECK: sltiu $3, $3, 103 # encoding: [0x67,0x00,0x63,0x2c] 25 # CHECK: sltu $3, $3, $5 # encoding: [0x2b,0x18,0x65,0x00] 26 # CHECK: sra $4, $3, 7 # encoding: [0xc3,0x21,0x03,0x00] 27 # CHECK: srav $2, $3, $5 # encoding: [0x07,0x10,0xa3,0x00] 28 # CHECK: srl $4, $3, 7 # encoding: [0xc2,0x21,0x03,0x00] 29 # CHECK: srlv $2, $3, $5 # encoding: [0x06,0x10,0xa3,0x00] 30 # CHECK: xor $3, $3, $5 # encoding: [0x26,0x18,0x65,0x00] 31 # CHECK: xori $9, $6, 17767 # encoding: [0x67,0x45,0xc9,0x38] 32 # CHECK: xori $9, $6, 17767 # encoding: [0x67,0x45,0xc9,0x38] 33 # CHECK: wsbh $6, $7 # encoding: [0xa0,0x30,0x07,0x7c] 34 # CHECK: not $7, $8 # encoding: [0x27,0x38,0x00,0x01] 35 and $9, $6, $7 36 and $9, $6, 17767 37 andi $9, $6, 17767 38 clo $6, $7 39 clz $6, $7 40 ins $19, $9, 6,7 41 nor $9, $6, $7 42 or $3, $3, $5 43 or $4, $5, 17767 44 ori $9, $6, 17767 45 rotr $9, $6, 7 46 rotrv $9, $6, $7 47 sll $4, $3, 7 48 sllv $2, $3, $5 49 slt $3, $3, $5 50 slt $3, $3, 103 51 slti $3, $3, 103 52 sltiu $3, $3, 103 53 sltu $3, $3, $5 54 sra $4, $3, 7 55 srav $2, $3, $5 56 srl $4, $3, 7 57 srlv $2, $3, $5 58 xor $3, $3, $5 59 xor $9, $6, 17767 60 xori $9, $6, 17767 61 wsbh $6, $7 62 not $7 ,$8 63 64 #------------------------------------------------------------------------------ 65 # Arithmetic instructions 66 #------------------------------------------------------------------------------ 67 68 # CHECK: dadd $9, $6, $7 # encoding: [0x2c,0x48,0xc7,0x00] 69 # CHECK: daddi $9, $6, 17767 # encoding: [0x67,0x45,0xc9,0x60] 70 # CHECK: daddiu $9, $6, -15001 # encoding: [0x67,0xc5,0xc9,0x64] 71 # CHECK: daddi $9, $6, 17767 # encoding: [0x67,0x45,0xc9,0x60] 72 # CHECK: daddi $9, $9, 17767 # encoding: [0x67,0x45,0x29,0x61] 73 # CHECK: daddiu $9, $6, -15001 # encoding: [0x67,0xc5,0xc9,0x64] 74 # CHECK: daddiu $9, $9, -15001 # encoding: [0x67,0xc5,0x29,0x65] 75 # CHECK: daddu $9, $6, $7 # encoding: [0x2d,0x48,0xc7,0x00] 76 # CHECK: drotr $9, $6, 20 # encoding: [0x3a,0x4d,0x26,0x00] 77 # CHECK: drotr32 $9, $6, 52 # encoding: [0x3e,0x4d,0x26,0x00] 78 # CHECK: madd $6, $7 # encoding: [0x00,0x00,0xc7,0x70] 79 # CHECK: maddu $6, $7 # encoding: [0x01,0x00,0xc7,0x70] 80 # CHECK: msub $6, $7 # encoding: [0x04,0x00,0xc7,0x70] 81 # CHECK: msubu $6, $7 # encoding: [0x05,0x00,0xc7,0x70] 82 # CHECK: mult $3, $5 # encoding: [0x18,0x00,0x65,0x00] 83 # CHECK: multu $3, $5 # encoding: [0x19,0x00,0x65,0x00] 84 # CHECK: dsub $9, $6, $7 # encoding: [0x2e,0x48,0xc7,0x00] 85 # CHECK: dsubu $4, $3, $5 # encoding: [0x2f,0x20,0x65,0x00] 86 # CHECK: daddiu $9, $6, -17767 # encoding: [0x99,0xba,0xc9,0x64] 87 # CHECK: move $7, $8 # encoding: [0x2d,0x38,0x00,0x01] 88 # CHECK: .set push 89 # CHECK: .set mips32r2 90 # CHECK: rdhwr $5, $29 91 # CHECK: .set pop # encoding: [0x3b,0xe8,0x05,0x7c] 92 93 dadd $9,$6,$7 94 dadd $9,$6,17767 95 daddu $9,$6,-15001 96 daddi $9,$6,17767 97 daddi $9,17767 98 daddiu $9,$6,-15001 99 daddiu $9,-15001 100 daddu $9,$6,$7 101 drotr $9, $6, 20 102 drotr32 $9, $6, 52 103 madd $6,$7 104 maddu $6,$7 105 msub $6,$7 106 msubu $6,$7 107 mult $3,$5 108 multu $3,$5 109 dsub $9,$6,$7 110 dsubu $4,$3,$5 111 dsubu $9,$6,17767 112 move $7,$8 113 rdhwr $5, $29 114 115 #------------------------------------------------------------------------------ 116 # Shortcuts for arithmetic instructions 117 #------------------------------------------------------------------------------ 118 119 # CHECK: and $9, $9, $3 # encoding: [0x24,0x48,0x23,0x01] 120 # CHECK: dadd $9, $9, $3 # encoding: [0x2c,0x48,0x23,0x01] 121 # CHECK: daddu $9, $9, $3 # encoding: [0x2d,0x48,0x23,0x01] 122 # CHECK: daddi $9, $9, 10 # encoding: [0x0a,0x00,0x29,0x61] 123 # CHECK: daddiu $9, $9, 10 # encoding: [0x0a,0x00,0x29,0x65] 124 # CHECK: dsub $9, $9, $3 # encoding: [0x2e,0x48,0x23,0x01] 125 # CHECK: dsubu $9, $9, $3 # encoding: [0x2f,0x48,0x23,0x01] 126 # CHECK: daddi $9, $9, -10 # encoding: [0xf6,0xff,0x29,0x61] 127 # CHECK: daddiu $9, $9, -10 # encoding: [0xf6,0xff,0x29,0x65] 128 # CHECK: or $9, $9, $3 # encoding: [0x25,0x48,0x23,0x01] 129 # CHECK: xor $9, $9, $3 # encoding: [0x26,0x48,0x23,0x01] 130 and $9, $3 131 dadd $9, $3 132 daddu $9, $3 133 dadd $9, 10 134 daddu $9, 10 135 dsub $9, $3 136 dsubu $9, $3 137 dsub $9, 10 138 dsubu $9, 10 139 or $9, $3 140 xor $9, $3 141 142 #------------------------------------------------------------------------------ 143 # Did you know that GAS supports complex arithmetic expressions in assembly? 144 #------------------------------------------------------------------------------ 145 # CHECK: daddiu $9, $3, 32 # encoding: [0x20,0x00,0x69,0x64] 146 # CHECK: daddiu $9, $3, 32 # encoding: [0x20,0x00,0x69,0x64] 147 # CHECK: daddiu $9, $3, -32 # encoding: [0xe0,0xff,0x69,0x64] 148 # CHECK: daddiu $9, $3, -32 # encoding: [0xe0,0xff,0x69,0x64] 149 daddiu $9, $3, 8 * 4 150 daddiu $9, $3, (8 * 4) 151 dsubu $9, $3, 8 * 4 152 dsubu $9, $3, (8 * 4) 153