CommandFlags.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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/ADT/StringExtras.h"
  23. #include "llvm/ADT/Triple.h"
  24. #include "llvm/IR/Instructions.h"
  25. #include "llvm/IR/Intrinsics.h"
  26. #include "llvm/MC/MCTargetOptionsCommandFlags.h"
  27. #include "llvm/Support/CodeGen.h"
  28. #include "llvm/Target/TargetOptions.h"
  29. #include <string>
  30. #include <vector>
  31. namespace llvm {
  32. class Module;
  33. namespace codegen {
  34. std::string getMArch();
  35. std::string getMCPU();
  36. std::vector<std::string> getMAttrs();
  37. Reloc::Model getRelocModel();
  38. Optional<Reloc::Model> getExplicitRelocModel();
  39. ThreadModel::Model getThreadModel();
  40. CodeModel::Model getCodeModel();
  41. Optional<CodeModel::Model> getExplicitCodeModel();
  42. llvm::ExceptionHandling getExceptionModel();
  43. Optional<CodeGenFileType> getExplicitFileType();
  44. CodeGenFileType getFileType();
  45. FramePointerKind getFramePointerUsage();
  46. bool getEnableUnsafeFPMath();
  47. bool getEnableNoInfsFPMath();
  48. bool getEnableNoNaNsFPMath();
  49. bool getEnableNoSignedZerosFPMath();
  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 getRelaxELFRelocations();
  67. bool getDataSections();
  68. Optional<bool> getExplicitDataSections();
  69. bool getFunctionSections();
  70. Optional<bool> getExplicitFunctionSections();
  71. bool getIgnoreXCOFFVisibility();
  72. bool getXCOFFTracebackTable();
  73. std::string getBBSections();
  74. unsigned getTLSSize();
  75. bool getEmulatedTLS();
  76. bool getUniqueSectionNames();
  77. bool getUniqueBasicBlockSectionNames();
  78. llvm::EABI getEABIVersion();
  79. llvm::DebuggerKind getDebuggerTuningOpt();
  80. bool getEnableStackSizeSection();
  81. bool getEnableAddrsig();
  82. bool getEmitCallSiteInfo();
  83. bool getEnableMachineFunctionSplitter();
  84. bool getEnableDebugEntryValues();
  85. bool getValueTrackingVariableLocations();
  86. Optional<bool> getExplicitValueTrackingVariableLocations();
  87. bool getForceDwarfFrameSection();
  88. bool getXRayOmitFunctionIndex();
  89. bool getDebugStrictDwarf();
  90. unsigned getAlignLoops();
  91. /// Create this object with static storage to register codegen-related command
  92. /// line options.
  93. struct RegisterCodeGenFlags {
  94. RegisterCodeGenFlags();
  95. };
  96. llvm::BasicBlockSection getBBSectionsMode(llvm::TargetOptions &Options);
  97. /// Common utility function tightly tied to the options listed here. Initializes
  98. /// a TargetOptions object with CodeGen flags and returns it.
  99. /// \p TheTriple is used to determine the default value for options if
  100. /// options are not explicitly specified. If those triple dependant options
  101. /// value do not have effect for your component, a default Triple() could be
  102. /// passed in.
  103. TargetOptions InitTargetOptionsFromCodeGenFlags(const llvm::Triple &TheTriple);
  104. std::string getCPUStr();
  105. std::string getFeaturesStr();
  106. std::vector<std::string> getFeatureList();
  107. void renderBoolStringAttr(AttrBuilder &B, StringRef Name, bool Val);
  108. /// Set function attributes of function \p F based on CPU, Features, and command
  109. /// line flags.
  110. void setFunctionAttributes(StringRef CPU, StringRef Features, Function &F);
  111. /// Set function attributes of functions in Module M based on CPU,
  112. /// Features, and command line flags.
  113. void setFunctionAttributes(StringRef CPU, StringRef Features, Module &M);
  114. /// Should value-tracking variable locations / instruction referencing be
  115. /// enabled by default for this triple?
  116. bool getDefaultValueTrackingVariableLocations(const llvm::Triple &T);
  117. } // namespace codegen
  118. } // namespace llvm
  119. #endif // LLVM_CODEGEN_COMMANDFLAGS_H
  120. #ifdef __GNUC__
  121. #pragma GCC diagnostic pop
  122. #endif