Chris Lattner | d9113c7 | 2003-10-13 04:22:07 +0000 | [diff] [blame] | 1 | //===-- ReaderInternals.h - Definitions internal to the reader --*- C++ -*-===// |
John Criswell | 856ba76 | 2003-10-21 15:17:13 +0000 | [diff] [blame] | 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by the LLVM research group and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 9 | // |
| 10 | // This header file defines various stuff that is used by the bytecode reader. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #ifndef READER_INTERNALS_H |
| 15 | #define READER_INTERNALS_H |
| 16 | |
Chris Lattner | 3446ae8 | 2004-01-10 19:00:15 +0000 | [diff] [blame] | 17 | #include "ReaderPrimitives.h" |
Chris Lattner | 8dc6ba9 | 2003-11-14 06:38:46 +0000 | [diff] [blame] | 18 | #include "llvm/Constants.h" |
Chris Lattner | 7061dc5 | 2001-12-03 18:02:31 +0000 | [diff] [blame] | 19 | #include "llvm/DerivedTypes.h" |
Chris Lattner | 7473413 | 2002-08-17 22:01:27 +0000 | [diff] [blame] | 20 | #include "llvm/Function.h" |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 21 | #include "llvm/ModuleProvider.h" |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 22 | #include <utility> |
Chris Lattner | 7473413 | 2002-08-17 22:01:27 +0000 | [diff] [blame] | 23 | #include <map> |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 24 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 25 | namespace llvm { |
| 26 | |
Chris Lattner | 1d670cc | 2001-09-07 16:37:43 +0000 | [diff] [blame] | 27 | // Enable to trace to figure out what the heck is going on when parsing fails |
Chris Lattner | d256ed8 | 2003-09-04 23:47:07 +0000 | [diff] [blame] | 28 | //#define TRACE_LEVEL 10 |
Alkis Evlogimenos | 60048b8 | 2003-10-30 18:33:58 +0000 | [diff] [blame] | 29 | //#define DEBUG_OUTPUT |
Chris Lattner | 1d670cc | 2001-09-07 16:37:43 +0000 | [diff] [blame] | 30 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 31 | #if TRACE_LEVEL // ByteCodeReading_TRACEr |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 32 | #define BCR_TRACE(n, X) \ |
| 33 | if (n < TRACE_LEVEL) std::cerr << std::string(n*2, ' ') << X |
Chris Lattner | 1d670cc | 2001-09-07 16:37:43 +0000 | [diff] [blame] | 34 | #else |
| 35 | #define BCR_TRACE(n, X) |
| 36 | #endif |
| 37 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 38 | struct LazyFunctionInfo { |
| 39 | const unsigned char *Buf, *EndBuf; |
Chris Lattner | 29b789b | 2003-11-19 17:27:18 +0000 | [diff] [blame] | 40 | LazyFunctionInfo(const unsigned char *B = 0, const unsigned char *EB = 0) |
| 41 | : Buf(B), EndBuf(EB) {} |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 42 | }; |
| 43 | |
Chris Lattner | 00413e3 | 2003-10-04 20:14:59 +0000 | [diff] [blame] | 44 | class BytecodeParser : public ModuleProvider { |
Chris Lattner | 7473413 | 2002-08-17 22:01:27 +0000 | [diff] [blame] | 45 | BytecodeParser(const BytecodeParser &); // DO NOT IMPLEMENT |
| 46 | void operator=(const BytecodeParser &); // DO NOT IMPLEMENT |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 47 | public: |
Chris Lattner | 89e0253 | 2004-01-18 21:08:15 +0000 | [diff] [blame^] | 48 | BytecodeParser() {} |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 49 | |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 50 | ~BytecodeParser() { |
Chris Lattner | a2602f3 | 2003-05-22 18:26:48 +0000 | [diff] [blame] | 51 | freeState(); |
| 52 | } |
| 53 | void freeState() { |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 54 | freeTable(Values); |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 55 | freeTable(ModuleValues); |
| 56 | } |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 57 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 58 | Module* releaseModule() { |
| 59 | // Since we're losing control of this Module, we must hand it back complete |
Chris Lattner | 927b185 | 2003-10-09 20:22:47 +0000 | [diff] [blame] | 60 | Module *M = ModuleProvider::releaseModule(); |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 61 | freeState(); |
Chris Lattner | 927b185 | 2003-10-09 20:22:47 +0000 | [diff] [blame] | 62 | return M; |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 63 | } |
Chris Lattner | d6b6525 | 2001-10-24 01:15:12 +0000 | [diff] [blame] | 64 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 65 | void ParseBytecode(const unsigned char *Buf, unsigned Length, |
| 66 | const std::string &ModuleID); |
Chris Lattner | d6b6525 | 2001-10-24 01:15:12 +0000 | [diff] [blame] | 67 | |
Chris Lattner | b3afb1f | 2002-04-04 19:24:11 +0000 | [diff] [blame] | 68 | void dump() const { |
Anand Shukla | eea60fc | 2002-06-25 20:44:04 +0000 | [diff] [blame] | 69 | std::cerr << "BytecodeParser instance!\n"; |
Chris Lattner | b3afb1f | 2002-04-04 19:24:11 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Chris Lattner | 6e44802 | 2003-10-08 21:51:46 +0000 | [diff] [blame] | 72 | private: |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 73 | struct ValueList : public User { |
Chris Lattner | 6e44802 | 2003-10-08 21:51:46 +0000 | [diff] [blame] | 74 | ValueList() : User(Type::TypeTy, Value::TypeVal) {} |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 75 | |
| 76 | // vector compatibility methods |
| 77 | unsigned size() const { return getNumOperands(); } |
| 78 | void push_back(Value *V) { Operands.push_back(Use(V, this)); } |
| 79 | Value *back() const { return Operands.back(); } |
| 80 | void pop_back() { Operands.pop_back(); } |
| 81 | bool empty() const { return Operands.empty(); } |
| 82 | |
| 83 | virtual void print(std::ostream& OS) const { |
| 84 | OS << "Bytecode Reader UseHandle!"; |
| 85 | } |
| 86 | }; |
| 87 | |
Chris Lattner | 036b8aa | 2003-03-06 17:55:45 +0000 | [diff] [blame] | 88 | // Information about the module, extracted from the bytecode revision number. |
| 89 | unsigned char RevisionNum; // The rev # itself |
Chris Lattner | cb7e2e2 | 2003-10-18 05:54:18 +0000 | [diff] [blame] | 90 | bool hasExtendedLinkageSpecs; // Supports more than 4 linkage types |
| 91 | bool hasOldStyleVarargs; // Has old version of varargs intrinsics? |
| 92 | bool hasVarArgCallPadding; // Bytecode has extra padding in vararg call |
| 93 | |
| 94 | bool usesOldStyleVarargs; // Does this module USE old style varargs? |
Chris Lattner | 036b8aa | 2003-03-06 17:55:45 +0000 | [diff] [blame] | 95 | |
Chris Lattner | 80b9734 | 2004-01-17 23:25:43 +0000 | [diff] [blame] | 96 | // Flags to distinguish LLVM 1.0 & 1.1 bytecode formats (revision #0) |
| 97 | |
| 98 | // Revision #0 had an explicit alignment of data only for the ModuleGlobalInfo |
| 99 | // block. This was fixed to be like all other blocks in 1.2 |
Chris Lattner | 44d0eeb | 2004-01-15 17:55:01 +0000 | [diff] [blame] | 100 | bool hasInconsistentModuleGlobalInfo; |
| 101 | |
Chris Lattner | 80b9734 | 2004-01-17 23:25:43 +0000 | [diff] [blame] | 102 | // Revision #0 also explicitly encoded zero values for primitive types like |
| 103 | // int/sbyte/etc. |
| 104 | bool hasExplicitPrimitiveZeros; |
| 105 | |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 106 | typedef std::vector<ValueList*> ValueTable; |
Chris Lattner | 8eb10ce | 2003-10-09 06:05:40 +0000 | [diff] [blame] | 107 | ValueTable Values; |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 108 | ValueTable ModuleValues; |
Chris Lattner | 8eb10ce | 2003-10-09 06:05:40 +0000 | [diff] [blame] | 109 | std::map<std::pair<unsigned,unsigned>, Value*> ForwardReferences; |
Chris Lattner | 1d670cc | 2001-09-07 16:37:43 +0000 | [diff] [blame] | 110 | |
Chris Lattner | 89e0253 | 2004-01-18 21:08:15 +0000 | [diff] [blame^] | 111 | /// CompactionTable - If a compaction table is active in the current function, |
| 112 | /// this is the mapping that it contains. |
| 113 | std::vector<std::vector<Value*> > CompactionTable; |
| 114 | |
Chris Lattner | 4ee8ef2 | 2003-10-08 22:52:54 +0000 | [diff] [blame] | 115 | std::vector<BasicBlock*> ParsedBasicBlocks; |
| 116 | |
Chris Lattner | 29b789b | 2003-11-19 17:27:18 +0000 | [diff] [blame] | 117 | // ConstantFwdRefs - This maintains a mapping between <Type, Slot #>'s and |
| 118 | // forward references to constants. Such values may be referenced before they |
| 119 | // are defined, and if so, the temporary object that they represent is held |
| 120 | // here. |
Chris Lattner | 7473413 | 2002-08-17 22:01:27 +0000 | [diff] [blame] | 121 | // |
Chris Lattner | 29b789b | 2003-11-19 17:27:18 +0000 | [diff] [blame] | 122 | typedef std::map<std::pair<const Type*,unsigned>, Constant*> ConstantRefsType; |
| 123 | ConstantRefsType ConstantFwdRefs; |
Chris Lattner | 05950c3 | 2001-10-13 06:47:01 +0000 | [diff] [blame] | 124 | |
Chris Lattner | 1d670cc | 2001-09-07 16:37:43 +0000 | [diff] [blame] | 125 | // TypesLoaded - This vector mirrors the Values[TypeTyID] plane. It is used |
| 126 | // to deal with forward references to types. |
| 127 | // |
Chris Lattner | c7b6f03 | 2003-10-02 20:26:18 +0000 | [diff] [blame] | 128 | typedef std::vector<PATypeHolder> TypeValuesListTy; |
Chris Lattner | 1d670cc | 2001-09-07 16:37:43 +0000 | [diff] [blame] | 129 | TypeValuesListTy ModuleTypeValues; |
Chris Lattner | 6e5a0e4 | 2003-03-06 17:18:14 +0000 | [diff] [blame] | 130 | TypeValuesListTy FunctionTypeValues; |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 131 | |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 132 | // When the ModuleGlobalInfo section is read, we create a function object for |
| 133 | // each function in the module. When the function is loaded, this function is |
| 134 | // filled in. |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 135 | // |
Chris Lattner | 29b789b | 2003-11-19 17:27:18 +0000 | [diff] [blame] | 136 | std::vector<Function*> FunctionSignatureList; |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 137 | |
| 138 | // Constant values are read in after global variables. Because of this, we |
| 139 | // must defer setting the initializers on global variables until after module |
| 140 | // level constants have been read. In the mean time, this list keeps track of |
| 141 | // what we must do. |
| 142 | // |
| 143 | std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits; |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 144 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 145 | // For lazy reading-in of functions, we need to save away several pieces of |
| 146 | // information about each function: its begin and end pointer in the buffer |
| 147 | // and its FunctionSlot. |
| 148 | // |
Chris Lattner | 29b789b | 2003-11-19 17:27:18 +0000 | [diff] [blame] | 149 | std::map<Function*, LazyFunctionInfo> LazyFunctionLoadMap; |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 150 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 151 | private: |
Chris Lattner | 52e20b0 | 2003-03-19 20:54:26 +0000 | [diff] [blame] | 152 | void freeTable(ValueTable &Tab) { |
| 153 | while (!Tab.empty()) { |
| 154 | delete Tab.back(); |
| 155 | Tab.pop_back(); |
| 156 | } |
| 157 | } |
| 158 | |
Chris Lattner | 89e0253 | 2004-01-18 21:08:15 +0000 | [diff] [blame^] | 159 | /// getGlobalTableType - This is just like getType, but when a compaction |
| 160 | /// table is in use, it is ignored. Also, no forward references or other |
| 161 | /// fancy features are supported. |
| 162 | const Type *getGlobalTableType(unsigned Slot) { |
| 163 | if (Slot < Type::FirstDerivedTyID) { |
| 164 | const Type *Ty = Type::getPrimitiveType((Type::PrimitiveID)Slot); |
| 165 | assert(Ty && "Not a primitive type ID?"); |
| 166 | return Ty; |
| 167 | } |
| 168 | Slot -= Type::FirstDerivedTyID; |
| 169 | if (Slot >= ModuleTypeValues.size()) |
| 170 | throw std::string("Illegal compaction table type reference!"); |
| 171 | return ModuleTypeValues[Slot]; |
| 172 | } |
| 173 | |
| 174 | unsigned getGlobalTableTypeSlot(const Type *Ty) { |
| 175 | if (Ty->isPrimitiveType()) |
| 176 | return Ty->getPrimitiveID(); |
| 177 | TypeValuesListTy::iterator I = find(ModuleTypeValues.begin(), |
| 178 | ModuleTypeValues.end(), Ty); |
| 179 | if (I == ModuleTypeValues.end()) |
| 180 | throw std::string("Didn't find type in ModuleTypeValues."); |
| 181 | return Type::FirstDerivedTyID + (&*I - &ModuleTypeValues[0]); |
| 182 | } |
| 183 | |
| 184 | /// getGlobalTableValue - This is just like getValue, but when a compaction |
| 185 | /// table is in use, it is ignored. Also, no forward references or other |
| 186 | /// fancy features are supported. |
| 187 | Value *getGlobalTableValue(const Type *Ty, unsigned SlotNo) { |
| 188 | // FIXME: getTypeSlot is inefficient! |
| 189 | unsigned TyID = getGlobalTableTypeSlot(Ty); |
| 190 | |
| 191 | if (TyID != Type::LabelTyID) { |
| 192 | if (SlotNo == 0) |
| 193 | return Constant::getNullValue(Ty); |
| 194 | --SlotNo; |
| 195 | } |
| 196 | |
| 197 | if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0 || |
| 198 | SlotNo >= ModuleValues[TyID]->getNumOperands()) { |
| 199 | std::cerr << TyID << ", " << SlotNo << ": " << ModuleValues.size() << ", " |
| 200 | << (void*)ModuleValues[TyID] << ", " |
| 201 | << ModuleValues[TyID]->getNumOperands() << "\n"; |
| 202 | throw std::string("Corrupt compaction table entry!"); |
| 203 | } |
| 204 | return ModuleValues[TyID]->getOperand(SlotNo); |
| 205 | } |
| 206 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 207 | public: |
| 208 | void ParseModule(const unsigned char * Buf, const unsigned char *End); |
| 209 | void materializeFunction(Function *F); |
| 210 | |
| 211 | private: |
| 212 | void ParseVersionInfo (const unsigned char *&Buf, const unsigned char *End); |
| 213 | void ParseModuleGlobalInfo(const unsigned char *&Buf, const unsigned char *E); |
| 214 | void ParseSymbolTable(const unsigned char *&Buf, const unsigned char *End, |
Chris Lattner | 4ee8ef2 | 2003-10-08 22:52:54 +0000 | [diff] [blame] | 215 | SymbolTable *, Function *CurrentFunction); |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 216 | void ParseFunction(const unsigned char *&Buf, const unsigned char *End); |
Chris Lattner | 89e0253 | 2004-01-18 21:08:15 +0000 | [diff] [blame^] | 217 | void ParseCompactionTable(const unsigned char *&Buf,const unsigned char *End); |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 218 | void ParseGlobalTypes(const unsigned char *&Buf, const unsigned char *EndBuf); |
| 219 | |
Chris Lattner | 4ee8ef2 | 2003-10-08 22:52:54 +0000 | [diff] [blame] | 220 | BasicBlock *ParseBasicBlock(const unsigned char *&Buf, |
| 221 | const unsigned char *End, |
| 222 | unsigned BlockNo); |
Chris Lattner | 8d1dbd2 | 2003-12-01 07:05:31 +0000 | [diff] [blame] | 223 | unsigned ParseInstructionList(Function *F, const unsigned char *&Buf, |
| 224 | const unsigned char *EndBuf); |
| 225 | |
Chris Lattner | cb7e2e2 | 2003-10-18 05:54:18 +0000 | [diff] [blame] | 226 | void ParseInstruction(const unsigned char *&Buf, const unsigned char *End, |
| 227 | std::vector<unsigned> &Args, BasicBlock *BB); |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 228 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 229 | void ParseConstantPool(const unsigned char *&Buf, const unsigned char *EndBuf, |
| 230 | ValueTable &Tab, TypeValuesListTy &TypeTab); |
Chris Lattner | 9e460f2 | 2003-10-04 20:00:03 +0000 | [diff] [blame] | 231 | Constant *parseConstantValue(const unsigned char *&Buf, |
| 232 | const unsigned char *End, |
Chris Lattner | 29b789b | 2003-11-19 17:27:18 +0000 | [diff] [blame] | 233 | unsigned TypeID); |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 234 | void parseTypeConstants(const unsigned char *&Buf, |
Chris Lattner | 12e6465 | 2003-05-22 18:08:30 +0000 | [diff] [blame] | 235 | const unsigned char *EndBuf, |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 236 | TypeValuesListTy &Tab, unsigned NumEntries); |
Chris Lattner | 12e6465 | 2003-05-22 18:08:30 +0000 | [diff] [blame] | 237 | const Type *parseTypeConstant(const unsigned char *&Buf, |
| 238 | const unsigned char *EndBuf); |
Chris Lattner | 9e893e8 | 2004-01-14 23:35:21 +0000 | [diff] [blame] | 239 | void parseStringConstants(const unsigned char *&Buf, |
| 240 | const unsigned char *EndBuf, |
| 241 | unsigned NumEntries, ValueTable &Tab); |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 242 | |
Chris Lattner | 36392bc | 2003-10-08 21:18:57 +0000 | [diff] [blame] | 243 | Value *getValue(unsigned TypeID, unsigned num, bool Create = true); |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 244 | const Type *getType(unsigned ID); |
Chris Lattner | 4ee8ef2 | 2003-10-08 22:52:54 +0000 | [diff] [blame] | 245 | BasicBlock *getBasicBlock(unsigned ID); |
Chris Lattner | 1c3673b | 2003-11-19 06:01:12 +0000 | [diff] [blame] | 246 | Constant *getConstantValue(unsigned TypeID, unsigned num); |
| 247 | Constant *getConstantValue(const Type *Ty, unsigned num) { |
| 248 | return getConstantValue(getTypeSlot(Ty), num); |
| 249 | } |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 250 | |
Chris Lattner | f0d9273 | 2003-10-13 14:34:59 +0000 | [diff] [blame] | 251 | unsigned insertValue(Value *V, unsigned Type, ValueTable &Table); |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 252 | |
Chris Lattner | 9e460f2 | 2003-10-04 20:00:03 +0000 | [diff] [blame] | 253 | unsigned getTypeSlot(const Type *Ty); |
Chris Lattner | 1d670cc | 2001-09-07 16:37:43 +0000 | [diff] [blame] | 254 | |
Chris Lattner | 29b789b | 2003-11-19 17:27:18 +0000 | [diff] [blame] | 255 | // resolve all references to the placeholder (if any) for the given constant |
| 256 | void ResolveReferencesToConstant(Constant *C, unsigned Slot); |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 257 | }; |
| 258 | |
| 259 | template<class SuperType> |
| 260 | class PlaceholderDef : public SuperType { |
| 261 | unsigned ID; |
Chris Lattner | 7473413 | 2002-08-17 22:01:27 +0000 | [diff] [blame] | 262 | PlaceholderDef(); // DO NOT IMPLEMENT |
| 263 | void operator=(const PlaceholderDef &); // DO NOT IMPLEMENT |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 264 | public: |
| 265 | PlaceholderDef(const Type *Ty, unsigned id) : SuperType(Ty), ID(id) {} |
| 266 | unsigned getID() { return ID; } |
| 267 | }; |
| 268 | |
Chris Lattner | 8dc6ba9 | 2003-11-14 06:38:46 +0000 | [diff] [blame] | 269 | struct ConstantPlaceHolderHelper : public ConstantExpr { |
Chris Lattner | db9546e | 2003-11-14 16:34:25 +0000 | [diff] [blame] | 270 | ConstantPlaceHolderHelper(const Type *Ty) |
| 271 | : ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty) {} |
Vikram S. Adve | c668b7c | 2002-07-14 23:05:09 +0000 | [diff] [blame] | 272 | }; |
| 273 | |
Vikram S. Adve | c668b7c | 2002-07-14 23:05:09 +0000 | [diff] [blame] | 274 | typedef PlaceholderDef<ConstantPlaceHolderHelper> ConstPHolder; |
| 275 | |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 276 | static inline void readBlock(const unsigned char *&Buf, |
Chris Lattner | 12e6465 | 2003-05-22 18:08:30 +0000 | [diff] [blame] | 277 | const unsigned char *EndBuf, |
Misha Brukman | 12c29d1 | 2003-09-22 23:38:23 +0000 | [diff] [blame] | 278 | unsigned &Type, unsigned &Size) { |
Chris Lattner | 7969dc2 | 2004-01-15 06:13:09 +0000 | [diff] [blame] | 279 | Type = read(Buf, EndBuf); |
| 280 | Size = read(Buf, EndBuf); |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 283 | } // End llvm namespace |
| 284 | |
Chris Lattner | 0095054 | 2001-06-06 20:29:01 +0000 | [diff] [blame] | 285 | #endif |