/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. #ifndef __cplusplus
  5. #error This header expects to be included only in C++ source
  6. #endif
  7. #include "llvm/Support/IRBuilder.h"
  8. #include "llvm/Support/TargetFolder.h"
  9. namespace llvm {
  10. class Value;
  11. }
  12. namespace py {
  13. class LlvmFunctionBuilder;
  14. class LlvmFunctionState;
  15. // This class includes all code to implement the compare opcode.
  16. class OpcodeCmpops
  17. {
  18. public:
  19. OpcodeCmpops(LlvmFunctionBuilder *fbuilder);
  20. void COMPARE_OP(int cmp_op);
  21. private:
  22. typedef llvm::IRBuilder<true, llvm::TargetFolder> BuilderT;
  23. bool COMPARE_OP_fast(int cmp_op,
  24. const PyTypeObject *lhs_type,
  25. const PyTypeObject *rhs_type);
  26. void COMPARE_OP_safe(int cmp_op);
  27. // Call PyObject_RichCompare(lhs, rhs, cmp_op), pushing the result
  28. // onto the stack. cmp_op is one of Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT
  29. // or Py_GE as defined in Python/object.h. Steals both references.
  30. void RichCompare(llvm::Value *lhs, llvm::Value *rhs, int cmp_op);
  31. // Call PySequence_Contains(seq, item), returning the result as an i1.
  32. // Steals both references.
  33. llvm::Value *ContainerContains(llvm::Value *seq, llvm::Value *item);
  34. // Check whether exc (a thrown exception) matches exc_type
  35. // (a class or tuple of classes) for the purpose of catching
  36. // exc in an except clause. Returns an i1. Steals both references.
  37. llvm::Value *ExceptionMatches(llvm::Value *exc, llvm::Value *exc_type);
  38. LlvmFunctionBuilder *fbuilder_;
  39. LlvmFunctionState *state_;
  40. BuilderT &builder_;
  41. };
  42. }
  43. #endif /* OPCODE_CMPOPS_H_ */