Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1 | // autogenerated from gen/generic.rules: do not edit! |
| 2 | // generated with: cd gen; go run *.go |
| 3 | package ssa |
| 4 | |
| 5 | func rewriteValuegeneric(v *Value, config *Config) bool { |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 6 | b := v.Block |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 7 | switch v.Op { |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 8 | case OpAdd64: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 9 | // match: (Add64 (Const64 [c]) (Const64 [d])) |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 10 | // cond: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 11 | // result: (Const64 [c+d]) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 12 | { |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 13 | if v.Args[0].Op != OpConst64 { |
| 14 | goto end8c46df6f85a11cb1d594076b0e467908 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 15 | } |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 16 | c := v.Args[0].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 17 | if v.Args[1].Op != OpConst64 { |
| 18 | goto end8c46df6f85a11cb1d594076b0e467908 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 19 | } |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 20 | d := v.Args[1].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 21 | v.Op = OpConst64 |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 22 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 23 | v.Aux = nil |
| 24 | v.resetArgs() |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 25 | v.AuxInt = c + d |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 26 | return true |
| 27 | } |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 28 | goto end8c46df6f85a11cb1d594076b0e467908 |
| 29 | end8c46df6f85a11cb1d594076b0e467908: |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 30 | ; |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 31 | case OpAddPtr: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 32 | // match: (AddPtr (ConstPtr [c]) (ConstPtr [d])) |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 33 | // cond: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 34 | // result: (ConstPtr [c+d]) |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 35 | { |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 36 | if v.Args[0].Op != OpConstPtr { |
| 37 | goto end145c1aec793b2befff34bc8983b48a38 |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 38 | } |
| 39 | c := v.Args[0].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 40 | if v.Args[1].Op != OpConstPtr { |
| 41 | goto end145c1aec793b2befff34bc8983b48a38 |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 42 | } |
| 43 | d := v.Args[1].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 44 | v.Op = OpConstPtr |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 45 | v.AuxInt = 0 |
| 46 | v.Aux = nil |
| 47 | v.resetArgs() |
| 48 | v.AuxInt = c + d |
| 49 | return true |
| 50 | } |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 51 | goto end145c1aec793b2befff34bc8983b48a38 |
| 52 | end145c1aec793b2befff34bc8983b48a38: |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 53 | ; |
Alexandru Moșoi | 198fc9a | 2015-08-14 12:59:33 +0200 | [diff] [blame] | 54 | case OpAnd16: |
| 55 | // match: (And16 x x) |
| 56 | // cond: |
| 57 | // result: x |
| 58 | { |
| 59 | x := v.Args[0] |
| 60 | if v.Args[1] != x { |
| 61 | goto end69ed6ee2a4fb0491b56c17f3c1926b10 |
| 62 | } |
| 63 | v.Op = OpCopy |
| 64 | v.AuxInt = 0 |
| 65 | v.Aux = nil |
| 66 | v.resetArgs() |
| 67 | v.Type = x.Type |
| 68 | v.AddArg(x) |
| 69 | return true |
| 70 | } |
| 71 | goto end69ed6ee2a4fb0491b56c17f3c1926b10 |
| 72 | end69ed6ee2a4fb0491b56c17f3c1926b10: |
| 73 | ; |
| 74 | case OpAnd32: |
| 75 | // match: (And32 x x) |
| 76 | // cond: |
| 77 | // result: x |
| 78 | { |
| 79 | x := v.Args[0] |
| 80 | if v.Args[1] != x { |
| 81 | goto endbbe8c3c5b2ca8f013aa178d856f3a99c |
| 82 | } |
| 83 | v.Op = OpCopy |
| 84 | v.AuxInt = 0 |
| 85 | v.Aux = nil |
| 86 | v.resetArgs() |
| 87 | v.Type = x.Type |
| 88 | v.AddArg(x) |
| 89 | return true |
| 90 | } |
| 91 | goto endbbe8c3c5b2ca8f013aa178d856f3a99c |
| 92 | endbbe8c3c5b2ca8f013aa178d856f3a99c: |
| 93 | ; |
| 94 | case OpAnd64: |
| 95 | // match: (And64 x x) |
| 96 | // cond: |
| 97 | // result: x |
| 98 | { |
| 99 | x := v.Args[0] |
| 100 | if v.Args[1] != x { |
| 101 | goto endc9736bf24d2e5cd8d662e1bcf3164640 |
| 102 | } |
| 103 | v.Op = OpCopy |
| 104 | v.AuxInt = 0 |
| 105 | v.Aux = nil |
| 106 | v.resetArgs() |
| 107 | v.Type = x.Type |
| 108 | v.AddArg(x) |
| 109 | return true |
| 110 | } |
| 111 | goto endc9736bf24d2e5cd8d662e1bcf3164640 |
| 112 | endc9736bf24d2e5cd8d662e1bcf3164640: |
| 113 | ; |
| 114 | case OpAnd8: |
| 115 | // match: (And8 x x) |
| 116 | // cond: |
| 117 | // result: x |
| 118 | { |
| 119 | x := v.Args[0] |
| 120 | if v.Args[1] != x { |
| 121 | goto endeaf127389bd0d4b0e0e297830f8f463b |
| 122 | } |
| 123 | v.Op = OpCopy |
| 124 | v.AuxInt = 0 |
| 125 | v.Aux = nil |
| 126 | v.resetArgs() |
| 127 | v.Type = x.Type |
| 128 | v.AddArg(x) |
| 129 | return true |
| 130 | } |
| 131 | goto endeaf127389bd0d4b0e0e297830f8f463b |
| 132 | endeaf127389bd0d4b0e0e297830f8f463b: |
| 133 | ; |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 134 | case OpArrayIndex: |
| 135 | // match: (ArrayIndex (Load ptr mem) idx) |
| 136 | // cond: |
Josh Bleecher Snyder | 8c6abfe | 2015-06-12 11:01:13 -0700 | [diff] [blame] | 137 | // result: (Load (PtrIndex <v.Type.PtrTo()> ptr idx) mem) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 138 | { |
| 139 | if v.Args[0].Op != OpLoad { |
Josh Bleecher Snyder | 8c6abfe | 2015-06-12 11:01:13 -0700 | [diff] [blame] | 140 | goto end4894dd7b58383fee5f8a92be08437c33 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 141 | } |
| 142 | ptr := v.Args[0].Args[0] |
| 143 | mem := v.Args[0].Args[1] |
| 144 | idx := v.Args[1] |
| 145 | v.Op = OpLoad |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 146 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 147 | v.Aux = nil |
| 148 | v.resetArgs() |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 149 | v0 := b.NewValue0(v.Line, OpPtrIndex, TypeInvalid) |
Josh Bleecher Snyder | 8c6abfe | 2015-06-12 11:01:13 -0700 | [diff] [blame] | 150 | v0.Type = v.Type.PtrTo() |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 151 | v0.AddArg(ptr) |
| 152 | v0.AddArg(idx) |
| 153 | v.AddArg(v0) |
| 154 | v.AddArg(mem) |
| 155 | return true |
| 156 | } |
Josh Bleecher Snyder | 8c6abfe | 2015-06-12 11:01:13 -0700 | [diff] [blame] | 157 | goto end4894dd7b58383fee5f8a92be08437c33 |
| 158 | end4894dd7b58383fee5f8a92be08437c33: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 159 | ; |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 160 | case OpCom16: |
| 161 | // match: (Com16 (Com16 x)) |
| 162 | // cond: |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 163 | // result: x |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 164 | { |
| 165 | if v.Args[0].Op != OpCom16 { |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 166 | goto end1ea17710dd4dd7ba4e710e0e4c7b5a56 |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 167 | } |
| 168 | x := v.Args[0].Args[0] |
| 169 | v.Op = OpCopy |
| 170 | v.AuxInt = 0 |
| 171 | v.Aux = nil |
| 172 | v.resetArgs() |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 173 | v.Type = x.Type |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 174 | v.AddArg(x) |
| 175 | return true |
| 176 | } |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 177 | goto end1ea17710dd4dd7ba4e710e0e4c7b5a56 |
| 178 | end1ea17710dd4dd7ba4e710e0e4c7b5a56: |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 179 | ; |
| 180 | case OpCom32: |
| 181 | // match: (Com32 (Com32 x)) |
| 182 | // cond: |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 183 | // result: x |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 184 | { |
| 185 | if v.Args[0].Op != OpCom32 { |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 186 | goto end9a04ed536496e292c27bef4414128cbf |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 187 | } |
| 188 | x := v.Args[0].Args[0] |
| 189 | v.Op = OpCopy |
| 190 | v.AuxInt = 0 |
| 191 | v.Aux = nil |
| 192 | v.resetArgs() |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 193 | v.Type = x.Type |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 194 | v.AddArg(x) |
| 195 | return true |
| 196 | } |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 197 | goto end9a04ed536496e292c27bef4414128cbf |
| 198 | end9a04ed536496e292c27bef4414128cbf: |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 199 | ; |
| 200 | case OpCom64: |
| 201 | // match: (Com64 (Com64 x)) |
| 202 | // cond: |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 203 | // result: x |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 204 | { |
| 205 | if v.Args[0].Op != OpCom64 { |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 206 | goto ended44e29d5968f0f7b86972b7bf417ab3 |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 207 | } |
| 208 | x := v.Args[0].Args[0] |
| 209 | v.Op = OpCopy |
| 210 | v.AuxInt = 0 |
| 211 | v.Aux = nil |
| 212 | v.resetArgs() |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 213 | v.Type = x.Type |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 214 | v.AddArg(x) |
| 215 | return true |
| 216 | } |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 217 | goto ended44e29d5968f0f7b86972b7bf417ab3 |
| 218 | ended44e29d5968f0f7b86972b7bf417ab3: |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 219 | ; |
| 220 | case OpCom8: |
| 221 | // match: (Com8 (Com8 x)) |
| 222 | // cond: |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 223 | // result: x |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 224 | { |
| 225 | if v.Args[0].Op != OpCom8 { |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 226 | goto end4d92ff3ba567d9afd38fc9ca113602ad |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 227 | } |
| 228 | x := v.Args[0].Args[0] |
| 229 | v.Op = OpCopy |
| 230 | v.AuxInt = 0 |
| 231 | v.Aux = nil |
| 232 | v.resetArgs() |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 233 | v.Type = x.Type |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 234 | v.AddArg(x) |
| 235 | return true |
| 236 | } |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 237 | goto end4d92ff3ba567d9afd38fc9ca113602ad |
| 238 | end4d92ff3ba567d9afd38fc9ca113602ad: |
Todd Neal | 38ed6c1 | 2015-07-30 16:02:24 -0400 | [diff] [blame] | 239 | ; |
David Chase | 5257858 | 2015-08-28 14:24:10 -0400 | [diff] [blame] | 240 | case OpComplexImag: |
| 241 | // match: (ComplexImag (ComplexMake _ imag )) |
| 242 | // cond: |
| 243 | // result: imag |
| 244 | { |
| 245 | if v.Args[0].Op != OpComplexMake { |
| 246 | goto endec3009fd8727d03002021997936e091f |
| 247 | } |
| 248 | imag := v.Args[0].Args[1] |
| 249 | v.Op = OpCopy |
| 250 | v.AuxInt = 0 |
| 251 | v.Aux = nil |
| 252 | v.resetArgs() |
| 253 | v.Type = imag.Type |
| 254 | v.AddArg(imag) |
| 255 | return true |
| 256 | } |
| 257 | goto endec3009fd8727d03002021997936e091f |
| 258 | endec3009fd8727d03002021997936e091f: |
| 259 | ; |
| 260 | case OpComplexReal: |
| 261 | // match: (ComplexReal (ComplexMake real _ )) |
| 262 | // cond: |
| 263 | // result: real |
| 264 | { |
| 265 | if v.Args[0].Op != OpComplexMake { |
| 266 | goto end8db3e16bd59af1adaa4b734c8adcc71d |
| 267 | } |
| 268 | real := v.Args[0].Args[0] |
| 269 | v.Op = OpCopy |
| 270 | v.AuxInt = 0 |
| 271 | v.Aux = nil |
| 272 | v.resetArgs() |
| 273 | v.Type = real.Type |
| 274 | v.AddArg(real) |
| 275 | return true |
| 276 | } |
| 277 | goto end8db3e16bd59af1adaa4b734c8adcc71d |
| 278 | end8db3e16bd59af1adaa4b734c8adcc71d: |
| 279 | ; |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 280 | case OpConstInterface: |
| 281 | // match: (ConstInterface) |
| 282 | // cond: |
| 283 | // result: (IMake (ConstNil <config.fe.TypeBytePtr()>) (ConstNil <config.fe.TypeBytePtr()>)) |
| 284 | { |
| 285 | v.Op = OpIMake |
| 286 | v.AuxInt = 0 |
| 287 | v.Aux = nil |
| 288 | v.resetArgs() |
| 289 | v0 := b.NewValue0(v.Line, OpConstNil, TypeInvalid) |
| 290 | v0.Type = config.fe.TypeBytePtr() |
| 291 | v.AddArg(v0) |
| 292 | v1 := b.NewValue0(v.Line, OpConstNil, TypeInvalid) |
| 293 | v1.Type = config.fe.TypeBytePtr() |
| 294 | v.AddArg(v1) |
| 295 | return true |
| 296 | } |
| 297 | goto end0367bd8f20a320cc41568f2b28657f6b |
| 298 | end0367bd8f20a320cc41568f2b28657f6b: |
| 299 | ; |
| 300 | case OpConstSlice: |
| 301 | // match: (ConstSlice) |
| 302 | // cond: |
| 303 | // result: (SliceMake (ConstNil <config.fe.TypeBytePtr()>) (ConstPtr <config.fe.TypeUintptr()>) (ConstPtr <config.fe.TypeUintptr()>)) |
| 304 | { |
| 305 | v.Op = OpSliceMake |
| 306 | v.AuxInt = 0 |
| 307 | v.Aux = nil |
| 308 | v.resetArgs() |
| 309 | v0 := b.NewValue0(v.Line, OpConstNil, TypeInvalid) |
| 310 | v0.Type = config.fe.TypeBytePtr() |
| 311 | v.AddArg(v0) |
| 312 | v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid) |
| 313 | v1.Type = config.fe.TypeUintptr() |
| 314 | v.AddArg(v1) |
| 315 | v2 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid) |
| 316 | v2.Type = config.fe.TypeUintptr() |
| 317 | v.AddArg(v2) |
| 318 | return true |
| 319 | } |
| 320 | goto endfd2d8ffcd55eaf8a5092a20c3ae61ba3 |
| 321 | endfd2d8ffcd55eaf8a5092a20c3ae61ba3: |
| 322 | ; |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 323 | case OpConstString: |
| 324 | // match: (ConstString {s}) |
| 325 | // cond: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 326 | // result: (StringMake (Addr <config.fe.TypeBytePtr()> {config.fe.StringData(s.(string))} (SB <config.fe.TypeUintptr()>)) (ConstPtr <config.fe.TypeUintptr()> [int64(len(s.(string)))])) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 327 | { |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 328 | s := v.Aux |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 329 | v.Op = OpStringMake |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 330 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 331 | v.Aux = nil |
| 332 | v.resetArgs() |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 333 | v0 := b.NewValue0(v.Line, OpAddr, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 334 | v0.Type = config.fe.TypeBytePtr() |
Josh Bleecher Snyder | 8d31df18a | 2015-07-24 11:28:12 -0700 | [diff] [blame] | 335 | v0.Aux = config.fe.StringData(s.(string)) |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 336 | v1 := b.NewValue0(v.Line, OpSB, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 337 | v1.Type = config.fe.TypeUintptr() |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 338 | v0.AddArg(v1) |
| 339 | v.AddArg(v0) |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 340 | v2 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 341 | v2.Type = config.fe.TypeUintptr() |
Josh Bleecher Snyder | 8d31df18a | 2015-07-24 11:28:12 -0700 | [diff] [blame] | 342 | v2.AuxInt = int64(len(s.(string))) |
| 343 | v.AddArg(v2) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 344 | return true |
| 345 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 346 | goto end51a3d96f2d304db9a52f36ee6b29c14e |
| 347 | end51a3d96f2d304db9a52f36ee6b29c14e: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 348 | ; |
Alexandru Moșoi | 9b25da7 | 2015-07-31 12:32:22 +0200 | [diff] [blame] | 349 | case OpEq16: |
| 350 | // match: (Eq16 x x) |
| 351 | // cond: |
| 352 | // result: (ConstBool {true}) |
| 353 | { |
| 354 | x := v.Args[0] |
| 355 | if v.Args[1] != x { |
| 356 | goto enda503589f9b617e708a5ad3ddb047809f |
| 357 | } |
| 358 | v.Op = OpConstBool |
| 359 | v.AuxInt = 0 |
| 360 | v.Aux = nil |
| 361 | v.resetArgs() |
| 362 | v.Aux = true |
| 363 | return true |
| 364 | } |
| 365 | goto enda503589f9b617e708a5ad3ddb047809f |
| 366 | enda503589f9b617e708a5ad3ddb047809f: |
| 367 | ; |
| 368 | case OpEq32: |
| 369 | // match: (Eq32 x x) |
| 370 | // cond: |
| 371 | // result: (ConstBool {true}) |
| 372 | { |
| 373 | x := v.Args[0] |
| 374 | if v.Args[1] != x { |
| 375 | goto endc94ae3b97d0090257b02152e437b3e17 |
| 376 | } |
| 377 | v.Op = OpConstBool |
| 378 | v.AuxInt = 0 |
| 379 | v.Aux = nil |
| 380 | v.resetArgs() |
| 381 | v.Aux = true |
| 382 | return true |
| 383 | } |
| 384 | goto endc94ae3b97d0090257b02152e437b3e17 |
| 385 | endc94ae3b97d0090257b02152e437b3e17: |
| 386 | ; |
| 387 | case OpEq64: |
| 388 | // match: (Eq64 x x) |
| 389 | // cond: |
| 390 | // result: (ConstBool {true}) |
| 391 | { |
| 392 | x := v.Args[0] |
| 393 | if v.Args[1] != x { |
| 394 | goto end4d21cead60174989467a9c8202dbb91d |
| 395 | } |
| 396 | v.Op = OpConstBool |
| 397 | v.AuxInt = 0 |
| 398 | v.Aux = nil |
| 399 | v.resetArgs() |
| 400 | v.Aux = true |
| 401 | return true |
| 402 | } |
| 403 | goto end4d21cead60174989467a9c8202dbb91d |
| 404 | end4d21cead60174989467a9c8202dbb91d: |
| 405 | ; |
| 406 | case OpEq8: |
| 407 | // match: (Eq8 x x) |
| 408 | // cond: |
| 409 | // result: (ConstBool {true}) |
| 410 | { |
| 411 | x := v.Args[0] |
| 412 | if v.Args[1] != x { |
| 413 | goto end73dce8bba164e4f4a1dd701bf8cfb362 |
| 414 | } |
| 415 | v.Op = OpConstBool |
| 416 | v.AuxInt = 0 |
| 417 | v.Aux = nil |
| 418 | v.resetArgs() |
| 419 | v.Aux = true |
| 420 | return true |
| 421 | } |
| 422 | goto end73dce8bba164e4f4a1dd701bf8cfb362 |
| 423 | end73dce8bba164e4f4a1dd701bf8cfb362: |
| 424 | ; |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 425 | case OpEqFat: |
| 426 | // match: (EqFat x y) |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 427 | // cond: x.Op == OpConstNil && y.Op != OpConstNil |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 428 | // result: (EqFat y x) |
| 429 | { |
| 430 | x := v.Args[0] |
| 431 | y := v.Args[1] |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 432 | if !(x.Op == OpConstNil && y.Op != OpConstNil) { |
| 433 | goto endcea7f7399afcff860c54d82230a9a934 |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 434 | } |
| 435 | v.Op = OpEqFat |
| 436 | v.AuxInt = 0 |
| 437 | v.Aux = nil |
| 438 | v.resetArgs() |
| 439 | v.AddArg(y) |
| 440 | v.AddArg(x) |
| 441 | return true |
| 442 | } |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 443 | goto endcea7f7399afcff860c54d82230a9a934 |
| 444 | endcea7f7399afcff860c54d82230a9a934: |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 445 | ; |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 446 | // match: (EqFat (Load ptr mem) (ConstNil)) |
| 447 | // cond: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 448 | // result: (EqPtr (Load <config.fe.TypeUintptr()> ptr mem) (ConstPtr <config.fe.TypeUintptr()> [0])) |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 449 | { |
| 450 | if v.Args[0].Op != OpLoad { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 451 | goto ende10070e5ddd3dc059674d25ccc6a63b5 |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 452 | } |
| 453 | ptr := v.Args[0].Args[0] |
| 454 | mem := v.Args[0].Args[1] |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 455 | if v.Args[1].Op != OpConstNil { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 456 | goto ende10070e5ddd3dc059674d25ccc6a63b5 |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 457 | } |
| 458 | v.Op = OpEqPtr |
| 459 | v.AuxInt = 0 |
| 460 | v.Aux = nil |
| 461 | v.resetArgs() |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 462 | v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 463 | v0.Type = config.fe.TypeUintptr() |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 464 | v0.AddArg(ptr) |
| 465 | v0.AddArg(mem) |
| 466 | v.AddArg(v0) |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 467 | v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 468 | v1.Type = config.fe.TypeUintptr() |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 469 | v1.AuxInt = 0 |
| 470 | v.AddArg(v1) |
| 471 | return true |
| 472 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 473 | goto ende10070e5ddd3dc059674d25ccc6a63b5 |
| 474 | ende10070e5ddd3dc059674d25ccc6a63b5: |
| 475 | ; |
| 476 | case OpIData: |
| 477 | // match: (IData (IMake _ data)) |
| 478 | // cond: |
| 479 | // result: data |
| 480 | { |
| 481 | if v.Args[0].Op != OpIMake { |
| 482 | goto endbfa1bb944cdc07933effb16a35152e12 |
| 483 | } |
| 484 | data := v.Args[0].Args[1] |
| 485 | v.Op = OpCopy |
| 486 | v.AuxInt = 0 |
| 487 | v.Aux = nil |
| 488 | v.resetArgs() |
| 489 | v.Type = data.Type |
| 490 | v.AddArg(data) |
| 491 | return true |
| 492 | } |
| 493 | goto endbfa1bb944cdc07933effb16a35152e12 |
| 494 | endbfa1bb944cdc07933effb16a35152e12: |
| 495 | ; |
| 496 | case OpITab: |
| 497 | // match: (ITab (IMake itab _)) |
| 498 | // cond: |
| 499 | // result: itab |
| 500 | { |
| 501 | if v.Args[0].Op != OpIMake { |
| 502 | goto endfcbb9414a776ff9c8512da3e0f4d8fbd |
| 503 | } |
| 504 | itab := v.Args[0].Args[0] |
| 505 | v.Op = OpCopy |
| 506 | v.AuxInt = 0 |
| 507 | v.Aux = nil |
| 508 | v.resetArgs() |
| 509 | v.Type = itab.Type |
| 510 | v.AddArg(itab) |
| 511 | return true |
| 512 | } |
| 513 | goto endfcbb9414a776ff9c8512da3e0f4d8fbd |
| 514 | endfcbb9414a776ff9c8512da3e0f4d8fbd: |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 515 | ; |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 516 | case OpIsInBounds: |
Josh Bleecher Snyder | 3e7904b | 2015-08-12 13:48:36 -0700 | [diff] [blame] | 517 | // match: (IsInBounds (Const32 [c]) (Const32 [d])) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 518 | // cond: |
Josh Bleecher Snyder | 3e7904b | 2015-08-12 13:48:36 -0700 | [diff] [blame] | 519 | // result: (ConstBool {inBounds32(c,d)}) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 520 | { |
Josh Bleecher Snyder | 3e7904b | 2015-08-12 13:48:36 -0700 | [diff] [blame] | 521 | if v.Args[0].Op != OpConst32 { |
| 522 | goto endc3396bf88b56276e1691abe62811dba5 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 523 | } |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 524 | c := v.Args[0].AuxInt |
Josh Bleecher Snyder | 3e7904b | 2015-08-12 13:48:36 -0700 | [diff] [blame] | 525 | if v.Args[1].Op != OpConst32 { |
| 526 | goto endc3396bf88b56276e1691abe62811dba5 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 527 | } |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 528 | d := v.Args[1].AuxInt |
Josh Bleecher Snyder | 3e7904b | 2015-08-12 13:48:36 -0700 | [diff] [blame] | 529 | v.Op = OpConstBool |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 530 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 531 | v.Aux = nil |
| 532 | v.resetArgs() |
Josh Bleecher Snyder | 3e7904b | 2015-08-12 13:48:36 -0700 | [diff] [blame] | 533 | v.Aux = inBounds32(c, d) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 534 | return true |
| 535 | } |
Josh Bleecher Snyder | 3e7904b | 2015-08-12 13:48:36 -0700 | [diff] [blame] | 536 | goto endc3396bf88b56276e1691abe62811dba5 |
| 537 | endc3396bf88b56276e1691abe62811dba5: |
| 538 | ; |
| 539 | // match: (IsInBounds (Const64 [c]) (Const64 [d])) |
| 540 | // cond: |
| 541 | // result: (ConstBool {inBounds64(c,d)}) |
| 542 | { |
| 543 | if v.Args[0].Op != OpConst64 { |
| 544 | goto end0b4b8178a54662835b00bfa503cf879a |
| 545 | } |
| 546 | c := v.Args[0].AuxInt |
| 547 | if v.Args[1].Op != OpConst64 { |
| 548 | goto end0b4b8178a54662835b00bfa503cf879a |
| 549 | } |
| 550 | d := v.Args[1].AuxInt |
| 551 | v.Op = OpConstBool |
| 552 | v.AuxInt = 0 |
| 553 | v.Aux = nil |
| 554 | v.resetArgs() |
| 555 | v.Aux = inBounds64(c, d) |
| 556 | return true |
| 557 | } |
| 558 | goto end0b4b8178a54662835b00bfa503cf879a |
| 559 | end0b4b8178a54662835b00bfa503cf879a: |
| 560 | ; |
| 561 | // match: (IsInBounds (ConstPtr [c]) (ConstPtr [d])) |
| 562 | // cond: config.PtrSize == 4 |
| 563 | // result: (ConstBool {inBounds32(c,d)}) |
| 564 | { |
| 565 | if v.Args[0].Op != OpConstPtr { |
| 566 | goto end2c6938f68a67e08dbd96edb1e693e549 |
| 567 | } |
| 568 | c := v.Args[0].AuxInt |
| 569 | if v.Args[1].Op != OpConstPtr { |
| 570 | goto end2c6938f68a67e08dbd96edb1e693e549 |
| 571 | } |
| 572 | d := v.Args[1].AuxInt |
| 573 | if !(config.PtrSize == 4) { |
| 574 | goto end2c6938f68a67e08dbd96edb1e693e549 |
| 575 | } |
| 576 | v.Op = OpConstBool |
| 577 | v.AuxInt = 0 |
| 578 | v.Aux = nil |
| 579 | v.resetArgs() |
| 580 | v.Aux = inBounds32(c, d) |
| 581 | return true |
| 582 | } |
| 583 | goto end2c6938f68a67e08dbd96edb1e693e549 |
| 584 | end2c6938f68a67e08dbd96edb1e693e549: |
| 585 | ; |
| 586 | // match: (IsInBounds (ConstPtr [c]) (ConstPtr [d])) |
| 587 | // cond: config.PtrSize == 8 |
| 588 | // result: (ConstBool {inBounds64(c,d)}) |
| 589 | { |
| 590 | if v.Args[0].Op != OpConstPtr { |
| 591 | goto end84d6ae817944985f572ecaac51999d6c |
| 592 | } |
| 593 | c := v.Args[0].AuxInt |
| 594 | if v.Args[1].Op != OpConstPtr { |
| 595 | goto end84d6ae817944985f572ecaac51999d6c |
| 596 | } |
| 597 | d := v.Args[1].AuxInt |
| 598 | if !(config.PtrSize == 8) { |
| 599 | goto end84d6ae817944985f572ecaac51999d6c |
| 600 | } |
| 601 | v.Op = OpConstBool |
| 602 | v.AuxInt = 0 |
| 603 | v.Aux = nil |
| 604 | v.resetArgs() |
| 605 | v.Aux = inBounds64(c, d) |
| 606 | return true |
| 607 | } |
| 608 | goto end84d6ae817944985f572ecaac51999d6c |
| 609 | end84d6ae817944985f572ecaac51999d6c: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 610 | ; |
| 611 | case OpLoad: |
| 612 | // match: (Load <t> ptr mem) |
David Chase | 5257858 | 2015-08-28 14:24:10 -0400 | [diff] [blame] | 613 | // cond: t.IsComplex() && t.Size() == 8 |
| 614 | // result: (ComplexMake (Load <config.fe.TypeFloat32()> ptr mem) (Load <config.fe.TypeFloat32()> (OffPtr <config.fe.TypeFloat32().PtrTo()> [4] ptr) mem) ) |
| 615 | { |
| 616 | t := v.Type |
| 617 | ptr := v.Args[0] |
| 618 | mem := v.Args[1] |
| 619 | if !(t.IsComplex() && t.Size() == 8) { |
| 620 | goto end665854b31b828893d90b36bb462ff381 |
| 621 | } |
| 622 | v.Op = OpComplexMake |
| 623 | v.AuxInt = 0 |
| 624 | v.Aux = nil |
| 625 | v.resetArgs() |
| 626 | v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 627 | v0.Type = config.fe.TypeFloat32() |
| 628 | v0.AddArg(ptr) |
| 629 | v0.AddArg(mem) |
| 630 | v.AddArg(v0) |
| 631 | v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 632 | v1.Type = config.fe.TypeFloat32() |
| 633 | v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 634 | v2.Type = config.fe.TypeFloat32().PtrTo() |
| 635 | v2.AuxInt = 4 |
| 636 | v2.AddArg(ptr) |
| 637 | v1.AddArg(v2) |
| 638 | v1.AddArg(mem) |
| 639 | v.AddArg(v1) |
| 640 | return true |
| 641 | } |
| 642 | goto end665854b31b828893d90b36bb462ff381 |
| 643 | end665854b31b828893d90b36bb462ff381: |
| 644 | ; |
| 645 | // match: (Load <t> ptr mem) |
| 646 | // cond: t.IsComplex() && t.Size() == 16 |
| 647 | // result: (ComplexMake (Load <config.fe.TypeFloat64()> ptr mem) (Load <config.fe.TypeFloat64()> (OffPtr <config.fe.TypeFloat64().PtrTo()> [8] ptr) mem) ) |
| 648 | { |
| 649 | t := v.Type |
| 650 | ptr := v.Args[0] |
| 651 | mem := v.Args[1] |
| 652 | if !(t.IsComplex() && t.Size() == 16) { |
| 653 | goto end1b106f89e0e3e26c613b957a7c98d8ad |
| 654 | } |
| 655 | v.Op = OpComplexMake |
| 656 | v.AuxInt = 0 |
| 657 | v.Aux = nil |
| 658 | v.resetArgs() |
| 659 | v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 660 | v0.Type = config.fe.TypeFloat64() |
| 661 | v0.AddArg(ptr) |
| 662 | v0.AddArg(mem) |
| 663 | v.AddArg(v0) |
| 664 | v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 665 | v1.Type = config.fe.TypeFloat64() |
| 666 | v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 667 | v2.Type = config.fe.TypeFloat64().PtrTo() |
| 668 | v2.AuxInt = 8 |
| 669 | v2.AddArg(ptr) |
| 670 | v1.AddArg(v2) |
| 671 | v1.AddArg(mem) |
| 672 | v.AddArg(v1) |
| 673 | return true |
| 674 | } |
| 675 | goto end1b106f89e0e3e26c613b957a7c98d8ad |
| 676 | end1b106f89e0e3e26c613b957a7c98d8ad: |
| 677 | ; |
| 678 | // match: (Load <t> ptr mem) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 679 | // cond: t.IsString() |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 680 | // result: (StringMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeUintptr()> (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] ptr) mem)) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 681 | { |
| 682 | t := v.Type |
| 683 | ptr := v.Args[0] |
| 684 | mem := v.Args[1] |
| 685 | if !(t.IsString()) { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 686 | goto end7c75255555bf9dd796298d9f6eaf9cf2 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 687 | } |
| 688 | v.Op = OpStringMake |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 689 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 690 | v.Aux = nil |
| 691 | v.resetArgs() |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 692 | v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 693 | v0.Type = config.fe.TypeBytePtr() |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 694 | v0.AddArg(ptr) |
| 695 | v0.AddArg(mem) |
| 696 | v.AddArg(v0) |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 697 | v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 698 | v1.Type = config.fe.TypeUintptr() |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 699 | v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 700 | v2.Type = config.fe.TypeUintptr().PtrTo() |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 701 | v2.AuxInt = config.PtrSize |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 702 | v2.AddArg(ptr) |
| 703 | v1.AddArg(v2) |
| 704 | v1.AddArg(mem) |
| 705 | v.AddArg(v1) |
| 706 | return true |
| 707 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 708 | goto end7c75255555bf9dd796298d9f6eaf9cf2 |
| 709 | end7c75255555bf9dd796298d9f6eaf9cf2: |
| 710 | ; |
| 711 | // match: (Load <t> ptr mem) |
| 712 | // cond: t.IsSlice() |
| 713 | // result: (SliceMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeUintptr()> (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] ptr) mem) (Load <config.fe.TypeUintptr()> (OffPtr <config.fe.TypeUintptr().PtrTo()> [2*config.PtrSize] ptr) mem)) |
| 714 | { |
| 715 | t := v.Type |
| 716 | ptr := v.Args[0] |
| 717 | mem := v.Args[1] |
| 718 | if !(t.IsSlice()) { |
| 719 | goto end12c46556d962198680eb3238859e3016 |
| 720 | } |
| 721 | v.Op = OpSliceMake |
| 722 | v.AuxInt = 0 |
| 723 | v.Aux = nil |
| 724 | v.resetArgs() |
| 725 | v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 726 | v0.Type = config.fe.TypeBytePtr() |
| 727 | v0.AddArg(ptr) |
| 728 | v0.AddArg(mem) |
| 729 | v.AddArg(v0) |
| 730 | v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 731 | v1.Type = config.fe.TypeUintptr() |
| 732 | v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 733 | v2.Type = config.fe.TypeUintptr().PtrTo() |
| 734 | v2.AuxInt = config.PtrSize |
| 735 | v2.AddArg(ptr) |
| 736 | v1.AddArg(v2) |
| 737 | v1.AddArg(mem) |
| 738 | v.AddArg(v1) |
| 739 | v3 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 740 | v3.Type = config.fe.TypeUintptr() |
| 741 | v4 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 742 | v4.Type = config.fe.TypeUintptr().PtrTo() |
| 743 | v4.AuxInt = 2 * config.PtrSize |
| 744 | v4.AddArg(ptr) |
| 745 | v3.AddArg(v4) |
| 746 | v3.AddArg(mem) |
| 747 | v.AddArg(v3) |
| 748 | return true |
| 749 | } |
| 750 | goto end12c46556d962198680eb3238859e3016 |
| 751 | end12c46556d962198680eb3238859e3016: |
| 752 | ; |
| 753 | // match: (Load <t> ptr mem) |
| 754 | // cond: t.IsInterface() |
| 755 | // result: (IMake (Load <config.fe.TypeBytePtr()> ptr mem) (Load <config.fe.TypeBytePtr()> (OffPtr <config.fe.TypeBytePtr().PtrTo()> [config.PtrSize] ptr) mem)) |
| 756 | { |
| 757 | t := v.Type |
| 758 | ptr := v.Args[0] |
| 759 | mem := v.Args[1] |
| 760 | if !(t.IsInterface()) { |
| 761 | goto end12671c83ebe3ccbc8e53383765ee7675 |
| 762 | } |
| 763 | v.Op = OpIMake |
| 764 | v.AuxInt = 0 |
| 765 | v.Aux = nil |
| 766 | v.resetArgs() |
| 767 | v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 768 | v0.Type = config.fe.TypeBytePtr() |
| 769 | v0.AddArg(ptr) |
| 770 | v0.AddArg(mem) |
| 771 | v.AddArg(v0) |
| 772 | v1 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
| 773 | v1.Type = config.fe.TypeBytePtr() |
| 774 | v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 775 | v2.Type = config.fe.TypeBytePtr().PtrTo() |
| 776 | v2.AuxInt = config.PtrSize |
| 777 | v2.AddArg(ptr) |
| 778 | v1.AddArg(v2) |
| 779 | v1.AddArg(mem) |
| 780 | v.AddArg(v1) |
| 781 | return true |
| 782 | } |
| 783 | goto end12671c83ebe3ccbc8e53383765ee7675 |
| 784 | end12671c83ebe3ccbc8e53383765ee7675: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 785 | ; |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 786 | case OpMul64: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 787 | // match: (Mul64 (Const64 [c]) (Const64 [d])) |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 788 | // cond: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 789 | // result: (Const64 [c*d]) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 790 | { |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 791 | if v.Args[0].Op != OpConst64 { |
| 792 | goto end7aea1048b5d1230974b97f17238380ae |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 793 | } |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 794 | c := v.Args[0].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 795 | if v.Args[1].Op != OpConst64 { |
| 796 | goto end7aea1048b5d1230974b97f17238380ae |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 797 | } |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 798 | d := v.Args[1].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 799 | v.Op = OpConst64 |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 800 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 801 | v.Aux = nil |
| 802 | v.resetArgs() |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 803 | v.AuxInt = c * d |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 804 | return true |
| 805 | } |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 806 | goto end7aea1048b5d1230974b97f17238380ae |
| 807 | end7aea1048b5d1230974b97f17238380ae: |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 808 | ; |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 809 | case OpMulPtr: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 810 | // match: (MulPtr (ConstPtr [c]) (ConstPtr [d])) |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 811 | // cond: |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 812 | // result: (ConstPtr [c*d]) |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 813 | { |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 814 | if v.Args[0].Op != OpConstPtr { |
| 815 | goto end808c190f346658bb1ad032bf37a1059f |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 816 | } |
| 817 | c := v.Args[0].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 818 | if v.Args[1].Op != OpConstPtr { |
| 819 | goto end808c190f346658bb1ad032bf37a1059f |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 820 | } |
| 821 | d := v.Args[1].AuxInt |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 822 | v.Op = OpConstPtr |
Keith Randall | be1eb57 | 2015-07-22 13:46:15 -0700 | [diff] [blame] | 823 | v.AuxInt = 0 |
| 824 | v.Aux = nil |
| 825 | v.resetArgs() |
| 826 | v.AuxInt = c * d |
| 827 | return true |
| 828 | } |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 829 | goto end808c190f346658bb1ad032bf37a1059f |
| 830 | end808c190f346658bb1ad032bf37a1059f: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 831 | ; |
Alexandru Moșoi | 9b25da7 | 2015-07-31 12:32:22 +0200 | [diff] [blame] | 832 | case OpNeq16: |
| 833 | // match: (Neq16 x x) |
| 834 | // cond: |
| 835 | // result: (ConstBool {false}) |
| 836 | { |
| 837 | x := v.Args[0] |
| 838 | if v.Args[1] != x { |
| 839 | goto end192755dd3c2be992e9d3deb53794a8d2 |
| 840 | } |
| 841 | v.Op = OpConstBool |
| 842 | v.AuxInt = 0 |
| 843 | v.Aux = nil |
| 844 | v.resetArgs() |
| 845 | v.Aux = false |
| 846 | return true |
| 847 | } |
| 848 | goto end192755dd3c2be992e9d3deb53794a8d2 |
| 849 | end192755dd3c2be992e9d3deb53794a8d2: |
| 850 | ; |
| 851 | case OpNeq32: |
| 852 | // match: (Neq32 x x) |
| 853 | // cond: |
| 854 | // result: (ConstBool {false}) |
| 855 | { |
| 856 | x := v.Args[0] |
| 857 | if v.Args[1] != x { |
| 858 | goto endeb23619fc85950a8df7b31126252c4dd |
| 859 | } |
| 860 | v.Op = OpConstBool |
| 861 | v.AuxInt = 0 |
| 862 | v.Aux = nil |
| 863 | v.resetArgs() |
| 864 | v.Aux = false |
| 865 | return true |
| 866 | } |
| 867 | goto endeb23619fc85950a8df7b31126252c4dd |
| 868 | endeb23619fc85950a8df7b31126252c4dd: |
| 869 | ; |
| 870 | case OpNeq64: |
| 871 | // match: (Neq64 x x) |
| 872 | // cond: |
| 873 | // result: (ConstBool {false}) |
| 874 | { |
| 875 | x := v.Args[0] |
| 876 | if v.Args[1] != x { |
| 877 | goto endfc6eea780fb4056afb9e4287076da60c |
| 878 | } |
| 879 | v.Op = OpConstBool |
| 880 | v.AuxInt = 0 |
| 881 | v.Aux = nil |
| 882 | v.resetArgs() |
| 883 | v.Aux = false |
| 884 | return true |
| 885 | } |
| 886 | goto endfc6eea780fb4056afb9e4287076da60c |
| 887 | endfc6eea780fb4056afb9e4287076da60c: |
| 888 | ; |
| 889 | case OpNeq8: |
| 890 | // match: (Neq8 x x) |
| 891 | // cond: |
| 892 | // result: (ConstBool {false}) |
| 893 | { |
| 894 | x := v.Args[0] |
| 895 | if v.Args[1] != x { |
| 896 | goto endcccf700d93c6d57765b80f92f7b3fa81 |
| 897 | } |
| 898 | v.Op = OpConstBool |
| 899 | v.AuxInt = 0 |
| 900 | v.Aux = nil |
| 901 | v.resetArgs() |
| 902 | v.Aux = false |
| 903 | return true |
| 904 | } |
| 905 | goto endcccf700d93c6d57765b80f92f7b3fa81 |
| 906 | endcccf700d93c6d57765b80f92f7b3fa81: |
| 907 | ; |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 908 | case OpNeqFat: |
| 909 | // match: (NeqFat x y) |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 910 | // cond: x.Op == OpConstNil && y.Op != OpConstNil |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 911 | // result: (NeqFat y x) |
| 912 | { |
| 913 | x := v.Args[0] |
| 914 | y := v.Args[1] |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 915 | if !(x.Op == OpConstNil && y.Op != OpConstNil) { |
| 916 | goto end94c68f7dc30c66ed42e507e01c4e5dc7 |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 917 | } |
| 918 | v.Op = OpNeqFat |
| 919 | v.AuxInt = 0 |
| 920 | v.Aux = nil |
| 921 | v.resetArgs() |
| 922 | v.AddArg(y) |
| 923 | v.AddArg(x) |
| 924 | return true |
| 925 | } |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 926 | goto end94c68f7dc30c66ed42e507e01c4e5dc7 |
| 927 | end94c68f7dc30c66ed42e507e01c4e5dc7: |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 928 | ; |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 929 | // match: (NeqFat (Load ptr mem) (ConstNil)) |
| 930 | // cond: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 931 | // result: (NeqPtr (Load <config.fe.TypeUintptr()> ptr mem) (ConstPtr <config.fe.TypeUintptr()> [0])) |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 932 | { |
| 933 | if v.Args[0].Op != OpLoad { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 934 | goto end423eea941d60473e73140e25f5818bfb |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 935 | } |
| 936 | ptr := v.Args[0].Args[0] |
| 937 | mem := v.Args[0].Args[1] |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 938 | if v.Args[1].Op != OpConstNil { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 939 | goto end423eea941d60473e73140e25f5818bfb |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 940 | } |
| 941 | v.Op = OpNeqPtr |
| 942 | v.AuxInt = 0 |
| 943 | v.Aux = nil |
| 944 | v.resetArgs() |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 945 | v0 := b.NewValue0(v.Line, OpLoad, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 946 | v0.Type = config.fe.TypeUintptr() |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 947 | v0.AddArg(ptr) |
| 948 | v0.AddArg(mem) |
| 949 | v.AddArg(v0) |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 950 | v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 951 | v1.Type = config.fe.TypeUintptr() |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 952 | v1.AuxInt = 0 |
| 953 | v.AddArg(v1) |
| 954 | return true |
| 955 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 956 | goto end423eea941d60473e73140e25f5818bfb |
| 957 | end423eea941d60473e73140e25f5818bfb: |
Josh Bleecher Snyder | 9ca24fc | 2015-07-27 13:17:45 -0700 | [diff] [blame] | 958 | ; |
Alexandru Moșoi | 198fc9a | 2015-08-14 12:59:33 +0200 | [diff] [blame] | 959 | case OpOr16: |
| 960 | // match: (Or16 x x) |
| 961 | // cond: |
| 962 | // result: x |
| 963 | { |
| 964 | x := v.Args[0] |
| 965 | if v.Args[1] != x { |
| 966 | goto end47a2f25fd31a76807aced3e2b126acdc |
| 967 | } |
| 968 | v.Op = OpCopy |
| 969 | v.AuxInt = 0 |
| 970 | v.Aux = nil |
| 971 | v.resetArgs() |
| 972 | v.Type = x.Type |
| 973 | v.AddArg(x) |
| 974 | return true |
| 975 | } |
| 976 | goto end47a2f25fd31a76807aced3e2b126acdc |
| 977 | end47a2f25fd31a76807aced3e2b126acdc: |
| 978 | ; |
| 979 | case OpOr32: |
| 980 | // match: (Or32 x x) |
| 981 | // cond: |
| 982 | // result: x |
| 983 | { |
| 984 | x := v.Args[0] |
| 985 | if v.Args[1] != x { |
| 986 | goto end231e283e568e90bd9a3e6a4fa328c8a4 |
| 987 | } |
| 988 | v.Op = OpCopy |
| 989 | v.AuxInt = 0 |
| 990 | v.Aux = nil |
| 991 | v.resetArgs() |
| 992 | v.Type = x.Type |
| 993 | v.AddArg(x) |
| 994 | return true |
| 995 | } |
| 996 | goto end231e283e568e90bd9a3e6a4fa328c8a4 |
| 997 | end231e283e568e90bd9a3e6a4fa328c8a4: |
| 998 | ; |
| 999 | case OpOr64: |
| 1000 | // match: (Or64 x x) |
| 1001 | // cond: |
| 1002 | // result: x |
| 1003 | { |
| 1004 | x := v.Args[0] |
| 1005 | if v.Args[1] != x { |
| 1006 | goto end6b0efc212016dc97d0e3939db04c81d9 |
| 1007 | } |
| 1008 | v.Op = OpCopy |
| 1009 | v.AuxInt = 0 |
| 1010 | v.Aux = nil |
| 1011 | v.resetArgs() |
| 1012 | v.Type = x.Type |
| 1013 | v.AddArg(x) |
| 1014 | return true |
| 1015 | } |
| 1016 | goto end6b0efc212016dc97d0e3939db04c81d9 |
| 1017 | end6b0efc212016dc97d0e3939db04c81d9: |
| 1018 | ; |
| 1019 | case OpOr8: |
| 1020 | // match: (Or8 x x) |
| 1021 | // cond: |
| 1022 | // result: x |
| 1023 | { |
| 1024 | x := v.Args[0] |
| 1025 | if v.Args[1] != x { |
| 1026 | goto end05295dbfafd6869af79b4daee9fda000 |
| 1027 | } |
| 1028 | v.Op = OpCopy |
| 1029 | v.AuxInt = 0 |
| 1030 | v.Aux = nil |
| 1031 | v.resetArgs() |
| 1032 | v.Type = x.Type |
| 1033 | v.AddArg(x) |
| 1034 | return true |
| 1035 | } |
| 1036 | goto end05295dbfafd6869af79b4daee9fda000 |
| 1037 | end05295dbfafd6869af79b4daee9fda000: |
| 1038 | ; |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1039 | case OpPtrIndex: |
| 1040 | // match: (PtrIndex <t> ptr idx) |
| 1041 | // cond: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1042 | // result: (AddPtr ptr (MulPtr <config.fe.TypeUintptr()> idx (ConstPtr <config.fe.TypeUintptr()> [t.Elem().Size()]))) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1043 | { |
| 1044 | t := v.Type |
| 1045 | ptr := v.Args[0] |
| 1046 | idx := v.Args[1] |
Keith Randall | 67fdb0d | 2015-07-19 15:48:20 -0700 | [diff] [blame] | 1047 | v.Op = OpAddPtr |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 1048 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1049 | v.Aux = nil |
| 1050 | v.resetArgs() |
| 1051 | v.AddArg(ptr) |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 1052 | v0 := b.NewValue0(v.Line, OpMulPtr, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1053 | v0.Type = config.fe.TypeUintptr() |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1054 | v0.AddArg(idx) |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 1055 | v1 := b.NewValue0(v.Line, OpConstPtr, TypeInvalid) |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1056 | v1.Type = config.fe.TypeUintptr() |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 1057 | v1.AuxInt = t.Elem().Size() |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1058 | v0.AddArg(v1) |
| 1059 | v.AddArg(v0) |
| 1060 | return true |
| 1061 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1062 | goto end1e1c5ef80c11231f89a5439cdda98359 |
| 1063 | end1e1c5ef80c11231f89a5439cdda98359: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1064 | ; |
| 1065 | case OpSliceCap: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1066 | // match: (SliceCap (SliceMake _ _ cap)) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1067 | // cond: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1068 | // result: cap |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1069 | { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1070 | if v.Args[0].Op != OpSliceMake { |
| 1071 | goto end1bd11616743632b33b410964667fb3c6 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1072 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1073 | cap := v.Args[0].Args[2] |
| 1074 | v.Op = OpCopy |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 1075 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1076 | v.Aux = nil |
| 1077 | v.resetArgs() |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1078 | v.Type = cap.Type |
| 1079 | v.AddArg(cap) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1080 | return true |
| 1081 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1082 | goto end1bd11616743632b33b410964667fb3c6 |
| 1083 | end1bd11616743632b33b410964667fb3c6: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1084 | ; |
| 1085 | case OpSliceLen: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1086 | // match: (SliceLen (SliceMake _ len _)) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1087 | // cond: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1088 | // result: len |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1089 | { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1090 | if v.Args[0].Op != OpSliceMake { |
| 1091 | goto endebb2090199d13e4c2ae52fb3e778f7fd |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1092 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1093 | len := v.Args[0].Args[1] |
| 1094 | v.Op = OpCopy |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 1095 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1096 | v.Aux = nil |
| 1097 | v.resetArgs() |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1098 | v.Type = len.Type |
| 1099 | v.AddArg(len) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1100 | return true |
| 1101 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1102 | goto endebb2090199d13e4c2ae52fb3e778f7fd |
| 1103 | endebb2090199d13e4c2ae52fb3e778f7fd: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1104 | ; |
| 1105 | case OpSlicePtr: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1106 | // match: (SlicePtr (SliceMake ptr _ _ )) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1107 | // cond: |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1108 | // result: ptr |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1109 | { |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1110 | if v.Args[0].Op != OpSliceMake { |
| 1111 | goto end526acc0a705137a5d25577499206720b |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1112 | } |
| 1113 | ptr := v.Args[0].Args[0] |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1114 | v.Op = OpCopy |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 1115 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1116 | v.Aux = nil |
| 1117 | v.resetArgs() |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1118 | v.Type = ptr.Type |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1119 | v.AddArg(ptr) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1120 | return true |
| 1121 | } |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1122 | goto end526acc0a705137a5d25577499206720b |
| 1123 | end526acc0a705137a5d25577499206720b: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1124 | ; |
| 1125 | case OpStore: |
David Chase | 5257858 | 2015-08-28 14:24:10 -0400 | [diff] [blame] | 1126 | // match: (Store [8] dst (ComplexMake real imag) mem) |
| 1127 | // cond: |
| 1128 | // result: (Store [4] (OffPtr <config.fe.TypeFloat32().PtrTo()> [4] dst) imag (Store <TypeMem> [4] dst real mem)) |
| 1129 | { |
| 1130 | if v.AuxInt != 8 { |
| 1131 | goto endba187c049aa71488994c8a2eb3453045 |
| 1132 | } |
| 1133 | dst := v.Args[0] |
| 1134 | if v.Args[1].Op != OpComplexMake { |
| 1135 | goto endba187c049aa71488994c8a2eb3453045 |
| 1136 | } |
| 1137 | real := v.Args[1].Args[0] |
| 1138 | imag := v.Args[1].Args[1] |
| 1139 | mem := v.Args[2] |
| 1140 | v.Op = OpStore |
| 1141 | v.AuxInt = 0 |
| 1142 | v.Aux = nil |
| 1143 | v.resetArgs() |
| 1144 | v.AuxInt = 4 |
| 1145 | v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 1146 | v0.Type = config.fe.TypeFloat32().PtrTo() |
| 1147 | v0.AuxInt = 4 |
| 1148 | v0.AddArg(dst) |
| 1149 | v.AddArg(v0) |
| 1150 | v.AddArg(imag) |
| 1151 | v1 := b.NewValue0(v.Line, OpStore, TypeInvalid) |
| 1152 | v1.Type = TypeMem |
| 1153 | v1.AuxInt = 4 |
| 1154 | v1.AddArg(dst) |
| 1155 | v1.AddArg(real) |
| 1156 | v1.AddArg(mem) |
| 1157 | v.AddArg(v1) |
| 1158 | return true |
| 1159 | } |
| 1160 | goto endba187c049aa71488994c8a2eb3453045 |
| 1161 | endba187c049aa71488994c8a2eb3453045: |
| 1162 | ; |
| 1163 | // match: (Store [16] dst (ComplexMake real imag) mem) |
| 1164 | // cond: |
| 1165 | // result: (Store [8] (OffPtr <config.fe.TypeFloat64().PtrTo()> [8] dst) imag (Store <TypeMem> [8] dst real mem)) |
| 1166 | { |
| 1167 | if v.AuxInt != 16 { |
| 1168 | goto end4df4c826201cf51af245d6b89de00589 |
| 1169 | } |
| 1170 | dst := v.Args[0] |
| 1171 | if v.Args[1].Op != OpComplexMake { |
| 1172 | goto end4df4c826201cf51af245d6b89de00589 |
| 1173 | } |
| 1174 | real := v.Args[1].Args[0] |
| 1175 | imag := v.Args[1].Args[1] |
| 1176 | mem := v.Args[2] |
| 1177 | v.Op = OpStore |
| 1178 | v.AuxInt = 0 |
| 1179 | v.Aux = nil |
| 1180 | v.resetArgs() |
| 1181 | v.AuxInt = 8 |
| 1182 | v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 1183 | v0.Type = config.fe.TypeFloat64().PtrTo() |
| 1184 | v0.AuxInt = 8 |
| 1185 | v0.AddArg(dst) |
| 1186 | v.AddArg(v0) |
| 1187 | v.AddArg(imag) |
| 1188 | v1 := b.NewValue0(v.Line, OpStore, TypeInvalid) |
| 1189 | v1.Type = TypeMem |
| 1190 | v1.AuxInt = 8 |
| 1191 | v1.AddArg(dst) |
| 1192 | v1.AddArg(real) |
| 1193 | v1.AddArg(mem) |
| 1194 | v.AddArg(v1) |
| 1195 | return true |
| 1196 | } |
| 1197 | goto end4df4c826201cf51af245d6b89de00589 |
| 1198 | end4df4c826201cf51af245d6b89de00589: |
| 1199 | ; |
Keith Randall | 9f954db | 2015-08-18 10:26:28 -0700 | [diff] [blame] | 1200 | // match: (Store [2*config.PtrSize] dst (StringMake ptr len) mem) |
| 1201 | // cond: |
| 1202 | // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] dst) len (Store <TypeMem> [config.PtrSize] dst ptr mem)) |
| 1203 | { |
| 1204 | if v.AuxInt != 2*config.PtrSize { |
| 1205 | goto end25ae4fc3dc01583a4adc45067d49940a |
| 1206 | } |
| 1207 | dst := v.Args[0] |
| 1208 | if v.Args[1].Op != OpStringMake { |
| 1209 | goto end25ae4fc3dc01583a4adc45067d49940a |
| 1210 | } |
| 1211 | ptr := v.Args[1].Args[0] |
| 1212 | len := v.Args[1].Args[1] |
| 1213 | mem := v.Args[2] |
| 1214 | v.Op = OpStore |
| 1215 | v.AuxInt = 0 |
| 1216 | v.Aux = nil |
| 1217 | v.resetArgs() |
| 1218 | v.AuxInt = config.PtrSize |
| 1219 | v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 1220 | v0.Type = config.fe.TypeUintptr().PtrTo() |
| 1221 | v0.AuxInt = config.PtrSize |
| 1222 | v0.AddArg(dst) |
| 1223 | v.AddArg(v0) |
| 1224 | v.AddArg(len) |
| 1225 | v1 := b.NewValue0(v.Line, OpStore, TypeInvalid) |
| 1226 | v1.Type = TypeMem |
| 1227 | v1.AuxInt = config.PtrSize |
| 1228 | v1.AddArg(dst) |
| 1229 | v1.AddArg(ptr) |
| 1230 | v1.AddArg(mem) |
| 1231 | v.AddArg(v1) |
| 1232 | return true |
| 1233 | } |
| 1234 | goto end25ae4fc3dc01583a4adc45067d49940a |
| 1235 | end25ae4fc3dc01583a4adc45067d49940a: |
| 1236 | ; |
| 1237 | // match: (Store [3*config.PtrSize] dst (SliceMake ptr len cap) mem) |
| 1238 | // cond: |
| 1239 | // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeUintptr().PtrTo()> [2*config.PtrSize] dst) cap (Store <TypeMem> [config.PtrSize] (OffPtr <config.fe.TypeUintptr().PtrTo()> [config.PtrSize] dst) len (Store <TypeMem> [config.PtrSize] dst ptr mem))) |
| 1240 | { |
| 1241 | if v.AuxInt != 3*config.PtrSize { |
| 1242 | goto end39ab85d51c8cd7f5d54e3eea4fb79a96 |
| 1243 | } |
| 1244 | dst := v.Args[0] |
| 1245 | if v.Args[1].Op != OpSliceMake { |
| 1246 | goto end39ab85d51c8cd7f5d54e3eea4fb79a96 |
| 1247 | } |
| 1248 | ptr := v.Args[1].Args[0] |
| 1249 | len := v.Args[1].Args[1] |
| 1250 | cap := v.Args[1].Args[2] |
| 1251 | mem := v.Args[2] |
| 1252 | v.Op = OpStore |
| 1253 | v.AuxInt = 0 |
| 1254 | v.Aux = nil |
| 1255 | v.resetArgs() |
| 1256 | v.AuxInt = config.PtrSize |
| 1257 | v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 1258 | v0.Type = config.fe.TypeUintptr().PtrTo() |
| 1259 | v0.AuxInt = 2 * config.PtrSize |
| 1260 | v0.AddArg(dst) |
| 1261 | v.AddArg(v0) |
| 1262 | v.AddArg(cap) |
| 1263 | v1 := b.NewValue0(v.Line, OpStore, TypeInvalid) |
| 1264 | v1.Type = TypeMem |
| 1265 | v1.AuxInt = config.PtrSize |
| 1266 | v2 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 1267 | v2.Type = config.fe.TypeUintptr().PtrTo() |
| 1268 | v2.AuxInt = config.PtrSize |
| 1269 | v2.AddArg(dst) |
| 1270 | v1.AddArg(v2) |
| 1271 | v1.AddArg(len) |
| 1272 | v3 := b.NewValue0(v.Line, OpStore, TypeInvalid) |
| 1273 | v3.Type = TypeMem |
| 1274 | v3.AuxInt = config.PtrSize |
| 1275 | v3.AddArg(dst) |
| 1276 | v3.AddArg(ptr) |
| 1277 | v3.AddArg(mem) |
| 1278 | v1.AddArg(v3) |
| 1279 | v.AddArg(v1) |
| 1280 | return true |
| 1281 | } |
| 1282 | goto end39ab85d51c8cd7f5d54e3eea4fb79a96 |
| 1283 | end39ab85d51c8cd7f5d54e3eea4fb79a96: |
| 1284 | ; |
| 1285 | // match: (Store [2*config.PtrSize] dst (IMake itab data) mem) |
| 1286 | // cond: |
| 1287 | // result: (Store [config.PtrSize] (OffPtr <config.fe.TypeBytePtr().PtrTo()> [config.PtrSize] dst) data (Store <TypeMem> [config.PtrSize] dst itab mem)) |
| 1288 | { |
| 1289 | if v.AuxInt != 2*config.PtrSize { |
| 1290 | goto end63b77ae78d92c05d496202e8b6b96ff3 |
| 1291 | } |
| 1292 | dst := v.Args[0] |
| 1293 | if v.Args[1].Op != OpIMake { |
| 1294 | goto end63b77ae78d92c05d496202e8b6b96ff3 |
| 1295 | } |
| 1296 | itab := v.Args[1].Args[0] |
| 1297 | data := v.Args[1].Args[1] |
| 1298 | mem := v.Args[2] |
| 1299 | v.Op = OpStore |
| 1300 | v.AuxInt = 0 |
| 1301 | v.Aux = nil |
| 1302 | v.resetArgs() |
| 1303 | v.AuxInt = config.PtrSize |
| 1304 | v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
| 1305 | v0.Type = config.fe.TypeBytePtr().PtrTo() |
| 1306 | v0.AuxInt = config.PtrSize |
| 1307 | v0.AddArg(dst) |
| 1308 | v.AddArg(v0) |
| 1309 | v.AddArg(data) |
| 1310 | v1 := b.NewValue0(v.Line, OpStore, TypeInvalid) |
| 1311 | v1.Type = TypeMem |
| 1312 | v1.AuxInt = config.PtrSize |
| 1313 | v1.AddArg(dst) |
| 1314 | v1.AddArg(itab) |
| 1315 | v1.AddArg(mem) |
| 1316 | v.AddArg(v1) |
| 1317 | return true |
| 1318 | } |
| 1319 | goto end63b77ae78d92c05d496202e8b6b96ff3 |
| 1320 | end63b77ae78d92c05d496202e8b6b96ff3: |
| 1321 | ; |
Keith Randall | d4cc51d | 2015-08-14 21:47:20 -0700 | [diff] [blame] | 1322 | // match: (Store [size] dst (Load src mem) mem) |
| 1323 | // cond: size > config.IntSize |
| 1324 | // result: (Move [size] dst src mem) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1325 | { |
Keith Randall | d4cc51d | 2015-08-14 21:47:20 -0700 | [diff] [blame] | 1326 | size := v.AuxInt |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1327 | dst := v.Args[0] |
| 1328 | if v.Args[1].Op != OpLoad { |
Keith Randall | d4cc51d | 2015-08-14 21:47:20 -0700 | [diff] [blame] | 1329 | goto enda18a7163888e2f4fca9f38bae56cef42 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1330 | } |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1331 | src := v.Args[1].Args[0] |
| 1332 | mem := v.Args[1].Args[1] |
Alexandru Moșoi | 9b25da7 | 2015-07-31 12:32:22 +0200 | [diff] [blame] | 1333 | if v.Args[2] != mem { |
Keith Randall | d4cc51d | 2015-08-14 21:47:20 -0700 | [diff] [blame] | 1334 | goto enda18a7163888e2f4fca9f38bae56cef42 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1335 | } |
Keith Randall | d4cc51d | 2015-08-14 21:47:20 -0700 | [diff] [blame] | 1336 | if !(size > config.IntSize) { |
| 1337 | goto enda18a7163888e2f4fca9f38bae56cef42 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1338 | } |
| 1339 | v.Op = OpMove |
Keith Randall | 8f22b52 | 2015-06-11 21:29:25 -0700 | [diff] [blame] | 1340 | v.AuxInt = 0 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1341 | v.Aux = nil |
| 1342 | v.resetArgs() |
Keith Randall | d4cc51d | 2015-08-14 21:47:20 -0700 | [diff] [blame] | 1343 | v.AuxInt = size |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1344 | v.AddArg(dst) |
| 1345 | v.AddArg(src) |
| 1346 | v.AddArg(mem) |
| 1347 | return true |
| 1348 | } |
Keith Randall | d4cc51d | 2015-08-14 21:47:20 -0700 | [diff] [blame] | 1349 | goto enda18a7163888e2f4fca9f38bae56cef42 |
| 1350 | enda18a7163888e2f4fca9f38bae56cef42: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1351 | ; |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1352 | case OpStringLen: |
| 1353 | // match: (StringLen (StringMake _ len)) |
| 1354 | // cond: |
| 1355 | // result: len |
| 1356 | { |
| 1357 | if v.Args[0].Op != OpStringMake { |
| 1358 | goto end0d922460b7e5ca88324034f4bd6c027c |
| 1359 | } |
| 1360 | len := v.Args[0].Args[1] |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 1361 | v.Op = OpCopy |
| 1362 | v.AuxInt = 0 |
| 1363 | v.Aux = nil |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1364 | v.resetArgs() |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 1365 | v.Type = len.Type |
| 1366 | v.AddArg(len) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1367 | return true |
| 1368 | } |
| 1369 | goto end0d922460b7e5ca88324034f4bd6c027c |
| 1370 | end0d922460b7e5ca88324034f4bd6c027c: |
| 1371 | ; |
| 1372 | case OpStringPtr: |
| 1373 | // match: (StringPtr (StringMake ptr _)) |
| 1374 | // cond: |
| 1375 | // result: ptr |
| 1376 | { |
| 1377 | if v.Args[0].Op != OpStringMake { |
| 1378 | goto end061edc5d85c73ad909089af2556d9380 |
| 1379 | } |
| 1380 | ptr := v.Args[0].Args[0] |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 1381 | v.Op = OpCopy |
| 1382 | v.AuxInt = 0 |
| 1383 | v.Aux = nil |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1384 | v.resetArgs() |
Josh Bleecher Snyder | 0fb818a | 2015-08-05 10:33:09 -0700 | [diff] [blame] | 1385 | v.Type = ptr.Type |
| 1386 | v.AddArg(ptr) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1387 | return true |
| 1388 | } |
| 1389 | goto end061edc5d85c73ad909089af2556d9380 |
| 1390 | end061edc5d85c73ad909089af2556d9380: |
Keith Randall | cd7e059 | 2015-07-15 21:33:49 -0700 | [diff] [blame] | 1391 | ; |
| 1392 | case OpStructSelect: |
| 1393 | // match: (StructSelect [idx] (Load ptr mem)) |
| 1394 | // cond: |
| 1395 | // result: (Load (OffPtr <v.Type.PtrTo()> [idx] ptr) mem) |
| 1396 | { |
| 1397 | idx := v.AuxInt |
| 1398 | if v.Args[0].Op != OpLoad { |
| 1399 | goto end16fdb45e1dd08feb36e3cc3fb5ed8935 |
| 1400 | } |
| 1401 | ptr := v.Args[0].Args[0] |
| 1402 | mem := v.Args[0].Args[1] |
| 1403 | v.Op = OpLoad |
| 1404 | v.AuxInt = 0 |
| 1405 | v.Aux = nil |
| 1406 | v.resetArgs() |
Keith Randall | 683f5d7 | 2015-08-04 12:24:23 -0700 | [diff] [blame] | 1407 | v0 := b.NewValue0(v.Line, OpOffPtr, TypeInvalid) |
Keith Randall | cd7e059 | 2015-07-15 21:33:49 -0700 | [diff] [blame] | 1408 | v0.Type = v.Type.PtrTo() |
| 1409 | v0.AuxInt = idx |
| 1410 | v0.AddArg(ptr) |
| 1411 | v.AddArg(v0) |
| 1412 | v.AddArg(mem) |
| 1413 | return true |
| 1414 | } |
| 1415 | goto end16fdb45e1dd08feb36e3cc3fb5ed8935 |
| 1416 | end16fdb45e1dd08feb36e3cc3fb5ed8935: |
Alexandru Moșoi | 198fc9a | 2015-08-14 12:59:33 +0200 | [diff] [blame] | 1417 | ; |
| 1418 | case OpSub16: |
| 1419 | // match: (Sub16 x x) |
| 1420 | // cond: |
| 1421 | // result: (Const16 [0]) |
| 1422 | { |
| 1423 | x := v.Args[0] |
| 1424 | if v.Args[1] != x { |
| 1425 | goto end83da541391be564f2a08464e674a49e7 |
| 1426 | } |
| 1427 | v.Op = OpConst16 |
| 1428 | v.AuxInt = 0 |
| 1429 | v.Aux = nil |
| 1430 | v.resetArgs() |
| 1431 | v.AuxInt = 0 |
| 1432 | return true |
| 1433 | } |
| 1434 | goto end83da541391be564f2a08464e674a49e7 |
| 1435 | end83da541391be564f2a08464e674a49e7: |
| 1436 | ; |
| 1437 | case OpSub32: |
| 1438 | // match: (Sub32 x x) |
| 1439 | // cond: |
| 1440 | // result: (Const32 [0]) |
| 1441 | { |
| 1442 | x := v.Args[0] |
| 1443 | if v.Args[1] != x { |
| 1444 | goto enda747581e798f199e07f4ad69747cd069 |
| 1445 | } |
| 1446 | v.Op = OpConst32 |
| 1447 | v.AuxInt = 0 |
| 1448 | v.Aux = nil |
| 1449 | v.resetArgs() |
| 1450 | v.AuxInt = 0 |
| 1451 | return true |
| 1452 | } |
| 1453 | goto enda747581e798f199e07f4ad69747cd069 |
| 1454 | enda747581e798f199e07f4ad69747cd069: |
| 1455 | ; |
| 1456 | case OpSub64: |
| 1457 | // match: (Sub64 x x) |
| 1458 | // cond: |
| 1459 | // result: (Const64 [0]) |
| 1460 | { |
| 1461 | x := v.Args[0] |
| 1462 | if v.Args[1] != x { |
| 1463 | goto end0387dc2b7bbe57d4aa54eab5d959da4b |
| 1464 | } |
| 1465 | v.Op = OpConst64 |
| 1466 | v.AuxInt = 0 |
| 1467 | v.Aux = nil |
| 1468 | v.resetArgs() |
| 1469 | v.AuxInt = 0 |
| 1470 | return true |
| 1471 | } |
| 1472 | goto end0387dc2b7bbe57d4aa54eab5d959da4b |
| 1473 | end0387dc2b7bbe57d4aa54eab5d959da4b: |
| 1474 | ; |
| 1475 | case OpSub8: |
| 1476 | // match: (Sub8 x x) |
| 1477 | // cond: |
| 1478 | // result: (Const8 [0]) |
| 1479 | { |
| 1480 | x := v.Args[0] |
| 1481 | if v.Args[1] != x { |
| 1482 | goto end4e2ee15ef17611919a1a6b5f80bbfe18 |
| 1483 | } |
| 1484 | v.Op = OpConst8 |
| 1485 | v.AuxInt = 0 |
| 1486 | v.Aux = nil |
| 1487 | v.resetArgs() |
| 1488 | v.AuxInt = 0 |
| 1489 | return true |
| 1490 | } |
| 1491 | goto end4e2ee15ef17611919a1a6b5f80bbfe18 |
| 1492 | end4e2ee15ef17611919a1a6b5f80bbfe18: |
| 1493 | ; |
| 1494 | case OpXor16: |
| 1495 | // match: (Xor16 x x) |
| 1496 | // cond: |
| 1497 | // result: (Const16 [0]) |
| 1498 | { |
| 1499 | x := v.Args[0] |
| 1500 | if v.Args[1] != x { |
| 1501 | goto end5733ceb1903b8140248d8e2cac02fefe |
| 1502 | } |
| 1503 | v.Op = OpConst16 |
| 1504 | v.AuxInt = 0 |
| 1505 | v.Aux = nil |
| 1506 | v.resetArgs() |
| 1507 | v.AuxInt = 0 |
| 1508 | return true |
| 1509 | } |
| 1510 | goto end5733ceb1903b8140248d8e2cac02fefe |
| 1511 | end5733ceb1903b8140248d8e2cac02fefe: |
| 1512 | ; |
| 1513 | case OpXor32: |
| 1514 | // match: (Xor32 x x) |
| 1515 | // cond: |
| 1516 | // result: (Const32 [0]) |
| 1517 | { |
| 1518 | x := v.Args[0] |
| 1519 | if v.Args[1] != x { |
| 1520 | goto end268ca02df6515d648e0bfb4e90981d25 |
| 1521 | } |
| 1522 | v.Op = OpConst32 |
| 1523 | v.AuxInt = 0 |
| 1524 | v.Aux = nil |
| 1525 | v.resetArgs() |
| 1526 | v.AuxInt = 0 |
| 1527 | return true |
| 1528 | } |
| 1529 | goto end268ca02df6515d648e0bfb4e90981d25 |
| 1530 | end268ca02df6515d648e0bfb4e90981d25: |
| 1531 | ; |
| 1532 | case OpXor64: |
| 1533 | // match: (Xor64 x x) |
| 1534 | // cond: |
| 1535 | // result: (Const64 [0]) |
| 1536 | { |
| 1537 | x := v.Args[0] |
| 1538 | if v.Args[1] != x { |
| 1539 | goto endaf44e7f9fc58af30df69070953fb45ce |
| 1540 | } |
| 1541 | v.Op = OpConst64 |
| 1542 | v.AuxInt = 0 |
| 1543 | v.Aux = nil |
| 1544 | v.resetArgs() |
| 1545 | v.AuxInt = 0 |
| 1546 | return true |
| 1547 | } |
| 1548 | goto endaf44e7f9fc58af30df69070953fb45ce |
| 1549 | endaf44e7f9fc58af30df69070953fb45ce: |
| 1550 | ; |
| 1551 | case OpXor8: |
| 1552 | // match: (Xor8 x x) |
| 1553 | // cond: |
| 1554 | // result: (Const8 [0]) |
| 1555 | { |
| 1556 | x := v.Args[0] |
| 1557 | if v.Args[1] != x { |
| 1558 | goto end949b3a60b7d181688e6f79f93c782fc8 |
| 1559 | } |
| 1560 | v.Op = OpConst8 |
| 1561 | v.AuxInt = 0 |
| 1562 | v.Aux = nil |
| 1563 | v.resetArgs() |
| 1564 | v.AuxInt = 0 |
| 1565 | return true |
| 1566 | } |
| 1567 | goto end949b3a60b7d181688e6f79f93c782fc8 |
| 1568 | end949b3a60b7d181688e6f79f93c782fc8: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1569 | } |
| 1570 | return false |
| 1571 | } |
| 1572 | func rewriteBlockgeneric(b *Block) bool { |
| 1573 | switch b.Kind { |
| 1574 | case BlockIf: |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1575 | // match: (If (IsNonNil (GetG)) yes no) |
| 1576 | // cond: |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1577 | // result: (First nil yes no) |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1578 | { |
| 1579 | v := b.Control |
| 1580 | if v.Op != OpIsNonNil { |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1581 | goto endafdc4e2525f9933ab0ae7effc3559597 |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1582 | } |
| 1583 | if v.Args[0].Op != OpGetG { |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1584 | goto endafdc4e2525f9933ab0ae7effc3559597 |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1585 | } |
| 1586 | yes := b.Succs[0] |
| 1587 | no := b.Succs[1] |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1588 | b.Kind = BlockFirst |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1589 | b.Control = nil |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1590 | b.Succs[0] = yes |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1591 | b.Succs[1] = no |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1592 | return true |
| 1593 | } |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1594 | goto endafdc4e2525f9933ab0ae7effc3559597 |
| 1595 | endafdc4e2525f9933ab0ae7effc3559597: |
Josh Bleecher Snyder | 3d23afb | 2015-08-12 11:22:16 -0700 | [diff] [blame] | 1596 | ; |
Todd Neal | 52d76f7 | 2015-07-23 18:44:09 -0500 | [diff] [blame] | 1597 | // match: (If (Not cond) yes no) |
| 1598 | // cond: |
| 1599 | // result: (If cond no yes) |
| 1600 | { |
| 1601 | v := b.Control |
| 1602 | if v.Op != OpNot { |
| 1603 | goto endebe19c1c3c3bec068cdb2dd29ef57f96 |
| 1604 | } |
| 1605 | cond := v.Args[0] |
| 1606 | yes := b.Succs[0] |
| 1607 | no := b.Succs[1] |
| 1608 | b.Kind = BlockIf |
| 1609 | b.Control = cond |
| 1610 | b.Succs[0] = no |
| 1611 | b.Succs[1] = yes |
Josh Bleecher Snyder | bbf8c5c | 2015-08-11 17:28:56 -0700 | [diff] [blame] | 1612 | b.Likely *= -1 |
Todd Neal | 52d76f7 | 2015-07-23 18:44:09 -0500 | [diff] [blame] | 1613 | return true |
| 1614 | } |
| 1615 | goto endebe19c1c3c3bec068cdb2dd29ef57f96 |
| 1616 | endebe19c1c3c3bec068cdb2dd29ef57f96: |
| 1617 | ; |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 1618 | // match: (If (ConstBool {c}) yes no) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1619 | // cond: c.(bool) |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1620 | // result: (First nil yes no) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1621 | { |
| 1622 | v := b.Control |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 1623 | if v.Op != OpConstBool { |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1624 | goto end7a20763049489cdb40bb1eaa57d113d8 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1625 | } |
| 1626 | c := v.Aux |
| 1627 | yes := b.Succs[0] |
| 1628 | no := b.Succs[1] |
| 1629 | if !(c.(bool)) { |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1630 | goto end7a20763049489cdb40bb1eaa57d113d8 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1631 | } |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1632 | b.Kind = BlockFirst |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1633 | b.Control = nil |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1634 | b.Succs[0] = yes |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1635 | b.Succs[1] = no |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1636 | return true |
| 1637 | } |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1638 | goto end7a20763049489cdb40bb1eaa57d113d8 |
| 1639 | end7a20763049489cdb40bb1eaa57d113d8: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1640 | ; |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 1641 | // match: (If (ConstBool {c}) yes no) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1642 | // cond: !c.(bool) |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1643 | // result: (First nil no yes) |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1644 | { |
| 1645 | v := b.Control |
Keith Randall | 9cb332e | 2015-07-28 14:19:20 -0700 | [diff] [blame] | 1646 | if v.Op != OpConstBool { |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1647 | goto end3ecbf5b2cc1f0a08444d8ab1871a829c |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1648 | } |
| 1649 | c := v.Aux |
| 1650 | yes := b.Succs[0] |
| 1651 | no := b.Succs[1] |
| 1652 | if !(!c.(bool)) { |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1653 | goto end3ecbf5b2cc1f0a08444d8ab1871a829c |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1654 | } |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1655 | b.Kind = BlockFirst |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1656 | b.Control = nil |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1657 | b.Succs[0] = no |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1658 | b.Succs[1] = yes |
| 1659 | b.Likely *= -1 |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1660 | return true |
| 1661 | } |
Keith Randall | 186cf1b | 2015-08-28 16:45:17 -0700 | [diff] [blame^] | 1662 | goto end3ecbf5b2cc1f0a08444d8ab1871a829c |
| 1663 | end3ecbf5b2cc1f0a08444d8ab1871a829c: |
Keith Randall | 0dca735 | 2015-06-06 16:03:33 -0700 | [diff] [blame] | 1664 | } |
| 1665 | return false |
| 1666 | } |