<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-size:small"><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 27, 2021 at 4:59 PM David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</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>
Hi Eliot,<br>
<br>
That would be better, although I was in a "minimally invasive surgury"<br>
frame of mind :-)<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">OK, but don't be afraid to :-)</div><div class="gmail_default" style="font-size:small"></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">My goal was/is to enable VectorEnginePlugin to be included in our<br>
standard VMs. For that, I think it is important that the C code<br>
generation should work with VMMaker.oscog. The Cuis-generated C<br>
source already works well, but we also should be able to generate<br>
and compile it from VMMaker.oscog for ongoing maintenance.<br>
<br>
I sent a patch to Juan on the Cuis list to address a code inlining issue:<br>
<a href="https://lists.cuis.st/mailman/archives/cuis-dev/2021-July/003473.html" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/archives/cuis-dev/2021-July/003473.html</a><br>
<br>
That patch on the Cuis side, along with the sizeOfIntegralCType: patch<br>
here, result in a VectorEnginePlugin that can be generated from<br>
VMMaker.oscog and compiled in the normal opensmalltalk-vm builds.<br></blockquote><div><br></div><div class="gmail_default" style="font-size:small">Cool.  LMK when there's a repo I can load it from.</div><div class="gmail_default" style="font-size:small"></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>
Dave<br>
<br>
On Tue, Jul 27, 2021 at 04:22:08PM -0700, Eliot Miranda wrote:<br>
>  <br>
> Hi David,<br>
> <br>
>     why not do the full job and add int32_t, int8_t, uint8_t et al?<br>
> <br>
> On Tue, Jul 27, 2021 at 4:06 PM <<a href="mailto:commits@source.squeak.org" target="_blank">commits@source.squeak.org</a>> wrote:<br>
> <br>
> ><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<br>
> > #unsigned and #uint_32 declarations as 32 bit integer. Supports<br>
> > VectorEnginePlugin code generation.<br>
> ><br>
> > =============== Diff against VMMaker.oscog-eem.3003 ===============<br>
> ><br>
> > Item was changed:<br>
> >   ----- Method: CCodeGenerator>>isIntegralCType: (in category 'inlining')<br>
> > -----<br>
> >   isIntegralCType: aCType "<String>"<br>
> > +       ^(#('sqLong' 'usqLong' 'sqInt' 'usqInt' 'uint32_t' 'sqIntptr_t'<br>
> > 'usqIntptr_t'<br>
> > -       ^(#('sqLong' 'usqLong' 'sqInt' 'usqInt' 'sqIntptr_t' 'usqIntptr_t'<br>
> >                 'long' 'long long' 'int' 'short' 'short int' 'char'<br>
> > 'signed char'<br>
> >                 'size_t' 'pid_t') includes: aCType asString)<br>
> >         or: [(aCType beginsWith: 'unsigned') "Accept e.g. 'unsigned long'<br>
> > and also 'unsigned  : 8'"<br>
> >                 and: [(aCType includesAnyOf: '[*]') not]]!<br>
> ><br>
> > Item was changed:<br>
> >   ----- Method: CCodeGenerator>>sizeOfIntegralCType: (in category<br>
> > 'inlining') -----<br>
> >   sizeOfIntegralCType: anIntegralCType "<String>"<br>
> >         "N.B. Only works for values for which isIntegralCType: answers<br>
> > true."<br>
> >         | prunedCType index |<br>
> >         prunedCType := (anIntegralCType beginsWith: 'unsigned ')<br>
> >                                                 ifTrue: [(anIntegralCType<br>
> > allButFirst: 9) withBlanksTrimmed]<br>
> >                                                 ifFalse: [(anIntegralCType<br>
> > beginsWith: 'signed ')<br>
> ><br>
> > ifTrue: [(anIntegralCType allButFirst: 7) withBlanksTrimmed]<br>
> ><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<br>
> > 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<br>
> > allButFirst: 9)].<br>
> >                  (anIntegralCType beginsWith: 'static ') ifTrue:<br>
> >                         [^self sizeOfIntegralCType: (anIntegralCType<br>
> > allButFirst: 7)].<br>
> >                  ((anIntegralCType beginsWith: 'unsigned') "e.g.<br>
> > 'unsigned  : 8'"<br>
> >                   and: [(anIntegralCType includesAnyOf: '[*]') not<br>
> >                   and: [(index := anIntegralCType indexOf: $:) > 0]])<br>
> > ifTrue:<br>
> >                         [^(Integer readFrom: (anIntegralCType copyFrom:<br>
> > 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:<br>
> > substring withBlanksTrimmed]<br>
> >                                                 on: Error<br>
> >                                                 do: [:ex| nil]) ifNotNil:<br>
> > [:size| ^size]]]].<br>
> >                 self error: 'unrecognized integral type']!<br>
> ><br>
> > Item was added:<br>
> > + ----- Method: SlangTypePromotionTest>>testUint32tAndInt (in category<br>
> > 'unsigned-priority') -----<br>
> > + testUint32tAndInt<br>
> > +       "representative of two types bigger than sizeOf(int) and with same<br>
> > 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<br>
> > 'unsigned-priority') -----<br>
> > + testUnsignedAndInt<br>
> > +       "representative of two types bigger than sizeOf(int) and with same<br>
> > 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<br>
> > 'inlining') -----<br>
> >   sizeOfIntegralCType: anIntegralCType "<String>"<br>
> >         "Hack; because the plugin sources are compiled either as 32 or 64<br>
> > bit<br>
> >          size those types which are either 32 or 64 bits in size as 48<br>
> > bits.<br>
> >          This happens to produce sane results for integer promotion."<br>
> >         "N.B. Only works for values for which isIntegralCType: answers<br>
> > true."<br>
> >         | prunedCType index |<br>
> >         (anIntegralCType beginsWith: 'register ') ifTrue:<br>
> >                 [^self sizeOfIntegralCType: (anIntegralCType allButFirst:<br>
> > 9)].<br>
> >         prunedCType := (anIntegralCType beginsWith: 'unsigned ')<br>
> >                                                 ifTrue: [(anIntegralCType<br>
> > allButFirst: 9) withBlanksTrimmed]<br>
> >                                                 ifFalse: [(anIntegralCType<br>
> > beginsWith: 'signed ')<br>
> ><br>
> > ifTrue: [(anIntegralCType allButFirst: 7) withBlanksTrimmed]<br>
> ><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].<br>
> > "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.<br>
> > 'unsigned  : 8'"<br>
> >                   and: [(anIntegralCType includesAnyOf: '[*]') not<br>
> >                   and: [(index := anIntegralCType indexOf: $:) > 0]])<br>
> >                         ifTrue: [(Integer readFrom: (anIntegralCType<br>
> > copyFrom: index + 1 to: anIntegralCType size) withBlanksTrimmed readStream)<br>
> > + 7 // 8]<br>
> >                         ifFalse: [self error: 'unrecognized integral<br>
> > type']]!<br>
> ><br>
> ><br>
> <br>
> -- <br>
> _,,,^..^,,,_<br>
> best, Eliot<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></div>