gem5  v21.1.0.2
definition.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2019 Google Inc.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met: redistributions of source code must retain the above copyright
7  * notice, this list of conditions and the following disclaimer;
8  * redistributions in binary form must reproduce the above copyright
9  * notice, this list of conditions and the following disclaimer in the
10  * documentation and/or other materials provided with the distribution;
11  * neither the name of the copyright holders nor the names of its
12  * contributors may be used to endorse or promote products derived from
13  * this software without specific prior written permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #ifndef __SIM_GUEST_ABI_DEFINITION_HH__
29 #define __SIM_GUEST_ABI_DEFINITION_HH__
30 
31 #include "base/compiler.hh"
32 
33 namespace gem5
34 {
35 
36 class ThreadContext;
37 
38 GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi);
39 namespace guest_abi
40 {
41 
42 /*
43  * To implement an ABI, a subclass needs to implement a system of
44  * specializations of these two templates Result and Argument, and define a
45  * "State" type.
46  *
47  * The State type carries information about, for instance, how many
48  * integer registers have been consumed gathering earlier arguments. It
49  * may contain multiple elements if there are multiple dimensions to track,
50  * for instance the number of integer and floating point registers used so far.
51  *
52  * Result and Argument are class templates instead of function templates so
53  * that they can be partially specialized if necessary. C++ doesn't let you
54  * partially specialize function templates because that conflicts with
55  * template resolution using the function's arguments. Since we already know
56  * what type we want and we don't need argument based resolution, we can just
57  * wrap the desired functionality in classes and sidestep the problem.
58  *
59  * Also note that these templates have an "Enabled" parameter to support
60  * std::enable_if style conditional specializations.
61  */
62 
63 template <typename ABI, typename Ret, typename Enabled=void>
64 struct Result
65 {
66  /*
67  * Store result "ret" into the state accessible through tc. Optionally
68  * accept "state" in case it holds some signature wide information.
69  *
70  * Note that the declaration below is only to document the expected
71  * signature and is commented out so it won't be used by accident.
72  * Specializations of this Result class should define their own version
73  * of this method which actually does something.
74  *
75  * static void store(ThreadContext *tc, const Ret &ret);
76  * static void store(ThreadContext *tc, const Ret &ret,
77  * typename ABI::State &state);
78  */
79 
80  /*
81  * Prepare for a result of type Ret. This might mean, for instance,
82  * allocating an argument register for a result pointer.
83  *
84  * This method can be excluded if no preparation is necessary.
85  *
86  * static void prepare(ThreadContext *tc, typename ABI::State &state);
87  */
88 };
89 
90 /*
91  * This partial specialization prevents having to special case 'void' when
92  * working with return types.
93  */
94 template <typename ABI>
95 struct Result<ABI, void>
96 {};
97 
98 template <typename ABI, typename Arg, typename Enabled=void>
99 struct Argument
100 {
101  /*
102  * Retrieve an argument of type Arg from the state accessible through tc,
103  * assuming the state represented by "state" has already been used.
104  * Also update state to account for this argument as well.
105  *
106  * Like Result::store above, the declaration below is only to document
107  * the expected method signature.
108  *
109  * static Arg get(ThreadContext *tc, typename ABI::State &state);
110  */
111 
112  /*
113  * Prepare for an argument of type Arg. This might mean, for instance,
114  * allocating an argument register for a result pointer.
115  *
116  * This method can be excluded if no preparation is necessary.
117  *
118  * static void allocate(ThreadContext *tc, typename ABI::State &state);
119  */
120 };
121 
122 } // namespace guest_abi
123 } // namespace gem5
124 
125 #endif // __SIM_GUEST_ABI_DEFINITION_HH__
compiler.hh
gem5::GEM5_DEPRECATED_NAMESPACE
GEM5_DEPRECATED_NAMESPACE(GuestABI, guest_abi)
gem5::guest_abi::Argument
Definition: definition.hh:99
gem5::guest_abi::Result
Definition: definition.hh:64
gem5
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
Definition: decoder.cc:40

Generated on Tue Sep 21 2021 12:25:47 for gem5 by doxygen 1.8.17