Type.py (7832:de7601e6e19d) | Type.py (8086:bf0335d98250) |
---|---|
1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 2# Copyright (c) 2009 The Hewlett-Packard Development Company 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 86 unchanged lines hidden (view full) --- 95 if self.ident == "Prefetcher": 96 self["prefetcher"] = "yes" 97 98 if self.ident == "DNUCA_Movement": 99 self["mover"] = "yes" 100 101 self.isMachineType = (ident == "MachineType") 102 | 1# Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 2# Copyright (c) 2009 The Hewlett-Packard Development Company 3# All rights reserved. 4# 5# Redistribution and use in source and binary forms, with or without 6# modification, are permitted provided that the following conditions are 7# met: redistributions of source code must retain the above copyright 8# notice, this list of conditions and the following disclaimer; --- 86 unchanged lines hidden (view full) --- 95 if self.ident == "Prefetcher": 96 self["prefetcher"] = "yes" 97 98 if self.ident == "DNUCA_Movement": 99 self["mover"] = "yes" 100 101 self.isMachineType = (ident == "MachineType") 102 |
103 self.isStateDecl = ("state_decl" in self) 104 self.statePermPairs = [] 105 |
|
103 self.data_members = orderdict() 104 105 # Methods 106 self.methods = {} 107 108 # Enums 109 self.enums = orderdict() 110 --- 42 unchanged lines hidden (view full) --- 153 return self.data_members[ident].type 154 155 def methodId(self, name, param_type_vec): 156 return '_'.join([name] + [ pt.c_ident for pt in param_type_vec ]) 157 158 def methodIdAbstract(self, name, param_type_vec): 159 return '_'.join([name] + [ pt.abstract_ident for pt in param_type_vec ]) 160 | 106 self.data_members = orderdict() 107 108 # Methods 109 self.methods = {} 110 111 # Enums 112 self.enums = orderdict() 113 --- 42 unchanged lines hidden (view full) --- 156 return self.data_members[ident].type 157 158 def methodId(self, name, param_type_vec): 159 return '_'.join([name] + [ pt.c_ident for pt in param_type_vec ]) 160 161 def methodIdAbstract(self, name, param_type_vec): 162 return '_'.join([name] + [ pt.abstract_ident for pt in param_type_vec ]) 163 |
164 def statePermPairAdd(self, state_name, perm_name): 165 self.statePermPairs.append([state_name, perm_name]) 166 |
|
161 def methodAdd(self, name, return_type, param_type_vec): 162 ident = self.methodId(name, param_type_vec) 163 if ident in self.methods: 164 return False 165 166 self.methods[ident] = Method(return_type, param_type_vec) 167 return True 168 --- 272 unchanged lines hidden (view full) --- 441 442#ifndef __${{self.c_ident}}_HH__ 443#define __${{self.c_ident}}_HH__ 444 445#include <iostream> 446#include <string> 447 448#include "mem/ruby/common/Global.hh" | 167 def methodAdd(self, name, return_type, param_type_vec): 168 ident = self.methodId(name, param_type_vec) 169 if ident in self.methods: 170 return False 171 172 self.methods[ident] = Method(return_type, param_type_vec) 173 return True 174 --- 272 unchanged lines hidden (view full) --- 447 448#ifndef __${{self.c_ident}}_HH__ 449#define __${{self.c_ident}}_HH__ 450 451#include <iostream> 452#include <string> 453 454#include "mem/ruby/common/Global.hh" |
455''') 456 if self.isStateDecl: 457 code('#include "mem/protocol/AccessPermission.hh"') |
|
449 | 458 |
459 code(''' 460 |
|
450// Class definition 451/** \\enum ${{self.c_ident}} 452 * \\brief ${{self.desc}} 453 */ 454enum ${{self.c_ident}} { 455 ${{self.c_ident}}_FIRST, 456''') 457 --- 28 unchanged lines hidden (view full) --- 486MachineType ${{self.c_ident}}_from_base_level(int); 487int ${{self.c_ident}}_base_number(const ${{self.c_ident}}& obj); 488int ${{self.c_ident}}_base_count(const ${{self.c_ident}}& obj); 489''') 490 491 for enum in self.enums.itervalues(): 492 code('#define MACHINETYPE_${{enum.ident}} 1') 493 | 461// Class definition 462/** \\enum ${{self.c_ident}} 463 * \\brief ${{self.desc}} 464 */ 465enum ${{self.c_ident}} { 466 ${{self.c_ident}}_FIRST, 467''') 468 --- 28 unchanged lines hidden (view full) --- 497MachineType ${{self.c_ident}}_from_base_level(int); 498int ${{self.c_ident}}_base_number(const ${{self.c_ident}}& obj); 499int ${{self.c_ident}}_base_count(const ${{self.c_ident}}& obj); 500''') 501 502 for enum in self.enums.itervalues(): 503 code('#define MACHINETYPE_${{enum.ident}} 1') 504 |
505 if self.isStateDecl: 506 code(''' 507 508// Code to convert the current state to an access permission 509AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj); 510 511''') 512 |
|
494 # Trailer 495 code(''' 496std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj); 497 498#endif // __${{self.c_ident}}_HH__ 499''') 500 501 code.write(path, "%s.hh" % self.c_ident) --- 12 unchanged lines hidden (view full) --- 514 515#include "base/misc.hh" 516#include "mem/protocol/${{self.c_ident}}.hh" 517 518using namespace std; 519 520''') 521 | 513 # Trailer 514 code(''' 515std::ostream& operator<<(std::ostream& out, const ${{self.c_ident}}& obj); 516 517#endif // __${{self.c_ident}}_HH__ 518''') 519 520 code.write(path, "%s.hh" % self.c_ident) --- 12 unchanged lines hidden (view full) --- 533 534#include "base/misc.hh" 535#include "mem/protocol/${{self.c_ident}}.hh" 536 537using namespace std; 538 539''') 540 |
541 if self.isStateDecl: 542 code(''' 543// Code to convert the current state to an access permission 544AccessPermission ${{self.c_ident}}_to_permission(const ${{self.c_ident}}& obj) 545{ 546 switch(obj) { 547''') 548 # For each case 549 code.indent() 550 for statePerm in self.statePermPairs: 551 code(' case ${{self.c_ident}}_${{statePerm[0]}}:') 552 code(' return AccessPermission_${{statePerm[1]}};') 553 code.dedent() 554 code (''' 555 default: 556 panic("Unknown state access permission converstion for ${{self.c_ident}}"); 557 } 558} 559 560''') 561 |
|
522 if self.isMachineType: 523 for enum in self.enums.itervalues(): 524 code('#include "mem/protocol/${{enum.ident}}_Controller.hh"') 525 526 code(''' 527// Code for output operator 528ostream& 529operator<<(ostream& out, const ${{self.c_ident}}& obj) --- 172 unchanged lines hidden --- | 562 if self.isMachineType: 563 for enum in self.enums.itervalues(): 564 code('#include "mem/protocol/${{enum.ident}}_Controller.hh"') 565 566 code(''' 567// Code for output operator 568ostream& 569operator<<(ostream& out, const ${{self.c_ident}}& obj) --- 172 unchanged lines hidden --- |