[llvm-commits] CVS: llvm/include/llvm/Bitcode/BitCodes.h BitstreamReader.h BitstreamWriter.h
Chris Lattner
sabre at nondot.org
Fri May 4 18:16:00 PDT 2007
Changes in directory llvm/include/llvm/Bitcode:
BitCodes.h updated: 1.6 -> 1.7
BitstreamReader.h updated: 1.15 -> 1.16
BitstreamWriter.h updated: 1.11 -> 1.12
---
Log message:
add a 6-bit encoding type for strings.
---
Diffs of the changes: (+38 -3)
BitCodes.h | 35 ++++++++++++++++++++++++++++++++---
BitstreamReader.h | 3 +++
BitstreamWriter.h | 3 +++
3 files changed, 38 insertions(+), 3 deletions(-)
Index: llvm/include/llvm/Bitcode/BitCodes.h
diff -u llvm/include/llvm/Bitcode/BitCodes.h:1.6 llvm/include/llvm/Bitcode/BitCodes.h:1.7
--- llvm/include/llvm/Bitcode/BitCodes.h:1.6 Fri May 4 19:16:30 2007
+++ llvm/include/llvm/Bitcode/BitCodes.h Fri May 4 20:15:42 2007
@@ -85,15 +85,15 @@
unsigned Enc : 3; // The encoding to use.
public:
enum Encoding {
- Fixed = 1, // A fixed with field, Val specifies number of bits.
+ Fixed = 1, // A fixed width 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.
+ Array = 3, // A sequence of fields, next field species elt encoding.
+ Char6 = 4 // A 6-bit fixed field which maps to [a-zA-Z0-9._].
};
BitCodeAbbrevOp(uint64_t V) : Val(V), IsLiteral(true) {}
BitCodeAbbrevOp(Encoding E, uint64_t Data = 0)
: Val(Data), IsLiteral(false), Enc(E) {}
-
bool isLiteral() const { return IsLiteral; }
bool isEncoding() const { return !IsLiteral; }
@@ -116,9 +116,38 @@
case VBR:
return true;
case Array:
+ case Char6:
return false;
}
}
+
+ /// isChar6 - Return true if this character is legal in the Char6 encoding.
+ static bool isChar6(char C) {
+ if (C >= 'a' && C <= 'z') return true;
+ if (C >= 'A' && C <= 'Z') return true;
+ if (C >= '0' && C <= '9') return true;
+ if (C == '.' || C == '_') return true;
+ return false;
+ }
+ static unsigned EncodeChar6(char C) {
+ if (C >= 'a' && C <= 'z') return C-'a';
+ if (C >= 'A' && C <= 'Z') return C-'A'+26;
+ if (C >= '0' && C <= '9') return C-'0'+26+26;
+ if (C == '.') return 62;
+ if (C == '_') return 63;
+ assert(0 && "Not a value Char6 character!");
+ }
+
+ static char DecodeChar6(unsigned V) {
+ assert((V & ~63) == 0 && "Not a Char6 encoded character!");
+ if (V < 26) return V+'a';
+ if (V < 26+26) return V-26+'A';
+ if (V < 26+26+10) return V-26-26+'0';
+ if (V == 62) return '.';
+ if (V == 63) return '_';
+ assert(0 && "Not a value Char6 character!");
+ }
+
};
/// BitCodeAbbrev - This class represents an abbreviation record. An
Index: llvm/include/llvm/Bitcode/BitstreamReader.h
diff -u llvm/include/llvm/Bitcode/BitstreamReader.h:1.15 llvm/include/llvm/Bitcode/BitstreamReader.h:1.16
--- llvm/include/llvm/Bitcode/BitstreamReader.h:1.15 Fri May 4 19:16:30 2007
+++ llvm/include/llvm/Bitcode/BitstreamReader.h Fri May 4 20:15:42 2007
@@ -332,6 +332,9 @@
case BitCodeAbbrevOp::VBR:
Vals.push_back(ReadVBR64(Op.getEncodingData()));
break;
+ case BitCodeAbbrevOp::Char6:
+ Vals.push_back(BitCodeAbbrevOp::DecodeChar6(Read(6)));
+ break;
}
}
}
Index: llvm/include/llvm/Bitcode/BitstreamWriter.h
diff -u llvm/include/llvm/Bitcode/BitstreamWriter.h:1.11 llvm/include/llvm/Bitcode/BitstreamWriter.h:1.12
--- llvm/include/llvm/Bitcode/BitstreamWriter.h:1.11 Fri May 4 19:16:30 2007
+++ llvm/include/llvm/Bitcode/BitstreamWriter.h Fri May 4 20:15:42 2007
@@ -260,6 +260,9 @@
case BitCodeAbbrevOp::VBR:
EmitVBR(V, Op.getEncodingData());
break;
+ case BitCodeAbbrevOp::Char6:
+ Emit(BitCodeAbbrevOp::EncodeChar6((char)V), 6);
+ break;
}
}
public:
More information about the llvm-commits
mailing list