aboutsummaryrefslogtreecommitdiff
path: root/snug-clean/src/MIPS
diff options
context:
space:
mode:
Diffstat (limited to 'snug-clean/src/MIPS')
-rw-r--r--snug-clean/src/MIPS/MIPS32.dcl4
-rw-r--r--snug-clean/src/MIPS/MIPS32.icl27
2 files changed, 17 insertions, 14 deletions
diff --git a/snug-clean/src/MIPS/MIPS32.dcl b/snug-clean/src/MIPS/MIPS32.dcl
index 83f15cb..cda120e 100644
--- a/snug-clean/src/MIPS/MIPS32.dcl
+++ b/snug-clean/src/MIPS/MIPS32.dcl
@@ -37,8 +37,8 @@ instance toString Line
| XorWord !DestinationRegister !SourceRegister !TargetRegister
| Jump !Link !JumpTarget
- | BranchOn1 !BranchCondition1 !SourceRegister !Offset
- | BranchOn2 !BranchCondition2 !SourceRegister !TargetRegister !Offset
+ | BranchOn1 !BranchCondition1 !SourceRegister !Label !Offset
+ | BranchOn2 !BranchCondition2 !SourceRegister !TargetRegister !Label !Offset
| Break !Int
| Syscall !Int /* applications should also set v0 to the syscall argument */
diff --git a/snug-clean/src/MIPS/MIPS32.icl b/snug-clean/src/MIPS/MIPS32.icl
index e8053e3..d95b71c 100644
--- a/snug-clean/src/MIPS/MIPS32.icl
+++ b/snug-clean/src/MIPS/MIPS32.icl
@@ -63,16 +63,16 @@ where
(Link, Direct _) -> "jal\t"
(NoLink, Register _) -> "jr\t"
(Link, Register _) -> "jalr\t"
- toString (BranchOn1 (BCGeZero link) rs offset) =
- branch1InstrS (if (link=:Link) "bgezal" "bgez") rs (checkOffset offset)
- toString (BranchOn1 BCGtZero rs offset) =
- branch1InstrS "bgtz" rs (checkOffset offset)
- toString (BranchOn1 BCLeZero rs offset) =
- branch1InstrS "blez" rs (checkOffset offset)
- toString (BranchOn1 (BCLtZero link) rs offset) =
- branch1InstrS (if (link=:Link) "bltzal" "bltz") rs (checkOffset offset)
- toString (BranchOn2 cond rs rt offset) =
- immediateInstrS (if (cond=:BCEq) "beq" "bne") rs rt (Immediate (checkOffset offset))
+ toString (BranchOn1 (BCGeZero link) rs label offset) =
+ branch1InstrS (if (link=:Link) "bgezal" "bgez") rs label (checkOffset offset)
+ toString (BranchOn1 BCGtZero rs label offset) =
+ branch1InstrS "bgtz" rs label (checkOffset offset)
+ toString (BranchOn1 BCLeZero rs label offset) =
+ branch1InstrS "blez" rs label (checkOffset offset)
+ toString (BranchOn1 (BCLtZero link) rs label offset) =
+ branch1InstrS (if (link=:Link) "bltzal" "bltz") rs label (checkOffset offset)
+ toString (BranchOn2 cond rs rt label offset) =
+ branch2InstrS (if (cond=:BCEq) "beq" "bne") rs rt label (checkOffset offset)
toString (Break arg) =
"break\t" +++ toString arg
@@ -112,8 +112,11 @@ immediateInstrS opcode rt rs imm = concat [opcode,"\t",toString rt,",",toString
threeRegInstrS :: !String !DestinationRegister !SourceRegister !TargetRegister -> String
threeRegInstrS opcode rd rs rt = concat [opcode,"\t",toString rd,",",toString rs,",",toString rt]
-branch1InstrS :: !String !SourceRegister !Offset -> String
-branch1InstrS opcode rs offset = concat [opcode,"\t",toString rs,",",toString offset]
+branch1InstrS :: !String !SourceRegister !Label !Offset -> String
+branch1InstrS opcode rs label _ = concat [opcode,"\t",toString rs,",",label]
+
+branch2InstrS :: !String !SourceRegister !SourceRegister !Label !Offset -> String
+branch2InstrS opcode rx ry label _ = concat [opcode,"\t",toString rx,",",toString ry,",",label]
instance toString Register
where