diff gen_arm.c @ 563:c8fefa140c80

Moved some generic stuff from backend.h gen_arm.h and gen_arm.c into gen.h and gen.c. Added a couple fields to cpu_options so that gen_mem_fun can be made guest CPU generic
author Michael Pavone <pavone@retrodev.com>
date Mon, 24 Feb 2014 09:55:24 -0800
parents 474270dbff15
children bff307e03a94
line wrap: on
line diff
--- a/gen_arm.c	Mon Feb 24 01:30:16 2014 -0800
+++ b/gen_arm.c	Mon Feb 24 09:55:24 2014 -0800
@@ -57,10 +57,6 @@
 #define REG      0u
 
 
-
-#define RESERVE_INSTRUCTIONS 4 //1 ldr + 1bx + 1 constant
-#define CODE_ALLOC_SIZE (1024*1024)
-
 uint32_t make_immed(uint32_t val)
 {
 	uint32_t rot_amount = 0;
@@ -74,17 +70,6 @@
 	return INVALID_IMMED;
 }
 
-void init_code_info(code_info *code)
-{
-	size_t size = CODE_ALLOC_SIZE;
-	code->cur = alloc_code(&size);
-	if (!code->cur) {
-		fputs("Failed to allocate memory for generated code\n", stderr);
-		exit(1);
-	}
-	code->last = code->cur + size/sizeof(uint32_t) - RESERVE_INSTRUCTIONS;
-}
-
 void check_alloc_code(code_info *code)
 {
 	if (code->cur == code->last) {
@@ -94,9 +79,9 @@
 			fputs("Failed to allocate memory for generated code\n", stderr);
 			exit(1);
 		}
-		if (next_code = code->last + RESERVE_INSTRUCTIONS) {
+		if (next_code = code->last + RESERVE_WORDS) {
 			//new chunk is contiguous with the current one
-			code->last = next_code + size/sizeof(uint32_t) - RESERVE_INSTRUCTIONS;
+			code->last = next_code + size/sizeof(code_word) - RESERVE_WORDS;
 		} else {
 			uint32_t * from = code->cur + 2;
 			if (next_code - from < 0x400000 || from - next_code <= 0x400000) {
@@ -115,7 +100,7 @@
 				}
 				//branch to address in r0
 				*from = CC_AL | OP_BX;
-				code->last = next_code + size/sizeof(uint32_t) - RESERVE_INSTRUCTIONS;
+				code->last = next_code + size/sizeof(code_word) - RESERVE_WORDS;
 				//pop r0
 				*(next_code++) = CC_AL | POP;
 				code->cur = next_code;