axe_reg_alloc.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Andrea Di Biagio
  3. * Politecnico di Milano, 2007
  4. *
  5. * axe_reg_alloc.h
  6. * Formal Languages & Compilers Machine, 2007/2008
  7. *
  8. */
  9. #ifndef _AXE_REG_ALLOC_H
  10. #define _AXE_REG_ALLOC_H
  11. #include "axe_struct.h"
  12. #include "axe_engine.h"
  13. #include "collections.h"
  14. #include "axe_cflow_graph.h"
  15. typedef struct t_live_interval
  16. {
  17. int varID; /* a variable identifier */
  18. int startPoint; /* the index of the first instruction
  19. * that make use of (or define) this variable */
  20. int endPoint; /* the index of the last instruction
  21. * that make use of (or define) this variable */
  22. }t_live_interval;
  23. typedef struct t_reg_allocator
  24. {
  25. t_list *live_intervals; /* an ordered list of live intervals */
  26. int regNum; /* the number of registers of the machine */
  27. int varNum; /* number of variables */
  28. int *bindings; /* an array of bindings of kind : varID-->register.
  29. * If a certain variable X need to be spilled
  30. * in memory, the value of `register' is set
  31. * to the value of the macro RA_SPILL_REQUIRED */
  32. t_list *freeRegisters; /* a list of free registers */
  33. }t_reg_allocator;
  34. /* Initialize the internal structure of the register allocator */
  35. extern t_reg_allocator * initializeRegAlloc(t_cflow_Graph *graph);
  36. /* finalize all the data structure associated with the given register allocator */
  37. extern void finalizeRegAlloc(t_reg_allocator *RA);
  38. /* execute the register allocation algorythm (Linear Scan) */
  39. extern int execute_linear_scan(t_reg_allocator *RA);
  40. #endif