CACAO
X86_64Cond.hpp
Go to the documentation of this file.
1 /* src/vm/jit/compiler2/X86_64Cond.hpp - X86_64Cond
2 
3  Copyright (C) 2013
4  CACAOVM - Verein zur Foerderung der freien virtuellen Maschine CACAO
5 
6  This file is part of CACAO.
7 
8  This program is free software; you can redistribute it and/or
9  modify it under the terms of the GNU General Public License as
10  published by the Free Software Foundation; either version 2, or (at
11  your option) any later version.
12 
13  This program is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  02110-1301, USA.
22 
23 */
24 
25 #ifndef _JIT_COMPILER2_X86_64COND
26 #define _JIT_COMPILER2_X86_64COND
27 
30 
31 namespace cacao {
32 namespace jit {
33 namespace compiler2 {
34 namespace x86_64 {
35 /**
36  * x86_64 registers flags
37  */
38 class Cond {
39 public:
40  struct COND {
41  const u1 code;
42  private:
43  COND(u1 code) : code(code) {}
44  friend class Cond;
45  };
46 #if 0
47  enum COND {
48  C, /* carry (CF = 1). */
49  NAE, /* not above or equal (CF = 1). */
50  NB, /* not below (CF = 0). */
51  NC, /* not carry (CF = 0). */
52  AE, /* above or equal (CF = 0). */
53  Z, /* zero (ZF = 1). */
54  E, /* equal (ZF = 1). */
55  NZ, /* not zero (ZF = 0). */
56  NE, /* not equal (ZF = 0). */
57  BE, /* below or equal (CF = 1 or ZF = 1). */
58  NA, /* not above (CF = 1 or ZF = 1). */
59  NBE, /* not below or equal (CF = 0 and ZF = 0). */
60  A, /* above (CF = 0 and ZF = 0). */
61  S, /* sign (SF = 1). */
62  NS, /* not sign (SF = 0). */
63  P, /* parity (PF = 1). */
64  PE, /* parity even (PF = 1). */
65  NP, /* not parity (PF = 0). */
66  PO, /* parity odd (PF = 0). */
67  L, /* less (SF <> OF). */
68  NGE, /* not greater or equal (SF <> OF). */
69  NL, /* not less (SF = OF). */
70  GE, /* greater or equal (SF = OF). */
71  LE, /* less or equal (ZF = 1 or SF <> OF). */
72  NG, /* not greater (ZF = 1 or SF <> OF). */
73  NLE, /* not less or equal (ZF = 0 and SF = OF). */
74  G, /* greater (ZF = 0 and SF = OF). */
75  NO_COND
76  };
77 #endif
78 
79  static const COND O; ///< overflow (OF = 1)
80  static const COND NO; ///< not overflow (OF = 0)
81  static const COND B; ///< below (CF = 1)
82  static const COND C; ///< carry (CF = 1)
83  static const COND NAE; ///< not above or equal (CF = 1)
84  static const COND NB; ///< not below (CF = 0)
85  static const COND NC; ///< not carry (CF = 0)
86  static const COND AE; ///< above or equal (CF = 0)
87  static const COND Z; ///< zero (ZF = 1)
88  static const COND E; ///< equal (ZF = 1)
89  static const COND NZ; ///< not zero (ZF = 0)
90  static const COND NE; ///< not equal (ZF = 0)
91  static const COND BE; ///< below or equal (CF = 1 or ZF = 1)
92  static const COND NA; ///< not above (CF = 1 or ZF = 1)
93  static const COND NBE; ///< not below or equal (CF = 0 and ZF = 0)
94  static const COND A; ///< above (CF = 0 and ZF = 0)
95  static const COND S; ///< sign (SF = 1)
96  static const COND NS; ///< not sign (SF = 0)
97  static const COND P; ///< parity (PF = 1)
98  static const COND PE; ///< parity even (PF = 1)
99  static const COND NP; ///< not parity (PF = 0)
100  static const COND PO; ///< parity odd (PF = 0)
101  static const COND L; ///< less (SF <> OF)
102  static const COND NGE; ///< not greater or equal (SF <> OF)
103  static const COND NL; ///< not less (SF = OF)
104  static const COND GE; ///< greater or equal (SF = OF)
105  static const COND LE; ///< less or equal (ZF = 1 or SF <> OF)
106  static const COND NG; ///< not greater (ZF = 1 or SF <> OF)
107  static const COND NLE; ///< not less or equal (ZF = 0 and SF = OF)
108  static const COND G; ///< greater (ZF = 0 and SF = OF)
109 #if 0
110 // vim search and replace
111 // declare
112 // :'<,'>s/J\([^ ]*\) [^ ]* 7\(.\) cb Jump if \(.*\)\.$/\tstatic const COND \1; \/\/\/< \3/cg
113 // define
114 // :'<,'>s/J\([^ ]*\) [^ ]* 7\(.\) cb Jump if \(.*\)\.$/const Cond::COND Cond::\1 = {0x0\L\2};/cg
115 
116 // raw data
117 JO rel8off 70 cb Jump if overflow (OF = 1).
118 JNO rel8off 71 cb Jump if not overflow (OF = 0).
119 JB rel8off 72 cb Jump if below (CF = 1).
120 JC rel8off 72 cb Jump if carry (CF = 1).
121 JNAE rel8off 72 cb Jump if not above or equal (CF = 1).
122 JNB rel8off 73 cb Jump if not below (CF = 0).
123 JNC rel8off 73 cb Jump if not carry (CF = 0).
124 JAE rel8off 73 cb Jump if above or equal (CF = 0).
125 JZ rel8off 74 cb Jump if zero (ZF = 1).
126 JE rel8off 74 cb Jump if equal (ZF = 1).
127 JNZ rel8off 75 cb Jump if not zero (ZF = 0).
128 JNE rel8off 75 cb Jump if not equal (ZF = 0).
129 JBE rel8off 76 cb Jump if below or equal (CF = 1 or ZF = 1).
130 JNA rel8off 76 cb Jump if not above (CF = 1 or ZF = 1).
131 JNBE rel8off 77 cb Jump if not below or equal (CF = 0 and ZF = 0).
132 JA rel8off 77 cb Jump if above (CF = 0 and ZF = 0).
133 JS rel8off 78 cb Jump if sign (SF = 1).
134 JNS rel8off 79 cb Jump if not sign (SF = 0).
135 JP rel8off 7A cb Jump if parity (PF = 1).
136 JPE rel8off 7A cb Jump if parity even (PF = 1).
137 JNP rel8off 7B cb Jump if not parity (PF = 0).
138 JPO rel8off 7B cb Jump if parity odd (PF = 0).
139 JL rel8off 7C cb Jump if less (SF <> OF).
140 JNGE rel8off 7C cb Jump if not greater or equal (SF <> OF).
141 JNL rel8off 7D cb Jump if not less (SF = OF).
142 JGE rel8off 7D cb Jump if greater or equal (SF = OF).
143 JLE rel8off 7E cb Jump if less or equal (ZF = 1 or SF <> OF).
144 JNG rel8off 7E cb Jump if not greater (ZF = 1 or SF <> OF).
145 JNLE rel8off 7F cb Jump if not less or equal (ZF = 0 and SF = OF).
146 JG rel8off 7F cb Jump if greater (ZF = 0 and SF = OF).
147 #endif
148 };
149 
150 } // end namespace x86_64
151 } // end namespace compiler2
152 } // end namespace jit
153 } // end namespace cacao
154 
155 #endif /* _JIT_COMPILER2_X86_64COND */
156 
157 
158 /*
159  * These are local overrides for various environment variables in Emacs.
160  * Please do not remove this and leave it at the end of the file, where
161  * Emacs will automagically detect them.
162  * ---------------------------------------------------------------------
163  * Local variables:
164  * mode: c++
165  * indent-tabs-mode: t
166  * c-basic-offset: 4
167  * tab-width: 4
168  * End:
169  * vim:noexpandtab:sw=4:ts=4:
170  */
static const COND B
below (CF = 1)
Definition: X86_64Cond.hpp:81
#define zero
Definition: md-asm.hpp:83
static const COND E
equal (ZF = 1)
Definition: X86_64Cond.hpp:88
static const COND NO
not overflow (OF = 0)
Definition: X86_64Cond.hpp:80
static const COND PO
parity odd (PF = 0)
Definition: X86_64Cond.hpp:100
static const COND NA
not above (CF = 1 or ZF = 1)
Definition: X86_64Cond.hpp:92
static const COND NGE
not greater or equal (SF &lt;&gt; OF)
Definition: X86_64Cond.hpp:102
static const COND C
carry (CF = 1)
Definition: X86_64Cond.hpp:82
static const COND G
greater (ZF = 0 and SF = OF)
Definition: X86_64Cond.hpp:108
uint8_t u1
Definition: types.hpp:40
static const COND NZ
not zero (ZF = 0)
Definition: X86_64Cond.hpp:89
x86_64 registers flags
Definition: X86_64Cond.hpp:38
static const COND L
less (SF &lt;&gt; OF)
Definition: X86_64Cond.hpp:101
static const COND AE
above or equal (CF = 0)
Definition: X86_64Cond.hpp:86
static const COND NG
not greater (ZF = 1 or SF &lt;&gt; OF)
Definition: X86_64Cond.hpp:106
static const COND GE
greater or equal (SF = OF)
Definition: X86_64Cond.hpp:104
static const COND NB
not below (CF = 0)
Definition: X86_64Cond.hpp:84
static const COND PE
parity even (PF = 1)
Definition: X86_64Cond.hpp:98
static const COND O
overflow (OF = 1)
Definition: X86_64Cond.hpp:79
static const COND BE
below or equal (CF = 1 or ZF = 1)
Definition: X86_64Cond.hpp:91
static const COND NE
not equal (ZF = 0)
Definition: X86_64Cond.hpp:90
static const COND Z
zero (ZF = 1)
Definition: X86_64Cond.hpp:87
static const COND A
above (CF = 0 and ZF = 0)
Definition: X86_64Cond.hpp:94
static const COND NLE
not less or equal (ZF = 0 and SF = OF)
Definition: X86_64Cond.hpp:107
static const COND P
parity (PF = 1)
Definition: X86_64Cond.hpp:97
static const COND NS
not sign (SF = 0)
Definition: X86_64Cond.hpp:96
static const COND NBE
not below or equal (CF = 0 and ZF = 0)
Definition: X86_64Cond.hpp:93
static const COND NP
not parity (PF = 0)
Definition: X86_64Cond.hpp:99
static const COND NL
not less (SF = OF)
Definition: X86_64Cond.hpp:103
static const COND NAE
not above or equal (CF = 1)
Definition: X86_64Cond.hpp:83
static const COND NC
not carry (CF = 0)
Definition: X86_64Cond.hpp:85
static const COND LE
less or equal (ZF = 1 or SF &lt;&gt; OF)
Definition: X86_64Cond.hpp:105
static const COND S
sign (SF = 1)
Definition: X86_64Cond.hpp:95