mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-07-29 12:28:38 +00:00
Implement third pass
This commit is contained in:
parent
69175d27ed
commit
4e6dc07a52
3 changed files with 8 additions and 23 deletions
|
@ -26,17 +26,9 @@ pub(crate) fn run(
|
||||||
src: src_reg,
|
src: src_reg,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
ast::Instruction::Call(call) => {
|
|
||||||
let resolver = fn_defs.get_fn_sig_resolver(call.func)?;
|
|
||||||
let resolved_call = resolver.resolve_in_spirv_repr(call)?;
|
|
||||||
let mut visitor = VectorRepackVisitor::new(&mut result, id_defs);
|
|
||||||
let reresolved_call = resolved_call.visit(&mut visitor)?;
|
|
||||||
visitor.func.push(reresolved_call);
|
|
||||||
visitor.func.extend(visitor.post_stmts);
|
|
||||||
}
|
|
||||||
inst => {
|
inst => {
|
||||||
let mut visitor = VectorRepackVisitor::new(&mut result, id_defs);
|
let mut visitor = VectorRepackVisitor::new(&mut result, id_defs);
|
||||||
let instruction = Statement::Instruction(inst.map(&mut visitor)?);
|
let instruction = Statement::Instruction(ast::visit_map(inst, &mut visitor)?);
|
||||||
visitor.func.push(instruction);
|
visitor.func.push(instruction);
|
||||||
visitor.func.extend(visitor.post_stmts);
|
visitor.func.extend(visitor.post_stmts);
|
||||||
}
|
}
|
||||||
|
@ -68,12 +60,7 @@ impl<'a, 'b> VectorRepackVisitor<'a, 'b> {
|
||||||
fn convert_vector(
|
fn convert_vector(
|
||||||
&mut self,
|
&mut self,
|
||||||
is_dst: bool,
|
is_dst: bool,
|
||||||
non_default_implicit_conversion: Option<
|
relaxed_type_check: bool,
|
||||||
fn(
|
|
||||||
(ast::StateSpace, &ast::Type),
|
|
||||||
(ast::StateSpace, &ast::Type),
|
|
||||||
) -> Result<Option<ConversionKind>, TranslateError>,
|
|
||||||
>,
|
|
||||||
typ: &ast::Type,
|
typ: &ast::Type,
|
||||||
state_space: ast::StateSpace,
|
state_space: ast::StateSpace,
|
||||||
idx: Vec<SpirvWord>,
|
idx: Vec<SpirvWord>,
|
||||||
|
@ -91,7 +78,7 @@ impl<'a, 'b> VectorRepackVisitor<'a, 'b> {
|
||||||
typ: scalar_t,
|
typ: scalar_t,
|
||||||
packed: temp_vec,
|
packed: temp_vec,
|
||||||
unpacked: idx,
|
unpacked: idx,
|
||||||
non_default_implicit_conversion,
|
relaxed_type_check,
|
||||||
});
|
});
|
||||||
if is_dst {
|
if is_dst {
|
||||||
self.post_stmts = Some(statement);
|
self.post_stmts = Some(statement);
|
||||||
|
@ -110,6 +97,7 @@ impl<'a, 'b> ast::VisitorMap<ast::ParsedOperand<SpirvWord>, TypedOperand, Transl
|
||||||
ident: SpirvWord,
|
ident: SpirvWord,
|
||||||
_: Option<(&ptx_parser::Type, ptx_parser::StateSpace)>,
|
_: Option<(&ptx_parser::Type, ptx_parser::StateSpace)>,
|
||||||
_: bool,
|
_: bool,
|
||||||
|
_: bool,
|
||||||
) -> Result<SpirvWord, TranslateError> {
|
) -> Result<SpirvWord, TranslateError> {
|
||||||
Ok(ident)
|
Ok(ident)
|
||||||
}
|
}
|
||||||
|
@ -119,6 +107,7 @@ impl<'a, 'b> ast::VisitorMap<ast::ParsedOperand<SpirvWord>, TypedOperand, Transl
|
||||||
op: ast::ParsedOperand<SpirvWord>,
|
op: ast::ParsedOperand<SpirvWord>,
|
||||||
type_space: Option<(&ptx_parser::Type, ptx_parser::StateSpace)>,
|
type_space: Option<(&ptx_parser::Type, ptx_parser::StateSpace)>,
|
||||||
is_dst: bool,
|
is_dst: bool,
|
||||||
|
relaxed_type_check: bool,
|
||||||
) -> Result<TypedOperand, TranslateError> {
|
) -> Result<TypedOperand, TranslateError> {
|
||||||
Ok(match op {
|
Ok(match op {
|
||||||
ast::ParsedOperand::Reg(reg) => TypedOperand::Reg(reg),
|
ast::ParsedOperand::Reg(reg) => TypedOperand::Reg(reg),
|
||||||
|
@ -129,7 +118,7 @@ impl<'a, 'b> ast::VisitorMap<ast::ParsedOperand<SpirvWord>, TypedOperand, Transl
|
||||||
let (type_, space) = type_space.ok_or(TranslateError::MismatchedType)?;
|
let (type_, space) = type_space.ok_or(TranslateError::MismatchedType)?;
|
||||||
TypedOperand::Reg(self.convert_vector(
|
TypedOperand::Reg(self.convert_vector(
|
||||||
is_dst,
|
is_dst,
|
||||||
desc.non_default_implicit_conversion,
|
relaxed_type_check,
|
||||||
type_,
|
type_,
|
||||||
space,
|
space,
|
||||||
vec,
|
vec,
|
||||||
|
|
|
@ -798,12 +798,7 @@ struct RepackVectorDetails {
|
||||||
typ: ast::ScalarType,
|
typ: ast::ScalarType,
|
||||||
packed: SpirvWord,
|
packed: SpirvWord,
|
||||||
unpacked: Vec<SpirvWord>,
|
unpacked: Vec<SpirvWord>,
|
||||||
non_default_implicit_conversion: Option<
|
relaxed_type_check: bool
|
||||||
fn(
|
|
||||||
(ast::StateSpace, &ast::Type),
|
|
||||||
(ast::StateSpace, &ast::Type),
|
|
||||||
) -> Result<Option<ConversionKind>, TranslateError>,
|
|
||||||
>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FunctionPointerDetails {
|
struct FunctionPointerDetails {
|
||||||
|
|
|
@ -41,6 +41,7 @@ fn expand_map_variables<'a, 'b>(
|
||||||
.transpose()?,
|
.transpose()?,
|
||||||
ast::visit_map(i, &mut |id,
|
ast::visit_map(i, &mut |id,
|
||||||
_: Option<(&ast::Type, ast::StateSpace)>,
|
_: Option<(&ast::Type, ast::StateSpace)>,
|
||||||
|
_: bool,
|
||||||
_: bool| {
|
_: bool| {
|
||||||
id_defs.get_id(id)
|
id_defs.get_id(id)
|
||||||
})?,
|
})?,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue