tcg-internal.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * Internal declarations for Tiny Code Generator for QEMU
  3. *
  4. * Copyright (c) 2008 Fabrice Bellard
  5. *
  6. * Permission is hereby granted, free of charge, to any person obtaining a copy
  7. * of this software and associated documentation files (the "Software"), to deal
  8. * in the Software without restriction, including without limitation the rights
  9. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. * copies of the Software, and to permit persons to whom the Software is
  11. * furnished to do so, subject to the following conditions:
  12. *
  13. * The above copyright notice and this permission notice shall be included in
  14. * all copies or substantial portions of the Software.
  15. *
  16. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  19. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  22. * THE SOFTWARE.
  23. */
  24. #ifndef TCG_INTERNAL_H
  25. #define TCG_INTERNAL_H
  26. #include "tcg/helper-info.h"
  27. #define TCG_HIGHWATER 1024
  28. extern TCGContext tcg_init_ctx;
  29. extern TCGContext **tcg_ctxs;
  30. extern unsigned int tcg_cur_ctxs;
  31. extern unsigned int tcg_max_ctxs;
  32. void tcg_region_init(size_t tb_size, int splitwx, unsigned max_cpus);
  33. bool tcg_region_alloc(TCGContext *s);
  34. void tcg_region_initial_alloc(TCGContext *s);
  35. void tcg_region_prologue_set(TCGContext *s);
  36. static inline void *tcg_call_func(TCGOp *op)
  37. {
  38. return (void *)(uintptr_t)op->args[TCGOP_CALLO(op) + TCGOP_CALLI(op)];
  39. }
  40. static inline const TCGHelperInfo *tcg_call_info(TCGOp *op)
  41. {
  42. return (void *)(uintptr_t)op->args[TCGOP_CALLO(op) + TCGOP_CALLI(op) + 1];
  43. }
  44. static inline unsigned tcg_call_flags(TCGOp *op)
  45. {
  46. return tcg_call_info(op)->flags;
  47. }
  48. #if TCG_TARGET_REG_BITS == 32
  49. static inline TCGv_i32 TCGV_LOW(TCGv_i64 t)
  50. {
  51. return temp_tcgv_i32(tcgv_i64_temp(t) + HOST_BIG_ENDIAN);
  52. }
  53. static inline TCGv_i32 TCGV_HIGH(TCGv_i64 t)
  54. {
  55. return temp_tcgv_i32(tcgv_i64_temp(t) + !HOST_BIG_ENDIAN);
  56. }
  57. #else
  58. TCGv_i32 TCGV_LOW(TCGv_i64) QEMU_ERROR("32-bit code path is reachable");
  59. TCGv_i32 TCGV_HIGH(TCGv_i64) QEMU_ERROR("32-bit code path is reachable");
  60. #endif
  61. static inline TCGv_i64 TCGV128_LOW(TCGv_i128 t)
  62. {
  63. /* For 32-bit, offset by 2, which may then have TCGV_{LOW,HIGH} applied. */
  64. int o = HOST_BIG_ENDIAN ? 64 / TCG_TARGET_REG_BITS : 0;
  65. return temp_tcgv_i64(tcgv_i128_temp(t) + o);
  66. }
  67. static inline TCGv_i64 TCGV128_HIGH(TCGv_i128 t)
  68. {
  69. int o = HOST_BIG_ENDIAN ? 0 : 64 / TCG_TARGET_REG_BITS;
  70. return temp_tcgv_i64(tcgv_i128_temp(t) + o);
  71. }
  72. bool tcg_target_has_memory_bswap(MemOp memop);
  73. TCGTemp *tcg_temp_new_internal(TCGType type, TCGTempKind kind);
  74. /*
  75. * Locate or create a read-only temporary that is a constant.
  76. * This kind of temporary need not be freed, but for convenience
  77. * will be silently ignored by tcg_temp_free_*.
  78. */
  79. TCGTemp *tcg_constant_internal(TCGType type, int64_t val);
  80. TCGOp *tcg_gen_op1(TCGOpcode, TCGArg);
  81. TCGOp *tcg_gen_op2(TCGOpcode, TCGArg, TCGArg);
  82. TCGOp *tcg_gen_op3(TCGOpcode, TCGArg, TCGArg, TCGArg);
  83. TCGOp *tcg_gen_op4(TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg);
  84. TCGOp *tcg_gen_op5(TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg);
  85. TCGOp *tcg_gen_op6(TCGOpcode, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg, TCGArg);
  86. void vec_gen_2(TCGOpcode, TCGType, unsigned, TCGArg, TCGArg);
  87. void vec_gen_3(TCGOpcode, TCGType, unsigned, TCGArg, TCGArg, TCGArg);
  88. void vec_gen_4(TCGOpcode, TCGType, unsigned, TCGArg, TCGArg, TCGArg, TCGArg);
  89. void vec_gen_6(TCGOpcode opc, TCGType type, unsigned vece, TCGArg r,
  90. TCGArg a, TCGArg b, TCGArg c, TCGArg d, TCGArg e);
  91. #endif /* TCG_INTERNAL_H */