gem5  v20.1.0.0
branch64.hh
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011-2013 ARM Limited
3  * All rights reserved
4  *
5  * The license below extends only to copyright in the software and shall
6  * not be construed as granting a license to any other intellectual
7  * property including but not limited to intellectual property relating
8  * to a hardware implementation of the functionality of the software
9  * licensed hereunder. You may use the software subject to the license
10  * terms below provided that you ensure that this notice is replicated
11  * unmodified and in its entirety in all distributions of the software,
12  * modified or unmodified, in source code or in binary form.
13  *
14  * Redistribution and use in source and binary forms, with or without
15  * modification, are permitted provided that the following conditions are
16  * met: redistributions of source code must retain the above copyright
17  * notice, this list of conditions and the following disclaimer;
18  * redistributions in binary form must reproduce the above copyright
19  * notice, this list of conditions and the following disclaimer in the
20  * documentation and/or other materials provided with the distribution;
21  * neither the name of the copyright holders nor the names of its
22  * contributors may be used to endorse or promote products derived from
23  * this software without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef __ARCH_ARM_INSTS_BRANCH64_HH__
39 #define __ARCH_ARM_INSTS_BRANCH64_HH__
40 
42 
43 namespace ArmISA
44 {
45 // Branch to a target computed with an immediate
46 class BranchImm64 : public ArmStaticInst
47 {
48  protected:
49  int64_t imm;
50 
51  public:
52  BranchImm64(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
53  int64_t _imm) :
54  ArmStaticInst(mnem, _machInst, __opClass), imm(_imm)
55  {}
56 
58  const ArmISA::PCState &branchPC) const override;
59 
62 
63  std::string generateDisassembly(
64  Addr pc, const Loader::SymbolTable *symtab) const override;
65 };
66 
67 // Conditionally Branch to a target computed with an immediate
69 {
70  protected:
72 
73  public:
74  BranchImmCond64(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
75  int64_t _imm, ConditionCode _condCode) :
76  BranchImm64(mnem, _machInst, __opClass, _imm), condCode(_condCode)
77  {}
78 
79  std::string generateDisassembly(
80  Addr pc, const Loader::SymbolTable *symtab) const override;
81 };
82 
83 // Branch to a target computed with two registers
85 {
86  protected:
89 
90  public:
91  BranchRegReg64(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
92  IntRegIndex _op1, IntRegIndex _op2) :
93  ArmStaticInst(mnem, _machInst, __opClass), op1(_op1), op2(_op2)
94  {}
95 
96  std::string generateDisassembly(
97  Addr pc, const Loader::SymbolTable *symtab) const override;
98 };
99 
100 // Branch to a target computed with a register
102 {
103  protected:
105 
106  public:
107  BranchReg64(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
108  IntRegIndex _op1) :
109  ArmStaticInst(mnem, _machInst, __opClass), op1(_op1)
110  {}
111 
112  std::string generateDisassembly(
113  Addr pc, const Loader::SymbolTable *symtab) const override;
114 };
115 
116 // Ret instruction
117 class BranchRet64 : public BranchReg64
118 {
119  public:
120  BranchRet64(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
121  IntRegIndex _op1) :
122  BranchReg64(mnem, _machInst, __opClass, _op1)
123  {}
124 
125  std::string generateDisassembly(
126  Addr pc, const Loader::SymbolTable *symtab) const override;
127 };
128 
129 // RetAA/RetAB instruction
131 {
132  public:
133  BranchRetA64(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
134  BranchRegReg64(mnem, _machInst, __opClass, INTREG_X30,
136  {}
137 
138  std::string generateDisassembly(
139  Addr pc, const Loader::SymbolTable *symtab) const override;
140 };
141 
142 // Eret instruction
144 {
145  public:
146  BranchEret64(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
147  ArmStaticInst(mnem, _machInst, __opClass)
148  {}
149 
150  std::string generateDisassembly(
151  Addr pc, const Loader::SymbolTable *symtab) const override;
152 };
153 
154 // EretA/B instruction
156 {
157  protected:
159 
160  public:
161  BranchEretA64(const char *mnem, ExtMachInst _machInst, OpClass __opClass) :
162  ArmStaticInst(mnem, _machInst, __opClass), op1(makeSP(INTREG_SPX))
163  {}
164 
165  std::string generateDisassembly(
166  Addr pc, const Loader::SymbolTable *symtab) const override;
167 };
168 // Branch to a target computed with an immediate and a register
170 {
171  protected:
172  int64_t imm;
174 
175  public:
176  BranchImmReg64(const char *mnem, ExtMachInst _machInst, OpClass __opClass,
177  int64_t _imm, IntRegIndex _op1) :
178  ArmStaticInst(mnem, _machInst, __opClass), imm(_imm), op1(_op1)
179  {}
180 
182  const ArmISA::PCState &branchPC) const override;
183 
186 
187  std::string generateDisassembly(
188  Addr pc, const Loader::SymbolTable *symtab) const override;
189 };
190 
191 // Branch to a target computed with two immediates
193 {
194  protected:
195  int64_t imm1;
196  int64_t imm2;
198 
199  public:
200  BranchImmImmReg64(const char *mnem, ExtMachInst _machInst,
201  OpClass __opClass, int64_t _imm1, int64_t _imm2,
202  IntRegIndex _op1) :
203  ArmStaticInst(mnem, _machInst, __opClass),
204  imm1(_imm1), imm2(_imm2), op1(_op1)
205  {}
206 
208  const ArmISA::PCState &branchPC) const override;
209 
212 
213  std::string generateDisassembly(
214  Addr pc, const Loader::SymbolTable *symtab) const override;
215 };
216 
217 }
218 
219 #endif //__ARCH_ARM_INSTS_BRANCH_HH__
ArmISA::BranchImmCond64::BranchImmCond64
BranchImmCond64(const char *mnem, ExtMachInst _machInst, OpClass __opClass, int64_t _imm, ConditionCode _condCode)
Definition: branch64.hh:74
ArmISA::BranchRet64
Definition: branch64.hh:117
ArmISA::BranchImmImmReg64::op1
IntRegIndex op1
Definition: branch64.hh:197
ArmISA::ConditionCode
ConditionCode
Definition: ccregs.hh:63
ArmISA::BranchImmImmReg64::BranchImmImmReg64
BranchImmImmReg64(const char *mnem, ExtMachInst _machInst, OpClass __opClass, int64_t _imm1, int64_t _imm2, IntRegIndex _op1)
Definition: branch64.hh:200
ArmISA::BranchRegReg64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:101
ArmISA::BranchRetA64::BranchRetA64
BranchRetA64(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: branch64.hh:133
ArmISA::BranchImm64::branchTarget
ArmISA::PCState branchTarget(const ArmISA::PCState &branchPC) const override
Definition: branch64.cc:44
ArmISA::BranchReg64::op1
IntRegIndex op1
Definition: branch64.hh:104
ArmISA::BranchRet64::BranchRet64
BranchRet64(const char *mnem, ExtMachInst _machInst, OpClass __opClass, IntRegIndex _op1)
Definition: branch64.hh:120
ArmISA::BranchImmImmReg64::imm1
int64_t imm1
Definition: branch64.hh:195
Loader::SymbolTable
Definition: symtab.hh:59
ArmISA::IntRegIndex
IntRegIndex
Definition: intregs.hh:51
ArmISA::BranchRetA64
Definition: branch64.hh:130
ArmISA::BranchEretA64::BranchEretA64
BranchEretA64(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: branch64.hh:161
ArmISA::BranchReg64::BranchReg64
BranchReg64(const char *mnem, ExtMachInst _machInst, OpClass __opClass, IntRegIndex _op1)
Definition: branch64.hh:107
ArmISA::BranchRet64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:113
ArmISA
Definition: ccregs.hh:41
ArmISA::BranchEret64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:135
ArmISA::BranchEretA64
Definition: branch64.hh:155
ArmISA::ArmStaticInst
Definition: static_inst.hh:60
ArmISA::BranchImmReg64::imm
int64_t imm
Definition: branch64.hh:172
ArmISA::BranchImm64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:81
ArmISA::BranchRegReg64::op1
IntRegIndex op1
Definition: branch64.hh:87
ArmISA::BranchRetA64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:124
ArmISA::BranchImmReg64::branchTarget
ArmISA::PCState branchTarget(const ArmISA::PCState &branchPC) const override
Definition: branch64.cc:53
ArmISA::INTREG_SPX
@ INTREG_SPX
Definition: intregs.hh:160
ArmISA::BranchEret64
Definition: branch64.hh:143
ArmISA::BranchImm64::BranchImm64
BranchImm64(const char *mnem, ExtMachInst _machInst, OpClass __opClass, int64_t _imm)
Definition: branch64.hh:52
StaticInst::branchTarget
virtual TheISA::PCState branchTarget(const TheISA::PCState &pc) const
Return the target address for a PC-relative branch.
Definition: static_inst.cc:105
ArmISA::BranchImmReg64::BranchImmReg64
BranchImmReg64(const char *mnem, ExtMachInst _machInst, OpClass __opClass, int64_t _imm, IntRegIndex _op1)
Definition: branch64.hh:176
ArmISA::BranchEretA64::op1
IntRegIndex op1
Definition: branch64.hh:158
ArmISA::BranchImmImmReg64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:165
MipsISA::pc
Bitfield< 4 > pc
Definition: pra_constants.hh:240
ArmISA::BranchRegReg64
Definition: branch64.hh:84
ArmISA::BranchImmImmReg64::imm2
int64_t imm2
Definition: branch64.hh:196
ArmISA::BranchRegReg64::op2
IntRegIndex op2
Definition: branch64.hh:88
ArmISA::BranchEret64::BranchEret64
BranchEret64(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
Definition: branch64.hh:146
ArmISA::BranchImmCond64::condCode
ConditionCode condCode
Definition: branch64.hh:71
ArmISA::BranchImmImmReg64::branchTarget
ArmISA::PCState branchTarget(const ArmISA::PCState &branchPC) const override
Definition: branch64.cc:62
StaticInst::ExtMachInst
TheISA::ExtMachInst ExtMachInst
Binary extended machine instruction type.
Definition: static_inst.hh:89
ArmISA::BranchImmCond64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:71
ArmISA::BranchImm64::imm
int64_t imm
Definition: branch64.hh:49
ArmISA::BranchImmImmReg64
Definition: branch64.hh:192
ArmISA::BranchImmReg64
Definition: branch64.hh:169
Addr
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
Definition: types.hh:142
ArmISA::makeSP
static IntRegIndex makeSP(IntRegIndex reg)
Definition: intregs.hh:499
ArmISA::BranchRegReg64::BranchRegReg64
BranchRegReg64(const char *mnem, ExtMachInst _machInst, OpClass __opClass, IntRegIndex _op1, IntRegIndex _op2)
Definition: branch64.hh:91
ArmISA::BranchImmCond64
Definition: branch64.hh:68
ArmISA::BranchImm64
Definition: branch64.hh:46
ArmISA::BranchReg64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:91
MipsISA::PCState
GenericISA::DelaySlotPCState< MachInst > PCState
Definition: types.hh:41
ArmISA::BranchImmReg64::op1
IntRegIndex op1
Definition: branch64.hh:173
static_inst.hh
ArmISA::INTREG_X30
@ INTREG_X30
Definition: intregs.hh:157
ArmISA::BranchEretA64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:144
ArmISA::BranchImmReg64::generateDisassembly
std::string generateDisassembly(Addr pc, const Loader::SymbolTable *symtab) const override
Internal function to generate disassembly string.
Definition: branch64.cc:153
ArmISA::BranchReg64
Definition: branch64.hh:101

Generated on Wed Sep 30 2020 14:02:00 for gem5 by doxygen 1.8.17