Chris seems fond of #include <vector>. Fix these. Also convert use list in
[oota-llvm.git] / include / llvm / CodeGen / InstrSelection.h
1 // $Id$ -*-c++-*-
2 //***************************************************************************
3 // File:
4 //      InstrSelection.h
5 // 
6 // Purpose:
7 //      
8 // History:
9 //      7/02/01  -  Vikram Adve  -  Created
10 //***************************************************************************
11
12 #ifndef LLVM_CODEGEN_INSTR_SELECTION_H
13 #define LLVM_CODEGEN_INSTR_SELECTION_H
14
15 #include "llvm/Instruction.h"
16 class Method;
17 class InstrForest;
18 class MachineInstr;
19 class InstructionNode;
20 class TmpInstruction;
21 class ConstPoolVal;
22 class TargetMachine;
23
24 //---------------------------------------------------------------------------
25 // GLOBAL data and an external function that must be implemented
26 // for each architecture.
27 //---------------------------------------------------------------------------
28
29 const unsigned MAX_INSTR_PER_VMINSTR = 8;
30
31 extern unsigned GetInstructionsByRule   (InstructionNode* subtreeRoot,
32                                          int ruleForNode,
33                                          short* nts,
34                                          TargetMachine &Target,
35                                          MachineInstr** minstrVec);
36
37 extern bool     ThisIsAChainRule        (int eruleno);
38
39
40 //************************ Exported Data Types *****************************/
41
42
43 //---------------------------------------------------------------------------
44 // Function: SelectInstructionsForMethod
45 // 
46 // Purpose:
47 //   Entry point for instruction selection using BURG.
48 //   Returns true if instruction selection failed, false otherwise.
49 //   Implemented in machine-specific instruction selection file.
50 //---------------------------------------------------------------------------
51
52 bool            SelectInstructionsForMethod     (Method* method,
53                                                  TargetMachine &Target);
54
55 //---------------------------------------------------------------------------
56 // Function: FoldGetElemChain
57 // 
58 // Purpose:
59 //   Fold a chain of GetElementPtr instructions into an equivalent
60 //   (Pointer, IndexVector) pair.  Returns the pointer Value, and
61 //   stores the resulting IndexVector in argument chainIdxVec.
62 //---------------------------------------------------------------------------
63
64 Value*          FoldGetElemChain    (const InstructionNode* getElemInstrNode,
65                                      vector<ConstPoolVal*>& chainIdxVec);
66
67
68 //---------------------------------------------------------------------------
69 // class TmpInstruction
70 //
71 //   This class represents temporary intermediate values
72 //   used within the machine code for a VM instruction
73 //---------------------------------------------------------------------------
74
75 class TmpInstruction : public Instruction {
76   TmpInstruction (const TmpInstruction  &CI) : Instruction(CI.getType(), CI.getOpcode()) {
77     Operands.reserve(2);
78     Operands.push_back(Use(Operands[0], this));
79     Operands.push_back(Use(Operands[1], this));
80   }
81 public:
82   TmpInstruction(OtherOps Opcode, Value *S1, Value* S2, const string &Name = "")
83     : Instruction(S1->getType(), Opcode, Name)
84   {
85     assert(Opcode == UserOp1 && "Tmp instruction opcode invalid!");
86     Operands.reserve(S2? 2 : 1);
87     Operands.push_back(Use(S1, this));
88     if (S2)
89       Operands.push_back(Use(S2, this));
90   }
91   
92   virtual Instruction *clone() const { return new TmpInstruction(*this); }
93   virtual const char *getOpcodeName() const {
94     return "userOp1";
95   }
96 };
97
98 //**************************************************************************/
99
100 #endif