Include SparcV9TmpInstr.h to pick up the def. of TmpInstruction,
[oota-llvm.git] / include / llvm / CodeGen / InstrSelection.h
1 //===-- llvm/CodeGen/InstrSelection.h ---------------------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // External interface to instruction selection.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_CODEGEN_INSTR_SELECTION_H
15 #define LLVM_CODEGEN_INSTR_SELECTION_H
16
17 #include "llvm/Instruction.h"
18
19 namespace llvm {
20
21 class Function;
22 class FunctionPass;
23 class InstrForest;
24 class InstructionNode;
25 class MachineCodeForInstruction;
26 class MachineInstr;
27 class TargetMachine;
28
29 //===--------------------- Required Functions ---------------------------------
30 // Target-dependent functions that MUST be implemented for each target.
31 //
32
33 extern void     GetInstructionsByRule   (InstructionNode* subtreeRoot,
34                                          int ruleForNode,
35                                          short* nts,
36                                          TargetMachine &Target,
37                                          std::vector<MachineInstr*>& mvec);
38
39 extern bool     ThisIsAChainRule        (int eruleno);
40
41
42
43 //---------------------------------------------------------------------------
44 // Function: createInstructionSelectionPass
45 // 
46 // Purpose:
47 //   Entry point for instruction selection using BURG.
48 //   Return a pass that performs machine dependent instruction selection.
49 //---------------------------------------------------------------------------
50
51 FunctionPass *createInstructionSelectionPass(TargetMachine &Target);
52
53
54
55 //---------------------------------------------------------------------------
56 // class TmpInstruction
57 //
58 //   This class represents temporary intermediate values
59 //   used within the machine code for a VM instruction
60 //---------------------------------------------------------------------------
61
62 class TmpInstruction : public Instruction {
63   TmpInstruction(const TmpInstruction &TI)
64     : Instruction(TI.getType(), TI.getOpcode()) {
65     if (!TI.Operands.empty()) {
66       Operands.push_back(Use(TI.Operands[0], this));
67       if (TI.Operands.size() == 2)
68         Operands.push_back(Use(TI.Operands[1], this));
69       else
70         assert(0 && "Bad # operands to TmpInstruction!");
71     }
72   }
73 public:
74   // Constructor that uses the type of S1 as the type of the temporary.
75   // s1 must be a valid value.  s2 may be NULL.
76   TmpInstruction(MachineCodeForInstruction& mcfi,
77                  Value *s1, Value *s2 = 0, const std::string &name = "");
78                  
79   // Constructor that uses the type of S1 as the type of the temporary,
80   // but does not require a MachineCodeForInstruction.
81   // s1 must be a valid value.  s2 may be NULL.
82   TmpInstruction(Value *s1, Value *s2 = 0, const std::string &name = "");
83
84   // Constructor that requires the type of the temporary to be specified.
85   // Both S1 and S2 may be NULL.
86   TmpInstruction(MachineCodeForInstruction& mcfi,
87                  const Type *Ty, Value *s1 = 0, Value* s2 = 0,
88                  const std::string &name = "");
89   
90   virtual Instruction *clone() const {
91     assert(0 && "Cannot clone TmpInstructions!");
92     return 0;
93   }
94   virtual const char *getOpcodeName() const {
95     return "TempValueForMachineInstr";
96   }
97   
98   // Methods for support type inquiry through isa, cast, and dyn_cast:
99   static inline bool classof(const TmpInstruction *) { return true; }
100   static inline bool classof(const Instruction *I) {
101     return (I->getOpcode() == Instruction::UserOp1);
102   }
103   static inline bool classof(const Value *V) {
104     return isa<Instruction>(V) && classof(cast<Instruction>(V));
105   }
106 };
107
108 } // End llvm namespace
109
110 #endif