Commit 50c5a7e9 authored by Tom Finegan's avatar Tom Finegan

Add support for x86_64 assembly and intrinsics to the cmake build.

Darwin/Linux x86_64 only.

BUG=https://bugs.chromium.org/p/aomedia/issues/detail?id=76

Change-Id: I1500c085f26066ac0108017b5155aba0f003427c
parent 0d3aeda3
This diff is collapsed.
ARCH_ARM equ ${ARCH_ARM}
ARCH_MIPS equ ${ARCH_MIPS}
ARCH_X86 equ ${ARCH_X86}
ARCH_X86_64 equ ${ARCH_X86_64}
HAVE_EDSP equ ${HAVE_EDSP}
HAVE_MEDIA equ ${HAVE_MEDIA}
HAVE_NEON equ ${HAVE_NEON}
HAVE_NEON_ASM equ ${HAVE_NEON_ASM}
HAVE_MIPS32 equ ${HAVE_MIPS32}
HAVE_DSPR2 equ ${HAVE_DSPR2}
HAVE_MSA equ ${HAVE_MSA}
HAVE_MIPS64 equ ${HAVE_MIPS64}
HAVE_MMX equ ${HAVE_MMX}
HAVE_SSE equ ${HAVE_SSE}
HAVE_SSE2 equ ${HAVE_SSE2}
HAVE_SSE3 equ ${HAVE_SSE3}
HAVE_SSSE3 equ ${HAVE_SSSE3}
HAVE_SSE4_1 equ ${HAVE_SSE4_1}
HAVE_AVX equ ${HAVE_AVX}
HAVE_AVX2 equ ${HAVE_AVX2}
HAVE_AOM_PORTS equ ${HAVE_AOM_PORTS}
HAVE_PTHREAD_H equ ${HAVE_PTHREAD_H}
HAVE_UNISTD_H equ ${HAVE_UNISTD_H}
CONFIG_DEPENDENCY_TRACKING equ ${CONFIG_DEPENDENCY_TRACKING}
CONFIG_EXTERNAL_BUILD equ ${CONFIG_EXTERNAL_BUILD}
CONFIG_INSTALL_DOCS equ ${CONFIG_INSTALL_DOCS}
CONFIG_INSTALL_BINS equ ${CONFIG_INSTALL_BINS}
CONFIG_INSTALL_LIBS equ ${CONFIG_INSTALL_LIBS}
CONFIG_INSTALL_SRCS equ ${CONFIG_INSTALL_SRCS}
CONFIG_DEBUG equ ${CONFIG_DEBUG}
CONFIG_GPROF equ ${CONFIG_GPROF}
CONFIG_GCOV equ ${CONFIG_GCOV}
CONFIG_RVCT equ ${CONFIG_RVCT}
CONFIG_GCC equ ${CONFIG_GCC}
CONFIG_MSVS equ ${CONFIG_MSVS}
CONFIG_PIC equ ${CONFIG_PIC}
CONFIG_BIG_ENDIAN equ ${CONFIG_BIG_ENDIAN}
CONFIG_CODEC_SRCS equ ${CONFIG_CODEC_SRCS}
CONFIG_DEBUG_LIBS equ ${CONFIG_DEBUG_LIBS}
CONFIG_DEQUANT_TOKENS equ ${CONFIG_DEQUANT_TOKENS}
CONFIG_DC_RECON equ ${CONFIG_DC_RECON}
CONFIG_RUNTIME_CPU_DETECT equ ${CONFIG_RUNTIME_CPU_DETECT}
CONFIG_POSTPROC equ ${CONFIG_POSTPROC}
CONFIG_AV1_POSTPROC equ ${CONFIG_AV1_POSTPROC}
CONFIG_MULTITHREAD equ ${CONFIG_MULTITHREAD}
CONFIG_INTERNAL_STATS equ ${CONFIG_INTERNAL_STATS}
CONFIG_AV1_ENCODER equ ${CONFIG_AV1_ENCODER}
CONFIG_AV1_DECODER equ ${CONFIG_AV1_DECODER}
CONFIG_AV1 equ ${CONFIG_AV1}
CONFIG_ENCODERS equ ${CONFIG_ENCODERS}
CONFIG_DECODERS equ ${CONFIG_DECODERS}
CONFIG_STATIC_MSVCRT equ ${CONFIG_STATIC_MSVCRT}
CONFIG_SPATIAL_RESAMPLING equ ${CONFIG_SPATIAL_RESAMPLING}
CONFIG_REALTIME_ONLY equ ${CONFIG_REALTIME_ONLY}
CONFIG_ONTHEFLY_BITPACKING equ ${CONFIG_ONTHEFLY_BITPACKING}
CONFIG_ERROR_CONCEALMENT equ ${CONFIG_ERROR_CONCEALMENT}
CONFIG_SHARED equ ${CONFIG_SHARED}
CONFIG_STATIC equ ${CONFIG_STATIC}
CONFIG_SMALL equ ${CONFIG_SMALL}
CONFIG_POSTPROC_VISUALIZER equ ${CONFIG_POSTPROC_VISUALIZER}
CONFIG_OS_SUPPORT equ ${CONFIG_OS_SUPPORT}
CONFIG_UNIT_TESTS equ ${CONFIG_UNIT_TESTS}
CONFIG_WEBM_IO equ ${CONFIG_WEBM_IO}
CONFIG_LIBYUV equ ${CONFIG_LIBYUV}
CONFIG_ACCOUNTING equ ${CONFIG_ACCOUNTING}
CONFIG_DECODE_PERF_TESTS equ ${CONFIG_DECODE_PERF_TESTS}
CONFIG_ENCODE_PERF_TESTS equ ${CONFIG_ENCODE_PERF_TESTS}
CONFIG_MULTI_RES_ENCODING equ ${CONFIG_MULTI_RES_ENCODING}
CONFIG_TEMPORAL_DENOISING equ ${CONFIG_TEMPORAL_DENOISING}
CONFIG_AV1_TEMPORAL_DENOISING equ ${CONFIG_AV1_TEMPORAL_DENOISING}
CONFIG_COEFFICIENT_RANGE_CHECKING equ ${CONFIG_COEFFICIENT_RANGE_CHECKING}
CONFIG_AOM_HIGHBITDEPTH equ ${CONFIG_AOM_HIGHBITDEPTH}
CONFIG_BETTER_HW_COMPATIBILITY equ ${CONFIG_BETTER_HW_COMPATIBILITY}
CONFIG_EXPERIMENTAL equ ${CONFIG_EXPERIMENTAL}
CONFIG_SIZE_LIMIT equ ${CONFIG_SIZE_LIMIT}
CONFIG_AOM_QM equ ${CONFIG_AOM_QM}
CONFIG_FP_MB_STATS equ ${CONFIG_FP_MB_STATS}
CONFIG_EMULATE_HARDWARE equ ${CONFIG_EMULATE_HARDWARE}
CONFIG_CLPF equ ${CONFIG_CLPF}
CONFIG_DERING equ ${CONFIG_DERING}
CONFIG_VAR_TX equ ${CONFIG_VAR_TX}
CONFIG_RECT_TX equ ${CONFIG_RECT_TX}
CONFIG_REF_MV equ ${CONFIG_REF_MV}
CONFIG_DUAL_FILTER equ ${CONFIG_DUAL_FILTER}
CONFIG_EXT_TX equ ${CONFIG_EXT_TX}
CONFIG_TX64X64 equ ${CONFIG_TX64X64}
CONFIG_SUB8X8_MC equ ${CONFIG_SUB8X8_MC}
CONFIG_EXT_INTRA equ ${CONFIG_EXT_INTRA}
CONFIG_FILTER_INTRA equ ${CONFIG_FILTER_INTRA}
CONFIG_EXT_INTER equ ${CONFIG_EXT_INTER}
CONFIG_EXT_REFS equ ${CONFIG_EXT_REFS}
CONFIG_GLOBAL_MOTION equ ${CONFIG_GLOBAL_MOTION}
CONFIG_NEW_QUANT equ ${CONFIG_NEW_QUANT}
CONFIG_SUPERTX equ ${CONFIG_SUPERTX}
CONFIG_ANS equ ${CONFIG_ANS}
CONFIG_EC_MULTISYMBOL equ ${CONFIG_EC_MULTISYMBOL}
CONFIG_LOOP_RESTORATION equ ${CONFIG_LOOP_RESTORATION}
CONFIG_EXT_PARTITION equ ${CONFIG_EXT_PARTITION}
CONFIG_EXT_PARTITION_TYPES equ ${CONFIG_EXT_PARTITION_TYPES}
CONFIG_UNPOISON_PARTITION_CTX equ ${CONFIG_UNPOISON_PARTITION_CTX}
CONFIG_EXT_TILE equ ${CONFIG_EXT_TILE}
CONFIG_MOTION_VAR equ ${CONFIG_MOTION_VAR}
CONFIG_WARPED_MOTION equ ${CONFIG_WARPED_MOTION}
CONFIG_ENTROPY equ ${CONFIG_ENTROPY}
CONFIG_BIDIR_PRED equ ${CONFIG_BIDIR_PRED}
CONFIG_BITSTREAM_DEBUG equ ${CONFIG_BITSTREAM_DEBUG}
CONFIG_ALT_INTRA equ ${CONFIG_ALT_INTRA}
CONFIG_PALETTE equ ${CONFIG_PALETTE}
CONFIG_DAALA_EC equ ${CONFIG_DAALA_EC}
CONFIG_PVQ equ ${CONFIG_PVQ}
CONFIG_CB4X4 equ ${CONFIG_CB4X4}
CONFIG_FRAME_SIZE equ ${CONFIG_FRAME_SIZE}
CONFIG_DELTA_Q equ ${CONFIG_DELTA_Q}
CONFIG_ADAPT_SCAN equ ${CONFIG_ADAPT_SCAN}
CONFIG_FILTER_7BIT equ ${CONFIG_FILTER_7BIT}
CONFIG_PARALLEL_DEBLOCKING equ ${CONFIG_PARALLEL_DEBLOCKING}
CONFIG_TILE_GROUPS equ ${CONFIG_TILE_GROUPS}
CONFIG_EC_ADAPT equ ${CONFIG_EC_ADAPT}
CONFIG_SIMP_MV_PRED equ ${CONFIG_SIMP_MV_PRED}
CONFIG_RD_DEBUG equ ${CONFIG_RD_DEBUG}
CONFIG_REFERENCE_BUFFER equ ${CONFIG_REFERENCE_BUFFER}
CONFIG_COEF_INTERLEAVE equ ${CONFIG_COEF_INTERLEAVE}
CONFIG_ENTROPY_STATS equ ${CONFIG_ENTROPY_STATS}
CONFIG_MASKED_TX equ ${CONFIG_MASKED_TX}
CONFIG_DAALA_DIST equ ${CONFIG_DAALA_DIST}
......@@ -13,11 +13,27 @@ cmake_minimum_required(VERSION 3.2)
include("${AOM_ROOT}/build/cmake/aom_config_defaults.cmake")
include("${AOM_ROOT}/build/cmake/compiler_flags.cmake")
include("${AOM_ROOT}/build/cmake/compiler_tests.cmake")
include("${AOM_ROOT}/build/cmake/targets/${AOM_TARGET}.cmake")
# TODO(tomfinegan): For some ${AOM_TARGET} values a toolchain can be
# inferred, and we could include it here instead of forcing users to
# remember to explicitly specify ${AOM_TARGET} and the cmake toolchain.
# Detect target CPU.
if (NOT AOM_TARGET_CPU)
# TODO(tomfinegan): This will not work for a cross compile. Target CPU and
# system will have to come from a toolchain file or the cmake command line.
set(AOM_TARGET_CPU ${CMAKE_SYSTEM_PROCESSOR})
set(AOM_TARGET_SYSTEM ${CMAKE_SYSTEM_NAME})
if (NOT EXISTS "${AOM_ROOT}/build/cmake/targets/${AOM_TARGET_CPU}.cmake")
message("No RTCD template for ${AOM_TARGET_CPU}, using generic.")
set(AOM_TARGET_CPU "generic")
endif ()
if (NOT AOM_TARGET_CPU STREQUAL "generic")
find_program(YASM_EXECUTABLE yasm $ENV{YASM_PATH})
if (NOT YASM_EXECUTABLE)
message(WARNING "Unable to find yasm, using generic as target CPU.")
set(AOM_TARGET_CPU "generic")
endif ()
endif ()
endif ()
include("${AOM_ROOT}/build/cmake/targets/${AOM_TARGET_CPU}.cmake")
include(FindGit)
include(FindPerl)
......@@ -76,6 +92,8 @@ endif ()
# values require special casing).
configure_file("${AOM_ROOT}/build/cmake/aom_config.h.cmake"
"${AOM_CONFIG_DIR}/aom_config.h")
configure_file("${AOM_ROOT}/build/cmake/aom_config.asm.cmake"
"${AOM_CONFIG_DIR}/aom_config.asm")
# Read the current git hash.
find_package(Git)
......@@ -145,10 +163,11 @@ endforeach()
macro(AomAddRtcdGenerationCommand config output source symbol)
add_custom_command(OUTPUT ${output}
COMMAND ${PERL_EXECUTABLE} "${AOM_ROOT}/build/make/rtcd.pl"
--arch=${AOM_ARCH} --sym=${symbol}
--config=${AOM_CONFIG_DIR}/${AOM_ARCH}.rtcd
${config} > ${output}
COMMAND ${PERL_EXECUTABLE}
ARGS "${AOM_ROOT}/build/make/rtcd.pl"
--arch=${AOM_ARCH} --sym=${symbol}
--config=${AOM_CONFIG_DIR}/${AOM_ARCH}.rtcd
${config} > ${output}
DEPENDS ${config}
COMMENT "Generating ${output}"
WORKING_DIRECTORY ${AOM_CONFIG_DIR}
......
##
## Copyright (c) 2017, Alliance for Open Media. All rights reserved
##
## This source code is subject to the terms of the BSD 2 Clause License and
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
## was not distributed with this source code in the LICENSE file, you can
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
## Media Patent License 1.0 was not distributed with this source code in the
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
##
# Adds an object library target. Terminates generation if $flag is not supported
# by the current compiler. $flag is the intrinsics flag required by the current
# compiler, and is added to the compile flags for all sources in $sources.
# $opt_name is used to name the target. $target_to_update is made
# dependent upon the created target.
#
# Note: the libaom target is always updated because OBJECT libraries have rules
# that disallow the direct addition of .o files to them as dependencies. Static
# libraries do not have this limitation.
function (add_intrinsics_object_library flag opt_name target_to_update sources)
if (MSVC)
message(FATAL_ERROR "MSVC instrinics support not implemented.")
endif ()
set(target_name ${target_to_update}_${opt_name}_intrinsics)
add_library(${target_name} OBJECT ${${sources}})
target_compile_options(${target_name} PUBLIC ${flag})
target_sources(aom PUBLIC $<TARGET_OBJECTS:${target_name}>)
endfunction ()
# Adds build commands for ASM files in $sources and uses $asm_build_name to
# build an output directory path. Adds ASM objects to libaom directly. $sources
# must be the name of a variable containing a list of sources.
#
# Note: the libaom target is always updated because OBJECT libraries have rules
# that disallow the direct addition of .o files to them as dependencies. Static
# libraries do not have this limitation.
function (add_asm_build asm_build_name sources)
set(AOM_ASM_OBJECTS_DIR "${AOM_CONFIG_DIR}/asm_objects/${asm_build_name}")
if (NOT EXISTS "${AOM_ASM_OBJECTS_DIR}")
file(MAKE_DIRECTORY "${AOM_ASM_OBJECTS_DIR}")
endif ()
# TODO(tomfinegan): This might get rather lengthy; probably best to move it
# out into its own function or macro.
if ("${AOM_TARGET_CPU}" STREQUAL "x86_64" AND
"${AOM_TARGET_SYSTEM}" STREQUAL "Darwin")
set(objformat "macho64")
elseif ("${AOM_TARGET_CPU}" STREQUAL "x86_64" AND
"${AOM_TARGET_SYSTEM}" STREQUAL "Linux")
set(objformat "elf64")
else ()
message(FATAL_ERROR
"Unknown obj format: ${AOM_TARGET_CPU}-${AOM_TARGET_SYSTEM}")
endif ()
foreach (asm_source ${${sources}})
get_filename_component(asm_source_name "${asm_source}" NAME)
set(asm_object "${AOM_ASM_OBJECTS_DIR}/${asm_source_name}.o")
add_custom_command(OUTPUT "${asm_object}"
COMMAND ${YASM_EXECUTABLE}
ARGS -f ${objformat}
-I${AOM_ROOT} -I${AOM_CONFIG_DIR}
-o "${asm_object}" "${asm_source}"
DEPENDS "${asm_source}"
COMMENT "Building ASM object ${asm_object}"
WORKING_DIRECTORY "${AOM_CONFIG_DIR}"
VERBATIM)
target_sources(aom PUBLIC "${asm_source}" "${asm_object}")
endforeach ()
endfunction ()
......@@ -23,6 +23,10 @@ set(AOM_C_FAILED_TESTS)
set(AOM_CXX_PASSED_TESTS)
set(AOM_CXX_FAILED_TESTS)
# TODO(tomfinegan): Rename the functions in here to_be_of_this_format to match
# other custom CMake commands (from CMake built in plugins and other cmake code
# in AOM).
# Confirms $test_source compiles and stores $test_name in one of
# $AOM_C_PASSED_TESTS or $AOM_C_FAILED_TESTS depending on out come. When the
# test passes $result_var is set to 1. When it fails $result_var is unset.
......
......@@ -8,8 +8,6 @@
## Media Patent License 1.0 was not distributed with this source code in the
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
##
cmake_minimum_required(VERSION 3.2)
set(AOM_ARCH "generic")
# TODO(tomfinegan): These must not be hard coded. They must be set based on
......@@ -17,7 +15,6 @@ set(AOM_ARCH "generic")
set(RTCD_CONFIG_AV1 "yes")
set(RTCD_CONFIG_AV1_DECODER "yes")
set(RTCD_CONFIG_AV1_ENCODER "yes")
set(RTCD_CONFIG_DEPENDENCY_TRACKING "yes")
set(RTCD_CONFIG_INSTALL_BINS "yes")
set(RTCD_CONFIG_INSTALL_LIBS "yes")
set(RTCD_CONFIG_GCC "yes")
......
......@@ -11,7 +11,6 @@
CONFIG_AV1=${RTCD_CONFIG_AV1}
CONFIG_AV1_DECODER=${RTCD_CONFIG_AV1_DECODER}
CONFIG_AV1_ENCODER=${RTCD_CONFIG_AV1_ENCODER}
CONFIG_DEPENDENCY_TRACKING=${RTCD_CONFIG_DEPENDENCY_TRACKING}
CONFIG_INSTALL_BINS=${RTCD_CONFIG_INSTALL_BINS}
CONFIG_INSTALL_LIBS=${RTCD_CONFIG_INSTALL_LIBS}
CONFIG_GCC=${RTCD_CONFIG_GCC}
......
##
## Copyright (c) 2017, Alliance for Open Media. All rights reserved
##
## This source code is subject to the terms of the BSD 2 Clause License and
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
## was not distributed with this source code in the LICENSE file, you can
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
## Media Patent License 1.0 was not distributed with this source code in the
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
##
HAVE_MMX=${RTCD_HAVE_MMX}
HAVE_SSE=${RTCD_HAVE_SSE}
HAVE_SSE2=${RTCD_HAVE_SSE2}
HAVE_SSE3=${RTCD_HAVE_SSE3}
HAVE_SSSE3=${RTCD_HAVE_SSSE3}
HAVE_SSE4_1=${RTCD_HAVE_SSE4_1}
HAVE_AVX=${RTCD_HAVE_AVX}
HAVE_AVX2=${RTCD_HAVE_AVX2}
CONFIG_AV1=${RTCD_CONFIG_AV1}
CONFIG_AV1_DECODER=${RTCD_CONFIG_AV1_DECODER}
CONFIG_AV1_ENCODER=${RTCD_CONFIG_AV1_ENCODER}
CONFIG_INSTALL_BINS=${RTCD_CONFIG_INSTALL_BINS}
CONFIG_INSTALL_LIBS=${RTCD_CONFIG_INSTALL_LIBS}
CONFIG_GCC=${RTCD_CONFIG_GCC}
CONFIG_MULTITHREAD=${RTCD_CONFIG_MULTITHREAD}
CONFIG_AV1_ENCODER=${RTCD_CONFIG_AV1_ENCODER}
CONFIG_AV1_DECODER=${RTCD_CONFIG_AV1_DECODER}
CONFIG_AV1=${RTCD_CONFIG_AV1}
CONFIG_ENCODERS=${RTCD_CONFIG_ENCODERS}
CONFIG_DECODERS=${RTCD_CONFIG_DECODERS}
CONFIG_SPATIAL_RESAMPLING=${RTCD_CONFIG_SPATIAL_RESAMPLING}
CONFIG_STATIC=${RTCD_CONFIG_STATIC}
CONFIG_OS_SUPPORT=${RTCD_CONFIG_OS_SUPPORT}
CONFIG_TEMPORAL_DENOISING=${RTCD_CONFIG_TEMPORAL_DENOISING}
##
## Copyright (c) 2017, Alliance for Open Media. All rights reserved
##
## This source code is subject to the terms of the BSD 2 Clause License and
## the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
## was not distributed with this source code in the LICENSE file, you can
## obtain it at www.aomedia.org/license/software. If the Alliance for Open
## Media Patent License 1.0 was not distributed with this source code in the
## PATENTS file, you can obtain it at www.aomedia.org/license/patent.
##
set(AOM_ARCH "x86_64")
set(ARCH_X86_64 1)
# Assembly flavors available for the target.
set(HAVE_MMX 1)
set(HAVE_SSE 1)
set(HAVE_SSE2 1)
set(HAVE_SSE3 1)
set(HAVE_SSSE3 1)
set(HAVE_SSE4_1 1)
set(HAVE_AVX 1)
set(HAVE_AVX2 1)
# RTCD versions of assembly flavor flags ("yes" means on in rtcd.pl, not 1).
set(RTCD_HAVE_MMX "yes")
set(RTCD_HAVE_SSE "yes")
set(RTCD_HAVE_SSE2 "yes")
set(RTCD_HAVE_SSE3 "yes")
set(RTCD_HAVE_SSSE3 "yes")
set(RTCD_HAVE_SSE4_1 "yes")
set(RTCD_HAVE_AVX "yes")
set(RTCD_HAVE_AVX2 "yes")
# TODO(tomfinegan): These must not be hard coded. They must be set based on
# the values of the externally configurable vars that omit the RTCD_ prefix.
set(RTCD_CONFIG_AV1 "yes")
set(RTCD_CONFIG_AV1_DECODER "yes")
set(RTCD_CONFIG_AV1_ENCODER "yes")
set(RTCD_CONFIG_INSTALL_BINS "yes")
set(RTCD_CONFIG_INSTALL_LIBS "yes")
set(RTCD_CONFIG_GCC "yes")
set(RTCD_CONFIG_MULTITHREAD "yes")
set(RTCD_CONFIG_AV1_ENCODER "yes")
set(RTCD_CONFIG_AV1_DECODER "yes")
set(RTCD_CONFIG_AV1 "yes")
set(RTCD_CONFIG_ENCODERS "yes")
set(RTCD_CONFIG_DECODERS "yes")
set(RTCD_CONFIG_SPATIAL_RESAMPLING "yes")
set(RTCD_CONFIG_STATIC "yes")
set(RTCD_CONFIG_OS_SUPPORT "yes")
set(RTCD_CONFIG_TEMPORAL_DENOISING "yes")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment