diff modules/il.tp @ 310:2308336790d4

WIP compiler module for low-level dialect
author Michael Pavone <pavone@retrodev.com>
date Fri, 01 Aug 2014 18:56:39 -0700
parents 56b2100d9fff
children f987bb2a1911
line wrap: on
line diff
--- a/modules/il.tp	Fri Aug 01 18:55:01 2014 -0700
+++ b/modules/il.tp	Fri Aug 01 18:56:39 2014 -0700
@@ -4,26 +4,31 @@
 	_and    <- 1
 	_or     <- 2
 	_xor    <- 3
+	_mul    <- 4
 	//non-commutative ops
-	_sub    <- 4
-	_cmp    <- 5
-	_not    <- 6
-	_sl     <- 7
-	_asr    <- 8
-	_lsr    <- 9
-	_rol    <- 10
-	_ror    <- 11
-	_mov    <- 12
-	_call   <- 13
-	_ret    <- 14
-	_skipif <- 15
-	_save   <- 16
+	_div    <- 5
+	_sub    <- 6
+	_cmp    <- 7
+	_not    <- 8
+	_sl     <- 9
+	_asr    <- 10
+	_lsr    <- 11
+	_rol    <- 12
+	_ror    <- 13
+	_mov    <- 14
+	_call   <- 15
+	_ret    <- 16
+	_skipif <- 17
+	_save   <- 18
+	_bool   <- 19
 
 	_names <- #[
 		"add"
 		"and"
 		"or"
 		"xor"
+		"mul"
+		"div"
 		"sub"
 		"cmp"
 		"not"
@@ -37,6 +42,7 @@
 		"ret"
 		"skipIf"
 		"save"
+		"bool"
 	]
 
 	op3:a:b:out:size <- :_opcode :_ina :_inb :_out :_size {
@@ -299,6 +305,14 @@
 			op3: _xor a: ina b: inb out: out size: size
 		}
 
+		mul <- :ina inb out size {
+			op3: _mul a: ina b: inb out: out size: size
+		}
+
+		div <- :ina inb out size {
+			op3: _div a: ina b: inb out: out size: size
+		}
+
 		bnot <- :in out size {
 			op2: _not in: in out: out size: size
 		}
@@ -432,6 +446,18 @@
 			}
 		}
 
+		//produces a non-zero value or zero based on condition code flags
+		bool <- :_cond _out {
+			#{
+				opcode <- { _bool }
+				cond <- { _cond }
+				out <- { _code }
+				name <- { _names get: _save }
+				numops <- { 0 }
+
+			}
+		}
+
 		allocRegs:withSource <- :instarr:regSrc {
 			_regMap <- dict linear
 			_argMap <- dict linear