Add support for casting operators
[oota-llvm.git] / lib / VMCore / iOperators.cpp
index 6f7c2f158ebb71c1d694dfec48fe64dc77ae599e..22b6052d4692dd5f484e22795387e0011bf5767b 100644 (file)
@@ -1,24 +1,30 @@
-//===-- iBinaryOperators.cpp - Implement the BinaryOperators -----*- C++ -*--=//
+//===-- iOperators.cpp - Implement the Binary & Unary Operators --*- C++ -*--=//
 //
-// This file implements the nontrivial binary operator instructions.
+// This file implements the nontrivial binary & unary operator instructions.
 //
 //===----------------------------------------------------------------------===//
 
-#include "llvm/iBinary.h"
+#include "llvm/iOperators.h"
 #include "llvm/Type.h"
 
-UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source,
-                                    const Type *DestTy = 0) {
-  if (DestTy == 0) DestTy = Source->getType();
+//===----------------------------------------------------------------------===//
+//                              UnaryOperator Class
+//===----------------------------------------------------------------------===//
+
+UnaryOperator *UnaryOperator::create(UnaryOps Op, Value *Source) {
   switch (Op) {
-  case Not:  assert(DestTy == Source->getType());
-  case Cast: return new GenericUnaryInst(Op, Source, DestTy);
+  case Not:  return new GenericUnaryInst(Op, Source);
   default:
-    cerr << "Don't know how to GetUnaryOperator " << Op << endl;
+    cerr << "Don't know how to Create UnaryOperator " << Op << endl;
     return 0;
   }
 }
 
+
+//===----------------------------------------------------------------------===//
+//                           GenericUnaryOperator Class
+//===----------------------------------------------------------------------===//
+
 const char *GenericUnaryInst::getOpcodeName() const {
   switch (getOpcode()) {
   case Not: return "not";
@@ -29,6 +35,7 @@ const char *GenericUnaryInst::getOpcodeName() const {
   }
 }
 
+
 //===----------------------------------------------------------------------===//
 //                             BinaryOperator Class
 //===----------------------------------------------------------------------===//
@@ -46,6 +53,7 @@ BinaryOperator *BinaryOperator::create(BinaryOps Op, Value *S1, Value *S2,
   }
 }
 
+
 //===----------------------------------------------------------------------===//
 //                            GenericBinaryInst Class
 //===----------------------------------------------------------------------===//
@@ -69,6 +77,7 @@ const char *GenericBinaryInst::getOpcodeName() const {
   }
 }
 
+
 //===----------------------------------------------------------------------===//
 //                             SetCondInst Class
 //===----------------------------------------------------------------------===//