Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 //===- BitCodes.h - Enum values for the bitcode format ----------*- C++ -*-===// | 1 //===- NaClBitCodes.h - Enum values for the bitcode format ------*- C++ -*-===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // This header Bitcode enum values. | 10 // This header Bitcode enum values. |
| 11 // | 11 // |
| 12 // The enum values defined in this file should be considered permanent. If | 12 // The enum values defined in this file should be considered permanent. If |
| 13 // new features are added, they should have values added at the end of the | 13 // new features are added, they should have values added at the end of the |
| 14 // respective lists. | 14 // respective lists. |
| 15 // | 15 // |
| 16 //===----------------------------------------------------------------------===// | 16 //===----------------------------------------------------------------------===// |
| 17 | 17 |
| 18 #ifndef LLVM_BITCODE_BITCODES_H | 18 #ifndef LLVM_BITCODE_NACL_NACLBITCODES_H |
| 19 #define LLVM_BITCODE_BITCODES_H | 19 #define LLVM_BITCODE_NACL_NACLBITCODES_H |
| 20 | 20 |
| 21 #include "llvm/ADT/SmallVector.h" | 21 #include "llvm/ADT/SmallVector.h" |
| 22 #include "llvm/Support/DataTypes.h" | 22 #include "llvm/Support/DataTypes.h" |
| 23 #include "llvm/Support/ErrorHandling.h" | 23 #include "llvm/Support/ErrorHandling.h" |
| 24 #include <cassert> | 24 #include <cassert> |
| 25 | 25 |
| 26 namespace llvm { | 26 namespace llvm { |
| 27 namespace bitc { | 27 namespace naclbitc { |
| 28 enum StandardWidths { | 28 enum StandardWidths { |
| 29 BlockIDWidth = 8, // We use VBR-8 for block IDs. | 29 BlockIDWidth = 8, // We use VBR-8 for block IDs. |
| 30 CodeLenWidth = 4, // Codelen are VBR-4. | 30 CodeLenWidth = 4, // Codelen are VBR-4. |
| 31 BlockSizeWidth = 32 // BlockSize up to 2^32 32-bit words = 16GB per block. | 31 BlockSizeWidth = 32 // BlockSize up to 2^32 32-bit words = 16GB per block. |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 // The standard abbrev namespace always has a way to exit a block, enter a | 34 // The standard abbrev namespace always has a way to exit a block, enter a |
| 35 // nested block, define abbrevs, and define an unabbreviated record. | 35 // nested block, define abbrevs, and define an unabbreviated record. |
| 36 enum FixedAbbrevIDs { | 36 enum FixedAbbrevIDs { |
| 37 END_BLOCK = 0, // Must be zero to guarantee termination for broken bitcode. | 37 END_BLOCK = 0, // Must be zero to guarantee termination for broken bitcode. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 enum BlockInfoCodes { | 69 enum BlockInfoCodes { |
| 70 // DEFINE_ABBREV has magic semantics here, applying to the current SETBID'd | 70 // DEFINE_ABBREV has magic semantics here, applying to the current SETBID'd |
| 71 // block, instead of the BlockInfo block. | 71 // block, instead of the BlockInfo block. |
| 72 | 72 |
| 73 BLOCKINFO_CODE_SETBID = 1, // SETBID: [blockid#] | 73 BLOCKINFO_CODE_SETBID = 1, // SETBID: [blockid#] |
| 74 BLOCKINFO_CODE_BLOCKNAME = 2, // BLOCKNAME: [name] | 74 BLOCKINFO_CODE_BLOCKNAME = 2, // BLOCKNAME: [name] |
| 75 BLOCKINFO_CODE_SETRECORDNAME = 3 // BLOCKINFO_CODE_SETRECORDNAME: | 75 BLOCKINFO_CODE_SETRECORDNAME = 3 // BLOCKINFO_CODE_SETRECORDNAME: |
| 76 // [id, name] | 76 // [id, name] |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 } // End bitc namespace | 79 } // End bitc namespace |
|
jvoung (off chromium)
2013/05/01 23:41:13
naclbitc
Karl
2013/05/02 14:32:14
Done.
| |
| 80 | 80 |
| 81 /// BitCodeAbbrevOp - This describes one or more operands in an abbreviation. | 81 /// NaClBitCodeAbbrevOp - This describes one or more operands in an abbreviation . |
| 82 /// This is actually a union of two different things: | 82 /// This is actually a union of two different things: |
| 83 /// 1. It could be a literal integer value ("the operand is always 17"). | 83 /// 1. It could be a literal integer value ("the operand is always 17"). |
| 84 /// 2. It could be an encoding specification ("this operand encoded like so"). | 84 /// 2. It could be an encoding specification ("this operand encoded like so"). |
| 85 /// | 85 /// |
| 86 class BitCodeAbbrevOp { | 86 class NaClBitCodeAbbrevOp { |
| 87 uint64_t Val; // A literal value or data for an encoding. | 87 uint64_t Val; // A literal value or data for an encoding. |
| 88 bool IsLiteral : 1; // Indicate whether this is a literal value or not. | 88 bool IsLiteral : 1; // Indicate whether this is a literal value or not. |
| 89 unsigned Enc : 3; // The encoding to use. | 89 unsigned Enc : 3; // The encoding to use. |
| 90 public: | 90 public: |
| 91 enum Encoding { | 91 enum Encoding { |
| 92 Fixed = 1, // A fixed width field, Val specifies number of bits. | 92 Fixed = 1, // A fixed width field, Val specifies number of bits. |
| 93 VBR = 2, // A VBR field where Val specifies the width of each chunk. | 93 VBR = 2, // A VBR field where Val specifies the width of each chunk. |
| 94 Array = 3, // A sequence of fields, next field species elt encoding. | 94 Array = 3, // A sequence of fields, next field species elt encoding. |
| 95 Char6 = 4, // A 6-bit fixed field which maps to [a-zA-Z0-9._]. | 95 Char6 = 4, // A 6-bit fixed field which maps to [a-zA-Z0-9._]. |
| 96 Blob = 5 // 32-bit aligned array of 8-bit characters. | 96 Blob = 5 // 32-bit aligned array of 8-bit characters. |
| 97 }; | 97 }; |
| 98 | 98 |
| 99 explicit BitCodeAbbrevOp(uint64_t V) : Val(V), IsLiteral(true) {} | 99 explicit NaClBitCodeAbbrevOp(uint64_t V) : Val(V), IsLiteral(true) {} |
| 100 explicit BitCodeAbbrevOp(Encoding E, uint64_t Data = 0) | 100 explicit NaClBitCodeAbbrevOp(Encoding E, uint64_t Data = 0) |
| 101 : Val(Data), IsLiteral(false), Enc(E) {} | 101 : Val(Data), IsLiteral(false), Enc(E) {} |
| 102 | 102 |
| 103 bool isLiteral() const { return IsLiteral; } | 103 bool isLiteral() const { return IsLiteral; } |
| 104 bool isEncoding() const { return !IsLiteral; } | 104 bool isEncoding() const { return !IsLiteral; } |
| 105 | 105 |
| 106 // Accessors for literals. | 106 // Accessors for literals. |
| 107 uint64_t getLiteralValue() const { assert(isLiteral()); return Val; } | 107 uint64_t getLiteralValue() const { assert(isLiteral()); return Val; } |
| 108 | 108 |
| 109 // Accessors for encoding info. | 109 // Accessors for encoding info. |
| 110 Encoding getEncoding() const { assert(isEncoding()); return (Encoding)Enc; } | 110 Encoding getEncoding() const { assert(isEncoding()); return (Encoding)Enc; } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 149 if (V < 26) return V+'a'; | 149 if (V < 26) return V+'a'; |
| 150 if (V < 26+26) return V-26+'A'; | 150 if (V < 26+26) return V-26+'A'; |
| 151 if (V < 26+26+10) return V-26-26+'0'; | 151 if (V < 26+26+10) return V-26-26+'0'; |
| 152 if (V == 62) return '.'; | 152 if (V == 62) return '.'; |
| 153 if (V == 63) return '_'; | 153 if (V == 63) return '_'; |
| 154 llvm_unreachable("Not a value Char6 character!"); | 154 llvm_unreachable("Not a value Char6 character!"); |
| 155 } | 155 } |
| 156 | 156 |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 template <> struct isPodLike<BitCodeAbbrevOp> { static const bool value=true; }; | 159 template <> struct isPodLike<NaClBitCodeAbbrevOp> { |
| 160 static const bool value=true; | |
| 161 }; | |
| 160 | 162 |
| 161 /// BitCodeAbbrev - This class represents an abbreviation record. An | 163 /// NaClBitCodeAbbrev - This class represents an abbreviation record. An |
| 162 /// abbreviation allows a complex record that has redundancy to be stored in a | 164 /// abbreviation allows a complex record that has redundancy to be stored in a |
| 163 /// specialized format instead of the fully-general, fully-vbr, format. | 165 /// specialized format instead of the fully-general, fully-vbr, format. |
| 164 class BitCodeAbbrev { | 166 class NaClBitCodeAbbrev { |
| 165 SmallVector<BitCodeAbbrevOp, 32> OperandList; | 167 SmallVector<NaClBitCodeAbbrevOp, 32> OperandList; |
| 166 unsigned char RefCount; // Number of things using this. | 168 unsigned char RefCount; // Number of things using this. |
| 167 ~BitCodeAbbrev() {} | 169 ~NaClBitCodeAbbrev() {} |
| 168 public: | 170 public: |
| 169 BitCodeAbbrev() : RefCount(1) {} | 171 NaClBitCodeAbbrev() : RefCount(1) {} |
| 170 | 172 |
| 171 void addRef() { ++RefCount; } | 173 void addRef() { ++RefCount; } |
| 172 void dropRef() { if (--RefCount == 0) delete this; } | 174 void dropRef() { if (--RefCount == 0) delete this; } |
| 173 | 175 |
| 174 unsigned getNumOperandInfos() const { | 176 unsigned getNumOperandInfos() const { |
| 175 return static_cast<unsigned>(OperandList.size()); | 177 return static_cast<unsigned>(OperandList.size()); |
| 176 } | 178 } |
| 177 const BitCodeAbbrevOp &getOperandInfo(unsigned N) const { | 179 const NaClBitCodeAbbrevOp &getOperandInfo(unsigned N) const { |
| 178 return OperandList[N]; | 180 return OperandList[N]; |
| 179 } | 181 } |
| 180 | 182 |
| 181 void Add(const BitCodeAbbrevOp &OpInfo) { | 183 void Add(const NaClBitCodeAbbrevOp &OpInfo) { |
| 182 OperandList.push_back(OpInfo); | 184 OperandList.push_back(OpInfo); |
| 183 } | 185 } |
| 184 }; | 186 }; |
| 185 } // End llvm namespace | 187 } // End llvm namespace |
| 186 | 188 |
| 187 #endif | 189 #endif |
| OLD | NEW |