• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2021-2022 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6# http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//arkcompiler/runtime_core/ark_config.gni")
15import("//build/ohos.gni")
16
17config("arkencoder_config") {
18  include_dirs = [ "$ark_root/compiler/optimizer/code_generator" ]
19  cflags_cc = [ "-DPANDA_BUILD" ]
20  if (ark_standalone_build) {
21    ldflags = [ "-lrt" ]
22  }
23}
24
25ohos_shared_library("libarkencoder") {
26  sources = [
27    "target/asm_printer.cpp",
28    "target/target.cpp",
29  ]
30  deps = []
31
32  if (current_cpu == "x86") {
33    sources += [
34      "target/x86/callconv.cpp",
35      "target/x86/encode.cpp",
36      "target/x86/regfile.cpp",
37    ]
38    include_dirs = [ "$ark_root/compiler/optimizer/code_generator/target/x86" ]
39  } else if (current_cpu == "amd64" || current_cpu == "x64" ||
40             current_cpu == "x86_64") {
41    if (!is_mingw) {
42      sources += [
43        "target/aarch64/callconv.cpp",
44        "target/aarch64/encode.cpp",
45        "target/aarch64/regfile.cpp",
46      ]
47      cflags_cc = [
48        "-DUSE_VIXL_ARM64",
49        "-DVIXL_CODE_BUFFER_MMAP",
50      ]
51
52      include_dirs =
53          [ "$ark_root/compiler/optimizer/code_generator/target/aarch64" ]
54
55      if (ark_enable_compiler_x64) {
56        sources += [
57          "target/amd64/callconv.cpp",
58          "target/amd64/encode.cpp",
59          "target/amd64/regfile.cpp",
60        ]
61        include_dirs += [
62          "$ark_third_party_root/asmjit/src",
63          "$ark_third_party_root/zydis/include",
64          "$ark_third_party_root/zydis/zycore/include",
65        ]
66        deps += [
67          "$ark_third_party_root/asmjit:libasmjit_frontend_static",
68          "$ark_third_party_root/zydis:libZydis",
69        ]
70      }
71    }
72  } else if (current_cpu == "arm") {
73    sources += [
74      "target/aarch32/callconv.cpp",
75      "target/aarch32/encode.cpp",
76      "target/aarch32/regfile.cpp",
77    ]
78    cflags_cc = [
79      "-DUSE_VIXL_ARM32",
80      "-DVIXL_CODE_BUFFER_MMAP",
81    ]
82    include_dirs =
83        [ "$ark_root/compiler/optimizer/code_generator/target/aarch32" ]
84  } else if (current_cpu == "arm64") {
85    sources += [
86      "target/aarch64/callconv.cpp",
87      "target/aarch64/encode.cpp",
88      "target/aarch64/regfile.cpp",
89    ]
90    cflags_cc = [
91      "-DUSE_VIXL_ARM64",
92      "-DVIXL_CODE_BUFFER_MMAP",
93    ]
94    include_dirs =
95        [ "$ark_root/compiler/optimizer/code_generator/target/aarch64" ]
96  }
97
98  configs = [
99    "$ark_root:ark_config",
100    "$ark_root/libpandabase:arkbase_public_config",
101    "$ark_root/compiler:arkcompiler_public_config",
102    ":arkencoder_config",
103  ]
104
105  deps += [
106    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_can_encode_builtin_inl",
107    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_graph_inl",
108    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_inst_inl",
109    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_get_intrinsics_inl",
110    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_get_intrinsics_names_inl",
111    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_intrinsic_codegen_test_inl",
112    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_intrinsics_enum_inl",
113    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_intrinsics_ir_build_inl",
114    "$ark_root/libpandabase:libarkbase",
115  ]
116
117  output_extension = "so"
118  relative_install_dir = "ark"
119  part_name = "runtime_core"
120  subsystem_name = "arkcompiler"
121}
122
123ohos_static_library("libarkencoder_frontend_static") {
124  sources = [
125    "target/asm_printer.cpp",
126    "target/target.cpp",
127  ]
128  deps = []
129
130  if (current_cpu == "x86") {
131    sources += [
132      "target/x86/callconv.cpp",
133      "target/x86/encode.cpp",
134      "target/x86/regfile.cpp",
135    ]
136    include_dirs = [ "$ark_root/compiler/optimizer/code_generator/target/x86" ]
137  } else if (current_cpu == "amd64" || current_cpu == "x64" ||
138             current_cpu == "x86_64") {
139    if (!is_mingw) {
140      sources += [
141        "target/aarch64/callconv.cpp",
142        "target/aarch64/encode.cpp",
143        "target/aarch64/regfile.cpp",
144      ]
145      cflags_cc = [
146        "-DUSE_VIXL_ARM64",
147        "-DVIXL_CODE_BUFFER_MMAP",
148      ]
149      include_dirs =
150          [ "$ark_root/compiler/optimizer/code_generator/target/aarch64" ]
151
152      if (ark_enable_compiler_x64) {
153        sources += [
154          "target/amd64/callconv.cpp",
155          "target/amd64/encode.cpp",
156          "target/amd64/regfile.cpp",
157        ]
158        include_dirs += [
159          "$ark_third_party_root/asmjit/src",
160          "$ark_third_party_root/zydis/include",
161          "$ark_third_party_root/zydis/zycore/include",
162        ]
163        deps += [
164          "$ark_third_party_root/asmjit:libasmjit_frontend_static",
165          "$ark_third_party_root/zydis:libZydis",
166        ]
167      }
168    }
169  } else if (current_cpu == "arm") {
170    sources += [
171      "target/aarch32/callconv.cpp",
172      "target/aarch32/encode.cpp",
173      "target/aarch32/regfile.cpp",
174    ]
175    cflags_cc = [
176      "-DUSE_VIXL_ARM32",
177      "-DVIXL_CODE_BUFFER_MMAP",
178    ]
179    include_dirs =
180        [ "$ark_root/compiler/optimizer/code_generator/target/aarch32" ]
181  } else if (current_cpu == "arm64") {
182    sources += [
183      "target/aarch64/callconv.cpp",
184      "target/aarch64/encode.cpp",
185      "target/aarch64/regfile.cpp",
186    ]
187    cflags_cc = [
188      "-DUSE_VIXL_ARM64",
189      "-DVIXL_CODE_BUFFER_MMAP",
190    ]
191    include_dirs =
192        [ "$ark_root/compiler/optimizer/code_generator/target/aarch64" ]
193  }
194
195  configs = [
196    "$ark_root:ark_config",
197    "$ark_root/libpandabase:arkbase_public_config",
198    "$ark_root/compiler:arkcompiler_public_config",
199    ":arkencoder_config",
200  ]
201
202  deps += [
203    "$ark_root/compiler:intrinsics_stub_inl_h",
204    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_can_encode_builtin_inl",
205    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_graph_inl",
206    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_generate_operations_intrinsic_inst_inl",
207    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_get_intrinsics_inl",
208    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_get_intrinsics_names_inl",
209    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_intrinsics_enum_inl",
210    "$ark_root/compiler:libarkcompiler_intrinsics_gen_inl_intrinsics_ir_build_inl",
211    "$ark_root/compiler:libarkcompiler_opcodes_h_arch_info_gen_h",
212    "$ark_root/libpandabase:libarkbase_frontend_static",
213  ]
214}
215