Added MachineCodeForInstruction object as an argument to
[oota-llvm.git] / include / llvm / CodeGen / InstrSelection.h
1 //===-- llvm/CodeGen/InstrSelection.h --------------------------*- C++ -*--===//
2 //
3 // External interface to instruction selection.
4 //
5 //===----------------------------------------------------------------------===//
6
7 #ifndef LLVM_CODEGEN_INSTR_SELECTION_H
8 #define LLVM_CODEGEN_INSTR_SELECTION_H
9
10 #include "llvm/Instruction.h"
11 class Function;
12 class InstrForest;
13 class MachineInstr;
14 class InstructionNode;
15 class TargetMachine;
16 class MachineCodeForInstruction;
17 class Pass;
18
19 //===--------------------- Required Functions ---------------------------------
20 // Target-dependent functions that MUST be implemented for each target.
21 //
22
23 const unsigned MAX_INSTR_PER_VMINSTR = 8;
24
25 extern void     GetInstructionsByRule   (InstructionNode* subtreeRoot,
26                                          int ruleForNode,
27                                          short* nts,
28                                          TargetMachine &Target,
29                                          std::vector<MachineInstr*>& mvec);
30
31 extern bool     ThisIsAChainRule        (int eruleno);
32
33
34 //************************ Exported Functions ******************************/
35
36
37 //---------------------------------------------------------------------------
38 // Function: createInstructionSelectionPass
39 // 
40 // Purpose:
41 //   Entry point for instruction selection using BURG.
42 //   Return a pass that performs machine dependant instruction selection.
43 //---------------------------------------------------------------------------
44
45 Pass *createInstructionSelectionPass(TargetMachine &Target);
46
47
48 //************************ Exported Data Types *****************************/
49
50
51 //---------------------------------------------------------------------------
52 // class TmpInstruction
53 //
54 //   This class represents temporary intermediate values
55 //   used within the machine code for a VM instruction
56 //---------------------------------------------------------------------------
57
58 class TmpInstruction : public Instruction {
59   TmpInstruction(const TmpInstruction &TI)
60     : Instruction(TI.getType(), TI.getOpcode()) {
61     if (!TI.Operands.empty()) {
62       Operands.push_back(Use(TI.Operands[0], this));
63       if (TI.Operands.size() == 2)
64         Operands.push_back(Use(TI.Operands[1], this));
65       else
66         assert(0 && "Bad # operands to TmpInstruction!");
67     }
68   }
69 public:
70   // Constructor that uses the type of S1 as the type of the temporary.
71   // s1 must be a valid value.  s2 may be NULL.
72   TmpInstruction(MachineCodeForInstruction& mcfi,
73                  Value *s1, Value *s2 = 0, const std::string &name = "");
74   
75   // Constructor that requires the type of the temporary to be specified.
76   // Both S1 and S2 may be NULL.
77   TmpInstruction(MachineCodeForInstruction& mcfi,
78                  const Type *Ty, Value *s1 = 0, Value* s2 = 0,
79                  const std::string &name = "");
80   
81   virtual Instruction *clone() const {
82     assert(0 && "Cannot clone TmpInstructions!");
83     return 0;
84   }
85   virtual const char *getOpcodeName() const {
86     return "TempValueForMachineInstr";
87   }
88   
89   // Methods for support type inquiry through isa, cast, and dyn_cast:
90   static inline bool classof(const TmpInstruction *) { return true; }
91   static inline bool classof(const Instruction *I) {
92     return (I->getOpcode() == Instruction::UserOp1);
93   }
94   static inline bool classof(const Value *V) {
95     return isa<Instruction>(V) && classof(cast<Instruction>(V));
96   }
97 };
98
99 #endif