Ruby: Add field to slicc machine for generic type
authorJoel Hestness <jthestness@gmail.com>
Tue, 9 Apr 2013 21:25:29 +0000 (16:25 -0500)
committerJoel Hestness <jthestness@gmail.com>
Tue, 9 Apr 2013 21:25:29 +0000 (16:25 -0500)
This allows you to have (i.e.) an L2 cache that is not named "L2Cache"
but is still a GenericMachineType_L2Cache. This is particularly
helpful if the protocol has multiple L2 controllers.

src/mem/slicc/symbols/Type.py

index 6ee48ba8bee2f0e6a73cce05be64d50c649f3a75..1c2177ce1a22de76b6127f9d11af4a546ec95d00 100644 (file)
@@ -540,9 +540,11 @@ ConvertMachToGenericMach(MachineType machType)
 {
 ''')
             for enum in self.enums.itervalues():
+                genericType = self.enums[enum.ident].get('genericType',
+                                                         enum.ident)
                 code('''
       if (machType == MachineType_${{enum.ident}})
-          return GenericMachineType_${{enum.ident}};
+          return GenericMachineType_${{genericType}};
 ''')
             code('''
       panic("cannot convert to a GenericMachineType");