10d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt/*
20d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * Copyright © 2010 Intel Corporation
30d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt *
40d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * Permission is hereby granted, free of charge, to any person obtaining a
50d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * copy of this software and associated documentation files (the "Software"),
60d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * to deal in the Software without restriction, including without limitation
70d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * the rights to use, copy, modify, merge, publish, distribute, sublicense,
80d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * and/or sell copies of the Software, and to permit persons to whom the
90d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * Software is furnished to do so, subject to the following conditions:
100d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt *
110d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * The above copyright notice and this permission notice (including the next
120d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * paragraph) shall be included in all copies or substantial portions of the
130d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * Software.
140d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt *
150d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
160d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
170d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
180d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
190d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
200d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
210d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * DEALINGS IN THE SOFTWARE.
220d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt */
230d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt
240d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt
250d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt/**
260d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * \file ir_expression_flattening.h
270d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt *
280d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * Takes the leaves of expression trees and makes them dereferences of
290d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * assignments of the leaves to temporaries, according to a predicate.
300d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt *
310d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * This is used for automatic function inlining, where we want to take
320d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * an expression containing a call and move the call out to its own
330d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * assignment so that we can inline it at the appropriate place in the
340d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt * instruction stream.
350d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt */
360d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt
370d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholtvoid do_expression_flattening(exec_list *instructions,
380d42321ec1aaeaf60ee2dd8b1872182065ebc057Eric Anholt			      bool (*predicate)(ir_instruction *ir));
39