This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ][z/OS] Create utility functions for converting between EBCDIC and UTF-8.
ClosedPublic

Authored by Everybody0523 on Apr 20 2023, 11:00 AM.

Details

Summary

This patch adds some utility functions for converting between EBCDIC and UTF-8.

This functionality was originally intended to be packed alongside general character set conversion, but based on comments on an RFC it seems more prudent to separate the two tasks.

This functionality will be used in the SystemZ back-end for z/OS as well as GOFF Object File read/write support.

Diff Detail

Event Timeline

Everybody0523 created this revision.Apr 20 2023, 11:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 11:00 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Everybody0523 requested review of this revision.Apr 20 2023, 11:00 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 20 2023, 11:00 AM
efriedma added inline comments.Apr 20 2023, 3:49 PM
llvm/include/llvm/Support/ConvertEBCDIC.h
7

Probably should indicate in the header somewhere precisely what encoding this uses; there are a number of different "EBCDIC" encodings (although probably most of them are irrelevant these days).

llvm/lib/Support/ConvertEBCDIC.cpp
110

Out-of-date comment?

Correct comments.

efriedma added inline comments.Apr 21 2023, 9:45 AM
llvm/lib/Support/ConvertEBCDIC.cpp
101

Maybe convertToUTF8 should return void, instead of an std::error_code, because it can't fail. (The only reason I can think of to keep it is consistency with conversions which can fail. But that doesn't seem compelling given an explicit entry point like this.)

Everybody0523 added inline comments.Apr 21 2023, 12:15 PM
llvm/lib/Support/ConvertEBCDIC.cpp
101

FWIW I actually did personally prefer the consistency with the reverse direction (which can fail), but I'm open to changing it.

Make convertToUTF8 return void since it cannot fail.

This revision is now accepted and ready to land.Apr 21 2023, 1:41 PM
cor3ntin added inline comments.Apr 24 2023, 5:35 AM
llvm/lib/Support/ConvertEBCDIC.cpp
76

I think I'd prefer to assert Result is empty
also, I think we should do something like Result.reserve(Source.size()) to minimize allocations in the common case

107

Same comment as above

Require Result to be an empty SmallVector.