This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Add "InitValue": Handle operands with set bit values in decoder methods
ClosedPublic

Authored by nlguillemot on Jun 24 2019, 3:13 PM.

Details

Summary

The problem:

When an operand had bits explicitly set to "1" (as in the InitValue.td test case attached), the decoder was ignoring those bits, and the DecoderMethod was receiving an input where the bits were still zero.

The solution:

We added an "InitValue" variable that stores the initial value of the operand based on what bits were explicitly initialized to 1 in TableGen code. The generated decoder code then uses that initial value to initialize the "tmp" variable, then calls fieldFromInstruction to read the values for the remaining bits that were left unknown in TableGen.

This is mainly useful when there are variations of an instruction that differ based on what bits are set in the operands, since this change makes it possible to access those bits in a DecoderMethod. The DecoderMethod can use those bits to know how to handle the input.

Patch by Nicolas Guillemot

Diff Detail

Repository
rL LLVM

Event Timeline

nlguillemot created this revision.Jun 24 2019, 3:13 PM
dsanders accepted this revision.Jul 18 2019, 6:40 PM

LGTM with a couple nits fixed

test/TableGen/FixedLenDecoderEmitter/InitValue.td
11 ↗(On Diff #206305)

This is a bit confusing and isn't really doing anything helpful. For this test case, I'd prefer to just have the lets duplicated inside the defs.

Also, the formatting in this file isn't following the conventions used by most tablegen files (e.g. closing } being in the same column as the 'd' from def)

This revision is now accepted and ready to land.Jul 18 2019, 6:40 PM
nlguillemot marked an inline comment as done.Jul 19 2019, 9:11 AM
nlguillemot added inline comments.
test/TableGen/FixedLenDecoderEmitter/InitValue.td
11 ↗(On Diff #206305)

The formatting is copy/pasted from test/TableGen/BitOffsetDecoder.td, so that's my "claim of innocence". Of course we could change it anyways, and clean up BitOffsetDecoder.td as well in a separate patch. Thoughts?

nlguillemot marked an inline comment as done.Aug 1 2019, 1:17 PM
nlguillemot added inline comments.
test/TableGen/FixedLenDecoderEmitter/InitValue.td
11 ↗(On Diff #206305)

ping - what would you like to do?

dsanders added inline comments.Aug 7 2019, 7:36 PM
test/TableGen/FixedLenDecoderEmitter/InitValue.td
11 ↗(On Diff #206305)

I'd prefer it to be formatted in the conventional way but since the same formatting is used elsewhere it's ok to keep it as-is

I don't have commit privileges yet. Could somebody commit this for me?

nlguillemot edited the summary of this revision. (Show Details)Aug 9 2019, 10:27 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 9 2019, 10:32 AM