mem.isa revision 2107
14997Sgblack@eecs.umich.edu// -*- mode:c++ -*- 25268Sksewell@umich.edu 35222Sksewell@umich.edu// Copyright (c) 2003-2005 The Regents of The University of Michigan 44997Sgblack@eecs.umich.edu// All rights reserved. 54997Sgblack@eecs.umich.edu// 64997Sgblack@eecs.umich.edu// Redistribution and use in source and binary forms, with or without 74997Sgblack@eecs.umich.edu// modification, are permitted provided that the following conditions are 84997Sgblack@eecs.umich.edu// met: redistributions of source code must retain the above copyright 94997Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer; 104997Sgblack@eecs.umich.edu// redistributions in binary form must reproduce the above copyright 114997Sgblack@eecs.umich.edu// notice, this list of conditions and the following disclaimer in the 124997Sgblack@eecs.umich.edu// documentation and/or other materials provided with the distribution; 134997Sgblack@eecs.umich.edu// neither the name of the copyright holders nor the names of its 144997Sgblack@eecs.umich.edu// contributors may be used to endorse or promote products derived from 154997Sgblack@eecs.umich.edu// this software without specific prior written permission. 164997Sgblack@eecs.umich.edu// 174997Sgblack@eecs.umich.edu// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 184997Sgblack@eecs.umich.edu// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 194997Sgblack@eecs.umich.edu// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 204997Sgblack@eecs.umich.edu// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 214997Sgblack@eecs.umich.edu// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 224997Sgblack@eecs.umich.edu// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 234997Sgblack@eecs.umich.edu// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 244997Sgblack@eecs.umich.edu// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 254997Sgblack@eecs.umich.edu// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 264997Sgblack@eecs.umich.edu// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 274997Sgblack@eecs.umich.edu// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 284997Sgblack@eecs.umich.edu 295268Sksewell@umich.eduoutput header {{ 305268Sksewell@umich.edu /** 315268Sksewell@umich.edu * Base class for general Alpha memory-format instructions. 325268Sksewell@umich.edu */ 334997Sgblack@eecs.umich.edu class Memory : public AlphaStaticInst 344997Sgblack@eecs.umich.edu { 354997Sgblack@eecs.umich.edu protected: 364997Sgblack@eecs.umich.edu 374997Sgblack@eecs.umich.edu /// Memory request flags. See mem_req_base.hh. 385222Sksewell@umich.edu unsigned memAccessFlags; 395222Sksewell@umich.edu /// Pointer to EAComp object. 405222Sksewell@umich.edu const StaticInstPtr eaCompPtr; 415222Sksewell@umich.edu /// Pointer to MemAcc object. 425222Sksewell@umich.edu const StaticInstPtr memAccPtr; 435222Sksewell@umich.edu 445222Sksewell@umich.edu /// Constructor 455222Sksewell@umich.edu Memory(const char *mnem, MachInst _machInst, OpClass __opClass, 466022Sgblack@eecs.umich.edu StaticInstPtr _eaCompPtr = nullStaticInstPtr, 477678Sgblack@eecs.umich.edu StaticInstPtr _memAccPtr = nullStaticInstPtr) 484997Sgblack@eecs.umich.edu : AlphaStaticInst(mnem, _machInst, __opClass), 495222Sksewell@umich.edu memAccessFlags(0), eaCompPtr(_eaCompPtr), memAccPtr(_memAccPtr) 504997Sgblack@eecs.umich.edu { 515222Sksewell@umich.edu } 525222Sksewell@umich.edu 535222Sksewell@umich.edu std::string 545222Sksewell@umich.edu generateDisassembly(Addr pc, const SymbolTable *symtab) const; 555222Sksewell@umich.edu 565222Sksewell@umich.edu public: 575222Sksewell@umich.edu 585222Sksewell@umich.edu const StaticInstPtr &eaCompInst() const { return eaCompPtr; } 595222Sksewell@umich.edu const StaticInstPtr &memAccInst() const { return memAccPtr; } 604997Sgblack@eecs.umich.edu }; 615222Sksewell@umich.edu 625222Sksewell@umich.edu /** 635222Sksewell@umich.edu * Base class for memory-format instructions using a 32-bit 645222Sksewell@umich.edu * displacement (i.e. most of them). 655222Sksewell@umich.edu */ 665014Sgblack@eecs.umich.edu class MemoryDisp32 : public Memory 675222Sksewell@umich.edu { 685222Sksewell@umich.edu protected: 695184Sgblack@eecs.umich.edu /// Displacement for EA calculation (signed). 705877Shsul@eecs.umich.edu int32_t disp; 715877Shsul@eecs.umich.edu 725877Shsul@eecs.umich.edu /// Constructor. 735222Sksewell@umich.edu MemoryDisp32(const char *mnem, MachInst _machInst, OpClass __opClass, 745222Sksewell@umich.edu StaticInstPtr _eaCompPtr = nullStaticInstPtr, 755222Sksewell@umich.edu StaticInstPtr _memAccPtr = nullStaticInstPtr) 765222Sksewell@umich.edu : Memory(mnem, _machInst, __opClass, _eaCompPtr, _memAccPtr), 775014Sgblack@eecs.umich.edu disp(MEMDISP) 785222Sksewell@umich.edu { 795222Sksewell@umich.edu } 805222Sksewell@umich.edu }; 815222Sksewell@umich.edu 825014Sgblack@eecs.umich.edu 834997Sgblack@eecs.umich.edu /** 844997Sgblack@eecs.umich.edu * Base class for a few miscellaneous memory-format insts 855358Sgblack@eecs.umich.edu * that don't interpret the disp field: wh64, fetch, fetch_m, ecb. 865222Sksewell@umich.edu * None of these instructions has a destination register either. 875222Sksewell@umich.edu */ 885222Sksewell@umich.edu class MemoryNoDisp : public Memory 895543Ssaidi@eecs.umich.edu { 905222Sksewell@umich.edu protected: 915543Ssaidi@eecs.umich.edu /// Constructor 925543Ssaidi@eecs.umich.edu MemoryNoDisp(const char *mnem, MachInst _machInst, OpClass __opClass, 935543Ssaidi@eecs.umich.edu StaticInstPtr _eaCompPtr = nullStaticInstPtr, 945222Sksewell@umich.edu StaticInstPtr _memAccPtr = nullStaticInstPtr) 955222Sksewell@umich.edu : Memory(mnem, _machInst, __opClass, _eaCompPtr, _memAccPtr) 965222Sksewell@umich.edu { 975222Sksewell@umich.edu } 985999Snate@binkert.org 995999Snate@binkert.org std::string 1005999Snate@binkert.org generateDisassembly(Addr pc, const SymbolTable *symtab) const; 1015999Snate@binkert.org }; 1025999Snate@binkert.org}}; 1035999Snate@binkert.org 1045999Snate@binkert.org 1055999Snate@binkert.orgoutput decoder {{ 1065222Sksewell@umich.edu std::string 1075222Sksewell@umich.edu Memory::generateDisassembly(Addr pc, const SymbolTable *symtab) const 1085222Sksewell@umich.edu { 1095222Sksewell@umich.edu return csprintf("%-10s %c%d,%d(r%d)", mnemonic, 1105222Sksewell@umich.edu flags[IsFloating] ? 'f' : 'r', RA, MEMDISP, RB); 1115222Sksewell@umich.edu } 1125222Sksewell@umich.edu 1135222Sksewell@umich.edu std::string 1145222Sksewell@umich.edu MemoryNoDisp::generateDisassembly(Addr pc, const SymbolTable *symtab) const 1155222Sksewell@umich.edu { 1165222Sksewell@umich.edu return csprintf("%-10s (r%d)", mnemonic, RB); 1175222Sksewell@umich.edu } 1185222Sksewell@umich.edu}}; 1195222Sksewell@umich.edu 1205222Sksewell@umich.edudef format LoadAddress(code) {{ 1215222Sksewell@umich.edu iop = InstObjParams(name, Name, 'MemoryDisp32', CodeBlock(code)) 1225222Sksewell@umich.edu header_output = BasicDeclare.subst(iop) 1235222Sksewell@umich.edu decoder_output = BasicConstructor.subst(iop) 1245358Sgblack@eecs.umich.edu decode_block = BasicDecode.subst(iop) 1255358Sgblack@eecs.umich.edu exec_output = BasicExecute.subst(iop) 1265358Sgblack@eecs.umich.edu}}; 1275358Sgblack@eecs.umich.edu 1285222Sksewell@umich.edu 1295222Sksewell@umich.edudef template LoadStoreDeclare {{ 1305222Sksewell@umich.edu /** 1315222Sksewell@umich.edu * Static instruction class for "%(mnemonic)s". 1325222Sksewell@umich.edu */ 1335222Sksewell@umich.edu class %(class_name)s : public %(base_class)s 1345222Sksewell@umich.edu { 1355222Sksewell@umich.edu protected: 1365222Sksewell@umich.edu 1375222Sksewell@umich.edu /** 1385222Sksewell@umich.edu * "Fake" effective address computation class for "%(mnemonic)s". 1395222Sksewell@umich.edu */ 1406023Snate@binkert.org class EAComp : public %(base_class)s 1415894Sgblack@eecs.umich.edu { 1426023Snate@binkert.org public: 1435222Sksewell@umich.edu /// Constructor 1446022Sgblack@eecs.umich.edu EAComp(MachInst machInst); 1456022Sgblack@eecs.umich.edu 1466022Sgblack@eecs.umich.edu %(BasicExecDeclare)s 1475222Sksewell@umich.edu }; 1485222Sksewell@umich.edu 1495222Sksewell@umich.edu /** 1505222Sksewell@umich.edu * "Fake" memory access instruction class for "%(mnemonic)s". 1515222Sksewell@umich.edu */ 1525222Sksewell@umich.edu class MemAcc : public %(base_class)s 1535222Sksewell@umich.edu { 154 public: 155 /// Constructor 156 MemAcc(MachInst machInst); 157 158 %(BasicExecDeclare)s 159 }; 160 161 public: 162 163 /// Constructor. 164 %(class_name)s(MachInst machInst); 165 166 %(BasicExecDeclare)s 167 168 %(InitiateAccDeclare)s 169 170 %(CompleteAccDeclare)s 171 }; 172}}; 173 174 175def template InitiateAccDeclare {{ 176 Fault * initiateAcc(%(CPU_exec_context)s *, Trace::InstRecord *) const; 177}}; 178 179 180def template CompleteAccDeclare {{ 181 Fault * completeAcc(uint8_t *, %(CPU_exec_context)s *, Trace::InstRecord *) const; 182}}; 183 184 185def template LoadStoreConstructor {{ 186 /** TODO: change op_class to AddrGenOp or something (requires 187 * creating new member of OpClass enum in op_class.hh, updating 188 * config files, etc.). */ 189 inline %(class_name)s::EAComp::EAComp(MachInst machInst) 190 : %(base_class)s("%(mnemonic)s (EAComp)", machInst, IntAluOp) 191 { 192 %(ea_constructor)s; 193 } 194 195 inline %(class_name)s::MemAcc::MemAcc(MachInst machInst) 196 : %(base_class)s("%(mnemonic)s (MemAcc)", machInst, %(op_class)s) 197 { 198 %(memacc_constructor)s; 199 } 200 201 inline %(class_name)s::%(class_name)s(MachInst machInst) 202 : %(base_class)s("%(mnemonic)s", machInst, %(op_class)s, 203 new EAComp(machInst), new MemAcc(machInst)) 204 { 205 %(constructor)s; 206 } 207}}; 208 209 210def template EACompExecute {{ 211 Fault * 212 %(class_name)s::EAComp::execute(%(CPU_exec_context)s *xc, 213 Trace::InstRecord *traceData) const 214 { 215 Addr EA; 216 Fault * fault = NoFault; 217 218 %(fp_enable_check)s; 219 %(op_decl)s; 220 %(op_rd)s; 221 %(code)s; 222 223 if (fault == NoFault) { 224 %(op_wb)s; 225 xc->setEA(EA); 226 } 227 228 return fault; 229 } 230}}; 231 232def template LoadMemAccExecute {{ 233 Fault * 234 %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 235 Trace::InstRecord *traceData) const 236 { 237 Addr EA; 238 Fault * fault = NoFault; 239 240 %(fp_enable_check)s; 241 %(op_decl)s; 242 %(op_rd)s; 243 EA = xc->getEA(); 244 245 if (fault == NoFault) { 246 fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags); 247 %(code)s; 248 } 249 250 if (fault == NoFault) { 251 %(op_wb)s; 252 } 253 254 return fault; 255 } 256}}; 257 258 259def template LoadExecute {{ 260 Fault * %(class_name)s::execute(%(CPU_exec_context)s *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 fault = xc->read(EA, (uint%(mem_acc_size)d_t&)Mem, memAccessFlags); 273 %(memacc_code)s; 274 } 275 276 if (fault == NoFault) { 277 %(op_wb)s; 278 } 279 280 return fault; 281 } 282}}; 283 284 285def template LoadInitiateAcc {{ 286 Fault * %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 287 Trace::InstRecord *traceData) const 288 { 289 Addr EA; 290 Fault * fault = NoFault; 291 %(mem_acc_type)s Mem = 0; 292 293 %(fp_enable_check)s; 294 %(op_src_decl)s; 295 %(op_rd)s; 296 %(ea_code)s; 297 298 if (fault == NoFault) { 299 fault = xc->read(EA, (uint%(mem_acc_size)d_t &)Mem, memAccessFlags); 300 } 301 302 return fault; 303 } 304}}; 305 306 307def template LoadCompleteAcc {{ 308 Fault * %(class_name)s::completeAcc(uint8_t *data, 309 %(CPU_exec_context)s *xc, 310 Trace::InstRecord *traceData) const 311 { 312 Fault * fault = NoFault; 313 %(mem_acc_type)s Mem = 0; 314 315 %(fp_enable_check)s; 316 %(op_dest_decl)s; 317 318 memcpy(&Mem, data, sizeof(Mem)); 319 320 if (fault == NoFault) { 321 %(memacc_code)s; 322 } 323 324 if (fault == NoFault) { 325 %(op_wb)s; 326 } 327 328 return fault; 329 } 330}}; 331 332 333def template StoreMemAccExecute {{ 334 Fault * 335 %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 336 Trace::InstRecord *traceData) const 337 { 338 Addr EA; 339 Fault * fault = NoFault; 340 uint64_t write_result = 0; 341 342 %(fp_enable_check)s; 343 %(op_decl)s; 344 %(op_rd)s; 345 EA = xc->getEA(); 346 347 if (fault == NoFault) { 348 %(code)s; 349 } 350 351 if (fault == NoFault) { 352 fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 353 memAccessFlags, &write_result); 354 if (traceData) { traceData->setData(Mem); } 355 } 356 357 if (fault == NoFault) { 358 %(postacc_code)s; 359 } 360 361 if (fault == NoFault) { 362 %(op_wb)s; 363 } 364 365 return fault; 366 } 367}}; 368 369 370def template StoreExecute {{ 371 Fault * %(class_name)s::execute(%(CPU_exec_context)s *xc, 372 Trace::InstRecord *traceData) const 373 { 374 Addr EA; 375 Fault * fault = NoFault; 376 uint64_t write_result = 0; 377 378 %(fp_enable_check)s; 379 %(op_decl)s; 380 %(op_rd)s; 381 %(ea_code)s; 382 383 if (fault == NoFault) { 384 %(memacc_code)s; 385 } 386 387 if (fault == NoFault) { 388 fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 389 memAccessFlags, &write_result); 390 if (traceData) { traceData->setData(Mem); } 391 } 392 393 if (fault == NoFault) { 394 %(postacc_code)s; 395 } 396 397 if (fault == NoFault) { 398 %(op_wb)s; 399 } 400 401 return fault; 402 } 403}}; 404 405def template StoreInitiateAcc {{ 406 Fault * %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 407 Trace::InstRecord *traceData) const 408 { 409 Addr EA; 410 Fault * fault = NoFault; 411 uint64_t write_result = 0; 412 %(mem_acc_type)s Mem = 0; 413 414 %(fp_enable_check)s; 415 %(op_src_decl)s; 416 %(op_rd)s; 417 %(ea_code)s; 418 419 if (fault == NoFault) { 420 %(memacc_code)s; 421 } 422 423 if (fault == NoFault) { 424 fault = xc->write((uint%(mem_acc_size)d_t&)Mem, EA, 425 memAccessFlags, &write_result); 426 if (traceData) { traceData->setData(Mem); } 427 } 428 429 return fault; 430 } 431}}; 432 433 434def template StoreCompleteAcc {{ 435 Fault * %(class_name)s::completeAcc(uint8_t *data, 436 %(CPU_exec_context)s *xc, 437 Trace::InstRecord *traceData) const 438 { 439 Fault * fault = NoFault; 440 uint64_t write_result = 0; 441 442 %(fp_enable_check)s; 443 %(op_dest_decl)s; 444 445 memcpy(&write_result, data, sizeof(write_result)); 446 447 if (fault == NoFault) { 448 %(postacc_code)s; 449 } 450 451 if (fault == NoFault) { 452 %(op_wb)s; 453 } 454 455 return fault; 456 } 457}}; 458 459 460def template MiscMemAccExecute {{ 461 Fault * %(class_name)s::MemAcc::execute(%(CPU_exec_context)s *xc, 462 Trace::InstRecord *traceData) const 463 { 464 Addr EA; 465 Fault * fault = NoFault; 466 467 %(fp_enable_check)s; 468 %(op_decl)s; 469 %(op_rd)s; 470 EA = xc->getEA(); 471 472 if (fault == NoFault) { 473 %(code)s; 474 } 475 476 return NoFault; 477 } 478}}; 479 480def template MiscExecute {{ 481 Fault * %(class_name)s::execute(%(CPU_exec_context)s *xc, 482 Trace::InstRecord *traceData) const 483 { 484 Addr EA; 485 Fault * fault = NoFault; 486 487 %(fp_enable_check)s; 488 %(op_decl)s; 489 %(op_rd)s; 490 %(ea_code)s; 491 492 if (fault == NoFault) { 493 %(memacc_code)s; 494 } 495 496 return NoFault; 497 } 498}}; 499 500def template MiscInitiateAcc {{ 501 Fault * %(class_name)s::initiateAcc(%(CPU_exec_context)s *xc, 502 Trace::InstRecord *traceData) const 503 { 504 Addr EA; 505 Fault * fault = NoFault; 506 507 %(fp_enable_check)s; 508 %(op_decl)s; 509 %(op_rd)s; 510 %(ea_code)s; 511 512 if (fault == NoFault) { 513 %(memacc_code)s; 514 } 515 516 return NoFault; 517 } 518}}; 519 520 521def template MiscCompleteAcc {{ 522 Fault * %(class_name)s::completeAcc(uint8_t *data, 523 %(CPU_exec_context)s *xc, 524 Trace::InstRecord *traceData) const 525 { 526 return NoFault; 527 } 528}}; 529 530// load instructions use Ra as dest, so check for 531// Ra == 31 to detect nops 532def template LoadNopCheckDecode {{ 533 { 534 AlphaStaticInst *i = new %(class_name)s(machInst); 535 if (RA == 31) { 536 i = makeNop(i); 537 } 538 return i; 539 } 540}}; 541 542 543// for some load instructions, Ra == 31 indicates a prefetch (not a nop) 544def template LoadPrefetchCheckDecode {{ 545 { 546 if (RA != 31) { 547 return new %(class_name)s(machInst); 548 } 549 else { 550 return new %(class_name)sPrefetch(machInst); 551 } 552 } 553}}; 554 555 556let {{ 557def LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 558 postacc_code = '', base_class = 'MemoryDisp32', 559 decode_template = BasicDecode, exec_template_base = ''): 560 # Make sure flags are in lists (convert to lists if not). 561 mem_flags = makeList(mem_flags) 562 inst_flags = makeList(inst_flags) 563 564 # add hook to get effective addresses into execution trace output. 565 ea_code += '\nif (traceData) { traceData->setAddr(EA); }\n' 566 567 # generate code block objects 568 ea_cblk = CodeBlock(ea_code) 569 memacc_cblk = CodeBlock(memacc_code) 570 postacc_cblk = CodeBlock(postacc_code) 571 572 # Some CPU models execute the memory operation as an atomic unit, 573 # while others want to separate them into an effective address 574 # computation and a memory access operation. As a result, we need 575 # to generate three StaticInst objects. Note that the latter two 576 # are nested inside the larger "atomic" one. 577 578 # generate InstObjParams for EAComp object 579 ea_iop = InstObjParams(name, Name, base_class, ea_cblk, inst_flags) 580 581 # generate InstObjParams for MemAcc object 582 memacc_iop = InstObjParams(name, Name, base_class, memacc_cblk, inst_flags) 583 # in the split execution model, the MemAcc portion is responsible 584 # for the post-access code. 585 memacc_iop.postacc_code = postacc_cblk.code 586 587 # generate InstObjParams for unified execution 588 cblk = CodeBlock(ea_code + memacc_code + postacc_code) 589 iop = InstObjParams(name, Name, base_class, cblk, inst_flags) 590 591 iop.ea_constructor = ea_cblk.constructor 592 iop.ea_code = ea_cblk.code 593 iop.memacc_constructor = memacc_cblk.constructor 594 iop.memacc_code = memacc_cblk.code 595 iop.postacc_code = postacc_cblk.code 596 597 if mem_flags: 598 s = '\n\tmemAccessFlags = ' + string.join(mem_flags, '|') + ';' 599 iop.constructor += s 600 memacc_iop.constructor += s 601 602 # select templates 603 memAccExecTemplate = eval(exec_template_base + 'MemAccExecute') 604 fullExecTemplate = eval(exec_template_base + 'Execute') 605 initiateAccTemplate = eval(exec_template_base + 'InitiateAcc') 606 completeAccTemplate = eval(exec_template_base + 'CompleteAcc') 607 608 # (header_output, decoder_output, decode_block, exec_output) 609 return (LoadStoreDeclare.subst(iop), LoadStoreConstructor.subst(iop), 610 decode_template.subst(iop), 611 EACompExecute.subst(ea_iop) 612 + memAccExecTemplate.subst(memacc_iop) 613 + fullExecTemplate.subst(iop) 614 + initiateAccTemplate.subst(iop) 615 + completeAccTemplate.subst(iop)) 616}}; 617 618 619def format LoadOrNop(memacc_code, ea_code = {{ EA = Rb + disp; }}, 620 mem_flags = [], inst_flags = []) {{ 621 (header_output, decoder_output, decode_block, exec_output) = \ 622 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 623 decode_template = LoadNopCheckDecode, 624 exec_template_base = 'Load') 625}}; 626 627 628// Note that the flags passed in apply only to the prefetch version 629def format LoadOrPrefetch(memacc_code, ea_code = {{ EA = Rb + disp; }}, 630 mem_flags = [], pf_flags = [], inst_flags = []) {{ 631 # declare the load instruction object and generate the decode block 632 (header_output, decoder_output, decode_block, exec_output) = \ 633 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 634 decode_template = LoadPrefetchCheckDecode, 635 exec_template_base = 'Load') 636 637 # Declare the prefetch instruction object. 638 639 # Make sure flag args are lists so we can mess with them. 640 mem_flags = makeList(mem_flags) 641 pf_flags = makeList(pf_flags) 642 inst_flags = makeList(inst_flags) 643 644 pf_mem_flags = mem_flags + pf_flags + ['NO_FAULT'] 645 pf_inst_flags = inst_flags + ['IsMemRef', 'IsLoad', 646 'IsDataPrefetch', 'MemReadOp'] 647 648 (pf_header_output, pf_decoder_output, _, pf_exec_output) = \ 649 LoadStoreBase(name, Name + 'Prefetch', ea_code, 650 'xc->prefetch(EA, memAccessFlags);', 651 pf_mem_flags, pf_inst_flags, exec_template_base = 'Misc') 652 653 header_output += pf_header_output 654 decoder_output += pf_decoder_output 655 exec_output += pf_exec_output 656}}; 657 658 659def format Store(memacc_code, ea_code = {{ EA = Rb + disp; }}, 660 mem_flags = [], inst_flags = []) {{ 661 (header_output, decoder_output, decode_block, exec_output) = \ 662 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 663 exec_template_base = 'Store') 664}}; 665 666 667def format StoreCond(memacc_code, postacc_code, 668 ea_code = {{ EA = Rb + disp; }}, 669 mem_flags = [], inst_flags = []) {{ 670 (header_output, decoder_output, decode_block, exec_output) = \ 671 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 672 postacc_code, exec_template_base = 'Store') 673}}; 674 675 676// Use 'MemoryNoDisp' as base: for wh64, fetch, ecb 677def format MiscPrefetch(ea_code, memacc_code, 678 mem_flags = [], inst_flags = []) {{ 679 (header_output, decoder_output, decode_block, exec_output) = \ 680 LoadStoreBase(name, Name, ea_code, memacc_code, mem_flags, inst_flags, 681 base_class = 'MemoryNoDisp', exec_template_base = 'Misc') 682}}; 683 684 685