Comments (9)
Ok. Thank you for informing me.
I had MIR_T_V for some time but got rid of it.
I'll correct the documentation on this weekend. Thanks again.
from mir.
So what is the way to express the "void" type concept?
from mir.
So what is the way to express the "void" type concept?
This type was necessary once to express a MIR function w/o result in MIR textual representation. Since then the syntax was changed and void result function is a function with zero number of results.
So you don't need this type as for other assembler-level languages.
from mir.
extern MIR_item_t MIR_new_func (MIR_context_t ctx, const char *name, size_t nres,
MIR_type_t *res_types, size_t nargs, ...);
So how do I describe a function returning "void"? Is the following one correct ?
MIR_type_t res_type = MIR_T_I64; // What type should be used for "res_type" ?
fCompute = MIR_new_func(fContext, "compute", 0, &res_type, 2, MIR_T_P, "inputs", MIR_T_P, "outputs");
from mir.
So how do I describe a function returning "void"? Is the following one correct ?
Yes. nres
should be zero. You can pass NULL for res_types
in this case.
In MIR textual representation, void function looks like
foo: func i32:arg
and the same function returning i64 value
foo: func i64, i32:arg
from mir.
OK thanks !
My project with MIR it to recode this class https://github.com/grame-cncm/faust/blob/master-dev/compiler/generator/interpreter/fbc_llvm_compiler.hh, which generates LLVM IR, to directly generate MIR, in the context of the Faust language.
from mir.
It is an interesting project. But I guess you need a very optimized code for your language domain, including auto-vectorization. LLVM optimization pipeline can do auto-vectorization. Vectorized code vs unvectorized code can be 2-3 times faster. Although it is hard to say what real performance difference between MIR and LLVM generated code will be for your language applications (although it is definitely less than 2-3 times).
I don't think MIR will ever support vector insns. My plans concerning optimizations is to implement loop-invariant motion additionally and add new speculative insns (it is mostly for easy implementation of dynamic type languages). Although MIR could be used as tier1 JIT compiler and LLVM as tier 2 JIT compiler. LLVM is complicated and LLVM IR interface unstable (e.g. fedora distribution has a tendency to have several versions of LLVM as different LLVM versions are required for different components), MIR is much simpler but its interface can be changed too as it is not ready yet for a release.
In any case good luck with your project and I hope you share any your experience with MIR usage for your project.
from mir.
Yes I know all of that.
My hope is to have a reasonable fast JIT (like for testing the code), easier to deploy on smaller devices (like Android, possible ARM based embedded devices at some point ?) than the big LLVM chain.
from mir.
This simple program (a function that does nothing for now, and just returns):
#include "/Documents/JIT-compilation/mir/mir.h"
#include "/Documents/JIT-compilation/mir/mir-gen.h"
typedef void (*compiledFun)(int* int_heap, float* real_heap, float** inputs, float** outputs);
int main(int argc, char* argv[])
{
MIR_context_t fContext = MIR_init();
MIR_module_t fModule = MIR_new_module(fContext, "Faust");
// Create 'compute' function
MIR_item_t fCompute = MIR_new_func(fContext, "compute", 0,
NULL, 4,
MIR_T_P, "int_heap",
MIR_T_P, "real_heap",
MIR_T_P, "inputs",
MIR_T_P, "outputs");
MIR_append_insn(fContext, fCompute, MIR_new_ret_insn(fContext, 0));
// Finish function
MIR_finish_func(fContext);
// Finish module
MIR_finish_module(fContext);
// Output MIR file
FILE* file = fopen("log_mir.txt", "w");
MIR_output_module(fContext, file, fModule);
fclose(file);
// Code generation and link
MIR_gen_init(fContext);
MIR_gen_set_debug_file(fContext, stderr);
compiledFun fCompiledFun = (compiledFun)MIR_gen(fContext, fCompute);
MIR_gen_finish(fContext);
MIR_finish(fContext);
return 0;
}
crash with:
Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0 libsystem_platform.dylib 0x00007fff7215ffd0 _platform_memmove$VARIANT$Haswell + 176
1 libsystem_c.dylib 0x00007fff71f1f101 __memcpy_chk + 22
2 mir-test 0x0000000107745120 _MIR_update_code + 1072 (mir.c:3335)
3 mir-test 0x0000000107739b68 _MIR_redirect_thunk + 56 (mir-x86_64.c:70)
4 mir-test 0x000000010776d562 MIR_gen + 1794 (mir-gen.c:4641)
5 mir-test 0x0000000107732a84 main + 356 (mir-test.c:36)
6 libdyld.dylib 0x00007
fff71e4e015 start + 1
I could not find why...
from mir.
Related Issues (20)
- Segfault in `target_get_blk_type` HOT 1
- Segfault in `classify_node` HOT 1
- Segfault in `get_enum_basic_type` HOT 1
- Segfault in `get_enum_basic_type` HOT 1
- heap-buffer-overflow in `def_symbol` HOT 1
- heap-buffer-overflow in `VARR_token_tpush` and `VARR_token_tpop` HOT 3
- Assertion failed: (0), function out_op, file mir2c.c, line 65 HOT 8
- Supplying custom allocation/deallocation routines HOT 2
- Building with zig and failing at runtime on `mir_hash_1`
- Support for system calls? HOT 11
- Issue 361 test case failed HOT 2
- Shebang support for Mir files? HOT 13
- Awk has a syntax error in the benchmarks HOT 16
- Allow MIR text to be mixed in with C API
- Bug in mir-gen-x86_64.c on bbv branch HOT 3
- Add Apple Silicon CI support HOT 2
- Assertion error in 'process_aggregate_arg' for anonymous struct/union
- Assertion error in 'get_uptodate_def_insn' relating to division by `sizeof(char)` HOT 1
- Please implement _Thread_local HOT 1
- CMake build broken with 9b7aa03
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mir.