codemod 2010-2016 to 2010-present
[hiphop-php.git] / hphp / runtime / vm / jit / alignment.h
blobae0f9727956c19d761843b51935a49b04d4db803
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_ALIGNMENT_H_
18 #define incl_HPHP_JIT_ALIGNMENT_H_
20 #include <cstdint>
21 #include <string>
23 namespace HPHP { namespace jit {
25 ///////////////////////////////////////////////////////////////////////////////
28 * Whether we're aligning at a live or a dead code point.
30 * Live alignments must use nop gaps; alignment requests in dead contexts are
31 * allowed to use various trap instructions.
33 enum class AlignContext : uint32_t { Live, Dead };
36 * What to align to.
38 * Not all of these will actually require alignment on all targets.
40 enum class Alignment : uint32_t {
42 * Align to the start of the next cache line unconditionally (unless we are
43 * already aligned to one).
45 CacheLine = 0,
48 * If we are in the second half of a cache line, align to the next one.
50 CacheLineRoundUp,
53 * Align to the nearest valid jmp target.
55 JmpTarget,
58 * Alignments needed by smashable instructions.
60 SmashMovq,
61 SmashCmpq,
62 SmashCall,
63 SmashJmp,
64 SmashJcc,
67 constexpr auto kNumAlignments =
68 static_cast<size_t>(Alignment::SmashJcc) + 1;
71 * Under most architectures, the Alignments can be expressed by stipulating
72 * that the code region given by
74 * [frontier + offset, nbytes)
76 * fits into the nearest `align'-aligned and -sized line.
78 struct AlignInfo {
79 size_t align;
80 size_t nbytes;
81 size_t offset;
84 ///////////////////////////////////////////////////////////////////////////////
88 #endif