[YAML] Add an optional argument `EnumMask` to the `yaml::IO::bitSetCase()`.
authorSimon Atanasyan <simon@atanasyan.com>
Fri, 23 May 2014 08:07:09 +0000 (08:07 +0000)
committerSimon Atanasyan <simon@atanasyan.com>
Fri, 23 May 2014 08:07:09 +0000 (08:07 +0000)
commit84242dc774be3fae8a9a9f2712e6f37b150aeecc
tree0f3077aeea2ce77a7ad3180fcc3241d047ac59ae
parent57dd5cf441351531d26d7255a778430904c5288d
[YAML] Add an optional argument `EnumMask` to the `yaml::IO::bitSetCase()`.

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. New method
`yaml::IO::maskedBitSetCase()` handle "enumeration" part of bitset
defined by provided mask.

Patch reviewed by Nick Kledzik and Sean Silva.

llvm-svn: 209504
llvm/docs/YamlIO.rst
llvm/include/llvm/Support/YAMLTraits.h
llvm/lib/Object/ELFYAML.cpp
llvm/test/Object/obj2yaml.test