← Documents Documentation/arch/arm/nwfpe/netwinder-fpe.rst GitHub 원문 ↗

Linux 6.18.37 · Architecture

NetWinder FPE Current State

NetWinder FPE의 ARM floating-point instruction grammar와 CPDT·CPRT·산술·비교·library call별 구현 상태 및 signal 제약을 정리합니다.

Source pathDocumentation/arch/arm/nwfpe/netwinder-fpe.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약과 해설

netwinder-fpe.rst:1-162

emulator는 compiler가 실제로 emit하는 load/store, conversion, compare, 기본 산술 instruction을 우선 완성했습니다. transcendental library-call instruction은 compiler가 내지 않고 libc가 처리하므로 미구현으로 남았습니다.

NWFPE instruction 처리 범위
ARM FPA instructionCPDT load/storeCPRT convert/statusdyadic / monadic arithmeticresult / SIGFPE
POW / LOG / SIN ...not implementedlibc routines

register transfer와 기본 arithmetic은 emulator가 직접 처리하고 transcendental operation은 software library 경로에 남습니다.

Implementation status
group상태특이점
LDF/STF, LFM/SFMcompletememory format 비호환 가능
FLT/FIX, status/controlcompleteRFC/WFC supervisor-only
basic arithmeticcompletefast도 동일 algorithm
URD/NRMimplementedNRM은 NOP
library callsnot implementedlibc가 처리

문서에 기록된 instruction group별 상태입니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

원문 전체 펼치기
1 =============
2 Current State
3 =============
4
5 The following describes the current state of the NetWinder's floating point
6 emulator.
7
8 In the following nomenclature is used to describe the floating point
9 instructions. It follows the conventions in the ARM manual.
10
11 ::
12
13 <S|D|E> = <single|double|extended>, no default
14 {P|M|Z} = {round to +infinity,round to -infinity,round to zero},
15 default = round to nearest
16
17 Note: items enclosed in {} are optional.
18
19 Floating Point Coprocessor Data Transfer Instructions (CPDT)
20 ------------------------------------------------------------
21
22 LDF/STF - load and store floating
23
24 <LDF|STF>{cond}<S|D|E> Fd, Rn
25 <LDF|STF>{cond}<S|D|E> Fd, [Rn, #<expression>]{!}
26 <LDF|STF>{cond}<S|D|E> Fd, [Rn], #<expression>
27
28 These instructions are fully implemented.
29
30 LFM/SFM - load and store multiple floating
31
32 Form 1 syntax:
33 <LFM|SFM>{cond}<S|D|E> Fd, <count>, [Rn]
34 <LFM|SFM>{cond}<S|D|E> Fd, <count>, [Rn, #<expression>]{!}
35 <LFM|SFM>{cond}<S|D|E> Fd, <count>, [Rn], #<expression>
36
37 Form 2 syntax:
38 <LFM|SFM>{cond}<FD,EA> Fd, <count>, [Rn]{!}
39
40 These instructions are fully implemented. They store/load three words
41 for each floating point register into the memory location given in the
42 instruction. The format in memory is unlikely to be compatible with
43 other implementations, in particular the actual hardware. Specific
44 mention of this is made in the ARM manuals.
45
46 Floating Point Coprocessor Register Transfer Instructions (CPRT)
47 ----------------------------------------------------------------
48
49 Conversions, read/write status/control register instructions
50
51 FLT{cond}<S,D,E>{P,M,Z} Fn, Rd Convert integer to floating point
52 FIX{cond}{P,M,Z} Rd, Fn Convert floating point to integer
53 WFS{cond} Rd Write floating point status register
54 RFS{cond} Rd Read floating point status register
55 WFC{cond} Rd Write floating point control register
56 RFC{cond} Rd Read floating point control register
57
58 FLT/FIX are fully implemented.
59
60 RFS/WFS are fully implemented.
61
62 RFC/WFC are fully implemented. RFC/WFC are supervisor only instructions, and
63 presently check the CPU mode, and do an invalid instruction trap if not called
64 from supervisor mode.
65
66 Compare instructions
67
68 CMF{cond} Fn, Fm Compare floating
69 CMFE{cond} Fn, Fm Compare floating with exception
70 CNF{cond} Fn, Fm Compare negated floating
71 CNFE{cond} Fn, Fm Compare negated floating with exception
72
73 These are fully implemented.
74
75 Floating Point Coprocessor Data Instructions (CPDT)
76 ---------------------------------------------------
77
78 Dyadic operations:
79
80 ADF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - add
81 SUF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - subtract
82 RSF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse subtract
83 MUF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - multiply
84 DVF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - divide
85 RDV{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse divide
86
87 These are fully implemented.
88
89 FML{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - fast multiply
90 FDV{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - fast divide
91 FRD{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - fast reverse divide
92
93 These are fully implemented as well. They use the same algorithm as the
94 non-fast versions. Hence, in this implementation their performance is
95 equivalent to the MUF/DVF/RDV instructions. This is acceptable according
96 to the ARM manual. The manual notes these are defined only for single
97 operands, on the actual FPA11 hardware they do not work for double or
98 extended precision operands. The emulator currently does not check
99 the requested permissions conditions, and performs the requested operation.
100
101 RMF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - IEEE remainder
102
103 This is fully implemented.
104
105 Monadic operations:
106
107 MVF{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - move
108 MNF{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - move negated
109
110 These are fully implemented.
111
112 ABS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - absolute value
113 SQT{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - square root
114 RND{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - round
115
116 These are fully implemented.
117
118 URD{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - unnormalized round
119 NRM{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - normalize
120
121 These are implemented. URD is implemented using the same code as the RND
122 instruction. Since URD cannot return a unnormalized number, NRM becomes
123 a NOP.
124
125 Library calls:
126
127 POW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - power
128 RPW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse power
129 POL{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - polar angle (arctan2)
130
131 LOG{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base 10
132 LGN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base e
133 EXP{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - exponent
134 SIN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - sine
135 COS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - cosine
136 TAN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - tangent
137 ASN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arcsine
138 ACS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arccosine
139 ATN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arctangent
140
141 These are not implemented. They are not currently issued by the compiler,
142 and are handled by routines in libc. These are not implemented by the FPA11
143 hardware, but are handled by the floating point support code. They should
144 be implemented in future versions.
145
146 Signalling:
147
148 Signals are implemented. However current ELF kernels produced by Rebel.com
149 have a bug in them that prevents the module from generating a SIGFPE. This
150 is caused by a failure to alias fp_current to the kernel variable
151 current_set[0] correctly.
152
153 The kernel provided with this distribution (vmlinux-nwfpe-0.93) contains
154 a fix for this problem and also incorporates the current version of the
155 emulator directly. It is possible to run with no floating point module
156 loaded with this kernel. It is provided as a demonstration of the
157 technology and for those who want to do floating point work that depends
158 on signals. It is not strictly necessary to use the module.
159
160 A module (either the one provided by Russell King, or the one in this
161 distribution) can be loaded to replace the functionality of the emulator
162 built into the kernel.
163

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Current State

1-18

NetWinder floating-point emulator의 현재 구현 상태를 설명합니다. instruction 표기법은 ARM manual convention을 따릅니다.

<S|D|E> = <single|double|extended>, no default
{P|M|Z} = {round to +infinity,round to -infinity,round to zero},
          default = round to nearest

`S`, `D`, `E`는 각각 single, double, extended precision이며 기본값이 없습니다. optional `P`, `M`, `Z`는 각각 +infinity, -infinity, zero 방향 rounding이고 지정하지 않으면 nearest로 round합니다. 중괄호 `{}` 안 항목은 선택 사항입니다.

Floating Point Coprocessor Data Transfer Instructions

19-45

`LDF`/`STF`는 floating-point 값을 load/store합니다.

<LDF|STF>{cond}<S|D|E> Fd, Rn
<LDF|STF>{cond}<S|D|E> Fd, [Rn, #<expression>]{!}
<LDF|STF>{cond}<S|D|E> Fd, [Rn], #<expression>

세 syntax 모두 완전히 구현되어 있습니다.

`LFM`/`SFM`은 여러 floating-point register를 load/store합니다.

<LFM|SFM>{cond}<S|D|E> Fd, <count>, [Rn]
<LFM|SFM>{cond}<S|D|E> Fd, <count>, [Rn, #<expression>]{!}
<LFM|SFM>{cond}<S|D|E> Fd, <count>, [Rn], #<expression>

두 번째 syntax form은 다음과 같습니다.

<LFM|SFM>{cond}<FD,EA> Fd, <count>, [Rn]{!}

`LFM`/`SFM`도 완전히 구현되어 있습니다. instruction이 지정한 memory location에 floating-point register 하나당 word 세 개를 store/load합니다. 이 memory format은 다른 구현, 특히 실제 hardware와 호환되지 않을 가능성이 크며 ARM manual도 이를 명시합니다.

Floating Point Coprocessor Register Transfer Instructions

46-74

conversion과 status/control register read/write instruction은 다음과 같습니다.

FLT{cond}<S,D,E>{P,M,Z} Fn, Rd          Convert integer to floating point
FIX{cond}{P,M,Z} Rd, Fn                 Convert floating point to integer
WFS{cond} Rd                            Write floating point status register
RFS{cond} Rd                            Read floating point status register
WFC{cond} Rd                            Write floating point control register
RFC{cond} Rd                            Read floating point control register
instruction group구현 상태·제약
`FLT` / `FIX`완전 구현
`RFS` / `WFS`완전 구현
`RFC` / `WFC`완전 구현. supervisor-only이며 CPU mode를 검사해 supervisor mode가 아니면 invalid-instruction trap 발생

floating-point compare instruction은 다음과 같습니다.

CMF{cond} Fn, Fm        Compare floating
CMFE{cond} Fn, Fm       Compare floating with exception
CNF{cond} Fn, Fm        Compare negated floating
CNFE{cond} Fn, Fm       Compare negated floating with exception

`CMF`, `CMFE`, `CNF`, `CNFE`는 모두 완전히 구현되어 있습니다.

Floating Point Coprocessor Data Instructions: dyadic

75-104

두 operand를 사용하는 기본 산술 operation은 다음과 같습니다.

ADF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - add
SUF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - subtract
RSF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse subtract
MUF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - multiply
DVF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - divide
RDV{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse divide

add, subtract, reverse subtract, multiply, divide, reverse divide가 모두 완전 구현되었습니다.

fast variant syntax는 다음과 같습니다.

FML{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - fast multiply
FDV{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - fast divide
FRD{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - fast reverse divide

`FML`, `FDV`, `FRD`도 완전히 구현되지만 non-fast version과 같은 algorithm을 쓰므로 이 구현에서 성능은 `MUF`/`DVF`/`RDV`와 같습니다. ARM manual은 이를 허용합니다. 실제 FPA11 hardware에서 fast instruction은 single operand만 정의되고 double·extended operand에는 동작하지 않지만, emulator는 현재 요청 precision 조건을 검사하지 않고 operation을 수행합니다.

IEEE remainder instruction은 다음과 같습니다.

RMF{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - IEEE remainder

`RMF`는 완전히 구현되어 있습니다.

Monadic operations

105-124

move와 negated move는 다음과 같으며 모두 완전히 구현되어 있습니다.

MVF{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - move
MNF{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - move negated

absolute value, square root, round도 완전히 구현되어 있습니다.

ABS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - absolute value
SQT{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - square root
RND{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - round

unnormalized round와 normalize instruction은 다음과 같습니다.

URD{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - unnormalized round
NRM{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - normalize

`URD`는 `RND`와 같은 code로 구현됩니다. `URD`가 unnormalized number를 반환할 수 없으므로 `NRM`은 NOP가 됩니다.

Library calls

125-145

power, logarithm, trigonometric library-call instruction은 다음과 같습니다.

POW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - power
RPW{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - reverse power
POL{cond}<S|D|E>{P,M,Z} Fd, Fn, <Fm,#value> - polar angle (arctan2)

LOG{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base 10
LGN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - logarithm to base e
EXP{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - exponent
SIN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - sine
COS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - cosine
TAN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - tangent
ASN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arcsine
ACS{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arccosine
ATN{cond}<S|D|E>{P,M,Z} Fd, <Fm,#value> - arctangent

이 instruction들은 구현되어 있지 않습니다. 현재 compiler가 emit하지 않고 libc routine이 처리합니다. FPA11 hardware에도 구현되지 않았으며 floating-point support code가 맡습니다. 향후 version에서 구현할 대상으로 기록되어 있습니다.

Signalling

146-162

signal 처리는 구현되어 있습니다. 다만 당시 Rebel.com이 만든 ELF kernel에는 `fp_current`를 kernel variable `current_set[0]`에 올바르게 alias하지 못해 module이 `SIGFPE`를 만들지 못하는 bug가 있습니다.

배포 kernel `vmlinux-nwfpe-0.93`은 이 문제를 고치고 현재 emulator를 kernel에 직접 포함합니다. 이 kernel은 floating-point module 없이도 실행할 수 있으며 signal에 의존하는 floating-point 작업을 위한 demonstration입니다. module 사용이 반드시 필요한 것은 아닙니다.

Russell King이 제공한 module이나 이 배포본의 module을 load하면 kernel에 내장된 emulator 기능을 대체할 수 있습니다.