static_inst.cc (7629:0f0c231e3e97) static_inst.cc (9913:7f43babfde6a)
1/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
1/*
2 * Copyright (c) 2007 The Hewlett-Packard Development Company
3 * Copyright (c) 2013 Advanced Micro Devices, Inc.
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

--- 23 unchanged lines hidden (view full) ---

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 * Authors: Gabe Black
38 */
39
40#include "arch/x86/insts/static_inst.hh"
41#include "arch/x86/regs/segment.hh"
4 * All rights reserved.
5 *
6 * The license below extends only to copyright in the software and shall
7 * not be construed as granting a license to any other intellectual
8 * property including but not limited to intellectual property relating
9 * to a hardware implementation of the functionality of the software
10 * licensed hereunder. You may use the software subject to the license
11 * terms below provided that you ensure that this notice is replicated

--- 23 unchanged lines hidden (view full) ---

35 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 *
38 * Authors: Gabe Black
39 */
40
41#include "arch/x86/insts/static_inst.hh"
42#include "arch/x86/regs/segment.hh"
43#include "cpu/reg_class.hh"
42
43namespace X86ISA
44{
45 void X86StaticInst::printMnemonic(std::ostream &os,
46 const char * mnemonic) const
47 {
48 ccprintf(os, " %s ", mnemonic);
49 }

--- 74 unchanged lines hidden (view full) ---

124 {"", "%s", "%sx", "", "e%sx", "", "", "", "r%sx"};
125 static const char * piFormats[9] =
126 {"", "%s", "%s", "", "e%s", "", "", "", "r%s"};
127 static const char * longFormats[9] =
128 {"", "r%sb", "r%sw", "", "r%sd", "", "", "", "r%s"};
129 static const char * microFormats[9] =
130 {"", "t%db", "t%dw", "", "t%dd", "", "", "", "t%d"};
131
44
45namespace X86ISA
46{
47 void X86StaticInst::printMnemonic(std::ostream &os,
48 const char * mnemonic) const
49 {
50 ccprintf(os, " %s ", mnemonic);
51 }

--- 74 unchanged lines hidden (view full) ---

126 {"", "%s", "%sx", "", "e%sx", "", "", "", "r%sx"};
127 static const char * piFormats[9] =
128 {"", "%s", "%s", "", "e%s", "", "", "", "r%s"};
129 static const char * longFormats[9] =
130 {"", "r%sb", "r%sw", "", "r%sd", "", "", "", "r%s"};
131 static const char * microFormats[9] =
132 {"", "t%db", "t%dw", "", "t%dd", "", "", "", "t%d"};
133
132 if (reg < FP_Base_DepTag) {
134 RegIndex rel_reg;
135
136 switch (regIdxToClass(reg, &rel_reg)) {
137 case IntRegClass: {
133 const char * suffix = "";
138 const char * suffix = "";
134 bool fold = reg & IntFoldBit;
135 reg &= ~IntFoldBit;
139 bool fold = rel_reg & IntFoldBit;
140 rel_reg &= ~IntFoldBit;
136
137 if(fold)
138 suffix = "h";
141
142 if(fold)
143 suffix = "h";
139 else if(reg < 8 && size == 1)
144 else if(rel_reg < 8 && size == 1)
140 suffix = "l";
141
145 suffix = "l";
146
142 switch (reg) {
147 switch (rel_reg) {
143 case INTREG_RAX:
144 ccprintf(os, abcdFormats[size], "a");
145 break;
146 case INTREG_RBX:
147 ccprintf(os, abcdFormats[size], "b");
148 break;
149 case INTREG_RCX:
150 ccprintf(os, abcdFormats[size], "c");

--- 33 unchanged lines hidden (view full) ---

184 break;
185 case INTREG_R14W:
186 ccprintf(os, longFormats[size], "14");
187 break;
188 case INTREG_R15W:
189 ccprintf(os, longFormats[size], "15");
190 break;
191 default:
148 case INTREG_RAX:
149 ccprintf(os, abcdFormats[size], "a");
150 break;
151 case INTREG_RBX:
152 ccprintf(os, abcdFormats[size], "b");
153 break;
154 case INTREG_RCX:
155 ccprintf(os, abcdFormats[size], "c");

--- 33 unchanged lines hidden (view full) ---

189 break;
190 case INTREG_R14W:
191 ccprintf(os, longFormats[size], "14");
192 break;
193 case INTREG_R15W:
194 ccprintf(os, longFormats[size], "15");
195 break;
196 default:
192 ccprintf(os, microFormats[size], reg - NUM_INTREGS);
197 ccprintf(os, microFormats[size], rel_reg - NUM_INTREGS);
193 }
194 ccprintf(os, suffix);
198 }
199 ccprintf(os, suffix);
195 } else if (reg < Ctrl_Base_DepTag) {
196 int fpindex = reg - FP_Base_DepTag;
197 if(fpindex < NumMMXRegs) {
198 ccprintf(os, "%%mmx%d", reg - FP_Base_DepTag);
200 break;
201 }
202
203 case FloatRegClass: {
204 if (rel_reg < NumMMXRegs) {
205 ccprintf(os, "%%mmx%d", rel_reg);
199 return;
200 }
206 return;
207 }
201 fpindex -= NumMMXRegs;
202 if(fpindex < NumXMMRegs * 2) {
203 ccprintf(os, "%%xmm%d_%s", fpindex / 2,
204 (fpindex % 2) ? "high": "low");
208 rel_reg -= NumMMXRegs;
209 if (rel_reg < NumXMMRegs * 2) {
210 ccprintf(os, "%%xmm%d_%s", rel_reg / 2,
211 (rel_reg % 2) ? "high": "low");
205 return;
206 }
212 return;
213 }
207 fpindex -= NumXMMRegs * 2;
208 if(fpindex < NumMicroFpRegs) {
209 ccprintf(os, "%%ufp%d", fpindex);
214 rel_reg -= NumXMMRegs * 2;
215 if (rel_reg < NumMicroFpRegs) {
216 ccprintf(os, "%%ufp%d", rel_reg);
210 return;
211 }
217 return;
218 }
212 fpindex -= NumMicroFpRegs;
213 ccprintf(os, "%%st(%d)", fpindex);
214 } else {
215 switch (reg - Ctrl_Base_DepTag) {
219 rel_reg -= NumMicroFpRegs;
220 ccprintf(os, "%%st(%d)", rel_reg);
221 break;
222 }
223
224 case MiscRegClass:
225 switch (rel_reg) {
216 default:
226 default:
217 ccprintf(os, "%%ctrl%d", reg - Ctrl_Base_DepTag);
227 ccprintf(os, "%%ctrl%d", rel_reg);
218 }
228 }
229 break;
219 }
220 }
221
222 void X86StaticInst::printMem(std::ostream &os, uint8_t segment,
223 uint8_t scale, RegIndex index, RegIndex base,
224 uint64_t disp, uint8_t addressSize, bool rip) const
225 {
226 bool someAddr = false;

--- 43 unchanged lines hidden ---
230 }
231 }
232
233 void X86StaticInst::printMem(std::ostream &os, uint8_t segment,
234 uint8_t scale, RegIndex index, RegIndex base,
235 uint64_t disp, uint8_t addressSize, bool rip) const
236 {
237 bool someAddr = false;

--- 43 unchanged lines hidden ---