CoolFace
Datasetpublic

hschumann2/TempleOS-Source-Code

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes838downloads
BackFA.txt609 linesDownload Raw Back to Compiler
1 2#define CN_A2   03#define CN_A1   14#define CN_INST 25#define CN_RES  36 7U0 CmpNoteFloatOp(CCmpCtrl *cc,CIntermediateCode *tmpi,8        Bool dont_pushable,Bool dont_popable,I64 pos)9{10  Bool link=FALSE;11  if (cc->pass==7 && cc->last_float_op_ic &&12        cc->last_dont_popable && dont_pushable) {13    switch [pos] {14      case CN_A2:15        if (cc->last_float_op_ic!=tmpi && cc->dont_push_float)16          link=TRUE;17        break;18      case CN_A1:19        if (cc->last_float_op_ic!=tmpi && cc->dont_push_float)20          link=TRUE;21        break;22      case CN_INST:23        if (cc->last_float_op_ic!=tmpi) {24          if (cc->dont_push_float) {25            if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG &&26                  cc->last_float_op_ic->res.reg!=REG_R8)27              tmpi->ic_flags|=ICF_ALT_TEMPLATE;28            else29              tmpi->ic_flags&=~ICF_ALT_TEMPLATE;30            link=TRUE;31          }32        } else {33          if (intermediate_code_table[tmpi->ic_code].arg_cnt==IS_2_ARG &&34                cc->last_float_op_pos!=CN_A1)35            tmpi->ic_flags|=ICF_ALT_TEMPLATE;36          else37            tmpi->ic_flags&=~ICF_ALT_TEMPLATE;38          link=TRUE;39        }40        break;41      case CN_RES:42        if (cc->last_float_op_ic==tmpi && cc->last_float_op_pos==CN_INST)43          link=TRUE;44        break;45    }46    if (link) {47      if (!Bts(&cc->last_float_op_ic->ic_flags,48            ICf_DONT_POP_FLOAT0+cc->last_ic_float_op_num))49        cc->last_float_op_ic->ic_flags&=~ICF_CODE_FINAL;50      if (!Bts(&tmpi->ic_flags,ICf_DONT_PUSH_FLOAT0+cc->cur_ic_float_op_num))51        tmpi->ic_flags&=~ICF_CODE_FINAL;52    }53  }54  cc->last_float_op_ic=tmpi;55  cc->last_dont_pushable=dont_pushable;56  cc->last_dont_popable=dont_popable;57  cc->last_ic_float_op_num=cc->cur_ic_float_op_num++;58  cc->last_float_op_pos=pos;59  if (cc->cur_ic_float_op_num>4)60    throw('Compiler');61}62 63U0 CmpSetFloatOpPushPop(CCmpCtrl *cc,CIntermediateCode *tmpi,64        Bool *dont_push_float,Bool *dont_pop_float)65{66  if (cc->pass==7) {67    *dont_push_float=FALSE;68    *dont_pop_float =FALSE;69    tmpi->ic_flags&=~ICF_CODE_FINAL;70  } else {71    *dont_push_float=Bt(&tmpi->ic_flags,72          ICf_DONT_PUSH_FLOAT0+cc->cur_ic_float_op_num);73    *dont_pop_float=Bt(&tmpi->ic_flags,74          ICf_DONT_POP_FLOAT0+cc->cur_ic_float_op_num);75  }76}77 78U0 ICCopyTemplate(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,79  Bool off_the_record,Bool dont_pushable,Bool dont_popable,I64 pos)80{81  Bool dont_push_float,dont_pop_float,alt;82  U8 *ptr;83  I64 i=0;84  if (!off_the_record) {85    if (tmpi->ic_flags&ICF_ALT_TEMPLATE)86      alt=TRUE;87    else88      alt=FALSE;89    CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);90  } else {91    dont_push_float=FALSE;92    dont_pop_float=FALSE;93    alt=FALSE;94  }95  if (alt && dont_push_float && !dont_pop_float) {96    ptr=cmp_templates_dont_push2[op];97    i=cmp_templates_dont_push2[op+1]-ptr;98  }99  if (!i) {100    if (dont_push_float) {101      if (dont_pop_float) {102        ptr=cmp_templates_dont_push_pop[op];103        i=cmp_templates_dont_push_pop[op+1]-ptr;104      } else {105        ptr=cmp_templates_dont_push[op];106        i=cmp_templates_dont_push[op+1]-ptr;107      }108    } else {109      if (dont_pop_float) {110        ptr=cmp_templates_dont_pop[op];111        i=cmp_templates_dont_pop[op+1]-ptr;112      } else {113        ptr=cmp_templates[op];114        i=cmp_templates[op+1]-ptr;115      }116    }117  }118  MemCpy(&tmpi->ic_body[tmpi->ic_cnt],ptr,i);119  if (!off_the_record)120    CmpNoteFloatOp(cc,tmpi,dont_pushable,dont_popable,pos);121  tmpi->ic_cnt+=i;122}123 124U0 ICFCvt(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 r1,125        CICType t2,I64 r2,I64 d2,Bool to_int,I64 pos,I64 rip)126{127  I64 rsp_size=0,op1,op2;128  Bool dont_push_float,dont_pop_float;129 130  if (to_int) {131    op1=SLASH_OP_FLD;132    op2=SLASH_OP_FISTTP;133  } else {134    op1=SLASH_OP_FILD;135    op2=SLASH_OP_FSTP;136  }137 138  CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);139  if (!dont_push_float) {140    if (!(t2.raw_type>=RT_I64 && t2&MDG_DISP_SIB_RIP)) {141      ICPush(tmpi,t2,r2,d2,rip);142      t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;143      rsp_size=8;144    } else {145      if (!dont_pop_float) {146        rsp_size=8;147        ICAddRSP(tmpi,-8);148      }149    }150    ICSlashOp(tmpi,t2,r2,d2,op1,rip);151  } else {152    if (!dont_pop_float) {153      rsp_size=8;154      ICAddRSP(tmpi,-8);155    }156  }157  if (to_int)158    CmpNoteFloatOp(cc,tmpi,TRUE,FALSE,pos);159  else160    CmpNoteFloatOp(cc,tmpi,FALSE,TRUE,pos);161  if (dont_pop_float) {162    if (rsp_size)163      ICAddRSP(tmpi,rsp_size);164  } else {165    ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,op2,rip);166    ICPop(tmpi,MDF_REG+RT_I64,r1,0,rip);167  }168}169 170U0 ICFCvt2(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 r1,171        CICType t2,I64 r2,I64 d2,Bool to_int,I64 rip)172{173  I64 rsp_size=0,op1,op2;174  if (to_int) {175    op1=SLASH_OP_FLD;176    op2=SLASH_OP_FISTTP;177  } else {178    op1=SLASH_OP_FILD;179    op2=SLASH_OP_FSTP;180  }181  if (!(t2.raw_type>=RT_I64 && t2&MDG_DISP_SIB_RIP)) {182    ICPush(tmpi,t2,r2,d2,rip);183    t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;184    rsp_size=8;185  } else {186    rsp_size=8;187    ICAddRSP(tmpi,-8);188  }189  ICSlashOp(tmpi,t2,r2,d2,op1,rip);190  ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,op2,rip);191  ICPop(tmpi,MDF_REG+RT_I64,r1,0,rip);192  cc->last_dont_pushable=cc->last_dont_popable=FALSE; //TODO: improve this193}194 195U0 ICFUnaryMinus(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf2,I64 rip)196{197  CICArg *arg1=&tmpi->arg1;198  I64 rsp_size=0,builtin1=0,t1,r1,d1;199  Bool dont_push_float,dont_pop_float;200 201  if (cc->flags&CCF_AOT_COMPILE)202    buf2=cc->aotc->rip;203 204  CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);205  if (!dont_push_float) {206    if (arg1->type.raw_type>=RT_I64 && arg1->type&MDG_DISP_SIB_RIP) {207      t1=arg1->type;208      r1=arg1->reg;209      d1=arg1->disp;210    } else {211      if (arg1->type&MDF_IMM) {212        if (!(builtin1=ICBuiltInFloatConst(arg1->disp(F64)))) {213          t1=MDF_RIP_DISP32+RT_I64;214          r1=REG_RIP;215          d1=COCFloatConstFind(cc,arg1->disp(F64))+buf2;216        }217      } else {218        ICPush(tmpi,arg1->type,arg1->reg,arg1->disp,rip);219        t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;220        rsp_size+=8;221      }222    }223    if (builtin1)224      ICU16(tmpi,builtin1);225    else226      ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_FLD,rip);227  }228  if (!dont_pop_float && !rsp_size) {229    rsp_size=8;230    ICAddRSP(tmpi,-8);231  }232  ICU16(tmpi,0xE0D9); //FCHS233  CmpNoteFloatOp(cc,tmpi,TRUE,TRUE,CN_INST);234  if (dont_pop_float) {235    if (rsp_size)236      ICAddRSP(tmpi,rsp_size);237  } else {238    ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,rip);239    ICPop(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,rip);240  }241}242 243U0 ICFMod(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 rip)244{//for MOD245  Bool dont_push_float,dont_pop_float;246  CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);247  if (dont_push_float) {248    if (tmpi->ic_flags&ICF_ALT_TEMPLATE)249      ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,250            tmpi->arg1.type,tmpi->arg1.reg,tmpi->arg1.disp,rip);251    else252      ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,253            tmpi->arg2.type,tmpi->arg2.reg,tmpi->arg2.disp,rip);254  } else {255    ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,256          tmpi->arg2.type,tmpi->arg2.reg,tmpi->arg2.disp,rip);257    ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,258          tmpi->arg1.type,tmpi->arg1.reg,tmpi->arg1.disp,rip);259  }260//TODO: unpushable,unpop?  Not sure261  ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_INST);262  if (!dont_pop_float)263    ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,264          MDF_REG+RT_I64,REG_RAX,0,rip);265}266 267U0 ICFPow(CCmpCtrl *cc,CIntermediateCode *tmpi,U8 *buf,I64 rip)268{//for POW269  I64 i;270  CAOTImportExport *tmpie;271  CHashExport *tmpex=HashFind("SYS_POW",272        cc->htc.hash_table_lst,HTT_EXPORT_SYS_SYM);273 274  ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,275        tmpi->arg2.type,tmpi->arg2.reg,tmpi->arg2.disp,rip);276  ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,277        tmpi->arg1.type,tmpi->arg1.reg,tmpi->arg1.disp,rip);278  if (cc->flags&CCF_AOT_COMPILE) {279    if (!tmpex) {280      tmpex=CAlloc(sizeof(CHashExport));281      tmpex->str=StrNew("SYS_POW");282      tmpex->type=HTT_EXPORT_SYS_SYM|HTF_UNRESOLVED|HTF_IMPORT;283      HashAdd(tmpex,cc->htc.glbl_hash_table);284    }285    if (tmpex->type&HTF_IMPORT) {286      if (GetOption(OPTf_USE_IMM64)) {287        ICU16(tmpi,0xBB48);288        ICU64(tmpi,0);289        if (buf) {290          tmpie=CAlloc(sizeof(CAOTImportExport));291          tmpie->type=IET_IMM_I64;292          tmpie->rip=rip+tmpi->ic_cnt-8;293          tmpie->next=tmpex->ie_lst;294          tmpex->ie_lst=tmpie;295        }296        ICU16(tmpi,0xD3FF);297      } else {298        ICU8(tmpi,0xE8);299        ICU32(tmpi,-(rip+tmpi->ic_cnt+4));300        if (buf) {301          tmpie=CAlloc(sizeof(CAOTImportExport));302          tmpie->type=IET_REL_I32;303          tmpie->rip=rip+tmpi->ic_cnt-4;304          tmpie->next=tmpex->ie_lst;305          tmpex->ie_lst=tmpie;306        }307      }308    } else {//Kernel309      if (tmpex->type&HTF_UNRESOLVED)310        throw('Compiler');311      else {312        i=tmpex->val-(rip+tmpi->ic_cnt+5);313        if (!(I32_MIN<=i<=I32_MAX)) {314          throw('Compiler');315//          ICU16(tmpi,0xBB48);316          //        ICU64(tmpi,tmpex->val);317          //        ICU16(tmpi,0xD3FF);318        } else {319          ICU8(tmpi,0xE8);320          ICU32(tmpi,i);321        }322      }323    }324  } else {325    i=tmpex->val-(rip+tmpi->ic_cnt+5);326    if (!(I32_MIN<=i<=I32_MAX)) {327      ICU16(tmpi,0xBB48);328      ICU64(tmpi,tmpex->val);329      ICU16(tmpi,0xD3FF);330    } else {331      ICU8(tmpi,0xE8);332      ICU32(tmpi,i);333    }334  }335  tmpi->ic_flags&=~ICF_CODE_FINAL;336  ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,337        MDF_REG+RT_I64,REG_RAX,0,rip);338}339 340U0 ICFOp(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,U8 *buf2,I64 rip)341{//for ADD,SUB,DIV,MUL342  CICArg *arg1,*arg2;343  Bool dont_push_float,dont_pop_float,alt;344  I64 rsp_size=0,builtin1=0,builtin2=0,t1,r1,d1,t2,r2,d2;345 346  if (tmpi->ic_flags&ICF_ALT_TEMPLATE) {347    arg1=&tmpi->arg2;348    arg2=&tmpi->arg1;349    alt=TRUE;350  } else {351    arg1=&tmpi->arg1;352    arg2=&tmpi->arg2;353    alt=FALSE;354  }355 356  if (cc->flags&CCF_AOT_COMPILE)357    buf2=cc->aotc->rip;358 359  CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);360  if (dont_push_float) {361    if (arg2->type.raw_type>=RT_I64 && arg2->type&MDG_DISP_SIB_RIP) {362      t2=arg2->type;363      r2=arg2->reg;364      d2=arg2->disp;365    } else {366      if (arg2->type&MDF_IMM) {367        if (!(builtin2=ICBuiltInFloatConst(arg2->disp(F64)))) {368          t2=MDF_RIP_DISP32+RT_I64;369          r2=REG_RIP;370          d2=COCFloatConstFind(cc,arg2->disp(F64))+buf2;371        }372      } else {373        ICPush(tmpi,arg2->type,arg2->reg,arg2->disp,rip);374        t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;375        rsp_size+=8;376      }377    }378  } else {379    if (alt) {380      if (!(arg2->type&MDF_STK)) {381        if (arg1->type.raw_type>=RT_I64 && arg1->type&MDG_DISP_SIB_RIP) {382          t1=arg1->type;383          r1=arg1->reg;384          d1=arg1->disp;385        } else {386          if (arg1->type&MDF_IMM) {387            if (!(builtin1=ICBuiltInFloatConst(arg1->disp(F64)))) {388              t1=MDF_RIP_DISP32+RT_I64;389              r1=REG_RIP;390              d1=COCFloatConstFind(cc,arg1->disp(F64))+buf2;391            }392          } else {393            ICPush(tmpi,arg1->type,arg1->reg,arg1->disp,rip);394            t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;395            rsp_size+=8;396          }397        }398        if (arg2->type.raw_type>=RT_I64 && arg2->type&MDG_DISP_SIB_RIP) {399          t2=arg2->type;400          r2=arg2->reg;401          d2=arg2->disp;402        } else {403          if (arg2->type&MDF_IMM) {404            if (!(builtin2=ICBuiltInFloatConst(arg2->disp(F64)))) {405              t2=MDF_RIP_DISP32+RT_I64;406              r2=REG_RIP;407              d2=COCFloatConstFind(cc,arg2->disp(F64))+buf2;408            }409          } else {410            ICPush(tmpi,arg2->type,arg2->reg,arg2->disp,rip);411            t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;412            rsp_size+=8;413            if (r1==REG_RSP+REG_RSP<<8)414              d1+=8;415          }416        }417      } else {418        ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,arg1->type,419              arg1->reg,arg1->disp,rip);420        ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,arg2->type,421              arg2->reg,arg2->disp,rip);422        ICU16(tmpi,0x5052);     //PUSH EDX PUSH EAX423        rsp_size=16;424        t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;425        t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;426      }427    } else {428      if (!(arg1->type&MDF_STK)) {429        if (arg2->type.raw_type>=RT_I64 && arg2->type&MDG_DISP_SIB_RIP) {430          t2=arg2->type;431          r2=arg2->reg;432          d2=arg2->disp;433        } else {434          if (arg2->type&MDF_IMM) {435            if (!(builtin2=ICBuiltInFloatConst(arg2->disp(F64)))) {436              t2=MDF_RIP_DISP32+RT_I64;437              r2=REG_RIP;438              d2=COCFloatConstFind(cc,arg2->disp(F64))+buf2;439            }440          } else {441            ICPush(tmpi,arg2->type,arg2->reg,arg2->disp,rip);442            t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;443            rsp_size+=8;444          }445        }446        if (arg1->type.raw_type>=RT_I64 && arg1->type&MDG_DISP_SIB_RIP) {447          t1=arg1->type;448          r1=arg1->reg;449          d1=arg1->disp;450        } else {451          if (arg1->type&MDF_IMM) {452            if (!(builtin1=ICBuiltInFloatConst(arg1->disp(F64)))) {453              t1=MDF_RIP_DISP32+RT_I64;454              r1=REG_RIP;455              d1=COCFloatConstFind(cc,arg1->disp(F64))+buf2;456            }457          } else {458            ICPush(tmpi,arg1->type,arg1->reg,arg1->disp,rip);459            t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=0;460            rsp_size+=8;461            if (r2==REG_RSP+REG_RSP<<8)462              d2+=8;463          }464        }465      } else {466        ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,arg2->type,467              arg2->reg,arg2->disp,rip);468        ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,arg1->type,469              arg1->reg,arg1->disp,rip);470        ICU16(tmpi,0x5052);     //PUSH EDX PUSH EAX471        rsp_size=16;472        t1=MDF_SIB+RT_I64; r1=REG_RSP+REG_RSP<<8; d1=8;473        t2=MDF_SIB+RT_I64; r2=REG_RSP+REG_RSP<<8; d2=0;474      }475    }476  }477  if (!dont_pop_float && !rsp_size) {478    rsp_size=8;479    ICAddRSP(tmpi,-8);480  }481  if (!dont_push_float) {482    if (builtin2 && !builtin1) {483      alt=!alt;484      SwapI64(&t1,&t2);485      SwapI64(&r1,&r2);486      SwapI64(&d1,&d2);487      SwapI64(&builtin1,&builtin2);488    }489    if (builtin1)490      ICU16(tmpi,builtin1);491    else492      ICSlashOp(tmpi,t1,r1,d1,SLASH_OP_FLD,rip);493  }494  if (alt)495    switch (op.u8[0]) {496      case 4: op=SLASH_OP_FSUBR; break;497      case 6: op=SLASH_OP_FDIVR; break;498    }499  if (builtin2) {500    ICU16(tmpi,builtin2);501    ICU16(tmpi,op.u16[2]);502  } else503    ICSlashOp(tmpi,t2,r2,d2,op,rip);504  CmpNoteFloatOp(cc,tmpi,TRUE,TRUE,CN_INST);505  if (dont_pop_float) {506    if (rsp_size)507      ICAddRSP(tmpi,rsp_size);508  } else {509    if (rsp_size==8)510      ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,0,SLASH_OP_FSTP,rip);511    else if (rsp_size>8) {512      ICSlashOp(tmpi,MDF_SIB+RT_I64,REG_RSP+REG_RSP<<8,rsp_size-8,513            SLASH_OP_FSTP,rip);514      ICAddRSP(tmpi,rsp_size-8);515    }516    ICPop(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,rip);517  }518}519 520U0 ICFCmp(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 op,I64 rip)521{522  Bool dont_push_float,dont_pop_float;523  CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);524  if (dont_push_float) {525    if (tmpi->ic_flags&ICF_ALT_TEMPLATE) {526      if (tmpi->ic_flags&ICF_POP_CMP)527        ICPopRegs(tmpi,1<<REG_RAX);528      else529        ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,530              tmpi->arg1.type,tmpi->arg1.reg,tmpi->arg1.disp,rip);531    } else532      ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,533            tmpi->arg2.type,tmpi->arg2.reg,tmpi->arg2.disp,rip);534  } else {535    ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,536          tmpi->arg2.type,tmpi->arg2.reg,tmpi->arg2.disp,rip);537    if (tmpi->ic_flags&ICF_POP_CMP)538      ICPopRegs(tmpi,1<<REG_RDX);539    else540      ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,541            tmpi->arg1.type,tmpi->arg1.reg,tmpi->arg1.disp,rip);542  }543  if (tmpi->ic_flags&ICF_PUSH_CMP)544    ICPushRegs(tmpi,1<<REG_RAX);545  ICCopyTemplate(cc,tmpi,op,FALSE,TRUE,FALSE,CN_INST);546  ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,547        MDF_REG+RT_I64,REG_RAX,0,rip);548}549 550U0 ICFModEqu(CCmpCtrl *cc,CIntermediateCode *tmpi,I64 rip)551{552  Bool dont_push_float,dont_pop_float;553  CmpSetFloatOpPushPop(cc,tmpi,&dont_push_float,&dont_pop_float);554  if (tmpi->ic_flags & ICF_BY_VAL) {555    if (dont_push_float) {556      ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,557            tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,558            tmpi->arg1.reg,tmpi->arg1.disp,rip);559      if (tmpi->arg1_type_pointed_to!=RT_F64)560        ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,rip);561    } else {562      ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,563            tmpi->arg2.type,tmpi->arg2.reg,tmpi->arg2.disp,rip);564      ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,565            tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,566            tmpi->arg1.reg,tmpi->arg1.disp,rip);567      if (tmpi->arg1_type_pointed_to!=RT_F64)568        ICFCvt2(cc,tmpi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,rip);569    }570//TODO: unpushable,unpop?  Not sure571    ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_INST);572    if (tmpi->arg1_type_pointed_to!=RT_F64)573      ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,rip);574    ICMov(tmpi,tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,575          tmpi->arg1.reg,tmpi->arg1.disp,MDF_REG+RT_I64,REG_RAX,0,rip);576    if (tmpi->res.type.mode)577      ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,578            tmpi->arg1.type&MDG_MASK+tmpi->arg1_type_pointed_to,579            tmpi->arg1.reg,tmpi->arg1.disp,rip);580  } else {581    if (dont_push_float) {582      ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,tmpi->arg1.type,583            tmpi->arg1.reg,tmpi->arg1.disp,rip);584      ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,585            MDF_DISP+tmpi->arg1_type_pointed_to,REG_RCX,0,rip);586      if (tmpi->arg1_type_pointed_to!=RT_F64)587        ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,FALSE,rip);588    } else {589      ICMov(tmpi,MDF_REG+RT_I64,REG_RAX,0,590            tmpi->arg2.type,tmpi->arg2.reg,tmpi->arg2.disp,rip);591      ICMov(tmpi,MDF_REG+RT_I64,REG_RCX,0,tmpi->arg1.type,592            tmpi->arg1.reg,tmpi->arg1.disp,rip);593      ICMov(tmpi,MDF_REG+RT_I64,REG_RDX,0,594            MDF_DISP+tmpi->arg1_type_pointed_to,REG_RCX,0,rip);595      if (tmpi->arg1_type_pointed_to!=RT_F64)596        ICFCvt2(cc,tmpi,REG_RDX,MDF_REG+RT_I64,REG_RDX,0,FALSE,rip);597    }598//TODO: unpushable,unpop?  Not sure599    ICCopyTemplate(cc,tmpi,CMP_TEMPLATE_MOD,FALSE,FALSE,FALSE,CN_INST);600    if (tmpi->arg1_type_pointed_to!=RT_F64)601      ICFCvt2(cc,tmpi,REG_RAX,MDF_REG+RT_I64,REG_RAX,0,TRUE,rip);602    ICMov(tmpi,MDF_DISP+tmpi->arg1_type_pointed_to,REG_RCX,0,603          MDF_REG+RT_I64,REG_RAX,0,rip);604    if (tmpi->res.type.mode)605      ICMov(tmpi,tmpi->res.type,tmpi->res.reg,tmpi->res.disp,606            MDF_REG+RT_I64,REG_RAX,0,rip);607  }608}609