diff options
| author | Tom Harley | 2020-01-11 02:53:36 +0000 |
|---|---|---|
| committer | Tom Harley | 2020-01-11 02:53:36 +0000 |
| commit | 1a3dc02a18a9050877288a5867e44d9c47a53542 (patch) | |
| tree | 9e0ace97436d177ab81f79372156e3f8d6a0a451 /sinter.c | |
| parent | Add option to enable/disable boxing (diff) | |
| download | sinter-1a3dc02a18a9050877288a5867e44d9c47a53542.tar.gz sinter-1a3dc02a18a9050877288a5867e44d9c47a53542.zip | |
Added int width specifiers
The width of an int can be specified at the site of its creation. For example, the following function returns an int of width 2 bits and value 1:
[def two_bit_int [] (2 1)]
Ints can still be written the old way; in these cases the compiler looks for a default int bit-width (specified with the -w flag). If a default has not been defined, the compiler throws an error.
Diffstat (limited to 'sinter.c')
| -rw-r--r-- | sinter.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -19,8 +19,6 @@ static char *input_filename; static char *output_filename; static format_t format; -static boxing_rule_t boxing_rules; - extern FILE *yyin; int yyparse(void); @@ -66,14 +64,14 @@ sexpr *new_node(sexpr *l, sexpr *r, lloc_t lloc) { return new_sexpr(BRANCH, c, lloc); } -void prologue() { +void prologue(boxing_rule_t br, uint dbw) { switch (format) { case LLVM_INTERMEDIATE: case BITCODE: case INTERPRET: - llvm_codegen_prologue(input_filename, boxing_rules); + llvm_codegen_prologue(input_filename, br, dbw); break; case GRAPHVIZ: @@ -135,12 +133,13 @@ int main(int argc, char **argv) { output_filename = 0; format = LLVM_INTERMEDIATE; - boxing_rules = ALWAYS_BOX; + boxing_rule_t boxing_rules = ALWAYS_BOX; + uint default_bit_width = 0; verbose = 0; debug("\n"); - while ((c = getopt(argc, argv, "bghilo:qsu:v")) != -1) { + while ((c = getopt(argc, argv, "bghilo:qsu:vw:")) != -1) { switch (c) { case 'b': format = BITCODE; @@ -163,7 +162,8 @@ int main(int argc, char **argv) { "-q Quiet (default)\n" "-s Output S-expression description\n" "-u <rule> Set the boxing rule: always, never, or smart\n" -"-v Verbose\n", +"-v Verbose\n" +"-w <width> Specify default width of integers in bits\n", argv[0]); exit(0); @@ -208,6 +208,10 @@ int main(int argc, char **argv) { verbose = 1; break; + case 'w': + default_bit_width = atoi(optarg); + break; + case '?': switch (optopt) { case 'o': @@ -232,7 +236,7 @@ int main(int argc, char **argv) { yyin = fopen(input_filename, "r"); } - prologue(); + prologue(boxing_rules, default_bit_width); yyparse(); epilogue(output_filename, format); return 0; |
