Various llvm backend bugfixes
[hiphop-php.git] / hphp / runtime / vm / jit / translator-inline.h
blobd1f55a247851d24c5178b2ea12a7bde1383320ac
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2014 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_TRANSLATOR_INLINE_H_
18 #define incl_HPHP_TRANSLATOR_INLINE_H_
20 #include <boost/noncopyable.hpp>
22 #include "hphp/runtime/vm/vm-regs.h"
23 #include "hphp/runtime/vm/jit/translator.h"
24 #include "hphp/runtime/base/execution-context.h"
27 * Because of a circular dependence with ExecutionContext, these
28 * translation-related helpers cannot live in translator.h.
30 namespace HPHP {
32 inline ActRec* liveFrame() { return vmfp(); }
33 inline const Func* liveFunc() { return liveFrame()->m_func; }
34 inline const Unit* liveUnit() { return liveFunc()->unit(); }
35 inline Class* liveClass() { return liveFunc()->cls(); }
36 inline bool liveResumed() { return liveFrame()->resumed(); }
38 inline Offset liveSpOff() {
39 Cell* fp = reinterpret_cast<Cell*>(vmfp());
40 if (liveFrame()->resumed()) {
41 fp = (Cell*)Stack::resumableStackBase((ActRec*)fp);
43 return fp - vmsp();
46 namespace jit {
48 inline int cellsToBytes(int nCells) {
49 return safe_cast<int32_t>(nCells * ssize_t(sizeof(Cell)));
52 inline int localOffset(int locId) {
53 return -cellsToBytes(locId + 1);
56 } } // HPHP::jit
58 #endif