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

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

Issue 1239583002: PPC: protect against malformed branch and memory access instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 months 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
« no previous file with comments | « no previous file | src/ppc/assembler-ppc-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 (c) 1994-2006 Sun Microsystems Inc. 1 // Copyright (c) 1994-2006 Sun Microsystems Inc.
2 // All Rights Reserved. 2 // All Rights Reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions 5 // modification, are permitted provided that the following conditions
6 // are met: 6 // are met:
7 // 7 //
8 // - Redistributions of source code must retain the above copyright notice, 8 // - Redistributions of source code must retain the above copyright notice,
9 // this list of conditions and the following disclaimer. 9 // this list of conditions and the following disclaimer.
10 // 10 //
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 } 427 }
428 428
429 429
430 void Assembler::target_at_put(int pos, int target_pos) { 430 void Assembler::target_at_put(int pos, int target_pos) {
431 Instr instr = instr_at(pos); 431 Instr instr = instr_at(pos);
432 int opcode = instr & kOpcodeMask; 432 int opcode = instr & kOpcodeMask;
433 433
434 switch (opcode) { 434 switch (opcode) {
435 case BX: { 435 case BX: {
436 int imm26 = target_pos - pos; 436 int imm26 = target_pos - pos;
437 DCHECK(is_int26(imm26) && (imm26 & (kAAMask | kLKMask)) == 0); 437 CHECK(is_int26(imm26) && (imm26 & (kAAMask | kLKMask)) == 0);
438 if (imm26 == kInstrSize && !(instr & kLKMask)) { 438 if (imm26 == kInstrSize && !(instr & kLKMask)) {
439 // Branch to next instr without link. 439 // Branch to next instr without link.
440 instr = ORI; // nop: ori, 0,0,0 440 instr = ORI; // nop: ori, 0,0,0
441 } else { 441 } else {
442 instr &= ((~kImm26Mask) | kAAMask | kLKMask); 442 instr &= ((~kImm26Mask) | kAAMask | kLKMask);
443 instr |= (imm26 & kImm26Mask); 443 instr |= (imm26 & kImm26Mask);
444 } 444 }
445 instr_at_put(pos, instr); 445 instr_at_put(pos, instr);
446 break; 446 break;
447 } 447 }
448 case BCX: { 448 case BCX: {
449 int imm16 = target_pos - pos; 449 int imm16 = target_pos - pos;
450 DCHECK(is_int16(imm16) && (imm16 & (kAAMask | kLKMask)) == 0); 450 CHECK(is_int16(imm16) && (imm16 & (kAAMask | kLKMask)) == 0);
451 if (imm16 == kInstrSize && !(instr & kLKMask)) { 451 if (imm16 == kInstrSize && !(instr & kLKMask)) {
452 // Branch to next instr without link. 452 // Branch to next instr without link.
453 instr = ORI; // nop: ori, 0,0,0 453 instr = ORI; // nop: ori, 0,0,0
454 } else { 454 } else {
455 instr &= ((~kImm16Mask) | kAAMask | kLKMask); 455 instr &= ((~kImm16Mask) | kAAMask | kLKMask);
456 instr |= (imm16 & kImm16Mask); 456 instr |= (imm16 & kImm16Mask);
457 } 457 }
458 instr_at_put(pos, instr); 458 instr_at_put(pos, instr);
459 break; 459 break;
460 } 460 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 emit(instr | frt.code() * B21 | fra.code() * B16 | frb.code() * B11 | r); 591 emit(instr | frt.code() * B21 | fra.code() * B16 | frb.code() * B11 | r);
592 } 592 }
593 593
594 594
595 void Assembler::d_form(Instr instr, Register rt, Register ra, 595 void Assembler::d_form(Instr instr, Register rt, Register ra,
596 const intptr_t val, bool signed_disp) { 596 const intptr_t val, bool signed_disp) {
597 if (signed_disp) { 597 if (signed_disp) {
598 if (!is_int16(val)) { 598 if (!is_int16(val)) {
599 PrintF("val = %" V8PRIdPTR ", 0x%" V8PRIxPTR "\n", val, val); 599 PrintF("val = %" V8PRIdPTR ", 0x%" V8PRIxPTR "\n", val, val);
600 } 600 }
601 DCHECK(is_int16(val)); 601 CHECK(is_int16(val));
602 } else { 602 } else {
603 if (!is_uint16(val)) { 603 if (!is_uint16(val)) {
604 PrintF("val = %" V8PRIdPTR ", 0x%" V8PRIxPTR 604 PrintF("val = %" V8PRIdPTR ", 0x%" V8PRIxPTR
605 ", is_unsigned_imm16(val)=%d, kImm16Mask=0x%x\n", 605 ", is_unsigned_imm16(val)=%d, kImm16Mask=0x%x\n",
606 val, val, is_uint16(val), kImm16Mask); 606 val, val, is_uint16(val), kImm16Mask);
607 } 607 }
608 DCHECK(is_uint16(val)); 608 CHECK(is_uint16(val));
609 } 609 }
610 emit(instr | rt.code() * B21 | ra.code() * B16 | (kImm16Mask & val)); 610 emit(instr | rt.code() * B21 | ra.code() * B16 | (kImm16Mask & val));
611 } 611 }
612 612
613 613
614 void Assembler::x_form(Instr instr, Register ra, Register rs, Register rb, 614 void Assembler::x_form(Instr instr, Register ra, Register rs, Register rb,
615 RCBit r) { 615 RCBit r) {
616 emit(instr | rs.code() * B21 | ra.code() * B16 | rb.code() * B11 | r); 616 emit(instr | rs.code() * B21 | ra.code() * B16 | rb.code() * B11 | r);
617 } 617 }
618 618
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 void Assembler::bctr() { bcctr(BA, LeaveLK); } 708 void Assembler::bctr() { bcctr(BA, LeaveLK); }
709 709
710 710
711 void Assembler::bctrl() { bcctr(BA, SetLK); } 711 void Assembler::bctrl() { bcctr(BA, SetLK); }
712 712
713 713
714 void Assembler::bc(int branch_offset, BOfield bo, int condition_bit, LKBit lk) { 714 void Assembler::bc(int branch_offset, BOfield bo, int condition_bit, LKBit lk) {
715 if (lk == SetLK) { 715 if (lk == SetLK) {
716 positions_recorder()->WriteRecordedPositions(); 716 positions_recorder()->WriteRecordedPositions();
717 } 717 }
718 DCHECK(is_int16(branch_offset)); 718 int imm16 = branch_offset;
719 emit(BCX | bo | condition_bit * B16 | (kImm16Mask & branch_offset) | lk); 719 CHECK(is_int16(imm16) && (imm16 & (kAAMask | kLKMask)) == 0);
720 emit(BCX | bo | condition_bit * B16 | (imm16 & kImm16Mask) | lk);
720 } 721 }
721 722
722 723
723 void Assembler::b(int branch_offset, LKBit lk) { 724 void Assembler::b(int branch_offset, LKBit lk) {
724 if (lk == SetLK) { 725 if (lk == SetLK) {
725 positions_recorder()->WriteRecordedPositions(); 726 positions_recorder()->WriteRecordedPositions();
726 } 727 }
727 DCHECK((branch_offset & 3) == 0);
728 int imm26 = branch_offset; 728 int imm26 = branch_offset;
729 DCHECK(is_int26(imm26)); 729 CHECK(is_int26(imm26) && (imm26 & (kAAMask | kLKMask)) == 0);
730 // todo add AA and LK bits
731 emit(BX | (imm26 & kImm26Mask) | lk); 730 emit(BX | (imm26 & kImm26Mask) | lk);
732 } 731 }
733 732
734 733
735 void Assembler::xori(Register dst, Register src, const Operand& imm) { 734 void Assembler::xori(Register dst, Register src, const Operand& imm) {
736 d_form(XORI, src, dst, imm.imm_, false); 735 d_form(XORI, src, dst, imm.imm_, false);
737 } 736 }
738 737
739 738
740 void Assembler::xoris(Register ra, Register rs, const Operand& imm) { 739 void Assembler::xoris(Register ra, Register rs, const Operand& imm) {
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 void Assembler::lha(Register dst, const MemOperand& src) { 1184 void Assembler::lha(Register dst, const MemOperand& src) {
1186 DCHECK(!src.ra_.is(r0)); 1185 DCHECK(!src.ra_.is(r0));
1187 d_form(LHA, dst, src.ra(), src.offset(), true); 1186 d_form(LHA, dst, src.ra(), src.offset(), true);
1188 } 1187 }
1189 1188
1190 1189
1191 void Assembler::lwa(Register dst, const MemOperand& src) { 1190 void Assembler::lwa(Register dst, const MemOperand& src) {
1192 #if V8_TARGET_ARCH_PPC64 1191 #if V8_TARGET_ARCH_PPC64
1193 int offset = src.offset(); 1192 int offset = src.offset();
1194 DCHECK(!src.ra_.is(r0)); 1193 DCHECK(!src.ra_.is(r0));
1195 DCHECK(!(offset & 3) && is_int16(offset)); 1194 CHECK(!(offset & 3) && is_int16(offset));
1196 offset = kImm16Mask & offset; 1195 offset = kImm16Mask & offset;
1197 emit(LD | dst.code() * B21 | src.ra().code() * B16 | offset | 2); 1196 emit(LD | dst.code() * B21 | src.ra().code() * B16 | offset | 2);
1198 #else 1197 #else
1199 lwz(dst, src); 1198 lwz(dst, src);
1200 #endif 1199 #endif
1201 } 1200 }
1202 1201
1203 1202
1204 void Assembler::lwax(Register rt, const MemOperand& src) { 1203 void Assembler::lwax(Register rt, const MemOperand& src) {
1205 #if V8_TARGET_ARCH_PPC64 1204 #if V8_TARGET_ARCH_PPC64
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 void Assembler::andc(Register dst, Register src1, Register src2, RCBit rc) { 1318 void Assembler::andc(Register dst, Register src1, Register src2, RCBit rc) {
1320 x_form(EXT2 | ANDCX, dst, src1, src2, rc); 1319 x_form(EXT2 | ANDCX, dst, src1, src2, rc);
1321 } 1320 }
1322 1321
1323 1322
1324 #if V8_TARGET_ARCH_PPC64 1323 #if V8_TARGET_ARCH_PPC64
1325 // 64bit specific instructions 1324 // 64bit specific instructions
1326 void Assembler::ld(Register rd, const MemOperand& src) { 1325 void Assembler::ld(Register rd, const MemOperand& src) {
1327 int offset = src.offset(); 1326 int offset = src.offset();
1328 DCHECK(!src.ra_.is(r0)); 1327 DCHECK(!src.ra_.is(r0));
1329 DCHECK(!(offset & 3) && is_int16(offset)); 1328 CHECK(!(offset & 3) && is_int16(offset));
1330 offset = kImm16Mask & offset; 1329 offset = kImm16Mask & offset;
1331 emit(LD | rd.code() * B21 | src.ra().code() * B16 | offset); 1330 emit(LD | rd.code() * B21 | src.ra().code() * B16 | offset);
1332 } 1331 }
1333 1332
1334 1333
1335 void Assembler::ldx(Register rd, const MemOperand& src) { 1334 void Assembler::ldx(Register rd, const MemOperand& src) {
1336 Register ra = src.ra(); 1335 Register ra = src.ra();
1337 Register rb = src.rb(); 1336 Register rb = src.rb();
1338 DCHECK(!ra.is(r0)); 1337 DCHECK(!ra.is(r0));
1339 emit(EXT2 | LDX | rd.code() * B21 | ra.code() * B16 | rb.code() * B11); 1338 emit(EXT2 | LDX | rd.code() * B21 | ra.code() * B16 | rb.code() * B11);
1340 } 1339 }
1341 1340
1342 1341
1343 void Assembler::ldu(Register rd, const MemOperand& src) { 1342 void Assembler::ldu(Register rd, const MemOperand& src) {
1344 int offset = src.offset(); 1343 int offset = src.offset();
1345 DCHECK(!src.ra_.is(r0)); 1344 DCHECK(!src.ra_.is(r0));
1346 DCHECK(!(offset & 3) && is_int16(offset)); 1345 CHECK(!(offset & 3) && is_int16(offset));
1347 offset = kImm16Mask & offset; 1346 offset = kImm16Mask & offset;
1348 emit(LD | rd.code() * B21 | src.ra().code() * B16 | offset | 1); 1347 emit(LD | rd.code() * B21 | src.ra().code() * B16 | offset | 1);
1349 } 1348 }
1350 1349
1351 1350
1352 void Assembler::ldux(Register rd, const MemOperand& src) { 1351 void Assembler::ldux(Register rd, const MemOperand& src) {
1353 Register ra = src.ra(); 1352 Register ra = src.ra();
1354 Register rb = src.rb(); 1353 Register rb = src.rb();
1355 DCHECK(!ra.is(r0)); 1354 DCHECK(!ra.is(r0));
1356 emit(EXT2 | LDUX | rd.code() * B21 | ra.code() * B16 | rb.code() * B11); 1355 emit(EXT2 | LDUX | rd.code() * B21 | ra.code() * B16 | rb.code() * B11);
1357 } 1356 }
1358 1357
1359 1358
1360 void Assembler::std(Register rs, const MemOperand& src) { 1359 void Assembler::std(Register rs, const MemOperand& src) {
1361 int offset = src.offset(); 1360 int offset = src.offset();
1362 DCHECK(!src.ra_.is(r0)); 1361 DCHECK(!src.ra_.is(r0));
1363 DCHECK(!(offset & 3) && is_int16(offset)); 1362 CHECK(!(offset & 3) && is_int16(offset));
1364 offset = kImm16Mask & offset; 1363 offset = kImm16Mask & offset;
1365 emit(STD | rs.code() * B21 | src.ra().code() * B16 | offset); 1364 emit(STD | rs.code() * B21 | src.ra().code() * B16 | offset);
1366 } 1365 }
1367 1366
1368 1367
1369 void Assembler::stdx(Register rs, const MemOperand& src) { 1368 void Assembler::stdx(Register rs, const MemOperand& src) {
1370 Register ra = src.ra(); 1369 Register ra = src.ra();
1371 Register rb = src.rb(); 1370 Register rb = src.rb();
1372 DCHECK(!ra.is(r0)); 1371 DCHECK(!ra.is(r0));
1373 emit(EXT2 | STDX | rs.code() * B21 | ra.code() * B16 | rb.code() * B11); 1372 emit(EXT2 | STDX | rs.code() * B21 | ra.code() * B16 | rb.code() * B11);
1374 } 1373 }
1375 1374
1376 1375
1377 void Assembler::stdu(Register rs, const MemOperand& src) { 1376 void Assembler::stdu(Register rs, const MemOperand& src) {
1378 int offset = src.offset(); 1377 int offset = src.offset();
1379 DCHECK(!src.ra_.is(r0)); 1378 DCHECK(!src.ra_.is(r0));
1380 DCHECK(!(offset & 3) && is_int16(offset)); 1379 CHECK(!(offset & 3) && is_int16(offset));
1381 offset = kImm16Mask & offset; 1380 offset = kImm16Mask & offset;
1382 emit(STD | rs.code() * B21 | src.ra().code() * B16 | offset | 1); 1381 emit(STD | rs.code() * B21 | src.ra().code() * B16 | offset | 1);
1383 } 1382 }
1384 1383
1385 1384
1386 void Assembler::stdux(Register rs, const MemOperand& src) { 1385 void Assembler::stdux(Register rs, const MemOperand& src) {
1387 Register ra = src.ra(); 1386 Register ra = src.ra();
1388 Register rb = src.rb(); 1387 Register rb = src.rb();
1389 DCHECK(!ra.is(r0)); 1388 DCHECK(!ra.is(r0));
1390 emit(EXT2 | STDUX | rs.code() * B21 | ra.code() * B16 | rb.code() * B11); 1389 emit(EXT2 | STDUX | rs.code() * B21 | ra.code() * B16 | rb.code() * B11);
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
1921 1920
1922 void Assembler::isync() { emit(EXT1 | ISYNC); } 1921 void Assembler::isync() { emit(EXT1 | ISYNC); }
1923 1922
1924 1923
1925 // Floating point support 1924 // Floating point support
1926 1925
1927 void Assembler::lfd(const DoubleRegister frt, const MemOperand& src) { 1926 void Assembler::lfd(const DoubleRegister frt, const MemOperand& src) {
1928 int offset = src.offset(); 1927 int offset = src.offset();
1929 Register ra = src.ra(); 1928 Register ra = src.ra();
1930 DCHECK(!ra.is(r0)); 1929 DCHECK(!ra.is(r0));
1931 DCHECK(is_int16(offset)); 1930 CHECK(is_int16(offset));
1932 int imm16 = offset & kImm16Mask; 1931 int imm16 = offset & kImm16Mask;
1933 // could be x_form instruction with some casting magic 1932 // could be x_form instruction with some casting magic
1934 emit(LFD | frt.code() * B21 | ra.code() * B16 | imm16); 1933 emit(LFD | frt.code() * B21 | ra.code() * B16 | imm16);
1935 } 1934 }
1936 1935
1937 1936
1938 void Assembler::lfdu(const DoubleRegister frt, const MemOperand& src) { 1937 void Assembler::lfdu(const DoubleRegister frt, const MemOperand& src) {
1939 int offset = src.offset(); 1938 int offset = src.offset();
1940 Register ra = src.ra(); 1939 Register ra = src.ra();
1941 DCHECK(!ra.is(r0)); 1940 DCHECK(!ra.is(r0));
1942 DCHECK(is_int16(offset)); 1941 CHECK(is_int16(offset));
1943 int imm16 = offset & kImm16Mask; 1942 int imm16 = offset & kImm16Mask;
1944 // could be x_form instruction with some casting magic 1943 // could be x_form instruction with some casting magic
1945 emit(LFDU | frt.code() * B21 | ra.code() * B16 | imm16); 1944 emit(LFDU | frt.code() * B21 | ra.code() * B16 | imm16);
1946 } 1945 }
1947 1946
1948 1947
1949 void Assembler::lfdx(const DoubleRegister frt, const MemOperand& src) { 1948 void Assembler::lfdx(const DoubleRegister frt, const MemOperand& src) {
1950 Register ra = src.ra(); 1949 Register ra = src.ra();
1951 Register rb = src.rb(); 1950 Register rb = src.rb();
1952 DCHECK(!ra.is(r0)); 1951 DCHECK(!ra.is(r0));
1953 emit(EXT2 | LFDX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 | 1952 emit(EXT2 | LFDX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 |
1954 LeaveRC); 1953 LeaveRC);
1955 } 1954 }
1956 1955
1957 1956
1958 void Assembler::lfdux(const DoubleRegister frt, const MemOperand& src) { 1957 void Assembler::lfdux(const DoubleRegister frt, const MemOperand& src) {
1959 Register ra = src.ra(); 1958 Register ra = src.ra();
1960 Register rb = src.rb(); 1959 Register rb = src.rb();
1961 DCHECK(!ra.is(r0)); 1960 DCHECK(!ra.is(r0));
1962 emit(EXT2 | LFDUX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 | 1961 emit(EXT2 | LFDUX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 |
1963 LeaveRC); 1962 LeaveRC);
1964 } 1963 }
1965 1964
1966 1965
1967 void Assembler::lfs(const DoubleRegister frt, const MemOperand& src) { 1966 void Assembler::lfs(const DoubleRegister frt, const MemOperand& src) {
1968 int offset = src.offset(); 1967 int offset = src.offset();
1969 Register ra = src.ra(); 1968 Register ra = src.ra();
1970 DCHECK(is_int16(offset)); 1969 CHECK(is_int16(offset));
1971 DCHECK(!ra.is(r0)); 1970 DCHECK(!ra.is(r0));
1972 int imm16 = offset & kImm16Mask; 1971 int imm16 = offset & kImm16Mask;
1973 // could be x_form instruction with some casting magic 1972 // could be x_form instruction with some casting magic
1974 emit(LFS | frt.code() * B21 | ra.code() * B16 | imm16); 1973 emit(LFS | frt.code() * B21 | ra.code() * B16 | imm16);
1975 } 1974 }
1976 1975
1977 1976
1978 void Assembler::lfsu(const DoubleRegister frt, const MemOperand& src) { 1977 void Assembler::lfsu(const DoubleRegister frt, const MemOperand& src) {
1979 int offset = src.offset(); 1978 int offset = src.offset();
1980 Register ra = src.ra(); 1979 Register ra = src.ra();
1981 DCHECK(is_int16(offset)); 1980 CHECK(is_int16(offset));
1982 DCHECK(!ra.is(r0)); 1981 DCHECK(!ra.is(r0));
1983 int imm16 = offset & kImm16Mask; 1982 int imm16 = offset & kImm16Mask;
1984 // could be x_form instruction with some casting magic 1983 // could be x_form instruction with some casting magic
1985 emit(LFSU | frt.code() * B21 | ra.code() * B16 | imm16); 1984 emit(LFSU | frt.code() * B21 | ra.code() * B16 | imm16);
1986 } 1985 }
1987 1986
1988 1987
1989 void Assembler::lfsx(const DoubleRegister frt, const MemOperand& src) { 1988 void Assembler::lfsx(const DoubleRegister frt, const MemOperand& src) {
1990 Register ra = src.ra(); 1989 Register ra = src.ra();
1991 Register rb = src.rb(); 1990 Register rb = src.rb();
1992 DCHECK(!ra.is(r0)); 1991 DCHECK(!ra.is(r0));
1993 emit(EXT2 | LFSX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 | 1992 emit(EXT2 | LFSX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 |
1994 LeaveRC); 1993 LeaveRC);
1995 } 1994 }
1996 1995
1997 1996
1998 void Assembler::lfsux(const DoubleRegister frt, const MemOperand& src) { 1997 void Assembler::lfsux(const DoubleRegister frt, const MemOperand& src) {
1999 Register ra = src.ra(); 1998 Register ra = src.ra();
2000 Register rb = src.rb(); 1999 Register rb = src.rb();
2001 DCHECK(!ra.is(r0)); 2000 DCHECK(!ra.is(r0));
2002 emit(EXT2 | LFSUX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 | 2001 emit(EXT2 | LFSUX | frt.code() * B21 | ra.code() * B16 | rb.code() * B11 |
2003 LeaveRC); 2002 LeaveRC);
2004 } 2003 }
2005 2004
2006 2005
2007 void Assembler::stfd(const DoubleRegister frs, const MemOperand& src) { 2006 void Assembler::stfd(const DoubleRegister frs, const MemOperand& src) {
2008 int offset = src.offset(); 2007 int offset = src.offset();
2009 Register ra = src.ra(); 2008 Register ra = src.ra();
2010 DCHECK(is_int16(offset)); 2009 CHECK(is_int16(offset));
2011 DCHECK(!ra.is(r0)); 2010 DCHECK(!ra.is(r0));
2012 int imm16 = offset & kImm16Mask; 2011 int imm16 = offset & kImm16Mask;
2013 // could be x_form instruction with some casting magic 2012 // could be x_form instruction with some casting magic
2014 emit(STFD | frs.code() * B21 | ra.code() * B16 | imm16); 2013 emit(STFD | frs.code() * B21 | ra.code() * B16 | imm16);
2015 } 2014 }
2016 2015
2017 2016
2018 void Assembler::stfdu(const DoubleRegister frs, const MemOperand& src) { 2017 void Assembler::stfdu(const DoubleRegister frs, const MemOperand& src) {
2019 int offset = src.offset(); 2018 int offset = src.offset();
2020 Register ra = src.ra(); 2019 Register ra = src.ra();
2021 DCHECK(is_int16(offset)); 2020 CHECK(is_int16(offset));
2022 DCHECK(!ra.is(r0)); 2021 DCHECK(!ra.is(r0));
2023 int imm16 = offset & kImm16Mask; 2022 int imm16 = offset & kImm16Mask;
2024 // could be x_form instruction with some casting magic 2023 // could be x_form instruction with some casting magic
2025 emit(STFDU | frs.code() * B21 | ra.code() * B16 | imm16); 2024 emit(STFDU | frs.code() * B21 | ra.code() * B16 | imm16);
2026 } 2025 }
2027 2026
2028 2027
2029 void Assembler::stfdx(const DoubleRegister frs, const MemOperand& src) { 2028 void Assembler::stfdx(const DoubleRegister frs, const MemOperand& src) {
2030 Register ra = src.ra(); 2029 Register ra = src.ra();
2031 Register rb = src.rb(); 2030 Register rb = src.rb();
2032 DCHECK(!ra.is(r0)); 2031 DCHECK(!ra.is(r0));
2033 emit(EXT2 | STFDX | frs.code() * B21 | ra.code() * B16 | rb.code() * B11 | 2032 emit(EXT2 | STFDX | frs.code() * B21 | ra.code() * B16 | rb.code() * B11 |
2034 LeaveRC); 2033 LeaveRC);
2035 } 2034 }
2036 2035
2037 2036
2038 void Assembler::stfdux(const DoubleRegister frs, const MemOperand& src) { 2037 void Assembler::stfdux(const DoubleRegister frs, const MemOperand& src) {
2039 Register ra = src.ra(); 2038 Register ra = src.ra();
2040 Register rb = src.rb(); 2039 Register rb = src.rb();
2041 DCHECK(!ra.is(r0)); 2040 DCHECK(!ra.is(r0));
2042 emit(EXT2 | STFDUX | frs.code() * B21 | ra.code() * B16 | rb.code() * B11 | 2041 emit(EXT2 | STFDUX | frs.code() * B21 | ra.code() * B16 | rb.code() * B11 |
2043 LeaveRC); 2042 LeaveRC);
2044 } 2043 }
2045 2044
2046 2045
2047 void Assembler::stfs(const DoubleRegister frs, const MemOperand& src) { 2046 void Assembler::stfs(const DoubleRegister frs, const MemOperand& src) {
2048 int offset = src.offset(); 2047 int offset = src.offset();
2049 Register ra = src.ra(); 2048 Register ra = src.ra();
2050 DCHECK(is_int16(offset)); 2049 CHECK(is_int16(offset));
2051 DCHECK(!ra.is(r0)); 2050 DCHECK(!ra.is(r0));
2052 int imm16 = offset & kImm16Mask; 2051 int imm16 = offset & kImm16Mask;
2053 // could be x_form instruction with some casting magic 2052 // could be x_form instruction with some casting magic
2054 emit(STFS | frs.code() * B21 | ra.code() * B16 | imm16); 2053 emit(STFS | frs.code() * B21 | ra.code() * B16 | imm16);
2055 } 2054 }
2056 2055
2057 2056
2058 void Assembler::stfsu(const DoubleRegister frs, const MemOperand& src) { 2057 void Assembler::stfsu(const DoubleRegister frs, const MemOperand& src) {
2059 int offset = src.offset(); 2058 int offset = src.offset();
2060 Register ra = src.ra(); 2059 Register ra = src.ra();
2061 DCHECK(is_int16(offset)); 2060 CHECK(is_int16(offset));
2062 DCHECK(!ra.is(r0)); 2061 DCHECK(!ra.is(r0));
2063 int imm16 = offset & kImm16Mask; 2062 int imm16 = offset & kImm16Mask;
2064 // could be x_form instruction with some casting magic 2063 // could be x_form instruction with some casting magic
2065 emit(STFSU | frs.code() * B21 | ra.code() * B16 | imm16); 2064 emit(STFSU | frs.code() * B21 | ra.code() * B16 | imm16);
2066 } 2065 }
2067 2066
2068 2067
2069 void Assembler::stfsx(const DoubleRegister frs, const MemOperand& src) { 2068 void Assembler::stfsx(const DoubleRegister frs, const MemOperand& src) {
2070 Register ra = src.ra(); 2069 Register ra = src.ra();
2071 Register rb = src.rb(); 2070 Register rb = src.rb();
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
2447 pc_offset() + kMaxCondBranchReach - kMaxBlockTrampolineSectionSize; 2446 pc_offset() + kMaxCondBranchReach - kMaxBlockTrampolineSectionSize;
2448 } 2447 }
2449 return; 2448 return;
2450 } 2449 }
2451 2450
2452 2451
2453 } // namespace internal 2452 } // namespace internal
2454 } // namespace v8 2453 } // namespace v8
2455 2454
2456 #endif // V8_TARGET_ARCH_PPC 2455 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « no previous file | src/ppc/assembler-ppc-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698