summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Zapata <jorgeluis.zapata@gmail.com>2024-01-07 19:58:14 +0100
committerJorge Zapata <jorgeluis.zapata@gmail.com>2024-03-12 10:03:58 +0100
commit10f69d7c379375bd9f40bb213b033218fb74363d (patch)
tree2b07c1b789c0cfdbc61ccfedee0edf86ef3198f6
parentbdf5269b2af21124da4ff9564e7c73d934f2507d (diff)
Move the orc_program_compile* to orcprogram.[ch]
Part-of: <https://gitlab.freedesktop.org/gstreamer/orc/-/merge_requests/148>
-rw-r--r--orc/orccompiler.c64
-rw-r--r--orc/orccompiler.h1
-rw-r--r--orc/orcprogram.c68
3 files changed, 70 insertions, 63 deletions
diff --git a/orc/orccompiler.c b/orc/orccompiler.c
index 5223c53..d7ad043 100644
--- a/orc/orccompiler.c
+++ b/orc/orccompiler.c
@@ -209,54 +209,6 @@ orc_compiler_allocate_register (OrcCompiler *compiler, int data_reg)
return 0;
}
-/**
- * orc_program_compile:
- * @program: the OrcProgram to compile
- *
- * Compiles an Orc program for the current CPU. If successful,
- * executable code for the program was generated and can be
- * executed.
- *
- * The return value indicates various levels of success or failure.
- * Success can be determined by checking for a true value of the
- * macro ORC_COMPILE_RESULT_IS_SUCCESSFUL() on the return value. This
- * indicates that executable code was generated. If the macro
- * ORC_COMPILE_RESULT_IS_FATAL() on the return value evaluates to
- * true, then there was a syntactical error in the program. If the
- * result is neither successful nor fatal, the program can still be
- * emulated.
- *
- * Returns: an OrcCompileResult
- */
-OrcCompileResult
-orc_program_compile (OrcProgram *program)
-{
- return orc_program_compile_for_target (program, orc_target_get_default ());
-}
-
-/**
- * orc_program_compile_for_target:
- * @program: the OrcProgram to compile
- *
- * Compiles an Orc program for the given target, using the
- * default target flags for that target.
- *
- * Returns: an OrcCompileResult
- */
-OrcCompileResult
-orc_program_compile_for_target (OrcProgram *program, OrcTarget *target)
-{
- unsigned int flags;
-
- if (target) {
- flags = target->get_default_flags ();
- } else {
- flags = 0;
- }
-
- return orc_program_compile_full (program, target, flags);
-}
-
#if defined(HAVE_CODEMEM_VIRTUALALLOC)
static orc_bool
_set_virtual_protect (void * mem, size_t size, int code_protect)
@@ -285,20 +237,9 @@ _set_virtual_protect (void * mem, size_t size, int code_protect)
}
#endif
-/**
- * orc_program_compile_full:
- * @program: the OrcProgram to compile
- *
- * Compiles an Orc program for the given target, using the
- * given target flags.
- *
- * Returns: an OrcCompileResult
- */
OrcCompileResult
-orc_program_compile_full (OrcProgram *program, OrcTarget *target,
- unsigned int flags)
+orc_compiler_compile_program (OrcCompiler *compiler, OrcProgram *program, OrcTarget *target, unsigned int flags)
{
- OrcCompiler *compiler;
int i;
OrcCompileResult result;
const char *error_msg;
@@ -321,9 +262,6 @@ orc_program_compile_full (OrcProgram *program, OrcTarget *target,
program->asm_code = NULL;
}
- compiler = malloc (sizeof(OrcCompiler));
- memset (compiler, 0, sizeof(OrcCompiler));
-
if (program->backup_func) {
program->code_exec = program->backup_func;
} else {
diff --git a/orc/orccompiler.h b/orc/orccompiler.h
index a6c301e..8bda6b2 100644
--- a/orc/orccompiler.h
+++ b/orc/orccompiler.h
@@ -161,6 +161,7 @@ ORC_API void orc_compiler_append_code (OrcCompiler *p, const char *fmt, ...) ORC
#ifdef ORC_ENABLE_UNSTABLE_API
ORC_API int orc_compiler_flag_check (const char *flag);
+ORC_API OrcCompileResult orc_compiler_compile_program (OrcCompiler *compiler, OrcProgram *program, OrcTarget *target, unsigned int flags);
/* FIXME: remove, these were never actually exported as public symbols, so unusable */
extern int _orc_compiler_flag_backup;
diff --git a/orc/orcprogram.c b/orc/orcprogram.c
index 671de4e..b414e8f 100644
--- a/orc/orcprogram.c
+++ b/orc/orcprogram.c
@@ -1283,3 +1283,71 @@ orc_program_has_float (OrcCompiler *compiler)
}
return FALSE;
}
+
+/**
+ * orc_program_compile:
+ * @program: the OrcProgram to compile
+ *
+ * Compiles an Orc program for the current CPU. If successful,
+ * executable code for the program was generated and can be
+ * executed.
+ *
+ * The return value indicates various levels of success or failure.
+ * Success can be determined by checking for a true value of the
+ * macro ORC_COMPILE_RESULT_IS_SUCCESSFUL() on the return value. This
+ * indicates that executable code was generated. If the macro
+ * ORC_COMPILE_RESULT_IS_FATAL() on the return value evaluates to
+ * true, then there was a syntactical error in the program. If the
+ * result is neither successful nor fatal, the program can still be
+ * emulated.
+ *
+ * Returns: an OrcCompileResult
+ */
+OrcCompileResult
+orc_program_compile (OrcProgram *program)
+{
+ return orc_program_compile_for_target (program, orc_target_get_default ());
+}
+
+/**
+ * orc_program_compile_for_target:
+ * @program: the OrcProgram to compile
+ *
+ * Compiles an Orc program for the given target, using the
+ * default target flags for that target.
+ *
+ * Returns: an OrcCompileResult
+ */
+OrcCompileResult
+orc_program_compile_for_target (OrcProgram *program, OrcTarget *target)
+{
+ unsigned int flags;
+
+ if (target) {
+ flags = target->get_default_flags ();
+ } else {
+ flags = 0;
+ }
+
+ return orc_program_compile_full (program, target, flags);
+}
+
+/**
+ * orc_program_compile_full:
+ * @program: the OrcProgram to compile
+ *
+ * Compiles an Orc program for the given target, using the
+ * given target flags.
+ *
+ * Returns: an OrcCompileResult
+ */
+OrcCompileResult
+orc_program_compile_full (OrcProgram *program, OrcTarget *target,
+ unsigned int flags)
+{
+ OrcCompiler *compiler;
+
+ compiler = malloc (sizeof(OrcCompiler));
+ memset (compiler, 0, sizeof(OrcCompiler));
+ return orc_compiler_compile_program (compiler, program, target, flags);
+}