| 1 | //===-- MCTargetOptionsCommandFlags.cpp -----------------------*- C++ //-*-===// |
|---|---|
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file contains machine code-specific flags that are shared between |
| 10 | // different command line tools. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "llvm/MC/MCTargetOptionsCommandFlags.h" |
| 15 | #include "llvm/MC/MCTargetOptions.h" |
| 16 | #include "llvm/Option/LibraryOptions.h" |
| 17 | |
| 18 | using namespace llvm; |
| 19 | |
| 20 | #define OPTIONS_STRUCT_DECL |
| 21 | #include "MCToolOptions.inc" |
| 22 | |
| 23 | #define OPTIONS_STRUCT_DEFS |
| 24 | #include "MCToolOptions.inc" |
| 25 | |
| 26 | ArrayRef<const cl::LibraryOptions *> llvm::mc::getToolOptions() { |
| 27 | static constexpr opt::LibraryOptionsParser Parser( |
| 28 | std::in_place_type<MCToolOptions>); |
| 29 | static constexpr const cl::LibraryOptions *Libraries[] = {&Parser}; |
| 30 | return Libraries; |
| 31 | } |
| 32 | |
| 33 | StringRef llvm::mc::getABIName(const cl::LibraryOptionsContext &C) { |
| 34 | return C.get<MCToolOptions>().target_abi; |
| 35 | } |
| 36 | |
| 37 | MCTargetOptions |
| 38 | llvm::mc::getMCTargetOptions(const cl::LibraryOptionsContext &C) { |
| 39 | const MCToolOptions &Opts = C.get<MCToolOptions>(); |
| 40 | MCTargetOptions Options; |
| 41 | Options.LibraryOptions = &C; |
| 42 | Options.MCRelaxAll = Opts.mc_relax_all; |
| 43 | Options.MCIncrementalLinkerCompatible = Opts.incremental_linker_compatible; |
| 44 | Options.FDPIC = Opts.fdpic; |
| 45 | Options.Dwarf64 = Opts.dwarf64; |
| 46 | Options.DwarfVersion = Opts.dwarf_version; |
| 47 | Options.ShowMCInst = Opts.asm_show_inst; |
| 48 | Options.ABIName = Opts.target_abi; |
| 49 | Options.MCFatalWarnings = Opts.fatal_warnings; |
| 50 | Options.MCNoWarn = Opts.no_warn; |
| 51 | Options.MCNoDeprecatedWarn = Opts.no_deprecated_warn; |
| 52 | Options.MCNoTypeCheck = Opts.no_type_check; |
| 53 | Options.MCSaveTempLabels = Opts.save_temp_labels; |
| 54 | Options.Crel = Opts.crel; |
| 55 | Options.ImplicitMapSyms = Opts.implicit_mapsyms; |
| 56 | Options.MachORelocatableDwarf = Opts.macho_relocatable_dwarf; |
| 57 | Options.X86RelaxRelocations = Opts.x86_relax_relocations; |
| 58 | Options.X86Sse2Avx = Opts.x86_sse2avx; |
| 59 | Options.DisableIntegratedAS = Opts.no_integrated_as; |
| 60 | Options.RelocSectionSym = Opts.reloc_section_sym; |
| 61 | Options.LargeEHEncoding = Opts.large_eh_encoding; |
| 62 | Options.EmitDwarfUnwind = Opts.emit_dwarf_unwind; |
| 63 | Options.EmitCompactUnwindNonCanonical = |
| 64 | Opts.emit_compact_unwind_non_canonical; |
| 65 | Options.EmitSFrameUnwind = Opts.gsframe; |
| 66 | Options.AsSecureLogFile = Opts.as_secure_log_file; |
| 67 | |
| 68 | return Options; |
| 69 | } |
| 70 |