/Include/_llvmfunctionobject.h

http://unladen-swallow.googlecode.com/ · C Header · 58 lines · 25 code · 13 blank · 20 comment · 1 complexity · d527cb4772718d4dadd50e90e400d15c MD5 · raw file

  1. /* _llvmfunction (llvm::Function wrapper) object interface */
  2. #ifndef Py_LLVMFUNCTIONOBJECT_H
  3. #define Py_LLVMFUNCTIONOBJECT_H
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. #ifdef WITH_LLVM
  8. /* We store an _LlvmFunction in the PyCodeObject; these can be created without
  9. changing any Python reference counts, which would show up as reference leaks
  10. in a regrtest.py -R:: run. When the code object's co_llvm attribute is
  11. accessed, the _LlvmFunction is wrapped in a PyLlvmFuntionObject so it can
  12. exposed to Python code.
  13. This is all done to allow us to embed C++ data structures inside C
  14. structures. */
  15. /* Internal wrapper for llvm::Function*s. */
  16. typedef struct _LlvmFunction _LlvmFunction;
  17. /* Really takes an llvm::Function*, and wraps it into a new'ed
  18. _LlvmFunction. */
  19. PyAPI_FUNC(_LlvmFunction *) _LlvmFunction_New(
  20. void *llvm_function);
  21. /* JIT compiles the llvm function. Note that once the function has
  22. been translated to machine code once, it will never be
  23. re-translated even if the underlying IR function changes. */
  24. typedef PyObject *(*PyEvalFrameFunction)(struct _frame *);
  25. PyAPI_FUNC(PyEvalFrameFunction) _LlvmFunction_Jit(
  26. _LlvmFunction *llvm_function);
  27. // Forwards to global_data->Optimize(llvm_function->lf_function, level);
  28. PyAPI_FUNC(int) _LlvmFunction_Optimize(struct PyGlobalLlvmData *global_data,
  29. _LlvmFunction *llvm_function,
  30. int level);
  31. PyAPI_FUNC(void) _LlvmFunction_Dealloc(_LlvmFunction *functionobj);
  32. /*
  33. _llvmfunction exposes an llvm::Function instance to Python code. Only the
  34. compiler can create these, but they also know how to prettyprint
  35. themselves to LLVM assembly.
  36. */
  37. typedef struct PyLlvmFunctionObject PyLlvmFunctionObject;
  38. PyAPI_DATA(PyTypeObject) PyLlvmFunction_Type;
  39. #define PyLlvmFunction_Check(op) (Py_TYPE(op) == &PyLlvmFunction_Type)
  40. PyAPI_DATA(PyObject *) _PyLlvmFunction_FromCodeObject(PyObject *);
  41. #endif /* WITH_LLVM */
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. #endif /* !Py_LLVMFUNCTIONOBJECT_H */