Skip to content

Commit

Permalink
mips: Initial MSA support
Browse files Browse the repository at this point in the history
MSA is the MIPS SIMD Architecture.

Add X264_CPU_MSA define.
Update configure to detect MIPS platform and set flags.
CPU-specific gcc options are expected through --extra-cflags.

Sample command line for mips32r5:
    ./configure --host=mipsel-linux-gnu --cross-prefix=<TOOLCHAIN>/mips-mti-linux-gnu-
    --extra-cflags="-EL -mips32r5 -msched-weight -mload-store-pairs"

Signed-off-by: Kaustubh Raste <kaustubh.raste@imgtec.com>
  • Loading branch information
KaustubhIMG authored and Gramner committed Jul 25, 2015
1 parent 9140ee1 commit ce0757d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
13 changes: 13 additions & 0 deletions common/cpu.c
Expand Up @@ -92,6 +92,8 @@ const x264_cpu_name_t x264_cpu_names[] =
#elif ARCH_AARCH64
{"ARMv8", X264_CPU_ARMV8},
{"NEON", X264_CPU_NEON},
#elif ARCH_MIPS
{"MSA", X264_CPU_MSA},
#endif
{"", 0},
};
Expand Down Expand Up @@ -419,6 +421,17 @@ uint32_t x264_cpu_detect( void )
return X264_CPU_ARMV8 | X264_CPU_NEON;
}

#elif ARCH_MIPS

uint32_t x264_cpu_detect( void )
{
uint32_t flags = 0;
#if HAVE_MSA
flags |= X264_CPU_MSA;
#endif
return flags;
}

#else

uint32_t x264_cpu_detect( void )
Expand Down
21 changes: 19 additions & 2 deletions configure
Expand Up @@ -358,7 +358,8 @@ NL="

# list of all preprocessor HAVE values we can define
CONFIG_HAVE="MALLOC_H ALTIVEC ALTIVEC_H MMX ARMV6 ARMV6T2 NEON BEOSTHREAD POSIXTHREAD WIN32THREAD THREAD LOG2F SWSCALE \
LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM AS_FUNC INTEL_DISPATCHER"
LAVF FFMS GPAC AVS GPL VECTOREXT INTERLACED CPU_COUNT OPENCL THP LSMASH X86_INLINE_ASM AS_FUNC INTEL_DISPATCHER \
MSA"

# parse options

Expand Down Expand Up @@ -727,8 +728,10 @@ case $host_cpu in
sparc)
ARCH="SPARC"
;;
mips|mipsel|mips64|mips64el)
mips*)
ARCH="MIPS"
AS="${AS-${CC}}"
AS_EXT=".c"
;;
arm*)
ARCH="ARM"
Expand Down Expand Up @@ -854,6 +857,20 @@ if [ $asm = auto -a \( $ARCH = ARM -o $ARCH = AARCH64 \) ] ; then
as_check ".func test${NL}.endfunc" && define HAVE_AS_FUNC 1
fi

if [ $asm = auto -a $ARCH = MIPS ] ; then
if ! echo $CFLAGS | grep -Eq '(-march|-mmsa|-mno-msa)' ; then
cc_check '' '-mmsa -mfp64 -mhard-float' && CFLAGS="-mmsa -mfp64 -mhard-float $CFLAGS"
fi

if cc_check '' '' '__asm__("addvi.b $w0, $w1, 1");' ; then
define HAVE_MSA
else
echo "You specified a pre-MSA CPU in your CFLAGS."
echo "If you really want to run on such a CPU, configure with --disable-asm."
exit 1
fi
fi

[ $asm = no ] && AS=""
[ "x$AS" = x ] && asm="no" || asm="yes"

Expand Down
5 changes: 4 additions & 1 deletion x264.h
Expand Up @@ -41,7 +41,7 @@

#include "x264_config.h"

#define X264_BUILD 147
#define X264_BUILD 148

/* Application developers planning to link against a shared library version of
* libx264 from a Microsoft Visual Studio or similar development environment
Expand Down Expand Up @@ -158,6 +158,9 @@ typedef struct
#define X264_CPU_FAST_NEON_MRC 0x0000004 /* Transfer from NEON to ARM register is fast (Cortex-A9) */
#define X264_CPU_ARMV8 0x0000008

/* MIPS */
#define X264_CPU_MSA 0x0000001 /* MIPS MSA */

/* Analyse flags */
#define X264_ANALYSE_I4x4 0x0001 /* Analyse i4x4 */
#define X264_ANALYSE_I8x8 0x0002 /* Analyse i8x8 (requires 8x8 transform) */
Expand Down

0 comments on commit ce0757d

Please sign in to comment.