2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2016 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #include "hphp/runtime/vm/jit/phys-reg-saver.h"
19 #include "hphp/runtime/vm/jit/abi.h"
20 #include "hphp/runtime/vm/jit/phys-reg.h"
21 #include "hphp/runtime/vm/jit/vasm-gen.h"
22 #include "hphp/runtime/vm/jit/vasm-instr.h"
24 namespace HPHP
{ namespace jit
{
26 ///////////////////////////////////////////////////////////////////////////////
28 PhysRegSaver::PhysRegSaver(Vout
& v
, RegSet regs
)
32 auto gpr
= m_regs
& abi().gp();
33 auto xmm
= m_regs
& abi().simd();
34 auto const sp
= rsp();
36 m_adjust
= gpr
.size() & 0x1 ? 8 : 0;
39 v
<< lea
{sp
[-16 * xmm
.size()], sp
};
42 xmm
.forEach([&] (PhysReg r
) {
43 v
<< storeups
{r
, sp
[offset
]};
48 gpr
.forEach([&] (PhysReg r
) {
53 v
<< lea
{sp
[-m_adjust
], sp
};
57 PhysRegSaver::~PhysRegSaver() {
59 auto const sp
= rsp();
62 v
<< lea
{sp
[m_adjust
], sp
};
65 auto gpr
= m_regs
& abi().gp();
66 auto xmm
= m_regs
& abi().simd();
68 gpr
.forEachR([&] (PhysReg r
) {
74 xmm
.forEach([&] (PhysReg r
) {
75 v
<< loadups
{sp
[offset
], r
};
78 v
<< lea
{sp
[offset
], sp
};
82 size_t PhysRegSaver::rspAdjustment() const {
86 size_t PhysRegSaver::dwordsPushed() const {
87 assertx((m_adjust
% sizeof(int64_t)) == 0);
88 return m_regs
.size() + m_adjust
/ sizeof(int64_t);
91 ///////////////////////////////////////////////////////////////////////////////