michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef jit_MoveEmitter_x86_shared_h michael@0: #define jit_MoveEmitter_x86_shared_h michael@0: michael@0: #if defined(JS_CODEGEN_X86) michael@0: # include "jit/x86/MacroAssembler-x86.h" michael@0: #elif defined(JS_CODEGEN_X64) michael@0: # include "jit/x64/MacroAssembler-x64.h" michael@0: #else michael@0: # error "Wrong architecture. Only x86 and x64 should build this file!" michael@0: #endif michael@0: #include "jit/MoveResolver.h" michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: class CodeGenerator; michael@0: michael@0: class MoveEmitterX86 michael@0: { michael@0: bool inCycle_; michael@0: MacroAssemblerSpecific &masm; michael@0: michael@0: // Original stack push value. michael@0: uint32_t pushedAtStart_; michael@0: michael@0: // This is a store stack offset for the cycle-break spill slot, snapshotting michael@0: // codegen->framePushed_ at the time it is allocated. -1 if not allocated. michael@0: int32_t pushedAtCycle_; michael@0: michael@0: void assertDone(); michael@0: Address cycleSlot(); michael@0: Address toAddress(const MoveOperand &operand) const; michael@0: Operand toOperand(const MoveOperand &operand) const; michael@0: Operand toPopOperand(const MoveOperand &operand) const; michael@0: michael@0: size_t characterizeCycle(const MoveResolver &moves, size_t i, michael@0: bool *allGeneralRegs, bool *allFloatRegs); michael@0: bool maybeEmitOptimizedCycle(const MoveResolver &moves, size_t i, michael@0: bool allGeneralRegs, bool allFloatRegs, size_t swapCount); michael@0: void emitInt32Move(const MoveOperand &from, const MoveOperand &to); michael@0: void emitGeneralMove(const MoveOperand &from, const MoveOperand &to); michael@0: void emitFloat32Move(const MoveOperand &from, const MoveOperand &to); michael@0: void emitDoubleMove(const MoveOperand &from, const MoveOperand &to); michael@0: void breakCycle(const MoveOperand &to, MoveOp::Type type); michael@0: void completeCycle(const MoveOperand &to, MoveOp::Type type); michael@0: michael@0: public: michael@0: MoveEmitterX86(MacroAssemblerSpecific &masm); michael@0: ~MoveEmitterX86(); michael@0: void emit(const MoveResolver &moves); michael@0: void finish(); michael@0: }; michael@0: michael@0: typedef MoveEmitterX86 MoveEmitter; michael@0: michael@0: } // ion michael@0: } // js michael@0: michael@0: #endif /* jit_MoveEmitter_x86_shared_h */