about summary refs log tree commit diff
path: root/ach
diff options
context:
space:
mode:
authorGriffin Smith <root@gws.fyi>2021-03-07T20·29-0500
committerGriffin Smith <root@gws.fyi>2021-03-07T20·29-0500
commit80f8ede0bbc9799d5199707e1e1ad8e80e4ca7ac (patch)
treecbb418b042583714fe09f946f1b9a03d1d98857f /ach
Initial commit
Diffstat (limited to 'ach')
-rw-r--r--ach/.gitignore2
-rw-r--r--ach/Makefile15
-rw-r--r--ach/functions.ach3
-rw-r--r--ach/simple.ach1
4 files changed, 21 insertions, 0 deletions
diff --git a/ach/.gitignore b/ach/.gitignore
new file mode 100644
index 000000000000..e8423ae351b8
--- /dev/null
+++ b/ach/.gitignore
@@ -0,0 +1,2 @@
+*.ll
+*.o
diff --git a/ach/Makefile b/ach/Makefile
new file mode 100644
index 000000000000..869a0d0f8a3e
--- /dev/null
+++ b/ach/Makefile
@@ -0,0 +1,15 @@
+default: simple
+
+%.ll: %.ach
+	cargo run -- compile $< -o $@ -f llvm
+
+%.o: %.ll
+	llc $< -o $@ -filetype=obj
+
+%: %.o
+	clang $< -o $@
+
+.PHONY: clean
+
+clean:
+	@rm -f *.ll *.o simple
diff --git a/ach/functions.ach b/ach/functions.ach
new file mode 100644
index 000000000000..8d91564c1559
--- /dev/null
+++ b/ach/functions.ach
@@ -0,0 +1,3 @@
+fn id x = x
+fn plus x y = x + y
+fn main = plus (id 2) 7
diff --git a/ach/simple.ach b/ach/simple.ach
new file mode 100644
index 000000000000..20f1677235c0
--- /dev/null
+++ b/ach/simple.ach
@@ -0,0 +1 @@
+fn main = let x = 2; y = 3 in x + y