Deleted Added
sdiff udiff text old ( 12234:78ece221f9f5 ) new ( 12295:4fc6c59aa554 )
full compact
1// Copyright (c) 2006-2007 The Regents of The University of Michigan
2// All rights reserved.
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// Authors: Ali Saidi
28// Gabe Black
29// Steve Reinhardt
30
31////////////////////////////////////////////////////////////////////
32//
33// Integer operate instructions
34//
35
36def template SetHiDecode {{
37 {
38 if (RD == 0 && IMM22 == 0)
39 return (SparcStaticInst *)(new Nop("nop", machInst, No_OpClass));
40 else
41 return (SparcStaticInst *)(new %(class_name)s(machInst));
42 }
43}};
44
45def template IntOpExecute {{
46 Fault %(class_name)s::execute(ExecContext *xc,
47 Trace::InstRecord *traceData) const
48 {
49 Fault fault = NoFault;
50
51 %(op_decl)s;
52 %(op_rd)s;
53 %(code)s;
54
55 // Write the resulting state to the execution context
56 if (fault == NoFault) {
57 %(cc_code)s;
58 %(op_wb)s;
59 }
60 return fault;
61 }
62}};
63
64let {{
65 def doIntFormat(code, ccCode, name, Name, opt_flags):
66 (usesImm, code, immCode,
67 rString, iString) = splitOutImm(code)
68 iop = InstObjParams(name, Name, 'IntOp',
69 {"code": code, "cc_code": ccCode},
70 opt_flags)
71 header_output = BasicDeclare.subst(iop)
72 decoder_output = BasicConstructor.subst(iop)
73 exec_output = IntOpExecute.subst(iop)
74 if usesImm:
75 imm_iop = InstObjParams(name, Name + 'Imm', 'IntOpImm' + iString,
76 {"code": immCode, "cc_code": ccCode}, opt_flags)
77 header_output += BasicDeclare.subst(imm_iop)
78 decoder_output += BasicConstructor.subst(imm_iop)
79 exec_output += IntOpExecute.subst(imm_iop)
80 decode_block = ROrImmDecode.subst(iop)
81 else:
82 decode_block = BasicDecode.subst(iop)
83 return (header_output, decoder_output, exec_output, decode_block)
84
85 calcCcCode = '''
86 uint16_t _ic, _iv, _iz, _in, _xc, _xv, _xz, _xn;
87
88 _in = (Rd >> 31) & 1;
89 _iz = ((Rd & 0xFFFFFFFF) == 0);
90 _xn = (Rd >> 63) & 1;
91 _xz = (Rd == 0);
92 _iv = %(iv)s & 1;
93 _ic = %(ic)s & 1;
94 _xv = %(xv)s & 1;
95 _xc = %(xc)s & 1;
96
97 Ccr = _ic << 0 | _iv << 1 | _iz << 2 | _in << 3 |
98 _xc << 4 | _xv << 5 | _xz << 6 | _xn << 7;
99
100
101 DPRINTF(Sparc, "in = %%d\\n", _in);
102 DPRINTF(Sparc, "iz = %%d\\n", _iz);
103 DPRINTF(Sparc, "xn = %%d\\n", _xn);
104 DPRINTF(Sparc, "xz = %%d\\n", _xz);
105 DPRINTF(Sparc, "iv = %%d\\n", _iv);
106 DPRINTF(Sparc, "ic = %%d\\n", _ic);
107 DPRINTF(Sparc, "xv = %%d\\n", _xv);
108 DPRINTF(Sparc, "xc = %%d\\n", _xc);
109 '''
110
111 default_ic = "findCarry(32, res, op1, op2)"
112 default_iv = "findOverflow(32, res, op1, op2)"
113 default_xc = "findCarry(64, res, op1, op2)"
114 default_xv = "findOverflow(64, res, op1, op2)"
115 default_sub_ic = "!findCarry(32, res, op1, ~op2)"
116 default_sub_iv = "findOverflow(32, res, op1, ~op2)"
117 default_sub_xc = "!findCarry(64, res, op1, ~op2)"
118 default_sub_xv = "findOverflow(64, res, op1, ~op2)"
119}};
120
121// Primary format for integer operate instructions:
122def format IntOp(code, *opt_flags) {{
123 ccCode = ''
124 (header_output,
125 decoder_output,
126 exec_output,
127 decode_block) = doIntFormat(code, ccCode,
128 name, Name, opt_flags)
129}};
130
131// Primary format for integer operate instructions:
132def format IntOpCc(code, ic=default_ic, iv=default_iv,
133 xc=default_xc, xv=default_xv,
134 sub=False, *opt_flags) {{
135
136 if sub == "False":
137 (def_ic, def_iv, def_xc, def_xv) = \
138 (default_ic, default_iv, default_xc, default_xv)
139 else:
140 (def_ic, def_iv, def_xc, def_xv) = \
141 (default_sub_ic, default_sub_iv, default_sub_xc, default_sub_xv)
142 if ic == "default_ic":
143 ic = def_ic
144 if iv == "default_iv":
145 iv = def_iv
146 if xc == "default_xc":
147 xc = def_xc
148 if xv == "default_xv":
149 xv = def_xv
150 ccCode = calcCcCode % vars()
151 (header_output,
152 decoder_output,
153 exec_output,
154 decode_block) = doIntFormat(code, ccCode,
155 name, Name, opt_flags)
156}};
157
158// Primary format for integer operate instructions:
159def format IntOpCcRes(code, ic=0, iv=0, xc=0, xv=0, *opt_flags) {{
160 ccCode = calcCcCode % {"ic" : ic, "iv" : iv, "xc" : xc, "xv" : xv}
161 (header_output,
162 decoder_output,
163 exec_output,
164 decode_block) = doIntFormat(code, ccCode,
165 name, Name, opt_flags)
166}};
167
168def format SetHi(code, *opt_flags) {{
169 iop = InstObjParams(name, Name, 'SetHi',
170 {"code": code, "cc_code": ''}, opt_flags)
171 header_output = BasicDeclare.subst(iop)
172 decoder_output = BasicConstructor.subst(iop)
173 exec_output = IntOpExecute.subst(iop)
174 decode_block = SetHiDecode.subst(iop)
175}};
176