mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-17 21:29:20 +00:00
Write/read allocation instruction alignment info to .bc files.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24203 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4e240c25e3
commit
42ba6b4b88
@ -902,27 +902,33 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
|
|||||||
if (CallingConv) cast<InvokeInst>(Result)->setCallingConv(CallingConv);
|
if (CallingConv) cast<InvokeInst>(Result)->setCallingConv(CallingConv);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Instruction::Malloc:
|
case Instruction::Malloc: {
|
||||||
if (Oprnds.size() > 2)
|
unsigned Align = 0;
|
||||||
|
if (Oprnds.size() == 2)
|
||||||
|
Align = (1 << Oprnds[1]) >> 1;
|
||||||
|
else if (Oprnds.size() > 2)
|
||||||
error("Invalid malloc instruction!");
|
error("Invalid malloc instruction!");
|
||||||
if (!isa<PointerType>(InstTy))
|
if (!isa<PointerType>(InstTy))
|
||||||
error("Invalid malloc instruction!");
|
error("Invalid malloc instruction!");
|
||||||
|
|
||||||
Result = new MallocInst(cast<PointerType>(InstTy)->getElementType(),
|
Result = new MallocInst(cast<PointerType>(InstTy)->getElementType(),
|
||||||
Oprnds.size() ? getValue(Type::UIntTyID,
|
getValue(Type::UIntTyID, Oprnds[0]), Align);
|
||||||
Oprnds[0]) : 0);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case Instruction::Alloca:
|
case Instruction::Alloca: {
|
||||||
if (Oprnds.size() > 2)
|
unsigned Align = 0;
|
||||||
|
if (Oprnds.size() == 2)
|
||||||
|
Align = (1 << Oprnds[1]) >> 1;
|
||||||
|
else if (Oprnds.size() > 2)
|
||||||
error("Invalid alloca instruction!");
|
error("Invalid alloca instruction!");
|
||||||
if (!isa<PointerType>(InstTy))
|
if (!isa<PointerType>(InstTy))
|
||||||
error("Invalid alloca instruction!");
|
error("Invalid alloca instruction!");
|
||||||
|
|
||||||
Result = new AllocaInst(cast<PointerType>(InstTy)->getElementType(),
|
Result = new AllocaInst(cast<PointerType>(InstTy)->getElementType(),
|
||||||
Oprnds.size() ? getValue(Type::UIntTyID,
|
getValue(Type::UIntTyID, Oprnds[0]), Align);
|
||||||
Oprnds[0]) :0);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
case Instruction::Free:
|
case Instruction::Free:
|
||||||
if (!isa<PointerType>(InstTy))
|
if (!isa<PointerType>(InstTy))
|
||||||
error("Invalid free instruction!");
|
error("Invalid free instruction!");
|
||||||
|
@ -693,6 +693,13 @@ void BytecodeWriter::outputInstruction(const Instruction &I) {
|
|||||||
assert(Slots[1] != ~0U && "Cast return type unknown?");
|
assert(Slots[1] != ~0U && "Cast return type unknown?");
|
||||||
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
|
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
|
||||||
NumOperands++;
|
NumOperands++;
|
||||||
|
} else if (const AllocationInst *AI = dyn_cast<AllocationInst>(&I)) {
|
||||||
|
assert(NumOperands == 1 && "Bogus allocation!");
|
||||||
|
if (AI->getAlignment()) {
|
||||||
|
Slots[1] = Log2_32(AI->getAlignment())+1;
|
||||||
|
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
|
||||||
|
NumOperands = 2;
|
||||||
|
}
|
||||||
} else if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&I)) {
|
} else if (const GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(&I)) {
|
||||||
// We need to encode the type of sequential type indices into their slot #
|
// We need to encode the type of sequential type indices into their slot #
|
||||||
unsigned Idx = 1;
|
unsigned Idx = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user