GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). 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 09c2ba88 authored by John Zhang's avatar John Zhang

refactor tests; c source files added; fibonacci test added;

parent b0ad239c
// 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_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;
MuCString var_8;
mu_8 = mu_fastimpl_new();
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);
var_8 = mu_8->compile_to_sharedlib(mu_8, id_75);
printf("%s\n", var_8);
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;
MuCtx* ctx;
MuIRBuilder* bldr;
MuID id;
MuID id_2;
MuID id_3;
MuID id_4;
MuID id_5;
MuID id_6;
MuID id_7;
MuID id_8;
MuID id_9;
MuID id_10;
MuID id_11;
MuID id_12;
MuID id_13;
MuID id_14;
MuID id_15;
MuID id_16;
MuID id_17;
MuID id_18;
MuID id_19;
MuID id_20;
MuID id_21;
MuID id_22;
MuID id_23;
MuID id_24;
MuID id_25;
MuID id_26;
MuID id_27;
MuID id_28;
MuID id_29;
MuCString var;
mu = mu_fastimpl_new();
ctx = mu->new_context(mu);
bldr = ctx->new_ir_builder(ctx);
id = bldr->gen_sym(bldr, "@i64");
bldr->new_type_int(bldr, id, 64);
id_2 = bldr->gen_sym(bldr, "@0_i64");
bldr->new_const_int(bldr, id_2, id, 0);
id_3 = bldr->gen_sym(bldr, "@1_i64");
bldr->new_const_int(bldr, id_3, id, 1);
id_4 = bldr->gen_sym(bldr, "@2_i64");
bldr->new_const_int(bldr, id_4, id, 2);
id_5 = bldr->gen_sym(bldr, "@sig_i64_i64");
bldr->new_funcsig(bldr, id_5, (MuTypeNode [1]){id}, 1, (MuTypeNode [1]){id}, 1);
id_6 = bldr->gen_sym(bldr, "@fib");
bldr->new_func(bldr, id_6, id_5);
id_7 = bldr->gen_sym(bldr, "@fib_v1");
id_8 = bldr->gen_sym(bldr, "@fib_v1.blk0");
id_9 = bldr->gen_sym(bldr, "@fib_v1.blk1");
id_10 = bldr->gen_sym(bldr, "@fib_v1.blk2");
id_11 = bldr->gen_sym(bldr, "@fib_v1.blk0.k");
id_12 = bldr->gen_sym(bldr, NULL);
id_13 = bldr->gen_sym(bldr, NULL);
id_14 = bldr->gen_sym(bldr, NULL);
bldr->new_dest_clause(bldr, id_12, id_10, (MuVarNode [1]){id_11}, 1);
bldr->new_dest_clause(bldr, id_13, id_9, (MuVarNode [1]){id_2}, 1);
bldr->new_dest_clause(bldr, id_14, id_9, (MuVarNode [1]){id_3}, 1);
id_15 = bldr->gen_sym(bldr, NULL);
bldr->new_switch(bldr, id_15, id, id_11, id_12, (MuConstNode [2]){id_2, id_3}, (MuDestClause [2]){id_13, id_14}, 2);
bldr->new_bb(bldr, id_8, (MuID [1]){id_11}, (MuTypeNode [1]){id}, 1, MU_NO_ID, (MuInstNode [1]){id_15}, 1);
id_16 = bldr->gen_sym(bldr, "@fig_v1.blk1.rtn");
id_17 = bldr->gen_sym(bldr, NULL);
bldr->new_ret(bldr, id_17, (MuVarNode [1]){id_16}, 1);
bldr->new_bb(bldr, id_9, (MuID [1]){id_16}, (MuTypeNode [1]){id}, 1, MU_NO_ID, (MuInstNode [1]){id_17}, 1);
id_18 = bldr->gen_sym(bldr, "@fig_v1.blk2.k");
id_19 = bldr->gen_sym(bldr, "@fig_v1.blk2.k_1");
id_20 = bldr->gen_sym(bldr, "@fig_v1.blk2.k_2");
id_21 = bldr->gen_sym(bldr, "@fig_v1.blk2.res");
id_22 = bldr->gen_sym(bldr, "@fig_v1.blk2.res1");
id_23 = bldr->gen_sym(bldr, "@fig_v1.blk2.res2");
id_24 = bldr->gen_sym(bldr, NULL);
bldr->new_binop(bldr, id_24, id_19, MU_BINOP_SUB, id, id_18, id_3, MU_NO_ID);
id_25 = bldr->gen_sym(bldr, NULL);
bldr->new_call(bldr, id_25, (MuID [1]){id_22}, 1, id_5, id_6, (MuVarNode [1]){id_19}, 1, MU_NO_ID, MU_NO_ID);
id_26 = bldr->gen_sym(bldr, NULL);
bldr->new_binop(bldr, id_26, id_20, MU_BINOP_SUB, id, id_18, id_4, MU_NO_ID);
id_27 = bldr->gen_sym(bldr, NULL);
bldr->new_call(bldr, id_27, (MuID [1]){id_23}, 1, id_5, id_6, (MuVarNode [1]){id_20}, 1, MU_NO_ID, MU_NO_ID);
id_28 = bldr->gen_sym(bldr, NULL);
bldr->new_binop(bldr, id_28, id_21, MU_BINOP_ADD, id, id_22, id_23, MU_NO_ID);
id_29 = bldr->gen_sym(bldr, NULL);
bldr->new_ret(bldr, id_29, (MuVarNode [1]){id_21}, 1);
bldr->new_bb(bldr, id_10, (MuID [1]){id_18}, (MuTypeNode [1]){id}, 1, MU_NO_ID, (MuInstNode [6]){id_24, id_25, id_26, id_27, id_28, id_29}, 6);
bldr->new_func_ver(bldr, id_7, id_6, (MuBBNode [3]){id_8, id_9, id_10}, 3);
bldr->load(bldr);
var = mu->compile_to_sharedlib(mu, id_6);
printf("%s\n", var);
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_7;
MuCtx* ctx_7;
MuIRBuilder* bldr_7;
MuID id_61;
MuID id_62;
MuID id_63;
MuID id_64;
MuID id_65;
MuID id_66;
MuID id_67;
MuID id_68;
MuID id_69;
MuID id_70;
MuCString var_7;
mu_7 = mu_fastimpl_new();
ctx_7 = mu_7->new_context(mu_7);
bldr_7 = ctx_7->new_ir_builder(ctx_7);
id_61 = bldr_7->gen_sym(bldr_7, "@i64");
bldr_7->new_type_int(bldr_7, id_61, 64);
id_62 = bldr_7->gen_sym(bldr_7, "@0x8d9f9c1d58324b55_i64");
bldr_7->new_const_int(bldr_7, id_62, id_61, 10205046930492509013);
id_63 = bldr_7->gen_sym(bldr_7, "@0x0a_i64");
bldr_7->new_const_int(bldr_7, id_63, id_61, 10);
id_64 = bldr_7->gen_sym(bldr_7, "@sig__i64");
bldr_7->new_funcsig(bldr_7, id_64, NULL, 0, (MuTypeNode [1]){id_61}, 1);
id_65 = bldr_7->gen_sym(bldr_7, "@test_fnc");
bldr_7->new_func(bldr_7, id_65, id_64);
id_66 = bldr_7->gen_sym(bldr_7, "@test_fnc_v1");
id_67 = bldr_7->gen_sym(bldr_7, "@test_fnc_v1.blk0");
id_68 = bldr_7->gen_sym(bldr_7, "@test_fnc_v1.blk0.res");
id_69 = bldr_7->gen_sym(bldr_7, NULL);
bldr_7->new_binop(bldr_7, id_69, id_68, MU_BINOP_LSHR, id_61, id_62, id_63, MU_NO_ID);
id_70 = bldr_7->gen_sym(bldr_7, NULL);
bldr_7->new_ret(bldr_7, id_70, (MuVarNode [1]){id_68}, 1);
bldr_7->new_bb(bldr_7, id_67, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_69, id_70}, 2);
bldr_7->new_func_ver(bldr_7, id_66, id_65, (MuBBNode [1]){id_67}, 1);
bldr_7->load(bldr_7);
var_7 = mu_7->compile_to_sharedlib(mu_7, id_65);
printf("%s\n", var_7);
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_3;
MuCtx* ctx_3;
MuIRBuilder* bldr_3;
MuID id_21;
MuID id_22;
MuID id_23;
MuID id_24;
MuID id_25;
MuID id_26;
MuID id_27;
MuID id_28;
MuID id_29;
MuID id_30;
MuCString var_3;
mu_3 = mu_fastimpl_new();
ctx_3 = mu_3->new_context(mu_3);
bldr_3 = ctx_3->new_ir_builder(ctx_3);
id_21 = bldr_3->gen_sym(bldr_3, "@i8");
bldr_3->new_type_int(bldr_3, id_21, 8);
id_22 = bldr_3->gen_sym(bldr_3, "@0xff_i8");
bldr_3->new_const_int(bldr_3, id_22, id_21, 255);
id_23 = bldr_3->gen_sym(bldr_3, "@0x0a_i8");
bldr_3->new_const_int(bldr_3, id_23, id_21, 10);
id_24 = bldr_3->gen_sym(bldr_3, "@sig__i8");
bldr_3->new_funcsig(bldr_3, id_24, NULL, 0, (MuTypeNode [1]){id_21}, 1);
id_25 = bldr_3->gen_sym(bldr_3, "@test_fnc");
bldr_3->new_func(bldr_3, id_25, id_24);
id_26 = bldr_3->gen_sym(bldr_3, "@test_fnc_v1");
id_27 = bldr_3->gen_sym(bldr_3, "@test_fnc_v1.blk0");
id_28 = bldr_3->gen_sym(bldr_3, "@test_fnc_v1.blk0.res");
id_29 = bldr_3->gen_sym(bldr_3, NULL);
bldr_3->new_binop(bldr_3, id_29, id_28, MU_BINOP_MUL, id_21, id_22, id_23, MU_NO_ID);
id_30 = bldr_3->gen_sym(bldr_3, NULL);
bldr_3->new_ret(bldr_3, id_30, (MuVarNode [1]){id_28}, 1);
bldr_3->new_bb(bldr_3, id_27, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_29, id_30}, 2);
bldr_3->new_func_ver(bldr_3, id_26, id_25, (MuBBNode [1]){id_27}, 1);
bldr_3->load(bldr_3);
var_3 = mu_3->compile_to_sharedlib(mu_3, id_25);
printf("%s\n", var_3);
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_4;
MuCtx* ctx_4;
MuIRBuilder* bldr_4;
MuID id_31;
MuID id_32;
MuID id_33;
MuID id_34;
MuID id_35;
MuID id_36;
MuID id_37;
MuID id_38;
MuID id_39;
MuID id_40;
MuCString var_4;
mu_4 = mu_fastimpl_new();
ctx_4 = mu_4->new_context(mu_4);
bldr_4 = ctx_4->new_ir_builder(ctx_4);
id_31 = bldr_4->gen_sym(bldr_4, "@i8");
bldr_4->new_type_int(bldr_4, id_31, 8);
id_32 = bldr_4->gen_sym(bldr_4, "@0x80_i8");
bldr_4->new_const_int(bldr_4, id_32, id_31, 128);
id_33 = bldr_4->gen_sym(bldr_4, "@0x0a_i8");
bldr_4->new_const_int(bldr_4, id_33, id_31, 10);
id_34 = bldr_4->gen_sym(bldr_4, "@sig__i8");
bldr_4->new_funcsig(bldr_4, id_34, NULL, 0, (MuTypeNode [1]){id_31}, 1);
id_35 = bldr_4->gen_sym(bldr_4, "@test_fnc");
bldr_4->new_func(bldr_4, id_35, id_34);
id_36 = bldr_4->gen_sym(bldr_4, "@test_fnc_v1");
id_37 = bldr_4->gen_sym(bldr_4, "@test_fnc_v1.blk0");
id_38 = bldr_4->gen_sym(bldr_4, "@test_fnc_v1.blk0.res");
id_39 = bldr_4->gen_sym(bldr_4, NULL);
bldr_4->new_binop(bldr_4, id_39, id_38, MU_BINOP_SDIV, id_31, id_32, id_33, MU_NO_ID);
id_40 = bldr_4->gen_sym(bldr_4, NULL);
bldr_4->new_ret(bldr_4, id_40, (MuVarNode [1]){id_38}, 1);
bldr_4->new_bb(bldr_4, id_37, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_39, id_40}, 2);
bldr_4->new_func_ver(bldr_4, id_36, id_35, (MuBBNode [1]){id_37}, 1);
bldr_4->load(bldr_4);
var_4 = mu_4->compile_to_sharedlib(mu_4, id_35);
printf("%s\n", var_4);
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_6;
MuCtx* ctx_6;
MuIRBuilder* bldr_6;
MuID id_51;
MuID id_52;
MuID id_53;
MuID id_54;
MuID id_55;
MuID id_56;
MuID id_57;
MuID id_58;
MuID id_59;
MuID id_60;
MuCString var_6;
mu_6 = mu_fastimpl_new();
ctx_6 = mu_6->new_context(mu_6);
bldr_6 = ctx_6->new_ir_builder(ctx_6);
id_51 = bldr_6->gen_sym(bldr_6, "@i64");
bldr_6->new_type_int(bldr_6, id_51, 64);
id_52 = bldr_6->gen_sym(bldr_6, "@0x6d9f9c1d58324b55_i64");
bldr_6->new_const_int(bldr_6, id_52, id_51, 7899203921278815061);
id_53 = bldr_6->gen_sym(bldr_6, "@0x0a_i64");
bldr_6->new_const_int(bldr_6, id_53, id_51, 10);
id_54 = bldr_6->gen_sym(bldr_6, "@sig__i64");
bldr_6->new_funcsig(bldr_6, id_54, NULL, 0, (MuTypeNode [1]){id_51}, 1);
id_55 = bldr_6->gen_sym(bldr_6, "@test_fnc");
bldr_6->new_func(bldr_6, id_55, id_54);
id_56 = bldr_6->gen_sym(bldr_6, "@test_fnc_v1");
id_57 = bldr_6->gen_sym(bldr_6, "@test_fnc_v1.blk0");
id_58 = bldr_6->gen_sym(bldr_6, "@test_fnc_v1.blk0.res");
id_59 = bldr_6->gen_sym(bldr_6, NULL);
bldr_6->new_binop(bldr_6, id_59, id_58, MU_BINOP_SHL, id_51, id_52, id_53, MU_NO_ID);
id_60 = bldr_6->gen_sym(bldr_6, NULL);
bldr_6->new_ret(bldr_6, id_60, (MuVarNode [1]){id_58}, 1);
bldr_6->new_bb(bldr_6, id_57, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_59, id_60}, 2);
bldr_6->new_func_ver(bldr_6, id_56, id_55, (MuBBNode [1]){id_57}, 1);
bldr_6->load(bldr_6);
var_6 = mu_6->compile_to_sharedlib(mu_6, id_55);
printf("%s\n", var_6);
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_2;
MuCtx* ctx_2;
MuIRBuilder* bldr_2;
MuID id_11;
MuID id_12;
MuID id_13;
MuID id_14;
MuID id_15;
MuID id_16;
MuID id_17;
MuID id_18;
MuID id_19;
MuID id_20;
MuCString var_2;
mu_2 = mu_fastimpl_new();
ctx_2 = mu_2->new_context(mu_2);
bldr_2 = ctx_2->new_ir_builder(ctx_2);
id_11 = bldr_2->gen_sym(bldr_2, "@i8");
bldr_2->new_type_int(bldr_2, id_11, 8);
id_12 = bldr_2->gen_sym(bldr_2, "@0xff_i8");
bldr_2->new_const_int(bldr_2, id_12, id_11, 255);
id_13 = bldr_2->gen_sym(bldr_2, "@0x0a_i8");
bldr_2->new_const_int(bldr_2, id_13, id_11, 10);
id_14 = bldr_2->gen_sym(bldr_2, "@sig__i8");
bldr_2->new_funcsig(bldr_2, id_14, NULL, 0, (MuTypeNode [1]){id_11}, 1);
id_15 = bldr_2->gen_sym(bldr_2, "@test_fnc");
bldr_2->new_func(bldr_2, id_15, id_14);
id_16 = bldr_2->gen_sym(bldr_2, "@test_fnc_v1");
id_17 = bldr_2->gen_sym(bldr_2, "@test_fnc_v1.blk0");
id_18 = bldr_2->gen_sym(bldr_2, "@test_fnc_v1.blk0.res");
id_19 = bldr_2->gen_sym(bldr_2, NULL);
bldr_2->new_binop(bldr_2, id_19, id_18, MU_BINOP_SUB, id_11, id_13, id_12, MU_NO_ID);
id_20 = bldr_2->gen_sym(bldr_2, NULL);
bldr_2->new_ret(bldr_2, id_20, (MuVarNode [1]){id_18}, 1);
bldr_2->new_bb(bldr_2, id_17, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_19, id_20}, 2);
bldr_2->new_func_ver(bldr_2, id_16, id_15, (MuBBNode [1]){id_17}, 1);
bldr_2->load(bldr_2);
var_2 = mu_2->compile_to_sharedlib(mu_2, id_15);
printf("%s\n", var_2);
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_5;
MuCtx* ctx_5;
MuIRBuilder* bldr_5;
MuID id_41;
MuID id_42;
MuID id_43;
MuID id_44;
MuID id_45;
MuID id_46;
MuID id_47;
MuID id_48;
MuID id_49;
MuID id_50;
MuCString var_5;
mu_5 = mu_fastimpl_new();
ctx_5 = mu_5->new_context(mu_5);
bldr_5 = ctx_5->new_ir_builder(ctx_5);
id_41 = bldr_5->gen_sym(bldr_5, "@i8");
bldr_5->new_type_int(bldr_5, id_41, 8);
id_42 = bldr_5->gen_sym(bldr_5, "@0xff_i8");
bldr_5->new_const_int(bldr_5, id_42, id_41, 255);
id_43 = bldr_5->gen_sym(bldr_5, "@0x0a_i8");
bldr_5->new_const_int(bldr_5, id_43, id_41, 10);
id_44 = bldr_5->gen_sym(bldr_5, "@sig__i8");
bldr_5->new_funcsig(bldr_5, id_44, NULL, 0, (MuTypeNode [1]){id_41}, 1);
id_45 = bldr_5->gen_sym(bldr_5, "@test_fnc");
bldr_5->new_func(bldr_5, id_45, id_44);
id_46 = bldr_5->gen_sym(bldr_5, "@test_fnc_v1");
id_47 = bldr_5->gen_sym(bldr_5, "@test_fnc_v1.blk0");
id_48 = bldr_5->gen_sym(bldr_5, "@test_fnc_v1.blk0.res");
id_49 = bldr_5->gen_sym(bldr_5, NULL);
bldr_5->new_binop(bldr_5, id_49, id_48, MU_BINOP_UREM, id_41, id_42, id_43, MU_NO_ID);
id_50 = bldr_5->gen_sym(bldr_5, NULL);
bldr_5->new_ret(bldr_5, id_50, (MuVarNode [1]){id_48}, 1);
bldr_5->new_bb(bldr_5, id_47, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_49, id_50}, 2);
bldr_5->new_func_ver(bldr_5, id_46, id_45, (MuBBNode [1]){id_47}, 1);
bldr_5->load(bldr_5);
var_5 = mu_5->compile_to_sharedlib(mu_5, id_45);
printf("%s\n", var_5);
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_9;
MuCtx* ctx_9;
MuIRBuilder* bldr_9;
MuID id_81;
MuID id_82;
MuID id_83;
MuID id_84;
MuID id_85;
MuID id_86;
MuID id_87;
MuID id_88;
MuID id_89;
MuID id_90;
MuCString var_9;
mu_9 = mu_fastimpl_new();
ctx_9 = mu_9->new_context(mu_9);
bldr_9 = ctx_9->new_ir_builder(ctx_9);
id_81 = bldr_9->gen_sym(bldr_9, "@i64");
bldr_9->new_type_int(bldr_9, id_81, 64);
id_82 = bldr_9->gen_sym(bldr_9, "@0x8d9f9c1d58324b55_i64");
bldr_9->new_const_int(bldr_9, id_82, id_81, 10205046930492509013);
id_83 = bldr_9->gen_sym(bldr_9, "@0xd5a8f2deb00debb4_i64");
bldr_9->new_const_int(bldr_9, id_83, id_81, 15395822364416404404);
id_84 = bldr_9->gen_sym(bldr_9, "@sig__i64");
bldr_9->new_funcsig(bldr_9, id_84, NULL, 0, (MuTypeNode [1]){id_81}, 1);
id_85 = bldr_9->gen_sym(bldr_9, "@test_fnc");
bldr_9->new_func(bldr_9, id_85, id_84);
id_86 = bldr_9->gen_sym(bldr_9, "@test_fnc_v1");
id_87 = bldr_9->gen_sym(bldr_9, "@test_fnc_v1.blk0");
id_88 = bldr_9->gen_sym(bldr_9, "@test_fnc_v1.blk0.res");
id_89 = bldr_9->gen_sym(bldr_9, NULL);
bldr_9->new_binop(bldr_9, id_89, id_88, MU_BINOP_XOR, id_81, id_82, id_83, MU_NO_ID);
id_90 = bldr_9->gen_sym(bldr_9, NULL);
bldr_9->new_ret(bldr_9, id_90, (MuVarNode [1]){id_88}, 1);
bldr_9->new_bb(bldr_9, id_87, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_89, id_90}, 2);
bldr_9->new_func_ver(bldr_9, id_86, id_85, (MuBBNode [1]){id_87}, 1);
bldr_9->load(bldr_9);
var_9 = mu_9->compile_to_sharedlib(mu_9, id_85);
printf("%s\n", var_9);
return 0;
}
def test_add():
src_c = "suite/test_add.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 9
def test_sub():
src_c = "suite/test_sub.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 11
def test_mul():
src_c = "suite/test_mul.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 0xf6
def test_sdiv():
src_c = "suite/test_sdiv.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 0xf4
def test_urem():
src_c = "suite/test_urem.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 5
def test_shl():
src_c = "suite/test_shl.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 0x7e707560c92d5400
def test_lshr():
src_c = "suite/test_shr.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 0x2367e707560c92
def test_and():
src_c = "suite/test_and.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 0x8588901c10004b14
def test_xor():
src_c = "suite/test_xor.c"
entry_fnc = "test_fnc"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 0x58376ec3e83fa0e1
......@@ -6,8 +6,8 @@ import os, sys
import ctypes
CC = 'clang'
CI_PROJ_DIR = os.environ["CI_PROJECT_DIR"]
# CI_PROJ_DIR = os.environ["MU_RUST"]
# CI_PROJ_DIR = os.environ["CI_PROJECT_DIR"]
CI_PROJ_DIR = os.environ["MU_RUST"]
CFLAGS = [
"-std=c99",
"-I%(CI_PROJ_DIR)s/src/vm/api" % globals(),
......@@ -47,11 +47,11 @@ def test_constant_function():
assert fn() == 0
def test_add():
src_c = "suite/test_add.c"
entry_fnc = "test_fnc"
def test_factorial():
src_c = "suite/test_fib.c"
entry_fnc = "fib"
lib = ctypes.CDLL(get_lib(src_c))
fn = getattr(lib, entry_fnc)
assert fn() == 9
assert fn(20) == 6765
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