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

Merge in Datomic sources #9

Merged
merged 35 commits into from
May 10, 2013
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
5a61c8c
work adding datomic
Mar 9, 2013
968e487
Added float, pointer, and fn types to ssa
Mar 9, 2013
ce8d9fe
latest work on ssa
Mar 11, 2013
19af157
latest work on datomic code
Mar 14, 2013
97634bb
more fixups to the datomic code
Mar 15, 2013
957d97c
Functions are commited
Mar 15, 2013
3b4d1c3
start of ssa refactor using state modnads(-ish)
Mar 21, 2013
a1c6637
If blocks are kindof implemented
Mar 26, 2013
5c61e2f
need validation/type inference next
Mar 28, 2013
b19b463
more work on the datomic backend
Mar 30, 2013
3058b58
fixed phi node linking
Mar 30, 2013
dce71cc
loops are working now
Apr 3, 2013
1e28bcc
reworked the binop system
Apr 4, 2013
df849ed
removing out-dated tests
Apr 4, 2013
6033e37
updated project.clj
Apr 4, 2013
6c00ba1
forgot to add some recent files
Apr 4, 2013
ea0d1ec
fixed malloc bug and other changes
Apr 25, 2013
7f5c3bf
added aset
Apr 27, 2013
4fd1c33
started fixing up the bf example to the new api
Apr 30, 2013
8e2fc49
bf compiler is working
May 1, 2013
d420f23
rewrote inference with pure clojure
May 2, 2013
6a4cab0
added fn translator
May 4, 2013
e697998
tons of updates, but tests are still broken
May 5, 2013
d349b89
some fixes, still some issues
May 6, 2013
c350f49
fixed a ugly bug with args
May 7, 2013
bbf305d
mandelbrot tests compile now
May 7, 2013
c068460
removed a ton of unused code in expressions.clj
May 7, 2013
a10a596
implementing structs, set, get
May 8, 2013
ae31ff6
added get
May 9, 2013
058b8d9
simple_lisp.clj can now compile to datomic
May 10, 2013
e7de853
more debugging
May 10, 2013
5fd7b4f
latest updates and fixes
May 10, 2013
5f72ef4
Update README.md
halgari May 10, 2013
a408004
updated version
May 10, 2013
8df3a6c
Merge branch 'datomic' of https://github.com/halgari/mjolnir into dat…
May 10, 2013
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
latest work on ssa
  • Loading branch information
Timothy Baldridge committed Mar 11, 2013
commit ce8d9fe739ce5282e50d6744c94888844444dacf
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "MIT License"}
:dependencies [[org.clojure/clojure "1.5.0"]
:dependencies [[org.clojure/clojure "1.5.1"]
[com.datomic/datomic-free "0.8.3826" ]
[speclj "2.5.0"]
[net.java.dev.jna/jna "3.4.0"]
Expand Down
5 changes: 2 additions & 3 deletions src/examples/bf.clj
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@
[ip code]
(let [ip_name (name (gensym "ip_"))
{ret-code :code ret-ip :ip}
(compile-block (exp/->Local ip_name) (next code))
]
(compile-block (exp/->Local ip_name) (next code))]

{:ip (exp/->Loop [[ip_name ip]]
(c/if (c/is (c/aget cells (exp/->Local ip_name)) Zero8)
Expand All @@ -119,7 +118,7 @@
(loop [ip 0
code program-code]
(let [{ip :ip code :code} (compile-bf ip code)]
#_(println "::::: " code)

(if code
(recur ip code)
ip)))))]
Expand Down
133 changes: 0 additions & 133 deletions src/examples/vectors2.clj

This file was deleted.

42 changes: 39 additions & 3 deletions src/mjolnir/expressions.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(ns mjolnir.expressions
(:require [mjolnir.types :refer :all]
[mjolnir.ssa :as ssa]
[mjolnir.llvmc :as llvm]
[mjolnir.config :refer :all]
[clojure.java.shell :as shell]
Expand Down Expand Up @@ -331,7 +332,23 @@
(= :extern
(:linkage this))))
(llvm/SetLinkage gbl (llvm/kw->linkage :extern))
gbl)))
gbl))
ssa/IToDatoms
(ssa/-to-datoms [this conn]
(let [tp (ssa/-to-datoms type conn)
arg-ids (map #(-> (ssa/transact-new conn
{:argument/name %2
:argument/idx %1})
:db/id)
(range)
arg-names)
names (ssa/transact-seq conn arg-ids)
body-id (-> (ssa/-to-datoms body conn)
:db/id)]
{:fn/type (:db/id tp)
:fn/name name
:fn/argument-names names
:fn/body body-id})))

(defrecord Module [name body]
Validatable
Expand Down Expand Up @@ -971,7 +988,17 @@
(assert *int-type* "No type set for ints")
*int-type*)
(build [this]
(encode-const *int-type* this)))
(encode-const *int-type* this))
ssa/IToDatoms
(ssa/-to-datoms [this conn]
(ssa/transact-new
conn
{:node/type :type/const
:const/int-value this
:node/return-type (-> (ssa/-to-datoms
*int-type*
conn)
:db/id)})))

(extend-type java.lang.Double
Validatable
Expand All @@ -982,7 +1009,16 @@
(assert *float-type* "No type set for floats")
*float-type*)
(build [this]
(encode-const *float-type* this)))
(encode-const *float-type* this))
ssa/IToDatoms
(ssa/-to-datoms [this conn]
(ssa/transact-new
conn
{:node/type :type/const
:node/return-type (-> (ssa/-to-datoms
*float-type*
conn)
:db/id)})))



Expand Down
15 changes: 14 additions & 1 deletion src/mjolnir/ssa.clj
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,34 @@

(def kw->attrs
{:one [:db/cardinality :db.cardinality/one]
:many [:db/cardinality :db.cardinalty/many]
:ref [:db/valueType :db.type/ref]
:keyword [:db/valueType :db.type/keyword]
:int [:db/valueType :db.type/long]})
:int [:db/valueType :db.type/long]
:string [:db/valueType :db.type/string]
:unique [:db/unique :db.unique/value]})


(defn default-schema []
{:list/tail #{:one :ref}
:fn/type #{:one :ref}
:fn/argument-names #{:one :ref}
:fn/name #{:one :string}
:fn/body #{:one :ref}

:const/int-value #{:one :int}

:argument/name #{:one :string}
:argument/idx #{:one :int}

:type.fn/return #{:one :ref}
:type.fn/arguments #{:one :ref}

:list/head #{:one :ref}

:node/type #{:one :keyword}
:node/return-type #{:one :ref}

:type/width #{:one :int}

:type/element-type #{:one :ref}
Expand Down
39 changes: 37 additions & 2 deletions test/mjolnir/ssa_test.clj
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
(ns mjolnir.ssa-test
(:require
[mjolnir.config :refer [*int-type*]]
[mjolnir.ssa :refer :all]
[mjolnir.types :refer [Int64 Int32 Float64 Float32 Float32* Float64*
->FunctionType]]
[mjolnir.expressions :refer [->Fn]]
[midje.sweet :refer :all]))

(with-state-changes [(around :facts (binding [*db-conn* (new-db)] ?form))]
(with-state-changes [(around :facts (binding [*db-conn* (new-db)
*int-type* Int64] ?form))]
(facts "IntegerType"
(fact "IntegerType is singleton"
(to-datoms Int64) => (to-datoms Int64))
Expand Down Expand Up @@ -38,4 +41,36 @@
(to-seq (:type.fn/arguments (to-datoms ft)))
=>
[(to-datoms Float64)
(to-datoms Int64)]))))
(to-datoms Int64)])))

(let [ft (->FunctionType [Int64] Int64)
f (->Fn "ret0" ft ["a" "b"]
0)]
(facts "Fn"
(fact "Functions create new entities each time"
(to-datoms f)
=not=>
(to-datoms f))
(fact "Functions with the same types are the same types"
(:fn/type (to-datoms f))
=>
(:fn/type (to-datoms f)))
(fact "Functions assert names"
(->> (to-datoms f)
:fn/argument-names
to-seq
(map :argument/name))
=>
["a" "b"])
(fact "Functions assert indexes"
(->> (to-datoms f)
:fn/argument-names
to-seq
(map :argument/idx))
=>
[0 1]))
(facts "Long"
(fact "Can be transacted"
(:const/int-value (to-datoms 0))
=>
0))))