PageRenderTime 395ms CodeModel.GetById 181ms app.highlight 15ms RepoModel.GetById 196ms app.codeStats 1ms

/JIT/PyBytecodeDispatch.h

http://unladen-swallow.googlecode.com/
C++ Header | 182 lines | 146 code | 27 blank | 9 comment | 0 complexity | 57a795c65764f7eac53f6c07ddff6e36 MD5 | raw file
  1// -*- C++ -*-
  2#ifndef UTIL_PYBYTECODEDISPATCH_H
  3#define UTIL_PYBYTECODEDISPATCH_H
  4
  5#ifndef __cplusplus
  6#error This header expects to be included only in C++ source
  7#endif
  8
  9namespace llvm {
 10    class BasicBlock;
 11}
 12
 13namespace py {
 14
 15class LlvmFunctionBuilder;
 16
 17// This class handles dispatching opcodes by calling their
 18// implementations in JIT/opcodes/*.  If you want to replace a opcode
 19// implementation, subclass PyBytecodeDispatch and override the
 20// corresponding method.
 21//
 22// The opcode methods are not yet virtualized for performance reasons.
 23class PyBytecodeDispatch {
 24public:
 25    PyBytecodeDispatch(LlvmFunctionBuilder *fbuilder);
 26
 27    /// The following methods operate like the opcodes with the same
 28    /// name.
 29    void LOAD_CONST(int index);
 30    void LOAD_FAST(int index);
 31    void STORE_FAST(int index);
 32    void DELETE_FAST(int index);
 33
 34    void SETUP_LOOP(llvm::BasicBlock *target, int target_opindex,
 35                    llvm::BasicBlock *fallthrough);
 36    void GET_ITER();
 37    void FOR_ITER(llvm::BasicBlock *target,
 38                  llvm::BasicBlock *fallthrough);
 39    void POP_BLOCK();
 40
 41    void SETUP_EXCEPT(llvm::BasicBlock *target, int target_opindex,
 42                      llvm::BasicBlock *fallthrough);
 43    void SETUP_FINALLY(llvm::BasicBlock *target, int target_opindex,
 44                       llvm::BasicBlock *fallthrough);
 45    void END_FINALLY();
 46    void WITH_CLEANUP();
 47
 48    void JUMP_FORWARD(llvm::BasicBlock *target,
 49                      llvm::BasicBlock *fallthrough);
 50    void JUMP_ABSOLUTE(llvm::BasicBlock *target,
 51                       llvm::BasicBlock *fallthrough);
 52
 53    void POP_JUMP_IF_FALSE(unsigned target_idx,
 54                           unsigned fallthrough_idx,
 55                           llvm::BasicBlock *target,
 56                           llvm::BasicBlock *fallthrough);
 57    void POP_JUMP_IF_TRUE(unsigned target_idx,
 58                          unsigned fallthrough_idx,
 59                          llvm::BasicBlock *target,
 60                          llvm::BasicBlock *fallthrough);
 61    void JUMP_IF_FALSE_OR_POP(unsigned target_idx,
 62                              unsigned fallthrough_idx,
 63                              llvm::BasicBlock *target,
 64                              llvm::BasicBlock *fallthrough);
 65    void JUMP_IF_TRUE_OR_POP(unsigned target_idx,
 66                             unsigned fallthrough_idx,
 67                             llvm::BasicBlock *target,
 68                             llvm::BasicBlock *fallthrough);
 69    void CONTINUE_LOOP(llvm::BasicBlock *target,
 70                       int target_opindex,
 71                       llvm::BasicBlock *fallthrough);
 72
 73    void BREAK_LOOP();
 74    void RETURN_VALUE();
 75    void YIELD_VALUE();
 76
 77    void POP_TOP();
 78    void DUP_TOP();
 79    void DUP_TOP_TWO();
 80    void DUP_TOP_THREE();
 81    void ROT_TWO();
 82    void ROT_THREE();
 83    void ROT_FOUR();
 84
 85    void BINARY_ADD();
 86    void BINARY_SUBTRACT();
 87    void BINARY_MULTIPLY();
 88    void BINARY_TRUE_DIVIDE();
 89    void BINARY_DIVIDE();
 90    void BINARY_MODULO();
 91    void BINARY_POWER();
 92    void BINARY_LSHIFT();
 93    void BINARY_RSHIFT();
 94    void BINARY_OR();
 95    void BINARY_XOR();
 96    void BINARY_AND();
 97    void BINARY_FLOOR_DIVIDE();
 98    void BINARY_SUBSCR();
 99
100    void INPLACE_ADD();
101    void INPLACE_SUBTRACT();
102    void INPLACE_MULTIPLY();
103    void INPLACE_TRUE_DIVIDE();
104    void INPLACE_DIVIDE();
105    void INPLACE_MODULO();
106    void INPLACE_POWER();
107    void INPLACE_LSHIFT();
108    void INPLACE_RSHIFT();
109    void INPLACE_OR();
110    void INPLACE_XOR();
111    void INPLACE_AND();
112    void INPLACE_FLOOR_DIVIDE();
113
114    void UNARY_CONVERT();
115    void UNARY_INVERT();
116    void UNARY_POSITIVE();
117    void UNARY_NEGATIVE();
118    void UNARY_NOT();
119
120    void SLICE_NONE();
121    void SLICE_LEFT();
122    void SLICE_RIGHT();
123    void SLICE_BOTH();
124    void STORE_SLICE_NONE();
125    void STORE_SLICE_LEFT();
126    void STORE_SLICE_RIGHT();
127    void STORE_SLICE_BOTH();
128    void DELETE_SLICE_NONE();
129    void DELETE_SLICE_LEFT();
130    void DELETE_SLICE_RIGHT();
131    void DELETE_SLICE_BOTH();
132    void STORE_SUBSCR();
133    void DELETE_SUBSCR();
134    void STORE_MAP();
135    void LIST_APPEND();
136    void IMPORT_NAME();
137
138    void COMPARE_OP(int cmp_op);
139
140    void CALL_FUNCTION(int num_args);
141    void CALL_METHOD(int num_args);
142    void CALL_FUNCTION_VAR(int num_args);
143    void CALL_FUNCTION_KW(int num_args);
144    void CALL_FUNCTION_VAR_KW(int num_args);
145
146    void BUILD_TUPLE(int size);
147    void BUILD_LIST(int size);
148    void BUILD_MAP(int size);
149    void BUILD_SLICE_TWO();
150    void BUILD_SLICE_THREE();
151    void UNPACK_SEQUENCE(int size);
152
153    void LOAD_GLOBAL(int index);
154    void STORE_GLOBAL(int index);
155    void DELETE_GLOBAL(int index);
156
157    void LOAD_NAME(int index);
158    void STORE_NAME(int index);
159    void DELETE_NAME(int index);
160
161    void LOAD_ATTR(int index);
162    void LOAD_METHOD(int index);
163    void STORE_ATTR(int index);
164    void DELETE_ATTR(int index);
165
166    void LOAD_CLOSURE(int freevar_index);
167    void MAKE_CLOSURE(int num_defaults);
168    void LOAD_DEREF(int index);
169    void STORE_DEREF(int index);
170
171    void RAISE_VARARGS_ZERO();
172    void RAISE_VARARGS_ONE();
173    void RAISE_VARARGS_TWO();
174    void RAISE_VARARGS_THREE();
175
176private:
177    LlvmFunctionBuilder *fbuilder_;
178};
179
180}
181
182#endif  // UTIL_PYBYTECODEDISPATCH_H