gem5  v22.1.0.0
branch.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2006-2007 The Regents of The University of Michigan
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met: redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer;
9  * redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution;
12  * neither the name of the copyright holders nor the names of its
13  * contributors may be used to endorse or promote products derived from
14  * this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 #ifndef __ARCH_SPARC_INSTS_BRANCH_HH__
30 #define __ARCH_SPARC_INSTS_BRANCH_HH__
31 
33 
34 namespace gem5
35 {
36 
38 //
39 // Branch instructions
40 //
41 
42 namespace SparcISA
43 {
44 
48 class Branch : public SparcStaticInst
49 {
50  protected:
52 
53  std::string generateDisassembly(
54  Addr pc, const loader::SymbolTable *symtab) const override;
55 };
56 
60 class BranchDisp : public Branch
61 {
62  protected:
63  BranchDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
64  int32_t _disp) :
65  Branch(mnem, _machInst, __opClass), disp(_disp)
66  {}
67 
68  std::string generateDisassembly(
69  Addr pc, const loader::SymbolTable *symtab) const override;
70 
71  int32_t disp;
72 };
73 
77 template<int bits>
78 class BranchNBits : public BranchDisp
79 {
80  protected:
81  // Constructor
82  BranchNBits(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
83  BranchDisp(mnem, _machInst, __opClass, szext<bits>(_machInst) << 2)
84  {}
85 };
86 
90 class BranchSplit : public BranchDisp
91 {
92  protected:
93  // Constructor
94  BranchSplit(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
95  BranchDisp(mnem, _machInst, __opClass,
96  sext<18>((bits(_machInst, 21, 20) << 16) |
97  (bits(_machInst, 13, 0) << 2)))
98  {}
99 };
100 
105 class BranchImm13 : public Branch
106 {
107  protected:
108  // Constructor
109  BranchImm13(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
110  Branch(mnem, _machInst, __opClass), imm(szext<13>(_machInst))
111  {}
112 
113  std::string generateDisassembly(
114  Addr pc, const loader::SymbolTable *symtab) const override;
115 
116  int32_t imm;
117 };
118 
119 } // namespace SparcISA
120 } // namespace gem5
121 
122 #endif // __ARCH_SPARC_INSTS_BRANCH_HH__
Base class for branch operations with an immediate displacement.
Definition: branch.hh:61
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch.cc:79
BranchDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass, int32_t _disp)
Definition: branch.hh:63
Base class for branches that use an immediate and a register to compute their displacements.
Definition: branch.hh:106
BranchImm13(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: branch.hh:109
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch.cc:61
Base class for branches with n bit displacements.
Definition: branch.hh:79
BranchNBits(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: branch.hh:82
Base class for 16bit split displacements.
Definition: branch.hh:91
BranchSplit(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: branch.hh:94
Base class for branch operations.
Definition: branch.hh:49
std::string generateDisassembly(Addr pc, const loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch.cc:47
Base class for all SPARC static instructions.
Definition: static_inst.hh:94
SparcStaticInst(const char *_mnemonic, ExtMachInst _machInst, OpClass __opClass)
Definition: static_inst.hh:98
constexpr T bits(T val, unsigned first, unsigned last)
Extract the bitfield from position 'first' to 'last' (inclusive) from 'val' and right justify it.
Definition: bitfield.hh:76
constexpr uint64_t szext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
Definition: bitfield.hh:142
constexpr uint64_t sext(uint64_t val)
Sign-extend an N-bit value to 64 bits.
Definition: bitfield.hh:126
Bitfield< 4 > pc
uint64_t ExtMachInst
Definition: types.hh:42
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:147

Generated on Wed Dec 21 2022 10:22:25 for gem5 by doxygen 1.9.1