Skip to content

Commit

Permalink
Remove sreg address space
Browse files Browse the repository at this point in the history
  • Loading branch information
vosen committed Sep 13, 2024
1 parent 02cf83e commit 415639d
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 26 deletions.
2 changes: 1 addition & 1 deletion ptx/src/pass/convert_to_stateful_memory_access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ fn convert_to_stateful_memory_access_postprocess(
let (old_operand_type, old_operand_space, _) = id_defs.get_typed(operand)?;
let converting_id = id_defs
.register_intermediate(Some((old_operand_type.clone(), old_operand_space)));
let kind = if space_is_compatible(new_operand_space, ast::StateSpace::Reg) {
let kind = if new_operand_space == ast::StateSpace::Reg {
ConversionKind::Default
} else {
ConversionKind::PtrToPtr
Expand Down
1 change: 0 additions & 1 deletion ptx/src/pass/emit_llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,6 @@ fn get_state_space(space: ast::StateSpace) -> Result<u32, TranslateError> {
match space {
ast::StateSpace::Reg => Ok(PRIVATE_ADDRESS_SPACE),
ast::StateSpace::Generic => Ok(GENERIC_ADDRESS_SPACE),
ast::StateSpace::Sreg => Ok(PRIVATE_ADDRESS_SPACE),
ast::StateSpace::Param => Err(TranslateError::Todo),
ast::StateSpace::ParamEntry => Err(TranslateError::Todo),
ast::StateSpace::ParamFunc => Err(TranslateError::Todo),
Expand Down
2 changes: 0 additions & 2 deletions ptx/src/pass/emit_spirv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,6 @@ fn space_to_spirv(this: ast::StateSpace) -> spirv::StorageClass {
ast::StateSpace::Shared => spirv::StorageClass::Workgroup,
ast::StateSpace::Param => spirv::StorageClass::Function,
ast::StateSpace::Reg => spirv::StorageClass::Function,
ast::StateSpace::Sreg => spirv::StorageClass::Input,
ast::StateSpace::ParamEntry
| ast::StateSpace::ParamFunc
| ast::StateSpace::SharedCluster
Expand Down Expand Up @@ -693,7 +692,6 @@ fn emit_variable<'input>(
ast::StateSpace::Shared => (false, spirv::StorageClass::Workgroup),
ast::StateSpace::Const => (false, spirv::StorageClass::UniformConstant),
ast::StateSpace::Generic => todo!(),
ast::StateSpace::Sreg => todo!(),
ast::StateSpace::ParamEntry
| ast::StateSpace::ParamFunc
| ast::StateSpace::SharedCluster
Expand Down
4 changes: 2 additions & 2 deletions ptx/src/pass/expand_arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ impl<'a, 'b> FlattenArguments<'a, 'b> {
} else {
return Err(TranslateError::UntypedSymbol);
};
if state_space == ast::StateSpace::Reg || state_space == ast::StateSpace::Sreg {
if state_space == ast::StateSpace::Reg {
let (reg_type, reg_space) = self.id_def.get_typed(reg)?;
if !space_is_compatible(reg_space, ast::StateSpace::Reg) {
if reg_space != ast::StateSpace::Reg {
return Err(error_mismatched_type());
}
let reg_scalar_type = match reg_type {
Expand Down
1 change: 0 additions & 1 deletion ptx/src/pass/extract_globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ fn space_to_ptx_name(this: ast::StateSpace) -> &'static str {
ast::StateSpace::Const => "const",
ast::StateSpace::Local => "local",
ast::StateSpace::Param => "param",
ast::StateSpace::Sreg => "sreg",
ast::StateSpace::SharedCluster => "shared_cluster",
ast::StateSpace::ParamEntry => "param_entry",
ast::StateSpace::SharedCta => "shared_cta",
Expand Down
19 changes: 9 additions & 10 deletions ptx/src/pass/insert_implicit_conversions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ pub(crate) fn default_implicit_conversion(
(instruction_space, instruction_type): (ast::StateSpace, &ast::Type),
) -> Result<Option<ConversionKind>, TranslateError> {
if instruction_space == ast::StateSpace::Reg {
if space_is_compatible(operand_space, ast::StateSpace::Reg) {
if operand_space == ast::StateSpace::Reg {
if let (ast::Type::Vector(vec_len, vec_underlying_type), ast::Type::Scalar(scalar)) =
(operand_type, instruction_type)
{
Expand All @@ -142,7 +142,7 @@ pub(crate) fn default_implicit_conversion(
return Ok(Some(ConversionKind::AddressOf));
}
}
if !space_is_compatible(instruction_space, operand_space) {
if instruction_space != operand_space {
default_implicit_conversion_space(
(operand_space, operand_type),
(instruction_space, instruction_type),
Expand All @@ -161,7 +161,7 @@ fn is_addressable(this: ast::StateSpace) -> bool {
| ast::StateSpace::Global
| ast::StateSpace::Local
| ast::StateSpace::Shared => true,
ast::StateSpace::Param | ast::StateSpace::Reg | ast::StateSpace::Sreg => false,
ast::StateSpace::Param | ast::StateSpace::Reg => false,
ast::StateSpace::SharedCluster
| ast::StateSpace::SharedCta
| ast::StateSpace::ParamEntry
Expand All @@ -178,7 +178,7 @@ fn default_implicit_conversion_space(
|| (operand_space == ast::StateSpace::Generic && coerces_to_generic(instruction_space))
{
Ok(Some(ConversionKind::PtrToPtr))
} else if space_is_compatible(operand_space, ast::StateSpace::Reg) {
} else if operand_space == ast::StateSpace::Reg {
match operand_type {
ast::Type::Pointer(operand_ptr_type, operand_ptr_space)
if *operand_ptr_space == instruction_space =>
Expand Down Expand Up @@ -210,7 +210,7 @@ fn default_implicit_conversion_space(
},
_ => Err(error_mismatched_type()),
}
} else if space_is_compatible(instruction_space, ast::StateSpace::Reg) {
} else if instruction_space == ast::StateSpace::Reg {
match instruction_type {
ast::Type::Pointer(instruction_ptr_type, instruction_ptr_space)
if operand_space == *instruction_ptr_space =>
Expand All @@ -234,7 +234,7 @@ fn default_implicit_conversion_type(
operand_type: &ast::Type,
instruction_type: &ast::Type,
) -> Result<Option<ConversionKind>, TranslateError> {
if space_is_compatible(space, ast::StateSpace::Reg) {
if space == ast::StateSpace::Reg {
if should_bitcast(instruction_type, operand_type) {
Ok(Some(ConversionKind::Default))
} else {
Expand All @@ -257,8 +257,7 @@ fn coerces_to_generic(this: ast::StateSpace) -> bool {
| ast::StateSpace::Param
| ast::StateSpace::ParamEntry
| ast::StateSpace::ParamFunc
| ast::StateSpace::Generic
| ast::StateSpace::Sreg => false,
| ast::StateSpace::Generic => false,
}
}

Expand Down Expand Up @@ -294,7 +293,7 @@ pub(crate) fn should_convert_relaxed_dst_wrapper(
(operand_space, operand_type): (ast::StateSpace, &ast::Type),
(instruction_space, instruction_type): (ast::StateSpace, &ast::Type),
) -> Result<Option<ConversionKind>, TranslateError> {
if !space_is_compatible(operand_space, instruction_space) {
if operand_space != instruction_space {
return Err(TranslateError::MismatchedType);
}
if operand_type == instruction_type {
Expand Down Expand Up @@ -371,7 +370,7 @@ pub(crate) fn should_convert_relaxed_src_wrapper(
(operand_space, operand_type): (ast::StateSpace, &ast::Type),
(instruction_space, instruction_type): (ast::StateSpace, &ast::Type),
) -> Result<Option<ConversionKind>, TranslateError> {
if !space_is_compatible(operand_space, instruction_space) {
if operand_space != instruction_space {
return Err(error_mismatched_type());
}
if operand_type == instruction_type {
Expand Down
2 changes: 1 addition & 1 deletion ptx/src/pass/insert_mem_ssa_statements.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ impl<'a, 'input> InsertMemSSAVisitor<'a, 'input> {
return Ok(symbol);
};
let (mut var_type, var_space, is_variable) = self.id_def.get_typed(symbol)?;
if !space_is_compatible(var_space, ast::StateSpace::Reg) || !is_variable {
if var_space != ast::StateSpace::Reg || !is_variable {
return Ok(symbol);
};
let member_index = match member_index {
Expand Down
8 changes: 1 addition & 7 deletions ptx/src/pass/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ impl<'b> NumericIdResolver<'b> {
Some(Some(x)) => Ok(x.clone()),
Some(None) => Err(TranslateError::UntypedSymbol),
None => match self.special_registers.get(id) {
Some(x) => Ok((x.get_type(), ast::StateSpace::Sreg, true)),
Some(x) => Ok((x.get_type(), ast::StateSpace::Reg, true)),
None => match self.global_type_check.get(&id) {
Some(Some(result)) => Ok(result.clone()),
Some(None) | None => Err(TranslateError::UntypedSymbol),
Expand Down Expand Up @@ -1207,12 +1207,6 @@ impl<
}
}

fn space_is_compatible(this: ast::StateSpace, other: ast::StateSpace) -> bool {
this == other
|| this == ast::StateSpace::Reg && other == ast::StateSpace::Sreg
|| this == ast::StateSpace::Sreg && other == ast::StateSpace::Reg
}

fn register_external_fn_call<'a>(
id_defs: &mut NumericIdResolver,
ptx_impl_imports: &mut HashMap<String, Directive>,
Expand Down
1 change: 0 additions & 1 deletion ptx_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,6 @@ derive_parser!(
pub enum StateSpace {
Reg,
Generic,
Sreg,
}

#[derive(Copy, Clone, PartialEq, Eq, Hash)]
Expand Down

0 comments on commit 415639d

Please sign in to comment.