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;
18 //===--------------------- Required Functions ---------------------------------
19 // Target-dependent functions that MUST be implemented for each target.
22 const unsigned MAX_INSTR_PER_VMINSTR = 8;
24 extern void GetInstructionsByRule (InstructionNode* subtreeRoot,
27 TargetMachine &Target,
28 std::vector<MachineInstr*>& mvec);
30 extern bool ThisIsAChainRule (int eruleno);
33 //************************ Exported Functions ******************************/
36 //---------------------------------------------------------------------------
37 // Function: createInstructionSelectionPass
40 // Entry point for instruction selection using BURG.
41 // Return a pass that performs machine dependant instruction selection.
42 //---------------------------------------------------------------------------
44 Pass *createInstructionSelectionPass(TargetMachine &Target);
47 //************************ Exported Data Types *****************************/
50 //---------------------------------------------------------------------------
51 // class TmpInstruction
53 // This class represents temporary intermediate values
54 // used within the machine code for a VM instruction
55 //---------------------------------------------------------------------------
57 class TmpInstruction : public Instruction {
58 TmpInstruction(const TmpInstruction &TI)
59 : Instruction(TI.getType(), TI.getOpcode()) {
60 if (!TI.Operands.empty()) {
61 Operands.push_back(Use(TI.Operands[0], this));
62 if (TI.Operands.size() == 2)
63 Operands.push_back(Use(TI.Operands[1], this));
65 assert(0 && "Bad # operands to TmpInstruction!");
69 // Constructor that uses the type of S1 as the type of the temporary.
70 // s1 must be a valid value. s2 may be NULL.
71 TmpInstruction(Value *s1, Value *s2 = 0, const std::string &name = "");
73 // Constructor that requires the type of the temporary to be specified.
74 // Both S1 and S2 may be NULL.
75 TmpInstruction(const Type *Ty, Value *s1 = 0, Value* s2 = 0,
76 const std::string &name = "");
78 virtual Instruction *clone() const { return new TmpInstruction(*this); }
79 virtual const char *getOpcodeName() const {
80 return "TempValueForMachineInstr";
83 // Methods for support type inquiry through isa, cast, and dyn_cast:
84 static inline bool classof(const TmpInstruction *) { return true; }
85 static inline bool classof(const Instruction *I) {
86 return (I->getOpcode() == Instruction::UserOp1);
88 static inline bool classof(const Value *V) {
89 return isa<Instruction>(V) && classof(cast<Instruction>(V));