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);
57 // Debugging function to print the generated instructions
58 void PrintMachineInstructions (Method* method);
61 //---------------------------------------------------------------------------
62 // Function: FoldGetElemChain
65 // Fold a chain of GetElementPtr instructions into an equivalent
66 // (Pointer, IndexVector) pair. Returns the pointer Value, and
67 // stores the resulting IndexVector in argument chainIdxVec.
68 //---------------------------------------------------------------------------
70 Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
71 vector<ConstPoolVal*>& chainIdxVec);
74 //---------------------------------------------------------------------------
75 // class TmpInstruction
77 // This class represents temporary intermediate values
78 // used within the machine code for a VM instruction
79 //---------------------------------------------------------------------------
81 class TmpInstruction : public Instruction {
82 TmpInstruction (const TmpInstruction &CI) : Instruction(CI.getType(), CI.getOpcode()) {
84 Operands.push_back(Use(Operands[0], this));
85 Operands.push_back(Use(Operands[1], this));
88 TmpInstruction(OtherOps Opcode, Value *S1, Value* S2, const string &Name = "")
89 : Instruction(S1->getType(), Opcode, Name)
91 assert(Opcode == UserOp1 && "Tmp instruction opcode invalid!");
92 Operands.reserve(S2? 2 : 1);
93 Operands.push_back(Use(S1, this));
95 Operands.push_back(Use(S2, this));
98 virtual Instruction *clone() const { return new TmpInstruction(*this); }
99 virtual const char *getOpcodeName() const {
104 //**************************************************************************/