[llvm] [GOFF] Refactor writing GOFF records (PR #93855)

Kai Nacke via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 7 10:18:07 PDT 2024


================
@@ -25,25 +25,87 @@ namespace llvm {
 // to use yaml::IO, we use these structures which are closer to the source.
 namespace GOFFYAML {
 
-struct FileHeader {
-  uint32_t TargetEnvironment = 0;
-  uint32_t TargetOperatingSystem = 0;
-  uint16_t CCSID = 0;
-  StringRef CharacterSetName;
-  StringRef LanguageProductIdentifier;
-  uint32_t ArchitectureLevel = 0;
-  std::optional<uint16_t> InternalCCSID;
-  std::optional<uint8_t> TargetSoftwareEnvironment;
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_AMODE)
+LLVM_YAML_STRONG_TYPEDEF(uint8_t, GOFF_ENDFLAGS)
+
+// The GOFF format uses different kinds of logical records. The format imposes
+// some rules on those records (e.g. the module header must come first, no
+// forward references to records, etc.). However, to be able to specify invalid
+// GOFF files, we treat all records the same way.
+struct RecordBase {
+  enum RecordBaseKind {
----------------
redstar wrote:

Changed. I also renamed the type and the member., because I think that `RecordBase::Kind::ModuleHeader` is more readable than `RecordBase::RecordBaseKind::ModuleHeader`.

https://github.com/llvm/llvm-project/pull/93855


More information about the llvm-commits mailing list