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

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

Issue 6366010: X64 Crankshaft: Added a bunch of operations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge/build-x64
Patch Set: Created 9 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/x64/assembler-x64.cc » ('j') | src/x64/lithium-codegen-x64.cc » ('J')
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 are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 } 146 }
147 // Return the 3 low bits of the register code. Used when encoding registers 147 // Return the 3 low bits of the register code. Used when encoding registers
148 // in modR/M, SIB, and opcode bytes. 148 // in modR/M, SIB, and opcode bytes.
149 int low_bits() const { 149 int low_bits() const {
150 return code_ & 0x7; 150 return code_ & 0x7;
151 } 151 }
152 152
153 // Unfortunately we can't make this private in a struct when initializing 153 // Unfortunately we can't make this private in a struct when initializing
154 // by assignment. 154 // by assignment.
155 int code_; 155 int code_;
156
156 private: 157 private:
157 static const int registerCodeByAllocationIndex[kNumAllocatableRegisters]; 158 static const int registerCodeByAllocationIndex[kNumAllocatableRegisters];
158 static const int allocationIndexByRegisterCode[kNumRegisters]; 159 static const int allocationIndexByRegisterCode[kNumRegisters];
159 }; 160 };
160 161
161 const Register rax = { 0 }; 162 const Register rax = { 0 };
162 const Register rcx = { 1 }; 163 const Register rcx = { 1 };
163 const Register rdx = { 2 }; 164 const Register rdx = { 2 };
164 const Register rbx = { 3 }; 165 const Register rbx = { 3 };
165 const Register rsp = { 4 }; 166 const Register rsp = { 4 };
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 // [index*scale + disp/r] 384 // [index*scale + disp/r]
384 Operand(Register index, 385 Operand(Register index,
385 ScaleFactor scale, 386 ScaleFactor scale,
386 int32_t disp); 387 int32_t disp);
387 388
388 // Offset from existing memory operand. 389 // Offset from existing memory operand.
389 // Offset is added to existing displacement as 32-bit signed values and 390 // Offset is added to existing displacement as 32-bit signed values and
390 // this must not overflow. 391 // this must not overflow.
391 Operand(const Operand& base, int32_t offset); 392 Operand(const Operand& base, int32_t offset);
392 393
394 // Checks whether either base or index register is the given reg.
395 // Does not check the "reg" part of the Operand.
396 bool depends_on_register(Register reg) const {
William Hesse 2011/01/24 16:25:27 Could you call it address_uses_register() ?
Lasse Reichstein 2011/01/25 10:13:27 It should probably even be AddressUsesRegister. An
397 int code = reg.code();
398 ASSERT((buf_[0] & 0xC0) != 0xC0); // Always a memory operand.
399 int base_bits = buf_[0] & 0x07;
400 int base_code;
401 if (base_bits == 0x04) {
402 // SIB byte present in buf_[1].
403 // Check the index register from the SIB byte + REX.X prefix.
404 int index_code = ((buf_[1] >> 3) & 0x07) | ((rex_ & 0x02) << 2);
405 // Index code (including REX.X) of 0x04 (esp) means no index register.
Rico 2011/01/25 07:13:28 esp -> rsp
Lasse Reichstein 2011/01/25 10:13:27 Done.
406 if (index_code != 0x04 && index_code == code) return true;
Rico 2011/01/25 07:13:28 What about using rsp.code() instead of 0x04
Lasse Reichstein 2011/01/25 10:13:27 Done, and also rbp.code() instead of 0x05 later.
407 // Add REX.B to base_bits to get base register code.
408 base_bits = (buf_[1] & 0x07) | ((rex_ & 0x01) << 3);
409 base_code = base_bits;
410 } else {
411 // Add REX.B to base_bits to get base register code.
412 base_code = base_bits | ((rex_ & 0x01) << 3);
413 }
414 // Base register is unused if mod = 0 and r/m = 5 (ebp).
415 // Comparison uses REX.B if using the SIB byte, otherwise not.
William Hesse 2011/01/24 16:25:27 instead of "if using the SIB byte", say "if base_c
Lasse Reichstein 2011/01/25 10:13:27 I have rewritten it so the two branches have no sh
416 if (base_bits == 0x05 && ((buf_[0] & 0xC0) == 0)) return false;
417 return code == base_code;
418 }
419
393 private: 420 private:
394 byte rex_; 421 byte rex_;
395 byte buf_[6]; 422 byte buf_[6];
396 // The number of bytes in buf_. 423 // The number of bytes in buf_.
397 unsigned int len_; 424 unsigned int len_;
398 425
399 // Set the ModR/M byte without an encoded 'reg' register. The 426 // Set the ModR/M byte without an encoded 'reg' register. The
400 // register is encoded later as part of the emit_operand operation. 427 // register is encoded later as part of the emit_operand operation.
401 // set_modrm can be called before or after set_sib and set_disp*. 428 // set_modrm can be called before or after set_sib and set_disp*.
402 inline void set_modrm(int mod, Register rm); 429 inline void set_modrm(int mod, Register rm);
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 } 841 }
815 842
816 void andl(Register dst, Immediate src) { 843 void andl(Register dst, Immediate src) {
817 immediate_arithmetic_op_32(0x4, dst, src); 844 immediate_arithmetic_op_32(0x4, dst, src);
818 } 845 }
819 846
820 void andl(Register dst, Register src) { 847 void andl(Register dst, Register src) {
821 arithmetic_op_32(0x23, dst, src); 848 arithmetic_op_32(0x23, dst, src);
822 } 849 }
823 850
851 void andl(Register dst, const Operand& src) {
William Hesse 2011/01/24 16:25:27 Add to disassembler.
Lasse Reichstein 2011/01/25 10:13:27 This one is already there (it's one of the fairly
852 arithmetic_op_32(0x23, dst, src);
853 }
854
824 void andb(Register dst, Immediate src) { 855 void andb(Register dst, Immediate src) {
825 immediate_arithmetic_op_8(0x4, dst, src); 856 immediate_arithmetic_op_8(0x4, dst, src);
826 } 857 }
827 858
828 void decq(Register dst); 859 void decq(Register dst);
829 void decq(const Operand& dst); 860 void decq(const Operand& dst);
830 void decl(Register dst); 861 void decl(Register dst);
831 void decl(const Operand& dst); 862 void decl(const Operand& dst);
832 void decb(Register dst); 863 void decb(Register dst);
833 void decb(const Operand& dst); 864 void decb(const Operand& dst);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1198 void movd(XMMRegister dst, Register src); 1229 void movd(XMMRegister dst, Register src);
1199 void movd(Register dst, XMMRegister src); 1230 void movd(Register dst, XMMRegister src);
1200 void movq(XMMRegister dst, Register src); 1231 void movq(XMMRegister dst, Register src);
1201 void movq(Register dst, XMMRegister src); 1232 void movq(Register dst, XMMRegister src);
1202 void extractps(Register dst, XMMRegister src, byte imm8); 1233 void extractps(Register dst, XMMRegister src, byte imm8);
1203 1234
1204 void movsd(const Operand& dst, XMMRegister src); 1235 void movsd(const Operand& dst, XMMRegister src);
1205 void movsd(XMMRegister dst, XMMRegister src); 1236 void movsd(XMMRegister dst, XMMRegister src);
1206 void movsd(XMMRegister dst, const Operand& src); 1237 void movsd(XMMRegister dst, const Operand& src);
1207 1238
1239 void movdqa(const Operand& dst, XMMRegister src);
William Hesse 2011/01/24 16:25:27 Add to disassembler.
Lasse Reichstein 2011/01/25 10:13:27 Done.
1240 void movdqa(XMMRegister dst, const Operand& src);
1241
1208 void movss(XMMRegister dst, const Operand& src); 1242 void movss(XMMRegister dst, const Operand& src);
1209 void movss(const Operand& dst, XMMRegister src); 1243 void movss(const Operand& dst, XMMRegister src);
1210 1244
1211 void cvttss2si(Register dst, const Operand& src); 1245 void cvttss2si(Register dst, const Operand& src);
1212 void cvttss2si(Register dst, XMMRegister src); 1246 void cvttss2si(Register dst, XMMRegister src);
1213 void cvttsd2si(Register dst, const Operand& src); 1247 void cvttsd2si(Register dst, const Operand& src);
1214 void cvttsd2si(Register dst, XMMRegister src); 1248 void cvttsd2si(Register dst, XMMRegister src);
1215 void cvttsd2siq(Register dst, XMMRegister src); 1249 void cvttsd2siq(Register dst, XMMRegister src);
1216 1250
1217 void cvtlsi2sd(XMMRegister dst, const Operand& src); 1251 void cvtlsi2sd(XMMRegister dst, const Operand& src);
(...skipping 20 matching lines...) Expand all
1238 1272
1239 void ucomisd(XMMRegister dst, XMMRegister src); 1273 void ucomisd(XMMRegister dst, XMMRegister src);
1240 void ucomisd(XMMRegister dst, const Operand& src); 1274 void ucomisd(XMMRegister dst, const Operand& src);
1241 1275
1242 // The first argument is the reg field, the second argument is the r/m field. 1276 // The first argument is the reg field, the second argument is the r/m field.
1243 void emit_sse_operand(XMMRegister dst, XMMRegister src); 1277 void emit_sse_operand(XMMRegister dst, XMMRegister src);
1244 void emit_sse_operand(XMMRegister reg, const Operand& adr); 1278 void emit_sse_operand(XMMRegister reg, const Operand& adr);
1245 void emit_sse_operand(XMMRegister dst, Register src); 1279 void emit_sse_operand(XMMRegister dst, Register src);
1246 void emit_sse_operand(Register dst, XMMRegister src); 1280 void emit_sse_operand(Register dst, XMMRegister src);
1247 1281
1248 // Use either movsd or movlpd. 1282 // Use either movsd or movlpd.
William Hesse 2011/01/24 16:25:27 I commented these, but did not remove them. We sh
Lasse Reichstein 2011/01/25 10:13:27 Done.
1249 // void movdbl(XMMRegister dst, const Operand& src); 1283 // void movdbl(XMMRegister dst, const Operand& src);
1250 // void movdbl(const Operand& dst, XMMRegister src); 1284 // void movdbl(const Operand& dst, XMMRegister src);
1251 1285
1252 // Debugging 1286 // Debugging
1253 void Print(); 1287 void Print();
1254 1288
1255 // Check the code size generated from label to here. 1289 // Check the code size generated from label to here.
1256 int SizeOfCodeGeneratedSince(Label* l) { return pc_offset() - l->pos(); } 1290 int SizeOfCodeGeneratedSince(Label* l) { return pc_offset() - l->pos(); }
1257 1291
1258 // Mark address of the ExitJSFrame code. 1292 // Mark address of the ExitJSFrame code.
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 private: 1558 private:
1525 Assembler* assembler_; 1559 Assembler* assembler_;
1526 #ifdef DEBUG 1560 #ifdef DEBUG
1527 int space_before_; 1561 int space_before_;
1528 #endif 1562 #endif
1529 }; 1563 };
1530 1564
1531 } } // namespace v8::internal 1565 } } // namespace v8::internal
1532 1566
1533 #endif // V8_X64_ASSEMBLER_X64_H_ 1567 #endif // V8_X64_ASSEMBLER_X64_H_
OLDNEW
« no previous file with comments | « no previous file | src/x64/assembler-x64.cc » ('j') | src/x64/lithium-codegen-x64.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698