The Scratch buffer passed to getBinaryCodeForInst needs to be able to hold any value returned by getMachineOpValue or other custom encoders. It's better to let the caller of getBinaryCodeForInst set the size of Scratch as it's impossible for VarLenCodeEmitterGen to know what the smallest needed size is. VarLenCodeEmitterGen now calculates its smallest needed Scratch bit width based on the slice operations and zero extends Scratch if it's too small. This only guarantees that Scratch has enough bits for the generated code not for getMachineOpValue or custom encoders. The smallest internal APInt representation uses one uint64_t word so there is no point in using a smaller size.
19 KiB
19 KiB