BPFInstrFormats.td 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //===-- BPFInstrFormats.td - BPF Instruction Formats -------*- 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. class BPFOpClass<bits<3> val> {
  9. bits<3> Value = val;
  10. }
  11. def BPF_LD : BPFOpClass<0x0>;
  12. def BPF_LDX : BPFOpClass<0x1>;
  13. def BPF_ST : BPFOpClass<0x2>;
  14. def BPF_STX : BPFOpClass<0x3>;
  15. def BPF_ALU : BPFOpClass<0x4>;
  16. def BPF_JMP : BPFOpClass<0x5>;
  17. def BPF_JMP32 : BPFOpClass<0x6>;
  18. def BPF_ALU64 : BPFOpClass<0x7>;
  19. class BPFSrcType<bits<1> val> {
  20. bits<1> Value = val;
  21. }
  22. def BPF_K : BPFSrcType<0x0>;
  23. def BPF_X : BPFSrcType<0x1>;
  24. class BPFArithOp<bits<4> val> {
  25. bits<4> Value = val;
  26. }
  27. def BPF_ADD : BPFArithOp<0x0>;
  28. def BPF_SUB : BPFArithOp<0x1>;
  29. def BPF_MUL : BPFArithOp<0x2>;
  30. def BPF_DIV : BPFArithOp<0x3>;
  31. def BPF_OR : BPFArithOp<0x4>;
  32. def BPF_AND : BPFArithOp<0x5>;
  33. def BPF_LSH : BPFArithOp<0x6>;
  34. def BPF_RSH : BPFArithOp<0x7>;
  35. def BPF_NEG : BPFArithOp<0x8>;
  36. def BPF_MOD : BPFArithOp<0x9>;
  37. def BPF_XOR : BPFArithOp<0xa>;
  38. def BPF_MOV : BPFArithOp<0xb>;
  39. def BPF_ARSH : BPFArithOp<0xc>;
  40. def BPF_END : BPFArithOp<0xd>;
  41. def BPF_XCHG : BPFArithOp<0xe>;
  42. def BPF_CMPXCHG : BPFArithOp<0xf>;
  43. class BPFEndDir<bits<1> val> {
  44. bits<1> Value = val;
  45. }
  46. def BPF_TO_LE : BPFSrcType<0x0>;
  47. def BPF_TO_BE : BPFSrcType<0x1>;
  48. class BPFJumpOp<bits<4> val> {
  49. bits<4> Value = val;
  50. }
  51. def BPF_JA : BPFJumpOp<0x0>;
  52. def BPF_JEQ : BPFJumpOp<0x1>;
  53. def BPF_JGT : BPFJumpOp<0x2>;
  54. def BPF_JGE : BPFJumpOp<0x3>;
  55. def BPF_JNE : BPFJumpOp<0x5>;
  56. def BPF_JSGT : BPFJumpOp<0x6>;
  57. def BPF_JSGE : BPFJumpOp<0x7>;
  58. def BPF_CALL : BPFJumpOp<0x8>;
  59. def BPF_EXIT : BPFJumpOp<0x9>;
  60. def BPF_JLT : BPFJumpOp<0xa>;
  61. def BPF_JLE : BPFJumpOp<0xb>;
  62. def BPF_JSLT : BPFJumpOp<0xc>;
  63. def BPF_JSLE : BPFJumpOp<0xd>;
  64. class BPFWidthModifer<bits<2> val> {
  65. bits<2> Value = val;
  66. }
  67. def BPF_W : BPFWidthModifer<0x0>;
  68. def BPF_H : BPFWidthModifer<0x1>;
  69. def BPF_B : BPFWidthModifer<0x2>;
  70. def BPF_DW : BPFWidthModifer<0x3>;
  71. class BPFModeModifer<bits<3> val> {
  72. bits<3> Value = val;
  73. }
  74. def BPF_IMM : BPFModeModifer<0x0>;
  75. def BPF_ABS : BPFModeModifer<0x1>;
  76. def BPF_IND : BPFModeModifer<0x2>;
  77. def BPF_MEM : BPFModeModifer<0x3>;
  78. def BPF_ATOMIC : BPFModeModifer<0x6>;
  79. class BPFAtomicFlag<bits<4> val> {
  80. bits<4> Value = val;
  81. }
  82. def BPF_FETCH : BPFAtomicFlag<0x1>;
  83. class InstBPF<dag outs, dag ins, string asmstr, list<dag> pattern>
  84. : Instruction {
  85. field bits<64> Inst;
  86. field bits<64> SoftFail = 0;
  87. let Size = 8;
  88. let Namespace = "BPF";
  89. let DecoderNamespace = "BPF";
  90. BPFOpClass BPFClass;
  91. let Inst{58-56} = BPFClass.Value;
  92. dag OutOperandList = outs;
  93. dag InOperandList = ins;
  94. let AsmString = asmstr;
  95. let Pattern = pattern;
  96. }
  97. // Pseudo instructions
  98. class Pseudo<dag outs, dag ins, string asmstr, list<dag> pattern>
  99. : InstBPF<outs, ins, asmstr, pattern> {
  100. let Inst{63-0} = 0;
  101. let isPseudo = 1;
  102. }