Re: [RFC PATCH 32/77] dtc-parser: Introduce last_header_flags
David Gibson <[email protected]> Wed, 21 Jan 2026 13:37:52 +1100
| Newsgroups | org.kernel.vger.devicetree-compiler,org.kernel.vger.devicetree-spec,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <aXA8AOuucE5JdJCW@zatzit> |
On Mon, Jan 19, 2026 at 03:11:45PM +0100, Herve Codina wrote: > On Thu, 15 Jan 2026 17:31:24 +1100 > David Gibson <[email protected]> wrote: > > > On Mon, Jan 12, 2026 at 03:19:22PM +0100, Herve Codina wrote: > > > The parser needs to get header flags value in different places. > > > > > > It relies on the fact that the rule used to parse the dts file is always > > > headers memreserves devicetree > > > > > > With that only rule to parse the file, it uses '$<flags>-1' construct to > > > get the flags value. > > > > > > With the future introduction of import symbols parsing, this rule will > > > change and the parser couldn't rely anymore on '$<flags>-1' to get flags > > > value. Indeed, import symbols parsing will add a new optional symbol in > > > this rule leading to two possible rules (with and without the new > > > symbol) to parse the source file. > > > > > > Introduce the last_header_flags variable to explicitly keep track of > > > flags while also being agnostic of the rule structure and use this new > > > variable instead of '$<flags>-1'. > > > > I'm not sure this approach is safe: I'm not sure bison guarantees that > > semantic rules will always be executed in the same order, so using > > global variables is risky. > > if rules were not executed in the same order '$<flags>-1' construct would > not work. Uhh.. I'm pretty sure $<flags>-1 only depends on the parse tree structure, not the order in which the actual semantic rule code fragments run. > The problem is not the order. I don't think the order will change. The > problem is related to the number of items on stack. > > With import symbols, that the stack will be: > header memreserved devicetree > or > header memreserved importsyms devicetree > > Using '$-1' will no more be possible. Indeed, '$-1' from the devicetree > rule will reference 'header' in one case and 'memreserved' in the other > case. > > Without a global variable, I don't know how to reference 'header' (or flags > value) in all cases. > > Any better ideas are welcome. Ok, I'll try to look into it and see what I can come up with. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmlwO/AACgkQzQJF27ox 2Gf4zA//ecAeKaXiIbLxczvbxzNwZeSNtvGNo8SZeo5/LDe+8qNrYwaRVmJKqQHD LFbL+RLBjdkIgEajYvPSgEGqQ7pkYmy034t53HogY2H5n2oqw0Y7neiyQ0brdIry nHde0wqi1NBH1iZmImGeEG0Sul17WEBmgFLZWjsyf7uE8AiiegNh6DDH3HY5YBno cTwoMgAcjwcb1WUcez2fcRl34RKz2yahC2tPvwE4fXwbuFATbqJRTQ5eEbYKO55h vzb575T9YvH3u2NThVxVcmzvuhwOd6CHTi0oyM+gHCDzVK8ZWx89vvgNipaaCSeG /a+s7RGOzvMfJvx0fhH6xZ2vwRsOtHej++w5/EBxunSlMXHUt+1MYRnHaYRD12OS m5n2Xx1uLN6IVoTmlATxABiqCacfKGPtOVYoGd1KoiXMu1ZN+L7ELWNkbRGem4c/ NjNDLLBOguRKX0RDVeviVjYbR24dMn8/Ug6ZOzlvf4SpYCxOJTFlEao28sQUrUbi 3iol12958J5GO8Lu0egRJdq/ztzRCS2DeOyhvHDO+6mspm/OQTw1ex9YXDD8nrL9 uYKBHxq+X2an4SJEVfSQmH55Px5/S/peQxCzS31xdMi1N07Yfn6Be4z1mYJRCbdE kMDsLDDh1AHO00AKaM6SYxCvhnaD8sHvx0NRgGqQ9WM30KyoGhU= =VXLW -----END PGP SIGNATURE-----