Procedure.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include "types.h"
  3. #include "ast.h"
  4. #include "icode.h"
  5. #include "locident.h"
  6. #include "error.h"
  7. #include "graph.h"
  8. #include "bundle.h"
  9. #include "StackFrame.h"
  10. /* PROCEDURE NODE */
  11. struct CALL_GRAPH;
  12. struct Function
  13. {
  14. dword procEntry; /* label number */
  15. char name[SYMLEN]; /* Meaningful name for this proc */
  16. STATE state; /* Entry state */
  17. Int depth; /* Depth at which we found it - for printing */
  18. flags32 flg; /* Combination of Icode & Proc flags */
  19. int16 cbParam; /* Probable no. of bytes of parameters */
  20. STKFRAME args; /* Array of arguments */
  21. LOCAL_ID localId; /* Local identifiers */
  22. ID retVal; /* Return value - identifier */
  23. /* Icodes and control flow graph */
  24. CIcodeRec Icode; /* Object with ICODE records */
  25. std::vector<BB*> cfg; /* Ptr. to BB list/CFG */
  26. std::vector<BB*> dfsLast;
  27. std::vector<BB*> heldBBs;
  28. //BB * *dfsLast; /* Array of pointers to BBs in dfsLast
  29. // * (reverse postorder) order */
  30. Int numBBs; /* Number of BBs in the graph cfg */
  31. boolT hasCase; /* Procedure has a case node */
  32. /* For interprocedural live analysis */
  33. dword liveIn; /* Registers used before defined */
  34. dword liveOut; /* Registers that may be used in successors */
  35. boolT liveAnal; /* Procedure has been analysed already */
  36. /* Double-linked list */
  37. // Function *next;
  38. // Function *prev;
  39. public:
  40. Function() : procEntry(0),depth(0),flg(0),cbParam(0),cfg(0),dfsLast(0),numBBs(0),
  41. hasCase(false),liveIn(0),liveOut(0),liveAnal(0)//,next(0),prev(0)
  42. {
  43. memset(name,0,SYMLEN);
  44. }
  45. void compoundCond();
  46. void writeProcComments();
  47. void lowLevelAnalysis();
  48. void bindIcodeOff();
  49. void dataFlow(dword liveOut);
  50. void compressCFG();
  51. void highLevelGen();
  52. void structure(derSeq *derivedG);
  53. derSeq *checkReducibility();
  54. void createCFG();
  55. void markImpure();
  56. void findImmedDom();
  57. void FollowCtrl(CALL_GRAPH *pcallGraph, STATE *pstate);
  58. void process_operands(ICODE *pIcode, STATE *pstate);
  59. boolT process_JMP(ICODE *pIcode, STATE *pstate, CALL_GRAPH *pcallGraph);
  60. boolT process_CALL(ICODE *pIcode, CALL_GRAPH *pcallGraph, STATE *pstate);
  61. void displayCFG();
  62. void freeCFG();
  63. void codeGen(std::ostream &fs);
  64. void displayStats();
  65. void mergeFallThrough(BB *pBB);
  66. protected:
  67. void findExps();
  68. void genDU1();
  69. void elimCondCodes();
  70. void liveRegAnalysis(dword in_liveOut);
  71. void findIdioms();
  72. void propLong();
  73. void genLiveKtes();
  74. };