Silence -Wunused-variable in release builds.
[llvm/stm8.git] / utils / emacs / llvm-mode.el
blob3780624b5a43d7893f6fd3c50ada3e915a123033
1 ;; Maintainer: The LLVM team, http://llvm.org/
2 ;; Description: Major mode for the LLVM assembler language.
3 ;; Updated: 2007-09-19
5 ;; Create mode-specific tables.
6 (defvar llvm-mode-syntax-table nil
7 "Syntax table used while in LLVM mode.")
9 (defvar llvm-font-lock-keywords
10 (list
11 ;; Comments
12 '(";.*" . font-lock-comment-face)
13 ;; Variables
14 '("%[-a-zA-Z$\._][-a-zA-Z$\._0-9]*" . font-lock-variable-name-face)
15 ;; Labels
16 '("[-a-zA-Z$\._0-9]+:" . font-lock-variable-name-face)
17 ;; Strings
18 '("\"[^\"]+\"" . font-lock-string-face)
19 ;; Unnamed variable slots
20 '("%[-]?[0-9]+" . font-lock-variable-name-face)
21 ;; Types
22 `(,(regexp-opt '("void" "i[0-9]+" "float" "double" "type" "label" "opaque") 'words) . font-lock-type-face)
23 ;; Integer literals
24 '("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
25 ;; Floating point constants
26 '("\\b[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?\\b" . font-lock-preprocessor-face)
27 ;; Hex constants
28 '("\\b0x[0-9A-Fa-f]+\\b" . font-lock-preprocessor-face)
29 ;; Keywords
30 `(,(regexp-opt '("begin" "end" "true" "false" "zeroinitializer" "declare"
31 "define" "global" "constant" "const" "internal" "linkonce" "linkonce_odr"
32 "weak" "weak_odr" "appending" "uninitialized" "implementation" "..."
33 "null" "undef" "to" "except" "not" "target" "endian" "little" "big"
34 "pointersize" "deplibs" "volatile" "fastcc" "coldcc" "cc") 'words) . font-lock-keyword-face)
35 ;; Arithmetic and Logical Operators
36 `(,(regexp-opt '("add" "sub" "mul" "div" "rem" "and" "or" "xor"
37 "setne" "seteq" "setlt" "setgt" "setle" "setge") 'words) . font-lock-keyword-face)
38 ;; Special instructions
39 `(,(regexp-opt '("phi" "tail" "call" "cast" "select" "to" "shl" "shr" "vaarg" "vanext") 'words) . font-lock-keyword-face)
40 ;; Control instructions
41 `(,(regexp-opt '("ret" "br" "switch" "invoke" "unwind" "unreachable") 'words) . font-lock-keyword-face)
42 ;; Memory operators
43 `(,(regexp-opt '("malloc" "alloca" "free" "load" "store" "getelementptr") 'words) . font-lock-keyword-face)
45 "Syntax highlighting for LLVM"
48 ;; ---------------------- Syntax table ---------------------------
49 ;; Shamelessly ripped from jasmin.el
50 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el.html
52 (if (not llvm-mode-syntax-table)
53 (progn
54 (setq llvm-mode-syntax-table (make-syntax-table))
55 (mapcar (function (lambda (n)
56 (modify-syntax-entry (aref n 0)
57 (aref n 1)
58 llvm-mode-syntax-table)))
60 ;; whitespace (` ')
61 [?\^m " "]
62 [?\f " "]
63 [?\n " "]
64 [?\t " "]
65 [?\ " "]
66 ;; word constituents (`w')
67 ;;[?< "w"]
68 ;;[?> "w"]
69 [?\% "w"]
70 ;;[?_ "w "]
71 ;; comments
72 [?\; "< "]
73 [?\n "> "]
74 ;;[?\r "> "]
75 ;;[?\^m "> "]
76 ;; symbol constituents (`_')
77 ;; punctuation (`.')
78 ;; open paren (`(')
79 [?\( "("]
80 [?\[ "("]
81 [?\{ "("]
82 ;; close paren (`)')
83 [?\) ")"]
84 [?\] ")"]
85 [?\} ")"]
86 ;; string quote ('"')
87 [?\" "\""]
88 ))))
90 ;; --------------------- Abbrev table -----------------------------
92 (defvar llvm-mode-abbrev-table nil
93 "Abbrev table used while in LLVM mode.")
94 (define-abbrev-table 'llvm-mode-abbrev-table ())
96 (defvar llvm-mode-hook nil)
97 (defvar llvm-mode-map nil) ; Create a mode-specific keymap.
99 (if (not llvm-mode-map)
100 () ; Do not change the keymap if it is already set up.
101 (setq llvm-mode-map (make-sparse-keymap))
102 (define-key llvm-mode-map "\t" 'tab-to-tab-stop)
103 (define-key llvm-mode-map "\es" 'center-line)
104 (define-key llvm-mode-map "\eS" 'center-paragraph))
107 (defun llvm-mode ()
108 "Major mode for editing LLVM source files.
109 \\{llvm-mode-map}
110 Runs llvm-mode-hook on startup."
111 (interactive)
112 (kill-all-local-variables)
113 (use-local-map llvm-mode-map) ; Provides the local keymap.
114 (setq major-mode 'llvm-mode)
116 (make-local-variable 'font-lock-defaults)
117 (setq major-mode 'llvm-mode ; This is how describe-mode
118 ; finds the doc string to print.
119 mode-name "LLVM" ; This name goes into the modeline.
120 font-lock-defaults `(llvm-font-lock-keywords))
122 (setq local-abbrev-table llvm-mode-abbrev-table)
123 (set-syntax-table llvm-mode-syntax-table)
124 (setq comment-start ";")
125 (run-hooks 'llvm-mode-hook)) ; Finally, this permits the user to
126 ; customize the mode with a hook.
128 ;; Associate .ll files with llvm-mode
129 (setq auto-mode-alist
130 (append '(("\\.ll$" . llvm-mode)) auto-mode-alist))
132 (provide 'llvm-mode)
133 ;; end of llvm-mode.el