use super::instruction::Instruction;
use super::types::PtxType;
#[derive(Debug, Clone)]
pub struct PtxFunction {
pub name: String,
pub params: Vec<(String, PtxType)>,
pub body: Vec<Instruction>,
pub shared_mem: Vec<(String, PtxType, usize)>,
pub max_threads: Option<u32>,
}
impl PtxFunction {
#[must_use]
pub fn new(name: impl Into<String>) -> Self {
Self {
name: name.into(),
params: Vec::new(),
body: Vec::new(),
shared_mem: Vec::new(),
max_threads: None,
}
}
pub fn add_param(&mut self, name: impl Into<String>, ty: PtxType) {
self.params.push((name.into(), ty));
}
pub fn add_shared_mem(&mut self, name: impl Into<String>, ty: PtxType, count: usize) {
self.shared_mem.push((name.into(), ty, count));
}
pub fn push(&mut self, inst: Instruction) {
self.body.push(inst);
}
}