[Vm-dev] VM Maker: VMMaker.oscog-dtl.3004.mcz
Eliot Miranda
eliot.miranda at gmail.com
Wed Jul 28 04:14:15 UTC 2021
On Tue, Jul 27, 2021 at 4:59 PM David T. Lewis <lewis at mail.msen.com> wrote:
>
> Hi Eliot,
>
> That would be better, although I was in a "minimally invasive surgury"
> frame of mind :-)
>
OK, but don't be afraid to :-)
> My goal was/is to enable VectorEnginePlugin to be included in our
> standard VMs. For that, I think it is important that the C code
> generation should work with VMMaker.oscog. The Cuis-generated C
> source already works well, but we also should be able to generate
> and compile it from VMMaker.oscog for ongoing maintenance.
>
> I sent a patch to Juan on the Cuis list to address a code inlining issue:
> https://lists.cuis.st/mailman/archives/cuis-dev/2021-July/003473.html
>
> That patch on the Cuis side, along with the sizeOfIntegralCType: patch
> here, result in a VectorEnginePlugin that can be generated from
> VMMaker.oscog and compiled in the normal opensmalltalk-vm builds.
>
Cool. LMK when there's a repo I can load it from.
>
> Dave
>
> On Tue, Jul 27, 2021 at 04:22:08PM -0700, Eliot Miranda wrote:
> >
> > Hi David,
> >
> > why not do the full job and add int32_t, int8_t, uint8_t et al?
> >
> > On Tue, Jul 27, 2021 at 4:06 PM <commits at source.squeak.org> wrote:
> >
> > >
> > > David T. Lewis uploaded a new version of VMMaker to project VM Maker:
> > > http://source.squeak.org/VMMaker/VMMaker.oscog-dtl.3004.mcz
> > >
> > > ==================== Summary ====================
> > >
> > > Name: VMMaker.oscog-dtl.3004
> > > Author: dtl
> > > Time: 27 July 2021, 7:04:41.67977 pm
> > > UUID: f6b6bb24-2fdf-4a09-bf4b-970eb4221ccd
> > > Ancestors: VMMaker.oscog-eem.3003
> > >
> > > Update sizeOfIntegralCType: and related methods and tests to recognize
> > > #unsigned and #uint_32 declarations as 32 bit integer. Supports
> > > VectorEnginePlugin code generation.
> > >
> > > =============== Diff against VMMaker.oscog-eem.3003 ===============
> > >
> > > Item was changed:
> > > ----- Method: CCodeGenerator>>isIntegralCType: (in category
> 'inlining')
> > > -----
> > > isIntegralCType: aCType "<String>"
> > > + ^(#('sqLong' 'usqLong' 'sqInt' 'usqInt' 'uint32_t' 'sqIntptr_t'
> > > 'usqIntptr_t'
> > > - ^(#('sqLong' 'usqLong' 'sqInt' 'usqInt' 'sqIntptr_t'
> 'usqIntptr_t'
> > > 'long' 'long long' 'int' 'short' 'short int' 'char'
> > > 'signed char'
> > > 'size_t' 'pid_t') includes: aCType asString)
> > > or: [(aCType beginsWith: 'unsigned') "Accept e.g. 'unsigned
> long'
> > > and also 'unsigned : 8'"
> > > and: [(aCType includesAnyOf: '[*]') not]]!
> > >
> > > Item was changed:
> > > ----- Method: CCodeGenerator>>sizeOfIntegralCType: (in category
> > > 'inlining') -----
> > > sizeOfIntegralCType: anIntegralCType "<String>"
> > > "N.B. Only works for values for which isIntegralCType: answers
> > > true."
> > > | prunedCType index |
> > > prunedCType := (anIntegralCType beginsWith: 'unsigned ')
> > > ifTrue:
> [(anIntegralCType
> > > allButFirst: 9) withBlanksTrimmed]
> > > ifFalse:
> [(anIntegralCType
> > > beginsWith: 'signed ')
> > >
> > > ifTrue: [(anIntegralCType allButFirst: 7) withBlanksTrimmed]
> > >
> > > ifFalse: [anIntegralCType]].
> > >
> > > ^prunedCType asString caseOf: {
> > > ['sqLong'] -> [8].
> > > ['usqLong'] -> [8].
> > > ['long long'] -> [8].
> > > ['sqInt'] -> [BytesPerOop].
> > > ['usqInt'] -> [BytesPerOop].
> > > ['sqIntptr_t'] -> [BytesPerWord].
> > > ['usqIntptr_t'] -> [BytesPerWord].
> > > ['int'] -> [4].
> > > + ['unsigned'] -> [4].
> > > + ['uint32_t'] -> [4].
> > > ['short'] -> [2].
> > > ['short int'] -> [2].
> > > ['char'] -> [1].
> > > ['long'] -> [BytesPerWord]. "It's
> > > ambiguous on LLP64 and we'll later remove it"
> > > ['size_t'] -> [BytesPerWord].
> > > ['pid_t'] -> [BytesPerWord].
> > > }
> > > otherwise:
> > > [(anIntegralCType beginsWith: 'register ') ifTrue:
> > > [^self sizeOfIntegralCType: (anIntegralCType
> > > allButFirst: 9)].
> > > (anIntegralCType beginsWith: 'static ') ifTrue:
> > > [^self sizeOfIntegralCType: (anIntegralCType
> > > allButFirst: 7)].
> > > ((anIntegralCType beginsWith: 'unsigned') "e.g.
> > > 'unsigned : 8'"
> > > and: [(anIntegralCType includesAnyOf: '[*]') not
> > > and: [(index := anIntegralCType indexOf: $:) > 0]])
> > > ifTrue:
> > > [^(Integer readFrom: (anIntegralCType copyFrom:
> > > index + 1 to: anIntegralCType size) withBlanksTrimmed readStream) + 7
> // 8].
> > > anIntegralCType first = $# ifTrue:
> > > [(anIntegralCType subStrings: '\') do:
> > > [:substring|
> > > substring first ~~ $# ifTrue:
> > > [([self sizeOfIntegralCType:
> > > substring withBlanksTrimmed]
> > > on: Error
> > > do: [:ex| nil])
> ifNotNil:
> > > [:size| ^size]]]].
> > > self error: 'unrecognized integral type']!
> > >
> > > Item was added:
> > > + ----- Method: SlangTypePromotionTest>>testUint32tAndInt (in category
> > > 'unsigned-priority') -----
> > > + testUint32tAndInt
> > > + "representative of two types bigger than sizeOf(int) and with
> same
> > > size"
> > > + | firstType secondType resType |
> > > + firstType := #'uint32_t'.
> > > + secondType := #'int'.
> > > + resType := ccg promoteArithmeticTypes: firstType and:
> secondType.
> > > +
> > > + self assert: resType equals: #'uint32_t'.
> > > +
> > > + "check that the system is in the assumed state."
> > > + self assert: (ccg isIntegralCType: #'uint32_t').
> > > + self assert: (ccg sizeOfIntegralCType: #'uint32_t') equals: 4.
> > > + self assert: (ccg isIntegralCType: #int).
> > > + self assert: (ccg sizeOfIntegralCType: #int) equals: 4.!
> > >
> > > Item was added:
> > > + ----- Method: SlangTypePromotionTest>>testUnsignedAndInt (in category
> > > 'unsigned-priority') -----
> > > + testUnsignedAndInt
> > > + "representative of two types bigger than sizeOf(int) and with
> same
> > > size"
> > > + | firstType secondType resType |
> > > + firstType := #'unsigned'.
> > > + secondType := #'int'.
> > > + resType := ccg promoteArithmeticTypes: firstType and:
> secondType.
> > > +
> > > + self assert: resType equals: #'unsigned'.
> > > +
> > > + "check that the system is in the assumed state."
> > > + self assert: (ccg isIntegralCType: #'unsigned').
> > > + self assert: (ccg sizeOfIntegralCType: #'unsigned') equals: 4.
> > > + self assert: (ccg isIntegralCType: #int).
> > > + self assert: (ccg sizeOfIntegralCType: #int) equals: 4.!
> > >
> > > Item was changed:
> > > ----- Method: VMPluginCodeGenerator>>sizeOfIntegralCType: (in
> category
> > > 'inlining') -----
> > > sizeOfIntegralCType: anIntegralCType "<String>"
> > > "Hack; because the plugin sources are compiled either as 32 or
> 64
> > > bit
> > > size those types which are either 32 or 64 bits in size as 48
> > > bits.
> > > This happens to produce sane results for integer promotion."
> > > "N.B. Only works for values for which isIntegralCType: answers
> > > true."
> > > | prunedCType index |
> > > (anIntegralCType beginsWith: 'register ') ifTrue:
> > > [^self sizeOfIntegralCType: (anIntegralCType
> allButFirst:
> > > 9)].
> > > prunedCType := (anIntegralCType beginsWith: 'unsigned ')
> > > ifTrue:
> [(anIntegralCType
> > > allButFirst: 9) withBlanksTrimmed]
> > > ifFalse:
> [(anIntegralCType
> > > beginsWith: 'signed ')
> > >
> > > ifTrue: [(anIntegralCType allButFirst: 7) withBlanksTrimmed]
> > >
> > > ifFalse: [anIntegralCType]].
> > >
> > > ^prunedCType asString caseOf: {
> > > ['sqLong'] -> [8].
> > > ['usqLong'] -> [8].
> > > ['long long'] -> [8].
> > > ['sqInt'] -> [6].
> > > ['usqInt'] -> [6].
> > > ['sqIntptr_t'] -> [6].
> > > ['usqIntptr_t'] -> [6].
> > > ['int'] -> [4].
> > > + ['uint32_t'] -> [4].
> > > + ['unsigned'] -> [4].
> > > ['short'] -> [2].
> > > ['short int'] -> [2].
> > > ['char'] -> [1].
> > > ['long'] -> [BytesPerWord].
> > > "It's ambiguous on LLP64 and we'll later remove it"
> > > ['size_t'] -> [6].
> > > ['pid_t'] -> [6].
> > > }
> > > otherwise:
> > > [((anIntegralCType beginsWith: 'unsigned') "e.g.
> > > 'unsigned : 8'"
> > > and: [(anIntegralCType includesAnyOf: '[*]') not
> > > and: [(index := anIntegralCType indexOf: $:) > 0]])
> > > ifTrue: [(Integer readFrom: (anIntegralCType
> > > copyFrom: index + 1 to: anIntegralCType size) withBlanksTrimmed
> readStream)
> > > + 7 // 8]
> > > ifFalse: [self error: 'unrecognized integral
> > > type']]!
> > >
> > >
> >
> > --
> > _,,,^..^,,,_
> > best, Eliot
>
>
--
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20210727/bf0ede0b/attachment-0001.html>
More information about the Vm-dev
mailing list