2011-09-23 16:18:22 +02:00
|
|
|
//===- PTXParamManager.cpp - Manager for .param variables -------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file implements the PTXParamManager class.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "PTX.h"
|
|
|
|
#include "PTXParamManager.h"
|
|
|
|
#include "llvm/ADT/StringExtras.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
PTXParamManager::PTXParamManager() {
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned PTXParamManager::addArgumentParam(unsigned Size) {
|
|
|
|
PTXParam Param;
|
|
|
|
Param.Type = PTX_PARAM_TYPE_ARGUMENT;
|
|
|
|
Param.Size = Size;
|
|
|
|
|
|
|
|
std::string Name;
|
|
|
|
Name = "__param_";
|
|
|
|
Name += utostr(ArgumentParams.size()+1);
|
|
|
|
Param.Name = Name;
|
|
|
|
|
|
|
|
unsigned Index = AllParams.size();
|
|
|
|
AllParams[Index] = Param;
|
2011-09-23 19:59:11 +02:00
|
|
|
ArgumentParams.push_back(Index);
|
2011-09-23 16:18:22 +02:00
|
|
|
|
|
|
|
return Index;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned PTXParamManager::addReturnParam(unsigned Size) {
|
|
|
|
PTXParam Param;
|
|
|
|
Param.Type = PTX_PARAM_TYPE_RETURN;
|
|
|
|
Param.Size = Size;
|
|
|
|
|
|
|
|
std::string Name;
|
|
|
|
Name = "__ret_";
|
|
|
|
Name += utostr(ReturnParams.size()+1);
|
|
|
|
Param.Name = Name;
|
|
|
|
|
|
|
|
unsigned Index = AllParams.size();
|
|
|
|
AllParams[Index] = Param;
|
2011-09-23 19:59:11 +02:00
|
|
|
ReturnParams.push_back(Index);
|
2011-09-23 16:18:22 +02:00
|
|
|
|
|
|
|
return Index;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned PTXParamManager::addLocalParam(unsigned Size) {
|
|
|
|
PTXParam Param;
|
|
|
|
Param.Type = PTX_PARAM_TYPE_LOCAL;
|
|
|
|
Param.Size = Size;
|
|
|
|
|
|
|
|
std::string Name;
|
|
|
|
Name = "__localparam_";
|
|
|
|
Name += utostr(LocalParams.size()+1);
|
|
|
|
Param.Name = Name;
|
|
|
|
|
|
|
|
unsigned Index = AllParams.size();
|
|
|
|
AllParams[Index] = Param;
|
2011-09-23 19:59:11 +02:00
|
|
|
LocalParams.push_back(Index);
|
2011-09-23 16:18:22 +02:00
|
|
|
|
|
|
|
return Index;
|
|
|
|
}
|
|
|
|
|