Home | History | Annotate | Download | only in i965
      1 /*
      2  * Copyright  2012 Intel Corporation
      3  *
      4  * Permission is hereby granted, free of charge, to any person obtaining a
      5  * copy of this software and associated documentation files (the "Software"),
      6  * to deal in the Software without restriction, including without limitation
      7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
      8  * and/or sell copies of the Software, and to permit persons to whom the
      9  * Software is furnished to do so, subject to the following conditions:
     10  *
     11  * The above copyright notice and this permission notice (including the next
     12  * paragraph) shall be included in all copies or substantial portions of the
     13  * Software.
     14  *
     15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
     21  * IN THE SOFTWARE.
     22  *
     23  * Authors:
     24  *    Eric Anholt <eric (at) anholt.net>
     25  *
     26  */
     27 
     28 #include "brw_fs.h"
     29 
     30 class fs_bblock_link : public exec_node {
     31 public:
     32    fs_bblock_link(fs_bblock *block)
     33       : block(block)
     34    {
     35    }
     36 
     37    fs_bblock *block;
     38 };
     39 
     40 class fs_bblock {
     41 public:
     42    static void* operator new(size_t size, void *ctx)
     43    {
     44       void *node;
     45 
     46       node = rzalloc_size(ctx, size);
     47       assert(node != NULL);
     48 
     49       return node;
     50    }
     51 
     52    fs_bblock_link *make_list(void *mem_ctx);
     53 
     54    fs_bblock();
     55 
     56    void add_successor(void *mem_ctx, fs_bblock *successor);
     57 
     58    fs_inst *start;
     59    fs_inst *end;
     60 
     61    int start_ip;
     62    int end_ip;
     63 
     64    exec_list parents;
     65    exec_list children;
     66    int block_num;
     67 };
     68 
     69 class fs_cfg {
     70 public:
     71    static void* operator new(size_t size, void *ctx)
     72    {
     73       void *node;
     74 
     75       node = rzalloc_size(ctx, size);
     76       assert(node != NULL);
     77 
     78       return node;
     79    }
     80 
     81    fs_cfg(fs_visitor *v);
     82    ~fs_cfg();
     83    fs_bblock *new_block();
     84    void set_next_block(fs_bblock *block);
     85    void make_block_array();
     86 
     87    /** @{
     88     *
     89     * Used while generating the block list.
     90     */
     91    fs_bblock *cur;
     92    int ip;
     93    /** @} */
     94 
     95    void *mem_ctx;
     96 
     97    /** Ordered list (by ip) of basic blocks */
     98    exec_list block_list;
     99    fs_bblock **blocks;
    100    int num_blocks;
    101 };
    102