diff --git a/llvm/lib/YkIR/YkIRWriter.cpp b/llvm/lib/YkIR/YkIRWriter.cpp index 8c6086b4263e4d..81f5838e281cb6 100644 --- a/llvm/lib/YkIR/YkIRWriter.cpp +++ b/llvm/lib/YkIR/YkIRWriter.cpp @@ -49,6 +49,7 @@ enum OpCode { OpCodeInsertValue, OpCodePtrAdd, OpCodeBinOp, + OpCodeCast, OpCodeUnimplemented = 255, // YKFIXME: Will eventually be deleted. }; @@ -69,6 +70,10 @@ enum TypeKind { TypeKindUnimplemented = 255, // YKFIXME: Will eventually be deleted. }; +enum CastKind { + CastKindSignExt = 0, +}; + // A predicate used in a numeric comparison. enum CmpPredicate { PredEqual = 0, @@ -603,6 +608,23 @@ class YkIRWriter { InstIdx++; } + void serialiseCastKind(enum CastKind Cast) { OutStreamer.emitInt8(Cast); } + + /// Serialise a cast-like insruction. + void serialiseSExtInst(SExtInst *I, ValueLoweringMap &VLMap, unsigned BBIdx, + unsigned &InstIdx) { + // opcode: + serialiseOpcode(OpCodeCast); + // cast_kind: + serialiseCastKind(CastKindSignExt); + // val: + serialiseOperand(I, VLMap, I->getOperand(0)); + // dest_type_idx: + OutStreamer.emitSizeT(typeIndex(I->getDestTy())); + + VLMap[I] = {BBIdx, InstIdx}; + InstIdx++; + } void serialiseInst(Instruction *I, ValueLoweringMap &VLMap, unsigned BBIdx, unsigned &InstIdx) { // Macro to make the dispatch below easier to read/sort. @@ -621,6 +643,7 @@ class YkIRWriter { INST_SERIALISE(I, InsertValueInst, serialiseInsertValueInst); INST_SERIALISE(I, LoadInst, serialiseLoadInst); INST_SERIALISE(I, ReturnInst, serialiseReturnInst); + INST_SERIALISE(I, SExtInst, serialiseSExtInst); INST_SERIALISE(I, StoreInst, serialiseStoreInst); // INST_SERIALISE does an early return upon a match, so if we get here then