Request for add a dynamicLibrary dialect

i want to load a dynamic library in my language, but dlfcn.h is only used for UNIX, and llvm’s dynamicLibrary is a class. i don’t know how to use a c++ class at IR-level. so, Whether a dynamicLibrary dialect can be added ?

I am wondering whether you are at right abstraction level. You can merge two IR modules, but only offline:

If you use a JIT, then you can certainly mount new modules into your process.

LLVM / MLIR IR and dynamic libraries are for me different concepts. IMHO, they are incompatible.

I need explicit dynamic load and free a library at runtime, it can supply some diffrenct ability compared to static link.

Maybe it is more suitable that add it to llvm intrinsic function.

If your meaning is that the dynamicLibrary class can be linked using llvm-link. yes , it does. but i don’t know how to call it’s function at ir-level. because it is a class.

Are you jitting or compile into executable binaries?

If you use a JIT, then your host process can certainly load a dynamic library and make the symbols available to the JIT.

I have not understood your meaning. the following is the flow of compile :

lexer -> parser -> codegen -> jit/binary. 

Now i am under codegen. i need generate some IR, these IR have abilities that runtime load and free dynamic library.

If your meaning is that the jit load llvm’s dynamicLibrary.lib and expose symbols to IR , then how should i do generate IR code to using the dynamicLibrary class ? it is a class , how declare it and call it’ function in IR ?

Are you proposing that you will design and implement it?

no, i can’t. i expect someone to implement it.

In general that falls to me in the “FFI” domain: the usual way to address this is to write your own C function that exposes the functionality you want. You can implement this C function in C++ and call whatever class you want.

Alright, just i think it is very general and foundational like malloc,although not many people use it. unfortunately , the llvm implement it as a class.