mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-11-03 14:21:30 +00:00 
			
		
		
		
	The first try (r238051) to land this was reverted due to ExecutionEngine build failure; that was hopefully addressed by r238788. The second try (r238842) to land this was reverted due to BUILD_SHARED_LIBS failure; that was hopefully addressed by r238953. This patch adds a TargetRecip class for processing many recip codegen possibilities. The class is intended to handle both command-line options to llc as well as options passed in from a front-end such as clang with the -mrecip option. The x86 backend is updated to use the new functionality. Only -mcpu=btver2 with -ffast-math should see a functional change from this patch. All other x86 CPUs continue to *not* use reciprocal estimates by default with -ffast-math. Differential Revision: http://reviews.llvm.org/D8982 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239001 91177308-0d34-0410-b5e6-96231b3b80d8
		
			
				
	
	
		
			74 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
//===--------------------- llvm/Target/TargetRecip.h ------------*- C++ -*-===//
 | 
						|
//
 | 
						|
//                     The LLVM Compiler Infrastructure
 | 
						|
//
 | 
						|
// This file is distributed under the University of Illinois Open Source
 | 
						|
// License. See LICENSE.TXT for details.
 | 
						|
//
 | 
						|
//===----------------------------------------------------------------------===//
 | 
						|
//
 | 
						|
// This class is used to customize machine-specific reciprocal estimate code
 | 
						|
// generation in a target-independent way.
 | 
						|
// If a target does not support operations in this specification, then code
 | 
						|
// generation will default to using supported operations.
 | 
						|
//
 | 
						|
//===----------------------------------------------------------------------===//
 | 
						|
 | 
						|
#ifndef LLVM_TARGET_TARGETRECIP_H
 | 
						|
#define LLVM_TARGET_TARGETRECIP_H
 | 
						|
 | 
						|
#include "llvm/ADT/StringRef.h"
 | 
						|
#include <vector>
 | 
						|
#include <string>
 | 
						|
#include <map>
 | 
						|
 | 
						|
namespace llvm {
 | 
						|
 | 
						|
struct TargetRecip {
 | 
						|
public:
 | 
						|
  TargetRecip();
 | 
						|
 | 
						|
  /// Initialize all or part of the operations from command-line options or
 | 
						|
  /// a front end.
 | 
						|
  TargetRecip(const std::vector<std::string> &Args);
 | 
						|
  
 | 
						|
  /// Set whether a particular reciprocal operation is enabled and how many
 | 
						|
  /// refinement steps are needed when using it. Use "all" to set enablement
 | 
						|
  /// and refinement steps for all operations.
 | 
						|
  void setDefaults(const StringRef &Key, bool Enable, unsigned RefSteps);
 | 
						|
 | 
						|
  /// Return true if the reciprocal operation has been enabled by default or
 | 
						|
  /// from the command-line. Return false if the operation has been disabled
 | 
						|
  /// by default or from the command-line.
 | 
						|
  bool isEnabled(const StringRef &Key) const;
 | 
						|
 | 
						|
  /// Return the number of iterations necessary to refine the
 | 
						|
  /// the result of a machine instruction for the given reciprocal operation.
 | 
						|
  unsigned getRefinementSteps(const StringRef &Key) const;
 | 
						|
 | 
						|
  bool operator==(const TargetRecip &Other) const;
 | 
						|
 | 
						|
private:
 | 
						|
  enum {
 | 
						|
    Uninitialized = -1
 | 
						|
  };
 | 
						|
  
 | 
						|
  struct RecipParams {
 | 
						|
    int8_t Enabled;
 | 
						|
    int8_t RefinementSteps;
 | 
						|
    
 | 
						|
    RecipParams() : Enabled(Uninitialized), RefinementSteps(Uninitialized) {}
 | 
						|
  };
 | 
						|
  
 | 
						|
  std::map<StringRef, RecipParams> RecipMap;
 | 
						|
  typedef std::map<StringRef, RecipParams>::iterator RecipIter;
 | 
						|
  typedef std::map<StringRef, RecipParams>::const_iterator ConstRecipIter;
 | 
						|
 | 
						|
  bool parseGlobalParams(const std::string &Arg);
 | 
						|
  void parseIndividualParams(const std::vector<std::string> &Args);
 | 
						|
};
 | 
						|
 | 
						|
} // End llvm namespace
 | 
						|
 | 
						|
#endif
 |