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"
15 class InstructionNode;
17 class MachineCodeForInstruction;
20 //===--------------------- Required Functions ---------------------------------
21 // Target-dependent functions that MUST be implemented for each target.
24 const unsigned MAX_INSTR_PER_VMINSTR = 8;
26 extern void GetInstructionsByRule (InstructionNode* subtreeRoot,
29 TargetMachine &Target,
30 std::vector<MachineInstr*>& mvec);
32 extern bool ThisIsAChainRule (int eruleno);
35 //************************ Exported Functions ******************************/
38 //---------------------------------------------------------------------------
39 // Function: createInstructionSelectionPass
42 // Entry point for instruction selection using BURG.
43 // Return a pass that performs machine dependant instruction selection.
44 //---------------------------------------------------------------------------
46 Pass *createInstructionSelectionPass(TargetMachine &Target);
49 //************************ Exported Data Types *****************************/
52 //---------------------------------------------------------------------------
53 // class TmpInstruction
55 // This class represents temporary intermediate values
56 // used within the machine code for a VM instruction
57 //---------------------------------------------------------------------------
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));
67 assert(0 && "Bad # operands to TmpInstruction!");
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 = "");
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 = "");
82 virtual Instruction *clone() const {
83 assert(0 && "Cannot clone TmpInstructions!");
86 virtual const char *getOpcodeName() const {
87 return "TempValueForMachineInstr";
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);
95 static inline bool classof(const Value *V) {
96 return isa<Instruction>(V) && classof(cast<Instruction>(V));