private Variable createVar(Function func, int frameOffset, int offset, int refSize)
			throws InvalidInputException {
		if (dontCreateNewVariables) {
			return null;
		}
		StackFrame frame = func.getStackFrame();
		int frameLoc = offset + frameOffset;
		Variable var = frame.getVariableContaining(frameLoc);
		if (var == null) {
			try {
				if (!createLocalStackVars && frameLoc <= 0) {
					return null;
				}
				if (!createStackParams && frameLoc > 0) {
					return null;
				}
				// only create variables at locations where a variable doesn't exist
				var = frame.createVariable(null, frameLoc, Undefined.getUndefinedDataType(refSize),
					SourceType.ANALYSIS);
			}
			catch (DuplicateNameException e) {
				throw new AssertException(e);
			}
		}
		else if (var.getStackOffset() == frameLoc && var.getDataType().getLength() < refSize) {
			// don't get rid of existing variables, just change their size bigger
			DataType dt = var.getDataType();
			if (dt instanceof Undefined || dt == DefaultDataType.dataType) {
				var.setDataType(Undefined.getUndefinedDataType(refSize), SourceType.ANALYSIS);
			}
		}
		return var;
	}
Look at the result register to try and figure out stack access size.

@param instr instruction being analyzed
@param opIndex operand that has a stack reference.

@return size of value referenced on the stack
Ghidra/Features/Base/src/main/java/ghidra/app/cmd/function/FunctionStackAnalysisCmd.java