Live ranges for Return value and return address of a Call are now
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9InstrSelectionSupport.h
1 //===-- llvm/CodeGen/SparcInstrSelectionSupport.h ---------------*- C++ -*-===//
2 //
3 //
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef SPARC_INSTR_SELECTION_SUPPORT_h
8 #define SPARC_INSTR_SELECTION_SUPPORT_h
9
10 #include "llvm/DerivedTypes.h"
11
12 inline MachineOpCode
13 ChooseLoadInstruction(const Type *DestTy)
14 {
15   switch (DestTy->getPrimitiveID()) {
16   case Type::BoolTyID:
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:
24   case Type::ULongTyID:
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");
29   }
30   
31   return 0;
32 }
33
34 inline MachineOpCode
35 ChooseStoreInstruction(const Type *DestTy)
36 {
37   switch (DestTy->getPrimitiveID()) {
38   case Type::BoolTyID:
39   case Type::UByteTyID:
40   case Type::SByteTyID:   return STB;
41   case Type::UShortTyID:
42   case Type::ShortTyID:   return STH;
43   case Type::UIntTyID:
44   case Type::IntTyID:     return STW;
45   case Type::PointerTyID:
46   case Type::ULongTyID:
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");
51   }
52   
53   return 0;
54 }
55
56
57 inline MachineOpCode 
58 ChooseAddInstructionByType(const Type* resultType)
59 {
60   MachineOpCode opCode = INVALID_OPCODE;
61   
62   if (resultType->isIntegral() ||
63       isa<PointerType>(resultType) ||
64       isa<FunctionType>(resultType) ||
65       resultType == Type::LabelTy)
66     {
67       opCode = ADD;
68     }
69   else
70     switch(resultType->getPrimitiveID())
71       {
72       case Type::FloatTyID:  opCode = FADDS; break;
73       case Type::DoubleTyID: opCode = FADDD; break;
74       default: assert(0 && "Invalid type for ADD instruction"); break; 
75       }
76   
77   return opCode;
78 }
79
80 #endif