IntrinsicsLoongArch.td 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //===- IntrinsicsLoongArch.td - Defines LoongArch intrinsics *- tablegen -*===//
  2. //
  3. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  4. // See https://llvm.org/LICENSE.txt for license information.
  5. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  6. //
  7. //===----------------------------------------------------------------------===//
  8. //
  9. // This file defines all of the LoongArch-specific intrinsics.
  10. //
  11. //===----------------------------------------------------------------------===//
  12. let TargetPrefix = "loongarch" in {
  13. //===----------------------------------------------------------------------===//
  14. // Atomics
  15. // T @llvm.<name>.T.<p>(any*, T, T, T imm);
  16. class MaskedAtomicRMW<LLVMType itype>
  17. : Intrinsic<[itype], [llvm_anyptr_ty, itype, itype, itype],
  18. [IntrArgMemOnly, NoCapture<ArgIndex<0>>, ImmArg<ArgIndex<3>>]>;
  19. // We define 32-bit and 64-bit variants of the above, where T stands for i32
  20. // or i64 respectively:
  21. multiclass MaskedAtomicRMWIntrinsics {
  22. // i32 @llvm.<name>.i32.<p>(any*, i32, i32, i32 imm);
  23. def _i32 : MaskedAtomicRMW<llvm_i32_ty>;
  24. // i64 @llvm.<name>.i32.<p>(any*, i64, i64, i64 imm);
  25. def _i64 : MaskedAtomicRMW<llvm_i64_ty>;
  26. }
  27. multiclass MaskedAtomicRMWFiveOpIntrinsics {
  28. // TODO: Support cmpxchg on LA32.
  29. // i64 @llvm.<name>.i64.<p>(any*, i64, i64, i64, i64 imm);
  30. def _i64 : MaskedAtomicRMWFiveArg<llvm_i64_ty>;
  31. }
  32. defm int_loongarch_masked_atomicrmw_xchg : MaskedAtomicRMWIntrinsics;
  33. defm int_loongarch_masked_atomicrmw_add : MaskedAtomicRMWIntrinsics;
  34. defm int_loongarch_masked_atomicrmw_sub : MaskedAtomicRMWIntrinsics;
  35. defm int_loongarch_masked_atomicrmw_nand : MaskedAtomicRMWIntrinsics;
  36. defm int_loongarch_masked_atomicrmw_umax : MaskedAtomicRMWIntrinsics;
  37. defm int_loongarch_masked_atomicrmw_umin : MaskedAtomicRMWIntrinsics;
  38. defm int_loongarch_masked_atomicrmw_max : MaskedAtomicRMWFiveOpIntrinsics;
  39. defm int_loongarch_masked_atomicrmw_min : MaskedAtomicRMWFiveOpIntrinsics;
  40. // @llvm.loongarch.masked.cmpxchg.i64.<p>(
  41. // ptr addr, grlen cmpval, grlen newval, grlen mask, grlenimm ordering)
  42. defm int_loongarch_masked_cmpxchg : MaskedAtomicRMWFiveOpIntrinsics;
  43. //===----------------------------------------------------------------------===//
  44. // LoongArch BASE
  45. def int_loongarch_break : Intrinsic<[], [llvm_i32_ty], [ImmArg<ArgIndex<0>>]>;
  46. def int_loongarch_cacop_d : Intrinsic<[], [llvm_i64_ty, llvm_i64_ty, llvm_i64_ty],
  47. [ImmArg<ArgIndex<0>>, ImmArg<ArgIndex<2>>]>;
  48. def int_loongarch_cacop_w : Intrinsic<[], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
  49. [ImmArg<ArgIndex<0>>, ImmArg<ArgIndex<2>>]>;
  50. def int_loongarch_dbar : Intrinsic<[], [llvm_i32_ty], [ImmArg<ArgIndex<0>>]>;
  51. def int_loongarch_ibar : Intrinsic<[], [llvm_i32_ty], [ImmArg<ArgIndex<0>>]>;
  52. def int_loongarch_movfcsr2gr : Intrinsic<[llvm_i32_ty], [llvm_i32_ty],
  53. [ImmArg<ArgIndex<0>>]>;
  54. def int_loongarch_movgr2fcsr : Intrinsic<[], [llvm_i32_ty, llvm_i32_ty],
  55. [ImmArg<ArgIndex<0>>]>;
  56. def int_loongarch_syscall : Intrinsic<[], [llvm_i32_ty], [ImmArg<ArgIndex<0>>]>;
  57. def int_loongarch_crc_w_b_w : Intrinsic<[llvm_i32_ty],
  58. [llvm_i32_ty, llvm_i32_ty]>;
  59. def int_loongarch_crc_w_h_w : Intrinsic<[llvm_i32_ty],
  60. [llvm_i32_ty, llvm_i32_ty]>;
  61. def int_loongarch_crc_w_w_w : Intrinsic<[llvm_i32_ty],
  62. [llvm_i32_ty, llvm_i32_ty]>;
  63. def int_loongarch_crc_w_d_w : Intrinsic<[llvm_i32_ty],
  64. [llvm_i64_ty, llvm_i32_ty]>;
  65. def int_loongarch_crcc_w_b_w : Intrinsic<[llvm_i32_ty],
  66. [llvm_i32_ty, llvm_i32_ty]>;
  67. def int_loongarch_crcc_w_h_w : Intrinsic<[llvm_i32_ty],
  68. [llvm_i32_ty, llvm_i32_ty]>;
  69. def int_loongarch_crcc_w_w_w : Intrinsic<[llvm_i32_ty],
  70. [llvm_i32_ty, llvm_i32_ty]>;
  71. def int_loongarch_crcc_w_d_w : Intrinsic<[llvm_i32_ty],
  72. [llvm_i64_ty, llvm_i32_ty]>;
  73. def int_loongarch_csrrd_w : Intrinsic<[llvm_i32_ty], [llvm_i32_ty],
  74. [ImmArg<ArgIndex<0>>]>;
  75. def int_loongarch_csrrd_d : Intrinsic<[llvm_i64_ty], [llvm_i32_ty],
  76. [ImmArg<ArgIndex<0>>]>;
  77. def int_loongarch_csrwr_w : Intrinsic<[llvm_i32_ty],
  78. [llvm_i32_ty, llvm_i32_ty],
  79. [ImmArg<ArgIndex<1>>]>;
  80. def int_loongarch_csrwr_d : Intrinsic<[llvm_i64_ty],
  81. [llvm_i64_ty, llvm_i32_ty],
  82. [ImmArg<ArgIndex<1>>]>;
  83. def int_loongarch_csrxchg_w : Intrinsic<[llvm_i32_ty],
  84. [llvm_i32_ty, llvm_i32_ty,
  85. llvm_i32_ty],
  86. [ImmArg<ArgIndex<2>>]>;
  87. def int_loongarch_csrxchg_d : Intrinsic<[llvm_i64_ty],
  88. [llvm_i64_ty, llvm_i64_ty,
  89. llvm_i32_ty],
  90. [ImmArg<ArgIndex<2>>]>;
  91. def int_loongarch_iocsrrd_b : Intrinsic<[llvm_i32_ty], [llvm_i32_ty]>;
  92. def int_loongarch_iocsrrd_h : Intrinsic<[llvm_i32_ty], [llvm_i32_ty]>;
  93. def int_loongarch_iocsrrd_w : Intrinsic<[llvm_i32_ty], [llvm_i32_ty]>;
  94. def int_loongarch_iocsrrd_d : Intrinsic<[llvm_i64_ty], [llvm_i32_ty]>;
  95. def int_loongarch_iocsrwr_b : Intrinsic<[], [llvm_i32_ty, llvm_i32_ty]>;
  96. def int_loongarch_iocsrwr_h : Intrinsic<[], [llvm_i32_ty, llvm_i32_ty]>;
  97. def int_loongarch_iocsrwr_w : Intrinsic<[], [llvm_i32_ty, llvm_i32_ty]>;
  98. def int_loongarch_iocsrwr_d : Intrinsic<[], [llvm_i64_ty, llvm_i32_ty]>;
  99. def int_loongarch_cpucfg : Intrinsic<[llvm_i32_ty], [llvm_i32_ty]>;
  100. def int_loongarch_asrtle_d : Intrinsic<[], [llvm_i64_ty, llvm_i64_ty]>;
  101. def int_loongarch_asrtgt_d : Intrinsic<[], [llvm_i64_ty, llvm_i64_ty]>;
  102. def int_loongarch_lddir_d : Intrinsic<[llvm_i64_ty],
  103. [llvm_i64_ty, llvm_i64_ty],
  104. [ImmArg<ArgIndex<1>>]>;
  105. def int_loongarch_ldpte_d : Intrinsic<[], [llvm_i64_ty, llvm_i64_ty],
  106. [ImmArg<ArgIndex<1>>]>;
  107. } // TargetPrefix = "loongarch"