| OLD | NEW |
| 1 import os | 1 import os |
| 2 import sys | 2 import sys |
| 3 | 3 |
| 4 class RegAliases(object): | 4 class RegAliases(object): |
| 5 def __init__(self, AliasesStr): | 5 def __init__(self, AliasesStr): |
| 6 self.Aliases = list(Alias.strip() for Alias in AliasesStr.split(',')) | 6 self.Aliases = list(Alias.strip() for Alias in AliasesStr.split(',')) |
| 7 | 7 |
| 8 def __str__(self): | 8 def __str__(self): |
| 9 return 'REGLIST{AliasCount}(RegARM32, {Aliases})'.format( | 9 return 'REGLIST{AliasCount}(RegARM32, {Aliases})'.format( |
| 10 AliasCount=len(self.Aliases), Aliases=', '.join(self.Aliases)) | 10 AliasCount=len(self.Aliases), Aliases=', '.join(self.Aliases)) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 def LivesInGPR(self): | 47 def LivesInGPR(self): |
| 48 return (any(self.FeaturesDict[IntFeature] for IntFeature in ( | 48 return (any(self.FeaturesDict[IntFeature] for IntFeature in ( |
| 49 'IsInt', 'IsI64Pair', 'IsStackPtr', 'IsFramePtr')) or | 49 'IsInt', 'IsI64Pair', 'IsStackPtr', 'IsFramePtr')) or |
| 50 not self.LivesInVFP()) | 50 not self.LivesInVFP()) |
| 51 | 51 |
| 52 def LivesInVFP(self): | 52 def LivesInVFP(self): |
| 53 return any(self.FeaturesDict[FpFeature] for FpFeature in ( | 53 return any(self.FeaturesDict[FpFeature] for FpFeature in ( |
| 54 'IsFP32', 'IsFP64', 'IsVec128')) | 54 'IsFP32', 'IsFP64', 'IsVec128')) |
| 55 | 55 |
| 56 def DefiningXMacro(self): | 56 def DefiningXMacro(self, OtherFeatures): |
| 57 return 'define X({parameters})'.format(parameters=', '.join(self.Features)) | 57 return 'define X({parameters})'.format( |
| 58 parameters=', '.join(OtherFeatures + self.Features)) |
| 58 | 59 |
| 59 class Reg(object): | 60 class Reg(object): |
| 60 def __init__(self, Name, Encode, AsmStr=None, **Features): | 61 def __init__(self, Name, Encode, AsmStr=None, **Features): |
| 61 self.Name = Name | 62 self.Name = Name |
| 62 self.Encode = Encode | 63 self.Encode = Encode |
| 63 if not AsmStr: | 64 if not AsmStr: |
| 64 AsmStr = '%s' % Name | 65 AsmStr = '%s' % Name |
| 65 self.Features = RegFeatures(AsmStr=AsmStr, **Features) | 66 self.Features = RegFeatures(AsmStr=AsmStr, **Features) |
| 66 | 67 |
| 67 def __str__(self): | 68 def __str__(self): |
| 68 return 'Reg_{Name}, {Encode}, {Features}'.format(Name=self.Name, | 69 return 'Reg_{Name}, {Encode}, {Features}'.format(Name=self.Name, |
| 69 Encode=self.Encode, Features=self.Features) | 70 Encode=self.Encode, Features=self.Features) |
| 70 | 71 |
| 71 def IsAnAliasOf(self, Other): | 72 def IsAnAliasOf(self, Other): |
| 72 return Other.Name in self.Features.Aliases().Aliases | 73 return Other.Name in self.Features.Aliases().Aliases |
| 73 | 74 |
| 74 def DefiningXMacro(self): | 75 def DefiningXMacro(self): |
| 75 return self.Features.DefiningXMacro() | 76 return self.Features.DefiningXMacro(['Tag', 'Encoding']) |
| 76 | 77 |
| 77 # Note: The following tables break the usual 80-col on purpose -- it is easier | 78 # Note: The following tables break the usual 80-col on purpose -- it is easier |
| 78 # to read the register tables if each register entry is contained on a single | 79 # to read the register tables if each register entry is contained on a single |
| 79 # line. | 80 # line. |
| 80 GPRs = [ | 81 GPRs = [ |
| 81 Reg( 'r0', 0, IsScratch=1, CCArg=1, IsGPR = 1, IsInt=1, Alias
es= 'r0, r0r1'), | 82 Reg( 'r0', 0, IsScratch=1, CCArg=1, IsGPR = 1, IsInt=1, Alias
es= 'r0, r0r1'), |
| 82 Reg( 'r1', 1, IsScratch=1, CCArg=2, IsGPR = 1, IsInt=1, Alias
es= 'r1, r0r1'), | 83 Reg( 'r1', 1, IsScratch=1, CCArg=2, IsGPR = 1, IsInt=1, Alias
es= 'r1, r0r1'), |
| 83 Reg( 'r2', 2, IsScratch=1, CCArg=3, IsGPR = 1, IsInt=1, Alias
es= 'r2, r2r3'), | 84 Reg( 'r2', 2, IsScratch=1, CCArg=3, IsGPR = 1, IsInt=1, Alias
es= 'r2, r2r3'), |
| 84 Reg( 'r3', 3, IsScratch=1, CCArg=4, IsGPR = 1, IsInt=1, Alias
es= 'r3, r2r3'), | 85 Reg( 'r3', 3, IsScratch=1, CCArg=4, IsGPR = 1, IsInt=1, Alias
es= 'r3, r2r3'), |
| 85 Reg( 'r4', 4, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r4, r4r5'), | 86 Reg( 'r4', 4, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r4, r4r5'), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 "#ifndef SUBZERO_SRC_ICEREGISTERSARM32_DEF\n" | 220 "#ifndef SUBZERO_SRC_ICEREGISTERSARM32_DEF\n" |
| 220 "#define SUBZERO_SRC_ICEREGISTERSARM32_DEF\n".format(script=os.path.basen
ame(sys.argv[0]))) | 221 "#define SUBZERO_SRC_ICEREGISTERSARM32_DEF\n".format(script=os.path.basen
ame(sys.argv[0]))) |
| 221 | 222 |
| 222 for Name, RegClass in RegClasses: | 223 for Name, RegClass in RegClasses: |
| 223 print '\n//{xmacro}'.format(xmacro=Reg.DefiningXMacro()) | 224 print '\n//{xmacro}'.format(xmacro=Reg.DefiningXMacro()) |
| 224 print "#define REGARM32_%s_TABLE" % Name, | 225 print "#define REGARM32_%s_TABLE" % Name, |
| 225 for Reg in RegClass: | 226 for Reg in RegClass: |
| 226 print '\\\n X({Reg})'.format(Reg=Reg), | 227 print '\\\n X({Reg})'.format(Reg=Reg), |
| 227 print '\n' | 228 print '\n' |
| 228 print "#endif // SUBZERO_SRC_ICEREGISTERSARM32_DEF", | 229 print "#endif // SUBZERO_SRC_ICEREGISTERSARM32_DEF", |
| OLD | NEW |