summaryrefslogtreecommitdiffstats
path: root/llvm
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2002-12-03 07:36:03 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2002-12-03 07:36:03 +0000
commitb6768573587a0f54d9745ac33ff437fe94e761a8 (patch)
tree32ef1bfdf8bfe6e8b25446c3d5c065af9705e55d /llvm
parent8052f8006b64093b0e3659f8d0cc99b53156a87e (diff)
downloadbcm5719-llvm-b6768573587a0f54d9745ac33ff437fe94e761a8.tar.gz
bcm5719-llvm-b6768573587a0f54d9745ac33ff437fe94e761a8.zip
brg
Add support for cast ... to bool in visitCastInst (it's a start, anyways...) llvm-svn: 4883
Diffstat (limited to 'llvm')
-rw-r--r--llvm/lib/Target/X86/InstSelectSimple.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Target/X86/InstSelectSimple.cpp b/llvm/lib/Target/X86/InstSelectSimple.cpp
index a6016604132..ac4084cbbb5 100644
--- a/llvm/lib/Target/X86/InstSelectSimple.cpp
+++ b/llvm/lib/Target/X86/InstSelectSimple.cpp
@@ -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)
OpenPOWER on IntegriCloud