fec --emit-asm -> wasm -> wlink -> .exe. 툴체인은 고정된 Open Watcom 그대로다. 레지스터 할당기가 없다. 임시값마다 스택 슬롯을 주고, 명령마다 피연산자를 고정 레지스터로 읽어 계산하고 다시 저장한다. 느린 코드지만 명백히 옳은 코드이고, 옳은 것이 먼저다. 나중에 할당기를 끼워도 나머지는 모른다 -- 임시값이 어디 사는지만 바뀐다. 런타임 fec/rt/start.asm 은 진입 스텁과 fe_trap 이다. trap 은 이유와 파일과 줄을 stderr 에 쓰고 3으로 끝낸다. 처음으로 Ferro 프로그램이 실행됐다: 1..10 합 -> 55 (7*6-2)/4 -> 10 루프+호출+분기 -> 1 tests/build.py 가 컴파일하고 링크하고 돌린다.
17 lines
574 B
C
17 lines
574 B
C
#ifndef FE_X86_H
|
|
#define FE_X86_H
|
|
|
|
#include "ir.h"
|
|
|
|
/* IR to i386 assembly, in the syntax Open Watcom's `wasm` accepts.
|
|
|
|
There is no register allocator. Every temporary gets a stack slot, and every
|
|
instruction loads its operands into fixed registers, computes, and stores
|
|
the result back. That is slow code and obviously correct code, and correct
|
|
comes first: a register allocator can be dropped in later without the rest
|
|
of the compiler noticing, because it only changes where a temporary lives. */
|
|
|
|
void fe_x86_emit(const FeIrModule *m, FILE *out);
|
|
|
|
#endif
|