2 //***************************************************************************
4 // SparcInstrSelectionSupport.h
9 // 10/17/01 - Vikram Adve - Created
10 //**************************************************************************/
12 #ifndef SPARC_INSTR_SELECTION_SUPPORT_h
13 #define SPARC_INSTR_SELECTION_SUPPORT_h
15 #include "llvm/DerivedTypes.h"
16 #include "llvm/Value.h"
19 ChooseLoadInstruction(const Type *DestTy)
21 switch (DestTy->getPrimitiveID()) {
23 case Type::UByteTyID: return LDUB;
24 case Type::SByteTyID: return LDSB;
25 case Type::UShortTyID: return LDUH;
26 case Type::ShortTyID: return LDSH;
27 case Type::UIntTyID: return LDUW;
28 case Type::IntTyID: return LDSW;
29 case Type::PointerTyID:
31 case Type::LongTyID: return LDX;
32 case Type::FloatTyID: return LD;
33 case Type::DoubleTyID: return LDD;
34 default: assert(0 && "Invalid type for Load instruction");
42 ChooseStoreInstruction(const Type *DestTy)
44 switch (DestTy->getPrimitiveID()) {
47 case Type::SByteTyID: return STB;
48 case Type::UShortTyID:
49 case Type::ShortTyID: return STH;
51 case Type::IntTyID: return STW;
52 case Type::PointerTyID:
54 case Type::LongTyID: return STX;
55 case Type::FloatTyID: return ST;
56 case Type::DoubleTyID: return STD;
57 default: assert(0 && "Invalid type for Store instruction");
65 ChooseAddInstructionByType(const Type* resultType)
67 MachineOpCode opCode = INVALID_OPCODE;
69 if (resultType->isIntegral() ||
70 isa<PointerType>(resultType) ||
71 isa<FunctionType>(resultType) ||
72 resultType == Type::LabelTy ||
73 resultType == Type::BoolTy)
78 switch(resultType->getPrimitiveID())
80 case Type::FloatTyID: opCode = FADDS; break;
81 case Type::DoubleTyID: opCode = FADDD; break;
82 default: assert(0 && "Invalid type for ADD instruction"); break;