@SuppressWarnings("unchecked")
	private static int readMappingsElem(Element regMappingsElem, Language lang,
			Map<Integer, Register> dwarfRegisterMap) throws IOException {

		int stackPointerIndex = -1;

		for (Element regMappingElem : (List<Element>) regMappingsElem.getChildren(
			"register_mapping")) {

			int dwarfRegNum =
				XmlUtilities.parseBoundedIntAttr(regMappingElem, "dwarf", 0, Integer.MAX_VALUE);
			String ghidraRegName = XmlUtilities.requireStringAttr(regMappingElem, "ghidra");
			boolean stackPointer =
				XmlUtilities.parseOptionalBooleanAttr(regMappingElem, "stackpointer", false);
			int autoincCount = XmlUtilities.parseOptionalBoundedIntAttr(regMappingElem,
				"auto_count", -1, 0, Integer.MAX_VALUE);
			if (autoincCount > 0) {
				Pattern regNamePattern = Pattern.compile("([a-zA-Z]+)([0-9]+)");
				Matcher m = regNamePattern.matcher(ghidraRegName);
				if (!m.matches()) {
					throw new IOException("Unsupported register name for auto-increment: " +
						ghidraRegName + ", " + XmlUtilities.toString(regMappingElem));
				}
				String baseGhidraRegName = m.group(1);
				int baseGhidraRegNum = Integer.parseInt(m.group(2));
				for (int autoIncNum = 0; autoIncNum < autoincCount; autoIncNum++) {
					String autoIncRegName =
						baseGhidraRegName + Integer.toString(baseGhidraRegNum + autoIncNum);
					Register autoIncReg = lang.getRegister(autoIncRegName);
					if (autoIncReg == null) {
						throw new IOException("Unknown Ghidra auto-increment register: " +
							autoIncRegName + ", " + XmlUtilities.toString(regMappingElem) +
							" for " + lang.getLanguageID());
					}
					int actualDwarfRegNum = dwarfRegNum + autoIncNum;
					if (dwarfRegisterMap.containsKey(actualDwarfRegNum)) {
						throw new IOException("Duplicate mapping for DWARF register " +
							actualDwarfRegNum + ": " + XmlUtilities.toString(regMappingElem));
					}
					dwarfRegisterMap.put(actualDwarfRegNum, autoIncReg);
				}
			}
			else {
				Register reg = lang.getRegister(ghidraRegName);
				if (reg == null) {
					throw new IOException("Unknown Ghidra register: " + ghidraRegName + ", " +
						XmlUtilities.toString(regMappingElem));
				}
				if (dwarfRegisterMap.containsKey(dwarfRegNum)) {
					throw new IOException("Duplicate mapping for DWARF register " + dwarfRegNum +
						": " + XmlUtilities.toString(regMappingElem));
				}

				dwarfRegisterMap.put(dwarfRegNum, reg);
				if (stackPointer) {
					stackPointerIndex = dwarfRegNum;
				}
			}
		}

		if (stackPointerIndex < 0) {
			throw new IOException("Missing stackpointer specification in registermappings");
		}

		return stackPointerIndex;
	}
Creates a new {@link DWARFRegisterMappings} from the data present in the
xml element.

@param rootElem JDom XML element containing the &lt;dwarf&gt; root
           element of the mapping file.
@param lang The Ghidra {@link Language} that the DWARF register mapping
           applies to
@return a new {@link DWARFRegisterMappings} instance, never null.
@throws IOException if missing or invalid data found in xml
Ghidra/Features/Base/src/main/java/ghidra/app/util/bin/format/dwarf/DWARFRegisterMappingsManager.java