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