diff --git a/target/i386/feature_word_info.c.inc b/target/i386/feature_word_info.c.inc
index 040c3c4e56..b8e77ab7e5 100644
--- a/target/i386/feature_word_info.c.inc
+++ b/target/i386/feature_word_info.c.inc
@@ -1,3 +1,5 @@
+/* This file is autogenerated by feature_word_info.py. */
+
 FeatureWordInfo feature_word_info[FEATURE_WORDS] = {
     [FEAT_1_EDX] = {
         .type = CPUID_FEATURE_WORD,
diff --git a/target/i386/feature_word_info.py b/target/i386/feature_word_info.py
new file mode 100755
index 0000000000..95f3931aa0
--- /dev/null
+++ b/target/i386/feature_word_info.py
@@ -0,0 +1,110 @@
+#!/bin/env python3
+
+import lxml.etree
+import os
+
+
+class FeatureWord:
+    def __init__(self, xml):
+        self.index = xml.values()[0]
+        for node in xml:
+            if node.tag == "cpuid":
+                self.cpuid = dict()
+                for child in node:
+                    self.cpuid[child.tag] = child.text
+            elif node.tag == "feat_names":
+                self.feat_names = [child.text for child in node]
+            else:
+                setattr(self, node.tag, node.text)
+
+
+def write_feat_names(f, data):
+    f.write("        .feat_names = {\n")
+    for index, name in enumerate(data):
+        if name is None:
+            name = "NULL"
+        if index % 4 == 0:
+            f.write(" " * 11)
+        f.write(" " + str(name) + ",")
+        if index % 4 == 3:
+            f.write("\n")
+    f.write("        },\n")
+
+
+def write_cpuid(f, data):
+    f.write("        .cpuid = {\n")
+    f.write("            .eax = {},\n".format(data["eax"]))
+    if "ecx" in data:
+        f.write("            .needs_ecx = true,\n")
+        f.write("            .ecx = {},\n".format(data["ecx"]))
+    f.write("            .reg = {},\n".format(data["reg"]))
+    f.write("        },\n")
+
+
+def write_msr(f, data):
+    f.write("        .msr = {\n")
+    f.write("            .index = {},\n".format(data))
+    f.write("        },\n")
+
+
+def write_tcg_features(f, data):
+    f.write("        .tcg_features = {},\n".format(data))
+
+
+def write_unmigratable_flags(f, data):
+    f.write("        .unmigratable_flags = {},\n".format(data))
+
+
+def write_migratable_flags(f, data):
+    f.write("        .migratable_flags = {},\n".format(data))
+
+
+def write_no_autoenable_flags(f, data):
+    f.write("        .no_autoenable_flags = {},\n".format(data))
+
+
+def write_feature_word(f, data):
+    f.write("    [{}] = {{\n".format(data.index))
+    f.write("        .type = {},\n".format(data.type))
+    if hasattr(data, "feat_names"):
+        write_feat_names(f, data.feat_names)
+    if hasattr(data, "cpuid"):
+        write_cpuid(f, data.cpuid)
+    if hasattr(data, "msr"):
+        write_msr(f, data.msr)
+    if hasattr(data, "tcg_features"):
+        write_tcg_features(f, data.tcg_features)
+    if hasattr(data, "unmigratable_flags"):
+        write_unmigratable_flags(f, data.unmigratable_flags)
+    if hasattr(data, "migratable_flags"):
+        write_migratable_flags(f, data.migratable_flags)
+    if hasattr(data, "no_autoenable_flags"):
+        write_no_autoenable_flags(f, data.no_autoenable_flags)
+    f.write("    },\n")
+
+
+def write_feature_words(f, data):
+    f.write("/* This file is autogenerated by feature_word_info.py. */\n\n")
+    f.write("FeatureWordInfo feature_word_info[FEATURE_WORDS] = {\n")
+    for feature_word in data:
+        write_feature_word(f, feature_word)
+    f.write("};\n")
+
+
+def main():
+    dirname = os.path.dirname(__file__)
+    ifile = os.path.join(dirname, "feature_word_info.xml")
+    ofile = os.path.join(dirname, "feature_word_info.c.inc")
+
+    parser = lxml.etree.XMLParser(remove_comments=True, remove_blank_text=True)
+    with open(ifile, "tr") as f:
+        doc = lxml.etree.parse(f, parser=parser)
+
+    feature_words = [FeatureWord(node) for node in doc.getroot()]
+
+    with open(ofile, "tw") as f:
+        write_feature_words(f, feature_words)
+
+
+if __name__ == "__main__":
+    main()
diff --git a/target/i386/feature_word_info.xml b/target/i386/feature_word_info.xml
index ff741b9f5a..662b8b1dfc 100644
--- a/target/i386/feature_word_info.xml
+++ b/target/i386/feature_word_info.xml
@@ -1,3 +1,6 @@
+<!--
+    Run `feature_word_info.py` when you make changes to this file.
+-->
 <feature_words>
     <feature_word index="FEAT_1_EDX">
         <type>CPUID_FEATURE_WORD</type>
