<div dir="ltr"><div class="gmail_default" style="font-size:small">Hi David,</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"> why not do the full job and add int32_t, int8_t, uint8_t et al?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 27, 2021 at 4:06 PM <<a href="mailto:commits@source.squeak.org">commits@source.squeak.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"> <br>
David T. Lewis uploaded a new version of VMMaker to project VM Maker:<br>
<a href="http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3004.mcz" rel="noreferrer" target="_blank">http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3004.mcz</a><br>
<br>
==================== Summary ====================<br>
<br>
Name: VMMaker.oscog-dtl.3004<br>
Author: dtl<br>
Time: 27 July 2021, 7:04:41.67977 pm<br>
UUID: f6b6bb24-2fdf-4a09-bf4b-970eb4221ccd<br>
Ancestors: VMMaker.oscog-eem.3003<br>
<br>
Update sizeOfIntegralCType: and related methods and tests to recognize #unsigned and #uint_32 declarations as 32 bit integer. Supports VectorEnginePlugin code generation.<br>
<br>
=============== Diff against VMMaker.oscog-eem.3003 ===============<br>
<br>
Item was changed:<br>
----- Method: CCodeGenerator>>isIntegralCType: (in category 'inlining') -----<br>
isIntegralCType: aCType "<String>"<br>
+ ^(#('sqLong' 'usqLong' 'sqInt' 'usqInt' 'uint32_t' 'sqIntptr_t' 'usqIntptr_t'<br>
- ^(#('sqLong' 'usqLong' 'sqInt' 'usqInt' 'sqIntptr_t' 'usqIntptr_t'<br>
'long' 'long long' 'int' 'short' 'short int' 'char' 'signed char'<br>
'size_t' 'pid_t') includes: aCType asString)<br>
or: [(aCType beginsWith: 'unsigned') "Accept e.g. 'unsigned long' and also 'unsigned : 8'"<br>
and: [(aCType includesAnyOf: '[*]') not]]!<br>
<br>
Item was changed:<br>
----- Method: CCodeGenerator>>sizeOfIntegralCType: (in category 'inlining') -----<br>
sizeOfIntegralCType: anIntegralCType "<String>"<br>
"N.B. Only works for values for which isIntegralCType: answers true."<br>
| prunedCType index |<br>
prunedCType := (anIntegralCType beginsWith: 'unsigned ')<br>
ifTrue: [(anIntegralCType allButFirst: 9) withBlanksTrimmed]<br>
ifFalse: [(anIntegralCType beginsWith: 'signed ')<br>
ifTrue: [(anIntegralCType allButFirst: 7) withBlanksTrimmed]<br>
ifFalse: [anIntegralCType]].<br>
<br>
^prunedCType asString caseOf: {<br>
['sqLong'] -> [8].<br>
['usqLong'] -> [8].<br>
['long long'] -> [8].<br>
['sqInt'] -> [BytesPerOop].<br>
['usqInt'] -> [BytesPerOop].<br>
['sqIntptr_t'] -> [BytesPerWord].<br>
['usqIntptr_t'] -> [BytesPerWord].<br>
['int'] -> [4].<br>
+ ['unsigned'] -> [4].<br>
+ ['uint32_t'] -> [4].<br>
['short'] -> [2].<br>
['short int'] -> [2].<br>
['char'] -> [1].<br>
['long'] -> [BytesPerWord]. "It's ambiguous on LLP64 and we'll later remove it"<br>
['size_t'] -> [BytesPerWord].<br>
['pid_t'] -> [BytesPerWord].<br>
}<br>
otherwise:<br>
[(anIntegralCType beginsWith: 'register ') ifTrue:<br>
[^self sizeOfIntegralCType: (anIntegralCType allButFirst: 9)].<br>
(anIntegralCType beginsWith: 'static ') ifTrue:<br>
[^self sizeOfIntegralCType: (anIntegralCType allButFirst: 7)].<br>
((anIntegralCType beginsWith: 'unsigned') "e.g. 'unsigned : 8'"<br>
and: [(anIntegralCType includesAnyOf: '[*]') not<br>
and: [(index := anIntegralCType indexOf: $:) > 0]]) ifTrue:<br>
[^(Integer readFrom: (anIntegralCType copyFrom: index + 1 to: anIntegralCType size) withBlanksTrimmed readStream) + 7 // 8].<br>
anIntegralCType first = $# ifTrue:<br>
[(anIntegralCType subStrings: '\') do:<br>
[:substring|<br>
substring first ~~ $# ifTrue:<br>
[([self sizeOfIntegralCType: substring withBlanksTrimmed]<br>
on: Error<br>
do: [:ex| nil]) ifNotNil: [:size| ^size]]]].<br>
self error: 'unrecognized integral type']!<br>
<br>
Item was added:<br>
+ ----- Method: SlangTypePromotionTest>>testUint32tAndInt (in category 'unsigned-priority') -----<br>
+ testUint32tAndInt<br>
+ "representative of two types bigger than sizeOf(int) and with same size"<br>
+ | firstType secondType resType |<br>
+ firstType := #'uint32_t'.<br>
+ secondType := #'int'.<br>
+ resType := ccg promoteArithmeticTypes: firstType and: secondType.<br>
+ <br>
+ self assert: resType equals: #'uint32_t'.<br>
+ <br>
+ "check that the system is in the assumed state."<br>
+ self assert: (ccg isIntegralCType: #'uint32_t').<br>
+ self assert: (ccg sizeOfIntegralCType: #'uint32_t') equals: 4.<br>
+ self assert: (ccg isIntegralCType: #int).<br>
+ self assert: (ccg sizeOfIntegralCType: #int) equals: 4.!<br>
<br>
Item was added:<br>
+ ----- Method: SlangTypePromotionTest>>testUnsignedAndInt (in category 'unsigned-priority') -----<br>
+ testUnsignedAndInt<br>
+ "representative of two types bigger than sizeOf(int) and with same size"<br>
+ | firstType secondType resType |<br>
+ firstType := #'unsigned'.<br>
+ secondType := #'int'.<br>
+ resType := ccg promoteArithmeticTypes: firstType and: secondType.<br>
+ <br>
+ self assert: resType equals: #'unsigned'.<br>
+ <br>
+ "check that the system is in the assumed state."<br>
+ self assert: (ccg isIntegralCType: #'unsigned').<br>
+ self assert: (ccg sizeOfIntegralCType: #'unsigned') equals: 4.<br>
+ self assert: (ccg isIntegralCType: #int).<br>
+ self assert: (ccg sizeOfIntegralCType: #int) equals: 4.!<br>
<br>
Item was changed:<br>
----- Method: VMPluginCodeGenerator>>sizeOfIntegralCType: (in category 'inlining') -----<br>
sizeOfIntegralCType: anIntegralCType "<String>"<br>
"Hack; because the plugin sources are compiled either as 32 or 64 bit<br>
size those types which are either 32 or 64 bits in size as 48 bits.<br>
This happens to produce sane results for integer promotion."<br>
"N.B. Only works for values for which isIntegralCType: answers true."<br>
| prunedCType index |<br>
(anIntegralCType beginsWith: 'register ') ifTrue:<br>
[^self sizeOfIntegralCType: (anIntegralCType allButFirst: 9)].<br>
prunedCType := (anIntegralCType beginsWith: 'unsigned ')<br>
ifTrue: [(anIntegralCType allButFirst: 9) withBlanksTrimmed]<br>
ifFalse: [(anIntegralCType beginsWith: 'signed ')<br>
ifTrue: [(anIntegralCType allButFirst: 7) withBlanksTrimmed]<br>
ifFalse: [anIntegralCType]].<br>
<br>
^prunedCType asString caseOf: {<br>
['sqLong'] -> [8].<br>
['usqLong'] -> [8].<br>
['long long'] -> [8].<br>
['sqInt'] -> [6].<br>
['usqInt'] -> [6].<br>
['sqIntptr_t'] -> [6].<br>
['usqIntptr_t'] -> [6].<br>
['int'] -> [4].<br>
+ ['uint32_t'] -> [4].<br>
+ ['unsigned'] -> [4].<br>
['short'] -> [2].<br>
['short int'] -> [2].<br>
['char'] -> [1].<br>
['long'] -> [BytesPerWord]. "It's ambiguous on LLP64 and we'll later remove it"<br>
['size_t'] -> [6].<br>
['pid_t'] -> [6].<br>
}<br>
otherwise:<br>
[((anIntegralCType beginsWith: 'unsigned') "e.g. 'unsigned : 8'"<br>
and: [(anIntegralCType includesAnyOf: '[*]') not<br>
and: [(index := anIntegralCType indexOf: $:) > 0]])<br>
ifTrue: [(Integer readFrom: (anIntegralCType copyFrom: index + 1 to: anIntegralCType size) withBlanksTrimmed readStream) + 7 // 8]<br>
ifFalse: [self error: 'unrecognized integral type']]!<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>