This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][Parser] Add `parseBase64Bytes`.
ClosedPublic

Authored by bzcheeseman on Nov 15 2022, 9:23 PM.

Details

Summary

This patch adds parseBase64Bytes to the parser. It attempts to avoid double-allocating the buffer by re-using the token's spelling directly and eliding the quotes if they exist. It also avoids extra allocations by using std::vector<char> in the API - something we should change when the llvm::decodeBase64 API changes.

Diff Detail

Event Timeline

bzcheeseman created this revision.Nov 15 2022, 9:23 PM
Herald added a project: Restricted Project. · View Herald Transcript
bzcheeseman requested review of this revision.Nov 15 2022, 9:23 PM
rriddle accepted this revision.Nov 18 2022, 1:48 AM
rriddle added inline comments.
mlir/lib/AsmParser/AsmParserImpl.h
262

Why does this need to trim whitespace? I'd just consume the string characters and let decodeBase64 error out as necessary.

This revision is now accepted and ready to land.Nov 18 2022, 1:48 AM
bzcheeseman added inline comments.Nov 18 2022, 8:12 AM
mlir/lib/AsmParser/AsmParserImpl.h
262

It's because we're using the token spelling directly, so I couldn't actually get *any* example to work without trim whitespace and trimming the quotes.

If you use token.getStringValue() then it works without trimming, so it's a tradeoff between double-allocating the buffer and having to trim.

This revision was landed with ongoing or failed builds.Nov 18 2022, 8:13 AM
This revision was automatically updated to reflect the committed changes.
bzcheeseman added inline comments.Nov 18 2022, 8:14 AM
mlir/lib/AsmParser/AsmParserImpl.h
262

I'm happy to revisit this and go the other way if you'd prefer :)