This is an archive of the discontinued LLVM Phabricator instance.

[mlir:Bytecode] Add encoding support for a majority of the builtin attributes
ClosedPublic

Authored by rriddle on Aug 24 2022, 2:40 AM.

Details

Summary

This adds support for the non-location, non-elements, non-affine
builtin attributes.

Diff Detail

Event Timeline

rriddle created this revision.Aug 24 2022, 2:40 AM
rriddle requested review of this revision.Aug 24 2022, 2:40 AM

Nice!

mlir/docs/BytecodeFormat.md
78

zigzag encoding for 64-bits integers:

mlir/include/mlir/Bytecode/BytecodeImplementation.h
175–176

What about this TODO?
We could support overloads with int64_t with zigzag encoding for example, without paying the price of APInt.

181

Worth mentioning that this is using ZigZag encoding for symmetry between negative and positive numbers.

Right, now if I have a uintX_t, it's not clear to me why one would pick this method instead of the one above directly for example.

mlir/lib/Bytecode/Reader/BytecodeReader.cpp
137

This bit manipulation is magic :)

(Translation: I'm too lazy to try to figure it out right now, but hey if it works...)

rriddle updated this revision to Diff 455286.Aug 24 2022, 10:56 AM
rriddle marked 4 inline comments as done.
rriddle added inline comments.Aug 24 2022, 10:57 AM
mlir/include/mlir/Bytecode/BytecodeImplementation.h
175–176

Yeah, I was deferring it until I had a method that needed it, but let me just add now (it just forwards to the underlying method anyways).

mlir/lib/Bytecode/Reader/BytecodeReader.cpp
137

I added a comment of the actual formula, which is easier to read IMO. This right here though, is the same thing that protobufs use for zigzag decoding.

jpienaar accepted this revision.Aug 24 2022, 12:20 PM

Nice, reads without surprises :-)

mlir/lib/Bytecode/Reader/BytecodeReader.cpp
563

I would have thought

read<What><How>

would result in better method sorting order. E.g., if I want to read an APLfloat , autocomplete would give me the variants just by me saying readAPFloat (

mlir/lib/IR/BuiltinDialectBytecode.cpp
83

Should we add comment why we don't have or want DenseElementsAttr here?

300–301

Keep these in alphabetical order?

This revision is now accepted and ready to land.Aug 24 2022, 12:20 PM
rriddle marked 3 inline comments as done.Aug 24 2022, 1:24 PM
rriddle added inline comments.
mlir/lib/IR/BuiltinDialectBytecode.cpp
83

I'm leaving that out for now, because I just haven't gotten to all of the attributes (so I haven't had time to figure out what we want to do there). We'll need to have a conversation on some of the attributes though, to figure out if we are planning on deleting things. We could also just add support for now, but then just delete it whenever we do drop the attributes. This all factors into versioning a bit as well (I don't want to version until we figure out what we want to change and how).

rriddle updated this revision to Diff 455359.Aug 24 2022, 1:46 PM
rriddle marked an inline comment as done.
mehdi_amini accepted this revision.Aug 24 2022, 2:15 PM
rriddle updated this revision to Diff 455861.Aug 26 2022, 3:55 AM