Use higher level method
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9InstrSelectionSupport.h
index f62457cb494964cc1e2ad81d15f1d1e6dfd403f3..9038a4db85ad937581c9a5a775931c953e626e13 100644 (file)
@@ -1,17 +1,13 @@
-// $Id$ -*-c++-*-
-//***************************************************************************
-// File:
-//     SparcInstrSelectionSupport.h
-// 
-// Purpose:
-// 
-// History:
-//     10/17/01         -  Vikram Adve  -  Created
-//**************************************************************************/
+//===-- llvm/CodeGen/SparcInstrSelectionSupport.h ---------------*- C++ -*-===//
+//
+//
+//
+//===----------------------------------------------------------------------===//
 
 #ifndef SPARC_INSTR_SELECTION_SUPPORT_h
 #define SPARC_INSTR_SELECTION_SUPPORT_h
 
+#include "llvm/DerivedTypes.h"
 
 inline MachineOpCode
 ChooseLoadInstruction(const Type *DestTy)
@@ -35,7 +31,6 @@ ChooseLoadInstruction(const Type *DestTy)
   return 0;
 }
 
-
 inline MachineOpCode
 ChooseStoreInstruction(const Type *DestTy)
 {
@@ -58,4 +53,28 @@ ChooseStoreInstruction(const Type *DestTy)
   return 0;
 }
 
-#endif SPARC_INSTR_SELECTION_SUPPORT_h
+
+inline MachineOpCode 
+ChooseAddInstructionByType(const Type* resultType)
+{
+  MachineOpCode opCode = INVALID_OPCODE;
+  
+  if (resultType->isIntegral() ||
+      isa<PointerType>(resultType) ||
+      isa<FunctionType>(resultType) ||
+      resultType == Type::LabelTy)
+    {
+      opCode = ADD;
+    }
+  else
+    switch(resultType->getPrimitiveID())
+      {
+      case Type::FloatTyID:  opCode = FADDS; break;
+      case Type::DoubleTyID: opCode = FADDD; break;
+      default: assert(0 && "Invalid type for ADD instruction"); break; 
+      }
+  
+  return opCode;
+}
+
+#endif