Function.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. /**
  20. * Structure representing a function.
  21. */
  22. struct Function {
  23. /**
  24. * Constructor.
  25. *
  26. * Required for use with STL, should not be called manually.
  27. */
  28. Function(): start_addr(0), end_addr(0), num_instructions(0){}
  29. /**
  30. * Constructor.
  31. *
  32. * @param start_addr[in] Address of the first instruction in the function.
  33. * @param end_addr[in] Address of the last instruction in the function
  34. */
  35. Function(uint32 start_addr, uint32 end_addr):
  36. start_addr(start_addr), end_addr(end_addr), num_instructions(0){}
  37. /**
  38. * The function starting address.
  39. */
  40. uint32 start_addr;
  41. /**
  42. * The function ending address.
  43. */
  44. uint32 end_addr;
  45. /**
  46. * Number of instructions in the function.
  47. */
  48. uint32 num_instructions;
  49. /**
  50. * The name of the function.
  51. */
  52. std::string name;
  53. /**
  54. * The function vertex.
  55. */
  56. GraphVertex vertex;
  57. /**
  58. * Number of arguments in the function.
  59. */
  60. uint32 num_args;
  61. /**
  62. * Return value of the function.
  63. */
  64. bool ret_val;
  65. /**
  66. * Metadata for code generation.
  67. */
  68. std::string metadata;
  69. };