mirror of
https://github.com/pestctrl/emacs-config.git
synced 2026-06-14 12:21:20 +00:00
Fixup home stuff
This commit is contained in:
parent
769bd39690
commit
d7192e0ac9
6 changed files with 62 additions and 52 deletions
|
|
@ -34,10 +34,10 @@
|
||||||
(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))
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
target-options lang-options
|
target-options lang-options
|
||||||
other-options optimization-level
|
other-options optimization-level
|
||||||
include-dirs)
|
include-dirs)
|
||||||
opts
|
config
|
||||||
(-->
|
(-->
|
||||||
(list
|
(list
|
||||||
(or binary-path "")
|
(or binary-path "")
|
||||||
|
|
|
||||||
|
|
@ -158,7 +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 comp-dev/prompt-tool (tool-regexp &optional directories)
|
(defun comp-dev/get-tools (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)
|
||||||
|
|
@ -171,7 +171,7 @@
|
||||||
(let (;;(vertico-sort-function nil)
|
(let (;;(vertico-sort-function nil)
|
||||||
)
|
)
|
||||||
(my/completing-read tool-regexp
|
(my/completing-read tool-regexp
|
||||||
(comp-dev/prompt-tool tool-regexp
|
(comp-dev/get-tools tool-regexp
|
||||||
(or (and (eq 'string (type-of directories))
|
(or (and (eq 'string (type-of directories))
|
||||||
(list directories)))))))
|
(list directories)))))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 (comp-dev/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*"
|
||||||
|
|
|
||||||
|
|
@ -62,8 +62,8 @@
|
||||||
'llvm-comp-dev-config
|
'llvm-comp-dev-config
|
||||||
:root-dir root-dir
|
:root-dir root-dir
|
||||||
:target (completing-read "Which target? " '("X86" "ARM" "Hexagon" "AIE" "RISCV"))
|
:target (completing-read "Which target? " '("X86" "ARM" "Hexagon" "AIE" "RISCV"))
|
||||||
:tramp tramp-conn
|
|
||||||
|
|
||||||
|
;; :tramp tramp-conn
|
||||||
;; :build-dirs-fun (lls/guess-build-dirs-fun root-dir)
|
;; :build-dirs-fun (lls/guess-build-dirs-fun root-dir)
|
||||||
;; :cc #'lls/default-comp-fun
|
;; :cc #'lls/default-comp-fun
|
||||||
;; :dc #'lls/default-dis-comm
|
;; :dc #'lls/default-dis-comm
|
||||||
|
|
@ -74,9 +74,29 @@
|
||||||
(add-to-list 'comp-dev/init-functions
|
(add-to-list 'comp-dev/init-functions
|
||||||
'llvm/default-target-init)
|
'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))
|
(cl-defmethod comp-dev/get-bin-dirs ((config llvm-comp-dev-config))
|
||||||
(list
|
(cons
|
||||||
"/usr/bin/"))
|
"/usr/bin/"
|
||||||
|
(lls/llvm-bin-dirs (comp-dev/conf-get 'root-dir))))
|
||||||
|
|
||||||
(cl-defmethod comp-dev/get-file-types ((config llvm-comp-dev-config))
|
(cl-defmethod comp-dev/get-file-types ((config llvm-comp-dev-config))
|
||||||
'(c pp-c llvm-ir asm obj exe))
|
'(c pp-c llvm-ir asm obj exe))
|
||||||
|
|
@ -86,35 +106,39 @@
|
||||||
(debug :key ?d :major-mode llvm-mode :buffer-string "debug" :description "[d]ebug pass" :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)
|
(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)
|
(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)
|
(changed :key ?P :major-mode llvm-mode :buffer-string "print-changed" :description "[P]rint before/after all" :end-state asm)))
|
||||||
(assembly :key ?a :major-mode asm-mode :buffer-string "assembly" :description "[a]ssembly" :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)
|
;; (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 compiler file output flags)
|
(cl-defmethod comp-dev/process-file ((config llvm-comp-dev-config) start-type end-type tool file output flags)
|
||||||
(pcase start
|
(pcase start-type
|
||||||
('c
|
('c
|
||||||
(-->
|
(-->
|
||||||
(list compiler
|
(list tool
|
||||||
(clang/get-clang-options)
|
(clang/get-clang-options)
|
||||||
(string-join rest " ")
|
|
||||||
file
|
file
|
||||||
|
flags
|
||||||
(pcase end-type
|
(pcase end-type
|
||||||
('pp-c "-E")
|
('pp-c "-E")
|
||||||
('llvm-ir "-S -emit-llvm")
|
('llvm-ir "-S -emit-llvm")
|
||||||
('asm "-S")
|
('asm "-S")
|
||||||
('obj "-c")
|
('obj "-c")
|
||||||
('exe (error "unimplemented")))
|
('exe (error "unimplemented")))
|
||||||
flags
|
|
||||||
"-o -"
|
"-o -"
|
||||||
(or (and output
|
(or (and output
|
||||||
(format "| tee %s" output))
|
(format "| tee %s" output))
|
||||||
""))
|
""))
|
||||||
(flatten-list it)
|
(flatten-list it)
|
||||||
|
(string-join it " ")))
|
||||||
|
('llvm-ir
|
||||||
|
(-->
|
||||||
|
(list tool file "-o -")
|
||||||
(string-join it " ")))))
|
(string-join it " ")))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defun lls/get-llvm-root-dir ()
|
(defun lls/get-llvm-root-dir ()
|
||||||
(comp-dev/ensure-initialized)
|
(comp-dev/ensure-initialized)
|
||||||
(comp-dev/conf-get 'root-dir))
|
(comp-dev/conf-get 'root-dir))
|
||||||
|
|
@ -194,21 +218,6 @@
|
||||||
(format "lldb %s"
|
(format "lldb %s"
|
||||||
binary)))
|
binary)))
|
||||||
|
|
||||||
(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)
|
(defun lls/cmake-here (directory build-type target)
|
||||||
(interactive
|
(interactive
|
||||||
(list (expand-file-name "llvm"
|
(list (expand-file-name "llvm"
|
||||||
|
|
|
||||||
|
|
@ -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")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue