1 //===-- llvm/CodeGen/SparcInstrSelectionSupport.h ---------------*- C++ -*-===//
5 //===----------------------------------------------------------------------===//
7 #ifndef SPARC_INSTR_SELECTION_SUPPORT_h
8 #define SPARC_INSTR_SELECTION_SUPPORT_h
10 #include "llvm/DerivedTypes.h"
13 ChooseLoadInstruction(const Type *DestTy)
15 switch (DestTy->getPrimitiveID()) {
17 case Type::UByteTyID: return LDUB;
18 case Type::SByteTyID: return LDSB;
19 case Type::UShortTyID: return LDUH;
20 case Type::ShortTyID: return LDSH;
21 case Type::UIntTyID: return LDUW;
22 case Type::IntTyID: return LDSW;
23 case Type::PointerTyID:
25 case Type::LongTyID: return LDX;
26 case Type::FloatTyID: return LD;
27 case Type::DoubleTyID: return LDD;
28 default: assert(0 && "Invalid type for Load instruction");
35 ChooseStoreInstruction(const Type *DestTy)
37 switch (DestTy->getPrimitiveID()) {
40 case Type::SByteTyID: return STB;
41 case Type::UShortTyID:
42 case Type::ShortTyID: return STH;
44 case Type::IntTyID: return STW;
45 case Type::PointerTyID:
47 case Type::LongTyID: return STX;
48 case Type::FloatTyID: return ST;
49 case Type::DoubleTyID: return STD;
50 default: assert(0 && "Invalid type for Store instruction");
58 ChooseAddInstructionByType(const Type* resultType)
60 MachineOpCode opCode = INVALID_OPCODE;
62 if (resultType->isIntegral() ||
63 isa<PointerType>(resultType) ||
64 isa<FunctionType>(resultType) ||
65 resultType == Type::LabelTy)
70 switch(resultType->getPrimitiveID())
72 case Type::FloatTyID: opCode = FADDS; break;
73 case Type::DoubleTyID: opCode = FADDD; break;
74 default: assert(0 && "Invalid type for ADD instruction"); break;