CommandFlags.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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. #ifndef LLVM_CODEGEN_COMMANDFLAGS_H
  15. #define LLVM_CODEGEN_COMMANDFLAGS_H
  16. #include "llvm/ADT/FloatingPointMode.h"
  17. #include "llvm/ADT/StringExtras.h"
  18. #include "llvm/ADT/Triple.h"
  19. #include "llvm/IR/Instructions.h"
  20. #include "llvm/IR/Intrinsics.h"
  21. #include "llvm/MC/MCTargetOptionsCommandFlags.h"
  22. #include "llvm/Support/CodeGen.h"
  23. #include "llvm/Target/TargetOptions.h"
  24. #include <string>
  25. #include <vector>
  26. namespace llvm {
  27. class Module;
  28. namespace codegen {
  29. std::string getMArch();
  30. std::string getMCPU();
  31. std::vector<std::string> getMAttrs();
  32. Reloc::Model getRelocModel();
  33. Optional<Reloc::Model> getExplicitRelocModel();
  34. ThreadModel::Model getThreadModel();
  35. CodeModel::Model getCodeModel();
  36. Optional<CodeModel::Model> getExplicitCodeModel();
  37. llvm::ExceptionHandling getExceptionModel();
  38. CodeGenFileType getFileType();
  39. Optional<CodeGenFileType> getExplicitFileType();
  40. CodeGenFileType getFileType();
  41. FramePointerKind getFramePointerUsage();
  42. bool getEnableUnsafeFPMath();
  43. bool getEnableNoInfsFPMath();
  44. bool getEnableNoNaNsFPMath();
  45. bool getEnableNoSignedZerosFPMath();
  46. bool getEnableNoTrappingFPMath();
  47. DenormalMode::DenormalModeKind getDenormalFPMath();
  48. DenormalMode::DenormalModeKind getDenormalFP32Math();
  49. bool getEnableHonorSignDependentRoundingFPMath();
  50. llvm::FloatABI::ABIType getFloatABIForCalls();
  51. llvm::FPOpFusion::FPOpFusionMode getFuseFPOps();
  52. bool getDontPlaceZerosInBSS();
  53. bool getEnableGuaranteedTailCallOpt();
  54. bool getEnableAIXExtendedAltivecABI();
  55. bool getDisableTailCalls();
  56. bool getStackSymbolOrdering();
  57. unsigned getOverrideStackAlignment();
  58. bool getStackRealign();
  59. std::string getTrapFuncName();
  60. bool getUseCtors();
  61. bool getRelaxELFRelocations();
  62. bool getDataSections();
  63. Optional<bool> getExplicitDataSections();
  64. bool getFunctionSections();
  65. Optional<bool> getExplicitFunctionSections();
  66. bool getIgnoreXCOFFVisibility();
  67. bool getXCOFFTracebackTable();
  68. std::string getBBSections();
  69. unsigned getTLSSize();
  70. bool getEmulatedTLS();
  71. bool getUniqueSectionNames();
  72. bool getUniqueBasicBlockSectionNames();
  73. llvm::EABI getEABIVersion();
  74. llvm::DebuggerKind getDebuggerTuningOpt();
  75. bool getEnableStackSizeSection();
  76. bool getEnableAddrsig();
  77. bool getEmitCallSiteInfo();
  78. bool getEnableMachineFunctionSplitter();
  79. bool getEnableDebugEntryValues();
  80. bool getPseudoProbeForProfiling();
  81. bool getValueTrackingVariableLocations();
  82. bool getForceDwarfFrameSection();
  83. bool getXRayOmitFunctionIndex();
  84. bool getDebugStrictDwarf();
  85. /// Create this object with static storage to register codegen-related command
  86. /// line options.
  87. struct RegisterCodeGenFlags {
  88. RegisterCodeGenFlags();
  89. };
  90. llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options);
  91. /// Common utility function tightly tied to the options listed here. Initializes
  92. /// a TargetOptions object with CodeGen flags and returns it.
  93. /// \p TheTriple is used to determine the default value for options if
  94. /// options are not explicitly specified. If those triple dependant options
  95. /// value do not have effect for your component, a default Triple() could be
  96. /// passed in.
  97. TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple);
  98. std::string getCPUStr();
  99. std::string getFeaturesStr();
  100. std::vector<std::string> getFeatureList();
  101. void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
  102. /// Set function attributes of function \p F based on CPU, Features, and command
  103. /// line flags.
  104. void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F);
  105. /// Set function attributes of functions in Module M based on CPU,
  106. /// Features, and command line flags.
  107. void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M);
  108. } // namespace codegen
  109. } // namespace llvm
  110. #endif // LLVM_CODEGEN_COMMANDFLAGS_H