2010-11-08 03:00:52 +00:00
|
|
|
//===- PTXMachineFuctionInfo.h - PTX machine function info -------*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file declares PTX-specific per-machine-function information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef PTX_MACHINE_FUNCTION_INFO_H
|
|
|
|
#define PTX_MACHINE_FUNCTION_INFO_H
|
|
|
|
|
|
|
|
#include "PTX.h"
|
2011-06-16 17:50:00 +00:00
|
|
|
#include "llvm/ADT/DenseSet.h"
|
2010-11-08 03:00:52 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
/// PTXMachineFunctionInfo - This class is derived from MachineFunction and
|
|
|
|
/// contains private PTX target-specific information for each MachineFunction.
|
|
|
|
///
|
|
|
|
class PTXMachineFunctionInfo : public MachineFunctionInfo {
|
|
|
|
private:
|
|
|
|
bool is_kernel;
|
|
|
|
std::vector<unsigned> reg_arg, reg_local_var;
|
2011-06-16 17:50:00 +00:00
|
|
|
DenseSet<unsigned> reg_ret;
|
2010-11-08 03:00:52 +00:00
|
|
|
bool _isDoneAddArg;
|
|
|
|
|
|
|
|
public:
|
|
|
|
PTXMachineFunctionInfo(MachineFunction &MF)
|
|
|
|
: is_kernel(false), reg_ret(PTX::NoRegister), _isDoneAddArg(false) {
|
2011-02-10 12:01:24 +00:00
|
|
|
reg_arg.reserve(8);
|
|
|
|
reg_local_var.reserve(32);
|
2010-11-08 03:00:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void setKernel(bool _is_kernel=true) { is_kernel = _is_kernel; }
|
|
|
|
|
|
|
|
void addArgReg(unsigned reg) { reg_arg.push_back(reg); }
|
|
|
|
void addLocalVarReg(unsigned reg) { reg_local_var.push_back(reg); }
|
2011-06-16 17:50:00 +00:00
|
|
|
void addRetReg(unsigned reg) { reg_ret.insert(reg); }
|
2010-11-08 03:00:52 +00:00
|
|
|
|
|
|
|
void doneAddArg(void) {
|
|
|
|
_isDoneAddArg = true;
|
|
|
|
}
|
2011-04-21 10:56:58 +00:00
|
|
|
void doneAddLocalVar(void) {}
|
2010-11-08 03:00:52 +00:00
|
|
|
|
|
|
|
bool isKernel() const { return is_kernel; }
|
|
|
|
|
2011-03-02 07:36:48 +00:00
|
|
|
typedef std::vector<unsigned>::const_iterator reg_iterator;
|
|
|
|
typedef std::vector<unsigned>::const_reverse_iterator reg_reverse_iterator;
|
2011-06-16 17:50:00 +00:00
|
|
|
typedef DenseSet<unsigned>::const_iterator ret_iterator;
|
2010-11-08 03:00:52 +00:00
|
|
|
|
2011-03-02 07:36:48 +00:00
|
|
|
bool argRegEmpty() const { return reg_arg.empty(); }
|
|
|
|
int getNumArg() const { return reg_arg.size(); }
|
2010-11-08 03:00:52 +00:00
|
|
|
reg_iterator argRegBegin() const { return reg_arg.begin(); }
|
|
|
|
reg_iterator argRegEnd() const { return reg_arg.end(); }
|
2011-03-02 07:36:48 +00:00
|
|
|
reg_reverse_iterator argRegReverseBegin() const { return reg_arg.rbegin(); }
|
|
|
|
reg_reverse_iterator argRegReverseEnd() const { return reg_arg.rend(); }
|
2010-11-08 03:00:52 +00:00
|
|
|
|
2011-03-02 07:36:48 +00:00
|
|
|
bool localVarRegEmpty() const { return reg_local_var.empty(); }
|
2010-11-08 03:00:52 +00:00
|
|
|
reg_iterator localVarRegBegin() const { return reg_local_var.begin(); }
|
|
|
|
reg_iterator localVarRegEnd() const { return reg_local_var.end(); }
|
|
|
|
|
2011-06-16 17:50:00 +00:00
|
|
|
bool retRegEmpty() const { return reg_ret.empty(); }
|
|
|
|
int getNumRet() const { return reg_ret.size(); }
|
|
|
|
ret_iterator retRegBegin() const { return reg_ret.begin(); }
|
|
|
|
ret_iterator retRegEnd() const { return reg_ret.end(); }
|
2010-11-08 03:00:52 +00:00
|
|
|
|
|
|
|
bool isArgReg(unsigned reg) const {
|
2011-04-21 10:16:20 +00:00
|
|
|
return std::find(reg_arg.begin(), reg_arg.end(), reg) != reg_arg.end();
|
2010-11-08 03:00:52 +00:00
|
|
|
}
|
|
|
|
|
2011-06-16 17:50:00 +00:00
|
|
|
bool isRetReg(unsigned reg) const {
|
|
|
|
return std::find(reg_ret.begin(), reg_ret.end(), reg) != reg_ret.end();
|
|
|
|
}
|
|
|
|
|
2010-11-08 03:00:52 +00:00
|
|
|
bool isLocalVarReg(unsigned reg) const {
|
2011-04-21 10:16:20 +00:00
|
|
|
return std::find(reg_local_var.begin(), reg_local_var.end(), reg)
|
|
|
|
!= reg_local_var.end();
|
2010-11-08 03:00:52 +00:00
|
|
|
}
|
|
|
|
}; // class PTXMachineFunctionInfo
|
|
|
|
} // namespace llvm
|
|
|
|
|
|
|
|
#endif // PTX_MACHINE_FUNCTION_INFO_H
|