aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Bytecode')
-rw-r--r--lib/Bytecode/Reader/InstructionReader.cpp4
-rw-r--r--lib/Bytecode/Writer/InstructionWriter.cpp9
2 files changed, 13 insertions, 0 deletions
diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp
index ab70e24f51..80127cef8c 100644
--- a/lib/Bytecode/Reader/InstructionReader.cpp
+++ b/lib/Bytecode/Reader/InstructionReader.cpp
@@ -105,6 +105,10 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
getValue(Raw.Ty, Raw.Arg1),
getValue(Raw.Ty, Raw.Arg2));
return false;
+ } else if (Raw.Opcode == Instruction::Cast) {
+ Res = UnaryOperator::create(Instruction::Cast, getValue(Raw.Ty, Raw.Arg1),
+ getType(Raw.Arg2));
+ return false;
} else if (Raw.Opcode == Instruction::PHINode) {
PHINode *PN = new PHINode(Raw.Ty);
switch (Raw.NumOperands) {
diff --git a/lib/Bytecode/Writer/InstructionWriter.cpp b/lib/Bytecode/Writer/InstructionWriter.cpp
index 3bd9a0902b..34d95682bf 100644
--- a/lib/Bytecode/Writer/InstructionWriter.cpp
+++ b/lib/Bytecode/Writer/InstructionWriter.cpp
@@ -145,6 +145,15 @@ bool BytecodeWriter::processInstruction(const Instruction *I) {
assert(Slot != -1 && "Type not available!!?!");
Type = (unsigned)Slot;
+ // Handle the special case for cast...
+ if (I->getOpcode() == Instruction::Cast) {
+ // Cast has to encode the destination type as the second argument in the
+ // packet, or else we won't know what type to cast to!
+ Slots[1] = Table.getValSlot(I->getType());
+ assert(Slots[1] != -1 && "Cast return type unknown?");
+ if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
+ NumOperands++;
+ }
// Decide which instruction encoding to use. This is determined primarily by
// the number of operands, and secondarily by whether or not the max operand