MC: Make TargetAsmBackend available to the AsmStreamer.
[oota-llvm.git] / lib / Target / PTX / PTXMachineFunctionInfo.h
1 //===- PTXMachineFuctionInfo.h - PTX machine function info -------*- C++ -*-==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file declares PTX-specific per-machine-function information.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef PTX_MACHINE_FUNCTION_INFO_H
15 #define PTX_MACHINE_FUNCTION_INFO_H
16
17 #include "PTX.h"
18 #include "llvm/CodeGen/MachineFunction.h"
19
20 namespace llvm {
21 /// PTXMachineFunctionInfo - This class is derived from MachineFunction and
22 /// contains private PTX target-specific information for each MachineFunction.
23 ///
24 class PTXMachineFunctionInfo : public MachineFunctionInfo {
25 private:
26   bool is_kernel;
27   std::vector<unsigned> reg_arg, reg_local_var;
28   unsigned reg_ret;
29   bool _isDoneAddArg;
30
31 public:
32   PTXMachineFunctionInfo(MachineFunction &MF)
33     : is_kernel(false), reg_ret(PTX::NoRegister), _isDoneAddArg(false) {
34       reg_arg.reserve(32);
35       reg_local_var.reserve(64);
36     }
37
38   void setKernel(bool _is_kernel=true) { is_kernel = _is_kernel; }
39
40   void addArgReg(unsigned reg) { reg_arg.push_back(reg); }
41   void addLocalVarReg(unsigned reg) { reg_local_var.push_back(reg); }
42   void setRetReg(unsigned reg) { reg_ret = reg; }
43
44   void doneAddArg(void) {
45     std::sort(reg_arg.begin(), reg_arg.end());
46     _isDoneAddArg = true;
47   }
48   void doneAddLocalVar(void) {
49     std::sort(reg_local_var.begin(), reg_local_var.end());
50   }
51
52   bool isDoneAddArg(void) { return _isDoneAddArg; }
53
54   bool isKernel() const { return is_kernel; }
55
56   typedef std::vector<unsigned>::const_iterator reg_iterator;
57
58   bool argRegEmpty() const { return reg_arg.empty(); }
59   int getNumArg() const { return reg_arg.size(); }
60   reg_iterator argRegBegin() const { return reg_arg.begin(); }
61   reg_iterator argRegEnd()   const { return reg_arg.end(); }
62
63   bool localVarRegEmpty() const { return reg_local_var.empty(); }
64   reg_iterator localVarRegBegin() const { return reg_local_var.begin(); }
65   reg_iterator localVarRegEnd()   const { return reg_local_var.end(); }
66
67   unsigned retReg() const { return reg_ret; }
68
69   bool isArgReg(unsigned reg) const {
70     return std::binary_search(reg_arg.begin(), reg_arg.end(), reg);
71   }
72
73   bool isLocalVarReg(unsigned reg) const {
74     return std::binary_search(reg_local_var.begin(), reg_local_var.end(), reg);
75   }
76 }; // class PTXMachineFunctionInfo
77 } // namespace llvm
78
79 #endif // PTX_MACHINE_FUNCTION_INFO_H