xref: /arkcompiler/toolchain/build/config/arm.gni (revision e509ee18)
1# Copyright (c) 2023 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
14# These are primarily relevant in current_cpu == "arm" contexts, where
15# ARM code is being compiled.  But they can also be relevant in the
16# other contexts when the code will change its behavior based on the
17# cpu it wants to generate code for.
18if (current_cpu == "arm") {
19  declare_args() {
20    # Version of the ARM processor when compiling on ARM. Ignored on non-ARM
21    # platforms.
22    arm_version = 7
23
24    # The ARM architecture. This will be a string like "armv6" or "armv7-a".
25    # An empty string means to use the default for the arm_version.
26    arm_arch = ""
27
28    # The ARM floating point hardware. This will be a string like "neon" or
29    # "vfpv3". An empty string means to use the default for the arm_version.
30    arm_fpu = ""
31
32    # The ARM floating point mode. This is either the string "hard", "soft", or
33    # "softfp". An empty string means to use the default one for the
34    # arm_version.
35    arm_float_abi = ""
36
37    # The ARM variant-specific tuning mode. This will be a string like "armv6"
38    # or "cortex-a15". An empty string means to use the default for the
39    # arm_version.
40    arm_tune = ""
41
42    # Whether to use the neon FPU instruction set or not.
43    arm_use_neon = ""
44
45    # Whether to enable optional NEON code paths.
46    arm_optionally_use_neon = false
47
48    # Thumb is a reduced instruction set available on some ARM processors that
49    # has increased code density.
50    arm_use_thumb = true
51  }
52
53  assert(arm_float_abi == "" || arm_float_abi == "hard" ||
54         arm_float_abi == "soft" || arm_float_abi == "softfp")
55
56  if (arm_use_neon == "") {
57    if (current_os == "linux") {
58      # Don't use neon as a default.
59      arm_use_neon = false
60    } else {
61      arm_use_neon = true
62    }
63  }
64
65  if (arm_version == 6) {
66    if (arm_arch == "") {
67      arm_arch = "armv6"
68    }
69    if (arm_tune != "") {
70      arm_tune = ""
71    }
72    if (arm_float_abi == "") {
73      arm_float_abi = "softfp"
74    }
75    if (arm_fpu == "") {
76      arm_fpu = "vfp"
77    }
78    arm_use_thumb = false
79    arm_use_neon = false
80  } else if (arm_version == 7) {
81    if (arm_arch == "") {
82      arm_arch = "armv7-a"
83    }
84    if (arm_tune == "") {
85      arm_tune = "generic-armv7-a"
86    }
87
88    if (arm_float_abi == "") {
89      if (current_os == "ohos" || target_os == "ohos") {
90        arm_float_abi = "softfp"
91      } else if (current_os == "linux") {
92        arm_float_abi = "softfp"
93      } else {
94        arm_float_abi = "hard"
95      }
96    }
97
98    if (arm_fpu == "") {
99      if (arm_use_neon) {
100        arm_fpu = "neon"
101      } else {
102        arm_fpu = "vfpv3-d16"
103      }
104    }
105  } else if (arm_version == 8) {
106    if (arm_arch == "") {
107      arm_arch = "armv8-a"
108    }
109    if (arm_tune == "") {
110      arm_tune = "generic-armv8-a"
111    }
112
113    if (arm_float_abi == "") {
114      if (current_os == "ohos" || target_os == "ohos") {
115        arm_float_abi = "softfp"
116      } else {
117        arm_float_abi = "hard"
118      }
119    }
120
121    if (arm_fpu == "") {
122      if (arm_use_neon) {
123        arm_fpu = "neon"
124      } else {
125        arm_fpu = "vfpv3-d16"
126      }
127    }
128  }
129} else if (current_cpu == "arm64") {
130  if (!defined(board_arch)) {
131    arm_arch = "armv8-a"
132  } else {
133    arm_arch = "$board_arch"
134  }
135  if (!defined(board_cpu)) {
136    arm_cpu = "cortex-a55"
137  } else {
138    arm_cpu = "$board_cpu"
139  }
140  if (!defined(board_fpu)) {
141    arm_fpu = "neon-fp-armv8"
142  } else {
143    arm_fpu = "$board_fpu"
144  }
145
146  # arm64 supports only "hard".
147  arm_float_abi = "hard"
148  arm_use_neon = true
149}
150