intel: genxml: prevent missing ; with address fields dwords
authorLionel Landwerlin <lionel.g.landwerlin@intel.com>
Sun, 12 Mar 2017 16:53:29 +0000 (16:53 +0000)
committerLionel Landwerlin <lionel.g.landwerlin@intel.com>
Mon, 13 Mar 2017 17:23:49 +0000 (17:23 +0000)
Before this change, the generator could print this kind of things :

   const uint32_t v0 =
      __gen_uint(values->ValidBit, 0, 0) |
      __gen_uint(values->FaultType, 1, 2) |
      __gen_uint(values->SRCIDofFault, 3, 10) |
      __gen_uint(values->GTTSEL, 11, 1) |
   dw[0] = __gen_combine_address(data, &dw[0], values->VirtualAddressofFault, v0);

This change fix the trailing '|'.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/intel/genxml/gen_pack_header.py

index a1befaf45e96ec5c4621d96232aa81b2ba69951b..2a709454af3061a584bb7cfac121d80461c67a36 100644 (file)
@@ -415,51 +415,49 @@ class Group(object):
                 v = "0"
 
             field_index = 0
+            non_address_fields = []
             for field in dw.fields:
                 if field.type != "mbo":
                     name = field.name + field.dim
 
                 if field.type == "mbo":
-                    s = "__gen_mbo(%d, %d)" % \
-                        (field.start - dword_start, field.end - dword_start)
+                    non_address_fields.append("__gen_mbo(%d, %d)" % \
+                        (field.start - dword_start, field.end - dword_start))
                 elif field.type == "address":
-                    s = None
+                    pass
                 elif field.type == "uint":
-                    s = "__gen_uint(values->%s, %d, %d)" % \
-                        (name, field.start - dword_start, field.end - dword_start)
+                    non_address_fields.append("__gen_uint(values->%s, %d, %d)" % \
+                        (name, field.start - dword_start, field.end - dword_start))
                 elif field.type in self.parser.enums:
-                    s = "__gen_uint(values->%s, %d, %d)" % \
-                        (name, field.start - dword_start, field.end - dword_start)
+                    non_address_fields.append("__gen_uint(values->%s, %d, %d)" % \
+                        (name, field.start - dword_start, field.end - dword_start))
                 elif field.type == "int":
-                    s = "__gen_sint(values->%s, %d, %d)" % \
-                        (name, field.start - dword_start, field.end - dword_start)
+                    non_address_fields.append("__gen_sint(values->%s, %d, %d)" % \
+                        (name, field.start - dword_start, field.end - dword_start))
                 elif field.type == "bool":
-                    s = "__gen_uint(values->%s, %d, %d)" % \
-                        (name, field.start - dword_start, field.end - dword_start)
+                    non_address_fields.append("__gen_uint(values->%s, %d, %d)" % \
+                        (name, field.start - dword_start, field.end - dword_start))
                 elif field.type == "float":
-                    s = "__gen_float(values->%s)" % name
+                    non_address_fields.append("__gen_float(values->%s)" % name)
                 elif field.type == "offset":
-                    s = "__gen_offset(values->%s, %d, %d)" % \
-                        (name, field.start - dword_start, field.end - dword_start)
+                    non_address_fields.append("__gen_offset(values->%s, %d, %d)" % \
+                        (name, field.start - dword_start, field.end - dword_start))
                 elif field.type == 'ufixed':
-                    s = "__gen_ufixed(values->%s, %d, %d, %d)" % \
-                        (name, field.start - dword_start, field.end - dword_start, field.fractional_size)
+                    non_address_fields.append("__gen_ufixed(values->%s, %d, %d, %d)" % \
+                        (name, field.start - dword_start, field.end - dword_start, field.fractional_size))
                 elif field.type == 'sfixed':
-                    s = "__gen_sfixed(values->%s, %d, %d, %d)" % \
-                        (name, field.start - dword_start, field.end - dword_start, field.fractional_size)
+                    non_address_fields.append("__gen_sfixed(values->%s, %d, %d, %d)" % \
+                        (name, field.start - dword_start, field.end - dword_start, field.fractional_size))
                 elif field.type in self.parser.structs:
-                    s = "__gen_uint(v%d_%d, %d, %d)" % \
-                        (index, field_index, field.start - dword_start, field.end - dword_start)
+                    non_address_fields.append("__gen_uint(v%d_%d, %d, %d)" % \
+                        (index, field_index, field.start - dword_start, field.end - dword_start))
                     field_index = field_index + 1
                 else:
-                    print("/* unhandled field %s, type %s */\n" % (name, field.type))
-                    s = None
-
-                if not s == None:
-                    if field == dw.fields[-1]:
-                        print("      %s;" % s)
-                    else:
-                        print("      %s |" % s)
+                    non_address_fields.append("/* unhandled field %s, type %s */\n" % \
+                                              (name, field.type))
+
+            if len(non_address_fields) > 0:
+                print(" |\n".join("      " + f for f in non_address_fields) + ";")
 
             if dw.size == 32:
                 if dw.address: