mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-06-14 12:21:20 +00:00
Compare commits
16 commits
354ce4041e
...
04cd529642
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04cd529642 | ||
|
|
2a27705094 | ||
|
|
4dd3b8fef7 | ||
| d7192e0ac9 | |||
| 769bd39690 | |||
| 6f4307601a | |||
| 26c05d08c4 | |||
| 2a0f9fef64 | |||
| cf32daf8ce | |||
| a4e62fe73e | |||
| 16c218cc25 | |||
|
|
665acffffb | ||
|
|
b5a2eaecff | ||
| 247c2011f2 | |||
|
|
b80bd6a333 | ||
|
|
83e2ca5a95 |
30 changed files with 520 additions and 426 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -1,6 +1,3 @@
|
||||||
[submodule "submodule/mu"]
|
|
||||||
path = submodule/mu
|
|
||||||
url = https://github.com/djcb/mu
|
|
||||||
[submodule "submodule/youtube-dl-emacs"]
|
[submodule "submodule/youtube-dl-emacs"]
|
||||||
path = submodule/youtube-dl-emacs
|
path = submodule/youtube-dl-emacs
|
||||||
url = https://github.com/skeeto/youtube-dl-emacs
|
url = https://github.com/skeeto/youtube-dl-emacs
|
||||||
|
|
|
||||||
|
|
@ -23,12 +23,14 @@
|
||||||
|
|
||||||
;; System tray
|
;; System tray
|
||||||
(require 'exwm-systemtray)
|
(require 'exwm-systemtray)
|
||||||
(exwm-systemtray-enable)
|
(exwm-systemtray-mode t)
|
||||||
|
|
||||||
;; Multi monitor support
|
;; Multi monitor support
|
||||||
(require 'exwm-randr)
|
(require 'exwm-randr)
|
||||||
(exwm-enable)
|
(exwm-randr-mode t)
|
||||||
(exwm-randr-enable)
|
|
||||||
|
(add-hook 'emacs-startup-hook
|
||||||
|
'exwm-wm-mode)
|
||||||
|
|
||||||
;; This is a new-frame hack. Don't copy faces for floating windows
|
;; This is a new-frame hack. Don't copy faces for floating windows
|
||||||
(require 'face-copier)
|
(require 'face-copier)
|
||||||
|
|
@ -77,9 +79,6 @@
|
||||||
(require 'exwm-startup)
|
(require 'exwm-startup)
|
||||||
(add-hook 'exwm-init-hook 'call-startup-programs)
|
(add-hook 'exwm-init-hook 'call-startup-programs)
|
||||||
|
|
||||||
(require 'exwm-systemtray)
|
|
||||||
(exwm-systemtray-enable)
|
|
||||||
|
|
||||||
;; Setup screens before anything else
|
;; Setup screens before anything else
|
||||||
(require 'exwm-screens)
|
(require 'exwm-screens)
|
||||||
(add-hook 'exwm-init-hook 'my/setup-screens)
|
(add-hook 'exwm-init-hook 'my/setup-screens)
|
||||||
|
|
|
||||||
|
|
@ -64,7 +64,8 @@
|
||||||
(setq global-mode-string '(" "))
|
(setq global-mode-string '(" "))
|
||||||
(setq display-time-day-and-date t)
|
(setq display-time-day-and-date t)
|
||||||
|
|
||||||
(display-battery-mode t)
|
(when (ec/load-or-ask-pred 'my-ec/display-battery "Display battery? ")
|
||||||
|
(display-battery-mode t))
|
||||||
(display-time-mode t)
|
(display-time-mode t)
|
||||||
(unless (or (eq 'windows-nt system-type)
|
(unless (or (eq 'windows-nt system-type)
|
||||||
(not (executable-find "df")))
|
(not (executable-find "df")))
|
||||||
|
|
|
||||||
|
|
@ -111,32 +111,6 @@
|
||||||
|
|
||||||
(use-package affe
|
(use-package affe
|
||||||
:config
|
:config
|
||||||
(defun my/affe-find (&optional dir initial)
|
|
||||||
"Fuzzy find in DIR with optional INITIAL input."
|
|
||||||
(interactive "P")
|
|
||||||
(pcase-let* ((`(,prompt ,paths ,dir) (consult--directory-prompt "Fuzzy find" dir))
|
|
||||||
(default-directory dir))
|
|
||||||
(consult--read
|
|
||||||
(thread-first (consult--async-sink)
|
|
||||||
(consult--async-refresh-timer 0.05)
|
|
||||||
(consult--async-map (lambda (x) (string-remove-prefix "./" x)))
|
|
||||||
(affe--async (affe--command affe-find-command paths))
|
|
||||||
(consult--async-split #'consult--split-nil))
|
|
||||||
:prompt prompt
|
|
||||||
:sort nil
|
|
||||||
:require-match t
|
|
||||||
:history '(:input affe--find-history)
|
|
||||||
:initial initial
|
|
||||||
:category 'file
|
|
||||||
:add-history (thing-at-point 'filename)
|
|
||||||
:state (lambda (action cand)
|
|
||||||
(when (and cand (eq action 'return))
|
|
||||||
(find-file (expand-file-name cand dir)))))))
|
|
||||||
|
|
||||||
(advice-add #'affe-find
|
|
||||||
:override
|
|
||||||
#'my/affe-find)
|
|
||||||
|
|
||||||
(with-eval-after-load 'projectile
|
(with-eval-after-load 'projectile
|
||||||
(define-key projectile-command-map (kbd "F") #'affe-find)
|
(define-key projectile-command-map (kbd "F") #'affe-find)
|
||||||
(define-key projectile-command-map (kbd "s G") #'affe-grep))
|
(define-key projectile-command-map (kbd "s G") #'affe-grep))
|
||||||
|
|
|
||||||
2
elpa
2
elpa
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6df853a359ff19a0a8fa40cc1dd52c0768a49129
|
Subproject commit b12ed477b68f85a0df9057f8c7b6d717b5a14586
|
||||||
|
|
@ -26,7 +26,7 @@
|
||||||
(defvar exwm-startup-programs
|
(defvar exwm-startup-programs
|
||||||
'(("megasync" "QT_SCALE_FACTOR=1 megasync")
|
'(("megasync" "QT_SCALE_FACTOR=1 megasync")
|
||||||
"/usr/lib/kdeconnectd"
|
"/usr/lib/kdeconnectd"
|
||||||
("compton" "compton -f -i .7 -b")
|
("compton" "picom --backend=glx -f -i .7 -b")
|
||||||
;; ("compton -f -i .7 -b --backend glx --blur-background --blur-method kawase --blur-strength 2")
|
;; ("compton -f -i .7 -b --backend glx --blur-background --blur-method kawase --blur-strength 2")
|
||||||
"start-pulseaudio-x11;pactl upload-sample /usr/share/sounds/gnome/default/alerts/drip.ogg beep; pactl load-module module-x11-bell sample=beep; xset b 100"
|
"start-pulseaudio-x11;pactl upload-sample /usr/share/sounds/gnome/default/alerts/drip.ogg beep; pactl load-module module-x11-bell sample=beep; xset b 100"
|
||||||
"kdeconnect-indicator"
|
"kdeconnect-indicator"
|
||||||
|
|
@ -46,6 +46,7 @@
|
||||||
(start-process-shell-command (file-name-nondirectory program) nil program))))
|
(start-process-shell-command (file-name-nondirectory program) nil program))))
|
||||||
|
|
||||||
(defun call-startup-programs ()
|
(defun call-startup-programs ()
|
||||||
|
(interactive)
|
||||||
(start-minimum-programs)
|
(start-minimum-programs)
|
||||||
(when (y-or-n-p "Run startup programs? ")
|
(when (y-or-n-p "Run startup programs? ")
|
||||||
(dolist (program exwm-startup-programs)
|
(dolist (program exwm-startup-programs)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
;;; compiler-option-sets.el --- -*- lexical-binding: t -*-
|
;;; c-compiler-option-sets.el --- -*- lexical-binding: t -*-
|
||||||
|
|
||||||
;; Copyright (C) 2024 Benson Chu
|
;; Copyright (C) 2024 Benson Chu
|
||||||
|
|
||||||
|
|
@ -34,25 +34,27 @@
|
||||||
(include-dirs :initarg :include-dirs :type list :initform nil)
|
(include-dirs :initarg :include-dirs :type list :initform nil)
|
||||||
(system-include-dirs :initarg :isystem :type list :initform nil)))
|
(system-include-dirs :initarg :isystem :type list :initform nil)))
|
||||||
|
|
||||||
(defmacro register-prebaked-optionset (hashmap target-str key &rest options)
|
(defmacro register-prebaked-optionset (hashmap type target-str key &rest options)
|
||||||
(declare (indent 3))
|
(declare (indent 3))
|
||||||
`(puthash ',key
|
`(puthash ',key
|
||||||
(make-instance 'compiler-option-config
|
(make-instance ,type
|
||||||
:target-str ,target-str
|
:target-str ,target-str
|
||||||
,@options)
|
,@options)
|
||||||
,hashmap))
|
,hashmap))
|
||||||
|
|
||||||
(defun cos/edit-compiler-options (optionset current-name)
|
(cl-defgeneric cos/to-string (config))
|
||||||
|
|
||||||
|
(defun cos/edit-compiler-options (prefix optionset current-name)
|
||||||
(dolist (slot (cddr (eieio-class-slots 'compiler-option-config)))
|
(dolist (slot (cddr (eieio-class-slots 'compiler-option-config)))
|
||||||
(let* ((slot-sym (eieio-slot-descriptor-name slot))
|
(let* ((slot-sym (eieio-slot-descriptor-name slot))
|
||||||
(slot-val (and (slot-boundp optionsset slot-sym)
|
(slot-val (and (slot-boundp optionset slot-sym)
|
||||||
(slot-value optionsset slot-sym))))
|
(slot-value optionset slot-sym))))
|
||||||
(when slot-val
|
(when slot-val
|
||||||
(pcase (cl--slot-descriptor-type slot)
|
(pcase (cl--slot-descriptor-type slot)
|
||||||
('list
|
('list
|
||||||
(when (or prefix
|
(when (or prefix
|
||||||
(not (zerop (length slot-val))))
|
(not (zerop (length slot-val))))
|
||||||
(setf (slot-value optionsset slot-sym)
|
(setf (slot-value optionset slot-sym)
|
||||||
(read
|
(read
|
||||||
(read-string (format "Edit '%s' for optionset '%s': "
|
(read-string (format "Edit '%s' for optionset '%s': "
|
||||||
(symbol-name slot-sym)
|
(symbol-name slot-sym)
|
||||||
|
|
@ -61,11 +63,11 @@
|
||||||
('string
|
('string
|
||||||
(when (or prefix
|
(when (or prefix
|
||||||
(not (string= slot-val "")))
|
(not (string= slot-val "")))
|
||||||
(setf (slot-value optionsset slot-sym)
|
(setf (slot-value optionset slot-sym)
|
||||||
(read-string (format "Edit '%s' for optionset '%s': "
|
(read-string (format "Edit '%s' for optionset '%s': "
|
||||||
(symbol-name slot-sym)
|
(symbol-name slot-sym)
|
||||||
current-name)
|
current-name)
|
||||||
slot-val)))))))))
|
slot-val)))))))))
|
||||||
|
|
||||||
(provide 'compiler-option-sets)
|
(provide 'c-compiler-option-sets)
|
||||||
;;; compiler-option-sets.el ends here
|
;;; c-compiler-option-sets.el ends here
|
||||||
|
|
@ -23,11 +23,32 @@
|
||||||
;;; Commentary:
|
;;; Commentary:
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'compiler-option-sets)
|
(require 'c-compiler-option-sets)
|
||||||
|
|
||||||
(defclass clang-option-config (compiler-option-config)
|
(defclass clang-option-config (compiler-option-config)
|
||||||
nil)
|
nil)
|
||||||
|
|
||||||
|
(cl-defmethod cos/to-string ((config clang-option-config))
|
||||||
|
(with-slots
|
||||||
|
(binary-path
|
||||||
|
target-options lang-options
|
||||||
|
other-options optimization-level
|
||||||
|
include-dirs)
|
||||||
|
config
|
||||||
|
(-->
|
||||||
|
(list
|
||||||
|
(or binary-path "")
|
||||||
|
target-options
|
||||||
|
lang-options
|
||||||
|
optimization-level
|
||||||
|
other-options
|
||||||
|
(mapconcat (lambda (x)
|
||||||
|
(format "-I\"%s\"" x))
|
||||||
|
include-dirs
|
||||||
|
" "))
|
||||||
|
(remove-if #'string-empty-p it)
|
||||||
|
(string-join it " "))))
|
||||||
|
|
||||||
(defvar clang-subtargets
|
(defvar clang-subtargets
|
||||||
(make-hash-table :test #'equal))
|
(make-hash-table :test #'equal))
|
||||||
|
|
||||||
|
|
@ -68,7 +89,7 @@
|
||||||
primary extensions)
|
primary extensions)
|
||||||
(setq primary
|
(setq primary
|
||||||
(my/completing-read-formatter
|
(my/completing-read-formatter
|
||||||
#'clang/clang-options->string
|
#'cos/to-string
|
||||||
"Primary Subtarget? "
|
"Primary Subtarget? "
|
||||||
(remove-if-not (lambda (x)
|
(remove-if-not (lambda (x)
|
||||||
(string= target
|
(string= target
|
||||||
|
|
@ -83,7 +104,7 @@
|
||||||
(alist-get option-name target-options nil nil #'equal))))
|
(alist-get option-name target-options nil nil #'equal))))
|
||||||
|
|
||||||
(defun clang/reinitialize-clang-options (target)
|
(defun clang/reinitialize-clang-options (target)
|
||||||
(interactive (list (intern (lls/conf-get 'target))))
|
(interactive (list (intern (comp-dev/conf-get 'target))))
|
||||||
(let ((option-name (or (gethash target clang/current-target-optionset)
|
(let ((option-name (or (gethash target clang/current-target-optionset)
|
||||||
(puthash target "default" clang/current-target-optionset))))
|
(puthash target "default" clang/current-target-optionset))))
|
||||||
(aprog1 (clang/make-clang-option-set target)
|
(aprog1 (clang/make-clang-option-set target)
|
||||||
|
|
@ -103,21 +124,21 @@
|
||||||
|
|
||||||
;; (defun clang/new-clang-option-set (target name &optional optionset)
|
;; (defun clang/new-clang-option-set (target name &optional optionset)
|
||||||
;; (interactive
|
;; (interactive
|
||||||
;; (list (intern (lls/conf-get 'target))
|
;; (list (intern (comp-dev/conf-get 'target))
|
||||||
;; (read-string "Name for new optionset? ")))
|
;; (read-string "Name for new optionset? ")))
|
||||||
;; (let ((optionset (or optionset (clang/make-clang-option-set target))))
|
;; (let ((optionset (or optionset (clang/make-clang-option-set target))))
|
||||||
;; (clang/add-and-set-target-option target name optionset)))
|
;; (clang/add-and-set-target-option target name optionset)))
|
||||||
|
|
||||||
;; (defun clang/copy-clang-option-set (target name &optional optionset)
|
;; (defun clang/copy-clang-option-set (target name &optional optionset)
|
||||||
;; (interactive
|
;; (interactive
|
||||||
;; (list (intern (lls/conf-get 'target))
|
;; (list (intern (comp-dev/conf-get 'target))
|
||||||
;; (read-string "Name for new optionset? ")))
|
;; (read-string "Name for new optionset? ")))
|
||||||
;; (let ((optionset (clang/get-clang-options-for-target target)))
|
;; (let ((optionset (clang/get-clang-options-for-target target)))
|
||||||
;; (clang/add-and-set-target-option target name optionset)))
|
;; (clang/add-and-set-target-option target name optionset)))
|
||||||
|
|
||||||
;; (defun clang/file-specific-option-set (target &optional optionset)
|
;; (defun clang/file-specific-option-set (target &optional optionset)
|
||||||
;; (interactive
|
;; (interactive
|
||||||
;; (list (intern (lls/conf-get 'target))))
|
;; (list (intern (comp-dev/conf-get 'target))))
|
||||||
;; ;; TODO: might need to garbage collect these
|
;; ;; TODO: might need to garbage collect these
|
||||||
;; (or (gethash (buffer-file-name)
|
;; (or (gethash (buffer-file-name)
|
||||||
;; clang/file-specific-options)
|
;; clang/file-specific-options)
|
||||||
|
|
@ -130,7 +151,7 @@
|
||||||
|
|
||||||
(defun clang/switch-clang-option-set (target name)
|
(defun clang/switch-clang-option-set (target name)
|
||||||
(interactive
|
(interactive
|
||||||
(let ((target lls/conf-get 'target))
|
(let ((target comp-dev/conf-get 'target))
|
||||||
(list target
|
(list target
|
||||||
(--> (intern target)
|
(--> (intern target)
|
||||||
(gethash it clang/all-target-options)
|
(gethash it clang/all-target-options)
|
||||||
|
|
@ -143,7 +164,7 @@
|
||||||
|
|
||||||
(defun clang/edit-clang-options (prefix)
|
(defun clang/edit-clang-options (prefix)
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(let* ((target (intern (lls/conf-get 'target)))
|
(let* ((target (intern (comp-dev/conf-get 'target)))
|
||||||
(options-config
|
(options-config
|
||||||
(->>
|
(->>
|
||||||
target
|
target
|
||||||
|
|
@ -153,7 +174,7 @@
|
||||||
(or (and (gethash (buffer-file-name) clang/file-specific-options )
|
(or (and (gethash (buffer-file-name) clang/file-specific-options )
|
||||||
"file-specific")
|
"file-specific")
|
||||||
(gethash target clang/current-target-optionset))))
|
(gethash target clang/current-target-optionset))))
|
||||||
(cos/edit-compiler-options options-config current-name)))
|
(cos/edit-compiler-options prefix options-config current-name)))
|
||||||
|
|
||||||
(defun clang/clang-options-merge (primary secondary)
|
(defun clang/clang-options-merge (primary secondary)
|
||||||
(make-instance
|
(make-instance
|
||||||
|
|
@ -181,40 +202,19 @@
|
||||||
(slot-value x 'include-dirs)))
|
(slot-value x 'include-dirs)))
|
||||||
it)))))
|
it)))))
|
||||||
|
|
||||||
(defun clang/clang-options->string (opts)
|
|
||||||
(with-slots
|
|
||||||
(binary-path
|
|
||||||
target-options lang-options
|
|
||||||
other-options optimization-level
|
|
||||||
include-dirs)
|
|
||||||
opts
|
|
||||||
(-->
|
|
||||||
(list
|
|
||||||
(or binary-path "")
|
|
||||||
target-options
|
|
||||||
lang-options
|
|
||||||
optimization-level
|
|
||||||
other-options
|
|
||||||
(mapconcat (lambda (x)
|
|
||||||
(format "-I\"%s\"" x))
|
|
||||||
include-dirs
|
|
||||||
" "))
|
|
||||||
(remove-if #'string-empty-p it)
|
|
||||||
(string-join it " "))))
|
|
||||||
|
|
||||||
(defvar clang/detect-extensions-function nil)
|
(defvar clang/detect-extensions-function nil)
|
||||||
|
|
||||||
(cl-defun clang/get-clang-options (&key filename compiler action)
|
(cl-defun clang/get-clang-options (&key filename compiler action)
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((filename (or filename (buffer-file-name)))
|
(let* ((filename (or filename (buffer-file-name)))
|
||||||
(target-str (lls/conf-get 'target))
|
(target-str (comp-dev/conf-get 'target))
|
||||||
(target (intern target-str))
|
(target (intern target-str))
|
||||||
(options-config
|
(options-config
|
||||||
(clang/get-clang-options-for-target target))
|
(clang/get-clang-options-for-target target))
|
||||||
(detected-extensions
|
(detected-extensions
|
||||||
(awhen clang/detect-extensions-function
|
(awhen clang/detect-extensions-function
|
||||||
(funcall it compiler action filename target-str))))
|
(funcall it compiler action filename target-str))))
|
||||||
(clang/clang-options->string
|
(cos/to-string
|
||||||
(clang/clang-options-merge
|
(clang/clang-options-merge
|
||||||
(car options-config)
|
(car options-config)
|
||||||
(append detected-extensions (cdr options-config))))))
|
(append detected-extensions (cdr options-config))))))
|
||||||
|
|
|
||||||
|
|
@ -26,25 +26,25 @@
|
||||||
|
|
||||||
(require 'magit)
|
(require 'magit)
|
||||||
(require 'eieio)
|
(require 'eieio)
|
||||||
(require 'load-llvm-mode)
|
|
||||||
(require 'my-clang-options)
|
(require 'my-clang-options)
|
||||||
(require 'my-nprocs)
|
(require 'my-nprocs)
|
||||||
(require 'use-package)
|
(require 'use-package)
|
||||||
(use-package realgud-lldb)
|
(use-package realgud-lldb)
|
||||||
|
|
||||||
;; =========================== LLVM Rebuild ==========================
|
;; =========================== Rebuild ==========================
|
||||||
|
|
||||||
(defvar llvm-core-count
|
(defvar comp-dev/default-parallelism
|
||||||
(nprocs))
|
(nprocs))
|
||||||
|
|
||||||
(defun lls/run-build-command (build-dir targets &optional verbose)
|
(defun comp-dev/build-target (build-dir targets &optional verbose)
|
||||||
(let ((cmake-make-program
|
(let ((cmake-make-program
|
||||||
(if (string= "Makefile" (car (directory-files build-dir nil "^\\(build\\.ninja$\\|Makefile\\)$")))
|
(if (string= "Makefile" (car (directory-files build-dir nil
|
||||||
|
(rx line-start (or "build.ninja" "Makefile") line-end))))
|
||||||
"make"
|
"make"
|
||||||
"ninja")))
|
"ninja")))
|
||||||
(format "set -o pipefail && CLICOLOR_FORCE=1 %s -C %s -j %d %s %s 2>&1 | tee ninja.log"
|
(format "set -o pipefail && CLICOLOR_FORCE=1 %s -C %s -j %d %s %s 2>&1 | tee ninja.log"
|
||||||
cmake-make-program
|
cmake-make-program
|
||||||
build-dir llvm-core-count
|
build-dir comp-dev/default-parallelism
|
||||||
(if verbose "-v" "")
|
(if verbose "-v" "")
|
||||||
(string-join targets " "))))
|
(string-join targets " "))))
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
(defclass comp-dev-config ()
|
(defclass comp-dev-config ()
|
||||||
((root-dir :initarg :root-dir :type string)
|
((root-dir :initarg :root-dir :type string)
|
||||||
(target :initarg :target :type string)
|
(target :initarg :target :type string)
|
||||||
(tramp-connection :initarg :tramp :type list :initform nil)
|
;; (tramp-connection :initarg :tramp :type list :initform nil)
|
||||||
|
|
||||||
(aux-props :initarg :aux-props :type list :initform nil)))
|
(aux-props :initarg :aux-props :type list :initform nil)))
|
||||||
|
|
||||||
|
|
@ -66,68 +66,35 @@
|
||||||
(cl-defgeneric comp-dev/process-file (config start-type end-type compiler file output flags))
|
(cl-defgeneric comp-dev/process-file (config start-type end-type compiler file output flags))
|
||||||
(cl-defgeneric comp-dev/tool-name (config tool))
|
(cl-defgeneric comp-dev/tool-name (config tool))
|
||||||
|
|
||||||
|
;; =============================== Tabs ===============================
|
||||||
|
|
||||||
|
(defvar comp-dev/configs (make-hash-table :test #'equal))
|
||||||
|
|
||||||
(defun comp-dev/get-config (&optional tab-name)
|
(defun comp-dev/get-config (&optional tab-name)
|
||||||
(let ((tab-name (or tab-name (alist-get 'name (tab-bar--current-tab)))))
|
(let ((tab-name (or tab-name (alist-get 'name (tab-bar--current-tab)))))
|
||||||
(gethash tab-name comp-dev/configs)))
|
(gethash tab-name comp-dev/configs)))
|
||||||
|
|
||||||
(defvar comp-dev/configs (make-hash-table :test #'equal))
|
(defun comp-dev/get-active-configs ()
|
||||||
|
|
||||||
(defvar lls/target-init-fun nil)
|
|
||||||
|
|
||||||
(defun lls/get-active-configs ()
|
|
||||||
(hash-table-values comp-dev/configs))
|
(hash-table-values comp-dev/configs))
|
||||||
|
|
||||||
(defun lls/set-llvm-config (conf &optional tab-name)
|
(defvar comp-dev/init-functions nil)
|
||||||
|
|
||||||
|
(defun comp-dev/set-config (conf &optional tab-name)
|
||||||
(puthash (or tab-name (alist-get 'name (tab-bar--current-tab)))
|
(puthash (or tab-name (alist-get 'name (tab-bar--current-tab)))
|
||||||
conf
|
conf
|
||||||
comp-dev/configs))
|
comp-dev/configs))
|
||||||
|
|
||||||
;; (defvar lls/llvm-config nil)
|
(defun comp-dev/conf-set (key val)
|
||||||
|
|
||||||
(defun lls/conf-get (sym)
|
|
||||||
(comp-dev/ensure-initialized)
|
|
||||||
(slot-value (comp-dev/get-config) sym))
|
|
||||||
|
|
||||||
(defun lls/conf-get-safe (sym)
|
|
||||||
(if-let ((conf (comp-dev/get-config)))
|
|
||||||
(slot-value conf sym)
|
|
||||||
nil))
|
|
||||||
|
|
||||||
(defun lls/conf-aux-get (sym)
|
|
||||||
(comp-dev/ensure-initialized)
|
|
||||||
(-->
|
|
||||||
(lls/conf-get 'aux-props)
|
|
||||||
(alist-get sym it)))
|
|
||||||
|
|
||||||
(defun lls/conf-set (key val)
|
|
||||||
(comp-dev/ensure-initialized)
|
(comp-dev/ensure-initialized)
|
||||||
(setf (slot-value (comp-dev/get-config) key)
|
(setf (slot-value (comp-dev/get-config) key)
|
||||||
val))
|
val))
|
||||||
|
|
||||||
(defun lls/tramp-connection ()
|
;; ====== External ======
|
||||||
(lls/conf-get 'tramp-connection))
|
|
||||||
|
|
||||||
(defun lls/trampify (path)
|
|
||||||
(if-let ((vec (lls/tramp-connection)))
|
|
||||||
(tramp-make-tramp-file-name vec path)
|
|
||||||
path))
|
|
||||||
|
|
||||||
(defun lls/un-trampify (path)
|
|
||||||
(if-let ((vec (lls/tramp-connection)))
|
|
||||||
(with-parsed-tramp-file-name path nil
|
|
||||||
localname)
|
|
||||||
path))
|
|
||||||
|
|
||||||
(defun lls/default-initialize ()
|
|
||||||
(interactive)
|
|
||||||
(let ((lls/target-init-fun #'lls/default-target-init))
|
|
||||||
(comp-dev/initialize)))
|
|
||||||
|
|
||||||
(defun comp-dev/initialize ()
|
(defun comp-dev/initialize ()
|
||||||
(interactive)
|
(interactive)
|
||||||
(lls/set-llvm-config
|
(comp-dev/set-config
|
||||||
(or
|
(or
|
||||||
(let ((active-conf (lls/get-active-configs)))
|
(let ((active-conf (comp-dev/get-active-configs)))
|
||||||
(and (not (zerop (length active-conf)))
|
(and (not (zerop (length active-conf)))
|
||||||
(y-or-n-p "Would you like to reuse a configuration? ")
|
(y-or-n-p "Would you like to reuse a configuration? ")
|
||||||
(let ((tab-name
|
(let ((tab-name
|
||||||
|
|
@ -137,10 +104,26 @@
|
||||||
(mapcar #'(lambda (x) (alist-get 'name x)))
|
(mapcar #'(lambda (x) (alist-get 'name x)))
|
||||||
(remove-if-not #'(lambda (x) (comp-dev/get-config x)))))))
|
(remove-if-not #'(lambda (x) (comp-dev/get-config x)))))))
|
||||||
(comp-dev/get-config tab-name))))
|
(comp-dev/get-config tab-name))))
|
||||||
(funcall lls/target-init-fun)))
|
(funcall (intern
|
||||||
(load-llvm-mode (lls/conf-get 'root-dir))
|
(completing-read "Which initialization function would you like to use? "
|
||||||
|
comp-dev/init-functions)))))
|
||||||
(message "comp-dev initialize!"))
|
(message "comp-dev initialize!"))
|
||||||
|
|
||||||
|
(defun comp-dev/conf-get (sym)
|
||||||
|
(comp-dev/ensure-initialized)
|
||||||
|
(slot-value (comp-dev/get-config) sym))
|
||||||
|
|
||||||
|
(defun comp-dev/conf-get-safe (sym)
|
||||||
|
(if-let ((conf (comp-dev/get-config)))
|
||||||
|
(slot-value conf sym)
|
||||||
|
nil))
|
||||||
|
|
||||||
|
(defun comp-dev/conf-aux-get (sym)
|
||||||
|
(comp-dev/ensure-initialized)
|
||||||
|
(-->
|
||||||
|
(comp-dev/conf-get 'aux-props)
|
||||||
|
(alist-get sym it)))
|
||||||
|
|
||||||
(defun comp-dev/initialized? ()
|
(defun comp-dev/initialized? ()
|
||||||
(and (comp-dev/get-config)
|
(and (comp-dev/get-config)
|
||||||
(typep (comp-dev/get-config) 'comp-dev-config)))
|
(typep (comp-dev/get-config) 'comp-dev-config)))
|
||||||
|
|
@ -151,65 +134,19 @@
|
||||||
(error "Please register an init function for llvm")
|
(error "Please register an init function for llvm")
|
||||||
(comp-dev/initialize))))
|
(comp-dev/initialize))))
|
||||||
|
|
||||||
(defun lls/get-cached-value (key fun)
|
;; (defun lls/tramp-connection ()
|
||||||
(or (lls/conf-get key)
|
;; (comp-dev/conf-get 'tramp-connection))
|
||||||
(lls/conf-set key (funcall fun))))
|
|
||||||
|
|
||||||
(require 'projectile)
|
;; (defun lls/trampify (path)
|
||||||
|
;; (if-let ((vec (lls/tramp-connection)))
|
||||||
|
;; (tramp-make-tramp-file-name vec path)
|
||||||
|
;; path))
|
||||||
|
|
||||||
(defun projectile-dont-switch-when-conf-available (x)
|
;; (defun lls/un-trampify (path)
|
||||||
(if-let ((dir (lls/conf-get-safe 'root-dir))
|
;; (if-let ((vec (lls/tramp-connection)))
|
||||||
(tools-dir
|
;; (with-parsed-tramp-file-name path nil
|
||||||
(when (string-match (rx line-start
|
;; localname)
|
||||||
"/scratch"
|
;; path))
|
||||||
(group "/benson/_repos-work/tools" (* (not "/")) "/"))
|
|
||||||
dir)
|
|
||||||
(match-string 1 dir))))
|
|
||||||
(remove-if #'(lambda (path)
|
|
||||||
(and (string-match-p (rx "/benson/_repos-work/tools")
|
|
||||||
path)
|
|
||||||
(not (string-match-p tools-dir path))))
|
|
||||||
x)
|
|
||||||
x))
|
|
||||||
|
|
||||||
(when my-ec/at-ti
|
|
||||||
(advice-add 'projectile-relevant-known-projects
|
|
||||||
:filter-return
|
|
||||||
#'projectile-dont-switch-when-conf-available))
|
|
||||||
|
|
||||||
|
|
||||||
;;===---------------------------------------------------------------------===;;
|
|
||||||
|
|
||||||
(defun lls/get-llvm-root-dir ()
|
|
||||||
(comp-dev/ensure-initialized)
|
|
||||||
(lls/conf-get 'root-dir))
|
|
||||||
|
|
||||||
(defun lls/get-llvm-build-dirs ()
|
|
||||||
(comp-dev/ensure-initialized)
|
|
||||||
(funcall (lls/conf-get 'build-dirs-fun)))
|
|
||||||
|
|
||||||
(defun lls/get-llvm-bin-dir ()
|
|
||||||
(car (lls/get-llvm-bin-dirs)))
|
|
||||||
|
|
||||||
(defun lls/get-llvm-bin-dirs ()
|
|
||||||
(comp-dev/ensure-initialized)
|
|
||||||
(append (mapcar #'(lambda (x) (expand-file-name "bin" x))
|
|
||||||
(lls/get-llvm-build-dirs))
|
|
||||||
(funcall (lls/conf-get 'bin-dirs-fun))))
|
|
||||||
|
|
||||||
(defun lls/prompt-llvm-build-dir ()
|
|
||||||
(completing-read "Which directory? " (lls/get-llvm-build-dirs)))
|
|
||||||
|
|
||||||
(defun lls/get-llvm-build-dir ()
|
|
||||||
(car (lls/get-llvm-build-dirs)))
|
|
||||||
|
|
||||||
(defun lls/add-llvm-build-dir (dir)
|
|
||||||
(interactive
|
|
||||||
(list (read-file-name "Where? ")))
|
|
||||||
(comp-dev/ensure-initialized)
|
|
||||||
(lls/conf-set 'build-dirs
|
|
||||||
(cons dir
|
|
||||||
(lls/conf-get 'build-dirs))))
|
|
||||||
|
|
||||||
;; =============================== Misc ==============================
|
;; =============================== Misc ==============================
|
||||||
|
|
||||||
|
|
@ -221,20 +158,7 @@
|
||||||
(t (completing-read (format "Which %s? " prompt)
|
(t (completing-read (format "Which %s? " prompt)
|
||||||
collection nil nil initial-input)))))
|
collection nil nil initial-input)))))
|
||||||
|
|
||||||
(defun lls/prompt-tool (tool-regexp &optional directories)
|
(defun comp-dev/get-tools (tool-regexp &optional directories)
|
||||||
(lls/un-trampify
|
|
||||||
(let (;;(vertico-sort-function nil)
|
|
||||||
)
|
|
||||||
(my/completing-read tool-regexp
|
|
||||||
(lls/get-tool tool-regexp
|
|
||||||
(or (and (eq 'string (type-of directories))
|
|
||||||
(list directories))
|
|
||||||
directories))
|
|
||||||
(awhen (ti/current-tools-directory)
|
|
||||||
(concat (file-name-nondirectory it)
|
|
||||||
" "))))))
|
|
||||||
|
|
||||||
(defun lls/get-tool (tool-regexp &optional directories)
|
|
||||||
(cl-mapcan #'(lambda (dir)
|
(cl-mapcan #'(lambda (dir)
|
||||||
(when (file-exists-p dir)
|
(when (file-exists-p dir)
|
||||||
(when (string-match-p "/sim/sds11.*" dir)
|
(when (string-match-p "/sim/sds11.*" dir)
|
||||||
|
|
@ -243,148 +167,13 @@
|
||||||
(or directories
|
(or directories
|
||||||
(comp-dev/get-bin-dirs (comp-dev/get-config)))))
|
(comp-dev/get-bin-dirs (comp-dev/get-config)))))
|
||||||
|
|
||||||
(defun lls/get-clang-command-fun (&rest args)
|
(defun comp-dev/prompt-tool (tool-regexp &optional directories)
|
||||||
(apply (lls/conf-get 'compile-command-fun)
|
(let (;;(vertico-sort-function nil)
|
||||||
args))
|
)
|
||||||
|
(my/completing-read tool-regexp
|
||||||
(defun lls/get-llc-command-fun (&rest args)
|
(comp-dev/get-tools tool-regexp
|
||||||
(apply (lls/conf-get 'llc-command-fun) args))
|
(or (and (eq 'string (type-of directories))
|
||||||
|
(list directories)))))))
|
||||||
(defun lls/get-dis-command-fun (&rest args)
|
|
||||||
(apply (lls/conf-get 'dis-command-fun) args))
|
|
||||||
|
|
||||||
;; ========================= LLVM Build Dirs =========================
|
|
||||||
(cl-defun lls/default-comp-fun (&key compiler file action output flags)
|
|
||||||
(-->
|
|
||||||
(list compiler
|
|
||||||
(lls/get-clang-options)
|
|
||||||
(string-join rest " ")
|
|
||||||
file
|
|
||||||
(pcase action
|
|
||||||
('compile "-c")
|
|
||||||
('assemble "-S")
|
|
||||||
('preprocess "-E")
|
|
||||||
('llvm-ir "-S -emit-llvm")
|
|
||||||
('executable ""))
|
|
||||||
flags
|
|
||||||
"-o -"
|
|
||||||
(or (and output
|
|
||||||
(format "| tee %s" output))
|
|
||||||
""))
|
|
||||||
(flatten-list it)
|
|
||||||
(string-join it " ")))
|
|
||||||
|
|
||||||
(defun ll/read-pass ()
|
|
||||||
(completing-read "Which pass? "
|
|
||||||
'("finalize-isel"
|
|
||||||
"machine-scheduler"
|
|
||||||
"greedy")))
|
|
||||||
|
|
||||||
(cl-defun lls/default-llc-comm (&key llc file action output pass)
|
|
||||||
(let ((llc (or llc "llc")))
|
|
||||||
(concat
|
|
||||||
(cond
|
|
||||||
((member action '(run-pass stop-before stop-after start-before start-after))
|
|
||||||
(format "%s %s -o - -%s=%s"
|
|
||||||
llc file (symbol-name action) pass))
|
|
||||||
(t
|
|
||||||
(read-string
|
|
||||||
"llc invocation: "
|
|
||||||
(string-join
|
|
||||||
(list
|
|
||||||
llc
|
|
||||||
file
|
|
||||||
"-o -")
|
|
||||||
" "))))
|
|
||||||
(or (and output
|
|
||||||
(format " | tee %s" output))
|
|
||||||
""))))
|
|
||||||
|
|
||||||
(defun lls/default-dis-comm (file _action)
|
|
||||||
(concat "llvm-objdump --disassemble "
|
|
||||||
file " "))
|
|
||||||
|
|
||||||
(defun lls/lldb (binary)
|
|
||||||
(interactive
|
|
||||||
(list (lls/prompt-tool (rx (or "clang" "llc") line-end))))
|
|
||||||
(realgud--lldb
|
|
||||||
(format "lldb %s"
|
|
||||||
binary)))
|
|
||||||
|
|
||||||
(defun lls/default-target-init ()
|
|
||||||
(interactive)
|
|
||||||
(let ((root-dir (lls/guess-root-dir-fun))
|
|
||||||
tramp-conn)
|
|
||||||
(when (tramp-tramp-file-p root-dir)
|
|
||||||
(with-parsed-tramp-file-name root-dir nil
|
|
||||||
(setf tramp-conn v)))
|
|
||||||
(make-instance
|
|
||||||
'llvm-config
|
|
||||||
:tramp tramp-conn
|
|
||||||
:root-dir root-dir
|
|
||||||
:build-dirs-fun (lls/guess-build-dirs-fun root-dir)
|
|
||||||
:target (completing-read "Which target? " '("X86" "ARM" "Hexagon" "AIE" "RISCV"))
|
|
||||||
:bin-dirs-fun (lambda ()
|
|
||||||
(list
|
|
||||||
(--> "/usr/bin/"
|
|
||||||
(if (not tramp-conn) it
|
|
||||||
(tramp-make-tramp-file-name tramp-conn it)))))
|
|
||||||
:cc #'lls/default-comp-fun
|
|
||||||
:dc #'lls/default-dis-comm
|
|
||||||
:llc #'lls/default-llc-comm
|
|
||||||
:clang-opts-fun #'cc/get-clang-options)))
|
|
||||||
|
|
||||||
(when (not lls/target-init-fun)
|
|
||||||
(setq lls/target-init-fun
|
|
||||||
;; TODO: load llvm-mode
|
|
||||||
#'lls/default-target-init))
|
|
||||||
|
|
||||||
(defun lls/guess-root-dir-fun ()
|
|
||||||
(if (-->
|
|
||||||
(shell-command-to-string "git remote get-url origin")
|
|
||||||
(string-trim it)
|
|
||||||
(string-match-p ".*llvm.*" it))
|
|
||||||
(vc-root-dir)
|
|
||||||
(--> (directory-files "~/workspace" t "^[^.]")
|
|
||||||
(remove-if-not #'(lambda (it)
|
|
||||||
(let ((default-directory it))
|
|
||||||
(-->
|
|
||||||
(shell-command-to-string "git remote get-url origin")
|
|
||||||
(string-trim it)
|
|
||||||
(member it repo-remotes))))
|
|
||||||
it)
|
|
||||||
(completing-read "Repo directory? " it))))
|
|
||||||
|
|
||||||
(defun lls/guess-build-dirs-fun (root-dir)
|
|
||||||
(lambda ()
|
|
||||||
(let ((build-dir (expand-file-name "build" root-dir)))
|
|
||||||
(when (file-exists-p build-dir)
|
|
||||||
(--> build-dir
|
|
||||||
(directory-files it t)
|
|
||||||
(remove-if-not #'(lambda (dir)
|
|
||||||
(file-exists-p
|
|
||||||
(expand-file-name "build.ninja" dir)))
|
|
||||||
it)
|
|
||||||
(sort it #'(lambda (x y)
|
|
||||||
(cond ((string-match-p "^Release$" (file-name-nondirectory y)) nil)
|
|
||||||
((string-match-p "^Release$" (file-name-nondirectory x)) t)
|
|
||||||
(t (string< x y))))))))))
|
|
||||||
|
|
||||||
(defun lls/cmake-here (directory build-type target)
|
|
||||||
(interactive
|
|
||||||
(list (expand-file-name "llvm"
|
|
||||||
(projectile-project-root))
|
|
||||||
(completing-read "Build Type? "
|
|
||||||
'("Release"
|
|
||||||
"Debug"
|
|
||||||
"RelWithDebInfo"))
|
|
||||||
(lls/conf-get 'target)))
|
|
||||||
(let* ((comm-temp
|
|
||||||
"cmake %s -G Ninja -DCMAKE_BUILD_TYPE='%s' -DLLVM_ENABLE_PROJECTS='clang;llvm' -DLLVM_TARGETS_TO_BUILD='%s' -DCMAKE_C_COMPILER='clang' -DCMAKE_CXX_COMPILER='clang++' -DLLVM_ENABLE_ASSERTIONS=On")
|
|
||||||
(command (read-string
|
|
||||||
"CMake Command? "
|
|
||||||
(format comm-temp directory build-type target))))
|
|
||||||
(compile command)))
|
|
||||||
|
|
||||||
(provide 'lib-comp-dev)
|
(provide 'lib-comp-dev)
|
||||||
;;; lib-comp-dev.el ends here
|
;;; lib-comp-dev.el ends here
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,14 @@
|
||||||
(list
|
(list
|
||||||
(string-join
|
(string-join
|
||||||
(list
|
(list
|
||||||
(lls/prompt-tool "clang$")
|
(comp-dev/prompt-tool "clang$")
|
||||||
file
|
file
|
||||||
"-target c29 -c -o"
|
"-target c29 -c -o"
|
||||||
temp-file)
|
temp-file)
|
||||||
" ")
|
" ")
|
||||||
(string-join
|
(string-join
|
||||||
(list
|
(list
|
||||||
(lls/prompt-tool "objdump$")
|
(comp-dev/prompt-tool "objdump$")
|
||||||
"-d"
|
"-d"
|
||||||
temp-file)
|
temp-file)
|
||||||
" "))
|
" "))
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@
|
||||||
(defun ll/ensure-clang-binary-built (dir)
|
(defun ll/ensure-clang-binary-built (dir)
|
||||||
;; TODO: assumed build-dir constant, should take as argument and prompt
|
;; TODO: assumed build-dir constant, should take as argument and prompt
|
||||||
;; further up
|
;; further up
|
||||||
(lls/run-build-command dir '("clang")))
|
(comp-dev/build-target dir '("clang")))
|
||||||
|
|
||||||
(defun ll/get-c-action-map ()
|
(defun ll/get-c-action-map ()
|
||||||
(append
|
(append
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
ll/c-file-action-map))
|
ll/c-file-action-map))
|
||||||
|
|
||||||
(defun ll/clang-output-disassemble-command (file)
|
(defun ll/clang-output-disassemble-command (file)
|
||||||
(let ((compiler (lls/prompt-tool "clang$"))
|
(let ((compiler (comp-dev/prompt-tool "clang$"))
|
||||||
(tmp-file (make-temp-file (file-name-sans-extension (file-name-nondirectory file)))))
|
(tmp-file (make-temp-file (file-name-sans-extension (file-name-nondirectory file)))))
|
||||||
(string-join
|
(string-join
|
||||||
(list (lls/get-clang-command-fun :compiler compiler
|
(list (lls/get-clang-command-fun :compiler compiler
|
||||||
|
|
@ -76,7 +76,7 @@
|
||||||
(let ((end (aml/get-map-prop
|
(let ((end (aml/get-map-prop
|
||||||
(ll/get-c-action-map)
|
(ll/get-c-action-map)
|
||||||
action :end-state))
|
action :end-state))
|
||||||
(compiler (lls/prompt-tool (comp-dev/tool-name (comp-dev/get-config) 'compiler))))
|
(compiler (comp-dev/prompt-tool (comp-dev/tool-name (comp-dev/get-config) 'compiler))))
|
||||||
(string-join
|
(string-join
|
||||||
(list
|
(list
|
||||||
(when (y-or-n-p "Would you like to `rr record`? ")
|
(when (y-or-n-p "Would you like to `rr record`? ")
|
||||||
|
|
@ -122,7 +122,7 @@
|
||||||
(call-interactively #'recompile)))))
|
(call-interactively #'recompile)))))
|
||||||
|
|
||||||
(defun ll/diff-on-optionset (file action)
|
(defun ll/diff-on-optionset (file action)
|
||||||
(let ((comm (ll/build-clang-command (lls/un-trampify file) action))
|
(let ((comm (ll/build-clang-command file action))
|
||||||
(extra-option (read-string "Extra option? "))
|
(extra-option (read-string "Extra option? "))
|
||||||
(pipe (if (y-or-n-p "Diff assembly (y) or debug (n)? ")
|
(pipe (if (y-or-n-p "Diff assembly (y) or debug (n)? ")
|
||||||
">" "2>")))
|
">" "2>")))
|
||||||
|
|
@ -134,8 +134,8 @@
|
||||||
(ediff-files "/tmp/no-option.asm" "/tmp/yes-option.asm")))
|
(ediff-files "/tmp/no-option.asm" "/tmp/yes-option.asm")))
|
||||||
|
|
||||||
(defun ll/diff-on-compiler (file action)
|
(defun ll/diff-on-compiler (file action)
|
||||||
(let ((comm (ll/build-clang-command (lls/un-trampify file) action))
|
(let ((comm (ll/build-clang-command file action))
|
||||||
(second-command (ll/build-clang-command (lls/un-trampify file) action))
|
(second-command (ll/build-clang-command file action))
|
||||||
(pipe (if (y-or-n-p "Diff assembly (y) or debug (n)? ")
|
(pipe (if (y-or-n-p "Diff assembly (y) or debug (n)? ")
|
||||||
">" "2>")))
|
">" "2>")))
|
||||||
(when (save-window-excursion
|
(when (save-window-excursion
|
||||||
|
|
@ -165,7 +165,7 @@
|
||||||
(t ".ll")))))
|
(t ".ll")))))
|
||||||
(if (eq action 'diff)
|
(if (eq action 'diff)
|
||||||
(ll/diff-c-on-two-compilations file action)
|
(ll/diff-c-on-two-compilations file action)
|
||||||
(let ((comm (ll/build-clang-command (lls/un-trampify file) action output)))
|
(let ((comm (ll/build-clang-command file action output)))
|
||||||
(aprog1
|
(aprog1
|
||||||
(compilation-start
|
(compilation-start
|
||||||
comm
|
comm
|
||||||
|
|
|
||||||
|
|
@ -28,17 +28,17 @@
|
||||||
(require 'make-tmp-output-file)
|
(require 'make-tmp-output-file)
|
||||||
|
|
||||||
(defvar ll/ll-file-action-map
|
(defvar ll/ll-file-action-map
|
||||||
'((assembly :key ?a :major-mode asm-mode :buffer-string "assembly" :description "[a]ssembly")
|
'((assembly :key ?a :major-mode asm-mode :end-state 'asm :buffer-string "assembly" :description "[a]ssembly")
|
||||||
(run-pass :key ?o :major-mode llvm-mode :buffer-string "run-%s" :description "run-[o]ne-pass")
|
(run-pass :key ?o :major-mode llvm-mode :end-state 'llvm-ir :buffer-string "run-%s" :description "run-[o]ne-pass")
|
||||||
(run-pass-diff :key ?d :major-mode llvm-mode :buffer-string "diff-%s" :description "[d]iff-one-pass")
|
(run-pass-diff :key ?d :major-mode llvm-mode :end-state 'llvm-ir :buffer-string "diff-%s" :description "[d]iff-one-pass")
|
||||||
(stop-after :key ?a :major-mode llvm-mode :buffer-string "stop-after-%s" :description "stop-[a]fter")
|
(stop-after :key ?a :major-mode llvm-mode :end-state 'llvm-ir :buffer-string "stop-after-%s" :description "stop-[a]fter")
|
||||||
(stop-before :key ?b :major-mode llvm-mode :buffer-string "stop-before-%s" :description "stop-[b]efore")
|
(stop-before :key ?b :major-mode llvm-mode :end-state 'llvm-ir :buffer-string "stop-before-%s" :description "stop-[b]efore")
|
||||||
(start-after :key ?A :major-mode llvm-mode :buffer-string "start-after-%s" :description "start-[A]fter")
|
(start-after :key ?A :major-mode llvm-mode :end-state 'llvm-ir :buffer-string "start-after-%s" :description "start-[A]fter")
|
||||||
(start-before :key ?B :major-mode llvm-mode :buffer-string "start-before-%s" :description "start-[B]efore")))
|
(start-before :key ?B :major-mode llvm-mode :end-state 'llvm-ir :buffer-string "start-before-%s" :description "start-[B]efore")))
|
||||||
|
|
||||||
(defun ll/build-llc-command (file action &optional output pass)
|
(defun ll/build-llc-command (file end-state &optional output pass)
|
||||||
(lls/get-llc-command-fun :file file :action action :output output :pass pass
|
(comp-dev/process-file
|
||||||
:llc (lls/prompt-tool "llc$")))
|
(comp-dev/get-config) 'llvm-ir end-state (comp-dev/prompt-tool "llc$") file output nil))
|
||||||
|
|
||||||
(defun ll/ll-file-diff-action (file action) )
|
(defun ll/ll-file-diff-action (file action) )
|
||||||
|
|
||||||
|
|
@ -57,7 +57,8 @@
|
||||||
(t ".mir")))))
|
(t ".mir")))))
|
||||||
(aprog1
|
(aprog1
|
||||||
(compilation-start
|
(compilation-start
|
||||||
(ll/build-llc-command file action output pass)
|
(ll/build-llc-command
|
||||||
|
file (aml/get-map-prop ll/ll-file-action-map action :end-state) output pass)
|
||||||
(aml/get-map-prop ll/ll-file-action-map action :major-mode)
|
(aml/get-map-prop ll/ll-file-action-map action :major-mode)
|
||||||
(lambda (_)
|
(lambda (_)
|
||||||
(format "*%s-%s*"
|
(format "*%s-%s*"
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
(defun ll/act-on-llvm-dump-file (fname)
|
(defun ll/act-on-llvm-dump-file (fname)
|
||||||
(let* ((action (aml/read-action-map ll/dump-file-action-map))
|
(let* ((action (aml/read-action-map ll/dump-file-action-map))
|
||||||
(command-flags (ll/dump-extract-command-flags (ll/dump-to-sh-file fname)))
|
(command-flags (ll/dump-extract-command-flags (ll/dump-to-sh-file fname)))
|
||||||
(clang (lls/prompt-tool "clang$")))
|
(clang (comp-dev/prompt-tool "clang$")))
|
||||||
(compilation-start
|
(compilation-start
|
||||||
(concat
|
(concat
|
||||||
(when (y-or-n-p "Would you like to `rr record`? ")
|
(when (y-or-n-p "Would you like to `rr record`? ")
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
(let ((dir (lls/get-llvm-build-dir)))
|
(let ((dir (lls/get-llvm-build-dir)))
|
||||||
(--> file
|
(--> file
|
||||||
(list (format "touch %s" it)
|
(list (format "touch %s" it)
|
||||||
(lls/run-build-command dir (list (concat it "^")) t))
|
(comp-dev/build-target dir (list (concat it "^")) t))
|
||||||
(string-join it " && ")
|
(string-join it " && ")
|
||||||
(compilation-start it nil
|
(compilation-start it nil
|
||||||
(lambda (_)
|
(lambda (_)
|
||||||
|
|
|
||||||
|
|
@ -33,14 +33,14 @@
|
||||||
(cons build-dir it)
|
(cons build-dir it)
|
||||||
(reverse it)
|
(reverse it)
|
||||||
(cons (file-name-directory file) it)
|
(cons (file-name-directory file) it)
|
||||||
(mapcar #'(lambda (x) (concat "-I" (lls/un-trampify x))) it)
|
(mapcar #'(lambda (x) (concat "-I" x)) it)
|
||||||
(string-join it " ")))
|
(string-join it " ")))
|
||||||
|
|
||||||
(defun ll-tblgen/gen-command (file flags output-file build-dir)
|
(defun ll-tblgen/gen-command (file flags output-file build-dir)
|
||||||
(let ((bin (car (lls/get-tool "llvm-tblgen$" (list (expand-file-name "bin" build-dir))))))
|
(let ((bin (car (comp-dev/prompt-tool "llvm-tblgen$" (list (expand-file-name "bin" build-dir))))))
|
||||||
(format "%s %s %s %s"
|
(format "%s %s %s %s"
|
||||||
bin
|
bin
|
||||||
(lls/un-trampify file)
|
file
|
||||||
(ll-tblgen/get-includes file build-dir)
|
(ll-tblgen/get-includes file build-dir)
|
||||||
(string-join
|
(string-join
|
||||||
(list
|
(list
|
||||||
|
|
@ -142,11 +142,11 @@
|
||||||
(setq comm (concat comm " --print-records")))
|
(setq comm (concat comm " --print-records")))
|
||||||
((eq action ?c)
|
((eq action ?c)
|
||||||
(setq comm (concat (format "mkdir -p %s"
|
(setq comm (concat (format "mkdir -p %s"
|
||||||
(lls/un-trampify (diredp-parent-dir out)))
|
(diredp-parent-dir out))
|
||||||
" && "
|
" && "
|
||||||
comm
|
comm
|
||||||
(format " -o %s"
|
(format " -o %s"
|
||||||
(lls/un-trampify out))))))
|
out)))))
|
||||||
|
|
||||||
(compilation-start
|
(compilation-start
|
||||||
comm
|
comm
|
||||||
|
|
|
||||||
|
|
@ -72,11 +72,11 @@
|
||||||
;; further up
|
;; further up
|
||||||
(let ((dir (lls/get-llvm-build-dir))
|
(let ((dir (lls/get-llvm-build-dir))
|
||||||
(tools (ll/get-required-binaries-for-test file)))
|
(tools (ll/get-required-binaries-for-test file)))
|
||||||
(lls/run-build-command dir tools)))
|
(comp-dev/build-target dir tools)))
|
||||||
|
|
||||||
(defun ll/build-lit-command (file action)
|
(defun ll/build-lit-command (file action)
|
||||||
(format "%s %s %s"
|
(format "%s %s %s"
|
||||||
(lls/prompt-tool "llvm-lit")
|
(comp-dev/prompt-tool "llvm-lit")
|
||||||
(pcase action
|
(pcase action
|
||||||
('verbose "-v")
|
('verbose "-v")
|
||||||
('all "-a")
|
('all "-a")
|
||||||
|
|
@ -121,7 +121,7 @@
|
||||||
(resolved
|
(resolved
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(or (gethash tool lookups)
|
(or (gethash tool lookups)
|
||||||
(aprog1 (lls/prompt-tool (concat tool "$"))
|
(aprog1 (comp-dev/prompt-tool (concat tool "$"))
|
||||||
(puthash tool it lookups))))))
|
(puthash tool it lookups))))))
|
||||||
(replace-match resolved nil nil res 1))))
|
(replace-match resolved nil nil res 1))))
|
||||||
it)
|
it)
|
||||||
|
|
@ -164,7 +164,7 @@
|
||||||
(when tools
|
(when tools
|
||||||
(-->
|
(-->
|
||||||
;; TODO: Assuming debug folder, (lls/get-llvm-build-dir) doesn't work
|
;; TODO: Assuming debug folder, (lls/get-llvm-build-dir) doesn't work
|
||||||
(lls/run-build-command "/scratch/benson/tools3/llvm_cgt/build/Debug/llvm" (seq-uniq tools))
|
(comp-dev/build-target "/scratch/benson/tools3/llvm_cgt/build/Debug/llvm" (seq-uniq tools))
|
||||||
(compilation-start
|
(compilation-start
|
||||||
it
|
it
|
||||||
nil
|
nil
|
||||||
|
|
|
||||||
|
|
@ -46,24 +46,24 @@
|
||||||
(let ((file (or (buffer-file-name)
|
(let ((file (or (buffer-file-name)
|
||||||
(aprog1 (make-temp-file nil nil ".ll")
|
(aprog1 (make-temp-file nil nil ".ll")
|
||||||
(write-file it)))))
|
(write-file it)))))
|
||||||
(when-let ((vec (lls/tramp-connection))
|
;; (when-let ((vec (lls/tramp-connection))
|
||||||
((not (file-remote-p file))))
|
;; ((not (file-remote-p file))))
|
||||||
;; If there's a cache entry, and the cache timestamp matches,
|
;; ;; If there's a cache entry, and the cache timestamp matches,
|
||||||
;; then we just reuse the file
|
;; ;; then we just reuse the file
|
||||||
(-->
|
;; (-->
|
||||||
(if-let* ((cache (gethash file ll/buffer-map))
|
;; (if-let* ((cache (gethash file ll/buffer-map))
|
||||||
(time (visited-file-modtime))
|
;; (time (visited-file-modtime))
|
||||||
((equal time (car cache))))
|
;; ((equal time (car cache))))
|
||||||
(cdr cache)
|
;; (cdr cache)
|
||||||
;; Otherwise, generate a new tmp file, copy that over, and
|
;; ;; Otherwise, generate a new tmp file, copy that over, and
|
||||||
;; update the cache.
|
;; ;; update the cache.
|
||||||
(let ((tmp (concat (tramp-make-tramp-temp-name vec)
|
;; (let ((tmp (concat (tramp-make-tramp-temp-name vec)
|
||||||
"." (file-name-extension file))))
|
;; "." (file-name-extension file))))
|
||||||
(puthash file (cons time tmp) ll/buffer-map)
|
;; (puthash file (cons time tmp) ll/buffer-map)
|
||||||
(copy-file file tmp)
|
;; (copy-file file tmp)
|
||||||
tmp))
|
;; tmp))
|
||||||
(setq file it)))
|
;; (setq file it)))
|
||||||
;; Let further compilation-commands be run over tramp
|
;; ;; Let further compilation-commands be run over tramp
|
||||||
(let ((default-directory (file-name-directory file)))
|
(let ((default-directory (file-name-directory file)))
|
||||||
(pcase (file-name-extension file)
|
(pcase (file-name-extension file)
|
||||||
((and _ (guard (ll/is-test-file file)))
|
((and _ (guard (ll/is-test-file file)))
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@
|
||||||
(compilation-start (-->
|
(compilation-start (-->
|
||||||
(list
|
(list
|
||||||
(format "touch %s" file)
|
(format "touch %s" file)
|
||||||
(lls/run-build-command
|
(comp-dev/build-target
|
||||||
build-dir (list (format "%s^" file)) t))
|
build-dir (list (format "%s^" file)) t))
|
||||||
(string-join it " && "))
|
(string-join it " && "))
|
||||||
nil
|
nil
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
;; "llc")))))
|
;; "llc")))))
|
||||||
;; (let* ((buffer-name (funcall lls/name-llvm-build-buffer directory tools)))
|
;; (let* ((buffer-name (funcall lls/name-llvm-build-buffer directory tools)))
|
||||||
;; (compilation-start
|
;; (compilation-start
|
||||||
;; (lls/run-build-command (lls/un-trampify directory) tools)
|
;; (comp-dev/build-target directory tools)
|
||||||
;; nil
|
;; nil
|
||||||
;; (lambda (_) buffer-name))))
|
;; (lambda (_) buffer-name))))
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
"llc")))))
|
"llc")))))
|
||||||
(name (funcall lls/name-llvm-build-buffer directory tools))
|
(name (funcall lls/name-llvm-build-buffer directory tools))
|
||||||
|
|
||||||
(lls/run-build-command (lls/un-trampify directory) tools))
|
(comp-dev/build-target directory tools))
|
||||||
|
|
||||||
(provide 'llvm-build-tool)
|
(provide 'llvm-build-tool)
|
||||||
;;; llvm-build-tool.el ends here
|
;;; llvm-build-tool.el ends here
|
||||||
|
|
|
||||||
238
lisp/llvm-lib/llvm-comp-dev.el
Normal file
238
lisp/llvm-lib/llvm-comp-dev.el
Normal file
|
|
@ -0,0 +1,238 @@
|
||||||
|
;;; llvm-comp-dev.el --- -*- lexical-binding: t -*-
|
||||||
|
|
||||||
|
;; Copyright (C) 2026 Benson Chu
|
||||||
|
|
||||||
|
;; Author: Benson Chu <bensonchu457@gmail.com>
|
||||||
|
;; Created: [2026-04-04 15:16]
|
||||||
|
|
||||||
|
;; This file is not part of GNU Emacs
|
||||||
|
|
||||||
|
;; This program is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
(require 'lib-comp-dev)
|
||||||
|
(require 'load-llvm-mode)
|
||||||
|
(require 'clang-command)
|
||||||
|
|
||||||
|
(defclass llvm-comp-dev-config (comp-dev-config)
|
||||||
|
nil)
|
||||||
|
|
||||||
|
(cl-defgeneric comp-dev/tool-name ((config llvm-comp-dev-config) tool)
|
||||||
|
(pcase tool
|
||||||
|
('compiler "clang$")))
|
||||||
|
|
||||||
|
(defun lls/guess-root-dir-fun ()
|
||||||
|
(if (-->
|
||||||
|
(shell-command-to-string "git remote get-url origin")
|
||||||
|
(string-trim it)
|
||||||
|
(string-match-p ".*llvm.*" it))
|
||||||
|
(projectile-project-root)
|
||||||
|
(--> (directory-files "~/workspace" t "^[^.]")
|
||||||
|
(remove-if-not #'(lambda (it)
|
||||||
|
(let ((default-directory it))
|
||||||
|
(-->
|
||||||
|
(shell-command-to-string "git remote get-url origin")
|
||||||
|
(string-trim it)
|
||||||
|
(member it repo-remotes))))
|
||||||
|
it)
|
||||||
|
(completing-read "Repo directory? " it))))
|
||||||
|
|
||||||
|
(defun llvm/default-target-init ()
|
||||||
|
(interactive)
|
||||||
|
(let ((root-dir (lls/guess-root-dir-fun))
|
||||||
|
tramp-conn)
|
||||||
|
(when (tramp-tramp-file-p root-dir)
|
||||||
|
(with-parsed-tramp-file-name root-dir nil
|
||||||
|
(setf tramp-conn v)))
|
||||||
|
(load-llvm-mode root-dir)
|
||||||
|
(make-instance
|
||||||
|
'llvm-comp-dev-config
|
||||||
|
:root-dir root-dir
|
||||||
|
:target (completing-read "Which target? " '("X86" "ARM" "Hexagon" "AIE" "RISCV"))
|
||||||
|
|
||||||
|
;; :tramp tramp-conn
|
||||||
|
;; :build-dirs-fun (lls/guess-build-dirs-fun root-dir)
|
||||||
|
;; :cc #'lls/default-comp-fun
|
||||||
|
;; :dc #'lls/default-dis-comm
|
||||||
|
;; :llc #'lls/default-llc-comm
|
||||||
|
;; :clang-opts-fun #'cc/get-clang-options
|
||||||
|
)))
|
||||||
|
|
||||||
|
(add-to-list 'comp-dev/init-functions
|
||||||
|
'llvm/default-target-init)
|
||||||
|
|
||||||
|
(defun lls/llvm-build-dirs (root-dir)
|
||||||
|
(let ((build-dir (expand-file-name "build" root-dir)))
|
||||||
|
(when (file-exists-p build-dir)
|
||||||
|
(--> build-dir
|
||||||
|
(directory-files it t)
|
||||||
|
(remove-if-not #'(lambda (dir)
|
||||||
|
(file-exists-p
|
||||||
|
(expand-file-name "build.ninja" dir)))
|
||||||
|
it)
|
||||||
|
(sort it #'(lambda (x y)
|
||||||
|
(cond ((string-match-p "^Release$" (file-name-nondirectory y)) nil)
|
||||||
|
((string-match-p "^Release$" (file-name-nondirectory x)) t)
|
||||||
|
(t (string< x y)))))))))
|
||||||
|
|
||||||
|
(defun lls/llvm-bin-dirs (root-dir)
|
||||||
|
(mapcar #'(lambda (dir)
|
||||||
|
(expand-file-name "bin" dir))
|
||||||
|
(lls/llvm-build-dirs root-dir)))
|
||||||
|
|
||||||
|
(cl-defmethod comp-dev/get-bin-dirs ((config llvm-comp-dev-config))
|
||||||
|
(cons
|
||||||
|
"/usr/bin/"
|
||||||
|
(lls/llvm-bin-dirs (comp-dev/conf-get 'root-dir))))
|
||||||
|
|
||||||
|
(cl-defmethod comp-dev/get-file-types ((config llvm-comp-dev-config))
|
||||||
|
'(c pp-c llvm-ir asm obj exe))
|
||||||
|
|
||||||
|
(cl-defmethod comp-dev/get-c-action-table ((config llvm-comp-dev-config))
|
||||||
|
'((assembly :key ?a :major-mode asm-mode :buffer-string "assembly" :description "[a]ssembly" :end-state asm)
|
||||||
|
(debug :key ?d :major-mode llvm-mode :buffer-string "debug" :description "[d]ebug pass" :end-state asm)
|
||||||
|
(LLVMIR :key ?l :major-mode llvm-mode :buffer-string "llvm-ir" :description "[l]lvm-ir" :end-state llvm-ir)
|
||||||
|
(before-after :key ?p :major-mode llvm-mode :buffer-string "print-before-after" :description "[p]rint before/after" :end-state asm)
|
||||||
|
(changed :key ?P :major-mode llvm-mode :buffer-string "print-changed" :description "[P]rint before/after all" :end-state asm)))
|
||||||
|
|
||||||
|
(cl-defmethod comp-dev/tool-name ((config llvm-comp-dev-config) type)
|
||||||
|
(pcase type
|
||||||
|
('compiler "clang")))
|
||||||
|
|
||||||
|
;; (output-dis :key ?A :major-mode asm-mode :buffer-string "dissasembly" :description "output-dis[A]ssemble" :end-state nil)
|
||||||
|
|
||||||
|
(cl-defmethod comp-dev/process-file ((config llvm-comp-dev-config) start-type end-type tool file output flags)
|
||||||
|
(pcase start-type
|
||||||
|
('c
|
||||||
|
(-->
|
||||||
|
(list tool
|
||||||
|
(clang/get-clang-options)
|
||||||
|
file
|
||||||
|
flags
|
||||||
|
(pcase end-type
|
||||||
|
('pp-c "-E")
|
||||||
|
('llvm-ir "-S -emit-llvm")
|
||||||
|
('asm "-S")
|
||||||
|
('obj "-c")
|
||||||
|
('exe (error "unimplemented")))
|
||||||
|
"-o -"
|
||||||
|
(or (and output
|
||||||
|
(format "| tee %s" output))
|
||||||
|
""))
|
||||||
|
(flatten-list it)
|
||||||
|
(string-join it " ")))
|
||||||
|
('llvm-ir
|
||||||
|
(-->
|
||||||
|
(list tool file "-o -")
|
||||||
|
(string-join it " ")))))
|
||||||
|
|
||||||
|
(defun lls/get-llvm-root-dir ()
|
||||||
|
(comp-dev/ensure-initialized)
|
||||||
|
(comp-dev/conf-get 'root-dir))
|
||||||
|
|
||||||
|
(defun lls/get-llvm-build-dirs ()
|
||||||
|
(comp-dev/ensure-initialized)
|
||||||
|
(funcall (comp-dev/conf-get 'build-dirs-fun)))
|
||||||
|
|
||||||
|
(defun lls/get-llvm-bin-dir ()
|
||||||
|
(car (lls/get-llvm-bin-dirs)))
|
||||||
|
|
||||||
|
(defun lls/get-llvm-bin-dirs ()
|
||||||
|
(comp-dev/ensure-initialized)
|
||||||
|
(append (mapcar #'(lambda (x) (expand-file-name "bin" x))
|
||||||
|
(lls/get-llvm-build-dirs))
|
||||||
|
(funcall (comp-dev/conf-get 'bin-dirs-fun))))
|
||||||
|
|
||||||
|
(defun lls/prompt-llvm-build-dir ()
|
||||||
|
(completing-read "Which directory? " (lls/get-llvm-build-dirs)))
|
||||||
|
|
||||||
|
(defun lls/get-llvm-build-dir ()
|
||||||
|
(car (lls/get-llvm-build-dirs)))
|
||||||
|
|
||||||
|
(defun lls/add-llvm-build-dir (dir)
|
||||||
|
(interactive
|
||||||
|
(list (read-file-name "Where? ")))
|
||||||
|
(comp-dev/ensure-initialized)
|
||||||
|
(comp-dev/conf-set 'build-dirs
|
||||||
|
(cons dir
|
||||||
|
(comp-dev/conf-get 'build-dirs))))
|
||||||
|
|
||||||
|
(defun lls/get-clang-command-fun (&rest args)
|
||||||
|
(apply (comp-dev/conf-get 'compile-command-fun)
|
||||||
|
args))
|
||||||
|
|
||||||
|
(defun lls/get-llc-command-fun (&rest args)
|
||||||
|
(apply (comp-dev/conf-get 'llc-command-fun) args))
|
||||||
|
|
||||||
|
(defun lls/get-dis-command-fun (&rest args)
|
||||||
|
(apply (comp-dev/conf-get 'dis-command-fun) args))
|
||||||
|
|
||||||
|
;; ========================= LLVM Build Dirs =========================
|
||||||
|
(defun ll/read-pass ()
|
||||||
|
(completing-read "Which pass? "
|
||||||
|
'("finalize-isel"
|
||||||
|
"machine-scheduler"
|
||||||
|
"greedy")))
|
||||||
|
|
||||||
|
(cl-defun lls/default-llc-comm (&key llc file action output pass)
|
||||||
|
(let ((llc (or llc "llc")))
|
||||||
|
(concat
|
||||||
|
(cond
|
||||||
|
((member action '(run-pass stop-before stop-after start-before start-after))
|
||||||
|
(format "%s %s -o - -%s=%s"
|
||||||
|
llc file (symbol-name action) pass))
|
||||||
|
(t
|
||||||
|
(read-string
|
||||||
|
"llc invocation: "
|
||||||
|
(string-join
|
||||||
|
(list
|
||||||
|
llc
|
||||||
|
file
|
||||||
|
"-o -")
|
||||||
|
" "))))
|
||||||
|
(or (and output
|
||||||
|
(format " | tee %s" output))
|
||||||
|
""))))
|
||||||
|
|
||||||
|
(defun lls/default-dis-comm (file _action)
|
||||||
|
(concat "llvm-objdump --disassemble "
|
||||||
|
file " "))
|
||||||
|
|
||||||
|
(defun lls/lldb (binary)
|
||||||
|
(interactive
|
||||||
|
(list (comp-dev/prompt-tool (rx (or "clang" "llc") line-end))))
|
||||||
|
(realgud--lldb
|
||||||
|
(format "lldb %s"
|
||||||
|
binary)))
|
||||||
|
|
||||||
|
(defun lls/cmake-here (directory build-type target)
|
||||||
|
(interactive
|
||||||
|
(list (expand-file-name "llvm"
|
||||||
|
(projectile-project-root))
|
||||||
|
(completing-read "Build Type? "
|
||||||
|
'("Release"
|
||||||
|
"Debug"
|
||||||
|
"RelWithDebInfo"))
|
||||||
|
(comp-dev/conf-get 'target)))
|
||||||
|
(let* ((comm-temp
|
||||||
|
"cmake %s -G Ninja -DCMAKE_BUILD_TYPE='%s' -DLLVM_ENABLE_PROJECTS='clang;llvm' -DLLVM_TARGETS_TO_BUILD='%s' -DCMAKE_C_COMPILER='clang' -DCMAKE_CXX_COMPILER='clang++' -DLLVM_ENABLE_ASSERTIONS=On")
|
||||||
|
(command (read-string
|
||||||
|
"CMake Command? "
|
||||||
|
(format comm-temp directory build-type target))))
|
||||||
|
(compile command)))
|
||||||
|
|
||||||
|
(provide 'llvm-comp-dev)
|
||||||
|
;;; llvm-comp-dev.el ends here
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
(interactive)
|
(interactive)
|
||||||
(let* ((buf (current-buffer))
|
(let* ((buf (current-buffer))
|
||||||
(fname (buffer-file-name buf))
|
(fname (buffer-file-name buf))
|
||||||
(clang (lls/prompt-tool "clang$"))
|
(clang (comp-dev/prompt-tool "clang$"))
|
||||||
(command
|
(command
|
||||||
(with-current-buffer buf
|
(with-current-buffer buf
|
||||||
(cond ((or compilation-minor-mode
|
(cond ((or compilation-minor-mode
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,8 @@
|
||||||
(require 'llvm-gdb-command)
|
(require 'llvm-gdb-command)
|
||||||
(require 'llvm-show-instr-info)
|
(require 'llvm-show-instr-info)
|
||||||
(require 'llvm-jump-to-tablegen)
|
(require 'llvm-jump-to-tablegen)
|
||||||
(require 'lib-comp-dev)
|
|
||||||
|
(require 'llvm-comp-dev)
|
||||||
|
|
||||||
(define-prefix-command '*llvm-map*)
|
(define-prefix-command '*llvm-map*)
|
||||||
(define-key *root-map* (kbd "C-w") '*llvm-map*)
|
(define-key *root-map* (kbd "C-w") '*llvm-map*)
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
(defun load-llvm-mode (root-dir)
|
(defun load-llvm-mode (root-dir)
|
||||||
(interactive (list (lls/conf-get 'root-dir)))
|
(interactive (list (comp-dev/conf-get 'root-dir)))
|
||||||
(when (not (require 'my-tablegen-mode nil t))
|
(when (not (require 'my-tablegen-mode nil t))
|
||||||
(load-file (expand-file-name "llvm/utils/emacs/tablegen-mode.el" root-dir)))
|
(load-file (expand-file-name "llvm/utils/emacs/tablegen-mode.el" root-dir)))
|
||||||
(define-key tablegen-mode-map (kbd "M-s") nil)
|
(define-key tablegen-mode-map (kbd "M-s") nil)
|
||||||
|
|
|
||||||
|
|
@ -25,29 +25,29 @@
|
||||||
;;; Code:
|
;;; Code:
|
||||||
(require 'clang-command)
|
(require 'clang-command)
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "ARM" cortex-r4-soft-float
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "ARM" cortex-r4-soft-float
|
||||||
:target "-target arm -mcpu=cortex-r4 -mfpu=none -mfloat-abi=soft -mlittle-endian")
|
:target "-target arm -mcpu=cortex-r4 -mfpu=none -mfloat-abi=soft -mlittle-endian")
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "ARM" cortex-hard-float
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "ARM" cortex-hard-float
|
||||||
:target "-target arm -mcpu=cortex-r4 -mfpu=vfpv3-d16 -mfloat-abi=hard -mlittle-endian")
|
:target "-target arm -mcpu=cortex-r4 -mfpu=vfpv3-d16 -mfloat-abi=hard -mlittle-endian")
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "ARM" cortex-hard-float-tmu
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "ARM" cortex-hard-float-tmu
|
||||||
:target "-target arm -mcpu=cortex-r4 -mfpu=vfpv3-d16 -mfloat-abi=hard -mlittle-endian")
|
:target "-target arm -mcpu=cortex-r4 -mfpu=vfpv3-d16 -mfloat-abi=hard -mlittle-endian")
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "ARM" cortex-m0
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "ARM" cortex-m0
|
||||||
:target "-target arm -mcpu=cortex-m0 -mlittle-endian -mthumb")
|
:target "-target arm -mcpu=cortex-m0 -mlittle-endian -mthumb")
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "ARM" cortex-m4
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "ARM" cortex-m4
|
||||||
:target "-target arm -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
|
:target "-target arm -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16")
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "ARM" cortex-m33
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "ARM" cortex-m33
|
||||||
:target "-target arm -mcpu=cortex-m33 -mfpu=vfpv3-d16 -mfloat-abi=hard -mlittle-endian")
|
:target "-target arm -mcpu=cortex-m33 -mfpu=vfpv3-d16 -mfloat-abi=hard -mlittle-endian")
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "RISCV" rv32im
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "RISCV" rv32im
|
||||||
:target "-target riscv32-unknown-elf -march=rv32im -mabi=ilp32"
|
:target "-target riscv32-unknown-elf -march=rv32im -mabi=ilp32"
|
||||||
:optimization "-O3")
|
:optimization "-O3")
|
||||||
|
|
||||||
(register-prebaked-optionset clang-subtargets "RISCV" rv32imafc
|
(register-prebaked-optionset clang-subtargets 'clang-option-config "RISCV" rv32imafc
|
||||||
:target "-target riscv32-unknown-elf -march=rv32imafc -mabi=ilp32f -mno-relax"
|
:target "-target riscv32-unknown-elf -march=rv32imafc -mabi=ilp32f -mno-relax"
|
||||||
:optimization "-O3")
|
:optimization "-O3")
|
||||||
|
|
||||||
|
|
|
||||||
45
lisp/org-config/my-org-date-refile.el
Normal file
45
lisp/org-config/my-org-date-refile.el
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
;;; my-org-date-refile.el --- -*- lexical-binding: t -*-
|
||||||
|
|
||||||
|
;; Copyright (C) 2025 Benson Chu
|
||||||
|
|
||||||
|
;; Author: Benson Chu <bensonchu457@gmail.com>
|
||||||
|
;; Created: [2025-09-08 15:51]
|
||||||
|
|
||||||
|
;; This file is not part of GNU Emacs
|
||||||
|
|
||||||
|
;; This program is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
(require 'org)
|
||||||
|
|
||||||
|
;; (format-time-string "%d" (org-read-date t t))
|
||||||
|
|
||||||
|
(defun modr/parse-timestamp (string)
|
||||||
|
(org-read-date t t string))
|
||||||
|
|
||||||
|
(defun modr/create-single-datetree (subtree-marker modr)
|
||||||
|
(with-current-buffer (marker-buffer subtree-marker)
|
||||||
|
(save-excursion
|
||||||
|
(goto-char (marker-position subtree-marker))
|
||||||
|
(save-restriction
|
||||||
|
(org-narrow-to-subtree)
|
||||||
|
(if (re-search-forward (rx "** "
|
||||||
|
(literal
|
||||||
|
(format-time-string "%b %d, %Y" modr))))
|
||||||
|
(point))))))
|
||||||
|
|
||||||
|
(provide 'my-org-date-refile)
|
||||||
|
;;; my-org-date-refile.el ends here
|
||||||
47
lisp/org-config/org-create-hierarchy.el
Normal file
47
lisp/org-config/org-create-hierarchy.el
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
;;; org-create-hierarchy.el --- -*- lexical-binding: t -*-
|
||||||
|
|
||||||
|
;; Copyright (C) 2025 Benson Chu
|
||||||
|
|
||||||
|
;; Author: Benson Chu <bensonchu457@gmail.com>
|
||||||
|
;; Created: [2025-12-26 10:33]
|
||||||
|
|
||||||
|
;; This file is not part of GNU Emacs
|
||||||
|
|
||||||
|
;; This program is free software: you can redistribute it and/or modify
|
||||||
|
;; it under the terms of the GNU General Public License as published by
|
||||||
|
;; the Free Software Foundation, either version 3 of the License, or
|
||||||
|
;; (at your option) any later version.
|
||||||
|
|
||||||
|
;; This program is distributed in the hope that it will be useful,
|
||||||
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
;; GNU General Public License for more details.
|
||||||
|
|
||||||
|
;; You should have received a copy of the GNU General Public License
|
||||||
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
;;; Commentary:
|
||||||
|
|
||||||
|
;;; Code:
|
||||||
|
|
||||||
|
(defun org-create-hierarchy (time format-strings &optional depth reverse)
|
||||||
|
(cl-labels ((create-hierarchy (time format-strings depth)
|
||||||
|
(when-let* ((fmt (car format-strings))
|
||||||
|
(timestr (format-time-string fmt time)))
|
||||||
|
(let ((str (concat (make-string depth ?*) " " timestr)))
|
||||||
|
(or (prog1 (search-forward str nil t)
|
||||||
|
(end-of-line))
|
||||||
|
(progn
|
||||||
|
(unless reverse
|
||||||
|
(when (org-get-next-sibling)
|
||||||
|
(previous-line)
|
||||||
|
(end-of-line)))
|
||||||
|
(insert "\n" str)))
|
||||||
|
(create-hierarchy time (cdr format-strings) (1+ depth))))))
|
||||||
|
(goto-char (point-min))
|
||||||
|
(create-hierarchy time format-strings (or depth 1))))
|
||||||
|
|
||||||
|
;; (org-create-hierarchy (current-time) '("%Y" "%B"))
|
||||||
|
|
||||||
|
(provide 'org-create-hierarchy)
|
||||||
|
;;; org-create-hierarchy.el ends here
|
||||||
|
|
@ -27,15 +27,15 @@
|
||||||
|
|
||||||
(deftheme dark-default)
|
(deftheme dark-default)
|
||||||
|
|
||||||
|
(let* ((rainbow-purple "#9E1CB2")
|
||||||
(let ((rainbow-purple "#9E1CB2")
|
(rainbow-green "#47B04B")
|
||||||
(rainbow-green "#47B04B")
|
(rainbow-red "#C90067")
|
||||||
(rainbow-blue "#1194f6")
|
(rainbow-blue "#1194f6")
|
||||||
(rainbow-red "#C90067")
|
(rainbow-yellow "#FFED18")
|
||||||
(rainbow-yellow "#FFED18")
|
(rainbow-white "#FFFFFF")
|
||||||
(rainbow-orange "#E7B500")
|
(rainbow-pink "#FE7380")
|
||||||
(rainbow-7 "#00AA5D")
|
(rainbow-cyan "Cyan")
|
||||||
(rainbow-8 "#FE7380"))
|
(rainbow-orange "#E7B500"))
|
||||||
(custom-theme-set-faces
|
(custom-theme-set-faces
|
||||||
'dark-default
|
'dark-default
|
||||||
|
|
||||||
|
|
@ -56,7 +56,7 @@
|
||||||
`(rainbow-delimiters-depth-5-face ((t :foreground ,rainbow-yellow)))
|
`(rainbow-delimiters-depth-5-face ((t :foreground ,rainbow-yellow)))
|
||||||
`(rainbow-delimiters-depth-6-face ((t :foreground ,rainbow-blue)))
|
`(rainbow-delimiters-depth-6-face ((t :foreground ,rainbow-blue)))
|
||||||
`(rainbow-delimiters-depth-7-face ((t :foreground ,rainbow-red)))
|
`(rainbow-delimiters-depth-7-face ((t :foreground ,rainbow-red)))
|
||||||
`(rainbow-delimiters-depth-8-face ((t :foreground ,rainbow-8)))
|
`(rainbow-delimiters-depth-8-face ((t :foreground ,rainbow-pink)))
|
||||||
|
|
||||||
;; '(vertico-current ((t :foreground "black" :background "#65a7e2")))
|
;; '(vertico-current ((t :foreground "black" :background "#65a7e2")))
|
||||||
'(vertico-current ((t :background "gray30")))
|
'(vertico-current ((t :background "gray30")))
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,14 @@
|
||||||
|
|
||||||
(custom-theme-set-faces
|
(custom-theme-set-faces
|
||||||
'same-defaults
|
'same-defaults
|
||||||
`(default ((t (:family "Roboto Mono" :height ,my/fixed-pitch-height
|
`(default ((t (:family "Commit Mono" :height ,my/fixed-pitch-height
|
||||||
))))
|
))))
|
||||||
`(fixed-pitch ((t (:family "Roboto Mono" :height ,my/fixed-pitch-height
|
`(fixed-pitch ((t (:family "Commit Mono" :height ,my/fixed-pitch-height
|
||||||
))))
|
))))
|
||||||
`(variable-pitch ((t (:family "Linux Libertine" :height ,my/variable-pitch-height
|
`(variable-pitch ((t (:family "Linux Libertine" :height ,my/variable-pitch-height
|
||||||
))))
|
))))
|
||||||
`(mode-line ((t (:family "Roboto Mono" :height ,my/fixed-pitch-height))))
|
`(mode-line ((t (:family "Commit Mono" :height ,my/fixed-pitch-height))))
|
||||||
`(mode-line-inactive ((t (:family "Roboto Mono" :height ,my/fixed-pitch-height))))
|
`(mode-line-inactive ((t (:family "Commit Mono" :height ,my/fixed-pitch-height))))
|
||||||
`(tab-bar-tab ((t (:box (:line-width 2 :color "gray6")))))
|
`(tab-bar-tab ((t (:box (:line-width 2 :color "gray6")))))
|
||||||
;; '(org-todo ((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t :inherit fixed-pitch))
|
;; '(org-todo ((((class color) (min-colors 16) (background light)) (:foreground "Red1" :bold t :inherit fixed-pitch))
|
||||||
;; (((class color) (min-colors 16) (background dark)) (:foreground "Pink" :bold t :inherit fixed-pitch))
|
;; (((class color) (min-colors 16) (background dark)) (:foreground "Pink" :bold t :inherit fixed-pitch))
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 5e5d4984816ace917f78190e04936b038c43365b
|
Subproject commit 034ae31a6faa5c70b22d647c63f495b63d4bcee7
|
||||||
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit e978a58400f6c5ebc9de13f52dd5d13e1d7820e6
|
|
||||||
Loading…
Reference in a new issue