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/CodeGen/MachineFunction.h"
21 /// PTXMachineFunctionInfo - This class is derived from MachineFunction and
22 /// contains private PTX target-specific information for each MachineFunction.
24 class PTXMachineFunctionInfo
: public MachineFunctionInfo
{
27 std::vector
<unsigned> reg_arg
, reg_local_var
;
32 PTXMachineFunctionInfo(MachineFunction
&MF
)
33 : is_kernel(false), reg_ret(PTX::NoRegister
), _isDoneAddArg(false) {
35 reg_local_var
.reserve(32);
38 void setKernel(bool _is_kernel
=true) { is_kernel
= _is_kernel
; }
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
; }
44 void doneAddArg(void) {
45 std::sort(reg_arg
.begin(), reg_arg
.end());
48 void doneAddLocalVar(void) {
49 std::sort(reg_local_var
.begin(), reg_local_var
.end());
52 bool isDoneAddArg(void) { return _isDoneAddArg
; }
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
;
59 bool argRegEmpty() const { return reg_arg
.empty(); }
60 int getNumArg() const { return reg_arg
.size(); }
61 reg_iterator
argRegBegin() const { return reg_arg
.begin(); }
62 reg_iterator
argRegEnd() const { return reg_arg
.end(); }
63 reg_reverse_iterator
argRegReverseBegin() const { return reg_arg
.rbegin(); }
64 reg_reverse_iterator
argRegReverseEnd() const { return reg_arg
.rend(); }
66 bool localVarRegEmpty() const { return reg_local_var
.empty(); }
67 reg_iterator
localVarRegBegin() const { return reg_local_var
.begin(); }
68 reg_iterator
localVarRegEnd() const { return reg_local_var
.end(); }
70 unsigned retReg() const { return reg_ret
; }
72 bool isArgReg(unsigned reg
) const {
73 return std::binary_search(reg_arg
.begin(), reg_arg
.end(), reg
);
76 bool isLocalVarReg(unsigned reg
) const {
77 return std::binary_search(reg_local_var
.begin(), reg_local_var
.end(), reg
);
79 }; // class PTXMachineFunctionInfo
82 #endif // PTX_MACHINE_FUNCTION_INFO_H