├── .gitignore ├── .travis.yml ├── AUTHORS ├── CMakeLists.txt ├── COPYRIGHT ├── Makefile.am ├── Makefile.in ├── README.md ├── aclocal.m4 ├── build_android.sh ├── build_iphone.sh ├── config.guess ├── config.h.in ├── config.sub ├── configure ├── configure.ac ├── depcomp ├── ffts.pc.cmake.in ├── ffts.pc.in ├── include └── ffts.h ├── install-sh ├── java ├── Makefile.am ├── Makefile.in ├── android │ ├── .classpath │ ├── .project │ ├── .settings │ │ ├── org.eclipse.jdt.core.prefs │ │ └── org.eclipse.ltk.core.refactoring.prefs │ ├── AndroidManifest.xml │ ├── ant.properties │ ├── build.xml │ ├── jni │ │ ├── Android.mk │ │ └── Application.mk │ ├── proguard-project.txt │ └── project.properties ├── jni │ └── ffts_jni.c └── src │ └── nz │ └── ac │ └── waikato │ └── ffts │ └── FFTS.java ├── ltmain.sh ├── m4 ├── ax_check_class.m4 ├── ax_check_classpath.m4 ├── ax_check_java_home.m4 ├── ax_check_java_plugin.m4 ├── ax_java_check_class.m4 ├── ax_java_options.m4 ├── ax_jni_include_dir.m4 ├── ax_prog_jar.m4 ├── ax_prog_java.m4 ├── ax_prog_java_cc.m4 ├── ax_prog_java_works.m4 ├── ax_prog_javac.m4 ├── ax_prog_javac_works.m4 ├── ax_prog_javadoc.m4 ├── ax_prog_javah.m4 ├── ax_try_compile_java.m4 └── ax_try_run_java.m4 ├── missing ├── src ├── Makefile.am ├── Makefile.in ├── arch │ ├── .gitignore │ ├── ChangeLog │ ├── LICENSE │ ├── Makefile.am │ ├── README │ ├── arm │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── arm-codegen.c │ │ ├── arm-codegen.h │ │ ├── arm-dis.c │ │ ├── arm-dis.h │ │ ├── arm-vfp-codegen.h │ │ ├── arm-wmmx.h │ │ ├── cmp_macros.th │ │ ├── dpi_macros.th │ │ ├── dpiops.sh │ │ ├── mov_macros.th │ │ ├── tramp.c │ │ ├── vfp_macros.th │ │ ├── vfpm_macros.th │ │ └── vfpops.sh │ ├── arm64 │ │ ├── .gitignore │ │ ├── Makefile.am │ │ └── arm64-codegen.h │ ├── ia64 │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── codegen.c │ │ └── ia64-codegen.h │ ├── mips │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── mips-codegen.h │ │ └── test.c │ ├── ppc │ │ ├── .gitignore │ │ ├── Makefile.am │ │ └── ppc-codegen.h │ ├── s390x │ │ ├── .gitignore │ │ ├── ChangeLog │ │ ├── Makefile.am │ │ ├── s390x-codegen.h │ │ └── tramp.c │ ├── sparc │ │ ├── .gitignore │ │ ├── Makefile.am │ │ ├── sparc-codegen.h │ │ ├── test.c │ │ └── tramp.c │ ├── x64 │ │ ├── .gitignore │ │ ├── Makefile.am │ │ └── x64-codegen.h │ └── x86 │ │ ├── .gitignore │ │ ├── Makefile.am │ │ └── x86-codegen.h ├── codegen.c ├── codegen.h ├── codegen_arm.h ├── codegen_sse.h ├── ffts.c ├── ffts_attributes.h ├── ffts_chirp_z.c ├── ffts_chirp_z.h ├── ffts_dd.h ├── ffts_internal.h ├── ffts_nd.c ├── ffts_nd.h ├── ffts_real.c ├── ffts_real.h ├── ffts_real_nd.c ├── ffts_real_nd.h ├── ffts_static.c ├── ffts_static.h ├── ffts_transpose.c ├── ffts_transpose.h ├── ffts_trig.c ├── ffts_trig.h ├── macros-alpha.h ├── macros-altivec.h ├── macros-neon.h ├── macros-sse.h ├── macros.h ├── neon.h ├── neon.s ├── neon_static.s ├── patterns.h ├── sequitur.h ├── types.h ├── vfp.h └── vfp.s └── tests ├── Makefile.am ├── Makefile.in └── test.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.Po 3 | *.a 4 | *.la 5 | *.lai 6 | *.lo 7 | *.Plo 8 | *.so 9 | *~ 10 | *.log 11 | *.swp 12 | *.cache/* 13 | 14 | *Makefile 15 | 16 | config.h 17 | config.status 18 | compile 19 | libtool 20 | ffts.pc 21 | stamp-h1 22 | tests/test 23 | 24 | java/android/local.properties 25 | java/android/gen/* 26 | java/android/obj/* 27 | java/android/bin/* 28 | 29 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: c 2 | os: 3 | - linux 4 | - osx 5 | addons: 6 | apt: 7 | packages: 8 | - cmake 9 | sources: 10 | - kubuntu-backports 11 | script: 12 | - mkdir build && cd build && cmake .. && cmake --build . 13 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | FFTS was developed at the University of Waikato by Anthony Blake 2 | 3 | The following authors have also graciously contributed code: 4 | 5 | Michael Zucchi -- JNI java/android support 6 | Michael Cree -- Architecture specific code, including support for Altivec and DEC Alpha 7 | -------------------------------------------------------------------------------- /COPYRIGHT: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, 2013 Anthony M. Blake 6 | 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the organization nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | AUTOMAKE_OPTIONS = foreign 2 | SUBDIRS = src tests 3 | EXTRA_DIST=COPYRIGHT ffts.pc.in build_iphone.sh build_android.sh 4 | ACLOCAL_AMFLAGS = -Im4 5 | 6 | pkgconfigdir = $(libdir)/pkgconfig 7 | pkgconfig_DATA = ffts.pc 8 | 9 | if ENABLE_JNI 10 | SUBDIRS += java 11 | endif 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Please see more recently updated forks: 2 | 3 | https://github.com/linkotec/ffts 4 | 5 | https://github.com/ValveSoftware/ffts 6 | 7 | Sorry, but I haven't been able to touch this for many years! 8 | 9 | # FFTS -- The Fastest Fourier Transform in the South 10 | 11 | [![Build Status](https://travis-ci.org/linkotec/ffts.svg?branch=master)](https://travis-ci.org/linkotec/ffts) 12 | 13 | To build for Android, edit and run build_android.sh 14 | 15 | To build for iOS, edit and run build_iphone.sh 16 | 17 | To build for Linux or OS X on x86, run 18 | ./configure --enable-sse --enable-single --prefix=/usr/local 19 | make 20 | make install 21 | 22 | Optionally build for Windows and Linux with CMake, run 23 | mkdir build 24 | cd build 25 | cmake .. 26 | 27 | FFTS dynamically generates code at runtime. This can be disabled with 28 | --disable-dynamic-code 29 | 30 | Note that 32 bit x86 dynamic machine code generation is not supported at the moment. 31 | 32 | For JNI targets: --enable-jni will build the jni stuff automatically for 33 | the host target, and --enable-shared must also be added manually for it to 34 | work. 35 | 36 | -------------------------------------------------------------------------------- /build_android.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Compiles ffts for Android 3 | # Make sure you have NDK_ROOT defined in .bashrc or .bash_profile 4 | # Modify INSTALL_DIR to suit your situation 5 | 6 | INSTALL_DIR="`pwd`/java/android/bin" 7 | 8 | PLATFORM=android-8 9 | TOOL="4.6" 10 | 11 | case $(uname -s) in 12 | Darwin) 13 | CONFBUILD=i386-apple-darwin`uname -r` 14 | HOSTPLAT=darwin-x86 15 | ;; 16 | Linux) 17 | CONFBUILD=x86-unknown-linux 18 | HOSTPLAT=linux-`uname -m` 19 | ;; 20 | *) echo $0: Unknown platform; exit 21 | esac 22 | 23 | case arm in 24 | arm) 25 | TARGPLAT=arm-linux-androideabi 26 | ARCH=arm 27 | CONFTARG=arm-eabi 28 | ;; 29 | x86) 30 | TARGPLAT=x86 31 | ARCH=x86 32 | CONFTARG=x86 33 | ;; 34 | mips) 35 | ## probably wrong 36 | TARGPLAT=mipsel-linux-android 37 | ARCH=mips 38 | CONFTARG=mips 39 | ;; 40 | *) echo $0: Unknown target; exit 41 | esac 42 | 43 | : ${NDK_ROOT:?} 44 | 45 | echo "Using: $NDK_ROOT/toolchains/${TARGPLAT}-${TOOL}/prebuilt/${HOSTPLAT}/bin" 46 | 47 | export PATH="$NDK_ROOT/toolchains/${TARGPLAT}-${TOOL}/prebuilt/${HOSTPLAT}/bin/:$PATH" 48 | export SYS_ROOT="$NDK_ROOT/platforms/${PLATFORM}/arch-${ARCH}/" 49 | export CC="${TARGPLAT}-gcc --sysroot=$SYS_ROOT" 50 | export LD="${TARGPLAT}-ld" 51 | export AR="${TARGPLAT}-ar" 52 | export RANLIB="${TARGPLAT}-ranlib" 53 | export STRIP="${TARGPLAT}-strip" 54 | export CFLAGS="-Os" 55 | 56 | mkdir -p $INSTALL_DIR 57 | ./configure --enable-neon --build=${CONFBUILD} --host=${CONFTARG} --prefix=$INSTALL_DIR LIBS="-lc -lgcc" 58 | 59 | make clean 60 | make 61 | make install 62 | 63 | if [ -z "$ANDROID_HOME" ] ; then 64 | echo "" 65 | echo " No ANDROID_HOME defined" 66 | echo " Android JNI interfaces will not be built" 67 | echo 68 | else 69 | echo 70 | echo "Using android_home ${ANDROID_HOME}" 71 | echo 72 | ( cd java/android ; ${ANDROID_HOME}/tools/android update lib-project -p . ) || exit 1 73 | ( cd java/android/jni ; ${NDK_ROOT}/ndk-build V=1 ) || exit 1 74 | ( cd java/android ; ant release ) || exit 1 75 | echo 76 | echo "Android library project location:" 77 | echo " `pwd`/java/android" 78 | echo 79 | fi 80 | exit 0 81 | -------------------------------------------------------------------------------- /build_iphone.sh: -------------------------------------------------------------------------------- 1 | #/bin/sh 2 | # Compiles ffts for iOS 3 | # Modify INSTALL_DIR, SDKVER and DEVROOT to suit your situation 4 | 5 | INSTALL_DIR="`pwd`/build" 6 | 7 | export SDKVER="6.1" 8 | export DEVROOT="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer" 9 | export SDKROOT="$DEVROOT/SDKs/iPhoneOS$SDKVER.sdk" 10 | export CFLAGS="-O3 -Wreturn-type -Wparentheses -Wswitch -Wno-unused-parameter -Wno-unused-variable -Wunused-value -Wno-shorten-64-to-32 -Wno-trigraphs -fpascal-strings -miphoneos-version-min=5.0 -mcpu=cortex-a9 -arch armv7 -mfpu=neon -pipe -isysroot $SDKROOT -isystem $SDKROOT/usr/include -isystem $DEVROOT/usr/include -mno-thumb -no-integrated-as" 11 | export AR="$DEVROOT/usr/bin/ar" 12 | export CC="clang" 13 | 14 | 15 | mkdir -p $INSTALL_DIR 16 | ./configure --enable-neon --build=i386-apple-darwin`uname -r` --host=arm-eabi --prefix=$INSTALL_DIR 17 | 18 | make clean 19 | make 20 | make install 21 | 22 | exit 0 23 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to disable dynamic code generation. */ 4 | #undef DYNAMIC_DISABLED 5 | 6 | /* JNI being built. */ 7 | #undef ENABLE_JNI 8 | 9 | /* Define to FFT in single precision. */ 10 | #undef FFTS_PREC_SINGLE 11 | 12 | /* Define to 1 if you have the declaration of `memalign', and to 0 if you 13 | don't. */ 14 | #undef HAVE_DECL_MEMALIGN 15 | 16 | /* Define to 1 if you have the declaration of `posix_memalign', and to 0 if 17 | you don't. */ 18 | #undef HAVE_DECL_POSIX_MEMALIGN 19 | 20 | /* Define to 1 if you have the header file. */ 21 | #undef HAVE_DLFCN_H 22 | 23 | /* Define to 1 if you have the `gettimeofday' function. */ 24 | #undef HAVE_GETTIMEOFDAY 25 | 26 | /* Define to 1 if you have the header file. */ 27 | #undef HAVE_INTTYPES_H 28 | 29 | /* Define to 1 if you have the `m' library (-lm). */ 30 | #undef HAVE_LIBM 31 | 32 | /* Define to 1 if you have the header file. */ 33 | #undef HAVE_MEMORY_H 34 | 35 | /* Define to FFT with ARM NEON. */ 36 | #undef HAVE_NEON 37 | 38 | /* Define to 1 if you have the `pow' function. */ 39 | #undef HAVE_POW 40 | 41 | /* Define to FFT with SSE. */ 42 | #undef HAVE_SSE 43 | 44 | /* Define to 1 if stdbool.h conforms to C99. */ 45 | #undef HAVE_STDBOOL_H 46 | 47 | /* Define to 1 if you have the header file. */ 48 | #undef HAVE_STDINT_H 49 | 50 | /* Define to 1 if you have the header file. */ 51 | #undef HAVE_STDLIB_H 52 | 53 | /* Define to 1 if you have the header file. */ 54 | #undef HAVE_STRINGS_H 55 | 56 | /* Define to 1 if you have the header file. */ 57 | #undef HAVE_STRING_H 58 | 59 | /* Define to 1 if you have the header file. */ 60 | #undef HAVE_SYS_SOCKET_H 61 | 62 | /* Define to 1 if you have the header file. */ 63 | #undef HAVE_SYS_STAT_H 64 | 65 | /* Define to 1 if you have the header file. */ 66 | #undef HAVE_SYS_TIME_H 67 | 68 | /* Define to 1 if you have the header file. */ 69 | #undef HAVE_SYS_TYPES_H 70 | 71 | /* Define to 1 if you have the header file. */ 72 | #undef HAVE_UNISTD_H 73 | 74 | /* Define to FFT with ARM VFP. */ 75 | #undef HAVE_VFP 76 | 77 | /* Define to 1 if the system has the type `_Bool'. */ 78 | #undef HAVE__BOOL 79 | 80 | /* Define to the sub-directory in which libtool stores uninstalled libraries. 81 | */ 82 | #undef LT_OBJDIR 83 | 84 | /* Name of package */ 85 | #undef PACKAGE 86 | 87 | /* Define to the address where bug reports for this package should be sent. */ 88 | #undef PACKAGE_BUGREPORT 89 | 90 | /* Define to the full name of this package. */ 91 | #undef PACKAGE_NAME 92 | 93 | /* Define to the full name and version of this package. */ 94 | #undef PACKAGE_STRING 95 | 96 | /* Define to the one symbol short name of this package. */ 97 | #undef PACKAGE_TARNAME 98 | 99 | /* Define to the home page for this package. */ 100 | #undef PACKAGE_URL 101 | 102 | /* Define to the version of this package. */ 103 | #undef PACKAGE_VERSION 104 | 105 | /* Define to 1 if you have the ANSI C header files. */ 106 | #undef STDC_HEADERS 107 | 108 | /* Version number of package */ 109 | #undef VERSION 110 | 111 | /* Define for Solaris 2.5.1 so the uint64_t typedef from , 112 | , or is not used. If the typedef were allowed, the 113 | #define below would cause a syntax error. */ 114 | #undef _UINT64_T 115 | 116 | /* Define to `__inline__' or `__inline' if that's what the C compiler 117 | calls it, or to nothing if 'inline' is not supported under any name. */ 118 | #ifndef __cplusplus 119 | #undef inline 120 | #endif 121 | 122 | /* Define to the type of a signed integer type of width exactly 32 bits if 123 | such a type exists and the standard includes do not define it. */ 124 | #undef int32_t 125 | 126 | /* Define to the equivalent of the C99 'restrict' keyword, or to 127 | nothing if this is not supported. Do not define if restrict is 128 | supported directly. */ 129 | #undef restrict 130 | /* Work around a bug in Sun C++: it does not support _Restrict or 131 | __restrict__, even though the corresponding Sun C compiler ends up with 132 | "#define restrict _Restrict" or "#define restrict __restrict__" in the 133 | previous line. Perhaps some future version of Sun C++ will work with 134 | restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ 135 | #if defined __SUNPRO_CC && !defined __RESTRICT 136 | # define _Restrict 137 | # define __restrict__ 138 | #endif 139 | 140 | /* Define to `unsigned int' if does not define. */ 141 | #undef size_t 142 | 143 | /* Define to the type of an unsigned integer type of width exactly 64 bits if 144 | such a type exists and the standard includes do not define it. */ 145 | #undef uint64_t 146 | 147 | // vim: set autoindent noexpandtab tabstop=3 shiftwidth=3: 148 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ([2.65]) 5 | AC_INIT(ffts, 0.7, amb@anthonix.com) 6 | AM_INIT_AUTOMAKE(ffts, 0.7) 7 | 8 | AC_CONFIG_MACRO_DIR([m4]) 9 | 10 | # AC_CONFIG_SRCDIR([include/common.h]) 11 | AC_CONFIG_HEADERS([config.h]) 12 | 13 | AC_CANONICAL_HOST 14 | 15 | # Checks for programs. 16 | AC_PROG_CXX 17 | AC_PROG_CC 18 | #AX_COMPILER_VENDOR 19 | LT_INIT([disable-shared]) 20 | AM_PROG_AS 21 | #CXX="clang++" 22 | #CXXFLAGS="$CXXFLAGS -stdlib=libc++" 23 | 24 | #SFFT_AR="/usr/bin/ar" 25 | #SFFT_CFLAGS="$CFLAGS" 26 | #SFFT_CC="$CC" 27 | AC_ARG_ENABLE(dynamic-code, [AC_HELP_STRING([--enable-dynamic-code],[dynamically generate code])], sfft_dynamic=$enableval, sfft_dynamic=yes) 28 | if test "$sfft_dynamic" = "no"; then 29 | AC_DEFINE(DYNAMIC_DISABLED,1,[Define to disable dynamic code generation.]) 30 | fi 31 | AM_CONDITIONAL(DYNAMIC_DISABLED, test "$sfft_dynamic" = "no") 32 | 33 | AC_ARG_ENABLE(single, [AC_HELP_STRING([--enable-single],[compile single-precision library])], sfft_single=$enableval, sfft_single=no) 34 | if test "$sfft_single" = "yes"; then 35 | AC_DEFINE(FFTS_PREC_SINGLE,1,[Define to FFT in single precision.]) 36 | fi 37 | if test "$sfft_single" = "no"; then 38 | AC_DEFINE(FFTS_PREC_SINGLE,0,[Define to FFT in single precision.]) 39 | fi 40 | 41 | AC_ARG_ENABLE(sse, [AC_HELP_STRING([--enable-sse],[enable SSE extensions])], have_sse=$enableval, have_sse=no) 42 | if test "$have_sse" = "yes"; then 43 | SIMD=sse 44 | AC_DEFINE(HAVE_SSE,1,[Define to FFT with SSE.]) 45 | fi 46 | AM_CONDITIONAL(HAVE_SSE, test "$have_sse" = "yes") 47 | 48 | AC_ARG_ENABLE(neon, [AC_HELP_STRING([--enable-neon],[enable NEON extensions])], have_neon=$enableval, have_neon=no) 49 | if test "$have_neon" = "yes"; then 50 | AC_DEFINE(HAVE_NEON,1,[Define to FFT with ARM NEON.]) 51 | fi 52 | AM_CONDITIONAL(HAVE_NEON, test "$have_neon" = "yes") 53 | 54 | AC_ARG_ENABLE(vfp, [AC_HELP_STRING([--enable-vfp],[enable VFP extensions])], have_vfp=$enableval, have_vfp=no) 55 | if test "$have_vfp" = "yes"; then 56 | AC_DEFINE(HAVE_VFP,1,[Define to FFT with ARM VFP.]) 57 | fi 58 | AM_CONDITIONAL(HAVE_VFP, test "$have_vfp" = "yes") 59 | 60 | AC_ARG_WITH(float-abi, [AS_HELP_STRING([--with-float-abi=ABI],[set float abi for arm, hard or softfp (default is softfp)])], 61 | float_abi=$withval, float_abi=softfp) 62 | 63 | AC_ARG_ENABLE(jni, [AC_HELP_STRING([--enable-jni],[enable JNI binding])], have_jni=$enableval, have_jni=no) 64 | if test "$have_jni" = "yes"; then 65 | # Java stuff 66 | AX_JAVA_OPTIONS 67 | AC_CHECK_JAVA_HOME 68 | AC_CHECK_CLASSPATH 69 | AC_PROG_JAVAC 70 | # blah this whinges about something 71 | #AC_PROG_JAVAH 72 | AC_PROG_JAR 73 | AX_JNI_INCLUDE_DIR 74 | for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS 75 | do 76 | JNI_CPPFLAGS="$JNI_CPPFLAGS -I$JNI_INCLUDE_DIR" 77 | done 78 | AC_SUBST(JNI_CPPFLAGS, [$JNI_CPPFLAGS]) 79 | 80 | AC_DEFINE(ENABLE_JNI,1,[JNI being built.]) 81 | fi 82 | AM_CONDITIONAL(ENABLE_JNI, test "$have_jni" = "yes") 83 | 84 | fpu="" 85 | AS_IF([test "$have_vfp" = "yes"],[fpu="-mfpu=vfp"], 86 | [test "$have_neon" = "yes"],[fpu="-mfpu=neon"], 87 | []) 88 | 89 | AC_MSG_NOTICE([host is "${host}"]) 90 | case "${host}" in 91 | arm* ) 92 | CFLAGS="$CFLAGS -mfloat-abi=${float_abi} ${fpu} -std=c99" 93 | CCASFLAGS="$CCASFLAGS -mfloat-abi=${float_abi} ${fpu}" 94 | ;; 95 | *) 96 | ;; 97 | esac 98 | 99 | #if test "$ord_sr" = "no"; then 100 | # AC_DEFINE(SFFT_ORD_SR,0,[Define to enable ordinary split radix.]) 101 | #fi 102 | 103 | # Checks for libraries. 104 | AC_CHECK_LIB([m], [cos]) 105 | AC_CHECK_DECLS([posix_memalign, 106 | memalign],,, 107 | [#define _XOPEN_SOURCE 600 108 | #include 109 | #include ]) 110 | 111 | # Checks for header files. 112 | AC_CHECK_HEADERS([malloc.h stddef.h stdint.h stdlib.h string.h sys/mman.h sys/socket.h sys/time.h unistd.h]) 113 | 114 | # Checks for typedefs, structures, and compiler characteristics. 115 | AC_HEADER_STDBOOL 116 | AC_C_INLINE 117 | AC_TYPE_INT32_T 118 | AC_C_RESTRICT 119 | AC_TYPE_SIZE_T 120 | AC_TYPE_UINT64_T 121 | AC_PROG_CC_STDC 122 | AC_PROG_INSTALL 123 | AC_PROG_LN_S 124 | AC_PROG_LIBTOOL 125 | 126 | # Checks for library functions. 127 | #AC_FUNC_MALLOC 128 | AC_CHECK_FUNCS([gettimeofday pow]) 129 | 130 | 131 | AC_CONFIG_FILES([Makefile 132 | src/Makefile 133 | tests/Makefile 134 | ffts.pc 135 | java/Makefile 136 | ]) 137 | AC_OUTPUT 138 | -------------------------------------------------------------------------------- /ffts.pc.cmake.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${exec_prefix} 3 | libdir=${libdir} 4 | includedir=${includedir} 5 | 6 | Name: @CMAKE_PROJECT_NAME@ 7 | Description: fast Fourier transform library 8 | Version: @FFTS_VERSION@ 9 | Libs: -L${libdir} -lffts -lm 10 | Cflags: -I${includedir}/ffts 11 | -------------------------------------------------------------------------------- /ffts.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: FFTS 7 | Description: fast Fourier transform library 8 | Version: @VERSION@ 9 | Libs: -L${libdir} -lffts -lm 10 | Cflags: -I${includedir}/ffts 11 | -------------------------------------------------------------------------------- /include/ffts.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS. 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the organization nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | #ifndef FFTS_H 33 | #define FFTS_H 34 | 35 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 36 | #pragma once 37 | #endif 38 | 39 | #include 40 | 41 | #ifdef __cplusplus 42 | extern "C" { 43 | #endif 44 | 45 | #if (defined(_WIN32) || defined(WIN32)) && defined(FFTS_SHARED) 46 | # ifdef FFTS_BUILD 47 | # define FFTS_API __declspec(dllexport) 48 | # else 49 | # define FFTS_API __declspec(dllimport) 50 | # endif 51 | #else 52 | # if (__GNUC__ >= 4) || defined(HAVE_GCC_VISIBILITY) 53 | # define FFTS_API __attribute__ ((visibility("default"))) 54 | # else 55 | # define FFTS_API 56 | # endif 57 | #endif 58 | 59 | /* The direction of the transform 60 | (i.e, the sign of the exponent in the transform.) 61 | */ 62 | #define FFTS_FORWARD (-1) 63 | #define FFTS_BACKWARD (+1) 64 | 65 | struct _ffts_plan_t; 66 | typedef struct _ffts_plan_t ffts_plan_t; 67 | 68 | /* Complex data is stored in the interleaved format 69 | (i.e, the real and imaginary parts composing each 70 | element of complex data are stored adjacently in memory) 71 | 72 | The multi-dimensional arrays passed are expected to be 73 | stored as a single contiguous block in row-major order 74 | */ 75 | FFTS_API ffts_plan_t* 76 | ffts_init_1d(size_t N, int sign); 77 | 78 | FFTS_API ffts_plan_t* 79 | ffts_init_2d(size_t N1, size_t N2, int sign); 80 | 81 | FFTS_API ffts_plan_t* 82 | ffts_init_nd(int rank, size_t *Ns, int sign); 83 | 84 | /* For real transforms, sign == FFTS_FORWARD implies a real-to-complex 85 | forwards tranform, and sign == FFTS_BACKWARD implies a complex-to-real 86 | backwards transform. 87 | 88 | The output of a real-to-complex transform is N/2+1 complex numbers, 89 | where the redundant outputs have been omitted. 90 | */ 91 | FFTS_API ffts_plan_t* 92 | ffts_init_1d_real(size_t N, int sign); 93 | 94 | FFTS_API ffts_plan_t* 95 | ffts_init_2d_real(size_t N1, size_t N2, int sign); 96 | 97 | FFTS_API ffts_plan_t* 98 | ffts_init_nd_real(int rank, size_t *Ns, int sign); 99 | 100 | FFTS_API void 101 | ffts_execute(ffts_plan_t *p, const void *input, void *output); 102 | 103 | FFTS_API void 104 | ffts_free(ffts_plan_t *p); 105 | 106 | #ifdef __cplusplus 107 | } 108 | #endif 109 | 110 | #endif /* FFTS_H */ 111 | -------------------------------------------------------------------------------- /java/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | # TODO: the ax_prog_javah thing doesn't work so this 3 | # requires javah in the path 4 | 5 | if ENABLE_JNI 6 | JAVA_SRC=$(shell find $(srcdir)/src -name '*.java') 7 | 8 | BUILT_SOURCES = nz_ac_waikato_ffts_FFTS.h 9 | 10 | all: ffts.jar 11 | 12 | classes ffts.jar: $(JAVA_SRC) 13 | -rm -rf classes 14 | mkdir classes 15 | $(JAVAC) -d classes -sourcepath src $(JAVA_SRC) 16 | $(JAR) -cf ffts.jar -C classes . 17 | 18 | lib_LTLIBRARIES = libffts_jni.la 19 | libffts_jni_la_SOURCES = jni/ffts_jni.c 20 | nodist_include_HEADERS = nz_ac_waikato_ffts_FFTS.h 21 | libffts_jni_la_LIBADD = $(top_builddir)/src/libffts.la 22 | libffts_jni_la_CFLAGS = @JNI_CPPFLAGS@ $(AM_CFLAGS) -I$(top_srcdir)/include 23 | libffts_jni_la_LDFLAGS = -shared 24 | 25 | pkgdata_DATA = ffts.jar 26 | 27 | nz_ac_waikato_ffts_FFTS.h: classes 28 | javah -cp $< nz.ac.waikato.ffts.FFTS 29 | 30 | CLEANFILES=ffts.jar nz_ac_waikato_ffts_FFTS.h 31 | clean-local: 32 | -rm -rf classes 33 | endif 34 | -------------------------------------------------------------------------------- /java/android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /java/android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | ffts-android 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | 35 | src 36 | 2 37 | PARENT-1-PROJECT_LOC/src 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /java/android/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /java/android/.settings/org.eclipse.ltk.core.refactoring.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.ltk.core.refactoring.enable.project.refactoring.history=false 3 | -------------------------------------------------------------------------------- /java/android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /java/android/ant.properties: -------------------------------------------------------------------------------- 1 | # This file is used to override default values used by the Ant build system. 2 | # 3 | # This file must be checked into Version Control Systems, as it is 4 | # integral to the build system of your project. 5 | 6 | # This file is only used by the Ant script. 7 | 8 | # You can use this to override default values such as 9 | # 'source.dir' for the location of your java source folder and 10 | # 'out.dir' for the location of your output folder. 11 | source.dir=../src 12 | 13 | # You can also use it define how the release builds are signed by declaring 14 | # the following properties: 15 | # 'key.store' for the location of your keystore and 16 | # 'key.alias' for the name of the key to use. 17 | # The password will be asked during the build when you use the 'release' target. 18 | 19 | -------------------------------------------------------------------------------- /java/android/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 69 | 70 | 71 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /java/android/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | TOP=../../.. 4 | 5 | # Include the shared library 6 | #include $(CLEAR_VARS) 7 | #LOCAL_MODULE := ffts 8 | #LOCAL_SRC_FILES := ../../../src/.libs/libffts.so 9 | #include $(PREBUILT_SHARED_LIBRARY) 10 | 11 | # Include the static library in shared lib 12 | include $(CLEAR_VARS) 13 | LOCAL_MODULE := ffts 14 | LOCAL_SRC_FILES := $(TOP)/java/android/bin/lib/libffts.a 15 | LOCAL_EXPORT_C_INCLUDES := $(TOP)/include 16 | include $(PREBUILT_STATIC_LIBRARY) 17 | 18 | include $(CLEAR_VARS) 19 | LOCAL_MODULE := ffts_jni 20 | LOCAL_CFLAGS := -I$(TOP)/include -I$(TOP)/java/jni -I$(TOP) -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast 21 | LOCAL_SRC_FILES := $(TOP)/java/jni/ffts_jni.c 22 | LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog 23 | LOCAL_STATIC_LIBRARIES := ffts 24 | 25 | include $(BUILD_SHARED_LIBRARY) 26 | -------------------------------------------------------------------------------- /java/android/jni/Application.mk: -------------------------------------------------------------------------------- 1 | # requires NEON atm 2 | APP_ABI := armeabi-v7a 3 | -------------------------------------------------------------------------------- /java/android/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /java/android/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | android.library=true 14 | # Project target. 15 | target=android-10 16 | -------------------------------------------------------------------------------- /java/src/nz/ac/waikato/ffts/FFTS.java: -------------------------------------------------------------------------------- 1 | /* 2 | * This file is part of FFTS -- The Fastest Fourier Transform in the South 3 | * 4 | * Copyright (c) 2013, Michael Zucchi 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions are met: 10 | * 11 | * * Redistributions of source code must retain the above copyright 12 | * notice, this list of conditions and the following disclaimer. 13 | * * Redistributions in binary form must reproduce the above copyright 14 | * notice, this list of conditions and the following disclaimer in the 15 | * documentation and/or other materials provided with the distribution. 16 | * * Neither the name of the organization nor the 17 | * names of its contributors may be used to endorse or promote products 18 | * derived from this software without specific prior written permission. 19 | * 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | * DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 24 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | package nz.ac.waikato.ffts; 32 | 33 | import java.nio.FloatBuffer; 34 | 35 | /** 36 | * A java wrapper for ffts plans. 37 | * 38 | * Plans must currently be freed explicitly. 39 | * 40 | * @author notzed 41 | */ 42 | public class FFTS { 43 | 44 | /** 45 | * C pointer 46 | */ 47 | private long p; 48 | /** 49 | * Minimum size of input 50 | */ 51 | final protected long inSize; 52 | /** 53 | * Minimum size of output 54 | */ 55 | final protected long outSize; 56 | 57 | private FFTS(long p, long inSize) { 58 | this(p, inSize, inSize); 59 | } 60 | 61 | private FFTS(long p, long inSize, long outSize) { 62 | this.p = p; 63 | this.inSize = inSize; 64 | this.outSize = inSize; 65 | } 66 | /** 67 | * The sign to use for a forward transform. 68 | */ 69 | public static final int FORWARD = -1; 70 | /** 71 | * The sign to use for a backward transform. 72 | */ 73 | public static final int BACKWARD = 1; 74 | 75 | /** 76 | * Create a FFT plan for a 1-dimensional complex transform. 77 | * 78 | * The src and dst parameters to execute() use complex data. 79 | * 80 | * @param sign The direction of the transform. 81 | * @param N The size of the transform. 82 | * @return 83 | */ 84 | public static FFTS complex(int sign, int N) { 85 | return new FFTS(complex_1d(N, sign), N * 2); 86 | } 87 | 88 | /** 89 | * Create a FFT plan for a 2-dimensional complex transform. 90 | * @param sign The direction of the transform. 91 | * @param N1 The size of the transform. 92 | * @param N2 The size of the transform. 93 | * @return 94 | */ 95 | public static FFTS complex(int sign, int N1, int N2) { 96 | return new FFTS(complex_2d(N1, N2, sign), N1 * N2 * 2); 97 | } 98 | 99 | public static FFTS complex(int sign, int... Ns) { 100 | return new FFTS(complex_nd(Ns, sign), size(Ns) * 2); 101 | } 102 | 103 | public static FFTS real(int sign, int N) { 104 | return new FFTS(real_1d(N, sign), sign == FORWARD ? N : (N / 2 + 1) * 2, sign == FORWARD ? (N / 2 + 1) * 2 : N); 105 | } 106 | 107 | public static FFTS real(int sign, int N1, int N2) { 108 | return new FFTS(real_2d(N1, N2, sign), sign == FORWARD ? N1 * N2 : (N1 * N2 / 2 + 1) * 2, sign == FORWARD ? (N1 * N2 / 2 + 1) * 2 : N1 * N2); 109 | } 110 | 111 | public static FFTS real(int sign, int... Ns) { 112 | return new FFTS(real_nd(Ns, sign), sign == FORWARD ? size(Ns) : (size(Ns) / 2 + 1) * 2, sign == FORWARD ? (size(Ns) / 2 + 1) * 2 : size(Ns)); 113 | } 114 | 115 | /** 116 | * Execute this plan with the given array data. 117 | * 118 | * @param src 119 | * @param dst 120 | */ 121 | public void execute(float[] src, float[] dst) { 122 | execute(src, 0, dst, 0); 123 | } 124 | 125 | /** 126 | * Execute this plan with the given array data. 127 | * @param src 128 | * @param soff Start offset into src array. 129 | * @param dst 130 | * @param doff Start offset into dst array. 131 | */ 132 | public void execute(float[] src, int soff, float[] dst, int doff) { 133 | if (src.length - soff < inSize || dst.length - doff < outSize) 134 | throw new ArrayIndexOutOfBoundsException(); 135 | if (p == 0) 136 | throw new NullPointerException(); 137 | 138 | execute(p, inSize, src, soff, dst, doff); 139 | } 140 | 141 | /** 142 | * Execute this plan with the given nio buffers. The bufffers 143 | * must be derived from direct buffers. 144 | * 145 | * The buffer position and limits are ignored. 146 | * 147 | * @param src 148 | * @param dst 149 | */ 150 | public void execute(FloatBuffer src, FloatBuffer dst) { 151 | if (src.capacity() < inSize || dst.capacity() < outSize) 152 | throw new ArrayIndexOutOfBoundsException(); 153 | if (p == 0) 154 | throw new NullPointerException(); 155 | 156 | execute(p, inSize, src, dst); 157 | } 158 | 159 | /** 160 | * Free the plan. 161 | */ 162 | public void free() { 163 | if (p == 0) 164 | throw new NullPointerException(); 165 | free(p); 166 | } 167 | 168 | /* 169 | * Calculate the number of elements required to store one 170 | * set of n-dimensional data. 171 | */ 172 | protected static long size(int[] Ns) { 173 | long s = Ns[0]; 174 | for (int i = 1; i < Ns.length; i++) 175 | s *= Ns[i]; 176 | return s; 177 | } 178 | 179 | static { 180 | System.loadLibrary("ffts_jni"); 181 | } 182 | 183 | /* 184 | * Native interface 185 | */ 186 | protected static native long complex_1d(int N, int sign); 187 | 188 | protected static native long complex_2d(int N1, int N2, int sign); 189 | 190 | protected static native long complex_nd(int[] Ns, int sign); 191 | 192 | protected static native long real_1d(int N, int sign); 193 | 194 | protected static native long real_2d(int N1, int N2, int sign); 195 | 196 | protected static native long real_nd(int[] Ns, int sign); 197 | 198 | protected static native void execute(long p, long size, float[] src, int soff, float[] dst, int doff); 199 | 200 | protected static native void execute(long p, long size, FloatBuffer src, FloatBuffer dst); 201 | 202 | protected static native void free(long p); 203 | } 204 | -------------------------------------------------------------------------------- /m4/ax_check_class.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_class.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_CLASS 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_CHECK_CLASS tests the existence of a given Java class, either in a 12 | # jar or in a '.class' file. 13 | # 14 | # *Warning*: its success or failure can depend on a proper setting of the 15 | # CLASSPATH env. variable. 16 | # 17 | # Note: This is part of the set of autoconf M4 macros for Java programs. 18 | # It is VERY IMPORTANT that you download the whole set, some macros depend 19 | # on other. Unfortunately, the autoconf archive does not support the 20 | # concept of set of macros, so I had to break it for submission. The 21 | # general documentation, as well as the sample configure.in, is included 22 | # in the AX_PROG_JAVA macro. 23 | # 24 | # LICENSE 25 | # 26 | # Copyright (c) 2008 Stephane Bortzmeyer 27 | # 28 | # This program is free software; you can redistribute it and/or modify it 29 | # under the terms of the GNU General Public License as published by the 30 | # Free Software Foundation; either version 2 of the License, or (at your 31 | # option) any later version. 32 | # 33 | # This program is distributed in the hope that it will be useful, but 34 | # WITHOUT ANY WARRANTY; without even the implied warranty of 35 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 36 | # Public License for more details. 37 | # 38 | # You should have received a copy of the GNU General Public License along 39 | # with this program. If not, see . 40 | # 41 | # As a special exception, the respective Autoconf Macro's copyright owner 42 | # gives unlimited permission to copy, distribute and modify the configure 43 | # scripts that are the output of Autoconf when processing the Macro. You 44 | # need not follow the terms of the GNU General Public License when using 45 | # or distributing such scripts, even though portions of the text of the 46 | # Macro appear in them. The GNU General Public License (GPL) does govern 47 | # all other use of the material that constitutes the Autoconf Macro. 48 | # 49 | # This special exception to the GPL applies to versions of the Autoconf 50 | # Macro released by the Autoconf Archive. When you make and distribute a 51 | # modified version of the Autoconf Macro, you may extend this special 52 | # exception to the GPL to apply to your modified version as well. 53 | 54 | #serial 7 55 | 56 | AU_ALIAS([AC_CHECK_CLASS], [AX_CHECK_CLASS]) 57 | AC_DEFUN([AX_CHECK_CLASS],[ 58 | AC_REQUIRE([AX_PROG_JAVA]) 59 | ac_var_name=`echo $1 | sed 's/\./_/g'` 60 | dnl Normaly I'd use a AC_CACHE_CHECK here but since the variable name is 61 | dnl dynamic I need an extra level of extraction 62 | AC_MSG_CHECKING([for $1 class]) 63 | AC_CACHE_VAL(ax_cv_class_$ac_var_name, [ 64 | if test x$ac_cv_prog_uudecode_base64 = xyes; then 65 | dnl /** 66 | dnl * Test.java: used to test dynamicaly if a class exists. 67 | dnl */ 68 | dnl public class Test 69 | dnl { 70 | dnl 71 | dnl public static void 72 | dnl main( String[] argv ) 73 | dnl { 74 | dnl Class lib; 75 | dnl if (argv.length < 1) 76 | dnl { 77 | dnl System.err.println ("Missing argument"); 78 | dnl System.exit (77); 79 | dnl } 80 | dnl try 81 | dnl { 82 | dnl lib = Class.forName (argv[0]); 83 | dnl } 84 | dnl catch (ClassNotFoundException e) 85 | dnl { 86 | dnl System.exit (1); 87 | dnl } 88 | dnl lib = null; 89 | dnl System.exit (0); 90 | dnl } 91 | dnl 92 | dnl } 93 | cat << \EOF > Test.uue 94 | begin-base64 644 Test.class 95 | yv66vgADAC0AKQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE 96 | bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 97 | bWJlclRhYmxlDAAKAAsBAANlcnIBABVMamF2YS9pby9QcmludFN0cmVhbTsJ 98 | AA0ACQcADgEAEGphdmEvbGFuZy9TeXN0ZW0IABABABBNaXNzaW5nIGFyZ3Vt 99 | ZW50DAASABMBAAdwcmludGxuAQAVKExqYXZhL2xhbmcvU3RyaW5nOylWCgAV 100 | ABEHABYBABNqYXZhL2lvL1ByaW50U3RyZWFtDAAYABkBAARleGl0AQAEKEkp 101 | VgoADQAXDAAcAB0BAAdmb3JOYW1lAQAlKExqYXZhL2xhbmcvU3RyaW5nOylM 102 | amF2YS9sYW5nL0NsYXNzOwoAHwAbBwAgAQAPamF2YS9sYW5nL0NsYXNzBwAi 103 | AQAgamF2YS9sYW5nL0NsYXNzTm90Rm91bmRFeGNlcHRpb24BAAY8aW5pdD4B 104 | AAMoKVYMACMAJAoAAwAlAQAKU291cmNlRmlsZQEACVRlc3QuamF2YQAhAAEA 105 | AwAAAAAAAgAJAAUABgABAAcAAABtAAMAAwAAACkqvgSiABCyAAwSD7YAFBBN 106 | uAAaKgMyuAAeTKcACE0EuAAaAUwDuAAasQABABMAGgAdACEAAQAIAAAAKgAK 107 | AAAACgAAAAsABgANAA4ADgATABAAEwASAB4AFgAiABgAJAAZACgAGgABACMA 108 | JAABAAcAAAAhAAEAAQAAAAUqtwAmsQAAAAEACAAAAAoAAgAAAAQABAAEAAEA 109 | JwAAAAIAKA== 110 | ==== 111 | EOF 112 | if $UUDECODE Test.uue; then 113 | : 114 | else 115 | echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD 116 | echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD 117 | cat Test.uue >&AS_MESSAGE_LOG_FD 118 | ac_cv_prog_uudecode_base64=no 119 | fi 120 | rm -f Test.uue 121 | if AC_TRY_COMMAND($JAVA $JAVAFLAGS Test $1) >/dev/null 2>&1; then 122 | eval "ac_cv_class_$ac_var_name=yes" 123 | else 124 | eval "ac_cv_class_$ac_var_name=no" 125 | fi 126 | rm -f Test.class 127 | else 128 | AX_TRY_COMPILE_JAVA([$1], , [eval "ac_cv_class_$ac_var_name=yes"], 129 | [eval "ac_cv_class_$ac_var_name=no"]) 130 | fi 131 | eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" 132 | eval "HAVE_$ac_var_name=$`echo ac_cv_class_$ac_var_val`" 133 | HAVE_LAST_CLASS=$ac_var_val 134 | if test x$ac_var_val = xyes; then 135 | ifelse([$2], , :, [$2]) 136 | else 137 | ifelse([$3], , :, [$3]) 138 | fi 139 | ]) 140 | dnl for some reason the above statment didn't fall though here? 141 | dnl do scripts have variable scoping? 142 | eval "ac_var_val=$`eval echo ac_cv_class_$ac_var_name`" 143 | AC_MSG_RESULT($ac_var_val) 144 | ]) 145 | -------------------------------------------------------------------------------- /m4/ax_check_classpath.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_classpath.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_CLASSPATH 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_CHECK_CLASSPATH just displays the CLASSPATH, for the edification of 12 | # the user. 13 | # 14 | # Note: This is part of the set of autoconf M4 macros for Java programs. 15 | # It is VERY IMPORTANT that you download the whole set, some macros depend 16 | # on other. Unfortunately, the autoconf archive does not support the 17 | # concept of set of macros, so I had to break it for submission. The 18 | # general documentation, as well as the sample configure.in, is included 19 | # in the AX_PROG_JAVA macro. 20 | # 21 | # LICENSE 22 | # 23 | # Copyright (c) 2008 Stephane Bortzmeyer 24 | # 25 | # This program is free software; you can redistribute it and/or modify it 26 | # under the terms of the GNU General Public License as published by the 27 | # Free Software Foundation; either version 2 of the License, or (at your 28 | # option) any later version. 29 | # 30 | # This program is distributed in the hope that it will be useful, but 31 | # WITHOUT ANY WARRANTY; without even the implied warranty of 32 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 33 | # Public License for more details. 34 | # 35 | # You should have received a copy of the GNU General Public License along 36 | # with this program. If not, see . 37 | # 38 | # As a special exception, the respective Autoconf Macro's copyright owner 39 | # gives unlimited permission to copy, distribute and modify the configure 40 | # scripts that are the output of Autoconf when processing the Macro. You 41 | # need not follow the terms of the GNU General Public License when using 42 | # or distributing such scripts, even though portions of the text of the 43 | # Macro appear in them. The GNU General Public License (GPL) does govern 44 | # all other use of the material that constitutes the Autoconf Macro. 45 | # 46 | # This special exception to the GPL applies to versions of the Autoconf 47 | # Macro released by the Autoconf Archive. When you make and distribute a 48 | # modified version of the Autoconf Macro, you may extend this special 49 | # exception to the GPL to apply to your modified version as well. 50 | 51 | #serial 5 52 | 53 | AU_ALIAS([AC_CHECK_CLASSPATH], [AX_CHECK_CLASSPATH]) 54 | AC_DEFUN([AX_CHECK_CLASSPATH],[ 55 | if test "x$CLASSPATH" = x; then 56 | echo "You have no CLASSPATH, I hope it is good" 57 | else 58 | echo "You have CLASSPATH $CLASSPATH, hope it is correct" 59 | fi 60 | ]) 61 | -------------------------------------------------------------------------------- /m4/ax_check_java_home.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_java_home.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_JAVA_HOME 8 | # 9 | # DESCRIPTION 10 | # 11 | # Check for Sun Java (JDK / JRE) installation, where the 'java' VM is in. 12 | # If found, set environment variable JAVA_HOME = Java installation home, 13 | # else left JAVA_HOME untouch, which in most case means JAVA_HOME is 14 | # empty. 15 | # 16 | # LICENSE 17 | # 18 | # Copyright (c) 2008 Gleen Salmon 19 | # 20 | # This program is free software; you can redistribute it and/or modify it 21 | # under the terms of the GNU General Public License as published by the 22 | # Free Software Foundation; either version 2 of the License, or (at your 23 | # option) any later version. 24 | # 25 | # This program is distributed in the hope that it will be useful, but 26 | # WITHOUT ANY WARRANTY; without even the implied warranty of 27 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 28 | # Public License for more details. 29 | # 30 | # You should have received a copy of the GNU General Public License along 31 | # with this program. If not, see . 32 | # 33 | # As a special exception, the respective Autoconf Macro's copyright owner 34 | # gives unlimited permission to copy, distribute and modify the configure 35 | # scripts that are the output of Autoconf when processing the Macro. You 36 | # need not follow the terms of the GNU General Public License when using 37 | # or distributing such scripts, even though portions of the text of the 38 | # Macro appear in them. The GNU General Public License (GPL) does govern 39 | # all other use of the material that constitutes the Autoconf Macro. 40 | # 41 | # This special exception to the GPL applies to versions of the Autoconf 42 | # Macro released by the Autoconf Archive. When you make and distribute a 43 | # modified version of the Autoconf Macro, you may extend this special 44 | # exception to the GPL to apply to your modified version as well. 45 | 46 | #serial 6 47 | 48 | AU_ALIAS([AC_CHECK_JAVA_HOME], [AX_CHECK_JAVA_HOME]) 49 | 50 | AC_DEFUN([AX_CHECK_JAVA_HOME], 51 | [AC_MSG_CHECKING([for JAVA_HOME]) 52 | # We used a fake loop so that we can use "break" to exit when the result 53 | # is found. 54 | while true 55 | do 56 | # If the user defined JAVA_HOME, don't touch it. 57 | test "${JAVA_HOME+set}" = set && break 58 | 59 | # On Mac OS X 10.5 and following, run /usr/libexec/java_home to get 60 | # the value of JAVA_HOME to use. 61 | # (http://developer.apple.com/library/mac/#qa/qa2001/qa1170.html). 62 | JAVA_HOME=`/usr/libexec/java_home 2>/dev/null` 63 | test x"$JAVA_HOME" != x && break 64 | 65 | # See if we can find the java executable, and compute from there. 66 | TRY_JAVA_HOME=`ls -dr /usr/java/* 2> /dev/null | head -n 1` 67 | if test x$TRY_JAVA_HOME != x; then 68 | PATH=$PATH:$TRY_JAVA_HOME/bin 69 | fi 70 | AC_PATH_PROG([JAVA_PATH_NAME], [java]) 71 | if test "x$JAVA_PATH_NAME" != x; then 72 | JAVA_HOME=`echo $JAVA_PATH_NAME | sed "s/\(.*\)[[/]]bin[[/]]java.*/\1/"` 73 | break 74 | fi 75 | 76 | AC_MSG_NOTICE([Could not compute JAVA_HOME]) 77 | break 78 | done 79 | AC_MSG_RESULT([$JAVA_HOME]) 80 | ]) 81 | -------------------------------------------------------------------------------- /m4/ax_check_java_plugin.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_check_java_plugin.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CHECK_JAVA_PLUGIN() 8 | # 9 | # DESCRIPTION 10 | # 11 | # This macro sets to empty on failure and to a compatible 12 | # version of plugin.jar otherwise. Directories searched are /usr/java/* 13 | # and /usr/local/java/*, which are assumed to be j{dk,re} installations. 14 | # Apply the shell variable as you see fit. If sun changes things so 15 | # /lib/plugin.jar is not the magic file it will stop working. 16 | # 17 | # This macro assumes that unzip, zipinfo or pkzipc is avialable (and can 18 | # list the contents of the jar archive). The first two are assumed to work 19 | # similarly enough to the infozip versisonms. The pkzipc version is 20 | # assumed to work if I undertstand the documentation on pkware's site but 21 | # YMMV. I do not have access to pwkware's version to test it. 22 | # 23 | # LICENSE 24 | # 25 | # Copyright (c) 2008 Duncan Simpson 26 | # 27 | # This program is free software; you can redistribute it and/or modify it 28 | # under the terms of the GNU General Public License as published by the 29 | # Free Software Foundation; either version 2 of the License, or (at your 30 | # option) any later version. 31 | # 32 | # This program is distributed in the hope that it will be useful, but 33 | # WITHOUT ANY WARRANTY; without even the implied warranty of 34 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 35 | # Public License for more details. 36 | # 37 | # You should have received a copy of the GNU General Public License along 38 | # with this program. If not, see . 39 | # 40 | # As a special exception, the respective Autoconf Macro's copyright owner 41 | # gives unlimited permission to copy, distribute and modify the configure 42 | # scripts that are the output of Autoconf when processing the Macro. You 43 | # need not follow the terms of the GNU General Public License when using 44 | # or distributing such scripts, even though portions of the text of the 45 | # Macro appear in them. The GNU General Public License (GPL) does govern 46 | # all other use of the material that constitutes the Autoconf Macro. 47 | # 48 | # This special exception to the GPL applies to versions of the Autoconf 49 | # Macro released by the Autoconf Archive. When you make and distribute a 50 | # modified version of the Autoconf Macro, you may extend this special 51 | # exception to the GPL to apply to your modified version as well. 52 | 53 | #serial 6 54 | 55 | AU_ALIAS([DPS_CHECK_PLUGIN], [AX_CHECK_JAVA_PLUGIN]) 56 | AC_DEFUN([AX_CHECK_JAVA_PLUGIN], 57 | [AC_REQUIRE([AC_PROG_AWK]) 58 | AC_REQUIRE([AC_PROG_FGREP]) 59 | AC_CHECK_PROG(ZIPINFO,[zipinfo unzip pkzipc]) 60 | AC_MSG_CHECKING([for the java plugin]) 61 | case "x$ZIPINFO" in 62 | [*/zipinfo)] 63 | zipinf="zipinfo -1" ;; 64 | [*/unzip)] 65 | zipinf="unzip -l";; 66 | [*/pkzipc)] 67 | ziping="unzipc -view";; 68 | [x*)] 69 | AC_MSG_RESULT([skiped, none of zipinfo, unzip and pkzipc found]) 70 | AC_SUBST($1,[]) 71 | zipinf="";; 72 | esac 73 | if test "x$zipinf" != "x"; then 74 | jplugin="" 75 | for jhome in `ls -dr /usr/java/* /usr/local/java/* 2> /dev/null`; do 76 | for jfile in lib/plugin.jar jre/lib/plugin.jar; do 77 | if test "x$jplugin" = "x" && test -f "$jhome/$jfile"; then 78 | eval "$zipinf $jhome/$jfile | $AWK '{ print \$NF; }' | $FGREP netscape/javascript/JSObject" >/dev/null 2>/dev/null 79 | if test $? -eq 0; then 80 | dnl Some version of gcj (and javac) refuse to work with some files 81 | dnl that pass this test. To stop this problem make sure that the compiler 82 | dnl still works with this jar file in the classpath 83 | cat << \EOF > Test.java 84 | /* [#]line __oline__ "configure" */ 85 | public class Test { 86 | } 87 | EOF 88 | if eval "$JAVAC -classpath $jhome/$jfile Test.java 2>/dev/null >/dev/null" && test -f Test.class; then 89 | jplugin="$jhome/$jfile" 90 | fi 91 | rm -f Test.java Test.class 92 | fi; fi; done; done 93 | if test "x$jplugin" != "x"; then 94 | AC_SUBST($1,$jplugin) 95 | AC_MSG_RESULT($jplugin) 96 | else 97 | AC_MSG_RESULT([java plugin not found]) 98 | AC_SUBST($1,[]) 99 | fi 100 | fi 101 | ]) 102 | -------------------------------------------------------------------------------- /m4/ax_java_check_class.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_java_check_class.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_JAVA_CHECK_CLASS(,,) 8 | # 9 | # DESCRIPTION 10 | # 11 | # Test if a Java class is available. Based on AX_PROG_JAVAC_WORKS. This 12 | # version uses a cache variable which is both compiler, options and 13 | # classpath dependent (so if you switch from javac to gcj it correctly 14 | # notices and redoes the test). 15 | # 16 | # The macro tries to compile a minimal program importing . Some 17 | # newer compilers moan about the failure to use this but fail or produce a 18 | # class file anyway. All moaing is sunk to /dev/null since I only wanted 19 | # to know if the class could be imported. This is a recommended followup 20 | # to AX_CHECK_JAVA_PLUGIN with classpath appropriately adjusted. 21 | # 22 | # LICENSE 23 | # 24 | # Copyright (c) 2008 Duncan Simpson 25 | # 26 | # This program is free software; you can redistribute it and/or modify it 27 | # under the terms of the GNU General Public License as published by the 28 | # Free Software Foundation; either version 2 of the License, or (at your 29 | # option) any later version. 30 | # 31 | # This program is distributed in the hope that it will be useful, but 32 | # WITHOUT ANY WARRANTY; without even the implied warranty of 33 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 34 | # Public License for more details. 35 | # 36 | # You should have received a copy of the GNU General Public License along 37 | # with this program. If not, see . 38 | # 39 | # As a special exception, the respective Autoconf Macro's copyright owner 40 | # gives unlimited permission to copy, distribute and modify the configure 41 | # scripts that are the output of Autoconf when processing the Macro. You 42 | # need not follow the terms of the GNU General Public License when using 43 | # or distributing such scripts, even though portions of the text of the 44 | # Macro appear in them. The GNU General Public License (GPL) does govern 45 | # all other use of the material that constitutes the Autoconf Macro. 46 | # 47 | # This special exception to the GPL applies to versions of the Autoconf 48 | # Macro released by the Autoconf Archive. When you make and distribute a 49 | # modified version of the Autoconf Macro, you may extend this special 50 | # exception to the GPL to apply to your modified version as well. 51 | 52 | #serial 8 53 | 54 | AU_ALIAS([DPS_JAVA_CHECK_CLASS], [AX_JAVA_CHECK_CLASS]) 55 | AC_DEFUN([AX_JAVA_CHECK_CLASS],[ 56 | m4_define([cache_val],[m4_translit(ax_cv_have_java_class_$1, " ." ,"__")]) 57 | if test "x$CLASSPATH" != "x"; then 58 | xtra=" with classpath ${CLASSPATH}" 59 | xopts=`echo ${CLASSPATH} | ${SED} 's/^ *://'` 60 | xopts="-classpath $xopts" 61 | else xtra=""; xopts=""; fi 62 | cache_var="cache_val"AS_TR_SH([_Jc_${JAVAC}_Cp_${CLASSPATH}]) 63 | AC_CACHE_CHECK([if the $1 class is avialable$xtra], [$cache_var], [ 64 | JAVA_TEST=Test.java 65 | CLASS_TEST=Test.class 66 | cat << \EOF > $JAVA_TEST 67 | /* [#]xline __oline__ "configure" */ 68 | import $1; 69 | public class Test { 70 | } 71 | EOF 72 | if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $xopts $JAVA_TEST) >/dev/null 2>&1; then 73 | eval "${cache_var}=yes" 74 | else 75 | eval "${cache_var}=no" 76 | echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD 77 | cat $JAVA_TEST >&AS_MESSAGE_LOG_FD 78 | fi 79 | rm -f $JAVA_TEST $CLASS_TEST 80 | ]) 81 | if eval 'test "x$'${cache_var}'" = "xyes"'; then 82 | $2 83 | true; else 84 | $3 85 | false; fi]) 86 | -------------------------------------------------------------------------------- /m4/ax_java_options.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_java_options.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_JAVA_OPTIONS 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_JAVA_OPTIONS adds configure command line options used for Java m4 12 | # macros. This Macro is optional. 13 | # 14 | # Note: This is part of the set of autoconf M4 macros for Java programs. 15 | # It is VERY IMPORTANT that you download the whole set, some macros depend 16 | # on other. Unfortunately, the autoconf archive does not support the 17 | # concept of set of macros, so I had to break it for submission. The 18 | # general documentation, as well as the sample configure.in, is included 19 | # in the AX_PROG_JAVA macro. 20 | # 21 | # LICENSE 22 | # 23 | # Copyright (c) 2008 Devin Weaver 24 | # 25 | # Copying and distribution of this file, with or without modification, are 26 | # permitted in any medium without royalty provided the copyright notice 27 | # and this notice are preserved. This file is offered as-is, without any 28 | # warranty. 29 | 30 | #serial 6 31 | 32 | AU_ALIAS([AC_JAVA_OPTIONS], [AX_JAVA_OPTIONS]) 33 | AC_DEFUN([AX_JAVA_OPTIONS],[ 34 | AC_ARG_WITH(java-prefix, 35 | [ --with-java-prefix=PFX prefix where Java runtime is installed (optional)]) 36 | AC_ARG_WITH(javac-flags, 37 | [ --with-javac-flags=FLAGS flags to pass to the Java compiler (optional)]) 38 | AC_ARG_WITH(java-flags, 39 | [ --with-java-flags=FLAGS flags to pass to the Java VM (optional)]) 40 | JAVAPREFIX=$with_java_prefix 41 | JAVACFLAGS=$with_javac_flags 42 | JAVAFLAGS=$with_java_flags 43 | AC_SUBST(JAVAPREFIX)dnl 44 | AC_SUBST(JAVACFLAGS)dnl 45 | AC_SUBST(JAVAFLAGS)dnl 46 | AC_SUBST(JAVA)dnl 47 | AC_SUBST(JAVAC)dnl 48 | ]) 49 | -------------------------------------------------------------------------------- /m4/ax_jni_include_dir.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_jni_include_dir.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_JNI_INCLUDE_DIR 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_JNI_INCLUDE_DIR finds include directories needed for compiling 12 | # programs using the JNI interface. 13 | # 14 | # JNI include directories are usually in the java distribution This is 15 | # deduced from the value of JAVAC. When this macro completes, a list of 16 | # directories is left in the variable JNI_INCLUDE_DIRS. 17 | # 18 | # Example usage follows: 19 | # 20 | # AX_JNI_INCLUDE_DIR 21 | # 22 | # for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS 23 | # do 24 | # CPPFLAGS="$CPPFLAGS -I$JNI_INCLUDE_DIR" 25 | # done 26 | # 27 | # If you want to force a specific compiler: 28 | # 29 | # - at the configure.in level, set JAVAC=yourcompiler before calling 30 | # AX_JNI_INCLUDE_DIR 31 | # 32 | # - at the configure level, setenv JAVAC 33 | # 34 | # Note: This macro can work with the autoconf M4 macros for Java programs. 35 | # This particular macro is not part of the original set of macros. 36 | # 37 | # LICENSE 38 | # 39 | # Copyright (c) 2008 Don Anderson 40 | # 41 | # Copying and distribution of this file, with or without modification, are 42 | # permitted in any medium without royalty provided the copyright notice 43 | # and this notice are preserved. This file is offered as-is, without any 44 | # warranty. 45 | 46 | #serial 8 47 | 48 | AU_ALIAS([AC_JNI_INCLUDE_DIR], [AX_JNI_INCLUDE_DIR]) 49 | AC_DEFUN([AX_JNI_INCLUDE_DIR],[ 50 | 51 | JNI_INCLUDE_DIRS="" 52 | 53 | test "x$JAVAC" = x && AC_MSG_ERROR(['\$JAVAC' undefined]) 54 | AC_PATH_PROG([_ACJNI_JAVAC], [$JAVAC], [no]) 55 | test "x$_ACJNI_JAVAC" = xno && AC_MSG_ERROR([$JAVAC could not be found in path]) 56 | 57 | _ACJNI_FOLLOW_SYMLINKS("$_ACJNI_JAVAC") 58 | _JTOPDIR=`echo "$_ACJNI_FOLLOWED" | sed -e 's://*:/:g' -e 's:/[[^/]]*$::'` 59 | case "$host_os" in 60 | darwin*) _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` 61 | _JINC="$_JTOPDIR/Headers";; 62 | *) _JINC="$_JTOPDIR/include";; 63 | esac 64 | _AS_ECHO_LOG([_JTOPDIR=$_JTOPDIR]) 65 | _AS_ECHO_LOG([_JINC=$_JINC]) 66 | 67 | # On Mac OS X 10.6.4, jni.h is a symlink: 68 | # /System/Library/Frameworks/JavaVM.framework/Versions/Current/Headers/jni.h 69 | # -> ../../CurrentJDK/Headers/jni.h. 70 | if test -f "$_JINC/jni.h" || test -L "$_JINC/jni.h"; then 71 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JINC" 72 | else 73 | _JTOPDIR=`echo "$_JTOPDIR" | sed -e 's:/[[^/]]*$::'` 74 | if test -f "$_JTOPDIR/include/jni.h"; then 75 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include" 76 | else 77 | AC_MSG_ERROR([cannot find java include files]) 78 | fi 79 | fi 80 | 81 | # get the likely subdirectories for system specific java includes 82 | case "$host_os" in 83 | bsdi*) _JNI_INC_SUBDIRS="bsdos";; 84 | freebsd*) _JNI_INC_SUBDIRS="freebsd";; 85 | linux*) _JNI_INC_SUBDIRS="linux genunix";; 86 | osf*) _JNI_INC_SUBDIRS="alpha";; 87 | solaris*) _JNI_INC_SUBDIRS="solaris";; 88 | mingw*) _JNI_INC_SUBDIRS="win32";; 89 | cygwin*) _JNI_INC_SUBDIRS="win32";; 90 | *) _JNI_INC_SUBDIRS="genunix";; 91 | esac 92 | 93 | # add any subdirectories that are present 94 | for JINCSUBDIR in $_JNI_INC_SUBDIRS 95 | do 96 | if test -d "$_JTOPDIR/include/$JINCSUBDIR"; then 97 | JNI_INCLUDE_DIRS="$JNI_INCLUDE_DIRS $_JTOPDIR/include/$JINCSUBDIR" 98 | fi 99 | done 100 | ]) 101 | 102 | # _ACJNI_FOLLOW_SYMLINKS 103 | # Follows symbolic links on , 104 | # finally setting variable _ACJNI_FOLLOWED 105 | # ---------------------------------------- 106 | AC_DEFUN([_ACJNI_FOLLOW_SYMLINKS],[ 107 | # find the include directory relative to the javac executable 108 | _cur="$1" 109 | while ls -ld "$_cur" 2>/dev/null | grep " -> " >/dev/null; do 110 | AC_MSG_CHECKING([symlink for $_cur]) 111 | _slink=`ls -ld "$_cur" | sed 's/.* -> //'` 112 | case "$_slink" in 113 | /*) _cur="$_slink";; 114 | # 'X' avoids triggering unwanted echo options. 115 | *) _cur=`echo "X$_cur" | sed -e 's/^X//' -e 's:[[^/]]*$::'`"$_slink";; 116 | esac 117 | AC_MSG_RESULT([$_cur]) 118 | done 119 | _ACJNI_FOLLOWED="$_cur" 120 | ])# _ACJNI 121 | -------------------------------------------------------------------------------- /m4/ax_prog_jar.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_jar.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAR 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_PROG_JAR tests for an existing jar program. It uses the environment 12 | # variable JAR then tests in sequence various common jar programs. 13 | # 14 | # If you want to force a specific compiler: 15 | # 16 | # - at the configure.in level, set JAR=yourcompiler before calling 17 | # AX_PROG_JAR 18 | # 19 | # - at the configure level, setenv JAR 20 | # 21 | # You can use the JAR variable in your Makefile.in, with @JAR@. 22 | # 23 | # Note: This macro depends on the autoconf M4 macros for Java programs. It 24 | # is VERY IMPORTANT that you download that whole set, some macros depend 25 | # on other. Unfortunately, the autoconf archive does not support the 26 | # concept of set of macros, so I had to break it for submission. 27 | # 28 | # The general documentation of those macros, as well as the sample 29 | # configure.in, is included in the AX_PROG_JAVA macro. 30 | # 31 | # LICENSE 32 | # 33 | # Copyright (c) 2008 Egon Willighagen 34 | # 35 | # Copying and distribution of this file, with or without modification, are 36 | # permitted in any medium without royalty provided the copyright notice 37 | # and this notice are preserved. This file is offered as-is, without any 38 | # warranty. 39 | 40 | #serial 6 41 | 42 | AU_ALIAS([AC_PROG_JAR], [AX_PROG_JAR]) 43 | AC_DEFUN([AX_PROG_JAR],[ 44 | AC_REQUIRE([AC_EXEEXT])dnl 45 | if test "x$JAVAPREFIX" = x; then 46 | test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar$EXEEXT) 47 | else 48 | test "x$JAR" = x && AC_CHECK_PROGS(JAR, jar, $JAVAPREFIX) 49 | fi 50 | test "x$JAR" = x && AC_MSG_ERROR([no acceptable jar program found in \$PATH]) 51 | AC_PROVIDE([$0])dnl 52 | ]) 53 | -------------------------------------------------------------------------------- /m4/ax_prog_java.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_java.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAVA 8 | # 9 | # DESCRIPTION 10 | # 11 | # Here is a summary of the main macros: 12 | # 13 | # AX_PROG_JAVAC: finds a Java compiler. 14 | # 15 | # AX_PROG_JAVA: finds a Java virtual machine. 16 | # 17 | # AX_CHECK_CLASS: finds if we have the given class (beware of CLASSPATH!). 18 | # 19 | # AX_CHECK_RQRD_CLASS: finds if we have the given class and stops 20 | # otherwise. 21 | # 22 | # AX_TRY_COMPILE_JAVA: attempt to compile user given source. 23 | # 24 | # AX_TRY_RUN_JAVA: attempt to compile and run user given source. 25 | # 26 | # AX_JAVA_OPTIONS: adds Java configure options. 27 | # 28 | # AX_PROG_JAVA tests an existing Java virtual machine. It uses the 29 | # environment variable JAVA then tests in sequence various common Java 30 | # virtual machines. For political reasons, it starts with the free ones. 31 | # You *must* call [AX_PROG_JAVAC] before. 32 | # 33 | # If you want to force a specific VM: 34 | # 35 | # - at the configure.in level, set JAVA=yourvm before calling AX_PROG_JAVA 36 | # 37 | # (but after AC_INIT) 38 | # 39 | # - at the configure level, setenv JAVA 40 | # 41 | # You can use the JAVA variable in your Makefile.in, with @JAVA@. 42 | # 43 | # *Warning*: its success or failure can depend on a proper setting of the 44 | # CLASSPATH env. variable. 45 | # 46 | # TODO: allow to exclude virtual machines (rationale: most Java programs 47 | # cannot run with some VM like kaffe). 48 | # 49 | # Note: This is part of the set of autoconf M4 macros for Java programs. 50 | # It is VERY IMPORTANT that you download the whole set, some macros depend 51 | # on other. Unfortunately, the autoconf archive does not support the 52 | # concept of set of macros, so I had to break it for submission. 53 | # 54 | # A Web page, with a link to the latest CVS snapshot is at 55 | # . 56 | # 57 | # This is a sample configure.in Process this file with autoconf to produce 58 | # a configure script. 59 | # 60 | # AC_INIT(UnTag.java) 61 | # 62 | # dnl Checks for programs. 63 | # AC_CHECK_CLASSPATH 64 | # AX_PROG_JAVAC 65 | # AX_PROG_JAVA 66 | # 67 | # dnl Checks for classes 68 | # AX_CHECK_RQRD_CLASS(org.xml.sax.Parser) 69 | # AX_CHECK_RQRD_CLASS(com.jclark.xml.sax.Driver) 70 | # 71 | # AC_OUTPUT(Makefile) 72 | # 73 | # LICENSE 74 | # 75 | # Copyright (c) 2008 Stephane Bortzmeyer 76 | # 77 | # This program is free software; you can redistribute it and/or modify it 78 | # under the terms of the GNU General Public License as published by the 79 | # Free Software Foundation; either version 2 of the License, or (at your 80 | # option) any later version. 81 | # 82 | # This program is distributed in the hope that it will be useful, but 83 | # WITHOUT ANY WARRANTY; without even the implied warranty of 84 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 85 | # Public License for more details. 86 | # 87 | # You should have received a copy of the GNU General Public License along 88 | # with this program. If not, see . 89 | # 90 | # As a special exception, the respective Autoconf Macro's copyright owner 91 | # gives unlimited permission to copy, distribute and modify the configure 92 | # scripts that are the output of Autoconf when processing the Macro. You 93 | # need not follow the terms of the GNU General Public License when using 94 | # or distributing such scripts, even though portions of the text of the 95 | # Macro appear in them. The GNU General Public License (GPL) does govern 96 | # all other use of the material that constitutes the Autoconf Macro. 97 | # 98 | # This special exception to the GPL applies to versions of the Autoconf 99 | # Macro released by the Autoconf Archive. When you make and distribute a 100 | # modified version of the Autoconf Macro, you may extend this special 101 | # exception to the GPL to apply to your modified version as well. 102 | 103 | #serial 8 104 | 105 | AU_ALIAS([AC_PROG_JAVA], [AX_PROG_JAVA]) 106 | AC_DEFUN([AX_PROG_JAVA],[ 107 | if test x$JAVAPREFIX = x; then 108 | test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe java) 109 | else 110 | test x$JAVA = x && AC_CHECK_PROGS(JAVA, kaffe java, $JAVAPREFIX) 111 | fi 112 | test x$JAVA = x && AC_MSG_ERROR([no acceptable Java virtual machine found in \$PATH]) 113 | AX_PROG_JAVA_WORKS 114 | AC_PROVIDE([$0])dnl 115 | ]) 116 | -------------------------------------------------------------------------------- /m4/ax_prog_java_cc.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_java_cc.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAVA_CC 8 | # 9 | # DESCRIPTION 10 | # 11 | # Finds the appropriate java compiler on your path. By preference the java 12 | # compiler is gcj, then jikes then javac. 13 | # 14 | # The macro can take one argument specifying a space separated list of 15 | # java compiler names. 16 | # 17 | # For example: 18 | # 19 | # AX_PROG_JAVA_CC(javac, gcj) 20 | # 21 | # The macro also sets the compiler options variable: JAVA_CC_OPTS to 22 | # something sensible: 23 | # 24 | # - for GCJ it sets it to: @GCJ_OPTS@ 25 | # (if GCJ_OPTS is not yet defined then it is set to "-C") 26 | # 27 | # - no other compiler has applicable options yet 28 | # 29 | # Here's an example configure.in: 30 | # 31 | # AC_INIT(Makefile.in) 32 | # AX_PROG_JAVA_CC() 33 | # AC_OUTPUT(Makefile) 34 | # dnl End. 35 | # 36 | # And here's the start of the Makefile.in: 37 | # 38 | # PROJECT_ROOT := @srcdir@ 39 | # # Tool definitions. 40 | # JAVAC := @JAVA_CC@ 41 | # JAVAC_OPTS := @JAVA_CC_OPTS@ 42 | # JAR_TOOL := @jar_tool@ 43 | # 44 | # LICENSE 45 | # 46 | # Copyright (c) 2008 Nic Ferrier 47 | # 48 | # This program is free software; you can redistribute it and/or modify it 49 | # under the terms of the GNU General Public License as published by the 50 | # Free Software Foundation; either version 2 of the License, or (at your 51 | # option) any later version. 52 | # 53 | # This program is distributed in the hope that it will be useful, but 54 | # WITHOUT ANY WARRANTY; without even the implied warranty of 55 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 56 | # Public License for more details. 57 | # 58 | # You should have received a copy of the GNU General Public License along 59 | # with this program. If not, see . 60 | # 61 | # As a special exception, the respective Autoconf Macro's copyright owner 62 | # gives unlimited permission to copy, distribute and modify the configure 63 | # scripts that are the output of Autoconf when processing the Macro. You 64 | # need not follow the terms of the GNU General Public License when using 65 | # or distributing such scripts, even though portions of the text of the 66 | # Macro appear in them. The GNU General Public License (GPL) does govern 67 | # all other use of the material that constitutes the Autoconf Macro. 68 | # 69 | # This special exception to the GPL applies to versions of the Autoconf 70 | # Macro released by the Autoconf Archive. When you make and distribute a 71 | # modified version of the Autoconf Macro, you may extend this special 72 | # exception to the GPL to apply to your modified version as well. 73 | 74 | #serial 4 75 | 76 | # AX_PROG_JAVA_CC([COMPILER ...]) 77 | # -------------------------- 78 | # COMPILER ... is a space separated list of java compilers to search for. 79 | # This just gives the user an opportunity to specify an alternative 80 | # search list for the java compiler. 81 | AU_ALIAS([AC_PROG_JAVA_CC], [AX_PROG_JAVA_CC]) 82 | AC_DEFUN([AX_PROG_JAVA_CC], 83 | [AC_ARG_VAR([JAVA_CC], [java compiler command])dnl 84 | AC_ARG_VAR([JAVA_CC_FLAGS], [java compiler flags])dnl 85 | m4_ifval([$1], 86 | [AC_CHECK_TOOLS(JAVA_CC, [$1])], 87 | [AC_CHECK_TOOL(JAVA_CC, gcj) 88 | if test -z "$JAVA_CC"; then 89 | AC_CHECK_TOOL(JAVA_CC, javac) 90 | fi 91 | if test -z "$JAVA_CC"; then 92 | AC_CHECK_TOOL(JAVA_CC, jikes) 93 | fi 94 | ]) 95 | 96 | if test "$JAVA_CC" = "gcj"; then 97 | if test "$GCJ_OPTS" = ""; then 98 | AC_SUBST(GCJ_OPTS,-C) 99 | fi 100 | AC_SUBST(JAVA_CC_OPTS, @GCJ_OPTS@, 101 | [Define the compilation options for GCJ]) 102 | fi 103 | test -z "$JAVA_CC" && AC_MSG_ERROR([no acceptable java compiler found in \$PATH]) 104 | ])# AX_PROG_JAVA_CC 105 | -------------------------------------------------------------------------------- /m4/ax_prog_java_works.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_java_works.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAVA_WORKS 8 | # 9 | # DESCRIPTION 10 | # 11 | # Internal use ONLY. 12 | # 13 | # Note: This is part of the set of autoconf M4 macros for Java programs. 14 | # It is VERY IMPORTANT that you download the whole set, some macros depend 15 | # on other. Unfortunately, the autoconf archive does not support the 16 | # concept of set of macros, so I had to break it for submission. The 17 | # general documentation, as well as the sample configure.in, is included 18 | # in the AX_PROG_JAVA macro. 19 | # 20 | # LICENSE 21 | # 22 | # Copyright (c) 2008 Stephane Bortzmeyer 23 | # 24 | # This program is free software; you can redistribute it and/or modify it 25 | # under the terms of the GNU General Public License as published by the 26 | # Free Software Foundation; either version 2 of the License, or (at your 27 | # option) any later version. 28 | # 29 | # This program is distributed in the hope that it will be useful, but 30 | # WITHOUT ANY WARRANTY; without even the implied warranty of 31 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 32 | # Public License for more details. 33 | # 34 | # You should have received a copy of the GNU General Public License along 35 | # with this program. If not, see . 36 | # 37 | # As a special exception, the respective Autoconf Macro's copyright owner 38 | # gives unlimited permission to copy, distribute and modify the configure 39 | # scripts that are the output of Autoconf when processing the Macro. You 40 | # need not follow the terms of the GNU General Public License when using 41 | # or distributing such scripts, even though portions of the text of the 42 | # Macro appear in them. The GNU General Public License (GPL) does govern 43 | # all other use of the material that constitutes the Autoconf Macro. 44 | # 45 | # This special exception to the GPL applies to versions of the Autoconf 46 | # Macro released by the Autoconf Archive. When you make and distribute a 47 | # modified version of the Autoconf Macro, you may extend this special 48 | # exception to the GPL to apply to your modified version as well. 49 | 50 | #serial 8 51 | 52 | AU_ALIAS([AC_PROG_JAVA_WORKS], [AX_PROG_JAVA_WORKS]) 53 | AC_DEFUN([AX_PROG_JAVA_WORKS], [ 54 | AC_PATH_PROG(UUDECODE, uudecode, [no]) 55 | if test x$UUDECODE != xno; then 56 | AC_CACHE_CHECK([if uudecode can decode base 64 file], ac_cv_prog_uudecode_base64, [ 57 | dnl /** 58 | dnl * Test.java: used to test if java compiler works. 59 | dnl */ 60 | dnl public class Test 61 | dnl { 62 | dnl 63 | dnl public static void 64 | dnl main( String[] argv ) 65 | dnl { 66 | dnl System.exit (0); 67 | dnl } 68 | dnl 69 | dnl } 70 | cat << \EOF > Test.uue 71 | begin-base64 644 Test.class 72 | yv66vgADAC0AFQcAAgEABFRlc3QHAAQBABBqYXZhL2xhbmcvT2JqZWN0AQAE 73 | bWFpbgEAFihbTGphdmEvbGFuZy9TdHJpbmc7KVYBAARDb2RlAQAPTGluZU51 74 | bWJlclRhYmxlDAAKAAsBAARleGl0AQAEKEkpVgoADQAJBwAOAQAQamF2YS9s 75 | YW5nL1N5c3RlbQEABjxpbml0PgEAAygpVgwADwAQCgADABEBAApTb3VyY2VG 76 | aWxlAQAJVGVzdC5qYXZhACEAAQADAAAAAAACAAkABQAGAAEABwAAACEAAQAB 77 | AAAABQO4AAyxAAAAAQAIAAAACgACAAAACgAEAAsAAQAPABAAAQAHAAAAIQAB 78 | AAEAAAAFKrcAErEAAAABAAgAAAAKAAIAAAAEAAQABAABABMAAAACABQ= 79 | ==== 80 | EOF 81 | if $UUDECODE Test.uue; then 82 | ac_cv_prog_uudecode_base64=yes 83 | else 84 | echo "configure: __oline__: uudecode had trouble decoding base 64 file 'Test.uue'" >&AS_MESSAGE_LOG_FD 85 | echo "configure: failed file was:" >&AS_MESSAGE_LOG_FD 86 | cat Test.uue >&AS_MESSAGE_LOG_FD 87 | ac_cv_prog_uudecode_base64=no 88 | fi 89 | rm -f Test.uue]) 90 | fi 91 | if test x$ac_cv_prog_uudecode_base64 != xyes; then 92 | rm -f Test.class 93 | AC_MSG_WARN([I have to compile Test.class from scratch]) 94 | if test x$ac_cv_prog_javac_works = xno; then 95 | AC_MSG_ERROR([Cannot compile java source. $JAVAC does not work properly]) 96 | fi 97 | if test x$ac_cv_prog_javac_works = x; then 98 | AX_PROG_JAVAC 99 | fi 100 | fi 101 | AC_CACHE_CHECK(if $JAVA works, ac_cv_prog_java_works, [ 102 | JAVA_TEST=Test.java 103 | CLASS_TEST=Test.class 104 | TEST=Test 105 | changequote(, )dnl 106 | cat << \EOF > $JAVA_TEST 107 | /* [#]line __oline__ "configure" */ 108 | public class Test { 109 | public static void main (String args[]) { 110 | System.exit (0); 111 | } } 112 | EOF 113 | changequote([, ])dnl 114 | if test x$ac_cv_prog_uudecode_base64 != xyes; then 115 | if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) && test -s $CLASS_TEST; then 116 | : 117 | else 118 | echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD 119 | cat $JAVA_TEST >&AS_MESSAGE_LOG_FD 120 | AC_MSG_ERROR(The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)) 121 | fi 122 | fi 123 | if AC_TRY_COMMAND($JAVA $JAVAFLAGS $TEST) >/dev/null 2>&1; then 124 | ac_cv_prog_java_works=yes 125 | else 126 | echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD 127 | cat $JAVA_TEST >&AS_MESSAGE_LOG_FD 128 | AC_MSG_ERROR(The Java VM $JAVA failed (see config.log, check the CLASSPATH?)) 129 | fi 130 | rm -fr $JAVA_TEST $CLASS_TEST Test.uue 131 | ]) 132 | AC_PROVIDE([$0])dnl 133 | ] 134 | ) 135 | -------------------------------------------------------------------------------- /m4/ax_prog_javac.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_javac.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAVAC 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_PROG_JAVAC tests an existing Java compiler. It uses the environment 12 | # variable JAVAC then tests in sequence various common Java compilers. For 13 | # political reasons, it starts with the free ones. 14 | # 15 | # If you want to force a specific compiler: 16 | # 17 | # - at the configure.in level, set JAVAC=yourcompiler before calling 18 | # AX_PROG_JAVAC 19 | # 20 | # - at the configure level, setenv JAVAC 21 | # 22 | # You can use the JAVAC variable in your Makefile.in, with @JAVAC@. 23 | # 24 | # *Warning*: its success or failure can depend on a proper setting of the 25 | # CLASSPATH env. variable. 26 | # 27 | # TODO: allow to exclude compilers (rationale: most Java programs cannot 28 | # compile with some compilers like guavac). 29 | # 30 | # Note: This is part of the set of autoconf M4 macros for Java programs. 31 | # It is VERY IMPORTANT that you download the whole set, some macros depend 32 | # on other. Unfortunately, the autoconf archive does not support the 33 | # concept of set of macros, so I had to break it for submission. The 34 | # general documentation, as well as the sample configure.in, is included 35 | # in the AX_PROG_JAVA macro. 36 | # 37 | # LICENSE 38 | # 39 | # Copyright (c) 2008 Stephane Bortzmeyer 40 | # 41 | # This program is free software; you can redistribute it and/or modify it 42 | # under the terms of the GNU General Public License as published by the 43 | # Free Software Foundation; either version 2 of the License, or (at your 44 | # option) any later version. 45 | # 46 | # This program is distributed in the hope that it will be useful, but 47 | # WITHOUT ANY WARRANTY; without even the implied warranty of 48 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 49 | # Public License for more details. 50 | # 51 | # You should have received a copy of the GNU General Public License along 52 | # with this program. If not, see . 53 | # 54 | # As a special exception, the respective Autoconf Macro's copyright owner 55 | # gives unlimited permission to copy, distribute and modify the configure 56 | # scripts that are the output of Autoconf when processing the Macro. You 57 | # need not follow the terms of the GNU General Public License when using 58 | # or distributing such scripts, even though portions of the text of the 59 | # Macro appear in them. The GNU General Public License (GPL) does govern 60 | # all other use of the material that constitutes the Autoconf Macro. 61 | # 62 | # This special exception to the GPL applies to versions of the Autoconf 63 | # Macro released by the Autoconf Archive. When you make and distribute a 64 | # modified version of the Autoconf Macro, you may extend this special 65 | # exception to the GPL to apply to your modified version as well. 66 | 67 | #serial 6 68 | 69 | AU_ALIAS([AC_PROG_JAVAC], [AX_PROG_JAVAC]) 70 | AC_DEFUN([AX_PROG_JAVAC],[ 71 | if test "x$JAVAPREFIX" = x; then 72 | test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj -C" guavac jikes javac) 73 | else 74 | test "x$JAVAC" = x && AC_CHECK_PROGS(JAVAC, "gcj -C" guavac jikes javac, $JAVAPREFIX) 75 | fi 76 | test "x$JAVAC" = x && AC_MSG_ERROR([no acceptable Java compiler found in \$PATH]) 77 | AX_PROG_JAVAC_WORKS 78 | AC_PROVIDE([$0])dnl 79 | ]) 80 | -------------------------------------------------------------------------------- /m4/ax_prog_javac_works.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_javac_works.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAVAC_WORKS 8 | # 9 | # DESCRIPTION 10 | # 11 | # Internal use ONLY. 12 | # 13 | # Note: This is part of the set of autoconf M4 macros for Java programs. 14 | # It is VERY IMPORTANT that you download the whole set, some macros depend 15 | # on other. Unfortunately, the autoconf archive does not support the 16 | # concept of set of macros, so I had to break it for submission. The 17 | # general documentation, as well as the sample configure.in, is included 18 | # in the AX_PROG_JAVA macro. 19 | # 20 | # LICENSE 21 | # 22 | # Copyright (c) 2008 Stephane Bortzmeyer 23 | # 24 | # This program is free software; you can redistribute it and/or modify it 25 | # under the terms of the GNU General Public License as published by the 26 | # Free Software Foundation; either version 2 of the License, or (at your 27 | # option) any later version. 28 | # 29 | # This program is distributed in the hope that it will be useful, but 30 | # WITHOUT ANY WARRANTY; without even the implied warranty of 31 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 32 | # Public License for more details. 33 | # 34 | # You should have received a copy of the GNU General Public License along 35 | # with this program. If not, see . 36 | # 37 | # As a special exception, the respective Autoconf Macro's copyright owner 38 | # gives unlimited permission to copy, distribute and modify the configure 39 | # scripts that are the output of Autoconf when processing the Macro. You 40 | # need not follow the terms of the GNU General Public License when using 41 | # or distributing such scripts, even though portions of the text of the 42 | # Macro appear in them. The GNU General Public License (GPL) does govern 43 | # all other use of the material that constitutes the Autoconf Macro. 44 | # 45 | # This special exception to the GPL applies to versions of the Autoconf 46 | # Macro released by the Autoconf Archive. When you make and distribute a 47 | # modified version of the Autoconf Macro, you may extend this special 48 | # exception to the GPL to apply to your modified version as well. 49 | 50 | #serial 6 51 | 52 | AU_ALIAS([AC_PROG_JAVAC_WORKS], [AX_PROG_JAVAC_WORKS]) 53 | AC_DEFUN([AX_PROG_JAVAC_WORKS],[ 54 | AC_CACHE_CHECK([if $JAVAC works], ac_cv_prog_javac_works, [ 55 | JAVA_TEST=Test.java 56 | CLASS_TEST=Test.class 57 | cat << \EOF > $JAVA_TEST 58 | /* [#]line __oline__ "configure" */ 59 | public class Test { 60 | } 61 | EOF 62 | if AC_TRY_COMMAND($JAVAC $JAVACFLAGS $JAVA_TEST) >/dev/null 2>&1; then 63 | ac_cv_prog_javac_works=yes 64 | else 65 | AC_MSG_ERROR([The Java compiler $JAVAC failed (see config.log, check the CLASSPATH?)]) 66 | echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD 67 | cat $JAVA_TEST >&AS_MESSAGE_LOG_FD 68 | fi 69 | rm -f $JAVA_TEST $CLASS_TEST 70 | ]) 71 | AC_PROVIDE([$0])dnl 72 | ]) 73 | -------------------------------------------------------------------------------- /m4/ax_prog_javadoc.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_javadoc.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAVADOC 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_PROG_JAVADOC tests for an existing javadoc generator. It uses the 12 | # environment variable JAVADOC then tests in sequence various common 13 | # javadoc generator. 14 | # 15 | # If you want to force a specific compiler: 16 | # 17 | # - at the configure.in level, set JAVADOC=yourgenerator before calling 18 | # AX_PROG_JAVADOC 19 | # 20 | # - at the configure level, setenv JAVADOC 21 | # 22 | # You can use the JAVADOC variable in your Makefile.in, with @JAVADOC@. 23 | # 24 | # Note: This macro depends on the autoconf M4 macros for Java programs. It 25 | # is VERY IMPORTANT that you download that whole set, some macros depend 26 | # on other. Unfortunately, the autoconf archive does not support the 27 | # concept of set of macros, so I had to break it for submission. 28 | # 29 | # The general documentation of those macros, as well as the sample 30 | # configure.in, is included in the AX_PROG_JAVA macro. 31 | # 32 | # LICENSE 33 | # 34 | # Copyright (c) 2008 Egon Willighagen 35 | # 36 | # Copying and distribution of this file, with or without modification, are 37 | # permitted in any medium without royalty provided the copyright notice 38 | # and this notice are preserved. This file is offered as-is, without any 39 | # warranty. 40 | 41 | #serial 7 42 | 43 | AU_ALIAS([AC_PROG_JAVADOC], [AX_PROG_JAVADOC]) 44 | AC_DEFUN([AX_PROG_JAVADOC],[ 45 | if test "x$JAVAPREFIX" = x; then 46 | test "x$JAVADOC" = x && AC_CHECK_PROGS(JAVADOC, javadoc) 47 | else 48 | test "x$JAVADOC" = x && AC_CHECK_PROGS(JAVADOC, javadoc, $JAVAPREFIX) 49 | fi 50 | test "x$JAVADOC" = x && AC_MSG_ERROR([no acceptable javadoc generator found in \$PATH]) 51 | AC_PROVIDE([$0])dnl 52 | ]) 53 | -------------------------------------------------------------------------------- /m4/ax_prog_javah.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_prog_javah.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_PROG_JAVAH 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_PROG_JAVAH tests the availability of the javah header generator and 12 | # looks for the jni.h header file. If available, JAVAH is set to the full 13 | # path of javah and CPPFLAGS is updated accordingly. 14 | # 15 | # LICENSE 16 | # 17 | # Copyright (c) 2008 Luc Maisonobe 18 | # 19 | # Copying and distribution of this file, with or without modification, are 20 | # permitted in any medium without royalty provided the copyright notice 21 | # and this notice are preserved. This file is offered as-is, without any 22 | # warranty. 23 | 24 | #serial 5 25 | 26 | AU_ALIAS([AC_PROG_JAVAH], [AX_PROG_JAVAH]) 27 | AC_DEFUN([AX_PROG_JAVAH],[ 28 | AC_REQUIRE([AC_CANONICAL_SYSTEM])dnl 29 | AC_REQUIRE([AC_PROG_CPP])dnl 30 | AC_PATH_PROG(JAVAH,javah) 31 | if test x"`eval 'echo $ac_cv_path_JAVAH'`" != x ; then 32 | AC_TRY_CPP([#include ],,[ 33 | ac_save_CPPFLAGS="$CPPFLAGS" 34 | changequote(, )dnl 35 | ac_dir=`echo $ac_cv_path_JAVAH | sed 's,\(.*\)/[^/]*/[^/]*$,\1/include,'` 36 | ac_machdep=`echo $build_os | sed 's,[-0-9].*,,' | sed 's,cygwin,win32,'` 37 | changequote([, ])dnl 38 | CPPFLAGS="$ac_save_CPPFLAGS -I$ac_dir -I$ac_dir/$ac_machdep" 39 | AC_TRY_CPP([#include ], 40 | ac_save_CPPFLAGS="$CPPFLAGS", 41 | AC_MSG_WARN([unable to include ])) 42 | CPPFLAGS="$ac_save_CPPFLAGS"]) 43 | fi]) 44 | -------------------------------------------------------------------------------- /m4/ax_try_compile_java.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_try_compile_java.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_TRY_COMPILE_JAVA 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_TRY_COMPILE_JAVA attempt to compile user given source. 12 | # 13 | # *Warning*: its success or failure can depend on a proper setting of the 14 | # CLASSPATH env. variable. 15 | # 16 | # Note: This is part of the set of autoconf M4 macros for Java programs. 17 | # It is VERY IMPORTANT that you download the whole set, some macros depend 18 | # on other. Unfortunately, the autoconf archive does not support the 19 | # concept of set of macros, so I had to break it for submission. The 20 | # general documentation, as well as the sample configure.in, is included 21 | # in the AX_PROG_JAVA macro. 22 | # 23 | # LICENSE 24 | # 25 | # Copyright (c) 2008 Devin Weaver 26 | # 27 | # Copying and distribution of this file, with or without modification, are 28 | # permitted in any medium without royalty provided the copyright notice 29 | # and this notice are preserved. This file is offered as-is, without any 30 | # warranty. 31 | 32 | #serial 7 33 | 34 | AU_ALIAS([AC_TRY_COMPILE_JAVA], [AX_TRY_COMPILE_JAVA]) 35 | AC_DEFUN([AX_TRY_COMPILE_JAVA],[ 36 | AC_REQUIRE([AX_PROG_JAVAC])dnl 37 | cat << \EOF > Test.java 38 | /* [#]line __oline__ "configure" */ 39 | ifelse([$1], , , [import $1;]) 40 | public class Test { 41 | [$2] 42 | } 43 | EOF 44 | if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class 45 | then 46 | dnl Don't remove the temporary files here, so they can be examined. 47 | ifelse([$3], , :, [$3]) 48 | else 49 | echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD 50 | cat Test.java >&AS_MESSAGE_LOG_FD 51 | ifelse([$4], , , [ rm -fr Test* 52 | $4 53 | ])dnl 54 | fi 55 | rm -fr Test*]) 56 | -------------------------------------------------------------------------------- /m4/ax_try_run_java.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_try_run_java.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_TRY_RUN_JAVA 8 | # 9 | # DESCRIPTION 10 | # 11 | # AX_TRY_RUN_JAVA attempt to compile and run user given source. 12 | # 13 | # *Warning*: its success or failure can depend on a proper setting of the 14 | # CLASSPATH env. variable. 15 | # 16 | # Note: This is part of the set of autoconf M4 macros for Java programs. 17 | # It is VERY IMPORTANT that you download the whole set, some macros depend 18 | # on other. Unfortunately, the autoconf archive does not support the 19 | # concept of set of macros, so I had to break it for submission. The 20 | # general documentation, as well as the sample configure.in, is included 21 | # in the AX_PROG_JAVA macro. 22 | # 23 | # LICENSE 24 | # 25 | # Copyright (c) 2008 Devin Weaver 26 | # 27 | # Copying and distribution of this file, with or without modification, are 28 | # permitted in any medium without royalty provided the copyright notice 29 | # and this notice are preserved. This file is offered as-is, without any 30 | # warranty. 31 | 32 | #serial 1 33 | 34 | AU_ALIAS([AC_TRY_RUN_JAVA], [AX_TRY_RUN_JAVA]) 35 | AC_DEFUN([AX_TRY_RUN_JAVA],[ 36 | AC_REQUIRE([AX_PROG_JAVAC])dnl 37 | AC_REQUIRE([AX_PROG_JAVA])dnl 38 | cat << \EOF > Test.java 39 | /* [#]line __oline__ "configure" */ 40 | ifelse([$1], , , [include $1;]) 41 | public class Test { 42 | [$2] 43 | } 44 | EOF 45 | if AC_TRY_COMMAND($JAVAC $JAVACFLAGS Test.java) && test -s Test.class && ($JAVA $JAVAFLAGS Test; exit) 2>/dev/null 46 | then 47 | dnl Don't remove the temporary files here, so they can be examined. 48 | ifelse([$3], , :, [$3]) 49 | else 50 | echo "configure: failed program was:" >&AS_MESSAGE_LOG_FD 51 | cat Test.java >&AS_MESSAGE_LOG_FD 52 | ifelse([$4], , , [ rm -fr Test* 53 | $4 54 | ])dnl 55 | fi 56 | rm -fr Test*]) 57 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | lib_LTLIBRARIES = libffts.la 4 | 5 | libffts_la_SOURCES = ffts.c ffts_nd.c ffts_real.c ffts_real_nd.c ffts_transpose.c ffts_trig.c ffts_static.c 6 | libffts_la_SOURCES += codegen.h codegen_arm.h codegen_sse.h ffts.h ffts_nd.h ffts_real.h ffts_real_nd.h ffts_small.h ffts_static.h macros-alpha.h macros-altivec.h macros-neon.h macros-sse.h macros.h neon.h neon_float.h patterns.h types.h vfp.h 7 | 8 | if DYNAMIC_DISABLED 9 | libffts_la_SOURCES += ffts_static.c 10 | else 11 | libffts_la_SOURCES += codegen.c 12 | endif 13 | 14 | libffts_includedir=$(includedir)/ffts 15 | libffts_include_HEADERS = ../include/ffts.h 16 | 17 | AM_CFLAGS = -I$(top_srcdir)/include -DAUTOTOOLS_BUILD=yes 18 | 19 | if HAVE_VFP 20 | libffts_la_SOURCES += vfp.s 21 | else 22 | if HAVE_NEON 23 | 24 | libffts_la_SOURCES += neon.s 25 | 26 | if DYNAMIC_DISABLED 27 | libffts_la_SOURCES += neon_static_f.s neon_static_i.s 28 | endif 29 | 30 | else 31 | if HAVE_SSE 32 | libffts_la_SOURCES += macros-sse.h 33 | endif 34 | endif 35 | endif 36 | -------------------------------------------------------------------------------- /src/arch/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.deps 4 | /.libs 5 | /*.la 6 | /*.lo 7 | -------------------------------------------------------------------------------- /src/arch/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2001, 2002, 2003 Ximian, Inc and the individuals listed 2 | on the ChangeLog entries. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files (the 6 | "Software"), to deal in the Software without restriction, including 7 | without limitation the rights to use, copy, modify, merge, publish, 8 | distribute, sublicense, and/or sell copies of the Software, and to 9 | permit persons to whom the Software is furnished to do so, subject to 10 | the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 19 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 20 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/arch/Makefile.am: -------------------------------------------------------------------------------- 1 | DIST_SUBDIRS = x86 ppc sparc arm arm64 s390x amd64 ia64 mips 2 | 3 | AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) 4 | 5 | if ARM 6 | # arm needs to build some stuff even in JIT mode 7 | SUBDIRS = $(arch_target) 8 | endif 9 | 10 | EXTRA_DIST = ChangeLog 11 | 12 | -------------------------------------------------------------------------------- /src/arch/README: -------------------------------------------------------------------------------- 1 | mono_arch 2 | ========= 3 | 4 | Part of Mono project, https://github.com/mono 5 | 6 | These are C macros that are useful when generating native code on various platforms. 7 | This code is MIT X11 licensed. 8 | -------------------------------------------------------------------------------- /src/arch/arm/.gitattributes: -------------------------------------------------------------------------------- 1 | /arm-wmmx.h -crlf 2 | -------------------------------------------------------------------------------- /src/arch/arm/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.deps 4 | /.libs 5 | /*.o 6 | /*.la 7 | /*.lo 8 | /*.lib 9 | /*.obj 10 | /*.exe 11 | /*.dll 12 | /arm_dpimacros.h 13 | /arm_fpamacros.h 14 | /arm_vfpmacros.h 15 | /fixeol.sh 16 | -------------------------------------------------------------------------------- /src/arch/arm/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) 3 | 4 | noinst_LTLIBRARIES = libmonoarch-arm.la 5 | 6 | BUILT_SOURCES = arm_dpimacros.h arm_vfpmacros.h 7 | 8 | 9 | libmonoarch_arm_la_SOURCES = $(BUILT_SOURCES) \ 10 | arm-codegen.c \ 11 | arm-codegen.h \ 12 | arm-dis.c \ 13 | arm-dis.h 14 | 15 | arm_dpimacros.h: dpiops.sh mov_macros.th dpi_macros.th cmp_macros.th 16 | (cd $(srcdir); bash ./dpiops.sh) > $@t 17 | mv $@t $@ 18 | 19 | arm_vfpmacros.h: vfpops.sh vfpm_macros.th vfp_macros.th 20 | (cd $(srcdir); bash ./vfpops.sh) > $@t 21 | mv $@t $@ 22 | 23 | CLEANFILES = $(BUILT_SOURCES) 24 | 25 | EXTRA_DIST = dpiops.sh mov_macros.th dpi_macros.th cmp_macros.th \ 26 | vfpm_macros.th vfp_macros.th arm-vfp-codegen.h vfpops.sh 27 | 28 | -------------------------------------------------------------------------------- /src/arch/arm/arm-codegen.c: -------------------------------------------------------------------------------- 1 | /* 2 | * arm-codegen.c 3 | * Copyright (c) 2002 Sergey Chaban 4 | */ 5 | 6 | #include "arm-codegen.h" 7 | 8 | 9 | arminstr_t* arm_emit_std_prologue(arminstr_t* p, unsigned int local_size) { 10 | ARM_MOV_REG_REG(p, ARMREG_IP, ARMREG_SP); 11 | 12 | /* save args */ 13 | ARM_PUSH(p, (1 << ARMREG_A1) 14 | | (1 << ARMREG_A2) 15 | | (1 << ARMREG_A3) 16 | | (1 << ARMREG_A4)); 17 | 18 | ARM_PUSH(p, (1U << ARMREG_IP) | (1U << ARMREG_LR)); 19 | 20 | if (local_size != 0) { 21 | if ((local_size & (~0xFF)) == 0) { 22 | ARM_SUB_REG_IMM8(p, ARMREG_SP, ARMREG_SP, local_size); 23 | } else { 24 | /* TODO: optimize */ 25 | p = arm_mov_reg_imm32(p, ARMREG_IP, local_size); 26 | ARM_SUB_REG_REG(p, ARMREG_SP, ARMREG_SP, ARMREG_IP); 27 | ARM_ADD_REG_IMM8(p, ARMREG_IP, ARMREG_IP, sizeof(armword_t)); 28 | ARM_LDR_REG_REG(p, ARMREG_IP, ARMREG_SP, ARMREG_IP); 29 | } 30 | } 31 | 32 | return p; 33 | } 34 | 35 | arminstr_t* arm_emit_std_epilogue(arminstr_t* p, unsigned int local_size, int pop_regs) { 36 | if (local_size != 0) { 37 | if ((local_size & (~0xFF)) == 0) { 38 | ARM_ADD_REG_IMM8(p, ARMREG_SP, ARMREG_SP, local_size); 39 | } else { 40 | /* TODO: optimize */ 41 | p = arm_mov_reg_imm32(p, ARMREG_IP, local_size); 42 | ARM_ADD_REG_REG(p, ARMREG_SP, ARMREG_SP, ARMREG_IP); 43 | } 44 | } 45 | 46 | ARM_POP_NWB(p, (1 << ARMREG_SP) | (1 << ARMREG_PC) | (pop_regs & 0x3FF)); 47 | 48 | return p; 49 | } 50 | 51 | 52 | /* do not push A1-A4 */ 53 | arminstr_t* arm_emit_lean_prologue(arminstr_t* p, unsigned int local_size, int push_regs) { 54 | ARM_MOV_REG_REG(p, ARMREG_IP, ARMREG_SP); 55 | /* push_regs upto R10 will be saved */ 56 | ARM_PUSH(p, (1U << ARMREG_IP) | (1U << ARMREG_LR) | (push_regs & 0x3FF)); 57 | 58 | if (local_size != 0) { 59 | if ((local_size & (~0xFF)) == 0) { 60 | ARM_SUB_REG_IMM8(p, ARMREG_SP, ARMREG_SP, local_size); 61 | } else { 62 | /* TODO: optimize */ 63 | p = arm_mov_reg_imm32(p, ARMREG_IP, local_size); 64 | ARM_SUB_REG_REG(p, ARMREG_SP, ARMREG_SP, ARMREG_IP); 65 | /* restore IP from stack */ 66 | ARM_ADD_REG_IMM8(p, ARMREG_IP, ARMREG_IP, sizeof(armword_t)); 67 | ARM_LDR_REG_REG(p, ARMREG_IP, ARMREG_SP, ARMREG_IP); 68 | } 69 | } 70 | 71 | return p; 72 | } 73 | 74 | /* Bit scan forward. */ 75 | int arm_bsf(armword_t val) { 76 | int i; 77 | armword_t mask; 78 | 79 | if (val == 0) return 0; 80 | for (i=1, mask=1; (i <= 8 * sizeof(armword_t)) && ((val & mask) == 0); ++i, mask<<=1); 81 | 82 | return i; 83 | } 84 | 85 | 86 | int arm_is_power_of_2(armword_t val) { 87 | return ((val & (val-1)) == 0); 88 | } 89 | 90 | 91 | /* 92 | * returns: 93 | * 1 - unable to represent 94 | * positive even number - MOV-representable 95 | * negative even number - MVN-representable 96 | */ 97 | int calc_arm_mov_const_shift(armword_t val) { 98 | armword_t mask; 99 | int res = 1, shift; 100 | 101 | for (shift=0; shift < 32; shift+=2) { 102 | mask = ARM_SCALE(0xFF, shift); 103 | if ((val & (~mask)) == 0) { 104 | res = shift; 105 | break; 106 | } 107 | if (((~val) & (~mask)) == 0) { 108 | res = -shift - 2; 109 | break; 110 | } 111 | } 112 | 113 | return res; 114 | } 115 | 116 | 117 | int is_arm_const(armword_t val) { 118 | int res; 119 | res = arm_is_power_of_2(val); 120 | if (!res) { 121 | res = calc_arm_mov_const_shift(val); 122 | res = !(res < 0 || res == 1); 123 | } 124 | return res; 125 | } 126 | 127 | 128 | int arm_const_steps(armword_t val) { 129 | int shift, steps = 0; 130 | 131 | while (val != 0) { 132 | shift = (arm_bsf(val) - 1) & (~1); 133 | val &= ~(0xFF << shift); 134 | ++steps; 135 | } 136 | return steps; 137 | } 138 | 139 | 140 | /* 141 | * ARM cannot load arbitrary 32-bit constants directly into registers; 142 | * widely used work-around for this is to store constants into a 143 | * PC-addressable pool and use LDR instruction with PC-relative address 144 | * to load constant into register. Easiest way to implement this is to 145 | * embed constant inside a function with unconditional branch around it. 146 | * The above method is not used at the moment. 147 | * This routine always emits sequence of instructions to generate 148 | * requested constant. In the worst case it takes 4 instructions to 149 | * synthesize a constant - 1 MOV and 3 subsequent ORRs. 150 | */ 151 | arminstr_t* arm_mov_reg_imm32_cond(arminstr_t* p, int reg, armword_t imm32, int cond) { 152 | int mov_op; 153 | int step_op; 154 | int snip; 155 | int shift = calc_arm_mov_const_shift(imm32); 156 | 157 | if ((shift & 0x80000001) != 1) { 158 | if (shift >= 0) { 159 | ARM_MOV_REG_IMM_COND(p, reg, imm32 >> ((32 - shift) & 31), shift, cond); 160 | } else { 161 | ARM_MVN_REG_IMM_COND(p, reg, (imm32 ^ (~0)) >> ((32 + 2 + shift) & 31), (-shift - 2), cond); 162 | } 163 | } else { 164 | mov_op = ARMOP_MOV; 165 | step_op = ARMOP_ORR; 166 | 167 | if (arm_const_steps(imm32) > arm_const_steps(~imm32)) { 168 | mov_op = ARMOP_MVN; 169 | step_op = ARMOP_SUB; 170 | imm32 = ~imm32; 171 | } 172 | 173 | shift = (arm_bsf(imm32) - 1) & (~1); 174 | snip = imm32 & (0xFF << shift); 175 | ARM_EMIT(p, ARM_DEF_DPI_IMM_COND((unsigned)snip >> shift, (32 - shift) >> 1, reg, 0, 0, mov_op, cond)); 176 | 177 | while ((imm32 ^= snip) != 0) { 178 | shift = (arm_bsf(imm32) - 1) & (~1); 179 | snip = imm32 & (0xFF << shift); 180 | ARM_EMIT(p, ARM_DEF_DPI_IMM_COND((unsigned)snip >> shift, (32 - shift) >> 1, reg, reg, 0, step_op, cond)); 181 | } 182 | } 183 | 184 | return p; 185 | } 186 | 187 | 188 | arminstr_t* arm_mov_reg_imm32(arminstr_t* p, int reg, armword_t imm32) { 189 | return arm_mov_reg_imm32_cond(p, reg, imm32, ARMCOND_AL); 190 | } 191 | 192 | 193 | 194 | -------------------------------------------------------------------------------- /src/arch/arm/arm-dis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2002 Sergey Chaban 3 | */ 4 | 5 | #ifndef ARM_DIS 6 | #define ARM_DIS 7 | 8 | #include 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | typedef struct _ARMDis { 16 | FILE* dis_out; 17 | void* pi; 18 | } ARMDis; 19 | 20 | 21 | void _armdis_set_output(FILE* f); 22 | FILE* _armdis_get_output(void); 23 | void _armdis_decode(void* p, int size); 24 | void _armdis_open(const char* dump_name); 25 | void _armdis_close(void); 26 | void _armdis_dump(const char* dump_name, void* p, int size); 27 | 28 | 29 | void armdis_init(ARMDis* dis); 30 | void armdis_set_output(ARMDis* dis, FILE* f); 31 | FILE* armdis_get_output(ARMDis* dis); 32 | void armdis_decode(ARMDis* dis, void* p, int size); 33 | void armdis_open(ARMDis* dis, const char* dump_name); 34 | void armdis_close(ARMDis* dis); 35 | void armdis_dump(ARMDis* dis, const char* dump_name, void* p, int size); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif /* ARM_DIS */ 42 | -------------------------------------------------------------------------------- /src/arch/arm/arm-wmmx.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ARM CodeGen 3 | * XScale WirelessMMX extensions 4 | * Copyright 2002 Wild West Software 5 | */ 6 | 7 | #ifndef __WMMX_H__ 8 | #define __WMMX_H__ 1 9 | 10 | #if 0 11 | #include 12 | #endif 13 | 14 | #if defined(ARM_IASM) 15 | # define WM_ASM(_expr) ARM_IASM(_expr) 16 | #else 17 | # define WM_ASM(_expr) __emit (_expr) 18 | #endif 19 | 20 | #if defined(ARM_EMIT) 21 | # define WM_EMIT(p, i) ARM_EMIT(p, i) 22 | #else 23 | # define WM_EMIT(p, i) 24 | #endif 25 | 26 | enum { 27 | WM_CC_EQ = 0x0, 28 | WM_CC_NE = 0x1, 29 | WM_CC_CS = 0x2, 30 | WM_CC_HS = WM_CC_CS, 31 | WM_CC_CC = 0x3, 32 | WM_CC_LO = WM_CC_CC, 33 | WM_CC_MI = 0x4, 34 | WM_CC_PL = 0x5, 35 | WM_CC_VS = 0x6, 36 | WM_CC_VC = 0x7, 37 | WM_CC_HI = 0x8, 38 | WM_CC_LS = 0x9, 39 | WM_CC_GE = 0xA, 40 | WM_CC_LT = 0xB, 41 | WM_CC_GT = 0xC, 42 | WM_CC_LE = 0xD, 43 | WM_CC_AL = 0xE, 44 | WM_CC_NV = 0xF, 45 | WM_CC_SHIFT = 28 46 | }; 47 | 48 | #if defined(ARM_DEF_COND) 49 | # define WM_DEF_CC(_cc) ARM_DEF_COND(_cc) 50 | #else 51 | # define WM_DEF_CC(_cc) ((_cc & 0xF) << WM_CC_SHIFT) 52 | #endif 53 | 54 | 55 | enum { 56 | WM_R0 = 0x0, 57 | WM_R1 = 0x1, 58 | WM_R2 = 0x2, 59 | WM_R3 = 0x3, 60 | WM_R4 = 0x4, 61 | WM_R5 = 0x5, 62 | WM_R6 = 0x6, 63 | WM_R7 = 0x7, 64 | WM_R8 = 0x8, 65 | WM_R9 = 0x9, 66 | WM_R10 = 0xA, 67 | WM_R11 = 0xB, 68 | WM_R12 = 0xC, 69 | WM_R13 = 0xD, 70 | WM_R14 = 0xE, 71 | WM_R15 = 0xF, 72 | 73 | WM_wR0 = 0x0, 74 | WM_wR1 = 0x1, 75 | WM_wR2 = 0x2, 76 | WM_wR3 = 0x3, 77 | WM_wR4 = 0x4, 78 | WM_wR5 = 0x5, 79 | WM_wR6 = 0x6, 80 | WM_wR7 = 0x7, 81 | WM_wR8 = 0x8, 82 | WM_wR9 = 0x9, 83 | WM_wR10 = 0xA, 84 | WM_wR11 = 0xB, 85 | WM_wR12 = 0xC, 86 | WM_wR13 = 0xD, 87 | WM_wR14 = 0xE, 88 | WM_wR15 = 0xF 89 | }; 90 | 91 | 92 | /* 93 | * Qualifiers: 94 | * H - 16-bit (HalfWord) SIMD 95 | * W - 32-bit (Word) SIMD 96 | * D - 64-bit (Double) 97 | */ 98 | enum { 99 | WM_B = 0, 100 | WM_H = 1, 101 | WM_D = 2 102 | }; 103 | 104 | /* 105 | * B.2.3 Transfers From Coprocessor Register (MRC) 106 | * Table B-5 107 | */ 108 | enum { 109 | WM_TMRC_OP2 = 0, 110 | WM_TMRC_CPNUM = 1, 111 | 112 | WM_TMOVMSK_OP2 = 1, 113 | WM_TMOVMSK_CPNUM = 0, 114 | 115 | WM_TANDC_OP2 = 1, 116 | WM_TANDC_CPNUM = 1, 117 | 118 | WM_TORC_OP2 = 2, 119 | WM_TORC_CPNUM = 1, 120 | 121 | WM_TEXTRC_OP2 = 3, 122 | WM_TEXTRC_CPNUM = 1, 123 | 124 | WM_TEXTRM_OP2 = 3, 125 | WM_TEXTRM_CPNUM = 0 126 | }; 127 | 128 | 129 | /* 130 | * TANDC{Cond} R15 131 | * Performs AND across the fields of the SIMD PSR register (wCASF) and sends the result 132 | * to CPSR; can be performed after a Byte, Half-word or Word operation that sets the flags. 133 | * NOTE: R15 is omitted from the macro declaration; 134 | */ 135 | #define DEF_WM_TNADC_CC(_q, _cc) WM_DEF_CC((_cc)) + ((_q) << 0x16) + 0xE13F130 136 | 137 | #define _WM_TNADC_CC(_q, _cc) WM_ASM(DEF_WM_TNADC_CC(_q, _cc)) 138 | #define ARM_WM_TNADC_CC(_p, _q, _cc) WM_EMIT(_p, DEF_WM_TNADC_CC(_q, _cc)) 139 | 140 | /* inline assembly */ 141 | #define _WM_TNADC(_q) _WM_TNADC_CC((_q), WM_CC_AL) 142 | #define _WM_TNADCB() _WM_TNADC(WM_B) 143 | #define _WM_TNADCH() _WM_TNADC(WM_H) 144 | #define _WM_TNADCD() _WM_TNADC(WM_D) 145 | 146 | /* codegen */ 147 | #define ARM_WM_TNADC(_p, _q) ARM_WM_TNADC_CC((_p), (_q), WM_CC_AL) 148 | #define ARM_WM_TNADCB(_p) ARM_WM_TNADC(_p, WM_B) 149 | #define ARM_WM_TNADCH(_p) ARM_WM_TNADC(_p, WM_H) 150 | #define ARM_WM_TNADCD(_p) ARM_WM_TNADC(_p, WM_D) 151 | 152 | 153 | /* 154 | * TBCST{Cond} wRd, Rn 155 | * Broadcasts a value from the ARM Source reg (Rn) to every SIMD position 156 | * in the WMMX Destination reg (wRd). 157 | */ 158 | #define DEF_WM_TBCST_CC(_q, _cc, _wrd, _rn) \ 159 | WM_DEF_CC((_cc)) + ((_q) << 6) + ((_wrd) << 16) + ((_rn) << 12) + 0xE200010 160 | 161 | #define _WM_TBCST_CC(_q, _cc, _wrd, _rn) WM_ASM(DEF_WM_TBCST_CC(_q, _cc, _wrd, _rn)) 162 | #define ARM_WM_TBCST_CC(_p, _q, _cc, _wrd, _rn) WM_EMIT(_p, DEF_WM_TBCST_CC(_q, _cc, _wrd, _rn)) 163 | 164 | /* inline */ 165 | #define _WM_TBCST(_q, _wrd, _rn) _WM_TBCST_CC(_q, WM_CC_AL, _wrd, _rn) 166 | #define _WM_TBCSTB(_wrd, _rn) _WM_TBCST(WM_B) 167 | #define _WM_TBCSTH(_wrd, _rn) _WM_TBCST(WM_H) 168 | #define _WM_TBCSTD(_wrd, _rn) _WM_TBCST(WM_D) 169 | 170 | /* codegen */ 171 | #define ARM_WM_TBCST(_p, _q, _wrd, _rn) ARM_WM_TBCST_CC(_p, _q, WM_CC_AL, _wrd, _rn) 172 | #define ARM_WM_TBCSTB(_p, _wrd, _rn) _WM_TBCST(_p, WM_B) 173 | #define ARM_WM_TBCSTH(_p, _wrd, _rn) _WM_TBCST(_p, WM_H) 174 | #define ARM_WM_TBCSTD(_p, _wrd, _rn) _WM_TBCST(_p, WM_D) 175 | 176 | 177 | #endif /* __WMMX_H__ */ 178 | -------------------------------------------------------------------------------- /src/arch/arm/cmp_macros.th: -------------------------------------------------------------------------------- 1 | /* PSR := Rn, (imm8 ROR 2*rot) */ 2 | #define ARM__REG_IMM_COND(p, rn, imm8, rot, cond) \ 3 | ARM_DPIOP_S_REG_IMM8ROT_COND(p, ARMOP_, 0, rn, imm8, rot, cond) 4 | #define ARM__REG_IMM(p, rn, imm8, rot) \ 5 | ARM__REG_IMM_COND(p, rn, imm8, rot, ARMCOND_AL) 6 | 7 | #ifndef ARM_NOIASM 8 | #define __REG_IMM_COND(rn, imm8, rot, cond) \ 9 | ARM_IASM_DPIOP_S_REG_IMM8ROT_COND(ARMOP_, 0, rn, imm8, rot, cond) 10 | #define __REG_IMM(rn, imm8, rot) \ 11 | __REG_IMM_COND(rn, imm8, rot, ARMCOND_AL) 12 | #endif 13 | 14 | 15 | /* PSR := Rn, imm8 */ 16 | #define ARM__REG_IMM8_COND(p, rn, imm8, cond) \ 17 | ARM__REG_IMM_COND(p, rn, imm8, 0, cond) 18 | #define ARM__REG_IMM8(p, rn, imm8) \ 19 | ARM__REG_IMM8_COND(p, rn, imm8, ARMCOND_AL) 20 | 21 | #ifndef ARM_NOIASM 22 | #define __REG_IMM8_COND(rn, imm8, cond) \ 23 | __REG_IMM_COND(rn, imm8, 0, cond) 24 | #define __REG_IMM8(rn, imm8) \ 25 | __REG_IMM8_COND(rn, imm8, ARMCOND_AL) 26 | #endif 27 | 28 | 29 | /* PSR := Rn, Rm */ 30 | #define ARM__REG_REG_COND(p, rn, rm, cond) \ 31 | ARM_DPIOP_S_REG_REG_COND(p, ARMOP_, 0, rn, rm, cond) 32 | #define ARM__REG_REG(p, rn, rm) \ 33 | ARM__REG_REG_COND(p, rn, rm, ARMCOND_AL) 34 | 35 | #ifndef ARM_NOIASM 36 | #define __REG_REG_COND(rn, rm, cond) \ 37 | ARM_IASM_DPIOP_S_REG_REG_COND(ARMOP_, 0, rn, rm, cond) 38 | #define __REG_REG(rn, rm) \ 39 | __REG_REG_COND(rn, rm, ARMCOND_AL) 40 | #endif 41 | 42 | 43 | /* PSR := Rn, (Rm imm8) */ 44 | #define ARM__REG_IMMSHIFT_COND(p, rn, rm, shift_type, imm_shift, cond) \ 45 | ARM_DPIOP_S_REG_IMMSHIFT_COND(p, ARMOP_, 0, rn, rm, shift_type, imm_shift, cond) 46 | #define ARM__REG_IMMSHIFT(p, rn, rm, shift_type, imm_shift) \ 47 | ARM__REG_IMMSHIFT_COND(p, rn, rm, shift_type, imm_shift, ARMCOND_AL) 48 | 49 | #ifndef ARM_NOIASM 50 | #define __REG_IMMSHIFT_COND(rn, rm, shift_type, imm_shift, cond) \ 51 | ARM_IASM_DPIOP_S_REG_IMMSHIFT_COND(ARMOP_, 0, rn, rm, shift_type, imm_shift, cond) 52 | #define __REG_IMMSHIFT(rn, rm, shift_type, imm_shift) \ 53 | __REG_IMMSHIFT_COND(rn, rm, shift_type, imm_shift, ARMCOND_AL) 54 | #endif 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/arch/arm/dpi_macros.th: -------------------------------------------------------------------------------- 1 | /* -- -- */ 2 | 3 | /* Rd := Rn (imm8 ROR rot) ; rot is power of 2 */ 4 | #define ARM__REG_IMM_COND(p, rd, rn, imm8, rot, cond) \ 5 | ARM_DPIOP_REG_IMM8ROT_COND(p, ARMOP_, rd, rn, imm8, rot, cond) 6 | #define ARM__REG_IMM(p, rd, rn, imm8, rot) \ 7 | ARM__REG_IMM_COND(p, rd, rn, imm8, rot, ARMCOND_AL) 8 | #define ARM_S_REG_IMM_COND(p, rd, rn, imm8, rot, cond) \ 9 | ARM_DPIOP_S_REG_IMM8ROT_COND(p, ARMOP_, rd, rn, imm8, rot, cond) 10 | #define ARM_S_REG_IMM(p, rd, rn, imm8, rot) \ 11 | ARM_S_REG_IMM_COND(p, rd, rn, imm8, rot, ARMCOND_AL) 12 | 13 | #ifndef ARM_NOIASM 14 | #define __REG_IMM_COND(rd, rn, imm8, rot, cond) \ 15 | ARM_IASM_DPIOP_REG_IMM8ROT_COND(ARMOP_, rd, rn, imm8, rot, cond) 16 | #define __REG_IMM(rd, rn, imm8, rot) \ 17 | __REG_IMM_COND(rd, rn, imm8, rot, ARMCOND_AL) 18 | #define _S_REG_IMM_COND(rd, rn, imm8, rot, cond) \ 19 | ARM_IASM_DPIOP_S_REG_IMM8ROT_COND(ARMOP_, rd, rn, imm8, rot, cond) 20 | #define _S_REG_IMM(rd, rn, imm8, rot) \ 21 | _S_REG_IMM_COND(rd, rn, imm8, rot, ARMCOND_AL) 22 | #endif 23 | 24 | 25 | /* Rd := Rn imm8 */ 26 | #define ARM__REG_IMM8_COND(p, rd, rn, imm8, cond) \ 27 | ARM__REG_IMM_COND(p, rd, rn, imm8, 0, cond) 28 | #define ARM__REG_IMM8(p, rd, rn, imm8) \ 29 | ARM__REG_IMM8_COND(p, rd, rn, imm8, ARMCOND_AL) 30 | #define ARM_S_REG_IMM8_COND(p, rd, rn, imm8, cond) \ 31 | ARM_S_REG_IMM_COND(p, rd, rn, imm8, 0, cond) 32 | #define ARM_S_REG_IMM8(p, rd, rn, imm8) \ 33 | ARM_S_REG_IMM8_COND(p, rd, rn, imm8, ARMCOND_AL) 34 | 35 | #ifndef ARM_NOIASM 36 | #define __REG_IMM8_COND(rd, rn, imm8, cond) \ 37 | __REG_IMM_COND(rd, rn, imm8, 0, cond) 38 | #define __REG_IMM8(rd, rn, imm8) \ 39 | __REG_IMM8_COND(rd, rn, imm8, ARMCOND_AL) 40 | #define _S_REG_IMM8_COND(rd, rn, imm8, cond) \ 41 | _S_REG_IMM_COND(rd, rn, imm8, 0, cond) 42 | #define _S_REG_IMM8(rd, rn, imm8) \ 43 | _S_REG_IMM8_COND(rd, rn, imm8, ARMCOND_AL) 44 | #endif 45 | 46 | 47 | /* Rd := Rn Rm */ 48 | #define ARM__REG_REG_COND(p, rd, rn, rm, cond) \ 49 | ARM_DPIOP_REG_REG_COND(p, ARMOP_, rd, rn, rm, cond) 50 | #define ARM__REG_REG(p, rd, rn, rm) \ 51 | ARM__REG_REG_COND(p, rd, rn, rm, ARMCOND_AL) 52 | #define ARM_S_REG_REG_COND(p, rd, rn, rm, cond) \ 53 | ARM_DPIOP_S_REG_REG_COND(p, ARMOP_, rd, rn, rm, cond) 54 | #define ARM_S_REG_REG(p, rd, rn, rm) \ 55 | ARM_S_REG_REG_COND(p, rd, rn, rm, ARMCOND_AL) 56 | 57 | #ifndef ARM_NOIASM 58 | #define __REG_REG_COND(rd, rn, rm, cond) \ 59 | ARM_IASM_DPIOP_REG_REG_COND(ARMOP_, rd, rn, rm, cond) 60 | #define __REG_REG(rd, rn, rm) \ 61 | __REG_REG_COND(rd, rn, rm, ARMCOND_AL) 62 | #define _S_REG_REG_COND(rd, rn, rm, cond) \ 63 | ARM_IASM_DPIOP_S_REG_REG_COND(ARMOP_, rd, rn, rm, cond) 64 | #define _S_REG_REG(rd, rn, rm) \ 65 | _S_REG_REG_COND(rd, rn, rm, ARMCOND_AL) 66 | #endif 67 | 68 | 69 | /* Rd := Rn (Rm imm_shift) */ 70 | #define ARM__REG_IMMSHIFT_COND(p, rd, rn, rm, shift_type, imm_shift, cond) \ 71 | ARM_DPIOP_REG_IMMSHIFT_COND(p, ARMOP_, rd, rn, rm, shift_type, imm_shift, cond) 72 | #define ARM__REG_IMMSHIFT(p, rd, rn, rm, shift_type, imm_shift) \ 73 | ARM__REG_IMMSHIFT_COND(p, rd, rn, rm, shift_type, imm_shift, ARMCOND_AL) 74 | #define ARM_S_REG_IMMSHIFT_COND(p, rd, rn, rm, shift_type, imm_shift, cond) \ 75 | ARM_DPIOP_S_REG_IMMSHIFT_COND(p, ARMOP_, rd, rn, rm, shift_type, imm_shift, cond) 76 | #define ARM_S_REG_IMMSHIFT(p, rd, rn, rm, shift_type, imm_shift) \ 77 | ARM_S_REG_IMMSHIFT_COND(p, rd, rn, rm, shift_type, imm_shift, ARMCOND_AL) 78 | 79 | #ifndef ARM_NOIASM 80 | #define __REG_IMMSHIFT_COND(rd, rn, rm, shift_type, imm_shift, cond) \ 81 | ARM_IASM_DPIOP_REG_IMMSHIFT_COND(ARMOP_, rd, rn, rm, shift_type, imm_shift, cond) 82 | #define __REG_IMMSHIFT(rd, rn, rm, shift_type, imm_shift) \ 83 | __REG_IMMSHIFT_COND(rd, rn, rm, shift_type, imm_shift, ARMCOND_AL) 84 | #define _S_REG_IMMSHIFT_COND(rd, rn, rm, shift_type, imm_shift, cond) \ 85 | ARM_IASM_DPIOP_S_REG_IMMSHIFT_COND(ARMOP_, rd, rn, rm, shift_type, imm_shift, cond) 86 | #define _S_REG_IMMSHIFT(rd, rn, rm, shift_type, imm_shift) \ 87 | _S_REG_IMMSHIFT_COND(rd, rn, rm, shift_type, imm_shift, ARMCOND_AL) 88 | #endif 89 | 90 | 91 | /* Rd := Rn (Rm Rs) */ 92 | #define ARM__REG_REGSHIFT_COND(p, rd, rn, rm, shift_type, rs, cond) \ 93 | ARM_DPIOP_REG_REGSHIFT_COND(p, ARMOP_, rd, rn, rm, shift_t, rs, cond) 94 | #define ARM__REG_REGSHIFT(p, rd, rn, rm, shift_type, rs) \ 95 | ARM__REG_REGSHIFT_COND(p, rd, rn, rm, shift_type, rs, ARMCOND_AL) 96 | #define ARM_S_REG_REGSHIFT_COND(p, rd, rn, rm, shift_type, rs, cond) \ 97 | ARM_DPIOP_S_REG_REGSHIFT_COND(p, ARMOP_, rd, rn, rm, shift_t, rs, cond) 98 | #define ARM_S_REG_REGSHIFT(p, rd, rn, rm, shift_type, rs) \ 99 | ARM_S_REG_REGSHIFT_COND(p, rd, rn, rm, shift_type, rs, ARMCOND_AL) 100 | 101 | #ifndef ARM_NOIASM 102 | #define __REG_REGSHIFT_COND(rd, rn, rm, shift_type, rs, cond) \ 103 | ARM_IASM_DPIOP_REG_REGSHIFT_COND(ARMOP_, rd, rn, rm, shift_t, rs, cond) 104 | #define __REG_REGSHIFT(rd, rn, rm, shift_type, rs) \ 105 | __REG_REGSHIFT_COND(rd, rn, rm, shift_type, rs, ARMCOND_AL) 106 | #define _S_REG_REGSHIFT_COND(rd, rn, rm, shift_type, rs, cond) \ 107 | ARM_IASM_DPIOP_S_REG_REGSHIFT_COND(ARMOP_, rd, rn, rm, shift_t, rs, cond) 108 | #define _S_REG_REGSHIFT(rd, rn, rm, shift_type, rs) \ 109 | _S_REG_REGSHIFT_COND(rd, rn, rm, shift_type, rs, ARMCOND_AL) 110 | #endif 111 | 112 | 113 | -------------------------------------------------------------------------------- /src/arch/arm/dpiops.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | OPCODES="AND EOR SUB RSB ADD ADC SBC RSC ORR BIC" 4 | CMP_OPCODES="TST TEQ CMP CMN" 5 | MOV_OPCODES="MOV MVN" 6 | 7 | # $1: opcode list 8 | # $2: template 9 | gen() { 10 | for i in $1; do 11 | sed "s//$i/g" $2.th 12 | done 13 | } 14 | 15 | 16 | 17 | echo -e "/* Macros for DPI ops, auto-generated from template */\n" 18 | 19 | echo -e "\n/* mov/mvn */\n" 20 | gen "$MOV_OPCODES" mov_macros 21 | 22 | echo -e "\n/* DPIs, arithmetic and logical */\n" 23 | gen "$OPCODES" dpi_macros 24 | 25 | echo -e "\n\n" 26 | 27 | echo -e "\n/* DPIs, comparison */\n" 28 | gen "$CMP_OPCODES" cmp_macros 29 | 30 | echo -e "\n/* end generated */\n" 31 | -------------------------------------------------------------------------------- /src/arch/arm/mov_macros.th: -------------------------------------------------------------------------------- 1 | /* Rd := imm8 ROR rot */ 2 | #define ARM__REG_IMM_COND(p, reg, imm8, rot, cond) \ 3 | ARM_DPIOP_REG_IMM8ROT_COND(p, ARMOP_, reg, 0, imm8, rot, cond) 4 | #define ARM__REG_IMM(p, reg, imm8, rot) \ 5 | ARM__REG_IMM_COND(p, reg, imm8, rot, ARMCOND_AL) 6 | /* S */ 7 | #define ARM_S_REG_IMM_COND(p, reg, imm8, rot, cond) \ 8 | ARM_DPIOP_S_REG_IMM8ROT_COND(p, ARMOP_, reg, 0, imm8, rot, cond) 9 | #define ARM_S_REG_IMM(p, reg, imm8, rot) \ 10 | ARM_S_REG_IMM_COND(p, reg, imm8, rot, ARMCOND_AL) 11 | 12 | #ifndef ARM_NOIASM 13 | #define __REG_IMM_COND(reg, imm8, rot, cond) \ 14 | ARM_IASM_DPIOP_REG_IMM8ROT_COND(ARMOP_, reg, 0, imm8, rot, cond) 15 | #define __REG_IMM(reg, imm8, rot) \ 16 | __REG_IMM_COND(reg, imm8, rot, ARMCOND_AL) 17 | /* S */ 18 | #define _S_REG_IMM_COND(reg, imm8, rot, cond) \ 19 | ARM_IASM_DPIOP_S_REG_IMM8ROT_COND(ARMOP_, reg, 0, imm8, rot, cond) 20 | #define _S_REG_IMM(reg, imm8, rot) \ 21 | _S_REG_IMM_COND(reg, imm8, rot, ARMCOND_AL) 22 | #endif 23 | 24 | 25 | /* Rd := imm8 */ 26 | #define ARM__REG_IMM8_COND(p, reg, imm8, cond) \ 27 | ARM_DPIOP_REG_IMM8ROT_COND(p, ARMOP_, reg, 0, imm8, 0, cond) 28 | #define ARM__REG_IMM8(p, reg, imm8) \ 29 | ARM__REG_IMM8_COND(p, reg, imm8, ARMCOND_AL) 30 | /* S */ 31 | #define ARM_S_REG_IMM8_COND(p, reg, imm8, cond) \ 32 | ARM_DPIOP_S_REG_IMM8ROT_COND(p, ARMOP_, reg, 0, imm8, 0, cond) 33 | #define ARM_S_REG_IMM8(p, reg, imm8) \ 34 | ARM_S_REG_IMM8_COND(p, reg, imm8, ARMCOND_AL) 35 | 36 | #ifndef ARM_NOIASM 37 | #define __REG_IMM8_COND(reg, imm8, cond) \ 38 | ARM_IASM_DPIOP_REG_IMM8ROT_COND(ARMOP_, reg, 0, imm8, 0, cond) 39 | #define __REG_IMM8(reg, imm8) \ 40 | __REG_IMM8_COND(reg, imm8, ARMCOND_AL) 41 | /* S */ 42 | #define _S_REG_IMM8_COND(reg, imm8, cond) \ 43 | ARM_IASM_DPIOP_S_REG_IMM8ROT_COND(ARMOP_, reg, 0, imm8, 0, cond) 44 | #define _S_REG_IMM8(reg, imm8) \ 45 | _S_REG_IMM8_COND(reg, imm8, ARMCOND_AL) 46 | #endif 47 | 48 | 49 | /* Rd := Rm */ 50 | #define ARM__REG_REG_COND(p, rd, rm, cond) \ 51 | ARM_DPIOP_REG_REG_COND(p, ARMOP_, rd, 0, rm, cond) 52 | #define ARM__REG_REG(p, rd, rm) \ 53 | ARM__REG_REG_COND(p, rd, rm, ARMCOND_AL) 54 | /* S */ 55 | #define ARM_S_REG_REG_COND(p, rd, rm, cond) \ 56 | ARM_DPIOP_S_REG_REG_COND(p, ARMOP_, rd, 0, rm, cond) 57 | #define ARM_S_REG_REG(p, rd, rm) \ 58 | ARM_S_REG_REG_COND(p, rd, rm, ARMCOND_AL) 59 | 60 | #ifndef ARM_NOIASM 61 | #define __REG_REG_COND(rd, rm, cond) \ 62 | ARM_IASM_DPIOP_REG_REG_COND(ARMOP_, rd, 0, rm, cond) 63 | #define __REG_REG(rd, rm) \ 64 | __REG_REG_COND(rd, rm, ARMCOND_AL) 65 | /* S */ 66 | #define _S_REG_REG_COND(rd, rm, cond) \ 67 | ARM_IASM_DPIOP_S_REG_REG_COND(ARMOP_, rd, 0, rm, cond) 68 | #define _S_REG_REG(rd, rm) \ 69 | _S_REG_REG_COND(rd, rm, ARMCOND_AL) 70 | #endif 71 | 72 | 73 | /* Rd := Rm imm_shift */ 74 | #define ARM__REG_IMMSHIFT_COND(p, rd, rm, shift_type, imm_shift, cond) \ 75 | ARM_DPIOP_REG_IMMSHIFT_COND(p, ARMOP_, rd, 0, rm, shift_type, imm_shift, cond) 76 | #define ARM__REG_IMMSHIFT(p, rd, rm, shift_type, imm_shift) \ 77 | ARM__REG_IMMSHIFT_COND(p, rd, rm, shift_type, imm_shift, ARMCOND_AL) 78 | /* S */ 79 | #define ARM_S_REG_IMMSHIFT_COND(p, rd, rm, shift_type, imm_shift, cond) \ 80 | ARM_DPIOP_S_REG_IMMSHIFT_COND(p, ARMOP_, rd, 0, rm, shift_type, imm_shift, cond) 81 | #define ARM_S_REG_IMMSHIFT(p, rd, rm, shift_type, imm_shift) \ 82 | ARM_S_REG_IMMSHIFT_COND(p, rd, rm, shift_type, imm_shift, ARMCOND_AL) 83 | 84 | #ifndef ARM_NOIASM 85 | #define __REG_IMMSHIFT_COND(rd, rm, shift_type, imm_shift, cond) \ 86 | ARM_IASM_DPIOP_REG_IMMSHIFT_COND(ARMOP_, rd, 0, rm, shift_type, imm_shift, cond) 87 | #define __REG_IMMSHIFT(rd, rm, shift_type, imm_shift) \ 88 | __REG_IMMSHIFT_COND(rd, rm, shift_type, imm_shift, ARMCOND_AL) 89 | /* S */ 90 | #define _S_REG_IMMSHIFT_COND(rd, rm, shift_type, imm_shift, cond) \ 91 | ARM_IASM_DPIOP_S_REG_IMMSHIFT_COND(ARMOP_, rd, 0, rm, shift_type, imm_shift, cond) 92 | #define _S_REG_IMMSHIFT(rd, rm, shift_type, imm_shift) \ 93 | _S_REG_IMMSHIFT_COND(rd, rm, shift_type, imm_shift, ARMCOND_AL) 94 | #endif 95 | 96 | 97 | 98 | /* Rd := (Rm Rs) */ 99 | #define ARM__REG_REGSHIFT_COND(p, rd, rm, shift_type, rs, cond) \ 100 | ARM_DPIOP_REG_REGSHIFT_COND(p, ARMOP_, rd, 0, rm, shift_type, rs, cond) 101 | #define ARM__REG_REGSHIFT(p, rd, rm, shift_type, rs) \ 102 | ARM__REG_REGSHIFT_COND(p, rd, rm, shift_type, rs, ARMCOND_AL) 103 | /* S */ 104 | #define ARM_S_REG_REGSHIFT_COND(p, rd, rm, shift_type, rs, cond) \ 105 | ARM_DPIOP_S_REG_REGSHIFT_COND(p, ARMOP_, rd, 0, rm, shift_type, rs, cond) 106 | #define ARM_S_REG_REGSHIFT(p, rd, rm, shift_type, rs) \ 107 | ARM_S_REG_REGSHIFT_COND(p, rd, rm, shift_type, rs, ARMCOND_AL) 108 | 109 | #ifndef ARM_NOIASM 110 | #define __REG_REGSHIFT_COND(rd, rm, shift_type, rs, cond) \ 111 | ARM_IASM_DPIOP_REG_REGSHIFT_COND(ARMOP_, rd, 0, rm, shift_type, rs, cond) 112 | #define __REG_REGSHIFT(rd, rm, shift_type, rs) \ 113 | __REG_REGSHIFT_COND(rd, rm, shift_type, rs, ARMCOND_AL) 114 | /* S */ 115 | #define _S_REG_REGSHIFT_COND(rd, rm, shift_type, rs, cond) \ 116 | ARM_IASM_DPIOP_S_REG_REGSHIFT_COND(ARMOP_, rd, 0, rm, shift_type, rs, cond) 117 | #define _S_REG_REGSHIFT(rd, rm, shift_type, rs) \ 118 | _S_REG_REGSHIFT_COND(rd, rm, shift_type, rs, ARMCOND_AL) 119 | #endif 120 | 121 | 122 | -------------------------------------------------------------------------------- /src/arch/arm/vfp_macros.th: -------------------------------------------------------------------------------- 1 | /* -- -- */ 2 | 3 | 4 | /* Fd := Fn Fm */ 5 | #define ARM_VFP_D_COND(p, rd, rn, rm, cond) \ 6 | ARM_EMIT((p), ARM_DEF_VFP_DYADIC(cond,ARM_VFP_COPROC_DOUBLE,ARM_VFP_,rd,rn,rm)) 7 | #define ARM_VFP_D(p, rd, rn, rm) \ 8 | ARM_VFP_D_COND(p, rd, rn, rm, ARMCOND_AL) 9 | 10 | #define ARM_VFP_S_COND(p, rd, rn, rm, cond) \ 11 | ARM_EMIT((p), ARM_DEF_VFP_DYADIC(cond,ARM_VFP_COPROC_SINGLE,ARM_VFP_,rd,rn,rm)) 12 | #define ARM_VFP_S(p, rd, rn, rm) \ 13 | ARM_VFP_S_COND(p, rd, rn, rm, ARMCOND_AL) 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/arch/arm/vfpm_macros.th: -------------------------------------------------------------------------------- 1 | /* -- -- */ 2 | 3 | 4 | /* Fd := Fm */ 5 | 6 | #define ARM_D_COND(p,dreg,sreg,cond) \ 7 | ARM_EMIT((p), ARM_DEF_VFP_MONADIC((cond),ARM_VFP_COPROC_DOUBLE,ARM_VFP_,(dreg),(sreg))) 8 | #define ARM_D(p,dreg,sreg) ARM_D_COND(p,dreg,sreg,ARMCOND_AL) 9 | 10 | #define ARM_S_COND(p,dreg,sreg,cond) \ 11 | ARM_EMIT((p), ARM_DEF_VFP_MONADIC((cond),ARM_VFP_COPROC_SINGLE,ARM_VFP_,(dreg),(sreg))) 12 | #define ARM_S(p,dreg,sreg) ARM_S_COND(p,dreg,sreg,ARMCOND_AL) 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/arch/arm/vfpops.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | DYADIC="ADD SUB MUL NMUL DIV" 4 | MONADIC="CPY ABS NEG SQRT CMP CMPE CMPZ CMPEZ CVT UITO SITO TOUI TOSI TOUIZ TOSIZ" 5 | 6 | # $1: opcode list 7 | # $2: template 8 | gen() { 9 | for i in $1; do 10 | sed "s//$i/g" $2.th 11 | done 12 | } 13 | 14 | echo -e "/* Macros for VFP ops, auto-generated from template */\n" 15 | 16 | echo -e "\n/* dyadic */\n" 17 | gen "$DYADIC" vfp_macros 18 | 19 | echo -e "\n/* monadic */\n" 20 | gen "$MONADIC" vfpm_macros 21 | 22 | echo -e "\n\n" 23 | 24 | echo -e "\n/* end generated */\n" 25 | -------------------------------------------------------------------------------- /src/arch/arm64/.gitignore: -------------------------------------------------------------------------------- 1 | / 2 | /Makefile 3 | /Makefile.in 4 | /*.o 5 | /*.lo 6 | /.deps 7 | -------------------------------------------------------------------------------- /src/arch/arm64/Makefile.am: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonix/ffts/b22d839b61c5bd8a993e24ae3e01f39d9b5084fb/src/arch/arm64/Makefile.am -------------------------------------------------------------------------------- /src/arch/arm64/arm64-codegen.h: -------------------------------------------------------------------------------- 1 | #include "../../../../mono-extensions/mono/arch/arm64/arm64-codegen.h" 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/arch/ia64/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | -------------------------------------------------------------------------------- /src/arch/ia64/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = ia64-codegen.h 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/arch/mips/.gitignore: -------------------------------------------------------------------------------- 1 | / 2 | /Makefile 3 | /Makefile.in 4 | /*.o 5 | /*.lo 6 | /.deps 7 | -------------------------------------------------------------------------------- /src/arch/mips/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) 3 | 4 | noinst_LTLIBRARIES = libmonoarch-mips.la 5 | 6 | libmonoarch_mips_la_SOURCES = mips-codegen.h 7 | 8 | noinst_PROGRAMS = test 9 | -------------------------------------------------------------------------------- /src/arch/mips/test.c: -------------------------------------------------------------------------------- 1 | #include "config.h" 2 | #include 3 | #include 4 | 5 | #define NO_MIPS_JIT_DEBUG 6 | 7 | #include "mips-codegen.h" 8 | #include "mono/metadata/class.h" 9 | 10 | /* don't run the resulting program, it will destroy your computer, 11 | * just objdump -d it to inspect we generated the correct assembler. 12 | */ 13 | 14 | int main (int argc, char *argv[]) { 15 | guint32 *code, * p; 16 | 17 | code = p = (guint32 *) malloc (sizeof (guint32) * 1024); 18 | 19 | mips_add (p, 3, 4, 5); 20 | mips_addi (p, 3, 4, 5); 21 | mips_addu (p, 3, 4, 5); 22 | mips_addiu (p, 3, 4, 5); 23 | mips_sub (p, 3, 4, 5); 24 | mips_subu (p, 3, 4, 5); 25 | mips_dadd (p, 3, 4, 5); 26 | mips_daddi (p, 3, 4, 5); 27 | mips_daddu (p, 3, 4, 5); 28 | mips_daddiu (p, 3, 4, 5); 29 | mips_dsub (p, 3, 4, 5); 30 | mips_dsubu (p, 3, 4, 5); 31 | 32 | mips_mult (p, 6, 7); 33 | mips_multu (p, 6, 7); 34 | mips_div (p, 6, 7); 35 | mips_divu (p, 6, 7); 36 | mips_dmult (p, 6, 7); 37 | mips_dmultu (p, 6, 7); 38 | mips_ddiv (p, 6, 7); 39 | mips_ddivu (p, 6, 7); 40 | 41 | mips_sll (p, 3, 4, 5); 42 | mips_sllv (p, 3, 4, 5); 43 | mips_sra (p, 3, 4, 5); 44 | mips_srav (p, 3, 4, 5); 45 | mips_srl (p, 3, 4, 5); 46 | mips_srlv (p, 3, 4, 5); 47 | mips_dsll (p, 3, 4, 5); 48 | mips_dsll32 (p, 3, 4, 5); 49 | mips_dsllv (p, 3, 4, 5); 50 | mips_dsra (p, 3, 4, 5); 51 | mips_dsra32 (p, 3, 4, 5); 52 | mips_dsrav (p, 3, 4, 5); 53 | mips_dsrl (p, 3, 4, 5); 54 | mips_dsrl32 (p, 3, 4, 5); 55 | mips_dsrlv (p, 3, 4, 5); 56 | 57 | mips_and (p, 8, 9, 10); 58 | mips_andi (p, 8, 9, 10); 59 | mips_nor (p, 8, 9, 10); 60 | mips_or (p, 8, 9, 10); 61 | mips_ori (p, 8, 9, 10); 62 | mips_xor (p, 8, 9, 10); 63 | mips_xori (p, 8, 9, 10); 64 | 65 | mips_slt (p, 8, 9, 10); 66 | mips_slti (p, 8, 9, 10); 67 | mips_sltu (p, 8, 9, 10); 68 | mips_sltiu (p, 8, 9, 10); 69 | 70 | mips_beq (p, 8, 9, 0xff1f); 71 | mips_beql (p, 8, 9, 0xff1f); 72 | mips_bne (p, 8, 9, 0xff1f); 73 | mips_bnel (p, 8, 9, 0xff1f); 74 | mips_bgez (p, 11, 0xff1f); 75 | mips_bgezal (p, 11, 0xff1f); 76 | mips_bgezall (p, 11, 0xff1f); 77 | mips_bgezl (p, 11, 0xff1f); 78 | mips_bgtz (p, 11, 0xff1f); 79 | mips_bgtzl (p, 11, 0xff1f); 80 | mips_blez (p, 11, 0xff1f); 81 | mips_blezl (p, 11, 0xff1f); 82 | mips_bltz (p, 11, 0xff1f); 83 | mips_bltzal (p, 11, 0xff1f); 84 | mips_bltzall (p, 11, 0xff1f); 85 | mips_bltzl (p, 11, 0xff1f); 86 | 87 | mips_jump (p, 0xff1f); 88 | mips_jumpl (p, 0xff1f); 89 | mips_jalr (p, 12, mips_ra); 90 | mips_jr (p, 12); 91 | 92 | mips_lb (p, 13, 14, 128); 93 | mips_lbu (p, 13, 14, 128); 94 | mips_ld (p, 13, 14, 128); 95 | mips_ldl (p, 13, 14, 128); 96 | mips_ldr (p, 13, 14, 128); 97 | mips_lh (p, 13, 14, 128); 98 | mips_lhu (p, 13, 14, 128); 99 | mips_ll (p, 13, 14, 128); 100 | mips_lld (p, 13, 14, 128); 101 | mips_lui (p, 13, 14, 128); 102 | mips_lw (p, 13, 14, 128); 103 | mips_lwl (p, 13, 14, 128); 104 | mips_lwr (p, 13, 14, 128); 105 | mips_lwu (p, 13, 14, 128); 106 | mips_sb (p, 13, 14, 128); 107 | mips_sc (p, 13, 14, 128); 108 | mips_scd (p, 13, 14, 128); 109 | mips_sd (p, 13, 14, 128); 110 | mips_sdl (p, 13, 14, 128); 111 | mips_sdr (p, 13, 14, 128); 112 | mips_sh (p, 13, 14, 128); 113 | mips_sw (p, 13, 14, 128); 114 | mips_swl (p, 13, 14, 128); 115 | mips_swr (p, 13, 14, 128); 116 | 117 | mips_move (p, 15, 16); 118 | mips_nop (p); 119 | mips_break (p, 0); 120 | mips_sync (p, 0); 121 | mips_mfhi (p, 17); 122 | mips_mflo (p, 17); 123 | mips_mthi (p, 17); 124 | mips_mtlo (p, 17); 125 | 126 | mips_fabsd (p, 16, 18); 127 | mips_fnegd (p, 16, 18); 128 | mips_fsqrtd (p, 16, 18); 129 | mips_faddd (p, 16, 18, 20); 130 | mips_fdivd (p, 16, 18, 20); 131 | mips_fmuld (p, 16, 18, 20); 132 | mips_fsubd (p, 16, 18, 20); 133 | 134 | mips_fcmpd (p, MIPS_FPU_EQ, 18, 20); 135 | mips_fbfalse (p, 0xff1f); 136 | mips_fbfalsel (p, 0xff1f); 137 | mips_fbtrue (p, 0xff1f); 138 | mips_fbtruel (p, 0xff1f); 139 | 140 | mips_ceilwd (p, 20, 22); 141 | mips_ceilld (p, 20, 22); 142 | mips_floorwd (p, 20, 22); 143 | mips_floorld (p, 20, 22); 144 | mips_roundwd (p, 20, 22); 145 | mips_roundld (p, 20, 22); 146 | mips_truncwd (p, 20, 22); 147 | mips_truncld (p, 20, 22); 148 | mips_cvtdw (p, 20, 22); 149 | mips_cvtds (p, 20, 22); 150 | mips_cvtdl (p, 20, 22); 151 | mips_cvtld (p, 20, 22); 152 | mips_cvtsd (p, 20, 22); 153 | mips_cvtwd (p, 20, 22); 154 | 155 | mips_fmovd (p, 20, 22); 156 | printf ("size: %d\n", p - code); 157 | 158 | return 0; 159 | } 160 | -------------------------------------------------------------------------------- /src/arch/ppc/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.libs 4 | /.deps 5 | /*.la 6 | /*.lo 7 | /test 8 | -------------------------------------------------------------------------------- /src/arch/ppc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = ppc-codegen.h -------------------------------------------------------------------------------- /src/arch/s390x/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.libs 4 | /.deps 5 | /*.la 6 | /*.lo 7 | -------------------------------------------------------------------------------- /src/arch/s390x/ChangeLog: -------------------------------------------------------------------------------- 1 | 2010-03-23 Neale Ferguson 2 | 3 | * s390x-codegen.h: Remove duplicate 4 | 5 | 2009-06-24 Neale Ferguson 6 | 7 | * s390x-codegen.h: Add some new instructions. 8 | 9 | 2007-04-12 Neale Ferguson 10 | 11 | * tramp.c: Add MONO_TYPE_PTR case. 12 | 13 | 2007-01-23 Neale Ferguson 14 | 15 | * s390x-codegen.h: Add packed attribute to several instruction structures. 16 | 17 | 2006-03-13 Neale Ferguson 18 | 19 | * s390x-codegen.h: Fix immediate checks. 20 | 21 | 2006-01-06 Neale Ferguson 22 | 23 | * s390x-codegen.h: Add lpdbr instruction (OP_ABS). 24 | 25 | 2006-01-03 Neale Ferguson 26 | 27 | * s390x-codegen.h: Add some new instructions. 28 | 29 | 2004-12-15 Neale Ferguson 30 | 31 | * s390x-codegen.h: Add some new instructions (CS, CSG, CSY, CDS, CDSG, CDSY) 32 | 33 | 2004-08-03 Neale Ferguson 34 | 35 | * s390x-codegen.h Makefile.am tramp.c: S/390 64-bit interpreter 36 | -------------------------------------------------------------------------------- /src/arch/s390x/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) 3 | 4 | noinst_LTLIBRARIES = libmonoarch-s390x.la 5 | 6 | libmonoarch_s390x_la_SOURCES = tramp.c s390x-codegen.h 7 | 8 | -------------------------------------------------------------------------------- /src/arch/sparc/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.deps 4 | -------------------------------------------------------------------------------- /src/arch/sparc/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AM_CPPFLAGS = $(GLIB_CFLAGS) -I$(top_srcdir) 3 | 4 | noinst_LTLIBRARIES = libmonoarch-sparc.la 5 | 6 | libmonoarch_sparc_la_SOURCES = tramp.c sparc-codegen.h 7 | 8 | -------------------------------------------------------------------------------- /src/arch/sparc/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "sparc-codegen.h" 3 | 4 | /* don't run the resulting program, it will destroy your computer, 5 | * just objdump -d it to inspect we generated the correct assembler. 6 | */ 7 | 8 | int 9 | main () 10 | { 11 | guint32 *p; 12 | guint32 code_buffer [500]; 13 | guint32 local_size = 0, stack_size = 0, code_size = 6; 14 | guint32 arg_pos, simpletype; 15 | unsigned char *ins; 16 | int i, stringp, cur_out_reg, size; 17 | 18 | p = code_buffer; 19 | 20 | printf (".text\n.align 4\n.globl main\n.type main,@function\nmain:\n"); 21 | 22 | /* 23 | * Standard function prolog. 24 | */ 25 | sparc_save_imm (p, sparc_sp, -112-stack_size, sparc_sp); 26 | cur_out_reg = sparc_o0; 27 | arg_pos = 0; 28 | 29 | if (1) { 30 | sparc_mov_reg_reg (p, sparc_i2, cur_out_reg); 31 | ++cur_out_reg; 32 | } 33 | 34 | sparc_ld_imm (p, sparc_i3, arg_pos, cur_out_reg); 35 | ++cur_out_reg; 36 | sparc_ld_imm (p, sparc_i3, arg_pos+4, cur_out_reg); 37 | ++cur_out_reg; 38 | /* 39 | * Insert call to function 40 | */ 41 | sparc_jmpl (p, sparc_i0, 0, sparc_callsite); 42 | sparc_nop (p); 43 | 44 | sparc_jmpl_imm (p, sparc_i7, 8, sparc_zero); 45 | sparc_restore (p, sparc_zero, sparc_zero, sparc_zero); 46 | 47 | sparc_ldsb (p, sparc_i3, sparc_l0, sparc_o5); 48 | sparc_ldsb_imm (p, sparc_i3, 2, sparc_o5); 49 | 50 | sparc_ldsh (p, sparc_i3, sparc_l0, sparc_o5); 51 | sparc_ldsh_imm (p, sparc_i3, 2, sparc_o5); 52 | 53 | sparc_ldub (p, sparc_i3, sparc_l0, sparc_o5); 54 | sparc_ldub_imm (p, sparc_i3, 2, sparc_o5); 55 | 56 | sparc_lduh (p, sparc_i3, sparc_l0, sparc_o5); 57 | sparc_lduh_imm (p, sparc_i3, 2, sparc_o5); 58 | 59 | sparc_ldf (p, sparc_i3, sparc_l0, sparc_o5); 60 | sparc_ldf_imm (p, sparc_i3, 2, sparc_o5); 61 | 62 | sparc_stb (p, sparc_i3, sparc_l0, sparc_l2); 63 | sparc_stb_imm (p, sparc_i3, sparc_o5, 2); 64 | 65 | sparc_sethi (p, 0xff000000, sparc_o2); 66 | sparc_rdy (p, sparc_l0); 67 | sparc_wry (p, sparc_l0, sparc_l1); 68 | sparc_wry_imm (p, sparc_l0, 16); 69 | sparc_stbar (p); 70 | sparc_unimp (p, 24); 71 | sparc_flush (p, sparc_l4, 0); 72 | 73 | sparc_and (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 74 | sparc_and_imm (p, FALSE, sparc_l0, 0xff, sparc_o1); 75 | sparc_andn (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 76 | sparc_or (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 77 | sparc_orn (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 78 | sparc_xor (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 79 | sparc_xnor (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 80 | 81 | sparc_sll (p, sparc_l0, sparc_l1, sparc_o1); 82 | sparc_sll_imm (p, sparc_l0, 2, sparc_o1); 83 | sparc_srl (p, sparc_l0, sparc_l1, sparc_o1); 84 | sparc_srl_imm (p, sparc_l0, 2, sparc_o1); 85 | sparc_sra (p, sparc_l0, sparc_l1, sparc_o1); 86 | sparc_sra_imm (p, sparc_l0, 2, sparc_o1); 87 | 88 | sparc_add (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 89 | sparc_add_imm (p, FALSE, sparc_l0, 0xff, sparc_o1); 90 | sparc_addx (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 91 | sparc_sub (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 92 | sparc_subx (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 93 | 94 | sparc_muls (p, sparc_l0, sparc_l1, sparc_o1); 95 | sparc_umul (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 96 | sparc_smul (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 97 | sparc_udiv (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 98 | sparc_sdiv (p, sparc_cc, sparc_l0, sparc_l1, sparc_o1); 99 | 100 | sparc_branch (p, FALSE, sparc_bne, -12); 101 | sparc_ret (p); 102 | sparc_retl (p); 103 | sparc_test (p, sparc_l4); 104 | sparc_cmp (p, sparc_l4, sparc_l6); 105 | sparc_cmp_imm (p, sparc_l4, 4); 106 | sparc_restore_simple (p); 107 | 108 | sparc_set (p, 0xff000000, sparc_l7); 109 | sparc_set (p, 1, sparc_l7); 110 | sparc_set (p, 0xff0000ff, sparc_l7); 111 | 112 | sparc_not (p, sparc_g2); 113 | sparc_neg (p, sparc_g3); 114 | sparc_clr_reg (p, sparc_g4); 115 | 116 | 117 | size = (p-code_buffer)*4; 118 | ins = (gchar*)code_buffer; 119 | for (i = 0; i < size; ++i) 120 | printf (".byte %d\n", (unsigned int) ins [i]); 121 | return 0; 122 | } 123 | 124 | -------------------------------------------------------------------------------- /src/arch/x64/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile.in 2 | /Makefile 3 | /.deps 4 | /.libs 5 | -------------------------------------------------------------------------------- /src/arch/x64/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = x64-codegen.h 2 | 3 | -------------------------------------------------------------------------------- /src/arch/x86/.gitignore: -------------------------------------------------------------------------------- 1 | /Makefile 2 | /Makefile.in 3 | /.libs 4 | /.deps 5 | /*.la 6 | /*.lo 7 | -------------------------------------------------------------------------------- /src/arch/x86/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = x86-codegen.h -------------------------------------------------------------------------------- /src/codegen.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_CODEGEN_H 35 | #define FFTS_CODEGEN_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include "ffts.h" 42 | #include "ffts_internal.h" 43 | 44 | transform_func_t ffts_generate_func_code(ffts_plan_t *p, size_t N, size_t leaf_N, int sign); 45 | 46 | #endif /* FFTS_CODEGEN_H */ 47 | -------------------------------------------------------------------------------- /src/codegen_arm.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_CODEGEN_ARM_H 35 | #define FFTS_CODEGEN_ARM_H 36 | 37 | #include "neon.h" 38 | 39 | #ifdef HAVE_STRING_H 40 | #include 41 | #endif 42 | 43 | uint32_t BL(void *pos, void *target) { 44 | return 0xeb000000 | (((target - pos) / 4) & 0xffffff); 45 | } 46 | 47 | uint32_t B(uint8_t r) { 48 | return 0xe12fff10 | r; 49 | } 50 | 51 | uint32_t MOV(uint8_t dst, uint8_t src) { 52 | return 0xe1a00000 | (src & 0xf) | ((dst & 0xf) << 12); 53 | } 54 | 55 | void ADDI(uint32_t **p, uint8_t dst, uint8_t src, int32_t imm) { 56 | int32_t oimm = imm; 57 | if(imm < 0) { 58 | imm = -imm; 59 | uint32_t shamt = (__builtin_ctzl(imm)>23)?23:__builtin_ctzl(imm); 60 | if(shamt & 1) shamt -= 1; 61 | imm >>= shamt; 62 | shamt = (32 - shamt)/2; 63 | 64 | // if(imm > 255) fprintf(stderr, "imm>255: %d\n", oimm); 65 | *(*p)++ = 0xe2400000 | ((src & 0xf) << 16) | ((dst & 0xf) << 12) | ((shamt & 0xf) << 8) | (imm & 0xff); 66 | 67 | if(imm > 255) ADDI(p, dst, src, (oimm + ((imm & 0xff) << (32-shamt*2)))); 68 | 69 | }else{ 70 | uint32_t shamt = (__builtin_ctzl(imm)>23)?23:__builtin_ctzl(imm); 71 | if(shamt & 1) shamt -= 1; 72 | imm >>= shamt; 73 | shamt = (32 - shamt)/2; 74 | 75 | // if(imm > 255) fprintf(stderr, "imm>255: %d\n", oimm); 76 | 77 | *(*p)++ = 0xe2800000 | ((src & 0xf) << 16) | ((dst & 0xf) << 12) | ((shamt & 0xf) << 8) | (imm & 0xff); 78 | 79 | if(imm > 255) ADDI(p, dst, src, (oimm - ((imm & 0xff) << (32-shamt*2)))); 80 | } 81 | } 82 | 83 | uint32_t LDRI(uint8_t dst, uint8_t base, uint32_t offset) { 84 | return 0xe5900000 | ((dst & 0xf) << 12) 85 | | ((base & 0xf) << 16) | (offset & 0xfff) ; 86 | } 87 | 88 | void MOVI(uint32_t **p, uint8_t dst, uint32_t imm) { 89 | uint32_t oimm = imm; 90 | 91 | uint32_t shamt = (__builtin_ctzl(imm)>23)?23:__builtin_ctzl(imm); 92 | if(shamt & 1) shamt -= 1; 93 | imm >>= shamt; 94 | shamt = (32 - shamt)/2; 95 | *(*p)++ = 0xe3a00000 | ((dst & 0xf) << 12) | ((shamt & 0xf) << 8) | (imm & 0xff) ; 96 | if(imm > 255) ADDI(p, dst, dst, (oimm - ((imm & 0xff) << (32-shamt*2)))); 97 | } 98 | 99 | uint32_t PUSH_LR() { return 0xe92d4ff0; } //0xe92d4000; } 100 | uint32_t POP_LR() { return 0xe8bd8ff0; } //0xe8bd8000; } 101 | 102 | static FFTS_INLINE insns_t* generate_size4_base_case(insns_t **fp, int sign) 103 | { 104 | insns_t *x_4_addr; 105 | size_t len; 106 | 107 | x_4_addr = *fp; 108 | 109 | #ifdef HAVE_NEON 110 | len = (char*) neon_x8 - (char*) neon_x4; 111 | memcpy(x_4_addr, neon_x4, len); 112 | 113 | if (sign < 0) { 114 | x_4_addr[26] ^= 0x00200000; 115 | x_4_addr[28] ^= 0x00200000; 116 | x_4_addr[31] ^= 0x00200000; 117 | x_4_addr[32] ^= 0x00200000; 118 | } 119 | #else 120 | len = (char*) vfp_x8 - (char*) vfp_x4; 121 | memcpy(x_4_addr, vfp_x4, len); 122 | 123 | if (sign > 0) { 124 | x_4_addr[36] ^= 0x00000040; 125 | x_4_addr[38] ^= 0x00000040; 126 | x_4_addr[43] ^= 0x00000040; 127 | x_4_addr[44] ^= 0x00000040; 128 | } 129 | #endif 130 | 131 | *fp += len / 4; 132 | return x_4_addr; 133 | } 134 | 135 | static FFTS_INLINE insns_t* generate_size8_base_case(insns_t **fp, int sign) 136 | { 137 | insns_t *x_8_addr; 138 | ptrdiff_t len; 139 | 140 | x_8_addr = *fp; 141 | 142 | #ifdef HAVE_NEON 143 | len = (char*) neon_x8_t - (char*) neon_x8; 144 | memcpy(x_8_addr, neon_x8, len); 145 | 146 | /* 147 | * Changes adds to subtracts and vice versa to allow the computation 148 | * of both the IFFT and FFT 149 | */ 150 | if (sign < 0) { 151 | x_8_addr[31] ^= 0x00200000; 152 | x_8_addr[32] ^= 0x00200000; 153 | x_8_addr[33] ^= 0x00200000; 154 | x_8_addr[34] ^= 0x00200000; 155 | x_8_addr[65] ^= 0x00200000; 156 | x_8_addr[66] ^= 0x00200000; 157 | x_8_addr[70] ^= 0x00200000; 158 | x_8_addr[74] ^= 0x00200000; 159 | x_8_addr[97] ^= 0x00200000; 160 | x_8_addr[98] ^= 0x00200000; 161 | x_8_addr[102] ^= 0x00200000; 162 | x_8_addr[104] ^= 0x00200000; 163 | } 164 | 165 | *fp += len / 4; 166 | 167 | //uint32_t *x_8_t_addr = fp; 168 | //memcpy(fp, neon_x8_t, neon_end - neon_x8_t); 169 | //fp += (neon_end - neon_x8_t) / 4; 170 | #else 171 | len = (char*) vfp_end - (char*) vfp_x8; 172 | memcpy(x_8_addr, vfp_x8, len); 173 | 174 | if (sign > 0) { 175 | x_8_addr[65] ^= 0x00000040; 176 | x_8_addr[66] ^= 0x00000040; 177 | x_8_addr[68] ^= 0x00000040; 178 | x_8_addr[70] ^= 0x00000040; 179 | x_8_addr[103] ^= 0x00000040; 180 | x_8_addr[104] ^= 0x00000040; 181 | x_8_addr[105] ^= 0x00000040; 182 | x_8_addr[108] ^= 0x00000040; 183 | x_8_addr[113] ^= 0x00000040; 184 | x_8_addr[114] ^= 0x00000040; 185 | x_8_addr[117] ^= 0x00000040; 186 | x_8_addr[118] ^= 0x00000040; 187 | } 188 | 189 | *fp += len / 4; 190 | #endif 191 | 192 | return x_8_addr; 193 | } 194 | 195 | static FFTS_INLINE insns_t* generate_prologue(insns_t **fp, ffts_plan_t *p) 196 | { 197 | insns_t *start = *fp; 198 | 199 | *(*fp)++ = PUSH_LR(); 200 | *(*fp)++ = 0xed2d8b10; 201 | 202 | ADDI(fp, 3, 1, 0); 203 | ADDI(fp, 7, 1, p->N); 204 | ADDI(fp, 5, 1, 2 * p->N); 205 | ADDI(fp, 10, 7, 2 * p->N); 206 | ADDI(fp, 4, 5, 2 * p->N); 207 | ADDI(fp, 8, 10, 2 * p->N); 208 | ADDI(fp, 6, 4, 2 * p->N); 209 | ADDI(fp, 9, 8, 2 * p->N); 210 | 211 | // load offsets into r12 212 | *(*fp)++ = LDRI(12, 0, ((uint32_t) &p->offsets) - ((uint32_t) p)); 213 | // *(*fp)++ = LDRI(1, 0, 4); // load ws into r1 214 | ADDI(fp, 1, 0, 0); 215 | 216 | ADDI(fp, 0, 2, 0), // mov out into r0 217 | *(*fp)++ = LDRI(2, 1, ((uint32_t) &p->ee_ws) - ((uint32_t) p)); 218 | 219 | #ifdef HAVE_NEON 220 | MOVI(fp, 11, p->i0); 221 | #else 222 | MOVI(fp, 11, p->i0); 223 | #endif 224 | 225 | return start; 226 | } 227 | 228 | #endif /* FFTS_CODEGEN_ARM_H */ -------------------------------------------------------------------------------- /src/ffts_attributes.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_ATTRIBUTES_H 35 | #define FFTS_ATTRIBUTES_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | /* Macro definitions for various function/variable attributes */ 42 | #ifdef __GNUC__ 43 | #define GCC_VERSION_AT_LEAST(x,y) \ 44 | (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y) 45 | #else 46 | #define GCC_VERSION_AT_LEAST(x,y) 0 47 | #endif 48 | 49 | #ifdef __GNUC__ 50 | #define FFTS_ALIGN(x) __attribute__((aligned(x))) 51 | #elif defined(_MSC_VER) 52 | #define FFTS_ALIGN(x) __declspec(align(x)) 53 | #else 54 | #define FFTS_ALIGN(x) 55 | #endif 56 | 57 | #if GCC_VERSION_AT_LEAST(3,1) 58 | #define FFTS_ALWAYS_INLINE __attribute__((always_inline)) inline 59 | #elif defined(_MSC_VER) 60 | #define FFTS_ALWAYS_INLINE __forceinline 61 | #else 62 | #define FFTS_ALWAYS_INLINE inline 63 | #endif 64 | 65 | #if defined(_MSC_VER) 66 | #define FFTS_INLINE __inline 67 | #else 68 | #define FFTS_INLINE inline 69 | #endif 70 | 71 | #if defined(__GNUC__) 72 | #define FFTS_RESTRICT __restrict 73 | #elif defined(_MSC_VER) 74 | #define FFTS_RESTRICT __restrict 75 | #else 76 | #define FFTS_RESTRICT 77 | #endif 78 | 79 | #if GCC_VERSION_AT_LEAST(4,5) 80 | #define FFTS_ASSUME(cond) do { if (!(cond)) __builtin_unreachable(); } while (0) 81 | #elif defined(_MSC_VER) 82 | #define FFTS_ASSUME(cond) __assume(cond) 83 | #else 84 | #define FFTS_ASSUME(cond) 85 | #endif 86 | 87 | #if GCC_VERSION_AT_LEAST(4,7) 88 | #define FFTS_ASSUME_ALIGNED_16(x) __builtin_assume_aligned(x, 16) 89 | #else 90 | #define FFTS_ASSUME_ALIGNED_16(x) x 91 | #endif 92 | 93 | #if GCC_VERSION_AT_LEAST(4,7) 94 | #define FFTS_ASSUME_ALIGNED_32(x) __builtin_assume_aligned(x, 32) 95 | #else 96 | #define FFTS_ASSUME_ALIGNED_32(x) x 97 | #endif 98 | 99 | #if defined(__GNUC__) 100 | #define FFTS_LIKELY(cond) __builtin_expect(!!(cond), 1) 101 | #else 102 | #define FFTS_LIKELY(cond) cond 103 | #endif 104 | 105 | #if defined(__GNUC__) 106 | #define FFTS_UNLIKELY(cond) __builtin_expect(!!(cond), 0) 107 | #else 108 | #define FFTS_UNLIKELY(cond) cond 109 | #endif 110 | 111 | #endif /* FFTS_ATTRIBUTES_H */ 112 | -------------------------------------------------------------------------------- /src/ffts_chirp_z.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2016, Jukka Ojanen 6 | 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the organization nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #ifndef FFTS_CHIRP_Z_H 34 | #define FFTS_CHIRP_Z_H 35 | 36 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 37 | #pragma once 38 | #endif 39 | 40 | #include "ffts.h" 41 | 42 | ffts_plan_t* 43 | ffts_chirp_z_init(size_t N, int sign); 44 | 45 | #endif /* FFTS_CHIRP_Z_H */ 46 | -------------------------------------------------------------------------------- /src/ffts_nd.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2016, Jukka Ojanen 6 | Copyright (c) 2012, Anthony M. Blake 7 | Copyright (c) 2012, The University of Waikato 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | * Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | * Neither the name of the organization nor the 19 | names of its contributors may be used to endorse or promote products 20 | derived from this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 26 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | #include "ffts_nd.h" 36 | #include "ffts_internal.h" 37 | #include "ffts_transpose.h" 38 | 39 | static void 40 | ffts_free_nd(ffts_plan_t *p) 41 | { 42 | if (p->plans) { 43 | int i, j; 44 | 45 | for (i = 0; i < p->rank; i++) { 46 | ffts_plan_t *plan = p->plans[i]; 47 | 48 | if (plan) { 49 | for (j = 0; j < i; j++) { 50 | if (p->Ns[i] == p->Ns[j]) { 51 | plan = NULL; 52 | break; 53 | } 54 | } 55 | 56 | if (plan) { 57 | ffts_free(plan); 58 | } 59 | } 60 | } 61 | 62 | free(p->plans); 63 | } 64 | 65 | if (p->Ns) { 66 | free(p->Ns); 67 | } 68 | 69 | if (p->Ms) { 70 | free(p->Ms); 71 | } 72 | 73 | if (p->buf) { 74 | ffts_aligned_free(p->buf); 75 | } 76 | 77 | free(p); 78 | } 79 | 80 | static void 81 | ffts_execute_nd(ffts_plan_t *p, const void *in, void *out) 82 | { 83 | uint64_t *din = (uint64_t*) in; 84 | uint64_t *buf = p->buf; 85 | uint64_t *dout = (uint64_t*) out; 86 | 87 | ffts_plan_t *plan; 88 | int i; 89 | size_t j; 90 | 91 | plan = p->plans[0]; 92 | for (j = 0; j < p->Ms[0]; j++) { 93 | plan->transform(plan, din + (j * p->Ns[0]), buf + (j * p->Ns[0])); 94 | } 95 | 96 | ffts_transpose(buf, dout, p->Ns[0], p->Ms[0]); 97 | 98 | for (i = 1; i < p->rank; i++) { 99 | plan = p->plans[i]; 100 | 101 | for (j = 0; j < p->Ms[i]; j++) { 102 | plan->transform(plan, dout + (j * p->Ns[i]), buf + (j * p->Ns[i])); 103 | } 104 | 105 | ffts_transpose(buf, dout, p->Ns[i], p->Ms[i]); 106 | } 107 | } 108 | 109 | FFTS_API ffts_plan_t* 110 | ffts_init_nd(int rank, size_t *Ns, int sign) 111 | { 112 | ffts_plan_t *p; 113 | size_t vol = 1; 114 | int i, j; 115 | 116 | if (!Ns) { 117 | return NULL; 118 | } 119 | 120 | if (rank == 1) { 121 | return ffts_init_1d(Ns[0], sign); 122 | } 123 | 124 | p = calloc(1, sizeof(*p)); 125 | if (!p) { 126 | return NULL; 127 | } 128 | 129 | p->transform = &ffts_execute_nd; 130 | p->destroy = &ffts_free_nd; 131 | p->rank = rank; 132 | 133 | p->Ms = malloc(rank * sizeof(*p->Ms)); 134 | if (!p->Ms) { 135 | goto cleanup; 136 | } 137 | 138 | p->Ns = malloc(rank * sizeof(*p->Ns)); 139 | if (!p->Ns) { 140 | goto cleanup; 141 | } 142 | 143 | /* reverse the order */ 144 | for (i = 0; i < rank; i++) { 145 | size_t N = Ns[rank - i - 1]; 146 | p->Ns[i] = N; 147 | vol *= N; 148 | } 149 | 150 | p->buf = ffts_aligned_malloc(2 * vol * sizeof(float)); 151 | if (!p->buf) { 152 | goto cleanup; 153 | } 154 | 155 | p->plans = calloc(rank, sizeof(*p->plans)); 156 | if (!p->plans) { 157 | goto cleanup; 158 | } 159 | 160 | for (i = 0; i < rank; i++) { 161 | p->Ms[i] = vol / p->Ns[i]; 162 | 163 | for (j = 0; j < i; j++) { 164 | if (p->Ns[i] == p->Ns[j]) { 165 | p->plans[i] = p->plans[j]; 166 | break; 167 | } 168 | } 169 | 170 | if (!p->plans[i]) { 171 | p->plans[i] = ffts_init_1d(p->Ns[i], sign); 172 | if (!p->plans) { 173 | goto cleanup; 174 | } 175 | } 176 | } 177 | 178 | return p; 179 | 180 | cleanup: 181 | ffts_free_nd(p); 182 | return NULL; 183 | } 184 | 185 | FFTS_API ffts_plan_t* 186 | ffts_init_2d(size_t N1, size_t N2, int sign) 187 | { 188 | size_t Ns[2]; 189 | 190 | Ns[0] = N1; /* x */ 191 | Ns[1] = N2; /* y */ 192 | return ffts_init_nd(2, Ns, sign); 193 | } 194 | -------------------------------------------------------------------------------- /src/ffts_nd.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_ND_H 35 | #define FFTS_ND_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include "ffts.h" 42 | #include 43 | 44 | ffts_plan_t* 45 | ffts_init_nd(int rank, size_t *Ns, int sign); 46 | 47 | ffts_plan_t* 48 | ffts_init_2d(size_t N1, size_t N2, int sign); 49 | 50 | #endif /* FFTS_ND_H */ 51 | -------------------------------------------------------------------------------- /src/ffts_real.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_REAL_H 35 | #define FFTS_REAL_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include "ffts.h" 42 | #include 43 | 44 | ffts_plan_t* 45 | ffts_init_1d_real(size_t N, int sign); 46 | 47 | #endif /* FFTS_REAL_H */ 48 | -------------------------------------------------------------------------------- /src/ffts_real_nd.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_REAL_ND_H 35 | #define FFTS_REAL_ND_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include "ffts.h" 42 | #include 43 | 44 | ffts_plan_t* 45 | ffts_init_nd_real(int rank, size_t *Ns, int sign); 46 | 47 | ffts_plan_t* 48 | ffts_init_2d_real(size_t N1, size_t N2, int sign); 49 | 50 | #endif /* FFTS_REAL_ND_H */ -------------------------------------------------------------------------------- /src/ffts_static.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_STATIC_H 35 | #define FFTS_STATIC_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include "ffts.h" 42 | 43 | void 44 | ffts_small_2_32f(ffts_plan_t *p, const void *in, void *out); 45 | 46 | void 47 | ffts_small_2_64f(ffts_plan_t *p, const void *in, void *out); 48 | 49 | void 50 | ffts_small_forward4_32f(ffts_plan_t *p, const void *in, void *out); 51 | 52 | void 53 | ffts_small_forward4_64f(ffts_plan_t *p, const void *in, void *out); 54 | 55 | void 56 | ffts_small_backward4_32f(ffts_plan_t *p, const void *in, void *out); 57 | 58 | void 59 | ffts_small_backward4_64f(ffts_plan_t *p, const void *in, void *out); 60 | 61 | void 62 | ffts_small_forward8_32f(ffts_plan_t *p, const void *in, void *out); 63 | 64 | void 65 | ffts_small_forward8_64f(ffts_plan_t *p, const void *in, void *out); 66 | 67 | void 68 | ffts_small_backward8_32f(ffts_plan_t *p, const void *in, void *out); 69 | 70 | void 71 | ffts_small_backward8_64f(ffts_plan_t *p, const void *in, void *out); 72 | 73 | void 74 | ffts_small_forward16_32f(ffts_plan_t *p, const void *in, void *out); 75 | 76 | void 77 | ffts_small_forward16_64f(ffts_plan_t *p, const void *in, void *out); 78 | 79 | void 80 | ffts_small_backward16_32f(ffts_plan_t *p, const void *in, void *out); 81 | 82 | void 83 | ffts_small_backward16_64f(ffts_plan_t *p, const void *in, void *out); 84 | 85 | void 86 | ffts_static_transform_f_32f(ffts_plan_t *p, const void *in, void *out); 87 | 88 | void 89 | ffts_static_transform_i_32f(ffts_plan_t *p, const void *in, void *out); 90 | 91 | #endif /* FFTS_STATIC_H */ 92 | -------------------------------------------------------------------------------- /src/ffts_transpose.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2016, Jukka Ojanen 6 | Copyright (c) 2012, Anthony M. Blake 7 | Copyright (c) 2012, The University of Waikato 8 | 9 | All rights reserved. 10 | 11 | Redistribution and use in source and binary forms, with or without 12 | modification, are permitted provided that the following conditions are met: 13 | * Redistributions of source code must retain the above copyright 14 | notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | notice, this list of conditions and the following disclaimer in the 17 | documentation and/or other materials provided with the distribution. 18 | * Neither the name of the organization nor the 19 | names of its contributors may be used to endorse or promote products 20 | derived from this software without specific prior written permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 26 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 29 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | */ 34 | 35 | #include "ffts_transpose.h" 36 | #include "ffts_internal.h" 37 | 38 | #ifdef HAVE_NEON 39 | #include "neon.h" 40 | #include 41 | #elif HAVE_SSE2 42 | #include 43 | #endif 44 | 45 | #define TSIZE 8 46 | 47 | void 48 | ffts_transpose(uint64_t *in, uint64_t *out, int w, int h) 49 | { 50 | #ifdef HAVE_NEON 51 | #if 0 52 | neon_transpose4(in, out, w, h); 53 | #else 54 | neon_transpose8(in, out, w, h); 55 | #endif 56 | #elif HAVE_SSE2 57 | uint64_t FFTS_ALIGN(64) tmp[TSIZE*TSIZE]; 58 | int tx, ty; 59 | /* int x; */ 60 | int y; 61 | int tw = w / TSIZE; 62 | int th = h / TSIZE; 63 | 64 | for (ty = 0; ty < th; ty++) { 65 | for (tx = 0; tx < tw; tx++) { 66 | uint64_t *ip0 = in + w*TSIZE*ty + tx * TSIZE; 67 | uint64_t *op0 = tmp; /* out + h*TSIZE*tx + ty*TSIZE; */ 68 | 69 | /* copy/transpose to tmp */ 70 | for (y = 0; y < TSIZE; y += 2) { 71 | /* for (x=0;x 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_TRANSPOSE_H 35 | #define FFTS_TRANSPOSE_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include "ffts_internal.h" 42 | 43 | void 44 | ffts_transpose(uint64_t *in, uint64_t *out, int w, int h); 45 | 46 | #endif /* FFTS_TRANSPOSE_H */ 47 | -------------------------------------------------------------------------------- /src/ffts_trig.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/anthonix/ffts/b22d839b61c5bd8a993e24ae3e01f39d9b5084fb/src/ffts_trig.c -------------------------------------------------------------------------------- /src/ffts_trig.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2015-2016, Jukka Ojanen 6 | 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the organization nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #ifndef FFTS_TRIG_H 34 | #define FFTS_TRIG_H 35 | 36 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 37 | #pragma once 38 | #endif 39 | 40 | #include "ffts_internal.h" 41 | 42 | /* calculate cos(pi * n / d) and sin(pi * n / d) with maximum error less than 1 ULP, average ~0.5 ULP */ 43 | int 44 | ffts_cexp_32f(size_t n, size_t d, float *output); 45 | 46 | int 47 | ffts_generate_chirp_32f(ffts_cpx_32f *const table, size_t table_size); 48 | 49 | /* generate cosine and sine tables with maximum error less than 1 ULP, average ~0.5 ULP */ 50 | int 51 | ffts_generate_cosine_sine_32f(ffts_cpx_32f *const table, size_t table_size); 52 | 53 | int 54 | ffts_generate_cosine_sine_pow2_32f(ffts_cpx_32f *const table, int table_size); 55 | 56 | int 57 | ffts_generate_cosine_sine_pow2_64f(ffts_cpx_64f *const table, int table_size); 58 | 59 | int 60 | ffts_generate_table_1d_real_32f(struct _ffts_plan_t *const p, 61 | int sign, 62 | int invert); 63 | 64 | #endif /* FFTS_TRIG_H */ 65 | -------------------------------------------------------------------------------- /src/macros-alpha.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2013, Michael J. Cree 6 | Copyright (c) 2012, 2013, Anthony M. Blake 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_MACROS_ALPHA_H 35 | #define FFTS_MACROS_ALPHA_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include "ffts_attributes.h" 42 | 43 | #ifdef HAVE_STRING_H 44 | #include 45 | #endif 46 | 47 | #ifdef HAVE_STDLIB_H 48 | #include 49 | #endif 50 | 51 | typedef union { 52 | struct { 53 | float r1; 54 | float i1; 55 | float r2; 56 | float i2; 57 | } r; 58 | uint32_t u[4]; 59 | } V4SF; 60 | 61 | static FFTS_ALWAYS_INLINE V4SF 62 | V4SF_LIT4(float f3, float f2, float f1, float f0) 63 | { 64 | V4SF z; 65 | 66 | z.r.r1 = f0; 67 | z.r.i1 = f1; 68 | z.r.r2 = f2; 69 | z.r.i2 = f3; 70 | 71 | return z; 72 | } 73 | 74 | static FFTS_ALWAYS_INLINE V4SF 75 | V4SF_ADD(V4SF x, V4SF y) 76 | { 77 | V4SF z; 78 | 79 | z.r.r1 = x.r.r1 + y.r.r1; 80 | z.r.i1 = x.r.i1 + y.r.i1; 81 | z.r.r2 = x.r.r2 + y.r.r2; 82 | z.r.i2 = x.r.i2 + y.r.i2; 83 | 84 | return z; 85 | } 86 | 87 | static FFTS_ALWAYS_INLINE V4SF 88 | V4SF_SUB(V4SF x, V4SF y) 89 | { 90 | V4SF z; 91 | 92 | z.r.r1 = x.r.r1 - y.r.r1; 93 | z.r.i1 = x.r.i1 - y.r.i1; 94 | z.r.r2 = x.r.r2 - y.r.r2; 95 | z.r.i2 = x.r.i2 - y.r.i2; 96 | 97 | return z; 98 | } 99 | 100 | static FFTS_ALWAYS_INLINE V4SF 101 | V4SF_MUL(V4SF x, V4SF y) 102 | { 103 | V4SF z; 104 | 105 | z.r.r1 = x.r.r1 * y.r.r1; 106 | z.r.i1 = x.r.i1 * y.r.i1; 107 | z.r.r2 = x.r.r2 * y.r.r2; 108 | z.r.i2 = x.r.i2 * y.r.i2; 109 | 110 | return z; 111 | } 112 | 113 | static FFTS_ALWAYS_INLINE V4SF 114 | V4SF_XOR(V4SF x, V4SF y) 115 | { 116 | V4SF z; 117 | 118 | z.u[0] = x.u[0] ^ y.u[0]; 119 | z.u[1] = x.u[1] ^ y.u[1]; 120 | z.u[2] = x.u[2] ^ y.u[2]; 121 | z.u[3] = x.u[3] ^ y.u[3]; 122 | 123 | return z; 124 | } 125 | 126 | static FFTS_ALWAYS_INLINE V4SF 127 | V4SF_SWAP_PAIRS(V4SF x) 128 | { 129 | V4SF z; 130 | 131 | z.r.r1 = x.r.i1; 132 | z.r.i1 = x.r.r1; 133 | z.r.r2 = x.r.i2; 134 | z.r.i2 = x.r.r2; 135 | 136 | return z; 137 | } 138 | 139 | static FFTS_ALWAYS_INLINE V4SF 140 | V4SF_BLEND(V4SF x, V4SF y) 141 | { 142 | V4SF z; 143 | 144 | z.r.r1 = x.r.r1; 145 | z.r.i1 = x.r.i1; 146 | z.r.r2 = y.r.r2; 147 | z.r.i2 = y.r.i2; 148 | 149 | return z; 150 | } 151 | 152 | static FFTS_ALWAYS_INLINE V4SF 153 | V4SF_UNPACK_HI(V4SF x, V4SF y) 154 | { 155 | V4SF z; 156 | 157 | z.r.r1 = x.r.r2; 158 | z.r.i1 = x.r.i2; 159 | z.r.r2 = y.r.r2; 160 | z.r.i2 = y.r.i2; 161 | 162 | return z; 163 | } 164 | 165 | static FFTS_ALWAYS_INLINE V4SF 166 | V4SF_UNPACK_LO(V4SF x, V4SF y) 167 | { 168 | V4SF z; 169 | 170 | z.r.r1 = x.r.r1; 171 | z.r.i1 = x.r.i1; 172 | z.r.r2 = y.r.r1; 173 | z.r.i2 = y.r.i1; 174 | 175 | return z; 176 | } 177 | 178 | static FFTS_ALWAYS_INLINE V4SF 179 | V4SF_DUPLICATE_RE(V4SF x) 180 | { 181 | V4SF z; 182 | 183 | z.r.r1 = x.r.r1; 184 | z.r.i1 = x.r.r1; 185 | z.r.r2 = x.r.r2; 186 | z.r.i2 = x.r.r2; 187 | 188 | return z; 189 | } 190 | 191 | static FFTS_ALWAYS_INLINE V4SF 192 | V4SF_DUPLICATE_IM(V4SF x) 193 | { 194 | V4SF z; 195 | 196 | z.r.r1 = x.r.i1; 197 | z.r.i1 = x.r.i1; 198 | z.r.r2 = x.r.i2; 199 | z.r.i2 = x.r.i2; 200 | 201 | return z; 202 | } 203 | 204 | static FFTS_ALWAYS_INLINE V4SF 205 | V4SF_IMUL(V4SF d, V4SF re, V4SF im) 206 | { 207 | re = V4SF_MUL(re, d); 208 | im = V4SF_MUL(im, V4SF_SWAP_PAIRS(d)); 209 | return V4SF_SUB(re, im); 210 | } 211 | 212 | static FFTS_ALWAYS_INLINE V4SF 213 | V4SF_IMULJ(V4SF d, V4SF re, V4SF im) 214 | { 215 | re = V4SF_MUL(re, d); 216 | im = V4SF_MUL(im, V4SF_SWAP_PAIRS(d)); 217 | return V4SF_ADD(re, im); 218 | } 219 | 220 | static FFTS_ALWAYS_INLINE V4SF 221 | V4SF_MULI(int inv, V4SF x) 222 | { 223 | V4SF z; 224 | 225 | if (inv) { 226 | z.r.r1 = -x.r.r1; 227 | z.r.i1 = x.r.i1; 228 | z.r.r2 = -x.r.r2; 229 | z.r.i2 = x.r.i2; 230 | } else { 231 | z.r.r1 = x.r.r1; 232 | z.r.i1 = -x.r.i1; 233 | z.r.r2 = x.r.r2; 234 | z.r.i2 = -x.r.i2; 235 | } 236 | 237 | return z; 238 | } 239 | 240 | static FFTS_ALWAYS_INLINE V4SF 241 | V4SF_IMULI(int inv, V4SF x) 242 | { 243 | return V4SF_SWAP_PAIRS(V4SF_MULI(inv, x)); 244 | } 245 | 246 | static FFTS_ALWAYS_INLINE V4SF 247 | V4SF_LD(const void *s) 248 | { 249 | V4SF z; 250 | memcpy(&z, s, sizeof(z)); 251 | return z; 252 | } 253 | 254 | static FFTS_ALWAYS_INLINE void 255 | V4SF_ST(void *d, V4SF s) 256 | { 257 | V4SF *r = (V4SF*) d; 258 | *r = s; 259 | } 260 | 261 | #endif /* FFTS_MACROS_ALPHA_H */ -------------------------------------------------------------------------------- /src/macros-altivec.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2013, Michael J. Cree 6 | Copyright (c) 2012, 2013, Anthony M. Blake 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef __MACROS_ALTIVEC_H__ 35 | #define __MACROS_ALTIVEC_H__ 36 | 37 | #include 38 | #include 39 | 40 | #define restrict 41 | 42 | typedef vector float V; 43 | typedef vector unsigned char VUC; 44 | 45 | #define VLIT4(f0,f1,f2,f3) ((V){f0, f1, f2, f3}) 46 | 47 | #define VADD(x,y) vec_add(x,y) 48 | #define VSUB(x,y) vec_sub(x,y) 49 | #define VMUL(x,y) vec_madd(x,y,(V){0}) 50 | #define VMULADD(x,y,z) vec_madd(x,y,z) 51 | #define VNMULSUB(x,y,z) vec_nmsub(x,y,z) 52 | #define VXOR(x,y) vec_xor((x),(y)) 53 | #define VSWAPPAIRS(x) \ 54 | vec_perm(x,x,(VUC){0x04,0x05,0x06,0x07,0x00,0x01,0x02,0x03, \ 55 | 0x0c,0x0d,0x0e,0x0f,0x08,0x09,0x0a,0x0b}) 56 | 57 | #define VBLEND(x,y) \ 58 | vec_perm(x,y,(VUC){0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, \ 59 | 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f}) 60 | 61 | #define VUNPACKHI(x,y) \ 62 | vec_perm(x,y,(VUC){0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, \ 63 | 0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f}) 64 | 65 | #define VUNPACKLO(x,y) \ 66 | vec_perm(x,y,(VUC){0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, \ 67 | 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17}) 68 | 69 | #define VDUPRE(x) \ 70 | vec_perm(x,x,(VUC){0x00,0x01,0x02,0x03,0x00,0x01,0x02,0x03, \ 71 | 0x18,0x19,0x1a,0x1b,0x18,0x19,0x1a,0x1b}) 72 | 73 | #define VDUPIM(x) \ 74 | vec_perm(x,x,(VUC){0x04,0x05,0x06,0x07,0x04,0x05,0x06,0x07, \ 75 | 0x1c,0x1d,0x1e,0x1f,0x1c,0x1d,0x1e,0x1f}) 76 | 77 | 78 | static inline V IMUL(V d, V re, V im) 79 | { 80 | im = VMUL(im, VSWAPPAIRS(d)); 81 | re = VMUL(re, d); 82 | return VSUB(re, im); 83 | } 84 | 85 | 86 | static inline V IMULJ(V d, V re, V im) 87 | { 88 | im = VMUL(im, VSWAPPAIRS(d)); 89 | return VMULADD(re, d, im); 90 | } 91 | 92 | #ifndef __GNUC__ 93 | /* gcc (4.6 and 4.7) ICEs on this code! */ 94 | static inline V MULI(int inv, V x) 95 | { 96 | return VXOR(x, inv ? VLIT4(-0.0f,0.0f,-0.0f,0.0f) : VLIT4(0.0f,-0.0f,0.0f,-0.0f)); 97 | } 98 | #else 99 | /* but compiles this fine... */ 100 | static inline V MULI(int inv, V x) 101 | { 102 | V t; 103 | t = inv ? VLIT4(-0.0f,0.0f,-0.0f,0.0f) : VLIT4(0.0f,-0.0f,0.0f,-0.0f); 104 | return VXOR(x, t); 105 | } 106 | #endif 107 | 108 | 109 | static inline V IMULI(int inv, V x) 110 | { 111 | return VSWAPPAIRS(MULI(inv, x)); 112 | } 113 | 114 | 115 | static inline V VLD(const void *s) 116 | { 117 | V *d = (V *)s; 118 | return *d; 119 | } 120 | 121 | 122 | static inline void VST(void *d, V s) 123 | { 124 | V *r = (V *)d; 125 | *r = s; 126 | } 127 | #endif 128 | // vim: set autoindent noexpandtab tabstop=3 shiftwidth=3: 129 | -------------------------------------------------------------------------------- /src/macros-neon.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, 2013, Anthony M. Blake 6 | 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of the organization nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | */ 32 | 33 | #ifndef FFTS_MACROS_NEON_H 34 | #define FFTS_MACROS_NEON_H 35 | 36 | #include 37 | 38 | #ifdef HAVE_STDLIB_H 39 | #include 40 | #endif 41 | 42 | typedef float32x4_t V4SF; 43 | typedef float32x4x2_t V4SF2; 44 | 45 | #define V4SF_ADD vaddq_f32 46 | #define V4SF_SUB vsubq_f32 47 | #define V4SF_MUL vmulq_f32 48 | 49 | #define V4SF_XOR(x,y) \ 50 | (vreinterpretq_f32_u32(veorq_u32(vreinterpretq_u32_f32(x), vreinterpretq_u32_f32(y)))) 51 | 52 | #define V4SF_ST vst1q_f32 53 | #define V4SF_LD vld1q_f32 54 | 55 | #define V4SF_SWAP_PAIRS(x) \ 56 | (vrev64q_f32(x)) 57 | 58 | #define V4SF_UNPACK_HI(a,b) \ 59 | (vcombine_f32(vget_high_f32(a), vget_high_f32(b))) 60 | 61 | #define V4SF_UNPACK_LO(a,b) \ 62 | (vcombine_f32(vget_low_f32(a), vget_low_f32(b))) 63 | 64 | #define V4SF_BLEND(x,y) \ 65 | (vcombine_f32(vget_low_f32(x), vget_high_f32(y))) 66 | 67 | static FFTS_ALWAYS_INLINE V4SF 68 | V4SF_LIT4(float f3, float f2, float f1, float f0) 69 | { 70 | float FFTS_ALIGN(16) d[4] = {f0, f1, f2, f3}; 71 | return V4SF_LD(d); 72 | } 73 | 74 | #define V4SF_DUPLICATE_RE(r) \ 75 | vcombine_f32(vdup_lane_f32(vget_low_f32(r),0), vdup_lane_f32(vget_high_f32(r),0)) 76 | 77 | #define V4SF_DUPLICATE_IM(r) \ 78 | vcombine_f32(vdup_lane_f32(vget_low_f32(r),1), vdup_lane_f32(vget_high_f32(r),1)) 79 | 80 | static FFTS_ALWAYS_INLINE V4SF 81 | V4SF_IMULI(int inv, V4SF a) 82 | { 83 | if (inv) { 84 | return V4SF_SWAP_PAIRS(V4SF_XOR(a, V4SF_LIT4(0.0f, -0.0f, 0.0f, -0.0f))); 85 | } else { 86 | return V4SF_SWAP_PAIRS(V4SF_XOR(a, V4SF_LIT4(-0.0f, 0.0f, -0.0f, 0.0f))); 87 | } 88 | } 89 | 90 | static FFTS_ALWAYS_INLINE V4SF 91 | V4SF_IMUL(V4SF d, V4SF re, V4SF im) 92 | { 93 | re = V4SF_MUL(re, d); 94 | im = V4SF_MUL(im, V4SF_SWAP_PAIRS(d)); 95 | return V4SF_SUB(re, im); 96 | } 97 | 98 | static FFTS_ALWAYS_INLINE V4SF 99 | V4SF_IMULJ(V4SF d, V4SF re, V4SF im) 100 | { 101 | re = V4SF_MUL(re, d); 102 | im = V4SF_MUL(im, V4SF_SWAP_PAIRS(d)); 103 | return V4SF_ADD(re, im); 104 | } 105 | 106 | #define V4SF2_ST vst2q_f32 107 | #define V4SF2_LD vld2q_f32 108 | 109 | static FFTS_ALWAYS_INLINE void 110 | V4SF2_STORE_SPR(float *addr, V4SF2 p) 111 | { 112 | vst1q_f32(addr, p.val[0]); 113 | vst1q_f32(addr + 4, p.val[1]); 114 | } 115 | 116 | #endif /* FFTS_MACROS_NEON_H */ 117 | -------------------------------------------------------------------------------- /src/macros-sse.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_MACROS_SSE_H 35 | #define FFTS_MACROS_SSE_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #include 42 | 43 | typedef __m128 V4SF; 44 | 45 | #define V4SF_ADD _mm_add_ps 46 | #define V4SF_SUB _mm_sub_ps 47 | #define V4SF_MUL _mm_mul_ps 48 | #define V4SF_LIT4 _mm_set_ps 49 | #define V4SF_XOR _mm_xor_ps 50 | #define V4SF_ST _mm_store_ps 51 | #define V4SF_LD _mm_load_ps 52 | 53 | #define V4SF_SWAP_PAIRS(x) \ 54 | (_mm_shuffle_ps(x, x, _MM_SHUFFLE(2,3,0,1))) 55 | 56 | /* note: order is swapped */ 57 | #define V4SF_UNPACK_HI(x,y) \ 58 | (_mm_movehl_ps(y, x)) 59 | 60 | #define V4SF_UNPACK_LO(x,y) \ 61 | (_mm_movelh_ps(x, y)) 62 | 63 | #define V4SF_BLEND(x, y) \ 64 | (_mm_shuffle_ps(x, y, _MM_SHUFFLE(3,2,1,0))) 65 | 66 | #define V4SF_DUPLICATE_RE(r) \ 67 | (_mm_shuffle_ps(r, r, _MM_SHUFFLE(2,2,0,0))) 68 | 69 | #define V4SF_DUPLICATE_IM(r) \ 70 | (_mm_shuffle_ps(r, r, _MM_SHUFFLE(3,3,1,1))) 71 | 72 | static FFTS_ALWAYS_INLINE V4SF 73 | V4SF_IMULI(int inv, V4SF a) 74 | { 75 | if (inv) { 76 | return V4SF_SWAP_PAIRS(V4SF_XOR(a, V4SF_LIT4(0.0f, -0.0f, 0.0f, -0.0f))); 77 | } else { 78 | return V4SF_SWAP_PAIRS(V4SF_XOR(a, V4SF_LIT4(-0.0f, 0.0f, -0.0f, 0.0f))); 79 | } 80 | } 81 | 82 | static FFTS_ALWAYS_INLINE V4SF 83 | V4SF_IMUL(V4SF d, V4SF re, V4SF im) 84 | { 85 | re = V4SF_MUL(re, d); 86 | im = V4SF_MUL(im, V4SF_SWAP_PAIRS(d)); 87 | return V4SF_SUB(re, im); 88 | } 89 | 90 | static FFTS_ALWAYS_INLINE V4SF 91 | V4SF_IMULJ(V4SF d, V4SF re, V4SF im) 92 | { 93 | re = V4SF_MUL(re, d); 94 | im = V4SF_MUL(im, V4SF_SWAP_PAIRS(d)); 95 | return V4SF_ADD(re, im); 96 | } 97 | 98 | #endif /* FFTS_MACROS_SSE_H */ 99 | -------------------------------------------------------------------------------- /src/macros.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2013, Michael J. Cree 6 | Copyright (c) 2012, 2013, Anthony M. Blake 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_MACROS_H 35 | #define FFTS_MACROS_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | #ifdef HAVE_NEON 42 | #include "macros-neon.h" 43 | #elif HAVE_SSE 44 | #include "macros-sse.h" 45 | // NOTE: AltiVec support disabled until updated to provide new V4SF variable type 46 | //#elif __powerpc__ 47 | //#include "macros-altivec.h" 48 | #else 49 | #include "macros-alpha.h" 50 | #endif 51 | 52 | static FFTS_INLINE void 53 | V4SF_TX2(V4SF *a, V4SF *b) 54 | { 55 | V4SF t0 = V4SF_UNPACK_LO(*a, *b); 56 | V4SF t1 = V4SF_UNPACK_HI(*a, *b); 57 | *a = t0; 58 | *b = t1; 59 | } 60 | 61 | static FFTS_INLINE void 62 | V4SF_K_N(int inv, 63 | V4SF re, 64 | V4SF im, 65 | V4SF *r0, 66 | V4SF *r1, 67 | V4SF *r2, 68 | V4SF *r3) 69 | { 70 | V4SF uk, uk2, zk_p, zk_n, zk, zk_d; 71 | 72 | uk = *r0; 73 | uk2 = *r1; 74 | 75 | zk_p = V4SF_IMUL(*r2, re, im); 76 | zk_n = V4SF_IMULJ(*r3, re, im); 77 | 78 | zk = V4SF_ADD(zk_p, zk_n); 79 | zk_d = V4SF_IMULI(inv, V4SF_SUB(zk_p, zk_n)); 80 | 81 | *r2 = V4SF_SUB(uk, zk); 82 | *r0 = V4SF_ADD(uk, zk); 83 | *r3 = V4SF_ADD(uk2, zk_d); 84 | *r1 = V4SF_SUB(uk2, zk_d); 85 | } 86 | 87 | static FFTS_INLINE void 88 | V4SF_L_2_4(int inv, 89 | const float *FFTS_RESTRICT i0, 90 | const float *FFTS_RESTRICT i1, 91 | const float *FFTS_RESTRICT i2, 92 | const float *FFTS_RESTRICT i3, 93 | V4SF *r0, 94 | V4SF *r1, 95 | V4SF *r2, 96 | V4SF *r3) 97 | { 98 | V4SF t0, t1, t2, t3, t4, t5, t6, t7; 99 | 100 | t0 = V4SF_LD(i0); 101 | t1 = V4SF_LD(i1); 102 | t2 = V4SF_LD(i2); 103 | t3 = V4SF_LD(i3); 104 | 105 | t4 = V4SF_ADD(t0, t1); 106 | t5 = V4SF_SUB(t0, t1); 107 | t6 = V4SF_ADD(t2, t3); 108 | t7 = V4SF_SUB(t2, t3); 109 | 110 | *r0 = V4SF_UNPACK_LO(t4, t5); 111 | *r1 = V4SF_UNPACK_LO(t6, t7); 112 | 113 | t5 = V4SF_IMULI(inv, t5); 114 | 115 | t0 = V4SF_ADD(t6, t4); 116 | t2 = V4SF_SUB(t6, t4); 117 | t1 = V4SF_SUB(t7, t5); 118 | t3 = V4SF_ADD(t7, t5); 119 | 120 | *r3 = V4SF_UNPACK_HI(t0, t1); 121 | *r2 = V4SF_UNPACK_HI(t2, t3); 122 | } 123 | 124 | static FFTS_INLINE void 125 | V4SF_L_4_4(int inv, 126 | const float *FFTS_RESTRICT i0, 127 | const float *FFTS_RESTRICT i1, 128 | const float *FFTS_RESTRICT i2, 129 | const float *FFTS_RESTRICT i3, 130 | V4SF *r0, 131 | V4SF *r1, 132 | V4SF *r2, 133 | V4SF *r3) 134 | { 135 | V4SF t0, t1, t2, t3, t4, t5, t6, t7; 136 | 137 | t0 = V4SF_LD(i0); 138 | t1 = V4SF_LD(i1); 139 | t2 = V4SF_LD(i2); 140 | t3 = V4SF_LD(i3); 141 | 142 | t4 = V4SF_ADD(t0, t1); 143 | t5 = V4SF_SUB(t0, t1); 144 | t6 = V4SF_ADD(t2, t3); 145 | 146 | t7 = V4SF_IMULI(inv, V4SF_SUB(t2, t3)); 147 | 148 | t0 = V4SF_ADD(t4, t6); 149 | t2 = V4SF_SUB(t4, t6); 150 | t1 = V4SF_SUB(t5, t7); 151 | t3 = V4SF_ADD(t5, t7); 152 | 153 | V4SF_TX2(&t0, &t1); 154 | V4SF_TX2(&t2, &t3); 155 | 156 | *r0 = t0; 157 | *r2 = t1; 158 | *r1 = t2; 159 | *r3 = t3; 160 | } 161 | 162 | static FFTS_INLINE void 163 | V4SF_L_4_2(int inv, 164 | const float *FFTS_RESTRICT i0, 165 | const float *FFTS_RESTRICT i1, 166 | const float *FFTS_RESTRICT i2, 167 | const float *FFTS_RESTRICT i3, 168 | V4SF *r0, 169 | V4SF *r1, 170 | V4SF *r2, 171 | V4SF *r3) 172 | { 173 | V4SF t0, t1, t2, t3, t4, t5, t6, t7; 174 | 175 | t0 = V4SF_LD(i0); 176 | t1 = V4SF_LD(i1); 177 | t6 = V4SF_LD(i2); 178 | t7 = V4SF_LD(i3); 179 | 180 | t2 = V4SF_BLEND(t6, t7); 181 | t3 = V4SF_BLEND(t7, t6); 182 | 183 | t4 = V4SF_ADD(t0, t1); 184 | t5 = V4SF_SUB(t0, t1); 185 | t6 = V4SF_ADD(t2, t3); 186 | t7 = V4SF_SUB(t2, t3); 187 | 188 | *r2 = V4SF_UNPACK_HI(t4, t5); 189 | *r3 = V4SF_UNPACK_HI(t6, t7); 190 | 191 | t7 = V4SF_IMULI(inv, t7); 192 | 193 | t0 = V4SF_ADD(t4, t6); 194 | t2 = V4SF_SUB(t4, t6); 195 | t1 = V4SF_SUB(t5, t7); 196 | t3 = V4SF_ADD(t5, t7); 197 | 198 | *r0 = V4SF_UNPACK_LO(t0, t1); 199 | *r1 = V4SF_UNPACK_LO(t2, t3); 200 | } 201 | 202 | #define V4SF_S_4(r0, r1, r2, r3, o0, o1, o2, o3) \ 203 | V4SF_ST(o0, r0); V4SF_ST(o1, r1); V4SF_ST(o2, r2); V4SF_ST(o3, r3); 204 | 205 | #endif /* FFTS_MACROS_H */ 206 | -------------------------------------------------------------------------------- /src/neon.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_NEON_H 35 | #define FFTS_NEON_H 36 | 37 | #include "ffts.h" 38 | 39 | void neon_x4(float *, size_t, float *); 40 | void neon_x8(float *, size_t, float *); 41 | void neon_x8_t(float *, size_t, float *); 42 | void neon_ee(); 43 | void neon_oo(); 44 | void neon_eo(); 45 | void neon_oe(); 46 | void neon_end(); 47 | 48 | void neon_transpose4(uint64_t *in, uint64_t *out, int w, int h); 49 | void neon_transpose8(uint64_t *in, uint64_t *out, int w, int h); 50 | 51 | void neon_static_e_f(ffts_plan_t*, const void*, void*); 52 | void neon_static_o_f(ffts_plan_t*, const void*, void*); 53 | void neon_static_x4_f(float*, const float*); 54 | void neon_static_x8_f(float*, size_t, const float*); 55 | void neon_static_x8_t_f(float*, size_t, const float*); 56 | 57 | void neon_static_e_i(ffts_plan_t*, const void*, void*); 58 | void neon_static_o_i(ffts_plan_t*, const void*, void*); 59 | void neon_static_x4_i(float*, const float*); 60 | void neon_static_x8_i(float*, size_t, const float*); 61 | void neon_static_x8_t_i(float*, size_t, const float*); 62 | 63 | #endif /* FFTS_NEON_H */ 64 | -------------------------------------------------------------------------------- /src/types.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | Copyright (c) 2012, The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef FFTS_TYPES_H 35 | #define FFTS_TYPES_H 36 | 37 | #if defined (_MSC_VER) && (_MSC_VER >= 1020) 38 | #pragma once 39 | #endif 40 | 41 | /* Define complex number as two element array */ 42 | typedef float ffts_cpx_32f[2]; 43 | typedef double ffts_cpx_64f[2]; 44 | 45 | #endif /* FFTS_TYPES_H */ 46 | -------------------------------------------------------------------------------- /src/vfp.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS -- The Fastest Fourier Transform in the South 4 | 5 | Copyright (c) 2012, 2013 Anthony M. Blake 6 | Copyright (c) 2012, 2013 The University of Waikato 7 | 8 | All rights reserved. 9 | 10 | Redistribution and use in source and binary forms, with or without 11 | modification, are permitted provided that the following conditions are met: 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | notice, this list of conditions and the following disclaimer in the 16 | documentation and/or other materials provided with the distribution. 17 | * Neither the name of the organization nor the 18 | names of its contributors may be used to endorse or promote products 19 | derived from this software without specific prior written permission. 20 | 21 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 22 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 25 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 27 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 28 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | */ 33 | 34 | #ifndef __VFP_H__ 35 | #define __VFP_H__ 36 | 37 | #include "ffts.h" 38 | 39 | void vfp_e(); 40 | void vfp_o(); 41 | void vfp_x4(); 42 | void vfp_x8(); 43 | void vfp_end(); 44 | 45 | #endif 46 | // vim: set autoindent noexpandtab tabstop=3 shiftwidth=3: 47 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_PROGRAMS = test 3 | test_SOURCES = test.c 4 | test_LDADD = $(top_builddir)/src/libffts.la 5 | -------------------------------------------------------------------------------- /tests/test.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | This file is part of FFTS. 4 | 5 | Copyright (c) 2012, Anthony M. Blake 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of the organization nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL ANTHONY M. BLAKE BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | 30 | */ 31 | 32 | #include "../include/ffts.h" 33 | #include "../src/ffts_attributes.h" 34 | 35 | #ifdef __ARM_NEON__ 36 | #endif 37 | 38 | #ifdef HAVE_SSE 39 | #include 40 | #endif 41 | 42 | #include 43 | #include 44 | #include 45 | 46 | #ifndef M_PI 47 | #define M_PI 3.1415926535897932384626433832795028841971693993751058209 48 | #endif 49 | 50 | static float impulse_error(int N, int sign, float *data) 51 | { 52 | #ifdef __ANDROID__ 53 | double delta_sum = 0.0f; 54 | double sum = 0.0f; 55 | #else 56 | long double delta_sum = 0.0f; 57 | long double sum = 0.0f; 58 | #endif 59 | int i; 60 | 61 | for (i = 0; i < N; i++) { 62 | #ifdef __ANDROID__ 63 | double re, im; 64 | 65 | if (sign < 0) { 66 | re = cos(2 * M_PI * (double) i / (double) N); 67 | im = -sin(2 * M_PI * (double) i / (double) N); 68 | } else { 69 | re = cos(2 * M_PI * (double) i / (double) N); 70 | im = sin(2 * M_PI * (double) i / (double) N); 71 | } 72 | #else 73 | long double re, im; 74 | 75 | if (sign < 0) { 76 | re = cosl(2 * M_PI * (long double) i / (long double) N); 77 | im = -sinl(2 * M_PI * (long double) i / (long double) N); 78 | } else { 79 | re = cosl(2 * M_PI * (long double) i / (long double) N); 80 | im = sinl(2 * M_PI * (long double) i / (long double) N); 81 | } 82 | #endif 83 | 84 | sum += re * re + im * im; 85 | 86 | re = re - data[2*i]; 87 | im = im - data[2*i+1]; 88 | 89 | delta_sum += re * re + im * im; 90 | } 91 | 92 | #ifdef __ANDROID__ 93 | return (float) (sqrt(delta_sum) / sqrt(sum)); 94 | #else 95 | return (float) (sqrtl(delta_sum) / sqrtl(sum)); 96 | #endif 97 | } 98 | 99 | int test_transform(int n, int sign) 100 | { 101 | ffts_plan_t *p; 102 | 103 | #ifdef HAVE_SSE 104 | float FFTS_ALIGN(32) *input = _mm_malloc(2 * n * sizeof(float), 32); 105 | float FFTS_ALIGN(32) *output = _mm_malloc(2 * n * sizeof(float), 32); 106 | #else 107 | float FFTS_ALIGN(32) *input = valloc(2 * n * sizeof(float)); 108 | float FFTS_ALIGN(32) *output = valloc(2 * n * sizeof(float)); 109 | #endif 110 | int i; 111 | 112 | for (i = 0; i < n; i++) { 113 | input[2*i + 0] = 0.0f; 114 | input[2*i + 1] = 0.0f; 115 | } 116 | 117 | input[2] = 1.0f; 118 | 119 | p = ffts_init_1d(i, sign); 120 | if (!p) { 121 | printf("Plan unsupported\n"); 122 | return 0; 123 | } 124 | 125 | ffts_execute(p, input, output); 126 | printf(" %3d | %9d | %10E\n", sign, n, impulse_error(n, sign, output)); 127 | ffts_free(p); 128 | return 1; 129 | } 130 | 131 | int main(int argc, char *argv[]) 132 | { 133 | if (argc == 3) { 134 | ffts_plan_t *p; 135 | int i; 136 | 137 | /* test specific transform with test pattern and display output */ 138 | int n = atoi(argv[1]); 139 | int sign = atoi(argv[2]); 140 | 141 | #ifdef HAVE_SSE 142 | float FFTS_ALIGN(32) *input = _mm_malloc(2 * n * sizeof(float), 32); 143 | float FFTS_ALIGN(32) *output = _mm_malloc(2 * n * sizeof(float), 32); 144 | #else 145 | float FFTS_ALIGN(32) *input = valloc(2 * n * sizeof(float)); 146 | float FFTS_ALIGN(32) *output = valloc(2 * n * sizeof(float)); 147 | #endif 148 | 149 | for (i = 0; i < n; i++) { 150 | input[2*i + 0] = (float) i; 151 | input[2*i + 1] = 0.0f; 152 | } 153 | 154 | /* input[2] = 1.0f; */ 155 | 156 | p = ffts_init_1d(i, sign); 157 | if (!p) { 158 | printf("Plan unsupported\n"); 159 | return 0; 160 | } 161 | 162 | ffts_execute(p, input, output); 163 | 164 | for (i = 0; i < n; i++) 165 | printf("%d %d %f %f\n", i, sign, output[2*i], output[2*i+1]); 166 | ffts_free(p); 167 | 168 | #ifdef HAVE_SSE 169 | _mm_free(input); 170 | _mm_free(output); 171 | #else 172 | free(input); 173 | free(output); 174 | #endif 175 | } else { 176 | int n, power2; 177 | 178 | /* test various sizes and display error */ 179 | printf(" Sign | Size | L2 Error\n"); 180 | printf("------+-----------+-------------\n"); 181 | 182 | for (n = 1, power2 = 2; n <= 18; n++, power2 <<= 1) { 183 | test_transform(power2, -1); 184 | } 185 | 186 | for (n = 1, power2 = 2; n <= 18; n++, power2 <<= 1) { 187 | test_transform(power2, 1); 188 | } 189 | } 190 | 191 | return 0; 192 | } 193 | --------------------------------------------------------------------------------