[PATCH] D104974: [doc]Added examples for generic opcodes

Jessica Paquette via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 28 08:56:33 PDT 2021


paquette added a comment.

I think that @xgupta's suggestions are a good idea. I would recommend changing any unnamed vregs (e.g. `%0`, `%2`, etc.) to named values.

`llvm/include/llvm/Target/GenericOpcodes.td` has the source for these. There operand lists may have some more descriptive names that you can reuse. E.g.:

  // Generic branch to jump table entry
  def G_BRJT : GenericInstruction {
    let OutOperandList = (outs);
    let InOperandList = (ins ptype0:$tbl, unknown:$jti, type1:$idx);
    let hasSideEffects = false;
    let isBranch = true;
    let isTerminator = true;
    let isBarrier = true;
    let isIndirectBranch = true;
  }

The input names here aren't //super// descriptive, but they give a better hint than what we have right now.

Ultimately, I think it would be nice if the documentation was written in this style:

  G_ADD
  ^^^^^^
  
  Adds %src1 to %src0 and stores the result in %dst.
  
  .. code-block:: none
  
    %dst:_(s32) = G_ADD %src0:_(s32), %src1:_(s32)



================
Comment at: llvm/docs/GlobalISel/GenericOpcode.rst:746
+.. code-block:: none
+  G_BRINDIRECT %0(p0)
+
----------------



================
Comment at: llvm/docs/GlobalISel/GenericOpcode.rst:754
+.. code-block:: none
+  G_BRJT %9(p0), %jump-table.0, %5(s64)
+
----------------
We could add more descriptive names here, like @xgupta suggested.

I just copied these from GenericOpcodes.td. (Although I changed "`$tbl`" to "`ptr`" here because I think that's more beginner-friendly.)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D104974/new/

https://reviews.llvm.org/D104974



More information about the llvm-commits mailing list