@@ -2867,6 +2867,44 @@ enum AsmLabelKind {
28672867 Binary ,
28682868}
28692869
2870+ /// Checks if a potential label is actually a Hexagon register span notation.
2871+ ///
2872+ /// Hexagon assembly uses register span notation like `r1:0`, `V5:4.w`, `p1:0` etc.
2873+ /// These follow the pattern: `[letter][digit(s)]:[digit(s)][optional_suffix]`
2874+ ///
2875+ /// Returns `true` if the string matches a valid Hexagon register span pattern.
2876+ fn is_hexagon_register_span ( possible_label : & str ) -> bool {
2877+ if possible_label. len ( ) < 3 {
2878+ return false ;
2879+ }
2880+
2881+ let mut chars = possible_label. chars ( ) ;
2882+ let start = chars. next ( ) . unwrap ( ) ;
2883+
2884+ // Must start with a letter (r, V, p, etc.)
2885+ if !start. is_ascii_alphabetic ( ) {
2886+ return false ;
2887+ }
2888+
2889+ let rest = & possible_label[ 1 ..] ;
2890+ let Some ( colon_idx) = rest. find ( ':' ) else {
2891+ return false ;
2892+ } ;
2893+
2894+ let ( before_colon, after_colon_with_colon) = rest. split_at ( colon_idx) ;
2895+ let after_colon = & after_colon_with_colon[ 1 ..] ; // Skip the ':'
2896+
2897+ // Check if before colon is all digits and non-empty
2898+ if before_colon. is_empty ( ) || !before_colon. chars ( ) . all ( |c| c. is_ascii_digit ( ) ) {
2899+ return false ;
2900+ }
2901+
2902+ // Check if after colon starts with digits (may have suffix like .w, .h)
2903+ let digits_after = after_colon. chars ( ) . take_while ( |c| c. is_ascii_digit ( ) ) . collect :: < String > ( ) ;
2904+
2905+ !digits_after. is_empty ( )
2906+ }
2907+
28702908impl < ' tcx > LateLintPass < ' tcx > for AsmLabels {
28712909 fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & ' tcx hir:: Expr < ' tcx > ) {
28722910 if let hir:: Expr {
@@ -2940,6 +2978,14 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
29402978 break ' label_loop;
29412979 }
29422980
2981+ // Check for Hexagon register span notation (e.g., "r1:0", "V5:4", "V3:2.w")
2982+ // This is valid Hexagon assembly syntax, not a label
2983+ if matches ! ( cx. tcx. sess. asm_arch, Some ( InlineAsmArch :: Hexagon ) )
2984+ && is_hexagon_register_span ( possible_label)
2985+ {
2986+ break ' label_loop;
2987+ }
2988+
29432989 for c in chars {
29442990 // Inside a template format arg, any character is permitted for the
29452991 // puproses of label detection because we assume that it can be
0 commit comments