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 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 dependent instruction selection.
42 //---------------------------------------------------------------------------
44 FunctionPass *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(MachineCodeForInstruction& mcfi,
72 Value *s1, Value *s2 = 0, const std::string &name = "");
74 // Constructor that requires the type of the temporary to be specified.
75 // Both S1 and S2 may be NULL.
76 TmpInstruction(MachineCodeForInstruction& mcfi,
77 const Type *Ty, Value *s1 = 0, Value* s2 = 0,
78 const std::string &name = "");
80 virtual Instruction *clone() const {
81 assert(0 && "Cannot clone TmpInstructions!");
84 virtual const char *getOpcodeName() const {
85 return "TempValueForMachineInstr";
88 // Methods for support type inquiry through isa, cast, and dyn_cast:
89 static inline bool classof(const TmpInstruction *) { return true; }
90 static inline bool classof(const Instruction *I) {
91 return (I->getOpcode() == Instruction::UserOp1);
93 static inline bool classof(const Value *V) {
94 return isa<Instruction>(V) && classof(cast<Instruction>(V));