private int calcContextVarLayout(int start, int sz, int numbits) {
		entry("calcContextVarLayout", start, sz, numbits);
		VarnodeSymbol sym = contexttable.get(start).sym;
		FieldQuality qual;
		int i, j;

		final int symSize = sym.getSize();
		if (symSize % 4 != 0) {
			reportError(sym.location,
				String.format("Invalid size of context register '%s' (%d); must be a multiple of 4",
					sym.getName(), symSize));
		}
		final int maxBits = symSize * 8 - 1;

		i = 0;
		while (i < sz) {

			qual = contexttable.get(i + start).qual;
			int min = qual.low;
			int max = qual.high;
			if (max - min > (8 * 4)) {
				reportError(qual.location,
					String.format(
						"Size of bitfield %s=(%d,%d) larger than %d bits in context register '%s'",
						qual.name, min, max, (8 * 4), sym.getName()));

			}
			if (max > maxBits) {
				reportError(qual.location, String.format(
					"Scope of bitfield %s=(%d,%d) extends beyond the size of context register '%s' (%d)",
					qual.name, min, max, sym.getName(), maxBits));
			}

			j = i + 1;
			// Find union of fields overlapping with first field
			while (j < sz) {
				qual = contexttable.get(j + start).qual;
				if (qual.low <= max) { // We have overlap of context variables
					if (qual.high > max) {
						max = qual.high;
						// reportWarning("Local context variables overlap in
						// "+sym.getName(),false);
					}
				}
				else {
					break;
				}
				j = j + 1;
			}

			int alloc = max - min + 1;
			int startword = Utils.unsignedDivide(numbits, (8 * 4));
			int endword = Utils.unsignedDivide((numbits + alloc - 1), (8 * 4));
			if (startword != endword) {
				numbits = endword * (8 * 4); // Bump up to next word
			}

			int low = numbits;
			numbits += alloc;

			for (; i < j; ++i) {
				qual = contexttable.get(i + start).qual;
				int l = qual.low - min + low;
				int h = numbits - 1 - (max - qual.high);
				ContextField field = new ContextField(qual.location, qual.signext, l, h);
				int id = addSymbol(new ContextSymbol(qual.location, qual.name, field, sym, qual.low,
					qual.high, qual.flow));
				if (firstContextField == null) {
					firstContextField = id;
				}
			}

		}
		sym.markAsContext();
		return numbits;
	}
<code>SleighCompile</code> provides the ability to compile Sleigh language module (e.g., *.slaspec)
files.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/pcodeCPort/slgh_compile/SleighCompile.java