[libre-riscv-dev] building structured CFG

Jacob Lifshay programmerjake at gmail.com
Mon Dec 31 09:54:35 GMT 2018


I finally realized that I was way over-complicating the structured
representation that I need to use for converting from SIMT-style code to
vectorized code. I'm hoping to have the structured CFG parser/builder
portion done by tomorrow.

All I really needed was to build a DAG of trees with inner nodes being
loops and leaves being basic blocks with the children sorted in a
topological order over the original CFG. This structure is the sequence in
which I need to execute basic blocks in order to properly cover all the
basic blocks without executing them multiple times by accident for each
time around the surrounding loop(s).

Since I already have the underlying CFG already, I can just put it in a
structure like:

pub enum CFGStructureNode {
    Loop { children: Vec<CFGStructureNode> },
    Node { node_index: CFGNodeIndex },
}

type CFGStructure = Vec<CFGStructureNode>;

CFGNodeIndex is the index of a basic block in the underlying CFG.
All of the Vecs are stored topologically-sorted over the underlying CFG.

Note that this means the parser won't work on OpenCL SPIR-V without
modifications since only Vulkan requires OpLoopMerge which I am using to
determine the loop tree.

Jacob


More information about the libre-riscv-dev mailing list