1 //***************************************************************************
8 // 7/15/01 - Vikram Adve - Created
9 //**************************************************************************/
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"
17 // allocateSparcTargetMachine - Allocate and return a subclass of TargetMachine
18 // that implements the Sparc backend. (the llvm/CodeGen/Sparc.h interface)
20 TargetMachine *allocateSparcTargetMachine() { return new UltraSparc(); }
23 //---------------------------------------------------------------------------
24 // class UltraSparcInstrInfo
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 //---------------------------------------------------------------------------
34 UltraSparcInstrInfo::UltraSparcInstrInfo()
35 : MachineInstrInfo(SparcMachineInstrDesc,
36 /*descSize = */ NUM_TOTAL_OPCODES,
37 /*numRealOpCodes = */ NUM_REAL_OPCODES)
42 //---------------------------------------------------------------------------
43 // class UltraSparcSchedInfo
46 // Scheduling information for the UltraSPARC.
47 // Primarily just initializes machine-dependent parameters in
48 // class MachineSchedInfo.
49 //---------------------------------------------------------------------------
52 UltraSparcSchedInfo::UltraSparcSchedInfo(const MachineInstrInfo* mii)
53 : MachineSchedInfo((unsigned int) SPARC_NUM_SCHED_CLASSES,
56 SparcInstrUsageDeltas,
57 SparcInstrIssueDeltas,
58 sizeof(SparcInstrUsageDeltas)/sizeof(InstrRUsageDelta),
59 sizeof(SparcInstrIssueDeltas)/sizeof(InstrIssueDelta))
62 longestIssueConflict = 0; // computed from issuesGaps[]
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
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
74 // must be called after above parameters are initialized.
75 this->initializeResources();
79 UltraSparcSchedInfo::initializeResources()
81 // Compute MachineSchedInfo::instrRUsages and MachineSchedInfo::issueGaps
82 MachineSchedInfo::initializeResources();
84 // Machine-dependent fixups go here. None for now.
88 //---------------------------------------------------------------------------
89 // class UltraSparcMachine
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.
97 //---------------------------------------------------------------------------
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
107 bool UltraSparc::compileMethod(Method *M) {
108 if (SelectInstructionsForMethod(M, *this)) {
109 cerr << "Instruction selection failed for method " << M->getName()
114 if (ScheduleInstructionsWithSSA(M, *this, InstSchedulingInfo)) {
115 cerr << "Instruction scheduling before allocation failed for method "
116 << M->getName() << "\n\n";