jit_codegen.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2021 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #ifndef _JIT_CODEGEN_H_
  6. #define _JIT_CODEGEN_H_
  7. #include "bh_platform.h"
  8. #include "jit_compiler.h"
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. /**
  13. * Initialize codegen module, such as instruction encoder.
  14. *
  15. * @return true if succeeded; false if failed.
  16. */
  17. bool
  18. jit_codegen_init();
  19. /**
  20. * Destroy codegen module, such as instruction encoder.
  21. */
  22. void
  23. jit_codegen_destroy();
  24. /**
  25. * Get hard register information of each kind.
  26. *
  27. * @return the JitHardRegInfo array of each kind
  28. */
  29. const JitHardRegInfo *
  30. jit_codegen_get_hreg_info();
  31. /**
  32. * Get hard register by name.
  33. *
  34. * @param name the name of the hard register
  35. *
  36. * @return the hard register of the name
  37. */
  38. JitReg
  39. jit_codegen_get_hreg_by_name(const char *name);
  40. /**
  41. * Generate native code for the given compilation context
  42. *
  43. * @param cc the compilation context that is ready to do codegen
  44. *
  45. * @return true if succeeds, false otherwise
  46. */
  47. bool
  48. jit_codegen_gen_native(JitCompContext *cc);
  49. /**
  50. * lower unsupported operations to supported ones for the target.
  51. *
  52. * @param cc the compilation context that is ready to do codegen
  53. *
  54. * @return true if succeeds, false otherwise
  55. */
  56. bool
  57. jit_codegen_lower(JitCompContext *cc);
  58. /**
  59. * Dump native code in the given range to assembly.
  60. *
  61. * @param begin_addr begin address of the native code
  62. * @param end_addr end address of the native code
  63. */
  64. void
  65. jit_codegen_dump_native(void *begin_addr, void *end_addr);
  66. int
  67. jit_codegen_interp_jitted_glue(void *self, JitInterpSwitchInfo *info, void *pc);
  68. #ifdef __cplusplus
  69. }
  70. #endif
  71. #endif /* end of _JIT_CODEGEN_H_ */