PageRenderTime 223ms CodeModel.GetById 101ms app.highlight 3ms RepoModel.GetById 117ms app.codeStats 1ms

/JIT/opcodes/cmpops.h

http://unladen-swallow.googlecode.com/
C++ Header | 58 lines | 33 code | 15 blank | 10 comment | 0 complexity | 0166d762d0a20c3a9589f6b7efd97397 MD5 | raw file
 1// -*- C++ -*-
 2#ifndef OPCODE_CMPOPS_H_
 3#define OPCODE_CMPOPS_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 Value;
14}
15
16namespace py {
17
18class LlvmFunctionBuilder;
19class LlvmFunctionState;
20
21// This class includes all code to implement the compare opcode.
22class OpcodeCmpops
23{
24public:
25    OpcodeCmpops(LlvmFunctionBuilder *fbuilder);
26
27    void COMPARE_OP(int cmp_op);
28
29private:
30    typedef llvm::IRBuilder<true, llvm::TargetFolder> BuilderT;
31
32    bool COMPARE_OP_fast(int cmp_op,
33                         const PyTypeObject *lhs_type,
34                         const PyTypeObject *rhs_type);
35    void COMPARE_OP_safe(int cmp_op);
36
37    // Call PyObject_RichCompare(lhs, rhs, cmp_op), pushing the result
38    // onto the stack. cmp_op is one of Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT
39    // or Py_GE as defined in Python/object.h. Steals both references.
40    void RichCompare(llvm::Value *lhs, llvm::Value *rhs, int cmp_op);
41
42    // Call PySequence_Contains(seq, item), returning the result as an i1.
43    // Steals both references.
44    llvm::Value *ContainerContains(llvm::Value *seq, llvm::Value *item);
45
46    // Check whether exc (a thrown exception) matches exc_type
47    // (a class or tuple of classes) for the purpose of catching
48    // exc in an except clause. Returns an i1. Steals both references.
49    llvm::Value *ExceptionMatches(llvm::Value *exc, llvm::Value *exc_type);
50
51    LlvmFunctionBuilder *fbuilder_;
52    LlvmFunctionState *state_;
53    BuilderT &builder_;
54};
55
56}
57
58#endif /* OPCODE_CMPOPS_H_ */