2002-08-30 20:27:15 +00:00
|
|
|
//===- llvm/Analysis/ValueNumbering.h - Value #'ing Interface ---*- C++ -*-===//
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-21 20:19:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-08-30 20:27:15 +00:00
|
|
|
//
|
|
|
|
// This file defines the abstract ValueNumbering interface, which is used as the
|
|
|
|
// common interface used by all clients of value numbering information, and
|
|
|
|
// implemented by all value numbering implementations.
|
|
|
|
//
|
|
|
|
// Implementations of this interface must implement the various virtual methods,
|
|
|
|
// which automatically provides functionality for the entire suite of client
|
|
|
|
// APIs.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_ANALYSIS_VALUE_NUMBERING_H
|
|
|
|
#define LLVM_ANALYSIS_VALUE_NUMBERING_H
|
|
|
|
|
|
|
|
#include <vector>
|
2003-12-11 05:05:56 +00:00
|
|
|
#include "llvm/Pass.h"
|
2003-11-11 22:41:34 +00:00
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
2002-08-30 20:27:15 +00:00
|
|
|
class Value;
|
2004-04-10 22:32:47 +00:00
|
|
|
class Instruction;
|
2002-08-30 20:27:15 +00:00
|
|
|
|
|
|
|
struct ValueNumbering {
|
2004-04-10 22:32:09 +00:00
|
|
|
virtual ~ValueNumbering(); // We want to be subclassed
|
2002-08-30 20:27:15 +00:00
|
|
|
|
|
|
|
/// getEqualNumberNodes - Return nodes with the same value number as the
|
|
|
|
/// specified Value. This fills in the argument vector with any equal values.
|
|
|
|
///
|
|
|
|
virtual void getEqualNumberNodes(Value *V1,
|
|
|
|
std::vector<Value*> &RetVals) const = 0;
|
|
|
|
|
2004-04-10 22:32:09 +00:00
|
|
|
///===-------------------------------------------------------------------===//
|
|
|
|
/// Interfaces to update value numbering analysis information as the client
|
2004-05-23 21:11:17 +00:00
|
|
|
/// changes the program.
|
2004-04-10 22:32:09 +00:00
|
|
|
///
|
|
|
|
|
2004-05-23 21:11:17 +00:00
|
|
|
/// deleteValue - This method should be called whenever an LLVM Value is
|
|
|
|
/// deleted from the program, for example when an instruction is found to be
|
|
|
|
/// redundant and is eliminated.
|
|
|
|
///
|
|
|
|
virtual void deleteValue(Value *V) {}
|
|
|
|
|
|
|
|
/// copyValue - This method should be used whenever a preexisting value in the
|
|
|
|
/// program is copied or cloned, introducing a new value. Note that analysis
|
|
|
|
/// implementations should tolerate clients that use this method to introduce
|
|
|
|
/// the same value multiple times: if the analysis already knows about a
|
|
|
|
/// value, it should ignore the request.
|
|
|
|
///
|
|
|
|
virtual void copyValue(Value *From, Value *To) {}
|
|
|
|
|
|
|
|
/// replaceWithNewValue - This method is the obvious combination of the two
|
|
|
|
/// above, and it provided as a helper to simplify client code.
|
|
|
|
///
|
|
|
|
void replaceWithNewValue(Value *Old, Value *New) {
|
|
|
|
copyValue(Old, New);
|
|
|
|
deleteValue(Old);
|
|
|
|
}
|
2002-08-30 20:27:15 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2006-06-07 22:00:26 +00:00
|
|
|
// Force any file including this header to get the implementation as well
|
|
|
|
FORCE_DEFINING_FILE_TO_BE_LINKED(BasicValueNumbering)
|
|
|
|
|
2002-08-30 20:27:15 +00:00
|
|
|
#endif
|