diff --git a/meson.build b/meson.build new file mode 100644 index 00000000..26628846 --- /dev/null +++ b/meson.build @@ -0,0 +1,142 @@ +# SPDX-FileCopyrightText: 2021 Andrea Pappacoda +# +# SPDX-License-Identifier: BSD-3-Clause + +project( + 'vixl', + 'cpp', + version: '5.1.0', + license: 'BSD-3-Clause', + meson_version: '>=0.49.0', + default_options: [ + 'cpp_std=c++14', + 'buildtype=release', + 'warning_level=3', + 'werror=true', + 'd_ndebug=if-release', + 'b_lto=true' + ] +) + +if get_option('debug') + add_project_arguments('-DVIXL_DEBUG', language: 'cpp') +endif + +hosts_32bit = ['arc', 'arm', 'c2000', 'csky', 'mips', 'ppc', 'riscv32', 'rx', 'sparc', 'wasm32', 'x86'] +can_target_aarch64 = not (host_machine.cpu_family() in hosts_32bit) + +build_a32 = false +build_t32 = false +build_a64 = false + +targets = get_option('target') +if 'auto' in targets or 'all' in targets + if can_target_aarch64 or 'all' in targets + add_project_arguments( + '-DVIXL_INCLUDE_TARGET_A32', + '-DVIXL_INCLUDE_TARGET_T32', + '-DVIXL_INCLUDE_TARGET_A64', + language: 'cpp' + ) + build_a32 = true + build_t32 = true + build_a64 = true + else + add_project_arguments( + '-DVIXL_INCLUDE_TARGET_A32', + '-DVIXL_INCLUDE_TARGET_T32', + language: 'cpp' + ) + build_a32 = true + build_t32 = true + endif +else + if 'a32' in targets or 'aarch32' in targets + add_project_arguments( + '-DVIXL_INCLUDE_TARGET_A32', + language: 'cpp' + ) + build_a32 = true + endif + if 't32' in targets or 'aarch32' in targets + add_project_arguments( + '-DVIXL_INCLUDE_TARGET_T32', + language: 'cpp' + ) + build_t32 = true + endif + if 'a64' in targets or 'aarch64' in targets + add_project_arguments( + '-DVIXL_INCLUDE_TARGET_A64', + language: 'cpp' + ) + build_a64 = true + endif +endif + +target_sources = [] +if build_a32 or build_t32 + subdir('src'/'aarch32') +endif +if build_a64 + subdir('src'/'aarch64') +endif + +if get_option('simulator') == 'auto' + if not (host_machine.cpu_family() == 'aarch64') and can_target_aarch64 + add_project_arguments('-DVIXL_INCLUDE_SIMULATOR_AARCH64', language: 'cpp') + endif +elif get_option('simulator') == 'aarch64' + if can_target_aarch64 and build_a64 + add_project_arguments('-DVIXL_INCLUDE_SIMULATOR_AARCH64', language: 'cpp') + else + error('Building an AArch64 simulator implies that VIXL targets AArch64. Set `target` to include `aarch64` or `a64`.') + endif +endif + +allocator = get_option('code_buffer_allocator') +if (allocator == 'auto' and host_machine.system() == 'linux') or allocator == 'mmap' + add_project_arguments('-DVIXL_CODE_BUFFER_MMAP', language: 'cpp') +else + add_project_arguments('-DVIXL_CODE_BUFFER_MALLOC', language: 'cpp') +endif + +libvixl = library( + 'vixl', + 'src'/'code-buffer-vixl.cc', + 'src'/'compiler-intrinsics-vixl.cc', + 'src'/'cpu-features.cc', + 'src'/'utils-vixl.cc', + sources: target_sources, + include_directories: 'src', + version: meson.project_version(), + install: true +) + +vixl_dep = declare_dependency(link_with: libvixl, include_directories: 'src') + +if meson.version().version_compare('>=0.54.0') + meson.override_dependency('vixl', vixl_dep) +endif + +install_headers( + 'src'/'assembler-base-vixl.h', + 'src'/'code-buffer-vixl.h', + 'src'/'code-generation-scopes-vixl.h', + 'src'/'compiler-intrinsics-vixl.h', + 'src'/'cpu-features.h', + 'src'/'globals-vixl.h', + 'src'/'invalset-vixl.h', + 'src'/'macro-assembler-interface.h', + 'src'/'platform-vixl.h', + 'src'/'pool-manager-impl.h', + 'src'/'pool-manager.h', + 'src'/'utils-vixl.h', + subdir: 'vixl' +) + +import('pkgconfig').generate( + libvixl, + description: 'ARMv8 Runtime Code Generation Library', + url: 'https://github.com/Linaro/vixl' +) diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 00000000..ce13a1d8 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2021 Andrea Pappacoda +# +# SPDX-License-Identifier: BSD-3-Clause + +option( + 'target', + type: 'array', + choices: ['auto', 'all', 'aarch32', 'a32', 't32', 'aarch64', 'a64'], + value: ['auto'], + description: 'Target ISA/Architecture' +) + +option( + 'simulator', + type: 'combo', + choices: ['auto', 'aarch64', 'none'], + value: 'auto', + description: 'Simulators to include' +) + +option( + 'code_buffer_allocator', + type: 'combo', + choices: ['auto', 'malloc', 'mmap'], + value: 'auto', + description: 'Configure the allocation mechanism in the CodeBuffer' +) diff --git a/src/aarch32/meson.build b/src/aarch32/meson.build new file mode 100644 index 00000000..d1b978c0 --- /dev/null +++ b/src/aarch32/meson.build @@ -0,0 +1,31 @@ +# SPDX-FileCopyrightText: 2021 Andrea Pappacoda +# +# SPDX-License-Identifier: BSD-3-Clause + +# Need to wrap the filenames in files() otherwise this array would be treated +# as a simple array of strings, and when used in the master meson.build they +# would refer to nonexistent paths. Wrapping in files() ensures that the +# filenames will be always relative to this directory, even if referenced in +# a different one. As a general rule, when I need to refer to a file from a +# different build directory I should wrap it in files(). + +target_sources += [ + files('assembler-aarch32.cc'), + files('constants-aarch32.cc'), + files('disasm-aarch32.cc'), + files('instructions-aarch32.cc'), + files('location-aarch32.cc'), + files('macro-assembler-aarch32.cc'), + files('operands-aarch32.cc'), +] + +install_headers( + 'assembler-aarch32.h', + 'constants-aarch32.h', + 'disasm-aarch32.h', + 'instructions-aarch32.h', + 'location-aarch32.h', + 'macro-assembler-aarch32.h', + 'operands-aarch32.h', + subdir: 'vixl'/'aarch32' +) diff --git a/src/aarch64/meson.build b/src/aarch64/meson.build new file mode 100644 index 00000000..81f29c5b --- /dev/null +++ b/src/aarch64/meson.build @@ -0,0 +1,46 @@ +# SPDX-FileCopyrightText: 2021 Andrea Pappacoda +# +# SPDX-License-Identifier: BSD-3-Clause + +# Need to wrap the filenames in files() otherwise this array would be treated +# as a simple array of strings, and when used in the master meson.build they +# would refer to nonexistent paths. Wrapping in files() ensures that the +# filenames will be always relative to this directory, even if referenced in +# a different one. As a general rule, when I need to refer to a file from a +# different build directory I should wrap it in files(). + +target_sources += [ + files('assembler-aarch64.cc'), + files('assembler-sve-aarch64.cc'), + files('cpu-aarch64.cc'), + files('cpu-features-auditor-aarch64.cc'), + files('decoder-aarch64.cc'), + files('disasm-aarch64.cc'), + files('instructions-aarch64.cc'), + files('logic-aarch64.cc'), + files('macro-assembler-aarch64.cc'), + files('macro-assembler-sve-aarch64.cc'), + files('operands-aarch64.cc'), + files('pointer-auth-aarch64.cc'), + files('registers-aarch64.cc'), + files('simulator-aarch64.cc'), +] + +install_headers( + 'abi-aarch64.h', + 'assembler-aarch64.h', + 'constants-aarch64.h', + 'cpu-aarch64.h', + 'cpu-features-auditor-aarch64.h', + 'decoder-aarch64.h', + 'decoder-constants-aarch64.h', + 'decoder-visitor-map-aarch64.h', + 'disasm-aarch64.h', + 'instructions-aarch64.h', + 'macro-assembler-aarch64.h', + 'operands-aarch64.h', + 'registers-aarch64.h', + 'simulator-aarch64.h', + 'simulator-constants-aarch64.h', + subdir: 'vixl'/'aarch64' +)