Commit d6ab2e7b authored by John Zhang's avatar John Zhang

add a few more tests for instructions leading towards PyPy interpreter

parent 19c29bb4
......@@ -262,7 +262,7 @@ def perf_quicksort(N, iterations):
results['input_size'] = N
results['iterations'] = iterations
save_results('quicksort', quicksort_res, tmpdir)
save_results('quicksort', results, tmpdir)
move_pypy_udir(tmpdir)
return results
......
// 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_10;
MuCtx* ctx_10;
MuIRBuilder* bldr_10;
MuID id_91;
MuID id_92;
MuID id_93;
MuID id_94;
MuID id_95;
MuID id_96;
MuID id_97;
MuID id_98;
MuID id_99;
MuID id_100;
mu_10 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
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);
id_92 = bldr_10->gen_sym(bldr_10, "@0x8d9f9c1d58324b55_i64");
bldr_10->new_const_int(bldr_10, id_92, id_91, 10205046930492509013);
id_93 = bldr_10->gen_sym(bldr_10, "@0x0a_i64");
bldr_10->new_const_int(bldr_10, id_93, id_91, 10);
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");
bldr_10->new_func(bldr_10, id_95, id_94);
id_96 = bldr_10->gen_sym(bldr_10, "@test_fnc_v1");
id_97 = bldr_10->gen_sym(bldr_10, "@test_fnc_v1.blk0");
id_98 = bldr_10->gen_sym(bldr_10, "@test_fnc_v1.blk0.res");
id_99 = bldr_10->gen_sym(bldr_10, NULL);
bldr_10->new_binop(bldr_10, id_99, id_98, MU_BINOP_ASHR, id_91, id_92, id_93, MU_NO_ID);
id_100 = bldr_10->gen_sym(bldr_10, NULL);
bldr_10->new_ret(bldr_10, id_100, (MuVarNode [1]){id_98}, 1);
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");
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_50;
MuCtx* ctx_50;
MuIRBuilder* bldr_50;
MuID id_663;
MuID id_664;
MuID id_665;
MuID id_666;
MuID id_667;
MuID id_668;
MuID id_669;
MuID id_670;
MuID id_671;
MuID id_672;
MuID id_673;
MuID id_674;
MuID id_675;
MuID id_676;
mu_50 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_50 = mu_50->new_context(mu_50);
bldr_50 = ctx_50->new_ir_builder(ctx_50);
id_663 = bldr_50->gen_sym(bldr_50, "@i64");
bldr_50->new_type_int(bldr_50, id_663, 64);
id_664 = bldr_50->gen_sym(bldr_50, "@arr");
bldr_50->new_type_array(bldr_50, id_664, id_663, 5);
id_665 = bldr_50->gen_sym(bldr_50, "@parr");
bldr_50->new_type_uptr(bldr_50, id_665, id_664);
id_666 = bldr_50->gen_sym(bldr_50, "@sig_parri64_i64");
bldr_50->new_funcsig(bldr_50, id_666, (MuTypeNode [2]){id_665, id_663}, 2, (MuTypeNode [1]){id_663}, 1);
id_667 = bldr_50->gen_sym(bldr_50, "@test_fnc");
bldr_50->new_func(bldr_50, id_667, id_666);
id_668 = bldr_50->gen_sym(bldr_50, "@test_fnc.v1");
id_669 = bldr_50->gen_sym(bldr_50, "@test_fnc.v1.blk0");
id_670 = bldr_50->gen_sym(bldr_50, "@test_fnc.v1.blk0.pa");
id_671 = bldr_50->gen_sym(bldr_50, "@test_fnc.v1.blk0.idx");
id_672 = bldr_50->gen_sym(bldr_50, "@test_fnc.v1.blk0.pelm");
id_673 = bldr_50->gen_sym(bldr_50, "@test_fnc.v1.blk0.res");
id_674 = bldr_50->gen_sym(bldr_50, NULL);
bldr_50->new_getelemiref(bldr_50, id_674, id_672, true, id_664, id_663, id_670, id_671);
id_675 = bldr_50->gen_sym(bldr_50, NULL);
bldr_50->new_load(bldr_50, id_675, id_673, true, MU_ORD_NOT_ATOMIC, id_663, id_672, MU_NO_ID);
id_676 = bldr_50->gen_sym(bldr_50, NULL);
bldr_50->new_ret(bldr_50, id_676, (MuVarNode [1]){id_673}, 1);
bldr_50->new_bb(bldr_50, id_669, (MuID [2]){id_670, id_671}, (MuTypeNode [2]){id_665, id_663}, 2, MU_NO_ID, (MuInstNode [3]){id_674, id_675, id_676}, 3);
bldr_50->new_func_ver(bldr_50, id_668, id_667, (MuBBNode [1]){id_669}, 1);
bldr_50->load(bldr_50);
mu_50->compile_to_sharedlib(mu_50, "test_getelemiref.dylib", NULL, 0);
printf("%s\n", "test_getelemiref.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_12;
MuCtx* ctx_12;
MuIRBuilder* bldr_12;
MuID id_111;
MuID id_112;
MuID id_113;
MuID id_114;
MuID id_115;
MuID id_116;
MuID id_117;
MuID id_118;
MuID id_119;
MuID id_120;
mu_12 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_12 = mu_12->new_context(mu_12);
bldr_12 = ctx_12->new_ir_builder(ctx_12);
id_111 = bldr_12->gen_sym(bldr_12, "@i64");
bldr_12->new_type_int(bldr_12, id_111, 64);
id_112 = bldr_12->gen_sym(bldr_12, "@0x8d9f9c1d58324b55_i64");
bldr_12->new_const_int(bldr_12, id_112, id_111, 10205046930492509013);
id_113 = bldr_12->gen_sym(bldr_12, "@0xd5a8f2deb00debb4_i64");
bldr_12->new_const_int(bldr_12, id_113, id_111, 15395822364416404404);
id_114 = bldr_12->gen_sym(bldr_12, "@sig__i64");
bldr_12->new_funcsig(bldr_12, id_114, NULL, 0, (MuTypeNode [1]){id_111}, 1);
id_115 = bldr_12->gen_sym(bldr_12, "@test_fnc");
bldr_12->new_func(bldr_12, id_115, id_114);
id_116 = bldr_12->gen_sym(bldr_12, "@test_fnc_v1");
id_117 = bldr_12->gen_sym(bldr_12, "@test_fnc_v1.blk0");
id_118 = bldr_12->gen_sym(bldr_12, "@test_fnc_v1.blk0.res");
id_119 = bldr_12->gen_sym(bldr_12, NULL);
bldr_12->new_binop(bldr_12, id_119, id_118, MU_BINOP_OR, id_111, id_112, id_113, MU_NO_ID);
id_120 = bldr_12->gen_sym(bldr_12, NULL);
bldr_12->new_ret(bldr_12, id_120, (MuVarNode [1]){id_118}, 1);
bldr_12->new_bb(bldr_12, id_117, NULL, NULL, 0, MU_NO_ID, (MuInstNode [2]){id_119, id_120}, 2);
bldr_12->new_func_ver(bldr_12, id_116, id_115, (MuBBNode [1]){id_117}, 1);
bldr_12->load(bldr_12);
mu_12->compile_to_sharedlib(mu_12, "test_or.dylib", NULL, 0);
printf("%s\n", "test_or.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_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;
mu_6 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
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, "@i8");
bldr_6->new_type_int(bldr_6, id_51, 8);
id_52 = bldr_6->gen_sym(bldr_6, "@0xff_i8");
bldr_6->new_const_int(bldr_6, id_52, id_51, 255);
id_53 = bldr_6->gen_sym(bldr_6, "@0x0a_i8");
bldr_6->new_const_int(bldr_6, id_53, id_51, 10);
id_54 = bldr_6->gen_sym(bldr_6, "@sig__i8");
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_SREM, 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);
mu_6->compile_to_sharedlib(mu_6, "test_srem.dylib", NULL, 0);
printf("%s\n", "test_srem.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_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;
mu_4 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
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_UDIV, 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);
mu_4->compile_to_sharedlib(mu_4, "test_udiv.dylib", NULL, 0);
printf("%s\n", "test_udiv.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_22;
MuCtx* ctx_22;
MuIRBuilder* bldr_22;
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;
mu_22 = mu_fastimpl_new_with_opts("init_mu --log-level=none --aot-emit-dir=emit");
ctx_22 = mu_22->new_context(mu_22);
bldr_22 = ctx_22->new_ir_builder(ctx_22);
id_255 = bldr_22->gen_sym(bldr_22, "@i1");
bldr_22->new_type_int(bldr_22, id_255, 1);
id_256 = bldr_22->gen_sym(bldr_22, "@i8");
bldr_22->new_type_int(bldr_22, id_256, 8);
id_257 = bldr_22->gen_sym(bldr_22, "@0xff_i8");
bldr_22->new_const_int(bldr_22, id_257, id_256, 255);
id_258 = bldr_22->gen_sym(bldr_22, "@0x0a_i8");
bldr_22->new_const_int(bldr_22, id_258, id_256, 10);
id_259 = bldr_22->gen_sym(bldr_22, "@sig__i8");
bldr_22->new_funcsig(bldr_22, id_259, NULL, 0, (MuTypeNode [1]){id_256}, 1);
id_260 = bldr_22->gen_sym(bldr_22, "@test_fnc");
bldr_22->new_func(bldr_22, id_260, id_259);
id_261 = bldr_22->gen_sym(bldr_22, "@test_fnc_v1");
id_262 = bldr_22->gen_sym(bldr_22, "@test_fnc_v1.blk0");
id_263 = bldr_22->gen_sym(bldr_22, "@test_fnc_v1.blk0.cmp_res_1");
id_264 = bldr_22->gen_sym(bldr_22, "@test_fnc_v1.blk0.cmp_res_2");
id_265 = bldr_22->gen_sym(bldr_22, "@test_fnc_v1.blk0.bin_res");
id_266 = bldr_22->gen_sym(bldr_22, "@test_fnc_v1.blk0.res");
id_267 = bldr_22->gen_sym(bldr_22, NULL);
bldr_22->new_cmp(bldr_22, id_267, id_263, MU_CMP_ULE, id_256, id_258, id_257);
id_268 = bldr_22->gen_sym(bldr_22, NULL);
bldr_22->new_cmp(bldr_22, id_268, id_264, MU_CMP_ULE, id_256, id_257, id_257);
id_269 = bldr_22->gen_sym(bldr_22, NULL);
bldr_22->new_binop(bldr_22, id_269, id_265, MU_BINOP_AND, id_255, id_263, id_264, MU_NO_ID);
id_270 = bldr_22->gen_sym(bldr_22, NULL);
bldr_22->new_conv(bldr_22, id_270, id_266, MU_CONV_ZEXT, id_255, id_256, id_265);
id_271 = bldr_22->gen_sym(bldr_22, NULL);
bldr_22->new_ret(bldr_22, id_271, (MuVarNode [1]){id_266}, 1);
bldr_22->new_bb(bldr_22, id_262, NULL, NULL, 0, MU_NO_ID, (MuInstNode [5]){id_267, id_268, id_269, id_270, id_271}, 5);
bldr_22->new_func_ver(bldr_22, id_261, id_260, (MuBBNode [1]){id_262}, 1);
bldr_22->load(bldr_22);
mu_22->compile_to_sharedlib(mu_22, "test_ule.dylib", NULL, 0);
printf("%s\n", "test_ule.dylib");
return 0;
}
......@@ -17,6 +17,14 @@ def test_sdiv():
fn, _ = fncptr_from_c_script("test_sdiv.c", "test_fnc", restype=ctypes.c_uint8)
assert fn() == 0xf4
def test_udiv():
fn, _ = fncptr_from_c_script("test_udiv.c", "test_fnc", restype=ctypes.c_uint8)
assert fn() == 12
def test_srem():
fn, _ = fncptr_from_c_script("test_srem.c", "test_fnc", restype=ctypes.c_uint8)
assert fn() == 0xff # -1
def test_urem():
fn, _ = fncptr_from_c_script("test_urem.c", "test_fnc", restype=ctypes.c_uint8)
assert fn() == 5
......@@ -25,6 +33,10 @@ def test_shl():
fn, _ = fncptr_from_c_script("test_shl.c", "test_fnc", restype=ctypes.c_uint64)
assert fn() == 0x7e707560c92d5400
def test_ashr():
fn, _ = fncptr_from_c_script("test_ashr.c", "test_fnc", restype=ctypes.c_uint64)
assert fn() == 0xffe367e707560c92
def test_lshr():
fn, _ = fncptr_from_c_script("test_lshr.c", "test_fnc", restype=ctypes.c_uint64)
assert fn() == 0x2367e707560c92
......@@ -33,6 +45,10 @@ def test_and():
fn, _ = fncptr_from_c_script("test_and.c", "test_fnc", restype=ctypes.c_uint64)
assert fn() == 0x8588901c10004b14
def test_or():
fn, _ = fncptr_from_c_script("test_or.c", "test_fnc", restype=ctypes.c_uint64)
assert fn() == 0xddbffedff83febf5
def test_xor():
fn, _ = fncptr_from_c_script("test_xor.c", "test_fnc", restype=ctypes.c_uint64)
assert fn() == 0x58376ec3e83fa0e1
......@@ -49,6 +49,10 @@ def test_sle():
fn, _ = fncptr_from_c_script("test_sle.c", "test_fnc", restype=ctypes.c_uint8)
assert fn() == 1
def test_ule():
fn, _ = fncptr_from_c_script("test_ule.c", "test_fnc", restype=ctypes.c_uint8)
assert fn() == 1
def test_slt():
fn, _ = fncptr_from_c_script("test_slt.c", "test_fnc", restype=ctypes.c_uint8)
assert fn() == 0
......
......@@ -31,6 +31,22 @@ def test_getfieldiref():
assert res == 0xcafebabe, "result: %s" % hex(res)
def test_getelemiref():
Arr = ctypes.ARRAY(ctypes.c_int64, 5)
fn, _ = fncptr_from_c_script("test_getelemiref.c", "test_fnc",
argtypes=[ctypes.POINTER(Arr)],
restype=ctypes.c_int64)
arr = Arr()
arr[0] = -23
arr[1] = 35
arr[2] = 42
arr[3] = 0
arr[4] = 152
res = fn(ctypes.byref(arr), 2)
assert res == 42, "result: %d" % res
def test_getvarpartiref():
class Stt(ctypes.Structure):
_fields_ = [('ui8', ctypes.c_uint8),
......
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