[PATCH] [YAML] Add an optional argument `EnumMask` to the `yaml::IO::bitSetCase()`

Simon Atanasyan simon at atanasyan.com
Fri May 16 11:00:02 PDT 2014


Hi kledzik,

Some bit-set fields used in ELF file headers in fact contain two parts. The first one is a regular bit-field. The second one is an enumeraion. For example ELF header `e_flags` for MIPS target might contain the following values:

Bit-set values:

  EF_MIPS_NOREORDER = 0x00000001
  EF_MIPS_PIC       = 0x00000002
  EF_MIPS_CPIC      = 0x00000004
  EF_MIPS_ABI2      = 0x00000020

Enumeration:

  EF_MIPS_ARCH_32   = 0x50000000
  EF_MIPS_ARCH_64   = 0x60000000
  EF_MIPS_ARCH_32R2 = 0x70000000
  EF_MIPS_ARCH_64R2 = 0x80000000

For printing bit-sets we use the `yaml::IO::bitSetCase()`. It does not support bit-set/enumeration combinations and prints too many flags from an enumeration part. This patch fixes this problem. We add an optional `EnumMask` argument which defines a mask to select an enumeration part from a bit-field.

The idea of this patch is inspired by the implementation of the `StreamWriter::printFlags()` method the `llvm-readobj` tool.

http://reviews.llvm.org/D3807

Files:
  include/llvm/Support/YAMLTraits.h
  lib/Object/ELFYAML.cpp
  test/Object/obj2yaml.test
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3807.9491.patch
Type: text/x-patch
Size: 4561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140516/62cf03bb/attachment.bin>


More information about the llvm-commits mailing list