freedreno/rnn: add relaxed boolean type
authorRob Clark <robdclark@chromium.org>
Tue, 28 Jul 2020 16:47:38 +0000 (09:47 -0700)
committerMarge Bot <eric+marge@anholt.net>
Wed, 29 Jul 2020 14:30:35 +0000 (14:30 +0000)
In the schema, boolean means strictly "true" or "false".  But rnn
parsing code was looking for "yes"/"1"/"no"/"0".  So split the
difference, and add a relaxed boolean type, and update rnn to also
accept "true" or "false".

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6107>

src/freedreno/registers/rules-ng.xsd
src/freedreno/rnn/rnn.c

index a5a33412aed2f2352249240f615f4f40a343c572..e5f80efaee566cfdb0a472206036ddcff2615762 100644 (file)
@@ -80,7 +80,7 @@
                        <group ref="rng:regarrayGroup" />\r
                </choice>\r
                <attribute name="name" type="NMTOKEN" use="required" />\r
-               <attribute name="bare" type="boolean" use="optional" />\r
+               <attribute name="bare" type="rng:Boolean" use="optional" />\r
                <attribute name="prefix" type="NMTOKENS" use="optional" />\r
                <attribute name="width" type="rng:DomainWidth" use="optional" />\r
                <attribute name="size" type="rng:Hexadecimal" use="optional" />\r
                        <group ref="rng:topGroup" />\r
                </choice>\r
                <attribute name="name" type="NMTOKEN" use="required" />\r
-               <attribute name="inline" type="boolean" use="optional" />\r
-               <attribute name="bare" type="boolean" use="optional" />\r
+               <attribute name="inline" type="rng:Boolean" use="optional" />\r
+               <attribute name="bare" type="rng:Boolean" use="optional" />\r
                <attribute name="prefix" type="NMTOKENS" use="optional" />\r
        </complexType>\r
 \r
                        <group ref="rng:topGroup" />\r
                </choice>\r
                <attribute name="name" type="NMTOKEN" use="required" />\r
-               <attribute name="inline" type="boolean" use="optional" />\r
-               <attribute name="bare" type="boolean" use="optional" />\r
+               <attribute name="inline" type="rng:Boolean" use="optional" />\r
+               <attribute name="bare" type="rng:Boolean" use="optional" />\r
                <attribute name="prefix" type="NMTOKENS" use="optional" />\r
        </complexType>\r
 \r
                <union memberTypes="rng:Hexadecimal nonNegativeInteger" />\r
        </simpleType>\r
 \r
+       <simpleType name="Boolean">\r
+               <restriction base="string">\r
+                       <enumeration value="true" />\r
+                       <enumeration value="1" />\r
+                       <enumeration value="yes" />\r
+                       <enumeration value="false" />\r
+                       <enumeration value="0" />\r
+                       <enumeration value="no" />\r
+               </restriction>\r
+       </simpleType>\r
+\r
        <simpleType name="Access">\r
                <annotation>\r
                        <documentation>Access</documentation>\r
index d6ba6fa50052a5da62e0ef698c2988608ca87a14..17abf79715c086bee467eb47ed3f20fac4392518 100644 (file)
@@ -124,9 +124,9 @@ static char *getattrib (struct rnndb *db, char *file, int line, xmlAttr *attr) {
 
 static int getboolattrib (struct rnndb *db, char *file, int line, xmlAttr *attr) {
        char *c = getattrib(db, file, line, attr);
-       if (!strcmp(c, "yes") || !strcmp(c, "1"))
+       if (!strcmp(c, "yes") || !strcmp(c, "1") || !strcmp(c, "true"))
                return 1;
-       if (!strcmp(c, "no") || !strcmp(c, "0"))
+       if (!strcmp(c, "no") || !strcmp(c, "0") || !strcmp(c, "false"))
                return 0;
        rnn_err(db, "%s:%d: invalid boolean value \"%s\" in attribute \"%s\"\n", file, line, c, attr->name);
        return 0;