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"
19 class InstructionNode;
24 //---------------------------------------------------------------------------
25 // GLOBAL data and an external function that must be implemented
26 // for each architecture.
27 //---------------------------------------------------------------------------
29 const unsigned MAX_INSTR_PER_VMINSTR = 8;
31 extern unsigned GetInstructionsByRule (InstructionNode* subtreeRoot,
34 TargetMachine &Target,
35 MachineInstr** minstrVec);
37 extern bool ThisIsAChainRule (int eruleno);
40 //************************ Exported Data Types *****************************/
43 //---------------------------------------------------------------------------
44 // Function: SelectInstructionsForMethod
47 // Entry point for instruction selection using BURG.
48 // Returns true if instruction selection failed, false otherwise.
49 // Implemented in machine-specific instruction selection file.
50 //---------------------------------------------------------------------------
52 bool SelectInstructionsForMethod (Method* method,
53 TargetMachine &Target);
55 //---------------------------------------------------------------------------
56 // Function: FoldGetElemChain
59 // Fold a chain of GetElementPtr instructions into an equivalent
60 // (Pointer, IndexVector) pair. Returns the pointer Value, and
61 // stores the resulting IndexVector in argument chainIdxVec.
62 //---------------------------------------------------------------------------
64 Value* FoldGetElemChain (const InstructionNode* getElemInstrNode,
65 vector<ConstPoolVal*>& chainIdxVec);
68 //---------------------------------------------------------------------------
69 // class TmpInstruction
71 // This class represents temporary intermediate values
72 // used within the machine code for a VM instruction
73 //---------------------------------------------------------------------------
75 class TmpInstruction : public Instruction {
76 TmpInstruction (const TmpInstruction &CI) : Instruction(CI.getType(), CI.getOpcode()) {
78 Operands.push_back(Use(Operands[0], this));
79 Operands.push_back(Use(Operands[1], this));
82 TmpInstruction(OtherOps Opcode, Value *S1, Value* S2, const string &Name = "")
83 : Instruction(S1->getType(), Opcode, Name)
85 assert(Opcode == UserOp1 && "Tmp instruction opcode invalid!");
86 Operands.reserve(S2? 2 : 1);
87 Operands.push_back(Use(S1, this));
89 Operands.push_back(Use(S2, this));
92 virtual Instruction *clone() const { return new TmpInstruction(*this); }
93 virtual const char *getOpcodeName() const {
98 //**************************************************************************/