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 '("\\bvoid\\b\\|\\bi[0-9]+\\b\\|\\float\\b\\|\\bdouble\\b\\|\\btype\\b\\|\\blabel\\b\\|\\bopaque\\b" . 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 '("\\bbegin\\b\\|\\bend\\b\\|\\btrue\\b\\|\\bfalse\\b\\|\\bzeroinitializer\\b\\|\\bdeclare\\b\\|\\bdefine\\b\\|\\bglobal\\b\\|\\bconstant\\b\\|\\bconst\\b\\|\\binternal\\b\\|\\blinkonce\\b\\|\\blinkonce_odr\\b\\|\\bweak\\b\\|\\bweak_odr\\b\\|\\bappending\\b\\|\\buninitialized\\b\\|\\bimplementation\\b\\|\\b\\.\\.\\.\\b\\|\\bnull\\b\\|\\bundef\\b\\|\\bto\\b\\|\\bexcept\\b\\|\\bnot\\b\\|\\btarget\\b\\|\\bendian\\b\\|\\blittle\\b\\|\\bbig\\b\\|\\bpointersize\\b\\|\\bdeplibs\\b\\|\\bvolatile\\b\\|\\bfastcc\\b\\|\\bcoldcc\\b\\|\\bcc\\b" . font-lock-keyword-face
)
31 ;; Arithmetic and Logical Operators
32 '("\\badd\\b\\|\\bsub\\b\\|\\bmul\\b\\|\\bdiv\\b\\|\\brem\\b\\|\\band\\b\\|\\bor\\b\\|\\bxor\\b\\|\\bset\\(ne\\b\\|\\beq\\b\\|\\blt\\b\\|\\bgt\\b\\|\\ble\\b\\|\\bge\\b\\)" . font-lock-keyword-face
)
33 ;; Special instructions
34 '("\\bphi\\b\\|\\btail\\b\\|\\bcall\\b\\|\\bcast\\b\\|\\bselect\\b\\|\\bto\\b\\|\\bshl\\b\\|\\bshr\\b\\|\\bvaarg\\b\\|\\bvanext\\b" . font-lock-keyword-face
)
35 ;; Control instructions
36 '("\\bret\\b\\|\\bbr\\b\\|\\bswitch\\b\\|\\binvoke\\b\\|\\bunwind\\b\\|\\bunreachable\\b" . font-lock-keyword-face
)
38 '("\\bmalloc\\b\\|\\balloca\\b\\|\\bfree\\b\\|\\bload\\b\\|\\bstore\\b\\|\\bgetelementptr\\b" . font-lock-keyword-face
)
40 "Syntax highlighting for LLVM"
43 ;; ---------------------- Syntax table ---------------------------
44 ;; Shamelessly ripped from jasmin.el
45 ;; URL: http://www.neilvandyke.org/jasmin-emacs/jasmin.el.html
47 (if (not llvm-mode-syntax-table
)
49 (setq llvm-mode-syntax-table
(make-syntax-table))
50 (mapcar (function (lambda (n)
51 (modify-syntax-entry (aref n
0)
53 llvm-mode-syntax-table
)))
61 ;; word constituents (`w')
71 ;; symbol constituents (`_')
85 ;; --------------------- Abbrev table -----------------------------
87 (defvar llvm-mode-abbrev-table nil
88 "Abbrev table used while in LLVM mode.")
89 (define-abbrev-table 'llvm-mode-abbrev-table
())
91 (defvar llvm-mode-hook nil
)
92 (defvar llvm-mode-map nil
) ; Create a mode-specific keymap.
94 (if (not llvm-mode-map
)
95 () ; Do not change the keymap if it is already set up.
96 (setq llvm-mode-map
(make-sparse-keymap))
97 (define-key llvm-mode-map
"\t" 'tab-to-tab-stop
)
98 (define-key llvm-mode-map
"\es" 'center-line
)
99 (define-key llvm-mode-map
"\eS" 'center-paragraph
))
103 "Major mode for editing LLVM source files.
105 Runs llvm-mode-hook on startup."
107 (kill-all-local-variables)
108 (use-local-map llvm-mode-map
) ; Provides the local keymap.
109 (setq major-mode
'llvm-mode
)
111 (make-local-variable 'font-lock-defaults
)
112 (setq major-mode
'llvm-mode
; This is how describe-mode
113 ; finds the doc string to print.
114 mode-name
"LLVM" ; This name goes into the modeline.
115 font-lock-defaults
`(llvm-font-lock-keywords))
117 (setq local-abbrev-table llvm-mode-abbrev-table
)
118 (set-syntax-table llvm-mode-syntax-table
)
119 (setq comment-start
";")
120 (run-hooks 'llvm-mode-hook
)) ; Finally, this permits the user to
121 ; customize the mode with a hook.
123 ;; Associate .ll files with llvm-mode
124 (setq auto-mode-alist
125 (append '(("\\.ll$" . llvm-mode
) ("\\.llx$" . llvm-mode
)) auto-mode-alist
))
128 ;; end of llvm-mode.el