blob: 1f4aa68f4aebaeface3c719138be676a6ca25137 [file] [log] [blame]
Chris Lattner05950c32001-10-13 06:47:01 +00001//===- ReadInst.cpp - Code to read an instruction from bytecode -----------===//
Chris Lattner00950542001-06-06 20:29:01 +00002//
3// This file defines the mechanism to read an instruction from a bytecode
4// stream.
5//
6// Note that this library should be as fast as possible, reentrant, and
7// threadsafe!!
8//
9// TODO: Change from getValue(Raw.Arg1) etc, to getArg(Raw, 1)
10// Make it check type, so that casts are checked.
11//
Chris Lattner05950c32001-10-13 06:47:01 +000012//===----------------------------------------------------------------------===//
Chris Lattner00950542001-06-06 20:29:01 +000013
14#include "llvm/iOther.h"
15#include "llvm/iTerminators.h"
16#include "llvm/iMemory.h"
17#include "llvm/DerivedTypes.h"
18#include "ReaderInternals.h"
19
20bool BytecodeParser::ParseRawInst(const uchar *&Buf, const uchar *EndBuf,
21 RawInst &Result) {
22 unsigned Op, Typ;
Chris Lattner3d3f2892001-07-28 17:50:18 +000023 if (read(Buf, EndBuf, Op)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000024
25 Result.NumOperands = Op >> 30;
26 Result.Opcode = (Op >> 24) & 63;
27
28 switch (Result.NumOperands) {
29 case 1:
30 Result.Ty = getType((Op >> 12) & 4095);
31 Result.Arg1 = Op & 4095;
32 if (Result.Arg1 == 4095) // Handle special encoding for 0 operands...
33 Result.NumOperands = 0;
34 break;
35 case 2:
36 Result.Ty = getType((Op >> 16) & 255);
37 Result.Arg1 = (Op >> 8 ) & 255;
38 Result.Arg2 = (Op >> 0 ) & 255;
39 break;
40 case 3:
41 Result.Ty = getType((Op >> 18) & 63);
42 Result.Arg1 = (Op >> 12) & 63;
43 Result.Arg2 = (Op >> 6 ) & 63;
44 Result.Arg3 = (Op >> 0 ) & 63;
45 break;
46 case 0:
47 Buf -= 4; // Hrm, try this again...
Chris Lattner3d3f2892001-07-28 17:50:18 +000048 if (read_vbr(Buf, EndBuf, Result.Opcode)) return failure(true);
49 if (read_vbr(Buf, EndBuf, Typ)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000050 Result.Ty = getType(Typ);
Chris Lattner5ab1f872001-10-21 00:14:44 +000051 if (Result.Ty == 0) return failure(true);
Chris Lattner3d3f2892001-07-28 17:50:18 +000052 if (read_vbr(Buf, EndBuf, Result.NumOperands)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000053
54 switch (Result.NumOperands) {
55 case 0:
56 cerr << "Zero Arg instr found!\n";
Chris Lattner3d3f2892001-07-28 17:50:18 +000057 return failure(true); // This encoding is invalid!
Chris Lattner00950542001-06-06 20:29:01 +000058 case 1:
Chris Lattner3d3f2892001-07-28 17:50:18 +000059 if (read_vbr(Buf, EndBuf, Result.Arg1)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000060 break;
61 case 2:
62 if (read_vbr(Buf, EndBuf, Result.Arg1) ||
Chris Lattner3d3f2892001-07-28 17:50:18 +000063 read_vbr(Buf, EndBuf, Result.Arg2)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000064 break;
65 case 3:
66 if (read_vbr(Buf, EndBuf, Result.Arg1) ||
67 read_vbr(Buf, EndBuf, Result.Arg2) ||
Chris Lattner3d3f2892001-07-28 17:50:18 +000068 read_vbr(Buf, EndBuf, Result.Arg3)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000069 break;
70 default:
71 if (read_vbr(Buf, EndBuf, Result.Arg1) ||
Chris Lattner3d3f2892001-07-28 17:50:18 +000072 read_vbr(Buf, EndBuf, Result.Arg2)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000073
74 // Allocate a vector to hold arguments 3, 4, 5, 6 ...
75 Result.VarArgs = new vector<unsigned>(Result.NumOperands-2);
76 for (unsigned a = 0; a < Result.NumOperands-2; a++)
Chris Lattner3d3f2892001-07-28 17:50:18 +000077 if (read_vbr(Buf, EndBuf, (*Result.VarArgs)[a])) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000078 break;
79 }
Chris Lattner3d3f2892001-07-28 17:50:18 +000080 if (align32(Buf, EndBuf)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000081 break;
82 }
83
Chris Lattnerc8b25d42001-07-07 08:36:50 +000084#if 0
85 cerr << "NO: " << Result.NumOperands << " opcode: " << Result.Opcode
Chris Lattner1d670cc2001-09-07 16:37:43 +000086 << " Ty: " << Result.Ty->getDescription() << " arg1: " << Result.Arg1
Chris Lattnerc8b25d42001-07-07 08:36:50 +000087 << " arg2: " << Result.Arg2 << " arg3: " << Result.Arg3 << endl;
88#endif
Chris Lattner00950542001-06-06 20:29:01 +000089 return false;
90}
91
92
93bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
94 Instruction *&Res) {
95 RawInst Raw;
Chris Lattner3d3f2892001-07-28 17:50:18 +000096 if (ParseRawInst(Buf, EndBuf, Raw)) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +000097
98 if (Raw.Opcode >= Instruction::FirstUnaryOp &&
99 Raw.Opcode < Instruction::NumUnaryOps && Raw.NumOperands == 1) {
Chris Lattner9f3d2762001-07-07 20:17:23 +0000100 Res = UnaryOperator::create((Instruction::UnaryOps)Raw.Opcode,
101 getValue(Raw.Ty,Raw.Arg1));
Chris Lattner00950542001-06-06 20:29:01 +0000102 return false;
103 } else if (Raw.Opcode >= Instruction::FirstBinaryOp &&
104 Raw.Opcode < Instruction::NumBinaryOps && Raw.NumOperands == 2) {
Chris Lattner9f3d2762001-07-07 20:17:23 +0000105 Res = BinaryOperator::create((Instruction::BinaryOps)Raw.Opcode,
106 getValue(Raw.Ty, Raw.Arg1),
107 getValue(Raw.Ty, Raw.Arg2));
Chris Lattner00950542001-06-06 20:29:01 +0000108 return false;
Chris Lattner027dcc52001-07-08 21:10:27 +0000109 }
110
111 Value *V;
112 switch (Raw.Opcode) {
Chris Lattner5ab1f872001-10-21 00:14:44 +0000113 case Instruction::Cast: {
114 V = getValue(Raw.Ty, Raw.Arg1);
115 const Type *Ty = getType(Raw.Arg2);
116 if (V == 0 || Ty == 0) { cerr << "Invalid cast!\n"; return true; }
117 Res = new CastInst(V, Ty);
Chris Lattner09083092001-07-08 04:57:15 +0000118 return false;
Chris Lattner5ab1f872001-10-21 00:14:44 +0000119 }
Chris Lattner027dcc52001-07-08 21:10:27 +0000120 case Instruction::PHINode: {
Chris Lattner00950542001-06-06 20:29:01 +0000121 PHINode *PN = new PHINode(Raw.Ty);
122 switch (Raw.NumOperands) {
Chris Lattneree976f32001-06-11 15:04:40 +0000123 case 0:
124 case 1:
125 case 3: cerr << "Invalid phi node encountered!\n";
Chris Lattner00950542001-06-06 20:29:01 +0000126 delete PN;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000127 return failure(true);
Chris Lattneree976f32001-06-11 15:04:40 +0000128 case 2: PN->addIncoming(getValue(Raw.Ty, Raw.Arg1),
Chris Lattnerb00c5822001-10-02 03:41:24 +0000129 cast<BasicBlock>(getValue(Type::LabelTy,Raw.Arg2)));
Chris Lattneree976f32001-06-11 15:04:40 +0000130 break;
Chris Lattner00950542001-06-06 20:29:01 +0000131 default:
Chris Lattneree976f32001-06-11 15:04:40 +0000132 PN->addIncoming(getValue(Raw.Ty, Raw.Arg1),
Chris Lattnerb00c5822001-10-02 03:41:24 +0000133 cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2)));
Chris Lattneree976f32001-06-11 15:04:40 +0000134 if (Raw.VarArgs->size() & 1) {
135 cerr << "PHI Node with ODD number of arguments!\n";
136 delete PN;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000137 return failure(true);
Chris Lattneree976f32001-06-11 15:04:40 +0000138 } else {
Chris Lattner00950542001-06-06 20:29:01 +0000139 vector<unsigned> &args = *Raw.VarArgs;
Chris Lattneree976f32001-06-11 15:04:40 +0000140 for (unsigned i = 0; i < args.size(); i+=2)
141 PN->addIncoming(getValue(Raw.Ty, args[i]),
Chris Lattnerb00c5822001-10-02 03:41:24 +0000142 cast<BasicBlock>(getValue(Type::LabelTy, args[i+1])));
Chris Lattner00950542001-06-06 20:29:01 +0000143 }
Chris Lattneree976f32001-06-11 15:04:40 +0000144 delete Raw.VarArgs;
145 break;
Chris Lattner00950542001-06-06 20:29:01 +0000146 }
147 Res = PN;
148 return false;
Chris Lattner027dcc52001-07-08 21:10:27 +0000149 }
150
151 case Instruction::Shl:
152 case Instruction::Shr:
153 Res = new ShiftInst((Instruction::OtherOps)Raw.Opcode,
154 getValue(Raw.Ty, Raw.Arg1),
155 getValue(Type::UByteTy, Raw.Arg2));
156 return false;
157 case Instruction::Ret:
Chris Lattner00950542001-06-06 20:29:01 +0000158 if (Raw.NumOperands == 0) {
159 Res = new ReturnInst(); return false;
160 } else if (Raw.NumOperands == 1) {
161 Res = new ReturnInst(getValue(Raw.Ty, Raw.Arg1)); return false;
162 }
Chris Lattner027dcc52001-07-08 21:10:27 +0000163 break;
164
165 case Instruction::Br:
Chris Lattner00950542001-06-06 20:29:01 +0000166 if (Raw.NumOperands == 1) {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000167 Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg1)));
Chris Lattner00950542001-06-06 20:29:01 +0000168 return false;
169 } else if (Raw.NumOperands == 3) {
Chris Lattnerb00c5822001-10-02 03:41:24 +0000170 Res = new BranchInst(cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg1)),
171 cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2)),
172 getValue(Type::BoolTy , Raw.Arg3));
Chris Lattner00950542001-06-06 20:29:01 +0000173 return false;
174 }
Chris Lattner027dcc52001-07-08 21:10:27 +0000175 break;
176
177 case Instruction::Switch: {
Chris Lattner00950542001-06-06 20:29:01 +0000178 SwitchInst *I =
179 new SwitchInst(getValue(Raw.Ty, Raw.Arg1),
Chris Lattnerb00c5822001-10-02 03:41:24 +0000180 cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2)));
Chris Lattner00950542001-06-06 20:29:01 +0000181 Res = I;
182 if (Raw.NumOperands < 3) return false; // No destinations? Wierd.
183
184 if (Raw.NumOperands == 3 || Raw.VarArgs->size() & 1) {
185 cerr << "Switch statement with odd number of arguments!\n";
186 delete I;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000187 return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000188 }
189
190 vector<unsigned> &args = *Raw.VarArgs;
191 for (unsigned i = 0; i < args.size(); i += 2)
Chris Lattnerb00c5822001-10-02 03:41:24 +0000192 I->dest_push_back(cast<ConstPoolVal>(getValue(Raw.Ty, args[i])),
193 cast<BasicBlock>(getValue(Type::LabelTy, args[i+1])));
Chris Lattner00950542001-06-06 20:29:01 +0000194
195 delete Raw.VarArgs;
196 return false;
Chris Lattner027dcc52001-07-08 21:10:27 +0000197 }
198
199 case Instruction::Call: {
Chris Lattner05950c32001-10-13 06:47:01 +0000200 Value *M = getValue(Raw.Ty, Raw.Arg1);
Chris Lattner3d3f2892001-07-28 17:50:18 +0000201 if (M == 0) return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000202
Chris Lattner05950c32001-10-13 06:47:01 +0000203 // Check to make sure we have a pointer to method type
204 PointerType *PTy = dyn_cast<PointerType>(M->getType());
205 if (PTy == 0) return failure(true);
206 MethodType *MTy = dyn_cast<MethodType>(PTy->getValueType());
207 if (MTy == 0) return failure(true);
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000208
Chris Lattner05950c32001-10-13 06:47:01 +0000209 vector<Value *> Params;
210 const MethodType::ParamTypes &PL = MTy->getParamTypes();
211
212 if (!MTy->isVarArg()) {
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000213 MethodType::ParamTypes::const_iterator It = PL.begin();
214
215 switch (Raw.NumOperands) {
216 case 0: cerr << "Invalid call instruction encountered!\n";
Chris Lattner3d3f2892001-07-28 17:50:18 +0000217 return failure(true);
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000218 case 1: break;
219 case 2: Params.push_back(getValue(*It++, Raw.Arg2)); break;
220 case 3: Params.push_back(getValue(*It++, Raw.Arg2));
Chris Lattner3d3f2892001-07-28 17:50:18 +0000221 if (It == PL.end()) return failure(true);
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000222 Params.push_back(getValue(*It++, Raw.Arg3)); break;
223 default:
224 Params.push_back(getValue(*It++, Raw.Arg2));
225 {
226 vector<unsigned> &args = *Raw.VarArgs;
227 for (unsigned i = 0; i < args.size(); i++) {
Chris Lattner3d3f2892001-07-28 17:50:18 +0000228 if (It == PL.end()) return failure(true);
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000229 // TODO: Check getValue for null!
230 Params.push_back(getValue(*It++, args[i]));
231 }
Chris Lattner00950542001-06-06 20:29:01 +0000232 }
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000233 delete Raw.VarArgs;
234 }
Chris Lattner3d3f2892001-07-28 17:50:18 +0000235 if (It != PL.end()) return failure(true);
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000236 } else {
Chris Lattner05950c32001-10-13 06:47:01 +0000237 if (Raw.NumOperands > 2) {
238 vector<unsigned> &args = *Raw.VarArgs;
239 if (args.size() < 1) return failure(true);
Chris Lattnere5a57ee2001-07-25 22:47:55 +0000240
Chris Lattner05950c32001-10-13 06:47:01 +0000241 if ((args.size() & 1) != 0)
242 return failure(true); // Must be pairs of type/value
243 for (unsigned i = 0; i < args.size(); i+=2) {
244 const Type *Ty = getType(args[i]);
245 if (Ty == 0)
246 return failure(true);
247
248 Value *V = getValue(Ty, args[i+1]);
249 if (V == 0) return failure(true);
250 Params.push_back(V);
251 }
252 delete Raw.VarArgs;
Chris Lattner00950542001-06-06 20:29:01 +0000253 }
Chris Lattner00950542001-06-06 20:29:01 +0000254 }
Chris Lattner00950542001-06-06 20:29:01 +0000255
256 Res = new CallInst(M, Params);
257 return false;
Chris Lattner027dcc52001-07-08 21:10:27 +0000258 }
Chris Lattner05950c32001-10-13 06:47:01 +0000259 case Instruction::Invoke: {
260 Value *M = getValue(Raw.Ty, Raw.Arg1);
261 if (M == 0) return failure(true);
262
263 // Check to make sure we have a pointer to method type
264 PointerType *PTy = dyn_cast<PointerType>(M->getType());
265 if (PTy == 0) return failure(true);
266 MethodType *MTy = dyn_cast<MethodType>(PTy->getValueType());
267 if (MTy == 0) return failure(true);
268
269 vector<Value *> Params;
270 const MethodType::ParamTypes &PL = MTy->getParamTypes();
271 vector<unsigned> &args = *Raw.VarArgs;
272
273 BasicBlock *Normal, *Except;
274
275 if (!MTy->isVarArg()) {
276 if (Raw.NumOperands < 3) return failure(true);
277
278 Normal = cast<BasicBlock>(getValue(Type::LabelTy, Raw.Arg2));
279 Except = cast<BasicBlock>(getValue(Type::LabelTy, args[0]));
280
281 MethodType::ParamTypes::const_iterator It = PL.begin();
282 for (unsigned i = 1; i < args.size(); i++) {
283 if (It == PL.end()) return failure(true);
284 // TODO: Check getValue for null!
285 Params.push_back(getValue(*It++, args[i]));
286 }
287
288 if (It != PL.end()) return failure(true);
289 } else {
290 if (args.size() < 4) return failure(true);
291
292 Normal = cast<BasicBlock>(getValue(Type::LabelTy, args[0]));
293 Except = cast<BasicBlock>(getValue(Type::LabelTy, args[2]));
294
295 if ((args.size() & 1) != 0)
296 return failure(true); // Must be pairs of type/value
297 for (unsigned i = 4; i < args.size(); i+=2) {
298 // TODO: Check getValue for null!
299 Params.push_back(getValue(getType(args[i]), args[i+1]));
300 }
301 }
302
303 delete Raw.VarArgs;
304 Res = new InvokeInst(M, Normal, Except, Params);
305 return false;
306 }
Chris Lattner027dcc52001-07-08 21:10:27 +0000307 case Instruction::Malloc:
Chris Lattner3d3f2892001-07-28 17:50:18 +0000308 if (Raw.NumOperands > 2) return failure(true);
Chris Lattner027dcc52001-07-08 21:10:27 +0000309 V = Raw.NumOperands ? getValue(Type::UIntTy, Raw.Arg1) : 0;
310 Res = new MallocInst(Raw.Ty, V);
Chris Lattner00950542001-06-06 20:29:01 +0000311 return false;
Chris Lattner027dcc52001-07-08 21:10:27 +0000312
313 case Instruction::Alloca:
Chris Lattner3d3f2892001-07-28 17:50:18 +0000314 if (Raw.NumOperands > 2) return failure(true);
Chris Lattner027dcc52001-07-08 21:10:27 +0000315 V = Raw.NumOperands ? getValue(Type::UIntTy, Raw.Arg1) : 0;
316 Res = new AllocaInst(Raw.Ty, V);
Chris Lattner00950542001-06-06 20:29:01 +0000317 return false;
Chris Lattner027dcc52001-07-08 21:10:27 +0000318
319 case Instruction::Free:
320 V = getValue(Raw.Ty, Raw.Arg1);
Chris Lattner3d3f2892001-07-28 17:50:18 +0000321 if (!V->getType()->isPointerType()) return failure(true);
Chris Lattner027dcc52001-07-08 21:10:27 +0000322 Res = new FreeInst(V);
323 return false;
324
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000325 case Instruction::Load:
326 case Instruction::GetElementPtr: {
Chris Lattner027dcc52001-07-08 21:10:27 +0000327 vector<ConstPoolVal*> Idx;
328 switch (Raw.NumOperands) {
Chris Lattner3d3f2892001-07-28 17:50:18 +0000329 case 0: cerr << "Invalid load encountered!\n"; return failure(true);
Chris Lattner027dcc52001-07-08 21:10:27 +0000330 case 1: break;
331 case 2: V = getValue(Type::UByteTy, Raw.Arg2);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000332 if (!isa<ConstPoolVal>(V)) return failure(true);
333 Idx.push_back(cast<ConstPoolVal>(V));
Chris Lattner027dcc52001-07-08 21:10:27 +0000334 break;
335 case 3: V = getValue(Type::UByteTy, Raw.Arg2);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000336 if (!isa<ConstPoolVal>(V)) return failure(true);
337 Idx.push_back(cast<ConstPoolVal>(V));
Chris Lattner027dcc52001-07-08 21:10:27 +0000338 V = getValue(Type::UByteTy, Raw.Arg3);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000339 if (!isa<ConstPoolVal>(V)) return failure(true);
340 Idx.push_back(cast<ConstPoolVal>(V));
Chris Lattner027dcc52001-07-08 21:10:27 +0000341 break;
342 default:
343 V = getValue(Type::UByteTy, Raw.Arg2);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000344 if (!isa<ConstPoolVal>(V)) return failure(true);
345 Idx.push_back(cast<ConstPoolVal>(V));
Chris Lattner027dcc52001-07-08 21:10:27 +0000346 vector<unsigned> &args = *Raw.VarArgs;
347 for (unsigned i = 0, E = args.size(); i != E; ++i) {
348 V = getValue(Type::UByteTy, args[i]);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000349 if (!isa<ConstPoolVal>(V)) return failure(true);
350 Idx.push_back(cast<ConstPoolVal>(V));
Chris Lattner027dcc52001-07-08 21:10:27 +0000351 }
352 delete Raw.VarArgs;
353 break;
354 }
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000355 if (Raw.Opcode == Instruction::Load)
356 Res = new LoadInst(getValue(Raw.Ty, Raw.Arg1), Idx);
357 else if (Raw.Opcode == Instruction::GetElementPtr)
358 Res = new GetElementPtrInst(getValue(Raw.Ty, Raw.Arg1), Idx);
359 else
360 abort();
361 return false;
362 }
363 case Instruction::Store: {
364 vector<ConstPoolVal*> Idx;
365 switch (Raw.NumOperands) {
366 case 0:
Chris Lattner3d3f2892001-07-28 17:50:18 +0000367 case 1: cerr << "Invalid store encountered!\n"; return failure(true);
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000368 case 2: break;
369 case 3: V = getValue(Type::UByteTy, Raw.Arg3);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000370 if (!isa<ConstPoolVal>(V)) return failure(true);
371 Idx.push_back(cast<ConstPoolVal>(V));
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000372 break;
373 default:
374 vector<unsigned> &args = *Raw.VarArgs;
375 for (unsigned i = 0, E = args.size(); i != E; ++i) {
376 V = getValue(Type::UByteTy, args[i]);
Chris Lattner1d87bcf2001-10-01 20:11:19 +0000377 if (!isa<ConstPoolVal>(V)) return failure(true);
378 Idx.push_back(cast<ConstPoolVal>(V));
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000379 }
380 delete Raw.VarArgs;
381 break;
382 }
383
384 const Type *ElType = StoreInst::getIndexedType(Raw.Ty, Idx);
Chris Lattner3d3f2892001-07-28 17:50:18 +0000385 if (ElType == 0) return failure(true);
Chris Lattnerab5ac6b2001-07-08 23:22:50 +0000386 Res = new StoreInst(getValue(ElType, Raw.Arg1), getValue(Raw.Ty, Raw.Arg2),
387 Idx);
Chris Lattner00950542001-06-06 20:29:01 +0000388 return false;
389 }
Chris Lattner027dcc52001-07-08 21:10:27 +0000390 } // end switch(Raw.Opcode)
Chris Lattner00950542001-06-06 20:29:01 +0000391
Chris Lattnerc8b25d42001-07-07 08:36:50 +0000392 cerr << "Unrecognized instruction! " << Raw.Opcode
393 << " ADDR = 0x" << (void*)Buf << endl;
Chris Lattner3d3f2892001-07-28 17:50:18 +0000394 return failure(true);
Chris Lattner00950542001-06-06 20:29:01 +0000395}