src/lj_target_arm64.h - luajit-2.0-src

Data types defined

Macros defined

Source code

  1. /*
  2. ** Definitions for ARM64 CPUs.
  3. ** Copyright (C) 2005-2015 Mike Pall. See Copyright Notice in luajit.h
  4. */

  5. #ifndef _LJ_TARGET_ARM64_H
  6. #define _LJ_TARGET_ARM64_H

  7. /* -- Registers IDs ------------------------------------------------------- */

  8. #define GPRDEF(_) \
  9.   _(X0) _(X1) _(X2) _(X3) _(X4) _(X5) _(X6) _(X7) \
  10.   _(X8) _(X9) _(X10) _(X11) _(X12) _(X13) _(X14) _(X15) \
  11.   _(X16) _(X17) _(X18) _(X19) _(X20) _(X21) _(X22) _(X23) \
  12.   _(X24) _(X25) _(X26) _(X27) _(X28) _(FP) _(LR) _(SP)
  13. #define FPRDEF(_) \
  14.   _(D0) _(D1) _(D2) _(D3) _(D4) _(D5) _(D6) _(D7) \
  15.   _(D8) _(D9) _(D10) _(D11) _(D12) _(D13) _(D14) _(D15) \
  16.   _(D16) _(D17) _(D18) _(D19) _(D20) _(D21) _(D22) _(D23) \
  17.   _(D24) _(D25) _(D26) _(D27) _(D28) _(D29) _(D30) _(D31)
  18. #define VRIDDEF(_)

  19. #define RIDENUM(name)        RID_##name,

  20. enum {
  21.   GPRDEF(RIDENUM)                /* General-purpose registers (GPRs). */
  22.   FPRDEF(RIDENUM)                /* Floating-point registers (FPRs). */
  23.   RID_MAX,
  24.   RID_TMP = RID_LR,
  25.   RID_ZERO = RID_SP,

  26.   /* Calling conventions. */
  27.   RID_RET = RID_X0,
  28.   RID_FPRET = RID_D0,

  29.   /* These definitions must match with the *.dasc file(s): */
  30.   RID_BASE = RID_X19,                /* Interpreter BASE. */
  31.   RID_LPC = RID_X21,                /* Interpreter PC. */
  32.   RID_GL = RID_X22,                /* Interpreter GL. */
  33.   RID_LREG = RID_X23,                /* Interpreter L. */

  34.   /* Register ranges [min, max) and number of registers. */
  35.   RID_MIN_GPR = RID_X0,
  36.   RID_MAX_GPR = RID_SP+1,
  37.   RID_MIN_FPR = RID_MAX_GPR,
  38.   RID_MAX_FPR = RID_D31+1,
  39.   RID_NUM_GPR = RID_MAX_GPR - RID_MIN_GPR,
  40.   RID_NUM_FPR = RID_MAX_FPR - RID_MIN_FPR
  41. };

  42. #define RID_NUM_KREF                RID_NUM_GPR
  43. #define RID_MIN_KREF                RID_X0

  44. /* -- Register sets ------------------------------------------------------- */

  45. /* Make use of all registers, except for x18, fp, lr and sp. */
  46. #define RSET_FIXED \
  47.   (RID2RSET(RID_X18)|RID2RSET(RID_FP)|RID2RSET(RID_LR)|RID2RSET(RID_SP))
  48. #define RSET_GPR        (RSET_RANGE(RID_MIN_GPR, RID_MAX_GPR) - RSET_FIXED)
  49. #define RSET_FPR        RSET_RANGE(RID_MIN_FPR, RID_MAX_FPR)
  50. #define RSET_ALL        (RSET_GPR|RSET_FPR)
  51. #define RSET_INIT        RSET_ALL

  52. /* lr is an implicit scratch register. */
  53. #define RSET_SCRATCH_GPR        (RSET_RANGE(RID_X0, RID_X17+1))
  54. #define RSET_SCRATCH_FPR \
  55.   (RSET_RANGE(RID_D0, RID_D7+1)|RSET_RANGE(RID_D16, RID_D31+1))
  56. #define RSET_SCRATCH                (RSET_SCRATCH_GPR|RSET_SCRATCH_FPR)
  57. #define REGARG_FIRSTGPR                RID_X0
  58. #define REGARG_LASTGPR                RID_X7
  59. #define REGARG_NUMGPR                8
  60. #define REGARG_FIRSTFPR                RID_D0
  61. #define REGARG_LASTFPR                RID_D7
  62. #define REGARG_NUMFPR                8

  63. /* -- Instructions -------------------------------------------------------- */

  64. /* Instruction fields. */
  65. #define A64F_D(r)        (r)
  66. #define A64F_N(r)       ((r) << 5)
  67. #define A64F_A(r)       ((r) << 10)
  68. #define A64F_M(r)       ((r) << 16)
  69. #define A64F_U16(x)        ((x) << 5)
  70. #define A64F_S26(x)        (x)
  71. #define A64F_S19(x)        ((x) << 5)

  72. typedef enum A64Ins {
  73.   A64I_MOVZw = 0x52800000,
  74.   A64I_MOVZx = 0xd2800000,
  75.   A64I_LDRLw = 0x18000000,
  76.   A64I_LDRLx = 0x58000000,
  77.   A64I_NOP = 0xd503201f,
  78.   A64I_B = 0x14000000,
  79.   A64I_BR = 0xd61f0000,
  80. } A64Ins;

  81. #endif