BSD 4_4_Lite2 development
[unix-history] / usr / src / contrib / gcc-2.3.3 / README.NS32K
CommitLineData
fa988507
C
1Copyright (C) 1987 Free Software Foundation, Inc.
2Contributed by Michael Tiemann (tiemann@mcc.com)
3
4This file is part of GNU CC.
5
6GNU CC is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 1, or (at your option)
9any later version.
10
11GNU CC is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with GNU CC; see the file COPYING. If not, write to
18the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
19
20
21This file describes the implementation notes of the GNU C Compiler for
22the National Semiconductor 32032 chip (and 32000 family).
23
24The 32032 machine description and configuration file for this compiler
25is, for NS32000 family machine, primarily machine independent.
26However, since this release still depends on vendor-supplied
27assemblers and linkers, the compiler must obey the existing
28conventions of the actual machine to which this compiler is targeted.
29In this case, the actual machine which this compiler was targeted to
30is a Sequent Balance 8000, running DYNIX 2.1.
31
32The assembler for DYNIX 2.1 (and DYNIX 3.0, alas) does not cope with
33the full generality of the addressing mode REGISTER RELATIVE.
34Specifically, it generates incorrect code for operands of the
35following form:
36
37 sym(rn)
38
39Where `rn' is one of the general registers. Correct code is generated
40for operands of the form
41
42 sym(pn)
43
44where `pn' is one of the special processor registers (sb, fp, or sp).
45
46An equivalent operand can be generated by the form
47
48 sym[rn:b]
49
50although this addressing mode is about twice as slow on the 32032.
51
52The more efficient addressing mode is controlled by defining the
53constant SEQUENT_ADDRESS_BUG to 0. It is currently defined to be 1.
54
55Another bug in the assembler makes it impossible to compute with
56explicit addresses. In order to compute with a symbolic address, it
57is necessary to load that address into a register using the "addr"
58instruction. For example, it is not possible to say
59
60 cmpd _p,@_x
61
62Rather one must say
63
64 addr _x,rn
65 cmpd _p,rn
66
67
68The ns32032 chip has a number of known bugs. Any attempt to make the
69compiler unaware of these deficiencies will surely bring disaster.
70The current list of know bugs are as follows (list provided by Richard
71Stallman):
72
731) instructions with two overlapping operands in memory
74(unlikely in C code, perhaps impossible).
75
762) floating point conversion instructions with constant
77operands (these may never happen, but I'm not certain).
78
793) operands crossing a page boundary. These can be prevented
80by setting the flag in tm.h that requires strict alignment.
81
824) Scaled indexing in an insn following an insn that has a read-write
83operand in memory. This can be prevented by placing a no-op in
84between. I, Michael Tiemann, do not understand what exactly is meant
85by `read-write operand in memory'. If this is referring to the special
86TOS mode, for example "addd 5,tos" then one need not fear, since this
87will never be generated. However, is this includes "addd 5,-4(fp)"
88then there is room for disaster. The Sequent compiler does not insert
89a no-op for code involving the latter, and I have been informed that
90Sequent is aware of this list of bugs, so I must assume that it is not
91a problem.
92
935) The 32032 cannot shift by 32 bits. It shifts modulo the word size
94of the operand. Therefore, for 32-bit operations, 32-bit shifts are
95interpreted as zero bit shifts. 32-bit shifts have been removed from
96the compiler, but future hackers must be careful not to reintroduce
97them.
98
996) The ns32032 is a very slow chip; however, some instructions are
100still very much slower than one might expect. For example, it is
101almost always faster to double a quantity by adding it to itself than
102by shifting it by one, even if that quantity is deep in memory. The
103MOVM instruction has a 20-cycle setup time, after which it moves data
104at about the speed that normal moves would. It is also faster to use
105address generation instructions than shift instructions for left
106shifts less than 4. I do not claim that I generate optimal code for all
107given patterns, but where I did escape from National's "clean
108architecture", I did so because the timing specification from the data
109book says that I will win if I do. I suppose this is called the
110"performance gap".
111
112
113Signed bitfield extraction has not been implemented. It is not
114provided by the NS32032, and while it is most certainly possible to do
115better than the standard shift-left/shift-right sequence, it is also
116quite hairy. Also, since signed bitfields do not yet exist in C, this
117omission seems relatively harmless.
118
119
120Zero extractions could be better implemented if it were possible in
121GCC to provide sized zero extractions: i.e. a byte zero extraction
122would be allowed to yield a byte result. The current implementation
123of GCC manifests 68000-ist thinking, where bitfields are extracted
124into a register, and automatically sign/zero extended to fill the
125register. See comments in ns32k.md around the "extzv" insn for more
126details.
127
128
129It should be noted that while the NS32000 family was designed to
130provide odd-aligned addressing capability for multi-byte data (also
131provided by the 68020, but not by the 68000 or 68010), many machines
132do not opt to take advantage of this. For example, on the sequent,
133although there is no advantage to long-word aligning word data, shorts
134must be int-aligned in structs. This is an example of another
135machine-specific machine dependency.
136
137
138Because the ns32032 is has a coherent byte-order/bit-order
139architecture, many instructions which would be different for
14068000-style machines, fold into the same instruction for the 32032.
141The classic case is push effective address, where it does not matter
142whether one is pushing a long, word, or byte address. They all will
143push the same address.
144
145
146The macro FUNCTION_VALUE_REGNO_P is probably not sufficient, what is
147needed is FUNCTION_VALUE_P, which also takes a MODE parameter. In
148this way it will be possible to determine more exactly whether a
149register is really a function value register, or just one that happens
150to look right.