Add pat cms !defined($1)
Switch .cms to pass inputs and outputs on the real stack, not in registers; like we do with .and, .or (81c677d) and .xor (c578c49). At this point, nearly all functions in libem use the real stack, not registers, for passing inputs and outputs. This simplifies the ncg table (which needs fewer lists of specific registers) but slows calls to libem. For example, afterba9b021, each call to .aar4 is about 10 instructions slower. I moved 3 inputs and 1 output from registers to the real stack. A program would take 4 instructions to move registers to stack, 4 to move stack to registers, and perhaps 2 to adjust the stack pointer.
This commit is contained in:
		
							parent
							
								
									89dd80e34d
								
							
						
					
					
						commit
						dc05cb2dc8
					
				
					 2 changed files with 17 additions and 15 deletions
				
			
		|  | @ -1,18 +1,17 @@ | |||
| .sect .text | ||||
| 
 | ||||
| ! Compare sets a, b. | ||||
| !  Stack: ( b a -- ) | ||||
| !  With r3 = size of each set | ||||
| !  Yields r3 = 0 if equal, nonzero if not equal | ||||
| !  Stack: ( b a size -- result ) | ||||
| !  Result is 0 if equal, nonzero if not equal. | ||||
| 
 | ||||
| .define .cms | ||||
| .cms: | ||||
| 	lwz	r3, 0(sp)		! r3 = size of each set | ||||
| 	srwi	r7, r3, 2 | ||||
| 	mtspr	ctr, r7			! ctr = size / 4 | ||||
| 	mr	r4, sp			! r4 = ptr to set a | ||||
| 	add	r5, sp, r3		! r5 = ptr to set b | ||||
| 	addi	r4, sp, 4		! r4 = ptr to set a | ||||
| 	add	r5, r4, r3		! r5 = ptr to set b | ||||
| 	li	r6, 0			! r6 = index | ||||
| 	add	r9, r5, r3		! r9 = future sp | ||||
| 1: | ||||
| 	lwzx	r7, r4, r6 | ||||
| 	lwzx	r8, r5, r6 | ||||
|  | @ -20,10 +19,12 @@ | |||
| 	addi	r6, r6, 4 | ||||
| 	bne	cr0, 2f			! branch if not equal | ||||
| 	bdnz	1b			! loop ctr times | ||||
| 	li	r3, 0			! equal: return 0 | ||||
| 	li	r9, 0			! equal: return 0 | ||||
| 	b	3f | ||||
| 2: | ||||
| 	li	r3, 1			! not equal: return 1 | ||||
| 	li	r9, 1			! not equal: return 1 | ||||
| 3: | ||||
| 	mr	sp, r9			! remove sets from stack | ||||
| 	slwi	r7, r3, 1 | ||||
| 	add	sp, sp, r7		! adjust stack pointer | ||||
| 	stw	r9, 0(sp)		! push result | ||||
| 	blr | ||||
|  |  | |||
|  | @ -1854,12 +1854,13 @@ PATTERNS | |||
| 			cmi INT32 | ||||
| 
 | ||||
| 	pat cms defined($1) | ||||
| 		with STACK | ||||
| 			kills ALL | ||||
| 			gen | ||||
| 				move {CONST, $1}, R3 | ||||
| 				bl {LABEL, ".cms"} | ||||
| 			yields R3 | ||||
| 		leaving | ||||
| 			loc $1 | ||||
| 			cal ".cms" | ||||
| 
 | ||||
| 	pat cms !defined($1) | ||||
| 		leaving | ||||
| 			cal ".cms" | ||||
| 
 | ||||
| 
 | ||||
| /* Other branching and labelling */ | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue