Added LLVM copyright header (for lack of a better term).
[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 class Function;
20 class InstrForest;
21 class MachineInstr;
22 class InstructionNode;
23 class TargetMachine;
24 class MachineCodeForInstruction;
25 class FunctionPass;
26
27 //===--------------------- Required Functions ---------------------------------
28 // Target-dependent functions that MUST be implemented for each target.
29 //
30
31 extern void     GetInstructionsByRule   (InstructionNode* subtreeRoot,
32                                          int ruleForNode,
33                                          short* nts,
34                                          TargetMachine &Target,
35                                          std::vector<MachineInstr*>& mvec);
36
37 extern bool     ThisIsAChainRule        (int eruleno);
38
39
40 //************************ Exported Functions ******************************/
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 //************************ Exported Data Types *****************************/
55
56
57 //---------------------------------------------------------------------------
58 // class TmpInstruction
59 //
60 //   This class represents temporary intermediate values
61 //   used within the machine code for a VM instruction
62 //---------------------------------------------------------------------------
63
64 class TmpInstruction : public Instruction {
65   TmpInstruction(const TmpInstruction &TI)
66     : Instruction(TI.getType(), TI.getOpcode()) {
67     if (!TI.Operands.empty()) {
68       Operands.push_back(Use(TI.Operands[0], this));
69       if (TI.Operands.size() == 2)
70         Operands.push_back(Use(TI.Operands[1], this));
71       else
72         assert(0 && "Bad # operands to TmpInstruction!");
73     }
74   }
75 public:
76   // Constructor that uses the type of S1 as the type of the temporary.
77   // s1 must be a valid value.  s2 may be NULL.
78   TmpInstruction(MachineCodeForInstruction& mcfi,
79                  Value *s1, Value *s2 = 0, const std::string &name = "");
80   
81   // Constructor that requires the type of the temporary to be specified.
82   // Both S1 and S2 may be NULL.
83   TmpInstruction(MachineCodeForInstruction& mcfi,
84                  const Type *Ty, Value *s1 = 0, Value* s2 = 0,
85                  const std::string &name = "");
86   
87   virtual Instruction *clone() const {
88     assert(0 && "Cannot clone TmpInstructions!");
89     return 0;
90   }
91   virtual const char *getOpcodeName() const {
92     return "TempValueForMachineInstr";
93   }
94   
95   // Methods for support type inquiry through isa, cast, and dyn_cast:
96   static inline bool classof(const TmpInstruction *) { return true; }
97   static inline bool classof(const Instruction *I) {
98     return (I->getOpcode() == Instruction::UserOp1);
99   }
100   static inline bool classof(const Value *V) {
101     return isa<Instruction>(V) && classof(cast<Instruction>(V));
102   }
103 };
104
105 #endif