Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1 | // Copyright 2015 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
Dave Cheney | 7208a2c | 2016-04-05 15:11:08 +1000 | [diff] [blame] | 5 | // +build ignore |
| 6 | |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 7 | package main |
| 8 | |
Keith Randall | 7fc5621 | 2016-03-29 16:39:53 -0700 | [diff] [blame] | 9 | // Generic opcodes typically specify a width. The inputs and outputs |
| 10 | // of that op are the given number of bits wide. There is no notion of |
| 11 | // "sign", so Add32 can be used both for signed and unsigned 32-bit |
| 12 | // addition. |
| 13 | |
| 14 | // Signed/unsigned is explicit with the extension ops |
| 15 | // (SignExt*/ZeroExt*) and implicit as the arg to some opcodes |
| 16 | // (e.g. the second argument to shifts is unsigned). If not mentioned, |
| 17 | // all args take signed inputs, or don't care whether their inputs |
| 18 | // are signed or unsigned. |
| 19 | |
| 20 | // Unused portions of AuxInt are filled by sign-extending the used portion. |
| 21 | // Users of AuxInt which interpret AuxInt as unsigned (e.g. shifts) must be careful. |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 22 | var genericOps = []opData{ |
| 23 | // 2-input arithmetic |
Brad Fitzpatrick | 5fea2cc | 2016-03-01 23:21:55 +0000 | [diff] [blame] | 24 | // Types must be consistent with Go typing. Add, for example, must take two values |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 25 | // of the same type and produces that same type. |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 26 | {name: "Add8", argLength: 2, commutative: true}, // arg0 + arg1 |
| 27 | {name: "Add16", argLength: 2, commutative: true}, |
| 28 | {name: "Add32", argLength: 2, commutative: true}, |
| 29 | {name: "Add64", argLength: 2, commutative: true}, |
| 30 | {name: "AddPtr", argLength: 2}, // For address calculations. arg0 is a pointer and arg1 is an int. |
Keith Randall | 53f8a6a | 2017-03-30 03:30:22 +0000 | [diff] [blame] | 31 | {name: "Add32F", argLength: 2, commutative: true}, |
| 32 | {name: "Add64F", argLength: 2, commutative: true}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 33 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 34 | {name: "Sub8", argLength: 2}, // arg0 - arg1 |
| 35 | {name: "Sub16", argLength: 2}, |
| 36 | {name: "Sub32", argLength: 2}, |
| 37 | {name: "Sub64", argLength: 2}, |
| 38 | {name: "SubPtr", argLength: 2}, |
| 39 | {name: "Sub32F", argLength: 2}, |
| 40 | {name: "Sub64F", argLength: 2}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 41 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 42 | {name: "Mul8", argLength: 2, commutative: true}, // arg0 * arg1 |
| 43 | {name: "Mul16", argLength: 2, commutative: true}, |
| 44 | {name: "Mul32", argLength: 2, commutative: true}, |
| 45 | {name: "Mul64", argLength: 2, commutative: true}, |
Keith Randall | 53f8a6a | 2017-03-30 03:30:22 +0000 | [diff] [blame] | 46 | {name: "Mul32F", argLength: 2, commutative: true}, |
| 47 | {name: "Mul64F", argLength: 2, commutative: true}, |
David Chase | 997a9f3 | 2015-08-12 16:38:11 -0400 | [diff] [blame] | 48 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 49 | {name: "Div32F", argLength: 2}, // arg0 / arg1 |
| 50 | {name: "Div64F", argLength: 2}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 51 | |
Keith Randall | 53f8a6a | 2017-03-30 03:30:22 +0000 | [diff] [blame] | 52 | {name: "Hmul32", argLength: 2, commutative: true}, |
| 53 | {name: "Hmul32u", argLength: 2, commutative: true}, |
| 54 | {name: "Hmul64", argLength: 2, commutative: true}, |
| 55 | {name: "Hmul64u", argLength: 2, commutative: true}, |
Keith Randall | a3055af | 2016-02-05 20:26:18 -0800 | [diff] [blame] | 56 | |
Keith Randall | 53f8a6a | 2017-03-30 03:30:22 +0000 | [diff] [blame] | 57 | {name: "Mul32uhilo", argLength: 2, typ: "(UInt32,UInt32)", commutative: true}, // arg0 * arg1, returns (hi, lo) |
| 58 | {name: "Mul64uhilo", argLength: 2, typ: "(UInt64,UInt64)", commutative: true}, // arg0 * arg1, returns (hi, lo) |
Cherry Zhang | 2756d56 | 2016-10-06 15:43:47 -0400 | [diff] [blame] | 59 | |
Keith Randall | 708ba22 | 2017-02-13 16:00:09 -0800 | [diff] [blame] | 60 | // Weird special instructions for use in the strength reduction of divides. |
| 61 | // These ops compute unsigned (arg0 + arg1) / 2, correct to all |
| 62 | // 32/64 bits, even when the intermediate result of the add has 33/65 bits. |
| 63 | // These ops can assume arg0 >= arg1. |
Keith Randall | 53f8a6a | 2017-03-30 03:30:22 +0000 | [diff] [blame] | 64 | // Note: these ops aren't commutative! |
Keith Randall | 708ba22 | 2017-02-13 16:00:09 -0800 | [diff] [blame] | 65 | {name: "Avg32u", argLength: 2, typ: "UInt32"}, // 32-bit platforms only |
| 66 | {name: "Avg64u", argLength: 2, typ: "UInt64"}, // 64-bit platforms only |
Todd Neal | 67cbd5b | 2015-08-18 19:14:47 -0500 | [diff] [blame] | 67 | |
Keith Randall | 7fc5621 | 2016-03-29 16:39:53 -0700 | [diff] [blame] | 68 | {name: "Div8", argLength: 2}, // arg0 / arg1, signed |
| 69 | {name: "Div8u", argLength: 2}, // arg0 / arg1, unsigned |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 70 | {name: "Div16", argLength: 2}, |
| 71 | {name: "Div16u", argLength: 2}, |
| 72 | {name: "Div32", argLength: 2}, |
| 73 | {name: "Div32u", argLength: 2}, |
| 74 | {name: "Div64", argLength: 2}, |
| 75 | {name: "Div64u", argLength: 2}, |
Cherry Zhang | 2756d56 | 2016-10-06 15:43:47 -0400 | [diff] [blame] | 76 | {name: "Div128u", argLength: 3}, // arg0:arg1 / arg2 (128-bit divided by 64-bit), returns (q, r) |
Todd Neal | a45f2d8 | 2015-08-17 17:46:06 -0500 | [diff] [blame] | 77 | |
Keith Randall | 7fc5621 | 2016-03-29 16:39:53 -0700 | [diff] [blame] | 78 | {name: "Mod8", argLength: 2}, // arg0 % arg1, signed |
| 79 | {name: "Mod8u", argLength: 2}, // arg0 % arg1, unsigned |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 80 | {name: "Mod16", argLength: 2}, |
| 81 | {name: "Mod16u", argLength: 2}, |
| 82 | {name: "Mod32", argLength: 2}, |
| 83 | {name: "Mod32u", argLength: 2}, |
| 84 | {name: "Mod64", argLength: 2}, |
| 85 | {name: "Mod64u", argLength: 2}, |
Todd Neal | 57d9e7e | 2015-08-18 19:51:44 -0500 | [diff] [blame] | 86 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 87 | {name: "And8", argLength: 2, commutative: true}, // arg0 & arg1 |
| 88 | {name: "And16", argLength: 2, commutative: true}, |
| 89 | {name: "And32", argLength: 2, commutative: true}, |
| 90 | {name: "And64", argLength: 2, commutative: true}, |
Alexandru Moșoi | edff881 | 2015-07-28 14:58:49 +0200 | [diff] [blame] | 91 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 92 | {name: "Or8", argLength: 2, commutative: true}, // arg0 | arg1 |
| 93 | {name: "Or16", argLength: 2, commutative: true}, |
| 94 | {name: "Or32", argLength: 2, commutative: true}, |
| 95 | {name: "Or64", argLength: 2, commutative: true}, |
Alexandru Moșoi | 7402416 | 2015-07-29 17:52:25 +0200 | [diff] [blame] | 96 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 97 | {name: "Xor8", argLength: 2, commutative: true}, // arg0 ^ arg1 |
| 98 | {name: "Xor16", argLength: 2, commutative: true}, |
| 99 | {name: "Xor32", argLength: 2, commutative: true}, |
| 100 | {name: "Xor64", argLength: 2, commutative: true}, |
Keith Randall | 20550cb | 2015-07-28 16:04:50 -0700 | [diff] [blame] | 101 | |
Keith Randall | 4b80315 | 2015-07-29 17:07:09 -0700 | [diff] [blame] | 102 | // For shifts, AxB means the shifted value has A bits and the shift amount has B bits. |
Keith Randall | 7fc5621 | 2016-03-29 16:39:53 -0700 | [diff] [blame] | 103 | // Shift amounts are considered unsigned. |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 104 | {name: "Lsh8x8", argLength: 2}, // arg0 << arg1 |
| 105 | {name: "Lsh8x16", argLength: 2}, |
| 106 | {name: "Lsh8x32", argLength: 2}, |
| 107 | {name: "Lsh8x64", argLength: 2}, |
| 108 | {name: "Lsh16x8", argLength: 2}, |
| 109 | {name: "Lsh16x16", argLength: 2}, |
| 110 | {name: "Lsh16x32", argLength: 2}, |
| 111 | {name: "Lsh16x64", argLength: 2}, |
| 112 | {name: "Lsh32x8", argLength: 2}, |
| 113 | {name: "Lsh32x16", argLength: 2}, |
| 114 | {name: "Lsh32x32", argLength: 2}, |
| 115 | {name: "Lsh32x64", argLength: 2}, |
| 116 | {name: "Lsh64x8", argLength: 2}, |
| 117 | {name: "Lsh64x16", argLength: 2}, |
| 118 | {name: "Lsh64x32", argLength: 2}, |
| 119 | {name: "Lsh64x64", argLength: 2}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 120 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 121 | {name: "Rsh8x8", argLength: 2}, // arg0 >> arg1, signed |
| 122 | {name: "Rsh8x16", argLength: 2}, |
| 123 | {name: "Rsh8x32", argLength: 2}, |
| 124 | {name: "Rsh8x64", argLength: 2}, |
| 125 | {name: "Rsh16x8", argLength: 2}, |
| 126 | {name: "Rsh16x16", argLength: 2}, |
| 127 | {name: "Rsh16x32", argLength: 2}, |
| 128 | {name: "Rsh16x64", argLength: 2}, |
| 129 | {name: "Rsh32x8", argLength: 2}, |
| 130 | {name: "Rsh32x16", argLength: 2}, |
| 131 | {name: "Rsh32x32", argLength: 2}, |
| 132 | {name: "Rsh32x64", argLength: 2}, |
| 133 | {name: "Rsh64x8", argLength: 2}, |
| 134 | {name: "Rsh64x16", argLength: 2}, |
| 135 | {name: "Rsh64x32", argLength: 2}, |
| 136 | {name: "Rsh64x64", argLength: 2}, |
Keith Randall | 4b80315 | 2015-07-29 17:07:09 -0700 | [diff] [blame] | 137 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 138 | {name: "Rsh8Ux8", argLength: 2}, // arg0 >> arg1, unsigned |
| 139 | {name: "Rsh8Ux16", argLength: 2}, |
| 140 | {name: "Rsh8Ux32", argLength: 2}, |
| 141 | {name: "Rsh8Ux64", argLength: 2}, |
| 142 | {name: "Rsh16Ux8", argLength: 2}, |
| 143 | {name: "Rsh16Ux16", argLength: 2}, |
| 144 | {name: "Rsh16Ux32", argLength: 2}, |
| 145 | {name: "Rsh16Ux64", argLength: 2}, |
| 146 | {name: "Rsh32Ux8", argLength: 2}, |
| 147 | {name: "Rsh32Ux16", argLength: 2}, |
| 148 | {name: "Rsh32Ux32", argLength: 2}, |
| 149 | {name: "Rsh32Ux64", argLength: 2}, |
| 150 | {name: "Rsh64Ux8", argLength: 2}, |
| 151 | {name: "Rsh64Ux16", argLength: 2}, |
| 152 | {name: "Rsh64Ux32", argLength: 2}, |
| 153 | {name: "Rsh64Ux64", argLength: 2}, |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 154 | |
| 155 | // 2-input comparisons |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 156 | {name: "Eq8", argLength: 2, commutative: true, typ: "Bool"}, // arg0 == arg1 |
| 157 | {name: "Eq16", argLength: 2, commutative: true, typ: "Bool"}, |
| 158 | {name: "Eq32", argLength: 2, commutative: true, typ: "Bool"}, |
| 159 | {name: "Eq64", argLength: 2, commutative: true, typ: "Bool"}, |
| 160 | {name: "EqPtr", argLength: 2, commutative: true, typ: "Bool"}, |
| 161 | {name: "EqInter", argLength: 2, typ: "Bool"}, // arg0 or arg1 is nil; other cases handled by frontend |
| 162 | {name: "EqSlice", argLength: 2, typ: "Bool"}, // arg0 or arg1 is nil; other cases handled by frontend |
Keith Randall | 53f8a6a | 2017-03-30 03:30:22 +0000 | [diff] [blame] | 163 | {name: "Eq32F", argLength: 2, commutative: true, typ: "Bool"}, |
| 164 | {name: "Eq64F", argLength: 2, commutative: true, typ: "Bool"}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 165 | |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 166 | {name: "Neq8", argLength: 2, commutative: true, typ: "Bool"}, // arg0 != arg1 |
| 167 | {name: "Neq16", argLength: 2, commutative: true, typ: "Bool"}, |
| 168 | {name: "Neq32", argLength: 2, commutative: true, typ: "Bool"}, |
| 169 | {name: "Neq64", argLength: 2, commutative: true, typ: "Bool"}, |
| 170 | {name: "NeqPtr", argLength: 2, commutative: true, typ: "Bool"}, |
| 171 | {name: "NeqInter", argLength: 2, typ: "Bool"}, // arg0 or arg1 is nil; other cases handled by frontend |
| 172 | {name: "NeqSlice", argLength: 2, typ: "Bool"}, // arg0 or arg1 is nil; other cases handled by frontend |
Keith Randall | 53f8a6a | 2017-03-30 03:30:22 +0000 | [diff] [blame] | 173 | {name: "Neq32F", argLength: 2, commutative: true, typ: "Bool"}, |
| 174 | {name: "Neq64F", argLength: 2, commutative: true, typ: "Bool"}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 175 | |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 176 | {name: "Less8", argLength: 2, typ: "Bool"}, // arg0 < arg1, signed |
| 177 | {name: "Less8U", argLength: 2, typ: "Bool"}, // arg0 < arg1, unsigned |
| 178 | {name: "Less16", argLength: 2, typ: "Bool"}, |
| 179 | {name: "Less16U", argLength: 2, typ: "Bool"}, |
| 180 | {name: "Less32", argLength: 2, typ: "Bool"}, |
| 181 | {name: "Less32U", argLength: 2, typ: "Bool"}, |
| 182 | {name: "Less64", argLength: 2, typ: "Bool"}, |
| 183 | {name: "Less64U", argLength: 2, typ: "Bool"}, |
| 184 | {name: "Less32F", argLength: 2, typ: "Bool"}, |
| 185 | {name: "Less64F", argLength: 2, typ: "Bool"}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 186 | |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 187 | {name: "Leq8", argLength: 2, typ: "Bool"}, // arg0 <= arg1, signed |
| 188 | {name: "Leq8U", argLength: 2, typ: "Bool"}, // arg0 <= arg1, unsigned |
| 189 | {name: "Leq16", argLength: 2, typ: "Bool"}, |
| 190 | {name: "Leq16U", argLength: 2, typ: "Bool"}, |
| 191 | {name: "Leq32", argLength: 2, typ: "Bool"}, |
| 192 | {name: "Leq32U", argLength: 2, typ: "Bool"}, |
| 193 | {name: "Leq64", argLength: 2, typ: "Bool"}, |
| 194 | {name: "Leq64U", argLength: 2, typ: "Bool"}, |
| 195 | {name: "Leq32F", argLength: 2, typ: "Bool"}, |
| 196 | {name: "Leq64F", argLength: 2, typ: "Bool"}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 197 | |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 198 | {name: "Greater8", argLength: 2, typ: "Bool"}, // arg0 > arg1, signed |
| 199 | {name: "Greater8U", argLength: 2, typ: "Bool"}, // arg0 > arg1, unsigned |
| 200 | {name: "Greater16", argLength: 2, typ: "Bool"}, |
| 201 | {name: "Greater16U", argLength: 2, typ: "Bool"}, |
| 202 | {name: "Greater32", argLength: 2, typ: "Bool"}, |
| 203 | {name: "Greater32U", argLength: 2, typ: "Bool"}, |
| 204 | {name: "Greater64", argLength: 2, typ: "Bool"}, |
| 205 | {name: "Greater64U", argLength: 2, typ: "Bool"}, |
| 206 | {name: "Greater32F", argLength: 2, typ: "Bool"}, |
| 207 | {name: "Greater64F", argLength: 2, typ: "Bool"}, |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 208 | |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 209 | {name: "Geq8", argLength: 2, typ: "Bool"}, // arg0 <= arg1, signed |
| 210 | {name: "Geq8U", argLength: 2, typ: "Bool"}, // arg0 <= arg1, unsigned |
| 211 | {name: "Geq16", argLength: 2, typ: "Bool"}, |
| 212 | {name: "Geq16U", argLength: 2, typ: "Bool"}, |
| 213 | {name: "Geq32", argLength: 2, typ: "Bool"}, |
| 214 | {name: "Geq32U", argLength: 2, typ: "Bool"}, |
| 215 | {name: "Geq64", argLength: 2, typ: "Bool"}, |
| 216 | {name: "Geq64U", argLength: 2, typ: "Bool"}, |
| 217 | {name: "Geq32F", argLength: 2, typ: "Bool"}, |
| 218 | {name: "Geq64F", argLength: 2, typ: "Bool"}, |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 219 | |
Alexandru Moșoi | 8b92397 | 2016-04-24 21:21:07 +0200 | [diff] [blame] | 220 | // boolean ops |
Marvin Stenger | 9aeced6 | 2017-05-03 13:33:14 +0200 | [diff] [blame] | 221 | {name: "AndB", argLength: 2, commutative: true, typ: "Bool"}, // arg0 && arg1 (not shortcircuited) |
| 222 | {name: "OrB", argLength: 2, commutative: true, typ: "Bool"}, // arg0 || arg1 (not shortcircuited) |
| 223 | {name: "EqB", argLength: 2, commutative: true, typ: "Bool"}, // arg0 == arg1 |
| 224 | {name: "NeqB", argLength: 2, commutative: true, typ: "Bool"}, // arg0 != arg1 |
| 225 | {name: "Not", argLength: 1, typ: "Bool"}, // !arg0, boolean |
Brad Fitzpatrick | d9c72d7 | 2015-07-10 11:25:48 -0600 | [diff] [blame] | 226 | |
Alexandru Moșoi | 8b92397 | 2016-04-24 21:21:07 +0200 | [diff] [blame] | 227 | // 1-input ops |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 228 | {name: "Neg8", argLength: 1}, // -arg0 |
| 229 | {name: "Neg16", argLength: 1}, |
| 230 | {name: "Neg32", argLength: 1}, |
| 231 | {name: "Neg64", argLength: 1}, |
| 232 | {name: "Neg32F", argLength: 1}, |
| 233 | {name: "Neg64F", argLength: 1}, |
Alexandru Moșoi | 954d5ad | 2015-07-21 16:58:18 +0200 | [diff] [blame] | 234 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 235 | {name: "Com8", argLength: 1}, // ^arg0 |
| 236 | {name: "Com16", argLength: 1}, |
| 237 | {name: "Com32", argLength: 1}, |
| 238 | {name: "Com64", argLength: 1}, |
Keith Randall | 4b80315 | 2015-07-29 17:07:09 -0700 | [diff] [blame] | 239 | |
Keith Randall | 495b167 | 2017-03-16 14:08:31 -0700 | [diff] [blame] | 240 | {name: "Ctz32", argLength: 1}, // Count trailing (low order) zeroes (returns 0-32) |
| 241 | {name: "Ctz64", argLength: 1}, // Count trailing zeroes (returns 0-64) |
| 242 | {name: "BitLen32", argLength: 1}, // Number of bits in arg[0] (returns 0-32) |
| 243 | {name: "BitLen64", argLength: 1}, // Number of bits in arg[0] (returns 0-64) |
David Chase | 8eec2bb | 2016-03-11 00:10:52 -0500 | [diff] [blame] | 244 | |
David Chase | 8eec2bb | 2016-03-11 00:10:52 -0500 | [diff] [blame] | 245 | {name: "Bswap32", argLength: 1}, // Swap bytes |
| 246 | {name: "Bswap64", argLength: 1}, // Swap bytes |
| 247 | |
Keith Randall | 42e9746 | 2017-03-16 22:34:38 -0700 | [diff] [blame] | 248 | {name: "BitRev8", argLength: 1}, // Reverse the bits in arg[0] |
| 249 | {name: "BitRev16", argLength: 1}, // Reverse the bits in arg[0] |
| 250 | {name: "BitRev32", argLength: 1}, // Reverse the bits in arg[0] |
| 251 | {name: "BitRev64", argLength: 1}, // Reverse the bits in arg[0] |
| 252 | |
Keith Randall | 5cadc91 | 2017-03-16 21:33:03 -0700 | [diff] [blame] | 253 | {name: "PopCount8", argLength: 1}, // Count bits in arg[0] |
| 254 | {name: "PopCount16", argLength: 1}, // Count bits in arg[0] |
| 255 | {name: "PopCount32", argLength: 1}, // Count bits in arg[0] |
| 256 | {name: "PopCount64", argLength: 1}, // Count bits in arg[0] |
| 257 | |
Michael Munday | 7582494 | 2017-09-14 20:00:02 +0100 | [diff] [blame] | 258 | // Square root, float64 only. |
| 259 | // Special cases: |
| 260 | // +∞ → +∞ |
| 261 | // ±0 → ±0 (sign preserved) |
| 262 | // x<0 → NaN |
| 263 | // NaN → NaN |
| 264 | {name: "Sqrt", argLength: 1}, // √arg0 |
| 265 | |
| 266 | // Round to integer, float64 only. |
| 267 | // Special cases: |
| 268 | // ±∞ → ±∞ (sign preserved) |
| 269 | // ±0 → ±0 (sign preserved) |
| 270 | // NaN → NaN |
Michael Munday | 4745604 | 2017-10-30 09:02:44 -0400 | [diff] [blame] | 271 | {name: "Floor", argLength: 1}, // round arg0 toward -∞ |
| 272 | {name: "Ceil", argLength: 1}, // round arg0 toward +∞ |
| 273 | {name: "Trunc", argLength: 1}, // round arg0 toward 0 |
| 274 | {name: "Round", argLength: 1}, // round arg0 to nearest, ties away from 0 |
| 275 | {name: "RoundToEven", argLength: 1}, // round arg0 to nearest, ties to even |
Keith Randall | a329e21 | 2015-09-12 13:26:57 -0700 | [diff] [blame] | 276 | |
Lynn Boger | 4d0151e | 2017-09-28 17:11:31 -0400 | [diff] [blame] | 277 | // Modify the sign bit |
| 278 | {name: "Abs", argLength: 1}, // absolute value arg0 |
| 279 | {name: "Copysign", argLength: 2}, // copy sign from arg0 to arg1 |
| 280 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 281 | // Data movement, max argument length for Phi is indefinite so just pick |
| 282 | // a really large number |
| 283 | {name: "Phi", argLength: -1}, // select an argument based on which predecessor block we came from |
| 284 | {name: "Copy", argLength: 1}, // output = arg0 |
Keith Randall | 7807bda | 2015-11-10 15:35:36 -0800 | [diff] [blame] | 285 | // Convert converts between pointers and integers. |
| 286 | // We have a special op for this so as to not confuse GC |
| 287 | // (particularly stack maps). It takes a memory arg so it |
| 288 | // gets correctly ordered with respect to GC safepoints. |
| 289 | // arg0=ptr/int arg1=mem, output=int/ptr |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 290 | {name: "Convert", argLength: 2}, |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 291 | |
Brad Fitzpatrick | 5fea2cc | 2016-03-01 23:21:55 +0000 | [diff] [blame] | 292 | // constants. Constant values are stored in the aux or |
Keith Randall | d8a6567 | 2016-01-25 09:21:17 -0800 | [diff] [blame] | 293 | // auxint fields. |
Keith Randall | 16b1fce | 2016-01-31 11:39:39 -0800 | [diff] [blame] | 294 | {name: "ConstBool", aux: "Bool"}, // auxint is 0 for false and 1 for true |
| 295 | {name: "ConstString", aux: "String"}, // value is aux.(string) |
| 296 | {name: "ConstNil", typ: "BytePtr"}, // nil pointer |
Keith Randall | 7fc5621 | 2016-03-29 16:39:53 -0700 | [diff] [blame] | 297 | {name: "Const8", aux: "Int8"}, // auxint is sign-extended 8 bits |
| 298 | {name: "Const16", aux: "Int16"}, // auxint is sign-extended 16 bits |
| 299 | {name: "Const32", aux: "Int32"}, // auxint is sign-extended 32 bits |
Keith Randall | 708ba22 | 2017-02-13 16:00:09 -0800 | [diff] [blame] | 300 | // Note: ConstX are sign-extended even when the type of the value is unsigned. |
| 301 | // For instance, uint8(0xaa) is stored as auxint=0xffffffffffffffaa. |
| 302 | {name: "Const64", aux: "Int64"}, // value is auxint |
| 303 | {name: "Const32F", aux: "Float32"}, // value is math.Float64frombits(uint64(auxint)) and is exactly prepresentable as float 32 |
| 304 | {name: "Const64F", aux: "Float64"}, // value is math.Float64frombits(uint64(auxint)) |
| 305 | {name: "ConstInterface"}, // nil interface |
| 306 | {name: "ConstSlice"}, // nil slice |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 307 | |
| 308 | // Constant-like things |
Matthew Dempsky | 6917553 | 2017-03-09 14:46:43 -0800 | [diff] [blame] | 309 | {name: "InitMem"}, // memory input to the function. |
Keith Randall | 1787ced | 2017-09-18 14:53:56 -0700 | [diff] [blame] | 310 | {name: "Arg", aux: "SymOff", symEffect: "Read"}, // argument to the function. aux=GCNode of arg, off = offset in that arg. |
Keith Randall | 8c46aa5 | 2015-06-19 21:02:28 -0700 | [diff] [blame] | 311 | |
Keith Randall | 1787ced | 2017-09-18 14:53:56 -0700 | [diff] [blame] | 312 | // The address of a variable. arg0 is the base pointer. |
| 313 | // If the variable is a global, the base pointer will be SB and |
| 314 | // the Aux field will be a *obj.LSym. |
| 315 | // If the variable is a local, the base pointer will be SP and |
| 316 | // the Aux field will be a *gc.Node. |
Matthew Dempsky | 6917553 | 2017-03-09 14:46:43 -0800 | [diff] [blame] | 317 | {name: "Addr", argLength: 1, aux: "Sym", symEffect: "Addr"}, // Address of a variable. Arg0=SP or SB. Aux identifies the variable. |
Keith Randall | 8c46aa5 | 2015-06-19 21:02:28 -0700 | [diff] [blame] | 318 | |
Matthew Dempsky | 91d08e3 | 2017-03-14 12:18:10 -0700 | [diff] [blame] | 319 | {name: "SP"}, // stack pointer |
| 320 | {name: "SB", typ: "Uintptr"}, // static base pointer (a.k.a. globals pointer) |
| 321 | {name: "Invalid"}, // unused value |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 322 | |
| 323 | // Memory operations |
Ilya Tocar | f388468 | 2017-08-09 14:00:38 -0500 | [diff] [blame^] | 324 | {name: "Load", argLength: 2}, // Load from arg0. arg1=memory |
| 325 | {name: "Store", argLength: 3, typ: "Mem", aux: "Typ"}, // Store arg1 to arg0. arg2=memory, aux=type. Returns memory. |
| 326 | // The source and destination of Move may overlap in some cases. See e.g. |
| 327 | // memmove inlining in generic.rules. When inlineablememmovesize (in ../rewrite.go) |
| 328 | // returns true, we must do all loads before all stores, when lowering Move. |
Cherry Zhang | c8f38b3 | 2017-03-13 21:51:08 -0400 | [diff] [blame] | 329 | {name: "Move", argLength: 3, typ: "Mem", aux: "TypSize"}, // arg0=destptr, arg1=srcptr, arg2=mem, auxint=size, aux=type. Returns memory. |
| 330 | {name: "Zero", argLength: 2, typ: "Mem", aux: "TypSize"}, // arg0=destptr, arg1=mem, auxint=size, aux=type. Returns memory. |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 331 | |
Cherry Zhang | f6aec88 | 2016-10-13 06:57:00 -0400 | [diff] [blame] | 332 | // Memory operations with write barriers. |
| 333 | // Expand to runtime calls. Write barrier will be removed if write on stack. |
Cherry Zhang | c8f38b3 | 2017-03-13 21:51:08 -0400 | [diff] [blame] | 334 | {name: "StoreWB", argLength: 3, typ: "Mem", aux: "Typ"}, // Store arg1 to arg0. arg2=memory, aux=type. Returns memory. |
| 335 | {name: "MoveWB", argLength: 3, typ: "Mem", aux: "TypSize"}, // arg0=destptr, arg1=srcptr, arg2=mem, auxint=size, aux=type. Returns memory. |
| 336 | {name: "ZeroWB", argLength: 2, typ: "Mem", aux: "TypSize"}, // arg0=destptr, arg1=mem, auxint=size, aux=type. Returns memory. |
Cherry Zhang | f6aec88 | 2016-10-13 06:57:00 -0400 | [diff] [blame] | 337 | |
Austin Clements | 7e34313 | 2017-10-26 12:33:04 -0400 | [diff] [blame] | 338 | // WB invokes runtime.gcWriteBarrier. This is not a normal |
| 339 | // call: it takes arguments in registers, doesn't clobber |
| 340 | // general-purpose registers (the exact clobber set is |
| 341 | // arch-dependent), and is not a safe-point. |
| 342 | {name: "WB", argLength: 3, typ: "Mem", aux: "Sym", symEffect: "None"}, // arg0=destptr, arg1=srcptr, arg2=mem, aux=runtime.gcWriteBarrier |
| 343 | |
Brad Fitzpatrick | 5fea2cc | 2016-03-01 23:21:55 +0000 | [diff] [blame] | 344 | // Function calls. Arguments to the call have already been written to the stack. |
| 345 | // Return values appear on the stack. The method receiver, if any, is treated |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 346 | // as a phantom first argument. |
Matthew Dempsky | 6917553 | 2017-03-09 14:46:43 -0800 | [diff] [blame] | 347 | {name: "ClosureCall", argLength: 3, aux: "Int64", call: true}, // arg0=code pointer, arg1=context ptr, arg2=memory. auxint=arg size. Returns memory. |
Keith Randall | 1e72bf6 | 2016-06-08 22:02:08 -0700 | [diff] [blame] | 348 | {name: "StaticCall", argLength: 1, aux: "SymOff", call: true, symEffect: "None"}, // call function aux.(*obj.LSym), arg0=memory. auxint=arg size. Returns memory. |
Matthew Dempsky | 6917553 | 2017-03-09 14:46:43 -0800 | [diff] [blame] | 349 | {name: "InterCall", argLength: 2, aux: "Int64", call: true}, // interface call. arg0=code pointer, arg1=memory, auxint=arg size. Returns memory. |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 350 | |
Josh Bleecher Snyder | 95aff4d | 2015-07-28 14:31:25 -0700 | [diff] [blame] | 351 | // Conversions: signed extensions, zero (unsigned) extensions, truncations |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 352 | {name: "SignExt8to16", argLength: 1, typ: "Int16"}, |
Cherry Zhang | e2848de | 2016-05-06 10:13:31 -0700 | [diff] [blame] | 353 | {name: "SignExt8to32", argLength: 1, typ: "Int32"}, |
Josh Bleecher Snyder | 68dc102 | 2016-06-25 16:07:56 -0700 | [diff] [blame] | 354 | {name: "SignExt8to64", argLength: 1, typ: "Int64"}, |
Cherry Zhang | e2848de | 2016-05-06 10:13:31 -0700 | [diff] [blame] | 355 | {name: "SignExt16to32", argLength: 1, typ: "Int32"}, |
Josh Bleecher Snyder | 68dc102 | 2016-06-25 16:07:56 -0700 | [diff] [blame] | 356 | {name: "SignExt16to64", argLength: 1, typ: "Int64"}, |
| 357 | {name: "SignExt32to64", argLength: 1, typ: "Int64"}, |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 358 | {name: "ZeroExt8to16", argLength: 1, typ: "UInt16"}, |
Cherry Zhang | e2848de | 2016-05-06 10:13:31 -0700 | [diff] [blame] | 359 | {name: "ZeroExt8to32", argLength: 1, typ: "UInt32"}, |
Josh Bleecher Snyder | 68dc102 | 2016-06-25 16:07:56 -0700 | [diff] [blame] | 360 | {name: "ZeroExt8to64", argLength: 1, typ: "UInt64"}, |
Cherry Zhang | e2848de | 2016-05-06 10:13:31 -0700 | [diff] [blame] | 361 | {name: "ZeroExt16to32", argLength: 1, typ: "UInt32"}, |
Josh Bleecher Snyder | 68dc102 | 2016-06-25 16:07:56 -0700 | [diff] [blame] | 362 | {name: "ZeroExt16to64", argLength: 1, typ: "UInt64"}, |
| 363 | {name: "ZeroExt32to64", argLength: 1, typ: "UInt64"}, |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 364 | {name: "Trunc16to8", argLength: 1}, |
| 365 | {name: "Trunc32to8", argLength: 1}, |
| 366 | {name: "Trunc32to16", argLength: 1}, |
| 367 | {name: "Trunc64to8", argLength: 1}, |
| 368 | {name: "Trunc64to16", argLength: 1}, |
| 369 | {name: "Trunc64to32", argLength: 1}, |
Keith Randall | 2a5e6c4 | 2015-07-23 14:35:02 -0700 | [diff] [blame] | 370 | |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 371 | {name: "Cvt32to32F", argLength: 1}, |
| 372 | {name: "Cvt32to64F", argLength: 1}, |
| 373 | {name: "Cvt64to32F", argLength: 1}, |
| 374 | {name: "Cvt64to64F", argLength: 1}, |
| 375 | {name: "Cvt32Fto32", argLength: 1}, |
| 376 | {name: "Cvt32Fto64", argLength: 1}, |
| 377 | {name: "Cvt64Fto32", argLength: 1}, |
| 378 | {name: "Cvt64Fto64", argLength: 1}, |
| 379 | {name: "Cvt32Fto64F", argLength: 1}, |
| 380 | {name: "Cvt64Fto32F", argLength: 1}, |
David Chase | 4282588 | 2015-08-20 15:14:20 -0400 | [diff] [blame] | 381 | |
Michael Munday | bd8a39b | 2017-02-12 22:12:12 -0500 | [diff] [blame] | 382 | // Force rounding to precision of type. |
| 383 | {name: "Round32F", argLength: 1}, |
| 384 | {name: "Round64F", argLength: 1}, |
| 385 | |
Josh Bleecher Snyder | 7e74e43 | 2015-07-24 11:55:52 -0700 | [diff] [blame] | 386 | // Automatically inserted safety checks |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 387 | {name: "IsNonNil", argLength: 1, typ: "Bool"}, // arg0 != nil |
Keith Randall | 7fc5621 | 2016-03-29 16:39:53 -0700 | [diff] [blame] | 388 | {name: "IsInBounds", argLength: 2, typ: "Bool"}, // 0 <= arg0 < arg1. arg1 is guaranteed >= 0. |
| 389 | {name: "IsSliceInBounds", argLength: 2, typ: "Bool"}, // 0 <= arg0 <= arg1. arg1 is guaranteed >= 0. |
Keith Randall | 3134ab3 | 2016-09-13 17:01:01 -0700 | [diff] [blame] | 390 | {name: "NilCheck", argLength: 2, typ: "Void"}, // arg0=ptr, arg1=mem. Panics if arg0 is nil. Returns void. |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 391 | |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 392 | // Pseudo-ops |
Keith Randall | 7fc5621 | 2016-03-29 16:39:53 -0700 | [diff] [blame] | 393 | {name: "GetG", argLength: 1}, // runtime.getg() (read g pointer). arg0=mem |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 394 | {name: "GetClosurePtr"}, // get closure pointer from dedicated register |
David Chase | 6cac100 | 2016-10-24 10:25:05 -0400 | [diff] [blame] | 395 | {name: "GetCallerPC"}, // for getcallerpc intrinsic |
Cherry Zhang | 6f3e5e6 | 2017-10-09 15:33:29 -0400 | [diff] [blame] | 396 | {name: "GetCallerSP"}, // for getcallersp intrinsic |
Josh Bleecher Snyder | 463858e | 2015-08-11 09:47:45 -0700 | [diff] [blame] | 397 | |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 398 | // Indexing operations |
Keith Randall | 7414450 | 2016-10-30 21:10:03 -0700 | [diff] [blame] | 399 | {name: "PtrIndex", argLength: 2}, // arg0=ptr, arg1=index. Computes ptr+sizeof(*v.type)*index, where index is extended to ptrwidth type |
| 400 | {name: "OffPtr", argLength: 1, aux: "Int64"}, // arg0 + auxint (arg0 and result are pointers) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 401 | |
| 402 | // Slices |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 403 | {name: "SliceMake", argLength: 3}, // arg0=ptr, arg1=len, arg2=cap |
| 404 | {name: "SlicePtr", argLength: 1, typ: "BytePtr"}, // ptr(arg0) |
| 405 | {name: "SliceLen", argLength: 1}, // len(arg0) |
| 406 | {name: "SliceCap", argLength: 1}, // cap(arg0) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 407 | |
David Chase | 5257858 | 2015-08-28 14:24:10 -0400 | [diff] [blame] | 408 | // Complex (part/whole) |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 409 | {name: "ComplexMake", argLength: 2}, // arg0=real, arg1=imag |
| 410 | {name: "ComplexReal", argLength: 1}, // real(arg0) |
| 411 | {name: "ComplexImag", argLength: 1}, // imag(arg0) |
David Chase | 5257858 | 2015-08-28 14:24:10 -0400 | [diff] [blame] | 412 | |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 413 | // Strings |
Keith Randall | 3572c64 | 2016-04-21 19:28:28 -0700 | [diff] [blame] | 414 | {name: "StringMake", argLength: 2}, // arg0=ptr, arg1=len |
| 415 | {name: "StringPtr", argLength: 1, typ: "BytePtr"}, // ptr(arg0) |
| 416 | {name: "StringLen", argLength: 1, typ: "Int"}, // len(arg0) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 417 | |
Keith Randall | d1c15a0 | 2015-08-04 15:47:22 -0700 | [diff] [blame] | 418 | // Interfaces |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 419 | {name: "IMake", argLength: 2}, // arg0=itab, arg1=data |
| 420 | {name: "ITab", argLength: 1, typ: "BytePtr"}, // arg0=interface, returns itable field |
| 421 | {name: "IData", argLength: 1}, // arg0=interface, returns data field |
Keith Randall | d1c15a0 | 2015-08-04 15:47:22 -0700 | [diff] [blame] | 422 | |
Keith Randall | a734bbc | 2016-01-11 21:05:33 -0800 | [diff] [blame] | 423 | // Structs |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 424 | {name: "StructMake0"}, // Returns struct with 0 fields. |
| 425 | {name: "StructMake1", argLength: 1}, // arg0=field0. Returns struct. |
| 426 | {name: "StructMake2", argLength: 2}, // arg0,arg1=field0,field1. Returns struct. |
| 427 | {name: "StructMake3", argLength: 3}, // arg0..2=field0..2. Returns struct. |
| 428 | {name: "StructMake4", argLength: 4}, // arg0..3=field0..3. Returns struct. |
| 429 | {name: "StructSelect", argLength: 1, aux: "Int64"}, // arg0=struct, auxint=field index. Returns the auxint'th field. |
Keith Randall | a734bbc | 2016-01-11 21:05:33 -0800 | [diff] [blame] | 430 | |
Keith Randall | 7414450 | 2016-10-30 21:10:03 -0700 | [diff] [blame] | 431 | // Arrays |
| 432 | {name: "ArrayMake0"}, // Returns array with 0 elements |
| 433 | {name: "ArrayMake1", argLength: 1}, // Returns array with 1 element |
| 434 | {name: "ArraySelect", argLength: 1, aux: "Int64"}, // arg0=array, auxint=index. Returns a[i]. |
| 435 | |
Brad Fitzpatrick | 5fea2cc | 2016-03-01 23:21:55 +0000 | [diff] [blame] | 436 | // Spill&restore ops for the register allocator. These are |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 437 | // semantically identical to OpCopy; they do not take/return |
Brad Fitzpatrick | 5fea2cc | 2016-03-01 23:21:55 +0000 | [diff] [blame] | 438 | // stores like regular memory ops do. We can get away without memory |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 439 | // args because we know there is no aliasing of spill slots on the stack. |
Todd Neal | 4e95dfe | 2016-02-27 08:04:48 -0600 | [diff] [blame] | 440 | {name: "StoreReg", argLength: 1}, |
| 441 | {name: "LoadReg", argLength: 1}, |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 442 | |
Brad Fitzpatrick | 5fea2cc | 2016-03-01 23:21:55 +0000 | [diff] [blame] | 443 | // Used during ssa construction. Like Copy, but the arg has not been specified yet. |
Matthew Dempsky | 6917553 | 2017-03-09 14:46:43 -0800 | [diff] [blame] | 444 | {name: "FwdRef", aux: "Sym", symEffect: "None"}, |
Keith Randall | d2107fc | 2015-08-24 02:16:19 -0700 | [diff] [blame] | 445 | |
Brad Fitzpatrick | 5fea2cc | 2016-03-01 23:21:55 +0000 | [diff] [blame] | 446 | // Unknown value. Used for Values whose values don't matter because they are dead code. |
Keith Randall | b5c5efd | 2016-01-14 16:02:23 -0800 | [diff] [blame] | 447 | {name: "Unknown"}, |
| 448 | |
Matthew Dempsky | 6917553 | 2017-03-09 14:46:43 -0800 | [diff] [blame] | 449 | {name: "VarDef", argLength: 1, aux: "Sym", typ: "Mem", symEffect: "None"}, // aux is a *gc.Node of a variable that is about to be initialized. arg0=mem, returns mem |
| 450 | {name: "VarKill", argLength: 1, aux: "Sym", symEffect: "None"}, // aux is a *gc.Node of a variable that is known to be dead. arg0=mem, returns mem |
Keith Randall | 1787ced | 2017-09-18 14:53:56 -0700 | [diff] [blame] | 451 | {name: "VarLive", argLength: 1, aux: "Sym", symEffect: "Read"}, // aux is a *gc.Node of a variable that must be kept live. arg0=mem, returns mem |
Matthew Dempsky | 6917553 | 2017-03-09 14:46:43 -0800 | [diff] [blame] | 452 | {name: "KeepAlive", argLength: 2, typ: "Mem"}, // arg[0] is a value that must be kept alive until this mark. arg[1]=mem, returns mem |
Heschi Kreinick | 4c54a04 | 2017-07-21 18:30:19 -0400 | [diff] [blame] | 453 | {name: "RegKill"}, // regalloc has determined that the value in this register is dead |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 454 | |
| 455 | // Ops for breaking 64-bit operations on 32-bit architectures |
| 456 | {name: "Int64Make", argLength: 2, typ: "UInt64"}, // arg0=hi, arg1=lo |
| 457 | {name: "Int64Hi", argLength: 1, typ: "UInt32"}, // high 32-bit of arg0 |
| 458 | {name: "Int64Lo", argLength: 1, typ: "UInt32"}, // low 32-bit of arg0 |
| 459 | |
Keith Randall | 320ddcf | 2016-08-23 16:49:28 -0700 | [diff] [blame] | 460 | {name: "Add32carry", argLength: 2, commutative: true, typ: "(UInt32,Flags)"}, // arg0 + arg1, returns (value, carry) |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 461 | {name: "Add32withcarry", argLength: 3, commutative: true}, // arg0 + arg1 + arg2, arg2=carry (0 or 1) |
| 462 | |
Keith Randall | 320ddcf | 2016-08-23 16:49:28 -0700 | [diff] [blame] | 463 | {name: "Sub32carry", argLength: 2, typ: "(UInt32,Flags)"}, // arg0 - arg1, returns (value, carry) |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 464 | {name: "Sub32withcarry", argLength: 3}, // arg0 - arg1 - arg2, arg2=carry (0 or 1) |
| 465 | |
Cherry Zhang | 4636d02 | 2016-05-25 23:17:42 -0400 | [diff] [blame] | 466 | {name: "Signmask", argLength: 1, typ: "Int32"}, // 0 if arg0 >= 0, -1 if arg0 < 0 |
| 467 | {name: "Zeromask", argLength: 1, typ: "UInt32"}, // 0 if arg0 == 0, 0xffffffff if arg0 != 0 |
Keith Randall | deb4177 | 2016-10-25 15:49:52 -0700 | [diff] [blame] | 468 | {name: "Slicemask", argLength: 1}, // 0 if arg0 == 0, -1 if arg0 > 0, undef if arg0<0. Type is native int size. |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 469 | |
Cherry Zhang | 59e11d7 | 2016-05-31 11:27:16 -0400 | [diff] [blame] | 470 | {name: "Cvt32Uto32F", argLength: 1}, // uint32 -> float32, only used on 32-bit arch |
| 471 | {name: "Cvt32Uto64F", argLength: 1}, // uint32 -> float64, only used on 32-bit arch |
| 472 | {name: "Cvt32Fto32U", argLength: 1}, // float32 -> uint32, only used on 32-bit arch |
| 473 | {name: "Cvt64Fto32U", argLength: 1}, // float64 -> uint32, only used on 32-bit arch |
Cherry Zhang | 659dd4f | 2016-08-16 14:17:33 -0400 | [diff] [blame] | 474 | {name: "Cvt64Uto32F", argLength: 1}, // uint64 -> float32, only used on archs that has the instruction |
| 475 | {name: "Cvt64Uto64F", argLength: 1}, // uint64 -> float64, only used on archs that has the instruction |
| 476 | {name: "Cvt32Fto64U", argLength: 1}, // float32 -> uint64, only used on archs that has the instruction |
| 477 | {name: "Cvt64Fto64U", argLength: 1}, // float64 -> uint64, only used on archs that has the instruction |
Cherry Zhang | 59e11d7 | 2016-05-31 11:27:16 -0400 | [diff] [blame] | 478 | |
Cherry Zhang | 8756d92 | 2016-05-18 18:14:36 -0400 | [diff] [blame] | 479 | // pseudo-ops for breaking Tuple |
| 480 | {name: "Select0", argLength: 1}, // the first component of a tuple |
| 481 | {name: "Select1", argLength: 1}, // the second component of a tuple |
Keith Randall | 320ddcf | 2016-08-23 16:49:28 -0700 | [diff] [blame] | 482 | |
| 483 | // Atomic operations used for semantically inlining runtime/internal/atomic. |
| 484 | // Atomic loads return a new memory so that the loads are properly ordered |
| 485 | // with respect to other loads and stores. |
| 486 | // TODO: use for sync/atomic at some point. |
David Chase | 11b2830 | 2017-02-21 15:22:52 -0500 | [diff] [blame] | 487 | {name: "AtomicLoad32", argLength: 2, typ: "(UInt32,Mem)"}, // Load from arg0. arg1=memory. Returns loaded value and new memory. |
| 488 | {name: "AtomicLoad64", argLength: 2, typ: "(UInt64,Mem)"}, // Load from arg0. arg1=memory. Returns loaded value and new memory. |
| 489 | {name: "AtomicLoadPtr", argLength: 2, typ: "(BytePtr,Mem)"}, // Load from arg0. arg1=memory. Returns loaded value and new memory. |
| 490 | {name: "AtomicStore32", argLength: 3, typ: "Mem", hasSideEffects: true}, // Store arg1 to *arg0. arg2=memory. Returns memory. |
| 491 | {name: "AtomicStore64", argLength: 3, typ: "Mem", hasSideEffects: true}, // Store arg1 to *arg0. arg2=memory. Returns memory. |
| 492 | {name: "AtomicStorePtrNoWB", argLength: 3, typ: "Mem", hasSideEffects: true}, // Store arg1 to *arg0. arg2=memory. Returns memory. |
| 493 | {name: "AtomicExchange32", argLength: 3, typ: "(UInt32,Mem)", hasSideEffects: true}, // Store arg1 to *arg0. arg2=memory. Returns old contents of *arg0 and new memory. |
| 494 | {name: "AtomicExchange64", argLength: 3, typ: "(UInt64,Mem)", hasSideEffects: true}, // Store arg1 to *arg0. arg2=memory. Returns old contents of *arg0 and new memory. |
| 495 | {name: "AtomicAdd32", argLength: 3, typ: "(UInt32,Mem)", hasSideEffects: true}, // Do *arg0 += arg1. arg2=memory. Returns sum and new memory. |
| 496 | {name: "AtomicAdd64", argLength: 3, typ: "(UInt64,Mem)", hasSideEffects: true}, // Do *arg0 += arg1. arg2=memory. Returns sum and new memory. |
| 497 | {name: "AtomicCompareAndSwap32", argLength: 4, typ: "(Bool,Mem)", hasSideEffects: true}, // if *arg0==arg1, then set *arg0=arg2. Returns true iff store happens and new memory. |
| 498 | {name: "AtomicCompareAndSwap64", argLength: 4, typ: "(Bool,Mem)", hasSideEffects: true}, // if *arg0==arg1, then set *arg0=arg2. Returns true iff store happens and new memory. |
| 499 | {name: "AtomicAnd8", argLength: 3, typ: "Mem", hasSideEffects: true}, // *arg0 &= arg1. arg2=memory. Returns memory. |
| 500 | {name: "AtomicOr8", argLength: 3, typ: "Mem", hasSideEffects: true}, // *arg0 |= arg1. arg2=memory. Returns memory. |
Keith Randall | 1e72bf6 | 2016-06-08 22:02:08 -0700 | [diff] [blame] | 501 | |
| 502 | // Clobber experiment op |
| 503 | {name: "Clobber", argLength: 0, typ: "Void", aux: "SymOff", symEffect: "None"}, // write an invalid pointer value to the given pointer slot of a stack variable |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 504 | } |
| 505 | |
Keith Randall | f5c53e0 | 2015-09-09 18:03:41 -0700 | [diff] [blame] | 506 | // kind control successors implicit exit |
| 507 | // ---------------------------------------------------------- |
| 508 | // Exit return mem [] yes |
| 509 | // Ret return mem [] yes |
| 510 | // RetJmp return mem [] yes |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 511 | // Plain nil [next] |
| 512 | // If a boolean Value [then, else] |
Keith Randall | f5c53e0 | 2015-09-09 18:03:41 -0700 | [diff] [blame] | 513 | // Call mem [next] yes (control opcode should be OpCall or OpStaticCall) |
Keith Randall | 31115a5 | 2015-10-23 19:12:49 -0700 | [diff] [blame] | 514 | // Check void [next] yes (control opcode should be Op{Lowered}NilCheck) |
Keith Randall | a7cfc759 | 2015-09-08 16:04:37 -0700 | [diff] [blame] | 515 | // First nil [always,never] |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 516 | |
| 517 | var genericBlocks = []blockData{ |
Keith Randall | 8a1f621 | 2015-09-08 21:28:44 -0700 | [diff] [blame] | 518 | {name: "Plain"}, // a single successor |
| 519 | {name: "If"}, // 2 successors, if control goto Succs[0] else goto Succs[1] |
Keith Randall | ddc6b64 | 2016-03-09 19:27:57 -0800 | [diff] [blame] | 520 | {name: "Defer"}, // 2 successors, Succs[0]=defer queued, Succs[1]=defer recovered. control is call op (of memory type) |
Keith Randall | f5c53e0 | 2015-09-09 18:03:41 -0700 | [diff] [blame] | 521 | {name: "Ret"}, // no successors, control value is memory result |
| 522 | {name: "RetJmp"}, // no successors, jumps to b.Aux.(*gc.Sym) |
| 523 | {name: "Exit"}, // no successors, control value generates a panic |
| 524 | |
Keith Randall | 6ed79fb | 2016-04-28 15:04:10 -0700 | [diff] [blame] | 525 | // transient block state used for dead code removal |
Keith Randall | f5c53e0 | 2015-09-09 18:03:41 -0700 | [diff] [blame] | 526 | {name: "First"}, // 2 successors, always takes the first one (second is dead) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 527 | } |
| 528 | |
| 529 | func init() { |
Michael Pratt | a4e31d4 | 2016-03-12 14:07:40 -0800 | [diff] [blame] | 530 | archs = append(archs, arch{ |
Keith Randall | 4c9a470 | 2016-03-21 22:57:26 -0700 | [diff] [blame] | 531 | name: "generic", |
| 532 | ops: genericOps, |
| 533 | blocks: genericBlocks, |
| 534 | generic: true, |
Michael Pratt | a4e31d4 | 2016-03-12 14:07:40 -0800 | [diff] [blame] | 535 | }) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 536 | } |