1b8021494Sopenharmony_ci# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2b8021494Sopenharmony_ci#
3b8021494Sopenharmony_ci# Redistribution and use in source and binary forms, with or without
4b8021494Sopenharmony_ci# modification, are permitted provided that the following conditions are met:
5b8021494Sopenharmony_ci#
6b8021494Sopenharmony_ci#   * Redistributions of source code must retain the above copyright notice,
7b8021494Sopenharmony_ci#     this list of conditions and the following disclaimer.
8b8021494Sopenharmony_ci#   * Redistributions in binary form must reproduce the above copyright notice,
9b8021494Sopenharmony_ci#     this list of conditions and the following disclaimer in the documentation
10b8021494Sopenharmony_ci#     and/or other materials provided with the distribution.
11b8021494Sopenharmony_ci#   * Neither the name of ARM Limited nor the names of its contributors may be
12b8021494Sopenharmony_ci#     used to endorse or promote products derived from this software without
13b8021494Sopenharmony_ci#     specific prior written permission.
14b8021494Sopenharmony_ci#
15b8021494Sopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
16b8021494Sopenharmony_ci# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17b8021494Sopenharmony_ci# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18b8021494Sopenharmony_ci# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
19b8021494Sopenharmony_ci# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20b8021494Sopenharmony_ci# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21b8021494Sopenharmony_ci# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
22b8021494Sopenharmony_ci# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23b8021494Sopenharmony_ci# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24b8021494Sopenharmony_ci# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25b8021494Sopenharmony_ci
26b8021494Sopenharmony_cicmake_minimum_required(VERSION 3.10)
27b8021494Sopenharmony_ci
28b8021494Sopenharmony_ciproject(vixl)
29b8021494Sopenharmony_ci
30b8021494Sopenharmony_ciset(VIXL_SOURCES
31b8021494Sopenharmony_ci    src/code-buffer-vixl.cc
32b8021494Sopenharmony_ci    src/compiler-intrinsics-vixl.cc
33b8021494Sopenharmony_ci    src/cpu-features.cc
34b8021494Sopenharmony_ci    src/utils-vixl.cc )
35b8021494Sopenharmony_ci
36b8021494Sopenharmony_ciset(VIXL_DIR
37b8021494Sopenharmony_ci    .
38b8021494Sopenharmony_ci    src/ )
39b8021494Sopenharmony_ci
40b8021494Sopenharmony_ciif (PANDA_TARGET_MACOS)
41b8021494Sopenharmony_ciset(VIXL_FLAGS -DVIXL_CODE_BUFFER_MALLOC -DPANDA_BUILD)
42b8021494Sopenharmony_cielse()
43b8021494Sopenharmony_ciset(VIXL_FLAGS -DVIXL_CODE_BUFFER_MMAP -DPANDA_BUILD)
44b8021494Sopenharmony_ciendif()
45b8021494Sopenharmony_ci
46b8021494Sopenharmony_ciset(VIXL_AARCH32_SOURCES
47b8021494Sopenharmony_ci    src/aarch32/assembler-aarch32.cc
48b8021494Sopenharmony_ci    src/aarch32/disasm-aarch32.cc
49b8021494Sopenharmony_ci    src/aarch32/location-aarch32.cc
50b8021494Sopenharmony_ci    src/aarch32/operands-aarch32.cc
51b8021494Sopenharmony_ci    src/aarch32/constants-aarch32.cc
52b8021494Sopenharmony_ci    src/aarch32/instructions-aarch32.cc
53b8021494Sopenharmony_ci    src/aarch32/macro-assembler-aarch32.cc )
54b8021494Sopenharmony_ci
55b8021494Sopenharmony_ciset(VIXL_AARCH32_DIR src/aarch32/)
56b8021494Sopenharmony_ci
57b8021494Sopenharmony_ciset(VIXL_AARCH64_SOURCES
58b8021494Sopenharmony_ci    src/aarch64/assembler-aarch64.cc
59b8021494Sopenharmony_ci    src/aarch64/operands-aarch64.cc
60b8021494Sopenharmony_ci    src/aarch64/cpu-aarch64.cc
61b8021494Sopenharmony_ci    src/aarch64/instructions-aarch64.cc
62b8021494Sopenharmony_ci    src/aarch64/macro-assembler-aarch64.cc )
63b8021494Sopenharmony_ci
64b8021494Sopenharmony_ciif (NOT PANDA_MINIMAL_VIXL)
65b8021494Sopenharmony_ci    list(APPEND VIXL_AARCH64_SOURCES
66b8021494Sopenharmony_ci        #src/aarch64/assembler-sve-aarch64.cc
67b8021494Sopenharmony_ci        src/aarch64/decoder-aarch64.cc
68b8021494Sopenharmony_ci        src/aarch64/disasm-aarch64.cc
69b8021494Sopenharmony_ci        src/aarch64/logic-aarch64.cc
70b8021494Sopenharmony_ci        src/aarch64/pointer-auth-aarch64.cc
71b8021494Sopenharmony_ci        src/aarch64/cpu-features-auditor-aarch64.cc
72b8021494Sopenharmony_ci        #src/aarch64/macro-assembler-sve-aarch64.cc
73b8021494Sopenharmony_ci        src/aarch64/debugger-aarch64.cc
74b8021494Sopenharmony_ci        src/aarch64/simulator-aarch64.cc )
75b8021494Sopenharmony_ciendif()
76b8021494Sopenharmony_ci
77b8021494Sopenharmony_ciset(VIXL_AARCH64_DIR src/aarch64/)
78b8021494Sopenharmony_ci
79b8021494Sopenharmony_ciif (NOT(CMAKE_BUILD_TYPE MATCHES Release OR CMAKE_BUILD_TYPE MATCHES RelWithDebInfo))
80b8021494Sopenharmony_ci    list(APPEND VIXL_FLAGS -DVIXL_DEBUG)
81b8021494Sopenharmony_ciendif()
82b8021494Sopenharmony_ci
83b8021494Sopenharmony_ci# !TODO Add test suite to check with PANDA_COMPILER_TARGET_AARCH32
84b8021494Sopenharmony_ciif ((PANDA_TARGET_ARM32) OR (PANDA_TARGET_AMD64))
85b8021494Sopenharmony_ci    list(APPEND VIXL_FLAGS -DVIXL_INCLUDE_TARGET_A32)
86b8021494Sopenharmony_ci    list(APPEND VIXL_SOURCES ${VIXL_AARCH32_SOURCES})
87b8021494Sopenharmony_ci    list(APPEND VIXL_DIR ${VIXL_AARCH32_DIR})
88b8021494Sopenharmony_ciendif()
89b8021494Sopenharmony_ci
90b8021494Sopenharmony_ci# !TODO Add  test suite to check with PANDA_COMPILER_TARGET_AARCH64
91b8021494Sopenharmony_ciif ((PANDA_TARGET_ARM64) OR (PANDA_TARGET_AMD64))
92b8021494Sopenharmony_ci    list(APPEND VIXL_FLAGS -DVIXL_INCLUDE_SIMULATOR_AARCH64 -DVIXL_INCLUDE_TARGET_A64)
93b8021494Sopenharmony_ci    list(APPEND VIXL_SOURCES ${VIXL_AARCH64_SOURCES})
94b8021494Sopenharmony_ci    list(APPEND VIXL_DIR ${VIXL_AARCH64_DIR})
95b8021494Sopenharmony_ciendif()
96b8021494Sopenharmony_ci
97b8021494Sopenharmony_ciinclude_directories(${VIXL_DIR})
98b8021494Sopenharmony_ci
99b8021494Sopenharmony_ciadd_library(vixl STATIC ${VIXL_SOURCES})
100b8021494Sopenharmony_citarget_link_libraries(vixl arkbase)
101b8021494Sopenharmony_ci
102b8021494Sopenharmony_citarget_compile_options(vixl PUBLIC ${VIXL_FLAGS})
103b8021494Sopenharmony_citarget_compile_options(vixl PRIVATE -Wno-shadow -Wno-deprecated-declarations)
104b8021494Sopenharmony_ci
105b8021494Sopenharmony_citarget_compile_definitions(vixl PUBLIC "VIXL_USE_PANDA_ALLOC")
106b8021494Sopenharmony_ci
107b8021494Sopenharmony_ciif (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0.0)
108b8021494Sopenharmony_ci    target_compile_options(vixl PRIVATE -Wno-bitwise-instead-of-logical)
109b8021494Sopenharmony_ciendif()
110b8021494Sopenharmony_ci
111b8021494Sopenharmony_ciset_property(TARGET vixl PROPERTY POSITION_INDEPENDENT_CODE ON)
112b8021494Sopenharmony_ciset_property(TARGET vixl PROPERTY EXCLUDE_FROM_ALL TRUE)
113b8021494Sopenharmony_ci
114b8021494Sopenharmony_citarget_include_directories(vixl
115b8021494Sopenharmony_ci    SYSTEM INTERFACE src/
116b8021494Sopenharmony_ci)
117b8021494Sopenharmony_ci
118b8021494Sopenharmony_cipanda_add_sanitizers(TARGET vixl SANITIZERS ${PANDA_SANITIZERS_LIST})
119