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 3d65a058 authored by John Zhang's avatar John Zhang

merge build_fib_fast into build_fib.c, use a preprocessor definition to select between them

parent a35d622b
......@@ -106,7 +106,10 @@ fib:
language:
name: mu
impl: zebu
source: build_fib_fast.c
source: build_fib.c
compiler:
flags:
- -DBUILD_FIB_FAST
compare:
- - c_O0
- c_O3
......
......@@ -137,6 +137,7 @@ class Mu(Language):
flags.extend(['-I%s' % d for d in cc['include_dirs']])
flags.extend(['-L%s' % d for d in cc['library_dirs']])
flags.append('-l%(libmu_link_name)s' % cc)
flags.extend(cc.get('flags', []))
target = cls.get_default_target(task)
build_target = target.with_name('build_' + target.name)
......
......@@ -103,6 +103,7 @@ static MuID extern_atoi, extern_exit;
static MuID fib, entry;
void build_func_fib(MuIRBuilder *b);
void build_func_fib_fast(MuIRBuilder *b);
void build_func_entry(MuIRBuilder *b);
MuID mubench_build_benchmark(MuIRBuilder *b)
......@@ -147,7 +148,11 @@ MuID mubench_build_benchmark(MuIRBuilder *b)
b->new_const_extern(b, extern_atoi, t_fp_atoi, "atoi");
b->new_const_extern(b, extern_exit, t_fp_exit, "exit");
#ifdef BUILD_FIB_FAST
build_func_fib_fast(b);
#else
build_func_fib(b);
#endif
build_func_entry(b);
return entry;
}
......@@ -215,6 +220,93 @@ void build_func_fib(MuIRBuilder *b)
b->new_func_ver(b, v1, fib, IDARR(3, blk0, blk1, blk2), 3);
}
void build_func_fib_fast(MuIRBuilder *irbuilder)
{
#define G(id, ...) global_ ## id
#define L(id, ...) local_ ## id
MuID G(0, int32);
MuID G(2);
MuID G(4);
MuID G(5);
MuID G(6);
G(0, int32) = irbuilder->gen_sym(irbuilder, "@int32");
irbuilder->new_type_int(irbuilder, G(0, int32), 32);
fib = irbuilder->gen_sym(irbuilder, "@fib");
G(2) = irbuilder->gen_sym(irbuilder, "@__2");
irbuilder->new_funcsig(irbuilder, G(2), (MuTypeNode[]){G(0, int32)}, 1, (MuTypeNode[]){G(0, int32)}, 1);
irbuilder->new_func(irbuilder, fib, G(2));
MuID L(0, fib.__3) = irbuilder->gen_sym(irbuilder, "@fib.__3");
MuID L(1, fib.__3.1) = irbuilder->gen_sym(irbuilder, "@fib.__3.1");
MuID L(2, fib.__3.1.0) = irbuilder->gen_sym(irbuilder, "@fib.__3.1.0");
MuID L(3) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(4, fib.__3.1.2) = irbuilder->gen_sym(irbuilder, "@fib.__3.1.2");
G(4) = irbuilder->gen_sym(irbuilder, "@__4");
irbuilder->new_const_int(irbuilder, G(4), G(0, int32), 1);
irbuilder->new_binop(irbuilder, L(3), L(4, fib.__3.1.2), MU_BINOP_OR, G(0, int32), L(2, fib.__3.1.0), G(4), MU_NO_ID);
MuID L(5) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(6, fib.__3.1.3) = irbuilder->gen_sym(irbuilder, "@fib.__3.1.3");
irbuilder->new_cmp(irbuilder, L(5), L(6, fib.__3.1.3), MU_CMP_EQ, G(0, int32), L(4, fib.__3.1.2), G(4));
MuID L(7) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(8) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(9, fib.__3.15) = irbuilder->gen_sym(irbuilder, "@fib.__3.15");
irbuilder->new_dest_clause(irbuilder, L(8), L(9, fib.__3.15), (MuVarNode[]){G(4)}, 1);
MuID L(10) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(12, fib.__3.5) = irbuilder->gen_sym(irbuilder, "@fib.__3.5");
irbuilder->new_dest_clause(irbuilder, L(10), L(12, fib.__3.5), (MuVarNode[]){L(2, fib.__3.1.0), G(4)}, 2);
irbuilder->new_branch2(irbuilder, L(7), L(6, fib.__3.1.3), L(8), L(10));
irbuilder->new_bb(irbuilder, L(1, fib.__3.1), (MuID[]){L(2, fib.__3.1.0)}, (MuTypeNode[]){G(0, int32)}, 1, MU_NO_ID, (MuInstNode[]){L(3), L(5), L(7)}, 3);
MuID L(13, fib.__3.5.6) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.6");
MuID L(14, fib.__3.5.7) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.7");
MuID L(15) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(16, fib.__3.5.8) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.8");
G(5) = irbuilder->gen_sym(irbuilder, "@__5");
irbuilder->new_const_int(irbuilder, G(5), G(0, int32), -1);
irbuilder->new_binop(irbuilder, L(15), L(16, fib.__3.5.8), MU_BINOP_ADD, G(0, int32), L(13, fib.__3.5.6), G(5), MU_NO_ID);
MuID L(17) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(18, fib.__3.5.9) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.9");
irbuilder->new_call(irbuilder, L(17), (MuVarNode[]){L(18, fib.__3.5.9)}, 1, G(2), fib, (MuVarNode[]){L(16, fib.__3.5.8)}, 1, MU_NO_ID, MU_NO_ID);
MuID L(19) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(20, fib.__3.5.10) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.10");
G(6) = irbuilder->gen_sym(irbuilder, "@__6");
irbuilder->new_const_int(irbuilder, G(6), G(0, int32), -2);
irbuilder->new_binop(irbuilder, L(19), L(20, fib.__3.5.10), MU_BINOP_ADD, G(0, int32), L(13, fib.__3.5.6), G(6), MU_NO_ID);
MuID L(21) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(22, fib.__3.5.11) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.11");
irbuilder->new_binop(irbuilder, L(21), L(22, fib.__3.5.11), MU_BINOP_ADD, G(0, int32), L(18, fib.__3.5.9), L(14, fib.__3.5.7), MU_NO_ID);
MuID L(23) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(24, fib.__3.5.12) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.12");
irbuilder->new_binop(irbuilder, L(23), L(24, fib.__3.5.12), MU_BINOP_OR, G(0, int32), L(20, fib.__3.5.10), G(4), MU_NO_ID);
MuID L(25) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(26, fib.__3.5.13) = irbuilder->gen_sym(irbuilder, "@fib.__3.5.13");
irbuilder->new_cmp(irbuilder, L(25), L(26, fib.__3.5.13), MU_CMP_EQ, G(0, int32), L(24, fib.__3.5.12), G(4));
MuID L(27) = irbuilder->gen_sym(irbuilder, NULL);
MuID L(28) = irbuilder->gen_sym(irbuilder, NULL);
irbuilder->new_dest_clause(irbuilder, L(28), L(9, fib.__3.15), (MuVarNode[]){L(22, fib.__3.5.11)}, 1);
MuID L(29) = irbuilder->gen_sym(irbuilder, NULL);
irbuilder->new_dest_clause(irbuilder, L(29), L(12, fib.__3.5), (MuVarNode[]){L(20, fib.__3.5.10), L(22, fib.__3.5.11)}, 2);
irbuilder->new_branch2(irbuilder, L(27), L(26, fib.__3.5.13), L(28), L(29));
irbuilder->new_bb(irbuilder, L(12, fib.__3.5), (MuID[]){L(13, fib.__3.5.6), L(14, fib.__3.5.7)}, (MuTypeNode[]){G(0, int32), G(0, int32)}, 2, MU_NO_ID, (MuInstNode[]){L(15), L(17), L(19), L(21), L(23), L(25), L(27)}, 7);
MuID L(30, fib.__3.15.16) = irbuilder->gen_sym(irbuilder, "@fib.__3.15.16");
MuID L(31) = irbuilder->gen_sym(irbuilder, NULL);
irbuilder->new_ret(irbuilder, L(31), (MuVarNode[]){L(30, fib.__3.15.16)}, 1);
irbuilder->new_bb(irbuilder, L(9, fib.__3.15), (MuID[]){L(30, fib.__3.15.16)}, (MuTypeNode[]){G(0, int32)}, 1, MU_NO_ID, (MuInstNode[]){L(31)}, 1);
irbuilder->new_func_ver(irbuilder, L(0, fib.__3), fib, (MuBBNode[]){L(1, fib.__3.1), L(12, fib.__3.5), L(9, fib.__3.15)}, 3);
}
void build_func_entry(MuIRBuilder *b)
{
MuID v1, blk0, blk1, blk2, blk3;
......
This diff is collapsed.
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