From: Gabe Black Date: Sun, 5 Apr 2020 12:31:08 +0000 (-0700) Subject: util: Expose the "sum" m5 op in the m5 utility. X-Git-Tag: v20.1.0.0~396 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d4640ffe33ee3c1377582d69795a637452442409;p=gem5.git util: Expose the "sum" m5 op in the m5 utility. This is just for testing purposes, and can be used to sanity check that m5 ops work when running a simulation. Change-Id: I784d033fe4704e60ace5d109beac7bafe1498de6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/27558 Reviewed-by: Jason Lowe-Power Maintainer: Jason Lowe-Power Tested-by: kokoro --- diff --git a/util/m5/src/commands.cc b/util/m5/src/commands.cc index c779e8083..2d71f9314 100644 --- a/util/m5/src/commands.cc +++ b/util/m5/src/commands.cc @@ -117,6 +117,19 @@ do_exit(const DispatchTable &dt, Args &args) (*dt.m5_exit)(ns_delay); } +// For testing purposes. +static void +do_sum(const DispatchTable &dt, Args &args) +{ + uint64_t a, b, c, d, e, f; + if (!args.pop(a) || !args.pop(b) || !args.pop(c, 0) || + !args.pop(d, 0) || !args.pop(e, 0) || !args.pop(f, 0)) + usage(); + + unsigned sum = (*dt.m5_sum)(a, b, c, d, e, f); + std::cout << "Sum is " << sum << "." << std::endl; +} + static void do_fail(const DispatchTable &dt, Args &args) { @@ -230,6 +243,8 @@ std::map Command::map = { " Exit after delay, or immediately" }}, { "fail", { 1, 2, do_fail, " [delay]\n" " Exit with failure code code after delay, or immediately" }}, + { "sum", { 2, 6, do_sum, " [c [d [e [f]]]]\n" + " Sum a-f (defaults are 0), for testing purposes" }}, { "initparam", { 1, 1, do_initparam, "[key]\n" " optional key may be at most 16 characters long" }}, { "loadsymbol", { 0, 0, do_loadsymbol, "\n"