1 //===-- SparcV9Internals.h --------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file defines stuff that is to be private to the SparcV9 backend, but is
11 // shared among different portions of the backend.
13 //===----------------------------------------------------------------------===//
15 #ifndef SPARCV9INTERNALS_H
16 #define SPARCV9INTERNALS_H
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 "SparcV9RegInfo.h"
23 #include "llvm/Type.h"
24 #include "SparcV9RegClassInfo.h"
25 #include "llvm/Config/sys/types.h"
30 class SparcV9TargetMachine;
32 class GetElementPtrInst;
34 enum SparcV9InstrSchedClass {
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 */
46 SPARC_INV, /* This should stay at the end for the next value */
47 SPARC_NUM_SCHED_CLASSES = SPARC_INV
51 //---------------------------------------------------------------------------
52 // enum SparcV9MachineOpCode.
53 // const TargetInstrDescriptor SparcV9MachineInstrDesc[]
56 // Description of UltraSparcV9 machine instructions.
58 //---------------------------------------------------------------------------
61 enum SparcV9MachineOpCode {
62 #define I(ENUM, OPCODESTRING, NUMOPERANDS, RESULTPOS, MAXIMM, IMMSE, \
63 NUMDELAYSLOTS, LATENCY, SCHEDCLASS, INSTFLAGS) \
65 #include "SparcV9Instr.def"
67 // End-of-array marker
69 NUM_REAL_OPCODES = PHI, // number of valid opcodes
70 NUM_TOTAL_OPCODES = INVALID_OPCODE
74 // Array of machine instruction descriptions...
75 extern const TargetInstrDescriptor SparcV9MachineInstrDesc[];
77 //---------------------------------------------------------------------------
78 // class SparcV9SchedInfo
81 // Interface to instruction scheduling information for UltraSPARC.
82 // The parameter values above are based on UltraSPARC IIi.
83 //---------------------------------------------------------------------------
85 class SparcV9SchedInfo: public TargetSchedInfo {
87 SparcV9SchedInfo(const TargetMachine &tgt);
89 virtual void initializeResources();
92 /// createStackSlotsPass - External interface to stack-slots pass that enters 2
93 /// empty slots at the top of each function stack
95 FunctionPass *createStackSlotsPass(const TargetMachine &TM);
97 /// Specializes LLVM code for a target machine.
99 FunctionPass *createPreSelectionPass(const TargetMachine &TM);
101 // DecomposeMultiDimRefs - Convert multi-dimensional references consisting of
102 // any combination of 2 or more array and structure indices into a sequence of
103 // instructions (using getelementpr and cast) so that each instruction has at
104 // most one index (except structure references, which need an extra leading
106 // This pass decomposes all multi-dimensional references in a function.
107 FunctionPass *createDecomposeMultiDimRefsPass();
109 // This function decomposes a single instance of such a reference.
110 // Return value: true if the instruction was replaced; false otherwise.
112 bool DecomposeArrayRef(GetElementPtrInst* GEP);
114 /// Peephole optimization pass operating on machine code
116 FunctionPass *createPeepholeOptsPass(const TargetMachine &TM);
118 /// Writes out assembly code for the module, one function at a time
120 FunctionPass *createAsmPrinterPass(std::ostream &Out, TargetMachine &TM);
122 /// getPrologEpilogInsertionPass - Inserts prolog/epilog code.
124 FunctionPass* createPrologEpilogInsertionPass();
126 /// getBytecodeAsmPrinterPass - Emits final LLVM bytecode to assembly file.
128 ModulePass* createBytecodeAsmPrinterPass(std::ostream &Out);
130 FunctionPass *createSparcV9MachineCodeDestructionPass();
132 } // End llvm namespace