@@ -239,6 +239,30 @@ class YkIRWriter {
239
239
InstIdx++;
240
240
}
241
241
242
+ void serialiseCallInst (CallInst *I, ValueLoweringMap &VLMap, unsigned BBIdx,
243
+ unsigned InstIdx) {
244
+ // type_index:
245
+ OutStreamer.emitSizeT (typeIndex (I->getType ()));
246
+ // opcode:
247
+ serialiseOpcode (OpCode::Call);
248
+ // num_operands:
249
+ unsigned NumOpers = I->getNumOperands ();
250
+ OutStreamer.emitInt32 (NumOpers);
251
+
252
+ // OPERAND 0: What to call.
253
+ //
254
+ // In LLVM IR this is the final operand, which is a cause of confusion.
255
+ serialiseOperand (I, VLMap, I->getOperand (NumOpers - 1 ));
256
+
257
+ // Now the rest of the operands.
258
+ for (unsigned OI = 0 ; OI < NumOpers - 1 ; OI++) {
259
+ serialiseOperand (I, VLMap, I->getOperand (OI));
260
+ }
261
+
262
+ VLMap[I] = {BBIdx, InstIdx};
263
+ InstIdx++;
264
+ }
265
+
242
266
void serialiseInst (Instruction *I, ValueLoweringMap &VLMap, unsigned BBIdx,
243
267
unsigned &InstIdx) {
244
268
// Macros to help dispatch to serialisers.
@@ -257,14 +281,14 @@ class YkIRWriter {
257
281
258
282
GENERIC_INST_SERIALISE (I, LoadInst, Load)
259
283
GENERIC_INST_SERIALISE (I, StoreInst, Store)
260
- GENERIC_INST_SERIALISE (I, CallInst, Call)
261
284
GENERIC_INST_SERIALISE (I, GetElementPtrInst, GetElementPtr)
262
285
GENERIC_INST_SERIALISE (I, BranchInst, Branch)
263
286
GENERIC_INST_SERIALISE (I, ICmpInst, ICmp)
264
287
GENERIC_INST_SERIALISE (I, llvm::BinaryOperator, BinaryOperator)
265
288
GENERIC_INST_SERIALISE (I, ReturnInst, Ret)
266
289
267
290
CUSTOM_INST_SERIALISE (I, AllocaInst, serialiseAllocaInst)
291
+ CUSTOM_INST_SERIALISE (I, CallInst, serialiseCallInst)
268
292
269
293
// GENERIC_INST_SERIALISE and CUSTOM_INST_SERIALISE do an early return upon
270
294
// a match, so if we get here then the instruction wasn't handled.
0 commit comments