Skip to content

[emacs] Handle vector types, arbitary integer types and function names #88246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions llvm/utils/emacs/llvm-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
table)
"Syntax table used while in LLVM mode.")

(defconst llvm-mode-primitive-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)
"\\)"))

(defvar llvm-font-lock-keywords
(list
;; Attributes
Expand All @@ -34,10 +42,23 @@
'("[-a-zA-Z$._0-9]+:" . font-lock-variable-name-face)
;; Unnamed variable slots
'("%[-]?[0-9]+" . font-lock-variable-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)
;; Function names
'("@[-a-zA-Z$._][-a-zA-Z$._0-9]*" . font-lock-function-name-face)
;; Fixed vector types
`(,(concat "<[ \t]*\\([0-9]+\\)[ \t]*x[ \t]+"
llvm-mode-primitive-type-regexp
"[ \t]*>")
(1 'font-lock-type-face)
(2 'font-lock-type-face))
;; Scalable vector types
`(,(concat "<[ \t]*\\(vscale[ \t]\\)+x[ \t]+\\([0-9]+\\)[ \t]*x[ \t]+"
llvm-mode-primitive-type-regexp
"[ \t]*>")
(1 'font-lock-keyword-face)
(2 'font-lock-type-face)
(3 'font-lock-type-face))
;; Primitive types
`(,(concat "\\<" llvm-mode-primitive-type-regexp "\\>") . font-lock-type-face)
;; Integer literals
'("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
;; Floating point constants
Expand Down