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