mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-22 13:29:44 +00:00
Implement reading and writing of the ICmp and FCmp instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32149 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
74f1642bc1
commit
c8dab49aad
@ -550,12 +550,11 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
|
|||||||
|
|
||||||
// First, handle the easy binary operators case
|
// First, handle the easy binary operators case
|
||||||
if (Opcode >= Instruction::BinaryOpsBegin &&
|
if (Opcode >= Instruction::BinaryOpsBegin &&
|
||||||
Opcode < Instruction::BinaryOpsEnd && Oprnds.size() == 2)
|
Opcode < Instruction::BinaryOpsEnd && Oprnds.size() == 2) {
|
||||||
Result = BinaryOperator::create(Instruction::BinaryOps(Opcode),
|
Result = BinaryOperator::create(Instruction::BinaryOps(Opcode),
|
||||||
getValue(iType, Oprnds[0]),
|
getValue(iType, Oprnds[0]),
|
||||||
getValue(iType, Oprnds[1]));
|
getValue(iType, Oprnds[1]));
|
||||||
|
} else {
|
||||||
if (!Result) {
|
|
||||||
// Indicate that we don't think this is a call instruction (yet).
|
// Indicate that we don't think this is a call instruction (yet).
|
||||||
// Process based on the Opcode read
|
// Process based on the Opcode read
|
||||||
switch (Opcode) {
|
switch (Opcode) {
|
||||||
@ -700,6 +699,13 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
|
|||||||
Result = PN;
|
Result = PN;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Instruction::ICmp:
|
||||||
|
case Instruction::FCmp:
|
||||||
|
// These instructions encode the comparison predicate as the 3rd operand.
|
||||||
|
Result = CmpInst::create(Instruction::OtherOps(Opcode),
|
||||||
|
static_cast<unsigned short>(Oprnds[2]),
|
||||||
|
getValue(iType, Oprnds[0]), getValue(iType, Oprnds[1]));
|
||||||
|
break;
|
||||||
case Instruction::Shl:
|
case Instruction::Shl:
|
||||||
case Instruction::LShr:
|
case Instruction::LShr:
|
||||||
case Instruction::AShr:
|
case Instruction::AShr:
|
||||||
|
@ -718,6 +718,15 @@ void BytecodeWriter::outputInstruction(const Instruction &I) {
|
|||||||
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
|
if (Slots[1] > MaxOpSlot) MaxOpSlot = Slots[1];
|
||||||
NumOperands = 2;
|
NumOperands = 2;
|
||||||
}
|
}
|
||||||
|
} else if (isa<ICmpInst>(I) || isa<FCmpInst>(I)) {
|
||||||
|
// We need to encode the compare instruction's predicate as the third
|
||||||
|
// operand. Its not really a slot, but we don't want to break the
|
||||||
|
// instruction format for these instructions.
|
||||||
|
NumOperands++;
|
||||||
|
assert(NumOperands == 3 && "CmpInst with wrong number of operands?");
|
||||||
|
Slots[2] = unsigned(cast<CmpInst>(&I)->getPredicate());
|
||||||
|
if (Slots[2] > MaxOpSlot)
|
||||||
|
MaxOpSlot = Slots[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…
x
Reference in New Issue
Block a user