mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-11 00:39:36 +00:00
* Implement cast (long|ulong) to bool
* Fix cast of (short|ushort|int|uint) to bool to work right git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6510 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6c8125fa56
commit
20772547c5
@ -1552,10 +1552,28 @@ void ISel::emitCastOperation(MachineBasicBlock *BB,
|
||||
// Implement casts to bool by using compare on the operand followed by set if
|
||||
// not zero on the result.
|
||||
if (DestTy == Type::BoolTy) {
|
||||
if (SrcClass == cFP || SrcClass == cLong)
|
||||
abort(); // FIXME: implement cast (long & FP) to bool
|
||||
|
||||
BMI(BB, IP, X86::CMPri8, 2).addReg(SrcReg).addZImm(0);
|
||||
switch (SrcClass) {
|
||||
case cByte:
|
||||
BMI(BB, IP, X86::TESTrr8, 2).addReg(SrcReg).addReg(SrcReg);
|
||||
break;
|
||||
case cShort:
|
||||
BMI(BB, IP, X86::TESTrr16, 2).addReg(SrcReg).addReg(SrcReg);
|
||||
break;
|
||||
case cInt:
|
||||
BMI(BB, IP, X86::TESTrr32, 2).addReg(SrcReg).addReg(SrcReg);
|
||||
break;
|
||||
case cLong: {
|
||||
unsigned TmpReg = makeAnotherReg(Type::IntTy);
|
||||
BMI(BB, IP, X86::ORrr32, 2, TmpReg).addReg(SrcReg).addReg(SrcReg+1);
|
||||
break;
|
||||
}
|
||||
case cFP:
|
||||
assert(0 && "FIXME: implement cast FP to bool");
|
||||
abort();
|
||||
}
|
||||
|
||||
// If the zero flag is not set, then the value is true, set the byte to
|
||||
// true.
|
||||
BMI(BB, IP, X86::SETNEr, 1, DestReg);
|
||||
return;
|
||||
}
|
||||
|
@ -1552,10 +1552,28 @@ void ISel::emitCastOperation(MachineBasicBlock *BB,
|
||||
// Implement casts to bool by using compare on the operand followed by set if
|
||||
// not zero on the result.
|
||||
if (DestTy == Type::BoolTy) {
|
||||
if (SrcClass == cFP || SrcClass == cLong)
|
||||
abort(); // FIXME: implement cast (long & FP) to bool
|
||||
|
||||
BMI(BB, IP, X86::CMPri8, 2).addReg(SrcReg).addZImm(0);
|
||||
switch (SrcClass) {
|
||||
case cByte:
|
||||
BMI(BB, IP, X86::TESTrr8, 2).addReg(SrcReg).addReg(SrcReg);
|
||||
break;
|
||||
case cShort:
|
||||
BMI(BB, IP, X86::TESTrr16, 2).addReg(SrcReg).addReg(SrcReg);
|
||||
break;
|
||||
case cInt:
|
||||
BMI(BB, IP, X86::TESTrr32, 2).addReg(SrcReg).addReg(SrcReg);
|
||||
break;
|
||||
case cLong: {
|
||||
unsigned TmpReg = makeAnotherReg(Type::IntTy);
|
||||
BMI(BB, IP, X86::ORrr32, 2, TmpReg).addReg(SrcReg).addReg(SrcReg+1);
|
||||
break;
|
||||
}
|
||||
case cFP:
|
||||
assert(0 && "FIXME: implement cast FP to bool");
|
||||
abort();
|
||||
}
|
||||
|
||||
// If the zero flag is not set, then the value is true, set the byte to
|
||||
// true.
|
||||
BMI(BB, IP, X86::SETNEr, 1, DestReg);
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user