1 |
709 |
jeremybenn |
/* Header for constant multiple table for TILEPro.
|
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_TILEPRO_MULTIPLY_H
|
23 |
|
|
#define GCC_TILEPRO_MULTIPLY_H
|
24 |
|
|
|
25 |
|
|
/* A node of a tilepro_multiply_insn_seq, corresponding to a single
|
26 |
|
|
machine instruction such as 'add', 's1a', or an shl by a
|
27 |
|
|
constant. */
|
28 |
|
|
struct tilepro_multiply_insn_seq_entry
|
29 |
|
|
{
|
30 |
|
|
/* Which operation this node performs (e.g. an add or sub). Don't
|
31 |
|
|
use this directly, call get_opcode() table to get a
|
32 |
|
|
insn_code. */
|
33 |
|
|
unsigned char compressed_opcode;
|
34 |
|
|
|
35 |
|
|
/* The left-hand side of this expression tree.
|
36 |
|
|
If equal to 0, it refers to 'zero'.
|
37 |
|
|
If equal to 1, it refers to the original input to the multiply
|
38 |
|
|
operation.
|
39 |
|
|
Otherwise, subtract two and it is an index into the containing
|
40 |
|
|
tilepro_multiply_insn_seq's 'op' array. Since it can only point
|
41 |
|
|
to some value that has already been computed it will always point
|
42 |
|
|
to an earlier entry in the array. */
|
43 |
|
|
unsigned char lhs;
|
44 |
|
|
|
45 |
|
|
/* This is like lhs, but for the right-hand side. However, for shift
|
46 |
|
|
opcodes this is a shift count rather than an operand index. */
|
47 |
|
|
unsigned char rhs;
|
48 |
|
|
};
|
49 |
|
|
|
50 |
|
|
/* Maximum size of op array. */
|
51 |
|
|
#define tilepro_multiply_insn_seq_MAX_OPERATIONS 4
|
52 |
|
|
|
53 |
|
|
/* This defines a DAG describing how to multiply by a constant in
|
54 |
|
|
terms of one or more machine instructions. */
|
55 |
|
|
struct tilepro_multiply_insn_seq
|
56 |
|
|
{
|
57 |
|
|
/* The constant factor by which this expression tree multiplies its
|
58 |
|
|
input. */
|
59 |
|
|
int multiplier;
|
60 |
|
|
|
61 |
|
|
/* The nodes of the parse tree. These are ordered so that
|
62 |
|
|
instructions can be emitted in the same order that they appear in
|
63 |
|
|
this array. Entry entry in this array can only refer to earlier
|
64 |
|
|
entries in the array. */
|
65 |
|
|
struct tilepro_multiply_insn_seq_entry
|
66 |
|
|
op[tilepro_multiply_insn_seq_MAX_OPERATIONS];
|
67 |
|
|
|
68 |
|
|
};
|
69 |
|
|
|
70 |
|
|
/* A mapping from the compressed opcode to the corresponding enum
|
71 |
|
|
insn_code. */
|
72 |
|
|
extern const enum insn_code tilepro_multiply_insn_seq_decode_opcode[];
|
73 |
|
|
|
74 |
|
|
/* Table mapping constant int multipliers to an expression tree that
|
75 |
|
|
efficiently performs that multiplication. This is sorted by its
|
76 |
|
|
'multiplier' field so a binary search can look for matches. */
|
77 |
|
|
extern const struct tilepro_multiply_insn_seq
|
78 |
|
|
tilepro_multiply_insn_seq_table[];
|
79 |
|
|
|
80 |
|
|
/* The number of elements in multiply_insn_seq_table. */
|
81 |
|
|
extern const int tilepro_multiply_insn_seq_table_size;
|
82 |
|
|
|
83 |
|
|
#endif /* !GCC_TILEPRO_MULTIPLY_H */
|