Rename ConstPoolVal -> Constant
Rename ConstPool* -> Constant*
Rename ConstPoolVals.h -> ConstantVals.h
llvm-svn: 1407
diff --git a/llvm/lib/Target/Sparc/EmitAssembly.cpp b/llvm/lib/Target/Sparc/EmitAssembly.cpp
index 3edeb96..385ffff 100644
--- a/llvm/lib/Target/Sparc/EmitAssembly.cpp
+++ b/llvm/lib/Target/Sparc/EmitAssembly.cpp
@@ -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 @@
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 @@
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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
// 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 @@
// 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 @@
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 @@
// 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 @@
{ // 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 @@
// 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 @@
<< 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 @@
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 @@
// 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 @@
}
}
- 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
diff --git a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
index f8162fc..13e6f54 100644
--- a/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
+++ b/llvm/lib/Target/Sparc/SparcInstrInfo.cpp
@@ -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 @@
// 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 @@
{
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 @@
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 @@
minstr->SetMachineOperand(2, MachineOperand::MO_VirtualRegister,addrVal);
minstrVec.push_back(minstr);
- if (isa<ConstPoolVal>(val))
+ if (isa<Constant>(val))
{
// addrVal->addMachineInstruction(minstr);
diff --git a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp
index 631d609..2439b98 100644
--- a/llvm/lib/Target/Sparc/SparcInstrSelection.cpp
+++ b/llvm/lib/Target/Sparc/SparcInstrSelection.cpp
@@ -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 @@
const InstructionNode* vmInstrNode,
Value* ptrVal,
Value* arrayOffsetVal,
- const vector<ConstPoolVal*>& idxVec,
+ const vector<Constant*>& idxVec,
const TargetMachine& target);
@@ -367,7 +367,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
// 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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
: 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 @@
// 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 @@
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 @@
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 @@
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 @@
// 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 @@
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));