Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: src/x64/assembler-x64.cc

Issue 90643003: Experimental implementation: Exposing SIMD instructions into JavaScript Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 2710 matching lines...) Expand 10 before | Expand all | Expand 10 after
2721 emit(0x66); 2721 emit(0x66);
2722 emit_optional_rex_32(src, dst); 2722 emit_optional_rex_32(src, dst);
2723 emit(0x0F); 2723 emit(0x0F);
2724 emit(0x3A); 2724 emit(0x3A);
2725 emit(0x17); 2725 emit(0x17);
2726 emit_sse_operand(src, dst); 2726 emit_sse_operand(src, dst);
2727 emit(imm8); 2727 emit(imm8);
2728 } 2728 }
2729 2729
2730 2730
2731 void Assembler::shufps(XMMRegister dst, XMMRegister src, byte imm8) {
2732 ASSERT(is_uint8(imm8));
2733 EnsureSpace ensure_space(this);
2734 emit_optional_rex_32(src, dst);
2735 emit(0x0F);
2736 emit(0xC6);
2737 emit_sse_operand(dst, src);
2738 emit(imm8);
2739 }
2740
2741
2742 void Assembler::insertps(XMMRegister dst, XMMRegister src, byte imm8) {
2743 ASSERT(CpuFeatures::IsSupported(SSE4_1));
2744 ASSERT(is_uint8(imm8));
2745 EnsureSpace ensure_space(this);
2746 emit(0x66);
2747 emit_optional_rex_32(dst, src);
2748 emit(0x0F);
2749 emit(0x3A);
2750 emit(0x21);
2751 emit_sse_operand(dst, src);
2752 emit(imm8);
2753 }
2754
2755
2756 void Assembler::pinsrd(XMMRegister dst, Register src, byte imm8) {
2757 ASSERT(CpuFeatures::IsSupported(SSE4_1));
2758 ASSERT(is_uint8(imm8));
2759 EnsureSpace ensure_space(this);
2760 emit(0x66);
2761 emit_optional_rex_32(dst, src);
2762 emit(0x0F);
2763 emit(0x3A);
2764 emit(0x22);
2765 emit_sse_operand(dst, src);
2766 emit(imm8);
2767 }
2768
2769
2731 void Assembler::movsd(const Operand& dst, XMMRegister src) { 2770 void Assembler::movsd(const Operand& dst, XMMRegister src) {
2732 EnsureSpace ensure_space(this); 2771 EnsureSpace ensure_space(this);
2733 emit(0xF2); // double 2772 emit(0xF2); // double
2734 emit_optional_rex_32(src, dst); 2773 emit_optional_rex_32(src, dst);
2735 emit(0x0F); 2774 emit(0x0F);
2736 emit(0x11); // store 2775 emit(0x11); // store
2737 emit_sse_operand(src, dst); 2776 emit_sse_operand(src, dst);
2738 } 2777 }
2739 2778
2740 2779
(...skipping 27 matching lines...) Expand all
2768 emit_sse_operand(src, dst); 2807 emit_sse_operand(src, dst);
2769 } else { 2808 } else {
2770 emit_optional_rex_32(dst, src); 2809 emit_optional_rex_32(dst, src);
2771 emit(0x0F); 2810 emit(0x0F);
2772 emit(0x28); 2811 emit(0x28);
2773 emit_sse_operand(dst, src); 2812 emit_sse_operand(dst, src);
2774 } 2813 }
2775 } 2814 }
2776 2815
2777 2816
2778 void Assembler::shufps(XMMRegister dst, XMMRegister src, byte imm8) {
2779 ASSERT(is_uint8(imm8));
2780 EnsureSpace ensure_space(this);
2781 emit_optional_rex_32(src, dst);
2782 emit(0x0F);
2783 emit(0xC6);
2784 emit_sse_operand(dst, src);
2785 emit(imm8);
2786 }
2787
2788 2817
2789 void Assembler::movapd(XMMRegister dst, XMMRegister src) { 2818 void Assembler::movapd(XMMRegister dst, XMMRegister src) {
2790 EnsureSpace ensure_space(this); 2819 EnsureSpace ensure_space(this);
2791 if (src.low_bits() == 4) { 2820 if (src.low_bits() == 4) {
2792 // Try to avoid an unnecessary SIB byte. 2821 // Try to avoid an unnecessary SIB byte.
2793 emit(0x66); 2822 emit(0x66);
2794 emit_optional_rex_32(src, dst); 2823 emit_optional_rex_32(src, dst);
2795 emit(0x0F); 2824 emit(0x0F);
2796 emit(0x29); 2825 emit(0x29);
2797 emit_sse_operand(src, dst); 2826 emit_sse_operand(src, dst);
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 EnsureSpace ensure_space(this); 3118 EnsureSpace ensure_space(this);
3090 emit(0xF2); 3119 emit(0xF2);
3091 emit_optional_rex_32(dst, src); 3120 emit_optional_rex_32(dst, src);
3092 emit(0x0F); 3121 emit(0x0F);
3093 emit(0xC2); 3122 emit(0xC2);
3094 emit_sse_operand(dst, src); 3123 emit_sse_operand(dst, src);
3095 emit(0x01); // LT == 1 3124 emit(0x01); // LT == 1
3096 } 3125 }
3097 3126
3098 3127
3128 void Assembler::cmpps(XMMRegister dst, XMMRegister src, int8_t cmp) {
3129 EnsureSpace ensure_space(this);
3130 emit_optional_rex_32(dst, src);
3131 emit(0x0F);
3132 emit(0xC2);
3133 emit_sse_operand(dst, src);
3134 emit(cmp);
3135 }
3136
3137
3138 void Assembler::cmpeqps(XMMRegister dst, XMMRegister src) {
3139 cmpps(dst, src, 0x0);
3140 }
3141
3142
3143 void Assembler::cmpltps(XMMRegister dst, XMMRegister src) {
3144 cmpps(dst, src, 0x1);
3145 }
3146
3147
3148 void Assembler::cmpleps(XMMRegister dst, XMMRegister src) {
3149 cmpps(dst, src, 0x2);
3150 }
3151
3152
3153 void Assembler::cmpneqps(XMMRegister dst, XMMRegister src) {
3154 cmpps(dst, src, 0x4);
3155 }
3156
3157
3158 void Assembler::cmpnltps(XMMRegister dst, XMMRegister src) {
3159 cmpps(dst, src, 0x5);
3160 }
3161
3162
3163 void Assembler::cmpnleps(XMMRegister dst, XMMRegister src) {
3164 cmpps(dst, src, 0x6);
3165 }
3166
3167
3099 void Assembler::roundsd(XMMRegister dst, XMMRegister src, 3168 void Assembler::roundsd(XMMRegister dst, XMMRegister src,
3100 Assembler::RoundingMode mode) { 3169 Assembler::RoundingMode mode) {
3101 ASSERT(IsEnabled(SSE4_1)); 3170 ASSERT(IsEnabled(SSE4_1));
3102 EnsureSpace ensure_space(this); 3171 EnsureSpace ensure_space(this);
3103 emit(0x66); 3172 emit(0x66);
3104 emit_optional_rex_32(dst, src); 3173 emit_optional_rex_32(dst, src);
3105 emit(0x0f); 3174 emit(0x0f);
3106 emit(0x3a); 3175 emit(0x3a);
3107 emit(0x0b); 3176 emit(0x0b);
3108 emit_sse_operand(dst, src); 3177 emit_sse_operand(dst, src);
(...skipping 14 matching lines...) Expand all
3123 3192
3124 void Assembler::movmskps(Register dst, XMMRegister src) { 3193 void Assembler::movmskps(Register dst, XMMRegister src) {
3125 EnsureSpace ensure_space(this); 3194 EnsureSpace ensure_space(this);
3126 emit_optional_rex_32(dst, src); 3195 emit_optional_rex_32(dst, src);
3127 emit(0x0f); 3196 emit(0x0f);
3128 emit(0x50); 3197 emit(0x50);
3129 emit_sse_operand(dst, src); 3198 emit_sse_operand(dst, src);
3130 } 3199 }
3131 3200
3132 3201
3202 void Assembler::minps(XMMRegister dst, XMMRegister src) {
3203 EnsureSpace ensure_space(this);
3204 emit_optional_rex_32(dst, src);
3205 emit(0x0F);
3206 emit(0x5D);
3207 emit_sse_operand(dst, src);
3208 }
3209
3210
3211 void Assembler::minps(XMMRegister dst, const Operand& src) {
3212 EnsureSpace ensure_space(this);
3213 emit_optional_rex_32(dst, src);
3214 emit(0x0F);
3215 emit(0x5D);
3216 emit_sse_operand(dst, src);
3217 }
3218
3219
3220 void Assembler::maxps(XMMRegister dst, XMMRegister src) {
3221 EnsureSpace ensure_space(this);
3222 emit_optional_rex_32(dst, src);
3223 emit(0x0F);
3224 emit(0x5F);
3225 emit_sse_operand(dst, src);
3226 }
3227
3228
3229 void Assembler::maxps(XMMRegister dst, const Operand& src) {
3230 EnsureSpace ensure_space(this);
3231 emit_optional_rex_32(dst, src);
3232 emit(0x0F);
3233 emit(0x5F);
3234 emit_sse_operand(dst, src);
3235 }
3236
3237
3238 void Assembler::rcpps(XMMRegister dst, XMMRegister src) {
3239 EnsureSpace ensure_space(this);
3240 emit_optional_rex_32(dst, src);
3241 emit(0x0F);
3242 emit(0x53);
3243 emit_sse_operand(dst, src);
3244 }
3245
3246
3247 void Assembler::rcpps(XMMRegister dst, const Operand& src) {
3248 EnsureSpace ensure_space(this);
3249 emit_optional_rex_32(dst, src);
3250 emit(0x0F);
3251 emit(0x53);
3252 emit_sse_operand(dst, src);
3253 }
3254
3255
3256 void Assembler::rsqrtps(XMMRegister dst, XMMRegister src) {
3257 EnsureSpace ensure_space(this);
3258 emit_optional_rex_32(dst, src);
3259 emit(0x0F);
3260 emit(0x52);
3261 emit_sse_operand(dst, src);
3262 }
3263
3264
3265 void Assembler::rsqrtps(XMMRegister dst, const Operand& src) {
3266 EnsureSpace ensure_space(this);
3267 emit_optional_rex_32(dst, src);
3268 emit(0x0F);
3269 emit(0x52);
3270 emit_sse_operand(dst, src);
3271 }
3272
3273
3274 void Assembler::sqrtps(XMMRegister dst, XMMRegister src) {
3275 EnsureSpace ensure_space(this);
3276 emit_optional_rex_32(dst, src);
3277 emit(0x0F);
3278 emit(0x51);
3279 emit_sse_operand(dst, src);
3280 }
3281
3282
3283 void Assembler::sqrtps(XMMRegister dst, const Operand& src) {
3284 EnsureSpace ensure_space(this);
3285 emit_optional_rex_32(dst, src);
3286 emit(0x0F);
3287 emit(0x51);
3288 emit_sse_operand(dst, src);
3289 }
3290
3291
3292 void Assembler::cvtdq2ps(XMMRegister dst, XMMRegister src) {
3293 EnsureSpace ensure_space(this);
3294 emit_optional_rex_32(dst, src);
3295 emit(0x0F);
3296 emit(0x5B);
3297 emit_sse_operand(dst, src);
3298 }
3299
3300
3301 void Assembler::cvtdq2ps(XMMRegister dst, const Operand& src) {
3302 EnsureSpace ensure_space(this);
3303 emit_optional_rex_32(dst, src);
3304 emit(0x0F);
3305 emit(0x5B);
3306 emit_sse_operand(dst, src);
3307 }
3308
3309
3310 void Assembler::movups(XMMRegister dst, XMMRegister src) {
3311 EnsureSpace ensure_space(this);
3312 if (src.low_bits() == 4) {
3313 // Try to avoid an unnecessary SIB byte.
3314 emit_optional_rex_32(src, dst);
3315 emit(0x0F);
3316 emit(0x11);
3317 emit_sse_operand(src, dst);
3318 } else {
3319 emit_optional_rex_32(dst, src);
3320 emit(0x0F);
3321 emit(0x10);
3322 emit_sse_operand(dst, src);
3323 }
3324 }
3325
3326
3327 void Assembler::movups(XMMRegister dst, const Operand& src) {
3328 EnsureSpace ensure_space(this);
3329 emit_optional_rex_32(dst, src);
3330 emit(0x0F);
3331 emit(0x10);
3332 emit_sse_operand(dst, src);
3333 }
3334
3335
3336 void Assembler::movups(const Operand& dst, XMMRegister src) {
3337 EnsureSpace ensure_space(this);
3338 emit_optional_rex_32(src, dst);
3339 emit(0x0F);
3340 emit(0x11);
3341 emit_sse_operand(src, dst);
3342 }
3343
3344
3345 void Assembler::paddd(XMMRegister dst, XMMRegister src) {
3346 EnsureSpace ensure_space(this);
3347 emit(0x66);
3348 emit_optional_rex_32(dst, src);
3349 emit(0x0F);
3350 emit(0xFE);
3351 emit_sse_operand(dst, src);
3352 }
3353
3354
3355 void Assembler::paddd(XMMRegister dst, const Operand& src) {
3356 EnsureSpace ensure_space(this);
3357 emit(0x66);
3358 emit_optional_rex_32(dst, src);
3359 emit(0x0F);
3360 emit(0xFE);
3361 emit_sse_operand(dst, src);
3362 }
3363
3364
3365 void Assembler::psubd(XMMRegister dst, XMMRegister src) {
3366 EnsureSpace ensure_space(this);
3367 emit(0x66);
3368 emit_optional_rex_32(dst, src);
3369 emit(0x0F);
3370 emit(0xFA);
3371 emit_sse_operand(dst, src);
3372 }
3373
3374
3375 void Assembler::psubd(XMMRegister dst, const Operand& src) {
3376 EnsureSpace ensure_space(this);
3377 emit(0x66);
3378 emit_optional_rex_32(dst, src);
3379 emit(0x0F);
3380 emit(0xFA);
3381 emit_sse_operand(dst, src);
3382 }
3383
3384
3385 void Assembler::pmulld(XMMRegister dst, XMMRegister src) {
3386 ASSERT(IsEnabled(SSE4_1));
3387 EnsureSpace ensure_space(this);
3388 emit(0x66);
3389 emit_optional_rex_32(dst, src);
3390 emit(0x0F);
3391 emit(0x38);
3392 emit(0x40);
3393 emit_sse_operand(dst, src);
3394 }
3395
3396
3397 void Assembler::pmulld(XMMRegister dst, const Operand& src) {
3398 EnsureSpace ensure_space(this);
3399 emit(0x66);
3400 emit_optional_rex_32(dst, src);
3401 emit(0x0F);
3402 emit(0xF4);
3403 emit_sse_operand(dst, src);
3404 }
3405
3406
3407 void Assembler::pmuludq(XMMRegister dst, XMMRegister src) {
3408 EnsureSpace ensure_space(this);
3409 emit(0x66);
3410 emit_optional_rex_32(dst, src);
3411 emit(0x0F);
3412 emit(0xF4);
3413 emit_sse_operand(dst, src);
3414 }
3415
3416
3417 void Assembler::pmuludq(XMMRegister dst, const Operand& src) {
3418 EnsureSpace ensure_space(this);
3419 emit(0x66);
3420 emit_optional_rex_32(dst, src);
3421 emit(0x0F);
3422 emit(0xF4);
3423 emit_sse_operand(dst, src);
3424 }
3425
3426
3427 void Assembler::punpackldq(XMMRegister dst, XMMRegister src) {
3428 EnsureSpace ensure_space(this);
3429 emit(0x66);
3430 emit_optional_rex_32(dst, src);
3431 emit(0x0F);
3432 emit(0x62);
3433 emit_sse_operand(dst, src);
3434 }
3435
3436
3437 void Assembler::punpackldq(XMMRegister dst, const Operand& src) {
3438 EnsureSpace ensure_space(this);
3439 emit(0x66);
3440 emit_optional_rex_32(dst, src);
3441 emit(0x0F);
3442 emit(0x62);
3443 emit_sse_operand(dst, src);
3444 }
3445
3446
3447 void Assembler::psrldq(XMMRegister dst, uint8_t shift) {
3448 EnsureSpace ensure_space(this);
3449 emit(0x66);
3450 emit_optional_rex_32(dst);
3451 emit(0x0F);
3452 emit(0x73);
3453 emit_sse_operand(dst);
3454 emit(shift);
3455 }
3456
3457
3458 void Assembler::cvtps2dq(XMMRegister dst, XMMRegister src) {
3459 EnsureSpace ensure_space(this);
3460 emit(0x66);
3461 emit_optional_rex_32(dst, src);
3462 emit(0x0F);
3463 emit(0x5B);
3464 emit_sse_operand(dst, src);
3465 }
3466
3467
3468 void Assembler::cvtps2dq(XMMRegister dst, const Operand& src) {
3469 EnsureSpace ensure_space(this);
3470 emit(0x66);
3471 emit_optional_rex_32(dst, src);
3472 emit(0x0F);
3473 emit(0x5B);
3474 emit_sse_operand(dst, src);
3475 }
3476
3477
3478 void Assembler::pshufd(XMMRegister dst, XMMRegister src, uint8_t shuffle) {
3479 EnsureSpace ensure_space(this);
3480 emit(0x66);
3481 emit_optional_rex_32(dst, src);
3482 emit(0x0F);
3483 emit(0x70);
3484 emit_sse_operand(dst, src);
3485 emit(shuffle);
3486 }
3487
3488
3133 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) { 3489 void Assembler::emit_sse_operand(XMMRegister reg, const Operand& adr) {
3134 Register ireg = { reg.code() }; 3490 Register ireg = { reg.code() };
3135 emit_operand(ireg, adr); 3491 emit_operand(ireg, adr);
3136 } 3492 }
3137 3493
3138 3494
3139 void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) { 3495 void Assembler::emit_sse_operand(XMMRegister dst, XMMRegister src) {
3140 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); 3496 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits());
3141 } 3497 }
3142 3498
3143 3499
3144 void Assembler::emit_sse_operand(XMMRegister dst, Register src) { 3500 void Assembler::emit_sse_operand(XMMRegister dst, Register src) {
3145 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); 3501 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits());
3146 } 3502 }
3147 3503
3148 3504
3149 void Assembler::emit_sse_operand(Register dst, XMMRegister src) { 3505 void Assembler::emit_sse_operand(Register dst, XMMRegister src) {
3150 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits()); 3506 emit(0xC0 | (dst.low_bits() << 3) | src.low_bits());
3151 } 3507 }
3152 3508
3153 3509
3510 void Assembler::emit_sse_operand(XMMRegister dst) {
3511 emit(0xD8 | dst.low_bits());
3512 }
3513
3514
3154 void Assembler::db(uint8_t data) { 3515 void Assembler::db(uint8_t data) {
3155 EnsureSpace ensure_space(this); 3516 EnsureSpace ensure_space(this);
3156 emit(data); 3517 emit(data);
3157 } 3518 }
3158 3519
3159 3520
3160 void Assembler::dd(uint32_t data) { 3521 void Assembler::dd(uint32_t data) {
3161 EnsureSpace ensure_space(this); 3522 EnsureSpace ensure_space(this);
3162 emitl(data); 3523 emitl(data);
3163 } 3524 }
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 bool RelocInfo::IsCodedSpecially() { 3578 bool RelocInfo::IsCodedSpecially() {
3218 // The deserializer needs to know whether a pointer is specially coded. Being 3579 // The deserializer needs to know whether a pointer is specially coded. Being
3219 // specially coded on x64 means that it is a relative 32 bit address, as used 3580 // specially coded on x64 means that it is a relative 32 bit address, as used
3220 // by branch instructions. 3581 // by branch instructions.
3221 return (1 << rmode_) & kApplyMask; 3582 return (1 << rmode_) & kApplyMask;
3222 } 3583 }
3223 3584
3224 } } // namespace v8::internal 3585 } } // namespace v8::internal
3225 3586
3226 #endif // V8_TARGET_ARCH_X64 3587 #endif // V8_TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « src/x64/assembler-x64.h ('k') | src/x64/assembler-x64-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698