static void make_instruction (void) { int i; unsigned int shift; for (i = 0; i < currInsn.nargs; i++) { argument a; memset (&a, 0, sizeof (a)); a.type = getargtype (instruction->operands[i].op_type); if (instruction->operands[i].op_type == cst4 || instruction->operands[i].op_type == rbase_dispu4) cst4flag = 1; a.size = getbits (instruction->operands[i].op_type); shift = instruction->operands[i].shift; make_argument (&a, shift); currInsn.arg[i] = a; } /* Calculate instruction size (in bytes). */ currInsn.size = instruction->size + (size_changed ? 1 : 0); /* Now in bits. */ currInsn.size *= 2; }
void writedefineregister(FILE *out, struct functionhead *funclistit, struct config *cfg) { struct functionarg *arglistit; int count, isvoid; char *type; isvoid = strcmp(funclistit->type, "void") == 0 || strcmp(funclistit->type, "VOID") == 0; fprintf(out, "\n" "#define __%s_WB(__%s", funclistit->name, cfg->libbase ); for (arglistit = funclistit->arguments, count = 1; arglistit!=NULL; arglistit = arglistit->next, count++ ) { fprintf(out, ", __arg%d", count); } fprintf(out, ") \\\n" " AROS_LC%d%s(%s, %s, \\\n", funclistit->argcount, (isvoid) ? "NR" : "", funclistit->type, funclistit->name ); for (arglistit = funclistit->arguments, count = 1; arglistit!=NULL; arglistit = arglistit->next, count++ ) { type = getargtype(arglistit); assert(type != NULL); fprintf(out, " AROS_LCA(%s,(__arg%d),%s), \\\n", type, count, arglistit->reg ); free(type); } fprintf(out, " %s, (__%s), %u, %s)\n\n", cfg->libbasetypeptrextern, cfg->libbase, funclistit->lvo, cfg->basename ); fprintf(out, "#define %s(", funclistit->name); for (arglistit = funclistit->arguments, count = 1; arglistit != NULL; arglistit = arglistit->next, count++ ) { if (arglistit != funclistit->arguments) fprintf(out, ", "); fprintf(out, "arg%d", count); } fprintf(out, ") \\\n __%s_WB(%s", funclistit->name, cfg->libbase); for (arglistit = funclistit->arguments, count = 1; arglistit != NULL; arglistit = arglistit->next, count++ ) fprintf(out, ", (arg%d)", count); fprintf(out, ")\n"); }
void writedefinevararg(FILE *out, struct functionhead *funclistit, struct config *cfg) { struct functionarg *arglistit = funclistit->arguments; char isvararg = 0, *varargname, *lastname; /* Go to last argument */ if (arglistit == NULL) return; while (arglistit->next != NULL) arglistit = arglistit->next; lastname = getargname(arglistit); assert(lastname != NULL); if (*(funclistit->name + strlen(funclistit->name) - 1) == 'A') { isvararg = 1; varargname = strdup(funclistit->name); varargname[strlen(funclistit->name)-1] = '\0'; } else if (strcmp(funclistit->name + strlen(funclistit->name) - 7, "TagList") == 0) { isvararg = 1; /* TagList has to be changed in Tags at the end of the functionname */ varargname = strdup(funclistit->name); varargname[strlen(funclistit->name)-4] = 's'; varargname[strlen(funclistit->name)-3] = '\0'; } else if (strcmp(funclistit->name + strlen(funclistit->name) - 4, "Args") == 0 && (strcasecmp(lastname, "args") == 0 || strcasecmp(lastname, "arglist") == 0) ) { isvararg = 1; varargname = strdup(funclistit->name); varargname[strlen(funclistit->name)-4] = '\0'; } else { char *p; if (strncmp(arglistit->arg, "const", 5) == 0) { p = arglistit->arg + 5; while (isspace(*p)) p++; } else p = arglistit->arg; if (strncmp(p, "struct", 6)==0) { p += 6; while (isspace(*p)) p++; if (strncmp(p, "TagItem", 7) == 0) { p += 7; while (isspace(*p)) p++; if (*p == '*') { isvararg = 1; varargname = malloc(strlen(funclistit->name) + 5); strcpy(varargname, funclistit->name); strcat(varargname, "Tags"); } } } } if (isvararg) { int count; char *type; fprintf(out, "\n#if !defined(NO_INLINE_STDARG) && !defined(%s_NO_INLINE_STDARG)\n" "#define %s(", cfg->modulenameupper, varargname ); for (arglistit = funclistit->arguments, count = 1; arglistit != NULL && arglistit->next != NULL; arglistit = arglistit->next, count++ ) { fprintf(out, "arg%d, ", count); } fprintf(out, "...) \\\n" "({ \\\n" " IPTR __args[] = { AROS_PP_VARIADIC_CAST2IPTR(__VA_ARGS__) }; \\\n" " %s(", funclistit->name ); for (arglistit = funclistit->arguments, count = 1; arglistit != NULL; arglistit = arglistit->next, count++ ) { if (arglistit != funclistit->arguments) fprintf(out, ", "); if (arglistit->next == NULL) { type = getargtype(arglistit); assert(type != NULL); fprintf(out, "(%s)__args", type); free(type); } else fprintf(out, "(arg%d)", count); } fprintf(out, "); \\\n" "})\n" "#endif /* !NO_INLINE_STDARG */\n" ); free(varargname); } }