1
0
mirror of https://github.com/janet-lang/janet synced 2025-10-30 15:13:03 +00:00

Begin work on simple x64 backend.

Introduce register allocation, spilling, etc. First implementation
will likely emit textual assembly and use a very bad register allocation
algorithm.
This commit is contained in:
Calvin Rose
2024-06-02 17:45:31 -05:00
parent 480c5b5e9d
commit 7ea118f248
7 changed files with 790 additions and 220 deletions

View File

@@ -118,6 +118,8 @@
'- (do-binop 'subtract args into)
'* (do-binop 'multiply args into)
'/ (do-binop 'divide args into)
'<< (do-binop 'shl args into)
'>> (do-binop 'shl args into)
# Comparison
'= (do-comp 'eq args into)
@@ -309,7 +311,6 @@
(array/push ir-asm ~(bind ,slot ,tp)))
(each part body
(visit1 part ir-asm true))
(eprintf "%.99M\n" ir-asm)
(sysir/asm ctx ir-asm))
(errorf "unknown form %v" form)))
@@ -340,18 +341,21 @@
(def main-fn
'(defn main:int []
(var x:int 10)
(doloop 10 20)
(printf "done!\n")
(return (the int 0))))
(defn dotest
[]
(def ctx (sysir/context))
(setup-default-types ctx)
#(top ctx myprog)
(top ctx doloop)
(top ctx main-fn)
(print (sysir/to-c ctx)))
(def ctx (sysir/context))
(setup-default-types ctx)
(dotest)
(defn compile1
[x]
(top ctx x))
(defn dump
[]
(eprintf "%.99M\n" (sysir/to-ir ctx)))
(defn dumpc
[]
(print (sysir/to-c ctx)))