2002-08-10 04:08:06 +08:00
|
|
|
//===-- llvm/CodeGen/SparcInstrSelectionSupport.h ---------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-10-18 08:03:20 +08:00
|
|
|
|
|
|
|
#ifndef SPARC_INSTR_SELECTION_SUPPORT_h
|
|
|
|
#define SPARC_INSTR_SELECTION_SUPPORT_h
|
|
|
|
|
2002-05-19 23:25:51 +08:00
|
|
|
#include "llvm/DerivedTypes.h"
|
2001-10-18 08:03:20 +08:00
|
|
|
|
|
|
|
inline MachineOpCode
|
|
|
|
ChooseLoadInstruction(const Type *DestTy)
|
|
|
|
{
|
|
|
|
switch (DestTy->getPrimitiveID()) {
|
|
|
|
case Type::BoolTyID:
|
2003-05-28 06:39:01 +08:00
|
|
|
case Type::UByteTyID: return V9::LDUBr;
|
|
|
|
case Type::SByteTyID: return V9::LDSBr;
|
|
|
|
case Type::UShortTyID: return V9::LDUHr;
|
|
|
|
case Type::ShortTyID: return V9::LDSHr;
|
|
|
|
case Type::UIntTyID: return V9::LDUWr;
|
|
|
|
case Type::IntTyID: return V9::LDSWr;
|
2001-10-18 08:03:20 +08:00
|
|
|
case Type::PointerTyID:
|
|
|
|
case Type::ULongTyID:
|
2003-05-28 06:39:01 +08:00
|
|
|
case Type::LongTyID: return V9::LDXr;
|
|
|
|
case Type::FloatTyID: return V9::LDFr;
|
|
|
|
case Type::DoubleTyID: return V9::LDDFr;
|
2001-10-18 08:03:20 +08: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-28 06:39:01 +08:00
|
|
|
case Type::SByteTyID: return V9::STBr;
|
2001-10-18 08:03:20 +08:00
|
|
|
case Type::UShortTyID:
|
2003-05-28 06:39:01 +08:00
|
|
|
case Type::ShortTyID: return V9::STHr;
|
2001-10-18 08:03:20 +08:00
|
|
|
case Type::UIntTyID:
|
2003-05-28 06:39:01 +08:00
|
|
|
case Type::IntTyID: return V9::STWr;
|
2001-10-18 08:03:20 +08:00
|
|
|
case Type::PointerTyID:
|
|
|
|
case Type::ULongTyID:
|
2003-05-28 06:39:01 +08:00
|
|
|
case Type::LongTyID: return V9::STXr;
|
|
|
|
case Type::FloatTyID: return V9::STFr;
|
|
|
|
case Type::DoubleTyID: return V9::STDFr;
|
2001-10-18 08:03:20 +08:00
|
|
|
default: assert(0 && "Invalid type for Store instruction");
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-05-19 23:25:51 +08:00
|
|
|
|
|
|
|
inline MachineOpCode
|
|
|
|
ChooseAddInstructionByType(const Type* resultType)
|
|
|
|
{
|
2003-05-21 04:32:24 +08:00
|
|
|
MachineOpCode opCode = V9::INVALID_OPCODE;
|
2002-05-19 23:25:51 +08:00
|
|
|
|
|
|
|
if (resultType->isIntegral() ||
|
|
|
|
isa<PointerType>(resultType) ||
|
|
|
|
isa<FunctionType>(resultType) ||
|
2002-09-03 09:08:28 +08:00
|
|
|
resultType == Type::LabelTy)
|
2003-05-21 04:32:24 +08:00
|
|
|
{
|
2003-05-28 06:39:01 +08:00
|
|
|
opCode = V9::ADDr;
|
2003-05-21 04:32:24 +08:00
|
|
|
}
|
2002-05-19 23:25:51 +08:00
|
|
|
else
|
|
|
|
switch(resultType->getPrimitiveID())
|
2003-05-21 04:32:24 +08: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 23:25:51 +08:00
|
|
|
|
|
|
|
return opCode;
|
|
|
|
}
|
|
|
|
|
2002-01-21 06:54:45 +08:00
|
|
|
#endif
|