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
some fixes, still some issues
  • Loading branch information
Timothy Baldridge committed May 6, 2013
commit d349b895a47aa35f02d561f277a533b874053fea
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[org.clojure/core.logic "0.8.3"]
[net.java.dev.jna/jna "3.4.0"]
[criterium "0.3.1"]
#_[jcuda/jcuda "0.5.0"]]
[jcuda/jcuda "0.5.0"]]
:test-paths ["test/"]
:java-source-paths ["src/examples"]
:jvm-opts ["-Djava.library.path=/usr/lib"
Expand Down
49 changes: 37 additions & 12 deletions src/mjolnir/llvm_builder.clj
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,22 @@
[test then else]
(llvm/BuildCondBr builder test then else)))


(def cmp-map
{[:type/int :type/int :inst.cmp.pred/=] :inst.cmp.sub-pred/int-eq
[:type/int :type/int :inst.cmp.pred/not=] :inst.cmp.sub-pred/int-ne
[:type/int :type/int :inst.cmp.pred/>] :inst.cmp.sub-pred/int-sgt
[:type/int :type/int :inst.cmp.pred/<] :inst.cmp.sub-pred/int-slt
[:type/int :type/int :inst.cmp.pred/<=] :inst.cmp.sub-pred/int-sle
[:type/int :type/int :inst.cmp.pred/>=] :inst.cmp.sub-pred/int-sge

[:type/float :type/float :inst.cmp.pred/=] :inst.cmp.sub-pred/real-oeq
[:type/float :type/float :inst.cmp.pred/not=] :inst.cmp.sub-pred/real-one
[:type/float :type/float :inst.cmp.pred/>] :inst.cmp.sub-pred/real-ogt
[:type/float :type/float :inst.cmp.pred/<] :inst.cmp.sub-pred/real-olt
[:type/float :type/float :inst.cmp.pred/<=] :inst.cmp.sub-pred/real-ole
[:type/float :type/float :inst.cmp.pred/>=] :inst.cmp.sub-pred/real-oge})

(def cmp-table
{:inst.cmp.sub-pred/int-eq llvm/LLVMIntEQ
:inst.cmp.sub-pred/int-ne llvm/LLVMIntNE
Expand All @@ -360,6 +376,7 @@
:inst.cmp.sub-pred/real-ogt llvm/LLVMRealOGT
:inst.cmp.sub-pred/real-oge llvm/LLVMRealOGE
:inst.cmp.sub-pred/real-ole llvm/LLVMRealOLE
:inst.cmp.sub-pred/real-olt llvm/LLVMRealOLT
:inst.cmp.sub-pred/real-one llvm/LLVMRealONE
:inst.cmp.sub-pred/real-ord llvm/LLVMRealORD
:inst.cmp.sub-pred/real-uno llvm/LLVMRealUNO
Expand All @@ -375,18 +392,26 @@
[d module builder fn inst defs]
(unpack-args defs inst
[lh rh]
(let [sub-type (cmp-table (:inst.cmp/sub-pred inst))]
(assert sub-type (pr-str "Invalid cmp type" [(:inst.cmp/sub-pred inst)
(:inst.cmp/pred inst)
(-> inst
:inst.arg/arg0
:node/return-type
:node/type)
(-> inst
:inst.arg/arg1
:node/return-type
:node/type)]))
(llvm/BuildICmp builder sub-type lh rh (str "cmp_" (:db/id inst))))))
(let [lh-t (-> inst :inst.arg/arg0 :node/return-type :node/type)
rh-t (-> inst :inst.arg/arg1 :node/return-type :node/type)
pred (-> inst :inst.cmp/pred)
sub-type (-> (cmp-map [lh-t rh-t pred])
cmp-table)]
(assert (integer? sub-type) (pr-str "Invalid cmp type" [sub-type
lh-t
rh-t
pred
(cmp-map [lh-t rh-t pred])
(-> (cmp-map [lh-t rh-t pred])
cmp-table)]))
(cond
(= lh-t rh-t :type/int)
(llvm/BuildICmp builder sub-type lh rh (str "cmp_" (:db/id inst)))

(= lh-t rh-t :type/float)
(llvm/BuildFCmp builder sub-type lh rh (str "cmp_" (:db/id inst)))

:else (assert false "No LLVM predicate builder")))))

(defmethod build-instruction :inst.type/return-val
[d module builder fn inst defs]
Expand Down
8 changes: 6 additions & 2 deletions src/mjolnir/ssa_rules.clj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
(infer-binop ?id ?val)
[(identity :inst.binop/sub-type) ?attr])

#_(defrule infer-node [?id ?attr ?val]
"infer cmp"
(infer-cmp-node ?id ?attr ?val))


(defrule infer-cast [?id ?attr ?val]
"infer casts"
Expand Down Expand Up @@ -167,7 +171,7 @@
[(mjolnir.ssa-rules/binop-int-translation ?binop) ?op])

(defrule binop-subtype [?type ?arg0-t ?arg1-t ?op]
"Int + resolves to :iadd"
"Float + resolves to :iadd"
[?arg0-t :node/type :type/float]
[?arg1-t :node/type :type/float]
[?type :inst.binop/type ?binop]
Expand Down Expand Up @@ -232,7 +236,7 @@
[:type/float :type/float :inst.cmp.pred/<=] :inst.cmp.sub-pred/real-ole
[:type/float :type/float :inst.cmp.pred/>=] :inst.cmp.sub-pred/real-oge})

(defrule infer-node [?id ?attr ?val]
#_(defrule infer-cmp-node [?id ?attr ?val]
"Infer cmp predicate"
[?id :inst/type :inst.type/cmp]
[(println "foo" ?id) ?v]
Expand Down