summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorSimon Atanasyan <simon@atanasyan.com>2014-05-23 08:07:09 +0000
committerSimon Atanasyan <simon@atanasyan.com>2014-05-23 08:07:09 +0000
commit84a0dc323d90f86e899519b31b789ed5c0a0ec9a (patch)
tree6bfd276f7732ac179f0ab834ba3978319cd390b7 /include
parent7a0a087f28153b62e856ba5fad4650f4ac5073ed (diff)
downloadllvm-84a0dc323d90f86e899519b31b789ed5c0a0ec9a.tar.gz
llvm-84a0dc323d90f86e899519b31b789ed5c0a0ec9a.tar.bz2
llvm-84a0dc323d90f86e899519b31b789ed5c0a0ec9a.tar.xz
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209504 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Support/YAMLTraits.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h
index 7f4a922935..4ee05ed133 100644
--- a/include/llvm/Support/YAMLTraits.h
+++ b/include/llvm/Support/YAMLTraits.h
@@ -487,6 +487,19 @@ public:
}
}
+ template <typename T>
+ void maskedBitSetCase(T &Val, const char *Str, T ConstVal, T Mask) {
+ if (bitSetMatch(Str, outputting() && (Val & Mask) == ConstVal))
+ Val = Val | ConstVal;
+ }
+
+ template <typename T>
+ void maskedBitSetCase(T &Val, const char *Str, uint32_t ConstVal,
+ uint32_t Mask) {
+ if (bitSetMatch(Str, outputting() && (Val & Mask) == ConstVal))
+ Val = Val | ConstVal;
+ }
+
void *getContext();
void setContext(void *);