1 //===- MCTargetOptions.h - MC Target Options --------------------*- 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 #ifndef LLVM_MC_MCTARGETOPTIONS_H 10 #define LLVM_MC_MCTARGETOPTIONS_H 11 12 #include "llvm/ADT/ArrayRef.h" 13 #include "llvm/Support/CodeGen.h" 14 #include "llvm/Support/Compiler.h" 15 #include "llvm/Support/Compression.h" 16 #include <string> 17 #include <vector> 18 19 namespace llvm { 20 21 enum class EmitDwarfUnwindType { 22 Always, // Always emit dwarf unwind 23 NoCompactUnwind, // Only emit if compact unwind isn't available 24 Default, // Default behavior is based on the target 25 }; 26 27 class StringRef; 28 29 class MCTargetOptions { 30 public: 31 enum AsmInstrumentation { 32 AsmInstrumentationNone, 33 AsmInstrumentationAddress 34 }; 35 36 bool MCRelaxAll : 1; 37 bool MCNoExecStack : 1; 38 bool MCFatalWarnings : 1; 39 bool MCNoWarn : 1; 40 bool MCNoDeprecatedWarn : 1; 41 bool MCNoTypeCheck : 1; 42 bool MCSaveTempLabels : 1; 43 bool MCIncrementalLinkerCompatible : 1; 44 bool FDPIC : 1; 45 bool ShowMCEncoding : 1; 46 bool ShowMCInst : 1; 47 bool AsmVerbose : 1; 48 49 /// Preserve Comments in Assembly. 50 bool PreserveAsmComments : 1; 51 52 bool Dwarf64 : 1; 53 54 // Use CREL relocation format for ELF. 55 bool Crel = false; 56 57 bool ImplicitMapSyms = false; 58 59 // If true, prefer R_X86_64_[REX_]GOTPCRELX to R_X86_64_GOTPCREL on x86-64 60 // ELF. 61 bool X86RelaxRelocations = true; 62 63 bool X86Sse2Avx = false; 64 65 std::optional<unsigned> OutputAsmVariant; 66 67 EmitDwarfUnwindType EmitDwarfUnwind; 68 69 int DwarfVersion = 0; 70 71 enum DwarfDirectory { 72 // Force disable 73 DisableDwarfDirectory, 74 // Force enable, for assemblers that support 75 // `.file fileno directory filename' syntax 76 EnableDwarfDirectory, 77 // Default is based on the target 78 DefaultDwarfDirectory 79 }; 80 DwarfDirectory MCUseDwarfDirectory; 81 82 // Whether to compress DWARF debug sections. 83 DebugCompressionType CompressDebugSections = DebugCompressionType::None; 84 85 std::string ABIName; 86 std::string AssemblyLanguage; 87 std::string SplitDwarfFile; 88 std::string AsSecureLogFile; 89 90 // Used for codeview debug info. These will be set as compiler path and commandline arguments in LF_BUILDINFO 91 std::string Argv0; 92 std::string CommandlineArgs; 93 94 /// Additional paths to search for `.include` directives when using the 95 /// integrated assembler. 96 std::vector<std::string> IASSearchPaths; 97 98 // InstPrinter options. 99 std::vector<std::string> InstPrinterOptions; 100 101 // Whether to emit compact-unwind for non-canonical personality 102 // functions on Darwins. 103 bool EmitCompactUnwindNonCanonical : 1; 104 105 // Whether or not to use full register names on PowerPC. 106 bool PPCUseFullRegisterNames : 1; 107 108 LLVM_ABI MCTargetOptions(); 109 110 /// getABIName - If this returns a non-empty string this represents the 111 /// textual name of the ABI that we want the backend to use, e.g. o32, or 112 /// aapcs-linux. 113 LLVM_ABI StringRef getABIName() const; 114 115 /// getAssemblyLanguage - If this returns a non-empty string this represents 116 /// the textual name of the assembly language that we will use for this 117 /// target, e.g. masm. 118 LLVM_ABI StringRef getAssemblyLanguage() const; 119 }; 120 121 } // end namespace llvm 122 123 #endif // LLVM_MC_MCTARGETOPTIONS_H 124