mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-06-05 06:58:54 +03:00
Clean up warnings
This commit is contained in:
@ -1,13 +1,9 @@
|
|||||||
use crate::ast;
|
use crate::ast;
|
||||||
use core::borrow;
|
|
||||||
use half::f16;
|
use half::f16;
|
||||||
use rspirv::dr;
|
use rspirv::dr;
|
||||||
use std::{borrow::Borrow, cell::RefCell};
|
use std::cell::RefCell;
|
||||||
|
use std::collections::{hash_map, HashMap, HashSet};
|
||||||
use std::{borrow::Cow, collections::BTreeSet, ffi::CString, hash::Hash, iter, mem, rc::Rc};
|
use std::{borrow::Cow, collections::BTreeSet, ffi::CString, hash::Hash, iter, mem, rc::Rc};
|
||||||
use std::{
|
|
||||||
collections::{hash_map, HashMap, HashSet},
|
|
||||||
convert::TryInto,
|
|
||||||
};
|
|
||||||
|
|
||||||
use rspirv::binary::Assemble;
|
use rspirv::binary::Assemble;
|
||||||
|
|
||||||
@ -433,7 +429,7 @@ pub fn to_spirv_module<'a>(ast: ast::Module<'a>) -> Result<Module, TranslateErro
|
|||||||
})
|
})
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
let must_link_ptx_impl = ptx_impl_imports.len() > 0;
|
let must_link_ptx_impl = ptx_impl_imports.len() > 0;
|
||||||
let mut directives = ptx_impl_imports
|
let directives = ptx_impl_imports
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|(_, v)| v)
|
.map(|(_, v)| v)
|
||||||
.chain(directives.into_iter())
|
.chain(directives.into_iter())
|
||||||
@ -1068,8 +1064,10 @@ fn emit_function_header<'a>(
|
|||||||
}) => {
|
}) => {
|
||||||
match (**func_decl).borrow().name {
|
match (**func_decl).borrow().name {
|
||||||
ast::MethodName::Func(name) => {
|
ast::MethodName::Func(name) => {
|
||||||
for var in globals {
|
if child_fns.contains(&name) {
|
||||||
interface.push(var.name);
|
for var in globals {
|
||||||
|
interface.push(var.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ast::MethodName::Kernel(_) => {}
|
ast::MethodName::Kernel(_) => {}
|
||||||
@ -1264,30 +1262,6 @@ fn to_ssa<'input, 'b>(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deparamize_function_decl(
|
|
||||||
func_decl_rc: &Rc<RefCell<ast::MethodDeclaration<u32>>>,
|
|
||||||
) -> Result<(), TranslateError> {
|
|
||||||
let mut func_decl = func_decl_rc.borrow_mut();
|
|
||||||
match func_decl.name {
|
|
||||||
ast::MethodName::Func(..) => {
|
|
||||||
for decl in func_decl.input_arguments.iter_mut() {
|
|
||||||
if decl.state_space == ast::StateSpace::Param {
|
|
||||||
decl.state_space = ast::StateSpace::Reg;
|
|
||||||
let baseline_type = match decl.v_type {
|
|
||||||
ast::Type::Scalar(t) => t,
|
|
||||||
ast::Type::Vector(t, _) => t, // TODO: write a test for this
|
|
||||||
ast::Type::Array(t, _) => t, // TODO: write a test for this
|
|
||||||
ast::Type::Pointer(_, _) => return Err(error_unreachable()),
|
|
||||||
};
|
|
||||||
decl.v_type = ast::Type::Pointer(baseline_type, ast::StateSpace::Param);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ast::MethodName::Kernel(..) => {}
|
|
||||||
};
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn fix_special_registers(
|
fn fix_special_registers(
|
||||||
typed_statements: Vec<TypedStatement>,
|
typed_statements: Vec<TypedStatement>,
|
||||||
numeric_id_defs: &mut NumericIdResolver,
|
numeric_id_defs: &mut NumericIdResolver,
|
||||||
@ -1905,17 +1879,6 @@ fn to_ptx_impl_bfi_call(
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_resolved_fn_args<T>(
|
|
||||||
params: Vec<T>,
|
|
||||||
params_decl: &[ast::Variable<spirv::Word>],
|
|
||||||
) -> Vec<(T, ast::Type, ast::StateSpace)> {
|
|
||||||
params
|
|
||||||
.into_iter()
|
|
||||||
.zip(params_decl.iter())
|
|
||||||
.map(|(id, var)| (id, var.v_type.clone(), var.state_space))
|
|
||||||
.collect::<Vec<_>>()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn normalize_labels(
|
fn normalize_labels(
|
||||||
func: Vec<ExpandedStatement>,
|
func: Vec<ExpandedStatement>,
|
||||||
id_def: &mut NumericIdResolver,
|
id_def: &mut NumericIdResolver,
|
||||||
@ -2644,10 +2607,15 @@ fn emit_function_body_ops(
|
|||||||
Statement::Label(_) => (),
|
Statement::Label(_) => (),
|
||||||
Statement::Call(call) => {
|
Statement::Call(call) => {
|
||||||
let (result_type, result_id) = match &*call.return_arguments {
|
let (result_type, result_id) = match &*call.return_arguments {
|
||||||
[(id, typ, space)] => (
|
[(id, typ, space)] => {
|
||||||
map.get_or_add(builder, SpirvType::new(typ.clone())),
|
if *space != ast::StateSpace::Reg {
|
||||||
Some(*id),
|
return Err(error_unreachable());
|
||||||
),
|
}
|
||||||
|
(
|
||||||
|
map.get_or_add(builder, SpirvType::new(typ.clone())),
|
||||||
|
Some(*id),
|
||||||
|
)
|
||||||
|
}
|
||||||
[] => (map.void(), None),
|
[] => (map.void(), None),
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
};
|
};
|
||||||
@ -4679,7 +4647,7 @@ fn convert_to_stateful_memory_access_postprocess(
|
|||||||
) -> Result<spirv::Word, TranslateError> {
|
) -> Result<spirv::Word, TranslateError> {
|
||||||
Ok(match remapped_ids.get(&arg_desc.op) {
|
Ok(match remapped_ids.get(&arg_desc.op) {
|
||||||
Some(new_id) => {
|
Some(new_id) => {
|
||||||
let (new_operand_type, new_operand_space, is_variable) = id_defs.get_typed(*new_id)?;
|
let (new_operand_type, new_operand_space, _) = id_defs.get_typed(*new_id)?;
|
||||||
if let Some((expected_type, expected_space)) = expected_type {
|
if let Some((expected_type, expected_space)) = expected_type {
|
||||||
let implicit_conversion = arg_desc
|
let implicit_conversion = arg_desc
|
||||||
.non_default_implicit_conversion
|
.non_default_implicit_conversion
|
||||||
@ -4694,7 +4662,6 @@ fn convert_to_stateful_memory_access_postprocess(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let (old_operand_type, old_operand_space, _) = id_defs.get_typed(arg_desc.op)?;
|
let (old_operand_type, old_operand_space, _) = id_defs.get_typed(arg_desc.op)?;
|
||||||
let new_operand_type_clone = new_operand_type.clone();
|
|
||||||
let converting_id =
|
let converting_id =
|
||||||
id_defs.register_intermediate(Some((old_operand_type.clone(), old_operand_space)));
|
id_defs.register_intermediate(Some((old_operand_type.clone(), old_operand_space)));
|
||||||
let kind = if new_operand_space.is_compatible(ast::StateSpace::Reg) {
|
let kind = if new_operand_space.is_compatible(ast::StateSpace::Reg) {
|
||||||
@ -5745,20 +5712,6 @@ pub struct PtrAccess<P: ast::ArgParams> {
|
|||||||
offset_src: P::Operand,
|
offset_src: P::Operand,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
|
||||||
pub enum ArgumentSemantics {
|
|
||||||
// normal register access
|
|
||||||
Default,
|
|
||||||
// normal register access with relaxed conversion rules (ld/st)
|
|
||||||
DefaultRelaxed,
|
|
||||||
// st/ld global
|
|
||||||
PhysicalPointer,
|
|
||||||
// st/ld .param, .local
|
|
||||||
RegisterPointer,
|
|
||||||
// mov of .local/.global variables
|
|
||||||
Address,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> ArgumentDescriptor<T> {
|
impl<T> ArgumentDescriptor<T> {
|
||||||
fn new_op<U>(&self, u: U) -> ArgumentDescriptor<U> {
|
fn new_op<U>(&self, u: U) -> ArgumentDescriptor<U> {
|
||||||
ArgumentDescriptor {
|
ArgumentDescriptor {
|
||||||
@ -7315,17 +7268,6 @@ impl ast::AtomSemantics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ast::StateSpace {
|
|
||||||
fn semantics(self) -> ArgumentSemantics {
|
|
||||||
match self {
|
|
||||||
ast::StateSpace::Reg => ArgumentSemantics::Default,
|
|
||||||
ast::StateSpace::Param => ArgumentSemantics::RegisterPointer,
|
|
||||||
ast::StateSpace::Shared => ArgumentSemantics::PhysicalPointer,
|
|
||||||
_ => todo!(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn default_implicit_conversion(
|
fn default_implicit_conversion(
|
||||||
(operand_space, operand_type): (ast::StateSpace, &ast::Type),
|
(operand_space, operand_type): (ast::StateSpace, &ast::Type),
|
||||||
(instruction_space, instruction_type): (ast::StateSpace, &ast::Type),
|
(instruction_space, instruction_type): (ast::StateSpace, &ast::Type),
|
||||||
@ -7475,22 +7417,6 @@ fn implicit_conversion_mov(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn should_bitcast_wrapper(
|
|
||||||
operand: &ast::Type,
|
|
||||||
_: ast::StateSpace,
|
|
||||||
instr: &ast::Type,
|
|
||||||
_: ast::StateSpace,
|
|
||||||
) -> Result<Option<ConversionKind>, TranslateError> {
|
|
||||||
if instr == operand {
|
|
||||||
return Ok(None);
|
|
||||||
}
|
|
||||||
if should_bitcast(instr, operand) {
|
|
||||||
Ok(Some(ConversionKind::Default))
|
|
||||||
} else {
|
|
||||||
Err(TranslateError::MismatchedType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn should_convert_relaxed_src_wrapper(
|
fn should_convert_relaxed_src_wrapper(
|
||||||
(operand_space, operand_type): (ast::StateSpace, &ast::Type),
|
(operand_space, operand_type): (ast::StateSpace, &ast::Type),
|
||||||
(instruction_space, instruction_type): (ast::StateSpace, &ast::Type),
|
(instruction_space, instruction_type): (ast::StateSpace, &ast::Type),
|
||||||
|
Reference in New Issue
Block a user