Commit 9114aad6 authored by John Zhang's avatar John Zhang

determine shared library extension at compile time for C scripts

parent 9f1d81ec
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
#ifdef __APPLE__
#define LIB_EXT ".dylib"
#elif __linux__
#define LIB_EXT ".so"
#elif _WIN32
#define LIB_EXT ".dll"
#endif
#define LIB_FILE_NAME(name) "lib" name LIB_EXT
int main(int argc, char** argv) {
MuVM* mu;
MuCtx* ctx;
......@@ -24,11 +31,11 @@ int main(int argc, char** argv) {
ctx = mu->new_context(mu);
bldr = ctx->new_ir_builder(ctx);
id = bldr->gen_sym(bldr, "@i8");
bldr->new_type_int(bldr, id, 8);
bldr->new_type_int(bldr, id, 0x00000008ull);
id_2 = bldr->gen_sym(bldr, "@0xff_i8");
bldr->new_const_int(bldr, id_2, id, 255);
bldr->new_const_int(bldr, id_2, id, 0x00000000000000ffull);
id_3 = bldr->gen_sym(bldr, "@0x0a_i8");
bldr->new_const_int(bldr, id_3, id, 10);
bldr->new_const_int(bldr, id_3, id, 0x000000000000000aull);
id_4 = bldr->gen_sym(bldr, "@sig__i8");
bldr->new_funcsig(bldr, id_4, NULL, 0, (MuTypeNode [1]){id}, 1);
id_5 = bldr->gen_sym(bldr, "@test_fnc");
......@@ -43,7 +50,6 @@ int main(int argc, char** argv) {
bldr->new_bb(bldr, id_7, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_9, id_10}, 2);
bldr->new_func_ver(bldr, id_6, id_5, (MuBBNode [1]){id_7}, 1);
bldr->load(bldr);
mu->compile_to_sharedlib(mu, "test_add.dylib", NULL, 0);
printf("%s\n", "test_add.dylib");
mu->compile_to_sharedlib(mu, LIB_FILE_NAME("test_add"), NULL, 0);
return 0;
}
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
#ifdef __APPLE__
#define LIB_EXT ".dylib"
#elif __linux__
#define LIB_EXT ".so"
#elif _WIN32
#define LIB_EXT ".dll"
#endif
#define LIB_FILE_NAME(name) "lib" name LIB_EXT
int main(int argc, char** argv) {
MuVM* mu_8;
MuCtx* ctx_8;
MuIRBuilder* bldr_8;
MuID id_71;
MuID id_72;
MuID id_73;
MuID id_74;
MuID id_75;
MuID id_76;
MuID id_77;
MuID id_78;
MuID id_79;
MuID id_80;
mu_8 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_8 = mu_8->new_context(mu_8);
bldr_8 = ctx_8->new_ir_builder(ctx_8);
id_71 = bldr_8->gen_sym(bldr_8, "@i64");
bldr_8->new_type_int(bldr_8, id_71, 64);
id_72 = bldr_8->gen_sym(bldr_8, "@0x8d9f9c1d58324b55_i64");
bldr_8->new_const_int(bldr_8, id_72, id_71, 10205046930492509013);
id_73 = bldr_8->gen_sym(bldr_8, "@0xd5a8f2deb00debb4_i64");
bldr_8->new_const_int(bldr_8, id_73, id_71, 15395822364416404404);
id_74 = bldr_8->gen_sym(bldr_8, "@sig__i64");
bldr_8->new_funcsig(bldr_8, id_74, NULL, 0, (MuTypeNode [1]){id_71}, 1);
id_75 = bldr_8->gen_sym(bldr_8, "@test_fnc");
bldr_8->new_func(bldr_8, id_75, id_74);
id_76 = bldr_8->gen_sym(bldr_8, "@test_fnc_v1");
id_77 = bldr_8->gen_sym(bldr_8, "@test_fnc_v1.blk0");
id_78 = bldr_8->gen_sym(bldr_8, "@test_fnc_v1.blk0.res");
id_79 = bldr_8->gen_sym(bldr_8, NULL);
bldr_8->new_binop(bldr_8, id_79, id_78, MU_BINOP_AND, id_71, id_72, id_73, MU_NO_ID);
id_80 = bldr_8->gen_sym(bldr_8, NULL);
bldr_8->new_ret(bldr_8, id_80, (MuVarNode [1]){id_78}, 1);
bldr_8->new_bb(bldr_8, id_77, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_79, id_80}, 2);
bldr_8->new_func_ver(bldr_8, id_76, id_75, (MuBBNode [1]){id_77}, 1);
bldr_8->load(bldr_8);
mu_8->compile_to_sharedlib(mu_8, "test_and.dylib", NULL, 0);
printf("%s\n", "test_and.dylib");
MuVM* mu_11;
MuCtx* ctx_11;
MuIRBuilder* bldr_11;
MuID id_101;
MuID id_102;
MuID id_103;
MuID id_104;
MuID id_105;
MuID id_106;
MuID id_107;
MuID id_108;
MuID id_109;
MuID id_110;
mu_11 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_11 = mu_11->new_context(mu_11);
bldr_11 = ctx_11->new_ir_builder(ctx_11);
id_101 = bldr_11->gen_sym(bldr_11, "@i64");
bldr_11->new_type_int(bldr_11, id_101, 0x00000040ull);
id_102 = bldr_11->gen_sym(bldr_11, "@0x8d9f9c1d58324b55_i64");
bldr_11->new_const_int(bldr_11, id_102, id_101, 0x8d9f9c1d58324b55ull);
id_103 = bldr_11->gen_sym(bldr_11, "@0xd5a8f2deb00debb4_i64");
bldr_11->new_const_int(bldr_11, id_103, id_101, 0xd5a8f2deb00debb4ull);
id_104 = bldr_11->gen_sym(bldr_11, "@sig__i64");
bldr_11->new_funcsig(bldr_11, id_104, NULL, 0, (MuTypeNode [1]){id_101}, 1);
id_105 = bldr_11->gen_sym(bldr_11, "@test_fnc");
bldr_11->new_func(bldr_11, id_105, id_104);
id_106 = bldr_11->gen_sym(bldr_11, "@test_fnc_v1");
id_107 = bldr_11->gen_sym(bldr_11, "@test_fnc_v1.blk0");
id_108 = bldr_11->gen_sym(bldr_11, "@test_fnc_v1.blk0.res");
id_109 = bldr_11->gen_sym(bldr_11, NULL);
bldr_11->new_binop(bldr_11, id_109, id_108, MU_BINOP_AND, id_101, id_102, id_103, MU_NO_ID);
id_110 = bldr_11->gen_sym(bldr_11, NULL);
bldr_11->new_ret(bldr_11, id_110, (MuVarNode [1]){id_108}, 1);
bldr_11->new_bb(bldr_11, id_107, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_109, id_110}, 2);
bldr_11->new_func_ver(bldr_11, id_106, id_105, (MuBBNode [1]){id_107}, 1);
bldr_11->load(bldr_11);
mu_11->compile_to_sharedlib(mu_11, LIB_FILE_NAME("test_and"), NULL, 0);
return 0;
}
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
#ifdef __APPLE__
#define LIB_EXT ".dylib"
#elif __linux__
#define LIB_EXT ".so"
#elif _WIN32
#define LIB_EXT ".dll"
#endif
#define LIB_FILE_NAME(name) "lib" name LIB_EXT
int main(int argc, char** argv) {
MuVM* mu_10;
MuCtx* ctx_10;
......@@ -24,11 +31,11 @@ int main(int argc, char** argv) {
ctx_10 = mu_10->new_context(mu_10);
bldr_10 = ctx_10->new_ir_builder(ctx_10);
id_91 = bldr_10->gen_sym(bldr_10, "@i64");
bldr_10->new_type_int(bldr_10, id_91, 64);
bldr_10->new_type_int(bldr_10, id_91, 0x00000040ull);
id_92 = bldr_10->gen_sym(bldr_10, "@0x8d9f9c1d58324b55_i64");
bldr_10->new_const_int(bldr_10, id_92, id_91, 10205046930492509013);
bldr_10->new_const_int(bldr_10, id_92, id_91, 0x8d9f9c1d58324b55ull);
id_93 = bldr_10->gen_sym(bldr_10, "@0x0a_i64");
bldr_10->new_const_int(bldr_10, id_93, id_91, 10);
bldr_10->new_const_int(bldr_10, id_93, id_91, 0x000000000000000aull);
id_94 = bldr_10->gen_sym(bldr_10, "@sig__i64");
bldr_10->new_funcsig(bldr_10, id_94, NULL, 0, (MuTypeNode [1]){id_91}, 1);
id_95 = bldr_10->gen_sym(bldr_10, "@test_fnc");
......@@ -43,7 +50,6 @@ int main(int argc, char** argv) {
bldr_10->new_bb(bldr_10, id_97, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_99, id_100}, 2);
bldr_10->new_func_ver(bldr_10, id_96, id_95, (MuBBNode [1]){id_97}, 1);
bldr_10->load(bldr_10);
mu_10->compile_to_sharedlib(mu_10, "test_ashr.dylib", NULL, 0);
printf("%s\n", "test_ashr.dylib");
mu_10->compile_to_sharedlib(mu_10, LIB_FILE_NAME("test_ashr"), NULL, 0);
return 0;
}
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
#ifdef __APPLE__
#define LIB_EXT ".dylib"
#elif __linux__
#define LIB_EXT ".so"
#elif _WIN32
#define LIB_EXT ".dll"
#endif
#define LIB_FILE_NAME(name) "lib" name LIB_EXT
int main(int argc, char** argv) {
MuVM* mu_19;
MuCtx* ctx_19;
MuIRBuilder* bldr_19;
MuID id_232;
MuID id_233;
MuID id_234;
MuID id_235;
MuID id_236;
MuID id_237;
MuID id_238;
MuID id_239;
MuID id_240;
MuID id_241;
MuID id_242;
MuID id_243;
MuID id_244;
MuID id_245;
MuID id_246;
mu_19 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_19 = mu_19->new_context(mu_19);
bldr_19 = ctx_19->new_ir_builder(ctx_19);
id_232 = bldr_19->gen_sym(bldr_19, "@i64");
bldr_19->new_type_int(bldr_19, id_232, 64);
id_233 = bldr_19->gen_sym(bldr_19, "@10_i64");
bldr_19->new_const_int(bldr_19, id_233, id_232, 10);
id_234 = bldr_19->gen_sym(bldr_19, "@20_i64");
bldr_19->new_const_int(bldr_19, id_234, id_232, 20);
id_235 = bldr_19->gen_sym(bldr_19, "@sig__i64");
bldr_19->new_funcsig(bldr_19, id_235, NULL, 0, (MuTypeNode [1]){id_232}, 1);
id_236 = bldr_19->gen_sym(bldr_19, "@test_fnc");
bldr_19->new_func(bldr_19, id_236, id_235);
id_237 = bldr_19->gen_sym(bldr_19, "@test_fnc.v1");
id_238 = bldr_19->gen_sym(bldr_19, "@test_fnc.v1.blk0");
id_239 = bldr_19->gen_sym(bldr_19, "@test_fnc.v1.blk1");
id_240 = bldr_19->gen_sym(bldr_19, NULL);
id_241 = bldr_19->gen_sym(bldr_19, NULL);
bldr_19->new_dest_clause(bldr_19, id_241, id_239, (MuVarNode [2]){id_233, id_234}, 2);
bldr_19->new_branch(bldr_19, id_240, id_241);
bldr_19->new_bb(bldr_19, id_238, NULL, NULL, 0, MU_NO_ID, (MuInstNode [1]){id_240}, 1);
id_242 = bldr_19->gen_sym(bldr_19, "@test_fnc.v1.blk1.a");
id_243 = bldr_19->gen_sym(bldr_19, "@test_fnc.v1.blk1.b");
id_244 = bldr_19->gen_sym(bldr_19, "@test_fnc.v1.blk1.res");
id_245 = bldr_19->gen_sym(bldr_19, NULL);
bldr_19->new_binop(bldr_19, id_245, id_244, MU_BINOP_ADD, id_232, id_242, id_243, MU_NO_ID);
id_246 = bldr_19->gen_sym(bldr_19, NULL);
bldr_19->new_ret(bldr_19, id_246, (MuVarNode [1]){id_244}, 1);
bldr_19->new_bb(bldr_19, id_239, (MuID [2]){id_242, id_243}, (MuTypeNode [2]){id_232, id_232}, 2, MU_NO_ID, (MuInstNode [2]){id_245, id_246}, 2);
bldr_19->new_func_ver(bldr_19, id_237, id_236, (MuBBNode [2]){id_238, id_239}, 2);
bldr_19->load(bldr_19);
mu_19->compile_to_sharedlib(mu_19, "test_branch.dylib", NULL, 0);
printf("%s\n", "test_branch.dylib");
MuVM* mu_24;
MuCtx* ctx_24;
MuIRBuilder* bldr_24;
MuID id_289;
MuID id_290;
MuID id_291;
MuID id_292;
MuID id_293;
MuID id_294;
MuID id_295;
MuID id_296;
MuID id_297;
MuID id_298;
MuID id_299;
MuID id_300;
MuID id_301;
MuID id_302;
MuID id_303;
mu_24 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_24 = mu_24->new_context(mu_24);
bldr_24 = ctx_24->new_ir_builder(ctx_24);
id_289 = bldr_24->gen_sym(bldr_24, "@i64");
bldr_24->new_type_int(bldr_24, id_289, 0x00000040ull);
id_290 = bldr_24->gen_sym(bldr_24, "@10_i64");
bldr_24->new_const_int(bldr_24, id_290, id_289, 0x000000000000000aull);
id_291 = bldr_24->gen_sym(bldr_24, "@20_i64");
bldr_24->new_const_int(bldr_24, id_291, id_289, 0x0000000000000014ull);
id_292 = bldr_24->gen_sym(bldr_24, "@sig__i64");
bldr_24->new_funcsig(bldr_24, id_292, NULL, 0, (MuTypeNode [1]){id_289}, 1);
id_293 = bldr_24->gen_sym(bldr_24, "@test_fnc");
bldr_24->new_func(bldr_24, id_293, id_292);
id_294 = bldr_24->gen_sym(bldr_24, "@test_fnc.v1");
id_295 = bldr_24->gen_sym(bldr_24, "@test_fnc.v1.blk0");
id_296 = bldr_24->gen_sym(bldr_24, "@test_fnc.v1.blk1");
id_297 = bldr_24->gen_sym(bldr_24, NULL);
id_298 = bldr_24->gen_sym(bldr_24, NULL);
bldr_24->new_dest_clause(bldr_24, id_298, id_296, (MuVarNode [2]){id_290, id_291}, 2);
bldr_24->new_branch(bldr_24, id_297, id_298);
bldr_24->new_bb(bldr_24, id_295, NULL, NULL, 0, MU_NO_ID, (MuInstNode [1]){id_297}, 1);
id_299 = bldr_24->gen_sym(bldr_24, "@test_fnc.v1.blk1.a");
id_300 = bldr_24->gen_sym(bldr_24, "@test_fnc.v1.blk1.b");
id_301 = bldr_24->gen_sym(bldr_24, "@test_fnc.v1.blk1.res");
id_302 = bldr_24->gen_sym(bldr_24, NULL);
bldr_24->new_binop(bldr_24, id_302, id_301, MU_BINOP_ADD, id_289, id_299, id_300, MU_NO_ID);
id_303 = bldr_24->gen_sym(bldr_24, NULL);
bldr_24->new_ret(bldr_24, id_303, (MuVarNode [1]){id_301}, 1);
bldr_24->new_bb(bldr_24, id_296, (MuID [2]){id_299, id_300}, (MuTypeNode [2]){id_289, id_289}, 2, MU_NO_ID, (MuInstNode [2]){id_302, id_303}, 2);
bldr_24->new_func_ver(bldr_24, id_294, id_293, (MuBBNode [2]){id_295, id_296}, 2);
bldr_24->load(bldr_24);
mu_24->compile_to_sharedlib(mu_24, LIB_FILE_NAME("test_branch"), NULL, 0);
return 0;
}
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
#ifdef __APPLE__
#define LIB_EXT ".dylib"
#elif __linux__
#define LIB_EXT ".so"
#elif _WIN32
#define LIB_EXT ".dll"
#endif
#define LIB_FILE_NAME(name) "lib" name LIB_EXT
int main(int argc, char** argv) {
MuVM* mu_20;
MuCtx* ctx_20;
MuIRBuilder* bldr_20;
MuID id_247;
MuID id_248;
MuID id_249;
MuID id_250;
MuID id_251;
MuID id_252;
MuID id_253;
MuID id_254;
MuID id_255;
MuID id_256;
MuID id_257;
MuID id_258;
MuID id_259;
MuID id_260;
MuID id_261;
MuID id_262;
MuID id_263;
MuID id_264;
MuID id_265;
MuID id_266;
MuID id_267;
MuID id_268;
MuID id_269;
MuID id_270;
MuID id_271;
MuID id_272;
MuID id_273;
mu_20 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_20 = mu_20->new_context(mu_20);
bldr_20 = ctx_20->new_ir_builder(ctx_20);
id_247 = bldr_20->gen_sym(bldr_20, "@i8");
bldr_20->new_type_int(bldr_20, id_247, 8);
id_248 = bldr_20->gen_sym(bldr_20, "@i64");
bldr_20->new_type_int(bldr_20, id_248, 64);
id_249 = bldr_20->gen_sym(bldr_20, "@TRUE");
bldr_20->new_const_int(bldr_20, id_249, id_247, 1);
id_250 = bldr_20->gen_sym(bldr_20, "@10_i64");
bldr_20->new_const_int(bldr_20, id_250, id_248, 10);
id_251 = bldr_20->gen_sym(bldr_20, "@20_i64");
bldr_20->new_const_int(bldr_20, id_251, id_248, 20);
id_252 = bldr_20->gen_sym(bldr_20, "@sig_i8_i64");
bldr_20->new_funcsig(bldr_20, id_252, (MuTypeNode [1]){id_247}, 1, (MuTypeNode [1]){id_248}, 1);
id_253 = bldr_20->gen_sym(bldr_20, "@test_fnc");
bldr_20->new_func(bldr_20, id_253, id_252);
id_254 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1");
id_255 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk0");
id_256 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk1");
id_257 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk2");
id_258 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk0.sel");
id_259 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk0.flag");
id_260 = bldr_20->gen_sym(bldr_20, NULL);
bldr_20->new_cmp(bldr_20, id_260, id_259, MU_CMP_EQ, id_247, id_258, id_249);
id_261 = bldr_20->gen_sym(bldr_20, NULL);
id_262 = bldr_20->gen_sym(bldr_20, NULL);
bldr_20->new_dest_clause(bldr_20, id_262, id_256, (MuVarNode [2]){id_250, id_251}, 2);
id_263 = bldr_20->gen_sym(bldr_20, NULL);
bldr_20->new_dest_clause(bldr_20, id_263, id_257, (MuVarNode [2]){id_250, id_251}, 2);
bldr_20->new_branch2(bldr_20, id_261, id_259, id_262, id_263);
bldr_20->new_bb(bldr_20, id_255, (MuID [1]){id_258}, (MuTypeNode [1]){id_247}, 1, MU_NO_ID, (MuInstNode [2]){id_260, id_261}, 2);
id_264 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk1.a");
id_265 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk1.b");
id_266 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk1.res");
id_267 = bldr_20->gen_sym(bldr_20, NULL);
bldr_20->new_binop(bldr_20, id_267, id_266, MU_BINOP_ADD, id_248, id_264, id_265, MU_NO_ID);
id_268 = bldr_20->gen_sym(bldr_20, NULL);
bldr_20->new_ret(bldr_20, id_268, (MuVarNode [1]){id_266}, 1);
bldr_20->new_bb(bldr_20, id_256, (MuID [2]){id_264, id_265}, (MuTypeNode [2]){id_248, id_248}, 2, MU_NO_ID, (MuInstNode [2]){id_267, id_268}, 2);
id_269 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk2.a");
id_270 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk2.b");
id_271 = bldr_20->gen_sym(bldr_20, "@test_fnc.v1.blk2.res");
id_272 = bldr_20->gen_sym(bldr_20, NULL);
bldr_20->new_binop(bldr_20, id_272, id_271, MU_BINOP_MUL, id_248, id_269, id_270, MU_NO_ID);
id_273 = bldr_20->gen_sym(bldr_20, NULL);
bldr_20->new_ret(bldr_20, id_273, (MuVarNode [1]){id_271}, 1);
bldr_20->new_bb(bldr_20, id_257, (MuID [2]){id_269, id_270}, (MuTypeNode [2]){id_248, id_248}, 2, MU_NO_ID, (MuInstNode [2]){id_272, id_273}, 2);
bldr_20->new_func_ver(bldr_20, id_254, id_253, (MuBBNode [3]){id_255, id_256, id_257}, 3);
bldr_20->load(bldr_20);
mu_20->compile_to_sharedlib(mu_20, "test_branch2.dylib", NULL, 0);
printf("%s\n", "test_branch2.dylib");
MuVM* mu_25;
MuCtx* ctx_25;
MuIRBuilder* bldr_25;
MuID id_304;
MuID id_305;
MuID id_306;
MuID id_307;
MuID id_308;
MuID id_309;
MuID id_310;
MuID id_311;
MuID id_312;
MuID id_313;
MuID id_314;
MuID id_315;
MuID id_316;
MuID id_317;
MuID id_318;
MuID id_319;
MuID id_320;
MuID id_321;
MuID id_322;
MuID id_323;
MuID id_324;
MuID id_325;
MuID id_326;
MuID id_327;
MuID id_328;
MuID id_329;
MuID id_330;
mu_25 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_25 = mu_25->new_context(mu_25);
bldr_25 = ctx_25->new_ir_builder(ctx_25);
id_304 = bldr_25->gen_sym(bldr_25, "@i8");
bldr_25->new_type_int(bldr_25, id_304, 0x00000008ull);
id_305 = bldr_25->gen_sym(bldr_25, "@i64");
bldr_25->new_type_int(bldr_25, id_305, 0x00000040ull);
id_306 = bldr_25->gen_sym(bldr_25, "@TRUE");
bldr_25->new_const_int(bldr_25, id_306, id_304, 0x0000000000000001ull);
id_307 = bldr_25->gen_sym(bldr_25, "@10_i64");
bldr_25->new_const_int(bldr_25, id_307, id_305, 0x000000000000000aull);
id_308 = bldr_25->gen_sym(bldr_25, "@20_i64");
bldr_25->new_const_int(bldr_25, id_308, id_305, 0x0000000000000014ull);
id_309 = bldr_25->gen_sym(bldr_25, "@sig_i8_i64");
bldr_25->new_funcsig(bldr_25, id_309, (MuTypeNode [1]){id_304}, 1, (MuTypeNode [1]){id_305}, 1);
id_310 = bldr_25->gen_sym(bldr_25, "@test_fnc");
bldr_25->new_func(bldr_25, id_310, id_309);
id_311 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1");
id_312 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk0");
id_313 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk1");
id_314 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk2");
id_315 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk0.sel");
id_316 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk0.flag");
id_317 = bldr_25->gen_sym(bldr_25, NULL);
bldr_25->new_cmp(bldr_25, id_317, id_316, MU_CMP_EQ, id_304, id_315, id_306);
id_318 = bldr_25->gen_sym(bldr_25, NULL);
id_319 = bldr_25->gen_sym(bldr_25, NULL);
bldr_25->new_dest_clause(bldr_25, id_319, id_313, (MuVarNode [2]){id_307, id_308}, 2);
id_320 = bldr_25->gen_sym(bldr_25, NULL);
bldr_25->new_dest_clause(bldr_25, id_320, id_314, (MuVarNode [2]){id_307, id_308}, 2);
bldr_25->new_branch2(bldr_25, id_318, id_316, id_319, id_320);
bldr_25->new_bb(bldr_25, id_312, (MuID [1]){id_315}, (MuTypeNode [1]){id_304}, 1, MU_NO_ID, (MuInstNode [2]){id_317, id_318}, 2);
id_321 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk1.a");
id_322 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk1.b");
id_323 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk1.res");
id_324 = bldr_25->gen_sym(bldr_25, NULL);
bldr_25->new_binop(bldr_25, id_324, id_323, MU_BINOP_ADD, id_305, id_321, id_322, MU_NO_ID);
id_325 = bldr_25->gen_sym(bldr_25, NULL);
bldr_25->new_ret(bldr_25, id_325, (MuVarNode [1]){id_323}, 1);
bldr_25->new_bb(bldr_25, id_313, (MuID [2]){id_321, id_322}, (MuTypeNode [2]){id_305, id_305}, 2, MU_NO_ID, (MuInstNode [2]){id_324, id_325}, 2);
id_326 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk2.a");
id_327 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk2.b");
id_328 = bldr_25->gen_sym(bldr_25, "@test_fnc.v1.blk2.res");
id_329 = bldr_25->gen_sym(bldr_25, NULL);
bldr_25->new_binop(bldr_25, id_329, id_328, MU_BINOP_MUL, id_305, id_326, id_327, MU_NO_ID);
id_330 = bldr_25->gen_sym(bldr_25, NULL);
bldr_25->new_ret(bldr_25, id_330, (MuVarNode [1]){id_328}, 1);
bldr_25->new_bb(bldr_25, id_314, (MuID [2]){id_326, id_327}, (MuTypeNode [2]){id_305, id_305}, 2, MU_NO_ID, (MuInstNode [2]){id_329, id_330}, 2);
bldr_25->new_func_ver(bldr_25, id_311, id_310, (MuBBNode [3]){id_312, id_313, id_314}, 3);
bldr_25->load(bldr_25);
mu_25->compile_to_sharedlib(mu_25, LIB_FILE_NAME("test_branch2"), NULL, 0);
return 0;
}
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
#ifdef __APPLE__
#define LIB_EXT ".dylib"
#elif __linux__
#define LIB_EXT ".so"
#elif _WIN32
#define LIB_EXT ".dll"
#endif
#define LIB_FILE_NAME(name) "lib" name LIB_EXT
int main(int argc, char** argv) {
MuVM* mu_21;
MuCtx* ctx_21;
MuIRBuilder* bldr_21;
MuID id_274;
MuID id_275;
MuID id_276;
MuID id_277;
MuID id_278;
MuID id_279;
MuID id_280;
MuID id_281;
MuID id_282;
MuID id_283;
MuID id_284;
mu_21 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_21 = mu_21->new_context(mu_21);
bldr_21 = ctx_21->new_ir_builder(ctx_21);
id_274 = bldr_21->gen_sym(bldr_21, "@i64");
bldr_21->new_type_int(bldr_21, id_274, 64);
id_275 = bldr_21->gen_sym(bldr_21, "@sig_i64_i64");
bldr_21->new_funcsig(bldr_21, id_275, (MuTypeNode [1]){id_274}, 1, (MuTypeNode [1]){id_274}, 1);
id_276 = bldr_21->gen_sym(bldr_21, "@fnpsig_i64_i64");
bldr_21->new_type_ufuncptr(bldr_21, id_276, id_275);
id_277 = bldr_21->gen_sym(bldr_21, "@c_fnc");
bldr_21->new_const_extern(bldr_21, id_277, id_276, "fnc");
id_278 = bldr_21->gen_sym(bldr_21, "@test_ccall");
bldr_21->new_func(bldr_21, id_278, id_275);
id_279 = bldr_21->gen_sym(bldr_21, "@test_ccall_v1");
id_280 = bldr_21->gen_sym(bldr_21, "@test_ccall_v1.blk0");
id_281 = bldr_21->gen_sym(bldr_21, "@test_ccall_v1.blk0.k");
id_282 = bldr_21->gen_sym(bldr_21, "@test_ccall_v1.blk0.res");
id_283 = bldr_21->gen_sym(bldr_21, NULL);
bldr_21->new_ccall(bldr_21, id_283, (MuID [1]){id_282}, 1, MU_CC_DEFAULT, id_276, id_275, id_277, (MuVarNode [1]){id_281}, 1, MU_NO_ID, MU_NO_ID);
id_284 = bldr_21->gen_sym(bldr_21, NULL);
bldr_21->new_ret(bldr_21, id_284, (MuVarNode [1]){id_282}, 1);
bldr_21->new_bb(bldr_21, id_280, (MuID [1]){id_281}, (MuTypeNode [1]){id_274}, 1, MU_NO_ID, (MuInstNode [2]){id_283, id_284}, 2);
bldr_21->new_func_ver(bldr_21, id_279, id_278, (MuBBNode [1]){id_280}, 1);
bldr_21->load(bldr_21);
mu_21->compile_to_sharedlib(mu_21, "test_ccall.dylib", (char*[]){&"suite/test_ccall_fnc.c"}, 1);
printf("%s\n", "test_ccall.dylib");
MuVM* mu_26;
MuCtx* ctx_26;
MuIRBuilder* bldr_26;
MuID id_331;
MuID id_332;
MuID id_333;
MuID id_334;
MuID id_335;
MuID id_336;
MuID id_337;
MuID id_338;
MuID id_339;
MuID id_340;
MuID id_341;
mu_26 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_26 = mu_26->new_context(mu_26);
bldr_26 = ctx_26->new_ir_builder(ctx_26);
id_331 = bldr_26->gen_sym(bldr_26, "@i64");
bldr_26->new_type_int(bldr_26, id_331, 0x00000040ull);
id_332 = bldr_26->gen_sym(bldr_26, "@sig_i64_i64");
bldr_26->new_funcsig(bldr_26, id_332, (MuTypeNode [1]){id_331}, 1, (MuTypeNode [1]){id_331}, 1);
id_333 = bldr_26->gen_sym(bldr_26, "@fnpsig_i64_i64");
bldr_26->new_type_ufuncptr(bldr_26, id_333, id_332);
id_334 = bldr_26->gen_sym(bldr_26, "@c_fnc");
bldr_26->new_const_extern(bldr_26, id_334, id_333, "fnc");
id_335 = bldr_26->gen_sym(bldr_26, "@test_ccall");
bldr_26->new_func(bldr_26, id_335, id_332);
id_336 = bldr_26->gen_sym(bldr_26, "@test_ccall_v1");
id_337 = bldr_26->gen_sym(bldr_26, "@test_ccall_v1.blk0");
id_338 = bldr_26->gen_sym(bldr_26, "@test_ccall_v1.blk0.k");
id_339 = bldr_26->gen_sym(bldr_26, "@test_ccall_v1.blk0.res");
id_340 = bldr_26->gen_sym(bldr_26, NULL);
bldr_26->new_ccall(bldr_26, id_340, (MuID [1]){id_339}, 1, MU_CC_DEFAULT, id_333, id_332, id_334, (MuVarNode [1]){id_338}, 1, MU_NO_ID, MU_NO_ID);
id_341 = bldr_26->gen_sym(bldr_26, NULL);
bldr_26->new_ret(bldr_26, id_341, (MuVarNode [1]){id_339}, 1);
bldr_26->new_bb(bldr_26, id_337, (MuID [1]){id_338}, (MuTypeNode [1]){id_331}, 1, MU_NO_ID, (MuInstNode [2]){id_340, id_341}, 2);
bldr_26->new_func_ver(bldr_26, id_336, id_335, (MuBBNode [1]){id_337}, 1);
bldr_26->load(bldr_26);
mu_26->compile_to_sharedlib(mu_26, LIB_FILE_NAME("test_ccall"), (char*[]){&"suite/test_ccall_fnc.c"}, 1);
return 0;
}
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
#ifdef __APPLE__
#define LIB_EXT ".dylib"
#elif __linux__
#define LIB_EXT ".so"
#elif _WIN32
#define LIB_EXT ".dll"
#endif
#define LIB_FILE_NAME(name) "lib" name LIB_EXT
int main(int argc, char** argv) {
MuVM* mu_32;
MuCtx* ctx_32;
MuIRBuilder* bldr_32;
MuID id_457;
MuID id_458;
MuID id_459;
MuID id_460;
MuID id_461;
MuID id_462;
MuID id_463;
MuID id_464;
mu_32 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_32 = mu_32->new_context(mu_32);
bldr_32 = ctx_32->new_ir_builder(ctx_32);
id_457 = bldr_32->gen_sym(bldr_32, "@i32");
bldr_32->new_type_int(bldr_32, id_457, 8);
id_458 = bldr_32->gen_sym(bldr_32, "@0_i32");
bldr_32->new_const_int(bldr_32, id_458, id_457, 0);
id_459 = bldr_32->gen_sym(bldr_32, "@sig__i32");
bldr_32->new_funcsig(bldr_32, id_459, NULL, 0, (MuTypeNode [1]){id_457}, 1);
id_460 = bldr_32->gen_sym(bldr_32, "@test_fnc");
bldr_32->new_func(bldr_32, id_460, id_459);
id_461 = bldr_32->gen_sym(bldr_32, "@test_fnc_v1");
id_462 = bldr_32->gen_sym(bldr_32, "@test_fnc_v1.blk0");
id_463 = bldr_32->gen_sym(bldr_32, "@test_fnc_v1.blk0.res");
id_464 = bldr_32->gen_sym(bldr_32, NULL);
bldr_32->new_ret(bldr_32, id_464, (MuVarNode [1]){id_458}, 1);
bldr_32->new_bb(bldr_32, id_462, NULL, NULL, 0, MU_NO_ID, (MuInstNode [1]){id_464}, 1);
bldr_32->new_func_ver(bldr_32, id_461, id_460, (MuBBNode [1]){id_462}, 1);
bldr_32->load(bldr_32);
mu_32->compile_to_sharedlib(mu_32, "test_constfunc.dylib", NULL, 0);
printf("%s\n", "test_constfunc.dylib");
MuVM* mu_53;
MuCtx* ctx_53;
MuIRBuilder* bldr_53;
MuID id_707;
MuID id_708;
MuID id_709;
MuID id_710;
MuID id_711;
MuID id_712;
MuID id_713;
MuID id_714;
mu_53 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_53 = mu_53->new_context(mu_53);
bldr_53 = ctx_53->new_ir_builder(ctx_53);
id_707 = bldr_53->gen_sym(bldr_53, "@i32");
bldr_53->new_type_int(bldr_53, id_707, 0x00000008ull);
id_708 = bldr_53->gen_sym(bldr_53, "@0_i32");
bldr_53->new_const_int(bldr_53, id_708, id_707, 0x0000000000000000ull);
id_709 = bldr_53->gen_sym(bldr_53, "@sig__i32");
bldr_53->new_funcsig(bldr_53, id_709, NULL, 0, (MuTypeNode [1]){id_707}, 1);
id_710 = bldr_53->gen_sym(bldr_53, "@test_fnc");
bldr_53->new_func(bldr_53, id_710, id_709);
id_711 = bldr_53->gen_sym(bldr_53, "@test_fnc_v1");
id_712 = bldr_53->gen_sym(bldr_53, "@test_fnc_v1.blk0");
id_713 = bldr_53->gen_sym(bldr_53, "@test_fnc_v1.blk0.res");