Statistics
| Branch: | Revision:

root / target-lm32 / lm32-decode.h @ fcda9863

History | View | Annotate | Download (3.4 kB)

1
/*
2
 *  LatticeMico32 instruction decoding macros.
3
 *
4
 *  Copyright (c) 2010 Michael Walle <michael@walle.cc>
5
 *
6
 * This library is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2 of the License, or (at your option) any later version.
10
 *
11
 * This library is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18
 */
19

    
20
/* Convenient binary macros */
21
#define HEX__(n) 0x##n##LU
22
#define B8__(x) (((x&0x0000000FLU) ? 1 : 0) \
23
                  + ((x&0x000000F0LU) ? 2 : 0) \
24
                  + ((x&0x00000F00LU) ? 4 : 0) \
25
                  + ((x&0x0000F000LU) ? 8 : 0) \
26
                  + ((x&0x000F0000LU) ? 16 : 0) \
27
                  + ((x&0x00F00000LU) ? 32 : 0) \
28
                  + ((x&0x0F000000LU) ? 64 : 0) \
29
                  + ((x&0xF0000000LU) ? 128 : 0))
30
#define B8(d) ((unsigned char)B8__(HEX__(d)))
31

    
32
/* Decode logic, value and mask.  */
33
#define DEC_ADD     {B8(00001101), B8(00011111)}
34
#define DEC_AND     {B8(00001000), B8(00011111)}
35
#define DEC_ANDHI   {B8(00011000), B8(00111111)}
36
#define DEC_B       {B8(00110000), B8(00111111)}
37
#define DEC_BI      {B8(00111000), B8(00111111)}
38
#define DEC_BE      {B8(00010001), B8(00111111)}
39
#define DEC_BG      {B8(00010010), B8(00111111)}
40
#define DEC_BGE     {B8(00010011), B8(00111111)}
41
#define DEC_BGEU    {B8(00010100), B8(00111111)}
42
#define DEC_BGU     {B8(00010101), B8(00111111)}
43
#define DEC_BNE     {B8(00010111), B8(00111111)}
44
#define DEC_CALL    {B8(00110110), B8(00111111)}
45
#define DEC_CALLI   {B8(00111110), B8(00111111)}
46
#define DEC_CMPE    {B8(00011001), B8(00011111)}
47
#define DEC_CMPG    {B8(00011010), B8(00011111)}
48
#define DEC_CMPGE   {B8(00011011), B8(00011111)}
49
#define DEC_CMPGEU  {B8(00011100), B8(00011111)}
50
#define DEC_CMPGU   {B8(00011101), B8(00011111)}
51
#define DEC_CMPNE   {B8(00011111), B8(00011111)}
52
#define DEC_DIVU    {B8(00100011), B8(00111111)}
53
#define DEC_LB      {B8(00000100), B8(00111111)}
54
#define DEC_LBU     {B8(00010000), B8(00111111)}
55
#define DEC_LH      {B8(00000111), B8(00111111)}
56
#define DEC_LHU     {B8(00001011), B8(00111111)}
57
#define DEC_LW      {B8(00001010), B8(00111111)}
58
#define DEC_MODU    {B8(00110001), B8(00111111)}
59
#define DEC_MUL     {B8(00000010), B8(00011111)}
60
#define DEC_NOR     {B8(00000001), B8(00011111)}
61
#define DEC_OR      {B8(00001110), B8(00011111)}
62
#define DEC_ORHI    {B8(00011110), B8(00111111)}
63
#define DEC_SCALL   {B8(00101011), B8(00111111)}
64
#define DEC_RCSR    {B8(00100100), B8(00111111)}
65
#define DEC_SB      {B8(00001100), B8(00111111)}
66
#define DEC_SEXTB   {B8(00101100), B8(00111111)}
67
#define DEC_SEXTH   {B8(00110111), B8(00111111)}
68
#define DEC_SH      {B8(00000011), B8(00111111)}
69
#define DEC_SL      {B8(00001111), B8(00011111)}
70
#define DEC_SR      {B8(00000101), B8(00011111)}
71
#define DEC_SRU     {B8(00000000), B8(00011111)}
72
#define DEC_SUB     {B8(00110010), B8(00111111)}
73
#define DEC_SW      {B8(00010110), B8(00111111)}
74
#define DEC_USER    {B8(00110011), B8(00111111)}
75
#define DEC_WCSR    {B8(00110100), B8(00111111)}
76
#define DEC_XNOR    {B8(00001001), B8(00011111)}
77
#define DEC_XOR     {B8(00000110), B8(00011111)}
78