Verified Commit ea4c0e25 authored by Camil Staps's avatar Camil Staps 🚀

Add opcodes for file-related rts labels used in jsr

parent 8df29455
......@@ -690,6 +690,38 @@ const char *instruction_type (BC_WORD i) {
case Ceval_upd32: return "";
case Cfill_a01_pop_rtn: return "";
case CcloseF: return "";
case CendF: return "";
case CendSF: return "";
case CerrorF: return "";
case CflushF: return "";
case CopenF: return "";
case CopenSF: return "";
case CpositionF: return "";
case CpositionSF: return "";
case CreadFC: return "";
case CreadFI: return "";
case CreadFR: return "";
case CreadFS: return "";
case CreadFString: return "";
case CreadLineF: return "";
case CreadLineSF: return "";
case CreadSFC: return "";
case CreadSFI: return "";
case CreadSFR: return "";
case CreadSFS: return "";
case CreopenF: return "";
case CseekF: return "";
case CseekSF: return "";
case CshareF: return "";
case CstderrF: return "";
case CstdioF: return "";
case CwriteFC: return "";
case CwriteFI: return "";
case CwriteFR: return "";
case CwriteFS: return "";
case CwriteFString: return "";
case CaddIi: return "i";
case CandIi: return "i";
case CandIio: return "ni";
......
......@@ -678,6 +678,38 @@ enum {
INSTRUCTION(swap_a3)
INSTRUCTION(swap_a)
INSTRUCTION(closeF)
INSTRUCTION(endF)
INSTRUCTION(endSF)
INSTRUCTION(errorF)
INSTRUCTION(flushF)
INSTRUCTION(openF)
INSTRUCTION(openSF)
INSTRUCTION(positionF)
INSTRUCTION(positionSF)
INSTRUCTION(readFC)
INSTRUCTION(readFI)
INSTRUCTION(readFR)
INSTRUCTION(readFS)
INSTRUCTION(readFString)
INSTRUCTION(readLineF)
INSTRUCTION(readLineSF)
INSTRUCTION(readSFC)
INSTRUCTION(readSFI)
INSTRUCTION(readSFR)
INSTRUCTION(readSFS)
INSTRUCTION(reopenF)
INSTRUCTION(seekF)
INSTRUCTION(seekSF)
INSTRUCTION(shareF)
INSTRUCTION(stderrF)
INSTRUCTION(stdioF)
INSTRUCTION(writeFC)
INSTRUCTION(writeFI)
INSTRUCTION(writeFR)
INSTRUCTION(writeFS)
INSTRUCTION(writeFString)
INSTRUCTION(addIi)
INSTRUCTION(andIi)
INSTRUCTION(andIio)
......
......@@ -941,57 +941,84 @@ struct word *add_add_arg_labels(void) {
return pgrm.code;
}
static char *specialized_jsr_labels[] = {
/* 0*/ "eqAC",
/* 1*/ "cmpAC",
/* 2*/ "catAC",
/* 3*/ "sliceAC",
/* 4*/ "updateAC",
/* 5*/ "ItoAC",
/* 6*/ "BtoAC",
/* 7*/ "RtoAC",
/* 8*/ "print__string__",
/* 9*/ "openF",
/*10*/ "stdioF",
/*11*/ "closeF",
/*12*/ "readLineF",
/*13*/ "endF",
/*14*/ "writeFI",
/*15*/ "writeFS",
/*16*/ "writeFC",
/*17*/ "openSF"
struct specialized_jsr {
const char *label;
int instruction;
int flags;
};
#define SPECIALIZED(instr,flags) {#instr, C ## instr, flags},
#define S_UNSUPPORTED 1
#define S_IO 2
static struct specialized_jsr specialized_jsr_labels[]={
SPECIALIZED(eqAC,0)
SPECIALIZED(cmpAC,0)
SPECIALIZED(catAC,0)
SPECIALIZED(sliceAC,0)
SPECIALIZED(updateAC,0)
SPECIALIZED(ItoAC,0)
SPECIALIZED(BtoAC,0)
SPECIALIZED(RtoAC,0)
{"print__string__",Cprint_string,0},
SPECIALIZED(closeF, S_IO)
SPECIALIZED(endF, S_IO)
SPECIALIZED(endSF, S_IO | S_UNSUPPORTED)
SPECIALIZED(errorF, S_IO)
SPECIALIZED(flushF, S_IO | S_UNSUPPORTED)
SPECIALIZED(openF, S_IO)
SPECIALIZED(openSF, S_IO | S_UNSUPPORTED)
SPECIALIZED(positionF, S_IO | S_UNSUPPORTED)
SPECIALIZED(positionSF, S_IO | S_UNSUPPORTED)
SPECIALIZED(readFC, S_IO)
SPECIALIZED(readFI, S_IO | S_UNSUPPORTED)
SPECIALIZED(readFR, S_IO | S_UNSUPPORTED)
SPECIALIZED(readFS, S_IO | S_UNSUPPORTED)
SPECIALIZED(readFString, S_IO | S_UNSUPPORTED)
SPECIALIZED(readLineF, S_IO)
SPECIALIZED(readLineSF, S_IO | S_UNSUPPORTED)
SPECIALIZED(readSFC, S_IO | S_UNSUPPORTED)
SPECIALIZED(readSFI, S_IO | S_UNSUPPORTED)
SPECIALIZED(readSFR, S_IO | S_UNSUPPORTED)
SPECIALIZED(readSFS, S_IO | S_UNSUPPORTED)
SPECIALIZED(reopenF, S_IO | S_UNSUPPORTED)
SPECIALIZED(seekF, S_IO | S_UNSUPPORTED)
SPECIALIZED(seekSF, S_IO | S_UNSUPPORTED)
SPECIALIZED(shareF, S_IO | S_UNSUPPORTED)
SPECIALIZED(stderrF, S_IO | S_UNSUPPORTED)
SPECIALIZED(stdioF, S_IO)
SPECIALIZED(writeFC, S_IO | S_UNSUPPORTED)
SPECIALIZED(writeFI, S_IO | S_UNSUPPORTED)
SPECIALIZED(writeFR, S_IO | S_UNSUPPORTED)
SPECIALIZED(writeFS, S_IO)
SPECIALIZED(writeFString, S_IO | S_UNSUPPORTED)
};
static int get_specialized_jsr_label_n(char label_name[]) {
int i,n;
n = sizeof(specialized_jsr_labels) / sizeof (char*);
n=sizeof(specialized_jsr_labels)/sizeof(struct specialized_jsr);
for(i=0; i<n; ++i)
if (!strcmp (label_name,specialized_jsr_labels[i]))
if (!strcmp(label_name,specialized_jsr_labels[i].label))
return i;
return -1;
}
void add_specialized_jsr_instruction(unsigned int n) {
switch (n) {
case 0: add_instruction(CeqAC); return;
case 1: add_instruction(CcmpAC); return;
case 2: add_instruction(CcatAC); return;
case 3: add_instruction(CsliceAC); return;
case 4: add_instruction(CupdateAC); return;
case 5: add_instruction(CItoAC); return;
case 6: add_instruction(CBtoAC); return;
case 7: add_instruction(CRtoAC); return;
case 8: add_instruction(Cprint_string); return;
default:
if (n < sizeof(specialized_jsr_labels)/sizeof(char*)) {
fprintf(stderr,"Warning: jsr %s is not supported by the interpreter\n",specialized_jsr_labels[n]);
} else {
fprintf(stderr,"internal error in add_specialized_jsr_instruction: %d\n",n);
exit(1);
}
if (n>=sizeof(specialized_jsr_labels)/sizeof(struct specialized_jsr)) {
fprintf(stderr,"internal error in add_specialized_jsr_instruction: %d\n",n);
exit(1);
}
struct specialized_jsr *entry=&specialized_jsr_labels[n];
if (entry->flags & S_UNSUPPORTED)
unsupported_instruction_warning(entry->instruction);
else if (entry->flags & S_IO)
fprintf(stderr,"Warning: jsr %s requires file IO\n",entry->label);
add_instruction(entry->instruction);
}
void add_label(char *label_name) {
......
......@@ -27,4 +27,4 @@ typedef int64_t CleanInt;
#define BCGEN_INSTRUCTION_TABLE_SIZE 512
#define ABC_MAGIC_NUMBER 0x2a434241
#define ABC_VERSION 12
#define ABC_VERSION 13
......@@ -3748,10 +3748,8 @@ all_instructions opts t = bootstrap $ collect_instructions opts $ map (\i -> i t
d += (B @ 0 <<. if_i64_or_i32_expr (lit_word 3) (lit_word 2)) :.
B @ 0 .= to_word_ptr d @ 0
, alias "add_arg" $
alias "buildF_b" $
alias "ccall" $
alias "centry" $
alias "fillF_b" $
alias "fill3_r" $
alias "fill3_r01a" $
alias "fill3_r01b" $
......@@ -3768,6 +3766,39 @@ all_instructions opts t = bootstrap $ collect_instructions opts $ map (\i -> i t
alias "pushL" $
alias "pushLc" $
alias "set_finalizers" $
alias "closeF"
alias "endF"
alias "endSF" $
alias "errorF"
alias "flushF" $
alias "openF"
alias "openSF" $
alias "positionF" $
alias "positionSF" $
alias "readFC"
alias "readFI" $
alias "readFR" $
alias "readFS" $
alias "readFString" $
alias "readLineF"
alias "readLineSF" $
alias "readSFC" $
alias "readSFI" $
alias "readSFR" $
alias "readSFS" $
alias "reopenF" $
alias "seekF" $
alias "seekSF" $
alias "shareF" $
alias "stderrF" $
alias "stdioF"
alias "writeFC"
alias "writeFI" $
alias "writeFR" $
alias "writeFS"
alias "writeFString" $
alias "A_data_IIIla" $
alias "A_data_IIl" $
alias "A_data_IlI" $
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment