1 //===--------------------- llvm/Target/TargetRecip.h ------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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.
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_TARGET_TARGETRECIP_H
18 #define LLVM_TARGET_TARGETRECIP_H
20 #include "llvm/ADT/StringRef.h"
31 /// Initialize all or part of the operations from command-line options or
33 TargetRecip(const std::vector<std::string> &Args);
35 /// Set whether a particular reciprocal operation is enabled and how many
36 /// refinement steps are needed when using it. Use "all" to set enablement
37 /// and refinement steps for all operations.
38 void setDefaults(StringRef Key, bool Enable, unsigned RefSteps);
40 /// Return true if the reciprocal operation has been enabled by default or
41 /// from the command-line. Return false if the operation has been disabled
42 /// by default or from the command-line.
43 bool isEnabled(StringRef Key) const;
45 /// Return the number of iterations necessary to refine the
46 /// the result of a machine instruction for the given reciprocal operation.
47 unsigned getRefinementSteps(StringRef Key) const;
49 bool operator==(const TargetRecip &Other) const;
58 int8_t RefinementSteps;
60 RecipParams() : Enabled(Uninitialized), RefinementSteps(Uninitialized) {}
63 std::map<StringRef, RecipParams> RecipMap;
64 typedef std::map<StringRef, RecipParams>::iterator RecipIter;
65 typedef std::map<StringRef, RecipParams>::const_iterator ConstRecipIter;
67 bool parseGlobalParams(const std::string &Arg);
68 void parseIndividualParams(const std::vector<std::string> &Args);
71 } // End llvm namespace