1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
//! PTX (Parallel Thread Execution) parser for NVIDIA GPU assembly language.
//!
//! This library provides a complete parser for PTX assembly code, including:
//! - Lexical analysis (tokenization)
//! - Syntactic parsing into structured types
//! - Unparsing back to PTX source code
//!
//! # Quick Start
//!
//! ```no_run
//! use ptx_parser::{parse_ptx};
//! use ptx_parser::r#type::{Module, ModuleDirective, Instruction};
//!
//! let source = r#"
//! .version 8.5
//! .target sm_90
//! .address_size 64
//!
//! .entry kernel() {
//! add.s32 %r1, %r2, %r3;
//! ret;
//! }
//! "#;
//!
//! let module: Module = parse_ptx(source).expect("Failed to parse PTX");
//! println!("Parsed {} directives", module.directives.len());
//! ```
//!
//! # Type Organization
//!
//! All types are re-exported at `ptx_parser::r#type::*` for easy access:
//!
//! ```rust
//! use ptx_parser::r#type::{
//! Module, // Root AST node
//! Instruction, // Instruction with label/predicate
//! Predicate, // Predicate guard
//! Operand, // Operand types
//! FunctionKernelDirective,
//! EntryFunction,
//! // ... all other types
//! };
//! ```
//!
//! Instruction variants are under `instruction::`:
//!
//! ```rust
//! use ptx_parser::r#type::instruction::{Inst, add, mov};
//! ```
// Internal modules - not part of public API
// Type definitions - AST nodes (public)
// Re-export commonly used items for convenience
// Lexer exports
pub use ;
// Parser exports
pub use ;
// Unlexer exports
pub use PtxUnlexer;
// Unparser exports
pub use PtxUnparser;