1
0
mirror of https://github.com/janet-lang/janet synced 2025-07-08 13:02:55 +00:00
janet/test/sysir/basic1.janet
Calvin Rose 0066a5a304 Start removing NASM dependence.
Start setting up a test suite for sysir and work towards emitting jitted
x86 machine code.
2025-05-04 20:20:11 -05:00

36 lines
695 B
Plaintext

(def ir-asm
'((link-name "test_function")
# Types
(type-prim Int s32)
(type-prim Double f64)
(type-struct MyPair 0 1)
(type-pointer PInt Int)
(type-array DoubleArray 1 1024)
# Declarations
(bind 0 Int)
(bind 1 Int)
(bind 2 Int)
(bind 3 Double)
(bind bob Double)
(bind 5 Double)
(bind 6 MyPair)
# Code
(move 0 (Int 10))
(move 0 (Int 21))
:location
(add 2 1 0)
(move 3 (Double 1.77))
(call :default 3 (PInt sin) 3)
(cast bob 2)
(call :default bob (PInt test_function))
(add 5 bob 3)
(jump :location)
(return 5)))
(def ctx (sysir/context))
(sysir/asm ctx ir-asm)
(print (sysir/to-c ctx))