[InstCombine] Signed saturation patterns
[llvm-core.git] / utils / emacs / tablegen-mode.el
bloba5da0fdac5a5a5e52eb862325b53d249d32e0580
1 ;;; tablegen-mode.el --- Major mode for TableGen description files (part of LLVM project)
3 ;; Maintainer: The LLVM team, http://llvm.org/
5 ;;; Commentary:
6 ;; A major mode for TableGen description files in LLVM.
8 (require 'comint)
9 (require 'custom)
10 (require 'ansi-color)
12 ;; Create mode-specific tables.
13 ;;; Code:
15 (defvar td-decorators-face 'td-decorators-face
16 "Face method decorators.")
17 (make-face 'td-decorators-face)
19 (defvar tablegen-font-lock-keywords
20 (let ((kw (regexp-opt '("class" "defm" "def" "field" "include" "in"
21 "let" "multiclass" "foreach")
22 'words))
23 (type-kw (regexp-opt '("bit" "bits" "code" "dag" "int" "list" "string")
24 'words))
26 (list
27 ;; Comments
28 ;; '("\/\/" . font-lock-comment-face)
29 ;; Strings
30 '("\"[^\"]+\"" . font-lock-string-face)
31 ;; Hex constants
32 '("\\<0x[0-9A-Fa-f]+\\>" . font-lock-preprocessor-face)
33 ;; Binary constants
34 '("\\<0b[01]+\\>" . font-lock-preprocessor-face)
35 ;; Integer literals
36 '("\\<[-]?[0-9]+\\>" . font-lock-preprocessor-face)
37 ;; Floating point constants
38 '("\\<[-+]?[0-9]+\.[0-9]*\([eE][-+]?[0-9]+\)?\\>" . font-lock-preprocessor-face)
40 '("^[ \t]*\\(@.+\\)" 1 'td-decorators-face)
41 ;; Keywords
43 ;; Type keywords
44 type-kw
46 "Additional expressions to highlight in TableGen mode.")
47 (put 'tablegen-mode 'font-lock-defaults '(tablegen-font-lock-keywords))
49 ;; ---------------------- Syntax table ---------------------------
51 (defvar tablegen-mode-syntax-table nil
52 "Syntax table used in `tablegen-mode' buffers.")
53 (when (not tablegen-mode-syntax-table)
54 (setq tablegen-mode-syntax-table (make-syntax-table))
55 ;; whitespace (` ')
56 (modify-syntax-entry ?\ " " tablegen-mode-syntax-table)
57 (modify-syntax-entry ?\t " " tablegen-mode-syntax-table)
58 (modify-syntax-entry ?\r " " tablegen-mode-syntax-table)
59 (modify-syntax-entry ?\n " " tablegen-mode-syntax-table)
60 (modify-syntax-entry ?\f " " tablegen-mode-syntax-table)
61 ;; word constituents (`w')
62 (modify-syntax-entry ?\% "w" tablegen-mode-syntax-table)
63 (modify-syntax-entry ?\_ "w" tablegen-mode-syntax-table)
64 ;; comments
65 (modify-syntax-entry ?/ ". 124b" tablegen-mode-syntax-table)
66 (modify-syntax-entry ?* ". 23" tablegen-mode-syntax-table)
67 (modify-syntax-entry ?\n "> b" tablegen-mode-syntax-table)
68 ;; open paren (`(')
69 (modify-syntax-entry ?\( "(" tablegen-mode-syntax-table)
70 (modify-syntax-entry ?\[ "(" tablegen-mode-syntax-table)
71 (modify-syntax-entry ?\{ "(" tablegen-mode-syntax-table)
72 (modify-syntax-entry ?\< "(" tablegen-mode-syntax-table)
73 ;; close paren (`)')
74 (modify-syntax-entry ?\) ")" tablegen-mode-syntax-table)
75 (modify-syntax-entry ?\] ")" tablegen-mode-syntax-table)
76 (modify-syntax-entry ?\} ")" tablegen-mode-syntax-table)
77 (modify-syntax-entry ?\> ")" tablegen-mode-syntax-table)
78 ;; string quote ('"')
79 (modify-syntax-entry ?\" "\"" tablegen-mode-syntax-table)
82 ;; --------------------- Abbrev table -----------------------------
84 (defvar tablegen-mode-abbrev-table nil
85 "Abbrev table used while in TableGen mode.")
86 (define-abbrev-table 'tablegen-mode-abbrev-table ())
88 (defvar tablegen-mode-hook nil)
89 (defvar tablegen-mode-map nil) ; Create a mode-specific keymap.
91 (if (not tablegen-mode-map)
92 () ; Do not change the keymap if it is already set up.
93 (setq tablegen-mode-map (make-sparse-keymap))
94 (define-key tablegen-mode-map "\t" 'tab-to-tab-stop)
95 (define-key tablegen-mode-map "\es" 'center-line)
96 (define-key tablegen-mode-map "\eS" 'center-paragraph))
98 ;;;###autoload
99 (defun tablegen-mode ()
100 "Major mode for editing TableGen description files.
101 \\{tablegen-mode-map}
102 Runs `tablegen-mode-hook' on startup."
103 (interactive)
104 (kill-all-local-variables)
105 (use-local-map tablegen-mode-map) ; Provides the local keymap.
106 (make-local-variable 'font-lock-defaults)
107 (setq major-mode 'tablegen-mode ; This is how describe-mode
108 ; finds the doc string to print.
109 mode-name "TableGen" ; This name goes into the modeline.
110 local-abbrev-table tablegen-mode-abbrev-table
111 font-lock-defaults `(tablegen-font-lock-keywords)
112 require-final-newline t
115 (set-syntax-table tablegen-mode-syntax-table)
116 (make-local-variable 'comment-start)
117 (setq comment-start "//")
118 (setq indent-tabs-mode nil)
119 (run-hooks 'tablegen-mode-hook)) ; Finally, this permits the user to
120 ; customize the mode with a hook.
122 ;; Associate .td files with tablegen-mode
123 ;;;###autoload
124 (add-to-list 'auto-mode-alist (cons (purecopy "\\.td\\'") 'tablegen-mode))
126 (provide 'tablegen-mode)
128 ;;; tablegen-mode.el ends here