mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
encode/decode function alignment in bc files
llvm-svn: 24218
This commit is contained in:
parent
aea08816e0
commit
6c8657e621
@ -1928,13 +1928,11 @@ void BytecodeReader::ParseModuleGlobalInfo() {
|
||||
}
|
||||
|
||||
const Type *Ty = getType(SlotNo);
|
||||
if (!Ty) {
|
||||
if (!Ty)
|
||||
error("Global has no type! SlotNo=" + utostr(SlotNo));
|
||||
}
|
||||
|
||||
if (!isa<PointerType>(Ty)) {
|
||||
if (!isa<PointerType>(Ty))
|
||||
error("Global not a pointer type! Ty= " + Ty->getDescription());
|
||||
}
|
||||
|
||||
const Type *ElTy = cast<PointerType>(Ty)->getElementType();
|
||||
|
||||
@ -1965,8 +1963,8 @@ void BytecodeReader::ParseModuleGlobalInfo() {
|
||||
FnSignature = (FnSignature << 5) + 1;
|
||||
|
||||
// List is terminated by VoidTy.
|
||||
while ((FnSignature >> 5) != Type::VoidTyID) {
|
||||
const Type *Ty = getType(FnSignature >> 5);
|
||||
while (((FnSignature & (~0U >> 1)) >> 5) != Type::VoidTyID) {
|
||||
const Type *Ty = getType((FnSignature & (~0U >> 1)) >> 5);
|
||||
if (!isa<PointerType>(Ty) ||
|
||||
!isa<FunctionType>(cast<PointerType>(Ty)->getElementType())) {
|
||||
error("Function not a pointer to function type! Ty = " +
|
||||
@ -1981,7 +1979,7 @@ void BytecodeReader::ParseModuleGlobalInfo() {
|
||||
// Insert the place holder.
|
||||
Function* Func = new Function(FTy, GlobalValue::ExternalLinkage,
|
||||
"", TheModule);
|
||||
insertValue(Func, FnSignature >> 5, ModuleValues);
|
||||
insertValue(Func, (FnSignature & (~0U >> 1)) >> 5, ModuleValues);
|
||||
|
||||
// Flags are not used yet.
|
||||
unsigned Flags = FnSignature & 31;
|
||||
@ -1992,13 +1990,17 @@ void BytecodeReader::ParseModuleGlobalInfo() {
|
||||
if ((Flags & (1 << 4)) == 0)
|
||||
FunctionSignatureList.push_back(Func);
|
||||
|
||||
// Look at the low bits. If there is a calling conv here, apply it,
|
||||
// read it as a vbr.
|
||||
Flags &= 15;
|
||||
if (Flags)
|
||||
Func->setCallingConv(Flags-1);
|
||||
else
|
||||
Func->setCallingConv(read_vbr_uint());
|
||||
// Get the calling convention from the low bits.
|
||||
unsigned CC = Flags & 15;
|
||||
unsigned Alignment = 0;
|
||||
if (FnSignature & (1 << 31)) { // Has extension word?
|
||||
unsigned ExtWord = read_vbr_uint();
|
||||
Alignment = (1 << (ExtWord & 31)) >> 1;
|
||||
CC |= ((ExtWord >> 5) & 15) << 4;
|
||||
}
|
||||
|
||||
Func->setCallingConv(CC);
|
||||
Func->setAlignment(Alignment);
|
||||
|
||||
if (Handler) Handler->handleFunctionDeclaration(Func);
|
||||
|
||||
|
@ -949,9 +949,8 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
|
||||
// The extension word has this format: bit 0 = has initializer, bit 1-3 =
|
||||
// linkage, bit 4-8 = alignment (log2), bits 10+ = future use.
|
||||
unsigned ExtWord = I->hasInitializer() | (getEncodedLinkage(I) << 1) |
|
||||
(Log2_32(I->getAlignment())+1) << 4;
|
||||
((Log2_32(I->getAlignment())+1) << 4);
|
||||
output_vbr(ExtWord);
|
||||
|
||||
}
|
||||
|
||||
// If we have an initializer, output it now.
|
||||
@ -968,18 +967,23 @@ void BytecodeWriter::outputModuleInfoBlock(const Module *M) {
|
||||
int Slot = Table.getSlot(I->getType());
|
||||
assert(Slot != -1 && "Module slot calculator is broken!");
|
||||
assert(Slot >= Type::FirstDerivedTyID && "Derived type not in range!");
|
||||
assert(((Slot << 5) >> 5) == Slot && "Slot # too big!");
|
||||
unsigned ID = (Slot << 5);
|
||||
|
||||
if (I->getCallingConv() < 15)
|
||||
ID += I->getCallingConv()+1;
|
||||
assert(((Slot << 6) >> 6) == Slot && "Slot # too big!");
|
||||
unsigned ID = (Slot << 5) | (I->getCallingConv() & 15);
|
||||
|
||||
if (I->isExternal()) // If external, we don't have an FunctionInfo block.
|
||||
ID |= 1 << 4;
|
||||
|
||||
if (I->getAlignment() || I->getCallingConv() & ~15)
|
||||
ID |= 1 << 31; // Do we need an extension word?
|
||||
|
||||
output_vbr(ID);
|
||||
|
||||
if (I->getCallingConv() >= 15)
|
||||
output_vbr(I->getCallingConv());
|
||||
|
||||
if (ID & (1 << 31)) {
|
||||
// Extension byte: bits 0-4 = alignment, bits 5-9 = top nibble of calling
|
||||
// convention.
|
||||
ID = (Log2_32(I->getAlignment())+1) | ((I->getCallingConv() >> 4) << 5);
|
||||
output_vbr(ID);
|
||||
}
|
||||
}
|
||||
output_vbr((unsigned)Table.getSlot(Type::VoidTy) << 5);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user