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