-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from GlowingScrewdriver/float
Floating-point support
- Loading branch information
Showing
17 changed files
with
168 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-0.450000 | ||
0.300000 | ||
0.300000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
(brilisp | ||
(bril-define ((fprint float) (n float))) | ||
|
||
(bril-define ((main void)) | ||
(set (v0 float) (const 9.0)) | ||
(set (v1 float) (const -20.0)) | ||
(set (res float) (fdiv v0 v1)) | ||
(set (tmp float) (call fprint res)) | ||
|
||
(set (v2 float) (const .1)) | ||
(set (v3 float) (const 0.1)) | ||
(set (add1 float) (fadd v2 v3)) | ||
(set (dres float) (fadd add1 v2)) | ||
(set (tmp float) (call fprint dres)) | ||
|
||
(set (v4 float) (const .1)) | ||
(set (add2 float) (fadd v4 v4)) | ||
(set (fres float) (fadd add2 v4)) | ||
(set (tmp float) (call fprint fres)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
0 | ||
1 | ||
0 | ||
1 | ||
0 | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(brilisp | ||
(bril-define ((print bool) (b bool))) | ||
|
||
(bril-define ((main void)) | ||
(set (v1 float) (const 50.0)) | ||
(set (v2 float) (const 50.1)) | ||
|
||
(set (res bool) (feq v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (fne v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (fge v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (fle v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (fgt v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (flt v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
-inf | ||
inf | ||
nan |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
(brilisp | ||
(bril-define ((fprint float) (n float))) | ||
|
||
(bril-define ((main void)) | ||
(set (v0 float) (const -1.0)) | ||
(set (v1 float) (const 1.0)) | ||
(set (zero float) (const 0.0)) | ||
(set (res float) (fdiv v0 zero)) | ||
(set (tmp float) (call fprint res)) | ||
(set (res float) (fdiv v1 zero)) | ||
(set (tmp float) (call fprint res)) | ||
(set (res float) (fdiv zero zero)) | ||
(set (tmp float) (call fprint res)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
(brilisp | ||
(bril-define ((print bool) (b bool))) | ||
|
||
(bril-define ((main void)) | ||
(set (zero float) (const 0.0)) | ||
(set (nan float) (fdiv zero zero)) | ||
(set (res bool) (feq nan nan)) | ||
(set (res bool) (not res)) | ||
(set (tmp bool) (call print res)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
(brilisp | ||
(bril-define ((print int) (n int))) | ||
|
||
(bril-define ((main void)) | ||
(set (v0 float) (const 0.0)) | ||
(set (v1 float) (const -0.0)) | ||
(set (res bool) (feq v0 v1)) | ||
(br res l_true l_false) | ||
|
||
(label l_true) | ||
(set (out int) (const 1)) | ||
(jmp out) | ||
(label l_false) | ||
(set (out int) (const 0)) | ||
(label out) | ||
(set (tmp int) (call print out)) | ||
(ret))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
0 | ||
1 | ||
0 | ||
1 | ||
0 | ||
1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
(brilisp | ||
(bril-define ((print bool) (b bool))) | ||
|
||
(bril-define ((main void)) | ||
(set (v1 int) (const 50)) | ||
(set (v2 int) (const 51)) | ||
|
||
(set (res bool) (eq v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (ne v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (ge v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (le v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (gt v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
|
||
(set (res bool) (lt v1 v2)) | ||
(set (tmp bool) (call print res)) | ||
(ret))) |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,8 @@ int print(int x){ | |
printf("%d\n", x); | ||
return x; | ||
} | ||
|
||
float fprint(float x) { | ||
printf("%f\n", x); | ||
return x; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
command = "guile ../../brilisp.scm < {filename} | python ../../llvm.py | bash ../../run.sh " | ||
command = "guile ../../brilisp.scm < {filename} | python ../../llvm.py | bash run.sh " |