[PATCH] D158321: [emacs] Handle vector types, arbitary integer types and function names

Luke Lau via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 18 15:02:17 PDT 2023


luke created this revision.
luke added a reviewer: goldstein.w.n.
Herald added subscribers: asb, sunshaoce, pmatos.
Herald added a project: All.
luke requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adds a few more regexp patterns for llvm-mode-syntax-table.  The primitive
type regexp was split out so it could be reused when handling vectors. Also
worth noting is that the vector regexp needs to come before the primitive
types, otherwise they will match first.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158321

Files:
  llvm/utils/emacs/llvm-mode.el


Index: llvm/utils/emacs/llvm-mode.el
===================================================================
--- llvm/utils/emacs/llvm-mode.el
+++ llvm/utils/emacs/llvm-mode.el
@@ -34,10 +34,24 @@
    '("[-a-zA-Z$._0-9]+:" . font-lock-variable-name-face)
    ;; Unnamed variable slots
    '("%[-]?[0-9]+" . font-lock-variable-name-face)
+   ;; Function names
+   '("@[-a-zA-Z$._][-a-zA-Z$._0-9]*" . font-lock-function-name-face)
    ;; Types
-   `(,(regexp-opt
-       '("void" "i1" "i8" "i16" "i32" "i64" "i128" "half" "bfloat" "float" "double" "fp128" "x86_fp80" "ppc_fp128" "x86_mmx" "x86_amx" "ptr"
-         "type" "label" "opaque" "token") 'symbols) . font-lock-type-face)
+   ,@(let ((type-regexp
+	    (concat
+	     "\\(i[0-9]+\\|"
+	     (regexp-opt
+	      '("void" "half" "bfloat" "float" "double" "fp128" "x86_fp80"
+		"ppc_fp128" "x86_mmx" "x86_amx" "ptr" "type" "label" "opaque"
+		"token") t)
+	     "\\)")))
+       (list
+	;; Vector types
+	`(,(concat "<[ \t]*\\(vscale[ \t]+x[ \t]+\\)?[0-9]+[ \t]+x[ \t]+"
+		   type-regexp
+		   "[ \t]*>") . font-lock-type-face)
+	;; Primitive types
+	`(,(concat "\\<" type-regexp "\\>") . font-lock-type-face)))
    ;; Integer literals
    '("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
    ;; Floating point constants


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158321.551657.patch
Type: text/x-patch
Size: 1275 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230818/d9f87909/attachment.bin>


More information about the llvm-commits mailing list