Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Base implementation of Dynamix, Tim #111

Open
wants to merge 88 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
d499a77
Adapter/task compilation for Dynamix, depend on runtime package
molenzwiebel Mar 25, 2022
bb529aa
Namespace Dynamix files, cleanup
molenzwiebel Mar 25, 2022
0c9b662
Finalize signature generation for Dynamix
molenzwiebel Mar 25, 2022
75dd7ed
Add Tim language implementation and runtime
molenzwiebel Mar 25, 2022
f0d6a71
Add Dynamix Runtime implementation
molenzwiebel Mar 25, 2022
eae224f
Add support for constraint-analyzer property lookup and globals in Dy…
molenzwiebel Apr 3, 2022
ffb6955
Allow configuration of Dynamix entry-point rule
molenzwiebel Apr 21, 2022
a05839a
Minor fixes, include source location in rules for better stack traces
molenzwiebel Apr 21, 2022
9b39ebd
Consult rules in order of specificity during Dynamix evaluation
molenzwiebel Apr 21, 2022
1c7625d
Check for overlapping patterns in Statix, add support for concurrent …
molenzwiebel Apr 21, 2022
e4c6bfa
Add (untested) #array-write primitive to Tim
molenzwiebel Apr 21, 2022
40b2e2c
Merge from upstream
molenzwiebel Apr 21, 2022
389964a
Attempt at more efficiently comparing patterns in Statix
molenzwiebel Apr 21, 2022
83bce2e
Add some more tim primitives, make injected lists more ergonomic in D…
molenzwiebel Apr 28, 2022
81c2318
Make TFuns first-class values, do not generate signatures for bracket…
molenzwiebel May 9, 2022
1913616
Extract Tim runtime into separate project, depend on project
molenzwiebel May 12, 2022
bece936
Reorganize automatically generated Dynamix tasks
molenzwiebel May 12, 2022
ece00c1
An attempt at adding some native strategies to Tim
molenzwiebel May 12, 2022
0aa5a6c
Initial work on a closure conversion strategy
RvanBaarle Sep 10, 2022
22d12fa
Extract closures to outermost level. Fix mutually recursive closures.
RvanBaarle Sep 10, 2022
b2c6774
Add uniquify transform
RvanBaarle Sep 12, 2022
8400495
Inlining of functions
RvanBaarle Sep 20, 2022
37919bf
Support for integer operations
RvanBaarle Sep 20, 2022
a613e40
Add support for array operations
RvanBaarle Sep 21, 2022
a24f490
Add support for refs
RvanBaarle Sep 21, 2022
ca8fafc
Add support for strings
RvanBaarle Sep 22, 2022
4f283af
Add partial record support
RvanBaarle Sep 22, 2022
a063d14
Support for arguments to `#record-new`
RvanBaarle Sep 22, 2022
fae98ed
Add closure type to tim
RvanBaarle Sep 23, 2022
58352b5
Allow for negative indices in closure reads/offsets
RvanBaarle Sep 23, 2022
032df6f
Implement compilation of new closure primops
RvanBaarle Sep 23, 2022
e95a454
Combine closures for each fix expression
RvanBaarle Sep 23, 2022
b6c381b
WIP for closure conversion improvements
RvanBaarle Sep 27, 2022
ed26c61
Creation of project for LLVM IR
RvanBaarle Sep 27, 2022
424162e
Initial version of LLVM syntax
RvanBaarle Sep 27, 2022
07c6db9
Minor syntax fixes
RvanBaarle Sep 27, 2022
af1474a
Move around files and minor syntax changes
RvanBaarle Sep 28, 2022
e4722d0
Get rid of all string interpolation
RvanBaarle Sep 28, 2022
32c4752
C runtime library for Tim
RvanBaarle Sep 28, 2022
adc0604
Differentiate between printing ints and strings
RvanBaarle Sep 28, 2022
0994d8d
Fix statix type of string literal
RvanBaarle Sep 28, 2022
fc3edfc
Add array tail, length and concat operations
RvanBaarle Sep 28, 2022
fdeedb8
Minor fixes to syntax
RvanBaarle Sep 28, 2022
1fc296a
Implement the last missing features
RvanBaarle Sep 29, 2022
dd22445
Fix non-escaping closure optimizations
RvanBaarle Sep 30, 2022
d98d25c
Update compiler flags to emit bitcode
RvanBaarle Sep 30, 2022
3380018
Use static closure address if known at compile time
RvanBaarle Sep 30, 2022
94521ff
Let binding inlining
RvanBaarle Oct 4, 2022
21a43b7
Extend LLVM syntax for GC support
RvanBaarle Oct 4, 2022
3810581
WIP in explicating types further
RvanBaarle Oct 4, 2022
fa3ff44
More explicit typing
RvanBaarle Oct 4, 2022
a91464e
Explicitly typed, and progress towards GC
RvanBaarle Oct 5, 2022
8ca9b1f
quick fixes to correctly compile
RvanBaarle Oct 5, 2022
bdf90ee
Change what gets logged
RvanBaarle Oct 5, 2022
6923584
Fix incorrect base pointer
RvanBaarle Oct 6, 2022
439620e
Arrays start at one, fix tailcall issue
RvanBaarle Oct 6, 2022
e5b55ba
Array type consistency
RvanBaarle Oct 7, 2022
0d370cb
Add gc-leaf-function to function applications
RvanBaarle Oct 7, 2022
1ae60ad
Garbage collector
RvanBaarle Oct 7, 2022
81a4b6a
Remove all unused includes
RvanBaarle Oct 7, 2022
c49e60b
Scan heap for pointers as well
RvanBaarle Oct 11, 2022
20a1f7e
Support for finalizers
RvanBaarle Oct 11, 2022
cd946cd
Add [[maybe_unused]] attributes
RvanBaarle Oct 11, 2022
cd0b74e
Fix array and string operations using old references
RvanBaarle Oct 12, 2022
4c6a686
Garbage collection for closures
RvanBaarle Oct 12, 2022
a69a415
Add LLVM IR to Spoofax LWB
RvanBaarle Oct 13, 2022
246c729
Quick fix for emitting LLVM from Spoofax 3
RvanBaarle Oct 13, 2022
6b254ed
Fix a couple of bugs
RvanBaarle Oct 13, 2022
2edbd52
Change stratego provider to ctree in hopes of harmony between spoofax…
RvanBaarle Oct 14, 2022
8bf568f
Add explicit type annotations in preparation of more efficient types
RvanBaarle Oct 14, 2022
9b15144
Add type annotations to functions as well
RvanBaarle Oct 14, 2022
19ea985
Integer boxing
RvanBaarle Oct 19, 2022
e40cb02
Bitfield encoding and flag-related bugfixes
RvanBaarle Oct 19, 2022
76e1a10
Typed closures
RvanBaarle Oct 19, 2022
9343bf4
Struct type added
RvanBaarle Oct 20, 2022
b4487e5
Add typing additions to dynamix
RvanBaarle Oct 24, 2022
ff437c3
Implement tuples and fixes to types
RvanBaarle Oct 25, 2022
a532600
Rename holy to pluggable
RvanBaarle Oct 26, 2022
515e6bd
Refactor locations of ast.str, type.str and string.str
RvanBaarle Oct 26, 2022
fe20ccd
Struct inheritance
RvanBaarle Oct 26, 2022
a2ed622
Small fixes to Tim
RvanBaarle Nov 1, 2022
0292cc4
Improve performance issue, change names to match those used in Thijs'…
RvanBaarle Nov 2, 2022
a4558af
Fix closure conversion edgecase
RvanBaarle Nov 2, 2022
4409c2c
Fix recursive types and possibility for gc to encounter invalid pointers
RvanBaarle Nov 8, 2022
b06880b
Fix recursive types better
RvanBaarle Nov 8, 2022
6c8d609
Revert changes to tim type system
RvanBaarle Nov 10, 2022
d247dfa
Have structs contain scopes
RvanBaarle Nov 22, 2022
972acd3
Adding str-neq condition, slight LLVM syntax fixes, some other small …
RvanBaarle Dec 6, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Array type consistency
RvanBaarle committed Oct 7, 2022
commit e5b55baf2ce971bd29b8e4903590c5c55262fd73
1 change: 1 addition & 0 deletions lwb/metalang/llvm/llvm.spoofax2/syntax/llvm.sdf3
Original file line number Diff line number Diff line change
@@ -23,6 +23,7 @@ context-free syntax
Definition.TargetTriple = <target triple = <STRING>>
Definition.ModuleAsm = <module asm <STRING>>
Definition.GlobalDef = <<Constant> = <Linkage> <GlobalAttribute*> <Type> <Literal>>
Definition.TypeDef = <<Variable> = type <Type>>
Definition.FunDecl = <declare <Linkage> <CallConv> <Type> <Constant>(<{Parameter ", "}*>) <FunctionAttribute*>>
Definition.FunDef = <
define <Linkage> <CallConv> <Type> <Constant>(<{Parameter ", "}*>) <FunctionAttribute*> {
3 changes: 3 additions & 0 deletions lwb/metalang/llvm/llvm.spoofax2/syntax/llvm/Atoms.sdf3
Original file line number Diff line number Diff line change
@@ -28,9 +28,12 @@ context-free syntax
Type.Pointer = <ptr>
Type.PointerAddrSpace = <ptr addrspace(<INT>)>
Type.Array = <[<POSINT> x <Type>]>
Type.Struct = <{<{Type ", "}*>}>
Type.PackedStruct = [<{[{Type ", "}*]}>]
Type.Label = <label>
Type.Void = <void>
Type.Function = <<Type> (<{Parameter ", "}*>)>
Type.VarType = <<Variable>>

Atom.Literal = <<Literal>>
Atom.ConstAtom = <<Constant>>
Original file line number Diff line number Diff line change
@@ -45,6 +45,7 @@ context-free syntax
FunctionAttribute.AllocKind = <allockind(<STRING>)>
FunctionAttribute.AllocSize = <allocsize(<INT>)>
FunctionAttribute.AllocFamily = <"alloc-family"=<STRING>>
FunctionAttribute.GCLeafFunction = <"gc-leaf-function"="true">

OperandBundles.NoOperandBundles = <>
OperandBundles.OperandBundles = <[<OperandBundle*>]>
20 changes: 8 additions & 12 deletions lwb/metalang/llvm/llvm.spoofax2/tim_head.aterm
Original file line number Diff line number Diff line change
@@ -14,6 +14,10 @@ LLVMProgram(
, Array("4", Int8())
, String("\"%s\\0A\\00\"")
)
, TypeDef(
Variable(".array_type")
, Struct([Int64(), Array("0", Int64())])
)
, ModuleAsm("\".globl __LLVM_StackMaps\"")
, FunDecl(
DefaultLinkage()
@@ -64,15 +68,15 @@ LLVMProgram(
, ParamUnnamed(PointerAddrSpace("1"), [])
, ParamUnnamed(Int64(), [])
]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
, FunDecl(
DefaultLinkage()
, DefaultCConv()
, Int64()
, Constant("record_read")
, [ParamUnnamed(PointerAddrSpace("1"), []), ParamUnnamed(PointerAddrSpace("1"), [])]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
, FunDecl(
DefaultLinkage()
@@ -83,23 +87,15 @@ LLVMProgram(
, ParamUnnamed(PointerAddrSpace("1"), [])
, ParamUnnamed(PointerAddrSpace("1"), [])
]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
, FunDecl(
DefaultLinkage()
, DefaultCConv()
, PointerAddrSpace("1")
, Constant("record_read_ptr")
, [ParamUnnamed(PointerAddrSpace("1"), []), ParamUnnamed(PointerAddrSpace("1"), [])]
, [NoUnwind()]
)
, FunDecl(
DefaultLinkage()
, DefaultCConv()
, Void()
, Constant("record_delete")
, [ParamUnnamed(PointerAddrSpace("1"), [])]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
, FunDecl(
DefaultLinkage()
10 changes: 5 additions & 5 deletions lwb/metalang/llvm/llvm.spoofax2/tim_head.ll
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
target triple = "x86_64-unknown-linux-gnu"
@.int_fmt = private unnamed_addr constant [5 x i8] c"%ld\0A\00"
@.str_fmt = private unnamed_addr constant [4 x i8] c"%s\0A\00"
%.array_type = type {i64, [0 x i64]}
module asm ".globl __LLVM_StackMaps"

declare void @exit(i32) noreturn nounwind
@@ -10,11 +11,10 @@ declare i64 @strcmp(ptr, ptr) nounwind

; tim runtime library
declare ptr addrspace(1) @record_new(i64, ...) nounwind
declare void @record_write(ptr addrspace(1), ptr addrspace(1), i64) nounwind
declare i64 @record_read(ptr addrspace(1), ptr addrspace(1)) nounwind
declare void @record_write_ptr(ptr addrspace(1), ptr addrspace(1), ptr addrspace(1)) nounwind
declare ptr addrspace(1) @record_read_ptr(ptr addrspace(1), ptr addrspace(1)) nounwind
declare void @record_delete(ptr addrspace(1)) nounwind
declare void @record_write(ptr addrspace(1), ptr addrspace(1), i64) nounwind "gc-leaf-function"="true"
declare i64 @record_read(ptr addrspace(1), ptr addrspace(1)) nounwind "gc-leaf-function"="true"
declare void @record_write_ptr(ptr addrspace(1), ptr addrspace(1), ptr addrspace(1)) nounwind "gc-leaf-function"="true"
declare ptr addrspace(1) @record_read_ptr(ptr addrspace(1), ptr addrspace(1)) nounwind "gc-leaf-function"="true"

declare ptr addrspace(1) @array_concat(ptr addrspace(1), ptr addrspace(1)) nounwind
declare ptr addrspace(1) @array_tail(ptr addrspace(1)) nounwind
22 changes: 9 additions & 13 deletions lwb/metalang/tim/tim.spoofax2/trans/compile/conclude.str
Original file line number Diff line number Diff line change
@@ -24,6 +24,10 @@ rules
, Array("4", Int8())
, String("\"%s\\0A\\00\"")
)
, TypeDef(
Variable(".array_type")
, Struct([Int64(), Array("0", Int64())])
)
// Garbage collection stack map
, ModuleAsm("\".globl __LLVM_StackMaps\"")
// Built in functions
@@ -78,15 +82,15 @@ rules
, ParamUnnamed(PointerAddrSpace("1"), [])
, ParamUnnamed(Int64(), [])
]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
, FunDecl(
DefaultLinkage()
, DefaultCConv()
, Int64()
, Constant("record_read")
, [ParamUnnamed(PointerAddrSpace("1"), []), ParamUnnamed(PointerAddrSpace("1"), [])]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
, FunDecl(
DefaultLinkage()
@@ -97,23 +101,15 @@ rules
, ParamUnnamed(PointerAddrSpace("1"), [])
, ParamUnnamed(PointerAddrSpace("1"), [])
]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
, FunDecl(
DefaultLinkage()
, DefaultCConv()
, PointerAddrSpace("1")
, Constant("record_read_ptr")
, [ParamUnnamed(PointerAddrSpace("1"), []), ParamUnnamed(PointerAddrSpace("1"), [])]
, [NoUnwind()]
)
, FunDecl(
DefaultLinkage()
, DefaultCConv()
, Void()
, Constant("record_delete")
, [ParamUnnamed(PointerAddrSpace("1"), [])]
, [NoUnwind()]
, [NoUnwind(), GCLeafFunction()]
)
// Arrays
, FunDecl(
@@ -207,4 +203,4 @@ rules
)
]
)
]
]
Original file line number Diff line number Diff line change
@@ -69,10 +69,9 @@ rules
where with(fail|"String comparison not yet implemented") // TODO

select-exp : TExpApp(x, args) ->
( [ Expression(Call(DefaultTail(), TailCConv(), Void(), <select-value> x, <select-call-args> args, [], NoOperandBundles()))]
( [ Expression(Call(MustTail(), TailCConv(), Void(), <select-value> x, <select-call-args> args, [], NoOperandBundles()))]
, RetVoid()
)
// TODO: restore tail calling

select-exp = with(fail|$[unsupported exp])

@@ -187,22 +186,25 @@ rules
; i' := TypedAtom(Int64(), Literal(Int(<int-to-string> i)))

select-primop(|result) : ("array-read", t, [arr, index]) ->
[ Assign(offset, GetElementPtr(Struct([Int64(), Array("0", <get-type> t)]), [<select-typed-value> arr, TypedAtom(Int32(), Literal(Int("0"))), TypedAtom(Int32(), Literal(Int("1"))), <select-typed-value> index]))
[ Assign(offset, GetElementPtr(VarType(Variable(".array_type")), [<select-typed-value> arr, TypedAtom(Int32(), Literal(Int("0"))), TypedAtom(Int32(), Literal(Int("1"))), <select-typed-value> index]))
, Assign(result, Load(<get-type> t, TypedAtom(PointerAddrSpace("1"), VarAtom(offset))))
]
with
offset := Variable(<newname> "offset")

select-primop(|result) : ("array-write", _, [arr, index, value]) ->
[ Assign(offset, GetElementPtr(Struct([Int64(), Array("0", <get-type> value)]), [<select-typed-value> arr, TypedAtom(Int32(), Literal(Int("0"))), TypedAtom(Int32(), Literal(Int("1"))), <select-typed-value> index]))
[ Assign(offset, GetElementPtr(VarType(Variable(".array_type")), [<select-typed-value> arr, TypedAtom(Int32(), Literal(Int("0"))), TypedAtom(Int32(), Literal(Int("1"))), <select-typed-value> index]))
, Expression(Store(<select-typed-value> value, TypedAtom(PointerAddrSpace("1"), VarAtom(offset))))
]
with
offset := Variable(<newname> "offset")

select-primop(|result) : ("array-length", _, [arr]) ->
[ Assign(result, Load(Int64(), <select-typed-value> arr))
[ Assign(offset, GetElementPtr(VarType(Variable(".array_type")), [<select-typed-value> arr, TypedAtom(Int32(), Literal(Int("0"))), TypedAtom(Int32(), Literal(Int("0")))]))
, Assign(result, Load(Int64(), TypedAtom(PointerAddrSpace("1"), VarAtom(offset))))
]
with
offset := Variable(<newname> "offset")

select-funcall-primop : ("array-concat", t) -> ("array_concat", <get-type> t)
select-funcall-primop : ("array-tail", t) -> ("array_tail", <get-type> t)