1 //===- PTXMachineFuctionInfo.h - PTX machine function info -------*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares PTX-specific per-machine-function information.
12 //===----------------------------------------------------------------------===//
14 #ifndef PTX_MACHINE_FUNCTION_INFO_H
15 #define PTX_MACHINE_FUNCTION_INFO_H
18 #include "llvm/ADT/DenseSet.h"
19 #include "llvm/CodeGen/MachineFunction.h"
22 /// PTXMachineFunctionInfo - This class is derived from MachineFunction and
23 /// contains private PTX target-specific information for each MachineFunction.
25 class PTXMachineFunctionInfo
: public MachineFunctionInfo
{
28 std::vector
<unsigned> reg_arg
, reg_local_var
;
29 std::vector
<unsigned> reg_ret
;
33 PTXMachineFunctionInfo(MachineFunction
&MF
)
34 : is_kernel(false), reg_ret(PTX::NoRegister
), _isDoneAddArg(false) {
36 reg_local_var
.reserve(32);
39 void setKernel(bool _is_kernel
=true) { is_kernel
= _is_kernel
; }
41 void addArgReg(unsigned reg
) { reg_arg
.push_back(reg
); }
42 void addLocalVarReg(unsigned reg
) { reg_local_var
.push_back(reg
); }
43 void addRetReg(unsigned reg
) {
45 reg_ret
.push_back(reg
);
49 void doneAddArg(void) {
52 void doneAddLocalVar(void) {}
54 bool isKernel() const { return is_kernel
; }
56 typedef std::vector
<unsigned>::const_iterator reg_iterator
;
57 typedef std::vector
<unsigned>::const_reverse_iterator reg_reverse_iterator
;
58 typedef std::vector
<unsigned>::const_iterator ret_iterator
;
60 bool argRegEmpty() const { return reg_arg
.empty(); }
61 int getNumArg() const { return reg_arg
.size(); }
62 reg_iterator
argRegBegin() const { return reg_arg
.begin(); }
63 reg_iterator
argRegEnd() const { return reg_arg
.end(); }
64 reg_reverse_iterator
argRegReverseBegin() const { return reg_arg
.rbegin(); }
65 reg_reverse_iterator
argRegReverseEnd() const { return reg_arg
.rend(); }
67 bool localVarRegEmpty() const { return reg_local_var
.empty(); }
68 reg_iterator
localVarRegBegin() const { return reg_local_var
.begin(); }
69 reg_iterator
localVarRegEnd() const { return reg_local_var
.end(); }
71 bool retRegEmpty() const { return reg_ret
.empty(); }
72 int getNumRet() const { return reg_ret
.size(); }
73 ret_iterator
retRegBegin() const { return reg_ret
.begin(); }
74 ret_iterator
retRegEnd() const { return reg_ret
.end(); }
76 bool isArgReg(unsigned reg
) const {
77 return std::find(reg_arg
.begin(), reg_arg
.end(), reg
) != reg_arg
.end();
80 bool isRetReg(unsigned reg
) const {
81 return std::find(reg_ret
.begin(), reg_ret
.end(), reg
) != reg_ret
.end();
84 bool isLocalVarReg(unsigned reg
) const {
85 return std::find(reg_local_var
.begin(), reg_local_var
.end(), reg
)
86 != reg_local_var
.end();
88 }; // class PTXMachineFunctionInfo
91 #endif // PTX_MACHINE_FUNCTION_INFO_H