From fe983ac3b41c6e66698b60447b098d9312931cde Mon Sep 17 00:00:00 2001 From: David Schleef Date: Thu, 28 May 2009 18:04:06 -0700 Subject: [PATCH] Fix up documentation --- configure.ac | 2 +- doc/orc-docs.sgml | 24 +++++++- doc/orc-sections.txt | 86 +++++++++++----------------- orc-pixel/orcpixel.c | 3 + orc/Makefile.am | 16 ++---- orc/orcarm.c | 6 ++ orc/orcarm.h | 49 ++++++++-------- orc/orccompiler.c | 6 ++ orc/orccpu-arm.c | 2 +- orc/orccpu-misc.c | 143 ---------------------------------------------- orc/orccpu-x86.c | 3 +- orc/orccpu.c | 158 --------------------------------------------------- orc/orccpu.h | 65 --------------------- orc/orcdebug.c | 2 +- orc/orcdebug.h | 6 +- orc/orcexecutor.c | 6 ++ orc/orcmmx.c | 6 ++ orc/orcmmx.h | 1 + orc/orcopcodes.c | 6 ++ orc/orcparse.c | 6 ++ orc/orcprogram-arm.c | 4 +- orc/orcprogram-mmx.c | 3 +- orc/orcprogram-sse.c | 3 +- orc/orcprogram.c | 6 ++ orc/orcprogram.h | 12 ---- orc/orcrule.c | 6 ++ orc/orcsse.c | 6 ++ orc/orcsse.h | 1 + orc/orcutils.c | 6 ++ orc/orcutils.h | 7 --- orc/orcx86.c | 48 +++------------- orc/orcx86.h | 4 +- 32 files changed, 167 insertions(+), 535 deletions(-) delete mode 100644 orc/orccpu-misc.c delete mode 100644 orc/orccpu.c delete mode 100644 orc/orccpu.h diff --git a/configure.ac b/configure.ac index 7ddb7bd..73d5e59 100644 --- a/configure.ac +++ b/configure.ac @@ -100,7 +100,7 @@ esac AC_DEFINE(ORC_EXPORTS, 1, [Defined for compiling internal code]) -ORC_CFLAGS="$ORC_CFLAGS -I\$(top_srcdir) -DORC_ENABLE_UNSTABLE_API" +ORC_CFLAGS="$ORC_CFLAGS -I\$(top_srcdir)" AC_SUBST(ORC_CFLAGS) ORC_LIBS="\$(top_builddir)/orc/liborc-$ORC_MAJORMINOR.la $LIBM $LIBRT" diff --git a/doc/orc-docs.sgml b/doc/orc-docs.sgml index 7b0ce3c..d3e97b1 100644 --- a/doc/orc-docs.sgml +++ b/doc/orc-docs.sgml @@ -12,8 +12,28 @@ - [Insert title here] + Application API + - + + + + + Extension API + + + + + + + Code Generation + + + + + + + Herein lie dragons + diff --git a/doc/orc-sections.txt b/doc/orc-sections.txt index 6527a7c..0701036 100644 --- a/doc/orc-sections.txt +++ b/doc/orc-sections.txt @@ -12,43 +12,36 @@ ORC_N_TARGETS ORC_PROGRAM_ERROR orc_program_new orc_program_new_dss -orc_program_append -orc_program_append_str -orc_program_compile -orc_program_x86_init -orc_program_powerpc_init -orc_program_assemble_x86 -orc_program_assemble_powerpc -orc_program_assemble_c +orc_program_new_as +orc_program_new_ass +orc_program_new_ds orc_program_free -orc_program_find_var_by_name +orc_program_get_name +orc_program_set_name + orc_program_add_temporary -orc_program_dup_temporary orc_program_add_source orc_program_add_destination orc_program_add_constant -orc_program_x86_reset_alloc -orc_program_powerpc_reset_alloc -orc_program_allocate_register -orc_program_x86_allocate_register -orc_program_powerpc_allocate_register -orc_program_x86_register_rules -orc_program_allocate_codemem -orc_program_dump_code orc_program_add_accumulator orc_program_add_parameter + +orc_program_append +orc_program_append_str orc_program_append_ds orc_program_append_ds_str + +orc_program_compile orc_program_compile_for_target orc_program_compile_full -orc_program_dump_asm + orc_program_get_asm_code + + +orc_program_find_var_by_name +orc_program_allocate_register orc_program_get_max_var_size -orc_program_get_name -orc_program_new_as -orc_program_new_ass -orc_program_new_ds -orc_program_set_name +orc_program_dup_temporary
@@ -69,11 +62,8 @@ ORC_WRITE_UINT32_LE
misc -OrcType OrcVariable -OrcArgument OrcInstruction -OrcRegister OrcRule OrcFixup OrcRuleEmitFunc @@ -84,19 +74,21 @@ ORC_N_REGISTERS ORC_N_FIXUPS ORC_N_LABELS ORC_GP_REG_BASE -ORC_VEC1_REG_BASE -ORC_VEC2_REG_BASE -ORC_REGCLASS_GP +ORC_VEC_REG_BASE ORC_STRUCT_OFFSET OrcVarType -orc_type_get -orc_type_register -orc_variable_get_size -orc_x86_init orc_powerpc_init orc_arm_init orc_c_init orc_parse +ARRAY_SIZE +MAX +MIN +get_cpuinfo_line +get_file +get_file_int +get_tag_value +strsplit
@@ -109,6 +101,7 @@ ORC_WARNING ORC_INFO ORC_DEBUG ORC_LOG +ORC_FUNCTION orc_debug_get_level orc_debug_print orc_debug_set_level @@ -119,6 +112,7 @@ orc_debug_set_print_function orccompiler OrcCompileResult OrcCompiler +OrcConstant ORC_COMPILER_ERROR ORC_COMPILE_RESULT_IS_FATAL ORC_COMPILE_RESULT_IS_SUCCESSFUL @@ -132,7 +126,6 @@ orc_compiler_label_new
orcopcode -OrcOpcode OrcOpcodeEmulateFunc OrcOpcodeExecutor OrcOpcodeSet @@ -140,7 +133,6 @@ OrcRuleSet OrcStaticOpcode OrcTarget ORC_OPCODE_N_ARGS -ORC_OPCODE_N_RULES ORC_STATIC_OPCODE_ACCUMULATOR ORC_STATIC_OPCODE_N_DEST ORC_STATIC_OPCODE_N_SRC @@ -232,6 +224,7 @@ orc_x86_get_regname_mmx orc_x86_get_regname_ptr orc_x86_get_regname_sse orc_x86_get_regnum +orc_x86_do_fixups
@@ -277,24 +270,9 @@ orc_mmx_init
orcarm -ORC_ARM_A1 -ORC_ARM_A2 -ORC_ARM_A3 -ORC_ARM_A4 -ORC_ARM_IP -ORC_ARM_LR -ORC_ARM_PC -ORC_ARM_R0 -ORC_ARM_SB -ORC_ARM_SP -ORC_ARM_V1 -ORC_ARM_V2 -ORC_ARM_V3 -ORC_ARM_V4 -ORC_ARM_V5 -ORC_ARM_V6 -ORC_ARM_V7 -ORC_ARM_V8 +OrcArmCond +OrcArmDP +OrcArmRegister orc_arm_do_fixups orc_arm_emit orc_arm_emit_add diff --git a/orc-pixel/orcpixel.c b/orc-pixel/orcpixel.c index 3508812..da38b8c 100644 --- a/orc-pixel/orcpixel.c +++ b/orc-pixel/orcpixel.c @@ -20,6 +20,9 @@ orc_pixel_init (void) orc_pixel_sse_register_rules (); } +#ifndef ORC_CLAMP +#define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x))) +#endif #define COMPOSITE_OVER(d,s,m) ((d) + (s) - ORC_MULDIV_255((d),(m))) #define COMPOSITE_ADD(d,s) ORC_CLAMP((d) + (s), 0, 255) diff --git a/orc/Makefile.am b/orc/Makefile.am index b7ab486..7cea88d 100644 --- a/orc/Makefile.am +++ b/orc/Makefile.am @@ -6,7 +6,8 @@ lib_LTLIBRARIES = liborc-@ORC_MAJORMINOR@.la liborc_@ORC_MAJORMINOR@_la_LIBS = $(ORC_LIBS) liborc_@ORC_MAJORMINOR@_la_LDFLAGS = \ -no-undefined -export-symbols-regex 'orc_' -liborc_@ORC_MAJORMINOR@_la_CFLAGS = $(ORC_CFLAGS) +liborc_@ORC_MAJORMINOR@_la_CFLAGS = $(ORC_CFLAGS) \ + -DORC_ENABLE_UNSTABLE_API liborc_@ORC_MAJORMINOR@_la_SOURCES = \ orc.c \ @@ -27,7 +28,6 @@ liborc_@ORC_MAJORMINOR@_la_SOURCES = \ orcrules-sse.c \ orcrules-arm.c \ orcdebug.c \ - orccpu.c \ orcutils.c \ orcsse.c \ orcmmx.c \ @@ -36,20 +36,15 @@ liborc_@ORC_MAJORMINOR@_la_SOURCES = \ if HAVE_I386 liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-x86.c -else +endif if HAVE_AMD64 liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-x86.c -else +endif if HAVE_POWERPC liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-powerpc.c -else +endif if HAVE_ARM liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-arm.c -else -liborc_@ORC_MAJORMINOR@_la_SOURCES += orccpu-misc.c -endif -endif -endif endif pkginclude_HEADERS = \ @@ -58,7 +53,6 @@ pkginclude_HEADERS = \ orcprogram.h \ orcutils.h \ orcparse.h \ - orccpu.h \ opcodes.h \ orcsse.h \ orcmmx.h \ diff --git a/orc/orcarm.c b/orc/orcarm.c index 85ed76d..a19dc99 100644 --- a/orc/orcarm.c +++ b/orc/orcarm.c @@ -14,6 +14,12 @@ #include #include +/** + * SECTION:orcarm + * @title: ARM + * @short_description: code generation for ARM + */ + const char * orc_arm_reg_name (int reg) diff --git a/orc/orcarm.h b/orc/orcarm.h index 82c237a..e1f7dd3 100644 --- a/orc/orcarm.h +++ b/orc/orcarm.h @@ -4,28 +4,27 @@ #include -#define ORC_ARM_R0 (ORC_GP_REG_BASE+0) - -#define ORC_ARM_A1 (ORC_GP_REG_BASE+0) -#define ORC_ARM_A2 (ORC_GP_REG_BASE+1) -#define ORC_ARM_A3 (ORC_GP_REG_BASE+2) -#define ORC_ARM_A4 (ORC_GP_REG_BASE+3) -#define ORC_ARM_V1 (ORC_GP_REG_BASE+4) -#define ORC_ARM_V2 (ORC_GP_REG_BASE+5) -#define ORC_ARM_V3 (ORC_GP_REG_BASE+6) -#define ORC_ARM_V4 (ORC_GP_REG_BASE+7) -#define ORC_ARM_V5 (ORC_GP_REG_BASE+8) -#define ORC_ARM_V6 (ORC_GP_REG_BASE+9) -#define ORC_ARM_V7 (ORC_GP_REG_BASE+10) -#define ORC_ARM_V8 (ORC_GP_REG_BASE+11) -#define ORC_ARM_IP (ORC_GP_REG_BASE+12) -#define ORC_ARM_SP (ORC_GP_REG_BASE+13) -#define ORC_ARM_LR (ORC_GP_REG_BASE+14) -#define ORC_ARM_PC (ORC_GP_REG_BASE+15) - -#define ORC_ARM_SB (ORC_GP_REG_BASE+9) - -enum { + +typedef enum { + ORC_ARM_A1 = ORC_GP_REG_BASE+0, + ORC_ARM_A2, + ORC_ARM_A3, + ORC_ARM_A4, + ORC_ARM_V1, + ORC_ARM_V2, + ORC_ARM_V3, + ORC_ARM_V4, + ORC_ARM_V5, + ORC_ARM_V6, + ORC_ARM_V7, + ORC_ARM_V8, + ORC_ARM_IP, + ORC_ARM_SP, + ORC_ARM_LR, + ORC_ARM_PC +} OrcArmRegister; + +typedef enum { ORC_ARM_DP_AND = 0, ORC_ARM_DP_EOR, ORC_ARM_DP_SUB, @@ -42,9 +41,9 @@ enum { ORC_ARM_DP_MOV, ORC_ARM_DP_BIC, ORC_ARM_DP_MVN -}; +} OrcArmDP; -enum { +typedef enum { ORC_ARM_COND_EQ = 0, ORC_ARM_COND_NE, ORC_ARM_COND_CS, @@ -60,7 +59,7 @@ enum { ORC_ARM_COND_GT, ORC_ARM_COND_LE, ORC_ARM_COND_AL, -}; +} OrcArmCond; void orc_arm_emit (OrcCompiler *compiler, uint32_t insn); void orc_arm_emit_bx_lr (OrcCompiler *compiler); diff --git a/orc/orccompiler.c b/orc/orccompiler.c index a2bb76b..905affb 100644 --- a/orc/orccompiler.c +++ b/orc/orccompiler.c @@ -9,6 +9,12 @@ #include #include +/** + * SECTION:orccompiler + * @title: OrcCompiler + * @short_description: Compile Orc programs + */ + void orc_compiler_assign_rules (OrcCompiler *compiler); void orc_compiler_global_reg_alloc (OrcCompiler *compiler); void orc_compiler_rewrite_vars (OrcCompiler *compiler); diff --git a/orc/orccpu-arm.c b/orc/orccpu-arm.c index 94f92c5..3819833 100644 --- a/orc/orccpu-arm.c +++ b/orc/orccpu-arm.c @@ -28,7 +28,7 @@ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#include +#include #include #include diff --git a/orc/orccpu-misc.c b/orc/orccpu-misc.c deleted file mode 100644 index 97b740c..0000000 --- a/orc/orccpu-misc.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - * LIBOIL - Library of Optimized Inner Loops - * Copyright (c) 2003,2004 David A. Schleef - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/***** alpha *****/ - -#if defined(__alpha__) -static unsigned long -oil_profile_stamp_alpha(void) -{ - unsigned int ts; - __asm__ __volatile__ ("rpcc %0\n" : "=r"(ts)); - return ts; -} - -static void -oil_cpu_detect_alpha(void) -{ - _oil_profile_stamp = oil_profile_stamp_alpha; -} -#endif - -/***** ia64 *****/ - -#if defined(__ia64__) -static unsigned long -oil_profile_stamp_ia64(void) -{ - unsigned int ts; - __asm__ __volatile__("mov %0=ar.itc\n" : "=r"(ts) :: "memory"); - return ts; -} - -static void -oil_cpu_detect_ia64(void) -{ - _oil_profile_stamp = oil_profile_stamp_ia64; -} -#endif - -/***** s390 *****/ - -#if defined(__s390__) -static unsigned long -oil_profile_stamp_s390(void) -{ - uint64_t ts; - __asm__ __volatile__ ("STCK %0(%0)\n" : : "r" (&ts)); - return ts; -} - -static void -oil_cpu_detect_s390(void) -{ - _oil_profile_stamp = oil_profile_stamp_s390; -} -#endif - -/***** mips *****/ - -#if defined(__mips__) -#if 0 -/* broken */ -static unsigned long -oil_profile_stamp_mips(void) -{ - unsigned int ts; - __asm__ __volatile__ ( - " .set push \n" - " .set reorder \n" - " mfc0 %0,$9 \n" - " .set pop \n" - : "=m" (ts)); - return ts; -} -#endif - -static void -oil_cpu_detect_mips(void) -{ - //_oil_profile_stamp = oil_profile_stamp_mips; -} -#endif - -void -oil_cpu_detect_arch(void) -{ -#ifdef __alpha__ - oil_cpu_detect_alpha(); -#endif -#ifdef __ia64__ - oil_cpu_detect_ia64(); -#endif -#ifdef __s390__ - oil_cpu_detect_s390(); -#endif -#ifdef __mips__ - oil_cpu_detect_mips(); -#endif -} - diff --git a/orc/orccpu-x86.c b/orc/orccpu-x86.c index be11443..eef2f51 100644 --- a/orc/orccpu-x86.c +++ b/orc/orccpu-x86.c @@ -29,7 +29,8 @@ #include "config.h" #endif #include -#include +#include +#include #include #include diff --git a/orc/orccpu.c b/orc/orccpu.c deleted file mode 100644 index ee5aaaf..0000000 --- a/orc/orccpu.c +++ /dev/null @@ -1,158 +0,0 @@ -/* - * ORC - Library of Optimized Inner Loops - * Copyright (c) 2003,2004 David A. Schleef - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif -#include -#include -#include - -#ifdef HAVE_UNISTD_H -#include -#endif -#include -#include -#include -#include -#include -#include -#ifdef HAVE_SYS_TIME_H -#include -#endif -#include - -#if defined(__FreeBSD__) -#include -#include -#endif - -#ifdef __sun -#include -#endif - - - -/** - * SECTION:liborccpu - * @title: CPU - * @short_description: Check the capabilities of the current CPU - * - */ - -void orc_cpu_detect_arch(void); - -unsigned long orc_cpu_flags; - -#if 0 -extern unsigned long (*_orc_profile_stamp)(void); -#endif - -#if 0 -#ifdef HAVE_GETTIMEOFDAY -static unsigned long -orc_profile_stamp_gtod (void) -{ - struct timeval tv; - gettimeofday(&tv,NULL); - return 1000000*(unsigned long)tv.tv_sec + (unsigned long)tv.tv_usec; -} -#endif - -#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_MONOTONIC_CLOCK) -static unsigned long -orc_profile_stamp_clock_gettime (void) -{ - struct timespec ts; - clock_gettime (CLOCK_MONOTONIC, &ts); - return 1000000000*ts.tv_sec + ts.tv_nsec; -} -#endif - -static unsigned long -orc_profile_stamp_zero (void) -{ - return 0; -} -#endif - -void -_orc_cpu_init (void) -{ - const char *envvar; - - //orc_cpu_detect_arch(); - - envvar = getenv ("ORC_CPU_FLAGS"); - if (envvar != NULL) { - char *end = NULL; - unsigned long flags; - - flags = strtoul (envvar, &end, 0); - if (end > envvar) { - orc_cpu_flags = flags; - } - ORC_INFO ("cpu flags from environment %08lx", orc_cpu_flags); - } - - ORC_INFO ("cpu flags %08lx", orc_cpu_flags); - -#if 0 -#if defined(HAVE_CLOCK_GETTIME) && defined(HAVE_MONOTONIC_CLOCK) - if (_orc_profile_stamp == NULL) { - _orc_profile_stamp = orc_profile_stamp_clock_gettime; - ORC_INFO("Using clock_gettime() as a timestamp function."); - } -#endif - -#ifdef HAVE_GETTIMEOFDAY - if (_orc_profile_stamp == NULL) { - _orc_profile_stamp = orc_profile_stamp_gtod; - ORC_WARNING("Using gettimeofday() as a timestamp function."); - } -#endif - if (_orc_profile_stamp == NULL) { - _orc_profile_stamp = orc_profile_stamp_zero; - ORC_ERROR("No timestamping function. This is kinda bad."); - } -#endif -} - -/** - * orc_cpu_get_flags: - * - * Returns a bitmask containing the available CPU features. - * - * Returns: the CPU features. - */ -unsigned int -orc_cpu_get_flags (void) -{ - return orc_cpu_flags; -} - - diff --git a/orc/orccpu.h b/orc/orccpu.h deleted file mode 100644 index 4d55e2b..0000000 --- a/orc/orccpu.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * ORC - Library of Optimized Inner Loops - * Copyright (c) 2003,2004 David A. Schleef - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, - * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING - * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _ORC_CPU_H_ -#define _ORC_CPU_H_ - -#include - -ORC_BEGIN_DECLS - -#ifdef ORC_ENABLE_UNSTABLE_API - -typedef enum { - ORC_CPU_FLAG_CMOV = (1<<0), - ORC_CPU_FLAG_MMX = (1<<1), - ORC_CPU_FLAG_SSE = (1<<2), - ORC_CPU_FLAG_MMXEXT = (1<<3), - ORC_CPU_FLAG_SSE2 = (1<<4), - ORC_CPU_FLAG_3DNOW = (1<<5), - ORC_CPU_FLAG_3DNOWEXT = (1<<6), - ORC_CPU_FLAG_SSE3 = (1<<7), - ORC_CPU_FLAG_ALTIVEC = (1<<8), - ORC_CPU_FLAG_EDSP = (1<<9), - ORC_CPU_FLAG_ARM6 = (1<<10), - ORC_CPU_FLAG_VFP = (1<<11), - ORC_CPU_FLAG_SSSE3 = (1<<12) -} OrcCpuFlag; - -unsigned int orc_sse_get_cpu_flags (void); -unsigned int orc_mmx_get_cpu_flags (void); - -void _orc_cpu_init (void); - -ORC_EXPORT unsigned long orc_cpu_flags; - -#endif - -ORC_END_DECLS - -#endif - diff --git a/orc/orcdebug.c b/orc/orcdebug.c index 22b8c9d..38bde6a 100644 --- a/orc/orcdebug.c +++ b/orc/orcdebug.c @@ -37,7 +37,7 @@ /** * SECTION:orcdebug - * @title: Debug + * @title: OrcDebug * @short_description: Printing and formatting debug information */ diff --git a/orc/orcdebug.h b/orc/orcdebug.h index e71ab5c..7964ab6 100644 --- a/orc/orcdebug.h +++ b/orc/orcdebug.h @@ -33,8 +33,6 @@ ORC_BEGIN_DECLS -#ifdef ORC_ENABLE_UNSTABLE_API - /** * OrcDebugPrintFunc: * @level: the debug level @@ -54,7 +52,7 @@ typedef void (*OrcDebugPrintFunc) (int level, const char *file, /** * OrcDebugLevel: * - * Enumeration describing debug levels in Liborc. + * Enumeration describing debug levels in Orc. */ typedef enum { ORC_DEBUG_NONE = 0, @@ -138,8 +136,6 @@ void _orc_debug_init (void); void orc_debug_print (int level, const char *file, const char *func, int line, const char *format, ...); -#endif - ORC_END_DECLS #endif diff --git a/orc/orcexecutor.c b/orc/orcexecutor.c index a142330..1b25773 100644 --- a/orc/orcexecutor.c +++ b/orc/orcexecutor.c @@ -8,6 +8,12 @@ #include #include +/** + * SECTION:orcexecutor + * @title: OrcExecutor + * @short_description: Running Orc programs + */ + OrcExecutor * orc_executor_new (OrcProgram *program) diff --git a/orc/orcmmx.c b/orc/orcmmx.c index b07c163..1091fcb 100644 --- a/orc/orcmmx.c +++ b/orc/orcmmx.c @@ -12,6 +12,12 @@ #include #include +/** + * SECTION:orcmmx + * @title: MMX + * @short_description: code generation for MMX + */ + const char * orc_x86_get_regname_mmx(int i) diff --git a/orc/orcmmx.h b/orc/orcmmx.h index 631d929..ca5152c 100644 --- a/orc/orcmmx.h +++ b/orc/orcmmx.h @@ -44,6 +44,7 @@ void orc_mmx_emit_0f (OrcCompiler *p, const char *insn_name, int code, void orc_mmx_emit_pshufw (OrcCompiler *p, int shuf, int src, int dest); void orc_mmx_emit_shiftimm (OrcCompiler *p, const char *insn_name, int code, int modrm_code, int shift, int reg); +unsigned int orc_mmx_get_cpu_flags (void); #endif diff --git a/orc/orcopcodes.c b/orc/orcopcodes.c index 20679cf..7a42586 100644 --- a/orc/orcopcodes.c +++ b/orc/orcopcodes.c @@ -8,6 +8,12 @@ #include #include +/** + * SECTION:orcopcode + * @title: OrcOpcode + * @short_description: Operations + */ + static OrcOpcodeSet *opcode_sets; static int n_opcode_sets; diff --git a/orc/orcparse.c b/orc/orcparse.c index 0c25c85..5f3af6f 100644 --- a/orc/orcparse.c +++ b/orc/orcparse.c @@ -10,6 +10,12 @@ #include #include +/** + * SECTION:orcparse + * @title: Parser + * @short_description: Parse Orc source code + */ + typedef struct _OrcParser OrcParser; struct _OrcParser { diff --git a/orc/orcprogram-arm.c b/orc/orcprogram-arm.c index 2f5a108..84e9c9f 100644 --- a/orc/orcprogram-arm.c +++ b/orc/orcprogram-arm.c @@ -15,7 +15,7 @@ #define SIZE 65536 -int orc_arm_exec_ptr = ORC_ARM_R0; +int orc_arm_exec_ptr = ORC_ARM_A1; void orc_arm_emit_loop (OrcCompiler *compiler); @@ -119,7 +119,7 @@ orc_compiler_orc_arm_init (OrcCompiler *compiler) for(i=ORC_GP_REG_BASE;ivalid_regs[i] = 1; } - compiler->valid_regs[ORC_ARM_R0] = 0; + compiler->valid_regs[ORC_ARM_A1] = 0; //compiler->valid_regs[ORC_ARM_SB] = 0; compiler->valid_regs[ORC_ARM_IP] = 0; compiler->valid_regs[ORC_ARM_SP] = 0; diff --git a/orc/orcprogram-mmx.c b/orc/orcprogram-mmx.c index 564f504..c791055 100644 --- a/orc/orcprogram-mmx.c +++ b/orc/orcprogram-mmx.c @@ -13,7 +13,6 @@ #include #include #include -#include #define SIZE 65536 @@ -522,7 +521,7 @@ orc_compiler_mmx_assemble (OrcCompiler *compiler) orc_x86_emit_epilogue (compiler); - x86_do_fixups (compiler); + orc_x86_do_fixups (compiler); } void diff --git a/orc/orcprogram-sse.c b/orc/orcprogram-sse.c index 6710754..1fb6d6f 100644 --- a/orc/orcprogram-sse.c +++ b/orc/orcprogram-sse.c @@ -13,7 +13,6 @@ #include #include #include -#include #define SIZE 65536 @@ -521,7 +520,7 @@ orc_compiler_sse_assemble (OrcCompiler *compiler) orc_x86_emit_epilogue (compiler); - x86_do_fixups (compiler); + orc_x86_do_fixups (compiler); } void diff --git a/orc/orcprogram.c b/orc/orcprogram.c index 2e9cddf..2114382 100644 --- a/orc/orcprogram.c +++ b/orc/orcprogram.c @@ -9,6 +9,12 @@ #include #include +/** + * SECTION:orcprogram + * @title: OrcProgram + * @short_description: Creating and manipulating Orc programs + */ + OrcProgram * orc_program_new (void) diff --git a/orc/orcprogram.h b/orc/orcprogram.h index 7bc33a9..105fbcc 100644 --- a/orc/orcprogram.h +++ b/orc/orcprogram.h @@ -33,9 +33,6 @@ typedef void (*OrcRuleEmitFunc)(OrcCompiler *p, void *user, OrcInstruction *insn #define ORC_GP_REG_BASE 32 #define ORC_VEC_REG_BASE 64 -#define ORC_REGCLASS_GP 1 -#define ORC_REGCLASS_VEC 2 - #define ORC_STATIC_OPCODE_N_SRC 4 #define ORC_STATIC_OPCODE_N_DEST 2 @@ -400,10 +397,6 @@ int orc_program_add_constant (OrcProgram *program, int size, int value, const ch int orc_program_add_parameter (OrcProgram *program, int size, const char *name); int orc_program_add_accumulator (OrcProgram *program, int size, const char *name); -void orc_program_x86_reset_alloc (OrcProgram *program); -void orc_program_powerpc_reset_alloc (OrcProgram *program); - - OrcExecutor * orc_executor_new (OrcProgram *program); void orc_executor_free (OrcExecutor *ex); void orc_executor_set_program (OrcExecutor *ex, OrcProgram *program); @@ -432,16 +425,11 @@ unsigned int orc_target_get_default_flags (OrcTarget *target); const char * orc_target_get_name (OrcTarget *target); int orc_program_allocate_register (OrcProgram *program, int is_data); -int orc_program_x86_allocate_register (OrcProgram *program, int is_data); -int orc_program_powerpc_allocate_register (OrcProgram *program, int is_data); -void orc_program_x86_register_rules (void); void orc_compiler_allocate_codemem (OrcCompiler *compiler); -void orc_program_dump_code (OrcProgram *program); int orc_compiler_label_new (OrcCompiler *compiler); const char *orc_program_get_asm_code (OrcProgram *program); -void orc_program_dump_asm (OrcProgram *program); const char *orc_target_get_asm_preamble (const char *target); void orc_compiler_append_code (OrcCompiler *p, const char *fmt, ...) diff --git a/orc/orcrule.c b/orc/orcrule.c index d2f676d..de57f78 100644 --- a/orc/orcrule.c +++ b/orc/orcrule.c @@ -8,6 +8,12 @@ #include #include +/** + * SECTION:orcrule + * @title: OrcRule + * @short_description: Creating rules for code generation + */ + void orc_rule_register (OrcRuleSet *rule_set, diff --git a/orc/orcsse.c b/orc/orcsse.c index aa68909..ed19339 100644 --- a/orc/orcsse.c +++ b/orc/orcsse.c @@ -12,6 +12,12 @@ #include #include +/** + * SECTION:orcsse + * @title: SSE + * @short_description: code generation for SSE + */ + const char * orc_x86_get_regname_sse(int i) diff --git a/orc/orcsse.h b/orc/orcsse.h index 3d18529..c6cf594 100644 --- a/orc/orcsse.h +++ b/orc/orcsse.h @@ -54,6 +54,7 @@ void orc_sse_emit_pshuflw (OrcCompiler *p, int shuf, int src, int dest); void orc_sse_emit_shiftimm (OrcCompiler *p, const char *insn_name, int code, int modrm_code, int shift, int reg); +unsigned int orc_sse_get_cpu_flags (void); #endif diff --git a/orc/orcutils.c b/orc/orcutils.c index 39aa909..82d9aff 100644 --- a/orc/orcutils.c +++ b/orc/orcutils.c @@ -36,6 +36,12 @@ #include #include +/** + * SECTION:orcutils + * @title: Utility functions + * @short_description: Orc utility functions + */ + int get_file_int (const char *file, int *value) { diff --git a/orc/orcutils.h b/orc/orcutils.h index 31b685e..79ad8e1 100644 --- a/orc/orcutils.h +++ b/orc/orcutils.h @@ -42,7 +42,6 @@ typedef unsigned int orc_bool; #ifdef ORC_ENABLE_UNSTABLE_API #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) -#define DIVIDE_ROUND_UP(a,b) (((a) + (b) - 1)/(b)) #ifndef MIN #define MIN(a,b) ((a)<(b) ? (a) : (b)) #endif @@ -53,12 +52,6 @@ typedef unsigned int orc_bool; #define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x))) #endif #define ORC_PTR_TO_INT(x) ((int)(long)(x)) -#define ROUND_UP_SHIFT(x,y) (((x) + (1<<(y)) - 1)>>(y)) -#define ROUND_UP_POW2(x,y) (((x) + (1<<(y)) - 1)&((~0)<<(y))) -#define ROUND_UP_2(x) ROUND_UP_POW2(x,1) -#define ROUND_UP_4(x) ROUND_UP_POW2(x,2) -#define ROUND_UP_8(x) ROUND_UP_POW2(x,3) -#define ROUND_SHIFT(x,y) (((x) + (1<<((y)-1)))>>(y)) #define ORC_READ_UINT32_LE(ptr) \ ((uint32_t)( \ diff --git a/orc/orcx86.c b/orc/orcx86.c index cd6753e..5c13b86 100644 --- a/orc/orcx86.c +++ b/orc/orcx86.c @@ -14,6 +14,12 @@ #include +/** + * SECTION:orcx86 + * @title: x86 + * @short_description: code generation for x86 + */ + const char * orc_x86_get_regname(int i) { @@ -726,7 +732,7 @@ void orc_x86_emit_label (OrcCompiler *compiler, int label) } void -x86_do_fixups (OrcCompiler *compiler) +orc_x86_do_fixups (OrcCompiler *compiler) { int i; for(i=0;in_fixups;i++){ @@ -824,43 +830,3 @@ orc_x86_emit_align (OrcCompiler *compiler) } } -void -x86_test (OrcCompiler *compiler) -{ - int size; - int i; - int j; - int reg; - - for(size=2;size<=4;size+=2) { - for(i=0;i<8;i++){ - reg = ORC_GP_REG_BASE + i; - orc_x86_emit_push (compiler, size, reg); - orc_x86_emit_pop (compiler, size, reg); - orc_x86_emit_mov_imm_reg (compiler, size, 0, reg); - orc_x86_emit_mov_imm_reg (compiler, size, 1, reg); - orc_x86_emit_mov_imm_reg (compiler, size, 256, reg); - orc_x86_emit_dec_memoffset (compiler, size, 0, reg); - orc_x86_emit_dec_memoffset (compiler, size, 1, reg); - orc_x86_emit_dec_memoffset (compiler, size, 256, reg); - orc_x86_emit_add_imm_memoffset (compiler, size, 1, 0, reg); - orc_x86_emit_add_imm_memoffset (compiler, size, 1, 1, reg); - orc_x86_emit_add_imm_memoffset (compiler, size, 1, 256, reg); - orc_x86_emit_add_imm_memoffset (compiler, size, 256, 0, reg); - orc_x86_emit_add_imm_memoffset (compiler, size, 256, 1, reg); - orc_x86_emit_add_imm_memoffset (compiler, size, 256, 256, reg); - for(j=0;j<8;j++){ - int reg2 = ORC_GP_REG_BASE + j; - orc_x86_emit_mov_reg_reg (compiler, size, reg, reg2); - orc_x86_emit_mov_memoffset_reg (compiler, size, 0, reg, reg2); - orc_x86_emit_mov_memoffset_reg (compiler, size, 1, reg, reg2); - orc_x86_emit_mov_memoffset_reg (compiler, size, 256, reg, reg2); - orc_x86_emit_mov_reg_memoffset (compiler, size, reg, 0, reg2); - orc_x86_emit_mov_reg_memoffset (compiler, size, reg, 1, reg2); - orc_x86_emit_mov_reg_memoffset (compiler, size, reg, 256, reg2); - } - } - } - -} - diff --git a/orc/orcx86.h b/orc/orcx86.h index 6e27a98..1e70d62 100644 --- a/orc/orcx86.h +++ b/orc/orcx86.h @@ -58,14 +58,14 @@ void orc_x86_emit_jne (OrcCompiler *compiler, int label); void orc_x86_emit_jmp (OrcCompiler *compiler, int label); void orc_x86_emit_label (OrcCompiler *compiler, int label); void orc_x86_emit_align (OrcCompiler *compiler); -void x86_do_fixups (OrcCompiler *compiler); void orc_x86_emit_prologue (OrcCompiler *compiler); void orc_x86_emit_epilogue (OrcCompiler *compiler); void orc_x86_emit_rex (OrcCompiler *compiler, int size, int reg1, int reg2, int reg3); void orc_x86_emit_modrm_memoffset (OrcCompiler *compiler, int reg1, int offset, int reg2); void orc_x86_emit_modrm_reg (OrcCompiler *compiler, int reg1, int reg2); -void x86_test (OrcCompiler *compiler); + +void orc_x86_do_fixups (OrcCompiler *compiler); #endif -- 2.7.4