[Vm-dev] VM Maker: VMMaker.oscog-tpr.291.mcz

commits at source.squeak.org commits at source.squeak.org
Thu May 16 01:10:31 UTC 2013


tim Rowledge uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-tpr.291.mcz

==================== Summary ====================

Name: VMMaker.oscog-tpr.291
Author: tpr
Time: 15 May 2013, 6:08:02.276 pm
UUID: ec89405f-12f5-4a55-98f7-b246fcbec660
Ancestors: VMMaker.oscog-tpr.290

Fix typo in SQ_USE_GLOBAL_STRUCT_REG.
Insert batshit insane C macro double expansion lunacy to make use of -DUSE_GLOBAL_STRUCT_REG=r6 convert to register struct foo * foo asm("r6"); in final code.

This does now build a Raspbian vm with global reg var for the pointer to the global struct. Doesn't seem to be any faster though. :-(

=============== Diff against VMMaker.oscog-tpr.290 ===============

Item was changed:
  ----- Method: CCodeGeneratorGlobalStructure>>emitCVariablesOn: (in category 'C code generator') -----
  emitCVariablesOn: aStream
  	"Store the global variable declarations on the given stream.
  	 Break logic into vars for structure and vars for non-structure."
  	| structure nonstruct |
  
  	structure := WriteStream on: (String new: 32768).
  	nonstruct := WriteStream on: (String new: 32768).
  	aStream nextPutAll: '/*** Variables ***/'; cr.
  	structure
  		nextPutAll: '#if SQ_USE_GLOBAL_STRUCT'; cr;
  		nextPutAll: '# define _iss /* define in-struct static as void */'; cr;
  		nextPutAll: 'static struct foo {'; cr;
  		nextPutAll: '#else'; cr;
  		nextPutAll: '# define _iss static'; cr;
  		nextPutAll: '#endif'; cr.
  	self buildSortedVariablesCollection do:
  		[ :var | | decl varString inStruct target |
  		target := (inStruct := self placeInStructure: (varString := var asString)) 
  					ifTrue: [structure]
  					ifFalse: [nonstruct].
  		decl := variableDeclarations at: varString ifAbsent: ['sqInt ' , varString].
  		decl first == $# "support cgen var: #bytecodeSetSelector declareC: '#define bytecodeSetSelector 0' hack"
  			ifTrue:
  				[target nextPutAll: decl; cr]
  			ifFalse:
  				[self isGeneratingPluginCode
  					ifTrue:
  						[varString = 'interpreterProxy'
  							ifTrue: "quite special..."
  								[self preDeclareInterpreterProxyOn: target]
  							ifFalse: [target nextPutAll: 'static ']]
  					ifFalse:
  						[(vmClass mustBeGlobal: varString) ifFalse:
  							[target nextPutAll: (inStruct ifTrue: ['_iss '] ifFalse: ['static '])]].
  				target nextPutAll: decl; nextPut: $;; cr]].
  	structure
  		nextPutAll: '#undef _iss'; cr;
  		nextPutAll: '#if SQ_USE_GLOBAL_STRUCT'; cr;
  		nextPutAll: ' } fum;'; cr;
+ 		nextPutAll: ' #if SQ_USE_GLOBAL_STRUCT_REG';cr;
- 		nextPutAll: ' #if SQ_USE_GLOBAL_STRUCT_REGISTER';cr;
  		nextPutAll: '# define DECL_MAYBE_SQ_GLOBAL_STRUCT /* using a global reg pointer */'; cr;
  		nextPutAll: '# define DECL_MAYBE_VOLATILE_SQ_GLOBAL_STRUCT /* using a global reg pointer */'; cr;
  		nextPutAll:'#else';cr;
  		nextPutAll: '# define DECL_MAYBE_SQ_GLOBAL_STRUCT register struct foo * foo = &fum;'; cr;
  		nextPutAll: '# define DECL_MAYBE_VOLATILE_SQ_GLOBAL_STRUCT volatile register struct foo * foo = &fum;'; cr;
  		nextPutAll: '#endif';cr;
  		nextPutAll: '# define GIV(interpreterInstVar) (foo->interpreterInstVar)'; cr;
  		nextPutAll: '#else'; cr;
  		nextPutAll: '# define DECL_MAYBE_SQ_GLOBAL_STRUCT /* oh, no mr bill!! */'; cr;
  		nextPutAll: '# define DECL_MAYBE_VOLATILE_SQ_GLOBAL_STRUCT /* oh no, mr bill!! */'; cr;
  		nextPutAll: '# define GIV(interpreterInstVar) interpreterInstVar'; cr;
  		nextPutAll: '#endif'; cr.
  
+ 	"if the machine needs the fum structure defining locally, do it now; global register users don't need that, but DO need some batshit insane C macro fudging in order to convert the define of USE_GLOBAL_STRUCT_REG into a simple string to use in the asm clause below. Sigh."
- 	"if the machine needs the fum structure defining locally, do it now; global register users don't need this"
  	structure
  		nextPutAll: '#if SQ_USE_GLOBAL_STRUCT'; cr;
+ 		nextPutAll: '#if SQ_USE_GLOBAL_STRUCT_REG';cr;
+ 		nextPutAll: '#define fooxstr(s) foostr(s)'; cr;
+ 		nextPutAll: '#define foostr(s)  #s'; cr;
+ 		nextPutAll: 'register struct foo * foo asm(fooxstr(USE_GLOBAL_STRUCT_REG));'; cr;
- 		nextPutAll: '#if SQ_USE_GLOBAL_STRUCT_REGISTER';cr;
- 		nextPutAll: 'register struct foo * foo asm("USE_GLOBAL_STRUCT_REG")'; cr;
  		nextPutAll: '#else'; cr;
  		nextPutAll: 'static struct foo * foo = &fum;'; cr;
  		nextPutAll: '#endif'; cr;
  		nextPutAll: '#endif'; cr.
  
  	aStream
  		nextPutAll: structure contents;
  		nextPutAll: nonstruct contents;
  		cr!



More information about the Vm-dev mailing list