Function.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2022 The V-Gears Team
  3. *
  4. * This file is part of V-Gears
  5. *
  6. * V-Gears is free software: you can redistribute it and/or modify it under
  7. * terms of the GNU General Public License as published by the Free Software
  8. * Foundation, version 3.0 (GPLv3) of the License.
  9. *
  10. * V-Gears is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. */
  15. #pragma once
  16. #include <set>
  17. #include "CodeGenerator.h"
  18. #include "Disassembler.h"
  19. #include "Graph.h"
  20. /**
  21. * Structure representing a function.
  22. */
  23. struct Function {
  24. /**
  25. * Constructor.
  26. *
  27. * Required for use with STL, should not be called manually.
  28. */
  29. Function(): start_addr(0), end_addr(0), num_instructions(0), ret_val(true){}
  30. /**
  31. * Constructor.
  32. *
  33. * @param start_addr[in] Address of the first instruction in the function.
  34. * @param end_addr[in] Address of the last instruction in the function
  35. */
  36. Function(uint32 start_addr, uint32 end_addr):
  37. start_addr(start_addr), end_addr(end_addr), num_instructions(0), ret_val(true){}
  38. /**
  39. * The function starting address.
  40. */
  41. uint32 start_addr;
  42. /**
  43. * The function ending address.
  44. */
  45. uint32 end_addr;
  46. /**
  47. * Number of instructions in the function.
  48. */
  49. uint32 num_instructions;
  50. /**
  51. * The name of the function.
  52. */
  53. std::string name;
  54. /**
  55. * The function vertex.
  56. */
  57. GraphVertex vertex;
  58. /**
  59. * Number of arguments in the function.
  60. */
  61. uint32 num_args;
  62. /**
  63. * Return value of the function.
  64. */
  65. bool ret_val;
  66. /**
  67. * Metadata for code generation.
  68. */
  69. std::string metadata;
  70. };