| 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): |
| 57 return 'define X({parameters})'.format(parameters=', '.join(self.Features)) |
| 58 |
| 56 class Reg(object): | 59 class Reg(object): |
| 57 def __init__(self, Name, Encode, AsmStr=None, **Features): | 60 def __init__(self, Name, Encode, AsmStr=None, **Features): |
| 58 self.Name = Name | 61 self.Name = Name |
| 59 self.Encode = Encode | 62 self.Encode = Encode |
| 60 if not AsmStr: | 63 if not AsmStr: |
| 61 AsmStr = '%s' % Name | 64 AsmStr = '%s' % Name |
| 62 self.Features = RegFeatures(AsmStr=AsmStr, **Features) | 65 self.Features = RegFeatures(AsmStr=AsmStr, **Features) |
| 63 | 66 |
| 64 def __str__(self): | 67 def __str__(self): |
| 65 return 'Reg_{Name}, {Encode}, {Features}'.format(Name=self.Name, | 68 return 'Reg_{Name}, {Encode}, {Features}'.format(Name=self.Name, |
| 66 Encode=self.Encode, Features=self.Features) | 69 Encode=self.Encode, Features=self.Features) |
| 67 | 70 |
| 68 def IsAnAliasOf(self, Other): | 71 def IsAnAliasOf(self, Other): |
| 69 return Other.Name in self.Features.Aliases().Aliases | 72 return Other.Name in self.Features.Aliases().Aliases |
| 70 | 73 |
| 74 def DefiningXMacro(self): |
| 75 return self.Features.DefiningXMacro() |
| 76 |
| 71 # Note: The following tables break the usual 80-col on purpose -- it is easier | 77 # Note: The following tables break the usual 80-col on purpose -- it is easier |
| 72 # to read the register tables if each register entry is contained on a single | 78 # to read the register tables if each register entry is contained on a single |
| 73 # line. | 79 # line. |
| 74 GPRs = [ | 80 GPRs = [ |
| 75 Reg( 'r0', 0, IsScratch=1, CCArg=1, IsGPR = 1, IsInt=1, Alias
es= 'r0, r0r1'), | 81 Reg( 'r0', 0, IsScratch=1, CCArg=1, IsGPR = 1, IsInt=1, Alias
es= 'r0, r0r1'), |
| 76 Reg( 'r1', 1, IsScratch=1, CCArg=2, IsGPR = 1, IsInt=1, Alias
es= 'r1, r0r1'), | 82 Reg( 'r1', 1, IsScratch=1, CCArg=2, IsGPR = 1, IsInt=1, Alias
es= 'r1, r0r1'), |
| 77 Reg( 'r2', 2, IsScratch=1, CCArg=3, IsGPR = 1, IsInt=1, Alias
es= 'r2, r2r3'), | 83 Reg( 'r2', 2, IsScratch=1, CCArg=3, IsGPR = 1, IsInt=1, Alias
es= 'r2, r2r3'), |
| 78 Reg( 'r3', 3, IsScratch=1, CCArg=4, IsGPR = 1, IsInt=1, Alias
es= 'r3, r2r3'), | 84 Reg( 'r3', 3, IsScratch=1, CCArg=4, IsGPR = 1, IsInt=1, Alias
es= 'r3, r2r3'), |
| 79 Reg( 'r4', 4, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r4, r4r5'), | 85 Reg( 'r4', 4, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r4, r4r5'), |
| 80 Reg( 'r5', 5, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r5, r4r5'), | 86 Reg( 'r5', 5, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r5, r4r5'), |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 assert (AllRegs[Alias].Features.LivesInGPR() == | 213 assert (AllRegs[Alias].Features.LivesInGPR() == |
| 208 Reg.Features.LivesInGPR()), '%s VS %s' % (Reg, AllRegs[Alias]) | 214 Reg.Features.LivesInGPR()), '%s VS %s' % (Reg, AllRegs[Alias]) |
| 209 assert (AllRegs[Alias].Features.LivesInVFP() == | 215 assert (AllRegs[Alias].Features.LivesInVFP() == |
| 210 Reg.Features.LivesInVFP()), '%s VS %s' % (Reg, AllRegs[Alias]) | 216 Reg.Features.LivesInVFP()), '%s VS %s' % (Reg, AllRegs[Alias]) |
| 211 | 217 |
| 212 print ("// This file was auto generated by the {script} script.\n" | 218 print ("// This file was auto generated by the {script} script.\n" |
| 213 "// Do not modify it: modify the script instead.\n" | 219 "// Do not modify it: modify the script instead.\n" |
| 214 "\n" | 220 "\n" |
| 215 "#ifndef SUBZERO_SRC_ICEREGISTERSARM32_DEF\n" | 221 "#ifndef SUBZERO_SRC_ICEREGISTERSARM32_DEF\n" |
| 216 "#define SUBZERO_SRC_ICEREGISTERSARM32_DEF\n".format(script=os.path.basen
ame(sys.argv[0]))) | 222 "#define SUBZERO_SRC_ICEREGISTERSARM32_DEF\n".format(script=os.path.basen
ame(sys.argv[0]))) |
| 217 | 223 |
| 218 for Name, RegClass in RegClasses: | 224 for Name, RegClass in RegClasses: |
| 225 print '\n//{xmacro}'.format(xmacro=Reg.DefiningXMacro()) |
| 219 print "#define REGARM32_%s_TABLE" % Name, | 226 print "#define REGARM32_%s_TABLE" % Name, |
| 220 for Reg in RegClass: | 227 for Reg in RegClass: |
| 221 print '\\\n X({Reg})'.format(Reg=Reg), | 228 print '\\\n X({Reg})'.format(Reg=Reg), |
| 222 print '\n' | 229 print '\n' |
| 223 print "#endif // SUBZERO_SRC_ICEREGISTERSARM32_DEF", | 230 print "#endif // SUBZERO_SRC_ICEREGISTERSARM32_DEF", |
| OLD | NEW |