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

Add select{BOOL,INT,REAL}oo for select with hard-coded offsets

parent 874c26b4
Pipeline #22303 passed with stages
in 27 minutes and 3 seconds
......@@ -736,7 +736,10 @@ const char *instruction_type (BC_WORD i) {
case Cpush_update_a: return "nn";
case Cput_a: return "n";
case Cput_b: return "n";
case CselectBOOLoo: return "nn";
case CselectCHARoo: return "nn";
case CselectINToo: return "nn";
case CselectREALoo: return "nn";
case Cselectoo: return "nn";
case Cupdate2_a: return "nn";
case Cupdate2_b: return "nn";
......
......@@ -724,7 +724,10 @@ enum {
INSTRUCTION(push_update_a)
INSTRUCTION(put_a)
INSTRUCTION(put_b)
INSTRUCTION(selectBOOLoo)
INSTRUCTION(selectCHARoo)
INSTRUCTION(selectINToo)
INSTRUCTION(selectREALoo)
INSTRUCTION(selectoo)
INSTRUCTION(update2_a)
INSTRUCTION(update2_b)
......
......@@ -3862,14 +3862,33 @@ void code_put_b(int b_offset) {
void code_selectoo(char element_descriptor[],int a_size,int b_size,int a_offset,int b_offset) {
switch(element_descriptor[0]) {
case 'B':
if (element_descriptor[1]=='O' && element_descriptor[2]=='O' && element_descriptor[3]=='L' &&
element_descriptor[4]=='\0') {
add_instruction_w_w(CselectBOOLoo,-a_offset,b_offset);
return;
}
break;
case 'C':
if (element_descriptor[1]=='H' && element_descriptor[2]=='A' && element_descriptor[3]=='R' &&
element_descriptor[4]=='\0')
{
element_descriptor[4]=='\0') {
add_instruction_w_w(CselectCHARoo,-a_offset,b_offset);
return;
}
break;
case 'I':
if (element_descriptor[1]=='N' && element_descriptor[2]=='T' && element_descriptor[3]=='\0') {
add_instruction_w_w(CselectINToo,-a_offset,b_offset);
return;
}
break;
case 'R':
if (element_descriptor[1]=='E' && element_descriptor[2]=='A' && element_descriptor[3]=='L' &&
element_descriptor[4]=='\0') {
add_instruction_w_w(CselectREALoo,-a_offset,b_offset);
return;
}
break;
case '_':
if (element_descriptor[1]=='_' && element_descriptor[2]=='\0') {
add_instruction_w_w(Cselectoo,-a_offset,b_offset);
......
......@@ -27,4 +27,4 @@ typedef int64_t CleanInt;
#define BCGEN_INSTRUCTION_TABLE_SIZE 512
#define ABC_MAGIC_NUMBER 0x2a434241
#define ABC_VERSION 5
#define ABC_VERSION 6
......@@ -3324,10 +3324,19 @@ all_instructions opts t = bootstrap $ collect_instructions opts $ map (\i -> i t
new_local (TPtr TWord) (to_word_ptr (A @ to_int (Pc @ 1))) \array ->
A @ 1 .= array @ (lit_word 3 + B @ to_int (Pc @ 2)) :.
grow_a 1
, instr "selectBOOLoo" (Just 2) $
new_local (TPtr TWord) (to_word_ptr (A @ to_int (Pc @ 1))) \array ->
B @ -1 .= to_char_ptr (array @? 3) @ (B @ to_int (Pc @ 2)) :.
grow_b 1
, instr "selectCHARoo" (Just 2) $
new_local (TPtr TWord) (to_word_ptr (A @ to_int (Pc @ 1))) \array ->
B @ -1 .= to_char_ptr (array @? 2) @ (B @ to_int (Pc @ 2)) :.
grow_b 1
, alias "selectINToo" $
instr "selectREALoo" (Just 2) $
new_local (TPtr TWord) (to_word_ptr (A @ to_int (Pc @ 1))) \array ->
B @ -1 .= to_word_ptr (array @? 3) @ (B @ to_int (Pc @ 2)) :.
grow_b 1
] ++
[ instr ("update"+++toString n+++"_a") (Just 2) $
new_local TInt (to_int (Pc @ 1)) \ao_s ->
......
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