TargetRecip.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. //===--------------------- llvm/Target/TargetRecip.h ------------*- C++ -*-===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is distributed under the University of Illinois Open Source
  6. // License. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. //
  10. // This class is used to customize machine-specific reciprocal estimate code
  11. // generation in a target-independent way.
  12. // If a target does not support operations in this specification, then code
  13. // generation will default to using supported operations.
  14. //
  15. //===----------------------------------------------------------------------===//
  16. #ifndef LLVM_TARGET_TARGETRECIP_H
  17. #define LLVM_TARGET_TARGETRECIP_H
  18. #include "llvm/ADT/StringRef.h"
  19. #include <vector>
  20. #include <string>
  21. #include <map>
  22. namespace llvm {
  23. struct TargetRecip {
  24. public:
  25. TargetRecip();
  26. /// Initialize all or part of the operations from command-line options or
  27. /// a front end.
  28. TargetRecip(const std::vector<std::string> &Args);
  29. /// Set whether a particular reciprocal operation is enabled and how many
  30. /// refinement steps are needed when using it. Use "all" to set enablement
  31. /// and refinement steps for all operations.
  32. void setDefaults(const StringRef &Key, bool Enable, unsigned RefSteps);
  33. /// Return true if the reciprocal operation has been enabled by default or
  34. /// from the command-line. Return false if the operation has been disabled
  35. /// by default or from the command-line.
  36. bool isEnabled(const StringRef &Key) const;
  37. /// Return the number of iterations necessary to refine the
  38. /// the result of a machine instruction for the given reciprocal operation.
  39. unsigned getRefinementSteps(const StringRef &Key) const;
  40. bool operator==(const TargetRecip &Other) const;
  41. private:
  42. enum {
  43. Uninitialized = -1
  44. };
  45. struct RecipParams {
  46. int8_t Enabled;
  47. int8_t RefinementSteps;
  48. RecipParams() : Enabled(Uninitialized), RefinementSteps(Uninitialized) {}
  49. };
  50. std::map<StringRef, RecipParams> RecipMap;
  51. typedef std::map<StringRef, RecipParams>::iterator RecipIter;
  52. typedef std::map<StringRef, RecipParams>::const_iterator ConstRecipIter;
  53. bool parseGlobalParams(const std::string &Arg);
  54. void parseIndividualParams(const std::vector<std::string> &Args);
  55. };
  56. } // End llvm namespace
  57. #endif