From 3c074f61ed2bd1d8d48c3851d827a06b80d2608b Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 4 May 2007 20:33:47 +0000 Subject: add support for array abbreviations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36754 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bitcode/BitCodes.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'include/llvm/Bitcode/BitCodes.h') diff --git a/include/llvm/Bitcode/BitCodes.h b/include/llvm/Bitcode/BitCodes.h index 647c28fb39..d9a5874966 100644 --- a/include/llvm/Bitcode/BitCodes.h +++ b/include/llvm/Bitcode/BitCodes.h @@ -84,13 +84,15 @@ class BitCodeAbbrevOp { unsigned Enc : 3; // The encoding to use. public: enum Encoding { - FixedWidth = 1, // A fixed with field, Val specifies number of bits. - VBR = 2 // A VBR field where Val specifies the width of each chunk. + Fixed = 1, // A fixed with field, Val specifies number of bits. + VBR = 2, // A VBR field where Val specifies the width of each chunk. + Array = 3 // A sequence of fields, next field species elt encoding. }; BitCodeAbbrevOp(uint64_t V) : Val(V), IsLiteral(true) {} - BitCodeAbbrevOp(Encoding E, uint64_t Data) + BitCodeAbbrevOp(Encoding E, uint64_t Data = 0) : Val(Data), IsLiteral(false), Enc(E) {} + bool isLiteral() const { return IsLiteral; } bool isEncoding() const { return !IsLiteral; } @@ -100,11 +102,21 @@ public: // Accessors for encoding info. Encoding getEncoding() const { assert(isEncoding()); return (Encoding)Enc; } - uint64_t getEncodingData() const { assert(isEncoding()); return Val; } + uint64_t getEncodingData() const { + assert(isEncoding() && hasEncodingData()); + return Val; + } bool hasEncodingData() const { return hasEncodingData(getEncoding()); } static bool hasEncodingData(Encoding E) { - return true; + switch (E) { + default: assert(0 && "Unknown encoding"); + case Fixed: + case VBR: + return true; + case Array: + return false; + } } }; -- cgit v1.2.3-18-g5258