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

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

Issue 1815213002: Extends testb and cmpb/cmpw instruction support in the ia32 assembler. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix a copy/pasted erroneous DCHECK. Created 4 years, 9 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 | « src/ia32/assembler-ia32.h ('k') | src/ia32/assembler-ia32-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 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 emit_arith(4, dst, x); 739 emit_arith(4, dst, x);
740 } 740 }
741 741
742 742
743 void Assembler::and_(const Operand& dst, Register src) { 743 void Assembler::and_(const Operand& dst, Register src) {
744 EnsureSpace ensure_space(this); 744 EnsureSpace ensure_space(this);
745 EMIT(0x21); 745 EMIT(0x21);
746 emit_operand(src, dst); 746 emit_operand(src, dst);
747 } 747 }
748 748
749 749 void Assembler::cmpb(const Operand& op, Immediate imm8) {
750 void Assembler::cmpb(const Operand& op, int8_t imm8) { 750 DCHECK(imm8.is_int8() || imm8.is_uint8());
751 EnsureSpace ensure_space(this); 751 EnsureSpace ensure_space(this);
752 if (op.is_reg(eax)) { 752 if (op.is_reg(eax)) {
753 EMIT(0x3C); 753 EMIT(0x3C);
754 } else { 754 } else {
755 EMIT(0x80); 755 EMIT(0x80);
756 emit_operand(edi, op); // edi == 7 756 emit_operand(edi, op); // edi == 7
757 } 757 }
758 EMIT(imm8); 758 emit_b(imm8);
759 } 759 }
760 760
761 761
762 void Assembler::cmpb(const Operand& op, Register reg) { 762 void Assembler::cmpb(const Operand& op, Register reg) {
763 CHECK(reg.is_byte_register()); 763 CHECK(reg.is_byte_register());
764 EnsureSpace ensure_space(this); 764 EnsureSpace ensure_space(this);
765 EMIT(0x38); 765 EMIT(0x38);
766 emit_operand(reg, op); 766 emit_operand(reg, op);
767 } 767 }
768 768
769 769
770 void Assembler::cmpb(Register reg, const Operand& op) { 770 void Assembler::cmpb(Register reg, const Operand& op) {
771 CHECK(reg.is_byte_register()); 771 CHECK(reg.is_byte_register());
772 EnsureSpace ensure_space(this); 772 EnsureSpace ensure_space(this);
773 EMIT(0x3A); 773 EMIT(0x3A);
774 emit_operand(reg, op); 774 emit_operand(reg, op);
775 } 775 }
776 776
777 777
778 void Assembler::cmpw(const Operand& op, Immediate imm16) { 778 void Assembler::cmpw(const Operand& op, Immediate imm16) {
779 DCHECK(imm16.is_int16()); 779 DCHECK(imm16.is_int16());
780 EnsureSpace ensure_space(this); 780 EnsureSpace ensure_space(this);
781 EMIT(0x66); 781 EMIT(0x66);
782 EMIT(0x81); 782 EMIT(0x81);
783 emit_operand(edi, op); 783 emit_operand(edi, op);
784 emit_w(imm16); 784 emit_w(imm16);
785 } 785 }
786 786
787 void Assembler::cmpw(Register reg, const Operand& op) {
788 EnsureSpace ensure_space(this);
789 EMIT(0x66);
790 EMIT(0x39);
791 emit_operand(reg, op);
792 }
793
794 void Assembler::cmpw(const Operand& op, Register reg) {
795 EnsureSpace ensure_space(this);
796 EMIT(0x66);
797 EMIT(0x3B);
798 emit_operand(reg, op);
799 }
787 800
788 void Assembler::cmp(Register reg, int32_t imm32) { 801 void Assembler::cmp(Register reg, int32_t imm32) {
789 EnsureSpace ensure_space(this); 802 EnsureSpace ensure_space(this);
790 emit_arith(7, Operand(reg), Immediate(imm32)); 803 emit_arith(7, Operand(reg), Immediate(imm32));
791 } 804 }
792 805
793 806
794 void Assembler::cmp(Register reg, Handle<Object> handle) { 807 void Assembler::cmp(Register reg, Handle<Object> handle) {
795 EnsureSpace ensure_space(this); 808 EnsureSpace ensure_space(this);
796 emit_arith(7, Operand(reg), Immediate(handle)); 809 emit_arith(7, Operand(reg), Immediate(handle));
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 1174
1162 1175
1163 void Assembler::sub(const Operand& dst, Register src) { 1176 void Assembler::sub(const Operand& dst, Register src) {
1164 EnsureSpace ensure_space(this); 1177 EnsureSpace ensure_space(this);
1165 EMIT(0x29); 1178 EMIT(0x29);
1166 emit_operand(src, dst); 1179 emit_operand(src, dst);
1167 } 1180 }
1168 1181
1169 1182
1170 void Assembler::test(Register reg, const Immediate& imm) { 1183 void Assembler::test(Register reg, const Immediate& imm) {
1171 if (RelocInfo::IsNone(imm.rmode_) && is_uint8(imm.x_)) { 1184 if (imm.is_uint8()) {
1172 test_b(reg, imm.x_); 1185 test_b(reg, imm);
1173 return; 1186 return;
1174 } 1187 }
1175 1188
1176 EnsureSpace ensure_space(this); 1189 EnsureSpace ensure_space(this);
1177 // This is not using emit_arith because test doesn't support 1190 // This is not using emit_arith because test doesn't support
1178 // sign-extension of 8-bit operands. 1191 // sign-extension of 8-bit operands.
1179 if (reg.is(eax)) { 1192 if (reg.is(eax)) {
1180 EMIT(0xA9); 1193 EMIT(0xA9);
1181 } else { 1194 } else {
1182 EMIT(0xF7); 1195 EMIT(0xF7);
(...skipping 16 matching lines...) Expand all
1199 EMIT(0x84); 1212 EMIT(0x84);
1200 emit_operand(reg, op); 1213 emit_operand(reg, op);
1201 } 1214 }
1202 1215
1203 1216
1204 void Assembler::test(const Operand& op, const Immediate& imm) { 1217 void Assembler::test(const Operand& op, const Immediate& imm) {
1205 if (op.is_reg_only()) { 1218 if (op.is_reg_only()) {
1206 test(op.reg(), imm); 1219 test(op.reg(), imm);
1207 return; 1220 return;
1208 } 1221 }
1209 if (RelocInfo::IsNone(imm.rmode_) && is_uint8(imm.x_)) { 1222 if (imm.is_uint8()) {
1210 return test_b(op, imm.x_); 1223 return test_b(op, imm);
1211 } 1224 }
1212 EnsureSpace ensure_space(this); 1225 EnsureSpace ensure_space(this);
1213 EMIT(0xF7); 1226 EMIT(0xF7);
1214 emit_operand(eax, op); 1227 emit_operand(eax, op);
1215 emit(imm); 1228 emit(imm);
1216 } 1229 }
1217 1230
1218 1231 void Assembler::test_b(Register reg, Immediate imm8) {
1219 void Assembler::test_b(Register reg, uint8_t imm8) { 1232 DCHECK(imm8.is_uint8());
1220 EnsureSpace ensure_space(this); 1233 EnsureSpace ensure_space(this);
1221 // Only use test against byte for registers that have a byte 1234 // Only use test against byte for registers that have a byte
1222 // variant: eax, ebx, ecx, and edx. 1235 // variant: eax, ebx, ecx, and edx.
1223 if (reg.is(eax)) { 1236 if (reg.is(eax)) {
1224 EMIT(0xA8); 1237 EMIT(0xA8);
1225 EMIT(imm8); 1238 emit_b(imm8);
1226 } else if (reg.is_byte_register()) { 1239 } else if (reg.is_byte_register()) {
1227 emit_arith_b(0xF6, 0xC0, reg, imm8); 1240 emit_arith_b(0xF6, 0xC0, reg, static_cast<uint8_t>(imm8.x_));
1228 } else { 1241 } else {
1242 EMIT(0x66);
1229 EMIT(0xF7); 1243 EMIT(0xF7);
1230 EMIT(0xC0 | reg.code()); 1244 EMIT(0xC0 | reg.code());
1231 emit(imm8); 1245 emit_w(imm8);
1232 } 1246 }
1233 } 1247 }
1234 1248
1235 1249 void Assembler::test_b(const Operand& op, Immediate imm8) {
1236 void Assembler::test_b(const Operand& op, uint8_t imm8) {
1237 if (op.is_reg_only()) { 1250 if (op.is_reg_only()) {
1238 test_b(op.reg(), imm8); 1251 test_b(op.reg(), imm8);
1239 return; 1252 return;
1240 } 1253 }
1241 EnsureSpace ensure_space(this); 1254 EnsureSpace ensure_space(this);
1242 EMIT(0xF6); 1255 EMIT(0xF6);
1243 emit_operand(eax, op); 1256 emit_operand(eax, op);
1244 EMIT(imm8); 1257 emit_b(imm8);
1245 } 1258 }
1246 1259
1247 1260
1248 void Assembler::xor_(Register dst, int32_t imm32) { 1261 void Assembler::xor_(Register dst, int32_t imm32) {
1249 EnsureSpace ensure_space(this); 1262 EnsureSpace ensure_space(this);
1250 emit_arith(6, Operand(dst), Immediate(imm32)); 1263 emit_arith(6, Operand(dst), Immediate(imm32));
1251 } 1264 }
1252 1265
1253 1266
1254 void Assembler::xor_(Register dst, const Operand& src) { 1267 void Assembler::xor_(Register dst, const Operand& src) {
(...skipping 1712 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 fflush(coverage_log); 2980 fflush(coverage_log);
2968 } 2981 }
2969 } 2982 }
2970 2983
2971 #endif 2984 #endif
2972 2985
2973 } // namespace internal 2986 } // namespace internal
2974 } // namespace v8 2987 } // namespace v8
2975 2988
2976 #endif // V8_TARGET_ARCH_IA32 2989 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.h ('k') | src/ia32/assembler-ia32-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698