summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Writer
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2006-12-31 05:44:24 +0000
committerReid Spencer <rspencer@reidspencer.com>2006-12-31 05:44:24 +0000
commitb46895bc1f25c243446bedf3cc73bc1e25d47512 (patch)
tree03e8a62585ed5861f1bc86a52196aa94ceb551ba /llvm/lib/Bytecode/Writer
parent42f0cbe7694d746e9129e8f2c5d2c6495ef47199 (diff)
downloadbcm5719-llvm-b46895bc1f25c243446bedf3cc73bc1e25d47512.tar.gz
bcm5719-llvm-b46895bc1f25c243446bedf3cc73bc1e25d47512.zip
For PR950:
Update for signless integer types and parameter attribute implementation. Of significant note: 1. This changes the bytecode format yet again. 2. There are 1/2 as many integer type planes (this is a good thing) 3. GEP indices now use only 1 bit to identify their type which means more GEP instructions won't be relegated to format 0 (size win) 4. Parameter attributes are implemented but currently being stored verbosely for each function type. Some other day this needs to be optimized for size. llvm-svn: 32783
Diffstat (limited to 'llvm/lib/Bytecode/Writer')
-rw-r--r--llvm/lib/Bytecode/Writer/SlotCalculator.cpp3
-rw-r--r--llvm/lib/Bytecode/Writer/Writer.cpp35
2 files changed, 15 insertions, 23 deletions
diff --git a/llvm/lib/Bytecode/Writer/SlotCalculator.cpp b/llvm/lib/Bytecode/Writer/SlotCalculator.cpp
index 9e096ee6eb2..cf770c4bbc9 100644
--- a/llvm/lib/Bytecode/Writer/SlotCalculator.cpp
+++ b/llvm/lib/Bytecode/Writer/SlotCalculator.cpp
@@ -145,8 +145,7 @@ void SlotCalculator::processModule() {
//
for (unsigned plane = 0, e = Table.size(); plane != e; ++plane) {
if (const ArrayType *AT = dyn_cast<ArrayType>(Types[plane]))
- if (AT->getElementType() == Type::SByteTy ||
- AT->getElementType() == Type::UByteTy) {
+ if (AT->getElementType() == Type::Int8Ty) {
TypePlane &Plane = Table[plane];
unsigned FirstNonStringID = 0;
for (unsigned i = 0, e = Plane.size(); i != e; ++i)
diff --git a/llvm/lib/Bytecode/Writer/Writer.cpp b/llvm/lib/Bytecode/Writer/Writer.cpp
index 44a654bc5b7..58cc13a1414 100644
--- a/llvm/lib/Bytecode/Writer/Writer.cpp
+++ b/llvm/lib/Bytecode/Writer/Writer.cpp
@@ -214,16 +214,20 @@ void BytecodeWriter::outputType(const Type *T) {
int Slot = Table.getSlot(MT->getReturnType());
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
+ output_vbr(unsigned(MT->getParamAttrs(0)));
// Output the number of arguments to function (+1 if varargs):
output_vbr((unsigned)MT->getNumParams()+MT->isVarArg());
// Output all of the arguments...
FunctionType::param_iterator I = MT->param_begin();
+ unsigned Idx = 1;
for (; I != MT->param_end(); ++I) {
Slot = Table.getSlot(*I);
assert(Slot != -1 && "Type used but not available!!");
output_typeid((unsigned)Slot);
+ output_vbr(unsigned(MT->getParamAttrs(Idx)));
+ Idx++;
}
// Terminate list with VoidTy if we are a varargs function...
@@ -323,20 +327,13 @@ void BytecodeWriter::outputConstant(const Constant *CPV) {
output_vbr(0U);
break;
- case Type::UByteTyID: // Unsigned integer types...
- case Type::UShortTyID:
- case Type::UIntTyID:
- case Type::ULongTyID:
+ case Type::Int8TyID: // Unsigned integer types...
+ case Type::Int16TyID:
+ case Type::Int32TyID:
+ case Type::Int64TyID:
output_vbr(cast<ConstantInt>(CPV)->getZExtValue());
break;
- case Type::SByteTyID: // Signed integer types...
- case Type::ShortTyID:
- case Type::IntTyID:
- case Type::LongTyID:
- output_vbr(cast<ConstantInt>(CPV)->getSExtValue());
- break;
-
case Type::ArrayTyID: {
const ConstantArray *CPA = cast<ConstantArray>(CPV);
assert(!CPA->isString() && "Constant strings should be handled specially!");
@@ -489,12 +486,10 @@ void BytecodeWriter::outputInstructionFormat0(const Instruction *I,
unsigned IdxId;
switch (I->getOperand(Idx)->getType()->getTypeID()) {
default: assert(0 && "Unknown index type!");
- case Type::UIntTyID: IdxId = 0; break;
- case Type::IntTyID: IdxId = 1; break;
- case Type::ULongTyID: IdxId = 2; break;
- case Type::LongTyID: IdxId = 3; break;
+ case Type::Int32TyID: IdxId = 0; break;
+ case Type::Int64TyID: IdxId = 1; break;
}
- Slot = (Slot << 2) | IdxId;
+ Slot = (Slot << 1) | IdxId;
}
output_vbr(unsigned(Slot));
}
@@ -742,12 +737,10 @@ void BytecodeWriter::outputInstruction(const Instruction &I) {
unsigned IdxId;
switch (GEP->getOperand(Idx)->getType()->getTypeID()) {
default: assert(0 && "Unknown index type!");
- case Type::UIntTyID: IdxId = 0; break;
- case Type::IntTyID: IdxId = 1; break;
- case Type::ULongTyID: IdxId = 2; break;
- case Type::LongTyID: IdxId = 3; break;
+ case Type::Int32TyID: IdxId = 0; break;
+ case Type::Int64TyID: IdxId = 1; break;
}
- Slots[Idx] = (Slots[Idx] << 2) | IdxId;
+ Slots[Idx] = (Slots[Idx] << 1) | IdxId;
if (Slots[Idx] > MaxOpSlot) MaxOpSlot = Slots[Idx];
}
} else if (Opcode == 58) {
OpenPOWER on IntegriCloud