GitLab will be partched to the latest stable version on 15 July 2020 at 2.00pm (AEDT) to 2.30pm (AEDT) due to Security Patch Availability. During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit c4e282d7 authored by John Zhang's avatar John Zhang

double precision floating point tests

parent 62870f1f
// Compile with flag -std=c99
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <dlfcn.h>
#include "muapi.h"
#include "mu-fastimpl.h"
int main(int argc, char** argv) {
MuVM* mu_26;
MuCtx* ctx_26;
MuIRBuilder* bldr_26;
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_332 = bldr_26->gen_sym(bldr_26, "@dbl");
bldr_26->new_type_double(bldr_26, id_332);
id_333 = bldr_26->gen_sym(bldr_26, "@pi");
bldr_26->new_const_double(bldr_26, id_333, id_332, 3.14159299999999985786);
id_334 = bldr_26->gen_sym(bldr_26, "@e");
bldr_26->new_const_double(bldr_26, id_334, id_332, 2.71828000000000002956);
id_335 = bldr_26->gen_sym(bldr_26, "@sig__dbl");
bldr_26->new_funcsig(bldr_26, id_335, NULL, 0, (MuTypeNode [1]){id_332}, 1);
id_336 = bldr_26->gen_sym(bldr_26, "@test_fnc");
bldr_26->new_func(bldr_26, id_336, id_335);
id_337 = bldr_26->gen_sym(bldr_26, "@test_fnc.v1");
id_338 = bldr_26->gen_sym(bldr_26, "@test_fnc.v1.blk0");
id_339 = bldr_26->gen_sym(bldr_26, "@test_fnc.v1.blk0.res");
id_340 = bldr_26->gen_sym(bldr_26, NULL);
bldr_26->new_binop(bldr_26, id_340, id_339, MU_BINOP_FADD, id_332, id_333, id_334, 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_338, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_340, id_341}, 2);
bldr_26->new_func_ver(bldr_26, id_337, id_336, (MuBBNode [1]){id_338}, 1);
bldr_26->load(bldr_26);
mu_26->compile_to_sharedlib(mu_26, "test_double_add.dylib", NULL, 0);
printf("%s\n", "test_double_add.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_29;
MuCtx* ctx_29;
MuIRBuilder* bldr_29;
MuID id_362;
MuID id_363;
MuID id_364;
MuID id_365;
MuID id_366;
MuID id_367;
MuID id_368;
MuID id_369;
MuID id_370;
MuID id_371;
mu_29 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_29 = mu_29->new_context(mu_29);
bldr_29 = ctx_29->new_ir_builder(ctx_29);
id_362 = bldr_29->gen_sym(bldr_29, "@dbl");
bldr_29->new_type_double(bldr_29, id_362);
id_363 = bldr_29->gen_sym(bldr_29, "@pi");
bldr_29->new_const_double(bldr_29, id_363, id_362, 3.14159299999999985786);
id_364 = bldr_29->gen_sym(bldr_29, "@e");
bldr_29->new_const_double(bldr_29, id_364, id_362, 2.71828000000000002956);
id_365 = bldr_29->gen_sym(bldr_29, "@sig__dbl");
bldr_29->new_funcsig(bldr_29, id_365, NULL, 0, (MuTypeNode [1]){id_362}, 1);
id_366 = bldr_29->gen_sym(bldr_29, "@test_fnc");
bldr_29->new_func(bldr_29, id_366, id_365);
id_367 = bldr_29->gen_sym(bldr_29, "@test_fnc.v1");
id_368 = bldr_29->gen_sym(bldr_29, "@test_fnc.v1.blk0");
id_369 = bldr_29->gen_sym(bldr_29, "@test_fnc.v1.blk0.res");
id_370 = bldr_29->gen_sym(bldr_29, NULL);
bldr_29->new_binop(bldr_29, id_370, id_369, MU_BINOP_FMUL, id_362, id_363, id_364, MU_NO_ID);
id_371 = bldr_29->gen_sym(bldr_29, NULL);
bldr_29->new_ret(bldr_29, id_371, (MuVarNode [1]){id_369}, 1);
bldr_29->new_bb(bldr_29, id_368, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_370, id_371}, 2);
bldr_29->new_func_ver(bldr_29, id_367, id_366, (MuBBNode [1]){id_368}, 1);
bldr_29->load(bldr_29);
mu_29->compile_to_sharedlib(mu_29, "test_double_div.dylib", NULL, 0);
printf("%s\n", "test_double_div.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_28;
MuCtx* ctx_28;
MuIRBuilder* bldr_28;
MuID id_352;
MuID id_353;
MuID id_354;
MuID id_355;
MuID id_356;
MuID id_357;
MuID id_358;
MuID id_359;
MuID id_360;
MuID id_361;
mu_28 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_28 = mu_28->new_context(mu_28);
bldr_28 = ctx_28->new_ir_builder(ctx_28);
id_352 = bldr_28->gen_sym(bldr_28, "@dbl");
bldr_28->new_type_double(bldr_28, id_352);
id_353 = bldr_28->gen_sym(bldr_28, "@pi");
bldr_28->new_const_double(bldr_28, id_353, id_352, 3.14159299999999985786);
id_354 = bldr_28->gen_sym(bldr_28, "@e");
bldr_28->new_const_double(bldr_28, id_354, id_352, 2.71828000000000002956);
id_355 = bldr_28->gen_sym(bldr_28, "@sig__dbl");
bldr_28->new_funcsig(bldr_28, id_355, NULL, 0, (MuTypeNode [1]){id_352}, 1);
id_356 = bldr_28->gen_sym(bldr_28, "@test_fnc");
bldr_28->new_func(bldr_28, id_356, id_355);
id_357 = bldr_28->gen_sym(bldr_28, "@test_fnc.v1");
id_358 = bldr_28->gen_sym(bldr_28, "@test_fnc.v1.blk0");
id_359 = bldr_28->gen_sym(bldr_28, "@test_fnc.v1.blk0.res");
id_360 = bldr_28->gen_sym(bldr_28, NULL);
bldr_28->new_binop(bldr_28, id_360, id_359, MU_BINOP_FMUL, id_352, id_353, id_354, MU_NO_ID);
id_361 = bldr_28->gen_sym(bldr_28, NULL);
bldr_28->new_ret(bldr_28, id_361, (MuVarNode [1]){id_359}, 1);
bldr_28->new_bb(bldr_28, id_358, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_360, id_361}, 2);
bldr_28->new_func_ver(bldr_28, id_357, id_356, (MuBBNode [1]){id_358}, 1);
bldr_28->load(bldr_28);
mu_28->compile_to_sharedlib(mu_28, "test_double_mul.dylib", NULL, 0);
printf("%s\n", "test_double_mul.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_30;
MuCtx* ctx_30;
MuIRBuilder* bldr_30;
MuID id_372;
MuID id_373;
MuID id_374;
MuID id_375;
MuID id_376;
MuID id_377;
MuID id_378;
MuID id_379;
MuID id_380;
MuID id_381;
MuID id_382;
MuID id_383;
MuID id_384;
MuID id_385;
mu_30 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_30 = mu_30->new_context(mu_30);
bldr_30 = ctx_30->new_ir_builder(ctx_30);
id_372 = bldr_30->gen_sym(bldr_30, "@dbl");
bldr_30->new_type_double(bldr_30, id_372);
id_373 = bldr_30->gen_sym(bldr_30, "@i1");
bldr_30->new_type_int(bldr_30, id_373, 1);
id_374 = bldr_30->gen_sym(bldr_30, "@i64");
bldr_30->new_type_int(bldr_30, id_374, 64);
id_375 = bldr_30->gen_sym(bldr_30, "@pi");
bldr_30->new_const_double(bldr_30, id_375, id_372, 3.14159299999999985786);
id_376 = bldr_30->gen_sym(bldr_30, "@e");
bldr_30->new_const_double(bldr_30, id_376, id_372, 2.71828000000000002956);
id_377 = bldr_30->gen_sym(bldr_30, "@sig__i64");
bldr_30->new_funcsig(bldr_30, id_377, NULL, 0, (MuTypeNode [1]){id_374}, 1);
id_378 = bldr_30->gen_sym(bldr_30, "@test_fnc");
bldr_30->new_func(bldr_30, id_378, id_377);
id_379 = bldr_30->gen_sym(bldr_30, "@test_fnc.v1");
id_380 = bldr_30->gen_sym(bldr_30, "@test_fnc.v1.blk0");
id_381 = bldr_30->gen_sym(bldr_30, "@test_fnc.v1.blk0.cmpres");
id_382 = bldr_30->gen_sym(bldr_30, "@test_fnc.v1.blk0.res");
id_383 = bldr_30->gen_sym(bldr_30, NULL);
bldr_30->new_cmp(bldr_30, id_383, id_381, MU_CMP_FOEQ, id_372, id_375, id_376);
id_384 = bldr_30->gen_sym(bldr_30, NULL);
bldr_30->new_conv(bldr_30, id_384, id_382, MU_CONV_ZEXT, id_373, id_374, id_381);
id_385 = bldr_30->gen_sym(bldr_30, NULL);
bldr_30->new_ret(bldr_30, id_385, (MuVarNode [1]){id_382}, 1);
bldr_30->new_bb(bldr_30, id_380, NULL, NULL, 0, MU_NO_ID, (MuInstNode [3]){id_383, id_384, id_385}, 3);
bldr_30->new_func_ver(bldr_30, id_379, id_378, (MuBBNode [1]){id_380}, 1);
bldr_30->load(bldr_30);
mu_30->compile_to_sharedlib(mu_30, "test_double_ordered_eq.dylib", NULL, 0);
printf("%s\n", "test_double_ordered_eq.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_34;
MuCtx* ctx_34;
MuIRBuilder* bldr_34;
MuID id_430;
MuID id_431;
MuID id_432;
MuID id_433;
MuID id_434;
MuID id_435;
MuID id_436;
MuID id_437;
MuID id_438;
MuID id_439;
MuID id_440;
MuID id_441;
MuID id_442;
mu_34 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_34 = mu_34->new_context(mu_34);
bldr_34 = ctx_34->new_ir_builder(ctx_34);
id_430 = bldr_34->gen_sym(bldr_34, "@dbl");
bldr_34->new_type_double(bldr_34, id_430);
id_431 = bldr_34->gen_sym(bldr_34, "@i1");
bldr_34->new_type_int(bldr_34, id_431, 1);
id_432 = bldr_34->gen_sym(bldr_34, "@i64");
bldr_34->new_type_int(bldr_34, id_432, 64);
id_433 = bldr_34->gen_sym(bldr_34, "@e");
bldr_34->new_const_double(bldr_34, id_433, id_430, 2.71828000000000002956);
id_434 = bldr_34->gen_sym(bldr_34, "@sig__i64");
bldr_34->new_funcsig(bldr_34, id_434, NULL, 0, (MuTypeNode [1]){id_432}, 1);
id_435 = bldr_34->gen_sym(bldr_34, "@test_fnc");
bldr_34->new_func(bldr_34, id_435, id_434);
id_436 = bldr_34->gen_sym(bldr_34, "@test_fnc.v1");
id_437 = bldr_34->gen_sym(bldr_34, "@test_fnc.v1.blk0");
id_438 = bldr_34->gen_sym(bldr_34, "@test_fnc.v1.blk0.cmpres");
id_439 = bldr_34->gen_sym(bldr_34, "@test_fnc.v1.blk0.res");
id_440 = bldr_34->gen_sym(bldr_34, NULL);
bldr_34->new_cmp(bldr_34, id_440, id_438, MU_CMP_FOGE, id_430, id_433, id_433);
id_441 = bldr_34->gen_sym(bldr_34, NULL);
bldr_34->new_conv(bldr_34, id_441, id_439, MU_CONV_ZEXT, id_431, id_432, id_438);
id_442 = bldr_34->gen_sym(bldr_34, NULL);
bldr_34->new_ret(bldr_34, id_442, (MuVarNode [1]){id_439}, 1);
bldr_34->new_bb(bldr_34, id_437, NULL, NULL, 0, MU_NO_ID, (MuInstNode [3]){id_440, id_441, id_442}, 3);
bldr_34->new_func_ver(bldr_34, id_436, id_435, (MuBBNode [1]){id_437}, 1);
bldr_34->load(bldr_34);
mu_34->compile_to_sharedlib(mu_34, "test_double_ordered_ge.dylib", NULL, 0);
printf("%s\n", "test_double_ordered_ge.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_35;
MuCtx* ctx_35;
MuIRBuilder* bldr_35;
MuID id_443;
MuID id_444;
MuID id_445;
MuID id_446;
MuID id_447;
MuID id_448;
MuID id_449;
MuID id_450;
MuID id_451;
MuID id_452;
MuID id_453;
MuID id_454;
MuID id_455;
MuID id_456;
mu_35 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_35 = mu_35->new_context(mu_35);
bldr_35 = ctx_35->new_ir_builder(ctx_35);
id_443 = bldr_35->gen_sym(bldr_35, "@dbl");
bldr_35->new_type_double(bldr_35, id_443);
id_444 = bldr_35->gen_sym(bldr_35, "@i1");
bldr_35->new_type_int(bldr_35, id_444, 1);
id_445 = bldr_35->gen_sym(bldr_35, "@i64");
bldr_35->new_type_int(bldr_35, id_445, 64);
id_446 = bldr_35->gen_sym(bldr_35, "@pi");
bldr_35->new_const_double(bldr_35, id_446, id_443, 3.14159299999999985786);
id_447 = bldr_35->gen_sym(bldr_35, "@e");
bldr_35->new_const_double(bldr_35, id_447, id_443, 2.71828000000000002956);
id_448 = bldr_35->gen_sym(bldr_35, "@sig__i64");
bldr_35->new_funcsig(bldr_35, id_448, NULL, 0, (MuTypeNode [1]){id_445}, 1);
id_449 = bldr_35->gen_sym(bldr_35, "@test_fnc");
bldr_35->new_func(bldr_35, id_449, id_448);
id_450 = bldr_35->gen_sym(bldr_35, "@test_fnc.v1");
id_451 = bldr_35->gen_sym(bldr_35, "@test_fnc.v1.blk0");
id_452 = bldr_35->gen_sym(bldr_35, "@test_fnc.v1.blk0.cmpres");
id_453 = bldr_35->gen_sym(bldr_35, "@test_fnc.v1.blk0.res");
id_454 = bldr_35->gen_sym(bldr_35, NULL);
bldr_35->new_cmp(bldr_35, id_454, id_452, MU_CMP_FOGT, id_443, id_446, id_447);
id_455 = bldr_35->gen_sym(bldr_35, NULL);
bldr_35->new_conv(bldr_35, id_455, id_453, MU_CONV_ZEXT, id_444, id_445, id_452);
id_456 = bldr_35->gen_sym(bldr_35, NULL);
bldr_35->new_ret(bldr_35, id_456, (MuVarNode [1]){id_453}, 1);
bldr_35->new_bb(bldr_35, id_451, NULL, NULL, 0, MU_NO_ID, (MuInstNode [3]){id_454, id_455, id_456}, 3);
bldr_35->new_func_ver(bldr_35, id_450, id_449, (MuBBNode [1]){id_451}, 1);
bldr_35->load(bldr_35);
mu_35->compile_to_sharedlib(mu_35, "test_double_ordered_gt.dylib", NULL, 0);
printf("%s\n", "test_double_ordered_gt.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_33;
MuCtx* ctx_33;
MuIRBuilder* bldr_33;
MuID id_417;
MuID id_418;
MuID id_419;
MuID id_420;
MuID id_421;
MuID id_422;
MuID id_423;
MuID id_424;
MuID id_425;
MuID id_426;
MuID id_427;
MuID id_428;
MuID id_429;
mu_33 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_33 = mu_33->new_context(mu_33);
bldr_33 = ctx_33->new_ir_builder(ctx_33);
id_417 = bldr_33->gen_sym(bldr_33, "@dbl");
bldr_33->new_type_double(bldr_33, id_417);
id_418 = bldr_33->gen_sym(bldr_33, "@i1");
bldr_33->new_type_int(bldr_33, id_418, 1);
id_419 = bldr_33->gen_sym(bldr_33, "@i64");
bldr_33->new_type_int(bldr_33, id_419, 64);
id_420 = bldr_33->gen_sym(bldr_33, "@pi");
bldr_33->new_const_double(bldr_33, id_420, id_417, 3.14159299999999985786);
id_421 = bldr_33->gen_sym(bldr_33, "@sig__i64");
bldr_33->new_funcsig(bldr_33, id_421, NULL, 0, (MuTypeNode [1]){id_419}, 1);
id_422 = bldr_33->gen_sym(bldr_33, "@test_fnc");
bldr_33->new_func(bldr_33, id_422, id_421);
id_423 = bldr_33->gen_sym(bldr_33, "@test_fnc.v1");
id_424 = bldr_33->gen_sym(bldr_33, "@test_fnc.v1.blk0");
id_425 = bldr_33->gen_sym(bldr_33, "@test_fnc.v1.blk0.cmpres");
id_426 = bldr_33->gen_sym(bldr_33, "@test_fnc.v1.blk0.res");
id_427 = bldr_33->gen_sym(bldr_33, NULL);
bldr_33->new_cmp(bldr_33, id_427, id_425, MU_CMP_FOLE, id_417, id_420, id_420);
id_428 = bldr_33->gen_sym(bldr_33, NULL);
bldr_33->new_conv(bldr_33, id_428, id_426, MU_CONV_ZEXT, id_418, id_419, id_425);
id_429 = bldr_33->gen_sym(bldr_33, NULL);
bldr_33->new_ret(bldr_33, id_429, (MuVarNode [1]){id_426}, 1);
bldr_33->new_bb(bldr_33, id_424, NULL, NULL, 0, MU_NO_ID, (MuInstNode [3]){id_427, id_428, id_429}, 3);
bldr_33->new_func_ver(bldr_33, id_423, id_422, (MuBBNode [1]){id_424}, 1);
bldr_33->load(bldr_33);
mu_33->compile_to_sharedlib(mu_33, "test_double_ordered_le.dylib", NULL, 0);
printf("%s\n", "test_double_ordered_le.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_32;
MuCtx* ctx_32;
MuIRBuilder* bldr_32;
MuID id_403;
MuID id_404;
MuID id_405;
MuID id_406;
MuID id_407;
MuID id_408;
MuID id_409;
MuID id_410;
MuID id_411;
MuID id_412;
MuID id_413;
MuID id_414;
MuID id_415;
MuID id_416;
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_403 = bldr_32->gen_sym(bldr_32, "@dbl");
bldr_32->new_type_double(bldr_32, id_403);
id_404 = bldr_32->gen_sym(bldr_32, "@i1");
bldr_32->new_type_int(bldr_32, id_404, 1);
id_405 = bldr_32->gen_sym(bldr_32, "@i64");
bldr_32->new_type_int(bldr_32, id_405, 64);
id_406 = bldr_32->gen_sym(bldr_32, "@pi");
bldr_32->new_const_double(bldr_32, id_406, id_403, 3.14159299999999985786);
id_407 = bldr_32->gen_sym(bldr_32, "@e");
bldr_32->new_const_double(bldr_32, id_407, id_403, 2.71828000000000002956);
id_408 = bldr_32->gen_sym(bldr_32, "@sig__i64");
bldr_32->new_funcsig(bldr_32, id_408, NULL, 0, (MuTypeNode [1]){id_405}, 1);
id_409 = bldr_32->gen_sym(bldr_32, "@test_fnc");
bldr_32->new_func(bldr_32, id_409, id_408);
id_410 = bldr_32->gen_sym(bldr_32, "@test_fnc.v1");
id_411 = bldr_32->gen_sym(bldr_32, "@test_fnc.v1.blk0");
id_412 = bldr_32->gen_sym(bldr_32, "@test_fnc.v1.blk0.cmpres");
id_413 = bldr_32->gen_sym(bldr_32, "@test_fnc.v1.blk0.res");
id_414 = bldr_32->gen_sym(bldr_32, NULL);
bldr_32->new_cmp(bldr_32, id_414, id_412, MU_CMP_FOLT, id_403, id_407, id_406);
id_415 = bldr_32->gen_sym(bldr_32, NULL);
bldr_32->new_conv(bldr_32, id_415, id_413, MU_CONV_ZEXT, id_404, id_405, id_412);
id_416 = bldr_32->gen_sym(bldr_32, NULL);
bldr_32->new_ret(bldr_32, id_416, (MuVarNode [1]){id_413}, 1);
bldr_32->new_bb(bldr_32, id_411, NULL, NULL, 0, MU_NO_ID, (MuInstNode [3]){id_414, id_415, id_416}, 3);
bldr_32->new_func_ver(bldr_32, id_410, id_409, (MuBBNode [1]){id_411}, 1);
bldr_32->load(bldr_32);
mu_32->compile_to_sharedlib(mu_32, "test_double_ordered_lt.dylib", NULL, 0);
printf("%s\n", "test_double_ordered_lt.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_31;
MuCtx* ctx_31;
MuIRBuilder* bldr_31;
MuID id_386;
MuID id_387;
MuID id_388;
MuID id_389;
MuID id_390;
MuID id_391;
MuID id_392;
MuID id_393;
MuID id_394;
MuID id_395;
MuID id_396;
MuID id_397;
MuID id_398;
MuID id_399;
MuID id_400;
MuID id_401;
MuID id_402;
mu_31 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_31 = mu_31->new_context(mu_31);
bldr_31 = ctx_31->new_ir_builder(ctx_31);
id_386 = bldr_31->gen_sym(bldr_31, "@dbl");
bldr_31->new_type_double(bldr_31, id_386);
id_387 = bldr_31->gen_sym(bldr_31, "@i1");
bldr_31->new_type_int(bldr_31, id_387, 1);
id_388 = bldr_31->gen_sym(bldr_31, "@i64");
bldr_31->new_type_int(bldr_31, id_388, 64);
id_389 = bldr_31->gen_sym(bldr_31, "@1_dbl");
bldr_31->new_const_double(bldr_31, id_389, id_386, 1.00000000000000000000);
id_390 = bldr_31->gen_sym(bldr_31, "@3_dbl");
bldr_31->new_const_double(bldr_31, id_390, id_386, 3.00000000000000000000);
id_391 = bldr_31->gen_sym(bldr_31, "@zp3");
bldr_31->new_const_double(bldr_31, id_391, id_386, 0.29999999999999998890);
id_392 = bldr_31->gen_sym(bldr_31, "@sig__i64");
bldr_31->new_funcsig(bldr_31, id_392, NULL, 0, (MuTypeNode [1]){id_388}, 1);
id_393 = bldr_31->gen_sym(bldr_31, "@test_fnc");
bldr_31->new_func(bldr_31, id_393, id_392);
id_394 = bldr_31->gen_sym(bldr_31, "@test_fnc.v1");
id_395 = bldr_31->gen_sym(bldr_31, "@test_fnc.v1.blk0");
id_396 = bldr_31->gen_sym(bldr_31, "@test_fnc.v1.blk0.k");
id_397 = bldr_31->gen_sym(bldr_31, "@test_fnc.v1.blk0.cmpres");
id_398 = bldr_31->gen_sym(bldr_31, "@test_fnc.v1.blk0.res");
id_399 = bldr_31->gen_sym(bldr_31, NULL);
bldr_31->new_binop(bldr_31, id_399, id_396, MU_BINOP_FDIV, id_386, id_389, id_390, MU_NO_ID);
id_400 = bldr_31->gen_sym(bldr_31, NULL);
bldr_31->new_cmp(bldr_31, id_400, id_397, MU_CMP_FONE, id_386, id_396, id_391);
id_401 = bldr_31->gen_sym(bldr_31, NULL);
bldr_31->new_conv(bldr_31, id_401, id_398, MU_CONV_ZEXT, id_387, id_388, id_397);
id_402 = bldr_31->gen_sym(bldr_31, NULL);
bldr_31->new_ret(bldr_31, id_402, (MuVarNode [1]){id_398}, 1);
bldr_31->new_bb(bldr_31, id_395, NULL, NULL, 0, MU_NO_ID, (MuInstNode [4]){id_399, id_400, id_401, id_402}, 4);
bldr_31->new_func_ver(bldr_31, id_394, id_393, (MuBBNode [1]){id_395}, 1);
bldr_31->load(bldr_31);
mu_31->compile_to_sharedlib(mu_31, "test_double_ordered_ne.dylib", NULL, 0);
printf("%s\n", "test_double_ordered_ne.dylib");
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"
int main(int argc, char** argv) {
MuVM* mu_27;
MuCtx* ctx_27;
MuIRBuilder* bldr_27;
MuID id_342;
MuID id_343;
MuID id_344;
MuID id_345;
MuID id_346;
MuID id_347;
MuID id_348;
MuID id_349;
MuID id_350;
MuID id_351;
mu_27 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_27 = mu_27->new_context(mu_27);
bldr_27 = ctx_27->new_ir_builder(ctx_27);
id_342 = bldr_27->gen_sym(bldr_27, "@dbl");
bldr_27->new_type_double(bldr_27, id_342);
id_343 = bldr_27->gen_sym(bldr_27, "@pi");
bldr_27->new_const_double(bldr_27, id_343, id_342, 3.14159299999999985786);
id_344 = bldr_27->gen_sym(bldr_27, "@e");
bldr_27->new_const_double(bldr_27, id_344, id_342, 2.71828000000000002956);
id_345 = bldr_27->gen_sym(bldr_27, "@sig__dbl");
bldr_27->new_funcsig(bldr_27, id_345, NULL, 0, (MuTypeNode [1]){id_342}, 1);
id_346 = bldr_27->gen_sym(bldr_27, "@test_fnc");
bldr_27->new_func(bldr_27, id_346, id_345);
id_347 = bldr_27->gen_sym(bldr_27, "@test_fnc.v1");
id_348 = bldr_27->gen_sym(bldr_27, "@test_fnc.v1.blk0");
id_349 = bldr_27->gen_sym(bldr_27, "@test_fnc.v1.blk0.res");
id_350 = bldr_27->gen_sym(bldr_27, NULL);
bldr_27->new_binop(bldr_27, id_350, id_349, MU_BINOP_FSUB, id_342, id_343, id_344, MU_NO_ID);
id_351 = bldr_27->gen_sym(bldr_27, NULL);
bldr_27->new_ret(bldr_27, id_351, (MuVarNode [1]){id_349}, 1);
bldr_27->new_bb(bldr_27, id_348, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_350, id_351}, 2);
bldr_27->new_func_ver(bldr_27, id_347, id_346, (MuBBNode [1]){id_348}, 1);
bldr_27->load(bldr_27);
mu_27->compile_to_sharedlib(mu_27, "test_double_sub.dylib", NULL, 0);
printf("%s\n", "test_double_sub.dylib");
return 0;
}
from util import fncptr_from_c_script
import ctypes
def within_err(res, exp, err=1e15):
return abs(res - exp) < err
def test_double_add():
fnp = fncptr_from_c_script("test_double_add.c", "test_fnc", restype=ctypes.c_double)
assert fnp() == 5.859873
def test_double_sub():
fnp = fncptr_from_c_script("test_double_sub.c", "test_fnc", restype=ctypes.c_double)
assert within_err(fnp(), 0.423313)
def test_double_mul():
fnp = fncptr_from_c_script("test_double_mul.c", "test_fnc", restype=ctypes.c_double)
assert fnp() == 8.53972942004
def test_double_div():
fnp = fncptr_from_c_script("test_double_div.c", "test_fnc", restype=ctypes.c_double)
assert fnp() == within_err(fnp, 1.1557282546316052)
def test_double_ordered_eq():
fnp = fncptr_from_c_script("test_double_ordered_eq.c", "test_fnc")
assert fnp() == 0
def test_double_ordered_ne():
fnp = fncptr_from_c_script("test_double_ordered_ne.c", "test_fnc")
assert fnp() == 1
def test_double_ordered_lt():
fnp = fncptr_from_c_script("test_double_ordered_lt.c", "test_fnc")
assert fnp() == 1
def test_double_ordered_le():
fnp = fncptr_from_c_script("test_double_ordered_le.c", "test_fnc")
assert fnp() == 1
def test_double_ordered_ge():
fnp = fncptr_from_c_script("test_double_ordered_ge.c", "test_fnc")
assert fnp() == 1
def test_double_ordered_gt():
fnp = fncptr_from_c_script("test_double_ordered_gt.c", "test_fnc")
assert fnp() == 1
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