Clean up irgen.h a bit
[hiphop-php.git] / hphp / runtime / vm / jit / abi.h
blobac5c140424694d7aae86e33783c0dfa0e3621f88
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
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 #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 // JIT and TC boundary ABI registers.
70 // These registers should not be used for scratch purposes between tracelets,
71 // and have to be specially handled if we are returning to the interpreter or
72 // invoking the translator.
75 * VM register sets. The other sets are defined relative to these.
77 RegSet vm_regs_with_sp();
78 RegSet vm_regs_no_sp();
81 * Registers that are live between tracelets, in two flavors, depending whether
82 * we are between tracelets in a resumed function.
84 inline RegSet cross_trace_regs() { return vm_regs_no_sp(); }
85 inline RegSet cross_trace_regs_resumed() { return vm_regs_with_sp(); }
88 * Registers that are live when we reenter the JIT from the TC (e.g., via
89 * service requests).
91 inline RegSet leave_trace_regs() { return vm_regs_with_sp(); }
94 * Registers that are live between the caller and the callee when making a PHP
95 * function call.
97 inline RegSet php_call_regs() { return cross_trace_regs(); }
100 * Registers that are live after a PHP function return.
102 * TODO(#2288359): We don't want this to include rvmsp() eventually.
104 inline RegSet php_return_regs() { return vm_regs_with_sp(); }
107 * Registers that are live on entry to fcallArrayHelper.
109 * TODO(#2288359): We don't want this to include rvmsp() eventually.
111 inline RegSet fcall_array_regs() { return vm_regs_with_sp(); }
114 ///////////////////////////////////////////////////////////////////////////////
115 // Calling convention registers.
118 * Native return value registers.
120 PhysReg rret(size_t i = 0);
121 PhysReg rret_simd(size_t i);
124 * Native argument registers.
126 PhysReg rarg(size_t i);
127 PhysReg rarg_simd(size_t i);
130 * Number of available argument registers.
132 size_t num_arg_regs();
133 size_t num_arg_regs_simd();
136 * RegSet for a call with `n' arguments.
138 RegSet arg_regs(size_t n);
139 RegSet arg_regs_simd(size_t n);
142 * Service request argument registers.
144 PhysReg r_svcreq_req();
145 PhysReg r_svcreq_stub();
146 PhysReg r_svcreq_sf();
147 PhysReg r_svcreq_arg(size_t i);
149 ///////////////////////////////////////////////////////////////////////////////
153 #endif