diff python/codegenarm.py @ 262:ed14e077124c

Added conditional branch instructions
author Windel Bouwman
date Fri, 09 Aug 2013 11:30:11 +0200
parents 444b9df2ed99
children 5ec7580976d9
line wrap: on
line diff
--- a/python/codegenarm.py	Fri Aug 09 09:05:13 2013 +0200
+++ b/python/codegenarm.py	Fri Aug 09 11:30:11 2013 +0200
@@ -5,6 +5,15 @@
 from ppci import CompilerError
 import irmach
 
+
+class InstructionSelector:
+    pass
+
+
+class RegisterAllocator:
+    pass
+
+
 class ArmCodeGenerator:
     """
         Simple code generator
@@ -173,13 +182,17 @@
             r0 = self.getreg(ins.a)
             r1 = self.getreg(ins.b)
             self.emit(arm.cmp_ins(r1, r0))
-            tgt_yes = Label(ins.lab1.name)
+            tgt_yes = LabelRef(ins.lab1.name)
             if ins.cond == '==':
                 self.emit(arm.beq_ins(tgt_yes))
+            elif ins.cond == '<':
+                self.emit(arm.blt_ins(tgt_yes))
+            elif ins.cond == '>':
+                self.emit(arm.bgt_ins(tgt_yes))
             else:
                 raise NotImplementedError('"{}" not covered'.format(ins.cond))
-            tgt_no = Label(ins.lab2.name)
-            self.emit(arm.jmp_ins(tgt_no))
+            tgt_no = LabelRef(ins.lab2.name)
+            self.emit(arm.b_ins(tgt_no))
             self.freereg(ins.a, ins)
             self.freereg(ins.b, ins)
         elif type(ins) is ir.Alloc: