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

Side by Side Diff: src/assembler_ia32.h

Issue 649463002: Handle "Mov" which is mov, movss, movsd, and used for nacl.read.tp. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: fixups Created 6 years, 2 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/PNaClTranslator.cpp ('k') | src/assembler_ia32.cpp » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 // 4 //
5 // Modified by the Subzero authors. 5 // Modified by the Subzero authors.
6 // 6 //
7 //===- subzero/src/assembler_ia32.h - Assembler for x86-32 ----------------===// 7 //===- subzero/src/assembler_ia32.h - Assembler for x86-32 ----------------===//
8 // 8 //
9 // The Subzero Code Generator 9 // The Subzero Code Generator
10 // 10 //
11 // This file is distributed under the University of Illinois Open Source 11 // This file is distributed under the University of Illinois Open Source
12 // License. See LICENSE.TXT for details. 12 // License. See LICENSE.TXT for details.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 // 15 //
16 // This file implements the Assembler class for x86-32. 16 // This file implements the Assembler class for x86-32.
17 // 17 //
18 //===----------------------------------------------------------------------===// 18 //===----------------------------------------------------------------------===//
19 19
20 #ifndef SUBZERO_SRC_ASSEMBLER_IA32_H_ 20 #ifndef SUBZERO_SRC_ASSEMBLER_IA32_H_
21 #define SUBZERO_SRC_ASSEMBLER_IA32_H_ 21 #define SUBZERO_SRC_ASSEMBLER_IA32_H_
22 22
23 #include "IceConditionCodesX8632.h"
23 #include "IceDefs.h" 24 #include "IceDefs.h"
24 #include "IceConditionCodesX8632.h" 25 #include "IceOperand.h"
25 #include "IceRegistersX8632.h" 26 #include "IceRegistersX8632.h"
26 #include "IceTypes.h" 27 #include "IceTypes.h"
27 #include "IceUtils.h" 28 #include "IceUtils.h"
28 29
29 #include "assembler.h" 30 #include "assembler.h"
30 31
31 namespace Ice { 32 namespace Ice {
32 33
33 class Assembler; 34 class Assembler;
34 class ConstantRelocatable;
35 35
36 using RegX8632::GPRRegister; 36 using RegX8632::GPRRegister;
37 using RegX8632::XmmRegister; 37 using RegX8632::XmmRegister;
38 using RegX8632::ByteRegister; 38 using RegX8632::ByteRegister;
39 using RegX8632::X87STRegister; 39 using RegX8632::X87STRegister;
40 40
41 namespace x86 { 41 namespace x86 {
42 42
43 const int MAX_NOP_SIZE = 8; 43 const int MAX_NOP_SIZE = 8;
44 44
(...skipping 15 matching lines...) Expand all
60 60
61 private: 61 private:
62 DisplacementRelocation(FixupKind Kind, const ConstantRelocatable *Sym) 62 DisplacementRelocation(FixupKind Kind, const ConstantRelocatable *Sym)
63 : AssemblerFixup(Kind, Sym) {} 63 : AssemblerFixup(Kind, Sym) {}
64 DisplacementRelocation(const DisplacementRelocation &) = delete; 64 DisplacementRelocation(const DisplacementRelocation &) = delete;
65 DisplacementRelocation &operator=(const DisplacementRelocation &) = delete; 65 DisplacementRelocation &operator=(const DisplacementRelocation &) = delete;
66 }; 66 };
67 67
68 class Immediate { 68 class Immediate {
69 public: 69 public:
70 explicit Immediate(int32_t value) : value_(value) {} 70 explicit Immediate(int32_t value) : value_(value), fixup_(NULL) {}
71 71
72 Immediate(const Immediate &other) : value_(other.value_) {} 72 explicit Immediate(const Immediate &other)
73 : value_(other.value_), fixup_(other.fixup_) {}
74
75 explicit Immediate(AssemblerFixup *fixup)
76 : value_(fixup->value()->getOffset()), fixup_(fixup) {
77 // Use the Offset in the "value" for now. If the symbol is part of
78 // ".bss", then the relocation's symbol will be plain ".bss" and
79 // the value will need to be adjusted further to be sym's
80 // bss offset + Offset.
81 }
73 82
74 int32_t value() const { return value_; } 83 int32_t value() const { return value_; }
84 AssemblerFixup *fixup() const { return fixup_; }
75 85
76 bool is_int8() const { return Utils::IsInt(8, value_); } 86 bool is_int8() const {
77 bool is_uint8() const { return Utils::IsUint(8, value_); } 87 // We currently only allow 32-bit fixups, and they usually have value = 0,
78 bool is_uint16() const { return Utils::IsUint(16, value_); } 88 // so if fixup_ != NULL, it shouldn't be classified as int8/16.
89 return fixup_ == NULL && Utils::IsInt(8, value_);
90 }
91 bool is_uint8() const { return fixup_ == NULL && Utils::IsUint(8, value_); }
92 bool is_uint16() const { return fixup_ == NULL && Utils::IsUint(16, value_); }
79 93
80 private: 94 private:
81 const int32_t value_; 95 const int32_t value_;
96 AssemblerFixup *fixup_;
82 }; 97 };
83 98
84 class Operand { 99 class Operand {
85 public: 100 public:
86 uint8_t mod() const { return (encoding_at(0) >> 6) & 3; } 101 uint8_t mod() const { return (encoding_at(0) >> 6) & 3; }
87 102
88 GPRRegister rm() const { 103 GPRRegister rm() const {
89 return static_cast<GPRRegister>(encoding_at(0) & 7); 104 return static_cast<GPRRegister>(encoding_at(0) & 7);
90 } 105 }
91 106
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 } 236 }
222 } 237 }
223 238
224 Address(const Address &other) : Operand(other) {} 239 Address(const Address &other) : Operand(other) {}
225 240
226 Address &operator=(const Address &other) { 241 Address &operator=(const Address &other) {
227 Operand::operator=(other); 242 Operand::operator=(other);
228 return *this; 243 return *this;
229 } 244 }
230 245
231 static Address Absolute(const uintptr_t addr, AssemblerFixup *fixup) { 246 static Address Absolute(const uintptr_t addr) {
232 Address result; 247 Address result;
233 result.SetModRM(0, RegX8632::Encoded_Reg_ebp); 248 result.SetModRM(0, RegX8632::Encoded_Reg_ebp);
234 result.SetDisp32(addr); 249 result.SetDisp32(addr);
250 return result;
251 }
252
253 static Address Absolute(AssemblerFixup *fixup) {
254 Address result;
255 result.SetModRM(0, RegX8632::Encoded_Reg_ebp);
256 // Use the Offset in the displacement for now. If the symbol is part of
257 // ".bss", then the relocation's symbol will be plain .bss and the
258 // displacement will need to be adjusted further to be sym's
259 // bss offset + Offset.
260 result.SetDisp32(fixup->value()->getOffset());
235 result.SetFixup(fixup); 261 result.SetFixup(fixup);
236 return result; 262 return result;
237 } 263 }
238 264
239 static Address ofConstPool(GlobalContext *Ctx, Assembler *Asm, 265 static Address ofConstPool(GlobalContext *Ctx, Assembler *Asm,
240 const Constant *Imm); 266 const Constant *Imm);
241 267
242 private: 268 private:
243 Address() {} // Needed by Address::Absolute. 269 Address() {} // Needed by Address::Absolute.
244 }; 270 };
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 void pushl(GPRRegister reg); 446 void pushl(GPRRegister reg);
421 447
422 void popl(GPRRegister reg); 448 void popl(GPRRegister reg);
423 void popl(const Address &address); 449 void popl(const Address &address);
424 450
425 void pushal(); 451 void pushal();
426 void popal(); 452 void popal();
427 453
428 void setcc(CondX86::BrCond condition, ByteRegister dst); 454 void setcc(CondX86::BrCond condition, ByteRegister dst);
429 455
430 void movl(GPRRegister dst, const Immediate &src); 456 void mov(Type Ty, GPRRegister dst, const Immediate &src);
431 void movl(GPRRegister dst, GPRRegister src); 457 void mov(Type Ty, GPRRegister dst, GPRRegister src);
432 458
433 void movl(GPRRegister dst, const Address &src); 459 void mov(Type Ty, GPRRegister dst, const Address &src);
434 void movl(const Address &dst, GPRRegister src); 460 void mov(Type Ty, const Address &dst, GPRRegister src);
435 void movl(const Address &dst, const Immediate &imm); 461 void mov(Type Ty, const Address &dst, const Immediate &imm);
436 462
437 void movzxb(GPRRegister dst, ByteRegister src); 463 void movzxb(GPRRegister dst, ByteRegister src);
438 void movzxb(GPRRegister dst, const Address &src); 464 void movzxb(GPRRegister dst, const Address &src);
439 void movsxb(GPRRegister dst, ByteRegister src); 465 void movsxb(GPRRegister dst, ByteRegister src);
440 void movsxb(GPRRegister dst, const Address &src); 466 void movsxb(GPRRegister dst, const Address &src);
441 467
442 void movb(ByteRegister dst, const Address &src);
443 void movb(const Address &dst, ByteRegister src);
444 void movb(const Address &dst, const Immediate &imm);
445
446 void movzxw(GPRRegister dst, GPRRegister src); 468 void movzxw(GPRRegister dst, GPRRegister src);
447 void movzxw(GPRRegister dst, const Address &src); 469 void movzxw(GPRRegister dst, const Address &src);
448 void movsxw(GPRRegister dst, GPRRegister src); 470 void movsxw(GPRRegister dst, GPRRegister src);
449 void movsxw(GPRRegister dst, const Address &src); 471 void movsxw(GPRRegister dst, const Address &src);
450 void movw(GPRRegister dst, const Address &src);
451 void movw(const Address &dst, GPRRegister src);
452 472
453 void lea(Type Ty, GPRRegister dst, const Address &src); 473 void lea(Type Ty, GPRRegister dst, const Address &src);
454 474
455 void cmov(CondX86::BrCond cond, GPRRegister dst, GPRRegister src); 475 void cmov(CondX86::BrCond cond, GPRRegister dst, GPRRegister src);
456 476
457 void rep_movsb(); 477 void rep_movsb();
458 478
459 void movss(Type Ty, XmmRegister dst, const Address &src); 479 void movss(Type Ty, XmmRegister dst, const Address &src);
460 void movss(Type Ty, const Address &dst, XmmRegister src); 480 void movss(Type Ty, const Address &dst, XmmRegister src);
461 void movss(Type Ty, XmmRegister dst, XmmRegister src); 481 void movss(Type Ty, XmmRegister dst, XmmRegister src);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 void cmpxchg(Type Ty, const Address &address, GPRRegister reg); 757 void cmpxchg(Type Ty, const Address &address, GPRRegister reg);
738 void cmpxchg8b(const Address &address); 758 void cmpxchg8b(const Address &address);
739 void xadd(Type Ty, const Address &address, GPRRegister reg); 759 void xadd(Type Ty, const Address &address, GPRRegister reg);
740 void xchg(Type Ty, const Address &address, GPRRegister reg); 760 void xchg(Type Ty, const Address &address, GPRRegister reg);
741 761
742 void LockCmpxchg(Type Ty, const Address &address, GPRRegister reg) { 762 void LockCmpxchg(Type Ty, const Address &address, GPRRegister reg) {
743 lock(); 763 lock();
744 cmpxchg(Ty, address, reg); 764 cmpxchg(Ty, address, reg);
745 } 765 }
746 766
767 void EmitSegmentOverride(uint8_t prefix) { EmitUint8(prefix); }
768
747 intptr_t PreferredLoopAlignment() { return 16; } 769 intptr_t PreferredLoopAlignment() { return 16; }
748 void Align(intptr_t alignment, intptr_t offset); 770 void Align(intptr_t alignment, intptr_t offset);
749 void Bind(Label *label); 771 void Bind(Label *label);
750 772
751 intptr_t CodeSize() const { return buffer_.Size(); } 773 intptr_t CodeSize() const { return buffer_.Size(); }
752 774
753 void FinalizeInstructions(const MemoryRegion &region) { 775 void FinalizeInstructions(const MemoryRegion &region) {
754 buffer_.FinalizeInstructions(region); 776 buffer_.FinalizeInstructions(region);
755 } 777 }
756 778
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { 836 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) {
815 buffer_.EmitFixup(fixup); 837 buffer_.EmitFixup(fixup);
816 } 838 }
817 839
818 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } 840 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); }
819 841
820 } // end of namespace x86 842 } // end of namespace x86
821 } // end of namespace Ice 843 } // end of namespace Ice
822 844
823 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ 845 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_
OLDNEW
« no previous file with comments | « src/PNaClTranslator.cpp ('k') | src/assembler_ia32.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698