2002-08-09 20:08:06 +00:00
|
|
|
//===-- llvm/CodeGen/SparcInstrSelectionSupport.h ---------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-18 00:03:20 +00:00
|
|
|
|
|
|
|
#ifndef SPARC_INSTR_SELECTION_SUPPORT_h
|
|
|
|
#define SPARC_INSTR_SELECTION_SUPPORT_h
|
|
|
|
|
2002-05-19 15:25:51 +00:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2001-10-18 00:03:20 +00:00
|
|
|
|
|
|
|
inline MachineOpCode
|
|
|
|
ChooseLoadInstruction(const Type *DestTy)
|
|
|
|
{
|
|
|
|
switch (DestTy->getPrimitiveID()) {
|
|
|
|
case Type::BoolTyID:
|
2003-05-20 20:32:24 +00:00
|
|
|
case Type::UByteTyID: return V9::LDUB;
|
|
|
|
case Type::SByteTyID: return V9::LDSB;
|
|
|
|
case Type::UShortTyID: return V9::LDUH;
|
|
|
|
case Type::ShortTyID: return V9::LDSH;
|
|
|
|
case Type::UIntTyID: return V9::LDUW;
|
|
|
|
case Type::IntTyID: return V9::LDSW;
|
2001-10-18 00:03:20 +00:00
|
|
|
case Type::PointerTyID:
|
|
|
|
case Type::ULongTyID:
|
2003-05-20 20:32:24 +00:00
|
|
|
case Type::LongTyID: return V9::LDX;
|
|
|
|
case Type::FloatTyID: return V9::LD;
|
|
|
|
case Type::DoubleTyID: return V9::LDD;
|
2001-10-18 00:03:20 +00:00
|
|
|
default: assert(0 && "Invalid type for Load instruction");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline MachineOpCode
|
|
|
|
ChooseStoreInstruction(const Type *DestTy)
|
|
|
|
{
|
|
|
|
switch (DestTy->getPrimitiveID()) {
|
|
|
|
case Type::BoolTyID:
|
|
|
|
case Type::UByteTyID:
|
2003-05-20 20:32:24 +00:00
|
|
|
case Type::SByteTyID: return V9::STB;
|
2001-10-18 00:03:20 +00:00
|
|
|
case Type::UShortTyID:
|
2003-05-20 20:32:24 +00:00
|
|
|
case Type::ShortTyID: return V9::STH;
|
2001-10-18 00:03:20 +00:00
|
|
|
case Type::UIntTyID:
|
2003-05-20 20:32:24 +00:00
|
|
|
case Type::IntTyID: return V9::STW;
|
2001-10-18 00:03:20 +00:00
|
|
|
case Type::PointerTyID:
|
|
|
|
case Type::ULongTyID:
|
2003-05-20 20:32:24 +00:00
|
|
|
case Type::LongTyID: return V9::STX;
|
|
|
|
case Type::FloatTyID: return V9::ST;
|
|
|
|
case Type::DoubleTyID: return V9::STD;
|
2001-10-18 00:03:20 +00:00
|
|
|
default: assert(0 && "Invalid type for Store instruction");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-05-19 15:25:51 +00:00
|
|
|
|
|
|
|
inline MachineOpCode
|
|
|
|
ChooseAddInstructionByType(const Type* resultType)
|
|
|
|
{
|
2003-05-20 20:32:24 +00:00
|
|
|
MachineOpCode opCode = V9::INVALID_OPCODE;
|
2002-05-19 15:25:51 +00:00
|
|
|
|
|
|
|
if (resultType->isIntegral() ||
|
|
|
|
isa<PointerType>(resultType) ||
|
|
|
|
isa<FunctionType>(resultType) ||
|
2002-09-03 01:08:28 +00:00
|
|
|
resultType == Type::LabelTy)
|
2003-05-20 20:32:24 +00:00
|
|
|
{
|
|
|
|
opCode = V9::ADD;
|
|
|
|
}
|
2002-05-19 15:25:51 +00:00
|
|
|
else
|
|
|
|
switch(resultType->getPrimitiveID())
|
2003-05-20 20:32:24 +00:00
|
|
|
{
|
|
|
|
case Type::FloatTyID: opCode = V9::FADDS; break;
|
|
|
|
case Type::DoubleTyID: opCode = V9::FADDD; break;
|
|
|
|
default: assert(0 && "Invalid type for ADD instruction"); break;
|
|
|
|
}
|
2002-05-19 15:25:51 +00:00
|
|
|
|
|
|
|
return opCode;
|
|
|
|
}
|
|
|
|
|
2002-01-20 22:54:45 +00:00
|
|
|
#endif
|