diff options
| author | Andrea Corallo | 2019-07-08 18:33:56 +0200 |
|---|---|---|
| committer | Andrea Corallo | 2020-01-01 11:33:51 +0100 |
| commit | cd55772c8c4fea27b344633dec7ad893cf799036 (patch) | |
| tree | 77b472e5529a609d8b8a82128c4b747cf2a4fb1c /src/comp.c | |
| parent | 3f98a32b7e15fd32da15b5be6fb4ef77a1e43a43 (diff) | |
| download | emacs-cd55772c8c4fea27b344633dec7ad893cf799036.tar.gz emacs-cd55772c8c4fea27b344633dec7ad893cf799036.zip | |
first functional function
Diffstat (limited to 'src/comp.c')
| -rw-r--r-- | src/comp.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/src/comp.c b/src/comp.c index 4f6382304a6..e524e28b143 100644 --- a/src/comp.c +++ b/src/comp.c | |||
| @@ -121,6 +121,7 @@ typedef struct { | |||
| 121 | gcc_jit_function *check_impure; | 121 | gcc_jit_function *check_impure; |
| 122 | Lisp_Object func_blocks; /* blk_name -> gcc_block. */ | 122 | Lisp_Object func_blocks; /* blk_name -> gcc_block. */ |
| 123 | Lisp_Object func_hash; /* f_name -> gcc_func. */ | 123 | Lisp_Object func_hash; /* f_name -> gcc_func. */ |
| 124 | Lisp_Object funcs; /* List of functions defined. */ | ||
| 124 | } comp_t; | 125 | } comp_t; |
| 125 | 126 | ||
| 126 | static comp_t comp; | 127 | static comp_t comp; |
| @@ -1686,6 +1687,7 @@ DEFUN ("comp-init-ctxt", Fcomp_init_ctxt, Scomp_init_ctxt, | |||
| 1686 | return Qnil; | 1687 | return Qnil; |
| 1687 | } | 1688 | } |
| 1688 | comp.ctxt = gcc_jit_context_acquire(); | 1689 | comp.ctxt = gcc_jit_context_acquire(); |
| 1690 | comp.funcs = Qnil; | ||
| 1689 | 1691 | ||
| 1690 | if (COMP_DEBUG) | 1692 | if (COMP_DEBUG) |
| 1691 | { | 1693 | { |
| @@ -1907,6 +1909,8 @@ DEFUN ("comp-add-func-to-ctxt", Fcomp_add_func_to_ctxt, Scomp_add_func_to_ctxt, | |||
| 1907 | limple = XCDR (limple); | 1909 | limple = XCDR (limple); |
| 1908 | } | 1910 | } |
| 1909 | 1911 | ||
| 1912 | comp.funcs = Fcons (func, comp.funcs); | ||
| 1913 | |||
| 1910 | return Qt; | 1914 | return Qt; |
| 1911 | } | 1915 | } |
| 1912 | 1916 | ||
| @@ -1933,15 +1937,26 @@ DEFUN ("comp-compile-and-load-ctxt", Fcomp_compile_and_load_ctxt, | |||
| 1933 | GCC_JIT_OUTPUT_KIND_ASSEMBLER, | 1937 | GCC_JIT_OUTPUT_KIND_ASSEMBLER, |
| 1934 | "gcc-ctxt-dump.s"); | 1938 | "gcc-ctxt-dump.s"); |
| 1935 | 1939 | ||
| 1936 | /* FIXME: must iterate all function names. */ | 1940 | while (CONSP (comp.funcs)) |
| 1937 | union Aligned_Lisp_Subr *x = xmalloc (sizeof (union Aligned_Lisp_Subr)); | 1941 | { |
| 1938 | x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; | 1942 | union Aligned_Lisp_Subr *x = xmalloc (sizeof (union Aligned_Lisp_Subr)); |
| 1939 | x->s.function.a0 = gcc_jit_result_get_code(gcc_res, "F666f6f_foo"); | 1943 | Lisp_Object func = XCAR (comp.funcs); |
| 1940 | eassert (x->s.function.a0); | 1944 | Lisp_Object args = (CALLN (Ffuncall, intern ("comp-func-args"), func)); |
| 1941 | x->s.min_args = 0; | 1945 | char *c_name = |
| 1942 | x->s.max_args = 0; | 1946 | (char *) SDATA (CALLN (Ffuncall, |
| 1943 | x->s.symbol_name = "foo"; | 1947 | intern ("comp-func-c-func-name"), |
| 1944 | defsubr(x); | 1948 | func)); |
| 1949 | |||
| 1950 | x->s.header.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS; | ||
| 1951 | x->s.function.a0 = gcc_jit_result_get_code(gcc_res, c_name); | ||
| 1952 | eassert (x->s.function.a0); | ||
| 1953 | x->s.min_args = XFIXNUM (CALLN (Ffuncall, intern ("comp-args-min"), args)); | ||
| 1954 | x->s.max_args = XFIXNUM (CALLN (Ffuncall, intern ("comp-args-min"), args)); | ||
| 1955 | x->s.symbol_name = "foo"; | ||
| 1956 | defsubr(x); | ||
| 1957 | |||
| 1958 | comp.funcs = XCDR (comp.funcs); | ||
| 1959 | } | ||
| 1945 | 1960 | ||
| 1946 | unblock_atimers (&oldset); | 1961 | unblock_atimers (&oldset); |
| 1947 | 1962 | ||