1 //===-- llvm/CodeGen/InstrSelection.h --------------------------*- C++ -*--===//
3 // External interface to instruction selection.
5 //===----------------------------------------------------------------------===//
7 #ifndef LLVM_CODEGEN_INSTR_SELECTION_H
8 #define LLVM_CODEGEN_INSTR_SELECTION_H
10 #include "llvm/Instruction.h"
14 class InstructionNode;
16 class MachineCodeForInstruction;
19 //===--------------------- Required Functions ---------------------------------
20 // Target-dependent functions that MUST be implemented for each target.
23 const unsigned MAX_INSTR_PER_VMINSTR = 8;
25 extern void GetInstructionsByRule (InstructionNode* subtreeRoot,
28 TargetMachine &Target,
29 std::vector<MachineInstr*>& mvec);
31 extern bool ThisIsAChainRule (int eruleno);
34 //************************ Exported Functions ******************************/
37 //---------------------------------------------------------------------------
38 // Function: createInstructionSelectionPass
41 // Entry point for instruction selection using BURG.
42 // Return a pass that performs machine dependant instruction selection.
43 //---------------------------------------------------------------------------
45 Pass *createInstructionSelectionPass(TargetMachine &Target);
48 //************************ Exported Data Types *****************************/
51 //---------------------------------------------------------------------------
52 // class TmpInstruction
54 // This class represents temporary intermediate values
55 // used within the machine code for a VM instruction
56 //---------------------------------------------------------------------------
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));
66 assert(0 && "Bad # operands to TmpInstruction!");
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 = "");
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 = "");
81 virtual Instruction *clone() const {
82 assert(0 && "Cannot clone TmpInstructions!");
85 virtual const char *getOpcodeName() const {
86 return "TempValueForMachineInstr";
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);
94 static inline bool classof(const Value *V) {
95 return isa<Instruction>(V) && classof(cast<Instruction>(V));