changeset 439:bfbb8613efb4

Add support for single operand instructions to 68K test generator
author Mike Pavone <pavone@retrodev.com>
date Tue, 16 Jul 2013 23:16:38 -0700
parents b3cee2fe690b
children 306986209cba
files gentests.py testcases.txt
diffstat 2 files changed, 43 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/gentests.py	Tue Jul 16 23:16:14 2013 -0700
+++ b/gentests.py	Tue Jul 16 23:16:38 2013 -0700
@@ -72,6 +72,16 @@
 	def get_dreg(self):
 		return Register('d', self.avail_dregs.pop())
 
+class Dummy(object):
+	def __str__(self):
+		return ''
+	def write_init(self, outfile, size, already):
+		pass
+	def consume_regs(self, program):
+		pass
+
+dummy_op = Dummy()
+
 class Register(object):
 	def __init__(self, kind, num):
 		self.kind = kind
@@ -441,30 +451,47 @@
 		self.src.consume_regs(program)
 		self.dst.consume_regs(program)
 
+class Inst1Op(Inst2Op):
+	def __init__(self, name, size, dst):
+		super(Inst1Op, self).__init__(name, size, dummy_op, dst)
+	
+	def __str__(self):
+		return self.name + '.' + self.size + ' ' + str(self.dst)
+
 class Entry(object):
 	def __init__(self, line):
 		fields = split_fields(line)
 		self.name = fields[0]
 		sizes = fields[1]
 		sources = fields[2].split(';')
-		dests = fields[3].split(';')
+		if len(fields) > 3:
+			dests = fields[3].split(';')
+		else:
+			dests = None
 		combos = []
 		for size in sizes:
 			for source in sources:
 				if size != 'b' or source != 'a':
-					for dest in dests:
-						if size != 'b' or dest != 'a':
-							combos.append((size, source, dest))
+					if dests:
+						for dest in dests:
+							if size != 'b' or dest != 'a':
+								combos.append((size, source, dest))
+					else:
+						combos.append((size, None, source))
 		self.cases = combos
 		
 	def programs(self):
 		res = []
 		for (size, src, dst) in self.cases:
-			sources = get_variations(src, size)
 			dests = get_variations(dst, size)
-			for source in sources:
+			if src:
+				sources = get_variations(src, size)
+				for source in sources:
+					for dest in dests:
+						res.append(Program(Inst2Op(self.name, size, source, dest)))
+			else:
 				for dest in dests:
-					res.append(Program(Inst2Op(self.name, size, source, dest)))
+					res.append(Program(Inst1Op(self.name, size, dest)))
 		return res
 		
 def process_entries(f):
--- a/testcases.txt	Tue Jul 16 23:16:14 2013 -0700
+++ b/testcases.txt	Tue Jul 16 23:16:38 2013 -0700
@@ -48,12 +48,13 @@
 #cmpa	wl		d;a;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x)	a
 #cmpi	bwl		#n																d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
 #cmpm	bwl		(a)+															(a)+
-eor		bwl		d																d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
-eori	bwl		#n																d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
-exg		l		d																d;a
-exg		l		a																a
-link	w		a																#n
-or		bwl		d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x)	d
-or		bwl		d																(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
-ori		bwl		#n																d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
+#eor		bwl		d																d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
+#eori	bwl		#n																d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
+#exg		l		d																d;a
+#exg		l		a																a
+#link	w		a																#n
+#or		bwl		d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l;#n;(n,pc);(n,pc,x)	d
+#or		bwl		d																(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
+#ori		bwl		#n																d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l
+clr		bwl		d;(a);(a)+;-(a);(n,a);(n,a,x);(n).w;(n).l