1 ;;; llvm-mir-mode.el --- Major mode for LLVM Machine IR
3 ;; Maintainer: The LLVM team, http://llvm.org/
8 ;; Major mode for editing LLVM MIR files.
14 (defvar llvm-mir-mode-map
15 (let ((map (make-sparse-keymap)))
17 "Keymap for `llvm-mir-mode'.")
19 (defvar llvm-mir-mode-syntax-table
20 (let ((st (make-syntax-table)))
21 (modify-syntax-entry ?%
"_" st
)
22 (modify-syntax-entry ?$
"_" st
)
23 (modify-syntax-entry ?.
"_" st
)
24 (modify-syntax-entry ?
# "< " st
)
25 (modify-syntax-entry ?\
; "< " st)
26 (modify-syntax-entry ?
\n "> " st
)
28 "Syntax table for `llvm-mir-mode'.")
30 (defvar llvm-mir-font-lock-keywords
34 '("^name: +\\([a-zA-Z._][-a-zA-Z._0-9]*\\)"
35 1 font-lock-function-name-face
)
36 '("^body: +|" . font-lock-keyword-face
)
37 '("^[a-zA-Z_.][-a-zA-Z._0-9]*:" . font-lock-keyword-face
)
38 `(,(regexp-opt '("true" "false")) . font-lock-constant-face
)
40 '("^\\(---\\( |\\)?\\|\\.\\.\\.\\)$" . font-lock-comment-face
)
42 '("%[a-zA-Z_.][-a-zA-Z._0-9]*" . font-lock-variable-name-face
)
43 '("%[0-9]+\\(\\.[a-zA-Z._0-9]+\\)?" . font-lock-variable-name-face
)
44 '("$[a-zA-Z_.][-a-zA-Z._0-9]*" . font-lock-constant-face
)
47 "%\\([a-zA-Z_.][-a-zA-Z._0-9]*\\|[0-9]+\\(\\.[a-zA-Z._0-9]+\\)?\\)"
48 "\\(:[a-zA-Z_.][-a-zA-Z._0-9]*\\)")
49 3 font-lock-type-face
)
50 '("class: \\([a-zA-Z_.][-a-zA-Z._0-9]*\\)" 1 font-lock-type-face
)
52 `(,(regexp-opt '("dead" "debug-use" "def" "early-clobber" "implicit"
53 "implicit-def" "internal" "killed" "renamable" "undef")
55 . font-lock-keyword-face
))
56 llvm-font-lock-keywords
)
57 "Keyword highlighting specification for `llvm-mir-mode'.")
60 (define-derived-mode llvm-mir-mode prog-mode
"LLVM MIR"
61 "A major mode for editing LLVM MIR files."
62 (setq-local comment-start
"; ")
63 (setq-local font-lock-defaults
`(llvm-mir-font-lock-keywords)))
66 (add-to-list 'auto-mode-alist
(cons "\\.mir\\'" 'llvm-mir-mode
))
68 (provide 'llvm-mir-mode
)
70 ;;; llvm-mir-mode.el ends here