codemod 2010-2016 to 2010-present
[hiphop-php.git] / hphp / runtime / vm / jit / abi.h
blob6b82c57ba6ae09f95c81cf00846ce47531443c8f
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present 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 #ifndef incl_HPHP_JIT_ABI_H
18 #define incl_HPHP_JIT_ABI_H
20 #include "hphp/runtime/vm/jit/types.h"
21 #include "hphp/runtime/vm/jit/abi-regs.h"
22 #include "hphp/runtime/vm/jit/phys-reg.h"
24 namespace HPHP { namespace jit {
26 ///////////////////////////////////////////////////////////////////////////////
29 * Return a suitable ABI for the targeted architecture and `kind'.
31 const Abi& abi(CodeKind kind = CodeKind::Trace);
34 ///////////////////////////////////////////////////////////////////////////////
35 // Principal reserved registers.
37 // These registers have special purposes both during and between traces.
40 * Frame pointer.
42 * When mid-trace, points to the ActRec for the function currently executing.
44 PhysReg rvmfp();
47 * Stack pointer.
49 * When mid-trace, points to the top of the eval stack (lowest valid address)
50 * at the start of the current tracelet.
52 PhysReg rvmsp();
55 * RDS base pointer.
57 * Always points to the base of the RDS block for the current request.
59 PhysReg rvmtl();
62 * Native stack pointer.
64 PhysReg rsp();
67 ///////////////////////////////////////////////////////////////////////////////
68 // Calling convention registers.
71 * PHP return value registers.
73 PhysReg rret_data();
74 PhysReg rret_type();
77 * Native return value registers.
79 PhysReg rret(size_t i = 0);
80 PhysReg rret_simd(size_t i);
83 * Native argument registers.
85 PhysReg rarg(size_t i);
86 PhysReg rarg_simd(size_t i);
87 PhysReg rarg_ind_ret(size_t i);
90 * Number of available argument registers.
92 size_t num_arg_regs();
93 size_t num_arg_regs_simd();
94 size_t num_arg_regs_ind_ret();
97 * RegSet for a call with `n' arguments.
99 RegSet arg_regs(size_t n);
100 RegSet arg_regs_simd(size_t n);
101 RegSet arg_regs_ind_ret(size_t n);
104 * Service request argument registers.
106 PhysReg r_svcreq_req();
107 PhysReg r_svcreq_stub();
108 PhysReg r_svcreq_sf();
109 PhysReg r_svcreq_arg(size_t i);
112 ///////////////////////////////////////////////////////////////////////////////
113 // JIT and TC boundary ABI registers.
115 // These registers should not be used for scratch purposes between tracelets,
116 // and have to be specially handled if we are returning to the interpreter or
117 // invoking the translator.
120 * VM register sets. The other sets are defined relative to these.
122 RegSet vm_regs_with_sp();
123 RegSet vm_regs_no_sp();
126 * Registers that are live between tracelets, in two flavors, depending whether
127 * we are between tracelets in a resumed function.
129 inline RegSet cross_trace_regs() { return vm_regs_no_sp(); }
130 inline RegSet cross_trace_regs_resumed() { return vm_regs_with_sp(); }
133 * Registers that are live when we reenter the JIT from the TC (e.g., via
134 * service requests).
136 inline RegSet leave_trace_regs() { return vm_regs_with_sp(); }
139 * Registers that are live between the caller and the callee when making a PHP
140 * function call.
142 inline RegSet php_call_regs() { return cross_trace_regs(); }
145 * Registers that are live after a PHP function return.
147 * TODO(#2288359): We don't want this to include rvmsp() eventually.
149 inline RegSet php_return_regs() {
150 return vm_regs_with_sp() | rret_data() | rret_type();
154 * Registers that are live on entry to fcallArrayHelper.
156 * TODO(#2288359): We don't want this to include rvmsp() eventually.
158 inline RegSet fcall_array_regs() { return vm_regs_with_sp(); }
160 ///////////////////////////////////////////////////////////////////////////////
163 * Return the status flags that must be set when testing 'cc'.
165 Vflags required_flags(ConditionCode cc);
167 ///////////////////////////////////////////////////////////////////////////////
171 #endif