diff modules/x86.tp @ 363:d949fe826e04

Unify il and backend labels
author Michael Pavone <pavone@retrodev.com>
date Sat, 25 Apr 2015 20:56:02 -0700
parents 7101ad443081
children e44f65abaf0e
line wrap: on
line diff
--- a/modules/x86.tp	Sat Apr 25 13:05:38 2015 -0700
+++ b/modules/x86.tp	Sat Apr 25 20:56:02 2015 -0700
@@ -466,37 +466,7 @@
 
 		ret <- { inst: [ 0xC3u8 ] }
 
-		label <- {
-			_offset <- -1
-			_forwardRefs <- #[]
-			#{
-				length <- { 0 }
-				hasOffset? <- { _offset >= 0 }
-				offset <- { _offset }
-				isInteger? <- { false }
-				register? <- { false }
-				label? <- { true }
-				flattenTo:at <- :dest :idx {
-					if: (not: hasOffset?) {
-						_offset <- idx
-						foreach: _forwardRefs :idx fun {
-							fun: _offset
-						}
-						_forwardRefs <- #[]
-					}
-					idx
-				}
-				string <- { "label: " . _offset }
-				withOffset:else <- :fun :elsefun {
-					if: hasOffset? {
-						fun: _offset
-					} else: {
-						_forwardRefs append: fun
-						elsefun:
-					}
-				}
-			}
-		}
+		label <- { il label }
 
 		jmp <- :jmpDest {
 			if: (jmpDest label?) {
@@ -887,7 +857,7 @@
 				{
 					//skipIf
 					endlab <- label:
-					outarr append: (jcc: (mapcond: (inst cond)) endlab)
+					outarr append: (jcc: (mapcond: (inst cond)) (endlab reference))
 					foreach: (inst toskip) :_ inst {
 						convertIL: inst to: outarr withLabels: labels withSaved: saved
 					}
@@ -897,11 +867,11 @@
 				{
 					endlab <- label:
 					elselab <- label:
-					outarr append: (jcc: (mapcond: (inst cond)) elselab)
+					outarr append: (jcc: (mapcond: (inst cond)) (elselab reference))
 					foreach: (inst toskip) :_ inst {
 						convertIL: inst to: outarr withLabels: labels withSaved: saved
 					}
-					outarr append: (jmp: endlab)
+					outarr append: (jmp: (endlab reference))
 					outarr append: elselab
 					foreach: (inst else) :_ inst {
 						convertIL: inst to: outarr withLabels: labels withSaved: saved
@@ -930,6 +900,7 @@
 				}
 				//label
 				{
+					outarr append: inst
 				}
 				//data
 				{