From 91236cf5c671385c24a433091997ca701d2bc3a5 Mon Sep 17 00:00:00 2001 From: Jayke Meijer <jayke.meijer@gmail.com> Date: Fri, 30 Dec 2011 13:16:18 +0100 Subject: [PATCH] Added unittest to test_statement, reoptimized some files --- benchmarks/optimized/acron.s | 444 ++++++++------- benchmarks/optimized/dhrystone.s | 949 +++++++++++++++---------------- tests/test_statement.py | 2 + 3 files changed, 698 insertions(+), 697 deletions(-) diff --git a/benchmarks/optimized/acron.s b/benchmarks/optimized/acron.s index be20fa7..8e97411 100644 --- a/benchmarks/optimized/acron.s +++ b/benchmarks/optimized/acron.s @@ -1,9 +1,11 @@ .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 # Cc1 defaults: # -mgas -mgpOPT # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1): # -quiet -dumpbase -O0 -o + gcc2_compiled.: __gnu_compiled_c: .globl w @@ -66,38 +68,38 @@ is_vowel: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,16 - sw $fp,8($sp) + sw $fp,8($sp) move $fp,$sp move $3,$4 - sb $3,0($fp) + sb $3,0($fp) move $2,$0 - lb $4,0($fp) - li $5,0x00000041 # 65 - beq $4,$5,$L3 - lb $4,0($fp) - li $5,0x00000045 # 69 - beq $4,$5,$L3 - lb $4,0($fp) - li $5,0x00000049 # 73 - beq $4,$5,$L3 - lb $4,0($fp) - li $5,0x0000004f # 79 - beq $4,$5,$L3 - lb $4,0($fp) - li $5,0x00000055 # 85 - beq $4,$5,$L3 - lb $4,0($fp) - li $5,0x00000059 # 89 - bne $4,$5,$L2 + lb $4,0($fp) + li $5,0x00000041 # $5 = 65 + beq $4,$5,$L3 + lb $4,0($fp) + li $5,0x00000045 # $5 = 69 + beq $4,$5,$L3 + lb $4,0($fp) + li $5,0x00000049 # $5 = 73 + beq $4,$5,$L3 + lb $4,0($fp) + li $5,0x0000004f # $5 = 79 + beq $4,$5,$L3 + lb $4,0($fp) + li $5,0x00000055 # $5 = 85 + beq $4,$5,$L3 + lb $4,0($fp) + li $5,0x00000059 # $5 = 89 + bne $4,$5,$L2 $L3: - li $2,0x00000001 # 1 + li $2,0x00000001 # $2 = 1 $L2: - j $L1 + j $L1 $L1: move $sp,$fp # sp not trusted here - lw $fp,8($sp) + lw $fp,8($sp) addu $sp,$sp,16 - j $31 + j $31 .end is_vowel .loc 1 15 .ent do_perm @@ -106,246 +108,246 @@ do_perm: .mask 0xc0030000,-4 .fmask 0x00000000,0 subu $sp,$sp,56 - sw $31,52($sp) - sw $fp,48($sp) - sw $17,44($sp) - sw $16,40($sp) + sw $31,52($sp) + sw $fp,48($sp) + sw $17,44($sp) + sw $16,40($sp) move $fp,$sp - sw $4,56($fp) - sw $5,60($fp) - sw $6,64($fp) - sw $7,68($fp) - sw $0,24($fp) - lw $2,64($fp) - li $3,0x00000001 # 1 - bne $2,$3,$L5 - lw $2,pindex + sw $4,56($fp) + sw $5,60($fp) + sw $6,64($fp) + sw $7,68($fp) + sw $0,24($fp) + lw $2,64($fp) + li $3,0x00000001 # $3 = 1 + bne $2,$3,$L5 + lw $2,pindex move $3,$2 - sll $2,$3,2 - la $3,w + sll $2,$3,2 + la $3,w addu $2,$2,$3 - lw $3,0($2) - lb $4,0($3) - jal is_vowel - bne $2,$0,$L5 - lw $2,56($fp) + lw $3,0($2) + lb $4,0($3) + jal is_vowel + bne $2,$0,$L5 + lw $2,56($fp) move $3,$2 - sll $2,$3,2 - la $3,w + sll $2,$3,2 + la $3,w addu $2,$2,$3 - lw $3,0($2) - lb $4,0($3) - jal is_vowel - beq $2,$0,$L4 + lw $3,0($2) + lb $4,0($3) + jal is_vowel + beq $2,$0,$L4 $L5: - lw $2,64($fp) - slt $3,$2,2 - bne $3,$0,$L6 - lw $2,64($fp) + lw $2,64($fp) + slt $3,$2,2 + bne $3,$0,$L6 + lw $2,64($fp) move $3,$2 - sll $2,$3,2 - la $3,pindex-8 + sll $2,$3,2 + la $3,pindex-8 addu $2,$2,$3 - lw $3,0($2) + lw $3,0($2) move $2,$3 - sll $3,$2,2 - la $4,w + sll $3,$2,2 + la $4,w addu $2,$3,$4 - lw $3,0($2) - lb $4,0($3) - jal is_vowel + lw $3,0($2) + lb $4,0($3) + jal is_vowel move $16,$2 - lw $2,64($fp) + lw $2,64($fp) move $3,$2 - sll $2,$3,2 - la $3,pindex-4 + sll $2,$3,2 + la $3,pindex-4 addu $2,$2,$3 - lw $3,0($2) + lw $3,0($2) move $2,$3 - sll $3,$2,2 - la $4,w + sll $3,$2,2 + la $4,w addu $2,$3,$4 - lw $3,0($2) - lb $4,0($3) - jal is_vowel + lw $3,0($2) + lb $4,0($3) + jal is_vowel move $17,$2 - lw $2,56($fp) + lw $2,56($fp) move $3,$2 - sll $2,$3,2 - la $3,w + sll $2,$3,2 + la $3,w addu $2,$2,$3 - lw $3,0($2) - lb $4,0($3) - jal is_vowel + lw $3,0($2) + lb $4,0($3) + jal is_vowel addu $3,$16,$17 addu $2,$3,$2 - sw $2,24($fp) - beq $2,$0,$L8 - lw $2,24($fp) - li $3,0x00000003 # 3 - bne $2,$3,$L7 + sw $2,24($fp) + beq $2,$0,$L8 + lw $2,24($fp) + li $3,0x00000003 # $3 = 3 + bne $2,$3,$L7 $L8: - j $L4 + j $L4 $L7: $L6: - lw $2,64($fp) + lw $2,64($fp) addu $3,$2,1 - sw $3,64($fp) - sll $3,$2,2 - la $4,pindex + sw $3,64($fp) + sll $3,$2,2 + la $4,pindex addu $2,$3,$4 - lw $3,56($fp) - sw $3,0($2) - lw $2,64($fp) - slt $3,$2,6 - beq $3,$0,$L9 - lw $3,68($fp) + lw $3,56($fp) + sw $3,0($2) + lw $2,64($fp) + slt $3,$2,6 + beq $3,$0,$L9 + lw $3,68($fp) subu $2,$3,1 move $3,$2 - sw $3,68($fp) - beq $3,$0,$L9 - sw $0,16($fp) + sw $3,68($fp) + beq $3,$0,$L9 + sw $0,16($fp) $L10: - lw $2,16($fp) - slt $3,$2,6 - beq $3,$0,$L11 + lw $2,16($fp) + slt $3,$2,6 + beq $3,$0,$L11 $L13: - lw $2,16($fp) + lw $2,16($fp) move $3,$2 - sll $2,$3,2 - lw $3,60($fp) + sll $2,$3,2 + lw $3,60($fp) addu $2,$2,$3 - lw $3,0($2) - bne $3,$0,$L14 - lw $2,16($fp) + lw $3,0($2) + bne $3,$0,$L14 + lw $2,16($fp) move $3,$2 - sll $2,$3,2 - lw $3,60($fp) + sll $2,$3,2 + lw $3,60($fp) addu $2,$2,$3 - li $3,0x00000001 # 1 - sw $3,0($2) - lw $4,16($fp) - lw $5,60($fp) - lw $6,64($fp) - lw $7,68($fp) - jal do_perm - lw $2,16($fp) + li $3,0x00000001 # $3 = 1 + sw $3,0($2) # 0($2) = 1 + lw $4,16($fp) + lw $5,60($fp) + lw $6,64($fp) + lw $7,68($fp) + jal do_perm + lw $2,16($fp) move $3,$2 - sll $2,$3,2 - lw $3,60($fp) + sll $2,$3,2 + lw $3,60($fp) addu $2,$2,$3 - sw $0,0($2) + sw $0,0($2) $L14: $L12: - lw $3,16($fp) + lw $3,16($fp) addu $2,$3,1 move $3,$2 - sw $3,16($fp) - j $L10 + sw $3,16($fp) + j $L10 $L11: - j $L15 + j $L15 $L9: - sw $0,28($fp) - sw $0,20($fp) + sw $0,28($fp) + sw $0,20($fp) $L16: - lw $2,20($fp) - lw $3,64($fp) - slt $2,$2,$3 - beq $2,$0,$L17 + lw $2,20($fp) + lw $3,64($fp) + slt $2,$2,$3 + beq $2,$0,$L17 $L19: - sw $0,32($fp) + sw $0,32($fp) $L20: - lw $2,20($fp) + lw $2,20($fp) move $3,$2 - sll $2,$3,2 - la $3,pindex + sll $2,$3,2 + la $3,pindex addu $2,$2,$3 - lw $3,0($2) + lw $3,0($2) move $2,$3 - sll $3,$2,2 - la $4,w + sll $3,$2,2 + la $4,w addu $2,$3,$4 - lw $3,0($2) - lw $4,32($fp) + lw $3,0($2) + lw $4,32($fp) addu $2,$3,$4 - lb $4,0($2) - jal isupper - beq $2,$0,$L21 + lb $4,0($2) + jal isupper + beq $2,$0,$L21 $L22: - lw $2,28($fp) + lw $2,28($fp) addu $3,$2,1 - sw $3,28($fp) - lw $3,20($fp) + sw $3,28($fp) + lw $3,20($fp) move $4,$3 - sll $3,$4,2 - la $4,pindex + sll $3,$4,2 + la $4,pindex addu $3,$3,$4 - lw $4,0($3) + lw $4,0($3) move $3,$4 - sll $4,$3,2 - la $5,w + sll $4,$3,2 + la $5,w addu $3,$4,$5 - lw $4,32($fp) + lw $4,32($fp) addu $5,$4,1 - sw $5,32($fp) - lw $5,0($3) + sw $5,32($fp) + lw $5,0($3) addu $3,$4,$5 - lbu $4,0($3) - sb $4,acron($2) - j $L20 + lbu $4,0($3) + sb $4,acron($2) + j $L20 $L21: $L18: - lw $3,20($fp) + lw $3,20($fp) addu $2,$3,1 move $3,$2 - sw $3,20($fp) - j $L16 + sw $3,20($fp) + j $L16 $L17: - lw $2,28($fp) - la $3,acron + lw $2,28($fp) + la $3,acron addu $2,$2,$3 - sb $0,0($2) - la $4,$LC6 - la $5,acron - jal printf - sw $0,20($fp) + sb $0,0($2) + la $4,$LC6 + la $5,acron + jal printf + sw $0,20($fp) $L23: - lw $2,20($fp) - lw $3,64($fp) - slt $2,$2,$3 - beq $2,$0,$L24 + lw $2,20($fp) + lw $3,64($fp) + slt $2,$2,$3 + beq $2,$0,$L24 $L26: - lw $2,20($fp) + lw $2,20($fp) move $3,$2 - sll $2,$3,2 - la $3,pindex + sll $2,$3,2 + la $3,pindex addu $2,$2,$3 - lw $3,0($2) + lw $3,0($2) move $2,$3 - sll $3,$2,2 - la $4,w + sll $3,$2,2 + la $4,w addu $2,$3,$4 - la $4,$LC7 - lw $5,0($2) - jal printf + la $4,$LC7 + lw $5,0($2) + jal printf $L25: - lw $3,20($fp) + lw $3,20($fp) addu $2,$3,1 move $3,$2 - sw $3,20($fp) - j $L23 + sw $3,20($fp) + j $L23 $L24: - la $4,$LC8 - jal printf + la $4,$LC8 + jal printf $L15: $L4: move $sp,$fp # sp not trusted here - lw $31,52($sp) - lw $fp,48($sp) - lw $17,44($sp) - lw $16,40($sp) + lw $31,52($sp) + lw $fp,48($sp) + lw $17,44($sp) + lw $16,40($sp) addu $sp,$sp,56 - j $31 + j $31 .end do_perm .loc 1 53 .ent main @@ -354,59 +356,59 @@ main: .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,32 - sw $31,28($sp) - sw $fp,24($sp) + sw $31,28($sp) + sw $fp,24($sp) move $fp,$sp - jal __main - li $2,0x00000004 # 4 - sw $2,20($fp) + jal __main + li $2,0x00000004 # $2 = 4 + sw $2,20($fp) # 20($fp) = 4 $L28: - lw $2,20($fp) - slt $3,$2,7 - beq $3,$0,$L29 + lw $2,20($fp) + slt $3,$2,7 + beq $3,$0,$L29 $L31: - sw $0,16($fp) + sw $0,16($fp) $L32: - lw $2,16($fp) - slt $3,$2,6 - beq $3,$0,$L33 + lw $2,16($fp) + slt $3,$2,6 + beq $3,$0,$L33 $L35: - lw $2,16($fp) + lw $2,16($fp) move $3,$2 - sll $2,$3,2 - la $3,done + sll $2,$3,2 + la $3,done addu $2,$2,$3 - li $3,0x00000001 # 1 - sw $3,0($2) - lw $4,16($fp) - la $5,done + li $3,0x00000001 # $3 = 1 + sw $3,0($2) # 0($2) = 1 + lw $4,16($fp) + la $5,done move $6,$0 - lw $7,20($fp) - jal do_perm - lw $2,16($fp) + lw $7,20($fp) + jal do_perm + lw $2,16($fp) move $3,$2 - sll $2,$3,2 - la $3,done + sll $2,$3,2 + la $3,done addu $2,$2,$3 - sw $0,0($2) + sw $0,0($2) $L34: - lw $3,16($fp) + lw $3,16($fp) addu $2,$3,1 move $3,$2 - sw $3,16($fp) - j $L32 + sw $3,16($fp) + j $L32 $L33: $L30: - lw $3,20($fp) + lw $3,20($fp) addu $2,$3,1 move $3,$2 - sw $3,20($fp) - j $L28 + sw $3,20($fp) + j $L28 $L29: $L27: move $sp,$fp # sp not trusted here - lw $31,28($sp) - lw $fp,24($sp) + lw $31,28($sp) + lw $fp,24($sp) addu $sp,$sp,32 - j $31 + j $31 .end main diff --git a/benchmarks/optimized/dhrystone.s b/benchmarks/optimized/dhrystone.s index ef06a43..9b56d3c 100644 --- a/benchmarks/optimized/dhrystone.s +++ b/benchmarks/optimized/dhrystone.s @@ -1,9 +1,11 @@ .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 # Cc1 defaults: # -mgas -mgpOPT # Cc1 arguments (-G value = 8, Cpu = default, ISA = 1): # -quiet -dumpbase -O0 -o + gcc2_compiled.: __gnu_compiled_c: .globl Version @@ -71,19 +73,19 @@ main: .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,24 - sw $31,20($sp) - sw $fp,16($sp) + sw $31,20($sp) + sw $fp,16($sp) move $fp,$sp - jal __main - jal Proc0 + jal __main + jal Proc0 move $4,$0 - jal exit + jal exit $L1: move $sp,$fp # sp not trusted here - lw $31,20($sp) - lw $fp,16($sp) + lw $31,20($sp) + lw $fp,16($sp) addu $sp,$sp,24 - j $31 + j $31 .end main .loc 1 432 .ent Proc0 @@ -92,203 +94,200 @@ Proc0: .mask 0xc0010000,-8 .fmask 0x00000000,0 subu $sp,$sp,152 - sw $31,144($sp) - sw $fp,140($sp) - sw $16,136($sp) + sw $31,144($sp) + sw $fp,140($sp) + sw $16,136($sp) move $fp,$sp - addu $4,$fp,120 - jal times - lw $2,120($fp) - sw $2,104($fp) + addu $4,$sp,120 + jal times + lw $2,120($fp) + sw $2,104($fp) move $16,$0 $L3: sltu $2,$16,5000 - beq $2,$0,$L4 + beq $2,$0,$L4 $L6: $L5: addu $16,$16,1 - j $L3 + j $L3 $L4: addu $4,$fp,120 - jal times - lw $2,120($fp) - lw $3,104($fp) + jal times + lw $2,120($fp) + lw $3,104($fp) subu $2,$2,$3 - sw $2,112($fp) - li $4,0x00000030 # 48 - jal malloc - sw $2,PtrGlbNext - li $4,0x00000030 # 48 - jal malloc - sw $2,PtrGlb - lw $2,PtrGlb - lw $3,PtrGlbNext - sw $3,0($2) - lw $2,PtrGlb - sw $0,4($2) - lw $2,PtrGlb - li $3,0x00000002 # 2 - sw $3,8($2) - lw $2,PtrGlb - li $3,0x00000028 # 40 - sw $3,12($2) - lw $3,PtrGlb + sw $2,112($fp) + li $4,0x00000030 # $4 = 48 + jal malloc + sw $2,PtrGlbNext + li $4,0x00000030 # $4 = 48 + jal malloc + sw $2,PtrGlb + lw $3,PtrGlbNext + sw $3,0($2) + lw $2,PtrGlb + sw $0,4($2) + lw $2,PtrGlb + li $3,0x00000002 # $3 = 2 + sw $3,8($2) # 8($2) = 2 + lw $2,PtrGlb + li $3,0x00000028 # $3 = 40 + sw $3,12($2) # 12($2) = 40 + lw $3,PtrGlb # $3 = unknown addu $2,$3,16 move $4,$2 - la $5,$LC0 - jal strcpy + la $5,$LC0 + jal strcpy addu $2,$fp,40 move $4,$2 - la $5,$LC1 - jal strcpy - li $2,0x0000000a # 10 - sw $2,Array2Glob+1660 + la $5,$LC1 + jal strcpy + li $2,0x0000000a # $2 = 10 + sw $2,Array2Glob+1660 # Array2Glob+1660 = 10 addu $4,$fp,120 - jal times - lw $2,120($fp) - sw $2,104($fp) + jal times + lw $2,120($fp) + sw $2,104($fp) move $16,$0 $L7: sltu $2,$16,5000 - beq $2,$0,$L8 + beq $2,$0,$L8 $L10: - jal Proc5 - jal Proc4 - li $2,0x00000002 # 2 - sw $2,16($fp) - li $2,0x00000003 # 3 - sw $2,20($fp) + jal Proc5 + jal Proc4 + li $2,0x00000002 # $2 = 2 + sw $2,16($fp) # 16($fp) = 2 + li $2,0x00000003 # $2 = 3 + sw $2,20($fp) # 20($fp) = 3 addu $2,$fp,72 move $4,$2 - la $5,$LC2 - jal strcpy - li $2,0x00000001 # 1 - sw $2,32($fp) + la $5,$LC2 + jal strcpy + li $2,0x00000001 # $2 = 1 + sw $2,32($fp) # 32($fp) = 1 addu $2,$fp,40 addu $3,$fp,72 move $4,$2 move $5,$3 - jal Func2 + jal Func2 xori $3,$2,0x0000 sltu $2,$3,1 - sw $2,BoolGlob + sw $2,BoolGlob $L11: - lw $2,16($fp) - lw $3,20($fp) - slt $2,$2,$3 - beq $2,$0,$L12 + lw $2,16($fp) + lw $3,20($fp) + slt $2,$2,$3 + beq $2,$0,$L12 $L13: - lw $2,16($fp) - move $4,$2 - sll $3,$4,2 + lw $2,16($fp) + # Dead code: move $4, $2 + sll $3,$2,2 addu $3,$3,$2 - lw $2,20($fp) + lw $2,20($fp) subu $3,$3,$2 - sw $3,24($fp) + sw $3,24($fp) addu $2,$fp,24 - lw $4,16($fp) - lw $5,20($fp) + lw $4,16($fp) + lw $5,20($fp) move $6,$2 - jal Proc7 - lw $3,16($fp) + jal Proc7 + lw $3,16($fp) addu $2,$3,1 move $3,$2 - sw $3,16($fp) - j $L11 + sw $3,16($fp) + j $L11 $L12: - la $4,Array1Glob - la $5,Array2Glob - lw $6,16($fp) - lw $7,24($fp) - jal Proc8 - lw $4,PtrGlb - jal Proc1 - li $2,0x00000041 # 65 - sb $2,29($fp) + la $4,Array1Glob + la $5,Array2Glob + lw $6,16($fp) + lw $7,24($fp) + jal Proc8 + lw $4,PtrGlb + jal Proc1 + li $2,0x00000041 # $2 = 65 + sb $2,29($fp) $L14: - lb $2,29($fp) - lb $3,Char2Glob - slt $2,$3,$2 - bne $2,$0,$L15 + lb $2,29($fp) + lb $3,Char2Glob + slt $2,$3,$2 + bne $2,$0,$L15 $L17: - lb $2,29($fp) + lb $2,29($fp) move $4,$2 - li $5,0x00000043 # 67 - jal Func1 - lw $3,32($fp) - bne $3,$2,$L18 + li $5,0x00000043 # $5 = 67 + jal Func1 + lw $3,32($fp) + bne $3,$2,$L18 addu $2,$fp,32 move $4,$0 move $5,$2 - jal Proc6 + jal Proc6 $L18: $L16: - lbu $2,29($fp) + lbu $2,29($fp) addu $3,$2,1 move $2,$3 - sb $2,29($fp) - j $L14 + sb $2,29($fp) + j $L14 $L15: - lw $2,20($fp) - lw $3,16($fp) + lw $2,20($fp) + lw $3,16($fp) mult $2,$3 mflo $2 - sw $2,24($fp) - lw $2,24($fp) - lw $3,16($fp) - div $2,$2,$3 - sw $2,20($fp) - lw $2,24($fp) - lw $3,20($fp) + sw $2,24($fp) + lw $3,16($fp) + div $2,$2,$3 + sw $2,20($fp) + lw $2,24($fp) + lw $3,20($fp) subu $2,$2,$3 - move $4,$2 - sll $3,$4,3 + # Dead code: move $4, $2 + sll $3,$2,3 subu $3,$3,$2 - lw $2,16($fp) + lw $2,16($fp) subu $3,$3,$2 - sw $3,20($fp) + sw $3,20($fp) addu $4,$fp,16 - jal Proc2 + jal Proc2 $L9: addu $16,$16,1 - j $L7 + j $L7 $L8: addu $4,$fp,120 - jal times - lw $2,120($fp) - lw $3,104($fp) + jal times + lw $2,120($fp) + lw $3,104($fp) subu $2,$2,$3 - lw $3,112($fp) + lw $3,112($fp) subu $2,$2,$3 - sw $2,108($fp) - lw $2,108($fp) - li $6,0x51eb851f # 1374389535 + sw $2,108($fp) + li $6,0x51eb851f # $6 = 1374389535 mult $2,$6 mfhi $5 - mflo $4 - srl $6,$5,0 - move $7,$0 - sra $3,$6,5 - sra $4,$2,31 + # Dead code: mflo $4 + srl $6,$5,0 # $6 = unknown + # Dead code: move $7, $0 + sra $3,$6,5 + sra $4,$2,31 subu $2,$3,$4 - la $4,$LC3 - la $5,Version - li $6,0x00001388 # 5000 + la $4,$LC3 + la $5,Version + li $6,0x00001388 # $6 = 5000 move $7,$2 - jal printf - li $2,0x0007a120 # 500000 - lw $3,108($fp) - div $2,$2,$3 - la $4,$LC4 + jal printf + li $2,0x0007a120 # $2 = 500000 + lw $3,108($fp) + div $2,$2,$3 + la $4,$LC4 move $5,$2 - jal printf + jal printf $L2: move $sp,$fp # sp not trusted here - lw $31,144($sp) - lw $fp,140($sp) - lw $16,136($sp) + lw $31,144($sp) + lw $fp,140($sp) + lw $16,136($sp) addu $sp,$sp,152 - j $31 + j $31 .end Proc0 .loc 1 540 .ent Proc1 @@ -297,80 +296,80 @@ Proc1: .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,24 - sw $31,20($sp) - sw $fp,16($sp) + sw $31,20($sp) + sw $fp,16($sp) move $fp,$sp - sw $4,24($fp) - lw $2,24($fp) - lw $3,0($2) - lw $2,PtrGlb + sw $4,24($fp) + lw $2,24($fp) + lw $3,0($2) + lw $2,PtrGlb move $4,$3 move $5,$2 - li $6,0x00000030 # 48 - jal memcpy - lw $2,24($fp) - li $3,0x00000005 # 5 - sw $3,12($2) - lw $3,24($fp) - lw $2,0($3) - lw $3,24($fp) - lw $4,12($3) - sw $4,12($2) - lw $3,24($fp) - lw $2,0($3) - lw $3,24($fp) - lw $4,0($3) - sw $4,0($2) - lw $2,24($fp) - lw $3,0($2) - lw $4,0($3) - jal Proc3 - lw $2,24($fp) - lw $3,0($2) - lw $2,4($3) - bne $2,$0,$L20 - lw $2,24($fp) - lw $3,0($2) - li $2,0x00000006 # 6 - sw $2,12($3) - lw $2,24($fp) - lw $3,24($fp) - lw $4,0($3) + li $6,0x00000030 # $6 = 48 + jal memcpy + lw $2,24($fp) + li $3,0x00000005 # $3 = 5 + sw $3,12($2) # 12($2) = 5 + lw $3,24($fp) # $3 = unknown + lw $2,0($3) + lw $3,24($fp) + lw $4,12($3) + sw $4,12($2) + lw $3,24($fp) + lw $2,0($3) + lw $3,24($fp) + lw $4,0($3) + sw $4,0($2) + lw $2,24($fp) + lw $3,0($2) + lw $4,0($3) + jal Proc3 + lw $2,24($fp) + lw $3,0($2) + lw $2,4($3) + bne $2,$0,$L20 + lw $2,24($fp) + lw $3,0($2) + li $2,0x00000006 # $2 = 6 + sw $2,12($3) # 12($3) = 6 + lw $2,24($fp) # $2 = unknown + lw $3,24($fp) + lw $4,0($3) addu $3,$4,8 - lw $4,8($2) + lw $4,8($2) move $5,$3 - jal Proc6 - lw $3,24($fp) - lw $2,0($3) - lw $3,PtrGlb - lw $4,0($3) - sw $4,0($2) - lw $3,24($fp) - lw $2,0($3) - lw $3,24($fp) - lw $4,0($3) + jal Proc6 + lw $3,24($fp) + lw $2,0($3) + lw $3,PtrGlb + lw $4,0($3) + sw $4,0($2) + lw $3,24($fp) + lw $2,0($3) + lw $3,24($fp) + lw $4,0($3) addu $3,$4,12 - lw $4,12($2) - li $5,0x0000000a # 10 + lw $4,12($2) + li $5,0x0000000a # $5 = 10 move $6,$3 - jal Proc7 - j $L21 + jal Proc7 + j $L21 $L20: - lw $2,24($fp) - lw $3,24($fp) - lw $4,0($3) + lw $2,24($fp) + lw $3,24($fp) + lw $4,0($3) move $3,$4 move $4,$2 move $5,$3 - li $6,0x00000030 # 48 - jal memcpy + li $6,0x00000030 # $6 = 48 + jal memcpy $L21: $L19: move $sp,$fp # sp not trusted here - lw $31,20($sp) - lw $fp,16($sp) + lw $31,20($sp) + lw $fp,16($sp) addu $sp,$sp,24 - j $31 + j $31 .end Proc1 .loc 1 563 .ent Proc2 @@ -379,39 +378,39 @@ Proc2: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,16 - sw $fp,8($sp) + sw $fp,8($sp) move $fp,$sp - sw $4,16($fp) - lw $2,16($fp) - lw $3,0($2) + sw $4,16($fp) + lw $2,16($fp) + lw $3,0($2) addu $2,$3,10 - sw $2,0($fp) + sw $2,0($fp) $L23: - lb $2,Char1Glob - li $3,0x00000041 # 65 - bne $2,$3,$L26 - lw $3,0($fp) + lb $2,Char1Glob + li $3,0x00000041 # $3 = 65 + bne $2,$3,$L26 + lw $3,0($fp) subu $2,$3,1 move $3,$2 - sw $3,0($fp) - lw $2,16($fp) - lw $3,0($fp) - lw $4,IntGlob + sw $3,0($fp) + lw $2,16($fp) + lw $3,0($fp) + lw $4,IntGlob subu $3,$3,$4 - sw $3,0($2) - sw $0,4($fp) + sw $3,0($2) + sw $0,4($fp) $L26: - lw $2,4($fp) - beq $2,$0,$L24 + lw $2,4($fp) + beq $2,$0,$L24 $L27: $L25: - j $L23 + j $L23 $L24: $L22: move $sp,$fp # sp not trusted here - lw $fp,8($sp) + lw $fp,8($sp) addu $sp,$sp,16 - j $31 + j $31 .end Proc2 .loc 1 583 .ent Proc3 @@ -420,33 +419,33 @@ Proc3: .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,24 - sw $31,20($sp) - sw $fp,16($sp) + sw $31,20($sp) + sw $fp,16($sp) move $fp,$sp - sw $4,24($fp) - lw $2,PtrGlb - beq $2,$0,$L29 - lw $2,24($fp) - lw $3,PtrGlb - lw $4,0($3) - sw $4,0($2) - j $L30 + sw $4,24($fp) + lw $2,PtrGlb + beq $2,$0,$L29 + lw $2,24($fp) + lw $3,PtrGlb + lw $4,0($3) + sw $4,0($2) + j $L30 $L29: - li $2,0x00000064 # 100 - sw $2,IntGlob + li $2,0x00000064 # $2 = 100 + sw $2,IntGlob # IntGlob = 100 $L30: - lw $3,PtrGlb + lw $3,PtrGlb addu $2,$3,12 - li $4,0x0000000a # 10 - lw $5,IntGlob + li $4,0x0000000a # $4 = 10 + lw $5,IntGlob move $6,$2 - jal Proc7 + jal Proc7 $L28: move $sp,$fp # sp not trusted here - lw $31,20($sp) - lw $fp,16($sp) + lw $31,20($sp) + lw $fp,16($sp) addu $sp,$sp,24 - j $31 + j $31 .end Proc3 .loc 1 593 .ent Proc4 @@ -455,23 +454,22 @@ Proc4: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,16 - sw $fp,8($sp) + sw $fp,8($sp) move $fp,$sp - lb $2,Char1Glob + lb $2,Char1Glob xori $3,$2,0x0041 sltu $2,$3,1 - sw $2,0($fp) - lw $2,0($fp) - lw $3,BoolGlob - or $2,$2,$3 - sw $2,0($fp) - li $2,0x00000042 # 66 - sb $2,Char2Glob + sw $2,0($fp) + lw $3,BoolGlob + or $2,$2,$3 + sw $2,0($fp) + li $2,0x00000042 # $2 = 66 + sb $2,Char2Glob $L31: move $sp,$fp # sp not trusted here - lw $fp,8($sp) + lw $fp,8($sp) addu $sp,$sp,16 - j $31 + j $31 .end Proc4 .loc 1 602 .ent Proc5 @@ -480,16 +478,16 @@ Proc5: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,8 - sw $fp,0($sp) + sw $fp,0($sp) move $fp,$sp - li $2,0x00000041 # 65 - sb $2,Char1Glob - sw $0,BoolGlob + li $2,0x00000041 # $2 = 65 + sb $2,Char1Glob + sw $0,BoolGlob $L32: move $sp,$fp # sp not trusted here - lw $fp,0($sp) + lw $fp,0($sp) addu $sp,$sp,8 - j $31 + j $31 .end Proc5 .loc 1 610 .ent Proc6 @@ -498,31 +496,31 @@ Proc6: .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,24 - sw $31,20($sp) - sw $fp,16($sp) + sw $31,20($sp) + sw $fp,16($sp) move $fp,$sp - sw $4,24($fp) - sw $5,28($fp) - lw $2,28($fp) - lw $3,24($fp) - sw $3,0($2) - lw $4,24($fp) - jal Func3 - bne $2,$0,$L34 - lw $2,28($fp) - li $3,0x00000003 # 3 - sw $3,0($2) + sw $4,24($fp) + sw $5,28($fp) + lw $2,28($fp) + lw $3,24($fp) + sw $3,0($2) + lw $4,24($fp) + jal Func3 + bne $2,$0,$L34 + lw $2,28($fp) + li $3,0x00000003 # $3 = 3 + sw $3,0($2) # 0($2) = 3 $L34: - lw $2,24($fp) + lw $2,24($fp) sltu $3,$2,5 - beq $3,$0,$L44 - lw $2,24($fp) + beq $3,$0,$L44 + lw $2,24($fp) move $3,$2 - sll $2,$3,2 - la $3,$L43 + sll $2,$3,2 + la $3,$L43 addu $2,$2,$3 - lw $3,0($2) - j $3 + lw $3,0($2) + j $3 .rdata .align 3 .align 2 @@ -534,41 +532,41 @@ $L43: .word $L42 .text $L36: - lw $2,28($fp) - sw $0,0($2) - j $L35 + lw $2,28($fp) + sw $0,0($2) + j $L35 $L37: - lw $2,IntGlob - slt $3,$2,101 - bne $3,$0,$L38 - lw $2,28($fp) - sw $0,0($2) - j $L39 + lw $2,IntGlob + slt $3,$2,101 + bne $3,$0,$L38 + lw $2,28($fp) + sw $0,0($2) + j $L39 $L38: - lw $2,28($fp) - li $3,0x00000003 # 3 - sw $3,0($2) + lw $2,28($fp) + li $3,0x00000003 # $3 = 3 + sw $3,0($2) # 0($2) = 3 $L39: - j $L35 + j $L35 $L40: - lw $2,28($fp) - li $3,0x00000001 # 1 - sw $3,0($2) - j $L35 + lw $2,28($fp) + li $3,0x00000001 # $3 = 1 + sw $3,0($2) # 0($2) = 1 + j $L35 $L41: - j $L35 + j $L35 $L42: - lw $2,28($fp) - li $3,0x00000002 # 2 - sw $3,0($2) + lw $2,28($fp) + li $3,0x00000002 # $3 = 2 + sw $3,0($2) # 0($2) = 2 $L44: $L35: $L33: move $sp,$fp # sp not trusted here - lw $31,20($sp) - lw $fp,16($sp) + lw $31,20($sp) + lw $fp,16($sp) addu $sp,$sp,24 - j $31 + j $31 .end Proc6 .loc 1 629 .ent Proc7 @@ -577,24 +575,24 @@ Proc7: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,16 - sw $fp,8($sp) + sw $fp,8($sp) move $fp,$sp - sw $4,16($fp) - sw $5,20($fp) - sw $6,24($fp) - lw $2,16($fp) + sw $4,16($fp) + sw $5,20($fp) + sw $6,24($fp) + lw $2,16($fp) addu $3,$2,2 - sw $3,0($fp) - lw $2,24($fp) - lw $3,20($fp) - lw $4,0($fp) + sw $3,0($fp) + lw $2,24($fp) + lw $3,20($fp) + lw $4,0($fp) addu $3,$3,$4 - sw $3,0($2) + sw $3,0($2) $L45: move $sp,$fp # sp not trusted here - lw $fp,8($sp) + lw $fp,8($sp) addu $sp,$sp,16 - j $31 + j $31 .end Proc7 .loc 1 640 .ent Proc8 @@ -603,148 +601,148 @@ Proc8: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,16 - sw $fp,8($sp) + sw $fp,8($sp) move $fp,$sp - sw $4,16($fp) - sw $5,20($fp) - sw $6,24($fp) - sw $7,28($fp) - lw $2,24($fp) + sw $4,16($fp) + sw $5,20($fp) + sw $6,24($fp) + sw $7,28($fp) + lw $2,24($fp) addu $3,$2,5 - sw $3,0($fp) - lw $2,0($fp) + sw $3,0($fp) + lw $2,0($fp) move $3,$2 - sll $2,$3,2 - lw $3,16($fp) + sll $2,$3,2 + lw $3,16($fp) addu $2,$2,$3 - lw $3,28($fp) - sw $3,0($2) - lw $2,0($fp) + lw $3,28($fp) + sw $3,0($2) + lw $2,0($fp) move $3,$2 - sll $2,$3,2 - lw $4,16($fp) + sll $2,$3,2 + lw $4,16($fp) addu $3,$2,$4 addu $2,$3,4 - lw $3,0($fp) + lw $3,0($fp) move $4,$3 - sll $3,$4,2 - lw $4,16($fp) + sll $3,$4,2 + lw $4,16($fp) addu $3,$3,$4 - lw $4,0($3) - sw $4,0($2) - lw $2,0($fp) + lw $4,0($3) + sw $4,0($2) + lw $2,0($fp) move $3,$2 - sll $2,$3,2 - lw $3,16($fp) + sll $2,$3,2 + lw $3,16($fp) addu $2,$2,$3 addu $3,$2,120 - lw $2,0($fp) - sw $2,0($3) - lw $2,0($fp) - sw $2,4($fp) + lw $2,0($fp) + sw $2,0($3) + lw $2,0($fp) + sw $2,4($fp) $L47: - lw $3,0($fp) + lw $3,0($fp) addu $2,$3,1 - lw $3,4($fp) - slt $2,$2,$3 - bne $2,$0,$L48 + lw $3,4($fp) + slt $2,$2,$3 + bne $2,$0,$L48 $L50: - lw $3,0($fp) - lw $2,4($fp) + lw $3,0($fp) + lw $2,4($fp) move $4,$2 - sll $2,$4,2 + sll $2,$4,2 move $5,$3 - sll $4,$5,1 + sll $4,$3,1 addu $4,$4,$3 - sll $3,$4,4 + sll $3,$4,4 addu $4,$4,$3 - sll $3,$4,2 - lw $4,20($fp) + sll $3,$4,2 + lw $4,20($fp) addu $3,$3,$4 addu $2,$2,$3 - lw $3,0($fp) - sw $3,0($2) + lw $3,0($fp) + sw $3,0($2) $L49: - lw $3,4($fp) + lw $3,4($fp) addu $2,$3,1 move $3,$2 - sw $3,4($fp) - j $L47 + sw $3,4($fp) + j $L47 $L48: - lw $3,0($fp) - lw $2,0($fp) + # Dead code: lw $3, 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 - sll $2,$4,2 - move $5,$3 - sll $4,$5,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 + sll $2,$4,2 + # Dead code: move $5, $3 + sll $4,$3,1 addu $4,$4,$3 - sll $3,$4,4 + sll $3,$4,4 addu $4,$4,$3 - sll $3,$4,2 - lw $4,20($fp) + sll $3,$4,2 + lw $4,20($fp) addu $3,$3,$4 addu $4,$2,$3 subu $2,$4,4 - lw $4,0($fp) - lw $3,0($fp) + lw $4,0($fp) + lw $3,0($fp) move $5,$3 - sll $3,$5,2 + sll $3,$5,2 move $6,$4 - sll $5,$6,1 + sll $5,$4,1 addu $5,$5,$4 - sll $4,$5,4 + sll $4,$5,4 addu $5,$5,$4 - sll $4,$5,2 - lw $5,20($fp) + sll $4,$5,2 + lw $5,20($fp) addu $4,$4,$5 addu $3,$3,$4 subu $4,$3,4 - lw $5,0($4) + lw $5,0($4) addu $3,$5,1 move $4,$3 - sw $4,0($2) - lw $3,0($fp) - lw $2,0($fp) + sw $4,0($2) + lw $3,0($fp) + lw $2,0($fp) move $4,$2 - sll $2,$4,2 + sll $2,$4,2 move $5,$3 - sll $4,$5,1 + sll $4,$5,1 addu $4,$4,$3 - sll $3,$4,4 + sll $3,$4,4 addu $4,$4,$3 - sll $3,$4,2 - lw $4,20($fp) + sll $3,$4,2 + lw $4,20($fp) addu $3,$3,$4 addu $4,$2,$3 addu $2,$4,4080 - lw $3,0($fp) + lw $3,0($fp) move $4,$3 - sll $3,$4,2 - lw $4,16($fp) + sll $3,$4,2 + lw $4,16($fp) addu $3,$3,$4 - lw $4,0($3) - sw $4,0($2) - li $2,0x00000005 # 5 - sw $2,IntGlob + lw $4,0($3) + sw $4,0($2) + li $2,0x00000005 # $2 = 5 + sw $2,IntGlob # IntGlob = 5 $L46: move $sp,$fp # sp not trusted here - lw $fp,8($sp) + lw $fp,8($sp) addu $sp,$sp,16 - j $31 + j $31 .end Proc8 .loc 1 660 .ent Func1 @@ -753,31 +751,31 @@ Func1: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,16 - sw $fp,8($sp) + sw $fp,8($sp) move $fp,$sp move $3,$4 move $4,$5 - sb $3,0($fp) - sb $4,1($fp) - lbu $2,0($fp) - sb $2,2($fp) - lbu $2,2($fp) - sb $2,3($fp) - lb $2,3($fp) - lb $5,1($fp) - beq $2,$5,$L52 + sb $3,0($fp) + sb $4,1($fp) + lbu $2,0($fp) + sb $2,2($fp) + lbu $2,2($fp) + sb $2,3($fp) + lb $2,3($fp) + lb $5,1($fp) + beq $2,$5,$L52 move $2,$0 - j $L51 - j $L53 + j $L51 + j $L53 $L52: - li $2,0x00000001 # 1 - j $L51 + li $2,0x00000001 # $2 = 1 + j $L51 $L53: $L51: move $sp,$fp # sp not trusted here - lw $fp,8($sp) + lw $fp,8($sp) addu $sp,$sp,16 - j $31 + j $31 .end Func1 .loc 1 675 .ent Func2 @@ -786,77 +784,77 @@ Func2: .mask 0xc0000000,-4 .fmask 0x00000000,0 subu $sp,$sp,32 - sw $31,28($sp) - sw $fp,24($sp) + sw $31,28($sp) + sw $fp,24($sp) move $fp,$sp - sw $4,32($fp) - sw $5,36($fp) - li $2,0x00000001 # 1 - sw $2,16($fp) + sw $4,32($fp) + sw $5,36($fp) + li $2,0x00000001 # $2 = 1 + sw $2,16($fp) # 16($fp) = 1 $L55: - lw $2,16($fp) - slt $3,$2,2 - beq $3,$0,$L56 + lw $2,16($fp) + slt $3,$2,2 + beq $3,$0,$L56 $L57: - lw $2,32($fp) - lw $4,16($fp) + lw $2,32($fp) + lw $4,16($fp) addu $3,$2,$4 - lb $2,0($3) - lw $3,16($fp) - lw $4,36($fp) + lb $2,0($3) + lw $3,16($fp) + lw $4,36($fp) addu $3,$3,$4 addu $4,$3,1 - lb $3,0($4) + lb $3,0($4) move $4,$2 move $5,$3 - jal Func1 - bne $2,$0,$L58 - li $2,0x00000041 # 65 - sb $2,20($fp) - lw $3,16($fp) + jal Func1 + bne $2,$0,$L58 + li $2,0x00000041 # $2 = 65 + sb $2,20($fp) + lw $3,16($fp) addu $2,$3,1 move $3,$2 - sw $3,16($fp) + sw $3,16($fp) $L58: - j $L55 + j $L55 $L56: - lb $2,20($fp) - slt $3,$2,87 - bne $3,$0,$L59 - lb $2,20($fp) - slt $3,$2,91 - beq $3,$0,$L59 - li $2,0x00000007 # 7 - sw $2,16($fp) + lb $2,20($fp) + slt $3,$2,87 + bne $3,$0,$L59 + lb $2,20($fp) + slt $3,$2,91 + beq $3,$0,$L59 + li $2,0x00000007 # $2 = 7 + sw $2,16($fp) # 16($fp) = 7 $L59: - lb $2,20($fp) - li $3,0x00000058 # 88 - bne $2,$3,$L60 - li $2,0x00000001 # 1 - j $L54 - j $L61 + lb $2,20($fp) + li $3,0x00000058 # $3 = 88 + bne $2,$3,$L60 + li $2,0x00000001 # $2 = 1 + j $L54 + j $L61 $L60: - lw $4,32($fp) - lw $5,36($fp) - jal strcmp + lw $4,32($fp) + lw $5,36($fp) + jal strcmp blez $2,$L62 - lw $2,16($fp) + lw $2,16($fp) addu $3,$2,7 - sw $3,16($fp) - li $2,0x00000001 # 1 - j $L54 - j $L63 + sw $3,16($fp) + li $2,0x00000001 # $2 = 1 + j $L54 + j $L63 $L62: move $2,$0 - j $L54 + j $L54 $L63: $L61: $L54: move $sp,$fp # sp not trusted here - lw $31,28($sp) - lw $fp,24($sp) + lw $31,28($sp) + lw $fp,24($sp) addu $sp,$sp,32 - j $31 + j $31 .end Func2 .loc 1 705 .ent Func3 @@ -865,22 +863,21 @@ Func3: .mask 0x40000000,-8 .fmask 0x00000000,0 subu $sp,$sp,16 - sw $fp,8($sp) + sw $fp,8($sp) move $fp,$sp - sw $4,16($fp) - lw $2,16($fp) - sw $2,0($fp) - lw $2,0($fp) - li $3,0x00000002 # 2 - bne $2,$3,$L65 - li $2,0x00000001 # 1 - j $L64 + sw $4,16($fp) + lw $2,16($fp) + sw $2,0($fp) + li $3,0x00000002 # $3 = 2 + bne $2,$3,$L65 + li $2,0x00000001 # $2 = 1 + j $L64 $L65: move $2,$0 - j $L64 + j $L64 $L64: move $sp,$fp # sp not trusted here - lw $fp,8($sp) + lw $fp,8($sp) addu $sp,$sp,16 - j $31 - .end Func3 \ No newline at end of file + j $31 + .end Func3 diff --git a/tests/test_statement.py b/tests/test_statement.py index 7618c36..63eaa4e 100644 --- a/tests/test_statement.py +++ b/tests/test_statement.py @@ -148,6 +148,8 @@ class TestStatement(unittest.TestCase): arg2) self.assertEqual(S('command', 's.s', '$1', '10($2)').get_use(), \ arg2) + self.assertEqual(S('command', 'sw', '$1', '10($2)').get_use(), \ + arg2) self.assertEqual(S('command', 'sb', '$1', '10($2)').get_use(), \ arg2) self.assertEqual(S('command', 'mtc1', '$1', '$2').get_use(), arg1) -- GitLab