aboutsummaryrefslogtreecommitdiffhomepage
path: root/ptx/src/ast.rs
diff options
context:
space:
mode:
authorAndrzej Janik <[email protected]>2024-09-04 15:47:42 +0200
committerGitHub <[email protected]>2024-09-04 15:47:42 +0200
commit193eb29be825370449afb1fe2358f6a654aa0986 (patch)
tree42ed1179594a362f417266d08842aa186028204a /ptx/src/ast.rs
parent872054ae4000df5eda1dd96f0b4e88dc071c22f9 (diff)
downloadZLUDA-193eb29be825370449afb1fe2358f6a654aa0986.tar.gz
ZLUDA-193eb29be825370449afb1fe2358f6a654aa0986.zip
PTX parser rewrite (#267)
Replaces traditional LALRPOP-based parser with winnow-based parser to handle out-of-order instruction modifer. Generate instruction type and instruction visitor from a macro instead of writing by hand. Add separate compilation path using the new parser that only works in tests for now
Diffstat (limited to 'ptx/src/ast.rs')
-rw-r--r--ptx/src/ast.rs28
1 files changed, 16 insertions, 12 deletions
diff --git a/ptx/src/ast.rs b/ptx/src/ast.rs
index d308479..358b8ce 100644
--- a/ptx/src/ast.rs
+++ b/ptx/src/ast.rs
@@ -16,6 +16,8 @@ pub enum PtxError {
source: ParseFloatError,
},
#[error("")]
+ Unsupported32Bit,
+ #[error("")]
SyntaxError,
#[error("")]
NonF32Ftz,
@@ -32,15 +34,9 @@ pub enum PtxError {
#[error("")]
NonExternPointer,
#[error("{start}:{end}")]
- UnrecognizedStatement {
- start: usize,
- end: usize,
- },
+ UnrecognizedStatement { start: usize, end: usize },
#[error("{start}:{end}")]
- UnrecognizedDirective {
- start: usize,
- end: usize,
- },
+ UnrecognizedDirective { start: usize, end: usize },
}
// For some weird reson this is illegal:
@@ -576,11 +572,15 @@ impl CvtDetails {
if saturate {
if src.kind() == ScalarKind::Signed {
if dst.kind() == ScalarKind::Signed && dst.size_of() >= src.size_of() {
- err.push(ParseError::from(PtxError::SyntaxError));
+ err.push(ParseError::User {
+ error: PtxError::SyntaxError,
+ });
}
} else {
if dst == src || dst.size_of() >= src.size_of() {
- err.push(ParseError::from(PtxError::SyntaxError));
+ err.push(ParseError::User {
+ error: PtxError::SyntaxError,
+ });
}
}
}
@@ -596,7 +596,9 @@ impl CvtDetails {
err: &'err mut Vec<ParseError<usize, Token<'input>, PtxError>>,
) -> Self {
if flush_to_zero && dst != ScalarType::F32 {
- err.push(ParseError::from(PtxError::NonF32Ftz));
+ err.push(ParseError::from(lalrpop_util::ParseError::User {
+ error: PtxError::NonF32Ftz,
+ }));
}
CvtDetails::FloatFromInt(CvtDesc {
dst,
@@ -616,7 +618,9 @@ impl CvtDetails {
err: &'err mut Vec<ParseError<usize, Token<'input>, PtxError>>,
) -> Self {
if flush_to_zero && src != ScalarType::F32 {
- err.push(ParseError::from(PtxError::NonF32Ftz));
+ err.push(ParseError::from(lalrpop_util::ParseError::User {
+ error: PtxError::NonF32Ftz,
+ }));
}
CvtDetails::IntFromFloat(CvtDesc {
dst,