1 |
709 |
jeremybenn |
/* Header for constant multiple table for TILE-Gx.
|
2 |
|
|
Copyright (C) 2011, 2012
|
3 |
|
|
Free Software Foundation, Inc.
|
4 |
|
|
Contributed by Walter Lee (walt@tilera.com)
|
5 |
|
|
|
6 |
|
|
This file is part of GCC.
|
7 |
|
|
|
8 |
|
|
GCC is free software; you can redistribute it and/or modify it
|
9 |
|
|
under the terms of the GNU General Public License as published
|
10 |
|
|
by the Free Software Foundation; either version 3, or (at your
|
11 |
|
|
option) any later version.
|
12 |
|
|
|
13 |
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT
|
14 |
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
15 |
|
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
16 |
|
|
License for more details.
|
17 |
|
|
|
18 |
|
|
You should have received a copy of the GNU General Public License
|
19 |
|
|
along with GCC; see the file COPYING3. If not see
|
20 |
|
|
<http://www.gnu.org/licenses/>. */
|
21 |
|
|
|
22 |
|
|
#ifndef GCC_TILEGX_MULTIPLY_H
|
23 |
|
|
#define GCC_TILEGX_MULTIPLY_H
|
24 |
|
|
|
25 |
|
|
/* A node of a tilegx_multiply_insn_seq, corresponding to a single
|
26 |
|
|
machine instruction such as 'add', 's1a', or an shl by a constant. */
|
27 |
|
|
struct tilegx_multiply_insn_seq_entry
|
28 |
|
|
{
|
29 |
|
|
/* Which operation this node performs (e.g. an add or sub).
|
30 |
|
|
Don't use this directly, call get_opcode() table to get a insn_code. */
|
31 |
|
|
unsigned char compressed_opcode;
|
32 |
|
|
|
33 |
|
|
/* The left-hand side of this expression tree.
|
34 |
|
|
If equal to 0, it refers to 'zero'.
|
35 |
|
|
If equal to 1, it refers to the original input to the multiply operation.
|
36 |
|
|
Otherwise, subtract two and it is an index into the containing
|
37 |
|
|
tilegx_multiply_insn_seq's 'op' array. Since it can only point to some
|
38 |
|
|
value that has already been computed it will always point to an
|
39 |
|
|
earlier entry in the array. */
|
40 |
|
|
unsigned char lhs;
|
41 |
|
|
|
42 |
|
|
/* This is like lhs, but for the right-hand side. However, for shift
|
43 |
|
|
opcodes this is a shift count rather than an operand index. */
|
44 |
|
|
unsigned char rhs;
|
45 |
|
|
};
|
46 |
|
|
|
47 |
|
|
/* Maximum size of op array. */
|
48 |
|
|
#define tilegx_multiply_insn_seq_MAX_OPERATIONS 4
|
49 |
|
|
|
50 |
|
|
/* This defines a DAG describing how to multiply by a constant in
|
51 |
|
|
terms of one or more machine instructions. */
|
52 |
|
|
struct tilegx_multiply_insn_seq
|
53 |
|
|
{
|
54 |
|
|
/* The constant factor by which this expression tree multiplies its input. */
|
55 |
|
|
long long multiplier;
|
56 |
|
|
|
57 |
|
|
/* The nodes of the parse tree. These are ordered so that instructions
|
58 |
|
|
can be emitted in the same order that they appear in this array.
|
59 |
|
|
Entry entry in this array can only refer to earlier entries in
|
60 |
|
|
the array. */
|
61 |
|
|
struct tilegx_multiply_insn_seq_entry
|
62 |
|
|
op[tilegx_multiply_insn_seq_MAX_OPERATIONS];
|
63 |
|
|
|
64 |
|
|
};
|
65 |
|
|
|
66 |
|
|
/* A mapping from the compressed opcode to the corresponding enum
|
67 |
|
|
insn_code. */
|
68 |
|
|
extern const enum insn_code tilegx_multiply_insn_seq_decode_opcode[];
|
69 |
|
|
|
70 |
|
|
/* Table mapping constant int multipliers to an expression
|
71 |
|
|
tree that efficiently performs that multiplication.
|
72 |
|
|
This is sorted by its 'multiplier' field so a binary search
|
73 |
|
|
can look for matches. */
|
74 |
|
|
extern const struct tilegx_multiply_insn_seq tilegx_multiply_insn_seq_table[];
|
75 |
|
|
|
76 |
|
|
/* The number of elements in multiply_insn_seq_table. */
|
77 |
|
|
extern const int tilegx_multiply_insn_seq_table_size;
|
78 |
|
|
|
79 |
|
|
#endif /* !GCC_TILEGX_MULTIPLY_H */
|