OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/x64/assembler-x64.h" | 5 #include "src/x64/assembler-x64.h" |
6 | 6 |
7 #include <cstring> | 7 #include <cstring> |
8 | 8 |
9 #if V8_TARGET_ARCH_X64 | 9 #if V8_TARGET_ARCH_X64 |
10 | 10 |
(...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2883 EnsureSpace ensure_space(this); | 2883 EnsureSpace ensure_space(this); |
2884 emit(0x66); | 2884 emit(0x66); |
2885 emit_optional_rex_32(dst, src); | 2885 emit_optional_rex_32(dst, src); |
2886 emit(0x0F); | 2886 emit(0x0F); |
2887 emit(0x3A); | 2887 emit(0x3A); |
2888 emit(0x22); | 2888 emit(0x22); |
2889 emit_sse_operand(dst, src); | 2889 emit_sse_operand(dst, src); |
2890 emit(imm8); | 2890 emit(imm8); |
2891 } | 2891 } |
2892 | 2892 |
| 2893 void Assembler::insertps(XMMRegister dst, XMMRegister src, byte imm8) { |
| 2894 DCHECK(CpuFeatures::IsSupported(SSE4_1)); |
| 2895 DCHECK(is_uint8(imm8)); |
| 2896 EnsureSpace ensure_space(this); |
| 2897 emit(0x66); |
| 2898 emit_optional_rex_32(dst, src); |
| 2899 emit(0x0F); |
| 2900 emit(0x3A); |
| 2901 emit(0x21); |
| 2902 emit_sse_operand(dst, src); |
| 2903 emit(imm8); |
| 2904 } |
2893 | 2905 |
2894 void Assembler::movsd(const Operand& dst, XMMRegister src) { | 2906 void Assembler::movsd(const Operand& dst, XMMRegister src) { |
2895 DCHECK(!IsEnabled(AVX)); | 2907 DCHECK(!IsEnabled(AVX)); |
2896 EnsureSpace ensure_space(this); | 2908 EnsureSpace ensure_space(this); |
2897 emit(0xF2); // double | 2909 emit(0xF2); // double |
2898 emit_optional_rex_32(src, dst); | 2910 emit_optional_rex_32(src, dst); |
2899 emit(0x0F); | 2911 emit(0x0F); |
2900 emit(0x11); // store | 2912 emit(0x11); // store |
2901 emit_sse_operand(src, dst); | 2913 emit_sse_operand(src, dst); |
2902 } | 2914 } |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3204 void Assembler::psrld(XMMRegister reg, byte imm8) { | 3216 void Assembler::psrld(XMMRegister reg, byte imm8) { |
3205 EnsureSpace ensure_space(this); | 3217 EnsureSpace ensure_space(this); |
3206 emit(0x66); | 3218 emit(0x66); |
3207 emit_optional_rex_32(reg); | 3219 emit_optional_rex_32(reg); |
3208 emit(0x0F); | 3220 emit(0x0F); |
3209 emit(0x72); | 3221 emit(0x72); |
3210 emit_sse_operand(rdx, reg); // rdx == 2 | 3222 emit_sse_operand(rdx, reg); // rdx == 2 |
3211 emit(imm8); | 3223 emit(imm8); |
3212 } | 3224 } |
3213 | 3225 |
| 3226 void Assembler::cmpps(XMMRegister dst, XMMRegister src, int8_t cmp) { |
| 3227 EnsureSpace ensure_space(this); |
| 3228 emit_optional_rex_32(dst, src); |
| 3229 emit(0x0F); |
| 3230 emit(0xC2); |
| 3231 emit_sse_operand(dst, src); |
| 3232 emit(cmp); |
| 3233 } |
| 3234 |
| 3235 void Assembler::cmpeqps(XMMRegister dst, XMMRegister src) { |
| 3236 cmpps(dst, src, 0x0); |
| 3237 } |
| 3238 |
| 3239 void Assembler::cmpltps(XMMRegister dst, XMMRegister src) { |
| 3240 cmpps(dst, src, 0x1); |
| 3241 } |
| 3242 |
| 3243 void Assembler::cmpleps(XMMRegister dst, XMMRegister src) { |
| 3244 cmpps(dst, src, 0x2); |
| 3245 } |
| 3246 |
| 3247 void Assembler::cmpneqps(XMMRegister dst, XMMRegister src) { |
| 3248 cmpps(dst, src, 0x4); |
| 3249 } |
| 3250 |
| 3251 void Assembler::cmpnltps(XMMRegister dst, XMMRegister src) { |
| 3252 cmpps(dst, src, 0x5); |
| 3253 } |
| 3254 |
| 3255 void Assembler::cmpnleps(XMMRegister dst, XMMRegister src) { |
| 3256 cmpps(dst, src, 0x6); |
| 3257 } |
3214 | 3258 |
3215 void Assembler::cvttss2si(Register dst, const Operand& src) { | 3259 void Assembler::cvttss2si(Register dst, const Operand& src) { |
3216 DCHECK(!IsEnabled(AVX)); | 3260 DCHECK(!IsEnabled(AVX)); |
3217 EnsureSpace ensure_space(this); | 3261 EnsureSpace ensure_space(this); |
3218 emit(0xF3); | 3262 emit(0xF3); |
3219 emit_optional_rex_32(dst, src); | 3263 emit_optional_rex_32(dst, src); |
3220 emit(0x0F); | 3264 emit(0x0F); |
3221 emit(0x2C); | 3265 emit(0x2C); |
3222 emit_operand(dst, src); | 3266 emit_operand(dst, src); |
3223 } | 3267 } |
(...skipping 961 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4185 DCHECK(IsEnabled(BMI2)); | 4229 DCHECK(IsEnabled(BMI2)); |
4186 DCHECK(is_uint8(imm8)); | 4230 DCHECK(is_uint8(imm8)); |
4187 Register vreg = {0}; // VEX.vvvv unused | 4231 Register vreg = {0}; // VEX.vvvv unused |
4188 EnsureSpace ensure_space(this); | 4232 EnsureSpace ensure_space(this); |
4189 emit_vex_prefix(dst, vreg, src, kLZ, kF2, k0F3A, kW0); | 4233 emit_vex_prefix(dst, vreg, src, kLZ, kF2, k0F3A, kW0); |
4190 emit(0xF0); | 4234 emit(0xF0); |
4191 emit_operand(dst, src); | 4235 emit_operand(dst, src); |
4192 emit(imm8); | 4236 emit(imm8); |
4193 } | 4237 } |
4194 | 4238 |
| 4239 void Assembler::minps(XMMRegister dst, XMMRegister src) { |
| 4240 EnsureSpace ensure_space(this); |
| 4241 emit_optional_rex_32(dst, src); |
| 4242 emit(0x0F); |
| 4243 emit(0x5D); |
| 4244 emit_sse_operand(dst, src); |
| 4245 } |
| 4246 |
| 4247 void Assembler::minps(XMMRegister dst, const Operand& src) { |
| 4248 EnsureSpace ensure_space(this); |
| 4249 emit_optional_rex_32(dst, src); |
| 4250 emit(0x0F); |
| 4251 emit(0x5D); |
| 4252 emit_sse_operand(dst, src); |
| 4253 } |
| 4254 |
| 4255 void Assembler::maxps(XMMRegister dst, XMMRegister src) { |
| 4256 EnsureSpace ensure_space(this); |
| 4257 emit_optional_rex_32(dst, src); |
| 4258 emit(0x0F); |
| 4259 emit(0x5F); |
| 4260 emit_sse_operand(dst, src); |
| 4261 } |
| 4262 |
| 4263 void Assembler::maxps(XMMRegister dst, const Operand& src) { |
| 4264 EnsureSpace ensure_space(this); |
| 4265 emit_optional_rex_32(dst, src); |
| 4266 emit(0x0F); |
| 4267 emit(0x5F); |
| 4268 emit_sse_operand(dst, src); |
| 4269 } |
| 4270 |
| 4271 void Assembler::rcpps(XMMRegister dst, XMMRegister src) { |
| 4272 EnsureSpace ensure_space(this); |
| 4273 emit_optional_rex_32(dst, src); |
| 4274 emit(0x0F); |
| 4275 emit(0x53); |
| 4276 emit_sse_operand(dst, src); |
| 4277 } |
| 4278 |
| 4279 void Assembler::rcpps(XMMRegister dst, const Operand& src) { |
| 4280 EnsureSpace ensure_space(this); |
| 4281 emit_optional_rex_32(dst, src); |
| 4282 emit(0x0F); |
| 4283 emit(0x53); |
| 4284 emit_sse_operand(dst, src); |
| 4285 } |
| 4286 |
| 4287 void Assembler::rsqrtps(XMMRegister dst, XMMRegister src) { |
| 4288 EnsureSpace ensure_space(this); |
| 4289 emit_optional_rex_32(dst, src); |
| 4290 emit(0x0F); |
| 4291 emit(0x52); |
| 4292 emit_sse_operand(dst, src); |
| 4293 } |
| 4294 |
| 4295 void Assembler::rsqrtps(XMMRegister dst, const Operand& src) { |
| 4296 EnsureSpace ensure_space(this); |
| 4297 emit_optional_rex_32(dst, src); |
| 4298 emit(0x0F); |
| 4299 emit(0x52); |
| 4300 emit_sse_operand(dst, src); |
| 4301 } |
| 4302 |
| 4303 void Assembler::sqrtps(XMMRegister dst, XMMRegister src) { |
| 4304 EnsureSpace ensure_space(this); |
| 4305 emit_optional_rex_32(dst, src); |
| 4306 emit(0x0F); |
| 4307 emit(0x51); |
| 4308 emit_sse_operand(dst, src); |
| 4309 } |
| 4310 |
| 4311 void Assembler::sqrtps(XMMRegister dst, const Operand& src) { |
| 4312 EnsureSpace ensure_space(this); |
| 4313 emit_optional_rex_32(dst, src); |
| 4314 emit(0x0F); |
| 4315 emit(0x51); |
| 4316 emit_sse_operand(dst, src); |
| 4317 } |
| 4318 |
| 4319 void Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) { |
| 4320 EnsureSpace ensure_space(this); |
| 4321 emit_optional_rex_32(dst, src); |
| 4322 emit(0x0F); |
| 4323 emit(0x5B); |
| 4324 emit_sse_operand(dst, src); |
| 4325 } |
| 4326 |
| 4327 void Assembler::cvtdq2ps(XMMRegister dst, const Operand& src) { |
| 4328 EnsureSpace ensure_space(this); |
| 4329 emit_optional_rex_32(dst, src); |
| 4330 emit(0x0F); |
| 4331 emit(0x5B); |
| 4332 emit_sse_operand(dst, src); |
| 4333 } |
| 4334 |
| 4335 void Assembler::movups(XMMRegister dst, XMMRegister src) { |
| 4336 EnsureSpace ensure_space(this); |
| 4337 if (src.low_bits() == 4) { |
| 4338 // Try to avoid an unnecessary SIB byte. |
| 4339 emit_optional_rex_32(src, dst); |
| 4340 emit(0x0F); |
| 4341 emit(0x11); |
| 4342 emit_sse_operand(src, dst); |
| 4343 } else { |
| 4344 emit_optional_rex_32(dst, src); |
| 4345 emit(0x0F); |
| 4346 emit(0x10); |
| 4347 emit_sse_operand(dst, src); |
| 4348 } |
| 4349 } |
| 4350 |
| 4351 void Assembler::movups(XMMRegister dst, const Operand& src) { |
| 4352 EnsureSpace ensure_space(this); |
| 4353 emit_optional_rex_32(dst, src); |
| 4354 emit(0x0F); |
| 4355 emit(0x10); |
| 4356 emit_sse_operand(dst, src); |
| 4357 } |
| 4358 |
| 4359 void Assembler::movups(const Operand& dst, XMMRegister src) { |
| 4360 EnsureSpace ensure_space(this); |
| 4361 emit_optional_rex_32(src, dst); |
| 4362 emit(0x0F); |
| 4363 emit(0x11); |
| 4364 emit_sse_operand(src, dst); |
| 4365 } |
| 4366 |
| 4367 void Assembler::paddd(XMMRegister dst, XMMRegister src) { |
| 4368 EnsureSpace ensure_space(this); |
| 4369 emit(0x66); |
| 4370 emit_optional_rex_32(dst, src); |
| 4371 emit(0x0F); |
| 4372 emit(0xFE); |
| 4373 emit_sse_operand(dst, src); |
| 4374 } |
| 4375 |
| 4376 void Assembler::paddd(XMMRegister dst, const Operand& src) { |
| 4377 EnsureSpace ensure_space(this); |
| 4378 emit(0x66); |
| 4379 emit_optional_rex_32(dst, src); |
| 4380 emit(0x0F); |
| 4381 emit(0xFE); |
| 4382 emit_sse_operand(dst, src); |
| 4383 } |
| 4384 |
| 4385 void Assembler::psubd(XMMRegister dst, XMMRegister src) { |
| 4386 EnsureSpace ensure_space(this); |
| 4387 emit(0x66); |
| 4388 emit_optional_rex_32(dst, src); |
| 4389 emit(0x0F); |
| 4390 emit(0xFA); |
| 4391 emit_sse_operand(dst, src); |
| 4392 } |
| 4393 |
| 4394 void Assembler::psubd(XMMRegister dst, const Operand& src) { |
| 4395 EnsureSpace ensure_space(this); |
| 4396 emit(0x66); |
| 4397 emit_optional_rex_32(dst, src); |
| 4398 emit(0x0F); |
| 4399 emit(0xFA); |
| 4400 emit_sse_operand(dst, src); |
| 4401 } |
| 4402 |
| 4403 void Assembler::pmulld(XMMRegister dst, XMMRegister src) { |
| 4404 DCHECK(IsEnabled(SSE4_1)); |
| 4405 EnsureSpace ensure_space(this); |
| 4406 emit(0x66); |
| 4407 emit_optional_rex_32(dst, src); |
| 4408 emit(0x0F); |
| 4409 emit(0x38); |
| 4410 emit(0x40); |
| 4411 emit_sse_operand(dst, src); |
| 4412 } |
| 4413 |
| 4414 void Assembler::pmulld(XMMRegister dst, const Operand& src) { |
| 4415 EnsureSpace ensure_space(this); |
| 4416 emit(0x66); |
| 4417 emit_optional_rex_32(dst, src); |
| 4418 emit(0x0F); |
| 4419 emit(0xF4); |
| 4420 emit_sse_operand(dst, src); |
| 4421 } |
| 4422 |
| 4423 void Assembler::pmuludq(XMMRegister dst, XMMRegister src) { |
| 4424 EnsureSpace ensure_space(this); |
| 4425 emit(0x66); |
| 4426 emit_optional_rex_32(dst, src); |
| 4427 emit(0x0F); |
| 4428 emit(0xF4); |
| 4429 emit_sse_operand(dst, src); |
| 4430 } |
| 4431 |
| 4432 void Assembler::pmuludq(XMMRegister dst, const Operand& src) { |
| 4433 EnsureSpace ensure_space(this); |
| 4434 emit(0x66); |
| 4435 emit_optional_rex_32(dst, src); |
| 4436 emit(0x0F); |
| 4437 emit(0xF4); |
| 4438 emit_sse_operand(dst, src); |
| 4439 } |
| 4440 |
| 4441 void Assembler::punpackldq(XMMRegister dst, XMMRegister src) { |
| 4442 EnsureSpace ensure_space(this); |
| 4443 emit(0x66); |
| 4444 emit_optional_rex_32(dst, src); |
| 4445 emit(0x0F); |
| 4446 emit(0x62); |
| 4447 emit_sse_operand(dst, src); |
| 4448 } |
| 4449 |
| 4450 void Assembler::punpackldq(XMMRegister dst, const Operand& src) { |
| 4451 EnsureSpace ensure_space(this); |
| 4452 emit(0x66); |
| 4453 emit_optional_rex_32(dst, src); |
| 4454 emit(0x0F); |
| 4455 emit(0x62); |
| 4456 emit_sse_operand(dst, src); |
| 4457 } |
| 4458 |
| 4459 void Assembler::psrldq(XMMRegister dst, uint8_t shift) { |
| 4460 EnsureSpace ensure_space(this); |
| 4461 emit(0x66); |
| 4462 emit_optional_rex_32(dst); |
| 4463 emit(0x0F); |
| 4464 emit(0x73); |
| 4465 emit_sse_operand(dst); |
| 4466 emit(shift); |
| 4467 } |
| 4468 |
| 4469 void Assembler::cvtps2dq(XMMRegister dst, XMMRegister src) { |
| 4470 EnsureSpace ensure_space(this); |
| 4471 emit(0x66); |
| 4472 emit_optional_rex_32(dst, src); |
| 4473 emit(0x0F); |
| 4474 emit(0x5B); |
| 4475 emit_sse_operand(dst, src); |
| 4476 } |
| 4477 |
| 4478 void Assembler::cvtps2dq(XMMRegister dst, const Operand& src) { |
| 4479 EnsureSpace ensure_space(this); |
| 4480 emit(0x66); |
| 4481 emit_optional_rex_32(dst, src); |
| 4482 emit(0x0F); |
| 4483 emit(0x5B); |
| 4484 emit_sse_operand(dst, src); |
| 4485 } |
| 4486 |
| 4487 void Assembler::pshufd(XMMRegister dst, XMMRegister src, uint8_t shuffle) { |
| 4488 EnsureSpace ensure_space(this); |
| 4489 emit(0x66); |
| 4490 emit_optional_rex_32(dst, src); |
| 4491 emit(0x0F); |
| 4492 emit(0x70); |
| 4493 emit_sse_operand(dst, src); |
| 4494 emit(shuffle); |
| 4495 } |
4195 | 4496 |
4196 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { | 4497 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { |
4197 Register ireg = { reg.code() }; | 4498 Register ireg = { reg.code() }; |
4198 emit_operand(ireg, adr); | 4499 emit_operand(ireg, adr); |
4199 } | 4500 } |
4200 | 4501 |
4201 | 4502 |
4202 void Assembler::emit_sse_operand(Register reg, const Operand& adr) { | 4503 void Assembler::emit_sse_operand(Register reg, const Operand& adr) { |
4203 Register ireg = {reg.code()}; | 4504 Register ireg = {reg.code()}; |
4204 emit_operand(ireg, adr); | 4505 emit_operand(ireg, adr); |
4205 } | 4506 } |
4206 | 4507 |
4207 | 4508 |
4208 void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) { | 4509 void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) { |
4209 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); | 4510 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); |
4210 } | 4511 } |
4211 | 4512 |
4212 | 4513 |
4213 void Assembler::emit_sse_operand(XMMRegister dst, Register src) { | 4514 void Assembler::emit_sse_operand(XMMRegister dst, Register src) { |
4214 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); | 4515 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); |
4215 } | 4516 } |
4216 | 4517 |
4217 | 4518 |
4218 void Assembler::emit_sse_operand(Register dst, XMMRegister src) { | 4519 void Assembler::emit_sse_operand(Register dst, XMMRegister src) { |
4219 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); | 4520 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); |
4220 } | 4521 } |
4221 | 4522 |
| 4523 void Assembler::emit_sse_operand(XMMRegister dst) { |
| 4524 emit(0xD8 | dst.low_bits()); |
| 4525 } |
| 4526 |
4222 | 4527 |
4223 void Assembler::db(uint8_t data) { | 4528 void Assembler::db(uint8_t data) { |
4224 EnsureSpace ensure_space(this); | 4529 EnsureSpace ensure_space(this); |
4225 emit(data); | 4530 emit(data); |
4226 } | 4531 } |
4227 | 4532 |
4228 | 4533 |
4229 void Assembler::dd(uint32_t data) { | 4534 void Assembler::dd(uint32_t data) { |
4230 EnsureSpace ensure_space(this); | 4535 EnsureSpace ensure_space(this); |
4231 emitl(data); | 4536 emitl(data); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4292 | 4597 |
4293 bool RelocInfo::IsInConstantPool() { | 4598 bool RelocInfo::IsInConstantPool() { |
4294 return false; | 4599 return false; |
4295 } | 4600 } |
4296 | 4601 |
4297 | 4602 |
4298 } // namespace internal | 4603 } // namespace internal |
4299 } // namespace v8 | 4604 } // namespace v8 |
4300 | 4605 |
4301 #endif // V8_TARGET_ARCH_X64 | 4606 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |