Lines Matching +full:1 +full:- +full:based

1 //===--- RISCV.cpp - RISC-V Helpers for Tools -------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
45 for (const std::string &Str : (*ISAInfo)->toFeatures(/*AddAllExtension=*/true,
68 << A->getSpelling() << Mcpu;
86 StringRef CPU = A->getValue();
98 // Handle features corresponding to "-ffixed-X" options
100 Features.push_back("+reserve-x1");
102 Features.push_back("+reserve-x2");
104 Features.push_back("+reserve-x3");
106 Features.push_back("+reserve-x4");
108 Features.push_back("+reserve-x5");
110 Features.push_back("+reserve-x6");
112 Features.push_back("+reserve-x7");
114 Features.push_back("+reserve-x8");
116 Features.push_back("+reserve-x9");
118 Features.push_back("+reserve-x10");
120 Features.push_back("+reserve-x11");
122 Features.push_back("+reserve-x12");
124 Features.push_back("+reserve-x13");
126 Features.push_back("+reserve-x14");
128 Features.push_back("+reserve-x15");
130 Features.push_back("+reserve-x16");
132 Features.push_back("+reserve-x17");
134 Features.push_back("+reserve-x18");
136 Features.push_back("+reserve-x19");
138 Features.push_back("+reserve-x20");
140 Features.push_back("+reserve-x21");
142 Features.push_back("+reserve-x22");
144 Features.push_back("+reserve-x23");
146 Features.push_back("+reserve-x24");
148 Features.push_back("+reserve-x25");
150 Features.push_back("+reserve-x26");
152 Features.push_back("+reserve-x27");
154 Features.push_back("+reserve-x28");
156 Features.push_back("+reserve-x29");
158 Features.push_back("+reserve-x30");
160 Features.push_back("+reserve-x31");
163 // -mno-relax is default, unless -mrelax is specified.
166 // -gsplit-dwarf -mrelax requires DW_AT_high_pc/DW_AT_ranges/... indexing
171 << A->getAsString(Args);
173 Features.push_back("-relax");
176 // If -mstrict-align, -mno-strict-align, -mscalar-strict-align, or
177 // -mno-scalar-strict-align is passed, use it. Otherwise, the
178 // unaligned-scalar-mem is enabled if the CPU supports it or the target is
183 if (A->getOption().matches(options::OPT_mno_strict_align) ||
184 A->getOption().matches(options::OPT_mno_scalar_strict_align)) {
185 Features.push_back("+unaligned-scalar-mem");
187 Features.push_back("-unaligned-scalar-mem");
190 Features.push_back("+unaligned-scalar-mem");
193 // If -mstrict-align, -mno-strict-align, -mvector-strict-align, or
194 // -mno-vector-strict-align is passed, use it. Otherwise, the
195 // unaligned-vector-mem is enabled if the CPU supports it or the target is
200 if (A->getOption().matches(options::OPT_mno_strict_align) ||
201 A->getOption().matches(options::OPT_mno_vector_strict_align)) {
202 Features.push_back("+unaligned-vector-mem");
204 Features.push_back("-unaligned-vector-mem");
207 Features.push_back("+unaligned-vector-mem");
219 // GCC's logic around choosing a default `-mabi=` is complex. If GCC is not
220 // configured using `--with-abi=`, then the logic for the default choice is
221 // defined in config.gcc. This function is based on the logic in GCC 9.2.0.
224 // 1. Explicit choices using `--with-abi=`
225 // 2. A default based on `--with-arch=`, if provided
226 // 3. A default based on the target triple's arch
230 // Clang does not have `--with-arch=` or `--with-abi=`, so we use `-march=`
231 // and `-mabi=` respectively instead.
235 // 1. Explicit choices using `-mabi=`
236 // 2. A default based on the architecture as determined by getRISCVArch
237 // 3. Choose a default based on the triple
239 // 1. If `-mabi=` is specified, use it.
241 return A->getValue();
243 // 2. Choose a default based on the target architecture.
245 // rv32g | rv32*d -> ilp32d
246 // rv32e -> ilp32e
247 // rv32* -> ilp32
248 // rv64g | rv64*d -> lp64d
249 // rv64e -> lp64e
250 // rv64* -> lp64
257 return (*ParseResult)->computeDefaultABI();
259 // 3. Choose a default based on the triple
262 // - On `riscv{XLEN}-unknown-elf` we use the integer calling convention only.
263 // - On all other OSs we use the double floating point calling convention.
281 // GCC's logic around choosing a default `-march=` is complex. If GCC is not
282 // configured using `--with-arch=`, then the logic for the default choice is
283 // defined in config.gcc. This function is based on the logic in GCC 9.2.0. We
284 // deviate from GCC's default on additional `-mcpu` option (GCC does not
285 // support `-mcpu`) and baremetal targets (UnknownOS) where neither `-march`
286 // nor `-mabi` is specified.
289 // 1. Explicit choices using `--with-arch=`
290 // 2. A default based on `--with-abi=`, if provided
291 // 3. A default based on the target triple's arch
295 // Clang does not have `--with-arch=` or `--with-abi=`, so we use `-march=`
296 // and `-mabi=` respectively instead.
299 // 1. Explicit choices using `-march=`
300 // 2. Based on `-mcpu` if the target CPU has a default ISA string
301 // 3. A default based on `-mabi`, if provided
302 // 4. A default based on the target triple's arch
307 // 1. If `-march=` is specified, use it.
309 return A->getValue();
311 // 2. Get march (isa string) based on `-mcpu=`
313 StringRef CPU = A->getValue();
323 Features.push_back(((F.second ? "+" : "-") + F.first()).str());
327 return (*ParseResult)->toString();
338 // 3. Choose a default based on `-mabi=`
340 // ilp32e -> rv32e
341 // lp64e -> rv64e
342 // ilp32 | ilp32f | ilp32d -> rv32imafdc
343 // lp64 | lp64f | lp64d -> rv64imafdc
345 StringRef MABI = A->getValue();
361 // 4. Choose a default based on the triple
364 // - On `riscv{XLEN}-unknown-elf` we default to `rv{XLEN}imac`
365 // - On all other OSs we use `rv{XLEN}imafdc` (equivalent to `rv{XLEN}gc`)
384 // If we have -mcpu, use that.
386 CPU = A->getValue();
395 return Triple.isRISCV64() ? "generic-rv64" : "generic-rv32";