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