-// $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)
return 0;
}
-
inline MachineOpCode
ChooseStoreInstruction(const Type *DestTy)
{
return 0;
}
+
+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