diff --git a/ptx/src/ptx.lalrpop b/ptx/src/ptx.lalrpop index 74740d3..6062be2 100644 --- a/ptx/src/ptx.lalrpop +++ b/ptx/src/ptx.lalrpop @@ -8,6 +8,7 @@ match { r"//[^\n\r]*[\n\r]*" => { }, r"/\*([^\*]*\*+[^\*/])*([^\*]*\*+|[^\*])*\*/" => { }, r"sm_[0-9]+" => ShaderModel, + r"-?[?:0x]?[0-9]+" => Num } else { r"(?:[a-zA-Z][a-zA-Z0-9_$]*|[_$%][a-zA-Z0-9_$]+)<[0-9]+>" => ParametrizedID, } else { @@ -39,12 +40,13 @@ TargetSpecifier = { Directive : () = { AddressSize, - Function + Function, + File, + Section }; AddressSize = { - ".address_size" "32", - ".address_size" "64" + ".address_size" Num }; Function: (bool, &'input str) = { @@ -332,8 +334,9 @@ ArrayOperand = { ID "[" Num "]", }; -VectorOperand = { +VectorOperand: () = { ID "." ID, + ID DotID, }; Vector = { @@ -341,6 +344,33 @@ Vector = { ".v4" }; +// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-file +File = { + ".file" Num String ("," Num "," Num)? +}; + +// https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#debugging-directives-section +Section = { + ".section" DotID "{" SectionDwarfLines* "}" +}; + +SectionDwarfLines: () = { + BitType Comma, + ".b32" SectionLabel, + ".b64" SectionLabel, + ".b32" SectionLabel "+" Num, + ".b64" SectionLabel "+" Num, +}; + +SectionLabel = { + ID, + DotID +}; + +BitType = { + ".b8", ".b16", ".b32", ".b64" +}; + Comma: Vec = { ",")*> => match e { None => v, @@ -352,7 +382,9 @@ Comma: Vec = { } }; +String = r#""[^"]*""#; VersionNumber = r"[0-9]+\.[0-9]+"; -Num: i128 = => i128::from_str(s).unwrap(); +//Num: i128 = => i128::from_str(s).unwrap(); // https://docs.nvidia.com/cuda/parallel-thread-execution/index.html#identifiers -ID: &'input str = => s; \ No newline at end of file +ID: &'input str = => s; +DotID: &'input str = => s; \ No newline at end of file