mirror of
https://github.com/open-goal/jak-project
synced 2026-09-07 03:30:01 -04:00
de25f39439
Got OpenGOAL building and running natively on Apple Silicon. This is the rest of the port after the smaller arm64 emitter PRs. I was told pushing one big PR was okay. This covers goalc, the runtime, linker, kernel and the GOAL asm. The new paths have native tests. I also found four more emitter bugs while running it. They're in scalar sqrt, 128-bit stores, scalar max and indexed stores above 4 GB. Spent a while cleaning it up so it's easier to read. 4am gotta sleep lol Closes #3841 --------- Co-authored-by: Tyler Wilding <xtvaser@gmail.com>
99 lines
2.2 KiB
Common Lisp
99 lines
2.2 KiB
Common Lisp
|
|
;; use backend register names where there is no role name
|
|
(#cond
|
|
((eq? INSTRUCTION_SET 'arm64)
|
|
(defun test-asm-func ()
|
|
(declare (asm-func uint64))
|
|
(rlet ((x :reg x19 :type int)
|
|
(ret :reg carg0 :type int))
|
|
(.push x :color #f)
|
|
(.push 3)
|
|
(.pop x :color #f)
|
|
(.push x :color #f)
|
|
(.pop ret)
|
|
(.pop x :color #f)
|
|
)
|
|
(.ret)
|
|
))
|
|
(#t
|
|
(defun test-asm-func ()
|
|
(declare (asm-func uint64))
|
|
(rlet ((x :reg rbx :type int)
|
|
(ret :reg rax :type int))
|
|
(.push x :color #f)
|
|
(.push 3)
|
|
(.pop x :color #f)
|
|
(.push x :color #f)
|
|
(.pop ret)
|
|
(.pop x :color #f)
|
|
)
|
|
(.ret)
|
|
)))
|
|
|
|
(#cond
|
|
((eq? INSTRUCTION_SET 'arm64)
|
|
(defun get-goal-rsp ()
|
|
(declare (asm-func uint)
|
|
(print-asm))
|
|
(rlet ((rsp :reg sp :type uint)
|
|
(off :reg off :type uint)
|
|
(ret :reg carg0 :type uint)
|
|
(unused :reg x25) ;; make sure x25 is accepted here
|
|
)
|
|
|
|
;; just something weird to make the regalloc more interesting
|
|
(.push off)
|
|
(set! off (the uint 12))
|
|
(.pop off)
|
|
|
|
(set! ret rsp)
|
|
(.sub ret off)
|
|
|
|
(.ret)
|
|
)
|
|
))
|
|
(#t
|
|
(defun get-goal-rsp ()
|
|
(declare (asm-func uint)
|
|
(print-asm))
|
|
(rlet ((rsp :reg sp :type uint)
|
|
(off :reg r15 :type uint)
|
|
(ret :reg rax :type uint)
|
|
(unused :reg r11) ;; just to test that this isn't a compiler error.
|
|
)
|
|
|
|
;; just something weird to make the regalloc more interesting
|
|
(.push off)
|
|
(set! off (the uint 12))
|
|
(.pop off)
|
|
|
|
;; do the actual computation
|
|
(set! ret rsp)
|
|
(.sub ret off)
|
|
|
|
;; return!
|
|
(.ret)
|
|
)
|
|
)))
|
|
|
|
(defun get-goal-rsp-2 ()
|
|
(rlet ((rsp :reg rsp :type uint)
|
|
(off :reg r15 :type uint)
|
|
(pp :reg r13 :type uint)
|
|
(st :reg r14 :type uint))
|
|
(- rsp off)
|
|
)
|
|
)
|
|
|
|
(if (and
|
|
;; ARM64 normal functions spill lr, so sp is 16 bytes lower
|
|
(#cond
|
|
((eq? INSTRUCTION_SET 'arm64) (= 16 (- (get-goal-rsp) (get-goal-rsp-2))))
|
|
(#t (= (get-goal-rsp) (get-goal-rsp-2))))
|
|
(< #x7ffff00 (get-goal-rsp))
|
|
(> #x7ffffff (get-goal-rsp))
|
|
(= 3 (test-asm-func))
|
|
)
|
|
1
|
|
0)
|