diff options
Diffstat (limited to 'llvm/include/llvm/CodeGen/CommandFlags.inc')
-rw-r--r-- | llvm/include/llvm/CodeGen/CommandFlags.inc | 107 |
1 files changed, 62 insertions, 45 deletions
diff --git a/llvm/include/llvm/CodeGen/CommandFlags.inc b/llvm/include/llvm/CodeGen/CommandFlags.inc index cb69e9f61405..8739b644873d 100644 --- a/llvm/include/llvm/CodeGen/CommandFlags.inc +++ b/llvm/include/llvm/CodeGen/CommandFlags.inc @@ -102,15 +102,15 @@ static cl::opt<llvm::ExceptionHandling> ExceptionModel( clEnumValN(ExceptionHandling::Wasm, "wasm", "WebAssembly exception handling"))); -static cl::opt<TargetMachine::CodeGenFileType> FileType( - "filetype", cl::init(TargetMachine::CGFT_AssemblyFile), +static cl::opt<CodeGenFileType> FileType( + "filetype", cl::init(CGFT_AssemblyFile), cl::desc( "Choose a file type (not all types are supported by all targets):"), - cl::values(clEnumValN(TargetMachine::CGFT_AssemblyFile, "asm", + cl::values(clEnumValN(CGFT_AssemblyFile, "asm", "Emit an assembly ('.s') file"), - clEnumValN(TargetMachine::CGFT_ObjectFile, "obj", + clEnumValN(CGFT_ObjectFile, "obj", "Emit a native object ('.o') file"), - clEnumValN(TargetMachine::CGFT_Null, "null", + clEnumValN(CGFT_Null, "null", "Emit nothing, for performance testing"))); static cl::opt<llvm::FramePointer::FP> FramePointerUsage( @@ -151,7 +151,7 @@ static cl::opt<bool> "attribute not to use exceptions"), cl::init(false)); -static cl::opt<llvm::FPDenormal::DenormalMode> DenormalMode( +static cl::opt<llvm::FPDenormal::DenormalMode> DenormalFPMath( "denormal-fp-math", cl::desc("Select which denormal numbers the code is permitted to require"), cl::init(FPDenormal::IEEE), @@ -238,6 +238,10 @@ static cl::opt<bool> cl::desc("Emit functions into separate sections"), cl::init(false)); +static cl::opt<unsigned> TLSSize("tls-size", + cl::desc("Bit size of immediate TLS offsets"), + cl::init(0)); + static cl::opt<bool> EmulatedTLS("emulated-tls", cl::desc("Use emulated TLS model"), cl::init(false)); @@ -276,6 +280,11 @@ static cl::opt<bool> cl::desc("Emit debug info about parameter's entry values"), cl::init(false)); +static cl::opt<bool> + ForceDwarfFrameSection("force-dwarf-frame-section", + cl::desc("Always emit a debug frame section."), + cl::init(false)); + // Common utility function tightly tied to the options listed here. Initializes // a TargetOptions object with CodeGen flags and returns it. static TargetOptions InitTargetOptionsFromCodeGenFlags() { @@ -286,7 +295,7 @@ static TargetOptions InitTargetOptionsFromCodeGenFlags() { Options.NoNaNsFPMath = EnableNoNaNsFPMath; Options.NoSignedZerosFPMath = EnableNoSignedZerosFPMath; Options.NoTrappingFPMath = EnableNoTrappingFPMath; - Options.FPDenormalMode = DenormalMode; + Options.FPDenormalMode = DenormalFPMath; Options.HonorSignDependentRoundingFPMathOption = EnableHonorSignDependentRoundingFPMath; if (FloatABIForCalls != FloatABI::Default) @@ -300,12 +309,14 @@ static TargetOptions InitTargetOptionsFromCodeGenFlags() { Options.DataSections = DataSections; Options.FunctionSections = FunctionSections; Options.UniqueSectionNames = UniqueSectionNames; + Options.TLSSize = TLSSize; Options.EmulatedTLS = EmulatedTLS; Options.ExplicitEmulatedTLS = EmulatedTLS.getNumOccurrences() > 0; Options.ExceptionModel = ExceptionModel; Options.EmitStackSizeSection = EnableStackSizeSection; Options.EmitAddrsig = EnableAddrsig; Options.EnableDebugEntryValues = EnableDebugEntryValues; + Options.ForceDwarfFrameSection = ForceDwarfFrameSection; Options.MCOptions = InitMCTargetOptionsFromFlags(); @@ -366,46 +377,52 @@ LLVM_ATTRIBUTE_UNUSED static std::vector<std::string> getFeatureList() { return Features.getFeatures(); } +/// Set function attributes of function \p F based on CPU, Features, and command +/// line flags. +LLVM_ATTRIBUTE_UNUSED static void +setFunctionAttributes(StringRef CPU, StringRef Features, Function &F) { + auto &Ctx = F.getContext(); + AttributeList Attrs = F.getAttributes(); + AttrBuilder NewAttrs; + + if (!CPU.empty() && !F.hasFnAttribute("target-cpu")) + NewAttrs.addAttribute("target-cpu", CPU); + if (!Features.empty()) + NewAttrs.addAttribute("target-features", Features); + if (FramePointerUsage.getNumOccurrences() > 0) { + if (FramePointerUsage == llvm::FramePointer::All) + NewAttrs.addAttribute("frame-pointer", "all"); + else if (FramePointerUsage == llvm::FramePointer::NonLeaf) + NewAttrs.addAttribute("frame-pointer", "non-leaf"); + else if (FramePointerUsage == llvm::FramePointer::None) + NewAttrs.addAttribute("frame-pointer", "none"); + } + if (DisableTailCalls.getNumOccurrences() > 0) + NewAttrs.addAttribute("disable-tail-calls", + toStringRef(DisableTailCalls)); + if (StackRealign) + NewAttrs.addAttribute("stackrealign"); + + if (TrapFuncName.getNumOccurrences() > 0) + for (auto &B : F) + for (auto &I : B) + if (auto *Call = dyn_cast<CallInst>(&I)) + if (const auto *F = Call->getCalledFunction()) + if (F->getIntrinsicID() == Intrinsic::debugtrap || + F->getIntrinsicID() == Intrinsic::trap) + Call->addAttribute( + llvm::AttributeList::FunctionIndex, + Attribute::get(Ctx, "trap-func-name", TrapFuncName)); + + // Let NewAttrs override Attrs. + F.setAttributes( + Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs)); +} + /// Set function attributes of functions in Module M based on CPU, /// Features, and command line flags. LLVM_ATTRIBUTE_UNUSED static void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M) { - for (auto &F : M) { - auto &Ctx = F.getContext(); - AttributeList Attrs = F.getAttributes(); - AttrBuilder NewAttrs; - - if (!CPU.empty()) - NewAttrs.addAttribute("target-cpu", CPU); - if (!Features.empty()) - NewAttrs.addAttribute("target-features", Features); - if (FramePointerUsage.getNumOccurrences() > 0) { - if (FramePointerUsage == llvm::FramePointer::All) - NewAttrs.addAttribute("frame-pointer", "all"); - else if (FramePointerUsage == llvm::FramePointer::NonLeaf) - NewAttrs.addAttribute("frame-pointer", "non-leaf"); - else if (FramePointerUsage == llvm::FramePointer::None) - NewAttrs.addAttribute("frame-pointer", "none"); - } - if (DisableTailCalls.getNumOccurrences() > 0) - NewAttrs.addAttribute("disable-tail-calls", - toStringRef(DisableTailCalls)); - if (StackRealign) - NewAttrs.addAttribute("stackrealign"); - - if (TrapFuncName.getNumOccurrences() > 0) - for (auto &B : F) - for (auto &I : B) - if (auto *Call = dyn_cast<CallInst>(&I)) - if (const auto *F = Call->getCalledFunction()) - if (F->getIntrinsicID() == Intrinsic::debugtrap || - F->getIntrinsicID() == Intrinsic::trap) - Call->addAttribute( - llvm::AttributeList::FunctionIndex, - Attribute::get(Ctx, "trap-func-name", TrapFuncName)); - - // Let NewAttrs override Attrs. - F.setAttributes( - Attrs.addAttributes(Ctx, AttributeList::FunctionIndex, NewAttrs)); - } + for (Function &F : M) + setFunctionAttributes(CPU, Features, F); } |