mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-08-06 08:10:18 +00:00
Fix array initializers
This commit is contained in:
parent
7a45b44854
commit
6a7c871b25
1 changed files with 51 additions and 83 deletions
|
@ -734,13 +734,13 @@ fn array_initializer<'a, 'input: 'a>(
|
||||||
return Err(ErrMode::from_error_kind(stream, ErrorKind::Verify));
|
return Err(ErrMode::from_error_kind(stream, ErrorKind::Verify));
|
||||||
}
|
}
|
||||||
delimited(
|
delimited(
|
||||||
Token::LBracket,
|
Token::LBrace,
|
||||||
separated(
|
separated(
|
||||||
array_dimensions[0] as usize..=array_dimensions[0] as usize,
|
array_dimensions[0] as usize..=array_dimensions[0] as usize,
|
||||||
single_value_append(&mut result, type_),
|
single_value_append(&mut result, type_),
|
||||||
Token::Comma,
|
Token::Comma,
|
||||||
),
|
),
|
||||||
Token::RBracket,
|
Token::RBrace,
|
||||||
)
|
)
|
||||||
.parse_next(stream)?;
|
.parse_next(stream)?;
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
@ -770,86 +770,54 @@ fn single_value_append<'a, 'input: 'a>(
|
||||||
move |stream: &mut PtxParser<'a, 'input>| {
|
move |stream: &mut PtxParser<'a, 'input>| {
|
||||||
let value = immediate_value.parse_next(stream)?;
|
let value = immediate_value.parse_next(stream)?;
|
||||||
match (type_, value) {
|
match (type_, value) {
|
||||||
(ScalarType::U8, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
(ScalarType::U8 | ScalarType::B8, ImmediateValue::U64(x)) => {
|
||||||
&u8::try_from(x)
|
accumulator.extend_from_slice(&(x as u8).to_le_bytes())
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
}
|
||||||
.to_le_bytes(),
|
(ScalarType::U8 | ScalarType::B8, ImmediateValue::S64(x)) => {
|
||||||
),
|
accumulator.extend_from_slice(&(x as u8).to_le_bytes())
|
||||||
(ScalarType::U8, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
}
|
||||||
&u8::try_from(x)
|
(ScalarType::U16 | ScalarType::B16, ImmediateValue::U64(x)) => {
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
accumulator.extend_from_slice(&(x as u16).to_le_bytes())
|
||||||
.to_le_bytes(),
|
}
|
||||||
),
|
(ScalarType::U16 | ScalarType::B16, ImmediateValue::S64(x)) => {
|
||||||
(ScalarType::U16, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
accumulator.extend_from_slice(&(x as u16).to_le_bytes())
|
||||||
&u16::try_from(x)
|
}
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
(ScalarType::U32 | ScalarType::B32, ImmediateValue::U64(x)) => {
|
||||||
.to_le_bytes(),
|
accumulator.extend_from_slice(&(x as u32).to_le_bytes())
|
||||||
),
|
}
|
||||||
(ScalarType::U16, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
(ScalarType::U32 | ScalarType::B32, ImmediateValue::S64(x)) => {
|
||||||
&u16::try_from(x)
|
accumulator.extend_from_slice(&(x as u32).to_le_bytes())
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
}
|
||||||
.to_le_bytes(),
|
(ScalarType::U64 | ScalarType::B64, ImmediateValue::U64(x)) => {
|
||||||
),
|
accumulator.extend_from_slice(&(x as u64).to_le_bytes())
|
||||||
(ScalarType::U32, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
}
|
||||||
&u32::try_from(x)
|
(ScalarType::U64 | ScalarType::B64, ImmediateValue::S64(x)) => {
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
accumulator.extend_from_slice(&(x as u64).to_le_bytes())
|
||||||
.to_le_bytes(),
|
}
|
||||||
),
|
(ScalarType::S8, ImmediateValue::U64(x)) => {
|
||||||
(ScalarType::U32, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
accumulator.extend_from_slice(&(x as i8).to_le_bytes())
|
||||||
&u32::try_from(x)
|
}
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
(ScalarType::S8, ImmediateValue::S64(x)) => {
|
||||||
.to_le_bytes(),
|
accumulator.extend_from_slice(&(x as i8).to_le_bytes())
|
||||||
),
|
}
|
||||||
(ScalarType::U64, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
(ScalarType::S16, ImmediateValue::U64(x)) => {
|
||||||
&u64::try_from(x)
|
accumulator.extend_from_slice(&(x as i16).to_le_bytes())
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
}
|
||||||
.to_le_bytes(),
|
(ScalarType::S16, ImmediateValue::S64(x)) => {
|
||||||
),
|
accumulator.extend_from_slice(&(x as i16).to_le_bytes())
|
||||||
(ScalarType::U64, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
}
|
||||||
&u64::try_from(x)
|
(ScalarType::S32, ImmediateValue::U64(x)) => {
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
accumulator.extend_from_slice(&(x as i32).to_le_bytes())
|
||||||
.to_le_bytes(),
|
}
|
||||||
),
|
(ScalarType::S32, ImmediateValue::S64(x)) => {
|
||||||
(ScalarType::S8, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
accumulator.extend_from_slice(&(x as i32).to_le_bytes())
|
||||||
&i8::try_from(x)
|
}
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
(ScalarType::S64, ImmediateValue::U64(x)) => {
|
||||||
.to_le_bytes(),
|
accumulator.extend_from_slice(&(x as i64).to_le_bytes())
|
||||||
),
|
}
|
||||||
(ScalarType::S8, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
(ScalarType::S64, ImmediateValue::S64(x)) => {
|
||||||
&i8::try_from(x)
|
accumulator.extend_from_slice(&(x as i64).to_le_bytes())
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
}
|
||||||
.to_le_bytes(),
|
|
||||||
),
|
|
||||||
(ScalarType::S16, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
|
||||||
&i16::try_from(x)
|
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
|
||||||
.to_le_bytes(),
|
|
||||||
),
|
|
||||||
(ScalarType::S16, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
|
||||||
&i16::try_from(x)
|
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
|
||||||
.to_le_bytes(),
|
|
||||||
),
|
|
||||||
(ScalarType::S32, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
|
||||||
&i32::try_from(x)
|
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
|
||||||
.to_le_bytes(),
|
|
||||||
),
|
|
||||||
(ScalarType::S32, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
|
||||||
&i32::try_from(x)
|
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
|
||||||
.to_le_bytes(),
|
|
||||||
),
|
|
||||||
(ScalarType::S64, ImmediateValue::U64(x)) => accumulator.extend_from_slice(
|
|
||||||
&i64::try_from(x)
|
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
|
||||||
.to_le_bytes(),
|
|
||||||
),
|
|
||||||
(ScalarType::S64, ImmediateValue::S64(x)) => accumulator.extend_from_slice(
|
|
||||||
&i64::try_from(x)
|
|
||||||
.map_err(|_| ErrMode::from_error_kind(stream, ErrorKind::Verify))?
|
|
||||||
.to_le_bytes(),
|
|
||||||
),
|
|
||||||
(ScalarType::F32, ImmediateValue::F32(x)) => {
|
(ScalarType::F32, ImmediateValue::F32(x)) => {
|
||||||
accumulator.extend_from_slice(&x.to_le_bytes())
|
accumulator.extend_from_slice(&x.to_le_bytes())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue