[Vm-dev] VM Maker: VMMaker.oscog-eem.1546.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Dec 4 02:34:23 UTC 2015


Eliot Miranda uploaded a new version of VMMaker to project VM Maker:
http://source.squeak.org/VMMaker/VMMaker.oscog-eem.1546.mcz

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

Name: VMMaker.oscog-eem.1546
Author: eem
Time: 3 December 2015, 6:33:03.684 pm
UUID: c944400d-c93e-49d8-85e7-d060d8585fd3
Ancestors: VMMaker.oscog-eem.1545

x64 cogit:  Fix slip in concretizeAndRR.

use assert:equals: throughout CogX64CompilerTests

=============== Diff against VMMaker.oscog-eem.1545 ===============

Item was changed:
  ----- Method: CogARMCompilerTests>>testAdd (in category 'tests') -----
  testAdd
  	"self new testAdd"
  	
  	"the forms are valid, "
  	"test AddCqR"
  	self concreteCompilerClass registersWithNamesDo: [ :reg :regName |
  		#(0 16rF 16rFF) do:
  			[:n| | inst len |
  			inst := self gen: AddCqR operand: n operand: reg.
  			len := inst concretizeAt: 0.
  			self
  				disassembleInstructionAt: 0
  				In: inst
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'adds	', regName, ', ', regName, ', #', n asString.
+ 					self assert: herIntended equals: plainJane]]].
- 					self assert: (plainJane match: herIntended)]]].
  		
  	"test AddCwR"
  	self concreteCompilerClass registersWithNamesDo: [ :reg :regName |
  		#(16rFFFFFFFF 16r88888888 0) do:
  			[:n| | inst len |
  			inst := self gen: AddCwR operand: n operand: reg.
  			len := inst concretizeAt: 0.
  			self
  				disassembleInstructionAt: 0
  				In: inst
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'mov	ip, #', (n bitAnd: 16rFF << 24) signedIntFromLong asString.
+ 					self assert: herIntended equals: plainJane].
- 					self assert: (plainJane match: herIntended)].
  			self
  				disassembleInstructionAt: 4
  				In: inst
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'orr	ip, ip, #', (n bitAnd: 16rFF << 16) asString.
+ 					self assert: herIntended equals: plainJane].
- 					self assert: (plainJane match: herIntended)].
  			self
  				disassembleInstructionAt: 8
  				In: inst
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'orr	ip, ip, #', (n bitAnd: 16rFF << 8) signedIntFromLong asString.
+ 					self assert: herIntended equals: plainJane].
- 					self assert: (plainJane match: herIntended)].
  			self
  				disassembleInstructionAt: 12
  				In: inst
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'orr	ip, ip, #', (n bitAnd: 16rFF) asString.
+ 					self assert: herIntended equals: plainJane].
- 					self assert: (plainJane match: herIntended)].
  			self
  				disassembleInstructionAt: 16
  				In: inst
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'adds	', regName, ', ', regName, ', ip'.
+ 					self assert: herIntended equals: plainJane]]]
- 					self assert: (plainJane match: herIntended)]]]
  !

Item was changed:
  ----- Method: CogARMCompilerTests>>testPrefetchAw (in category 'tests') -----
  testPrefetchAw
  	"self new testPrefetchAw"
  	
  	#(16rFF00FF00 16r00000012) do:
  		[:n| | inst len |
  		inst := self gen: PrefetchAw operand: n.
  		len := inst concretizeAt: 0.
  		self
  			disassembleInstructionAt: 12
  			In: inst
  			into: [:str :sz| | plainJane herIntended |
  				"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  				plainJane := self strip: str.
  				herIntended := 'pld	[sl', ((n bitAnd: 16rFF) = 0 ifTrue: [''] ifFalse: [', #', (n bitAnd: 16rFF) asString]) ,']'.
+ 				self assert: herIntended equals: plainJane.
- 				self assert: (plainJane match: herIntended).
  				self assert: len = 16]].
  !

Item was changed:
  ----- Method: CogARMCompilerTests>>testPushR (in category 'tests') -----
  testPushR
  	"self new testPushR"
  	
  	self concreteCompilerClass registersWithNamesDo:
  		[:r :name | | inst len |
  		inst := self gen: PushR operand: r.
  		len := inst concretizeAt: 0.
  		self
  			disassembleInstructionAt: 0
  			In: inst
  			into: [:str :sz| | plainJane herIntended |
  				"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  				plainJane := self strip: str.
  				herIntended := 'push	{', name ,'}'.
+ 				self assert: herIntended equals: plainJane.
- 				self assert: (plainJane match: herIntended).
  				self assert: len = 4]].
  !

Item was changed:
  ----- Method: CogARMCompilerTests>>testRetN (in category 'tests') -----
  testRetN
  	"self new testRetN"
  	
  	#(0) do:
  		[:n| | inst len |
  		inst := self gen: RetN operand: n.
  		len := inst concretizeAt: 0.
  		self
  			disassembleInstructionAt: 0
  			In: inst
  			into: [:str :sz| | plainJane  |
  				"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  				plainJane := self strip: str.
  				self assert: (plainJane match: 'mov	pc, lr').
  				self assert: len = sz]].
  	
  	#(1 2 3 4 5 6 7) do:
  		[:n| | inst len |
  		inst := self gen: RetN operand: n * 4.
  		len := inst concretizeAt: 0.
  		self
  			disassembleInstructionAt: 0
  			In: inst
  			into: [:str :sz| | plainJane herIntended |
  				plainJane := self strip: str.
  				herIntended := 'add	sp, sp, #', (n * 4 )asString.
+ 				self assert: herIntended equals: plainJane].
- 				self assert: (plainJane match: herIntended)].
  		self
  			disassembleInstructionAt: 4
  			In: inst
  			into: [:str :sz| | plainJane |
  				plainJane := self strip: str.
  				self assert: (plainJane match: 'mov	pc, lr').		
  		self assert: len = 8]]!

Item was changed:
  ----- Method: CogX64Compiler>>concretizeAndRR (in category 'generate machine code') -----
  concretizeAndRR
  	"Will get inlined into concretizeAt: switch."
  	<inline: true>
  	| regLHS regRHS |
  	regLHS := self concreteRegister: (operands at: 0).
  	regRHS := self concreteRegister: (operands at: 1).
  	machineCode
  		at: 0 put: (self rexR: regRHS x: 0 b: regLHS);
  		at: 1 put: 16r23;
  		at: 2 put: (self mod: ModReg RM: regLHS RO: regRHS).
+ 	^machineCodeSize := 3!
- 	^machineCodeSize := 2!

Item was changed:
  ----- Method: CogX64CompilerTests>>testAddCqR (in category 'tests') -----
  testAddCqR
  	"self new testAddCqR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
  			[:const| | inst len|
  			inst := self gen: AddCqR operand: const operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := 'addq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testAndCqR (in category 'tests') -----
  testAndCqR
  	"self new testAndCqR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
  			[:const| | inst len|
  			inst := self gen: AndCqR operand: const operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := 'andq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was added:
+ ----- Method: CogX64CompilerTests>>testAndRR (in category 'tests') -----
+ testAndRR
+ 	"CogX64CompilerTests new testAndRR"
+ 	self concreteCompilerClass registersWithNamesDo:
+ 		[:sreg :sregname|
+ 		self concreteCompilerClass registersWithNamesDo:
+ 			[:dreg :dregname| | inst len |
+ 			inst := self gen: AndRR operand: sreg operand: dreg.
+ 			len := inst concretizeAt: 0.
+ 			self processor
+ 				disassembleInstructionAt: 0
+ 				In: inst machineCode object
+ 				into: [:str :sz| | plainJane herIntended |
+ 					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
+ 					plainJane := self strip: str.
+ 					herIntended := 'andq ', sregname, ', ', dregname.
+ 					self assert: herIntended equals: plainJane.
+ 					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testCMPXCHGAwR (in category 'tests') -----
  testCMPXCHGAwR
  	"self new testCMPXCHGAwR"
  	| cmpxchgAwR |
  	cmpxchgAwR := CogX64Compiler classPool at: #CMPXCHGAwR.
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r555555 16rAAAAAA) do:
  			[:addr| | inst len |
  			inst := self gen: cmpxchgAwR operand: addr operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := 'cmpxchgl ', regname, ', 0x', (addr hex allButFirst: 3).
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testCMPXCHGMwrR (in category 'tests') -----
  testCMPXCHGMwrR
  	"self new testCMPXCHGMwrR"
  	| cmpxchgMwrR lock |
  	cmpxchgMwrR := CogX64Compiler classPool at: #CMPXCHGMwrR.
  	lock := CogX64Compiler classPool at: #LOCK.
  	self concreteCompilerClass registersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname|
  			((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  				[:offset|
  				#(false true) do:
  					[:prefixLock| | memory |
  					self resetGen.
  					prefixLock ifTrue: [self gen: lock].
  					self gen: cmpxchgMwrR operand: offset operand: sreg operand: dreg.
  					memory := self generateInstructions.
  					self processor
  						disassembleInstructionAt: 0
  						In: memory
  						into: [:str :sz| | plainJane herIntended |
  							plainJane := self strip: str.
  							herIntended := (prefixLock ifTrue: ['lock '] ifFalse: ['']),
  											'cmpxchgl ', drname, ', 0x', (offset hex allButFirst: 3), '(', srname, ')'.
+ 							self assert: herIntended equals: plainJane.
- 							self assert: (plainJane match: herIntended).
  							self assert: memory size = sz]]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testCmpCqR (in category 'tests') -----
  testCmpCqR
  	"self new testCmpCqR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
  			[:const| | inst len|
  			inst := self gen: CmpCqR operand: const operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := 'cmpq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveAbR (in category 'tests') -----
  testMoveAbR
  	"self neb testMoveAbR"
  	self concreteCompilerClass byteRegistersWithNamesDo:
  		[:reg :regname| | reg64name |
  		reg64name := self processor registerStateGetters at: reg + 1.
  		#(16r555555 16rAAAAAA 16r5A5A5A5A5A5A) do:
  			[:addr| | inst len totalsz |
  			inst := self gen: MoveAbR operand: addr operand: reg.
  			len := inst concretizeAt: 0.
  			totalsz := 0.
  			regname ~= '%al' ifTrue:
  				[self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, %', reg64name.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := sz]].
  			self processor
  				disassembleInstructionAt: totalsz
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'movb 0x', (addr printStringBase: 16 length: 16 padded: true), ', %al'.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					totalsz := totalsz + sz].
  			regname ~= '%al' ifTrue:
  				[self processor
  					disassembleInstructionAt: totalsz
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, %', reg64name.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := totalsz + sz]].
  			self assert: len = totalsz]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveAwR (in category 'tests') -----
  testMoveAwR
  	"self new testMoveAwR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r555555 16rAAAAAA 16r5A5A5A5A5A5A) do:
  			[:addr| | inst len totalsz |
  			inst := self gen: MoveAwR operand: addr operand: reg.
  			len := inst concretizeAt: 0.
  			totalsz := 0.
  			regname ~= '%rax' ifTrue:
  				[self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, ', regname.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := sz]].
  			self processor
  				disassembleInstructionAt: totalsz
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'movq 0x', (addr printStringBase: 16 length: 16 padded: true), ', %rax'.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					totalsz := totalsz + sz].
  			regname ~= '%rax' ifTrue:
  				[self processor
  					disassembleInstructionAt: totalsz
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, ', regname.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := totalsz + sz]].
  			self assert: len = totalsz]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveC32R (in category 'tests') -----
  testMoveC32R
  	"self new testMoveMwrR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :rname|
  		#(0 64 65536 -64 -65536) do:
  			[:offset| | inst len |
  			inst := self gen: MoveC32R operand: offset operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended po |
  					plainJane := self strip: str.
  					po := offset bitAnd: 1 << self processor bitsInWord - 1.
  					herIntended := 'movq $0x', (po printStringBase: 16 length: 16 padded: true), ', ', rname.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveMbrR (in category 'tests') -----
  testMoveMbrR
  	"self new testMoveMbrR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass byteRegistersWithNamesDo:
  			[:dreg :drname|
  			((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  				[:offset| | inst len |
  				inst := self gen: MoveMbrR operand: offset operand: sreg operand: dreg.
  				self deny: inst byteReadsZeroExtend.
  				len := inst concretizeAt: 0.
  				self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended po |
  						po := offset bitAnd: 1 << self processor bitsInWord - 1.
  						plainJane := self strip: str.
  						herIntended := 'movb ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16 length: 16 padded: true)]), '(', srname, '), ', drname.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						self assert: len = sz]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveMwrR (in category 'tests') -----
  testMoveMwrR
  	"self new testMoveMwrR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname| | inst len |
  			#(0 64 65536 -64 -65536) do:
  				[:offset|
  				inst := self gen: MoveMwrR operand: offset operand: sreg operand: dreg.
  				len := inst concretizeAt: 0.
  				self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended po |
  						plainJane := self strip: str.
  						po := offset bitAnd: 1 << self processor bitsInWord - 1.
  						herIntended := 'movq ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16 length: 16 padded: true)]), '(', srname, '), ', drname.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						self assert: len = sz]]]]
  
  	"| failures |
  	 failures := Dictionary new.
  	 self concreteCompilerClass registersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname| | inst len |
  			#(0 64 65536 -64 -65536) do:
  				[:offset|
  				inst := self gen: MoveMwrR operand: offset operand: sreg operand: dreg.
  				len := inst concretizeAt: 0.
  				self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended po |
  						plainJane := self strip: str.
  						po := offset bitAnd: 1 << self processor bitsInWord - 1.
  						herIntended := 'movq ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16 length: 16 padded: true)]), '(', srname, '), ', drname.
  						((plainJane match: herIntended) and: [len = sz]) ifFalse:
  							[failures at: herIntended put: plainJane]]]]].
  	 failures"!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveRAb (in category 'tests') -----
  testMoveRAb
  	"self new testMoveRAb"
  	self concreteCompilerClass byteRegistersWithNamesDo:
  		[:reg :regname| | reg64name |
  		reg64name := self processor registerStateGetters at: reg + 1.
  		#(16r555555 16rAAAAAA 16r5A5A5A5A5A5A) do:
  			[:addr| | inst len totalsz |
  			inst := self gen: MoveRAb operand: reg operand: addr.
  			len := inst concretizeAt: 0.
  			totalsz := 0.
  			regname ~= '%al' ifTrue:
  				[self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, %', reg64name.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := sz]].
  			self processor
  				disassembleInstructionAt: totalsz
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'movb %al, 0x', (addr printStringBase: 16 length: 16 padded: true).
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					totalsz := totalsz + sz].
  			regname ~= '%al' ifTrue:
  				[self processor
  					disassembleInstructionAt: totalsz
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, %', reg64name.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := totalsz + sz]].
  			self assert: len = totalsz]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveRAw (in category 'tests') -----
  testMoveRAw
  	"self new testMoveRAw"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r555555 16rAAAAAA 16r5A5A5A5A5A5A) do:
  			[:addr| | inst len totalsz |
  			inst := self gen: MoveRAw operand: reg operand: addr.
  			len := inst concretizeAt: 0.
  			totalsz := 0.
  			regname ~= '%rax' ifTrue:
  				[self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, ', regname.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := sz]].
  			self processor
  				disassembleInstructionAt: totalsz
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					plainJane := self strip: str.
  					herIntended := 'movq %rax, 0x', (addr printStringBase: 16 length: 16 padded: true).
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					totalsz := totalsz + sz].
  			regname ~= '%rax' ifTrue:
  				[self processor
  					disassembleInstructionAt: totalsz
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgq %rax, ', regname.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						totalsz := totalsz + sz]].
  			self assert: len = totalsz]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveRMbr (in category 'tests') -----
  testMoveRMbr
  	"self new testMoveRMbr"
  	self concreteCompilerClass byteRegistersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname|
  			((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  				[:offset| | inst len |
  				inst := self gen: MoveRMbr operand: sreg operand: offset operand: dreg.
  				len := inst concretizeAt: 0.
  				self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended po |
  						plainJane := self strip: str.
  						po := offset bitAnd: 1 << self processor bitsInWord - 1.
  						herIntended := 'movb ', srname, (offset = 0 ifTrue: [', '] ifFalse: [', 0x', (po printStringBase: 16 length: 16 padded: true)]), '(', drname, ')'.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						self assert: len = sz]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveRMwr (in category 'tests') -----
  testMoveRMwr
  	"self new testMoveRMwr"
  	self concreteCompilerClass registersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname| | inst len |
  			#(0 64 65536 -64 -65536) do:
  				[:offset|
  				inst := self gen: MoveRMwr operand: sreg operand: offset operand: dreg.
  				len := inst concretizeAt: 0.
  				self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended po |
  						"Convert e.g. '00000000: movq %rax, 0x2(%rax) : 48 89 40 02' to  'movl %rax, 0x2(%rax)'"
  						plainJane := self strip: str.
  						po := offset bitAnd: 1 << self processor bitsInWord - 1.
  						herIntended := 'movq ', srname, ', ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16 length: 16 padded: true)]), '(',drname,')'.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						self assert: len = sz]]]]
  
  	"| failures |
  	 failures := Dictionary new.
  	 self concreteCompilerClass registersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname| | inst len |
  			#(0 64 65536 -64 -65536) do:
  				[:offset|
  				inst := self gen: MoveRMwr operand: sreg operand: offset operand: dreg.
  				len := inst concretizeAt: 0.
  				self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended po |
  						plainJane := self strip: str.
  						po := offset bitAnd: 1 << self processor bitsInWord - 1.
  						herIntended := 'movq ', srname, ', ', (offset = 0 ifTrue: [''] ifFalse: ['0x', (po printStringBase: 16 length: 16 padded: true)]), '(',drname,')'.
  						((plainJane match: herIntended) and: [len = sz]) ifFalse:
  							[failures at: herIntended put: plainJane]]]]].
  	 failures"!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveRXwrR (in category 'tests') -----
  testMoveRXwrR
  	"self new testMoveXwrRR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:idxreg :irname|
  			irname ~= '%rsp' ifTrue:
  				[self concreteCompilerClass registersWithNamesDo:
  					[:basereg :brname|
  					self concreteCompilerClass registersWithNamesDo:
  						[:sreg :srname|
  						((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  							[:offset| | inst len |
  							inst := self gen: MoveRXwrR operand: sreg operand: idxreg operand: basereg.
  							len := inst concretizeAt: 0.
  							self processor
  								disassembleInstructionAt: 0
  								In: inst machineCode object
  								into: [:str :sz| | plainJane herIntended |
  									"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  									plainJane := self strip: str.
  									herIntended := 'movq ', srname, ', (', brname, ',', irname, ',8)'.
+ 									self assert: herIntended equals: plainJane.
- 									self assert: (plainJane match: herIntended).
  									self assert: len = sz]]]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveRdM64r (in category 'tests') -----
  testMoveRdM64r
  	"self new testMoveRdM64r"
  	self concreteCompilerClass xmmRegistersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname|
  			((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  				[:offset| | inst len |
  				inst := self gen: MoveRdM64r operand: sreg operand: offset operand: dreg.
  				len := inst concretizeAt: 0.
  				self processor
  					disassembleInstructionAt: 0
  					In: inst machineCode object
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'movsd ', srname, ', 0x', (offset hex allButFirst: 3), '(', drname, ')'.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						self assert: len = sz]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveX32rRR (in category 'tests') -----
  testMoveX32rRR
  	"self new testMoveX32rRR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:idxreg :irname|
  			irname ~= '%rsp' ifTrue:
  				[self concreteCompilerClass registersWithNamesDo:
  					[:basereg :brname|
  					self concreteCompilerClass doubleWordRegistersWithNamesDo:
  						[:dreg :drname|
  						((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  							[:offset| | inst len |
  							inst := self gen: MoveX32rRR operand: idxreg operand: basereg operand: dreg.
  							len := inst concretizeAt: 0.
  							self processor
  								disassembleInstructionAt: 3
  								In: inst machineCode object
  								into: [:str :sz| | plainJane herIntended |
  									"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  									plainJane := self strip: str.
  									herIntended := 'movl (', brname, ',', irname, ',4), ',drname.
+ 									self assert: herIntended equals: plainJane.
- 									self assert: (plainJane match: herIntended).
  									self assert: len - 3 = sz]]]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveXbrRR (in category 'tests') -----
  testMoveXbrRR
  	"self new testMoveXbrRR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:idxreg :irname|
  		irname ~= '%rsp' ifTrue:
  			[self concreteCompilerClass registersWithNamesDo:
  				[:basereg :brname|
  				self concreteCompilerClass byteRegistersWithNamesDo:
  					[:dreg :drname|
  					((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  						[:offset| | inst len |
  						inst := self gen: MoveXbrRR operand: idxreg operand: basereg operand: dreg.
  						self deny: inst byteReadsZeroExtend.
  						len := inst concretizeAt: 0.
  						self processor
  							disassembleInstructionAt: 0
  							In: inst machineCode object
  							into: [:str :sz| | plainJane herIntended |
  								"Convert e.g. '00000000: movzbq %ds:(%rax,%rax,1), %rax : 48 0F B6 04 00 ' to  'movzbq (%rax,%rax,1), %rax'"
  								plainJane := self strip: str.
  								herIntended := 'movb (', brname, ',', irname, ',1), ',drname.
+ 								self assert: herIntended equals: plainJane.
- 								self assert: (plainJane match: herIntended).
  								self assert: len = sz]]]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testMoveXwrRR (in category 'tests') -----
  testMoveXwrRR
  	"self new testMoveXwrRR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:idxreg :irname|
  			irname ~= '%rsp' ifTrue:
  				[self concreteCompilerClass registersWithNamesDo:
  					[:basereg :brname|
  					self concreteCompilerClass registersWithNamesDo:
  						[:dreg :drname|
  						((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  							[:offset| | inst len |
  							inst := self gen: MoveXwrRR operand: idxreg operand: basereg operand: dreg.
  							len := inst concretizeAt: 0.
  							self processor
  								disassembleInstructionAt: 0
  								In: inst machineCode object
  								into: [:str :sz| | plainJane herIntended |
  									"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  									plainJane := self strip: str.
  									herIntended := 'movq (', brname, ',', irname, ',8), ',drname.
+ 									self assert: herIntended equals: plainJane.
- 									self assert: (plainJane match: herIntended).
  									self assert: len = sz]]]]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testOrCqR (in category 'tests') -----
  testOrCqR
  	"self new testOrCqR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
  			[:const| | inst len|
  			inst := self gen: OrCqR operand: const operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := 'orq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testSubCqR (in category 'tests') -----
  testSubCqR
  	"self new testSubCqR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
  			[:const| | inst len|
  			inst := self gen: SubCqR operand: const operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := 'subq $0x', (const printStringBase: 16 length: 16 padded: true), ', ', regname.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testTstCqR (in category 'tests') -----
  testTstCqR
  	"self new testTstCqR"
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :theRegname|
  		#(16r1 16r3 16r7 16r555555 16rAAAAAA) do:
  			[:const| | op regname inst len constString|
  			inst := self gen: TstCqR operand: const operand: reg.
  			len := inst concretizeAt: 0.
  			(inst isQuick: const)
  				ifTrue:
  					[op := 'testb'.
  					 regname := reg < 8
  									ifTrue: [#('%al' '%cl' '%dl' '%bl' '%spl' '%bpl' '%sil' '%dil') at: reg + 1]
  									ifFalse: [theRegname, 'b'].
  					 constString := const printStringBase: 16 length: 2 padded: true]
  				ifFalse:
  					[op := 'testq'.
  					 regname := theRegname.
  					 constString := const printStringBase: 16 length: 16 padded: true].
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := op, ' $0x', constString, ', ', regname.
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testXCHGAwR (in category 'tests') -----
  testXCHGAwR
  	"self new testXCHGAwR"
  	| xchgAwR |
  	xchgAwR := CogX64Compiler classPool at: #XCHGAwR.
  	self concreteCompilerClass registersWithNamesDo:
  		[:reg :regname|
  		#(16r555555 16rAAAAAA) do:
  			[:addr| | inst len |
  			inst := self gen: xchgAwR operand: addr operand: reg.
  			len := inst concretizeAt: 0.
  			self processor
  				disassembleInstructionAt: 0
  				In: inst machineCode object
  				into: [:str :sz| | plainJane herIntended |
  					"Convert e.g. '00000000: movl %eax, 0x2(%eax) : 89 40 02' to  'movl %eax, 0x2(%eax)'"
  					plainJane := self strip: str.
  					herIntended := 'xchgl ', regname, ', 0x', (addr hex allButFirst: 3).
+ 					self assert: herIntended equals: plainJane.
- 					self assert: (plainJane match: herIntended).
  					self assert: len = sz]]]!

Item was changed:
  ----- Method: CogX64CompilerTests>>testXCHGMwrR (in category 'tests') -----
  testXCHGMwrR
  	"self new testXCHGMwrR"
  	| xchgMwrR |
  	xchgMwrR := CogX64Compiler classPool at: #XCHGMwrR.
  	self concreteCompilerClass registersWithNamesDo:
  		[:sreg :srname|
  		self concreteCompilerClass registersWithNamesDo:
  			[:dreg :drname|
  			((1 to: 19 by: 3) collect: [:po2| 2 raisedToInteger: po2]) do:
  				[:offset| | memory |
  				self resetGen.
  				self gen: xchgMwrR operand: offset operand: sreg operand: dreg.
  				memory := self generateInstructions.
  				self processor
  					disassembleInstructionAt: 0
  					In: memory
  					into: [:str :sz| | plainJane herIntended |
  						plainJane := self strip: str.
  						herIntended := 'xchgl ', drname, ', 0x', (offset hex allButFirst: 3), '(', srname, ')'.
+ 						self assert: herIntended equals: plainJane.
- 						self assert: (plainJane match: herIntended).
  						self assert: memory size = sz]]]]!



More information about the Vm-dev mailing list