diff options
Diffstat (limited to 'lib/Bytecode')
-rw-r--r-- | lib/Bytecode/Reader/ConstantReader.cpp | 57 | ||||
-rw-r--r-- | lib/Bytecode/Reader/InstructionReader.cpp | 2 | ||||
-rw-r--r-- | lib/Bytecode/Reader/Reader.cpp | 14 | ||||
-rw-r--r-- | lib/Bytecode/Reader/ReaderInternals.h | 6 | ||||
-rw-r--r-- | lib/Bytecode/Writer/ConstantWriter.cpp | 30 | ||||
-rw-r--r-- | lib/Bytecode/Writer/SlotCalculator.cpp | 12 | ||||
-rw-r--r-- | lib/Bytecode/Writer/Writer.cpp | 8 | ||||
-rw-r--r-- | lib/Bytecode/Writer/WriterInternals.h | 2 |
8 files changed, 65 insertions, 66 deletions
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp index 21462b16d7..ddeeba3336 100644 --- a/lib/Bytecode/Reader/ConstantReader.cpp +++ b/lib/Bytecode/Reader/ConstantReader.cpp @@ -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); } diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index a80f656d0d..5645e689f0 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -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; diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 2766b3485e..84fcd8d8ec 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -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... diff --git a/lib/Bytecode/Reader/ReaderInternals.h b/lib/Bytecode/Reader/ReaderInternals.h index b3977f6c12..6abaa2e56b 100644 --- a/lib/Bytecode/Reader/ReaderInternals.h +++ b/lib/Bytecode/Reader/ReaderInternals.h @@ -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); diff --git a/lib/Bytecode/Writer/ConstantWriter.cpp b/lib/Bytecode/Writer/ConstantWriter.cpp index 8beb132579..835ef9850b 100644 --- a/lib/Bytecode/Writer/ConstantWriter.cpp +++ b/lib/Bytecode/Writer/ConstantWriter.cpp @@ -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; } diff --git a/lib/Bytecode/Writer/SlotCalculator.cpp b/lib/Bytecode/Writer/SlotCalculator.cpp index 6fed526bd6..9c5d97a588 100644 --- a/lib/Bytecode/Writer/SlotCalculator.cpp +++ b/lib/Bytecode/Writer/SlotCalculator.cpp @@ -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; diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index dd46d88bc9..3091384722 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -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 { diff --git a/lib/Bytecode/Writer/WriterInternals.h b/lib/Bytecode/Writer/WriterInternals.h index ff49c1d7fb..8a929870f4 100644 --- a/lib/Bytecode/Writer/WriterInternals.h +++ b/lib/Bytecode/Writer/WriterInternals.h @@ -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); }; |