Reorganized the Sparc backend to be more modular -- each different
[oota-llvm.git] / lib / Target / SparcV9 / SparcV9Internals.h
1 //===-- SparcInternals.h ----------------------------------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 // 
10 // This file defines stuff that is to be private to the Sparc backend, but is
11 // shared among different portions of the backend.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef SPARC_INTERNALS_H
16 #define SPARC_INTERNALS_H
17
18 #include "llvm/CodeGen/MachineInstrBuilder.h"
19 #include "llvm/Target/TargetMachine.h"
20 #include "llvm/Target/TargetSchedInfo.h"
21 #include "llvm/Target/TargetFrameInfo.h"
22 #include "llvm/Target/TargetCacheInfo.h"
23 #include "llvm/Target/TargetRegInfo.h"
24 #include "llvm/Type.h"
25 #include "SparcRegClassInfo.h"
26 #include "Config/sys/types.h"
27
28 namespace llvm {
29
30 class LiveRange;
31 class SparcTargetMachine;
32 class Pass;
33
34 enum SparcInstrSchedClass {
35   SPARC_NONE,           /* Instructions with no scheduling restrictions */
36   SPARC_IEUN,           /* Integer class that can use IEU0 or IEU1 */
37   SPARC_IEU0,           /* Integer class IEU0 */
38   SPARC_IEU1,           /* Integer class IEU1 */
39   SPARC_FPM,            /* FP Multiply or Divide instructions */
40   SPARC_FPA,            /* All other FP instructions */ 
41   SPARC_CTI,            /* Control-transfer instructions */
42   SPARC_LD,             /* Load instructions */
43   SPARC_ST,             /* Store instructions */
44   SPARC_SINGLE,         /* Instructions that must issue by themselves */
45   
46   SPARC_INV,            /* This should stay at the end for the next value */
47   SPARC_NUM_SCHED_CLASSES = SPARC_INV
48 };
49
50
51 //---------------------------------------------------------------------------
52 // enum SparcMachineOpCode. 
53 // const TargetInstrDescriptor SparcMachineInstrDesc[]
54 // 
55 // Purpose:
56 //   Description of UltraSparc machine instructions.
57 // 
58 //---------------------------------------------------------------------------
59
60 namespace V9 {
61   enum SparcMachineOpCode {
62 #define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
63           NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS)             \
64    ENUM,
65 #include "SparcInstr.def"
66
67     // End-of-array marker
68     INVALID_OPCODE,
69     NUM_REAL_OPCODES = PHI,             // number of valid opcodes
70     NUM_TOTAL_OPCODES = INVALID_OPCODE
71   };
72 }
73
74 // Array of machine instruction descriptions...
75 extern const TargetInstrDescriptor SparcMachineInstrDesc[];
76
77 //---------------------------------------------------------------------------
78 // class SparcSchedInfo
79 // 
80 // Purpose:
81 //   Interface to instruction scheduling information for UltraSPARC.
82 //   The parameter values above are based on UltraSPARC IIi.
83 //---------------------------------------------------------------------------
84
85 class SparcSchedInfo: public TargetSchedInfo {
86 public:
87   SparcSchedInfo(const TargetMachine &tgt);
88 protected:
89   virtual void initializeResources();
90 };
91
92 //---------------------------------------------------------------------------
93 // class SparcCacheInfo 
94 // 
95 // Purpose:
96 //   Interface to cache parameters for the UltraSPARC.
97 //   Just use defaults for now.
98 //---------------------------------------------------------------------------
99
100 struct SparcCacheInfo: public TargetCacheInfo {
101   SparcCacheInfo(const TargetMachine &T) : TargetCacheInfo(T) {} 
102 };
103
104
105 /// createStackSlotsPass - External interface to stack-slots pass that enters 2
106 /// empty slots at the top of each function stack
107 ///
108 Pass *createStackSlotsPass(const TargetMachine &TM);
109
110 /// Specializes LLVM code for a target machine.
111 ///
112 FunctionPass *createPreSelectionPass(const TargetMachine &TM);
113
114 /// Peephole optimization pass operating on machine code
115 ///
116 FunctionPass *createPeepholeOptsPass(const TargetMachine &TM);
117
118 /// Writes out assembly code for the module, one function at a time
119 ///
120 FunctionPass *createAsmPrinterPass(std::ostream &Out, const TargetMachine &TM);
121
122 /// getPrologEpilogInsertionPass - Inserts prolog/epilog code.
123 ///
124 FunctionPass* createPrologEpilogInsertionPass();
125
126 /// getBytecodeAsmPrinterPass - Emits final LLVM bytecode to assembly file.
127 ///
128 Pass* createBytecodeAsmPrinterPass(std::ostream &Out);
129
130 } // End llvm namespace
131
132 #endif