Commit e755a9f6 authored by Richard Torenvliet's avatar Richard Torenvliet

Merge branch 'master' of github.com:taddeus/peephole

parents 31e9202c 069c57ce
.file 1 "acron.c" .file 1 "acron.c"
# GNU C 2.7.2.3 [AL 1.1, MM 40, tma 0.1] SimpleScalar running sstrix compiled by GNU C # GNU C 2.7.2.3 [AL 1.1, MM 40, tma 0.1] SimpleScalar running sstrix compiled by GNU C
# Cc1 defaults: # Cc1 defaults:
# -mgas -mgpOPT # -mgas -mgpOPT
# Cc1 arguments (-G value = 8, Cpu = default, ISA = 1): # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1):
# -quiet -dumpbase -O0 -o # -quiet -dumpbase -O0 -o
gcc2_compiled.: gcc2_compiled.:
__gnu_compiled_c: __gnu_compiled_c:
.globl w .globl w
...@@ -66,38 +68,38 @@ is_vowel: ...@@ -66,38 +68,38 @@ is_vowel:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,16 subu $sp,$sp,16
sw $fp,8($sp) sw $fp,8($sp)
move $fp,$sp move $fp,$sp
move $3,$4 move $3,$4
sb $3,0($fp) sb $3,0($fp)
move $2,$0 move $2,$0
lb $4,0($fp) lb $4,0($fp)
li $5,0x00000041 # 65 li $5,0x00000041 # $5 = 65
beq $4,$5,$L3 beq $4,$5,$L3
lb $4,0($fp) lb $4,0($fp)
li $5,0x00000045 # 69 li $5,0x00000045 # $5 = 69
beq $4,$5,$L3 beq $4,$5,$L3
lb $4,0($fp) lb $4,0($fp)
li $5,0x00000049 # 73 li $5,0x00000049 # $5 = 73
beq $4,$5,$L3 beq $4,$5,$L3
lb $4,0($fp) lb $4,0($fp)
li $5,0x0000004f # 79 li $5,0x0000004f # $5 = 79
beq $4,$5,$L3 beq $4,$5,$L3
lb $4,0($fp) lb $4,0($fp)
li $5,0x00000055 # 85 li $5,0x00000055 # $5 = 85
beq $4,$5,$L3 beq $4,$5,$L3
lb $4,0($fp) lb $4,0($fp)
li $5,0x00000059 # 89 li $5,0x00000059 # $5 = 89
bne $4,$5,$L2 bne $4,$5,$L2
$L3: $L3:
li $2,0x00000001 # 1 li $2,0x00000001 # $2 = 1
$L2: $L2:
j $L1 j $L1
$L1: $L1:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,8($sp) lw $fp,8($sp)
addu $sp,$sp,16 addu $sp,$sp,16
j $31 j $31
.end is_vowel .end is_vowel
.loc 1 15 .loc 1 15
.ent do_perm .ent do_perm
...@@ -106,246 +108,246 @@ do_perm: ...@@ -106,246 +108,246 @@ do_perm:
.mask 0xc0030000,-4 .mask 0xc0030000,-4
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,56 subu $sp,$sp,56
sw $31,52($sp) sw $31,52($sp)
sw $fp,48($sp) sw $fp,48($sp)
sw $17,44($sp) sw $17,44($sp)
sw $16,40($sp) sw $16,40($sp)
move $fp,$sp move $fp,$sp
sw $4,56($fp) sw $4,56($fp)
sw $5,60($fp) sw $5,60($fp)
sw $6,64($fp) sw $6,64($fp)
sw $7,68($fp) sw $7,68($fp)
sw $0,24($fp) sw $0,24($fp)
lw $2,64($fp) lw $2,64($fp)
li $3,0x00000001 # 1 li $3,0x00000001 # $3 = 1
bne $2,$3,$L5 bne $2,$3,$L5
lw $2,pindex lw $2,pindex
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,w la $3,w
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
lb $4,0($3) lb $4,0($3)
jal is_vowel jal is_vowel
bne $2,$0,$L5 bne $2,$0,$L5
lw $2,56($fp) lw $2,56($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,w la $3,w
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
lb $4,0($3) lb $4,0($3)
jal is_vowel jal is_vowel
beq $2,$0,$L4 beq $2,$0,$L4
$L5: $L5:
lw $2,64($fp) lw $2,64($fp)
slt $3,$2,2 slt $3,$2,2
bne $3,$0,$L6 bne $3,$0,$L6
lw $2,64($fp) lw $2,64($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,pindex-8 la $3,pindex-8
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
move $2,$3 move $2,$3
sll $3,$2,2 sll $3,$2,2
la $4,w la $4,w
addu $2,$3,$4 addu $2,$3,$4
lw $3,0($2) lw $3,0($2)
lb $4,0($3) lb $4,0($3)
jal is_vowel jal is_vowel
move $16,$2 move $16,$2
lw $2,64($fp) lw $2,64($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,pindex-4 la $3,pindex-4
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
move $2,$3 move $2,$3
sll $3,$2,2 sll $3,$2,2
la $4,w la $4,w
addu $2,$3,$4 addu $2,$3,$4
lw $3,0($2) lw $3,0($2)
lb $4,0($3) lb $4,0($3)
jal is_vowel jal is_vowel
move $17,$2 move $17,$2
lw $2,56($fp) lw $2,56($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,w la $3,w
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
lb $4,0($3) lb $4,0($3)
jal is_vowel jal is_vowel
addu $3,$16,$17 addu $3,$16,$17
addu $2,$3,$2 addu $2,$3,$2
sw $2,24($fp) sw $2,24($fp)
beq $2,$0,$L8 beq $2,$0,$L8
lw $2,24($fp) lw $2,24($fp)
li $3,0x00000003 # 3 li $3,0x00000003 # $3 = 3
bne $2,$3,$L7 bne $2,$3,$L7
$L8: $L8:
j $L4 j $L4
$L7: $L7:
$L6: $L6:
lw $2,64($fp) lw $2,64($fp)
addu $3,$2,1 addu $3,$2,1
sw $3,64($fp) sw $3,64($fp)
sll $3,$2,2 sll $3,$2,2
la $4,pindex la $4,pindex
addu $2,$3,$4 addu $2,$3,$4
lw $3,56($fp) lw $3,56($fp)
sw $3,0($2) sw $3,0($2)
lw $2,64($fp) lw $2,64($fp)
slt $3,$2,6 slt $3,$2,6
beq $3,$0,$L9 beq $3,$0,$L9
lw $3,68($fp) lw $3,68($fp)
subu $2,$3,1 subu $2,$3,1
move $3,$2 move $3,$2
sw $3,68($fp) sw $3,68($fp)
beq $3,$0,$L9 beq $3,$0,$L9
sw $0,16($fp) sw $0,16($fp)
$L10: $L10:
lw $2,16($fp) lw $2,16($fp)
slt $3,$2,6 slt $3,$2,6
beq $3,$0,$L11 beq $3,$0,$L11
$L13: $L13:
lw $2,16($fp) lw $2,16($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
lw $3,60($fp) lw $3,60($fp)
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
bne $3,$0,$L14 bne $3,$0,$L14
lw $2,16($fp) lw $2,16($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
lw $3,60($fp) lw $3,60($fp)
addu $2,$2,$3 addu $2,$2,$3
li $3,0x00000001 # 1 li $3,0x00000001 # $3 = 1
sw $3,0($2) sw $3,0($2) # 0($2) = 1
lw $4,16($fp) lw $4,16($fp)
lw $5,60($fp) lw $5,60($fp)
lw $6,64($fp) lw $6,64($fp)
lw $7,68($fp) lw $7,68($fp)
jal do_perm jal do_perm
lw $2,16($fp) lw $2,16($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
lw $3,60($fp) lw $3,60($fp)
addu $2,$2,$3 addu $2,$2,$3
sw $0,0($2) sw $0,0($2)
$L14: $L14:
$L12: $L12:
lw $3,16($fp) lw $3,16($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,16($fp) sw $3,16($fp)
j $L10 j $L10
$L11: $L11:
j $L15 j $L15
$L9: $L9:
sw $0,28($fp) sw $0,28($fp)
sw $0,20($fp) sw $0,20($fp)
$L16: $L16:
lw $2,20($fp) lw $2,20($fp)
lw $3,64($fp) lw $3,64($fp)
slt $2,$2,$3 slt $2,$2,$3
beq $2,$0,$L17 beq $2,$0,$L17
$L19: $L19:
sw $0,32($fp) sw $0,32($fp)
$L20: $L20:
lw $2,20($fp) lw $2,20($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,pindex la $3,pindex
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
move $2,$3 move $2,$3
sll $3,$2,2 sll $3,$2,2
la $4,w la $4,w
addu $2,$3,$4 addu $2,$3,$4
lw $3,0($2) lw $3,0($2)
lw $4,32($fp) lw $4,32($fp)
addu $2,$3,$4 addu $2,$3,$4
lb $4,0($2) lb $4,0($2)
jal isupper jal isupper
beq $2,$0,$L21 beq $2,$0,$L21
$L22: $L22:
lw $2,28($fp) lw $2,28($fp)
addu $3,$2,1 addu $3,$2,1
sw $3,28($fp) sw $3,28($fp)
lw $3,20($fp) lw $3,20($fp)
move $4,$3 move $4,$3
sll $3,$4,2 sll $3,$4,2
la $4,pindex la $4,pindex
addu $3,$3,$4 addu $3,$3,$4
lw $4,0($3) lw $4,0($3)
move $3,$4 move $3,$4
sll $4,$3,2 sll $4,$3,2
la $5,w la $5,w
addu $3,$4,$5 addu $3,$4,$5
lw $4,32($fp) lw $4,32($fp)
addu $5,$4,1 addu $5,$4,1
sw $5,32($fp) sw $5,32($fp)
lw $5,0($3) lw $5,0($3)
addu $3,$4,$5 addu $3,$4,$5
lbu $4,0($3) lbu $4,0($3)
sb $4,acron($2) sb $4,acron($2)
j $L20 j $L20
$L21: $L21:
$L18: $L18:
lw $3,20($fp) lw $3,20($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,20($fp) sw $3,20($fp)
j $L16 j $L16
$L17: $L17:
lw $2,28($fp) lw $2,28($fp)
la $3,acron la $3,acron
addu $2,$2,$3 addu $2,$2,$3
sb $0,0($2) sb $0,0($2)
la $4,$LC6 la $4,$LC6
la $5,acron la $5,acron
jal printf jal printf
sw $0,20($fp) sw $0,20($fp)
$L23: $L23:
lw $2,20($fp) lw $2,20($fp)
lw $3,64($fp) lw $3,64($fp)
slt $2,$2,$3 slt $2,$2,$3
beq $2,$0,$L24 beq $2,$0,$L24
$L26: $L26:
lw $2,20($fp) lw $2,20($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,pindex la $3,pindex
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
move $2,$3 move $2,$3
sll $3,$2,2 sll $3,$2,2
la $4,w la $4,w
addu $2,$3,$4 addu $2,$3,$4
la $4,$LC7 la $4,$LC7
lw $5,0($2) lw $5,0($2)
jal printf jal printf
$L25: $L25:
lw $3,20($fp) lw $3,20($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,20($fp) sw $3,20($fp)
j $L23 j $L23
$L24: $L24:
la $4,$LC8 la $4,$LC8
jal printf jal printf
$L15: $L15:
$L4: $L4:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,52($sp) lw $31,52($sp)
lw $fp,48($sp) lw $fp,48($sp)
lw $17,44($sp) lw $17,44($sp)
lw $16,40($sp) lw $16,40($sp)
addu $sp,$sp,56 addu $sp,$sp,56
j $31 j $31
.end do_perm .end do_perm
.loc 1 53 .loc 1 53
.ent main .ent main
...@@ -354,59 +356,59 @@ main: ...@@ -354,59 +356,59 @@ main:
.mask 0xc0000000,-4 .mask 0xc0000000,-4
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,32 subu $sp,$sp,32
sw $31,28($sp) sw $31,28($sp)
sw $fp,24($sp) sw $fp,24($sp)
move $fp,$sp move $fp,$sp
jal __main jal __main
li $2,0x00000004 # 4 li $2,0x00000004 # $2 = 4
sw $2,20($fp) sw $2,20($fp) # 20($fp) = 4
$L28: $L28:
lw $2,20($fp) lw $2,20($fp)
slt $3,$2,7 slt $3,$2,7
beq $3,$0,$L29 beq $3,$0,$L29
$L31: $L31:
sw $0,16($fp) sw $0,16($fp)
$L32: $L32:
lw $2,16($fp) lw $2,16($fp)
slt $3,$2,6 slt $3,$2,6
beq $3,$0,$L33 beq $3,$0,$L33
$L35: $L35:
lw $2,16($fp) lw $2,16($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,done la $3,done
addu $2,$2,$3 addu $2,$2,$3
li $3,0x00000001 # 1 li $3,0x00000001 # $3 = 1
sw $3,0($2) sw $3,0($2) # 0($2) = 1
lw $4,16($fp) lw $4,16($fp)
la $5,done la $5,done
move $6,$0 move $6,$0
lw $7,20($fp) lw $7,20($fp)
jal do_perm jal do_perm
lw $2,16($fp) lw $2,16($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,done la $3,done
addu $2,$2,$3 addu $2,$2,$3
sw $0,0($2) sw $0,0($2)
$L34: $L34:
lw $3,16($fp) lw $3,16($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,16($fp) sw $3,16($fp)
j $L32 j $L32
$L33: $L33:
$L30: $L30:
lw $3,20($fp) lw $3,20($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,20($fp) sw $3,20($fp)
j $L28 j $L28
$L29: $L29:
$L27: $L27:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,28($sp) lw $31,28($sp)
lw $fp,24($sp) lw $fp,24($sp)
addu $sp,$sp,32 addu $sp,$sp,32
j $31 j $31
.end main .end main
.file 1 "dhrystone.c" .file 1 "dhrystone.c"
# GNU C 2.7.2.3 [AL 1.1, MM 40, tma 0.1] SimpleScalar running sstrix compiled by GNU C # GNU C 2.7.2.3 [AL 1.1, MM 40, tma 0.1] SimpleScalar running sstrix compiled by GNU C
# Cc1 defaults: # Cc1 defaults:
# -mgas -mgpOPT # -mgas -mgpOPT
# Cc1 arguments (-G value = 8, Cpu = default, ISA = 1): # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1):
# -quiet -dumpbase -O0 -o # -quiet -dumpbase -O0 -o
gcc2_compiled.: gcc2_compiled.:
__gnu_compiled_c: __gnu_compiled_c:
.globl Version .globl Version
...@@ -71,19 +73,19 @@ main: ...@@ -71,19 +73,19 @@ main:
.mask 0xc0000000,-4 .mask 0xc0000000,-4
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,24 subu $sp,$sp,24
sw $31,20($sp) sw $31,20($sp)
sw $fp,16($sp) sw $fp,16($sp)
move $fp,$sp move $fp,$sp
jal __main jal __main
jal Proc0 jal Proc0
move $4,$0 move $4,$0
jal exit jal exit
$L1: $L1:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,20($sp) lw $31,20($sp)
lw $fp,16($sp) lw $fp,16($sp)
addu $sp,$sp,24 addu $sp,$sp,24
j $31 j $31
.end main .end main
.loc 1 432 .loc 1 432
.ent Proc0 .ent Proc0
...@@ -92,203 +94,200 @@ Proc0: ...@@ -92,203 +94,200 @@ Proc0:
.mask 0xc0010000,-8 .mask 0xc0010000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,152 subu $sp,$sp,152
sw $31,144($sp) sw $31,144($sp)
sw $fp,140($sp) sw $fp,140($sp)
sw $16,136($sp) sw $16,136($sp)
move $fp,$sp move $fp,$sp
addu $4,$fp,120 addu $4,$sp,120
jal times jal times
lw $2,120($fp) lw $2,120($fp)
sw $2,104($fp) sw $2,104($fp)
move $16,$0 move $16,$0
$L3: $L3:
sltu $2,$16,5000 sltu $2,$16,5000
beq $2,$0,$L4 beq $2,$0,$L4
$L6: $L6:
$L5: $L5:
addu $16,$16,1 addu $16,$16,1
j $L3 j $L3
$L4: $L4:
addu $4,$fp,120 addu $4,$fp,120
jal times jal times
lw $2,120($fp) lw $2,120($fp)
lw $3,104($fp) lw $3,104($fp)
subu $2,$2,$3 subu $2,$2,$3
sw $2,112($fp) sw $2,112($fp)
li $4,0x00000030 # 48 li $4,0x00000030 # $4 = 48
jal malloc jal malloc
sw $2,PtrGlbNext sw $2,PtrGlbNext
li $4,0x00000030 # 48 li $4,0x00000030 # $4 = 48
jal malloc jal malloc
sw $2,PtrGlb sw $2,PtrGlb
lw $2,PtrGlb lw $3,PtrGlbNext
lw $3,PtrGlbNext sw $3,0($2)
sw $3,0($2) lw $2,PtrGlb
lw $2,PtrGlb sw $0,4($2)
sw $0,4($2) lw $2,PtrGlb
lw $2,PtrGlb li $3,0x00000002 # $3 = 2
li $3,0x00000002 # 2 sw $3,8($2) # 8($2) = 2
sw $3,8($2) lw $2,PtrGlb
lw $2,PtrGlb li $3,0x00000028 # $3 = 40
li $3,0x00000028 # 40 sw $3,12($2) # 12($2) = 40
sw $3,12($2) lw $3,PtrGlb # $3 = unknown
lw $3,PtrGlb
addu $2,$3,16 addu $2,$3,16
move $4,$2 move $4,$2
la $5,$LC0 la $5,$LC0
jal strcpy jal strcpy
addu $2,$fp,40 addu $2,$fp,40
move $4,$2 move $4,$2
la $5,$LC1 la $5,$LC1
jal strcpy jal strcpy
li $2,0x0000000a # 10 li $2,0x0000000a # $2 = 10
sw $2,Array2Glob+1660 sw $2,Array2Glob+1660 # Array2Glob+1660 = 10
addu $4,$fp,120 addu $4,$fp,120
jal times jal times
lw $2,120($fp) lw $2,120($fp)
sw $2,104($fp) sw $2,104($fp)
move $16,$0 move $16,$0
$L7: $L7:
sltu $2,$16,5000 sltu $2,$16,5000
beq $2,$0,$L8 beq $2,$0,$L8
$L10: $L10:
jal Proc5 jal Proc5
jal Proc4 jal Proc4
li $2,0x00000002 # 2 li $2,0x00000002 # $2 = 2
sw $2,16($fp) sw $2,16($fp) # 16($fp) = 2
li $2,0x00000003 # 3 li $2,0x00000003 # $2 = 3
sw $2,20($fp) sw $2,20($fp) # 20($fp) = 3
addu $2,$fp,72 addu $2,$fp,72
move $4,$2 move $4,$2
la $5,$LC2 la $5,$LC2
jal strcpy jal strcpy
li $2,0x00000001 # 1 li $2,0x00000001 # $2 = 1
sw $2,32($fp) sw $2,32($fp) # 32($fp) = 1
addu $2,$fp,40 addu $2,$fp,40
addu $3,$fp,72 addu $3,$fp,72
move $4,$2 move $4,$2
move $5,$3 move $5,$3
jal Func2 jal Func2
xori $3,$2,0x0000 xori $3,$2,0x0000
sltu $2,$3,1 sltu $2,$3,1
sw $2,BoolGlob sw $2,BoolGlob
$L11: $L11:
lw $2,16($fp) lw $2,16($fp)
lw $3,20($fp) lw $3,20($fp)
slt $2,$2,$3 slt $2,$2,$3
beq $2,$0,$L12 beq $2,$0,$L12
$L13: $L13:
lw $2,16($fp) lw $2,16($fp)
move $4,$2 # Dead code: move $4, $2
sll $3,$4,2 sll $3,$2,2
addu $3,$3,$2 addu $3,$3,$2
lw $2,20($fp) lw $2,20($fp)
subu $3,$3,$2 subu $3,$3,$2
sw $3,24($fp) sw $3,24($fp)
addu $2,$fp,24 addu $2,$fp,24
lw $4,16($fp) lw $4,16($fp)
lw $5,20($fp) lw $5,20($fp)
move $6,$2 move $6,$2
jal Proc7 jal Proc7
lw $3,16($fp) lw $3,16($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,16($fp) sw $3,16($fp)
j $L11 j $L11
$L12: $L12:
la $4,Array1Glob la $4,Array1Glob
la $5,Array2Glob la $5,Array2Glob
lw $6,16($fp) lw $6,16($fp)
lw $7,24($fp) lw $7,24($fp)
jal Proc8 jal Proc8
lw $4,PtrGlb lw $4,PtrGlb
jal Proc1 jal Proc1
li $2,0x00000041 # 65 li $2,0x00000041 # $2 = 65
sb $2,29($fp) sb $2,29($fp)
$L14: $L14:
lb $2,29($fp) lb $2,29($fp)
lb $3,Char2Glob lb $3,Char2Glob
slt $2,$3,$2 slt $2,$3,$2
bne $2,$0,$L15 bne $2,$0,$L15
$L17: $L17:
lb $2,29($fp) lb $2,29($fp)
move $4,$2 move $4,$2
li $5,0x00000043 # 67 li $5,0x00000043 # $5 = 67
jal Func1 jal Func1
lw $3,32($fp) lw $3,32($fp)
bne $3,$2,$L18 bne $3,$2,$L18
addu $2,$fp,32 addu $2,$fp,32
move $4,$0 move $4,$0
move $5,$2 move $5,$2
jal Proc6 jal Proc6
$L18: $L18:
$L16: $L16:
lbu $2,29($fp) lbu $2,29($fp)
addu $3,$2,1 addu $3,$2,1
move $2,$3 move $2,$3
sb $2,29($fp) sb $2,29($fp)
j $L14 j $L14
$L15: $L15:
lw $2,20($fp) lw $2,20($fp)
lw $3,16($fp) lw $3,16($fp)
mult $2,$3 mult $2,$3
mflo $2 mflo $2
sw $2,24($fp) sw $2,24($fp)
lw $2,24($fp) lw $3,16($fp)
lw $3,16($fp) div $2,$2,$3
div $2,$2,$3 sw $2,20($fp)
sw $2,20($fp) lw $2,24($fp)
lw $2,24($fp) lw $3,20($fp)
lw $3,20($fp)
subu $2,$2,$3 subu $2,$2,$3
move $4,$2 # Dead code: move $4, $2
sll $3,$4,3 sll $3,$2,3
subu $3,$3,$2 subu $3,$3,$2
lw $2,16($fp) lw $2,16($fp)
subu $3,$3,$2 subu $3,$3,$2
sw $3,20($fp) sw $3,20($fp)
addu $4,$fp,16 addu $4,$fp,16
jal Proc2 jal Proc2
$L9: $L9:
addu $16,$16,1 addu $16,$16,1
j $L7 j $L7
$L8: $L8:
addu $4,$fp,120 addu $4,$fp,120
jal times jal times
lw $2,120($fp) lw $2,120($fp)
lw $3,104($fp) lw $3,104($fp)
subu $2,$2,$3 subu $2,$2,$3
lw $3,112($fp) lw $3,112($fp)
subu $2,$2,$3 subu $2,$2,$3
sw $2,108($fp) sw $2,108($fp)
lw $2,108($fp) li $6,0x51eb851f # $6 = 1374389535
li $6,0x51eb851f # 1374389535
mult $2,$6 mult $2,$6
mfhi $5 mfhi $5
mflo $4 # Dead code: mflo $4
srl $6,$5,0 srl $6,$5,0 # $6 = unknown
move $7,$0 # Dead code: move $7, $0
sra $3,$6,5 sra $3,$6,5
sra $4,$2,31 sra $4,$2,31
subu $2,$3,$4 subu $2,$3,$4
la $4,$LC3 la $4,$LC3
la $5,Version la $5,Version
li $6,0x00001388 # 5000 li $6,0x00001388 # $6 = 5000
move $7,$2 move $7,$2
jal printf jal printf
li $2,0x0007a120 # 500000 li $2,0x0007a120 # $2 = 500000
lw $3,108($fp) lw $3,108($fp)
div $2,$2,$3 div $2,$2,$3
la $4,$LC4 la $4,$LC4
move $5,$2 move $5,$2
jal printf jal printf
$L2: $L2:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,144($sp) lw $31,144($sp)
lw $fp,140($sp) lw $fp,140($sp)
lw $16,136($sp) lw $16,136($sp)
addu $sp,$sp,152 addu $sp,$sp,152
j $31 j $31
.end Proc0 .end Proc0
.loc 1 540 .loc 1 540
.ent Proc1 .ent Proc1
...@@ -297,80 +296,80 @@ Proc1: ...@@ -297,80 +296,80 @@ Proc1:
.mask 0xc0000000,-4 .mask 0xc0000000,-4
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,24 subu $sp,$sp,24
sw $31,20($sp) sw $31,20($sp)
sw $fp,16($sp) sw $fp,16($sp)
move $fp,$sp move $fp,$sp
sw $4,24($fp) sw $4,24($fp)
lw $2,24($fp) lw $2,24($fp)
lw $3,0($2) lw $3,0($2)
lw $2,PtrGlb lw $2,PtrGlb
move $4,$3 move $4,$3
move $5,$2 move $5,$2
li $6,0x00000030 # 48 li $6,0x00000030 # $6 = 48
jal memcpy jal memcpy
lw $2,24($fp) lw $2,24($fp)
li $3,0x00000005 # 5 li $3,0x00000005 # $3 = 5
sw $3,12($2) sw $3,12($2) # 12($2) = 5
lw $3,24($fp) lw $3,24($fp) # $3 = unknown
lw $2,0($3) lw $2,0($3)
lw $3,24($fp) lw $3,24($fp)
lw $4,12($3) lw $4,12($3)
sw $4,12($2) sw $4,12($2)
lw $3,24($fp) lw $3,24($fp)
lw $2,0($3) lw $2,0($3)
lw $3,24($fp) lw $3,24($fp)
lw $4,0($3) lw $4,0($3)
sw $4,0($2) sw $4,0($2)
lw $2,24($fp) lw $2,24($fp)
lw $3,0($2) lw $3,0($2)
lw $4,0($3) lw $4,0($3)
jal Proc3 jal Proc3
lw $2,24($fp) lw $2,24($fp)
lw $3,0($2) lw $3,0($2)
lw $2,4($3) lw $2,4($3)
bne $2,$0,$L20 bne $2,$0,$L20
lw $2,24($fp) lw $2,24($fp)
lw $3,0($2) lw $3,0($2)
li $2,0x00000006 # 6 li $2,0x00000006 # $2 = 6
sw $2,12($3) sw $2,12($3) # 12($3) = 6
lw $2,24($fp) lw $2,24($fp) # $2 = unknown
lw $3,24($fp) lw $3,24($fp)
lw $4,0($3) lw $4,0($3)
addu $3,$4,8 addu $3,$4,8
lw $4,8($2) lw $4,8($2)
move $5,$3 move $5,$3
jal Proc6 jal Proc6
lw $3,24($fp) lw $3,24($fp)
lw $2,0($3) lw $2,0($3)
lw $3,PtrGlb lw $3,PtrGlb
lw $4,0($3) lw $4,0($3)
sw $4,0($2) sw $4,0($2)
lw $3,24($fp) lw $3,24($fp)
lw $2,0($3) lw $2,0($3)
lw $3,24($fp) lw $3,24($fp)
lw $4,0($3) lw $4,0($3)
addu $3,$4,12 addu $3,$4,12
lw $4,12($2) lw $4,12($2)
li $5,0x0000000a # 10 li $5,0x0000000a # $5 = 10
move $6,$3 move $6,$3
jal Proc7 jal Proc7
j $L21 j $L21
$L20: $L20:
lw $2,24($fp) lw $2,24($fp)
lw $3,24($fp) lw $3,24($fp)
lw $4,0($3) lw $4,0($3)
move $3,$4 move $3,$4
move $4,$2 move $4,$2
move $5,$3 move $5,$3
li $6,0x00000030 # 48 li $6,0x00000030 # $6 = 48
jal memcpy jal memcpy
$L21: $L21:
$L19: $L19:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,20($sp) lw $31,20($sp)
lw $fp,16($sp) lw $fp,16($sp)
addu $sp,$sp,24 addu $sp,$sp,24
j $31 j $31
.end Proc1 .end Proc1
.loc 1 563 .loc 1 563
.ent Proc2 .ent Proc2
...@@ -379,39 +378,39 @@ Proc2: ...@@ -379,39 +378,39 @@ Proc2:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,16 subu $sp,$sp,16
sw $fp,8($sp) sw $fp,8($sp)
move $fp,$sp move $fp,$sp
sw $4,16($fp) sw $4,16($fp)
lw $2,16($fp) lw $2,16($fp)
lw $3,0($2) lw $3,0($2)
addu $2,$3,10 addu $2,$3,10
sw $2,0($fp) sw $2,0($fp)
$L23: $L23:
lb $2,Char1Glob lb $2,Char1Glob
li $3,0x00000041 # 65 li $3,0x00000041 # $3 = 65
bne $2,$3,$L26 bne $2,$3,$L26
lw $3,0($fp) lw $3,0($fp)
subu $2,$3,1 subu $2,$3,1
move $3,$2 move $3,$2
sw $3,0($fp) sw $3,0($fp)
lw $2,16($fp) lw $2,16($fp)
lw $3,0($fp) lw $3,0($fp)
lw $4,IntGlob lw $4,IntGlob
subu $3,$3,$4 subu $3,$3,$4
sw $3,0($2) sw $3,0($2)
sw $0,4($fp) sw $0,4($fp)
$L26: $L26:
lw $2,4($fp) lw $2,4($fp)
beq $2,$0,$L24 beq $2,$0,$L24
$L27: $L27:
$L25: $L25:
j $L23 j $L23
$L24: $L24:
$L22: $L22:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,8($sp) lw $fp,8($sp)
addu $sp,$sp,16 addu $sp,$sp,16
j $31 j $31
.end Proc2 .end Proc2
.loc 1 583 .loc 1 583
.ent Proc3 .ent Proc3
...@@ -420,33 +419,33 @@ Proc3: ...@@ -420,33 +419,33 @@ Proc3:
.mask 0xc0000000,-4 .mask 0xc0000000,-4
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,24 subu $sp,$sp,24
sw $31,20($sp) sw $31,20($sp)
sw $fp,16($sp) sw $fp,16($sp)
move $fp,$sp move $fp,$sp
sw $4,24($fp) sw $4,24($fp)
lw $2,PtrGlb lw $2,PtrGlb
beq $2,$0,$L29 beq $2,$0,$L29
lw $2,24($fp) lw $2,24($fp)
lw $3,PtrGlb lw $3,PtrGlb
lw $4,0($3) lw $4,0($3)
sw $4,0($2) sw $4,0($2)
j $L30 j $L30
$L29: $L29:
li $2,0x00000064 # 100 li $2,0x00000064 # $2 = 100
sw $2,IntGlob sw $2,IntGlob # IntGlob = 100
$L30: $L30:
lw $3,PtrGlb lw $3,PtrGlb
addu $2,$3,12 addu $2,$3,12
li $4,0x0000000a # 10 li $4,0x0000000a # $4 = 10
lw $5,IntGlob lw $5,IntGlob
move $6,$2 move $6,$2
jal Proc7 jal Proc7
$L28: $L28:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,20($sp) lw $31,20($sp)
lw $fp,16($sp) lw $fp,16($sp)
addu $sp,$sp,24 addu $sp,$sp,24
j $31 j $31
.end Proc3 .end Proc3
.loc 1 593 .loc 1 593
.ent Proc4 .ent Proc4
...@@ -455,23 +454,22 @@ Proc4: ...@@ -455,23 +454,22 @@ Proc4:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,16 subu $sp,$sp,16
sw $fp,8($sp) sw $fp,8($sp)
move $fp,$sp move $fp,$sp
lb $2,Char1Glob lb $2,Char1Glob
xori $3,$2,0x0041 xori $3,$2,0x0041
sltu $2,$3,1 sltu $2,$3,1
sw $2,0($fp) sw $2,0($fp)
lw $2,0($fp) lw $3,BoolGlob
lw $3,BoolGlob or $2,$2,$3
or $2,$2,$3 sw $2,0($fp)
sw $2,0($fp) li $2,0x00000042 # $2 = 66
li $2,0x00000042 # 66 sb $2,Char2Glob
sb $2,Char2Glob
$L31: $L31:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,8($sp) lw $fp,8($sp)
addu $sp,$sp,16 addu $sp,$sp,16
j $31 j $31
.end Proc4 .end Proc4
.loc 1 602 .loc 1 602
.ent Proc5 .ent Proc5
...@@ -480,16 +478,16 @@ Proc5: ...@@ -480,16 +478,16 @@ Proc5:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,8 subu $sp,$sp,8
sw $fp,0($sp) sw $fp,0($sp)
move $fp,$sp move $fp,$sp
li $2,0x00000041 # 65 li $2,0x00000041 # $2 = 65
sb $2,Char1Glob sb $2,Char1Glob
sw $0,BoolGlob sw $0,BoolGlob
$L32: $L32:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,0($sp) lw $fp,0($sp)
addu $sp,$sp,8 addu $sp,$sp,8
j $31 j $31
.end Proc5 .end Proc5
.loc 1 610 .loc 1 610
.ent Proc6 .ent Proc6
...@@ -498,31 +496,31 @@ Proc6: ...@@ -498,31 +496,31 @@ Proc6:
.mask 0xc0000000,-4 .mask 0xc0000000,-4
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,24 subu $sp,$sp,24
sw $31,20($sp) sw $31,20($sp)
sw $fp,16($sp) sw $fp,16($sp)
move $fp,$sp move $fp,$sp
sw $4,24($fp) sw $4,24($fp)
sw $5,28($fp) sw $5,28($fp)
lw $2,28($fp) lw $2,28($fp)
lw $3,24($fp) lw $3,24($fp)
sw $3,0($2) sw $3,0($2)
lw $4,24($fp) lw $4,24($fp)
jal Func3 jal Func3
bne $2,$0,$L34 bne $2,$0,$L34
lw $2,28($fp) lw $2,28($fp)
li $3,0x00000003 # 3 li $3,0x00000003 # $3 = 3
sw $3,0($2) sw $3,0($2) # 0($2) = 3
$L34: $L34:
lw $2,24($fp) lw $2,24($fp)
sltu $3,$2,5 sltu $3,$2,5
beq $3,$0,$L44 beq $3,$0,$L44
lw $2,24($fp) lw $2,24($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
la $3,$L43 la $3,$L43
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($2) lw $3,0($2)
j $3 j $3
.rdata .rdata
.align 3 .align 3
.align 2 .align 2
...@@ -534,41 +532,41 @@ $L43: ...@@ -534,41 +532,41 @@ $L43:
.word $L42 .word $L42
.text .text
$L36: $L36:
lw $2,28($fp) lw $2,28($fp)
sw $0,0($2) sw $0,0($2)
j $L35 j $L35
$L37: $L37:
lw $2,IntGlob lw $2,IntGlob
slt $3,$2,101 slt $3,$2,101
bne $3,$0,$L38 bne $3,$0,$L38
lw $2,28($fp) lw $2,28($fp)
sw $0,0($2) sw $0,0($2)
j $L39 j $L39
$L38: $L38:
lw $2,28($fp) lw $2,28($fp)
li $3,0x00000003 # 3 li $3,0x00000003 # $3 = 3
sw $3,0($2) sw $3,0($2) # 0($2) = 3
$L39: $L39:
j $L35 j $L35
$L40: $L40:
lw $2,28($fp) lw $2,28($fp)
li $3,0x00000001 # 1 li $3,0x00000001 # $3 = 1
sw $3,0($2) sw $3,0($2) # 0($2) = 1
j $L35 j $L35
$L41: $L41:
j $L35 j $L35
$L42: $L42:
lw $2,28($fp) lw $2,28($fp)
li $3,0x00000002 # 2 li $3,0x00000002 # $3 = 2
sw $3,0($2) sw $3,0($2) # 0($2) = 2
$L44: $L44:
$L35: $L35:
$L33: $L33:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,20($sp) lw $31,20($sp)
lw $fp,16($sp) lw $fp,16($sp)
addu $sp,$sp,24 addu $sp,$sp,24
j $31 j $31
.end Proc6 .end Proc6
.loc 1 629 .loc 1 629
.ent Proc7 .ent Proc7
...@@ -577,24 +575,24 @@ Proc7: ...@@ -577,24 +575,24 @@ Proc7:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,16 subu $sp,$sp,16
sw $fp,8($sp) sw $fp,8($sp)
move $fp,$sp move $fp,$sp
sw $4,16($fp) sw $4,16($fp)
sw $5,20($fp) sw $5,20($fp)
sw $6,24($fp) sw $6,24($fp)
lw $2,16($fp) lw $2,16($fp)
addu $3,$2,2 addu $3,$2,2
sw $3,0($fp) sw $3,0($fp)
lw $2,24($fp) lw $2,24($fp)
lw $3,20($fp) lw $3,20($fp)
lw $4,0($fp) lw $4,0($fp)
addu $3,$3,$4 addu $3,$3,$4
sw $3,0($2) sw $3,0($2)
$L45: $L45:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,8($sp) lw $fp,8($sp)
addu $sp,$sp,16 addu $sp,$sp,16
j $31 j $31
.end Proc7 .end Proc7
.loc 1 640 .loc 1 640
.ent Proc8 .ent Proc8
...@@ -603,148 +601,148 @@ Proc8: ...@@ -603,148 +601,148 @@ Proc8:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,16 subu $sp,$sp,16
sw $fp,8($sp) sw $fp,8($sp)
move $fp,$sp move $fp,$sp
sw $4,16($fp) sw $4,16($fp)
sw $5,20($fp) sw $5,20($fp)
sw $6,24($fp) sw $6,24($fp)
sw $7,28($fp) sw $7,28($fp)
lw $2,24($fp) lw $2,24($fp)
addu $3,$2,5 addu $3,$2,5
sw $3,0($fp) sw $3,0($fp)
lw $2,0($fp) lw $2,0($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
lw $3,16($fp) lw $3,16($fp)
addu $2,$2,$3 addu $2,$2,$3
lw $3,28($fp) lw $3,28($fp)
sw $3,0($2) sw $3,0($2)
lw $2,0($fp) lw $2,0($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
lw $4,16($fp) lw $4,16($fp)
addu $3,$2,$4 addu $3,$2,$4
addu $2,$3,4 addu $2,$3,4
lw $3,0($fp) lw $3,0($fp)
move $4,$3 move $4,$3
sll $3,$4,2 sll $3,$4,2
lw $4,16($fp) lw $4,16($fp)
addu $3,$3,$4 addu $3,$3,$4
lw $4,0($3) lw $4,0($3)
sw $4,0($2) sw $4,0($2)
lw $2,0($fp) lw $2,0($fp)
move $3,$2 move $3,$2
sll $2,$3,2 sll $2,$3,2
lw $3,16($fp) lw $3,16($fp)
addu $2,$2,$3 addu $2,$2,$3
addu $3,$2,120 addu $3,$2,120
lw $2,0($fp) lw $2,0($fp)
sw $2,0($3) sw $2,0($3)
lw $2,0($fp) lw $2,0($fp)
sw $2,4($fp) sw $2,4($fp)
$L47: $L47:
lw $3,0($fp) lw $3,0($fp)
addu $2,$3,1 addu $2,$3,1
lw $3,4($fp) lw $3,4($fp)
slt $2,$2,$3 slt $2,$2,$3
bne $2,$0,$L48 bne $2,$0,$L48
$L50: $L50:
lw $3,0($fp) lw $3,0($fp)
lw $2,4($fp) lw $2,4($fp)
move $4,$2 move $4,$2
sll $2,$4,2 sll $2,$4,2
move $5,$3 move $5,$3
sll $4,$5,1 sll $4,$3,1
addu $4,$4,$3 addu $4,$4,$3
sll $3,$4,4 sll $3,$4,4
addu $4,$4,$3 addu $4,$4,$3
sll $3,$4,2 sll $3,$4,2
lw $4,20($fp) lw $4,20($fp)
addu $3,$3,$4 addu $3,$3,$4
addu $2,$2,$3 addu $2,$2,$3
lw $3,0($fp) lw $3,0($fp)
sw $3,0($2) sw $3,0($2)
$L49: $L49:
lw $3,4($fp) lw $3,4($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,4($fp) sw $3,4($fp)
j $L47 j $L47
$L48: $L48:
lw $3,0($fp) # Dead code: lw $3, 0($fp)
lw $2,0($fp) # Dead code: lw $2, 0($fp)
# Dead code: move $4, $2
# Dead code: sll $2, $4, 2
# Dead code: move $5, $3
# Dead code: sll $4, $3, 1
# Dead code: addu $4, $4, $3
# Dead code: sll $3, $4, 4
# Dead code: addu $4, $4, $3
# Dead code: sll $3, $4, 2
# Dead code: lw $4, 20($fp)
# Dead code: addu $3, $3, $4
# Dead code: addu $4, $2, $3
# Dead code: subu $2, $4, 4
lw $3,0($fp)
lw $2,0($fp)
move $4,$2 move $4,$2
sll $2,$4,2 sll $2,$4,2
move $5,$3 # Dead code: move $5, $3
sll $4,$5,1 sll $4,$3,1
addu $4,$4,$3
sll $3,$4,4
addu $4,$4,$3
sll $3,$4,2
lw $4,20($fp)
addu $3,$3,$4
addu $4,$2,$3
subu $2,$4,4
lw $3,0($fp)
lw $2,0($fp)
move $4,$2
sll $2,$4,2
move $5,$3
sll $4,$5,1
addu $4,$4,$3 addu $4,$4,$3
sll $3,$4,4 sll $3,$4,4
addu $4,$4,$3 addu $4,$4,$3
sll $3,$4,2 sll $3,$4,2
lw $4,20($fp) lw $4,20($fp)
addu $3,$3,$4 addu $3,$3,$4
addu $4,$2,$3 addu $4,$2,$3
subu $2,$4,4 subu $2,$4,4
lw $4,0($fp) lw $4,0($fp)
lw $3,0($fp) lw $3,0($fp)
move $5,$3 move $5,$3
sll $3,$5,2 sll $3,$5,2
move $6,$4 move $6,$4
sll $5,$6,1 sll $5,$4,1
addu $5,$5,$4 addu $5,$5,$4
sll $4,$5,4 sll $4,$5,4
addu $5,$5,$4 addu $5,$5,$4
sll $4,$5,2 sll $4,$5,2
lw $5,20($fp) lw $5,20($fp)
addu $4,$4,$5 addu $4,$4,$5
addu $3,$3,$4 addu $3,$3,$4
subu $4,$3,4 subu $4,$3,4
lw $5,0($4) lw $5,0($4)
addu $3,$5,1 addu $3,$5,1
move $4,$3 move $4,$3
sw $4,0($2) sw $4,0($2)
lw $3,0($fp) lw $3,0($fp)
lw $2,0($fp) lw $2,0($fp)
move $4,$2 move $4,$2
sll $2,$4,2 sll $2,$4,2
move $5,$3 move $5,$3
sll $4,$5,1 sll $4,$5,1
addu $4,$4,$3 addu $4,$4,$3
sll $3,$4,4 sll $3,$4,4
addu $4,$4,$3 addu $4,$4,$3
sll $3,$4,2 sll $3,$4,2
lw $4,20($fp) lw $4,20($fp)
addu $3,$3,$4 addu $3,$3,$4
addu $4,$2,$3 addu $4,$2,$3
addu $2,$4,4080 addu $2,$4,4080
lw $3,0($fp) lw $3,0($fp)
move $4,$3 move $4,$3
sll $3,$4,2 sll $3,$4,2
lw $4,16($fp) lw $4,16($fp)
addu $3,$3,$4 addu $3,$3,$4
lw $4,0($3) lw $4,0($3)
sw $4,0($2) sw $4,0($2)
li $2,0x00000005 # 5 li $2,0x00000005 # $2 = 5
sw $2,IntGlob sw $2,IntGlob # IntGlob = 5
$L46: $L46:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,8($sp) lw $fp,8($sp)
addu $sp,$sp,16 addu $sp,$sp,16
j $31 j $31
.end Proc8 .end Proc8
.loc 1 660 .loc 1 660
.ent Func1 .ent Func1
...@@ -753,31 +751,31 @@ Func1: ...@@ -753,31 +751,31 @@ Func1:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,16 subu $sp,$sp,16
sw $fp,8($sp) sw $fp,8($sp)
move $fp,$sp move $fp,$sp
move $3,$4 move $3,$4
move $4,$5 move $4,$5
sb $3,0($fp) sb $3,0($fp)
sb $4,1($fp) sb $4,1($fp)
lbu $2,0($fp) lbu $2,0($fp)
sb $2,2($fp) sb $2,2($fp)
lbu $2,2($fp) lbu $2,2($fp)
sb $2,3($fp) sb $2,3($fp)
lb $2,3($fp) lb $2,3($fp)
lb $5,1($fp) lb $5,1($fp)
beq $2,$5,$L52 beq $2,$5,$L52
move $2,$0 move $2,$0
j $L51 j $L51
j $L53 j $L53
$L52: $L52:
li $2,0x00000001 # 1 li $2,0x00000001 # $2 = 1
j $L51 j $L51
$L53: $L53:
$L51: $L51:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,8($sp) lw $fp,8($sp)
addu $sp,$sp,16 addu $sp,$sp,16
j $31 j $31
.end Func1 .end Func1
.loc 1 675 .loc 1 675
.ent Func2 .ent Func2
...@@ -786,77 +784,77 @@ Func2: ...@@ -786,77 +784,77 @@ Func2:
.mask 0xc0000000,-4 .mask 0xc0000000,-4
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,32 subu $sp,$sp,32
sw $31,28($sp) sw $31,28($sp)
sw $fp,24($sp) sw $fp,24($sp)
move $fp,$sp move $fp,$sp
sw $4,32($fp) sw $4,32($fp)
sw $5,36($fp) sw $5,36($fp)
li $2,0x00000001 # 1 li $2,0x00000001 # $2 = 1
sw $2,16($fp) sw $2,16($fp) # 16($fp) = 1
$L55: $L55:
lw $2,16($fp) lw $2,16($fp)
slt $3,$2,2 slt $3,$2,2
beq $3,$0,$L56 beq $3,$0,$L56
$L57: $L57:
lw $2,32($fp) lw $2,32($fp)
lw $4,16($fp) lw $4,16($fp)
addu $3,$2,$4 addu $3,$2,$4
lb $2,0($3) lb $2,0($3)
lw $3,16($fp) lw $3,16($fp)
lw $4,36($fp) lw $4,36($fp)
addu $3,$3,$4 addu $3,$3,$4
addu $4,$3,1 addu $4,$3,1
lb $3,0($4) lb $3,0($4)
move $4,$2 move $4,$2
move $5,$3 move $5,$3
jal Func1 jal Func1
bne $2,$0,$L58 bne $2,$0,$L58
li $2,0x00000041 # 65 li $2,0x00000041 # $2 = 65
sb $2,20($fp) sb $2,20($fp)
lw $3,16($fp) lw $3,16($fp)
addu $2,$3,1 addu $2,$3,1
move $3,$2 move $3,$2
sw $3,16($fp) sw $3,16($fp)
$L58: $L58:
j $L55 j $L55
$L56: $L56:
lb $2,20($fp) lb $2,20($fp)
slt $3,$2,87 slt $3,$2,87
bne $3,$0,$L59 bne $3,$0,$L59
lb $2,20($fp) lb $2,20($fp)
slt $3,$2,91 slt $3,$2,91
beq $3,$0,$L59 beq $3,$0,$L59
li $2,0x00000007 # 7 li $2,0x00000007 # $2 = 7
sw $2,16($fp) sw $2,16($fp) # 16($fp) = 7
$L59: $L59:
lb $2,20($fp) lb $2,20($fp)
li $3,0x00000058 # 88 li $3,0x00000058 # $3 = 88
bne $2,$3,$L60 bne $2,$3,$L60
li $2,0x00000001 # 1 li $2,0x00000001 # $2 = 1
j $L54 j $L54
j $L61 j $L61
$L60: $L60:
lw $4,32($fp) lw $4,32($fp)
lw $5,36($fp) lw $5,36($fp)
jal strcmp jal strcmp
blez $2,$L62 blez $2,$L62
lw $2,16($fp) lw $2,16($fp)
addu $3,$2,7 addu $3,$2,7
sw $3,16($fp) sw $3,16($fp)
li $2,0x00000001 # 1 li $2,0x00000001 # $2 = 1
j $L54 j $L54
j $L63 j $L63
$L62: $L62:
move $2,$0 move $2,$0
j $L54 j $L54
$L63: $L63:
$L61: $L61:
$L54: $L54:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $31,28($sp) lw $31,28($sp)
lw $fp,24($sp) lw $fp,24($sp)
addu $sp,$sp,32 addu $sp,$sp,32
j $31 j $31
.end Func2 .end Func2
.loc 1 705 .loc 1 705
.ent Func3 .ent Func3
...@@ -865,22 +863,21 @@ Func3: ...@@ -865,22 +863,21 @@ Func3:
.mask 0x40000000,-8 .mask 0x40000000,-8
.fmask 0x00000000,0 .fmask 0x00000000,0
subu $sp,$sp,16 subu $sp,$sp,16
sw $fp,8($sp) sw $fp,8($sp)
move $fp,$sp move $fp,$sp
sw $4,16($fp) sw $4,16($fp)
lw $2,16($fp) lw $2,16($fp)
sw $2,0($fp) sw $2,0($fp)
lw $2,0($fp) li $3,0x00000002 # $3 = 2
li $3,0x00000002 # 2 bne $2,$3,$L65
bne $2,$3,$L65 li $2,0x00000001 # $2 = 1
li $2,0x00000001 # 1 j $L64
j $L64
$L65: $L65:
move $2,$0 move $2,$0
j $L64 j $L64
$L64: $L64:
move $sp,$fp # sp not trusted here move $sp,$fp # sp not trusted here
lw $fp,8($sp) lw $fp,8($sp)
addu $sp,$sp,16 addu $sp,$sp,16
j $31 j $31
.end Func3 .end Func3
\ No newline at end of file
from copy import copy from copy import copy
RESERVED_REGISTERS = ['$fp', '$sp']
def is_reg_dead_after(reg, block, index):
"""Check if a register is dead after a certain point in a basic block."""
if reg in RESERVED_REGISTERS:
return False
if index < len(block) - 1:
for s in block[index + 1:]:
# If used, the previous definition is live
if s.uses(reg):
return False
# If redefined, the previous definition is dead
if s.defines(reg):
return True
# If dead within the same block, check if the register is in the block's
# live_out set
return reg not in block.live_out
def create_use_def(block): def create_use_def(block):
used = set() used = set()
defined = set() defined = set()
......
from src.statement import Statement as S
from math import log from math import log
from src.statement import Statement as S
from src.liveness import is_reg_dead_after
def reg_can_be_used_in(reg, block, start, end): def reg_can_be_used_in(reg, block, start, end):
"""Check if a register addres safely be used in a block section using local """Check if a register addres safely be used in a block section using local
...@@ -173,50 +175,45 @@ def fold_constants(block): ...@@ -173,50 +175,45 @@ def fold_constants(block):
# Move of `Hi' register to another register # Move of `Hi' register to another register
register[s[0]] = register['$hi'] register[s[0]] = register['$hi']
known.append((s[0], register[s[0]])) known.append((s[0], register[s[0]]))
elif s.name in ['mult', 'div'] \ elif s.name == 'mult' and s[0]in register and s[1] in register:
and s[0]in register and s[1] in register:
# Multiplication/division with constants # Multiplication/division with constants
print s
rs, rt = s rs, rt = s
a, b = register[rs], register[rt] a, b = register[rs], register[rt]
if s.name == 'mult': if not a or not b:
if not a or not b: # Multiplication by 0
# Multiplication by 0 hi = lo = to_hex(0)
hi = lo = to_hex(0) message = 'Multiplication by 0: %d * 0' % (b if a else a)
message = 'Multiplication by 0: %d * 0' % (b if a else a) elif a == 1:
elif a == 1: # Multiplication by 1
# Multiplication by 1 hi = to_hex(0)
hi = to_hex(0) lo = to_hex(b)
lo = to_hex(b) message = 'Multiplication by 1: %d * 1' % b
message = 'Multiplication by 1: %d * 1' % b elif b == 1:
elif b == 1: # Multiplication by 1
# Multiplication by 1 hi = to_hex(0)
hi = to_hex(0) lo = to_hex(a)
lo = to_hex(a) message = 'Multiplication by 1: %d * 1' % a
message = 'Multiplication by 1: %d * 1' % a else:
else: # Calculate result and fill Hi/Lo registers
# Calculate result and fill Hi/Lo registers result = a * b
result = a * b binary = bin(result)[2:]
binary = bin(result)[2:] binary = '0' * (64 - len(binary)) + binary
binary = '0' * (64 - len(binary)) + binary hi = int(binary[:32], base=2)
hi = int(binary[:32], base=2) lo = int(binary[32:], base=2)
lo = int(binary[32:], base=2) message = 'Constant multiplication: %d * %d = %d' \
message = 'Constant multiplication: %d * %d = %d' \ % (a, b, result)
% (a, b, result)
# Replace the multiplication with two immidiate loads to the
# Replace the multiplication with two immidiate loads to the # Hi/Lo registers
# Hi/Lo registers block.replace(1, [S('command', 'li', '$hi', hi),
block.replace(1, [S('command', 'li', '$hi', hi), S('command', 'li', '$lo', li)],
S('command', 'li', '$lo', li)], message=message)
message=message)
elif s.name == 'div':
lo, hi = divmod(rs, rt)
register['$lo'], register['$hi'] = lo, hi register['$lo'], register['$hi'] = lo, hi
known += [('$lo', lo), ('$hi', hi)] known += [('$lo', lo), ('$hi', hi)]
changed = True changed = True
elif s.name in ['addu', 'subu']: elif s.name in ['addu', 'subu', 'div']:
# Addition/subtraction with constants # Addition/subtraction with constants
rd, rs, rt = s rd, rs, rt = s
rs_known = rs in register rs_known = rs in register
...@@ -233,12 +230,17 @@ def fold_constants(block): ...@@ -233,12 +230,17 @@ def fold_constants(block):
if s.name == 'addu': if s.name == 'addu':
result = rs_val + rt_val result = rs_val + rt_val
message = 'Constant addition: %d + %d = %d' \ message = 'Constant addition: %d + %d = %d' \
% (rs_val, rt_val, result) % (rs_val, rt_val, result)
if s.name == 'subu': if s.name == 'subu':
result = rs_val - rt_val result = rs_val - rt_val
message = 'Constant subtraction: %d - %d = %d' \ message = 'Constant subtraction: %d - %d = %d' \
% (rs_val, rt_val, result) % (rs_val, rt_val, result)
if s.name == 'div':
result = rs_val / rt_val
message = 'Constant division: %d - %d = %d' \
% (rs_val, rt_val, result)
block.replace(1, [S('command', 'li', rd, to_hex(result))], block.replace(1, [S('command', 'li', rd, to_hex(result))],
message=message) message=message)
...@@ -393,25 +395,42 @@ def eliminate_dead_code(block): ...@@ -393,25 +395,42 @@ def eliminate_dead_code(block):
is not used in the rest of the block, and is not in the `out' set of the is not used in the rest of the block, and is not in the `out' set of the
block. block.
""" """
# TODO: Finish
changed = False changed = False
unused = set()
for s in reversed(block): for n, s in enumerate(block):
for reg in s.get_def(): for reg in s.get_def():
if reg in unused: if is_reg_dead_after(reg, block, n):
# Statement is redefined later, so this statement is useless # Statement is redefined later, so this statement is useless
if block.debug: if block.debug:
s.stype = 'comment' s.stype = 'comment'
s.options['block'] = False s.options['block'] = False
s.name = ' Dead code: %s %s' \ s.options[''] = False
% (s.name, ', '.join(map(str, s))) s.name = ' Dead:\t%s\t%s\t(dead register %s)' \
% (s.name, ','.join(map(str, s)), reg)
else: else:
s.remove = True s.remove = True
else:
unused.add(reg)
unused -= set(s.get_use()) changed = True
#unused = set()
#for s in reversed(block):
# for reg in s.get_def():
# if reg in unused:
# # Statement is redefined later, so this statement is useless
# if block.debug:
# s.stype = 'comment'
# s.options['block'] = False
# s.name = ' Dead:\t%s\t%s' \
# % (s.name, ','.join(map(str, s)))
# else:
# s.remove = True
# changed = True
# else:
# unused.add(reg)
# unused -= set(s.get_use())
if not block.debug: if not block.debug:
block.apply_filter(lambda s: not hasattr(s, 'remove')) block.apply_filter(lambda s: not hasattr(s, 'remove'))
......
...@@ -148,6 +148,8 @@ class TestStatement(unittest.TestCase): ...@@ -148,6 +148,8 @@ class TestStatement(unittest.TestCase):
arg2) arg2)
self.assertEqual(S('command', 's.s', '$1', '10($2)').get_use(), \ self.assertEqual(S('command', 's.s', '$1', '10($2)').get_use(), \
arg2) arg2)
self.assertEqual(S('command', 'sw', '$1', '10($2)').get_use(), \
arg2)
self.assertEqual(S('command', 'sb', '$1', '10($2)').get_use(), \ self.assertEqual(S('command', 'sb', '$1', '10($2)').get_use(), \
arg2) arg2)
self.assertEqual(S('command', 'mtc1', '$1', '$2').get_use(), arg1) self.assertEqual(S('command', 'mtc1', '$1', '$2').get_use(), arg1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment