Commit 677dcb5a authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Fixed readme and added a notification if muc cant determine the size of an integer constant

parent e04b2803
......@@ -363,7 +363,9 @@ namespace C
}
virtual Any<std::string> visitCtorInt(UIRParser::CtorIntContext *context) override {
auto val = accept<std::string>(context->intLiteral());
std::size_t size = (std::size_t)int_sizes[current_type];
if (!int_sizes.count(current_type))
throw antlr4::RuntimeException("Cannot determine size of integer constant (make sure the type declaration preceds the constant)");
std::size_t size = (std::size_t)int_sizes[current_type];
std::string id;
if (size <= 64) {
......
......@@ -6,37 +6,36 @@ Translates MuIR in text form and creates a correspondinng boot image, or generat
* You will ned the GNU Multiple Precision Arithmetic Library (tested with GMP 6.1.0)
* You will need the Antlr4 C++ runtime, use `git clone https://github.com/antlr/antlr4.git` and follow the build instructions in `runtime/Cpp/README.md`.
Once you've done that, copy the include files and the libraries (where $antlr4 is the root of the antlr4 git repo you just cloned):
cp -r $antlr4/runtime/Cpp/run/usr/local/include/antlr4-runtime/* include/
cp -r $antlr4/runtime/Cpp/run/usr/local/lib/* lib/
* If you wan't to compile directly (as opposed to output C files) you'll need mu, place your `libmu*` files in `./lib`
also set the environement variable MU_ZEBU to the locatation of the mu-impl-fast source code
```
cp -r $antlr4/runtime/Cpp/run/usr/local/include/antlr4-runtime/* ./include/
cp -r $antlr4/runtime/Cpp/run/usr/local/lib/* ./lib/
```
* If you want to compile directly (as opposed to output C files) you'll need Mu, place your `libmu*` files in `./lib`,
also set the environement variable MU_ZEBU to the locatation of the mu-impl-fast source code.
## C Code prerequisites
To run the generated C code you will need:
* To link with Mu (make sure that the environment variable MU_ZEBU is set to the locatation of the mu-impl-fast source code)
* A C compiler (tested with GCC version 5.4.0, whith the default std=gnu11)
* A C compiler (tested with GCC version 5.4.0, whith the default `-std=gnu11`)
## Building
Run `make` or if you don't have Mu run `make no_mu`. If you're getting load errors, try `make static`.
## Usage
Run: `LD_LIBRARY_PATH=./lib muc -r [-f primordial-function-name] bundle1.mu... bootimage`
`LD_LIBRARY_PATH=./lib muc -r [-f primordial-function-name] bundle1.mu... bootimage`
Which will compile the bundles (there must be at least one) and generate a boot image in the file `bootimage`
Mu's emmit directory (were it puts intermediate files like assemblys) will be the same folder that contains `bootimage`.
Use `-c` instead of `-r` and it won't actually do that, instead it will print C code to stdout that will have the same effect once compiled and run.
Mu's output files will be written to the same folder that contains `bootimage`.
Use `-s` instead of `-r` to do syntax checking of your input files and nothing else.
## Syntax
The syntax is specified in `UIR.g4`, all the files in `./parser` are generated from this file.
The syntax is a super set of the reference implementations syntax and the syntax used in the mu-spec.
Note: you may now specified the function signature before the version in a `.funcdef`, it is also now optional.
It adds the following 'syntax sugar':
* comments, C++ style `// ... ` and C-style `/* ... */`.
* Comments, C++ style `// ... ` and C-style `/* ... */`.
* The signature in a `.funcdef` is optional, it may also be specified before the `VERSION` name.
* If there is a signature in a `.funcdef` and no previouse corresponding `.funcdecl`, one will be created for you.
* the version name in a `.funcdef` is optional, if absent a local one (starting with a `%`) will be automatically generated
......@@ -76,7 +75,7 @@ If they are changed (or their behaviour changes), muc may not work correctly.
If you are declaring a `.const` with an integer literal, the type must be declared before the literal
(i.e. it must be declared inline like `.const @foo <int<32>> = 3` or be declared in a previous line of the bundle or in a previous bundle).
In all other cases you may reference an entity before it is declared, as long as it is declared in the same bundle (this is the same restriction the Mu-spec places).
In all other cases (except for referencing the result of an instruction or a block parameter) you may reference an entity before it is declared, as long as it is declared in the same bundle (this is the same restriction the Mu-spec places).
When using `-c`, float and double inline constants will be be considered unique (for the purposes of generating inline declarations) if there text is unique, e.g:
`%a = FADD <float> <float>1.1f <float>1.10f` will generate two constants, whereas when using `-r` it will only generate one (since 1.1 = 1.10).
......
......@@ -308,6 +308,8 @@ namespace Runtime
}
virtual Any<MuVarNode> visitCtorInt(UIRParser::CtorIntContext *context) override {
auto val = accept<std::string>(context->intLiteral());
if (!int_sizes.count(current_type))
throw antlr4::RuntimeException("Cannot determine size of integer constant (make sure the type declaration preceds the constant)");
std::size_t size = (std::size_t)int_sizes[current_type];
MuID id;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment