PageRenderTime 22ms CodeModel.GetById 17ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

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