-void BytecodeWriter::outputCompactionTablePlane(unsigned PlaneNo,
- const std::vector<const Value*> &Plane,
- unsigned StartNo) {
- unsigned End = Table.getModuleLevel(PlaneNo);
- if (Plane.empty() || StartNo == End || End == 0) return; // Nothing to emit
- assert(StartNo < End && "Cannot emit negative range!");
- assert(StartNo < Plane.size() && End <= Plane.size());
-
- // Do not emit the null initializer!
- ++StartNo;
-
- // Figure out which encoding to use. By far the most common case we have is
- // to emit 0-2 entries in a compaction table plane.
- switch (End-StartNo) {
- case 0: // Avoid emitting two vbr's if possible.
- case 1:
- case 2:
- output_vbr((PlaneNo << 2) | End-StartNo);
- break;
- default:
- // Output the number of things.
- output_vbr((unsigned(End-StartNo) << 2) | 3);
- output_typeid(PlaneNo); // Emit the type plane this is
- break;
- }
-
- for (unsigned i = StartNo; i != End; ++i)
- output_vbr(Table.getGlobalSlot(Plane[i]));
-}
-
-void BytecodeWriter::outputCompactionTypes(unsigned StartNo) {
- // Get the compaction type table from the slot calculator
- const std::vector<const Type*> &CTypes = Table.getCompactionTypes();
-
- // The compaction types may have been uncompactified back to the
- // global types. If so, we just write an empty table
- if (CTypes.size() == 0 ) {
- output_vbr(0U);
- return;
- }
-
- assert(CTypes.size() >= StartNo && "Invalid compaction types start index");
-
- // Determine how many types to write
- unsigned NumTypes = CTypes.size() - StartNo;
-
- // Output the number of types.
- output_vbr(NumTypes);