1 ;; Maintainer: The LLVM team, http://llvm.org/
2 ;; Description: Major mode for the LLVM assembler language.
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
12 '(";.*" . font-lock-comment-face
)
14 '("%[-a-zA-Z$\._][-a-zA-Z$\._0-9]*" . font-lock-variable-name-face
)
16 '("[-a-zA-Z$\._0-9]+:" . font-lock-variable-name-face
)
18 '("\"[^\"]+\"" . font-lock-string-face
)
19 ;; Unnamed variable slots
20 '("%[-]?[0-9]+" . font-lock-variable-name-face
)
22 `(,(regexp-opt '("void" "i[0-9]+" "float" "double" "type" "label" "opaque") 'words
) . font-lock-type-face
)
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
)
28 '("\\b0x[0-9A-Fa-f]+\\b" . font-lock-preprocessor-face
)
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
)
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
)
54 (setq llvm-mode-syntax-table
(make-syntax-table))
55 (mapcar (function (lambda (n)
56 (modify-syntax-entry (aref n
0)
58 llvm-mode-syntax-table
)))
66 ;; word constituents (`w')
76 ;; symbol constituents (`_')
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
))
108 "Major mode for editing LLVM source files.
110 Runs llvm-mode-hook on startup."
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
))
133 ;; end of llvm-mode.el