2 * Copyright (C) 2020 Collabora, Ltd.
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:
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
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 FROM,
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 /* The scheduler packs multiple instructions into a clause (grouped as bundle),
27 * and the packing code takes in a clause and emits it to the wire. During
28 * scheduling, we need to lay out the instructions (bundles) and constants
29 * within the clause so constraints can be resolved during scheduling instead
30 * of failing packing. These routines will help building clauses from
31 * instructions so the scheduler can focus on the high-level algorithm, and
32 * manipulating clause layouts.
35 /* Helper to see if a bundle can be inserted. We must satisfy the invariant:
37 * constant_count + bundle_count <= 13
39 * ...which is equivalent to the clause ending up with 8 or fewer quardwords.
40 * Inserting a bundle increases bundle_count by one, and if it reads a unique
41 * constant, it increases constant_count by one.
45 bi_can_insert_bundle(bi_clause
*clause
, bool constant
)
47 unsigned constant_count
= clause
->constant_count
+ (constant
? 1 : 0);
48 unsigned bundle_count
= clause
->bundle_count
+ 1;
50 return (constant_count
+ bundle_count
) <= 13;