Added examples to G_BR, G_BRCOND, G_BRJT, G_BRINDIRECT
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
I would suggest you to take your full time, understand Generic Machine IR thoroughly i.e. know the meaning of every letter in the testcases from where you taken these examples. And then write more descriptive Opcode docs something like as LLVM IR instruction reference https://llvm.org/docs/LangRef.html#instruction-reference.
llvm/docs/GlobalISel/GenericOpcode.rst | ||
---|---|---|
768 | why 1 not 0 or 2? | |
776 | Why 4 not 3 or 5 or maybe 0? |
Ok will do that . Since there are short descriptions provided for the Generic opcodes, I thought I have to write short descriptions.
llvm/docs/GlobalISel/GenericOpcode.rst | ||
---|---|---|
768 | Since other Generic opcodes had examples with mentioning specific registers, I also took an example similar to that . For eg: the example of G_PHI |
Ok will do that . Since there are short descriptions provided for the Generic opcodes, I thought I have to write short descriptions.
I think more description will be better, beginner may find it difficult to understand without details.
Active developers might have more thoughts on how much you should extend it :)
okk. @paquette @aemerson @arsenm @gandhi21299 @kbarton looking forward for your suggestions.
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)
llvm/docs/GlobalISel/GenericOpcode.rst | ||
---|---|---|
784 | ||
792 | 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.) |
llvm/docs/GlobalISel/GenericOpcode.rst | ||
---|---|---|
768 | This isn't true, there's just currently some oddity that ends up emitting an extra block in IRTranslator |
sorry ...I have replied to inline comments week before but forgot to click the 'submit' button below. New to phabricator ..so keep on forgetting these small things. 😅
Will be updating other changes soon.
llvm/docs/GlobalISel/GenericOpcode.rst | ||
---|---|---|
295 | I suggest to make it clear that this sentence references the given example. |
llvm/docs/GlobalISel/GenericOpcode.rst | ||
---|---|---|
295 | Yes that would be precise, thanks for indicating it! |
minor typo