cgframe_x86.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef CGFRAME_X86_H
  2. #define CGFRAME_X86_H
  3. #include "cgframe.h"
  4. struct CGModule_X86;
  5. struct CGFrame_X86 : public CGFrame{
  6. CGModule_X86 *mod_x86;
  7. int arg_sz,param_sz,local_sz,tmp_mem,extern_jsrs;
  8. enum{
  9. EA_IMM=1,EA_MEM=2
  10. };
  11. enum{
  12. XOP_CDQ=1,XOP_DIV,
  13. XOP_PUSH4,XOP_PUSH8,XOP_POP
  14. };
  15. enum{
  16. EAX,EDX,ECX,EBX,ESI,EDI,EBP,ESP,
  17. FP0,FP1,FP2,FP3,FP4,FP5,FP6
  18. };
  19. CGReg *eax,*edx,*ecx,*ebx,*esi,*edi,*ebp,*esp;
  20. CGReg *fp0,*fp1,*fp2,*fp3,*fp4,*fp5,*fp6;
  21. CGMem* tmpMem( int type );
  22. CGMem* optMem( CGMem *exp,char *buf );
  23. bool optMov( CGExp *lhs,CGExp *rhs );
  24. CGMem* genMem( CGMem *exp,char *buf );
  25. CGExp* genExp( CGExp *exp,char *buf,int mask );
  26. CGReg* genExp( CGExp *exp );
  27. CGReg* genLea( CGLea *exp );
  28. CGReg* genCvt( CGCvt *exp );
  29. CGReg* genUop( CGUop *exp );
  30. CGReg* genBop( CGBop *exp );
  31. CGReg* genScc( CGScc *exp );
  32. CGReg* genJsr( CGJsr *exp );
  33. CGReg* genMacJsr( CGJsr *exp );
  34. CGReg* genLit( CGLit *exp );
  35. CGReg* genSym( CGSym *exp );
  36. CGReg* genFrm( CGFrm *exp );
  37. CGReg* genLoad( CGMem *exp );
  38. void genStore( CGMem *mem,CGExp *exp );
  39. void genCopy( CGReg *res,CGReg *exp );
  40. void genMov( CGExp *lhs,CGExp *rhs );
  41. void genPush( CGExp *exp );
  42. void genPush4( CGExp *exp );
  43. void genPush8( CGExp *exp );
  44. void genPop( CGExp *exp );
  45. void genBcc( int cc,CGExp *lhs,CGExp *rhs,CGSym *sym );
  46. void genRet( CGExp *exp );
  47. void fixFp();
  48. CGFrame_X86( CGFun *fun,CGModule_X86 *mod );
  49. virtual string fixSym( string id );
  50. virtual void genFun();
  51. virtual void genStm( CGStm *stm );
  52. virtual CGMem *allocLocal( int type );
  53. virtual CGExp *allocSpill( CGReg *r );
  54. virtual void finish();
  55. static const char *x86cc( int cg_cc );
  56. static const char *x86size( int cg_sz );
  57. };
  58. #endif