2 //***************************************************************************
9 // 7/02/01 - Vikram Adve - Created
10 //***************************************************************************
12 #ifndef LLVM_CODEGEN_INSTR_SELECTION_H
13 #define LLVM_CODEGEN_INSTR_SELECTION_H
15 #include "llvm/Instruction.h"
20 class InstructionNode;
25 //---------------------------------------------------------------------------
26 // GLOBAL data and an external function that must be implemented
27 // for each architecture.
28 //---------------------------------------------------------------------------
30 const unsigned MAX_INSTR_PER_VMINSTR = 8;
32 extern unsigned GetInstructionsByRule (InstructionNode* subtreeRoot,
35 TargetMachine &Target,
36 MachineInstr** minstrVec);
38 extern bool ThisIsAChainRule (int eruleno);
41 //************************ Exported Data Types *****************************/
44 //---------------------------------------------------------------------------
45 // Function: SelectInstructionsForMethod
48 // Entry point for instruction selection using BURG.
49 // Returns true if instruction selection failed, false otherwise.
50 // Implemented in machine-specific instruction selection file.
51 //---------------------------------------------------------------------------
53 bool SelectInstructionsForMethod (Method* method,
54 TargetMachine &Target);
56 //---------------------------------------------------------------------------
57 // Function: FoldGetElemChain
60 // Fold a chain of GetElementPtr instructions into an equivalent
61 // (Pointer, IndexVector) pair. Returns the pointer Value, and
62 // stores the resulting IndexVector in argument chainIdxVec.
63 //---------------------------------------------------------------------------
65 Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
66 vector<ConstPoolVal*>& chainIdxVec);
69 //---------------------------------------------------------------------------
70 // class TmpInstruction
72 // This class represents temporary intermediate values
73 // used within the machine code for a VM instruction
74 //---------------------------------------------------------------------------
76 class TmpInstruction : public Instruction {
77 TmpInstruction (const TmpInstruction &CI) : Instruction(CI.getType(), CI.getOpcode()) {
79 Operands.push_back(Use(Operands[0], this));
80 Operands.push_back(Use(Operands[1], this));
83 TmpInstruction(OtherOps Opcode, Value *S1, Value* S2, const string &Name = "")
84 : Instruction(S1->getType(), Opcode, Name)
86 assert(Opcode == UserOp1 && "Tmp instruction opcode invalid!");
87 Operands.reserve(S2? 2 : 1);
88 Operands.push_back(Use(S1, this));
90 Operands.push_back(Use(S2, this));
93 virtual Instruction *clone() const { return new TmpInstruction(*this); }
94 virtual const char *getOpcodeName() const {
99 //**************************************************************************/