@@ -889,6 +889,40 @@ class YkIRWriter {
889
889
InstIdx++;
890
890
}
891
891
892
+ // / Serialise ptrtoint instruction.
893
+ void serialisePtrToIntInst (PtrToIntInst *I, FuncLowerCtxt &FLCtxt,
894
+ unsigned BBIdx, unsigned &InstIdx) {
895
+ if (I->getType ()->isVectorTy ()) {
896
+ // Vector variants are currently not supported.
897
+ serialiseUnimplementedInstruction (I, FLCtxt, BBIdx, InstIdx);
898
+ return ;
899
+ }
900
+ DataLayout DL (&M);
901
+ TypeSize SrcSize = DL.getTypeSizeInBits (I->getSrcTy ());
902
+ TypeSize DstSize = DL.getTypeSizeInBits (I->getDestTy ());
903
+
904
+ if (SrcSize <= DstSize) {
905
+ // Zero extend
906
+ // FIXME: We probably want to lower same-sized types to a bitcast, but
907
+ // zeroextend will do for now.
908
+ // opcode:
909
+ serialiseOpcode (OpCodeCast);
910
+ // cast_kind:
911
+ serialiseCastKind (CastKindZeroExt);
912
+ // val:
913
+ serialiseOperand (I, FLCtxt, I->getPointerOperand ());
914
+ // dest_type_idx:
915
+ OutStreamer.emitSizeT (typeIndex (I->getDestTy ()));
916
+ } else if (SrcSize > DstSize) {
917
+ // Truncate
918
+ serialiseUnimplementedInstruction (I, FLCtxt, BBIdx, InstIdx);
919
+ return ;
920
+ }
921
+
922
+ FLCtxt.updateVLMap (I, InstIdx);
923
+ InstIdx++;
924
+ }
925
+
892
926
void serialiseSwitchInst (SwitchInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
893
927
unsigned &InstIdx) {
894
928
// opcode:
@@ -959,6 +993,7 @@ class YkIRWriter {
959
993
INST_SERIALISE (I, SExtInst, serialiseSExtInst);
960
994
INST_SERIALISE (I, StoreInst, serialiseStoreInst);
961
995
INST_SERIALISE (I, SwitchInst, serialiseSwitchInst);
996
+ INST_SERIALISE (I, PtrToIntInst, serialisePtrToIntInst);
962
997
963
998
// INST_SERIALISE does an early return upon a match, so if we get here then
964
999
// the instruction wasn't handled.
0 commit comments