summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Schleef <ds@schleef.org>2012-03-26 10:23:14 -0700
committerDavid Schleef <ds@schleef.org>2012-03-26 10:23:14 -0700
commitf3d0f49ace5ddc564404a6b8d3b23eaeffb3d3cd (patch)
tree53ff49b8b38c30fa1fbc0fb87aaaf810e42315c6
parent2267ce1de252db478c1d6dd516fa3f1740f8304a (diff)
Split headers out of orcprogram.h
-rw-r--r--examples/volscale.c2
-rw-r--r--orc/Makefile.am38
-rw-r--r--orc/orc.c2
-rw-r--r--orc/orc.h7
-rw-r--r--orc/orcbytecode.h282
-rw-r--r--orc/orcbytecodes.h258
-rw-r--r--orc/orccode.h59
-rw-r--r--orc/orccompiler.h171
-rw-r--r--orc/orcconstant.h39
-rw-r--r--orc/orccpu-x86.c2
-rw-r--r--orc/orccpu.h19
-rw-r--r--orc/orcexecutor.h118
-rw-r--r--orc/orcinstruction.h39
-rw-r--r--orc/orcinternal.h34
-rw-r--r--orc/orclimits.h87
-rw-r--r--orc/orcmmx.h13
-rw-r--r--orc/orcopcode.h57
-rw-r--r--orc/orcprogram.h648
-rw-r--r--orc/orcrule.h51
-rw-r--r--orc/orcsse.h13
-rw-r--r--orc/orctarget.h109
-rw-r--r--orc/orcutils.h26
-rw-r--r--orc/orcvariable.h75
-rw-r--r--orc/orcx86insn.c3
24 files changed, 1214 insertions, 938 deletions
diff --git a/examples/volscale.c b/examples/volscale.c
index e0ef2bb..b08da0c 100644
--- a/examples/volscale.c
+++ b/examples/volscale.c
@@ -7,6 +7,8 @@
#define ORC_ENABLE_UNSTABLE_API
#include <orc/orc.h>
+#include <orc/orcmmx.h>
+#include <orc/orcsse.h>
static OrcProgram *p = NULL;
diff --git a/orc/Makefile.am b/orc/Makefile.am
index 436eae0..172b77b 100644
--- a/orc/Makefile.am
+++ b/orc/Makefile.am
@@ -73,24 +73,40 @@ liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-arm.c
endif
pkginclude_HEADERS = \
+ orc-stdint.h \
orc.h \
+ orcarm.h \
+ orcbytecode.h \
+ orcbytecodes.h \
+ orccode.h \
+ orccompiler.h \
+ orcconstant.h \
+ orccpu.h \
+ orccpuinsn.h \
orcdebug.h \
- orcprogram.h \
orcemulateopcodes.h \
+ orcexecutor.h \
orcfunctions.h \
- orcutils.h \
- orcparse.h \
- opcodes.h \
- orconce.h \
- orcsse.h \
+ orcinstruction.h \
+ orcinternal.h \
+ orclimits.h \
orcmmx.h \
orcneon.h \
- orcx86.h \
+ orconce.h \
+ orcopcode.h \
+ orcparse.h \
orcpowerpc.h \
- orcarm.h \
- orcx86insn.h \
- orccpuinsn.h \
- orc-stdint.h
+ orcprogram.h \
+ orcrule.h \
+ orcsse.h \
+ orctarget.h \
+ orcutils.h \
+ orcvariable.h \
+ orcx86.h \
+ orcx86insn.h
+
+noinst_HEADERS = \
+ opcodes.h
noinst_PROGRAMS = generate-emulation generate-bytecode
diff --git a/orc/orc.c b/orc/orc.c
index 8a607c4..49f350f 100644
--- a/orc/orc.c
+++ b/orc/orc.c
@@ -9,6 +9,8 @@
#include <orc/orcdebug.h>
#include <orc/orconce.h>
+#include "orcinternal.h"
+
/**
* SECTION:orc
* @title: Orc
diff --git a/orc/orc.h b/orc/orc.h
index 3f711be..6814937 100644
--- a/orc/orc.h
+++ b/orc/orc.h
@@ -3,18 +3,13 @@
#define _ORC_ORC_H_
#include <orc/orcprogram.h>
-#include <orc/orc-stdint.h>
-#include <orc/orcarm.h>
#include <orc/orcdebug.h>
#include <orc/orcfunctions.h>
-#include <orc/orcmmx.h>
#include <orc/orconce.h>
#include <orc/orcparse.h>
#include <orc/orcprogram.h>
-#include <orc/orcsse.h>
#include <orc/orcutils.h>
-#include <orc/orcx86.h>
-#include <orc/orcpowerpc.h>
+#include <orc/orccpu.h>
#endif
diff --git a/orc/orcbytecode.h b/orc/orcbytecode.h
index c71f57b..6dfd6de 100644
--- a/orc/orcbytecode.h
+++ b/orc/orcbytecode.h
@@ -1,258 +1,32 @@
-/* autogenerated by generate-bytecode */
+#ifndef _ORC_BYTECODE_H_
+#define _ORC_BYTECODE_H_
+
+#include <orc/orcutils.h>
+#include <orc/orcbytecodes.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcBytecode OrcBytecode;
+
+struct _OrcBytecode {
+ /*< private >*/
+ orc_uint8 *bytecode;
+ int length;
+ int alloc_len;
+};
+
+
+#ifdef ORC_ENABLE_UNSTABLE_API
+
+OrcBytecode * orc_bytecode_new (void);
+void orc_bytecode_free (OrcBytecode *bytecode);
+OrcBytecode * orc_bytecode_from_program (OrcProgram *p);
+int orc_bytecode_parse_function (OrcProgram *program, const orc_uint8 *bytecode);
+
+#endif
+
+ORC_END_DECLS
-#ifdef HAVE_CONFIG_H
-#include "config.h"
#endif
-#include <math.h>
-#include <orc/orc.h>
-typedef enum {
- ORC_BC_END,
- ORC_BC_BEGIN_FUNCTION,
- ORC_BC_END_FUNCTION,
- ORC_BC_SET_CONSTANT_N,
- ORC_BC_SET_N_MULTIPLE,
- ORC_BC_SET_N_MINIMUM,
- ORC_BC_SET_N_MAXIMUM,
- ORC_BC_SET_2D,
- ORC_BC_SET_CONSTANT_M,
- ORC_BC_SET_NAME,
- ORC_BC_SET_BACKUP_FUNCTION,
- ORC_BC_ADD_DESTINATION,
- ORC_BC_ADD_SOURCE,
- ORC_BC_ADD_ACCUMULATOR,
- ORC_BC_ADD_CONSTANT,
- ORC_BC_ADD_CONSTANT_INT64,
- ORC_BC_ADD_PARAMETER,
- ORC_BC_ADD_PARAMETER_FLOAT,
- ORC_BC_ADD_PARAMETER_INT64,
- ORC_BC_ADD_PARAMETER_DOUBLE,
- ORC_BC_ADD_TEMPORARY,
- ORC_BC_INSTRUCTION_FLAGS,
- ORC_BC_RESERVED_22,
- ORC_BC_RESERVED_23,
- ORC_BC_RESERVED_24,
- ORC_BC_RESERVED_25,
- ORC_BC_RESERVED_26,
- ORC_BC_RESERVED_27,
- ORC_BC_RESERVED_28,
- ORC_BC_RESERVED_29,
- ORC_BC_RESERVED_30,
- ORC_BC_RESERVED_31,
- ORC_BC_absb,
- ORC_BC_addb,
- ORC_BC_addssb,
- ORC_BC_addusb,
- ORC_BC_andb,
- ORC_BC_andnb,
- ORC_BC_avgsb,
- ORC_BC_avgub,
- /* 40 */
- ORC_BC_cmpeqb,
- ORC_BC_cmpgtsb,
- ORC_BC_copyb,
- ORC_BC_loadb,
- ORC_BC_loadoffb,
- ORC_BC_loadupdb,
- ORC_BC_loadupib,
- ORC_BC_loadpb,
- ORC_BC_ldresnearb,
- ORC_BC_ldresnearl,
- /* 50 */
- ORC_BC_ldreslinb,
- ORC_BC_ldreslinl,
- ORC_BC_maxsb,
- ORC_BC_maxub,
- ORC_BC_minsb,
- ORC_BC_minub,
- ORC_BC_mullb,
- ORC_BC_mulhsb,
- ORC_BC_mulhub,
- ORC_BC_orb,
- /* 60 */
- ORC_BC_shlb,
- ORC_BC_shrsb,
- ORC_BC_shrub,
- ORC_BC_signb,
- ORC_BC_storeb,
- ORC_BC_subb,
- ORC_BC_subssb,
- ORC_BC_subusb,
- ORC_BC_xorb,
- ORC_BC_absw,
- /* 70 */
- ORC_BC_addw,
- ORC_BC_addssw,
- ORC_BC_addusw,
- ORC_BC_andw,
- ORC_BC_andnw,
- ORC_BC_avgsw,
- ORC_BC_avguw,
- ORC_BC_cmpeqw,
- ORC_BC_cmpgtsw,
- ORC_BC_copyw,
- /* 80 */
- ORC_BC_div255w,
- ORC_BC_divluw,
- ORC_BC_loadw,
- ORC_BC_loadoffw,
- ORC_BC_loadpw,
- ORC_BC_maxsw,
- ORC_BC_maxuw,
- ORC_BC_minsw,
- ORC_BC_minuw,
- ORC_BC_mullw,
- /* 90 */
- ORC_BC_mulhsw,
- ORC_BC_mulhuw,
- ORC_BC_orw,
- ORC_BC_shlw,
- ORC_BC_shrsw,
- ORC_BC_shruw,
- ORC_BC_signw,
- ORC_BC_storew,
- ORC_BC_subw,
- ORC_BC_subssw,
- /* 100 */
- ORC_BC_subusw,
- ORC_BC_xorw,
- ORC_BC_absl,
- ORC_BC_addl,
- ORC_BC_addssl,
- ORC_BC_addusl,
- ORC_BC_andl,
- ORC_BC_andnl,
- ORC_BC_avgsl,
- ORC_BC_avgul,
- /* 110 */
- ORC_BC_cmpeql,
- ORC_BC_cmpgtsl,
- ORC_BC_copyl,
- ORC_BC_loadl,
- ORC_BC_loadoffl,
- ORC_BC_loadpl,
- ORC_BC_maxsl,
- ORC_BC_maxul,
- ORC_BC_minsl,
- ORC_BC_minul,
- /* 120 */
- ORC_BC_mulll,
- ORC_BC_mulhsl,
- ORC_BC_mulhul,
- ORC_BC_orl,
- ORC_BC_shll,
- ORC_BC_shrsl,
- ORC_BC_shrul,
- ORC_BC_signl,
- ORC_BC_storel,
- ORC_BC_subl,
- /* 130 */
- ORC_BC_subssl,
- ORC_BC_subusl,
- ORC_BC_xorl,
- ORC_BC_loadq,
- ORC_BC_loadpq,
- ORC_BC_storeq,
- ORC_BC_splatw3q,
- ORC_BC_copyq,
- ORC_BC_cmpeqq,
- ORC_BC_cmpgtsq,
- /* 140 */
- ORC_BC_andq,
- ORC_BC_andnq,
- ORC_BC_orq,
- ORC_BC_xorq,
- ORC_BC_addq,
- ORC_BC_subq,
- ORC_BC_shlq,
- ORC_BC_shrsq,
- ORC_BC_shruq,
- ORC_BC_convsbw,
- /* 150 */
- ORC_BC_convubw,
- ORC_BC_splatbw,
- ORC_BC_splatbl,
- ORC_BC_convswl,
- ORC_BC_convuwl,
- ORC_BC_convslq,
- ORC_BC_convulq,
- ORC_BC_convwb,
- ORC_BC_convhwb,
- ORC_BC_convssswb,
- /* 160 */
- ORC_BC_convsuswb,
- ORC_BC_convusswb,
- ORC_BC_convuuswb,
- ORC_BC_convlw,
- ORC_BC_convhlw,
- ORC_BC_convssslw,
- ORC_BC_convsuslw,
- ORC_BC_convusslw,
- ORC_BC_convuuslw,
- ORC_BC_convql,
- /* 170 */
- ORC_BC_convsssql,
- ORC_BC_convsusql,
- ORC_BC_convussql,
- ORC_BC_convuusql,
- ORC_BC_mulsbw,
- ORC_BC_mulubw,
- ORC_BC_mulswl,
- ORC_BC_muluwl,
- ORC_BC_mulslq,
- ORC_BC_mululq,
- /* 180 */
- ORC_BC_accw,
- ORC_BC_accl,
- ORC_BC_accsadubl,
- ORC_BC_swapw,
- ORC_BC_swapl,
- ORC_BC_swapwl,
- ORC_BC_swapq,
- ORC_BC_swaplq,
- ORC_BC_select0wb,
- ORC_BC_select1wb,
- /* 190 */
- ORC_BC_select0lw,
- ORC_BC_select1lw,
- ORC_BC_select0ql,
- ORC_BC_select1ql,
- ORC_BC_mergelq,
- ORC_BC_mergewl,
- ORC_BC_mergebw,
- ORC_BC_splitql,
- ORC_BC_splitlw,
- ORC_BC_splitwb,
- /* 200 */
- ORC_BC_addf,
- ORC_BC_subf,
- ORC_BC_mulf,
- ORC_BC_divf,
- ORC_BC_sqrtf,
- ORC_BC_maxf,
- ORC_BC_minf,
- ORC_BC_cmpeqf,
- ORC_BC_cmpltf,
- ORC_BC_cmplef,
- /* 210 */
- ORC_BC_convfl,
- ORC_BC_convlf,
- ORC_BC_addd,
- ORC_BC_subd,
- ORC_BC_muld,
- ORC_BC_divd,
- ORC_BC_sqrtd,
- ORC_BC_maxd,
- ORC_BC_mind,
- ORC_BC_cmpeqd,
- /* 220 */
- ORC_BC_cmpltd,
- ORC_BC_cmpled,
- ORC_BC_convdl,
- ORC_BC_convld,
- ORC_BC_convfd,
- ORC_BC_convdf,
- /* 226 */
- ORC_BC_LAST
-} OrcBytecodes;
diff --git a/orc/orcbytecodes.h b/orc/orcbytecodes.h
new file mode 100644
index 0000000..c71f57b
--- /dev/null
+++ b/orc/orcbytecodes.h
@@ -0,0 +1,258 @@
+
+/* autogenerated by generate-bytecode */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include <math.h>
+#include <orc/orc.h>
+
+typedef enum {
+ ORC_BC_END,
+ ORC_BC_BEGIN_FUNCTION,
+ ORC_BC_END_FUNCTION,
+ ORC_BC_SET_CONSTANT_N,
+ ORC_BC_SET_N_MULTIPLE,
+ ORC_BC_SET_N_MINIMUM,
+ ORC_BC_SET_N_MAXIMUM,
+ ORC_BC_SET_2D,
+ ORC_BC_SET_CONSTANT_M,
+ ORC_BC_SET_NAME,
+ ORC_BC_SET_BACKUP_FUNCTION,
+ ORC_BC_ADD_DESTINATION,
+ ORC_BC_ADD_SOURCE,
+ ORC_BC_ADD_ACCUMULATOR,
+ ORC_BC_ADD_CONSTANT,
+ ORC_BC_ADD_CONSTANT_INT64,
+ ORC_BC_ADD_PARAMETER,
+ ORC_BC_ADD_PARAMETER_FLOAT,
+ ORC_BC_ADD_PARAMETER_INT64,
+ ORC_BC_ADD_PARAMETER_DOUBLE,
+ ORC_BC_ADD_TEMPORARY,
+ ORC_BC_INSTRUCTION_FLAGS,
+ ORC_BC_RESERVED_22,
+ ORC_BC_RESERVED_23,
+ ORC_BC_RESERVED_24,
+ ORC_BC_RESERVED_25,
+ ORC_BC_RESERVED_26,
+ ORC_BC_RESERVED_27,
+ ORC_BC_RESERVED_28,
+ ORC_BC_RESERVED_29,
+ ORC_BC_RESERVED_30,
+ ORC_BC_RESERVED_31,
+ ORC_BC_absb,
+ ORC_BC_addb,
+ ORC_BC_addssb,
+ ORC_BC_addusb,
+ ORC_BC_andb,
+ ORC_BC_andnb,
+ ORC_BC_avgsb,
+ ORC_BC_avgub,
+ /* 40 */
+ ORC_BC_cmpeqb,
+ ORC_BC_cmpgtsb,
+ ORC_BC_copyb,
+ ORC_BC_loadb,
+ ORC_BC_loadoffb,
+ ORC_BC_loadupdb,
+ ORC_BC_loadupib,
+ ORC_BC_loadpb,
+ ORC_BC_ldresnearb,
+ ORC_BC_ldresnearl,
+ /* 50 */
+ ORC_BC_ldreslinb,
+ ORC_BC_ldreslinl,
+ ORC_BC_maxsb,
+ ORC_BC_maxub,
+ ORC_BC_minsb,
+ ORC_BC_minub,
+ ORC_BC_mullb,
+ ORC_BC_mulhsb,
+ ORC_BC_mulhub,
+ ORC_BC_orb,
+ /* 60 */
+ ORC_BC_shlb,
+ ORC_BC_shrsb,
+ ORC_BC_shrub,
+ ORC_BC_signb,
+ ORC_BC_storeb,
+ ORC_BC_subb,
+ ORC_BC_subssb,
+ ORC_BC_subusb,
+ ORC_BC_xorb,
+ ORC_BC_absw,
+ /* 70 */
+ ORC_BC_addw,
+ ORC_BC_addssw,
+ ORC_BC_addusw,
+ ORC_BC_andw,
+ ORC_BC_andnw,
+ ORC_BC_avgsw,
+ ORC_BC_avguw,
+ ORC_BC_cmpeqw,
+ ORC_BC_cmpgtsw,
+ ORC_BC_copyw,
+ /* 80 */
+ ORC_BC_div255w,
+ ORC_BC_divluw,
+ ORC_BC_loadw,
+ ORC_BC_loadoffw,
+ ORC_BC_loadpw,
+ ORC_BC_maxsw,
+ ORC_BC_maxuw,
+ ORC_BC_minsw,
+ ORC_BC_minuw,
+ ORC_BC_mullw,
+ /* 90 */
+ ORC_BC_mulhsw,
+ ORC_BC_mulhuw,
+ ORC_BC_orw,
+ ORC_BC_shlw,
+ ORC_BC_shrsw,
+ ORC_BC_shruw,
+ ORC_BC_signw,
+ ORC_BC_storew,
+ ORC_BC_subw,
+ ORC_BC_subssw,
+ /* 100 */
+ ORC_BC_subusw,
+ ORC_BC_xorw,
+ ORC_BC_absl,
+ ORC_BC_addl,
+ ORC_BC_addssl,
+ ORC_BC_addusl,
+ ORC_BC_andl,
+ ORC_BC_andnl,
+ ORC_BC_avgsl,
+ ORC_BC_avgul,
+ /* 110 */
+ ORC_BC_cmpeql,
+ ORC_BC_cmpgtsl,
+ ORC_BC_copyl,
+ ORC_BC_loadl,
+ ORC_BC_loadoffl,
+ ORC_BC_loadpl,
+ ORC_BC_maxsl,
+ ORC_BC_maxul,
+ ORC_BC_minsl,
+ ORC_BC_minul,
+ /* 120 */
+ ORC_BC_mulll,
+ ORC_BC_mulhsl,
+ ORC_BC_mulhul,
+ ORC_BC_orl,
+ ORC_BC_shll,
+ ORC_BC_shrsl,
+ ORC_BC_shrul,
+ ORC_BC_signl,
+ ORC_BC_storel,
+ ORC_BC_subl,
+ /* 130 */
+ ORC_BC_subssl,
+ ORC_BC_subusl,
+ ORC_BC_xorl,
+ ORC_BC_loadq,
+ ORC_BC_loadpq,
+ ORC_BC_storeq,
+ ORC_BC_splatw3q,
+ ORC_BC_copyq,
+ ORC_BC_cmpeqq,
+ ORC_BC_cmpgtsq,
+ /* 140 */
+ ORC_BC_andq,
+ ORC_BC_andnq,
+ ORC_BC_orq,
+ ORC_BC_xorq,
+ ORC_BC_addq,
+ ORC_BC_subq,
+ ORC_BC_shlq,
+ ORC_BC_shrsq,
+ ORC_BC_shruq,
+ ORC_BC_convsbw,
+ /* 150 */
+ ORC_BC_convubw,
+ ORC_BC_splatbw,
+ ORC_BC_splatbl,
+ ORC_BC_convswl,
+ ORC_BC_convuwl,
+ ORC_BC_convslq,
+ ORC_BC_convulq,
+ ORC_BC_convwb,
+ ORC_BC_convhwb,
+ ORC_BC_convssswb,
+ /* 160 */
+ ORC_BC_convsuswb,
+ ORC_BC_convusswb,
+ ORC_BC_convuuswb,
+ ORC_BC_convlw,
+ ORC_BC_convhlw,
+ ORC_BC_convssslw,
+ ORC_BC_convsuslw,
+ ORC_BC_convusslw,
+ ORC_BC_convuuslw,
+ ORC_BC_convql,
+ /* 170 */
+ ORC_BC_convsssql,
+ ORC_BC_convsusql,
+ ORC_BC_convussql,
+ ORC_BC_convuusql,
+ ORC_BC_mulsbw,
+ ORC_BC_mulubw,
+ ORC_BC_mulswl,
+ ORC_BC_muluwl,
+ ORC_BC_mulslq,
+ ORC_BC_mululq,
+ /* 180 */
+ ORC_BC_accw,
+ ORC_BC_accl,
+ ORC_BC_accsadubl,
+ ORC_BC_swapw,
+ ORC_BC_swapl,
+ ORC_BC_swapwl,
+ ORC_BC_swapq,
+ ORC_BC_swaplq,
+ ORC_BC_select0wb,
+ ORC_BC_select1wb,
+ /* 190 */
+ ORC_BC_select0lw,
+ ORC_BC_select1lw,
+ ORC_BC_select0ql,
+ ORC_BC_select1ql,
+ ORC_BC_mergelq,
+ ORC_BC_mergewl,
+ ORC_BC_mergebw,
+ ORC_BC_splitql,
+ ORC_BC_splitlw,
+ ORC_BC_splitwb,
+ /* 200 */
+ ORC_BC_addf,
+ ORC_BC_subf,
+ ORC_BC_mulf,
+ ORC_BC_divf,
+ ORC_BC_sqrtf,
+ ORC_BC_maxf,
+ ORC_BC_minf,
+ ORC_BC_cmpeqf,
+ ORC_BC_cmpltf,
+ ORC_BC_cmplef,
+ /* 210 */
+ ORC_BC_convfl,
+ ORC_BC_convlf,
+ ORC_BC_addd,
+ ORC_BC_subd,
+ ORC_BC_muld,
+ ORC_BC_divd,
+ ORC_BC_sqrtd,
+ ORC_BC_maxd,
+ ORC_BC_mind,
+ ORC_BC_cmpeqd,
+ /* 220 */
+ ORC_BC_cmpltd,
+ ORC_BC_cmpled,
+ ORC_BC_convdl,
+ ORC_BC_convld,
+ ORC_BC_convfd,
+ ORC_BC_convdf,
+ /* 226 */
+ ORC_BC_LAST
+} OrcBytecodes;
diff --git a/orc/orccode.h b/orc/orccode.h
new file mode 100644
index 0000000..08775e0
--- /dev/null
+++ b/orc/orccode.h
@@ -0,0 +1,59 @@
+
+#ifndef _ORC_CODE_H_
+#define _ORC_CODE_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+#include <orc/orcexecutor.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcCodeChunk OrcCodeChunk;
+typedef struct _OrcCodeVariable OrcCodeVariable;
+
+
+struct _OrcCodeVariable {
+ /*< private >*/
+ int vartype;
+ int size;
+ orc_union64 value;
+};
+
+struct _OrcCode {
+ /*< public >*/
+ OrcExecutorFunc exec;
+
+ /*< private >*/
+ OrcCompileResult result;
+ char *name;
+
+ /* for execution */
+ unsigned char *code;
+ int code_size;
+ void *chunk;
+
+ /* for emulation */
+ int n_insns;
+ OrcInstruction *insns;
+ OrcCodeVariable *vars;
+ int is_2d;
+ int constant_n;
+ int constant_m;
+};
+
+
+void orc_code_allocate_codemem (OrcCode *code, int size);
+
+OrcCode * orc_code_new (void);
+void orc_code_free (OrcCode *code);
+
+#ifdef ORC_ENABLE_UNSTABLE_API
+
+void orc_code_chunk_free (OrcCodeChunk *chunk);
+
+#endif
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orccompiler.h b/orc/orccompiler.h
new file mode 100644
index 0000000..a19562e
--- /dev/null
+++ b/orc/orccompiler.h
@@ -0,0 +1,171 @@
+
+#ifndef _ORC_COMPILER_H_
+#define _ORC_COMPILER_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+#include <orc/orcexecutor.h>
+#include <orc/orccode.h>
+#include <orc/orctarget.h>
+#include <orc/orcinstruction.h>
+#include <orc/orcvariable.h>
+#include <orc/orcconstant.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcCompiler OrcCompiler;
+typedef struct _OrcFixup OrcFixup;
+
+
+#define ORC_ENABLE_ASM_CODE
+#ifdef ORC_ENABLE_ASM_CODE
+#define ORC_ASM_CODE(compiler,...) orc_compiler_append_code(compiler, __VA_ARGS__)
+#else
+#define ORC_ASM_CODE(compiler,...)
+#endif
+
+
+#define ORC_COMPILER_ERROR(compiler, ...) do { \
+ compiler->error = TRUE; \
+ compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE; \
+ orc_debug_print(ORC_DEBUG_WARNING, __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \
+} while (0)
+
+#if 0
+/* FIXME in orcutils.h since it's needed in orccode.h */
+typedef enum {
+ ORC_COMPILE_RESULT_OK = 0,
+
+ ORC_COMPILE_RESULT_UNKNOWN_COMPILE = 0x100,
+ ORC_COMPILE_RESULT_MISSING_RULE = 0x101,
+
+ ORC_COMPILE_RESULT_UNKNOWN_PARSE = 0x200,
+ ORC_COMPILE_RESULT_PARSE = 0x201,
+ ORC_COMPILE_RESULT_VARIABLE = 0x202
+
+} OrcCompileResult;
+#endif
+
+#define ORC_COMPILE_RESULT_IS_SUCCESSFUL(x) ((x) < 0x100)
+#define ORC_COMPILE_RESULT_IS_FATAL(x) ((x) >= 0x200)
+
+/**
+ * OrcFixup:
+ *
+ * The OrcFixup structure has no public members
+ */
+struct _OrcFixup {
+ /*< private >*/
+ unsigned char *ptr;
+ int type;
+ int label;
+};
+
+/**
+ * OrcCompiler:
+ *
+ * The OrcCompiler structure has no public members
+ */
+struct _OrcCompiler {
+ /*< private >*/
+ OrcProgram *program;
+ OrcTarget *target;
+
+ unsigned int target_flags;
+
+ OrcInstruction insns[ORC_N_INSNS];
+ int n_insns;
+
+ OrcVariable vars[ORC_N_COMPILER_VARIABLES];
+ int n_temp_vars;
+ int n_dup_vars;
+
+ unsigned char *code;
+ unsigned char *codeptr;
+
+ OrcConstant constants[ORC_N_CONSTANTS];
+ int n_constants;
+
+ OrcFixup fixups[ORC_N_FIXUPS];
+ int n_fixups;
+ unsigned char *labels[ORC_N_LABELS];
+ int labels_int[ORC_N_LABELS];
+ int n_labels;
+
+ int error;
+ char *error_msg;
+ OrcCompileResult result;
+
+ int valid_regs[ORC_N_REGS];
+ int save_regs[ORC_N_REGS];
+ int used_regs[ORC_N_REGS];
+ int alloc_regs[ORC_N_REGS];
+
+ int loop_shift;
+ int long_jumps;
+ int use_frame_pointer;
+
+ char *asm_code;
+ int asm_code_len;
+
+ int is_64bit;
+ int tmpreg;
+ int tmpreg2;
+ int exec_reg;
+ int gp_tmpreg;
+
+ int insn_index;
+ int unroll_index;
+ int need_mask_regs;
+ int unroll_shift;
+
+ int alloc_loop_counter;
+ int allow_gp_on_stack;
+ int loop_counter;
+ int size_region;
+ int has_iterator_opcode;
+
+ int offset;
+ int min_temp_reg;
+ int max_used_temp_reg;
+
+ int insn_shift; /* used when emitting rules */
+ int max_var_size; /* size of largest var */
+ int load_params;
+
+ void *output_insns;
+ int n_output_insns;
+ int n_output_insns_alloc;
+};
+
+
+void orc_code_allocate_codemem (OrcCode *code, int size);
+int orc_compiler_label_new (OrcCompiler *compiler);
+int orc_compiler_get_constant (OrcCompiler *compiler, int size, int value);
+int orc_compiler_get_constant_long (OrcCompiler *compiler, orc_uint32 a,
+ orc_uint32 b, orc_uint32 c, orc_uint32 d);
+int orc_compiler_try_get_constant_long (OrcCompiler *compiler, orc_uint32 a,
+ orc_uint32 b, orc_uint32 c, orc_uint32 d);
+int orc_compiler_get_temp_constant (OrcCompiler *compiler, int size, int value);
+int orc_compiler_get_temp_reg (OrcCompiler *compiler);
+int orc_compiler_get_constant_reg (OrcCompiler *compiler);
+void orc_compiler_error (OrcCompiler *compiler, const char *fmt, ...);
+
+void orc_compiler_append_code (OrcCompiler *p, const char *fmt, ...)
+ ORC_GNU_PRINTF(2,3);
+
+#ifdef ORC_ENABLE_UNSTABLE_API
+
+int orc_compiler_flag_check (const char *flag);
+
+extern int _orc_compiler_flag_backup;
+extern int _orc_compiler_flag_emulate;
+extern int _orc_compiler_flag_debug;
+extern int _orc_compiler_flag_randomize;
+
+#endif
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcconstant.h b/orc/orcconstant.h
new file mode 100644
index 0000000..adfc2d8
--- /dev/null
+++ b/orc/orcconstant.h
@@ -0,0 +1,39 @@
+
+#ifndef _ORC_CONSTANT_H_
+#define _ORC_CONSTANT_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcConstant OrcConstant;
+
+enum {
+ ORC_CONST_ZERO,
+ ORC_CONST_SPLAT_B,
+ ORC_CONST_SPLAT_W,
+ ORC_CONST_SPLAT_L,
+ ORC_CONST_FULL
+};
+
+/**
+ * OrcConstant:
+ *
+ * The OrcConstant structure has no public members
+ */
+struct _OrcConstant {
+ /*< private >*/
+ int type;
+ int alloc_reg;
+ unsigned int value;
+ unsigned int full_value[4];
+ int use_count;
+ int is_long;
+};
+
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orccpu-x86.c b/orc/orccpu-x86.c
index 2fdd29a..813dbc8 100644
--- a/orc/orccpu-x86.c
+++ b/orc/orccpu-x86.c
@@ -34,6 +34,8 @@
#include <orc/orcprogram.h>
#include <orc/orcutils.h>
+#include "orcinternal.h"
+
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
diff --git a/orc/orccpu.h b/orc/orccpu.h
new file mode 100644
index 0000000..7ab4355
--- /dev/null
+++ b/orc/orccpu.h
@@ -0,0 +1,19 @@
+
+#ifndef _ORC_CPU_H_
+#define _ORC_CPU_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+
+ORC_BEGIN_DECLS
+
+
+void orc_get_data_cache_sizes (int *level1, int *level2, int *level3);
+void orc_get_cpu_family_model_stepping (int *family, int *model, int *stepping);
+const char * orc_get_cpu_name (void);
+
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcexecutor.h b/orc/orcexecutor.h
new file mode 100644
index 0000000..0f901d6
--- /dev/null
+++ b/orc/orcexecutor.h
@@ -0,0 +1,118 @@
+
+#ifndef _ORC_EXECUTOR_H_
+#define _ORC_EXECUTOR_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+
+ORC_BEGIN_DECLS
+
+
+
+typedef struct _OrcOpcodeExecutor OrcOpcodeExecutor;
+typedef struct _OrcExecutor OrcExecutor;
+typedef struct _OrcExecutorAlt OrcExecutorAlt;
+
+typedef void (*OrcOpcodeEmulateFunc)(OrcOpcodeExecutor *ex, void *user);
+typedef void (*OrcOpcodeEmulateNFunc)(OrcOpcodeExecutor *ex, int index, int n);
+typedef void (*OrcOpcodeEmulate16Func)(OrcOpcodeExecutor *ex);
+typedef void (*OrcExecutorFunc)(OrcExecutor *ex);
+
+/**
+ * OrcOpcodeExecutor:
+ *
+ * The OrcOpcodeExecutor structure has no public members
+ */
+struct _OrcOpcodeExecutor {
+ /*< private >*/
+ int src_values[ORC_STATIC_OPCODE_N_SRC];
+ int dest_values[ORC_STATIC_OPCODE_N_DEST];
+
+ OrcOpcodeEmulateNFunc emulateN;
+
+ void *src_ptrs[ORC_STATIC_OPCODE_N_SRC];
+ void *dest_ptrs[ORC_STATIC_OPCODE_N_DEST];
+ int shift;
+};
+
+/**
+ * OrcExecutor:
+ *
+ */
+struct _OrcExecutor {
+ /*< private >*/
+ OrcProgram *program;
+ int n;
+ int counter1;
+ int counter2;
+ int counter3;
+
+ void *arrays[ORC_N_VARIABLES];
+ int params[ORC_N_VARIABLES];
+ int accumulators[4];
+ /* exec pointer is stored in arrays[ORC_VAR_A1] */
+ /* OrcCode pointer is stored in arrays[ORC_VAR_A2] */
+ /* row pointers are stored in arrays[i+ORC_VAR_C1] */
+ /* the stride for arrays[x] is stored in params[x] */
+ /* m is stored in params[ORC_VAR_A1] */
+ /* m_index is stored in params[ORC_VAR_A2] */
+ /* elapsed time is stored in params[ORC_VAR_A3] */
+ /* high half of params is stored in params[ORC_VAR_T1..] */
+};
+
+/* the alternate view of OrcExecutor */
+struct _OrcExecutorAlt {
+ /*< private >*/
+ OrcProgram *program;
+ int n;
+ int counter1;
+ int counter2;
+ int counter3;
+
+ void *arrays[ORC_N_ARRAYS];
+ OrcExecutorFunc exec;
+ OrcCode *code;
+ void *unused1[ORC_N_VARIABLES - ORC_N_ARRAYS - 2];
+ int strides[ORC_N_ARRAYS];
+ int m;
+ int m_index;
+ int time;
+ int unused2;
+ int unused4[8];
+ int params[ORC_VAR_T1-ORC_VAR_P1];
+ int params_hi[ORC_VAR_T1-ORC_VAR_P1];
+ int unused3[ORC_N_VARIABLES - ORC_VAR_T9];
+ int accumulators[4];
+};
+#define ORC_EXECUTOR_EXEC(ex) ((OrcExecutorFunc)((ex)->arrays[ORC_VAR_A1]))
+#define ORC_EXECUTOR_M(ex) ((ex)->params[ORC_VAR_A1])
+#define ORC_EXECUTOR_M_INDEX(ex) ((ex)->params[ORC_VAR_A2])
+#define ORC_EXECUTOR_TIME(ex) ((ex)->params[ORC_VAR_A3])
+
+
+
+
+OrcExecutor * orc_executor_new (OrcProgram *program);
+void orc_executor_free (OrcExecutor *ex);
+void orc_executor_set_program (OrcExecutor *ex, OrcProgram *program);
+void orc_executor_set_array (OrcExecutor *ex, int var, void *ptr);
+void orc_executor_set_stride (OrcExecutor *ex, int var, int stride);
+void orc_executor_set_array_str (OrcExecutor *ex, const char *name, void *ptr);
+void orc_executor_set_param (OrcExecutor *ex, int var, int value);
+void orc_executor_set_param_str (OrcExecutor *ex, const char *name, int value);
+void orc_executor_set_param_float (OrcExecutor *ex, int var, float value);
+void orc_executor_set_param_int64 (OrcExecutor *ex, int var, orc_int64 value);
+void orc_executor_set_param_double (OrcExecutor *ex, int var, double value);
+int orc_executor_get_accumulator (OrcExecutor *ex, int var);
+int orc_executor_get_accumulator_str (OrcExecutor *ex, const char *name);
+void orc_executor_set_n (OrcExecutor *ex, int n);
+void orc_executor_set_m (OrcExecutor *ex, int m);
+void orc_executor_emulate (OrcExecutor *ex);
+void orc_executor_run (OrcExecutor *ex);
+void orc_executor_run_backup (OrcExecutor *ex);
+
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcinstruction.h b/orc/orcinstruction.h
new file mode 100644
index 0000000..fe8bef5
--- /dev/null
+++ b/orc/orcinstruction.h
@@ -0,0 +1,39 @@
+
+#ifndef _ORC_INSTRUCTION_H_
+#define _ORC_INSTRUCTION_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+#include <orc/orcopcode.h>
+#include <orc/orcrule.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcInstruction OrcInstruction;
+
+/**
+ * OrcInstruction:
+ *
+ * The OrcInstruction structure has no public members
+ */
+struct _OrcInstruction {
+ /*< private >*/
+ OrcStaticOpcode *opcode;
+ int dest_args[ORC_STATIC_OPCODE_N_DEST];
+ int src_args[ORC_STATIC_OPCODE_N_SRC];
+
+ OrcRule *rule;
+ unsigned int flags;
+};
+
+#define ORC_INSTRUCTION_FLAG_X2 (1<<0)
+#define ORC_INSTRUCTION_FLAG_X4 (1<<1)
+
+#define ORC_INSN_FLAG_INVARIANT (1<<2)
+#define ORC_INSN_FLAG_ADDED (1<<3)
+
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcinternal.h b/orc/orcinternal.h
new file mode 100644
index 0000000..2eb390f
--- /dev/null
+++ b/orc/orcinternal.h
@@ -0,0 +1,34 @@
+
+#ifndef _ORC_INTERNAL_H_
+#define _ORC_INTERNAL_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+
+ORC_BEGIN_DECLS
+
+#ifdef ORC_ENABLE_UNSTABLE_API
+
+void orc_mmx_init (void);
+void orc_sse_init (void);
+void orc_arm_init (void);
+void orc_powerpc_init (void);
+void orc_c_init (void);
+void orc_neon_init (void);
+void orc_c64x_init (void);
+void orc_c64x_c_init (void);
+
+extern int _orc_data_cache_size_level1;
+extern int _orc_data_cache_size_level2;
+extern int _orc_data_cache_size_level3;
+extern int _orc_cpu_family;
+extern int _orc_cpu_model;
+extern int _orc_cpu_stepping;
+extern const char *_orc_cpu_name;
+
+#endif
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orclimits.h b/orc/orclimits.h
new file mode 100644
index 0000000..ebb9828
--- /dev/null
+++ b/orc/orclimits.h
@@ -0,0 +1,87 @@
+
+#ifndef _ORC_LIMITS_H_
+#define _ORC_LIMITS_H_
+
+#include <orc/orcutils.h>
+
+ORC_BEGIN_DECLS
+
+#define ORC_N_REGS (32*4)
+#define ORC_N_INSNS 100
+#define ORC_N_VARIABLES 64
+#define ORC_N_ARRAYS 12
+#define ORC_N_REGISTERS 20
+#define ORC_N_FIXUPS 100
+#define ORC_N_CONSTANTS 20
+#define ORC_N_LABELS 40
+#define ORC_N_COMPILER_VARIABLES (ORC_N_VARIABLES+32)
+
+#define ORC_GP_REG_BASE 32
+#define ORC_VEC_REG_BASE 64
+#define ORC_REG_INVALID 0
+
+#define ORC_STATIC_OPCODE_N_SRC 4
+#define ORC_STATIC_OPCODE_N_DEST 2
+
+#define ORC_OPCODE_N_ARGS 4
+#define ORC_N_TARGETS 10
+#define ORC_N_RULE_SETS 10
+
+#define ORC_MAX_VAR_SIZE 8
+
+enum {
+ ORC_VAR_D1,
+ ORC_VAR_D2,
+ ORC_VAR_D3,
+ ORC_VAR_D4,
+ ORC_VAR_S1,
+ ORC_VAR_S2,
+ ORC_VAR_S3,
+ ORC_VAR_S4,
+ ORC_VAR_S5,
+ ORC_VAR_S6,
+ ORC_VAR_S7,
+ ORC_VAR_S8,
+ ORC_VAR_A1,
+ ORC_VAR_A2,
+ ORC_VAR_A3,
+ ORC_VAR_A4,
+ ORC_VAR_C1,
+ ORC_VAR_C2,
+ ORC_VAR_C3,
+ ORC_VAR_C4,
+ ORC_VAR_C5,
+ ORC_VAR_C6,
+ ORC_VAR_C7,
+ ORC_VAR_C8,
+ ORC_VAR_P1,
+ ORC_VAR_P2,
+ ORC_VAR_P3,
+ ORC_VAR_P4,
+ ORC_VAR_P5,
+ ORC_VAR_P6,
+ ORC_VAR_P7,
+ ORC_VAR_P8,
+ ORC_VAR_T1,
+ ORC_VAR_T2,
+ ORC_VAR_T3,
+ ORC_VAR_T4,
+ ORC_VAR_T5,
+ ORC_VAR_T6,
+ ORC_VAR_T7,
+ ORC_VAR_T8,
+ ORC_VAR_T9,
+ ORC_VAR_T10,
+ ORC_VAR_T11,
+ ORC_VAR_T12,
+ ORC_VAR_T13,
+ ORC_VAR_T14,
+ ORC_VAR_T15,
+ ORC_VAR_T16
+};
+
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcmmx.h b/orc/orcmmx.h
index bdbd316..13395a4 100644
--- a/orc/orcmmx.h
+++ b/orc/orcmmx.h
@@ -7,19 +7,6 @@
ORC_BEGIN_DECLS
-typedef enum {
- ORC_TARGET_MMX_MMX = (1<<0),
- ORC_TARGET_MMX_MMXEXT = (1<<1),
- ORC_TARGET_MMX_3DNOW = (1<<2),
- ORC_TARGET_MMX_3DNOWEXT = (1<<3),
- ORC_TARGET_MMX_SSSE3 = (1<<4),
- ORC_TARGET_MMX_SSE4_1 = (1<<5),
- ORC_TARGET_MMX_SSE4_2 = (1<<6),
- ORC_TARGET_MMX_FRAME_POINTER = (1<<7),
- ORC_TARGET_MMX_SHORT_JUMPS = (1<<8),
- ORC_TARGET_MMX_64BIT = (1<<9)
-} OrcTargetMMXFlags;
-
#ifdef ORC_ENABLE_UNSTABLE_API
typedef enum {
diff --git a/orc/orcopcode.h b/orc/orcopcode.h
new file mode 100644
index 0000000..e209f98
--- /dev/null
+++ b/orc/orcopcode.h
@@ -0,0 +1,57 @@
+
+#ifndef _ORC_OPCODE_H_
+#define _ORC_OPCODE_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcOpcodeSet OrcOpcodeSet;
+typedef struct _OrcStaticOpcode OrcStaticOpcode;
+
+
+/**
+ * OrcOpcodeSet:
+ *
+ * The OrcOpcodeSet structure has no public members
+ */
+struct _OrcOpcodeSet {
+ /*< private >*/
+ int opcode_major;
+ char prefix[8];
+
+ int n_opcodes;
+ OrcStaticOpcode *opcodes;
+};
+
+#define ORC_STATIC_OPCODE_ACCUMULATOR (1<<0)
+#define ORC_STATIC_OPCODE_FLOAT_SRC (1<<1)
+#define ORC_STATIC_OPCODE_FLOAT_DEST (1<<2)
+#define ORC_STATIC_OPCODE_FLOAT (ORC_STATIC_OPCODE_FLOAT_SRC|ORC_STATIC_OPCODE_FLOAT_DEST)
+#define ORC_STATIC_OPCODE_SCALAR (1<<3)
+#define ORC_STATIC_OPCODE_LOAD (1<<4)
+#define ORC_STATIC_OPCODE_STORE (1<<5)
+#define ORC_STATIC_OPCODE_INVARIANT (1<<6)
+#define ORC_STATIC_OPCODE_ITERATOR (1<<7)
+
+
+struct _OrcStaticOpcode {
+ char name[16];
+ unsigned int flags;
+ int dest_size[ORC_STATIC_OPCODE_N_DEST];
+ int src_size[ORC_STATIC_OPCODE_N_SRC];
+ OrcOpcodeEmulateNFunc emulateN;
+};
+
+OrcStaticOpcode * orc_opcode_find_by_name (const char *name);
+void orc_opcode_init (void);
+OrcOpcodeSet *orc_opcode_set_get (const char *name);
+OrcOpcodeSet *orc_opcode_set_get_nth (int opcode_major);
+int orc_opcode_set_find_by_name (OrcOpcodeSet *opcode_set, const char *name);
+int orc_opcode_register_static (OrcStaticOpcode *sopcode, char *prefix);
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcprogram.h b/orc/orcprogram.h
index aa15fac..9d1935f 100644
--- a/orc/orcprogram.h
+++ b/orc/orcprogram.h
@@ -3,347 +3,22 @@
#define _ORC_PROGRAM_H_
#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+#include <orc/orcexecutor.h>
+#include <orc/orccode.h>
+#include <orc/orcbytecode.h>
+#include <orc/orccompiler.h>
+#include <orc/orctarget.h>
+#include <orc/orcrule.h>
ORC_BEGIN_DECLS
-typedef struct _OrcOpcodeExecutor OrcOpcodeExecutor;
-typedef struct _OrcExecutor OrcExecutor;
-typedef struct _OrcExecutorAlt OrcExecutorAlt;
-typedef struct _OrcVariable OrcVariable;
-typedef struct _OrcOpcodeSet OrcOpcodeSet;
-typedef struct _OrcStaticOpcode OrcStaticOpcode;
-typedef struct _OrcInstruction OrcInstruction;
-typedef struct _OrcProgram OrcProgram;
-typedef struct _OrcCompiler OrcCompiler;
-typedef struct _OrcRule OrcRule;
-typedef struct _OrcRuleSet OrcRuleSet;
-typedef struct _OrcConstant OrcConstant;
-typedef struct _OrcFixup OrcFixup;
-typedef struct _OrcTarget OrcTarget;
-typedef struct _OrcCode OrcCode;
-typedef struct _OrcCodeChunk OrcCodeChunk;
-typedef struct _OrcBytecode OrcBytecode;
-
-typedef void (*OrcOpcodeEmulateFunc)(OrcOpcodeExecutor *ex, void *user);
-typedef void (*OrcOpcodeEmulateNFunc)(OrcOpcodeExecutor *ex, int index, int n);
-typedef void (*OrcOpcodeEmulate16Func)(OrcOpcodeExecutor *ex);
-typedef void (*OrcRuleEmitFunc)(OrcCompiler *p, void *user, OrcInstruction *insn);
-typedef void (*OrcExecutorFunc)(OrcExecutor *ex);
-
-#define ORC_N_REGS (32*4)
-#define ORC_N_INSNS 100
-#define ORC_N_VARIABLES 64
-#define ORC_N_ARRAYS 12
-#define ORC_N_REGISTERS 20
-#define ORC_N_FIXUPS 100
-#define ORC_N_CONSTANTS 20
-#define ORC_N_LABELS 40
-#define ORC_N_COMPILER_VARIABLES (ORC_N_VARIABLES+32)
-
-#define ORC_GP_REG_BASE 32
-#define ORC_VEC_REG_BASE 64
-#define ORC_REG_INVALID 0
-
-#define ORC_STATIC_OPCODE_N_SRC 4
-#define ORC_STATIC_OPCODE_N_DEST 2
-
-#define ORC_OPCODE_N_ARGS 4
-#define ORC_N_TARGETS 10
-#define ORC_N_RULE_SETS 10
-
-#define ORC_MAX_VAR_SIZE 8
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#define ORC_ENABLE_ASM_CODE
-#ifdef ORC_ENABLE_ASM_CODE
-#define ORC_ASM_CODE(compiler,...) orc_compiler_append_code(compiler, __VA_ARGS__)
-#else
-#define ORC_ASM_CODE(compiler,...)
-#endif
#define ORC_PROGRAM_ERROR(program, ...) do { \
program->error = TRUE; \
orc_debug_print(ORC_DEBUG_WARNING, __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \
} while (0)
-#define ORC_COMPILER_ERROR(compiler, ...) do { \
- compiler->error = TRUE; \
- compiler->result = ORC_COMPILE_RESULT_UNKNOWN_PARSE; \
- orc_debug_print(ORC_DEBUG_WARNING, __FILE__, ORC_FUNCTION, __LINE__, __VA_ARGS__); \
-} while (0)
-
-enum {
- ORC_TARGET_C_C99 = (1<<0),
- ORC_TARGET_C_BARE = (1<<1),
- ORC_TARGET_C_NOEXEC = (1<<2),
- ORC_TARGET_C_OPCODE = (1<<3),
- ORC_TARGET_CLEAN_COMPILE = (1<<29),
- ORC_TARGET_FAST_NAN = (1<<30),
- ORC_TARGET_FAST_DENORMAL = (1<<31)
-};
-
-enum {
- ORC_TARGET_ALTIVEC_ALTIVEC = (1<<0)
-};
-
-enum {
- ORC_TARGET_NEON_CLEAN_COMPILE = (1<<0),
- ORC_TARGET_NEON_NEON = (1<<1),
- ORC_TARGET_NEON_EDSP = (1<<2)
-};
-
-enum {
- ORC_TARGET_ARM_EDSP = (1<<2),
- ORC_TARGET_ARM_ARM6 = (1<<3)
-};
-
-typedef enum {
- ORC_VAR_TYPE_TEMP,
- ORC_VAR_TYPE_SRC,
- ORC_VAR_TYPE_DEST,
- ORC_VAR_TYPE_CONST,
- ORC_VAR_TYPE_PARAM,
- ORC_VAR_TYPE_ACCUMULATOR
-} OrcVarType;
-
-enum {
- ORC_VAR_D1,
- ORC_VAR_D2,
- ORC_VAR_D3,
- ORC_VAR_D4,
- ORC_VAR_S1,
- ORC_VAR_S2,
- ORC_VAR_S3,
- ORC_VAR_S4,
- ORC_VAR_S5,
- ORC_VAR_S6,
- ORC_VAR_S7,
- ORC_VAR_S8,
- ORC_VAR_A1,
- ORC_VAR_A2,
- ORC_VAR_A3,
- ORC_VAR_A4,
- ORC_VAR_C1,
- ORC_VAR_C2,
- ORC_VAR_C3,
- ORC_VAR_C4,
- ORC_VAR_C5,
- ORC_VAR_C6,
- ORC_VAR_C7,
- ORC_VAR_C8,
- ORC_VAR_P1,
- ORC_VAR_P2,
- ORC_VAR_P3,
- ORC_VAR_P4,
- ORC_VAR_P5,
- ORC_VAR_P6,
- ORC_VAR_P7,
- ORC_VAR_P8,
- ORC_VAR_T1,
- ORC_VAR_T2,
- ORC_VAR_T3,
- ORC_VAR_T4,
- ORC_VAR_T5,
- ORC_VAR_T6,
- ORC_VAR_T7,
- ORC_VAR_T8,
- ORC_VAR_T9,
- ORC_VAR_T10,
- ORC_VAR_T11,
- ORC_VAR_T12,
- ORC_VAR_T13,
- ORC_VAR_T14,
- ORC_VAR_T15,
- ORC_VAR_T16
-};
-
-enum {
- ORC_CONST_ZERO,
- ORC_CONST_SPLAT_B,
- ORC_CONST_SPLAT_W,
- ORC_CONST_SPLAT_L,
- ORC_CONST_FULL
-};
-
-enum {
- ORC_SAMPLE_REGULAR = 0,
- ORC_SAMPLE_TRANSPOSED,
- ORC_SAMPLE_NEAREST,
- ORC_SAMPLE_BILINEAR,
- ORC_SAMPLE_FOUR_TAP
-};
-
-enum {
- ORC_PARAM_TYPE_INT = 0,
- ORC_PARAM_TYPE_FLOAT,
- ORC_PARAM_TYPE_INT64,
- ORC_PARAM_TYPE_DOUBLE
-};
-
-typedef enum {
- ORC_COMPILE_RESULT_OK = 0,
-
- ORC_COMPILE_RESULT_UNKNOWN_COMPILE = 0x100,
- ORC_COMPILE_RESULT_MISSING_RULE = 0x101,
-
- ORC_COMPILE_RESULT_UNKNOWN_PARSE = 0x200,
- ORC_COMPILE_RESULT_PARSE = 0x201,
- ORC_COMPILE_RESULT_VARIABLE = 0x202
-
-} OrcCompileResult;
-
-#define ORC_COMPILE_RESULT_IS_SUCCESSFUL(x) ((x) < 0x100)
-#define ORC_COMPILE_RESULT_IS_FATAL(x) ((x) >= 0x200)
-
-/**
- * OrcVariable:
- *
- * The OrcVariable structure has no public members
- */
-struct _OrcVariable {
- /*< private >*/
- char *name;
- char *type_name;
-
- int size;
- OrcVarType vartype;
-
- int used;
- int first_use;
- int last_use;
- int replaced;
- int replacement;
-
- int alloc;
- int is_chained;
- int is_aligned;
- int alignment;
- int is_uncached;
-
- orc_union64 value;
-
- int ptr_register;
- int ptr_offset;
- int mask_alloc;
- int aligned_data;
- int param_type;
- int load_dest;
- int update_type;
- int need_offset_reg;
-};
-
-/**
- * OrcRule:
- *
- * The OrcRule structure has no public members
- */
-struct _OrcRule {
- /*< private >*/
- OrcRuleEmitFunc emit;
- void *emit_user;
-};
-
-/**
- * OrcRuleSet:
- *
- * The OrcRuleSet structure has no public members
- */
-struct _OrcRuleSet {
- /*< private >*/
- int opcode_major;
- int required_target_flags;
-
- OrcRule *rules;
- int n_rules;
-};
-
-/**
- * OrcOpcodeSet:
- *
- * The OrcOpcodeSet structure has no public members
- */
-struct _OrcOpcodeSet {
- /*< private >*/
- int opcode_major;
- char prefix[8];
-
- int n_opcodes;
- OrcStaticOpcode *opcodes;
-};
-
-#define ORC_STATIC_OPCODE_ACCUMULATOR (1<<0)
-#define ORC_STATIC_OPCODE_FLOAT_SRC (1<<1)
-#define ORC_STATIC_OPCODE_FLOAT_DEST (1<<2)
-#define ORC_STATIC_OPCODE_FLOAT (ORC_STATIC_OPCODE_FLOAT_SRC|ORC_STATIC_OPCODE_FLOAT_DEST)
-#define ORC_STATIC_OPCODE_SCALAR (1<<3)
-#define ORC_STATIC_OPCODE_LOAD (1<<4)
-#define ORC_STATIC_OPCODE_STORE (1<<5)
-#define ORC_STATIC_OPCODE_INVARIANT (1<<6)
-#define ORC_STATIC_OPCODE_ITERATOR (1<<7)
-
-
-struct _OrcStaticOpcode {
- char name[16];
- unsigned int flags;
- int dest_size[ORC_STATIC_OPCODE_N_DEST];
- int src_size[ORC_STATIC_OPCODE_N_SRC];
- OrcOpcodeEmulateNFunc emulateN;
-};
-
-/**
- * OrcInstruction:
- *
- * The OrcInstruction structure has no public members
- */
-struct _OrcInstruction {
- /*< private >*/
- OrcStaticOpcode *opcode;
- int dest_args[ORC_STATIC_OPCODE_N_DEST];
- int src_args[ORC_STATIC_OPCODE_N_SRC];
-
- OrcRule *rule;
- unsigned int flags;
-};
-
-#define ORC_INSTRUCTION_FLAG_X2 (1<<0)
-#define ORC_INSTRUCTION_FLAG_X4 (1<<1)
-
-#define ORC_INSN_FLAG_INVARIANT (1<<2)
-#define ORC_INSN_FLAG_ADDED (1<<3)
-
-
-/**
- * OrcConstant:
- *
- * The OrcConstant structure has no public members
- */
-struct _OrcConstant {
- /*< private >*/
- int type;
- int alloc_reg;
- unsigned int value;
- unsigned int full_value[4];
- int use_count;
- int is_long;
-};
-
-/**
- * OrcFixup:
- *
- * The OrcFixup structure has no public members
- */
-struct _OrcFixup {
- /*< private >*/
- unsigned char *ptr;
- int type;
- int label;
-};
/**
* OrcProgram:
@@ -421,83 +96,6 @@ struct _OrcProgram {
char *error_msg;
};
-/**
- * OrcCompiler:
- *
- * The OrcCompiler structure has no public members
- */
-struct _OrcCompiler {
- /*< private >*/
- OrcProgram *program;
- OrcTarget *target;
-
- unsigned int target_flags;
-
- OrcInstruction insns[ORC_N_INSNS];
- int n_insns;
-
- OrcVariable vars[ORC_N_COMPILER_VARIABLES];
- int n_temp_vars;
- int n_dup_vars;
-
- unsigned char *code;
- unsigned char *codeptr;
-
- OrcConstant constants[ORC_N_CONSTANTS];
- int n_constants;
-
- OrcFixup fixups[ORC_N_FIXUPS];
- int n_fixups;
- unsigned char *labels[ORC_N_LABELS];
- int labels_int[ORC_N_LABELS];
- int n_labels;
-
- int error;
- char *error_msg;
- OrcCompileResult result;
-
- int valid_regs[ORC_N_REGS];
- int save_regs[ORC_N_REGS];
- int used_regs[ORC_N_REGS];
- int alloc_regs[ORC_N_REGS];
-
- int loop_shift;
- int long_jumps;
- int use_frame_pointer;
-
- char *asm_code;
- int asm_code_len;
-
- int is_64bit;
- int tmpreg;
- int tmpreg2;
- int exec_reg;
- int gp_tmpreg;
-
- int insn_index;
- int unroll_index;
- int need_mask_regs;
- int unroll_shift;
-
- int alloc_loop_counter;
- int allow_gp_on_stack;
- int loop_counter;
- int size_region;
- int has_iterator_opcode;
-
- int offset;
- int min_temp_reg;
- int max_used_temp_reg;
-
- int insn_shift; /* used when emitting rules */
- int max_var_size; /* size of largest var */
- int load_params;
-
- void *output_insns;
- int n_output_insns;
- int n_output_insns_alloc;
-};
-
#define ORC_SRC_ARG(p,i,n) ((p)->vars[(i)->src_args[(n)]].alloc)
#define ORC_DEST_ARG(p,i,n) ((p)->vars[(i)->dest_args[(n)]].alloc)
#define ORC_SRC_TYPE(p,i,n) ((p)->vars[(i)->src_args[(n)]].vartype)
@@ -505,139 +103,6 @@ struct _OrcCompiler {
#define ORC_SRC_VAL(p,insn,n) ((p)->vars[(insn)->src_args[(n)]].value.i)
#define ORC_DEST_VAL(p,insn,n) ((p)->vars[(insn)->dest_args[(n)]].value.i)
-/**
- * OrcOpcodeExecutor:
- *
- * The OrcOpcodeExecutor structure has no public members
- */
-struct _OrcOpcodeExecutor {
- /*< private >*/
- int src_values[ORC_STATIC_OPCODE_N_SRC];
- int dest_values[ORC_STATIC_OPCODE_N_DEST];
-
- OrcOpcodeEmulateNFunc emulateN;
-
- void *src_ptrs[ORC_STATIC_OPCODE_N_SRC];
- void *dest_ptrs[ORC_STATIC_OPCODE_N_DEST];
- int shift;
-};
-
-/**
- * OrcExecutor:
- *
- */
-struct _OrcExecutor {
- /*< private >*/
- OrcProgram *program;
- int n;
- int counter1;
- int counter2;
- int counter3;
-
- void *arrays[ORC_N_VARIABLES];
- int params[ORC_N_VARIABLES];
- int accumulators[4];
- /* exec pointer is stored in arrays[ORC_VAR_A1] */
- /* OrcCode pointer is stored in arrays[ORC_VAR_A2] */
- /* row pointers are stored in arrays[i+ORC_VAR_C1] */
- /* the stride for arrays[x] is stored in params[x] */
- /* m is stored in params[ORC_VAR_A1] */
- /* m_index is stored in params[ORC_VAR_A2] */
- /* elapsed time is stored in params[ORC_VAR_A3] */
- /* high half of params is stored in params[ORC_VAR_T1..] */
-};
-
-/* the alternate view of OrcExecutor */
-struct _OrcExecutorAlt {
- /*< private >*/
- OrcProgram *program;
- int n;
- int counter1;
- int counter2;
- int counter3;
-
- void *arrays[ORC_N_ARRAYS];
- OrcExecutorFunc exec;
- OrcCode *code;
- void *unused1[ORC_N_VARIABLES - ORC_N_ARRAYS - 2];
- int strides[ORC_N_ARRAYS];
- int m;
- int m_index;
- int time;
- int unused2;
- int unused4[8];
- int params[ORC_VAR_T1-ORC_VAR_P1];
- int params_hi[ORC_VAR_T1-ORC_VAR_P1];
- int unused3[ORC_N_VARIABLES - ORC_VAR_T9];
- int accumulators[4];
-};
-#define ORC_EXECUTOR_EXEC(ex) ((OrcExecutorFunc)((ex)->arrays[ORC_VAR_A1]))
-#define ORC_EXECUTOR_M(ex) ((ex)->params[ORC_VAR_A1])
-#define ORC_EXECUTOR_M_INDEX(ex) ((ex)->params[ORC_VAR_A2])
-#define ORC_EXECUTOR_TIME(ex) ((ex)->params[ORC_VAR_A3])
-
-typedef struct _OrcCodeVariable OrcCodeVariable;
-struct _OrcCodeVariable {
- /*< private >*/
- int vartype;
- int size;
- orc_union64 value;
-};
-
-struct _OrcCode {
- /*< public >*/
- OrcExecutorFunc exec;
-
- /*< private >*/
- OrcCompileResult result;
- char *name;
-
- /* for execution */
- unsigned char *code;
- int code_size;
- void *chunk;
-
- /* for emulation */
- int n_insns;
- OrcInstruction *insns;
- OrcCodeVariable *vars;
- int is_2d;
- int constant_n;
- int constant_m;
-};
-
-/**
- * OrcTarget:
- *
- */
-struct _OrcTarget {
- const char *name;
- orc_bool executable;
- int data_register_offset;
-
- unsigned int (*get_default_flags)(void);
- void (*compiler_init)(OrcCompiler *compiler);
- void (*compile)(OrcCompiler *compiler);
-
- OrcRuleSet rule_sets[ORC_N_RULE_SETS];
- int n_rule_sets;
-
- const char * (*get_asm_preamble)(void);
- void (*load_constant)(OrcCompiler *compiler, int reg, int size, int value);
- const char * (*get_flag_name)(int shift);
- void (*flush_cache) (OrcCode *code);
- void (*load_constant_long)(OrcCompiler *compiler, int reg,
- OrcConstant *constant);
-
- void *_unused[5];
-};
-
-struct _OrcBytecode {
- orc_uint8 *bytecode;
- int length;
- int alloc_len;
-};
-
void orc_init (void);
@@ -647,8 +112,6 @@ OrcProgram * orc_program_new_dss (int size1, int size2, int size3);
OrcProgram * orc_program_new_as (int size1, int size2);
OrcProgram * orc_program_new_ass (int size1, int size2, int size3);
OrcProgram * orc_program_new_from_static_bytecode (const orc_uint8 *bytecode);
-OrcStaticOpcode * orc_opcode_find_by_name (const char *name);
-void orc_opcode_init (void);
const char * orc_program_get_name (OrcProgram *program);
void orc_program_set_name (OrcProgram *program, const char *name);
@@ -674,15 +137,6 @@ void orc_program_append_ds_str (OrcProgram *p, const char *opcode,
void orc_program_append_dds_str (OrcProgram *program, const char *name,
const char *arg1, const char *arg2, const char *arg3);
-void orc_mmx_init (void);
-void orc_sse_init (void);
-void orc_arm_init (void);
-void orc_powerpc_init (void);
-void orc_c_init (void);
-void orc_neon_init (void);
-void orc_c64x_init (void);
-void orc_c64x_c_init (void);
-
OrcCompileResult orc_program_compile (OrcProgram *p);
OrcCompileResult orc_program_compile_for_target (OrcProgram *p, OrcTarget *target);
OrcCompileResult orc_program_compile_full (OrcProgram *p, OrcTarget *target,
@@ -714,105 +168,17 @@ void orc_program_set_type_name (OrcProgram *program, int var, const char *type_n
void orc_program_set_var_alignment (OrcProgram *program, int var, int alignment);
void orc_program_set_sampling_type (OrcProgram *program, int var, int sampling_type);
-OrcExecutor * orc_executor_new (OrcProgram *program);
-void orc_executor_free (OrcExecutor *ex);
-void orc_executor_set_program (OrcExecutor *ex, OrcProgram *program);
-void orc_executor_set_array (OrcExecutor *ex, int var, void *ptr);
-void orc_executor_set_stride (OrcExecutor *ex, int var, int stride);
-void orc_executor_set_array_str (OrcExecutor *ex, const char *name, void *ptr);
-void orc_executor_set_param (OrcExecutor *ex, int var, int value);
-void orc_executor_set_param_str (OrcExecutor *ex, const char *name, int value);
-void orc_executor_set_param_float (OrcExecutor *ex, int var, float value);
-void orc_executor_set_param_int64 (OrcExecutor *ex, int var, orc_int64 value);
-void orc_executor_set_param_double (OrcExecutor *ex, int var, double value);
-int orc_executor_get_accumulator (OrcExecutor *ex, int var);
-int orc_executor_get_accumulator_str (OrcExecutor *ex, const char *name);
-void orc_executor_set_n (OrcExecutor *ex, int n);
-void orc_executor_set_m (OrcExecutor *ex, int m);
-void orc_executor_emulate (OrcExecutor *ex);
-void orc_executor_run (OrcExecutor *ex);
-void orc_executor_run_backup (OrcExecutor *ex);
-
-OrcOpcodeSet *orc_opcode_set_get (const char *name);
-OrcOpcodeSet *orc_opcode_set_get_nth (int opcode_major);
-int orc_opcode_set_find_by_name (OrcOpcodeSet *opcode_set, const char *name);
-int orc_opcode_register_static (OrcStaticOpcode *sopcode, char *prefix);
-
-OrcRuleSet * orc_rule_set_new (OrcOpcodeSet *opcode_set, OrcTarget *target,
- unsigned int required_flags);
-void orc_rule_register (OrcRuleSet *rule_set, const char *opcode_name,
- OrcRuleEmitFunc emit, void *emit_user);
-OrcRule * orc_target_get_rule (OrcTarget *target, OrcStaticOpcode *opcode,
- unsigned int target_flags);
-OrcTarget * orc_target_get_default (void);
-unsigned int orc_target_get_default_flags (OrcTarget *target);
-const char * orc_target_get_name (OrcTarget *target);
-const char * orc_target_get_flag_name (OrcTarget *target, int shift);
-
int orc_program_allocate_register (OrcProgram *program, int is_data);
-void orc_code_allocate_codemem (OrcCode *code, int size);
-int orc_compiler_label_new (OrcCompiler *compiler);
-int orc_compiler_get_constant (OrcCompiler *compiler, int size, int value);
-int orc_compiler_get_constant_long (OrcCompiler *compiler, orc_uint32 a,
- orc_uint32 b, orc_uint32 c, orc_uint32 d);
-int orc_compiler_try_get_constant_long (OrcCompiler *compiler, orc_uint32 a,
- orc_uint32 b, orc_uint32 c, orc_uint32 d);
-int orc_compiler_get_temp_constant (OrcCompiler *compiler, int size, int value);
-int orc_compiler_get_temp_reg (OrcCompiler *compiler);
-int orc_compiler_get_constant_reg (OrcCompiler *compiler);
-void orc_compiler_error (OrcCompiler *compiler, const char *fmt, ...);
-
void orc_program_reset (OrcProgram *program);
OrcCode *orc_program_take_code (OrcProgram *program);
const char *orc_program_get_asm_code (OrcProgram *program);
-const char *orc_target_get_asm_preamble (const char *target);
-const char * orc_target_get_preamble (OrcTarget *target);
-const char * orc_target_c_get_typedefs (void);
const char * orc_program_get_error (OrcProgram *program);
-void orc_compiler_append_code (OrcCompiler *p, const char *fmt, ...)
- ORC_GNU_PRINTF(2,3);
-
-void orc_target_register (OrcTarget *target);
-OrcTarget *orc_target_get_by_name (const char *target_name);
int orc_program_get_max_array_size (OrcProgram *program);
int orc_program_get_max_accumulator_size (OrcProgram *program);
-void orc_get_data_cache_sizes (int *level1, int *level2, int *level3);
-void orc_get_cpu_family_model_stepping (int *family, int *model, int *stepping);
-const char * orc_get_cpu_name (void);
-
-OrcCode * orc_code_new (void);
-void orc_code_free (OrcCode *code);
-
-#ifdef ORC_ENABLE_UNSTABLE_API
-
-int orc_compiler_flag_check (const char *flag);
-
-extern int _orc_data_cache_size_level1;
-extern int _orc_data_cache_size_level2;
-extern int _orc_data_cache_size_level3;
-extern int _orc_cpu_family;
-extern int _orc_cpu_model;
-extern int _orc_cpu_stepping;
-extern const char *_orc_cpu_name;
-
-extern int _orc_compiler_flag_backup;
-extern int _orc_compiler_flag_emulate;
-extern int _orc_compiler_flag_debug;
-extern int _orc_compiler_flag_randomize;
-
-void orc_code_chunk_free (OrcCodeChunk *chunk);
-
-OrcBytecode * orc_bytecode_new (void);
-void orc_bytecode_free (OrcBytecode *bytecode);
-OrcBytecode * orc_bytecode_from_program (OrcProgram *p);
-int orc_bytecode_parse_function (OrcProgram *program, const orc_uint8 *bytecode);
-
-
-#endif
ORC_END_DECLS
diff --git a/orc/orcrule.h b/orc/orcrule.h
new file mode 100644
index 0000000..35b1cce
--- /dev/null
+++ b/orc/orcrule.h
@@ -0,0 +1,51 @@
+
+#ifndef _ORC_RULE_H_
+#define _ORC_RULE_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+#include <orc/orcopcode.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcRule OrcRule;
+typedef struct _OrcRuleSet OrcRuleSet;
+
+
+typedef void (*OrcRuleEmitFunc)(OrcCompiler *p, void *user, OrcInstruction *insn);
+
+/**
+ * OrcRule:
+ *
+ * The OrcRule structure has no public members
+ */
+struct _OrcRule {
+ /*< private >*/
+ OrcRuleEmitFunc emit;
+ void *emit_user;
+};
+
+/**
+ * OrcRuleSet:
+ *
+ * The OrcRuleSet structure has no public members
+ */
+struct _OrcRuleSet {
+ /*< private >*/
+ int opcode_major;
+ int required_target_flags;
+
+ OrcRule *rules;
+ int n_rules;
+};
+
+OrcRuleSet * orc_rule_set_new (OrcOpcodeSet *opcode_set, OrcTarget *target,
+ unsigned int required_flags);
+void orc_rule_register (OrcRuleSet *rule_set, const char *opcode_name,
+ OrcRuleEmitFunc emit, void *emit_user);
+
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcsse.h b/orc/orcsse.h
index ac7c009..7b130bf 100644
--- a/orc/orcsse.h
+++ b/orc/orcsse.h
@@ -7,19 +7,6 @@
ORC_BEGIN_DECLS
-typedef enum {
- ORC_TARGET_SSE_SSE2 = (1<<0),
- ORC_TARGET_SSE_SSE3 = (1<<1),
- ORC_TARGET_SSE_SSSE3 = (1<<2),
- ORC_TARGET_SSE_SSE4_1 = (1<<3),
- ORC_TARGET_SSE_SSE4_2 = (1<<4),
- ORC_TARGET_SSE_SSE4A = (1<<5),
- ORC_TARGET_SSE_SSE5 = (1<<6),
- ORC_TARGET_SSE_FRAME_POINTER = (1<<7),
- ORC_TARGET_SSE_SHORT_JUMPS = (1<<8),
- ORC_TARGET_SSE_64BIT = (1<<9)
-}OrcTargetSSEFlags;
-
#ifdef ORC_ENABLE_UNSTABLE_API
typedef enum {
diff --git a/orc/orctarget.h b/orc/orctarget.h
new file mode 100644
index 0000000..159b8a4
--- /dev/null
+++ b/orc/orctarget.h
@@ -0,0 +1,109 @@
+
+#ifndef _ORC_TARGET_H_
+#define _ORC_TARGET_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+#include <orc/orcrule.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcTarget OrcTarget;
+
+enum {
+ ORC_TARGET_C_C99 = (1<<0),
+ ORC_TARGET_C_BARE = (1<<1),
+ ORC_TARGET_C_NOEXEC = (1<<2),
+ ORC_TARGET_C_OPCODE = (1<<3),
+ ORC_TARGET_CLEAN_COMPILE = (1<<29),
+ ORC_TARGET_FAST_NAN = (1<<30),
+ ORC_TARGET_FAST_DENORMAL = (1<<31)
+};
+
+enum {
+ ORC_TARGET_ALTIVEC_ALTIVEC = (1<<0)
+};
+
+enum {
+ ORC_TARGET_NEON_CLEAN_COMPILE = (1<<0),
+ ORC_TARGET_NEON_NEON = (1<<1),
+ ORC_TARGET_NEON_EDSP = (1<<2)
+};
+
+enum {
+ ORC_TARGET_ARM_EDSP = (1<<2),
+ ORC_TARGET_ARM_ARM6 = (1<<3)
+};
+
+typedef enum {
+ ORC_TARGET_MMX_MMX = (1<<0),
+ ORC_TARGET_MMX_MMXEXT = (1<<1),
+ ORC_TARGET_MMX_3DNOW = (1<<2),
+ ORC_TARGET_MMX_3DNOWEXT = (1<<3),
+ ORC_TARGET_MMX_SSSE3 = (1<<4),
+ ORC_TARGET_MMX_SSE4_1 = (1<<5),
+ ORC_TARGET_MMX_SSE4_2 = (1<<6),
+ ORC_TARGET_MMX_FRAME_POINTER = (1<<7),
+ ORC_TARGET_MMX_SHORT_JUMPS = (1<<8),
+ ORC_TARGET_MMX_64BIT = (1<<9)
+} OrcTargetMMXFlags;
+
+typedef enum {
+ ORC_TARGET_SSE_SSE2 = (1<<0),
+ ORC_TARGET_SSE_SSE3 = (1<<1),
+ ORC_TARGET_SSE_SSSE3 = (1<<2),
+ ORC_TARGET_SSE_SSE4_1 = (1<<3),
+ ORC_TARGET_SSE_SSE4_2 = (1<<4),
+ ORC_TARGET_SSE_SSE4A = (1<<5),
+ ORC_TARGET_SSE_SSE5 = (1<<6),
+ ORC_TARGET_SSE_FRAME_POINTER = (1<<7),
+ ORC_TARGET_SSE_SHORT_JUMPS = (1<<8),
+ ORC_TARGET_SSE_64BIT = (1<<9)
+}OrcTargetSSEFlags;
+
+
+/**
+ * OrcTarget:
+ *
+ */
+struct _OrcTarget {
+ const char *name;
+ orc_bool executable;
+ int data_register_offset;
+
+ unsigned int (*get_default_flags)(void);
+ void (*compiler_init)(OrcCompiler *compiler);
+ void (*compile)(OrcCompiler *compiler);
+
+ OrcRuleSet rule_sets[ORC_N_RULE_SETS];
+ int n_rule_sets;
+
+ const char * (*get_asm_preamble)(void);
+ void (*load_constant)(OrcCompiler *compiler, int reg, int size, int value);
+ const char * (*get_flag_name)(int shift);
+ void (*flush_cache) (OrcCode *code);
+ void (*load_constant_long)(OrcCompiler *compiler, int reg,
+ OrcConstant *constant);
+
+ void *_unused[5];
+};
+
+
+OrcRule * orc_target_get_rule (OrcTarget *target, OrcStaticOpcode *opcode,
+ unsigned int target_flags);
+OrcTarget * orc_target_get_default (void);
+unsigned int orc_target_get_default_flags (OrcTarget *target);
+const char * orc_target_get_name (OrcTarget *target);
+const char * orc_target_get_flag_name (OrcTarget *target, int shift);
+
+const char *orc_target_get_asm_preamble (const char *target);
+const char * orc_target_get_preamble (OrcTarget *target);
+const char * orc_target_c_get_typedefs (void);
+
+void orc_target_register (OrcTarget *target);
+OrcTarget *orc_target_get_by_name (const char *target_name);
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcutils.h b/orc/orcutils.h
index 04b532a..1ca45b2 100644
--- a/orc/orcutils.h
+++ b/orc/orcutils.h
@@ -28,6 +28,32 @@
#ifndef _ORC_UTILS_H_
#define _ORC_UTILS_H_
+/* Orc objects */
+//typedef struct _OrcVariable OrcVariable;
+//typedef struct _OrcOpcodeSet OrcOpcodeSet;
+//typedef struct _OrcStaticOpcode OrcStaticOpcode;
+typedef struct _OrcInstruction OrcInstruction;
+typedef struct _OrcProgram OrcProgram;
+typedef struct _OrcCompiler OrcCompiler;
+typedef struct _OrcConstant OrcConstant;
+//typedef struct _OrcFixup OrcFixup;
+typedef struct _OrcTarget OrcTarget;
+typedef struct _OrcCode OrcCode;
+//typedef struct _OrcCodeChunk OrcCodeChunk;
+
+typedef enum {
+ ORC_COMPILE_RESULT_OK = 0,
+
+ ORC_COMPILE_RESULT_UNKNOWN_COMPILE = 0x100,
+ ORC_COMPILE_RESULT_MISSING_RULE = 0x101,
+
+ ORC_COMPILE_RESULT_UNKNOWN_PARSE = 0x200,
+ ORC_COMPILE_RESULT_PARSE = 0x201,
+ ORC_COMPILE_RESULT_VARIABLE = 0x202
+
+} OrcCompileResult;
+
+
#ifndef _ORC_INTEGER_TYPEDEFS_
#define _ORC_INTEGER_TYPEDEFS_
#if defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L
diff --git a/orc/orcvariable.h b/orc/orcvariable.h
new file mode 100644
index 0000000..c522c88
--- /dev/null
+++ b/orc/orcvariable.h
@@ -0,0 +1,75 @@
+
+#ifndef _ORC_VARIABLE_H_
+#define _ORC_VARIABLE_H_
+
+#include <orc/orcutils.h>
+#include <orc/orclimits.h>
+#include <orc/orcexecutor.h>
+#include <orc/orccode.h>
+#include <orc/orcbytecode.h>
+#include <orc/orccompiler.h>
+#include <orc/orctarget.h>
+#include <orc/orcrule.h>
+
+ORC_BEGIN_DECLS
+
+typedef struct _OrcVariable OrcVariable;
+
+typedef enum {
+ ORC_VAR_TYPE_TEMP,
+ ORC_VAR_TYPE_SRC,
+ ORC_VAR_TYPE_DEST,
+ ORC_VAR_TYPE_CONST,
+ ORC_VAR_TYPE_PARAM,
+ ORC_VAR_TYPE_ACCUMULATOR
+} OrcVarType;
+
+enum {
+ ORC_PARAM_TYPE_INT = 0,
+ ORC_PARAM_TYPE_FLOAT,
+ ORC_PARAM_TYPE_INT64,
+ ORC_PARAM_TYPE_DOUBLE
+};
+
+
+/**
+ * OrcVariable:
+ *
+ * The OrcVariable structure has no public members
+ */
+struct _OrcVariable {
+ /*< private >*/
+ char *name;
+ char *type_name;
+
+ int size;
+ OrcVarType vartype;
+
+ int used;
+ int first_use;
+ int last_use;
+ int replaced;
+ int replacement;
+
+ int alloc;
+ int is_chained;
+ int is_aligned;
+ int alignment;
+ int is_uncached;
+
+ orc_union64 value;
+
+ int ptr_register;
+ int ptr_offset;
+ int mask_alloc;
+ int aligned_data;
+ int param_type;
+ int load_dest;
+ int update_type;
+ int need_offset_reg;
+};
+
+ORC_END_DECLS
+
+#endif
+
diff --git a/orc/orcx86insn.c b/orc/orcx86insn.c
index 33982e2..4675a99 100644
--- a/orc/orcx86insn.c
+++ b/orc/orcx86insn.c
@@ -5,6 +5,9 @@
#include <orc/orc.h>
#include <orc/orccpuinsn.h>
+#include <orc/orcx86.h>
+#include <orc/orcsse.h>
+#include <orc/orcmmx.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>