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 17#ifndef LLVM_TARGET_TARGETRECIP_H 18#define LLVM_TARGET_TARGETRECIP_H 19 20#include "llvm/ADT/StringRef.h" 21#include <cstdint> 22#include <map> 23#include <string> 24#include <vector> 25 26namespace llvm { 27 28struct TargetRecip { 29public: 30 TargetRecip(); 31 32 /// Initialize all or part of the operations from command-line options or 33 /// a front end. 34 TargetRecip(const std::vector<std::string> &Args); 35 36 /// Set whether a particular reciprocal operation is enabled and how many 37 /// refinement steps are needed when using it. Use "all" to set enablement 38 /// and refinement steps for all operations. 39 void setDefaults(StringRef Key, bool Enable, unsigned RefSteps); 40 41 /// Return true if the reciprocal operation has been enabled by default or 42 /// from the command-line. Return false if the operation has been disabled 43 /// by default or from the command-line. 44 bool isEnabled(StringRef Key) const; 45 46 /// Return the number of iterations necessary to refine the 47 /// the result of a machine instruction for the given reciprocal operation. 48 unsigned getRefinementSteps(StringRef Key) const; 49 50 bool operator==(const TargetRecip &Other) const; 51 52private: 53 enum { 54 Uninitialized = -1 55 }; 56 57 struct RecipParams { 58 int8_t Enabled; 59 int8_t RefinementSteps; 60 61 RecipParams() : Enabled(Uninitialized), RefinementSteps(Uninitialized) {} 62 }; 63 64 std::map<StringRef, RecipParams> RecipMap; 65 typedef std::map<StringRef, RecipParams>::iterator RecipIter; 66 typedef std::map<StringRef, RecipParams>::const_iterator ConstRecipIter; 67 68 bool parseGlobalParams(const std::string &Arg); 69 void parseIndividualParams(const std::vector<std::string> &Args); 70}; 71 72} // end namespace llvm 73 74#endif // LLVM_TARGET_TARGETRECIP_H 75