1 //===-- CommandFlags.h - Command Line Flags Interface -----------*- 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 codegen-specific flags that are shared between different 10 // command line tools. The tools "llc" and "opt" both use this file to prevent 11 // flag duplication. 12 // 13 //===----------------------------------------------------------------------===// 14 15 #ifndef LLVM_CODEGEN_COMMANDFLAGS_H 16 #define LLVM_CODEGEN_COMMANDFLAGS_H 17 18 #include "llvm/ADT/FloatingPointMode.h" 19 #include "llvm/ADT/StringExtras.h" 20 #include "llvm/ADT/Triple.h" 21 #include "llvm/IR/Instructions.h" 22 #include "llvm/IR/Intrinsics.h" 23 #include "llvm/MC/MCTargetOptionsCommandFlags.h" 24 #include "llvm/Support/CodeGen.h" 25 #include "llvm/Target/TargetOptions.h" 26 #include <string> 27 #include <vector> 28 29 namespace llvm { 30 31 class Module; 32 33 namespace codegen { 34 35 std::string getMArch(); 36 37 std::string getMCPU(); 38 39 std::vector<std::string> getMAttrs(); 40 41 Reloc::Model getRelocModel(); 42 Optional<Reloc::Model> getExplicitRelocModel(); 43 44 ThreadModel::Model getThreadModel(); 45 46 CodeModel::Model getCodeModel(); 47 Optional<CodeModel::Model> getExplicitCodeModel(); 48 49 llvm::ExceptionHandling getExceptionModel(); 50 51 CodeGenFileType getFileType(); 52 Optional<CodeGenFileType> getExplicitFileType(); 53 54 CodeGenFileType getFileType(); 55 56 FramePointerKind getFramePointerUsage(); 57 58 bool getEnableUnsafeFPMath(); 59 60 bool getEnableNoInfsFPMath(); 61 62 bool getEnableNoNaNsFPMath(); 63 64 bool getEnableNoSignedZerosFPMath(); 65 66 bool getEnableNoTrappingFPMath(); 67 68 DenormalMode::DenormalModeKind getDenormalFPMath(); 69 DenormalMode::DenormalModeKind getDenormalFP32Math(); 70 71 bool getEnableHonorSignDependentRoundingFPMath(); 72 73 llvm::FloatABI::ABIType getFloatABIForCalls(); 74 75 llvm::FPOpFusion::FPOpFusionMode getFuseFPOps(); 76 77 bool getDontPlaceZerosInBSS(); 78 79 bool getEnableGuaranteedTailCallOpt(); 80 81 bool getEnableAIXExtendedAltivecABI(); 82 83 bool getDisableTailCalls(); 84 85 bool getStackSymbolOrdering(); 86 87 unsigned getOverrideStackAlignment(); 88 89 bool getStackRealign(); 90 91 std::string getTrapFuncName(); 92 93 bool getUseCtors(); 94 95 bool getRelaxELFRelocations(); 96 97 bool getDataSections(); 98 Optional<bool> getExplicitDataSections(); 99 100 bool getFunctionSections(); 101 Optional<bool> getExplicitFunctionSections(); 102 103 bool getIgnoreXCOFFVisibility(); 104 105 bool getXCOFFTracebackTable(); 106 107 std::string getBBSections(); 108 109 unsigned getTLSSize(); 110 111 bool getEmulatedTLS(); 112 113 bool getUniqueSectionNames(); 114 115 bool getUniqueBasicBlockSectionNames(); 116 117 llvm::EABI getEABIVersion(); 118 119 llvm::DebuggerKind getDebuggerTuningOpt(); 120 121 bool getEnableStackSizeSection(); 122 123 bool getEnableAddrsig(); 124 125 bool getEmitCallSiteInfo(); 126 127 bool getEnableMachineFunctionSplitter(); 128 129 bool getEnableDebugEntryValues(); 130 131 bool getPseudoProbeForProfiling(); 132 133 bool getValueTrackingVariableLocations(); 134 135 bool getForceDwarfFrameSection(); 136 137 bool getXRayOmitFunctionIndex(); 138 139 bool getDebugStrictDwarf(); 140 141 /// Create this object with static storage to register codegen-related command 142 /// line options. 143 struct RegisterCodeGenFlags { 144 RegisterCodeGenFlags(); 145 }; 146 147 llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options); 148 149 /// Common utility function tightly tied to the options listed here. Initializes 150 /// a TargetOptions object with CodeGen flags and returns it. 151 /// \p TheTriple is used to determine the default value for options if 152 /// options are not explicitly specified. If those triple dependant options 153 /// value do not have effect for your component, a default Triple() could be 154 /// passed in. 155 TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple); 156 157 std::string getCPUStr(); 158 159 std::string getFeaturesStr(); 160 161 std::vector<std::string> getFeatureList(); 162 163 void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val); 164 165 /// Set function attributes of function \p F based on CPU, Features, and command 166 /// line flags. 167 void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F); 168 169 /// Set function attributes of functions in Module M based on CPU, 170 /// Features, and command line flags. 171 void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M); 172 } // namespace codegen 173 } // namespace llvm 174 175 #endif // LLVM_CODEGEN_COMMANDFLAGS_H 176