diff options
author | Chris Lattner <sabre@nondot.org> | 2001-12-03 22:26:30 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-12-03 22:26:30 +0000 |
commit | e9bb2df410f7a22decad9a883f7139d5857c1520 (patch) | |
tree | f6ca07fb5f5de1df8a2572142a707f56bf25c6e6 /lib/Target | |
parent | 9ef18310beaabe7abfa712a3c761036ea2d17caa (diff) | |
download | external_llvm-e9bb2df410f7a22decad9a883f7139d5857c1520.tar.gz external_llvm-e9bb2df410f7a22decad9a883f7139d5857c1520.tar.bz2 external_llvm-e9bb2df410f7a22decad9a883f7139d5857c1520.zip |
Rename ConstPoolVal -> Constant
Rename ConstPool* -> Constant*
Rename ConstPoolVals.h -> ConstantVals.h
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r-- | lib/Target/SparcV9/InstrSelection/InstrForest.cpp | 6 | ||||
-rw-r--r-- | lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp | 36 | ||||
-rw-r--r-- | lib/Target/SparcV9/LiveVar/ValueSet.cpp | 6 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9AsmPrinter.cpp | 70 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9InstrInfo.cpp | 10 | ||||
-rw-r--r-- | lib/Target/SparcV9/SparcV9InstrSelection.cpp | 61 | ||||
-rw-r--r-- | lib/Target/TargetData.cpp | 6 |
7 files changed, 96 insertions, 99 deletions
diff --git a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp index e0f0219a73..ce3e2c3a3f 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrForest.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrForest.cpp @@ -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); diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp index d43e688dd7..468bd8f5b6 100644 --- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp +++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp @@ -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); } } diff --git a/lib/Target/SparcV9/LiveVar/ValueSet.cpp b/lib/Target/SparcV9/LiveVar/ValueSet.cpp index c93bc2028c..6806d1c563 100644 --- a/lib/Target/SparcV9/LiveVar/ValueSet.cpp +++ b/lib/Target/SparcV9/LiveVar/ValueSet.cpp @@ -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 << " "; } diff --git a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp b/lib/Target/SparcV9/SparcV9AsmPrinter.cpp index 3edeb96203..385ffffe56 100644 --- a/lib/Target/SparcV9/SparcV9AsmPrinter.cpp +++ b/lib/Target/SparcV9/SparcV9AsmPrinter.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 @@ 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 diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp index f8162fcd25..13e6f54219 100644 --- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp +++ b/lib/Target/SparcV9/SparcV9InstrInfo.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 @@ 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); diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp index 631d609018..2439b9877c 100644 --- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp +++ b/lib/Target/SparcV9/SparcV9InstrSelection.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 @@ 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)); diff --git a/lib/Target/TargetData.cpp b/lib/Target/TargetData.cpp index 02d18c21a5..b11ef0438a 100644 --- a/lib/Target/TargetData.cpp +++ b/lib/Target/TargetData.cpp @@ -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); |