cgframe.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef CGFRAME_H
  2. #define CGFRAME_H
  3. #include "cgflow.h"
  4. struct CGFrame{
  5. CGFun* fun;
  6. CGFlow* flow;
  7. CGAsmSeq assem;
  8. CGAsm* asm_it;
  9. CGReg* int64ret;
  10. bool big_endian,little_endian;
  11. int reg_banks[8]; //maps types->banks
  12. int reg_masks[4]; //usable regs per bank
  13. vector<const char*> reg_names[4]; //reg names per bank
  14. vector<CGReg*> regs;
  15. map<string,CGExp*> tmps;
  16. CGFrame( CGFun *fun );
  17. virtual ~CGFrame();
  18. //before ASM is generated
  19. void findEscapes(); //local escaping tmps
  20. void renameTmps(); //rename tmps->regs
  21. void fixInt64();
  22. void linearize(); //remove SEQ and ESQ nodes
  23. void fixSymbols(); //fix symbols depending on platform
  24. void preOptimize(); //do some opts before asm gen
  25. //generate ASM
  26. void genAssem(); //create assem from fun
  27. void createFlow(); //create flowgraph
  28. //optimize FlowGraph
  29. void optDeadCode(); //eliminate dead code
  30. void optDupLoads(); //eliminate extra 'loads'
  31. //assign regs/rewrite src
  32. void allocRegs(); //alloc registers
  33. void spillReg( CGReg *r,CGExp *e );
  34. void deleteFlow();
  35. void peepOpt();
  36. CGMem* int64el( CGMem *i64,int n );
  37. CGMem* int64lo( CGMem *i64 );
  38. CGMem* int64hi( CGMem *i64 );
  39. CGReg* reg( int type,CGReg *owner=0,int color=-1 );
  40. CGAsm* gen( CGStm *stm,const char *fmt,... );
  41. virtual string fixSym( string id )=0;
  42. virtual void genFun()=0;
  43. virtual void genStm( CGStm *stm )=0;
  44. virtual CGMem* allocLocal( int type )=0;
  45. virtual CGExp* allocSpill( CGReg *r )=0;
  46. virtual void finish()=0;
  47. };
  48. #endif