2 * Copyright © 2011 Intel Corporation
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
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25 #include "../glsl/ir_print_visitor.h"
32 assign(int *reg_hw_locations
, reg
*reg
)
34 if (reg
->file
== GRF
) {
35 reg
->reg
= reg_hw_locations
[reg
->reg
];
40 vec4_visitor::reg_allocate_trivial()
43 int hw_reg_mapping
[this->virtual_grf_count
];
47 /* Note that compressed instructions require alignment to 2 registers. */
48 hw_reg_mapping
[0] = this->first_non_payload_grf
;
49 next
= hw_reg_mapping
[0] + this->virtual_grf_sizes
[0];
50 for (i
= 1; i
< this->virtual_grf_count
; i
++) {
51 hw_reg_mapping
[i
] = next
;
52 next
+= this->virtual_grf_sizes
[i
];
54 prog_data
->total_grf
= next
;
56 foreach_iter(exec_list_iterator
, iter
, this->instructions
) {
57 vec4_instruction
*inst
= (vec4_instruction
*)iter
.get();
59 assign(hw_reg_mapping
, &inst
->dst
);
60 assign(hw_reg_mapping
, &inst
->src
[0]);
61 assign(hw_reg_mapping
, &inst
->src
[1]);
62 assign(hw_reg_mapping
, &inst
->src
[2]);
65 if (last_grf
>= BRW_MAX_GRF
) {
66 fail("Ran out of regs on trivial allocator (%d/%d)\n",
67 last_grf
, BRW_MAX_GRF
);
72 vec4_visitor::reg_allocate()
74 reg_allocate_trivial();