OpenCores
URL https://opencores.org/ocsvn/scarts/scarts/trunk

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-binutils/] [binutils-2.19.1/] [cgen/] [cpu/] [openrisc.opc] - Blame information for rev 6

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 6 jlechner
/* OpenRISC opcode support.  -*- C -*-
2
   Copyright (C) 2000, 2001, 2003, 2005 Free Software Foundation
3
   Based upon work by Red Hat, Inc.
4
   This file is part of CGEN.  */
5
 
6
/* This file is an addendum to or32.cpu.  Heavy use of C code isn't
7
   appropriate in .cpu files, so it resides here.  This especially applies
8
   to assembly/disassembly where parsing/printing can be quite involved.
9
   Such things aren't really part of the specification of the cpu, per se,
10
   so .cpu files provide the general framework and .opc files handle the
11
   nitty-gritty details as necessary.
12
 
13
   Each section is delimited with start and end markers.
14
 
15
   -opc.h additions use: "-- opc.h"
16
   -opc.c additions use: "-- opc.c"
17
   -asm.c additions use: "-- asm.c"
18
   -dis.c additions use: "-- dis.c"
19
   -ibd.h additions use: "-- ibd.h"  */
20
 
21
/* -- opc.h */
22
#undef  CGEN_DIS_HASH_SIZE
23
#define CGEN_DIS_HASH_SIZE 64
24
#undef  CGEN_DIS_HASH
25
#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 2)
26
 
27
extern long openrisc_sign_extend_16bit (long);
28
/* -- */
29
 
30
/* -- opc.c */
31
/* -- */
32
 
33
/* -- asm.c */
34
 
35
static const char * MISSING_CLOSING_PARENTHESIS = N_("missing `)'");
36
 
37
#define CGEN_VERBOSE_ASSEMBLER_ERRORS
38
 
39
long
40
openrisc_sign_extend_16bit (long value)
41
{
42
  return ((value & 0xffff) ^ 0x8000) - 0x8000;
43
}
44
 
45
/* Handle hi().  */
46
 
47
static const char *
48
parse_hi16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep)
49
{
50
  const char *errmsg;
51
  enum cgen_parse_operand_result result_type;
52
  unsigned long ret;
53
 
54
  if (**strp == '#')
55
    ++*strp;
56
 
57
  if (strncasecmp (*strp, "hi(", 3) == 0)
58
    {
59
      bfd_vma value;
60
 
61
      *strp += 3;
62
      errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16,
63
                                   & result_type, & value);
64
      if (**strp != ')')
65
        return MISSING_CLOSING_PARENTHESIS;
66
 
67
      ++*strp;
68
      if (errmsg == NULL
69
          && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER)
70
        value >>= 16;
71
      ret = value;
72
    }
73
  else
74
    {
75
      if (**strp == '-')
76
        {
77
          long value;
78
 
79
          errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
80
          ret = value;
81
        }
82
      else
83
        {
84
          unsigned long value;
85
 
86
          errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
87
          ret = value;
88
        }
89
    }
90
 
91
  *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
92
  return errmsg;
93
}
94
 
95
/* Handle lo().  */
96
 
97
static const char *
98
parse_lo16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep)
99
{
100
  const char *errmsg;
101
  enum cgen_parse_operand_result result_type;
102
  unsigned long ret;
103
 
104
  if (**strp == '#')
105
    ++*strp;
106
 
107
  if (strncasecmp (*strp, "lo(", 3) == 0)
108
    {
109
      bfd_vma value;
110
 
111
      *strp += 3;
112
      errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16,
113
                                   & result_type, & value);
114
      if (**strp != ')')
115
        return MISSING_CLOSING_PARENTHESIS;
116
 
117
      ++*strp;
118
      ret = value;
119
    }
120
  else
121
    {
122
      if (**strp == '-')
123
        {
124
          long value;
125
 
126
          errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value);
127
          ret = value;
128
        }
129
      else
130
        {
131
          unsigned long value;
132
 
133
          errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value);
134
          ret = value;
135
        }
136
    }
137
 
138
  *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000;
139
  return errmsg;
140
}
141
 
142
/* -- */
143
 
144
/* -- ibd.h */
145
extern long openrisc_sign_extend_16bit (long);
146
 
147
/* -- */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.