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

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

Issue 23679007: refactor test instruction on ia32 (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: update to master Created 7 years, 3 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/x64/assembler-x64.cc » ('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 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 1124
1125 1125
1126 void Assembler::sub(const Operand& dst, Register src) { 1126 void Assembler::sub(const Operand& dst, Register src) {
1127 EnsureSpace ensure_space(this); 1127 EnsureSpace ensure_space(this);
1128 EMIT(0x29); 1128 EMIT(0x29);
1129 emit_operand(src, dst); 1129 emit_operand(src, dst);
1130 } 1130 }
1131 1131
1132 1132
1133 void Assembler::test(Register reg, const Immediate& imm) { 1133 void Assembler::test(Register reg, const Immediate& imm) {
1134 if (RelocInfo::IsNone(imm.rmode_) && is_uint8(imm.x_)) {
1135 test_b(reg, imm.x_);
1136 return;
1137 }
1138
1134 EnsureSpace ensure_space(this); 1139 EnsureSpace ensure_space(this);
1135 // Only use test against byte for registers that have a byte 1140 // This is not using emit_arith because test doesn't support
1136 // variant: eax, ebx, ecx, and edx. 1141 // sign-extension of 8-bit operands.
1137 if (RelocInfo::IsNone(imm.rmode_) && 1142 if (reg.is(eax)) {
1138 is_uint8(imm.x_) && 1143 EMIT(0xA9);
1139 reg.is_byte_register()) {
1140 uint8_t imm8 = imm.x_;
1141 if (reg.is(eax)) {
1142 EMIT(0xA8);
1143 EMIT(imm8);
1144 } else {
1145 emit_arith_b(0xF6, 0xC0, reg, imm8);
1146 }
1147 } else { 1144 } else {
1148 // This is not using emit_arith because test doesn't support 1145 EMIT(0xF7);
1149 // sign-extension of 8-bit operands. 1146 EMIT(0xC0 | reg.code());
1150 if (reg.is(eax)) {
1151 EMIT(0xA9);
1152 } else {
1153 EMIT(0xF7);
1154 EMIT(0xC0 | reg.code());
1155 }
1156 emit(imm);
1157 } 1147 }
1148 emit(imm);
1158 } 1149 }
1159 1150
1160 1151
1161 void Assembler::test(Register reg, const Operand& op) { 1152 void Assembler::test(Register reg, const Operand& op) {
1162 EnsureSpace ensure_space(this); 1153 EnsureSpace ensure_space(this);
1163 EMIT(0x85); 1154 EMIT(0x85);
1164 emit_operand(reg, op); 1155 emit_operand(reg, op);
1165 } 1156 }
1166 1157
1167 1158
1168 void Assembler::test_b(Register reg, const Operand& op) { 1159 void Assembler::test_b(Register reg, const Operand& op) {
1169 CHECK(reg.is_byte_register()); 1160 CHECK(reg.is_byte_register());
1170 EnsureSpace ensure_space(this); 1161 EnsureSpace ensure_space(this);
1171 EMIT(0x84); 1162 EMIT(0x84);
1172 emit_operand(reg, op); 1163 emit_operand(reg, op);
1173 } 1164 }
1174 1165
1175 1166
1176 void Assembler::test(const Operand& op, const Immediate& imm) { 1167 void Assembler::test(const Operand& op, const Immediate& imm) {
1177 if (op.is_reg_only()) { 1168 if (op.is_reg_only()) {
1178 test(op.reg(), imm); 1169 test(op.reg(), imm);
1179 return; 1170 return;
1180 } 1171 }
1172 if (RelocInfo::IsNone(imm.rmode_) && is_uint8(imm.x_)) {
1173 return test_b(op, imm.x_);
1174 }
1181 EnsureSpace ensure_space(this); 1175 EnsureSpace ensure_space(this);
1182 EMIT(0xF7); 1176 EMIT(0xF7);
1183 emit_operand(eax, op); 1177 emit_operand(eax, op);
1184 emit(imm); 1178 emit(imm);
1185 } 1179 }
1186 1180
1187 1181
1182 void Assembler::test_b(Register reg, uint8_t imm8) {
1183 EnsureSpace ensure_space(this);
1184 // Only use test against byte for registers that have a byte
1185 // variant: eax, ebx, ecx, and edx.
1186 if (reg.is(eax)) {
1187 EMIT(0xA8);
1188 EMIT(imm8);
1189 } else if (reg.is_byte_register()) {
1190 emit_arith_b(0xF6, 0xC0, reg, imm8);
1191 } else {
1192 EMIT(0xF7);
1193 EMIT(0xC0 | reg.code());
1194 emit(imm8);
1195 }
1196 }
1197
1198
1188 void Assembler::test_b(const Operand& op, uint8_t imm8) { 1199 void Assembler::test_b(const Operand& op, uint8_t imm8) {
1189 if (op.is_reg_only() && !op.reg().is_byte_register()) { 1200 if (op.is_reg_only()) {
1190 test(op, Immediate(imm8)); 1201 test_b(op.reg(), imm8);
1191 return; 1202 return;
1192 } 1203 }
1193 EnsureSpace ensure_space(this); 1204 EnsureSpace ensure_space(this);
1194 EMIT(0xF6); 1205 EMIT(0xF6);
1195 emit_operand(eax, op); 1206 emit_operand(eax, op);
1196 EMIT(imm8); 1207 EMIT(imm8);
1197 } 1208 }
1198 1209
1199 1210
1200 void Assembler::xor_(Register dst, int32_t imm32) { 1211 void Assembler::xor_(Register dst, int32_t imm32) {
(...skipping 1471 matching lines...) Expand 10 before | Expand all | Expand 10 after
2672 fprintf(coverage_log, "%s\n", file_line); 2683 fprintf(coverage_log, "%s\n", file_line);
2673 fflush(coverage_log); 2684 fflush(coverage_log);
2674 } 2685 }
2675 } 2686 }
2676 2687
2677 #endif 2688 #endif
2678 2689
2679 } } // namespace v8::internal 2690 } } // namespace v8::internal
2680 2691
2681 #endif // V8_TARGET_ARCH_IA32 2692 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/assembler-ia32.h ('k') | src/x64/assembler-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698