Skip to content

Commit 7901e2c

Browse files
authored
Merge pull request rust-lang#156 from ptersilie/zext
Lower zext instructions.
2 parents ec1d0dd + 3c79b79 commit 7901e2c

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

llvm/lib/YkIR/YkIRWriter.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ enum TypeKind {
7777

7878
enum CastKind {
7979
CastKindSignExt = 0,
80+
CastKindZeroExt = 1,
8081
};
8182

8283
// A predicate used in a numeric comparison.
@@ -843,7 +844,7 @@ class YkIRWriter {
843844

844845
void serialiseCastKind(enum CastKind Cast) { OutStreamer.emitInt8(Cast); }
845846

846-
/// Serialise a cast-like insruction.
847+
/// Serialise a cast-like instruction.
847848
void serialiseSExtInst(SExtInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
848849
unsigned &InstIdx) {
849850
// opcode:
@@ -859,6 +860,22 @@ class YkIRWriter {
859860
InstIdx++;
860861
}
861862

863+
/// Serialise a cast-like instruction.
864+
void serialiseZExtInst(ZExtInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
865+
unsigned &InstIdx) {
866+
// opcode:
867+
serialiseOpcode(OpCodeCast);
868+
// cast_kind:
869+
serialiseCastKind(CastKindZeroExt);
870+
// val:
871+
serialiseOperand(I, FLCtxt, I->getOperand(0));
872+
// dest_type_idx:
873+
OutStreamer.emitSizeT(typeIndex(I->getDestTy()));
874+
875+
FLCtxt.updateVLMap(I, InstIdx);
876+
InstIdx++;
877+
}
878+
862879
void serialiseSwitchInst(SwitchInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
863880
unsigned &InstIdx) {
864881
// opcode:
@@ -925,6 +942,7 @@ class YkIRWriter {
925942
INST_SERIALISE(I, LoadInst, serialiseLoadInst);
926943
INST_SERIALISE(I, PHINode, serialisePhiInst);
927944
INST_SERIALISE(I, ReturnInst, serialiseReturnInst);
945+
INST_SERIALISE(I, ZExtInst, serialiseZExtInst);
928946
INST_SERIALISE(I, SExtInst, serialiseSExtInst);
929947
INST_SERIALISE(I, StoreInst, serialiseStoreInst);
930948
INST_SERIALISE(I, SwitchInst, serialiseSwitchInst);

0 commit comments

Comments
 (0)