PageRenderTime 36ms CodeModel.GetById 31ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/JIT/opcodes/block.h

http://unladen-swallow.googlecode.com/
C++ Header | 56 lines | 37 code | 14 blank | 5 comment | 0 complexity | 5ecc511c98032c1d662805e0f8f5278e MD5 | raw file
 1// -*- C++ -*-
 2#ifndef OPCODE_BLOCK_H_
 3#define OPCODE_BLOCK_H_
 4
 5#ifndef __cplusplus
 6#error This header expects to be included only in C++ source
 7#endif
 8
 9#include "llvm/Support/IRBuilder.h"
10#include "llvm/Support/TargetFolder.h"
11
12namespace llvm {
13    class BasicBlock;
14}
15
16namespace py {
17
18class LlvmFunctionBuilder;
19class LlvmFunctionState;
20
21// This class contains all opcodes which manipulate the blockstack.
22class OpcodeBlock
23{
24public:
25    OpcodeBlock(LlvmFunctionBuilder *fbuilder);
26
27    void SETUP_LOOP(llvm::BasicBlock *target, int target_opindex,
28                    llvm::BasicBlock *fallthrough);
29
30    void POP_BLOCK();
31
32    void SETUP_EXCEPT(llvm::BasicBlock *target, int target_opindex,
33                      llvm::BasicBlock *fallthrough);
34    void SETUP_FINALLY(llvm::BasicBlock *target, int target_opindex,
35                       llvm::BasicBlock *fallthrough);
36    void END_FINALLY();
37    void WITH_CLEANUP();
38    
39private:
40    typedef llvm::IRBuilder<true, llvm::TargetFolder> BuilderT;
41
42    // Adds handler to the switch for unwind targets and then sets up
43    // a call to PyFrame_BlockSetup() with the block type, handler
44    // index, and current stack level.
45    void CallBlockSetup(int block_type,
46                        llvm::BasicBlock *handler, int handler_opindex);
47
48    LlvmFunctionBuilder *fbuilder_;
49    LlvmFunctionState *state_;
50    BuilderT &builder_;
51    PyGlobalLlvmData *const llvm_data_;
52};
53
54}
55
56#endif /* OPCODE_BLOCK_H_ */