mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-18 12:29:21 +00:00
brg
Add support for cast ... to bool in visitCastInst (it's a start, anyways...) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4883 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ea1ddab58e
commit
07f02614f6
@ -641,9 +641,20 @@ ISel::visitCastInst (CastInst &CI)
|
||||
//the former is that the register allocator could use any register it wants,
|
||||
//but for now this obviously doesn't matter. :)
|
||||
|
||||
// if target type is bool
|
||||
// Emit Compare
|
||||
// Emit Set-if-not-zero
|
||||
Type *targetType = CI.getType ();
|
||||
Value *operand = CI.getOperand (0);
|
||||
unsigned int operandReg = getReg (operand);
|
||||
Type *sourceType = operand->getType ();
|
||||
unsigned int destReg = getReg (CI);
|
||||
|
||||
// cast to bool:
|
||||
if (targetType == Type::BoolTy) {
|
||||
// Emit Compare
|
||||
BuildMI (BB, X86::CMPri8, 2).addReg (operandReg).addZImm (0);
|
||||
// Emit Set-if-not-zero
|
||||
BuildMI (BB, X86::SETNEr, 1, destReg);
|
||||
return;
|
||||
}
|
||||
|
||||
// if size of target type == size of source type
|
||||
// Emit Mov reg(target) <- reg(source)
|
||||
|
@ -641,9 +641,20 @@ ISel::visitCastInst (CastInst &CI)
|
||||
//the former is that the register allocator could use any register it wants,
|
||||
//but for now this obviously doesn't matter. :)
|
||||
|
||||
// if target type is bool
|
||||
// Emit Compare
|
||||
// Emit Set-if-not-zero
|
||||
Type *targetType = CI.getType ();
|
||||
Value *operand = CI.getOperand (0);
|
||||
unsigned int operandReg = getReg (operand);
|
||||
Type *sourceType = operand->getType ();
|
||||
unsigned int destReg = getReg (CI);
|
||||
|
||||
// cast to bool:
|
||||
if (targetType == Type::BoolTy) {
|
||||
// Emit Compare
|
||||
BuildMI (BB, X86::CMPri8, 2).addReg (operandReg).addZImm (0);
|
||||
// Emit Set-if-not-zero
|
||||
BuildMI (BB, X86::SETNEr, 1, destReg);
|
||||
return;
|
||||
}
|
||||
|
||||
// if size of target type == size of source type
|
||||
// Emit Mov reg(target) <- reg(source)
|
||||
|
Loading…
Reference in New Issue
Block a user