mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-10-04 07:09:55 +00:00
Add func support in mode insertion
This commit is contained in:
parent
82ca92c5c3
commit
2cf9c597db
1 changed files with 32 additions and 18 deletions
|
@ -349,21 +349,9 @@ pub(crate) fn run<'input>(
|
||||||
is_kernel,
|
is_kernel,
|
||||||
..
|
..
|
||||||
}) => {
|
}) => {
|
||||||
// TODO: implement for non-kernels
|
let (mut bb_state, body_iter) =
|
||||||
if !*is_kernel {
|
BasicBlockState::new(&mut cfg, *name, body, *is_kernel)?;
|
||||||
todo!()
|
for statement in body_iter {
|
||||||
}
|
|
||||||
let entry_index = cfg.add_entry_basic_block(*name);
|
|
||||||
let mut bb_state = BasicBlockState::new(&mut cfg);
|
|
||||||
let mut body_iter = body.iter();
|
|
||||||
match body_iter.next() {
|
|
||||||
Some(Statement::Label(label)) => {
|
|
||||||
bb_state.cfg.add_jump(entry_index, *label);
|
|
||||||
bb_state.start(*label);
|
|
||||||
}
|
|
||||||
_ => return Err(error_unreachable()),
|
|
||||||
};
|
|
||||||
for statement in body.iter() {
|
|
||||||
match statement {
|
match statement {
|
||||||
Statement::Instruction(ast::Instruction::Bra { arguments }) => {
|
Statement::Instruction(ast::Instruction::Bra { arguments }) => {
|
||||||
bb_state.end(&[arguments.src]);
|
bb_state.end(&[arguments.src]);
|
||||||
|
@ -712,13 +700,39 @@ struct BasicBlockState<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BasicBlockState<'a> {
|
impl<'a> BasicBlockState<'a> {
|
||||||
fn new(cfg: &'a mut ControlFlowGraph) -> BasicBlockState<'a> {
|
#[must_use]
|
||||||
Self {
|
fn new<'x>(
|
||||||
|
cfg: &'a mut ControlFlowGraph,
|
||||||
|
fn_name: SpirvWord,
|
||||||
|
body: &'x Vec<Statement<ast::Instruction<SpirvWord>, SpirvWord>>,
|
||||||
|
is_kernel: bool,
|
||||||
|
) -> Result<
|
||||||
|
(
|
||||||
|
BasicBlockState<'a>,
|
||||||
|
impl Iterator<Item = &'x Statement<ast::Instruction<SpirvWord>, SpirvWord>>,
|
||||||
|
),
|
||||||
|
TranslateError,
|
||||||
|
> {
|
||||||
|
let entry_index = if is_kernel {
|
||||||
|
cfg.add_entry_basic_block(fn_name)
|
||||||
|
} else {
|
||||||
|
cfg.get_or_add_basic_block(fn_name)
|
||||||
|
};
|
||||||
|
let mut body_iter = body.iter();
|
||||||
|
let mut bb_state = Self {
|
||||||
cfg,
|
cfg,
|
||||||
node_index: None,
|
node_index: None,
|
||||||
entry: InstructionModes::none(),
|
entry: InstructionModes::none(),
|
||||||
exit: InstructionModes::none(),
|
exit: InstructionModes::none(),
|
||||||
|
};
|
||||||
|
match body_iter.next() {
|
||||||
|
Some(Statement::Label(label)) => {
|
||||||
|
bb_state.cfg.add_jump(entry_index, *label);
|
||||||
|
bb_state.start(*label);
|
||||||
}
|
}
|
||||||
|
_ => return Err(error_unreachable()),
|
||||||
|
};
|
||||||
|
Ok((bb_state, body_iter))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start(&mut self, label: SpirvWord) {
|
fn start(&mut self, label: SpirvWord) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue