Rename ConstPoolVal -> Constant

Rename ConstPool*   -> Constant*
Rename ConstPoolVals.h -> ConstantVals.h

llvm-svn: 1407
This commit is contained in:
Chris Lattner 2001-12-03 22:26:30 +00:00
parent bca18d7d96
commit 3462ae3ad7
72 changed files with 915 additions and 927 deletions

View File

@ -12,10 +12,10 @@
#include "llvm/Method.h"
#include "llvm/Instruction.h"
#include <iterator>
class ConstPoolVal;
class Constant;
class constant_iterator
: public std::forward_iterator<const ConstPoolVal, ptrdiff_t> {
: public std::forward_iterator<const Constant, ptrdiff_t> {
Method::inst_const_iterator InstI; // Method instruction iterator
unsigned OpIdx; // Operand index
@ -24,7 +24,7 @@ class constant_iterator
inline bool isAtConstant() const {
assert(!InstI.atEnd() && OpIdx < InstI->getNumOperands() &&
"isAtConstant called with invalid arguments!");
return isa<ConstPoolVal>(InstI->getOperand(OpIdx));
return isa<Constant>(InstI->getOperand(OpIdx));
}
public:
@ -45,7 +45,7 @@ public:
inline pointer operator*() const {
assert(isAtConstant() && "Dereferenced an iterator at the end!");
return cast<ConstPoolVal>(InstI->getOperand(OpIdx));
return cast<Constant>(InstI->getOperand(OpIdx));
}
inline pointer operator->() const { return operator*(); }

View File

@ -13,7 +13,7 @@
#include <assert.h>
class Type;
class Value;
class ConstPoolInt;
class ConstantInt;
namespace analysis {
@ -35,16 +35,16 @@ struct ExprType {
ScaledLinear, // Expr is scaled linear exp, Value is Scale*Var+Offset
} ExprTy;
const ConstPoolInt *Offset; // Offset of expr, or null if 0
Value *Var; // Var referenced, if Linear or above (null if 0)
const ConstPoolInt *Scale; // Scale of var if ScaledLinear expr (null if 1)
const ConstantInt *Offset; // Offset of expr, or null if 0
Value *Var; // Var referenced, if Linear or above (null if 0)
const ConstantInt *Scale; // Scale of var if ScaledLinear expr (null if 1)
inline ExprType(const ConstPoolInt *CPV = 0) {
inline ExprType(const ConstantInt *CPV = 0) {
Offset = CPV; Var = 0; Scale = 0;
ExprTy = Constant;
}
ExprType(Value *Val); // Create a linear or constant expression
ExprType(const ConstPoolInt *scale, Value *var, const ConstPoolInt *offset);
ExprType(const ConstantInt *scale, Value *var, const ConstantInt *offset);
// If this expression has an intrinsic type, return it. If it is zero, return
// the specified type.

View File

@ -73,11 +73,11 @@ public:
inline bool isTemporary() const { return getNodeType() == TemporaryNode; }
// Accessors for different node types...
inline ConstPoolVal *getConstant() {
return cast<ConstPoolVal>(getValue());
inline Constant *getConstant() {
return cast<Constant>(getValue());
}
inline const ConstPoolVal *getConstant() const {
return cast<const ConstPoolVal>(getValue());
inline const Constant *getConstant() const {
return cast<const Constant>(getValue());
}
inline BasicBlock *getBasicBlock() {
return cast<BasicBlock>(getValue());
@ -230,10 +230,10 @@ InstTreeNode<Payload>::InstTreeNode(InstForest<Payload> &IF, Value *V,
getTreeData().first.first = V; // Save tree node
if (!isa<Instruction>(V)) {
assert((isa<ConstPoolVal>(V) || isa<BasicBlock>(V) ||
assert((isa<Constant>(V) || isa<BasicBlock>(V) ||
isa<MethodArgument>(V) || isa<GlobalVariable>(V)) &&
"Unrecognized value type for InstForest Partition!");
if (isa<ConstPoolVal>(V))
if (isa<Constant>(V))
getTreeData().first.second = ConstNode;
else if (isa<BasicBlock>(V))
getTreeData().first.second = BasicBlockNode;

View File

@ -16,7 +16,6 @@ class Module;
class Method;
class BasicBlock;
class Instruction;
class ConstPoolVal;
class MethodType;
class MethodArgument;

View File

@ -53,7 +53,7 @@ public:
inline CachedWriter &operator<<(const Instruction *X) {
return *this << (const Value*)X;
}
inline CachedWriter &operator<<(const ConstPoolVal *X) {
inline CachedWriter &operator<<(const Constant *X) {
return *this << (const Value*)X;
}
inline CachedWriter &operator<<(const Type *X) {

View File

@ -35,7 +35,7 @@ void WriteToAssembly(const GlobalVariable *G, ostream &o);
void WriteToAssembly(const Method *Method, ostream &o);
void WriteToAssembly(const BasicBlock *BB, ostream &o);
void WriteToAssembly(const Instruction *In, ostream &o);
void WriteToAssembly(const ConstPoolVal *V, ostream &o);
void WriteToAssembly(const Constant *V, ostream &o);
// WriteTypeSymbolic - This attempts to write the specified type as a symbolic
// type, iff there is an entry in the modules symbol table for the specified
@ -86,7 +86,7 @@ inline ostream &operator<<(ostream &o, const Instruction *I) {
WriteToAssembly(I, o); return o;
}
inline ostream &operator<<(ostream &o, const ConstPoolVal *I) {
inline ostream &operator<<(ostream &o, const Constant *I) {
WriteToAssembly(I, o); return o;
}
@ -99,7 +99,7 @@ inline ostream &operator<<(ostream &o, const Type *T) {
inline ostream &operator<<(ostream &o, const Value *I) {
switch (I->getValueType()) {
case Value::TypeVal: return o << cast<const Type>(I);
case Value::ConstantVal: WriteToAssembly(cast<ConstPoolVal>(I) , o); break;
case Value::ConstantVal: WriteToAssembly(cast<Constant>(I) , o); break;
case Value::MethodArgumentVal: return o << I->getType() << " "<< I->getName();
case Value::InstructionVal:WriteToAssembly(cast<Instruction>(I) , o); break;
case Value::BasicBlockVal: WriteToAssembly(cast<BasicBlock>(I) , o); break;

View File

@ -115,12 +115,12 @@ public:
return V->getValueType() == Value::BasicBlockVal;
}
// hasConstantPoolReferences() - This predicate is true if there is a
// hasConstantReferences() - This predicate is true if there is a
// reference to this basic block in the constant pool for this method. For
// example, if a block is reached through a switch table, that table resides
// in the constant pool, and the basic block is reference from it.
//
bool hasConstantPoolReferences() const;
bool hasConstantReferences() const;
// dropAllReferences() - This function causes all the subinstructions to "let
// go" of all references that they are maintaining. This allows one to
@ -165,7 +165,7 @@ public:
public:
typedef PredIterator<_Ptr,_USE_iterator> _Self;
inline void advancePastConstPool() {
inline void advancePastConstants() {
// TODO: This is bad
// Loop to ignore constant pool references
while (It != BB->use_end() && !isa<TerminatorInst>(*It))
@ -173,7 +173,7 @@ public:
}
inline PredIterator(_Ptr *bb) : BB(bb), It(bb->use_begin()) {
advancePastConstPool();
advancePastConstants();
}
inline PredIterator(_Ptr *bb, bool) : BB(bb), It(bb->use_end()) {}
@ -186,7 +186,7 @@ public:
inline pointer *operator->() const { return &(operator*()); }
inline _Self& operator++() { // Preincrement
++It; advancePastConstPool();
++It; advancePastConstants();
return *this;
}

View File

@ -30,7 +30,7 @@
#include <hash_map>
#include <hash_set>
class ConstPoolVal;
class Constant;
class BasicBlock;
class Method;
class InstrTreeNode;
@ -205,11 +205,11 @@ protected:
class ConstantNode : public InstrTreeNode {
public:
ConstantNode(ConstPoolVal *constVal)
ConstantNode(Constant *constVal)
: InstrTreeNode(NTConstNode, (Value*)constVal) {
opLabel = ConstantNodeOp;
}
ConstPoolVal *getConstVal() const { return (ConstPoolVal*) val;}
Constant *getConstVal() const { return (Constant*) val;}
protected:
virtual void dumpNode(int indent) const;
};

View File

@ -19,7 +19,6 @@ class InstrForest;
class MachineInstr;
class InstructionNode;
class TmpInstruction;
class ConstPoolVal;
class TargetMachine;

View File

@ -21,7 +21,7 @@ class InstrForest;
class MachineInstr;
class InstructionNode;
class TmpInstruction;
class ConstPoolVal;
class Constant;
class TargetMachine;
//************************ Exported Functions ******************************/
@ -54,7 +54,7 @@ int64_t GetConstantValueAsSignedInt (const Value *V,
//---------------------------------------------------------------------------
Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
vector<ConstPoolVal*>& chainIdxVec);
vector<Constant*>& chainIdxVec);
//------------------------------------------------------------------------

View File

@ -529,7 +529,7 @@ private:
unsigned currentOptionalArgsSize;
unsigned maxOptionalArgsSize;
unsigned currentTmpValuesSize;
hash_set<const ConstPoolVal*> constantsForConstPool;
hash_set<const Constant*> constantsForConstPool;
hash_map<const Value*, int> offsets;
// hash_map<const Value*, int> offsetsFromSP;
@ -572,7 +572,7 @@ public:
inline unsigned getMaxOptionalArgsSize() const { return maxOptionalArgsSize;}
inline unsigned getCurrentOptionalArgsSize() const
{ return currentOptionalArgsSize;}
inline const hash_set<const ConstPoolVal*>&
inline const hash_set<const Constant*>&
getConstantPoolValues() const {return constantsForConstPool;}
//
@ -580,7 +580,7 @@ public:
//
void initializeFrameLayout (const TargetMachine& target);
void addToConstantPool (const ConstPoolVal* constVal)
void addToConstantPool (const Constant* constVal)
{ constantsForConstPool.insert(constVal); }
inline void markAsLeafMethod() { compiledAsLeaf = true; }

View File

@ -5,10 +5,10 @@
//
// Unfortunately we can't overload operators on pointer types (like this:)
//
// inline bool operator==(const ConstPoolVal *V1, const ConstPoolVal *V2)
// inline bool operator==(const Constant *V1, const Constant *V2)
//
// so we must make due with references, even though it leads to some butt ugly
// looking code downstream. *sigh* (ex: ConstPoolVal *Result = *V1 + *v2; )
// looking code downstream. *sigh* (ex: Constant *Result = *V1 + *v2; )
//
//===----------------------------------------------------------------------===//
//
@ -33,7 +33,7 @@
#ifndef LLVM_OPT_CONSTANTHANDLING_H
#define LLVM_OPT_CONSTANTHANDLING_H
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Instruction.h"
#include "llvm/Type.h"
class PointerType;
@ -44,15 +44,15 @@ namespace opt {
// Implement == and != directly...
//===----------------------------------------------------------------------===//
inline ConstPoolBool *operator==(const ConstPoolVal &V1,
const ConstPoolVal &V2) {
inline ConstantBool *operator==(const Constant &V1,
const Constant &V2) {
assert(V1.getType() == V2.getType() && "Constant types must be identical!");
return ConstPoolBool::get(&V1 == &V2);
return ConstantBool::get(&V1 == &V2);
}
inline ConstPoolBool *operator!=(const ConstPoolVal &V1,
const ConstPoolVal &V2) {
return ConstPoolBool::get(&V1 != &V2);
inline ConstantBool *operator!=(const Constant &V1,
const Constant &V2) {
return ConstantBool::get(&V1 != &V2);
}
//===----------------------------------------------------------------------===//
@ -66,35 +66,35 @@ public:
static AnnotationID AID; // AnnotationID for this class
// Unary Operators...
virtual ConstPoolVal *op_not(const ConstPoolVal *V) const = 0;
virtual Constant *op_not(const Constant *V) const = 0;
// Binary Operators...
virtual ConstPoolVal *add(const ConstPoolVal *V1,
const ConstPoolVal *V2) const = 0;
virtual ConstPoolVal *sub(const ConstPoolVal *V1,
const ConstPoolVal *V2) const = 0;
virtual ConstPoolVal *mul(const ConstPoolVal *V1,
const ConstPoolVal *V2) const = 0;
virtual Constant *add(const Constant *V1,
const Constant *V2) const = 0;
virtual Constant *sub(const Constant *V1,
const Constant *V2) const = 0;
virtual Constant *mul(const Constant *V1,
const Constant *V2) const = 0;
virtual ConstPoolBool *lessthan(const ConstPoolVal *V1,
const ConstPoolVal *V2) const = 0;
virtual ConstantBool *lessthan(const Constant *V1,
const Constant *V2) const = 0;
// Casting operators. ick
virtual ConstPoolBool *castToBool (const ConstPoolVal *V) const = 0;
virtual ConstPoolSInt *castToSByte (const ConstPoolVal *V) const = 0;
virtual ConstPoolUInt *castToUByte (const ConstPoolVal *V) const = 0;
virtual ConstPoolSInt *castToShort (const ConstPoolVal *V) const = 0;
virtual ConstPoolUInt *castToUShort(const ConstPoolVal *V) const = 0;
virtual ConstPoolSInt *castToInt (const ConstPoolVal *V) const = 0;
virtual ConstPoolUInt *castToUInt (const ConstPoolVal *V) const = 0;
virtual ConstPoolSInt *castToLong (const ConstPoolVal *V) const = 0;
virtual ConstPoolUInt *castToULong (const ConstPoolVal *V) const = 0;
virtual ConstPoolFP *castToFloat (const ConstPoolVal *V) const = 0;
virtual ConstPoolFP *castToDouble(const ConstPoolVal *V) const = 0;
virtual ConstPoolPointer *castToPointer(const ConstPoolVal *V,
const PointerType *Ty) const = 0;
virtual ConstantBool *castToBool (const Constant *V) const = 0;
virtual ConstantSInt *castToSByte (const Constant *V) const = 0;
virtual ConstantUInt *castToUByte (const Constant *V) const = 0;
virtual ConstantSInt *castToShort (const Constant *V) const = 0;
virtual ConstantUInt *castToUShort(const Constant *V) const = 0;
virtual ConstantSInt *castToInt (const Constant *V) const = 0;
virtual ConstantUInt *castToUInt (const Constant *V) const = 0;
virtual ConstantSInt *castToLong (const Constant *V) const = 0;
virtual ConstantUInt *castToULong (const Constant *V) const = 0;
virtual ConstantFP *castToFloat (const Constant *V) const = 0;
virtual ConstantFP *castToDouble(const Constant *V) const = 0;
virtual ConstantPointer *castToPointer(const Constant *V,
const PointerType *Ty) const = 0;
inline ConstPoolVal *castTo(const ConstPoolVal *V, const Type *Ty) const {
inline Constant *castTo(const Constant *V, const Type *Ty) const {
switch (Ty->getPrimitiveID()) {
case Type::BoolTyID: return castToBool(V);
case Type::UByteTyID: return castToUByte(V);
@ -116,7 +116,7 @@ public:
// we just want to make sure to hit the cache instead of doing it indirectly,
// if possible...
//
static inline ConstRules *get(const ConstPoolVal &V) {
static inline ConstRules *get(const Constant &V) {
return (ConstRules*)V.getType()->getOrCreateAnnotation(AID);
}
private :
@ -127,29 +127,29 @@ private :
};
inline ConstPoolVal *operator!(const ConstPoolVal &V) {
inline Constant *operator!(const Constant &V) {
return ConstRules::get(V)->op_not(&V);
}
inline ConstPoolVal *operator+(const ConstPoolVal &V1, const ConstPoolVal &V2) {
inline Constant *operator+(const Constant &V1, const Constant &V2) {
assert(V1.getType() == V2.getType() && "Constant types must be identical!");
return ConstRules::get(V1)->add(&V1, &V2);
}
inline ConstPoolVal *operator-(const ConstPoolVal &V1, const ConstPoolVal &V2) {
inline Constant *operator-(const Constant &V1, const Constant &V2) {
assert(V1.getType() == V2.getType() && "Constant types must be identical!");
return ConstRules::get(V1)->sub(&V1, &V2);
}
inline ConstPoolVal *operator*(const ConstPoolVal &V1, const ConstPoolVal &V2) {
inline Constant *operator*(const Constant &V1, const Constant &V2) {
assert(V1.getType() == V2.getType() && "Constant types must be identical!");
return ConstRules::get(V1)->mul(&V1, &V2);
}
inline ConstPoolBool *operator<(const ConstPoolVal &V1,
const ConstPoolVal &V2) {
inline ConstantBool *operator<(const Constant &V1,
const Constant &V2) {
assert(V1.getType() == V2.getType() && "Constant types must be identical!");
return ConstRules::get(V1)->lessthan(&V1, &V2);
}
@ -159,18 +159,18 @@ inline ConstPoolBool *operator<(const ConstPoolVal &V1,
// Implement 'derived' operators based on what we already have...
//===----------------------------------------------------------------------===//
inline ConstPoolBool *operator>(const ConstPoolVal &V1,
const ConstPoolVal &V2) {
inline ConstantBool *operator>(const Constant &V1,
const Constant &V2) {
return V2 < V1;
}
inline ConstPoolBool *operator>=(const ConstPoolVal &V1,
const ConstPoolVal &V2) {
inline ConstantBool *operator>=(const Constant &V1,
const Constant &V2) {
return (V1 < V2)->inverted(); // !(V1 < V2)
}
inline ConstPoolBool *operator<=(const ConstPoolVal &V1,
const ConstPoolVal &V2) {
inline ConstantBool *operator<=(const Constant &V1,
const Constant &V2) {
return (V1 > V2)->inverted(); // !(V1 > V2)
}
@ -179,13 +179,13 @@ inline ConstPoolBool *operator<=(const ConstPoolVal &V1,
// Implement higher level instruction folding type instructions
//===----------------------------------------------------------------------===//
inline ConstPoolVal *ConstantFoldCastInstruction(const ConstPoolVal *V,
const Type *DestTy) {
inline Constant *ConstantFoldCastInstruction(const Constant *V,
const Type *DestTy) {
return ConstRules::get(*V)->castTo(V, DestTy);
}
inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
const ConstPoolVal *V) {
inline Constant *ConstantFoldUnaryInstruction(unsigned Opcode,
const Constant *V) {
switch (Opcode) {
case Instruction::Not: return !*V;
// TODO: Handle get element ptr instruction here in the future? GEP null?
@ -193,9 +193,9 @@ inline ConstPoolVal *ConstantFoldUnaryInstruction(unsigned Opcode,
return 0;
}
inline ConstPoolVal *ConstantFoldBinaryInstruction(unsigned Opcode,
const ConstPoolVal *V1,
const ConstPoolVal *V2) {
inline Constant *ConstantFoldBinaryInstruction(unsigned Opcode,
const Constant *V1,
const Constant *V2) {
switch (Opcode) {
case Instruction::Add: return *V1 + *V2;
case Instruction::Sub: return *V1 - *V2;

View File

@ -1,6 +1,6 @@
//===-- llvm/ConstPoolVals.h - Constant Value nodes --------------*- C++ -*--=//
//===-- llvm/ConstantVals.h - Constant Value nodes ---------------*- C++ -*--=//
//
// This file contains the declarations for the ConstPoolVal class and all of
// This file contains the declarations for the Constant class and all of
// its subclasses, which represent the different type of constant pool values
//
//===----------------------------------------------------------------------===//
@ -16,13 +16,13 @@ class StructType;
class PointerType;
//===----------------------------------------------------------------------===//
// ConstPoolVal Class
// Constant Class
//===----------------------------------------------------------------------===//
class ConstPoolVal : public User {
class Constant : public User {
protected:
inline ConstPoolVal(const Type *Ty) : User(Ty, Value::ConstantVal) {}
~ConstPoolVal() {}
inline Constant(const Type *Ty) : User(Ty, Value::ConstantVal) {}
~Constant() {}
// destroyConstant - Called if some element of this constant is no longer
// valid. At this point only other constants may be on the use_list for this
@ -41,14 +41,14 @@ public:
virtual string getStrValue() const = 0;
// Static constructor to get a '0' constant of arbitrary type...
static ConstPoolVal *getNullConstant(const Type *Ty);
static Constant *getNullConstant(const Type *Ty);
// isNullValue - Return true if this is the value that would be returned by
// getNullConstant.
virtual bool isNullValue() const = 0;
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolVal *) { return true; }
static inline bool classof(const Constant *) { return true; }
static inline bool classof(const Value *V) {
return V->getValueType() == Value::ConstantVal;
}
@ -61,22 +61,22 @@ public:
//===----------------------------------------------------------------------===//
//===---------------------------------------------------------------------------
// ConstPoolBool - Boolean Values
// ConstantBool - Boolean Values
//
class ConstPoolBool : public ConstPoolVal {
class ConstantBool : public Constant {
bool Val;
ConstPoolBool(const ConstPoolBool &); // DO NOT IMPLEMENT
ConstPoolBool(bool V);
~ConstPoolBool() {}
ConstantBool(const ConstantBool &); // DO NOT IMPLEMENT
ConstantBool(bool V);
~ConstantBool() {}
public:
static ConstPoolBool *True, *False; // The True & False values
static ConstantBool *True, *False; // The True & False values
// Factory objects - Return objects of the specified value
static ConstPoolBool *get(bool Value) { return Value ? True : False; }
static ConstPoolBool *get(const Type *Ty, bool Value) { return get(Value); }
static ConstantBool *get(bool Value) { return Value ? True : False; }
static ConstantBool *get(const Type *Ty, bool Value) { return get(Value); }
// inverted - Return the opposite value of the current value.
inline ConstPoolBool *inverted() const { return (this==True) ? False : True; }
inline ConstantBool *inverted() const { return (this==True) ? False : True; }
virtual string getStrValue() const;
inline bool getValue() const { return Val; }
@ -86,29 +86,29 @@ public:
virtual bool isNullValue() const { return this == False; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolBool *) { return true; }
static bool classof(const ConstPoolVal *CPV) {
static inline bool classof(const ConstantBool *) { return true; }
static bool classof(const Constant *CPV) {
return (CPV == True) | (CPV == False);
}
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
//===---------------------------------------------------------------------------
// ConstPoolInt - Superclass of ConstPoolSInt & ConstPoolUInt, to make dealing
// ConstantInt - Superclass of ConstantSInt & ConstantUInt, to make dealing
// with integral constants easier.
//
class ConstPoolInt : public ConstPoolVal {
class ConstantInt : public Constant {
protected:
union {
int64_t Signed;
uint64_t Unsigned;
} Val;
ConstPoolInt(const ConstPoolInt &); // DO NOT IMPLEMENT
ConstPoolInt(const Type *Ty, uint64_t V);
~ConstPoolInt() {}
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
ConstantInt(const Type *Ty, uint64_t V);
~ConstantInt() {}
public:
// equalsInt - Provide a helper method that can be used to determine if the
// constant contained within is equal to a constant. This only works for very
@ -120,34 +120,34 @@ public:
return Val.Unsigned == V;
}
// ConstPoolInt::get static method: return a constant pool int with the
// ConstantInt::get static method: return a constant pool int with the
// specified value. as above, we work only with very small values here.
//
static ConstPoolInt *get(const Type *Ty, unsigned char V);
static ConstantInt *get(const Type *Ty, unsigned char V);
// isNullValue - Return true if this is the value that would be returned by
// getNullConstant.
virtual bool isNullValue() const { return Val.Unsigned == 0; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolInt *) { return true; }
static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
static inline bool classof(const ConstantInt *) { return true; }
static bool classof(const Constant *CPV); // defined in CPV.cpp
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
//===---------------------------------------------------------------------------
// ConstPoolSInt - Signed Integer Values [sbyte, short, int, long]
// ConstantSInt - Signed Integer Values [sbyte, short, int, long]
//
class ConstPoolSInt : public ConstPoolInt {
ConstPoolSInt(const ConstPoolSInt &); // DO NOT IMPLEMENT
class ConstantSInt : public ConstantInt {
ConstantSInt(const ConstantSInt &); // DO NOT IMPLEMENT
protected:
ConstPoolSInt(const Type *Ty, int64_t V);
~ConstPoolSInt() {}
ConstantSInt(const Type *Ty, int64_t V);
~ConstantSInt() {}
public:
static ConstPoolSInt *get(const Type *Ty, int64_t V);
static ConstantSInt *get(const Type *Ty, int64_t V);
virtual string getStrValue() const;
@ -155,23 +155,23 @@ public:
inline int64_t getValue() const { return Val.Signed; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolSInt *) { return true; }
static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
static inline bool classof(const ConstantSInt *) { return true; }
static bool classof(const Constant *CPV); // defined in CPV.cpp
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
//===---------------------------------------------------------------------------
// ConstPoolUInt - Unsigned Integer Values [ubyte, ushort, uint, ulong]
// ConstantUInt - Unsigned Integer Values [ubyte, ushort, uint, ulong]
//
class ConstPoolUInt : public ConstPoolInt {
ConstPoolUInt(const ConstPoolUInt &); // DO NOT IMPLEMENT
class ConstantUInt : public ConstantInt {
ConstantUInt(const ConstantUInt &); // DO NOT IMPLEMENT
protected:
ConstPoolUInt(const Type *Ty, uint64_t V);
~ConstPoolUInt() {}
ConstantUInt(const Type *Ty, uint64_t V);
~ConstantUInt() {}
public:
static ConstPoolUInt *get(const Type *Ty, uint64_t V);
static ConstantUInt *get(const Type *Ty, uint64_t V);
virtual string getStrValue() const;
@ -179,25 +179,25 @@ public:
inline uint64_t getValue() const { return Val.Unsigned; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolUInt *) { return true; }
static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
static inline bool classof(const ConstantUInt *) { return true; }
static bool classof(const Constant *CPV); // defined in CPV.cpp
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
//===---------------------------------------------------------------------------
// ConstPoolFP - Floating Point Values [float, double]
// ConstantFP - Floating Point Values [float, double]
//
class ConstPoolFP : public ConstPoolVal {
class ConstantFP : public Constant {
double Val;
ConstPoolFP(const ConstPoolFP &); // DO NOT IMPLEMENT
ConstantFP(const ConstantFP &); // DO NOT IMPLEMENT
protected:
ConstPoolFP(const Type *Ty, double V);
~ConstPoolFP() {}
ConstantFP(const Type *Ty, double V);
~ConstantFP() {}
public:
static ConstPoolFP *get(const Type *Ty, double V);
static ConstantFP *get(const Type *Ty, double V);
virtual string getStrValue() const;
@ -209,27 +209,27 @@ public:
virtual bool isNullValue() const { return Val == 0; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolFP *) { return true; }
static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
static inline bool classof(const ConstantFP *) { return true; }
static bool classof(const Constant *CPV); // defined in CPV.cpp
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
//===---------------------------------------------------------------------------
// ConstPoolArray - Constant Array Declarations
// ConstantArray - Constant Array Declarations
//
class ConstPoolArray : public ConstPoolVal {
ConstPoolArray(const ConstPoolArray &); // DO NOT IMPLEMENT
class ConstantArray : public Constant {
ConstantArray(const ConstantArray &); // DO NOT IMPLEMENT
protected:
ConstPoolArray(const ArrayType *T, const vector<ConstPoolVal*> &Val);
~ConstPoolArray() {}
ConstantArray(const ArrayType *T, const vector<Constant*> &Val);
~ConstantArray() {}
virtual void destroyConstant();
public:
static ConstPoolArray *get(const ArrayType *T, const vector<ConstPoolVal*> &);
static ConstPoolArray *get(const string &Initializer);
static ConstantArray *get(const ArrayType *T, const vector<Constant*> &);
static ConstantArray *get(const string &Initializer);
virtual string getStrValue() const;
@ -240,27 +240,27 @@ public:
virtual bool isNullValue() const { return false; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolArray *) { return true; }
static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
static inline bool classof(const ConstantArray *) { return true; }
static bool classof(const Constant *CPV); // defined in CPV.cpp
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
//===---------------------------------------------------------------------------
// ConstPoolStruct - Constant Struct Declarations
// ConstantStruct - Constant Struct Declarations
//
class ConstPoolStruct : public ConstPoolVal {
ConstPoolStruct(const ConstPoolStruct &); // DO NOT IMPLEMENT
class ConstantStruct : public Constant {
ConstantStruct(const ConstantStruct &); // DO NOT IMPLEMENT
protected:
ConstPoolStruct(const StructType *T, const vector<ConstPoolVal*> &Val);
~ConstPoolStruct() {}
ConstantStruct(const StructType *T, const vector<Constant*> &Val);
~ConstantStruct() {}
virtual void destroyConstant();
public:
static ConstPoolStruct *get(const StructType *T,
const vector<ConstPoolVal*> &V);
static ConstantStruct *get(const StructType *T,
const vector<Constant*> &V);
virtual string getStrValue() const;
@ -271,25 +271,25 @@ public:
virtual bool isNullValue() const { return false; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolStruct *) { return true; }
static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
static inline bool classof(const ConstantStruct *) { return true; }
static bool classof(const Constant *CPV); // defined in CPV.cpp
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
//===---------------------------------------------------------------------------
// ConstPoolPointer - Constant Pointer Declarations
// ConstantPointer - Constant Pointer Declarations
//
// The ConstPoolPointer class represents a null pointer of a specific type. For
// a more specific/useful instance, a subclass of ConstPoolPointer should be
// The ConstantPointer class represents a null pointer of a specific type. For
// a more specific/useful instance, a subclass of ConstantPointer should be
// used.
//
class ConstPoolPointer : public ConstPoolVal {
ConstPoolPointer(const ConstPoolPointer &); // DO NOT IMPLEMENT
class ConstantPointer : public Constant {
ConstantPointer(const ConstantPointer &); // DO NOT IMPLEMENT
protected:
inline ConstPoolPointer(const PointerType *T) : ConstPoolVal((const Type*)T){}
~ConstPoolPointer() {}
inline ConstantPointer(const PointerType *T) : Constant((const Type*)T){}
~ConstantPointer() {}
public:
virtual string getStrValue() const = 0;
@ -298,57 +298,57 @@ public:
virtual bool isNullValue() const { return false; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolPointer *) { return true; }
static bool classof(const ConstPoolVal *CPV); // defined in CPV.cpp
static inline bool classof(const ConstantPointer *) { return true; }
static bool classof(const Constant *CPV); // defined in CPV.cpp
static inline bool classof(const Value *V) {
return isa<ConstPoolVal>(V) && classof(cast<ConstPoolVal>(V));
return isa<Constant>(V) && classof(cast<Constant>(V));
}
};
// ConstPoolPointerNull - a constant pointer value that points to null
// ConstantPointerNull - a constant pointer value that points to null
//
class ConstPoolPointerNull : public ConstPoolPointer {
ConstPoolPointerNull(const ConstPoolPointerNull &); // DO NOT IMPLEMENT
class ConstantPointerNull : public ConstantPointer {
ConstantPointerNull(const ConstantPointerNull &); // DO NOT IMPLEMENT
protected:
inline ConstPoolPointerNull(const PointerType *T) : ConstPoolPointer(T) {}
inline ~ConstPoolPointerNull() {}
inline ConstantPointerNull(const PointerType *T) : ConstantPointer(T) {}
inline ~ConstantPointerNull() {}
public:
virtual string getStrValue() const;
static ConstPoolPointerNull *get(const PointerType *T);
static ConstantPointerNull *get(const PointerType *T);
// isNullValue - Return true if this is the value that would be returned by
// getNullConstant.
virtual bool isNullValue() const { return true; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolPointerNull *) { return true; }
static inline bool classof(const ConstPoolPointer *P) {
static inline bool classof(const ConstantPointerNull *) { return true; }
static inline bool classof(const ConstantPointer *P) {
return P->getNumOperands() == 0;
}
static inline bool classof(const ConstPoolVal *CPV) {
return isa<ConstPoolPointer>(CPV) && classof(cast<ConstPoolPointer>(CPV));
static inline bool classof(const Constant *CPV) {
return isa<ConstantPointer>(CPV) && classof(cast<ConstantPointer>(CPV));
}
static inline bool classof(const Value *V) {
return isa<ConstPoolPointer>(V) && classof(cast<ConstPoolPointer>(V));
return isa<ConstantPointer>(V) && classof(cast<ConstantPointer>(V));
}
};
// ConstPoolPointerRef - a constant pointer value that is initialized to
// ConstantPointerRef - a constant pointer value that is initialized to
// point to a global value, which lies at a constant, fixed address.
//
class ConstPoolPointerRef : public ConstPoolPointer {
class ConstantPointerRef : public ConstantPointer {
friend class Module; // Modules maintain these references
ConstPoolPointerRef(const ConstPoolPointerRef &); // DNI!
ConstantPointerRef(const ConstantPointerRef &); // DNI!
protected:
ConstPoolPointerRef(GlobalValue *GV);
~ConstPoolPointerRef() {}
ConstantPointerRef(GlobalValue *GV);
~ConstantPointerRef() {}
virtual void destroyConstant() { destroyConstantImpl(); }
public:
static ConstPoolPointerRef *get(GlobalValue *GV);
static ConstantPointerRef *get(GlobalValue *GV);
virtual string getStrValue() const;
@ -360,15 +360,15 @@ public:
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const ConstPoolPointerRef *) { return true; }
static inline bool classof(const ConstPoolPointer *CPV) {
static inline bool classof(const ConstantPointerRef *) { return true; }
static inline bool classof(const ConstantPointer *CPV) {
return CPV->getNumOperands() == 1;
}
static inline bool classof(const ConstPoolVal *CPV) {
return isa<ConstPoolPointer>(CPV) && classof(cast<ConstPoolPointer>(CPV));
static inline bool classof(const Constant *CPV) {
return isa<ConstantPointer>(CPV) && classof(cast<ConstantPointer>(CPV));
}
static inline bool classof(const Value *V) {
return isa<ConstPoolPointer>(V) && classof(cast<ConstPoolPointer>(V));
return isa<ConstantPointer>(V) && classof(cast<ConstantPointer>(V));
}
// WARNING: Only to be used by Bytecode & Assembly Parsers! USER CODE SHOULD

View File

@ -15,17 +15,17 @@
#include "llvm/GlobalValue.h"
class Module;
class ConstPoolVal;
class Constant;
class PointerType;
class GlobalVariable : public GlobalValue {
friend class ValueHolder<GlobalVariable, Module, Module>;
void setParent(Module *parent) { Parent = parent; }
bool Constant; // Is this a global constant?
bool isConstantGlobal; // Is this a global constant?
public:
GlobalVariable(const Type *Ty, bool isConstant, bool isInternal,
ConstPoolVal *Initializer = 0, const string &Name = "");
Constant *Initializer = 0, const string &Name = "");
~GlobalVariable() {}
// Specialize setName to handle symbol table majik...
@ -35,15 +35,15 @@ public:
// an initializer is specified.
//
inline bool hasInitializer() const { return !Operands.empty(); }
inline ConstPoolVal *getInitializer() const {
inline Constant *getInitializer() const {
assert(hasInitializer() && "GV doesn't have initializer!");
return (ConstPoolVal*)Operands[0].get();
return (Constant*)Operands[0].get();
}
inline ConstPoolVal *getInitializer() {
inline Constant *getInitializer() {
assert(hasInitializer() && "GV doesn't have initializer!");
return (ConstPoolVal*)Operands[0].get();
return (Constant*)Operands[0].get();
}
inline void setInitializer(ConstPoolVal *CPV) {
inline void setInitializer(Constant *CPV) {
if (CPV == 0) {
if (hasInitializer()) Operands.pop_back();
} else {
@ -57,7 +57,7 @@ public:
// runtime execution of the program. Assigning a value into the constant
// leads to undefined behavior.
//
inline bool isConstant() const { return Constant; }
inline bool isConstant() const { return isConstantGlobal; }
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const GlobalVariable *) { return true; }

View File

@ -17,8 +17,8 @@
#include "llvm/ValueHolder.h"
class Method;
class GlobalVariable;
class GlobalValueRefMap; // Used by ConstPoolVals.cpp
class ConstPoolPointerRef;
class GlobalValueRefMap; // Used by ConstantVals.cpp
class ConstantPointerRef;
class Module : public Value, public SymTabValue {
public:
@ -44,10 +44,10 @@ private:
GlobalValueRefMap *GVRefMap;
// Accessor for the underlying GlobalValRefMap... only through the
// ConstPoolPointerRef class...
friend class ConstPoolPointerRef;
void mutateConstPoolPointerRef(GlobalValue *OldGV, GlobalValue *NewGV);
ConstPoolPointerRef *getConstPoolPointerRef(GlobalValue *GV);
// ConstantPointerRef class...
friend class ConstantPointerRef;
void mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV);
ConstantPointerRef *getConstantPointerRef(GlobalValue *GV);
public:
Module();

View File

@ -21,7 +21,7 @@
#ifndef NDEBUG // Only for assertions
#include "llvm/Type.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#endif
class Type;
@ -64,7 +64,7 @@ public:
// (constant/type)s.
//
inline void insert(const string &Name, Value *V) {
assert((isa<Type>(V) || isa<ConstPoolVal>(V)) &&
assert((isa<Type>(V) || isa<Constant>(V)) &&
"Can only insert types and constants here!");
insertEntry(Name, V->getType(), V);
}

View File

@ -240,7 +240,7 @@ public:
//-------------------------------------------------------------------------
// Create an instruction sequence to put the constant `val' into
// the virtual register `dest'. `val' may be a ConstPoolVal or a
// the virtual register `dest'. `val' may be a Constant or a
// GlobalValue, viz., the constant address of a global variable or function.
// The generated instructions are returned in `minstrVec'.
// Any temp. registers (TmpInstruction) created are returned in `tempVec'.

View File

@ -61,7 +61,7 @@ public:
// stores that include the implicit form of getelementptr.
//
unsigned getIndexedOffset(const Type *Ty,
const vector<ConstPoolVal*> &Indices) const;
const vector<Constant*> &Indices) const;
inline const StructLayout *getStructLayout(const StructType *Ty) const {
return (const StructLayout*)((const Type*)Ty)->getOrCreateAnnotation(AID);

View File

@ -240,7 +240,7 @@ public:
//-------------------------------------------------------------------------
// Create an instruction sequence to put the constant `val' into
// the virtual register `dest'. `val' may be a ConstPoolVal or a
// the virtual register `dest'. `val' may be a Constant or a
// GlobalValue, viz., the constant address of a global variable or function.
// The generated instructions are returned in `minstrVec'.
// Any temp. registers (TmpInstruction) created are returned in `tempVec'.

View File

@ -19,12 +19,12 @@
#include "llvm/Pass.h"
#include <map>
class ConstPoolVal;
class Constant;
class GlobalVariable;
class ConstantMerge : public Pass {
protected:
map<ConstPoolVal*, GlobalVariable*> Constants;
map<Constant*, GlobalVariable*> Constants;
unsigned LastConstantSeen;
public:
inline ConstantMerge() : LastConstantSeen(0) {}

View File

@ -18,7 +18,7 @@
class User;
class Type;
class ConstPoolVal;
class Constant;
class MethodArgument;
class Instruction;
class BasicBlock;
@ -39,7 +39,7 @@ class Value : public Annotable, // Values are annotable
public:
enum ValueTy {
TypeVal, // This is an instance of Type
ConstantVal, // This is an instance of ConstPoolVal
ConstantVal, // This is an instance of Constant
MethodArgumentVal, // This is an instance of MethodArgument
InstructionVal, // This is an instance of Instruction
BasicBlockVal, // This is an instance of BasicBlock
@ -250,10 +250,10 @@ template <> inline bool isa<Type, const Value*>(const Value *Val) {
template <> inline bool isa<Type, Value*>(Value *Val) {
return Val->getValueType() == Value::TypeVal;
}
template <> inline bool isa<ConstPoolVal, const Value*>(const Value *Val) {
template <> inline bool isa<Constant, const Value*>(const Value *Val) {
return Val->getValueType() == Value::ConstantVal;
}
template <> inline bool isa<ConstPoolVal, Value*>(Value *Val) {
template <> inline bool isa<Constant, Value*>(Value *Val) {
return Val->getValueType() == Value::ConstantVal;
}
template <> inline bool isa<MethodArgument, const Value*>(const Value *Val) {

View File

@ -177,7 +177,7 @@ public:
const vector<Value*> &Indices,
bool AllowStructLeaf = false);
const vector<ConstPoolVal*> getIndicesBROKEN() const;
const vector<Constant*> getIndicesBROKEN() const;
inline op_iterator idx_begin() {

View File

@ -12,7 +12,7 @@
#include "llvm/InstrTypes.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
//===----------------------------------------------------------------------===//
// Classes to represent Basic Block "Terminator" instructions
@ -151,7 +151,7 @@ public:
return cast<BasicBlock>(Operands[1]);
}
void dest_push_back(ConstPoolVal *OnVal, BasicBlock *Dest);
void dest_push_back(Constant *OnVal, BasicBlock *Dest);
virtual const char *getOpcodeName() const { return "switch"; }
@ -170,13 +170,13 @@ public:
// getSuccessorValue - Return the value associated with the specified
// successor. WARNING: This does not gracefully accept idx's out of range!
inline const ConstPoolVal *getSuccessorValue(unsigned idx) const {
inline const Constant *getSuccessorValue(unsigned idx) const {
assert(idx < getNumSuccessors() && "Successor # out of range!");
return cast<const ConstPoolVal>(Operands[idx*2]);
return cast<const Constant>(Operands[idx*2]);
}
inline ConstPoolVal *getSuccessorValue(unsigned idx) {
inline Constant *getSuccessorValue(unsigned idx) {
assert(idx < getNumSuccessors() && "Successor # out of range!");
return cast<ConstPoolVal>(Operands[idx*2]);
return cast<Constant>(Operands[idx*2]);
}
virtual unsigned getNumSuccessors() const { return Operands.size()/2; }

View File

@ -17,7 +17,7 @@ using namespace analysis;
ExprType::ExprType(Value *Val) {
if (Val)
if (ConstPoolInt *CPI = dyn_cast<ConstPoolInt>(Val)) {
if (ConstantInt *CPI = dyn_cast<ConstantInt>(Val)) {
Offset = CPI;
Var = 0;
ExprTy = Constant;
@ -30,8 +30,8 @@ ExprType::ExprType(Value *Val) {
Scale = 0;
}
ExprType::ExprType(const ConstPoolInt *scale, Value *var,
const ConstPoolInt *offset) {
ExprType::ExprType(const ConstantInt *scale, Value *var,
const ConstantInt *offset) {
Scale = var ? scale : 0; Var = var; Offset = offset;
ExprTy = Scale ? ScaledLinear : (Var ? Linear : Constant);
if (Scale && Scale->equalsInt(0)) { // Simplify 0*Var + const
@ -50,31 +50,31 @@ const Type *ExprType::getExprType(const Type *Default) const {
class DefVal {
const ConstPoolInt * const Val;
const ConstantInt * const Val;
const Type * const Ty;
protected:
inline DefVal(const ConstPoolInt *val, const Type *ty) : Val(val), Ty(ty) {}
inline DefVal(const ConstantInt *val, const Type *ty) : Val(val), Ty(ty) {}
public:
inline const Type *getType() const { return Ty; }
inline const ConstPoolInt *getVal() const { return Val; }
inline operator const ConstPoolInt * () const { return Val; }
inline const ConstPoolInt *operator->() const { return Val; }
inline const ConstantInt *getVal() const { return Val; }
inline operator const ConstantInt * () const { return Val; }
inline const ConstantInt *operator->() const { return Val; }
};
struct DefZero : public DefVal {
inline DefZero(const ConstPoolInt *val, const Type *ty) : DefVal(val, ty) {}
inline DefZero(const ConstPoolInt *val) : DefVal(val, val->getType()) {}
inline DefZero(const ConstantInt *val, const Type *ty) : DefVal(val, ty) {}
inline DefZero(const ConstantInt *val) : DefVal(val, val->getType()) {}
};
struct DefOne : public DefVal {
inline DefOne(const ConstPoolInt *val, const Type *ty) : DefVal(val, ty) {}
inline DefOne(const ConstantInt *val, const Type *ty) : DefVal(val, ty) {}
};
static ConstPoolInt *getUnsignedConstant(uint64_t V, const Type *Ty) {
static ConstantInt *getUnsignedConstant(uint64_t V, const Type *Ty) {
if (Ty->isPointerType()) Ty = Type::ULongTy;
return Ty->isSigned() ? (ConstPoolInt*)ConstPoolSInt::get(Ty, V)
: (ConstPoolInt*)ConstPoolUInt::get(Ty, V);
return Ty->isSigned() ? (ConstantInt*)ConstantSInt::get(Ty, V)
: (ConstantInt*)ConstantUInt::get(Ty, V);
}
// Add - Helper function to make later code simpler. Basically it just adds
@ -89,16 +89,16 @@ static ConstPoolInt *getUnsignedConstant(uint64_t V, const Type *Ty) {
// 3. If DefOne is true, a null return value indicates a value of 1, if DefOne
// is false, a null return value indicates a value of 0.
//
static const ConstPoolInt *Add(const ConstPoolInt *Arg1,
const ConstPoolInt *Arg2, bool DefOne) {
static const ConstantInt *Add(const ConstantInt *Arg1,
const ConstantInt *Arg2, bool DefOne) {
assert(Arg1 && Arg2 && "No null arguments should exist now!");
assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!");
// Actually perform the computation now!
ConstPoolVal *Result = *Arg1 + *Arg2;
Constant *Result = *Arg1 + *Arg2;
assert(Result && Result->getType() == Arg1->getType() &&
"Couldn't perform addition!");
ConstPoolInt *ResultI = cast<ConstPoolInt>(Result);
ConstantInt *ResultI = cast<ConstantInt>(Result);
// Check to see if the result is one of the special cases that we want to
// recognize...
@ -108,13 +108,13 @@ static const ConstPoolInt *Add(const ConstPoolInt *Arg1,
return ResultI;
}
inline const ConstPoolInt *operator+(const DefZero &L, const DefZero &R) {
inline const ConstantInt *operator+(const DefZero &L, const DefZero &R) {
if (L == 0) return R;
if (R == 0) return L;
return Add(L, R, false);
}
inline const ConstPoolInt *operator+(const DefOne &L, const DefOne &R) {
inline const ConstantInt *operator+(const DefOne &L, const DefOne &R) {
if (L == 0) {
if (R == 0)
return getUnsignedConstant(2, L.getType());
@ -139,16 +139,16 @@ inline const ConstPoolInt *operator+(const DefOne &L, const DefOne &R) {
// 3. If DefOne is true, a null return value indicates a value of 1, if DefOne
// is false, a null return value indicates a value of 0.
//
inline const ConstPoolInt *Mul(const ConstPoolInt *Arg1,
const ConstPoolInt *Arg2, bool DefOne) {
inline const ConstantInt *Mul(const ConstantInt *Arg1,
const ConstantInt *Arg2, bool DefOne) {
assert(Arg1 && Arg2 && "No null arguments should exist now!");
assert(Arg1->getType() == Arg2->getType() && "Types must be compatible!");
// Actually perform the computation now!
ConstPoolVal *Result = *Arg1 * *Arg2;
Constant *Result = *Arg1 * *Arg2;
assert(Result && Result->getType() == Arg1->getType() &&
"Couldn't perform multiplication!");
ConstPoolInt *ResultI = cast<ConstPoolInt>(Result);
ConstantInt *ResultI = cast<ConstantInt>(Result);
// Check to see if the result is one of the special cases that we want to
// recognize...
@ -158,16 +158,16 @@ inline const ConstPoolInt *Mul(const ConstPoolInt *Arg1,
return ResultI;
}
inline const ConstPoolInt *operator*(const DefZero &L, const DefZero &R) {
inline const ConstantInt *operator*(const DefZero &L, const DefZero &R) {
if (L == 0 || R == 0) return 0;
return Mul(L, R, false);
}
inline const ConstPoolInt *operator*(const DefOne &L, const DefZero &R) {
inline const ConstantInt *operator*(const DefOne &L, const DefZero &R) {
if (R == 0) return getUnsignedConstant(0, L.getType());
if (L == 0) return R->equalsInt(1) ? 0 : R.getVal();
return Mul(L, R, true);
}
inline const ConstPoolInt *operator*(const DefZero &L, const DefOne &R) {
inline const ConstantInt *operator*(const DefZero &L, const DefOne &R) {
if (L == 0 || R == 0) return L.getVal();
return Mul(R, L, false);
}
@ -203,9 +203,9 @@ static ExprType handleAddition(ExprType Left, ExprType Right, Value *V) {
static inline ExprType negate(const ExprType &E, Value *V) {
const Type *Ty = V->getType();
const Type *ETy = E.getExprType(Ty);
ConstPoolInt *Zero = getUnsignedConstant(0, ETy);
ConstPoolInt *One = getUnsignedConstant(1, ETy);
ConstPoolInt *NegOne = cast<ConstPoolInt>(*Zero - *One);
ConstantInt *Zero = getUnsignedConstant(0, ETy);
ConstantInt *One = getUnsignedConstant(1, ETy);
ConstantInt *NegOne = cast<ConstantInt>(*Zero - *One);
if (NegOne == 0) return V; // Couldn't subtract values...
return ExprType(DefOne (E.Scale , Ty) * NegOne, E.Var,
@ -230,9 +230,9 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
case Value::MethodArgumentVal: // nothing known, return variable itself
return Expr;
case Value::ConstantVal: // Constant value, just return constant
ConstPoolVal *CPV = cast<ConstPoolVal>(Expr);
Constant *CPV = cast<Constant>(Expr);
if (CPV->getType()->isIntegral()) { // It's an integral constant!
ConstPoolInt *CPI = cast<ConstPoolInt>(Expr);
ConstantInt *CPI = cast<ConstantInt>(Expr);
return ExprType(CPI->equalsInt(0) ? 0 : CPI);
}
return Expr;
@ -264,8 +264,8 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
if (Right.Offset == 0) return Left; // shl x, 0 = x
assert(Right.Offset->getType() == Type::UByteTy &&
"Shift amount must always be a unsigned byte!");
uint64_t ShiftAmount = ((ConstPoolUInt*)Right.Offset)->getValue();
ConstPoolInt *Multiplier = getUnsignedConstant(1ULL << ShiftAmount, Ty);
uint64_t ShiftAmount = ((ConstantUInt*)Right.Offset)->getValue();
ConstantInt *Multiplier = getUnsignedConstant(1ULL << ShiftAmount, Ty);
return ExprType(DefOne(Left.Scale, Ty) * Multiplier, Left.Var,
DefZero(Left.Offset, Ty) * Multiplier);
@ -280,7 +280,7 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
if (Left.ExprTy != ExprType::Constant) // RHS must be > constant
return I; // Quadratic eqn! :(
const ConstPoolInt *Offs = Left.Offset;
const ConstantInt *Offs = Left.Offset;
if (Offs == 0) return ExprType();
return ExprType( DefOne(Right.Scale , Ty) * Offs, Right.Var,
DefZero(Right.Offset, Ty) * Offs);
@ -299,17 +299,17 @@ ExprType analysis::ClassifyExpression(Value *Expr) {
}
*/
const ConstPoolInt *Offset = Src.Offset;
const ConstPoolInt *Scale = Src.Scale;
const ConstantInt *Offset = Src.Offset;
const ConstantInt *Scale = Src.Scale;
if (Offset) {
const ConstPoolVal *CPV = ConstantFoldCastInstruction(Offset, DestTy);
const Constant *CPV = ConstantFoldCastInstruction(Offset, DestTy);
if (!CPV) return I;
Offset = cast<ConstPoolInt>(CPV);
Offset = cast<ConstantInt>(CPV);
}
if (Scale) {
const ConstPoolVal *CPV = ConstantFoldCastInstruction(Scale, DestTy);
const Constant *CPV = ConstantFoldCastInstruction(Scale, DestTy);
if (!CPV) return I;
Scale = cast<ConstPoolInt>(CPV);
Scale = cast<ConstantInt>(CPV);
}
return ExprType(Scale, Src.Var, Offset);
} // end case Instruction::Cast

View File

@ -22,13 +22,13 @@
#include "llvm/iPHINode.h"
#include "llvm/InstrTypes.h"
#include "llvm/Type.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
using analysis::ExprType;
static bool isLoopInvariant(const Value *V, const cfg::Loop *L) {
if (isa<ConstPoolVal>(V) || isa<MethodArgument>(V) || isa<GlobalValue>(V))
if (isa<Constant>(V) || isa<MethodArgument>(V) || isa<GlobalValue>(V))
return true;
const Instruction *I = cast<Instruction>(V);
@ -41,8 +41,8 @@ enum InductionVariable::iType
InductionVariable::Classify(const Value *Start, const Value *Step,
const cfg::Loop *L = 0) {
// Check for cannonical and simple linear expressions now...
if (ConstPoolInt *CStart = dyn_cast<ConstPoolInt>(Start))
if (ConstPoolInt *CStep = dyn_cast<ConstPoolInt>(Step)) {
if (ConstantInt *CStart = dyn_cast<ConstantInt>(Start))
if (ConstantInt *CStep = dyn_cast<ConstantInt>(Step)) {
if (CStart->equalsInt(0) && CStep->equalsInt(1))
return Cannonical;
else
@ -97,8 +97,8 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
const Type *ETy = Phi->getType();
if (ETy->isPointerType()) ETy = Type::ULongTy;
Start = (Value*)(E1.Offset ? E1.Offset : ConstPoolInt::get(ETy, 0));
Step = (Value*)(E2.Offset ? E2.Offset : ConstPoolInt::get(ETy, 0));
Start = (Value*)(E1.Offset ? E1.Offset : ConstantInt::get(ETy, 0));
Step = (Value*)(E2.Offset ? E2.Offset : ConstantInt::get(ETy, 0));
} else {
// Okay, at this point, we know that we have loop information...
@ -111,7 +111,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
Step = 0;
if (V2 == Phi) { // referencing the PHI directly? Must have zero step
Step = ConstPoolVal::getNullConstant(Phi->getType());
Step = Constant::getNullConstant(Phi->getType());
} else if (BinaryOperator *I = dyn_cast<BinaryOperator>(V2)) {
// TODO: This could be much better...
if (I->getOpcode() == Instruction::Add) {
@ -129,7 +129,7 @@ InductionVariable::InductionVariable(PHINode *P, cfg::LoopInfo *LoopInfo) {
const Type *ETy = Phi->getType();
if (ETy->isPointerType()) ETy = Type::ULongTy;
Step = (Value*)(StepE.Offset ? StepE.Offset : ConstPoolInt::get(ETy, 0));
Step = (Value*)(StepE.Offset ? StepE.Offset : ConstantInt::get(ETy, 0));
}
}

View File

@ -1,6 +1,6 @@
#include "llvm/Analysis/LiveVar/ValueSet.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
void printValue( const Value *const v) // func to print a Value
@ -8,8 +8,8 @@ void printValue( const Value *const v) // func to print a Value
if (v->hasName())
cerr << v << "(" << ((*v).getName()) << ") ";
else if (v->getValueType() == Value::ConstantVal) // if const
cerr << v << "(" << ((ConstPoolVal *) v)->getStrValue() << ") ";
else if (Constant *C = dyn_cast<Constant>(v))
cerr << v << "(" << C->getStrValue() << ") ";
else
cerr << v << " ";
}

View File

@ -11,7 +11,6 @@
#include "llvm/Module.h"
#include "llvm/BasicBlock.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ConstPoolVals.h"
#include "Support/STLExtras.h"
#include <map>

View File

@ -13,7 +13,7 @@
#include "llvm/InstrTypes.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/iOther.h"
#include "llvm/Method.h"
#include "llvm/DerivedTypes.h"

View File

@ -58,7 +58,7 @@ static struct PerModuleInfo {
// GlobalRefs - This maintains a mapping between <Type, ValID>'s and forward
// references to global values. Global values may be referenced before they
// are defined, and if so, the temporary object that they represent is held
// here. This is used for forward references of ConstPoolPointerRefs.
// here. This is used for forward references of ConstantPointerRefs.
//
typedef map<pair<const PointerType *, ValID>, GlobalVariable*> GlobalRefsType;
GlobalRefsType GlobalRefs;
@ -100,11 +100,11 @@ static struct PerModuleInfo {
I->first.second.destroy(); // Free string memory if neccesary
// Loop over all of the uses of the GlobalValue. The only thing they are
// allowed to be at this point is ConstPoolPointerRef's.
// allowed to be at this point is ConstantPointerRef's.
assert(OldGV->use_size() == 1 && "Only one reference should exist!");
while (!OldGV->use_empty()) {
User *U = OldGV->use_back(); // Must be a ConstPoolPointerRef...
ConstPoolPointerRef *CPPR = cast<ConstPoolPointerRef>(U);
User *U = OldGV->use_back(); // Must be a ConstantPointerRef...
ConstantPointerRef *CPPR = cast<ConstantPointerRef>(U);
assert(CPPR->getValue() == OldGV && "Something isn't happy");
// Change the const pool reference to point to the real global variable
@ -296,24 +296,24 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
// value will fit into the specified type...
case ValID::ConstSIntVal: // Is it a constant pool reference??
if (Ty == Type::BoolTy) { // Special handling for boolean data
return ConstPoolBool::get(D.ConstPool64 != 0);
return ConstantBool::get(D.ConstPool64 != 0);
} else {
if (!ConstPoolSInt::isValueValidForType(Ty, D.ConstPool64))
if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64))
ThrowException("Symbolic constant pool value '" +
itostr(D.ConstPool64) + "' is invalid for type '" +
Ty->getName() + "'!");
return ConstPoolSInt::get(Ty, D.ConstPool64);
return ConstantSInt::get(Ty, D.ConstPool64);
}
case ValID::ConstUIntVal: // Is it an unsigned const pool reference?
if (!ConstPoolUInt::isValueValidForType(Ty, D.UConstPool64)) {
if (!ConstPoolSInt::isValueValidForType(Ty, D.ConstPool64)) {
if (!ConstantUInt::isValueValidForType(Ty, D.UConstPool64)) {
if (!ConstantSInt::isValueValidForType(Ty, D.ConstPool64)) {
ThrowException("Integral constant pool reference is invalid!");
} else { // This is really a signed reference. Transmogrify.
return ConstPoolSInt::get(Ty, D.ConstPool64);
return ConstantSInt::get(Ty, D.ConstPool64);
}
} else {
return ConstPoolUInt::get(Ty, D.UConstPool64);
return ConstantUInt::get(Ty, D.UConstPool64);
}
case ValID::ConstStringVal: // Is it a string const pool reference?
@ -322,14 +322,14 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
return 0;
case ValID::ConstFPVal: // Is it a floating point const pool reference?
if (!ConstPoolFP::isValueValidForType(Ty, D.ConstPoolFP))
if (!ConstantFP::isValueValidForType(Ty, D.ConstPoolFP))
ThrowException("FP constant invalid for type!!");
return ConstPoolFP::get(Ty, D.ConstPoolFP);
return ConstantFP::get(Ty, D.ConstPoolFP);
case ValID::ConstNullVal: // Is it a null value?
if (!Ty->isPointerType())
ThrowException("Cannot create a a non pointer null!");
return ConstPoolPointerNull::get(cast<PointerType>(Ty));
return ConstantPointerNull::get(cast<PointerType>(Ty));
default:
assert(0 && "Unhandled case!");
@ -635,7 +635,7 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) {
BasicBlock *BasicBlockVal;
TerminatorInst *TermInstVal;
Instruction *InstVal;
ConstPoolVal *ConstVal;
Constant *ConstVal;
const Type *PrimType;
PATypeHolder<Type> *TypeVal;
@ -645,8 +645,8 @@ Module *RunVMAsmParser(const string &Filename, FILE *F) {
vector<Value*> *ValueList;
list<PATypeHolder<Type> > *TypeList;
list<pair<Value*, BasicBlock*> > *PHIList; // Represent the RHS of PHI node
list<pair<ConstPoolVal*, BasicBlock*> > *JumpTable;
vector<ConstPoolVal*> *ConstVector;
list<pair<Constant*, BasicBlock*> > *JumpTable;
vector<Constant*> *ConstVector;
int64_t SInt64Val;
uint64_t UInt64Val;
@ -894,7 +894,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
(*$3)[i]->getType()->getName() + "'.");
}
$$ = ConstPoolArray::get(ATy, *$3);
$$ = ConstantArray::get(ATy, *$3);
delete $1; delete $3;
}
| Types '[' ']' {
@ -907,7 +907,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
if (NumElements != -1 && NumElements != 0)
ThrowException("Type mismatch: constant sized array initialized with 0"
" arguments, but has size of " + itostr(NumElements) +"!");
$$ = ConstPoolArray::get(ATy, vector<ConstPoolVal*>());
$$ = ConstantArray::get(ATy, vector<Constant*>());
delete $1;
}
| Types 'c' STRINGCONSTANT {
@ -923,19 +923,19 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
ThrowException("Can't build string constant of size " +
itostr((int)(EndStr-$3)) +
" when array has size " + itostr(NumElements) + "!");
vector<ConstPoolVal*> Vals;
vector<Constant*> Vals;
if (ETy == Type::SByteTy) {
for (char *C = $3; C != EndStr; ++C)
Vals.push_back(ConstPoolSInt::get(ETy, *C));
Vals.push_back(ConstantSInt::get(ETy, *C));
} else if (ETy == Type::UByteTy) {
for (char *C = $3; C != EndStr; ++C)
Vals.push_back(ConstPoolUInt::get(ETy, *C));
Vals.push_back(ConstantUInt::get(ETy, *C));
} else {
free($3);
ThrowException("Cannot build string arrays of non byte sized elements!");
}
free($3);
$$ = ConstPoolArray::get(ATy, Vals);
$$ = ConstantArray::get(ATy, Vals);
delete $1;
}
| Types '{' ConstVector '}' {
@ -945,7 +945,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
(*$1)->getDescription() + "'!");
// FIXME: TODO: Check to see that the constants are compatible with the type
// initializer!
$$ = ConstPoolStruct::get(STy, *$3);
$$ = ConstantStruct::get(STy, *$3);
delete $1; delete $3;
}
| Types NULL_TOK {
@ -954,7 +954,7 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
ThrowException("Cannot make null pointer constant with type: '" +
(*$1)->getDescription() + "'!");
$$ = ConstPoolPointerNull::get(PTy);
$$ = ConstantPointerNull::get(PTy);
delete $1;
}
| Types SymbolicValueRef {
@ -994,29 +994,29 @@ ConstVal: Types '[' ConstVector ']' { // Nonempty unsized arr
}
GlobalValue *GV = cast<GlobalValue>(V);
$$ = ConstPoolPointerRef::get(GV);
$$ = ConstantPointerRef::get(GV);
delete $1; // Free the type handle
}
ConstVal : SIntType EINT64VAL { // integral constants
if (!ConstPoolSInt::isValueValidForType($1, $2))
if (!ConstantSInt::isValueValidForType($1, $2))
ThrowException("Constant value doesn't fit in type!");
$$ = ConstPoolSInt::get($1, $2);
$$ = ConstantSInt::get($1, $2);
}
| UIntType EUINT64VAL { // integral constants
if (!ConstPoolUInt::isValueValidForType($1, $2))
if (!ConstantUInt::isValueValidForType($1, $2))
ThrowException("Constant value doesn't fit in type!");
$$ = ConstPoolUInt::get($1, $2);
$$ = ConstantUInt::get($1, $2);
}
| BOOL TRUE { // Boolean constants
$$ = ConstPoolBool::True;
$$ = ConstantBool::True;
}
| BOOL FALSE { // Boolean constants
$$ = ConstPoolBool::False;
$$ = ConstantBool::False;
}
| FPType FPVAL { // Float & Double constants
$$ = ConstPoolFP::get($1, $2);
$$ = ConstantFP::get($1, $2);
}
// ConstVector - A list of comma seperated constants.
@ -1024,7 +1024,7 @@ ConstVector : ConstVector ',' ConstVal {
($$ = $1)->push_back($3);
}
| ConstVal {
$$ = new vector<ConstPoolVal*>();
$$ = new vector<Constant*>();
$$->push_back($1);
}
@ -1066,7 +1066,7 @@ ConstPool : ConstPool OptAssign CONST ConstVal {
| ConstPool OptAssign OptInternal GlobalType ConstVal {
const Type *Ty = $5->getType();
// Global declarations appear in Constant Pool
ConstPoolVal *Initializer = $5;
Constant *Initializer = $5;
if (Initializer == 0)
ThrowException("Global value initializer is not a constant!");
@ -1340,7 +1340,7 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
cast<BasicBlock>(getVal(Type::LabelTy, $6)));
$$ = S;
list<pair<ConstPoolVal*, BasicBlock*> >::iterator I = $8->begin(),
list<pair<Constant*, BasicBlock*> >::iterator I = $8->begin(),
end = $8->end();
for (; I != end; ++I)
S->dest_push_back(I->first, I->second);
@ -1403,15 +1403,15 @@ BBTerminatorInst : RET ResolvedVal { // Return with a result...
JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
$$ = $1;
ConstPoolVal *V = cast<ConstPoolVal>(getValNonImprovising($2, $3));
Constant *V = cast<Constant>(getValNonImprovising($2, $3));
if (V == 0)
ThrowException("May only switch on a constant pool value!");
$$->push_back(make_pair(V, cast<BasicBlock>(getVal($5, $6))));
}
| IntType ConstValueRef ',' LABEL ValueRef {
$$ = new list<pair<ConstPoolVal*, BasicBlock*> >();
ConstPoolVal *V = cast<ConstPoolVal>(getValNonImprovising($1, $2));
$$ = new list<pair<Constant*, BasicBlock*> >();
Constant *V = cast<Constant>(getValNonImprovising($1, $2));
if (V == 0)
ThrowException("May only switch on a constant pool value!");

View File

@ -1,4 +1,4 @@
//===- ReadConst.cpp - Code to constants and constant pools -----------------===
//===- ReadConst.cpp - Code to constants and constant pools ---------------===//
//
// This file implements functionality to deserialize constants and entire
// constant pools.
@ -6,12 +6,12 @@
// Note that this library should be as fast as possible, reentrant, and
// threadsafe!!
//
//===------------------------------------------------------------------------===
//===----------------------------------------------------------------------===//
#include "ReaderInternals.h"
#include "llvm/Module.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/GlobalVariable.h"
#include <algorithm>
@ -174,15 +174,14 @@ bool BytecodeParser::parseTypeConstants(const uchar *&Buf, const uchar *EndBuf,
}
bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
const uchar *EndBuf,
const Type *Ty, ConstPoolVal *&V) {
bool BytecodeParser::parseConstantValue(const uchar *&Buf, const uchar *EndBuf,
const Type *Ty, Constant *&V) {
switch (Ty->getPrimitiveID()) {
case Type::BoolTyID: {
unsigned Val;
if (read_vbr(Buf, EndBuf, Val)) return failure(true);
if (Val != 0 && Val != 1) return failure(true);
V = ConstPoolBool::get(Val == 1);
V = ConstantBool::get(Val == 1);
break;
}
@ -191,15 +190,15 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
case Type::UIntTyID: {
unsigned Val;
if (read_vbr(Buf, EndBuf, Val)) return failure(true);
if (!ConstPoolUInt::isValueValidForType(Ty, Val)) return failure(true);
V = ConstPoolUInt::get(Ty, Val);
if (!ConstantUInt::isValueValidForType(Ty, Val)) return failure(true);
V = ConstantUInt::get(Ty, Val);
break;
}
case Type::ULongTyID: {
uint64_t Val;
if (read_vbr(Buf, EndBuf, Val)) return failure(true);
V = ConstPoolUInt::get(Ty, Val);
V = ConstantUInt::get(Ty, Val);
break;
}
@ -208,29 +207,29 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
case Type::IntTyID: {
int Val;
if (read_vbr(Buf, EndBuf, Val)) return failure(true);
if (!ConstPoolSInt::isValueValidForType(Ty, Val)) return failure(true);
V = ConstPoolSInt::get(Ty, Val);
if (!ConstantSInt::isValueValidForType(Ty, Val)) return failure(true);
V = ConstantSInt::get(Ty, Val);
break;
}
case Type::LongTyID: {
int64_t Val;
if (read_vbr(Buf, EndBuf, Val)) return failure(true);
V = ConstPoolSInt::get(Ty, Val);
V = ConstantSInt::get(Ty, Val);
break;
}
case Type::FloatTyID: {
float F;
if (input_data(Buf, EndBuf, &F, &F+1)) return failure(true);
V = ConstPoolFP::get(Ty, F);
V = ConstantFP::get(Ty, F);
break;
}
case Type::DoubleTyID: {
double Val;
if (input_data(Buf, EndBuf, &Val, &Val+1)) return failure(true);
V = ConstPoolFP::get(Ty, Val);
V = ConstantFP::get(Ty, Val);
break;
}
@ -246,15 +245,15 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
else // Unsized array, # elements stored in stream!
if (read_vbr(Buf, EndBuf, NumElements)) return failure(true);
vector<ConstPoolVal *> Elements;
vector<Constant*> Elements;
while (NumElements--) { // Read all of the elements of the constant.
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Value *V = getValue(AT->getElementType(), Slot, false);
if (!V || !isa<ConstPoolVal>(V)) return failure(true);
Elements.push_back(cast<ConstPoolVal>(V));
if (!V || !isa<Constant>(V)) return failure(true);
Elements.push_back(cast<Constant>(V));
}
V = ConstPoolArray::get(AT, Elements);
V = ConstantArray::get(AT, Elements);
break;
}
@ -262,17 +261,17 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
const StructType *ST = cast<StructType>(Ty);
const StructType::ElementTypes &ET = ST->getElementTypes();
vector<ConstPoolVal *> Elements;
vector<Constant *> Elements;
for (unsigned i = 0; i < ET.size(); ++i) {
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
Value *V = getValue(ET[i], Slot, false);
if (!V || !isa<ConstPoolVal>(V))
if (!V || !isa<Constant>(V))
return failure(true);
Elements.push_back(cast<ConstPoolVal>(V));
Elements.push_back(cast<Constant>(V));
}
V = ConstPoolStruct::get(ST, Elements);
V = ConstantStruct::get(ST, Elements);
break;
}
@ -281,11 +280,11 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
unsigned SubClass;
if (read_vbr(Buf, EndBuf, SubClass)) return failure(true);
switch (SubClass) {
case 0: // ConstPoolPointerNull value...
V = ConstPoolPointerNull::get(PT);
case 0: // ConstantPointerNull value...
V = ConstantPointerNull::get(PT);
break;
case 1: { // ConstPoolPointerRef value...
case 1: { // ConstantPointerRef value...
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) return failure(true);
BCR_TRACE(4, "CPPR: Type: '" << Ty << "' slot: " << Slot << "\n");
@ -317,7 +316,7 @@ bool BytecodeParser::parseConstPoolValue(const uchar *&Buf,
}
}
V = ConstPoolPointerRef::get(GV);
V = ConstantPointerRef::get(GV);
break;
}
default:
@ -352,8 +351,8 @@ bool BytecodeParser::ParseConstantPool(const uchar *&Buf, const uchar *EndBuf,
if (parseTypeConstants(Buf, EndBuf, TypeTab, NumEntries)) return true;
} else {
for (unsigned i = 0; i < NumEntries; ++i) {
ConstPoolVal *I;
if (parseConstPoolValue(Buf, EndBuf, Ty, I)) return failure(true);
Constant *I;
if (parseConstantValue(Buf, EndBuf, Ty, I)) return failure(true);
BCR_TRACE(4, "Read Constant: '" << I << "'\n");
if (insertValue(I, Tab) == -1) return failure(true);
}

View File

@ -213,7 +213,7 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
vector<unsigned> &args = *Raw.VarArgs;
for (unsigned i = 0; i < args.size(); i += 2)
I->dest_push_back(cast<ConstPoolVal>(getValue(Raw.Ty, args[i])),
I->dest_push_back(cast<Constant>(getValue(Raw.Ty, args[i])),
cast<BasicBlock>(getValue(Type::LabelTy, args[i+1])));
delete Raw.VarArgs;

View File

@ -16,7 +16,7 @@
#include "llvm/GlobalVariable.h"
#include "llvm/Module.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
#include <sys/types.h>
@ -217,7 +217,7 @@ bool BytecodeParser::ParseSymbolTable(const uchar *&Buf, const uchar *EndBuf,
}
// DeclareNewGlobalValue - Patch up forward references to global values in the
// form of ConstPoolPointerRef.
// form of ConstantPointerRef.
//
void BytecodeParser::DeclareNewGlobalValue(GlobalValue *GV, unsigned Slot) {
// Check to see if there is a forward reference to this global variable...
@ -229,11 +229,11 @@ void BytecodeParser::DeclareNewGlobalValue(GlobalValue *GV, unsigned Slot) {
BCR_TRACE(3, "Mutating CPPR Forward Ref!\n");
// Loop over all of the uses of the GlobalValue. The only thing they are
// allowed to be at this point is ConstPoolPointerRef's.
// allowed to be at this point is ConstantPointerRef's.
assert(OldGV->use_size() == 1 && "Only one reference should exist!");
while (!OldGV->use_empty()) {
User *U = OldGV->use_back(); // Must be a ConstPoolPointerRef...
ConstPoolPointerRef *CPPR = cast<ConstPoolPointerRef>(U);
User *U = OldGV->use_back(); // Must be a ConstantPointerRef...
ConstantPointerRef *CPPR = cast<ConstantPointerRef>(U);
assert(CPPR->getValue() == OldGV && "Something isn't happy");
BCR_TRACE(4, "Mutating Forward Ref!\n");
@ -394,7 +394,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
const PointerType *PTy = cast<const PointerType>(Ty);
const Type *ElTy = PTy->getValueType();
ConstPoolVal *Initializer = 0;
Constant *Initializer = 0;
if (VarType & 2) { // Does it have an initalizer?
// Do not improvise... values must have been stored in the constant pool,
// which should have been read before now.
@ -404,7 +404,7 @@ bool BytecodeParser::ParseModuleGlobalInfo(const uchar *&Buf, const uchar *End,
Value *V = getValue(ElTy, InitSlot, false);
if (V == 0) return failure(true);
Initializer = cast<ConstPoolVal>(V);
Initializer = cast<Constant>(V);
}
// Create the global variable...

View File

@ -102,8 +102,8 @@ private:
bool ParseConstantPool(const uchar *&Buf, const uchar *EndBuf,
ValueTable &Tab, TypeValuesListTy &TypeTab);
bool parseConstPoolValue(const uchar *&Buf, const uchar *End,
const Type *Ty, ConstPoolVal *&V);
bool parseConstantValue(const uchar *&Buf, const uchar *End,
const Type *Ty, Constant *&V);
bool parseTypeConstants(const uchar *&Buf, const uchar *EndBuf,
TypeValuesListTy &Tab, unsigned NumEntries);
const Type *parseTypeConstant(const uchar *&Buf, const uchar *EndBuf);
@ -117,7 +117,7 @@ private:
bool getTypeSlot(const Type *Ty, unsigned &Slot);
// DeclareNewGlobalValue - Patch up forward references to global values in the
// form of ConstPoolPointerRefs.
// form of ConstantPointerRefs.
//
void DeclareNewGlobalValue(GlobalValue *GV, unsigned Slot);

View File

@ -10,7 +10,7 @@
//===----------------------------------------------------------------------===//
#include "WriterInternals.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
@ -93,10 +93,10 @@ void BytecodeWriter::outputType(const Type *T) {
}
}
bool BytecodeWriter::outputConstant(const ConstPoolVal *CPV) {
bool BytecodeWriter::outputConstant(const Constant *CPV) {
switch (CPV->getType()->getPrimitiveID()) {
case Type::BoolTyID: // Boolean Types
if (cast<const ConstPoolBool>(CPV)->getValue())
if (cast<const ConstantBool>(CPV)->getValue())
output_vbr((unsigned)1, Out);
else
output_vbr((unsigned)0, Out);
@ -106,22 +106,22 @@ bool BytecodeWriter::outputConstant(const ConstPoolVal *CPV) {
case Type::UShortTyID:
case Type::UIntTyID:
case Type::ULongTyID:
output_vbr(cast<const ConstPoolUInt>(CPV)->getValue(), Out);
output_vbr(cast<const ConstantUInt>(CPV)->getValue(), Out);
break;
case Type::SByteTyID: // Signed integer types...
case Type::ShortTyID:
case Type::IntTyID:
case Type::LongTyID:
output_vbr(cast<const ConstPoolSInt>(CPV)->getValue(), Out);
output_vbr(cast<const ConstantSInt>(CPV)->getValue(), Out);
break;
case Type::TypeTyID: // Serialize type type
assert(0 && "Types should not be in the ConstPool!");
assert(0 && "Types should not be in the Constant!");
break;
case Type::ArrayTyID: {
const ConstPoolArray *CPA = cast<const ConstPoolArray>(CPV);
const ConstantArray *CPA = cast<const ConstantArray>(CPV);
unsigned size = CPA->getValues().size();
if (!((const ArrayType *)CPA->getType())->isSized())
output_vbr(size, Out); // Not for sized arrays!!!
@ -135,7 +135,7 @@ bool BytecodeWriter::outputConstant(const ConstPoolVal *CPV) {
}
case Type::StructTyID: {
const ConstPoolStruct *CPS = cast<const ConstPoolStruct>(CPV);
const ConstantStruct *CPS = cast<const ConstantStruct>(CPV);
const vector<Use> &Vals = CPS->getValues();
for (unsigned i = 0; i < Vals.size(); ++i) {
@ -147,28 +147,28 @@ bool BytecodeWriter::outputConstant(const ConstPoolVal *CPV) {
}
case Type::PointerTyID: {
const ConstPoolPointer *CPP = cast<const ConstPoolPointer>(CPV);
if (isa<ConstPoolPointerNull>(CPP)) {
const ConstantPointer *CPP = cast<const ConstantPointer>(CPV);
if (isa<ConstantPointerNull>(CPP)) {
output_vbr((unsigned)0, Out);
} else if (const ConstPoolPointerRef *CPR =
dyn_cast<ConstPoolPointerRef>(CPP)) {
} else if (const ConstantPointerRef *CPR =
dyn_cast<ConstantPointerRef>(CPP)) {
output_vbr((unsigned)1, Out);
int Slot = Table.getValSlot((Value*)CPR->getValue());
assert(Slot != -1 && "Global used but not available!!");
output_vbr((unsigned)Slot, Out);
} else {
assert(0 && "Unknown ConstPoolPointer Subclass!");
assert(0 && "Unknown ConstantPointer Subclass!");
}
break;
}
case Type::FloatTyID: { // Floating point types...
float Tmp = (float)cast<ConstPoolFP>(CPV)->getValue();
float Tmp = (float)cast<ConstantFP>(CPV)->getValue();
output_data(&Tmp, &Tmp+1, Out);
break;
}
case Type::DoubleTyID: {
double Tmp = cast<ConstPoolFP>(CPV)->getValue();
double Tmp = cast<ConstantFP>(CPV)->getValue();
output_data(&Tmp, &Tmp+1, Out);
break;
}

View File

@ -27,7 +27,7 @@
#include "llvm/GlobalVariable.h"
#include "llvm/Method.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
#include "Support/STLExtras.h"
@ -81,7 +81,7 @@ void BytecodeWriter::outputConstants(bool isMethod) {
unsigned NC = ValNo; // Number of constants
for (; NC < Plane.size() &&
(isa<ConstPoolVal>(Plane[NC]) ||
(isa<Constant>(Plane[NC]) ||
isa<Type>(Plane[NC])); NC++) /*empty*/;
NC -= ValNo; // Convert from index into count
if (NC == 0) continue; // Skip empty type planes...
@ -100,9 +100,9 @@ void BytecodeWriter::outputConstants(bool isMethod) {
for (unsigned i = ValNo; i < ValNo+NC; ++i) {
const Value *V = Plane[i];
if (const ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {
if (const Constant *CPV = dyn_cast<Constant>(V)) {
//cerr << "Serializing value: <" << V->getType() << ">: "
// << ((const ConstPoolVal*)V)->getStrValue() << ":"
// << ((const Constant*)V)->getStrValue() << ":"
// << Out.size() << "\n";
outputConstant(CPV);
} else {

View File

@ -39,7 +39,7 @@ private :
void outputModuleInfoBlock(const Module *C);
void outputSymbolTable(const SymbolTable &ST);
bool outputConstant(const ConstPoolVal *CPV);
bool outputConstant(const Constant *CPV);
void outputType(const Type *T);
};

View File

@ -27,7 +27,7 @@
#include "llvm/iTerminators.h"
#include "llvm/iMemory.h"
#include "llvm/iPHINode.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/BasicBlock.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "Support/STLExtras.h"
@ -289,7 +289,7 @@ InstrForest::buildTreeForInstruction(Instruction *instr)
&& !instr->isTerminator();
if (includeAddressOperand || isa<Instruction>(operand) ||
isa<ConstPoolVal>(operand) || isa<MethodArgument>(operand) ||
isa<Constant>(operand) || isa<MethodArgument>(operand) ||
isa<GlobalVariable>(operand))
{
// This operand is a data value
@ -318,7 +318,7 @@ InstrForest::buildTreeForInstruction(Instruction *instr)
// Recursively create a treeNode for it.
opTreeNode = buildTreeForInstruction((Instruction*)operand);
}
else if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(operand))
else if (Constant *CPV = dyn_cast<Constant>(operand))
{
// Create a leaf node for a constant
opTreeNode = new ConstantNode(CPV);

View File

@ -16,7 +16,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/MachineRegInfo.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Method.h"
#include "llvm/BasicBlock.h"
#include "llvm/Instruction.h"
@ -73,7 +73,7 @@ int64_t
GetConstantValueAsSignedInt(const Value *V,
bool &isValidConstant)
{
if (!isa<ConstPoolVal>(V))
if (!isa<Constant>(V))
{
isValidConstant = false;
return 0;
@ -82,15 +82,15 @@ GetConstantValueAsSignedInt(const Value *V,
isValidConstant = true;
if (V->getType() == Type::BoolTy)
return (int64_t) ((ConstPoolBool*)V)->getValue();
return (int64_t) cast<ConstantBool>(V)->getValue();
if (V->getType()->isIntegral())
{
if (V->getType()->isSigned())
return ((ConstPoolSInt*)V)->getValue();
return cast<ConstantSInt>(V)->getValue();
assert(V->getType()->isUnsigned());
uint64_t Val = ((ConstPoolUInt*)V)->getValue();
uint64_t Val = cast<ConstantUInt>(V)->getValue();
if (Val < INT64_MAX) // then safe to cast to signed
return (int64_t)Val;
}
@ -111,7 +111,7 @@ GetConstantValueAsSignedInt(const Value *V,
Value*
FoldGetElemChain(const InstructionNode* getElemInstrNode,
vector<ConstPoolVal*>& chainIdxVec)
vector<Constant*>& chainIdxVec)
{
MemAccessInst* getElemInst = (MemAccessInst*)
getElemInstrNode->getInstruction();
@ -128,7 +128,7 @@ FoldGetElemChain(const InstructionNode* getElemInstrNode,
// Child is a GetElemPtr instruction
getElemInst = (MemAccessInst*)
((InstructionNode*) ptrChild)->getInstruction();
const vector<ConstPoolVal*>& idxVec = getElemInst->getIndicesBROKEN();
const vector<Constant*>& idxVec = getElemInst->getIndicesBROKEN();
// Get the pointer value out of ptrChild and *prepend* its index vector
ptrVal = getElemInst->getPointerOperand();
@ -225,12 +225,11 @@ ChooseRegOrImmed(Value* val,
// Check for the common case first: argument is not constant
//
ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(val);
Constant *CPV = dyn_cast<Constant>(val);
if (!CPV) return opType;
if (CPV->getType() == Type::BoolTy)
if (ConstantBool *CPB = dyn_cast<ConstantBool>(CPV))
{
ConstPoolBool *CPB = (ConstPoolBool*)CPV;
if (!CPB->getValue() && target.getRegInfo().getZeroRegNum() >= 0)
{
getMachineRegNum = target.getRegInfo().getZeroRegNum();
@ -259,11 +258,11 @@ ChooseRegOrImmed(Value* val,
}
else if (CPV->getType()->isSigned())
{
intValue = ((ConstPoolSInt*)CPV)->getValue();
intValue = cast<ConstantSInt>(CPV)->getValue();
}
else
{
uint64_t V = ((ConstPoolUInt*)CPV)->getValue();
uint64_t V = cast<ConstantUInt>(CPV)->getValue();
if (V >= INT64_MAX) return opType;
intValue = (int64_t)V;
}
@ -327,8 +326,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
Value* opValue = mop.getVRegValue();
bool constantThatMustBeLoaded = false;
if (isa<ConstPoolVal>(opValue))
{
if (Constant *OpConst = dyn_cast<Constant>(opValue)) {
unsigned int machineRegNum;
int64_t immedValue;
MachineOperand::MachineOperandType opType =
@ -345,8 +343,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
if (constantThatMustBeLoaded)
{ // register the value so it is emitted in the assembly
MachineCodeForMethod::get(method).addToConstantPool(
cast<ConstPoolVal>(opValue));
MachineCodeForMethod::get(method).addToConstantPool(OpConst);
}
}
@ -370,7 +367,7 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
// into a register.
//
for (unsigned i=0, N=minstr->getNumImplicitRefs(); i < N; ++i)
if (isa<ConstPoolVal>(minstr->getImplicitRef(i)) ||
if (isa<Constant>(minstr->getImplicitRef(i)) ||
isa<GlobalValue>(minstr->getImplicitRef(i)))
{
Value* oldVal = minstr->getImplicitRef(i);
@ -378,10 +375,9 @@ FixConstantOperandsForInstr(Instruction* vmInstr,
InsertCodeToLoadConstant(oldVal, vmInstr, loadConstVec, target);
minstr->setImplicitRef(i, tmpReg);
if (isa<ConstPoolVal>(oldVal))
if (Constant *C = dyn_cast<Constant>(oldVal))
{ // register the value so it is emitted in the assembly
MachineCodeForMethod::get(method).addToConstantPool(
cast<ConstPoolVal>(oldVal));
MachineCodeForMethod::get(method).addToConstantPool(C);
}
}

View File

@ -11,7 +11,7 @@
#include "llvm/iTerminators.h"
#include "llvm/iMemory.h"
#include "llvm/Type.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Target/TargetData.h"
#include "llvm/GlobalVariable.h"
@ -19,6 +19,7 @@
#include <signal.h>
#include <setjmp.h>
// Create a TargetData structure to handle memory addressing and size/alignment
// computations
//
@ -70,24 +71,24 @@ static unsigned getOperandSlot(Value *V) {
case Type::TY##TyID: Result.TY##Val = cast<CLASS>(CPV)->getValue(); break
static GenericValue getOperandValue(Value *V, ExecutionContext &SF) {
if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {
if (Constant *CPV = dyn_cast<Constant>(V)) {
GenericValue Result;
switch (CPV->getType()->getPrimitiveID()) {
GET_CONST_VAL(Bool , ConstPoolBool);
GET_CONST_VAL(UByte , ConstPoolUInt);
GET_CONST_VAL(SByte , ConstPoolSInt);
GET_CONST_VAL(UShort , ConstPoolUInt);
GET_CONST_VAL(Short , ConstPoolSInt);
GET_CONST_VAL(UInt , ConstPoolUInt);
GET_CONST_VAL(Int , ConstPoolSInt);
GET_CONST_VAL(ULong , ConstPoolUInt);
GET_CONST_VAL(Long , ConstPoolSInt);
GET_CONST_VAL(Float , ConstPoolFP);
GET_CONST_VAL(Double , ConstPoolFP);
GET_CONST_VAL(Bool , ConstantBool);
GET_CONST_VAL(UByte , ConstantUInt);
GET_CONST_VAL(SByte , ConstantSInt);
GET_CONST_VAL(UShort , ConstantUInt);
GET_CONST_VAL(Short , ConstantSInt);
GET_CONST_VAL(UInt , ConstantUInt);
GET_CONST_VAL(Int , ConstantSInt);
GET_CONST_VAL(ULong , ConstantUInt);
GET_CONST_VAL(Long , ConstantSInt);
GET_CONST_VAL(Float , ConstantFP);
GET_CONST_VAL(Double , ConstantFP);
case Type::PointerTyID:
if (isa<ConstPoolPointerNull>(CPV)) {
if (isa<ConstantPointerNull>(CPV)) {
Result.PointerVal = 0;
} else if (ConstPoolPointerRef *CPR =dyn_cast<ConstPoolPointerRef>(CPV)) {
} else if (ConstantPointerRef *CPR =dyn_cast<ConstantPointerRef>(CPV)) {
assert(0 && "Not implemented!");
} else {
assert(0 && "Unknown constant pointer type!");
@ -113,7 +114,7 @@ static GenericValue getOperandValue(Value *V, ExecutionContext &SF) {
}
static void printOperandInfo(Value *V, ExecutionContext &SF) {
if (isa<ConstPoolVal>(V)) {
if (isa<Constant>(V)) {
cout << "Constant Pool Value\n";
} else if (isa<GlobalValue>(V)) {
cout << "Global Value\n";
@ -156,10 +157,10 @@ void Interpreter::initializeExecutionEngine() {
initializeSignalHandlers();
}
// InitializeMemory - Recursive function to apply a ConstPool value into the
// InitializeMemory - Recursive function to apply a Constant value into the
// specified memory location...
//
static void InitializeMemory(ConstPoolVal *Init, char *Addr) {
static void InitializeMemory(Constant *Init, char *Addr) {
#define INITIALIZE_MEMORY(TYID, CLASS, TY) \
case Type::TYID##TyID: { \
TY Tmp = cast<CLASS>(Init)->getValue(); \
@ -167,43 +168,43 @@ static void InitializeMemory(ConstPoolVal *Init, char *Addr) {
} return
switch (Init->getType()->getPrimitiveID()) {
INITIALIZE_MEMORY(Bool , ConstPoolBool, bool);
INITIALIZE_MEMORY(UByte , ConstPoolUInt, unsigned char);
INITIALIZE_MEMORY(SByte , ConstPoolSInt, signed char);
INITIALIZE_MEMORY(UShort , ConstPoolUInt, unsigned short);
INITIALIZE_MEMORY(Short , ConstPoolSInt, signed short);
INITIALIZE_MEMORY(UInt , ConstPoolUInt, unsigned int);
INITIALIZE_MEMORY(Int , ConstPoolSInt, signed int);
INITIALIZE_MEMORY(ULong , ConstPoolUInt, uint64_t);
INITIALIZE_MEMORY(Long , ConstPoolSInt, int64_t);
INITIALIZE_MEMORY(Float , ConstPoolFP , float);
INITIALIZE_MEMORY(Double , ConstPoolFP , double);
INITIALIZE_MEMORY(Bool , ConstantBool, bool);
INITIALIZE_MEMORY(UByte , ConstantUInt, unsigned char);
INITIALIZE_MEMORY(SByte , ConstantSInt, signed char);
INITIALIZE_MEMORY(UShort , ConstantUInt, unsigned short);
INITIALIZE_MEMORY(Short , ConstantSInt, signed short);
INITIALIZE_MEMORY(UInt , ConstantUInt, unsigned int);
INITIALIZE_MEMORY(Int , ConstantSInt, signed int);
INITIALIZE_MEMORY(ULong , ConstantUInt, uint64_t);
INITIALIZE_MEMORY(Long , ConstantSInt, int64_t);
INITIALIZE_MEMORY(Float , ConstantFP , float);
INITIALIZE_MEMORY(Double , ConstantFP , double);
#undef INITIALIZE_MEMORY
case Type::ArrayTyID: {
ConstPoolArray *CPA = cast<ConstPoolArray>(Init);
ConstantArray *CPA = cast<ConstantArray>(Init);
const vector<Use> &Val = CPA->getValues();
unsigned ElementSize =
TD.getTypeSize(cast<ArrayType>(CPA->getType())->getElementType());
for (unsigned i = 0; i < Val.size(); ++i)
InitializeMemory(cast<ConstPoolVal>(Val[i].get()), Addr+i*ElementSize);
InitializeMemory(cast<Constant>(Val[i].get()), Addr+i*ElementSize);
return;
}
case Type::StructTyID: {
ConstPoolStruct *CPS = cast<ConstPoolStruct>(Init);
ConstantStruct *CPS = cast<ConstantStruct>(Init);
const StructLayout *SL=TD.getStructLayout(cast<StructType>(CPS->getType()));
const vector<Use> &Val = CPS->getValues();
for (unsigned i = 0; i < Val.size(); ++i)
InitializeMemory(cast<ConstPoolVal>(Val[i].get()),
InitializeMemory(cast<Constant>(Val[i].get()),
Addr+SL->MemberOffsets[i]);
return;
}
case Type::PointerTyID:
if (isa<ConstPoolPointerNull>(Init)) {
if (isa<ConstantPointerNull>(Init)) {
*(void**)Addr = 0;
} else if (ConstPoolPointerRef *CPR = dyn_cast<ConstPoolPointerRef>(Init)) {
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Init)) {
GlobalAddress *Address =
(GlobalAddress*)CPR->getValue()->getOrCreateAnnotation(GlobalAddressAID);
*(void**)Addr = (GenericValue*)Address->Ptr;
@ -245,7 +246,7 @@ Annotation *GlobalAddress::Create(AnnotationID AID, const Annotable *O, void *){
Ty = cast<const ArrayType>(Ty)->getElementType(); // Get the actual type...
// Get the number of elements being allocated by the array...
NumElements =cast<ConstPoolArray>(GV->getInitializer())->getValues().size();
NumElements =cast<ConstantArray>(GV->getInitializer())->getValues().size();
}
// Allocate enough memory to hold the type...
@ -778,7 +779,7 @@ static PointerTy getElementOffset(MemAccessInst *I, ExecutionContext &SF) {
const StructLayout *SLO = TD.getStructLayout(STy);
// Indicies must be ubyte constants...
const ConstPoolUInt *CPU = cast<ConstPoolUInt>(I->getOperand(ArgOff++));
const ConstantUInt *CPU = cast<ConstantUInt>(I->getOperand(ArgOff++));
assert(CPU->getType() == Type::UByteTy);
unsigned Index = CPU->getValue();

View File

@ -14,7 +14,7 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/GlobalVariable.h"
#include "llvm/GlobalValue.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/DerivedTypes.h"
#include "llvm/BasicBlock.h"
#include "llvm/Method.h"
@ -59,9 +59,9 @@ private :
void emitMachineInst(const MachineInstr *MI);
void printGlobalVariable( const GlobalVariable* GV);
void printSingleConstant( const ConstPoolVal* CV);
void printConstantValueOnly(const ConstPoolVal* CV);
void printConstant( const ConstPoolVal* CV, string valID=string(""));
void printSingleConstant( const Constant* CV);
void printConstantValueOnly(const Constant* CV);
void printConstant( const Constant* CV, string valID=string(""));
unsigned int printOperands(const MachineInstr *MI, unsigned int opNum);
void printOneOperand(const MachineOperand &Op);
@ -148,7 +148,7 @@ private :
string getID(const GlobalVariable *GV) {
return getID(GV, "LLVMGlobal_", ".G_");
}
string getID(const ConstPoolVal *CV) {
string getID(const Constant *CV) {
return getID(CV, "LLVMConst_", ".C_");
}
@ -165,13 +165,13 @@ private :
// Can we treat the specified array as a string? Only if it is an array of
// ubytes or non-negative sbytes.
//
static bool isStringCompatible(ConstPoolArray *CPA) {
static bool isStringCompatible(ConstantArray *CPA) {
const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
if (ETy == Type::UByteTy) return true;
if (ETy != Type::SByteTy) return false;
for (unsigned i = 0; i < CPA->getNumOperands(); ++i)
if (cast<ConstPoolSInt>(CPA->getOperand(i))->getValue() < 0)
if (cast<ConstantSInt>(CPA->getOperand(i))->getValue() < 0)
return false;
return true;
@ -185,15 +185,15 @@ static inline char toOctal(int X) {
// getAsCString - Return the specified array as a C compatible string, only if
// the predicate isStringCompatible is true.
//
static string getAsCString(ConstPoolArray *CPA) {
static string getAsCString(ConstantArray *CPA) {
if (isStringCompatible(CPA)) {
string Result;
const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
Result = "\"";
for (unsigned i = 0; i < CPA->getNumOperands(); ++i) {
unsigned char C = (ETy == Type::SByteTy) ?
(unsigned char)cast<ConstPoolSInt>(CPA->getOperand(i))->getValue() :
(unsigned char)cast<ConstPoolUInt>(CPA->getOperand(i))->getValue();
(unsigned char)cast<ConstantSInt>(CPA->getOperand(i))->getValue() :
(unsigned char)cast<ConstantUInt>(CPA->getOperand(i))->getValue();
if (isprint(C)) {
Result += C;
@ -309,7 +309,7 @@ SparcAsmPrinter::printOneOperand(const MachineOperand &op)
toAsm << getID(M);
else if (const GlobalVariable *GV=dyn_cast<const GlobalVariable>(Val))
toAsm << getID(GV);
else if (const ConstPoolVal *CV = dyn_cast<const ConstPoolVal>(Val))
else if (const Constant *CV = dyn_cast<const Constant>(Val))
toAsm << getID(CV);
else
toAsm << "<unknown value=" << Val << ">";
@ -440,9 +440,9 @@ TypeToDataDirective(const Type* type)
// If this is an unsized array, return 0.
//
inline unsigned int
ConstantToSize(const ConstPoolVal* CV, const TargetMachine& target)
ConstantToSize(const Constant* CV, const TargetMachine& target)
{
if (ConstPoolArray* CPA = dyn_cast<ConstPoolArray>(CV))
if (ConstantArray* CPA = dyn_cast<ConstantArray>(CV))
{
ArrayType *aty = cast<ArrayType>(CPA->getType());
if (ArrayTypeIsString(aty))
@ -493,10 +493,10 @@ TypeToAlignment(const Type* type, const TargetMachine& target)
// Get the size of the constant and then use SizeToAlignment.
// Handles strings as a special case;
inline unsigned int
ConstantToAlignment(const ConstPoolVal* CV, const TargetMachine& target)
ConstantToAlignment(const Constant* CV, const TargetMachine& target)
{
unsigned int constantSize;
if (ConstPoolArray* CPA = dyn_cast<ConstPoolArray>(CV))
if (ConstantArray* CPA = dyn_cast<ConstantArray>(CV))
if (ArrayTypeIsString(cast<ArrayType>(CPA->getType())))
return SizeToAlignment(1 + CPA->getNumOperands(), target);
@ -506,14 +506,14 @@ ConstantToAlignment(const ConstPoolVal* CV, const TargetMachine& target)
// Print a single constant value.
void
SparcAsmPrinter::printSingleConstant(const ConstPoolVal* CV)
SparcAsmPrinter::printSingleConstant(const Constant* CV)
{
assert(CV->getType() != Type::VoidTy &&
CV->getType() != Type::TypeTy &&
CV->getType() != Type::LabelTy &&
"Unexpected type for ConstPoolVal");
"Unexpected type for Constant");
assert((! isa<ConstPoolArray>( CV) && ! isa<ConstPoolStruct>(CV))
assert((! isa<ConstantArray>( CV) && ! isa<ConstantStruct>(CV))
&& "Collective types should be handled outside this function");
toAsm << "\t"
@ -525,14 +525,14 @@ SparcAsmPrinter::printSingleConstant(const ConstPoolVal* CV)
toAsm << "0r"; // FP constants must have this prefix
toAsm << CV->getStrValue() << endl;
}
else if (ConstPoolPointer* CPP = dyn_cast<ConstPoolPointer>(CV))
else if (ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
{
if (! CPP->isNullValue())
assert(0 && "Cannot yet print non-null pointer constants to assembly");
else
toAsm << (void*) NULL << endl;
}
else if (ConstPoolPointerRef* CPRef = dyn_cast<ConstPoolPointerRef>(CV))
else if (ConstantPointerRef* CPRef = dyn_cast<ConstantPointerRef>(CV))
{
assert(0 && "Cannot yet initialize pointer refs in assembly");
}
@ -545,9 +545,9 @@ SparcAsmPrinter::printSingleConstant(const ConstPoolVal* CV)
// Print a constant value or values (it may be an aggregate).
// Uses printSingleConstant() to print each individual value.
void
SparcAsmPrinter::printConstantValueOnly(const ConstPoolVal* CV)
SparcAsmPrinter::printConstantValueOnly(const Constant* CV)
{
ConstPoolArray *CPA = dyn_cast<ConstPoolArray>(CV);
ConstantArray *CPA = dyn_cast<ConstantArray>(CV);
if (CPA && isStringCompatible(CPA))
{ // print the string alone and return
@ -557,13 +557,13 @@ SparcAsmPrinter::printConstantValueOnly(const ConstPoolVal* CV)
{ // Not a string. Print the values in successive locations
const vector<Use>& constValues = CPA->getValues();
for (unsigned i=1; i < constValues.size(); i++)
this->printConstantValueOnly(cast<ConstPoolVal>(constValues[i].get()));
this->printConstantValueOnly(cast<Constant>(constValues[i].get()));
}
else if (ConstPoolStruct *CPS = dyn_cast<ConstPoolStruct>(CV))
else if (ConstantStruct *CPS = dyn_cast<ConstantStruct>(CV))
{ // Print the fields in successive locations
const vector<Use>& constValues = CPS->getValues();
for (unsigned i=1; i < constValues.size(); i++)
this->printConstantValueOnly(cast<ConstPoolVal>(constValues[i].get()));
this->printConstantValueOnly(cast<Constant>(constValues[i].get()));
}
else
this->printSingleConstant(CV);
@ -573,7 +573,7 @@ SparcAsmPrinter::printConstantValueOnly(const ConstPoolVal* CV)
// appropriate directives. Uses printConstantValueOnly() to print the
// value or values.
void
SparcAsmPrinter::printConstant(const ConstPoolVal* CV, string valID)
SparcAsmPrinter::printConstant(const Constant* CV, string valID)
{
if (valID.length() == 0)
valID = getID(CV);
@ -582,7 +582,7 @@ SparcAsmPrinter::printConstant(const ConstPoolVal* CV, string valID)
<< endl;
// Print .size and .type only if it is not a string.
ConstPoolArray *CPA = dyn_cast<ConstPoolArray>(CV);
ConstantArray *CPA = dyn_cast<ConstantArray>(CV);
if (CPA && isStringCompatible(CPA))
{ // print it as a string and return
toAsm << valID << ":" << endl;
@ -622,15 +622,15 @@ SparcAsmPrinter::printGlobalVariable(const GlobalVariable* GV)
static void
FoldConstPools(const Module *M,
hash_set<const ConstPoolVal*>& moduleConstPool)
FoldConstants(const Module *M,
hash_set<const Constant*>& moduleConstants)
{
for (Module::const_iterator I = M->begin(), E = M->end(); I != E; ++I)
if (! (*I)->isExternal())
{
const hash_set<const ConstPoolVal*>& pool =
const hash_set<const Constant*>& pool =
MachineCodeForMethod::get(*I).getConstantPoolValues();
moduleConstPool.insert(pool.begin(), pool.end());
moduleConstants.insert(pool.begin(), pool.end());
}
}
@ -644,8 +644,8 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M)
// lets force these constants into the slot table so that we can get
// unique names for unnamed constants also.
//
hash_set<const ConstPoolVal*> moduleConstPool;
FoldConstPools(M, moduleConstPool);
hash_set<const Constant*> moduleConstants;
FoldConstants(M, moduleConstants);
// Now, emit the three data sections separately; the cost of I/O should
// make up for the cost of extra passes over the globals list!
@ -662,8 +662,8 @@ SparcAsmPrinter::emitGlobalsAndConstants(const Module *M)
}
}
for (hash_set<const ConstPoolVal*>::const_iterator I=moduleConstPool.begin(),
E = moduleConstPool.end(); I != E; ++I)
for (hash_set<const Constant*>::const_iterator I = moduleConstants.begin(),
E = moduleConstants.end(); I != E; ++I)
printConstant(*I);
// Initialized read-write data section

View File

@ -17,7 +17,7 @@
#include "llvm/CodeGen/InstrSelectionSupport.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Method.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Type.h"
@ -81,7 +81,7 @@ UltraSparcInstrInfo::UltraSparcInstrInfo(const TargetMachine& tgt)
// Create an instruction sequence to put the constant `val' into
// the virtual register `dest'. `val' may be a ConstPoolVal or a
// the virtual register `dest'. `val' may be a Constant or a
// GlobalValue, viz., the constant address of a global variable or function.
// The generated instructions are returned in `minstrVec'.
// Any temp. registers (TmpInstruction) created are returned in `tempVec'.
@ -94,7 +94,7 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val,
{
MachineInstr* minstr;
assert(isa<ConstPoolVal>(val) || isa<GlobalValue>(val) &&
assert(isa<Constant>(val) || isa<GlobalValue>(val) &&
"I only know about constant values and global addresses");
// Use a "set" instruction for known constants that can go in an integer reg.
@ -127,7 +127,7 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val,
PointerType::get(val->getType()), val, NULL);
tempVec.push_back(tmpReg);
if (isa<ConstPoolVal>(val))
if (isa<Constant>(val))
{
// Create another TmpInstruction for the hidden integer register
TmpInstruction* addrReg =
@ -146,7 +146,7 @@ UltraSparcInstrInfo::CreateCodeToLoadConst(Value* val,
minstr->SetMachineOperand(2, MachineOperand::MO_VirtualRegister,addrVal);
minstrVec.push_back(minstr);
if (isa<ConstPoolVal>(val))
if (isa<Constant>(val))
{
// addrVal->addMachineInstruction(minstr);

View File

@ -22,7 +22,7 @@
#include "llvm/iOther.h"
#include "llvm/BasicBlock.h"
#include "llvm/Method.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "Support/MathExtras.h"
#include <math.h>
@ -34,7 +34,7 @@ static void SetMemOperands_Internal (MachineInstr* minstr,
const InstructionNode* vmInstrNode,
Value* ptrVal,
Value* arrayOffsetVal,
const vector<ConstPoolVal*>& idxVec,
const vector<Constant*>& idxVec,
const TargetMachine& target);
@ -367,7 +367,7 @@ CreateAddConstInstruction(const InstructionNode* instrNode)
MachineInstr* minstr = NULL;
Value* constOp = ((InstrTreeNode*) instrNode->rightChild())->getValue();
assert(isa<ConstPoolVal>(constOp));
assert(isa<Constant>(constOp));
// Cases worth optimizing are:
// (1) Add with 0 for float or double: use an FMOV of appropriate type,
@ -378,7 +378,7 @@ CreateAddConstInstruction(const InstructionNode* instrNode)
if (resultType == Type::FloatTy ||
resultType == Type::DoubleTy)
{
double dval = ((ConstPoolFP*) constOp)->getValue();
double dval = cast<ConstantFP>(constOp)->getValue();
if (dval == 0.0)
minstr = CreateMovFloatInstruction(instrNode, resultType);
}
@ -415,7 +415,7 @@ CreateSubConstInstruction(const InstructionNode* instrNode)
MachineInstr* minstr = NULL;
Value* constOp = ((InstrTreeNode*) instrNode->rightChild())->getValue();
assert(isa<ConstPoolVal>(constOp));
assert(isa<Constant>(constOp));
// Cases worth optimizing are:
// (1) Sub with 0 for float or double: use an FMOV of appropriate type,
@ -426,7 +426,7 @@ CreateSubConstInstruction(const InstructionNode* instrNode)
if (resultType == Type::FloatTy ||
resultType == Type::DoubleTy)
{
double dval = ((ConstPoolFP*) constOp)->getValue();
double dval = cast<ConstantFP>(constOp)->getValue();
if (dval == 0.0)
minstr = CreateMovFloatInstruction(instrNode, resultType);
}
@ -522,7 +522,7 @@ CreateMulConstInstruction(TargetMachine &target,
bool needNeg = false;
Value* constOp = ((InstrTreeNode*) instrNode->rightChild())->getValue();
assert(isa<ConstPoolVal>(constOp));
assert(isa<Constant>(constOp));
// Cases worth optimizing are:
// (1) Multiply by 0 or 1 for any type: replace with copy (ADD or FMOV)
@ -578,7 +578,7 @@ CreateMulConstInstruction(TargetMachine &target,
if (resultType == Type::FloatTy ||
resultType == Type::DoubleTy)
{
double dval = ((ConstPoolFP*) constOp)->getValue();
double dval = cast<ConstantFP>(constOp)->getValue();
if (fabs(dval) == 1)
{
bool needNeg = (dval < 0);
@ -638,7 +638,7 @@ CreateDivConstInstruction(TargetMachine &target,
getMinstr2 = NULL;
Value* constOp = ((InstrTreeNode*) instrNode->rightChild())->getValue();
assert(isa<ConstPoolVal>(constOp));
assert(isa<Constant>(constOp));
// Cases worth optimizing are:
// (1) Divide by 1 for any type: replace with copy (ADD or FMOV)
@ -691,7 +691,7 @@ CreateDivConstInstruction(TargetMachine &target,
if (resultType == Type::FloatTy ||
resultType == Type::DoubleTy)
{
double dval = ((ConstPoolFP*) constOp)->getValue();
double dval = cast<ConstantFP>(constOp)->getValue();
if (fabs(dval) == 1)
{
bool needNeg = (dval < 0);
@ -742,9 +742,9 @@ SetOperandsForMemInstr(MachineInstr* minstr,
// The major work here is to extract these for all 3 instruction types
// and then call the common function SetMemOperands_Internal().
//
const vector<ConstPoolVal*> OLDIDXVEC = memInst->getIndicesBROKEN();
const vector<ConstPoolVal*>* idxVec = &OLDIDXVEC; //FIXME
vector<ConstPoolVal*>* newIdxVec = NULL;
const vector<Constant*> OLDIDXVEC = memInst->getIndicesBROKEN();
const vector<Constant*>* idxVec = &OLDIDXVEC; //FIXME
vector<Constant*>* newIdxVec = NULL;
Value* ptrVal;
Value* arrayOffsetVal = NULL;
@ -765,7 +765,7 @@ SetOperandsForMemInstr(MachineInstr* minstr,
// instruction into one single index vector.
// Finally, we never fold for an array instruction so make that NULL.
newIdxVec = new vector<ConstPoolVal*>;
newIdxVec = new vector<Constant*>;
ptrVal = FoldGetElemChain((InstructionNode*) ptrChild, *newIdxVec);
newIdxVec->insert(newIdxVec->end(), idxVec->begin(), idxVec->end());
@ -806,7 +806,7 @@ SetMemOperands_Internal(MachineInstr* minstr,
const InstructionNode* vmInstrNode,
Value* ptrVal,
Value* arrayOffsetVal,
const vector<ConstPoolVal*>& idxVec,
const vector<Constant*>& idxVec,
const TargetMachine& target)
{
MemAccessInst* memInst = (MemAccessInst*) vmInstrNode->getInstruction();
@ -843,13 +843,13 @@ SetMemOperands_Internal(MachineInstr* minstr,
assert(arrayOffsetVal != NULL
&& "Expect to be given Value* for array offsets");
if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(arrayOffsetVal))
if (Constant *CPV = dyn_cast<Constant>(arrayOffsetVal))
{
isConstantOffset = true; // always constant for structs
assert(arrayOffsetVal->getType()->isIntegral());
offset = (CPV->getType()->isSigned()
? ((ConstPoolSInt*)CPV)->getValue()
: (int64_t) ((ConstPoolUInt*)CPV)->getValue());
? cast<ConstantSInt>(CPV)->getValue()
: (int64_t) cast<ConstantUInt>(CPV)->getValue());
}
else
{
@ -860,7 +860,7 @@ SetMemOperands_Internal(MachineInstr* minstr,
if (isConstantOffset)
{
// create a virtual register for the constant
valueForRegOffset = ConstPoolSInt::get(Type::IntTy, offset);
valueForRegOffset = ConstantSInt::get(Type::IntTy, offset);
}
}
else
@ -963,7 +963,7 @@ CreateCopyInstructionsByType(const TargetMachine& target,
// a global variable (i.e., a constant address), generate a load
// instruction instead of an add
//
if (isa<ConstPoolVal>(src))
if (isa<Constant>(src))
{
unsigned int machineRegNum;
int64_t immedValue;
@ -995,7 +995,7 @@ CreateCopyInstructionsByType(const TargetMachine& target,
: resultType;
MachineInstr* minstr = new MachineInstr(opCode);
minstr->SetMachineOperand(0, MachineOperand::MO_VirtualRegister,
ConstPoolVal::getNullConstant(nullValueType));
Constant::getNullConstant(nullValueType));
minstr->SetMachineOperand(1, MachineOperand::MO_VirtualRegister, src);
minstr->SetMachineOperand(2, MachineOperand::MO_VirtualRegister, dest);
minstrVec.push_back(minstr);
@ -1159,7 +1159,8 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
// Mark the return value register as an implicit ref of
// the machine instruction.
// Finally put a NOP in the delay slot.
ReturnInst* returnInstr = (ReturnInst*) subtreeRoot->getInstruction();
ReturnInst *returnInstr =
cast<ReturnInst>(subtreeRoot->getInstruction());
assert(returnInstr->getOpcode() == Instruction::Ret);
Method* method = returnInstr->getParent()->getParent();
@ -1195,7 +1196,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
mvec[0]->SetMachineOperand(0, MachineOperand::MO_CCRegister,
(Value*)NULL);
mvec[0]->SetMachineOperand(1, MachineOperand::MO_PCRelativeDisp,
((BranchInst*) subtreeRoot->getInstruction())->getSuccessor(0));
cast<BranchInst>(subtreeRoot->getInstruction())->getSuccessor(0));
// delay slot
mvec[numInstr++] = new MachineInstr(NOP);
@ -1210,7 +1211,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
InstrTreeNode* constNode = subtreeRoot->leftChild()->rightChild();
assert(constNode &&
constNode->getNodeType() ==InstrTreeNode::NTConstNode);
ConstPoolVal* constVal = (ConstPoolVal*) constNode->getValue();
Constant *constVal = cast<Constant>(constNode->getValue());
bool isValidConst;
if ((constVal->getType()->isIntegral()
@ -1287,9 +1288,9 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
case 208: // stmt: BrCond(boolconst)
{
// boolconst => boolean is a constant; use BA to first or second label
ConstPoolVal* constVal =
cast<ConstPoolVal>(subtreeRoot->leftChild()->getValue());
unsigned dest = ((ConstPoolBool*) constVal)->getValue()? 0 : 1;
Constant* constVal =
cast<Constant>(subtreeRoot->leftChild()->getValue());
unsigned dest = cast<ConstantBool>(constVal)->getValue()? 0 : 1;
mvec[0] = new MachineInstr(BA);
mvec[0]->SetMachineOperand(0, MachineOperand::MO_CCRegister,
@ -1861,7 +1862,7 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
// Create a temporary Value to hold the constant offset.
// This is needed because it may not fit in the immediate field.
ConstPoolSInt* offsetVal=ConstPoolSInt::get(Type::IntTy, offsetFromFP);
ConstantSInt* offsetVal = ConstantSInt::get(Type::IntTy, offsetFromFP);
// Instruction 1: add %fp, offsetFromFP -> result
mvec[0] = new MachineInstr(ADD);
@ -1888,12 +1889,12 @@ GetInstructionsByRule(InstructionNode* subtreeRoot,
assert(tsize != 0 && "Just to check when this can happen");
// Create a temporary Value to hold the constant type-size
ConstPoolSInt* tsizeVal = ConstPoolSInt::get(Type::IntTy, tsize);
ConstantSInt* tsizeVal = ConstantSInt::get(Type::IntTy, tsize);
// Create a temporary Value to hold the constant offset from SP
Method* method = instr->getParent()->getParent();
bool ignore; // we don't need this
ConstPoolSInt* dynamicAreaOffset = ConstPoolSInt::get(Type::IntTy,
ConstantSInt* dynamicAreaOffset = ConstantSInt::get(Type::IntTy,
target.getFrameInfo().getDynamicAreaOffset(MachineCodeForMethod::get(method),
ignore));

View File

@ -12,7 +12,7 @@
#include "llvm/Target/TargetData.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
static inline void getTypeInfo(const Type *Ty, const TargetData *TD,
unsigned &Size, unsigned char &Alignment);
@ -146,7 +146,7 @@ unsigned char TargetData::getTypeAlignment(const Type *Ty) const {
}
unsigned TargetData::getIndexedOffset(const Type *ptrTy,
const vector<ConstPoolVal*> &Idx) const {
const vector<Constant*> &Idx) const {
const PointerType *PtrTy = cast<const PointerType>(ptrTy);
unsigned Result = 0;
@ -156,7 +156,7 @@ unsigned TargetData::getIndexedOffset(const Type *ptrTy,
for (unsigned CurIDX = 0; CurIDX < Idx.size(); ++CurIDX) {
if (const StructType *STy = dyn_cast<const StructType>(Ty)) {
assert(Idx[CurIDX]->getType() == Type::UByteTy && "Illegal struct idx");
unsigned FieldNo = ((ConstPoolUInt*)Idx[CurIDX])->getValue();
unsigned FieldNo = cast<ConstantUInt>(Idx[CurIDX])->getValue();
// Get structure layout information...
const StructLayout *Layout = getStructLayout(STy);

View File

@ -11,7 +11,7 @@
#include "llvm/iOther.h"
#include "llvm/iPHINode.h"
#include "llvm/iMemory.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Optimizations/ConstantHandling.h"
#include "llvm/Optimizations/DCE.h"
#include "llvm/Analysis/Expressions.h"
@ -36,7 +36,7 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
static bool AllIndicesZero(const MemAccessInst *MAI) {
for (User::op_const_iterator S = MAI->idx_begin(), E = MAI->idx_end();
S != E; ++S)
if (!isa<ConstPoolVal>(*S) || !cast<ConstPoolVal>(*S)->isNullValue())
if (!isa<Constant>(*S) || !cast<Constant>(*S)->isNullValue())
return false;
return true;
}
@ -155,7 +155,7 @@ static Instruction *ConvertMallocToType(MallocInst *MI, const Type *Ty,
unsigned DataSize = TD.getTypeSize(ElType);
if (OffsetAmount > DataSize) // Allocate a sized array amount...
Expr.Var = ConstPoolUInt::get(Type::UIntTy, OffsetAmount/DataSize);
Expr.Var = ConstantUInt::get(Type::UIntTy, OffsetAmount/DataSize);
}
#endif
@ -198,7 +198,7 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
// const prop'd in general). We just ask the constant propogator to see if
// it can convert the value...
//
if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V))
if (Constant *CPV = dyn_cast<Constant>(V))
if (opt::ConstantFoldCastInstruction(CPV, Ty))
return true; // Don't worry about deallocating, it's a constant.
@ -285,8 +285,8 @@ bool ExpressionConvertableToType(Value *V, const Type *Ty,
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *ElTy = 0;
while (!Indices.empty() && isa<ConstPoolUInt>(Indices.back()) &&
cast<ConstPoolUInt>(Indices.back())->getValue() == 0) {
while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) &&
cast<ConstantUInt>(Indices.back())->getValue() == 0) {
Indices.pop_back();
ElTy = GetElementPtrInst::getIndexedType(BaseType, Indices,
true);
@ -329,7 +329,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
Instruction *I = dyn_cast<Instruction>(V);
if (I == 0)
if (ConstPoolVal *CPV = cast<ConstPoolVal>(V)) {
if (Constant *CPV = cast<Constant>(V)) {
// Constants are converted by constant folding the cast that is required.
// We assume here that all casts are implemented for constant prop.
Value *Result = opt::ConstantFoldCastInstruction(CPV, Ty);
@ -349,7 +349,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
ValueHandle IHandle(VMC, I); // Prevent I from being removed!
ConstPoolVal *Dummy = ConstPoolVal::getNullConstant(Ty);
Constant *Dummy = Constant::getNullConstant(Ty);
//cerr << endl << endl << "Type:\t" << Ty << "\nInst: " << I << "BB Before: " << BB << endl;
@ -380,8 +380,7 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
LoadInst *LI = cast<LoadInst>(I);
assert(!LI->hasIndices() || AllIndicesZero(LI));
Res = new LoadInst(ConstPoolVal::getNullConstant(PointerType::get(Ty)),
Name);
Res = new LoadInst(Constant::getNullConstant(PointerType::get(Ty)), Name);
VMC.ExprMap[I] = Res;
Res->setOperand(0, ConvertExpressionToType(LI->getPointerOperand(),
PointerType::get(Ty), VMC));
@ -433,8 +432,8 @@ Value *ConvertExpressionToType(Value *V, const Type *Ty, ValueMapCache &VMC) {
const Type *BaseType = GEP->getPointerOperand()->getType();
const Type *PVTy = cast<PointerType>(Ty)->getValueType();
Res = 0;
while (!Indices.empty() && isa<ConstPoolUInt>(Indices.back()) &&
cast<ConstPoolUInt>(Indices.back())->getValue() == 0) {
while (!Indices.empty() && isa<ConstantUInt>(Indices.back()) &&
cast<ConstantUInt>(Indices.back())->getValue() == 0) {
Indices.pop_back();
if (GetElementPtrInst::getIndexedType(BaseType, Indices, true) == PVTy) {
if (Indices.size() == 0) {
@ -723,8 +722,8 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
ValueHandle IHandle(VMC, I);
const Type *NewTy = NewVal->getType();
ConstPoolVal *Dummy = (NewTy != Type::VoidTy) ?
ConstPoolVal::getNullConstant(NewTy) : 0;
Constant *Dummy = (NewTy != Type::VoidTy) ?
Constant::getNullConstant(NewTy) : 0;
switch (I->getOpcode()) {
case Instruction::Cast:
@ -793,12 +792,12 @@ static void ConvertOperandToType(User *U, Value *OldVal, Value *NewVal,
case Instruction::Store: {
if (I->getOperand(0) == OldVal) { // Replace the source value
const PointerType *NewPT = PointerType::get(NewTy);
Res = new StoreInst(NewVal, ConstPoolVal::getNullConstant(NewPT));
Res = new StoreInst(NewVal, Constant::getNullConstant(NewPT));
VMC.ExprMap[I] = Res;
Res->setOperand(1, ConvertExpressionToType(I->getOperand(1), NewPT, VMC));
} else { // Replace the source pointer
const Type *ValTy = cast<PointerType>(NewTy)->getValueType();
Res = new StoreInst(ConstPoolVal::getNullConstant(ValTy), NewVal);
Res = new StoreInst(Constant::getNullConstant(ValTy), NewVal);
VMC.ExprMap[I] = Res;
Res->setOperand(0, ConvertExpressionToType(I->getOperand(0), ValTy, VMC));
}

View File

@ -51,32 +51,29 @@ bool HoistPHIConstants::doHoistPHIConstants(Method *M) {
CachedCopyMap Cache;
bool Changed = false;
for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI)
{
vector<PHINode*> phis; // normalizing invalidates BB iterator
for (Method::iterator BI = M->begin(), BE = M->end(); BI != BE; ++BI) {
vector<PHINode*> phis; // normalizing invalidates BB iterator
for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II)
{
if (PHINode *PN = dyn_cast<PHINode>(*II))
phis.push_back(PN);
else
break; // All PHIs occur at top of BB!
}
for (BasicBlock::iterator II = (*BI)->begin(); II != (*BI)->end(); ++II) {
if (PHINode *PN = dyn_cast<PHINode>(*II))
phis.push_back(PN);
else
break; // All PHIs occur at top of BB!
}
for (vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end(); ++PI)
for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i)
{
Value *Op = (*PI)->getIncomingValue(i);
if (isa<ConstPoolVal>(Op)) {
(*PI)->setIncomingValue(i,
for (vector<PHINode*>::iterator PI=phis.begin(); PI != phis.end(); ++PI)
for (unsigned i = 0; i < (*PI)->getNumIncomingValues(); ++i) {
Value *Op = (*PI)->getIncomingValue(i);
if (isa<Constant>(Op)) {
(*PI)->setIncomingValue(i,
NormalizePhiOperand((*PI),
(*PI)->getIncomingValue(i),
(*PI)->getIncomingBlock(i), Cache));
Changed = true;
}
}
}
Changed = true;
}
}
}
return Changed;
}

View File

@ -23,7 +23,7 @@
//
static inline
bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
map<ConstPoolVal*, GlobalVariable*> &CMap) {
map<Constant*, GlobalVariable*> &CMap) {
Module::GlobalListType &GList = M->getGlobalList();
if (GList.size() <= ConstantNo) return false; // No new constants
bool MadeChanges = false;
@ -32,10 +32,10 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
GlobalVariable *GV = GList[ConstantNo];
if (GV->isConstant()) { // Only process constants
assert(GV->hasInitializer() && "Globals constants must have inits!");
ConstPoolVal *Init = GV->getInitializer();
Constant *Init = GV->getInitializer();
// Check to see if the initializer is already known...
map<ConstPoolVal*, GlobalVariable*>::iterator I = CMap.find(Init);
map<Constant*, GlobalVariable*>::iterator I = CMap.find(Init);
if (I == CMap.end()) { // Nope, add it to the map
CMap.insert(make_pair(Init, GV));
@ -59,7 +59,7 @@ bool mergeDuplicateConstants(Module *M, unsigned &ConstantNo,
// deal with passes.
//
bool ConstantMerge::mergeDuplicateConstants(Module *M) {
map<ConstPoolVal*, GlobalVariable*> Constants;
map<Constant*, GlobalVariable*> Constants;
unsigned LastConstantSeen = 0;
return ::mergeDuplicateConstants(M, LastConstantSeen, Constants);
}

View File

@ -458,13 +458,13 @@ static inline void CheckIncomingValueFor(PHINode *PN, BasicBlock *BB) {
const Type *Ty = PN->getType();
if (const PointerType *PT = dyn_cast<PointerType>(Ty))
NewVal = ConstPoolPointerNull::get(PT);
NewVal = ConstantPointerNull::get(PT);
else if (Ty == Type::BoolTy)
NewVal = ConstPoolBool::True;
NewVal = ConstantBool::True;
else if (Ty == Type::FloatTy || Ty == Type::DoubleTy)
NewVal = ConstPoolFP::get(Ty, 42);
NewVal = ConstantFP::get(Ty, 42);
else if (Ty->isIntegral())
NewVal = ConstPoolInt::get(Ty, 42);
NewVal = ConstantInt::get(Ty, 42);
assert(NewVal && "Unknown PHI node type!");
PN->addIncoming(NewVal, BB);

View File

@ -41,7 +41,7 @@ static inline void RemapInstruction(Instruction *I,
for (unsigned op = 0, E = I->getNumOperands(); op != E; ++op) {
const Value *Op = I->getOperand(op);
Value *V = ValueMap[Op];
if (!V && (isa<GlobalValue>(Op) || isa<ConstPoolVal>(Op)))
if (!V && (isa<GlobalValue>(Op) || isa<Constant>(Op)))
continue; // Globals and constants don't get relocated
if (!V) {

View File

@ -115,7 +115,7 @@ void MutateStructTypes::AdjustIndices(const CompositeType *OldTy,
if (const StructType *OldST = dyn_cast<StructType>(OldTy)) {
// Figure out what the current index is...
unsigned ElNum = cast<ConstPoolUInt>(Idx[i])->getValue();
unsigned ElNum = cast<ConstantUInt>(Idx[i])->getValue();
assert(ElNum < OldST->getElementTypes().size());
map<const StructType*, TransformType>::iterator I = Transforms.find(OldST);
@ -123,7 +123,7 @@ void MutateStructTypes::AdjustIndices(const CompositeType *OldTy,
assert(ElNum < I->second.second.size());
// Apply the XForm specified by Transforms map...
unsigned NewElNum = I->second.second[ElNum];
Idx[i] = ConstPoolUInt::get(Type::UByteTy, NewElNum);
Idx[i] = ConstantUInt::get(Type::UByteTy, NewElNum);
}
}
@ -140,12 +140,12 @@ Value *MutateStructTypes::ConvertValue(const Value *V) {
// Ignore null values and simple constants..
if (V == 0) return 0;
if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {
if (Constant *CPV = dyn_cast<Constant>(V)) {
if (V->getType()->isPrimitiveType())
return CPV;
if (isa<ConstPoolPointerNull>(CPV))
return ConstPoolPointerNull::get(
if (isa<ConstantPointerNull>(CPV))
return ConstantPointerNull::get(
cast<PointerType>(ConvertType(V->getType())));
assert(0 && "Unable to convert constpool val of this type!");
}

View File

@ -15,7 +15,7 @@
#include "llvm/Transforms/Instrumentation/TraceValues.h"
#include "llvm/GlobalVariable.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Type.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instruction.h"
@ -68,7 +68,7 @@ PrintMethodNameForType(const Type* type)
}
static inline GlobalVariable *GetStringRef(Module *M, const string &str) {
ConstPoolArray *Init = ConstPoolArray::get(str);
ConstantArray *Init = ConstantArray::get(str);
GlobalVariable *GV = new GlobalVariable(Init->getType(), /*Const*/true,
/*intern*/true, Init);
M->getGlobalList().push_back(GV);

View File

@ -11,7 +11,7 @@
#include "llvm/Method.h"
#include "llvm/iOther.h"
#include "llvm/iMemory.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Optimizations/ConstantHandling.h"
#include "llvm/Optimizations/DCE.h"
#include "llvm/Optimizations/ConstantProp.h"
@ -175,7 +175,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
#endif
ValueMapCache ValueMap;
Value *E = ConvertExpressionToType(Src, DestTy, ValueMap);
if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(E))
if (Constant *CPV = dyn_cast<Constant>(E))
CI->replaceAllUsesWith(CPV);
BI = BB->begin(); // Rescan basic block. BI might be invalidated.
@ -242,7 +242,7 @@ static bool PeepholeOptimize(BasicBlock *BB, BasicBlock::iterator &BI) {
}
// Insert a zero to index through this type...
Indices.push_back(ConstPoolUInt::get(CurCTy->getIndexType(), 0));
Indices.push_back(ConstantUInt::get(CurCTy->getIndexType(), 0));
// Did we find what we're looking for?
if (ElTy->isLosslesslyConvertableTo(DestPointedTy)) break;
@ -502,8 +502,7 @@ static bool DoInsertArrayCast(Value *V, BasicBlock *BB,
// Insert a cast!
CastInst *TheCast =
new CastInst(ConstPoolVal::getNullConstant(V->getType()), DestTy,
V->getName());
new CastInst(Constant::getNullConstant(V->getType()), DestTy, V->getName());
BB->getInstList().insert(InsertBefore, TheCast);
cerr << "Inserting cast for " << V << endl;

View File

@ -29,12 +29,12 @@
#include "llvm/iTerminators.h"
#include "llvm/iPHINode.h"
#include "llvm/iOther.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
inline static bool
ConstantFoldUnaryInst(BasicBlock *BB, BasicBlock::iterator &II,
UnaryOperator *Op, ConstPoolVal *D) {
ConstPoolVal *ReplaceWith =
UnaryOperator *Op, Constant *D) {
Constant *ReplaceWith =
opt::ConstantFoldUnaryInstruction(Op->getOpcode(), D);
if (!ReplaceWith) return false; // Nothing new to change...
@ -56,8 +56,8 @@ ConstantFoldUnaryInst(BasicBlock *BB, BasicBlock::iterator &II,
inline static bool
ConstantFoldCast(BasicBlock *BB, BasicBlock::iterator &II,
CastInst *CI, ConstPoolVal *D) {
ConstPoolVal *ReplaceWith =
CastInst *CI, Constant *D) {
Constant *ReplaceWith =
opt::ConstantFoldCastInstruction(D, CI->getType());
if (!ReplaceWith) return false; // Nothing new to change...
@ -80,8 +80,8 @@ ConstantFoldCast(BasicBlock *BB, BasicBlock::iterator &II,
inline static bool
ConstantFoldBinaryInst(BasicBlock *BB, BasicBlock::iterator &II,
BinaryOperator *Op,
ConstPoolVal *D1, ConstPoolVal *D2) {
ConstPoolVal *ReplaceWith =
Constant *D1, Constant *D2) {
Constant *ReplaceWith =
opt::ConstantFoldBinaryInstruction(Op->getOpcode(), D1, D2);
if (!ReplaceWith) return false; // Nothing new to change...
@ -111,7 +111,7 @@ bool opt::ConstantFoldTerminator(TerminatorInst *T) {
BasicBlock *Dest1 = cast<BasicBlock>(BI->getOperand(0));
BasicBlock *Dest2 = cast<BasicBlock>(BI->getOperand(1));
if (ConstPoolBool *Cond = dyn_cast<ConstPoolBool>(BI->getCondition())) {
if (ConstantBool *Cond = dyn_cast<ConstantBool>(BI->getCondition())) {
// Are we branching on constant?
// YES. Change to unconditional branch...
BasicBlock *Destination = Cond->getValue() ? Dest1 : Dest2;
@ -160,18 +160,18 @@ bool opt::ConstantPropogation::doConstantPropogation(BasicBlock *BB,
BasicBlock::iterator &II) {
Instruction *Inst = *II;
if (BinaryOperator *BInst = dyn_cast<BinaryOperator>(Inst)) {
ConstPoolVal *D1 = dyn_cast<ConstPoolVal>(Inst->getOperand(0));
ConstPoolVal *D2 = dyn_cast<ConstPoolVal>(Inst->getOperand(1));
Constant *D1 = dyn_cast<Constant>(Inst->getOperand(0));
Constant *D2 = dyn_cast<Constant>(Inst->getOperand(1));
if (D1 && D2)
return ConstantFoldBinaryInst(BB, II, cast<BinaryOperator>(Inst), D1, D2);
} else if (CastInst *CI = dyn_cast<CastInst>(Inst)) {
ConstPoolVal *D = dyn_cast<ConstPoolVal>(CI->getOperand(0));
Constant *D = dyn_cast<Constant>(CI->getOperand(0));
if (D) return ConstantFoldCast(BB, II, CI, D);
} else if (UnaryOperator *UInst = dyn_cast<UnaryOperator>(Inst)) {
ConstPoolVal *D = dyn_cast<ConstPoolVal>(UInst->getOperand(0));
Constant *D = dyn_cast<Constant>(UInst->getOperand(0));
if (D) return ConstantFoldUnaryInst(BB, II, UInst, D);
} else if (TerminatorInst *TInst = dyn_cast<TerminatorInst>(Inst)) {
return opt::ConstantFoldTerminator(TInst);

View File

@ -96,7 +96,7 @@ static bool RemoveSingularPHIs(BasicBlock *BB) {
}
static void ReplaceUsesWithConstant(Instruction *I) {
ConstPoolVal *CPV = ConstPoolVal::getNullConstant(I->getType());
Constant *CPV = Constant::getNullConstant(I->getType());
// Make all users of this instruction reference the constant instead
I->replaceAllUsesWith(CPV);
@ -166,7 +166,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) {
// Remove basic blocks that have no predecessors... which are unreachable.
if (BB->pred_begin() == BB->pred_end() &&
!BB->hasConstantPoolReferences()) {
!BB->hasConstantReferences()) {
//cerr << "Removing BB: \n" << BB;
// Loop through all of our successors and make sure they know that one
@ -225,7 +225,7 @@ bool opt::SimplifyCFG(Method::iterator &BBIt) {
// and if there is only one successor of the predecessor.
BasicBlock::pred_iterator PI(BB->pred_begin());
if (PI != BB->pred_end() && *PI != BB && // Not empty? Not same BB?
++PI == BB->pred_end() && !BB->hasConstantPoolReferences()) {
++PI == BB->pred_end() && !BB->hasConstantReferences()) {
BasicBlock *Pred = *BB->pred_begin();
TerminatorInst *Term = Pred->getTerminator();
assert(Term != 0 && "malformed basic block without terminator!");

View File

@ -20,7 +20,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/Optimizations/InductionVars.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Analysis/IntervalPartition.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/SymbolTable.h"
@ -36,7 +36,7 @@ using namespace opt;
// an interval invariant computation.
//
static bool isLoopInvariant(cfg::Interval *Int, Value *V) {
assert(isa<ConstPoolVal>(V) || isa<Instruction>(V) || isa<MethodArgument>(V));
assert(isa<Constant>(V) || isa<Instruction>(V) || isa<MethodArgument>(V));
if (!isa<Instruction>(V))
return true; // Constants and arguments are always loop invariant
@ -132,12 +132,12 @@ static inline bool isLinearInductionVariable(cfg::Interval *Int, Value *V,
static inline bool isSimpleInductionVar(PHINode *PN) {
assert(PN->getNumIncomingValues() == 2 && "Must have cannonical PHI node!");
Value *Initializer = PN->getIncomingValue(0);
if (!isa<ConstPoolVal>(Initializer)) return false;
if (!isa<Constant>(Initializer)) return false;
if (Initializer->getType()->isSigned()) { // Signed constant value...
if (((ConstPoolSInt*)Initializer)->getValue() != 0) return false;
if (((ConstantSInt*)Initializer)->getValue() != 0) return false;
} else if (Initializer->getType()->isUnsigned()) { // Unsigned constant value
if (((ConstPoolUInt*)Initializer)->getValue() != 0) return false;
if (((ConstantUInt*)Initializer)->getValue() != 0) return false;
} else {
return false; // Not signed or unsigned? Must be FP type or something
}
@ -153,12 +153,12 @@ static inline bool isSimpleInductionVar(PHINode *PN) {
// Get the right hand side of the ADD node. See if it is a constant 1.
Value *StepSize = I->getOperand(1);
if (!isa<ConstPoolVal>(StepSize)) return false;
if (!isa<Constant>(StepSize)) return false;
if (StepSize->getType()->isSigned()) { // Signed constant value...
if (((ConstPoolSInt*)StepSize)->getValue() != 1) return false;
if (((ConstantSInt*)StepSize)->getValue() != 1) return false;
} else if (StepSize->getType()->isUnsigned()) { // Unsigned constant value
if (((ConstPoolUInt*)StepSize)->getValue() != 1) return false;
if (((ConstantUInt*)StepSize)->getValue() != 1) return false;
} else {
return false; // Not signed or unsigned? Must be FP type or something
}
@ -189,8 +189,8 @@ static PHINode *InjectSimpleInductionVariable(cfg::Interval *Int) {
// Create the neccesary instructions...
PHINode *PN = new PHINode(Type::UIntTy, PHIName);
ConstPoolVal *One = ConstPoolUInt::get(Type::UIntTy, 1);
ConstPoolVal *Zero = ConstPoolUInt::get(Type::UIntTy, 0);
Constant *One = ConstantUInt::get(Type::UIntTy, 1);
Constant *Zero = ConstantUInt::get(Type::UIntTy, 0);
BinaryOperator *AddNode = BinaryOperator::create(Instruction::Add,
PN, One, AddName);

View File

@ -13,7 +13,7 @@
#include "llvm/iMemory.h"
#include "llvm/iOther.h"
#include "llvm/SymbolTable.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
// doPassInitialization - For the lower allocations pass, this ensures that a
// module contains a declaration for a malloc and a free function.
@ -80,7 +80,7 @@ bool LowerAllocations::doPerMethodWork(Method *M) {
unsigned Size = DataLayout.getTypeSize(AllocTy);
// malloc(type) becomes sbyte *malloc(constint)
Value *MallocArg = ConstPoolUInt::get(Type::UIntTy, Size);
Value *MallocArg = ConstantUInt::get(Type::UIntTy, Size);
if (MI->getNumOperands() && Size == 1) {
MallocArg = MI->getOperand(0); // Operand * 1 = Operand
} else if (MI->getNumOperands()) {

View File

@ -19,7 +19,7 @@
#include "llvm/Optimizations/ConstantHandling.h"
#include "llvm/Method.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/InstrTypes.h"
#include "llvm/iPHINode.h"
#include "llvm/iMemory.h"
@ -38,28 +38,28 @@
//
class InstVal {
enum {
Undefined, // This instruction has no known value
Constant, // This instruction has a constant value
undefined, // This instruction has no known value
constant, // This instruction has a constant value
// Range, // This instruction is known to fall within a range
Overdefined // This instruction has an unknown value
} LatticeValue; // The current lattice position
ConstPoolVal *ConstantVal; // If Constant value, the current value
overdefined // This instruction has an unknown value
} LatticeValue; // The current lattice position
Constant *ConstantVal; // If Constant value, the current value
public:
inline InstVal() : LatticeValue(Undefined), ConstantVal(0) {}
inline InstVal() : LatticeValue(undefined), ConstantVal(0) {}
// markOverdefined - Return true if this is a new status to be in...
inline bool markOverdefined() {
if (LatticeValue != Overdefined) {
LatticeValue = Overdefined;
if (LatticeValue != overdefined) {
LatticeValue = overdefined;
return true;
}
return false;
}
// markConstant - Return true if this is a new status for us...
inline bool markConstant(ConstPoolVal *V) {
if (LatticeValue != Constant) {
LatticeValue = Constant;
inline bool markConstant(Constant *V) {
if (LatticeValue != constant) {
LatticeValue = constant;
ConstantVal = V;
return true;
} else {
@ -68,11 +68,11 @@ public:
return false;
}
inline bool isUndefined() const { return LatticeValue == Undefined; }
inline bool isConstant() const { return LatticeValue == Constant; }
inline bool isOverdefined() const { return LatticeValue == Overdefined; }
inline bool isUndefined() const { return LatticeValue == undefined; }
inline bool isConstant() const { return LatticeValue == constant; }
inline bool isOverdefined() const { return LatticeValue == overdefined; }
inline ConstPoolVal *getConstant() const { return ConstantVal; }
inline Constant *getConstant() const { return ConstantVal; }
};
@ -113,7 +113,7 @@ private:
// is not already a constant, add it to the instruction work list so that
// the users of the instruction are updated later.
//
inline bool markConstant(Instruction *I, ConstPoolVal *V) {
inline bool markConstant(Instruction *I, Constant *V) {
//cerr << "markConstant: " << V << " = " << I;
if (ValueState[I].markConstant(V)) {
InstWorkList.push_back(I);
@ -147,7 +147,7 @@ private:
map<Value*, InstVal>::iterator I = ValueState.find(V);
if (I != ValueState.end()) return I->second; // Common case, in the map
if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(V)) {//Constants are constant
if (Constant *CPV = dyn_cast<Constant>(V)) { // Constants are constant
ValueState[CPV].markConstant(CPV);
} else if (isa<MethodArgument>(V)) { // MethodArgs are overdefined
ValueState[V].markOverdefined();
@ -246,7 +246,7 @@ bool SCCP::doSCCP() {
Instruction *Inst = *II;
InstVal &IV = ValueState[Inst];
if (IV.isConstant()) {
ConstPoolVal *Const = IV.getConstant();
Constant *Const = IV.getConstant();
// cerr << "Constant: " << Inst << " is: " << Const;
// Replaces all of the uses of a variable with uses of the constant.
@ -393,7 +393,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
markExecutable(BI->getSuccessor(1));
} else if (BCValue.isConstant()) {
// Constant condition variables mean the branch can only go a single way.
ConstPoolBool *CPB = cast<ConstPoolBool>(BCValue.getConstant());
ConstantBool *CPB = cast<ConstantBool>(BCValue.getConstant());
if (CPB->getValue()) // If the branch condition is TRUE...
markExecutable(BI->getSuccessor(0));
else // Else if the br cond is FALSE...
@ -409,7 +409,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
for(unsigned i = 0; BasicBlock *Succ = SI->getSuccessor(i); ++i)
markExecutable(Succ);
} else if (SCValue.isConstant()) {
ConstPoolVal *CPV = SCValue.getConstant();
Constant *CPV = SCValue.getConstant();
// Make sure to skip the "default value" which isn't a value
for (unsigned i = 1, E = SI->getNumSuccessors(); i != E; ++i) {
if (SI->getSuccessorValue(i) == CPV) {// Found the right branch...
@ -443,7 +443,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
if (VState.isOverdefined()) { // Inherit overdefinedness of operand
markOverdefined(I);
} else if (VState.isConstant()) { // Propogate constant value
ConstPoolVal *Result = isa<CastInst>(I)
Constant *Result = isa<CastInst>(I)
? opt::ConstantFoldCastInstruction(VState.getConstant(), I->getType())
: opt::ConstantFoldUnaryInstruction(I->getOpcode(),
VState.getConstant());
@ -470,7 +470,7 @@ void SCCP::UpdateInstruction(Instruction *I) {
if (V1State.isOverdefined() || V2State.isOverdefined()) {
markOverdefined(I);
} else if (V1State.isConstant() && V2State.isConstant()) {
ConstPoolVal *Result =
Constant *Result =
opt::ConstantFoldBinaryInstruction(I->getOpcode(),
V1State.getConstant(),
V2State.getConstant());

View File

@ -29,7 +29,7 @@ static bool StripSymbolTable(SymbolTable *SymTab) {
SymbolTable::type_iterator B;
while ((B = Plane.begin()) != Plane.end()) { // Found nonempty type plane!
Value *V = B->second;
if (isa<ConstPoolVal>(V) || isa<Type>(V))
if (isa<Constant>(V) || isa<Type>(V))
SymTab->type_remove(B);
else
V->setName("", SymTab); // Set name to "", removing from symbol table!

View File

@ -8,7 +8,7 @@
#include "TransformInternals.h"
#include "llvm/Method.h"
#include "llvm/Type.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/Analysis/Expressions.h"
#include "llvm/iOther.h"
@ -96,7 +96,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
(i == SL->MemberOffsets.size()-1 || Offset <SL->MemberOffsets[i+1]));
// Make sure to save the current index...
Offsets.push_back(ConstPoolUInt::get(Type::UByteTy, i));
Offsets.push_back(ConstantUInt::get(Type::UByteTy, i));
ThisOffset = SL->MemberOffsets[i];
NextType = STy->getElementTypes()[i];
} else {
@ -106,7 +106,7 @@ const Type *getStructOffsetType(const Type *Ty, unsigned &Offset,
NextType = ATy->getElementType();
unsigned ChildSize = TD.getTypeSize(NextType);
Offsets.push_back(ConstPoolUInt::get(Type::UIntTy, Offset/ChildSize));
Offsets.push_back(ConstantUInt::get(Type::UIntTy, Offset/ChildSize));
ThisOffset = (Offset/ChildSize)*ChildSize;
}
@ -183,7 +183,7 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal,
if (Offset >= ElSize) {
// Calculate the index that we are entering into the array cell with
unsigned Index = Offset/ElSize;
Indices.push_back(ConstPoolUInt::get(Type::UIntTy, Index));
Indices.push_back(ConstantUInt::get(Type::UIntTy, Index));
Offset -= Index*ElSize; // Consume part of the offset
} else if (Scale && Scale != 1) {
@ -204,7 +204,7 @@ const Type *ConvertableToGEP(const Type *Ty, Value *OffsetVal,
// Must be indexing a small amount into the first cell of the array
// Just index into element zero of the array here.
//
Indices.push_back(ConstPoolUInt::get(Type::UIntTy, 0));
Indices.push_back(ConstantUInt::get(Type::UIntTy, 0));
}
NextTy = ElTy;
}

View File

@ -12,7 +12,7 @@
#include "llvm/Instruction.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DerivedTypes.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include <map>
#include <set>
@ -24,10 +24,10 @@
//
extern const TargetData TD;
static int getConstantValue(const ConstPoolInt *CPI) {
if (const ConstPoolSInt *CSI = dyn_cast<ConstPoolSInt>(CPI))
static int getConstantValue(const ConstantInt *CPI) {
if (const ConstantSInt *CSI = dyn_cast<ConstantSInt>(CPI))
return CSI->getValue();
return cast<ConstPoolUInt>(CPI)->getValue();
return cast<ConstantUInt>(CPI)->getValue();
}

View File

@ -16,7 +16,7 @@
#include "llvm/SymbolTable.h"
#include "llvm/DerivedTypes.h"
#include "llvm/iOther.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
// Error - Simple wrapper function to conditionally assign to E and return true.
// This just makes error return conditions a little bit simpler...
@ -90,31 +90,31 @@ static Value *RemapOperand(const Value *In, map<const Value*, Value*> &LocalMap,
}
// Check to see if it's a constant that we are interesting in transforming...
if (ConstPoolVal *CPV = dyn_cast<ConstPoolVal>(In)) {
if (Constant *CPV = dyn_cast<Constant>(In)) {
if (!isa<DerivedType>(CPV->getType()))
return CPV; // Simple constants stay identical...
ConstPoolVal *Result = 0;
Constant *Result = 0;
if (ConstPoolArray *CPA = dyn_cast<ConstPoolArray>(CPV)) {
if (ConstantArray *CPA = dyn_cast<ConstantArray>(CPV)) {
const vector<Use> &Ops = CPA->getValues();
vector<ConstPoolVal*> Operands(Ops.size());
vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<ConstPoolVal>(RemapOperand(Ops[i], LocalMap, GlobalMap));
Result = ConstPoolArray::get(cast<ArrayType>(CPA->getType()), Operands);
} else if (ConstPoolStruct *CPS = dyn_cast<ConstPoolStruct>(CPV)) {
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
Result = ConstantArray::get(cast<ArrayType>(CPA->getType()), Operands);
} else if (ConstantStruct *CPS = dyn_cast<ConstantStruct>(CPV)) {
const vector<Use> &Ops = CPS->getValues();
vector<ConstPoolVal*> Operands(Ops.size());
vector<Constant*> Operands(Ops.size());
for (unsigned i = 0; i < Ops.size(); ++i)
Operands[i] =
cast<ConstPoolVal>(RemapOperand(Ops[i], LocalMap, GlobalMap));
Result = ConstPoolStruct::get(cast<StructType>(CPS->getType()), Operands);
} else if (isa<ConstPoolPointerNull>(CPV)) {
cast<Constant>(RemapOperand(Ops[i], LocalMap, GlobalMap));
Result = ConstantStruct::get(cast<StructType>(CPS->getType()), Operands);
} else if (isa<ConstantPointerNull>(CPV)) {
Result = CPV;
} else if (ConstPoolPointerRef *CPR = dyn_cast<ConstPoolPointerRef>(CPV)) {
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(CPV)) {
Value *V = RemapOperand(CPR->getValue(), LocalMap, GlobalMap);
Result = ConstPoolPointerRef::get(cast<GlobalValue>(V));
Result = ConstantPointerRef::get(cast<GlobalValue>(V));
} else {
assert(0 && "Unknown type of derived type constant value!");
}
@ -207,8 +207,8 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
if (SGV->hasInitializer()) { // Only process initialized GV's
// Figure out what the initializer looks like in the dest module...
ConstPoolVal *DInit =
cast<ConstPoolVal>(RemapOperand(SGV->getInitializer(), ValueMap));
Constant *DInit =
cast<Constant>(RemapOperand(SGV->getInitializer(), ValueMap));
GlobalVariable *DGV = cast<GlobalVariable>(ValueMap[SGV]);
if (DGV->hasInitializer() && SGV->hasExternalLinkage() &&

View File

@ -16,7 +16,7 @@
#include "llvm/Method.h"
#include "llvm/GlobalVariable.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/iMemory.h"
#include "llvm/iTerminators.h"
#include "llvm/iPHINode.h"
@ -69,7 +69,7 @@ static void WriteAsOperandInternal(ostream &Out, const Value *V, bool PrintName,
if (PrintName && V->hasName()) {
Out << " %" << V->getName();
} else {
if (const ConstPoolVal *CPV = dyn_cast<const ConstPoolVal>(V)) {
if (const Constant *CPV = dyn_cast<const Constant>(V)) {
Out << " " << CPV->getStrValue();
} else {
int Slot;
@ -275,13 +275,13 @@ public:
inline void write(const Method *M) { printMethod(M); }
inline void write(const BasicBlock *BB) { printBasicBlock(BB); }
inline void write(const Instruction *I) { printInstruction(I); }
inline void write(const ConstPoolVal *CPV) { printConstant(CPV); }
inline void write(const Constant *CPV) { printConstant(CPV); }
inline void write(const Type *Ty) { printType(Ty); }
private :
void printModule(const Module *M);
void printSymbolTable(const SymbolTable &ST);
void printConstant(const ConstPoolVal *CPV);
void printConstant(const Constant *CPV);
void printGlobal(const GlobalVariable *GV);
void printMethod(const Method *M);
void printMethodArgument(const MethodArgument *MA);
@ -345,7 +345,7 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
for (; I != End; ++I) {
const Value *V = I->second;
if (const ConstPoolVal *CPV = dyn_cast<const ConstPoolVal>(V)) {
if (const Constant *CPV = dyn_cast<const Constant>(V)) {
printConstant(CPV);
} else if (const Type *Ty = dyn_cast<const Type>(V)) {
Out << "\t%" << I->first << " = type " << Ty->getDescription() << endl;
@ -357,7 +357,7 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
// printConstant - Print out a constant pool entry...
//
void AssemblyWriter::printConstant(const ConstPoolVal *CPV) {
void AssemblyWriter::printConstant(const Constant *CPV) {
// Don't print out unnamed constants, they will be inlined
if (!CPV->hasName()) return;
@ -666,7 +666,7 @@ void WriteToAssembly(const BasicBlock *BB, ostream &o) {
W.write(BB);
}
void WriteToAssembly(const ConstPoolVal *CPV, ostream &o) {
void WriteToAssembly(const Constant *CPV, ostream &o) {
if (CPV == 0) { o << "<null> constant pool value\n"; return; }
o << " " << CPV->getType()->getDescription() << " " << CPV->getStrValue();
}
@ -701,7 +701,7 @@ CachedWriter &CachedWriter::operator<<(const Value *V) {
switch (V->getValueType()) {
case Value::ConstantVal:
Out << " "; AW->write(V->getType());
Out << " " << cast<ConstPoolVal>(V)->getStrValue(); break;
Out << " " << cast<Constant>(V)->getStrValue(); break;
case Value::MethodArgumentVal:
AW->write(V->getType()); Out << " " << V->getName(); break;
case Value::TypeVal: AW->write(cast<const Type>(V)); break;

View File

@ -70,14 +70,14 @@ void BasicBlock::dropAllReferences() {
std::mem_fun(&Instruction::dropAllReferences));
}
// hasConstantPoolReferences() - This predicate is true if there is a
// hasConstantReferences() - This predicate is true if there is a
// reference to this basic block in the constant pool for this method. For
// example, if a block is reached through a switch table, that table resides
// in the constant pool, and the basic block is reference from it.
//
bool BasicBlock::hasConstantPoolReferences() const {
bool BasicBlock::hasConstantReferences() const {
for (use_const_iterator I = use_begin(), E = use_end(); I != E; ++I)
if (::isa<ConstPoolVal>(*I))
if (::isa<Constant>(*I))
return true;
return false;

View File

@ -1,11 +1,11 @@
//===-- iConstPool.cpp - Implement ConstPool instructions --------*- C++ -*--=//
//===-- ConstantVals.cpp - Implement Constant nodes --------------*- C++ -*--=//
//
// This file implements the ConstPool* classes...
// This file implements the Constant* classes...
//
//===----------------------------------------------------------------------===//
#define __STDC_LIMIT_MACROS // Get defs for INT64_MAX and friends...
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/GlobalValue.h"
@ -15,40 +15,40 @@
#include <algorithm>
#include <assert.h>
ConstPoolBool *ConstPoolBool::True = new ConstPoolBool(true);
ConstPoolBool *ConstPoolBool::False = new ConstPoolBool(false);
ConstantBool *ConstantBool::True = new ConstantBool(true);
ConstantBool *ConstantBool::False = new ConstantBool(false);
//===----------------------------------------------------------------------===//
// ConstPoolVal Class
// Constant Class
//===----------------------------------------------------------------------===//
// Specialize setName to take care of symbol table majik
void ConstPoolVal::setName(const string &Name, SymbolTable *ST) {
void Constant::setName(const string &Name, SymbolTable *ST) {
assert(ST && "Type::setName - Must provide symbol table argument!");
if (Name.size()) ST->insert(Name, this);
}
// Static constructor to create a '0' constant of arbitrary type...
ConstPoolVal *ConstPoolVal::getNullConstant(const Type *Ty) {
Constant *Constant::getNullConstant(const Type *Ty) {
switch (Ty->getPrimitiveID()) {
case Type::BoolTyID: return ConstPoolBool::get(false);
case Type::BoolTyID: return ConstantBool::get(false);
case Type::SByteTyID:
case Type::ShortTyID:
case Type::IntTyID:
case Type::LongTyID: return ConstPoolSInt::get(Ty, 0);
case Type::LongTyID: return ConstantSInt::get(Ty, 0);
case Type::UByteTyID:
case Type::UShortTyID:
case Type::UIntTyID:
case Type::ULongTyID: return ConstPoolUInt::get(Ty, 0);
case Type::ULongTyID: return ConstantUInt::get(Ty, 0);
case Type::FloatTyID:
case Type::DoubleTyID: return ConstPoolFP::get(Ty, 0);
case Type::DoubleTyID: return ConstantFP::get(Ty, 0);
case Type::PointerTyID:
return ConstPoolPointerNull::get(cast<PointerType>(Ty));
return ConstantPointerNull::get(cast<PointerType>(Ty));
default:
return 0;
}
@ -58,24 +58,24 @@ ConstPoolVal *ConstPoolVal::getNullConstant(const Type *Ty) {
#include "llvm/Assembly/Writer.h"
#endif
void ConstPoolVal::destroyConstantImpl() {
// When a ConstPoolVal is destroyed, there may be lingering
void Constant::destroyConstantImpl() {
// When a Constant is destroyed, there may be lingering
// references to the constant by other constants in the constant pool. These
// constants are implicitly dependant on the module that is being deleted,
// but they don't know that. Because we only find out when the CPV is
// deleted, we must now notify all of our users (that should only be
// ConstPoolVals) that they are, in fact, invalid now and should be deleted.
// Constants) that they are, in fact, invalid now and should be deleted.
//
while (!use_empty()) {
Value *V = use_back();
#ifndef NDEBUG // Only in -g mode...
if (!isa<ConstPoolVal>(V)) {
if (!isa<Constant>(V)) {
cerr << "While deleting: " << this << endl;
cerr << "Use still stuck around after Def is destroyed: " << V << endl;
}
#endif
assert(isa<ConstPoolVal>(V) && "References remain to ConstPoolPointerRef!");
ConstPoolVal *CPV = cast<ConstPoolVal>(V);
assert(isa<Constant>(V) && "References remain to ConstantPointerRef!");
Constant *CPV = cast<Constant>(V);
CPV->destroyConstant();
// The constant should remove itself from our use list...
@ -87,45 +87,43 @@ void ConstPoolVal::destroyConstantImpl() {
}
//===----------------------------------------------------------------------===//
// ConstPoolXXX Classes
// ConstantXXX Classes
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// Normal Constructors
ConstPoolBool::ConstPoolBool(bool V) : ConstPoolVal(Type::BoolTy) {
ConstantBool::ConstantBool(bool V) : Constant(Type::BoolTy) {
Val = V;
}
ConstPoolInt::ConstPoolInt(const Type *Ty, uint64_t V) : ConstPoolVal(Ty) {
ConstantInt::ConstantInt(const Type *Ty, uint64_t V) : Constant(Ty) {
Val.Unsigned = V;
}
ConstPoolSInt::ConstPoolSInt(const Type *Ty, int64_t V) : ConstPoolInt(Ty, V) {
ConstantSInt::ConstantSInt(const Type *Ty, int64_t V) : ConstantInt(Ty, V) {
assert(isValueValidForType(Ty, V) && "Value too large for type!");
}
ConstPoolUInt::ConstPoolUInt(const Type *Ty, uint64_t V) : ConstPoolInt(Ty, V) {
ConstantUInt::ConstantUInt(const Type *Ty, uint64_t V) : ConstantInt(Ty, V) {
assert(isValueValidForType(Ty, V) && "Value too large for type!");
}
ConstPoolFP::ConstPoolFP(const Type *Ty, double V) : ConstPoolVal(Ty) {
ConstantFP::ConstantFP(const Type *Ty, double V) : Constant(Ty) {
assert(isValueValidForType(Ty, V) && "Value too large for type!");
Val = V;
}
ConstPoolArray::ConstPoolArray(const ArrayType *T,
const vector<ConstPoolVal*> &V)
: ConstPoolVal(T) {
ConstantArray::ConstantArray(const ArrayType *T,
const vector<Constant*> &V) : Constant(T) {
for (unsigned i = 0; i < V.size(); i++) {
assert(V[i]->getType() == T->getElementType());
Operands.push_back(Use(V[i], this));
}
}
ConstPoolStruct::ConstPoolStruct(const StructType *T,
const vector<ConstPoolVal*> &V)
: ConstPoolVal(T) {
ConstantStruct::ConstantStruct(const StructType *T,
const vector<Constant*> &V) : Constant(T) {
const StructType::ElementTypes &ETypes = T->getElementTypes();
for (unsigned i = 0; i < V.size(); i++) {
@ -134,8 +132,8 @@ ConstPoolStruct::ConstPoolStruct(const StructType *T,
}
}
ConstPoolPointerRef::ConstPoolPointerRef(GlobalValue *GV)
: ConstPoolPointer(GV->getType()) {
ConstantPointerRef::ConstantPointerRef(GlobalValue *GV)
: ConstantPointer(GV->getType()) {
Operands.push_back(Use(GV, this));
}
@ -144,23 +142,23 @@ ConstPoolPointerRef::ConstPoolPointerRef(GlobalValue *GV)
//===----------------------------------------------------------------------===//
// getStrValue implementations
string ConstPoolBool::getStrValue() const {
string ConstantBool::getStrValue() const {
return Val ? "true" : "false";
}
string ConstPoolSInt::getStrValue() const {
string ConstantSInt::getStrValue() const {
return itostr(Val.Signed);
}
string ConstPoolUInt::getStrValue() const {
string ConstantUInt::getStrValue() const {
return utostr(Val.Unsigned);
}
string ConstPoolFP::getStrValue() const {
string ConstantFP::getStrValue() const {
return ftostr(Val);
}
string ConstPoolArray::getStrValue() const {
string ConstantArray::getStrValue() const {
string Result;
// As a special case, print the array as a string if it is an array of
@ -172,7 +170,7 @@ string ConstPoolArray::getStrValue() const {
if (ETy == Type::SByteTy) {
for (unsigned i = 0; i < Operands.size(); ++i)
if (ETy == Type::SByteTy &&
cast<ConstPoolSInt>(Operands[i])->getValue() < 0) {
cast<ConstantSInt>(Operands[i])->getValue() < 0) {
isString = false;
break;
}
@ -182,8 +180,8 @@ string ConstPoolArray::getStrValue() const {
Result = "c\"";
for (unsigned i = 0; i < Operands.size(); ++i) {
unsigned char C = (ETy == Type::SByteTy) ?
(unsigned char)cast<ConstPoolSInt>(Operands[i])->getValue() :
(unsigned char)cast<ConstPoolUInt>(Operands[i])->getValue();
(unsigned char)cast<ConstantSInt>(Operands[i])->getValue() :
(unsigned char)cast<ConstantUInt>(Operands[i])->getValue();
if (isprint(C)) {
Result += C;
@ -199,10 +197,10 @@ string ConstPoolArray::getStrValue() const {
Result = "[";
if (Operands.size()) {
Result += " " + Operands[0]->getType()->getDescription() +
" " + cast<ConstPoolVal>(Operands[0])->getStrValue();
" " + cast<Constant>(Operands[0])->getStrValue();
for (unsigned i = 1; i < Operands.size(); i++)
Result += ", " + Operands[i]->getType()->getDescription() +
" " + cast<ConstPoolVal>(Operands[i])->getStrValue();
" " + cast<Constant>(Operands[i])->getStrValue();
}
Result += " ]";
}
@ -210,24 +208,24 @@ string ConstPoolArray::getStrValue() const {
return Result;
}
string ConstPoolStruct::getStrValue() const {
string ConstantStruct::getStrValue() const {
string Result = "{";
if (Operands.size()) {
Result += " " + Operands[0]->getType()->getDescription() +
" " + cast<ConstPoolVal>(Operands[0])->getStrValue();
" " + cast<Constant>(Operands[0])->getStrValue();
for (unsigned i = 1; i < Operands.size(); i++)
Result += ", " + Operands[i]->getType()->getDescription() +
" " + cast<ConstPoolVal>(Operands[i])->getStrValue();
" " + cast<Constant>(Operands[i])->getStrValue();
}
return Result + " }";
}
string ConstPoolPointerNull::getStrValue() const {
string ConstantPointerNull::getStrValue() const {
return "null";
}
string ConstPoolPointerRef::getStrValue() const {
string ConstantPointerRef::getStrValue() const {
const GlobalValue *V = getValue();
if (V->hasName()) return "%" + V->getName();
@ -243,26 +241,26 @@ string ConstPoolPointerRef::getStrValue() const {
//===----------------------------------------------------------------------===//
// classof implementations
bool ConstPoolInt::classof(const ConstPoolVal *CPV) {
bool ConstantInt::classof(const Constant *CPV) {
return CPV->getType()->isIntegral();
}
bool ConstPoolSInt::classof(const ConstPoolVal *CPV) {
bool ConstantSInt::classof(const Constant *CPV) {
return CPV->getType()->isSigned();
}
bool ConstPoolUInt::classof(const ConstPoolVal *CPV) {
bool ConstantUInt::classof(const Constant *CPV) {
return CPV->getType()->isUnsigned();
}
bool ConstPoolFP::classof(const ConstPoolVal *CPV) {
bool ConstantFP::classof(const Constant *CPV) {
const Type *Ty = CPV->getType();
return Ty == Type::FloatTy || Ty == Type::DoubleTy;
}
bool ConstPoolArray::classof(const ConstPoolVal *CPV) {
bool ConstantArray::classof(const Constant *CPV) {
return isa<ArrayType>(CPV->getType());
}
bool ConstPoolStruct::classof(const ConstPoolVal *CPV) {
bool ConstantStruct::classof(const Constant *CPV) {
return isa<StructType>(CPV->getType());
}
bool ConstPoolPointer::classof(const ConstPoolVal *CPV) {
bool ConstantPointer::classof(const Constant *CPV) {
return isa<PointerType>(CPV->getType());
}
@ -270,7 +268,7 @@ bool ConstPoolPointer::classof(const ConstPoolVal *CPV) {
//===----------------------------------------------------------------------===//
// isValueValidForType implementations
bool ConstPoolSInt::isValueValidForType(const Type *Ty, int64_t Val) {
bool ConstantSInt::isValueValidForType(const Type *Ty, int64_t Val) {
switch (Ty->getPrimitiveID()) {
default:
return false; // These can't be represented as integers!!!
@ -289,7 +287,7 @@ bool ConstPoolSInt::isValueValidForType(const Type *Ty, int64_t Val) {
return false;
}
bool ConstPoolUInt::isValueValidForType(const Type *Ty, uint64_t Val) {
bool ConstantUInt::isValueValidForType(const Type *Ty, uint64_t Val) {
switch (Ty->getPrimitiveID()) {
default:
return false; // These can't be represented as integers!!!
@ -308,7 +306,7 @@ bool ConstPoolUInt::isValueValidForType(const Type *Ty, uint64_t Val) {
return false;
}
bool ConstPoolFP::isValueValidForType(const Type *Ty, double Val) {
bool ConstantFP::isValueValidForType(const Type *Ty, double Val) {
switch (Ty->getPrimitiveID()) {
default:
return false; // These can't be represented as floating point!
@ -326,28 +324,28 @@ bool ConstPoolFP::isValueValidForType(const Type *Ty, double Val) {
//===----------------------------------------------------------------------===//
// Hash Function Implementations
#if 0
unsigned ConstPoolSInt::hash(const Type *Ty, int64_t V) {
unsigned ConstantSInt::hash(const Type *Ty, int64_t V) {
return unsigned(Ty->getPrimitiveID() ^ V);
}
unsigned ConstPoolUInt::hash(const Type *Ty, uint64_t V) {
unsigned ConstantUInt::hash(const Type *Ty, uint64_t V) {
return unsigned(Ty->getPrimitiveID() ^ V);
}
unsigned ConstPoolFP::hash(const Type *Ty, double V) {
unsigned ConstantFP::hash(const Type *Ty, double V) {
return Ty->getPrimitiveID() ^ unsigned(V);
}
unsigned ConstPoolArray::hash(const ArrayType *Ty,
const vector<ConstPoolVal*> &V) {
unsigned ConstantArray::hash(const ArrayType *Ty,
const vector<Constant*> &V) {
unsigned Result = (Ty->getUniqueID() << 5) ^ (Ty->getUniqueID() * 7);
for (unsigned i = 0; i < V.size(); ++i)
Result ^= V[i]->getHash() << (i & 7);
return Result;
}
unsigned ConstPoolStruct::hash(const StructType *Ty,
const vector<ConstPoolVal*> &V) {
unsigned ConstantStruct::hash(const StructType *Ty,
const vector<Constant*> &V) {
unsigned Result = (Ty->getUniqueID() << 5) ^ (Ty->getUniqueID() * 7);
for (unsigned i = 0; i < V.size(); ++i)
Result ^= V[i]->getHash() << (i & 7);
@ -358,23 +356,23 @@ unsigned ConstPoolStruct::hash(const StructType *Ty,
//===----------------------------------------------------------------------===//
// Factory Function Implementation
template<class ValType, class ConstPoolClass>
template<class ValType, class ConstantClass>
struct ValueMap {
typedef pair<const Type*, ValType> ConstHashKey;
map<ConstHashKey, ConstPoolClass *> Map;
map<ConstHashKey, ConstantClass *> Map;
inline ConstPoolClass *get(const Type *Ty, ValType V) {
map<ConstHashKey,ConstPoolClass *>::iterator I =
inline ConstantClass *get(const Type *Ty, ValType V) {
map<ConstHashKey,ConstantClass *>::iterator I =
Map.find(ConstHashKey(Ty, V));
return (I != Map.end()) ? I->second : 0;
}
inline void add(const Type *Ty, ValType V, ConstPoolClass *CP) {
inline void add(const Type *Ty, ValType V, ConstantClass *CP) {
Map.insert(make_pair(ConstHashKey(Ty, V), CP));
}
inline void remove(ConstPoolClass *CP) {
for (map<ConstHashKey,ConstPoolClass *>::iterator I = Map.begin(),
inline void remove(ConstantClass *CP) {
for (map<ConstHashKey,ConstantClass *>::iterator I = Map.begin(),
E = Map.end(); I != E;++I)
if (I->second == CP) {
Map.erase(I);
@ -383,119 +381,119 @@ struct ValueMap {
}
};
//---- ConstPoolUInt::get() and ConstPoolSInt::get() implementations...
//---- ConstantUInt::get() and ConstantSInt::get() implementations...
//
static ValueMap<uint64_t, ConstPoolInt> IntConstants;
static ValueMap<uint64_t, ConstantInt> IntConstants;
ConstPoolSInt *ConstPoolSInt::get(const Type *Ty, int64_t V) {
ConstPoolSInt *Result = (ConstPoolSInt*)IntConstants.get(Ty, (uint64_t)V);
ConstantSInt *ConstantSInt::get(const Type *Ty, int64_t V) {
ConstantSInt *Result = (ConstantSInt*)IntConstants.get(Ty, (uint64_t)V);
if (!Result) // If no preexisting value, create one now...
IntConstants.add(Ty, V, Result = new ConstPoolSInt(Ty, V));
IntConstants.add(Ty, V, Result = new ConstantSInt(Ty, V));
return Result;
}
ConstPoolUInt *ConstPoolUInt::get(const Type *Ty, uint64_t V) {
ConstPoolUInt *Result = (ConstPoolUInt*)IntConstants.get(Ty, V);
ConstantUInt *ConstantUInt::get(const Type *Ty, uint64_t V) {
ConstantUInt *Result = (ConstantUInt*)IntConstants.get(Ty, V);
if (!Result) // If no preexisting value, create one now...
IntConstants.add(Ty, V, Result = new ConstPoolUInt(Ty, V));
IntConstants.add(Ty, V, Result = new ConstantUInt(Ty, V));
return Result;
}
ConstPoolInt *ConstPoolInt::get(const Type *Ty, unsigned char V) {
ConstantInt *ConstantInt::get(const Type *Ty, unsigned char V) {
assert(V <= 127 && "Can only be used with very small positive constants!");
if (Ty->isSigned()) return ConstPoolSInt::get(Ty, V);
return ConstPoolUInt::get(Ty, V);
if (Ty->isSigned()) return ConstantSInt::get(Ty, V);
return ConstantUInt::get(Ty, V);
}
//---- ConstPoolFP::get() implementation...
//---- ConstantFP::get() implementation...
//
static ValueMap<double, ConstPoolFP> FPConstants;
static ValueMap<double, ConstantFP> FPConstants;
ConstPoolFP *ConstPoolFP::get(const Type *Ty, double V) {
ConstPoolFP *Result = FPConstants.get(Ty, V);
ConstantFP *ConstantFP::get(const Type *Ty, double V) {
ConstantFP *Result = FPConstants.get(Ty, V);
if (!Result) // If no preexisting value, create one now...
FPConstants.add(Ty, V, Result = new ConstPoolFP(Ty, V));
FPConstants.add(Ty, V, Result = new ConstantFP(Ty, V));
return Result;
}
//---- ConstPoolArray::get() implementation...
//---- ConstantArray::get() implementation...
//
static ValueMap<vector<ConstPoolVal*>, ConstPoolArray> ArrayConstants;
static ValueMap<vector<Constant*>, ConstantArray> ArrayConstants;
ConstPoolArray *ConstPoolArray::get(const ArrayType *Ty,
const vector<ConstPoolVal*> &V) {
ConstPoolArray *Result = ArrayConstants.get(Ty, V);
ConstantArray *ConstantArray::get(const ArrayType *Ty,
const vector<Constant*> &V) {
ConstantArray *Result = ArrayConstants.get(Ty, V);
if (!Result) // If no preexisting value, create one now...
ArrayConstants.add(Ty, V, Result = new ConstPoolArray(Ty, V));
ArrayConstants.add(Ty, V, Result = new ConstantArray(Ty, V));
return Result;
}
// ConstPoolArray::get(const string&) - Return an array that is initialized to
// ConstantArray::get(const string&) - Return an array that is initialized to
// contain the specified string. A null terminator is added to the specified
// string so that it may be used in a natural way...
//
ConstPoolArray *ConstPoolArray::get(const string &Str) {
vector<ConstPoolVal*> ElementVals;
ConstantArray *ConstantArray::get(const string &Str) {
vector<Constant*> ElementVals;
for (unsigned i = 0; i < Str.length(); ++i)
ElementVals.push_back(ConstPoolUInt::get(Type::UByteTy, Str[i]));
ElementVals.push_back(ConstantUInt::get(Type::UByteTy, Str[i]));
// Add a null terminator to the string...
ElementVals.push_back(ConstPoolUInt::get(Type::UByteTy, 0));
ElementVals.push_back(ConstantUInt::get(Type::UByteTy, 0));
ArrayType *ATy = ArrayType::get(Type::UByteTy/*,stringConstant.length()*/);
return ConstPoolArray::get(ATy, ElementVals);
return ConstantArray::get(ATy, ElementVals);
}
// destroyConstant - Remove the constant from the constant table...
//
void ConstPoolArray::destroyConstant() {
void ConstantArray::destroyConstant() {
ArrayConstants.remove(this);
destroyConstantImpl();
}
//---- ConstPoolStruct::get() implementation...
//---- ConstantStruct::get() implementation...
//
static ValueMap<vector<ConstPoolVal*>, ConstPoolStruct> StructConstants;
static ValueMap<vector<Constant*>, ConstantStruct> StructConstants;
ConstPoolStruct *ConstPoolStruct::get(const StructType *Ty,
const vector<ConstPoolVal*> &V) {
ConstPoolStruct *Result = StructConstants.get(Ty, V);
ConstantStruct *ConstantStruct::get(const StructType *Ty,
const vector<Constant*> &V) {
ConstantStruct *Result = StructConstants.get(Ty, V);
if (!Result) // If no preexisting value, create one now...
StructConstants.add(Ty, V, Result = new ConstPoolStruct(Ty, V));
StructConstants.add(Ty, V, Result = new ConstantStruct(Ty, V));
return Result;
}
// destroyConstant - Remove the constant from the constant table...
//
void ConstPoolStruct::destroyConstant() {
void ConstantStruct::destroyConstant() {
StructConstants.remove(this);
destroyConstantImpl();
}
//---- ConstPoolPointerNull::get() implementation...
//---- ConstantPointerNull::get() implementation...
//
static ValueMap<char, ConstPoolPointerNull> NullPtrConstants;
static ValueMap<char, ConstantPointerNull> NullPtrConstants;
ConstPoolPointerNull *ConstPoolPointerNull::get(const PointerType *Ty) {
ConstPoolPointerNull *Result = NullPtrConstants.get(Ty, 0);
ConstantPointerNull *ConstantPointerNull::get(const PointerType *Ty) {
ConstantPointerNull *Result = NullPtrConstants.get(Ty, 0);
if (!Result) // If no preexisting value, create one now...
NullPtrConstants.add(Ty, 0, Result = new ConstPoolPointerNull(Ty));
NullPtrConstants.add(Ty, 0, Result = new ConstantPointerNull(Ty));
return Result;
}
//---- ConstPoolPointerRef::get() implementation...
//---- ConstantPointerRef::get() implementation...
//
ConstPoolPointerRef *ConstPoolPointerRef::get(GlobalValue *GV) {
ConstantPointerRef *ConstantPointerRef::get(GlobalValue *GV) {
assert(GV->getParent() && "Global Value must be attached to a module!");
// The Module handles the pointer reference sharing...
return GV->getParent()->getConstPoolPointerRef(GV);
return GV->getParent()->getConstantPointerRef(GV);
}
void ConstPoolPointerRef::mutateReference(GlobalValue *NewGV) {
getValue()->getParent()->mutateConstPoolPointerRef(getValue(), NewGV);
void ConstantPointerRef::mutateReference(GlobalValue *NewGV) {
getValue()->getParent()->mutateConstantPointerRef(getValue(), NewGV);
Operands[0] = NewGV;
}

View File

@ -30,67 +30,67 @@ class TemplateRules : public ConstRules {
// Redirecting functions that cast to the appropriate types
//===--------------------------------------------------------------------===//
virtual ConstPoolVal *op_not(const ConstPoolVal *V) const {
virtual Constant *op_not(const Constant *V) const {
return SubClassName::Not((const ArgType *)V);
}
virtual ConstPoolVal *add(const ConstPoolVal *V1,
const ConstPoolVal *V2) const {
virtual Constant *add(const Constant *V1,
const Constant *V2) const {
return SubClassName::Add((const ArgType *)V1, (const ArgType *)V2);
}
virtual ConstPoolVal *sub(const ConstPoolVal *V1,
const ConstPoolVal *V2) const {
virtual Constant *sub(const Constant *V1,
const Constant *V2) const {
return SubClassName::Sub((const ArgType *)V1, (const ArgType *)V2);
}
virtual ConstPoolVal *mul(const ConstPoolVal *V1,
const ConstPoolVal *V2) const {
virtual Constant *mul(const Constant *V1,
const Constant *V2) const {
return SubClassName::Mul((const ArgType *)V1, (const ArgType *)V2);
}
virtual ConstPoolBool *lessthan(const ConstPoolVal *V1,
const ConstPoolVal *V2) const {
virtual ConstantBool *lessthan(const Constant *V1,
const Constant *V2) const {
return SubClassName::LessThan((const ArgType *)V1, (const ArgType *)V2);
}
// Casting operators. ick
virtual ConstPoolBool *castToBool(const ConstPoolVal *V) const {
virtual ConstantBool *castToBool(const Constant *V) const {
return SubClassName::CastToBool((const ArgType*)V);
}
virtual ConstPoolSInt *castToSByte(const ConstPoolVal *V) const {
virtual ConstantSInt *castToSByte(const Constant *V) const {
return SubClassName::CastToSByte((const ArgType*)V);
}
virtual ConstPoolUInt *castToUByte(const ConstPoolVal *V) const {
virtual ConstantUInt *castToUByte(const Constant *V) const {
return SubClassName::CastToUByte((const ArgType*)V);
}
virtual ConstPoolSInt *castToShort(const ConstPoolVal *V) const {
virtual ConstantSInt *castToShort(const Constant *V) const {
return SubClassName::CastToShort((const ArgType*)V);
}
virtual ConstPoolUInt *castToUShort(const ConstPoolVal *V) const {
virtual ConstantUInt *castToUShort(const Constant *V) const {
return SubClassName::CastToUShort((const ArgType*)V);
}
virtual ConstPoolSInt *castToInt(const ConstPoolVal *V) const {
virtual ConstantSInt *castToInt(const Constant *V) const {
return SubClassName::CastToInt((const ArgType*)V);
}
virtual ConstPoolUInt *castToUInt(const ConstPoolVal *V) const {
virtual ConstantUInt *castToUInt(const Constant *V) const {
return SubClassName::CastToUInt((const ArgType*)V);
}
virtual ConstPoolSInt *castToLong(const ConstPoolVal *V) const {
virtual ConstantSInt *castToLong(const Constant *V) const {
return SubClassName::CastToLong((const ArgType*)V);
}
virtual ConstPoolUInt *castToULong(const ConstPoolVal *V) const {
virtual ConstantUInt *castToULong(const Constant *V) const {
return SubClassName::CastToULong((const ArgType*)V);
}
virtual ConstPoolFP *castToFloat(const ConstPoolVal *V) const {
virtual ConstantFP *castToFloat(const Constant *V) const {
return SubClassName::CastToFloat((const ArgType*)V);
}
virtual ConstPoolFP *castToDouble(const ConstPoolVal *V) const {
virtual ConstantFP *castToDouble(const Constant *V) const {
return SubClassName::CastToDouble((const ArgType*)V);
}
virtual ConstPoolPointer *castToPointer(const ConstPoolVal *V,
const PointerType *Ty) const {
virtual ConstantPointer *castToPointer(const Constant *V,
const PointerType *Ty) const {
return SubClassName::CastToPointer((const ArgType*)V, Ty);
}
@ -98,35 +98,35 @@ class TemplateRules : public ConstRules {
// Default "noop" implementations
//===--------------------------------------------------------------------===//
inline static ConstPoolVal *Not(const ArgType *V) { return 0; }
inline static Constant *Not(const ArgType *V) { return 0; }
inline static ConstPoolVal *Add(const ArgType *V1, const ArgType *V2) {
inline static Constant *Add(const ArgType *V1, const ArgType *V2) {
return 0;
}
inline static ConstPoolVal *Sub(const ArgType *V1, const ArgType *V2) {
inline static Constant *Sub(const ArgType *V1, const ArgType *V2) {
return 0;
}
inline static ConstPoolVal *Mul(const ArgType *V1, const ArgType *V2) {
inline static Constant *Mul(const ArgType *V1, const ArgType *V2) {
return 0;
}
inline static ConstPoolBool *LessThan(const ArgType *V1, const ArgType *V2) {
inline static ConstantBool *LessThan(const ArgType *V1, const ArgType *V2) {
return 0;
}
// Casting operators. ick
inline static ConstPoolBool *CastToBool (const ConstPoolVal *V) { return 0; }
inline static ConstPoolSInt *CastToSByte (const ConstPoolVal *V) { return 0; }
inline static ConstPoolUInt *CastToUByte (const ConstPoolVal *V) { return 0; }
inline static ConstPoolSInt *CastToShort (const ConstPoolVal *V) { return 0; }
inline static ConstPoolUInt *CastToUShort(const ConstPoolVal *V) { return 0; }
inline static ConstPoolSInt *CastToInt (const ConstPoolVal *V) { return 0; }
inline static ConstPoolUInt *CastToUInt (const ConstPoolVal *V) { return 0; }
inline static ConstPoolSInt *CastToLong (const ConstPoolVal *V) { return 0; }
inline static ConstPoolUInt *CastToULong (const ConstPoolVal *V) { return 0; }
inline static ConstPoolFP *CastToFloat (const ConstPoolVal *V) { return 0; }
inline static ConstPoolFP *CastToDouble(const ConstPoolVal *V) { return 0; }
inline static ConstPoolPointer *CastToPointer(const ConstPoolVal *,
const PointerType *) {return 0;}
inline static ConstantBool *CastToBool (const Constant *V) { return 0; }
inline static ConstantSInt *CastToSByte (const Constant *V) { return 0; }
inline static ConstantUInt *CastToUByte (const Constant *V) { return 0; }
inline static ConstantSInt *CastToShort (const Constant *V) { return 0; }
inline static ConstantUInt *CastToUShort(const Constant *V) { return 0; }
inline static ConstantSInt *CastToInt (const Constant *V) { return 0; }
inline static ConstantUInt *CastToUInt (const Constant *V) { return 0; }
inline static ConstantSInt *CastToLong (const Constant *V) { return 0; }
inline static ConstantUInt *CastToULong (const Constant *V) { return 0; }
inline static ConstantFP *CastToFloat (const Constant *V) { return 0; }
inline static ConstantFP *CastToDouble(const Constant *V) { return 0; }
inline static ConstantPointer *CastToPointer(const Constant *,
const PointerType *) {return 0;}
};
@ -137,7 +137,7 @@ class TemplateRules : public ConstRules {
//
// EmptyRules provides a concrete base class of ConstRules that does nothing
//
struct EmptyRules : public TemplateRules<ConstPoolVal, EmptyRules> {
struct EmptyRules : public TemplateRules<Constant, EmptyRules> {
};
@ -148,20 +148,20 @@ struct EmptyRules : public TemplateRules<ConstPoolVal, EmptyRules> {
//
// BoolRules provides a concrete base class of ConstRules for the 'bool' type.
//
struct BoolRules : public TemplateRules<ConstPoolBool, BoolRules> {
struct BoolRules : public TemplateRules<ConstantBool, BoolRules> {
inline static ConstPoolVal *Not(const ConstPoolBool *V) {
return ConstPoolBool::get(!V->getValue());
inline static Constant *Not(const ConstantBool *V) {
return ConstantBool::get(!V->getValue());
}
inline static ConstPoolVal *Or(const ConstPoolBool *V1,
const ConstPoolBool *V2) {
return ConstPoolBool::get(V1->getValue() | V2->getValue());
inline static Constant *Or(const ConstantBool *V1,
const ConstantBool *V2) {
return ConstantBool::get(V1->getValue() | V2->getValue());
}
inline static ConstPoolVal *And(const ConstPoolBool *V1,
const ConstPoolBool *V2) {
return ConstPoolBool::get(V1->getValue() & V2->getValue());
inline static Constant *And(const ConstantBool *V1,
const ConstantBool *V2) {
return ConstantBool::get(V1->getValue() & V2->getValue());
}
};
@ -172,56 +172,56 @@ struct BoolRules : public TemplateRules<ConstPoolBool, BoolRules> {
//
// PointerRules provides a concrete base class of ConstRules for pointer types
//
struct PointerRules : public TemplateRules<ConstPoolPointer, PointerRules> {
inline static ConstPoolBool *CastToBool (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolBool::False;
struct PointerRules : public TemplateRules<ConstantPointer, PointerRules> {
inline static ConstantBool *CastToBool (const Constant *V) {
if (V->isNullValue()) return ConstantBool::False;
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolSInt *CastToSByte (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolSInt::get(Type::SByteTy, 0);
inline static ConstantSInt *CastToSByte (const Constant *V) {
if (V->isNullValue()) return ConstantSInt::get(Type::SByteTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolUInt *CastToUByte (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolUInt::get(Type::UByteTy, 0);
inline static ConstantUInt *CastToUByte (const Constant *V) {
if (V->isNullValue()) return ConstantUInt::get(Type::UByteTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolSInt *CastToShort (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolSInt::get(Type::ShortTy, 0);
inline static ConstantSInt *CastToShort (const Constant *V) {
if (V->isNullValue()) return ConstantSInt::get(Type::ShortTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolUInt *CastToUShort(const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolUInt::get(Type::UShortTy, 0);
inline static ConstantUInt *CastToUShort(const Constant *V) {
if (V->isNullValue()) return ConstantUInt::get(Type::UShortTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolSInt *CastToInt (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolSInt::get(Type::IntTy, 0);
inline static ConstantSInt *CastToInt (const Constant *V) {
if (V->isNullValue()) return ConstantSInt::get(Type::IntTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolUInt *CastToUInt (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolUInt::get(Type::UIntTy, 0);
inline static ConstantUInt *CastToUInt (const Constant *V) {
if (V->isNullValue()) return ConstantUInt::get(Type::UIntTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolSInt *CastToLong (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolSInt::get(Type::LongTy, 0);
inline static ConstantSInt *CastToLong (const Constant *V) {
if (V->isNullValue()) return ConstantSInt::get(Type::LongTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolUInt *CastToULong (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolUInt::get(Type::ULongTy, 0);
inline static ConstantUInt *CastToULong (const Constant *V) {
if (V->isNullValue()) return ConstantUInt::get(Type::ULongTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolFP *CastToFloat (const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolFP::get(Type::FloatTy, 0);
inline static ConstantFP *CastToFloat (const Constant *V) {
if (V->isNullValue()) return ConstantFP::get(Type::FloatTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolFP *CastToDouble(const ConstPoolVal *V) {
if (V->isNullValue()) return ConstPoolFP::get(Type::DoubleTy, 0);
inline static ConstantFP *CastToDouble(const Constant *V) {
if (V->isNullValue()) return ConstantFP::get(Type::DoubleTy, 0);
return 0; // Can't const prop other types of pointers
}
inline static ConstPoolPointer *CastToPointer(const ConstPoolPointer *V,
const PointerType *PTy) {
inline static ConstantPointer *CastToPointer(const ConstantPointer *V,
const PointerType *PTy) {
if (V->isNullValue())
return ConstPoolPointerNull::get(PTy);
return ConstantPointerNull::get(PTy);
return 0; // Can't const prop other types of pointers
}
};
@ -235,66 +235,66 @@ struct PointerRules : public TemplateRules<ConstPoolPointer, PointerRules> {
// different types. This allows the C++ compiler to automatically generate our
// constant handling operations in a typesafe and accurate manner.
//
template<class ConstPoolClass, class BuiltinType, Type **Ty>
template<class ConstantClass, class BuiltinType, Type **Ty>
struct DirectRules
: public TemplateRules<ConstPoolClass,
DirectRules<ConstPoolClass, BuiltinType, Ty> > {
: public TemplateRules<ConstantClass,
DirectRules<ConstantClass, BuiltinType, Ty> > {
inline static ConstPoolVal *Not(const ConstPoolClass *V) {
return ConstPoolClass::get(*Ty, !(BuiltinType)V->getValue());;
inline static Constant *Not(const ConstantClass *V) {
return ConstantClass::get(*Ty, !(BuiltinType)V->getValue());;
}
inline static ConstPoolVal *Add(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
inline static Constant *Add(const ConstantClass *V1,
const ConstantClass *V2) {
BuiltinType Result = (BuiltinType)V1->getValue() +
(BuiltinType)V2->getValue();
return ConstPoolClass::get(*Ty, Result);
return ConstantClass::get(*Ty, Result);
}
inline static ConstPoolVal *Sub(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
inline static Constant *Sub(const ConstantClass *V1,
const ConstantClass *V2) {
BuiltinType Result = (BuiltinType)V1->getValue() -
(BuiltinType)V2->getValue();
return ConstPoolClass::get(*Ty, Result);
return ConstantClass::get(*Ty, Result);
}
inline static ConstPoolVal *Mul(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
inline static Constant *Mul(const ConstantClass *V1,
const ConstantClass *V2) {
BuiltinType Result = (BuiltinType)V1->getValue() *
(BuiltinType)V2->getValue();
return ConstPoolClass::get(*Ty, Result);
return ConstantClass::get(*Ty, Result);
}
inline static ConstPoolBool *LessThan(const ConstPoolClass *V1,
const ConstPoolClass *V2) {
inline static ConstantBool *LessThan(const ConstantClass *V1,
const ConstantClass *V2) {
bool Result = (BuiltinType)V1->getValue() < (BuiltinType)V2->getValue();
return ConstPoolBool::get(Result);
return ConstantBool::get(Result);
}
inline static ConstPoolPointer *CastToPointer(const ConstPoolClass *V,
const PointerType *PTy) {
inline static ConstantPointer *CastToPointer(const ConstantClass *V,
const PointerType *PTy) {
if (V->isNullValue()) // Is it a FP or Integral null value?
return ConstPoolPointerNull::get(PTy);
return ConstantPointerNull::get(PTy);
return 0; // Can't const prop other types of pointers
}
// Casting operators. ick
#define DEF_CAST(TYPE, CLASS, CTYPE) \
inline static CLASS *CastTo##TYPE (const ConstPoolClass *V) { \
inline static CLASS *CastTo##TYPE (const ConstantClass *V) { \
return CLASS::get(Type::TYPE##Ty, (CTYPE)(BuiltinType)V->getValue()); \
}
DEF_CAST(Bool , ConstPoolBool, bool)
DEF_CAST(SByte , ConstPoolSInt, signed char)
DEF_CAST(UByte , ConstPoolUInt, unsigned char)
DEF_CAST(Short , ConstPoolSInt, signed short)
DEF_CAST(UShort, ConstPoolUInt, unsigned short)
DEF_CAST(Int , ConstPoolSInt, signed int)
DEF_CAST(UInt , ConstPoolUInt, unsigned int)
DEF_CAST(Long , ConstPoolSInt, int64_t)
DEF_CAST(ULong , ConstPoolUInt, uint64_t)
DEF_CAST(Float , ConstPoolFP , float)
DEF_CAST(Double, ConstPoolFP , double)
DEF_CAST(Bool , ConstantBool, bool)
DEF_CAST(SByte , ConstantSInt, signed char)
DEF_CAST(UByte , ConstantUInt, unsigned char)
DEF_CAST(Short , ConstantSInt, signed short)
DEF_CAST(UShort, ConstantUInt, unsigned short)
DEF_CAST(Int , ConstantSInt, signed int)
DEF_CAST(UInt , ConstantUInt, unsigned int)
DEF_CAST(Long , ConstantSInt, int64_t)
DEF_CAST(ULong , ConstantUInt, uint64_t)
DEF_CAST(Float , ConstantFP , float)
DEF_CAST(Double, ConstantFP , double)
#undef DEF_CAST
};
@ -318,25 +318,25 @@ Annotation *ConstRules::find(AnnotationID AID, const Annotable *TyA, void *) {
case Type::BoolTyID: return new BoolRules();
case Type::PointerTyID: return new PointerRules();
case Type::SByteTyID:
return new DirectRules<ConstPoolSInt, signed char , &Type::SByteTy>();
return new DirectRules<ConstantSInt, signed char , &Type::SByteTy>();
case Type::UByteTyID:
return new DirectRules<ConstPoolUInt, unsigned char , &Type::UByteTy>();
return new DirectRules<ConstantUInt, unsigned char , &Type::UByteTy>();
case Type::ShortTyID:
return new DirectRules<ConstPoolSInt, signed short, &Type::ShortTy>();
return new DirectRules<ConstantSInt, signed short, &Type::ShortTy>();
case Type::UShortTyID:
return new DirectRules<ConstPoolUInt, unsigned short, &Type::UShortTy>();
return new DirectRules<ConstantUInt, unsigned short, &Type::UShortTy>();
case Type::IntTyID:
return new DirectRules<ConstPoolSInt, signed int , &Type::IntTy>();
return new DirectRules<ConstantSInt, signed int , &Type::IntTy>();
case Type::UIntTyID:
return new DirectRules<ConstPoolUInt, unsigned int , &Type::UIntTy>();
return new DirectRules<ConstantUInt, unsigned int , &Type::UIntTy>();
case Type::LongTyID:
return new DirectRules<ConstPoolSInt, int64_t , &Type::LongTy>();
return new DirectRules<ConstantSInt, int64_t , &Type::LongTy>();
case Type::ULongTyID:
return new DirectRules<ConstPoolUInt, uint64_t , &Type::ULongTy>();
return new DirectRules<ConstantUInt, uint64_t , &Type::ULongTy>();
case Type::FloatTyID:
return new DirectRules<ConstPoolFP , float , &Type::FloatTy>();
return new DirectRules<ConstantFP , float , &Type::FloatTy>();
case Type::DoubleTyID:
return new DirectRules<ConstPoolFP , double , &Type::DoubleTy>();
return new DirectRules<ConstantFP , double , &Type::DoubleTy>();
default:
return new EmptyRules();
}

View File

@ -85,11 +85,11 @@ void Method::dropAllReferences() {
// GlobalVariable Implementation
//===----------------------------------------------------------------------===//
GlobalVariable::GlobalVariable(const Type *Ty, bool isConstant, bool isIntern,
ConstPoolVal *Initializer = 0,
GlobalVariable::GlobalVariable(const Type *Ty, bool constant, bool isIntern,
Constant *Initializer = 0,
const string &Name = "")
: GlobalValue(PointerType::get(Ty), Value::GlobalVariableVal, isIntern, Name),
Constant(isConstant) {
isConstantGlobal(constant) {
if (Initializer) Operands.push_back(Use((Value*)Initializer, this));
}

View File

@ -11,7 +11,7 @@
#include "llvm/InstrTypes.h"
#include "llvm/ValueHolderImpl.h"
#include "llvm/Type.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "Support/STLExtras.h"
#include <map>
@ -24,7 +24,7 @@ template class ValueHolder<Method, Module, Module>;
// Define the GlobalValueRefMap as a struct that wraps a map so that we don't
// have Module.h depend on <map>
//
struct GlobalValueRefMap : public map<GlobalValue*, ConstPoolPointerRef*>{
struct GlobalValueRefMap : public map<GlobalValue*, ConstantPointerRef*>{
};
@ -63,7 +63,7 @@ void Module::dropAllReferences() {
if (GVRefMap) {
for (GlobalValueRefMap::iterator I = GVRefMap->begin(), E = GVRefMap->end();
I != E; ++I) {
// Delete the ConstPoolPointerRef node...
// Delete the ConstantPointerRef node...
I->second->destroyConstant();
}
@ -89,24 +89,24 @@ bool Module::reduceApply(bool (*Func)(const Method*)) const {
}
// Accessor for the underlying GlobalValRefMap...
ConstPoolPointerRef *Module::getConstPoolPointerRef(GlobalValue *V){
ConstantPointerRef *Module::getConstantPointerRef(GlobalValue *V){
// Create ref map lazily on demand...
if (GVRefMap == 0) GVRefMap = new GlobalValueRefMap();
GlobalValueRefMap::iterator I = GVRefMap->find(V);
if (I != GVRefMap->end()) return I->second;
ConstPoolPointerRef *Ref = new ConstPoolPointerRef(V);
ConstantPointerRef *Ref = new ConstantPointerRef(V);
GVRefMap->insert(make_pair(V, Ref));
return Ref;
}
void Module::mutateConstPoolPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) {
void Module::mutateConstantPointerRef(GlobalValue *OldGV, GlobalValue *NewGV) {
GlobalValueRefMap::iterator I = GVRefMap->find(OldGV);
assert(I != GVRefMap->end() &&
"mutateConstPoolPointerRef; OldGV not in table!");
ConstPoolPointerRef *Ref = I->second;
"mutateConstantPointerRef; OldGV not in table!");
ConstantPointerRef *Ref = I->second;
// Remove the old entry...
GVRefMap->erase(I);

View File

@ -15,7 +15,7 @@
#include "llvm/GlobalVariable.h"
#include "llvm/Module.h"
#include "llvm/BasicBlock.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/ConstantVals.h"
#include "llvm/iOther.h"
#include "llvm/DerivedTypes.h"
#include "llvm/SymbolTable.h"
@ -114,7 +114,7 @@ void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
for (SymbolTable::const_iterator I = ST->begin(), E = ST->end(); I != E; ++I)
for (SymbolTable::type_const_iterator TI = I->second.begin(),
TE = I->second.end(); TI != TE; ++TI)
if (isa<ConstPoolVal>(TI->second))
if (isa<Constant>(TI->second))
insertValue(TI->second);
}
@ -231,7 +231,7 @@ int SlotCalculator::getValSlot(const Value *D) const {
int SlotCalculator::insertValue(const Value *D) {
if (isa<ConstPoolVal>(D) || isa<GlobalVariable>(D)) {
if (isa<Constant>(D) || isa<GlobalVariable>(D)) {
const User *U = cast<const User>(D);
// This makes sure that if a constant has uses (for example an array
// of const ints), that they are inserted also. Same for global variable
@ -259,7 +259,7 @@ int SlotCalculator::insertVal(const Value *D, bool dontIgnore = false) {
if (!dontIgnore) // Don't ignore nonignorables!
if (D->getType() == Type::VoidTy || // Ignore void type nodes
(IgnoreNamedNodes && // Ignore named and constants
(D->hasName() || isa<ConstPoolVal>(D)) && !isa<Type>(D))) {
(D->hasName() || isa<Constant>(D)) && !isa<Type>(D))) {
SC_DEBUG("ignored value " << D << endl);
return -1; // We do need types unconditionally though
}
@ -336,8 +336,8 @@ int SlotCalculator::doInsertVal(const Value *D) {
SC_DEBUG(" Inserting value [" << Ty << "] = " << D << " slot=" <<
DestSlot << " [");
// G = Global, C = ConstPoolVal, T = Type, M = Method, o = other
SC_DEBUG((isa<GlobalVariable>(D) ? "G" : (isa<ConstPoolVal>(D) ? "C" :
// G = Global, C = Constant, T = Type, M = Method, o = other
SC_DEBUG((isa<GlobalVariable>(D) ? "G" : (isa<Constant>(D) ? "C" :
(isa<Type>(D) ? "T" : (isa<Method>(D) ? "M" : "o")))));
SC_DEBUG("]\n");
return (int)DestSlot;

View File

@ -26,14 +26,14 @@ SymbolTable::~SymbolTable() {
}
}
// TODO: FIXME: BIG ONE: This doesn't unreference abstract types for the planes
// that could still have entries!
// TODO: FIXME: BIG ONE: This doesn't unreference abstract types for the planes
// that could still have entries!
#ifndef NDEBUG // Only do this in -g mode...
bool LeftoverValues = true;
for (iterator i = begin(); i != end(); ++i) {
for (type_iterator I = i->second.begin(); I != i->second.end(); ++I)
if (!isa<ConstPoolVal>(I->second) && !isa<Type>(I->second)) {
if (!isa<Constant>(I->second) && !isa<Type>(I->second)) {
cerr << "Value still in symbol table! Type = '"
<< i->first->getDescription() << "' Name = '" << I->first << "'\n";
LeftoverValues = false;

View File

@ -98,9 +98,9 @@ bool Type::isLosslesslyConvertableTo(const Type *Ty) const {
bool StructType::indexValid(const Value *V) const {
if (!isa<ConstPoolVal>(V)) return false;
if (!isa<Constant>(V)) return false;
if (V->getType() != Type::UByteTy) return false;
unsigned Idx = cast<ConstPoolUInt>(V)->getValue();
unsigned Idx = cast<ConstantUInt>(V)->getValue();
return Idx < ETypes.size();
}
@ -108,9 +108,9 @@ bool StructType::indexValid(const Value *V) const {
// element. For a structure type, this must be a constant value...
//
const Type *StructType::getTypeAtIndex(const Value *V) const {
assert(isa<ConstPoolVal>(V) && "Structure index must be a constant!!");
assert(isa<Constant>(V) && "Structure index must be a constant!!");
assert(V->getType() == Type::UByteTy && "Structure index must be ubyte!");
unsigned Idx = cast<ConstPoolUInt>(V)->getValue();
unsigned Idx = cast<ConstantUInt>(V)->getValue();
assert(Idx < ETypes.size() && "Structure index out of range!");
assert(indexValid(V) && "Invalid structure index!"); // Duplicate check

View File

@ -8,7 +8,6 @@
#include "llvm/InstrTypes.h"
#include "llvm/SymbolTable.h"
#include "llvm/SymTabValue.h"
#include "llvm/ConstPoolVals.h"
#include "llvm/Type.h"
#ifndef NDEBUG // Only in -g mode...
#include "llvm/Assembly/Writer.h"

View File

@ -5,7 +5,6 @@
//===----------------------------------------------------------------------===//
#include "llvm/iMemory.h"
#include "llvm/ConstPoolVals.h"
//===----------------------------------------------------------------------===//
// MemAccessInst Implementation
@ -37,20 +36,23 @@ const Type* MemAccessInst::getIndexedType(const Type *Ptr,
return CurIDX == Idx.size() ? Ptr : 0;
}
const vector<ConstPoolVal*> MemAccessInst::getIndicesBROKEN() const {
#if 1
#include "llvm/ConstantVals.h"
const vector<Constant*> MemAccessInst::getIndicesBROKEN() const {
cerr << "MemAccessInst::getIndices() does not do what you want it to. Talk"
<< " to Chris about this. We can phase it out after the paper.\n";
vector<ConstPoolVal*> RetVal;
vector<Constant*> RetVal;
// THIS CODE WILL FAIL IF A NON CONSTANT INDEX IS USED AS AN ARRAY INDEX
// THIS IS WHY YOU SHOULD NOT USE THIS FUNCTION ANY MORE!!!
for (unsigned i = getFirstIndexOperandNumber(); i < getNumOperands(); ++i)
RetVal.push_back(cast<ConstPoolVal>(getOperand(i)));
RetVal.push_back(cast<Constant>(getOperand(i)));
return RetVal;
}
#endif
//===----------------------------------------------------------------------===//
// LoadInst Implementation

View File

@ -27,7 +27,7 @@ SwitchInst::SwitchInst(const SwitchInst &SI)
}
}
void SwitchInst::dest_push_back(ConstPoolVal *OnVal, BasicBlock *Dest) {
void SwitchInst::dest_push_back(Constant *OnVal, BasicBlock *Dest) {
Operands.push_back(Use(OnVal, this));
Operands.push_back(Use(Dest, this));
}