-
Notifications
You must be signed in to change notification settings - Fork 230
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
add fastbrili to repo #300
Merged
Merged
Changes from 8 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
28e57b5
add fastbril to repo
801db70
check in documentation; update makefile and gitignore
eab0f26
udpate readme
3eb4127
yeet local benchmarks, fix bug with arg parsing so that you can now
76949d9
Fix Makefile by using make functions
sampsyo bbba781
Remove & ignore doc product
sampsyo 06d5baf
Fix Makefile's use of awk converter
sampsyo df048f1
Remove srcgen.sh
sampsyo 77971ed
remove and ignore generated files
47cb6f9
move fastbrili turnt into main file
a088259
move fastbrili turnt into main file
9a04b18
Merge branch 'main' of github.com:charles-rs/bril
fea021b
Merge branch 'main' of github.com:charles-rs/bril into charles-rs/main
sampsyo 006375e
Use "interpreter mode" to test fastbrili
sampsyo 37680cc
Remove evaluation data
sampsyo bcbf046
Remove a stray lockfile
sampsyo 96aca05
Remove emission sources (which seem unused)
sampsyo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# command = "bril2json < {filename} | ../build/fastbrili -p {args}" | ||
command = "bril2json < {filename} | $FASTBRILI -ni -bo byte-out ; cat byte-out | $FASTBRILI -b {args} ; rm byte-out" | ||
output.out = "-" | ||
# output.prof = "2" |
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,4 @@ | ||
build/ | ||
*~ | ||
\#*\# | ||
*.o |
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,84 @@ | ||
TARGET_EXEC ?= fastbrili | ||
|
||
BUILD_DIR ?= ./build | ||
SRC_DIRS ?= ./src | ||
DOC_DIR ?= ./doc | ||
SHELL = /bin/sh | ||
|
||
CONFIGS := $(wildcard config/*.cf) | ||
GEN_HEAD := $(CONFIGS:config/%.cf=src/%.h) | ||
GEN_TEX := $(CONFIGS:config/%.cf=doc/%.tex) | ||
|
||
SRCS := $(wildcard $(SRC_DIRS)/*.c $(SRC_DIRS)/**/*.c) | ||
|
||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o) | ||
DEPS := $(OBJS:.o=.d) | ||
|
||
INC_DIRS := $(shell find $(SRC_DIRS) -type d) | ||
INC_FLAGS := $(addprefix -I,$(INC_DIRS)) | ||
|
||
|
||
CFLAGS += $(INC_FLAGS) | ||
|
||
.PHONY: debug | ||
|
||
debug: CFLAGS += -g -Og | ||
debug: $(BUILD_DIR)/$(TARGET_EXEC) | ||
|
||
.PHONY: coverage | ||
|
||
coverage: CFLAGS += --coverage -DDEBUG -g3 | ||
coverage: $(GEN_HEAD) | ||
mkdir $(BUILD_DIR) && cd $(BUILD_DIR) && $(CC) $(CFLAGS) $(abspath $(SRCS)) -o $(TARGET_EXEC) | ||
|
||
.PHONY: cov-report | ||
|
||
cov-report: | ||
gcovr -r . --html --html-details -o cov-report/out.html | ||
|
||
.PHONY: release | ||
|
||
release: CFLAGS += -O3 | ||
release: $(BUILD_DIR)/$(TARGET_EXEC) | ||
|
||
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS) lib/lib.o | ||
$(CC) $(OBJS) -o $@ $(LDFLAGS) | ||
|
||
# # assembly | ||
# $(BUILD_DIR)/%.s.o: %.s | ||
# $(MKDIR_P) $(dir $@) | ||
# $(AS) $(ASFLAGS) -c $< -o $@ | ||
|
||
# c source | ||
$(BUILD_DIR)/%.c.o: %.c | $(GEN_HEAD) | ||
$(MKDIR_P) $(dir $@) | ||
$(CC) $(CFLAGS) -c $< -o $@ | ||
|
||
# configured header files | ||
src/%.h: config/%.cf srcgen.awk | ||
./srcgen.awk < $< > $@ | ||
|
||
brb.pdf: $(GEN_TEX) $(DOC_DIR)/main.tex | ||
cd $(DOC_DIR) && latex -output-format=pdf main.tex && mv main.pdf brb.pdf | ||
|
||
lib/lib.o: lib/lib.c | ||
cd lib && $(CC) -O3 -c lib.c | ||
|
||
doc: brb.pdf | ||
|
||
$(GEN_TEX): $(configs) docgen.sh docgen.awk | ||
$(MKDIR_P) $(dir $@) | ||
./docgen.sh $@ | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
find . -name "*.aux" -o -name "*.log" -o -name "*.pdf" -o -name "*~" -o \ | ||
-name "*.gcda" -o -name "*.gcno" -o -name "*.o" | xargs rm || true | ||
$(RM) $(GEN_HEAD) | ||
$(RM) $(GEN_TEX) | ||
$(RM) -r $(BUILD_DIR) | ||
|
||
-include $(DEPS) | ||
|
||
MKDIR_P ?= mkdir -p |
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,31 @@ | ||
# The `fastbril` bytecode interpreter | ||
|
||
This is a bytecode spec/generator/interpreter for `bril`. It aims to | ||
be like the typescript or rust implementation, but faster. | ||
|
||
## To build | ||
|
||
+ binary: `make release` | ||
the binary will be `./build/fastbrili` | ||
+ doc: you need to have LaTeX installed. run `make doc` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI, I tried to run this and got:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this sounds like |
||
the doc will be `./doc/brb.pdf` | ||
there is a prebuilt pdf in case this is difficult | ||
|
||
|
||
|
||
### Features | ||
We support a superset of the behavior provided by `brili`, so options like `-p` | ||
work exactly the same. We also support the following: | ||
- `-b` will read in bytecode instead of the Bril json | ||
- `-bo <file>` will output the bytecode to `<file>` | ||
- `-pr` will print the program to standard out (probably more useful with the | ||
`-b` option) | ||
- `-ni` will NOT run the interpreter. | ||
- `-e <file>` will emit assembly to `<file>`. | ||
|
||
the current only supported assembly is armv8. sorry. | ||
|
||
the compiler to asm is probably the least trustworthy part of this | ||
whole project. The general interpreter should be pretty good, but it | ||
is always possible there are bugs. Please report bugs to | ||
`[email protected]`, and there's a chance that i will fix them :) |
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,49 @@ | ||
Instructions are 64bit numbers | ||
1 bit to mark labelled, 15 bits of opcode, 16bits of destination, 16 bits of | ||
arg1, 16 bits of arg2 | ||
|
||
this is modified for other instructions | ||
|
||
Opcodes: | ||
nop: 0 | ||
const: 1 | ||
add: 2 | ||
mul: 3 | ||
sub: 4 | ||
div: 5 | ||
eq: 6 | ||
lt: 7 | ||
gt: 8 | ||
le: 9 | ||
ge: 10 | ||
not: 11 | ||
and: 12 | ||
or: 13 | ||
jmp: 14 | ||
br: 15 | ||
call: 16 | ||
ret: 17 | ||
print: 18 | ||
phi: 19 | ||
alloc: 20 | ||
free: 21 | ||
store: 22 | ||
load: 23 | ||
ptradd: 24 | ||
fadd: 25 | ||
fmul: 26 | ||
fsub: 27 | ||
fdiv: 28 | ||
feq: 29 | ||
flt: 30 | ||
fle: 31 | ||
fgt: 32 | ||
fge: 33 | ||
lconst: 34 | ||
|
||
|
||
types: | ||
bool: 0 | ||
int: 1 | ||
float: 2 | ||
ptr: 3 |
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,22 @@ | ||
CONST 1 | ||
ADD 2 | ||
MUL 3 | ||
SUB 4 | ||
DIV 5 | ||
EQ 6 | ||
LT 7 | ||
GT 8 | ||
LE 9 | ||
GE 10 | ||
NOT 11 | ||
AND 12 | ||
OR 13 | ||
JMP 14 | ||
BR 15 | ||
CALL 16 | ||
RET 17 | ||
PRINT 18 | ||
LCONST 19 | ||
NOP 20 | ||
ID 21 | ||
|
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,9 @@ | ||
FADD 28 | ||
FMUL 29 | ||
FSUB 30 | ||
FDIV 31 | ||
FEQ 32 | ||
FLT 33 | ||
FLE 34 | ||
FGT 35 | ||
FGE 36 |
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,5 @@ | ||
ALLOC 23 | ||
FREE 24 | ||
STORE 25 | ||
LOAD 26 | ||
PTRADD 27 |
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,2 @@ | ||
PHI 22 | ||
|
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,4 @@ | ||
BRILINT 0 | ||
BRILBOOL 1 | ||
BRILFLOAT 2 | ||
BRILVOID 3 |
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,9 @@ | ||
*.aux | ||
*.out | ||
*.log | ||
base.tex | ||
float.tex | ||
mem.tex | ||
ssa.tex | ||
types.tex | ||
brb.pdf |
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,34 @@ | ||
(TeX-add-style-hook | ||
"main" | ||
(lambda () | ||
(TeX-add-to-alist 'LaTeX-provided-package-options | ||
'(("appendix" "toc" "page") ("geometry" "margin=3cm"))) | ||
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "href") | ||
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperref") | ||
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperimage") | ||
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "hyperbaseurl") | ||
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "nolinkurl") | ||
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "url") | ||
(add-to-list 'LaTeX-verbatim-macros-with-braces-local "path") | ||
(add-to-list 'LaTeX-verbatim-macros-with-delims-local "path") | ||
(TeX-run-style-hooks | ||
"latex2e" | ||
"base" | ||
"ssa" | ||
"mem" | ||
"float" | ||
"types" | ||
"article" | ||
"art10" | ||
"appendix" | ||
"hyperref" | ||
"geometry") | ||
(TeX-add-symbols | ||
"bril" | ||
"Bril" | ||
"refint") | ||
(LaTeX-add-labels | ||
"app:opcodes" | ||
"app:types")) | ||
:latex) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this need to be it's own toml file compared to being added to
benchmarks/turnt.toml
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no i just forgot you can put multiple things in one toml file 🤦