@@ -954,6 +954,40 @@ class YkIRWriter {
954
954
InstIdx++;
955
955
}
956
956
957
+ // / Serialise ptrtoint instruction.
958
+ void serialisePtrToIntInst (PtrToIntInst *I, FuncLowerCtxt &FLCtxt,
959
+ unsigned BBIdx, unsigned &InstIdx) {
960
+ if (I->getType ()->isVectorTy ()) {
961
+ // Vector variants are currently not supported.
962
+ serialiseUnimplementedInstruction (I, FLCtxt, BBIdx, InstIdx);
963
+ return ;
964
+ }
965
+ DataLayout DL (&M);
966
+ TypeSize SrcSize = DL.getTypeSizeInBits (I->getSrcTy ());
967
+ TypeSize DstSize = DL.getTypeSizeInBits (I->getDestTy ());
968
+
969
+ if (SrcSize <= DstSize) {
970
+ // Zero extend
971
+ // FIXME: We probably want to lower same-sized types to a bitcast, but
972
+ // zeroextend will do for now.
973
+ // opcode:
974
+ serialiseOpcode (OpCodeCast);
975
+ // cast_kind:
976
+ serialiseCastKind (CastKindZeroExt);
977
+ // val:
978
+ serialiseOperand (I, FLCtxt, I->getPointerOperand ());
979
+ // dest_type_idx:
980
+ OutStreamer.emitSizeT (typeIndex (I->getDestTy ()));
981
+ } else if (SrcSize > DstSize) {
982
+ // Truncate
983
+ serialiseUnimplementedInstruction (I, FLCtxt, BBIdx, InstIdx);
984
+ return ;
985
+ }
986
+
987
+ FLCtxt.updateVLMap (I, InstIdx);
988
+ InstIdx++;
989
+ }
990
+
957
991
void serialiseSwitchInst (SwitchInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
958
992
unsigned &InstIdx) {
959
993
// opcode:
@@ -1034,6 +1068,7 @@ class YkIRWriter {
1034
1068
INST_SERIALISE (I, SExtInst, serialiseSExtInst);
1035
1069
INST_SERIALISE (I, StoreInst, serialiseStoreInst);
1036
1070
INST_SERIALISE (I, SwitchInst, serialiseSwitchInst);
1071
+ INST_SERIALISE (I, PtrToIntInst, serialisePtrToIntInst);
1037
1072
1038
1073
// INST_SERIALISE does an early return upon a match, so if we get here then
1039
1074
// the instruction wasn't handled.
0 commit comments