| OLD | NEW |
| 1 //===- subzero/src/assembler_ia32.cpp - Assembler for x86-32 -------------===// |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // 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 | 3 // 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. | 4 // BSD-style license that can be found in the LICENSE file. |
| 4 // | 5 // |
| 5 // Modified by the Subzero authors. | 6 // Modified by the Subzero authors. |
| 6 // | 7 // |
| 7 //===- subzero/src/assembler_ia32.cpp - Assembler for x86-32 -------------===// | 8 //===----------------------------------------------------------------------===// |
| 8 // | 9 // |
| 9 // The Subzero Code Generator | 10 // The Subzero Code Generator |
| 10 // | 11 // |
| 11 // This file is distributed under the University of Illinois Open Source | 12 // This file is distributed under the University of Illinois Open Source |
| 12 // License. See LICENSE.TXT for details. | 13 // License. See LICENSE.TXT for details. |
| 13 // | 14 // |
| 14 //===----------------------------------------------------------------------===// | 15 //===----------------------------------------------------------------------===// |
| 15 // | 16 // |
| 16 // This file implements the Assembler class for x86-32. | 17 // This file implements the Assembler class for x86-32. |
| 17 // | 18 // |
| 18 //===----------------------------------------------------------------------===// | 19 //===----------------------------------------------------------------------===// |
| 19 | 20 |
| 20 #include "assembler_ia32.h" | 21 #include "assembler_ia32.h" |
| 21 #include "IceCfg.h" | 22 #include "IceCfg.h" |
| 22 #include "IceMemoryRegion.h" | 23 #include "IceMemoryRegion.h" |
| 23 #include "IceOperand.h" | 24 #include "IceOperand.h" |
| 24 | 25 |
| 25 namespace Ice { | 26 namespace Ice { |
| 26 namespace x86 { | 27 namespace x86 { |
| 27 | 28 |
| 28 class DirectCallRelocation : public AssemblerFixup { | 29 class DirectCallRelocation : public AssemblerFixup { |
| 30 DirectCallRelocation(const DirectCallRelocation &) = delete; |
| 31 DirectCallRelocation &operator=(const DirectCallRelocation &) = delete; |
| 32 |
| 29 public: | 33 public: |
| 30 static DirectCallRelocation *create(Assembler *Asm, FixupKind Kind, | 34 static DirectCallRelocation *create(Assembler *Asm, FixupKind Kind, |
| 31 const ConstantRelocatable *Sym) { | 35 const ConstantRelocatable *Sym) { |
| 32 return new (Asm->Allocate<DirectCallRelocation>()) | 36 return new (Asm->Allocate<DirectCallRelocation>()) |
| 33 DirectCallRelocation(Kind, Sym); | 37 DirectCallRelocation(Kind, Sym); |
| 34 } | 38 } |
| 35 | 39 |
| 36 void Process(const MemoryRegion ®ion, intptr_t position) override { | 40 void Process(const MemoryRegion ®ion, intptr_t position) override { |
| 37 // Direct calls are relative to the following instruction on x86. | 41 // Direct calls are relative to the following instruction on x86. |
| 38 int32_t pointer = region.Load<int32_t>(position); | 42 int32_t pointer = region.Load<int32_t>(position); |
| (...skipping 2274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2313 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 2317 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 2314 if (Ty == IceType_i16) | 2318 if (Ty == IceType_i16) |
| 2315 EmitOperandSizeOverride(); | 2319 EmitOperandSizeOverride(); |
| 2316 if (isByteSizedArithType(Ty)) | 2320 if (isByteSizedArithType(Ty)) |
| 2317 EmitUint8(0x86); | 2321 EmitUint8(0x86); |
| 2318 else | 2322 else |
| 2319 EmitUint8(0x87); | 2323 EmitUint8(0x87); |
| 2320 EmitOperand(reg, addr); | 2324 EmitOperand(reg, addr); |
| 2321 } | 2325 } |
| 2322 | 2326 |
| 2327 void AssemblerX86::EmitSegmentOverride(uint8_t prefix) { |
| 2328 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 2329 EmitUint8(prefix); |
| 2330 } |
| 2331 |
| 2323 void AssemblerX86::Align(intptr_t alignment, intptr_t offset) { | 2332 void AssemblerX86::Align(intptr_t alignment, intptr_t offset) { |
| 2324 assert(llvm::isPowerOf2_32(alignment)); | 2333 assert(llvm::isPowerOf2_32(alignment)); |
| 2325 intptr_t pos = offset + buffer_.GetPosition(); | 2334 intptr_t pos = offset + buffer_.GetPosition(); |
| 2326 intptr_t mod = pos & (alignment - 1); | 2335 intptr_t mod = pos & (alignment - 1); |
| 2327 if (mod == 0) { | 2336 if (mod == 0) { |
| 2328 return; | 2337 return; |
| 2329 } | 2338 } |
| 2330 intptr_t bytes_needed = alignment - mod; | 2339 intptr_t bytes_needed = alignment - mod; |
| 2331 while (bytes_needed > MAX_NOP_SIZE) { | 2340 while (bytes_needed > MAX_NOP_SIZE) { |
| 2332 nop(MAX_NOP_SIZE); | 2341 nop(MAX_NOP_SIZE); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 assert(shifter == RegX8632::Encoded_Reg_ecx); | 2474 assert(shifter == RegX8632::Encoded_Reg_ecx); |
| 2466 (void)shifter; | 2475 (void)shifter; |
| 2467 if (Ty == IceType_i16) | 2476 if (Ty == IceType_i16) |
| 2468 EmitOperandSizeOverride(); | 2477 EmitOperandSizeOverride(); |
| 2469 EmitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3); | 2478 EmitUint8(isByteSizedArithType(Ty) ? 0xD2 : 0xD3); |
| 2470 EmitOperand(rm, operand); | 2479 EmitOperand(rm, operand); |
| 2471 } | 2480 } |
| 2472 | 2481 |
| 2473 } // end of namespace x86 | 2482 } // end of namespace x86 |
| 2474 } // end of namespace Ice | 2483 } // end of namespace Ice |
| OLD | NEW |