mem.isa (11303:f694764d656d) mem.isa (12234:78ece221f9f5)
1// -*- mode:c++ -*-
2
3// Copyright (c) 2003-2005 The Regents of The University of Michigan
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: Steve Reinhardt
30// Kevin Lim
31
32////////////////////////////////////////////////////////////////////
33//
34// Memory-format instructions: LoadAddress, Load, Store
35//
36
37output header {{
38 /**
39 * Base class for general Alpha memory-format instructions.
40 */
41 class Memory : public AlphaStaticInst
42 {
43 protected:
44
45 /// Memory request flags. See mem_req_base.hh.
46 Request::Flags memAccessFlags;
47
48 /// Constructor
49 Memory(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
50 : AlphaStaticInst(mnem, _machInst, __opClass)
51 {
52 }
53
54 std::string
55 generateDisassembly(Addr pc, const SymbolTable *symtab) const;
56 };
57
58 /**
59 * Base class for memory-format instructions using a 32-bit
60 * displacement (i.e. most of them).
61 */
62 class MemoryDisp32 : public Memory
63 {
64 protected:
65 /// Displacement for EA calculation (signed).
66 int32_t disp;
67
68 /// Constructor.
69 MemoryDisp32(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
70 : Memory(mnem, _machInst, __opClass),
71 disp(MEMDISP)
72 {
73 }
74 };
75
76
77 /**
78 * Base class for a few miscellaneous memory-format insts
79 * that don't interpret the disp field: wh64, fetch, fetch_m, ecb.
80 * None of these instructions has a destination register either.
81 */
82 class MemoryNoDisp : public Memory
83 {
84 protected:
85 /// Constructor
86 MemoryNoDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
87 : Memory(mnem, _machInst, __opClass)
88 {
89 }
90
91 std::string
92 generateDisassembly(Addr pc, const SymbolTable *symtab) const;
93 };
94}};
95
96
97output decoder {{
98 std::string
99 Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const
100 {
101 return csprintf("%-10s %c%d,%d(r%d)", mnemonic,
102 flags[IsFloating] ? 'f' : 'r', RA, MEMDISP, RB);
103 }
104
105 std::string
106 MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
107 {
108 return csprintf("%-10s (r%d)", mnemonic, RB);
109 }
110}};
111
112def format LoadAddress(code) {{
113 iop = InstObjParams(name, Name, 'MemoryDisp32', code)
114 header_output = BasicDeclare.subst(iop)
115 decoder_output = BasicConstructor.subst(iop)
116 decode_block = BasicDecode.subst(iop)
117 exec_output = BasicExecute.subst(iop)
118}};
119
120
121def template LoadStoreDeclare {{
122 /**
123 * Static instruction class for "%(mnemonic)s".
124 */
125 class %(class_name)s : public %(base_class)s
126 {
127 public:
128
129 /// Constructor.
130 %(class_name)s(ExtMachInst machInst);
131
132 %(BasicExecDeclare)s
133
134 %(EACompDeclare)s
135
136 %(InitiateAccDeclare)s
137
138 %(CompleteAccDeclare)s
139 };
140}};
141
142
143def template EACompDeclare {{
1// -*- mode:c++ -*-
2
3// Copyright (c) 2003-2005 The Regents of The University of Michigan
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: Steve Reinhardt
30// Kevin Lim
31
32////////////////////////////////////////////////////////////////////
33//
34// Memory-format instructions: LoadAddress, Load, Store
35//
36
37output header {{
38 /**
39 * Base class for general Alpha memory-format instructions.
40 */
41 class Memory : public AlphaStaticInst
42 {
43 protected:
44
45 /// Memory request flags. See mem_req_base.hh.
46 Request::Flags memAccessFlags;
47
48 /// Constructor
49 Memory(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
50 : AlphaStaticInst(mnem, _machInst, __opClass)
51 {
52 }
53
54 std::string
55 generateDisassembly(Addr pc, const SymbolTable *symtab) const;
56 };
57
58 /**
59 * Base class for memory-format instructions using a 32-bit
60 * displacement (i.e. most of them).
61 */
62 class MemoryDisp32 : public Memory
63 {
64 protected:
65 /// Displacement for EA calculation (signed).
66 int32_t disp;
67
68 /// Constructor.
69 MemoryDisp32(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
70 : Memory(mnem, _machInst, __opClass),
71 disp(MEMDISP)
72 {
73 }
74 };
75
76
77 /**
78 * Base class for a few miscellaneous memory-format insts
79 * that don't interpret the disp field: wh64, fetch, fetch_m, ecb.
80 * None of these instructions has a destination register either.
81 */
82 class MemoryNoDisp : public Memory
83 {
84 protected:
85 /// Constructor
86 MemoryNoDisp(const char *mnem, ExtMachInst _machInst, OpClass __opClass)
87 : Memory(mnem, _machInst, __opClass)
88 {
89 }
90
91 std::string
92 generateDisassembly(Addr pc, const SymbolTable *symtab) const;
93 };
94}};
95
96
97output decoder {{
98 std::string
99 Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const
100 {
101 return csprintf("%-10s %c%d,%d(r%d)", mnemonic,
102 flags[IsFloating] ? 'f' : 'r', RA, MEMDISP, RB);
103 }
104
105 std::string
106 MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const
107 {
108 return csprintf("%-10s (r%d)", mnemonic, RB);
109 }
110}};
111
112def format LoadAddress(code) {{
113 iop = InstObjParams(name, Name, 'MemoryDisp32', code)
114 header_output = BasicDeclare.subst(iop)
115 decoder_output = BasicConstructor.subst(iop)
116 decode_block = BasicDecode.subst(iop)
117 exec_output = BasicExecute.subst(iop)
118}};
119
120
121def template LoadStoreDeclare {{
122 /**
123 * Static instruction class for "%(mnemonic)s".
124 */
125 class %(class_name)s : public %(base_class)s
126 {
127 public:
128
129 /// Constructor.
130 %(class_name)s(ExtMachInst machInst);
131
132 %(BasicExecDeclare)s
133
134 %(EACompDeclare)s
135
136 %(InitiateAccDeclare)s
137
138 %(CompleteAccDeclare)s
139 };
140}};
141
142
143def template EACompDeclare {{
144 Fault eaComp(%(CPU_exec_context)s *, Trace::InstRecord *) const;
144 Fault eaComp(ExecContext *, Trace::InstRecord *) const;
145}};
146
147def template InitiateAccDeclare {{
145}};
146
147def template InitiateAccDeclare {{
148 Fault initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const;
148 Fault initiateAcc(ExecContext *, Trace::InstRecord *) const;
149}};
150
151
152def template CompleteAccDeclare {{
149}};
150
151
152def template CompleteAccDeclare {{
153 Fault completeAcc(PacketPtr, %(CPU_exec_context)s *,
154 Trace::InstRecord *) const;
153 Fault completeAcc(PacketPtr, ExecContext *, Trace::InstRecord *) const;
155}};
156
157def template LoadStoreConstructor {{
158 %(class_name)s::%(class_name)s(ExtMachInst machInst)
159 : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
160 {
161 %(constructor)s;
162 }
163}};
164
165def template EACompExecute {{
154}};
155
156def template LoadStoreConstructor {{
157 %(class_name)s::%(class_name)s(ExtMachInst machInst)
158 : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s)
159 {
160 %(constructor)s;
161 }
162}};
163
164def template EACompExecute {{
166 Fault %(class_name)s::eaComp(CPU_EXEC_CONTEXT *xc,
167 Trace::InstRecord *traceData) const
165 Fault %(class_name)s::eaComp(ExecContext *xc,
166 Trace::InstRecord *traceData) const
168 {
169 Addr EA;
170 Fault fault = NoFault;
171
172 %(fp_enable_check)s;
173 %(op_decl)s;
174 %(op_rd)s;
175 %(ea_code)s;
176
177 if (fault == NoFault) {
178 %(op_wb)s;
179 xc->setEA(EA);
180 }
181
182 return fault;
183 }
184}};
185
186
187def template LoadExecute {{
167 {
168 Addr EA;
169 Fault fault = NoFault;
170
171 %(fp_enable_check)s;
172 %(op_decl)s;
173 %(op_rd)s;
174 %(ea_code)s;
175
176 if (fault == NoFault) {
177 %(op_wb)s;
178 xc->setEA(EA);
179 }
180
181 return fault;
182 }
183}};
184
185
186def template LoadExecute {{
188 Fault %(class_name)s::execute(CPU_EXEC_CONTEXT *xc,
187 Fault %(class_name)s::execute(ExecContext *xc,
189 Trace::InstRecord *traceData) const
190 {
191 Addr EA;
192 Fault fault = NoFault;
193
194 %(fp_enable_check)s;
195 %(op_decl)s;
196 %(op_rd)s;
197 %(ea_code)s;
198
199 if (fault == NoFault) {
200 fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
201 %(memacc_code)s;
202 }
203
204 if (fault == NoFault) {
205 %(op_wb)s;
206 }
207
208 return fault;
209 }
210}};
211
212
213def template LoadInitiateAcc {{
188 Trace::InstRecord *traceData) const
189 {
190 Addr EA;
191 Fault fault = NoFault;
192
193 %(fp_enable_check)s;
194 %(op_decl)s;
195 %(op_rd)s;
196 %(ea_code)s;
197
198 if (fault == NoFault) {
199 fault = readMemAtomic(xc, traceData, EA, Mem, memAccessFlags);
200 %(memacc_code)s;
201 }
202
203 if (fault == NoFault) {
204 %(op_wb)s;
205 }
206
207 return fault;
208 }
209}};
210
211
212def template LoadInitiateAcc {{
214 Fault %(class_name)s::initiateAcc(CPU_EXEC_CONTEXT *xc,
213 Fault %(class_name)s::initiateAcc(ExecContext *xc,
215 Trace::InstRecord *traceData) const
216 {
217 Addr EA;
218 Fault fault = NoFault;
219
220 %(fp_enable_check)s;
221 %(op_src_decl)s;
222 %(op_rd)s;
223 %(ea_code)s;
224
225 if (fault == NoFault) {
226 fault = initiateMemRead(xc, traceData, EA, Mem, memAccessFlags);
227 }
228
229 return fault;
230 }
231}};
232
233
234def template LoadCompleteAcc {{
214 Trace::InstRecord *traceData) const
215 {
216 Addr EA;
217 Fault fault = NoFault;
218
219 %(fp_enable_check)s;
220 %(op_src_decl)s;
221 %(op_rd)s;
222 %(ea_code)s;
223
224 if (fault == NoFault) {
225 fault = initiateMemRead(xc, traceData, EA, Mem, memAccessFlags);
226 }
227
228 return fault;
229 }
230}};
231
232
233def template LoadCompleteAcc {{
235 Fault %(class_name)s::completeAcc(PacketPtr pkt,
236 CPU_EXEC_CONTEXT *xc,
234 Fault %(class_name)s::completeAcc(PacketPtr pkt, ExecContext *xc,
237 Trace::InstRecord *traceData) const
238 {
239 Fault fault = NoFault;
240
241 %(fp_enable_check)s;
242 %(op_decl)s;
243
244 getMem(pkt, Mem, traceData);
245
246 if (fault == NoFault) {
247 %(memacc_code)s;
248 }
249
250 if (fault == NoFault) {
251 %(op_wb)s;
252 }
253
254 return fault;
255 }
256}};
257
258
259def template StoreExecute {{
235 Trace::InstRecord *traceData) const
236 {
237 Fault fault = NoFault;
238
239 %(fp_enable_check)s;
240 %(op_decl)s;
241
242 getMem(pkt, Mem, traceData);
243
244 if (fault == NoFault) {
245 %(memacc_code)s;
246 }
247
248 if (fault == NoFault) {
249 %(op_wb)s;
250 }
251
252 return fault;
253 }
254}};
255
256
257def template StoreExecute {{
260 Fault %(class_name)s::execute(CPU_EXEC_CONTEXT *xc,
258 Fault %(class_name)s::execute(ExecContext *xc,
261 Trace::InstRecord *traceData) const
262 {
263 Addr EA;
264 Fault fault = NoFault;
265
266 %(fp_enable_check)s;
267 %(op_decl)s;
268 %(op_rd)s;
269 %(ea_code)s;
270
271 if (fault == NoFault) {
272 %(memacc_code)s;
273 }
274
275 if (fault == NoFault) {
276 fault = writeMemAtomic(xc, traceData, Mem, EA,
277 memAccessFlags, NULL);
278 }
279
280 if (fault == NoFault) {
281 %(postacc_code)s;
282 }
283
284 if (fault == NoFault) {
285 %(op_wb)s;
286 }
287
288 return fault;
289 }
290}};
291
292def template StoreCondExecute {{
259 Trace::InstRecord *traceData) const
260 {
261 Addr EA;
262 Fault fault = NoFault;
263
264 %(fp_enable_check)s;
265 %(op_decl)s;
266 %(op_rd)s;
267 %(ea_code)s;
268
269 if (fault == NoFault) {
270 %(memacc_code)s;
271 }
272
273 if (fault == NoFault) {
274 fault = writeMemAtomic(xc, traceData, Mem, EA,
275 memAccessFlags, NULL);
276 }
277
278 if (fault == NoFault) {
279 %(postacc_code)s;
280 }
281
282 if (fault == NoFault) {
283 %(op_wb)s;
284 }
285
286 return fault;
287 }
288}};
289
290def template StoreCondExecute {{
293 Fault %(class_name)s::execute(CPU_EXEC_CONTEXT *xc,
291 Fault %(class_name)s::execute(ExecContext *xc,
294 Trace::InstRecord *traceData) const
295 {
296 Addr EA;
297 Fault fault = NoFault;
298 uint64_t write_result = 0;
299
300 %(fp_enable_check)s;
301 %(op_decl)s;
302 %(op_rd)s;
303 %(ea_code)s;
304
305 if (fault == NoFault) {
306 %(memacc_code)s;
307 }
308
309 if (fault == NoFault) {
310 fault = writeMemAtomic(xc, traceData, Mem, EA,
311 memAccessFlags, &write_result);
312 }
313
314 if (fault == NoFault) {
315 %(postacc_code)s;
316 }
317
318 if (fault == NoFault) {
319 %(op_wb)s;
320 }
321
322 return fault;
323 }
324}};
325
326def template StoreInitiateAcc {{
292 Trace::InstRecord *traceData) const
293 {
294 Addr EA;
295 Fault fault = NoFault;
296 uint64_t write_result = 0;
297
298 %(fp_enable_check)s;
299 %(op_decl)s;
300 %(op_rd)s;
301 %(ea_code)s;
302
303 if (fault == NoFault) {
304 %(memacc_code)s;
305 }
306
307 if (fault == NoFault) {
308 fault = writeMemAtomic(xc, traceData, Mem, EA,
309 memAccessFlags, &write_result);
310 }
311
312 if (fault == NoFault) {
313 %(postacc_code)s;
314 }
315
316 if (fault == NoFault) {
317 %(op_wb)s;
318 }
319
320 return fault;
321 }
322}};
323
324def template StoreInitiateAcc {{
327 Fault %(class_name)s::initiateAcc(CPU_EXEC_CONTEXT *xc,
325 Fault %(class_name)s::initiateAcc(ExecContext *xc,
328 Trace::InstRecord *traceData) const
329 {
330 Addr EA;
331 Fault fault = NoFault;
332
333 %(fp_enable_check)s;
334 %(op_decl)s;
335 %(op_rd)s;
336 %(ea_code)s;
337
338 if (fault == NoFault) {
339 %(memacc_code)s;
340 }
341
342 if (fault == NoFault) {
343 fault = writeMemTiming(xc, traceData, Mem, EA,
344 memAccessFlags, NULL);
345 }
346
347 return fault;
348 }
349}};
350
351
352def template StoreCompleteAcc {{
326 Trace::InstRecord *traceData) const
327 {
328 Addr EA;
329 Fault fault = NoFault;
330
331 %(fp_enable_check)s;
332 %(op_decl)s;
333 %(op_rd)s;
334 %(ea_code)s;
335
336 if (fault == NoFault) {
337 %(memacc_code)s;
338 }
339
340 if (fault == NoFault) {
341 fault = writeMemTiming(xc, traceData, Mem, EA,
342 memAccessFlags, NULL);
343 }
344
345 return fault;
346 }
347}};
348
349
350def template StoreCompleteAcc {{
353 Fault %(class_name)s::completeAcc(PacketPtr pkt,
354 CPU_EXEC_CONTEXT *xc,
351 Fault %(class_name)s::completeAcc(PacketPtr pkt, ExecContext *xc,
355 Trace::InstRecord *traceData) const
356 {
357 return NoFault;
358 }
359}};
360
361
362def template StoreCondCompleteAcc {{
352 Trace::InstRecord *traceData) const
353 {
354 return NoFault;
355 }
356}};
357
358
359def template StoreCondCompleteAcc {{
363 Fault %(class_name)s::completeAcc(PacketPtr pkt,
364 CPU_EXEC_CONTEXT *xc,
360 Fault %(class_name)s::completeAcc(PacketPtr pkt, ExecContext *xc,
365 Trace::InstRecord *traceData) const
366 {
367 Fault fault = NoFault;
368
369 %(fp_enable_check)s;
370 %(op_dest_decl)s;
371
372 uint64_t write_result = pkt->req->getExtraData();
373
374 if (fault == NoFault) {
375 %(postacc_code)s;
376 }
377
378 if (fault == NoFault) {
379 %(op_wb)s;
380 }
381
382 return fault;
383 }
384}};
385
386
387def template MiscExecute {{
361 Trace::InstRecord *traceData) const
362 {
363 Fault fault = NoFault;
364
365 %(fp_enable_check)s;
366 %(op_dest_decl)s;
367
368 uint64_t write_result = pkt->req->getExtraData();
369
370 if (fault == NoFault) {
371 %(postacc_code)s;
372 }
373
374 if (fault == NoFault) {
375 %(op_wb)s;
376 }
377
378 return fault;
379 }
380}};
381
382
383def template MiscExecute {{
388 Fault %(class_name)s::execute(CPU_EXEC_CONTEXT *xc,
384 Fault %(class_name)s::execute(ExecContext *xc,
389 Trace::InstRecord *traceData) const
390 {
391 Addr EA M5_VAR_USED;
392 Fault fault = NoFault;
393
394 %(fp_enable_check)s;
395 %(op_decl)s;
396 %(op_rd)s;
397 %(ea_code)s;
398
399 warn_once("Prefetch instructions in Alpha do not do anything\n");
400 if (fault == NoFault) {
401 %(memacc_code)s;
402 }
403
404 return NoFault;
405 }
406}};
407
408// Prefetches in Alpha don't actually do anything
409// They just build an effective address and complete
410def template MiscInitiateAcc {{
385 Trace::InstRecord *traceData) const
386 {
387 Addr EA M5_VAR_USED;
388 Fault fault = NoFault;
389
390 %(fp_enable_check)s;
391 %(op_decl)s;
392 %(op_rd)s;
393 %(ea_code)s;
394
395 warn_once("Prefetch instructions in Alpha do not do anything\n");
396 if (fault == NoFault) {
397 %(memacc_code)s;
398 }
399
400 return NoFault;
401 }
402}};
403
404// Prefetches in Alpha don't actually do anything
405// They just build an effective address and complete
406def template MiscInitiateAcc {{
411 Fault %(class_name)s::initiateAcc(CPU_EXEC_CONTEXT *xc,
407 Fault %(class_name)s::initiateAcc(ExecContext *xc,
412 Trace::InstRecord *traceData) const
413 {
414 warn("initiateAcc undefined: Misc instruction does not support split "
415 "access method!");
416 return NoFault;
417 }
418}};
419
420
421def template MiscCompleteAcc {{
408 Trace::InstRecord *traceData) const
409 {
410 warn("initiateAcc undefined: Misc instruction does not support split "
411 "access method!");
412 return NoFault;
413 }
414}};
415
416
417def template MiscCompleteAcc {{
422 Fault %(class_name)s::completeAcc(PacketPtr pkt,
423 CPU_EXEC_CONTEXT *xc,
418 Fault %(class_name)s::completeAcc(PacketPtr pkt, ExecContext *xc,
424 Trace::InstRecord *traceData) const
425 {
426 warn("completeAcc undefined: Misc instruction does not support split "
427 "access method!");
428
429 return NoFault;
430 }
431}};
432
433
434// load instructions use Ra as dest, so check for
435// Ra == 31 to detect nops
436def template LoadNopCheckDecode {{
437 {
438 AlphaStaticInst *i = new %(class_name)s(machInst);
439 if (RA == 31) {
440 i = makeNop(i);
441 }
442 return i;
443 }
444}};
445
446
447// for some load instructions, Ra == 31 indicates a prefetch (not a nop)
448def template LoadPrefetchCheckDecode {{
449 {
450 if (RA != 31) {
451 return new %(class_name)s(machInst);
452 }
453 else {
454 return new %(class_name)sPrefetch(machInst);
455 }
456 }
457}};
458
459
460let {{
461def LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
462 postacc_code = '', base_class = 'MemoryDisp32',
463 decode_template = BasicDecode, exec_template_base = ''):
464 # Make sure flags are in lists (convert to lists if not).
465 mem_flags = makeList(mem_flags)
466 inst_flags = makeList(inst_flags)
467
468 iop = InstObjParams(name, Name, base_class,
469 { 'ea_code':ea_code, 'memacc_code':memacc_code, 'postacc_code':postacc_code },
470 inst_flags)
471
472 if mem_flags:
473 mem_flags = [ 'Request::%s' % flag for flag in mem_flags ]
474 s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';'
475 iop.constructor += s
476
477 # select templates
478
479 # The InitiateAcc template is the same for StoreCond templates as the
480 # corresponding Store template..
481 StoreCondInitiateAcc = StoreInitiateAcc
482
483 fullExecTemplate = eval(exec_template_base + 'Execute')
484 initiateAccTemplate = eval(exec_template_base + 'InitiateAcc')
485 completeAccTemplate = eval(exec_template_base + 'CompleteAcc')
486
487 # (header_output, decoder_output, decode_block, exec_output)
488 return (LoadStoreDeclare.subst(iop),
489 LoadStoreConstructor.subst(iop),
490 decode_template.subst(iop),
491 fullExecTemplate.subst(iop)
492 + EACompExecute.subst(iop)
493 + initiateAccTemplate.subst(iop)
494 + completeAccTemplate.subst(iop))
495}};
496
497def format LoadOrNop(memacc_code, ea_code = {{ EA = Rb + disp; }},
498 mem_flags = [], inst_flags = []) {{
499 (header_output, decoder_output, decode_block, exec_output) = \
500 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
501 decode_template = LoadNopCheckDecode,
502 exec_template_base = 'Load')
503}};
504
505
506// Note that the flags passed in apply only to the prefetch version
507def format LoadOrPrefetch(memacc_code, ea_code = {{ EA = Rb + disp; }},
508 mem_flags = [], pf_flags = [], inst_flags = []) {{
509 # declare the load instruction object and generate the decode block
510 (header_output, decoder_output, decode_block, exec_output) = \
511 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
512 decode_template = LoadPrefetchCheckDecode,
513 exec_template_base = 'Load')
514
515 # Declare the prefetch instruction object.
516
517 # Make sure flag args are lists so we can mess with them.
518 mem_flags = makeList(mem_flags)
519 pf_flags = makeList(pf_flags)
520 inst_flags = makeList(inst_flags)
521
522 pf_mem_flags = mem_flags + pf_flags + ['PREFETCH']
523 pf_inst_flags = inst_flags
524
525 (pf_header_output, pf_decoder_output, _, pf_exec_output) = \
526 LoadStoreBase(name, Name + 'Prefetch', ea_code, ';',
527 pf_mem_flags, pf_inst_flags, exec_template_base = 'Misc')
528
529 header_output += pf_header_output
530 decoder_output += pf_decoder_output
531 exec_output += pf_exec_output
532}};
533
534
535def format Store(memacc_code, ea_code = {{ EA = Rb + disp; }},
536 mem_flags = [], inst_flags = []) {{
537 (header_output, decoder_output, decode_block, exec_output) = \
538 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
539 exec_template_base = 'Store')
540}};
541
542
543def format StoreCond(memacc_code, postacc_code,
544 ea_code = {{ EA = Rb + disp; }},
545 mem_flags = [], inst_flags = []) {{
546 (header_output, decoder_output, decode_block, exec_output) = \
547 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
548 postacc_code, exec_template_base = 'StoreCond')
549}};
550
551
552// Use 'MemoryNoDisp' as base: for wh64, fetch, ecb
553def format MiscPrefetch(ea_code, memacc_code,
554 mem_flags = [], inst_flags = []) {{
555 (header_output, decoder_output, decode_block, exec_output) = \
556 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
557 base_class = 'MemoryNoDisp', exec_template_base = 'Misc')
558}};
559
560
419 Trace::InstRecord *traceData) const
420 {
421 warn("completeAcc undefined: Misc instruction does not support split "
422 "access method!");
423
424 return NoFault;
425 }
426}};
427
428
429// load instructions use Ra as dest, so check for
430// Ra == 31 to detect nops
431def template LoadNopCheckDecode {{
432 {
433 AlphaStaticInst *i = new %(class_name)s(machInst);
434 if (RA == 31) {
435 i = makeNop(i);
436 }
437 return i;
438 }
439}};
440
441
442// for some load instructions, Ra == 31 indicates a prefetch (not a nop)
443def template LoadPrefetchCheckDecode {{
444 {
445 if (RA != 31) {
446 return new %(class_name)s(machInst);
447 }
448 else {
449 return new %(class_name)sPrefetch(machInst);
450 }
451 }
452}};
453
454
455let {{
456def LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
457 postacc_code = '', base_class = 'MemoryDisp32',
458 decode_template = BasicDecode, exec_template_base = ''):
459 # Make sure flags are in lists (convert to lists if not).
460 mem_flags = makeList(mem_flags)
461 inst_flags = makeList(inst_flags)
462
463 iop = InstObjParams(name, Name, base_class,
464 { 'ea_code':ea_code, 'memacc_code':memacc_code, 'postacc_code':postacc_code },
465 inst_flags)
466
467 if mem_flags:
468 mem_flags = [ 'Request::%s' % flag for flag in mem_flags ]
469 s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';'
470 iop.constructor += s
471
472 # select templates
473
474 # The InitiateAcc template is the same for StoreCond templates as the
475 # corresponding Store template..
476 StoreCondInitiateAcc = StoreInitiateAcc
477
478 fullExecTemplate = eval(exec_template_base + 'Execute')
479 initiateAccTemplate = eval(exec_template_base + 'InitiateAcc')
480 completeAccTemplate = eval(exec_template_base + 'CompleteAcc')
481
482 # (header_output, decoder_output, decode_block, exec_output)
483 return (LoadStoreDeclare.subst(iop),
484 LoadStoreConstructor.subst(iop),
485 decode_template.subst(iop),
486 fullExecTemplate.subst(iop)
487 + EACompExecute.subst(iop)
488 + initiateAccTemplate.subst(iop)
489 + completeAccTemplate.subst(iop))
490}};
491
492def format LoadOrNop(memacc_code, ea_code = {{ EA = Rb + disp; }},
493 mem_flags = [], inst_flags = []) {{
494 (header_output, decoder_output, decode_block, exec_output) = \
495 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
496 decode_template = LoadNopCheckDecode,
497 exec_template_base = 'Load')
498}};
499
500
501// Note that the flags passed in apply only to the prefetch version
502def format LoadOrPrefetch(memacc_code, ea_code = {{ EA = Rb + disp; }},
503 mem_flags = [], pf_flags = [], inst_flags = []) {{
504 # declare the load instruction object and generate the decode block
505 (header_output, decoder_output, decode_block, exec_output) = \
506 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
507 decode_template = LoadPrefetchCheckDecode,
508 exec_template_base = 'Load')
509
510 # Declare the prefetch instruction object.
511
512 # Make sure flag args are lists so we can mess with them.
513 mem_flags = makeList(mem_flags)
514 pf_flags = makeList(pf_flags)
515 inst_flags = makeList(inst_flags)
516
517 pf_mem_flags = mem_flags + pf_flags + ['PREFETCH']
518 pf_inst_flags = inst_flags
519
520 (pf_header_output, pf_decoder_output, _, pf_exec_output) = \
521 LoadStoreBase(name, Name + 'Prefetch', ea_code, ';',
522 pf_mem_flags, pf_inst_flags, exec_template_base = 'Misc')
523
524 header_output += pf_header_output
525 decoder_output += pf_decoder_output
526 exec_output += pf_exec_output
527}};
528
529
530def format Store(memacc_code, ea_code = {{ EA = Rb + disp; }},
531 mem_flags = [], inst_flags = []) {{
532 (header_output, decoder_output, decode_block, exec_output) = \
533 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
534 exec_template_base = 'Store')
535}};
536
537
538def format StoreCond(memacc_code, postacc_code,
539 ea_code = {{ EA = Rb + disp; }},
540 mem_flags = [], inst_flags = []) {{
541 (header_output, decoder_output, decode_block, exec_output) = \
542 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
543 postacc_code, exec_template_base = 'StoreCond')
544}};
545
546
547// Use 'MemoryNoDisp' as base: for wh64, fetch, ecb
548def format MiscPrefetch(ea_code, memacc_code,
549 mem_flags = [], inst_flags = []) {{
550 (header_output, decoder_output, decode_block, exec_output) = \
551 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags,
552 base_class = 'MemoryNoDisp', exec_template_base = 'Misc')
553}};
554
555