Deleted Added
sdiff udiff text old ( 6251:1d794d81a4e6 ) new ( 6253:988a001820f8 )
full compact
1// -*- mode:c++ -*-
2
3// Copyright (c) 2007-2008 The Florida State University
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met: redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer;
10// redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the
12// documentation and/or other materials provided with the distribution;
13// neither the name of the copyright holders nor the names of its
14// contributors may be used to endorse or promote products derived from
15// this software without specific prior written permission.
16//
17// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28//
29// Authors: Stephen Hines
30
31////////////////////////////////////////////////////////////////////
32//
33// Predicated Instruction Execution
34//
35
36let {{
37 predicateTest = 'testPredicate(Cpsr, condCode)'
38}};
39
40def template PredOpExecute {{
41 Fault %(class_name)s::execute(%(CPU_exec_context)s *xc, Trace::InstRecord *traceData) const
42 {
43 Fault fault = NoFault;
44 %(op_decl)s;
45 %(op_rd)s;
46
47 if (%(predicate_test)s)
48 {
49 %(code)s;
50 if (fault == NoFault)
51 {
52 %(op_wb)s;
53 }
54 }
55
56 return fault;
57 }
58}};
59
60let {{
61
62 calcCcCode = '''
63 uint16_t _ic, _iv, _iz, _in;
64
65 _in = (resTemp >> 31) & 1;
66 _iz = (resTemp == 0);
67 _iv = %(ivValue)s & 1;
68 _ic = %(icValue)s & 1;
69
70 Cpsr = _in << 31 | _iz << 30 | _ic << 29 | _iv << 28 |
71 (Cpsr & 0x0FFFFFFF);
72
73 DPRINTF(Arm, "in = %%d\\n", _in);
74 DPRINTF(Arm, "iz = %%d\\n", _iz);
75 DPRINTF(Arm, "ic = %%d\\n", _ic);
76 DPRINTF(Arm, "iv = %%d\\n", _iv);
77 '''
78
79}};
80
81def format PredOp(code, *opt_flags) {{
82 iop = InstObjParams(name, Name, 'PredOp',
83 {"code": code,
84 "predicate_test": predicateTest},
85 opt_flags)
86 header_output = BasicDeclare.subst(iop)
87 decoder_output = BasicConstructor.subst(iop)
88 decode_block = BasicDecode.subst(iop)
89 exec_output = PredOpExecute.subst(iop)
90}};
91
92def format PredImmOp(code, *opt_flags) {{
93 iop = InstObjParams(name, Name, 'PredImmOp',
94 {"code": code,
95 "predicate_test": predicateTest},
96 opt_flags)
97 header_output = BasicDeclare.subst(iop)
98 decoder_output = BasicConstructor.subst(iop)
99 decode_block = BasicDecode.subst(iop)
100 exec_output = PredOpExecute.subst(iop)
101}};
102
103def format PredImmOpCc(code, icValue, ivValue, *opt_flags) {{
104 ccCode = calcCcCode % vars()
105 code += ccCode;
106 iop = InstObjParams(name, Name, 'PredImmOp',
107 {"code": code,
108 "cc_code": ccCode,
109 "predicate_test": predicateTest},
110 opt_flags)
111 header_output = BasicDeclare.subst(iop)
112 decoder_output = BasicConstructor.subst(iop)
113 decode_block = BasicDecode.subst(iop)
114 exec_output = PredOpExecute.subst(iop)
115}};
116
117def format PredIntOp(code, *opt_flags) {{
118 new_code = ArmGenericCodeSubs(code)
119 iop = InstObjParams(name, Name, 'PredIntOp',
120 {"code": new_code,
121 "predicate_test": predicateTest},
122 opt_flags)
123 header_output = BasicDeclare.subst(iop)
124 decoder_output = BasicConstructor.subst(iop)
125 decode_block = BasicDecode.subst(iop)
126 exec_output = PredOpExecute.subst(iop)
127}};
128
129def format PredIntOpCc(code, icValue, ivValue, *opt_flags) {{
130 ccCode = calcCcCode % vars()
131 code += ccCode;
132 new_code = ArmGenericCodeSubs(code)
133 iop = InstObjParams(name, Name, 'PredIntOp',
134 {"code": new_code,
135 "cc_code": ccCode,
136 "predicate_test": predicateTest},
137 opt_flags)
138 header_output = BasicDeclare.subst(iop)
139 decoder_output = BasicConstructor.subst(iop)
140 decode_block = BasicDecode.subst(iop)
141 exec_output = PredOpExecute.subst(iop)
142}};
143