Sparc-specific code shared between local files.
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9InstrSelectionSupport.h
1 // $Id$ -*-c++-*-
2 //***************************************************************************
3 // File:
4 //      SparcInstrSelectionSupport.h
5 // 
6 // Purpose:
7 // 
8 // History:
9 //      10/17/01         -  Vikram Adve  -  Created
10 //**************************************************************************/
11
12 #ifndef SPARC_INSTR_SELECTION_SUPPORT_h
13 #define SPARC_INSTR_SELECTION_SUPPORT_h
14
15
16 inline MachineOpCode
17 ChooseLoadInstruction(const Type *DestTy)
18 {
19   switch (DestTy->getPrimitiveID()) {
20   case Type::BoolTyID:
21   case Type::UByteTyID:   return LDUB;
22   case Type::SByteTyID:   return LDSB;
23   case Type::UShortTyID:  return LDUH;
24   case Type::ShortTyID:   return LDSH;
25   case Type::UIntTyID:    return LDUW;
26   case Type::IntTyID:     return LDSW;
27   case Type::PointerTyID:
28   case Type::ULongTyID:
29   case Type::LongTyID:    return LDX;
30   case Type::FloatTyID:   return LD;
31   case Type::DoubleTyID:  return LDD;
32   default: assert(0 && "Invalid type for Load instruction");
33   }
34   
35   return 0;
36 }
37
38
39 inline MachineOpCode
40 ChooseStoreInstruction(const Type *DestTy)
41 {
42   switch (DestTy->getPrimitiveID()) {
43   case Type::BoolTyID:
44   case Type::UByteTyID:
45   case Type::SByteTyID:   return STB;
46   case Type::UShortTyID:
47   case Type::ShortTyID:   return STH;
48   case Type::UIntTyID:
49   case Type::IntTyID:     return STW;
50   case Type::PointerTyID:
51   case Type::ULongTyID:
52   case Type::LongTyID:    return STX;
53   case Type::FloatTyID:   return ST;
54   case Type::DoubleTyID:  return STD;
55   default: assert(0 && "Invalid type for Store instruction");
56   }
57   
58   return 0;
59 }
60
61 #endif SPARC_INSTR_SELECTION_SUPPORT_h