1 //===-- llvm/User.h - User class definition ----------------------*- C++ -*--=//
3 // This class defines the interface that one who 'use's a Value must implement.
4 // Each instance of the Value class keeps track of what User's have handles
7 // * Instructions are the largest class of User's.
8 // * Constants may be users of other constants (think arrays and stuff)
10 //===----------------------------------------------------------------------===//
15 #include "llvm/Value.h"
17 class User : public Value {
18 User(const User &); // Do not implement
20 User(const Type *Ty, ValueTy vty, const string &name = "");
23 // if i > the number of operands, then getOperand() returns 0, and setOperand
24 // returns false. setOperand() may also return false if the operand is of
27 virtual Value *getOperand(unsigned i) = 0;
28 virtual const Value *getOperand(unsigned i) const = 0;
29 virtual bool setOperand(unsigned i, Value *Val) = 0;
31 // dropAllReferences() - This virtual function should be overridden to "let
32 // go" of all references that this user is maintaining. This allows one to
33 // 'delete' a whole class at a time, even though there may be circular
34 // references... first all references are dropped, and all use counts go to
35 // zero. Then everything is delete'd for real. Note that no operations are
36 // valid on an object that has "dropped all references", except operator
39 virtual void dropAllReferences() = 0;
41 // replaceUsesOfWith - Replaces all references to the "From" definition with
42 // references to the "To" definition. (defined in Value.cpp)
44 void replaceUsesOfWith(Value *From, Value *To);