| 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)) |
| 11 | 11 |
| 12 def _ArgumentNames(Method): | 12 def _ArgumentNames(Method): |
| 13 import inspect | 13 import inspect |
| 14 return (ArgName for ArgName in inspect.getargspec(Method).args | 14 return (ArgName for ArgName in inspect.getargspec(Method).args |
| 15 if ArgName != 'self') | 15 if ArgName != 'self') |
| 16 | 16 |
| 17 class RegFeatures(object): | 17 class RegFeatures(object): |
| 18 def __init__(self, AsmStr=None, CCArg=0, IsScratch=0, IsPreserved=0, | 18 def __init__(self, AsmStr=None, CCArg=0, IsScratch=0, IsPreserved=0, |
| 19 IsStackPtr=0, IsFramePtr=0, IsInt=0, IsI64Pair=0, IsFP32=0, | 19 IsStackPtr=0, IsFramePtr=0, IsGPR=0, IsInt=0, IsI64Pair=0, |
| 20 IsFP64=0, IsVec128=0, Aliases=None): | 20 IsFP32=0, IsFP64=0, IsVec128=0, Aliases=None): |
| 21 assert (not IsInt) or IsGPR |
| 22 assert (not IsI64Pair) or (not IsGPR) |
| 21 assert not (IsInt and IsI64Pair) | 23 assert not (IsInt and IsI64Pair) |
| 22 assert not (IsFP32 and IsFP64) | 24 assert not (IsFP32 and IsFP64) |
| 23 assert not (IsFP32 and IsVec128) | 25 assert not (IsFP32 and IsVec128) |
| 24 assert not (IsFP64 and IsVec128) | 26 assert not (IsFP64 and IsVec128) |
| 25 assert not ((IsInt or IsI64Pair) and (IsFP32 or IsFP64 or IsVec128)) | 27 assert not ((IsGPR) and (IsFP32 or IsFP64 or IsVec128)) |
| 26 assert (not IsFramePtr) or IsInt | 28 assert (not IsFramePtr) or IsGPR |
| 27 assert (not IsStackPtr) or not( | 29 assert (not IsStackPtr) or IsGPR |
| 28 IsInt or IsI64Pair or IsFP32 or IsFP64 or IsVec128) | |
| 29 assert not (IsScratch and IsPreserved) | 30 assert not (IsScratch and IsPreserved) |
| 30 self.Features = [x for x in _ArgumentNames(self.__init__)] | 31 self.Features = [x for x in _ArgumentNames(self.__init__)] |
| 31 self.FeaturesDict = {} | 32 self.FeaturesDict = {} |
| 32 # The argument Aliases is a string with the register aliasing information. | 33 # The argument Aliases is a string with the register aliasing information. |
| 33 # The next line convert it to a RegAlias object, for pretty printing. | 34 # The next line convert it to a RegAlias object, for pretty printing. |
| 34 Aliases = RegAliases(Aliases) | 35 Aliases = RegAliases(Aliases) |
| 35 AsmStr = '"%s"' % AsmStr | 36 AsmStr = '"%s"' % AsmStr |
| 36 for Feature in self.Features: | 37 for Feature in self.Features: |
| 37 self.FeaturesDict[Feature] = locals()[Feature] | 38 self.FeaturesDict[Feature] = locals()[Feature] |
| 38 | 39 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 64 return 'Reg_{Name}, {Encode}, {Features}'.format(Name=self.Name, | 65 return 'Reg_{Name}, {Encode}, {Features}'.format(Name=self.Name, |
| 65 Encode=self.Encode, Features=self.Features) | 66 Encode=self.Encode, Features=self.Features) |
| 66 | 67 |
| 67 def IsAnAliasOf(self, Other): | 68 def IsAnAliasOf(self, Other): |
| 68 return Other.Name in self.Features.Aliases().Aliases | 69 return Other.Name in self.Features.Aliases().Aliases |
| 69 | 70 |
| 70 # Note: The following tables break the usual 80-col on purpose -- it is easier | 71 # Note: The following tables break the usual 80-col on purpose -- it is easier |
| 71 # to read the register tables if each register entry is contained on a single | 72 # to read the register tables if each register entry is contained on a single |
| 72 # line. | 73 # line. |
| 73 GPRs = [ | 74 GPRs = [ |
| 74 Reg( 'r0', 0, IsScratch=1, CCArg=1, IsInt=1, Aliases= 'r0, r
0r1'), | 75 Reg( 'r0', 0, IsScratch=1, CCArg=1, IsGPR = 1, IsInt=1, Alias
es= 'r0, r0r1'), |
| 75 Reg( 'r1', 1, IsScratch=1, CCArg=2, IsInt=1, Aliases= 'r1, r
0r1'), | 76 Reg( 'r1', 1, IsScratch=1, CCArg=2, IsGPR = 1, IsInt=1, Alias
es= 'r1, r0r1'), |
| 76 Reg( 'r2', 2, IsScratch=1, CCArg=3, IsInt=1, Aliases= 'r2, r
2r3'), | 77 Reg( 'r2', 2, IsScratch=1, CCArg=3, IsGPR = 1, IsInt=1, Alias
es= 'r2, r2r3'), |
| 77 Reg( 'r3', 3, IsScratch=1, CCArg=4, IsInt=1, Aliases= 'r3, r
2r3'), | 78 Reg( 'r3', 3, IsScratch=1, CCArg=4, IsGPR = 1, IsInt=1, Alias
es= 'r3, r2r3'), |
| 78 Reg( 'r4', 4, IsPreserved=1, IsInt=1, Aliases= 'r4, r
4r5'), | 79 Reg( 'r4', 4, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r4, r4r5'), |
| 79 Reg( 'r5', 5, IsPreserved=1, IsInt=1, Aliases= 'r5, r
4r5'), | 80 Reg( 'r5', 5, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r5, r4r5'), |
| 80 Reg( 'r6', 6, IsPreserved=1, IsInt=1, Aliases= 'r6, r
6r7'), | 81 Reg( 'r6', 6, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r6, r6r7'), |
| 81 Reg( 'r7', 7, IsPreserved=1, IsInt=1, Aliases= 'r7, r
6r7'), | 82 Reg( 'r7', 7, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r7, r6r7'), |
| 82 Reg( 'r8', 8, IsPreserved=1, IsInt=1, Aliases= 'r8, r
8r9'), | 83 Reg( 'r8', 8, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es= 'r8, r8r9'), |
| 83 Reg( 'r9', 9, IsPreserved=1, IsInt=0, Aliases= 'r9, r
8r9'), | 84 Reg( 'r9', 9, IsPreserved=1, IsGPR = 1, IsInt=0, Alias
es= 'r9, r8r9'), |
| 84 Reg('r10', 10, IsPreserved=1, IsInt=1, Aliases='r10, r1
0fp'), | 85 Reg('r10', 10, IsPreserved=1, IsGPR = 1, IsInt=1, Alias
es='r10, r10fp'), |
| 85 Reg( 'fp', 11, IsPreserved=1, IsInt=1, IsFramePtr=1, Aliases= 'fp, r1
0fp'), | 86 Reg( 'fp', 11, IsPreserved=1, IsGPR = 1, IsInt=1, IsFramePtr=1, Alias
es= 'fp, r10fp'), |
| 86 Reg( 'ip', 12, IsScratch=1, IsInt=0, Aliases= 'ip'), | 87 Reg( 'ip', 12, IsScratch=1, IsGPR = 1, IsInt=0, Alias
es= 'ip'), |
| 87 Reg( 'sp', 13, IsScratch=0, IsInt=0, IsStackPtr=1, Aliases= 'sp'), | 88 Reg( 'sp', 13, IsScratch=0, IsGPR = 1, IsInt=0, IsStackPtr=1, Alias
es= 'sp'), |
| 88 Reg( 'lr', 14, IsScratch=0, IsInt=0, Aliases= 'lr'), | 89 Reg( 'lr', 14, IsScratch=0, IsGPR = 1, IsInt=0, Alias
es= 'lr'), |
| 89 Reg( 'pc', 15, IsScratch=0, IsInt=0, Aliases= 'pc'), | 90 Reg( 'pc', 15, IsScratch=0, IsGPR = 1, IsInt=0, Alias
es= 'pc'), |
| 90 ] | 91 ] |
| 91 | 92 |
| 92 I64Pairs = [ | 93 I64Pairs = [ |
| 93 Reg( 'r0r1', 0, AsmStr= 'r0, r1', IsScratch=1, CCArg=1, IsI64Pair=1, Aliase
s= 'r0r1, r0, r1'), | 94 Reg( 'r0r1', 0, AsmStr= 'r0, r1', IsScratch=1, CCArg=1, IsI64Pair=1, Aliase
s= 'r0r1, r0, r1'), |
| 94 Reg( 'r2r3', 2, AsmStr= 'r2, r3', IsScratch=1, CCArg=2, IsI64Pair=1, Aliase
s= 'r2r3, r2, r3'), | 95 Reg( 'r2r3', 2, AsmStr= 'r2, r3', IsScratch=1, CCArg=2, IsI64Pair=1, Aliase
s= 'r2r3, r2, r3'), |
| 95 Reg( 'r4r5', 4, AsmStr= 'r4, r5', IsPreserved=1, IsI64Pair=1, Aliase
s= 'r4r5, r4, r5'), | 96 Reg( 'r4r5', 4, AsmStr= 'r4, r5', IsPreserved=1, IsI64Pair=1, Aliase
s= 'r4r5, r4, r5'), |
| 96 Reg( 'r6r7', 6, AsmStr= 'r6, r7', IsPreserved=1, IsI64Pair=1, Aliase
s= 'r6r7, r6, r7'), | 97 Reg( 'r6r7', 6, AsmStr= 'r6, r7', IsPreserved=1, IsI64Pair=1, Aliase
s= 'r6r7, r6, r7'), |
| 97 Reg( 'r8r9', 8, AsmStr= 'r8, r9', IsPreserved=1, IsI64Pair=0, Aliase
s= 'r8r9, r8, r9'), | 98 Reg( 'r8r9', 8, AsmStr= 'r8, r9', IsPreserved=1, IsI64Pair=0, Aliase
s= 'r8r9, r8, r9'), |
| 98 Reg('r10fp', 10, AsmStr='r10, fp', IsPreserved=1, IsI64Pair=0, Aliase
s='r10fp, r10, fp'), | 99 Reg('r10fp', 10, AsmStr='r10, fp', IsPreserved=1, IsI64Pair=0, Aliase
s='r10fp, r10, fp'), |
| 99 ] | 100 ] |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 "\n" | 214 "\n" |
| 214 "#ifndef SUBZERO_SRC_ICEREGISTERSARM32_DEF\n" | 215 "#ifndef SUBZERO_SRC_ICEREGISTERSARM32_DEF\n" |
| 215 "#define SUBZERO_SRC_ICEREGISTERSARM32_DEF\n".format(script=os.path.basen
ame(sys.argv[0]))) | 216 "#define SUBZERO_SRC_ICEREGISTERSARM32_DEF\n".format(script=os.path.basen
ame(sys.argv[0]))) |
| 216 | 217 |
| 217 for Name, RegClass in RegClasses: | 218 for Name, RegClass in RegClasses: |
| 218 print "#define REGARM32_%s_TABLE" % Name, | 219 print "#define REGARM32_%s_TABLE" % Name, |
| 219 for Reg in RegClass: | 220 for Reg in RegClass: |
| 220 print '\\\n X({Reg})'.format(Reg=Reg), | 221 print '\\\n X({Reg})'.format(Reg=Reg), |
| 221 print '\n' | 222 print '\n' |
| 222 print "#endif // SUBZERO_SRC_ICEREGISTERSARM32_DEF", | 223 print "#endif // SUBZERO_SRC_ICEREGISTERSARM32_DEF", |
| OLD | NEW |