Chris seems fond of #include <vector>. Fix these. Also convert use list in
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9TargetMachine.cpp
1 //***************************************************************************
2 // File:
3 //      Sparc.cpp
4 // 
5 // Purpose:
6 //      
7 // History:
8 //      7/15/01  -  Vikram Adve  -  Created
9 //**************************************************************************/
10
11 #include "llvm/Target/Sparc.h"
12 #include "SparcInternals.h"
13 #include "llvm/Method.h"
14 #include "llvm/CodeGen/InstrScheduling.h"
15 #include "llvm/CodeGen/InstrSelection.h"
16
17 // allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine
18 // that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface)
19 //
20 TargetMachine *allocateSparcTargetMachine() { return new UltraSparc(); }
21
22
23 //---------------------------------------------------------------------------
24 // class UltraSparcInstrInfo 
25 // 
26 // Purpose:
27 //   Information about individual instructions.
28 //   Most information is stored in the SparcMachineInstrDesc array above.
29 //   Other information is computed on demand, and most such functions
30 //   default to member functions in base class MachineInstrInfo. 
31 //---------------------------------------------------------------------------
32
33 /*ctor*/
34 UltraSparcInstrInfo::UltraSparcInstrInfo()
35   : MachineInstrInfo(SparcMachineInstrDesc,
36                      /*descSize = */ NUM_TOTAL_OPCODES,
37                      /*numRealOpCodes = */ NUM_REAL_OPCODES)
38 {
39 }
40
41
42 //---------------------------------------------------------------------------
43 // class UltraSparcSchedInfo 
44 // 
45 // Purpose:
46 //   Scheduling information for the UltraSPARC.
47 //   Primarily just initializes machine-dependent parameters in
48 //   class MachineSchedInfo.
49 //---------------------------------------------------------------------------
50
51 /*ctor*/
52 UltraSparcSchedInfo::UltraSparcSchedInfo(const MachineInstrInfo* mii)
53   : MachineSchedInfo((unsigned int) SPARC_NUM_SCHED_CLASSES,
54                      mii,
55                      SparcRUsageDesc,
56                      SparcInstrUsageDeltas,
57                      SparcInstrIssueDeltas,
58                      sizeof(SparcInstrUsageDeltas)/sizeof(InstrRUsageDelta),
59                      sizeof(SparcInstrIssueDeltas)/sizeof(InstrIssueDelta))
60 {
61   maxNumIssueTotal = 4;
62   longestIssueConflict = 0;             // computed from issuesGaps[]
63   
64   branchMispredictPenalty = 4;          // 4 for SPARC IIi
65   branchTargetUnknownPenalty = 2;       // 2 for SPARC IIi
66   l1DCacheMissPenalty = 8;              // 7 or 9 for SPARC IIi
67   l1ICacheMissPenalty = 8;              // ? for SPARC IIi
68   
69   inOrderLoads = true;                  // true for SPARC IIi
70   inOrderIssue = true;                  // true for SPARC IIi
71   inOrderExec  = false;                 // false for most architectures
72   inOrderRetire= true;                  // true for most architectures
73   
74   // must be called after above parameters are initialized.
75   this->initializeResources();
76 }
77
78 void
79 UltraSparcSchedInfo::initializeResources()
80 {
81   // Compute MachineSchedInfo::instrRUsages and MachineSchedInfo::issueGaps
82   MachineSchedInfo::initializeResources();
83   
84   // Machine-dependent fixups go here.  None for now.
85 }
86
87
88 //---------------------------------------------------------------------------
89 // class UltraSparcMachine 
90 // 
91 // Purpose:
92 //   Primary interface to machine description for the UltraSPARC.
93 //   Primarily just initializes machine-dependent parameters in
94 //   class TargetMachine, and creates machine-dependent subclasses
95 //   for classes such as MachineInstrInfo. 
96 // 
97 //---------------------------------------------------------------------------
98
99 UltraSparc::UltraSparc() : TargetMachine("UltraSparc-Native"),
100                            InstSchedulingInfo(&InstInfo) {
101   optSizeForSubWordData = 4;
102   minMemOpWordSize = 8; 
103   maxAtomicMemOpWordSize = 8;
104   zeroRegNum = 0;                       // %g0 always gives 0 on Sparc
105 }
106
107 bool UltraSparc::compileMethod(Method *M) {
108   if (SelectInstructionsForMethod(M, *this)) {
109     cerr << "Instruction selection failed for method " << M->getName()
110        << "\n\n";
111     return true;
112   }
113   
114   if (ScheduleInstructionsWithSSA(M, *this, InstSchedulingInfo)) {
115     cerr << "Instruction scheduling before allocation failed for method "
116        << M->getName() << "\n\n";
117     return true;
118   }
119   return false;
120 }
121