add support for array abbreviations.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36754 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2007-05-04 20:33:47 +00:00
parent 15e6d170e8
commit 3c074f61ed
3 changed files with 101 additions and 59 deletions

View File

@ -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;
}
}
};