CommandFlags.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===-- CommandFlags.h - Command Line Flags Interface -----------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file contains codegen-specific flags that are shared between different
  15. // command line tools. The tools "llc" and "opt" both use this file to prevent
  16. // flag duplication.
  17. //
  18. //===----------------------------------------------------------------------===//
  19. #ifndef LLVM_CODEGEN_COMMANDFLAGS_H
  20. #define LLVM_CODEGEN_COMMANDFLAGS_H
  21. #include "llvm/ADT/FloatingPointMode.h"
  22. #include "llvm/Support/CodeGen.h"
  23. #include "llvm/Target/TargetOptions.h"
  24. #include <optional>
  25. #include <string>
  26. #include <vector>
  27. namespace llvm {
  28. class Module;
  29. class AttrBuilder;
  30. class Function;
  31. class Triple;
  32. namespace codegen {
  33. std::string getMArch();
  34. std::string getMCPU();
  35. std::vector<std::string> getMAttrs();
  36. Reloc::Model getRelocModel();
  37. std::optional<Reloc::Model> getExplicitRelocModel();
  38. ThreadModel::Model getThreadModel();
  39. CodeModel::Model getCodeModel();
  40. std::optional<CodeModel::Model> getExplicitCodeModel();
  41. llvm::ExceptionHandling getExceptionModel();
  42. std::optional<CodeGenFileType> getExplicitFileType();
  43. CodeGenFileType getFileType();
  44. FramePointerKind getFramePointerUsage();
  45. bool getEnableUnsafeFPMath();
  46. bool getEnableNoInfsFPMath();
  47. bool getEnableNoNaNsFPMath();
  48. bool getEnableNoSignedZerosFPMath();
  49. bool getEnableApproxFuncFPMath();
  50. bool getEnableNoTrappingFPMath();
  51. DenormalMode::DenormalModeKind getDenormalFPMath();
  52. DenormalMode::DenormalModeKind getDenormalFP32Math();
  53. bool getEnableHonorSignDependentRoundingFPMath();
  54. llvm::FloatABI::ABIType getFloatABIForCalls();
  55. llvm::FPOpFusion::FPOpFusionMode getFuseFPOps();
  56. SwiftAsyncFramePointerMode getSwiftAsyncFramePointer();
  57. bool getDontPlaceZerosInBSS();
  58. bool getEnableGuaranteedTailCallOpt();
  59. bool getEnableAIXExtendedAltivecABI();
  60. bool getDisableTailCalls();
  61. bool getStackSymbolOrdering();
  62. unsigned getOverrideStackAlignment();
  63. bool getStackRealign();
  64. std::string getTrapFuncName();
  65. bool getUseCtors();
  66. bool getLowerGlobalDtorsViaCxaAtExit();
  67. bool getRelaxELFRelocations();
  68. bool getDataSections();
  69. std::optional<bool> getExplicitDataSections();
  70. bool getFunctionSections();
  71. std::optional<bool> getExplicitFunctionSections();
  72. bool getIgnoreXCOFFVisibility();
  73. bool getXCOFFTracebackTable();
  74. std::string getBBSections();
  75. unsigned getTLSSize();
  76. bool getEmulatedTLS();
  77. bool getUniqueSectionNames();
  78. bool getUniqueBasicBlockSectionNames();
  79. llvm::EABI getEABIVersion();
  80. llvm::DebuggerKind getDebuggerTuningOpt();
  81. bool getEnableStackSizeSection();
  82. bool getEnableAddrsig();
  83. bool getEmitCallSiteInfo();
  84. bool getEnableMachineFunctionSplitter();
  85. bool getEnableDebugEntryValues();
  86. bool getValueTrackingVariableLocations();
  87. std::optional<bool> getExplicitValueTrackingVariableLocations();
  88. bool getForceDwarfFrameSection();
  89. bool getXRayOmitFunctionIndex();
  90. bool getDebugStrictDwarf();
  91. unsigned getAlignLoops();
  92. bool getJMCInstrument();
  93. /// Create this object with static storage to register codegen-related command
  94. /// line options.
  95. struct RegisterCodeGenFlags {
  96. RegisterCodeGenFlags();
  97. };
  98. llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options);
  99. /// Common utility function tightly tied to the options listed here. Initializes
  100. /// a TargetOptions object with CodeGen flags and returns it.
  101. /// \p TheTriple is used to determine the default value for options if
  102. /// options are not explicitly specified. If those triple dependant options
  103. /// value do not have effect for your component, a default Triple() could be
  104. /// passed in.
  105. TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple);
  106. std::string getCPUStr();
  107. std::string getFeaturesStr();
  108. std::vector<std::string> getFeatureList();
  109. void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
  110. /// Set function attributes of function \p F based on CPU, Features, and command
  111. /// line flags.
  112. void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F);
  113. /// Set function attributes of functions in Module M based on CPU,
  114. /// Features, and command line flags.
  115. void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M);
  116. /// Should value-tracking variable locations / instruction referencing be
  117. /// enabled by default for this triple?
  118. bool getDefaultValueTrackingVariableLocations(const llvm::Triple &T);
  119. } // namespace codegen
  120. } // namespace llvm
  121. #endif // LLVM_CODEGEN_COMMANDFLAGS_H
  122. #ifdef __GNUC__
  123. #pragma GCC diagnostic pop
  124. #endif