From: Gabe Black Date: Sat, 28 Dec 2019 09:05:57 +0000 (-0800) Subject: sim: Get rid of the Arguments class. X-Git-Tag: v20.0.0.0~293 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=db7f6a5fa87178e7b5662427d154df21a81a6999;p=gem5.git sim: Get rid of the Arguments class. This class read arguments using the arch specific getArgument function and then presented the arguments as an array. The problem with that approach is that it's not possible to tell where different arguments are without knowing the types of previous arguments, and not all arguments can be simply represented as a native sized integer. This class has been phased out and is no longer needed. Change-Id: Ibb4c529fe8c51fd0ae15ed3b6ea30543ad9c23e0 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/24115 Tested-by: kokoro Reviewed-by: Gabe Black Maintainer: Gabe Black --- diff --git a/src/arch/mips/linux/system.cc b/src/arch/mips/linux/system.cc index cff1cefcf..b2a2a4d7f 100644 --- a/src/arch/mips/linux/system.cc +++ b/src/arch/mips/linux/system.cc @@ -49,7 +49,6 @@ #include "kern/linux/printk.hh" #include "mem/physical.hh" #include "mem/port.hh" -#include "sim/arguments.hh" #include "sim/byteswap.hh" using namespace std; diff --git a/src/base/cp_annotate.cc b/src/base/cp_annotate.cc index 472efa7e9..59c32ab83 100644 --- a/src/base/cp_annotate.cc +++ b/src/base/cp_annotate.cc @@ -38,7 +38,6 @@ #include "cpu/thread_context.hh" #include "debug/Annotate.hh" #include "debug/AnnotateVerbose.hh" -#include "sim/arguments.hh" #include "sim/core.hh" #include "sim/sim_exit.hh" #include "sim/system.hh" diff --git a/src/kern/freebsd/events.cc b/src/kern/freebsd/events.cc index 1367e5e83..0c4c61329 100644 --- a/src/kern/freebsd/events.cc +++ b/src/kern/freebsd/events.cc @@ -39,7 +39,6 @@ #include "cpu/thread_context.hh" #include "debug/DebugPrintf.hh" #include "kern/system_events.hh" -#include "sim/arguments.hh" #include "sim/system.hh" namespace FreeBSD diff --git a/src/kern/linux/events.cc b/src/kern/linux/events.cc index e576a39b2..db487e822 100644 --- a/src/kern/linux/events.cc +++ b/src/kern/linux/events.cc @@ -49,7 +49,6 @@ #include "cpu/thread_context.hh" #include "kern/linux/helpers.hh" #include "kern/system_events.hh" -#include "sim/arguments.hh" #include "sim/core.hh" #include "sim/system.hh" diff --git a/src/sim/SConscript b/src/sim/SConscript index 06b0822c2..53239b8a0 100644 --- a/src/sim/SConscript +++ b/src/sim/SConscript @@ -39,7 +39,6 @@ SimObject('DVFSHandler.py') SimObject('SubSystem.py') SimObject('RedirectPath.py') -Source('arguments.cc') Source('async.cc') Source('backtrace_%s.cc' % env['BACKTRACE_IMPL']) Source('core.cc') diff --git a/src/sim/arguments.cc b/src/sim/arguments.cc deleted file mode 100644 index 4162ffe14..000000000 --- a/src/sim/arguments.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2003-2005 The Regents of The University of Michigan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "sim/arguments.hh" - -#include "arch/utility.hh" -#include "config/the_isa.hh" - -Arguments::Data::~Data() -{ - while (!data.empty()) { - delete [] data.front(); - data.pop_front(); - } -} - -char * -Arguments::Data::alloc(size_t size) -{ - char *buf = new char[size]; - data.push_back(buf); - return buf; -} - -uint64_t -Arguments::getArg(uint16_t size, bool fp) -{ - return TheISA::getArgument(tc, number, size, fp); -} - diff --git a/src/sim/arguments.hh b/src/sim/arguments.hh deleted file mode 100644 index 2861e4dd6..000000000 --- a/src/sim/arguments.hh +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) 2003-2005 The Regents of The University of Michigan - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer; - * redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution; - * neither the name of the copyright holders nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __SIM_ARGUMENTS_HH__ -#define __SIM_ARGUMENTS_HH__ - -#include -#include - -#include "cpu/thread_context.hh" -#include "mem/port_proxy.hh" - -class Arguments -{ - protected: - ThreadContext *tc; - int number; - uint64_t getArg(uint16_t size = (uint16_t)(-1), bool fp = false); - - protected: - class Data - { - public: - Data(){} - ~Data(); - - private: - std::list data; - - public: - char *alloc(size_t size); - }; - - std::shared_ptr data; - - public: - Arguments(ThreadContext *ctx, int n = 0) - : tc(ctx), number(n), data(new Data()) - { assert(number >= 0); } - Arguments(const Arguments &args) - : tc(args.tc), number(args.number), data(args.data) {} - ~Arguments() {} - - ThreadContext *getThreadContext() const { return tc; } - - const Arguments &operator=(const Arguments &args) { - if (this != &args) { - tc = args.tc; - number = args.number; - data = args.data; - } - return *this; - } - - // for checking if an argument is NULL - bool operator!() { - return getArg() == 0; - } - - Arguments &operator++() { - ++number; - assert(number >= 0); - return *this; - } - - Arguments operator++(int) { - Arguments args = *this; - ++number; - assert(number >= 0); - return args; - } - - Arguments &operator--() { - --number; - assert(number >= 0); - return *this; - } - - Arguments operator--(int) { - Arguments args = *this; - --number; - assert(number >= 0); - return args; - } - - const Arguments &operator+=(int index) { - number += index; - assert(number >= 0); - return *this; - } - - const Arguments &operator-=(int index) { - number -= index; - assert(number >= 0); - return *this; - } - - Arguments operator[](int index) { - return Arguments(tc, index); - } - - template - operator T() { - assert(sizeof(T) <= sizeof(uint64_t)); - T d = static_cast(getArg(sizeof(T))); - return d; - } - - template - operator T *() { - T *buf = (T *)data->alloc(sizeof(T)); - tc->getVirtProxy().readBlob(getArg(sizeof(T)), buf, sizeof(T)); - return buf; - } - - operator char *() { - char *buf = data->alloc(2048); - tc->getVirtProxy().readString(buf, getArg(), 2048); - return buf; - } -}; - -#endif // __SIM_ARGUMENTS_HH__