llvm.org GIT mirror llvm / f9f2e83
add abbrevs for binops and casts. This shrinks a testcase from 725132->682500 bytes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36829 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
1 changed file(s) with 29 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
4444
4545 // FUNCTION_BLOCK abbrev id's.
4646 FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
47 FUNCTION_INST_BINOP_ABBREV,
48 FUNCTION_INST_CAST_ABBREV,
4749 FUNCTION_INST_RET_VOID_ABBREV,
4850 FUNCTION_INST_RET_VAL_ABBREV,
4951 FUNCTION_INST_UNREACHABLE_ABBREV
661663 default:
662664 if (Instruction::isCast(I.getOpcode())) {
663665 Code = bitc::FUNC_CODE_INST_CAST;
664 PushValueAndType(I.getOperand(0), InstID, Vals, VE);
666 if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
667 AbbrevToUse = FUNCTION_INST_CAST_ABBREV;
665668 Vals.push_back(VE.getTypeID(I.getType()));
666669 Vals.push_back(GetEncodedCastOpcode(I.getOpcode()));
667670 } else {
668671 assert(isa(I) && "Unknown instruction!");
669672 Code = bitc::FUNC_CODE_INST_BINOP;
670 PushValueAndType(I.getOperand(0), InstID, Vals, VE);
673 if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
674 AbbrevToUse = FUNCTION_INST_BINOP_ABBREV;
671675 Vals.push_back(VE.getValueID(I.getOperand(1)));
672676 Vals.push_back(GetEncodedBinaryOpcode(I.getOpcode()));
673677 }
894898 /// WriteFunction - Emit a function body to the module stream.
895899 static void WriteFunction(const Function &F, ValueEnumerator &VE,
896900 BitstreamWriter &Stream) {
897 Stream.EnterSubblock(bitc::FUNCTION_BLOCK_ID, 3);
901 Stream.EnterSubblock(bitc::FUNCTION_BLOCK_ID, 4);
898902 VE.incorporateFunction(F);
899903
900904 SmallVector Vals;
10711075 Abbv) != FUNCTION_INST_LOAD_ABBREV)
10721076 assert(0 && "Unexpected abbrev ordering!");
10731077 }
1078 { // INST_BINOP abbrev for FUNCTION_BLOCK.
1079 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
1080 Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_BINOP));
1081 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
1082 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS
1083 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
1084 if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
1085 Abbv) != FUNCTION_INST_BINOP_ABBREV)
1086 assert(0 && "Unexpected abbrev ordering!");
1087 }
1088 { // INST_CAST abbrev for FUNCTION_BLOCK.
1089 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
1090 Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_CAST));
1091 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // OpVal
1092 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, // dest ty
1093 Log2_32_Ceil(VE.getTypes().size()+1)));
1094 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
1095 if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
1096 Abbv) != FUNCTION_INST_CAST_ABBREV)
1097 assert(0 && "Unexpected abbrev ordering!");
1098 }
1099
10741100 { // INST_RET abbrev for FUNCTION_BLOCK.
10751101 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
10761102 Abbv->Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_RET));