aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--README.md42
-rwxr-xr-xbootstrap.sh2
-rw-r--r--src/a_embedfilesdir.c (renamed from src/c_embedfilesdir.c)0
-rw-r--r--src/a_main.c4
-rw-r--r--src/a_targ.c4
-rw-r--r--src/antcc.h (renamed from src/a_common.h)0
-rw-r--r--src/c.c8
-rw-r--r--src/c.h4
-rw-r--r--src/c_builtin.c2
-rw-r--r--src/c_eval.c2
-rw-r--r--src/c_lex.c6
-rw-r--r--src/c_lex.h6
-rw-r--r--src/c_type.c2
-rw-r--r--src/c_type.h2
-rw-r--r--src/ir.c6
-rw-r--r--src/ir.h8
-rw-r--r--src/ir_dump.c6
-rw-r--r--src/ir_fold.c2
-rw-r--r--src/o_elf.c6
-rw-r--r--src/o_elf.h131
-rw-r--r--src/obj.c2
-rw-r--r--src/obj.h2
-rw-r--r--src/t_aarch64.h2
-rw-r--r--src/t_aarch64_aapcs.c2
-rw-r--r--src/t_aarch64_emit.c6
-rw-r--r--src/t_aarch64_isel.c2
-rw-r--r--src/t_x86-64.h2
-rw-r--r--src/t_x86-64_emit.c6
-rw-r--r--src/t_x86-64_isel.c4
-rw-r--r--src/t_x86-64_sysv.c2
-rw-r--r--src/u_endian.h2
-rw-r--r--src/u_io.c (renamed from src/io.c)4
-rw-r--r--src/u_mem.c2
-rw-r--r--tool/depgen.c10
35 files changed, 154 insertions, 142 deletions
diff --git a/.gitignore b/.gitignore
index 22ef4d1..abee9df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -16,10 +16,11 @@
!Makefile
!bootstrap.sh
-src/hostconfig.h
!/src/
!/src/*
-!/tool/
+!/tool/*.c
+!/tool/*.h
+src/hostconfig.h
!/test/
!/test/external/**
diff --git a/README.md b/README.md
index 279a69b..30b7619 100644
--- a/README.md
+++ b/README.md
@@ -78,45 +78,46 @@ Contributions are welcome as long as they aren't low-effort AI slop, send as pul
## Internals & Design
-C type representation (`type.h` & `type.c`) is shared by the frontend and
+C type representation (`c_type.h` & `c_type.c`) is shared by the frontend and
backend because the backend is responsible for ABI-specific lowering of calling
conventions.
The C frontend is structured like so:
- - Compiler driver (`main.c`), which parses command line options, inputs and
+
+ - Compiler driver (`a_main.c`), which parses command line options, inputs and
outputs and calls out to the core compiler to build individual object
files and possibly invoke an external command to link them together.
- - Tokenizer & preprocessor (`c/lex.c`): The input file is scanned on-demand,
+ - Tokenizer & preprocessor (`c_lex.c`): The input file is scanned on-demand,
initially reading characters into an internal buffer after performing
backslash-newline delition (and possibly trigraph substitution), then producing
one token at a time when the parser requests the next one. Preprocessing
(directives & macro expansion) is also done on the fly.
- - Parser & IR generation (`c/c.c`): The handwritten parser reads declarations
+ - Parser & IR generation (`c.c`): The handwritten parser reads declarations
and keeps them in a symbol table/environment. Static data is written to
buffers that correspond to the .rodata/.data sections of the final object
file, emitting relocations to the object file interface too. Function
bodies are parsed and transformed into the IR in one pass. Expressions are
parsed into expression trees before being emitted or compile-time evaluated
- (`c/eval.c`), but there is no whole-program AST. When the end of a
+ (`c_eval.c`), but there is no whole-program AST. When the end of a
function definition is reached, the backend is called to perform all of the
passes that will finally transform it into machine code written to the
.text section.
-The backend (`ir/*`) uses an IR in Static Single Assignment (SSA) form.
+The backend (`ir_*`) uses an IR in Static Single Assignment (SSA) form.
Instructions have a return type and up to two operands. Because of SSA form,
temporaries are simply referenced by the instruction that provides their
definition, so an explicit output operand is not required. The list of
-instructions is defined in `ir/op.def`. Each basic block in the control flow
+instructions is defined in `ir_op.def`. Each basic block in the control flow
graph consists of 0 or more phi functions, followed by 0 or more instructions,
terminated by a jump (unconditional/conditional branch, return, or trap).
-The builder API (`ir/builder.c`) used by the frontend performs peephole
+The builder API (`ir_builder.c`) used by the frontend performs peephole
optimizations on the fly, mainly constant folding.
-Object file interface routines are in `obj/obj.[c/h]` ELF implementation in
-`obj/elf.[c/h]`. Support for other object formats like PE and Mach-O is planned.
+Object file interface routines are in `obj.[c/h]` ELF implementation in
+`o_elf.[c/h]`. Support for other object formats like PE and Mach-O is planned.
Debug information in the form of DWARF is also planned, but it is a sizeable
undertaking.
@@ -124,32 +125,33 @@ The `-d...` compiler flag can be used to print the output of different stages
of the backend for debugging.
The backend performs the following main passes:
- - ABI lowering (`ir/abi0.c`, `x86_64/sysv.c`): implements target calling
+
+ - ABI lowering (`ir_abi0.c`, `t_x86-64_sysv.c`): implements target calling
convention details, such as lowering structures being passed/returned by
value in registers or the stack.
- - Intrinsics lowering (`ir/intrin.c`): lowers some intrinsics emitted by the
+ - Intrinsics lowering (`ir_intrin.c`): lowers some intrinsics emitted by the
frontend (currently just structcopy)
- - mem2reg (`ir/mem2reg.c`): lower stack slots into SSA temporaries. This is
+ - mem2reg (`ir_mem2reg.c`): lower stack slots into SSA temporaries. This is
an important pass because the frontend puts every C variable into a stack
slot, and this pass transforms those into temporaries and phi instructions
in SSA form instructions when possible (most of the time, unless they are
aggregates or their address is taken), which is also how clang/LLVM does
it. Can be disabled with -O0.
- With -O1+ optimizations enabled
- + inlining (`ir/inliner.c`)
- + common-subexpression elimination (`ir/cse.c`),
+ + inlining (`ir_inliner.c`)
+ + common-subexpression elimination (`ir_cse.c`),
+ general arithmetic simplifications, branch simplification
- (`ir/simpl.c`)
+ (`ir_simpl.c`)
- - Stack lowering (`ir/stack.c`): `alloca` instructions are deleted and
+ - Stack lowering (`ir_stack.c`): `alloca` instructions are deleted and
corresponding stack slots replaced with calculated stack offsets.
- - Instruction selection (`ir/isel.c`, `x86_64/isel.c`): architecture-specific
+ - Instruction selection (`x86_64/isel.c`): architecture-specific
instruction selection, addressing mode utilization, introduction of
register constraints.
- - Register allocation (`ir/regalloc.c`): performs linear scan register
+ - Register allocation (`ir_regalloc.c`): performs linear scan register
allocation. A scratch register is reserved for operations with spilled
temporaries.
- - Code emission (`x86_64/emit.c`): binary code for the target architecture is
+ - Code emission (`t_x86-64_emit.c`): binary code for the target architecture is
emitted directly (not textual assembly). Relocations are deferred to the
object file interface too.
diff --git a/bootstrap.sh b/bootstrap.sh
index 8a2cd64..b193bbd 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -12,7 +12,7 @@ test -n "$cflags" || : ${cflags:="-std=c11"}
if test -n "$V"; then
opt="$opt -v"
fi
-src=$(head -n 15 Makefile | grep -o '\([_A-Za-z0-9/]\)\+\.c')
+src=$(find src/ -name '*.c')
X() {
echo "> $@" | (test -n "$V" && cat || sed -s 's/\([^ ]\+\.c \?\)\{10\}$/.../')
$@
diff --git a/src/c_embedfilesdir.c b/src/a_embedfilesdir.c
index d1c8dd4..d1c8dd4 100644
--- a/src/c_embedfilesdir.c
+++ b/src/a_embedfilesdir.c
diff --git a/src/a_main.c b/src/a_main.c
index 9710814..303d513 100644
--- a/src/a_main.c
+++ b/src/a_main.c
@@ -1,7 +1,7 @@
-#include "common.h"
+#include "antcc.h"
#include "version.h"
#include "hostconfig.h" /* run ./configure */
-#include "obj/obj.h"
+#include "obj.h"
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
diff --git a/src/a_targ.c b/src/a_targ.c
index fdc11f8..0a14554 100644
--- a/src/a_targ.c
+++ b/src/a_targ.c
@@ -1,5 +1,5 @@
-#include "common.h"
-#include "type.h"
+#include "antcc.h"
+#include "c_type.h"
extern const struct mctarg t_x86_64_sysv, t_aarch64_aapcs;
static const struct targ {
diff --git a/src/a_common.h b/src/antcc.h
index a24aa3d..a24aa3d 100644
--- a/src/a_common.h
+++ b/src/antcc.h
diff --git a/src/c.c b/src/c.c
index 63c3f7f..80ddc74 100644
--- a/src/c.c
+++ b/src/c.c
@@ -1,8 +1,8 @@
#include "c.h"
-#include "lex.h"
-#include "../endian.h"
-#include "../ir/ir.h"
-#include "../obj/obj.h"
+#include "c_lex.h"
+#include "u_endian.h"
+#include "ir.h"
+#include "obj.h"
/** Parsing helper functions **/
#define peek(Cm,Tk) lexpeek((Cm)->lx,Tk)
diff --git a/src/c.h b/src/c.h
index 0214db5..50d09ed 100644
--- a/src/c.h
+++ b/src/c.h
@@ -1,5 +1,5 @@
-#include "../common.h"
-#include "../type.h"
+#include "antcc.h"
+#include "c_type.h"
/*************/
/* EXPR TREE */
diff --git a/src/c_builtin.c b/src/c_builtin.c
index 5c59857..ddcfa82 100644
--- a/src/c_builtin.c
+++ b/src/c_builtin.c
@@ -1,5 +1,5 @@
#include "c.h"
-#include "../ir/ir.h"
+#include "ir.h"
static bool
callcheck(const struct span *span, int nparam, const union type *param, int narg, struct expr *args)
diff --git a/src/c_eval.c b/src/c_eval.c
index 3dfbbfb..ad5cf40 100644
--- a/src/c_eval.c
+++ b/src/c_eval.c
@@ -1,5 +1,5 @@
#include "c.h"
-#include "../ir/ir.h"
+#include "ir.h"
#include <limits.h>
static int
diff --git a/src/c_lex.c b/src/c_lex.c
index c196a21..d3529c0 100644
--- a/src/c_lex.c
+++ b/src/c_lex.c
@@ -1,5 +1,5 @@
-#include "lex.h"
-#include "../version.h"
+#include "c_lex.h"
+#include "version.h"
#include <string.h>
#include <stdlib.h>
@@ -2040,7 +2040,7 @@ identkeyword(struct token *tk)
const char *alias[2];
} kwtab[] = {
#define _(kw, cstd, ...) { #kw, {TKW##kw, cstd}, __VA_ARGS__ },
-#include "keywords.def"
+#include "c_keywords.def"
#undef _
};
#ifdef __GNUC__
diff --git a/src/c_lex.h b/src/c_lex.h
index e70bc78..8797ded 100644
--- a/src/c_lex.h
+++ b/src/c_lex.h
@@ -1,5 +1,5 @@
-#include "../common.h"
-#include "../type.h"
+#include "antcc.h"
+#include "c_type.h"
static inline bool
joinspan(struct span0 *dst, struct span0 snd)
@@ -45,7 +45,7 @@ enum toktag { /* single-character tokens' tag value is the character itself */
TKSETSHR, /* >>= */
TKIDENT = 0x80,
#define _(kw, stdc, ...) TKW##kw,
-#include "keywords.def"
+#include "c_keywords.def"
#undef _
NTOKTAG,
};
diff --git a/src/c_type.c b/src/c_type.c
index e8a5b1e..59d890b 100644
--- a/src/c_type.c
+++ b/src/c_type.c
@@ -1,4 +1,4 @@
-#include "type.h"
+#include "c_type.h"
struct typedata typedata[1<<13];
internstr ttypenames[1<<10];
diff --git a/src/c_type.h b/src/c_type.h
index ad8e1b1..12f24b2 100644
--- a/src/c_type.h
+++ b/src/c_type.h
@@ -1,6 +1,6 @@
#ifndef TYPE_H_
#define TYPE_H_
-#include "common.h"
+#include "antcc.h"
enum qualifier {
QCONST = 1<<0,
diff --git a/src/ir.c b/src/ir.c
index b612143..840ba0b 100644
--- a/src/ir.c
+++ b/src/ir.c
@@ -1,5 +1,5 @@
#include "ir.h"
-#include "../obj/obj.h"
+#include "obj.h"
uchar type2cls[NTYPETAG];
uchar cls2siz[] = { [KI32] = 4, [KI64] = 8, [KF32] = 4, [KF64] = 8 };
@@ -15,14 +15,14 @@ const uchar siz2intcls[] = { [1] = KI32, [2] = KI32, [4] = KI32, [8] = KI64 };
const char *opnames[] = {
"?\??",
#define _(o,...) #o,
-#include "op.def"
+#include "ir_op.def"
#undef _
};
const uchar opnarg[] = {
0,
#define _(o,n) n,
-#include "op.def"
+#include "ir_op.def"
#undef _
};
diff --git a/src/ir.h b/src/ir.h
index ab3e474..0aa5395 100644
--- a/src/ir.h
+++ b/src/ir.h
@@ -1,5 +1,5 @@
-#include "../common.h"
-#include "../type.h"
+#include "antcc.h"
+#include "c_type.h"
enum irclass {
KXXX,
@@ -93,7 +93,7 @@ struct addr {
enum op {
Oxxx,
#define _(o,...) O##o,
-#include "op.def"
+#include "ir_op.def"
#undef _
NOPER,
};
@@ -109,7 +109,7 @@ extern const uchar opnarg[];
enum intrin {
INxxx,
#define _(b,...) IN##b,
-#include "intrin.def"
+#include "ir_intrin.def"
#undef _
};
diff --git a/src/ir_dump.c b/src/ir_dump.c
index b0ce603..1036135 100644
--- a/src/ir_dump.c
+++ b/src/ir_dump.c
@@ -1,6 +1,6 @@
#include "ir.h"
-#include "../obj/obj.h"
-#include "../endian.h"
+#include "obj.h"
+#include "u_endian.h"
static int nextdat;
@@ -91,7 +91,7 @@ prityp(union irtype typ)
static const char *intrinname[] = {
"?\??",
#define _(b,...) #b,
-#include "intrin.def"
+#include "ir_intrin.def"
#undef _
};
diff --git a/src/ir_fold.c b/src/ir_fold.c
index 4c9861e..a7b5c6e 100644
--- a/src/ir_fold.c
+++ b/src/ir_fold.c
@@ -1,5 +1,5 @@
#include "ir.h"
-#include "../endian.h"
+#include "u_endian.h"
#include <limits.h>
#ifdef __clang__
diff --git a/src/o_elf.c b/src/o_elf.c
index 5044e56..f652657 100644
--- a/src/o_elf.c
+++ b/src/o_elf.c
@@ -1,7 +1,7 @@
-#include "elf.h"
+#include "o_elf.h"
#include "obj.h"
-#include "../ir/ir.h" /* mctarg */
-#include "../endian.h"
+#include "ir.h" /* mctarg */
+#include "u_endian.h"
#include <unistd.h>
#include <stdlib.h> /* qsort */
diff --git a/src/o_elf.h b/src/o_elf.h
index c96ae8b..c63a2be 100644
--- a/src/o_elf.h
+++ b/src/o_elf.h
@@ -1,4 +1,9 @@
-#include "../common.h"
+typedef unsigned char u8int;
+typedef unsigned short u16int;
+typedef unsigned int u32int;
+typedef signed int s32int;
+typedef signed long long s64int;
+typedef unsigned long long u64int;
#define ELFMAG "\177ELF"
enum {
@@ -27,55 +32,55 @@ enum {
EM_ARM64 = 0xB7,
};
-#define ELF_HDRIDENT \
- union { \
- uchar ident[16]; \
- struct { \
- uchar i_mag[4], \
- i_class, \
- i_data, \
- i_version, \
- i_osabi, \
- i_abiversion, \
- i_pad[7]; \
- }; \
+#define ELF_HDRIDENT \
+ union { \
+ char ident[16]; \
+ struct { \
+ u8int i_mag[4], \
+ i_class, \
+ i_data, \
+ i_version, \
+ i_osabi, \
+ i_abiversion, \
+ i_pad[7]; \
+ }; \
}
struct elf64hdr {
ELF_HDRIDENT;
- ushort type,
+ u16int type,
machine;
- uint version;
- uvlong entry,
+ u32int version;
+ u64int entry,
phoff,
shoff;
- uint flags;
- ushort ehsize,
+ u32int flags;
+ u16int ehsize,
phentsize,
phnum,
shentsize,
shnum,
shstrndx;
};
-static_assert(sizeof(struct elf64hdr) == 64);
+_Static_assert(sizeof(struct elf64hdr) == 64, "");
struct elf32hdr {
ELF_HDRIDENT;
- ushort type,
+ u16int type,
machine;
- uint version;
- uint entry,
+ u32int version;
+ u32int entry,
phoff,
shoff;
- uint flags;
- ushort ehsize,
+ u32int flags;
+ u16int ehsize,
phentsize,
phnum,
shentsize,
shnum,
shstrndx;
};
-static_assert(sizeof(struct elf32hdr) == 52);
+_Static_assert(sizeof(struct elf32hdr) == 52, "");
enum {
SHT_NULL = 0x0,
@@ -111,32 +116,32 @@ enum {
};
struct elf64shdr {
- uint name,
+ u32int name,
type;
- uvlong flags,
+ u64int flags,
addr,
offset,
size;
- uint link,
+ u32int link,
info;
- uvlong addralign,
+ u64int addralign,
entsize;
};
-static_assert(sizeof(struct elf64shdr) == 64);
+_Static_assert(sizeof(struct elf64shdr) == 64, "");
struct elf32shdr {
- uint name,
- type,
- flags,
- addr,
- offset,
- size,
- link,
- info,
- addralign,
- entsize;
-};
-static_assert(sizeof(struct elf32shdr) == 40);
+ u32int name,
+ type,
+ flags,
+ addr,
+ offset,
+ size,
+ link,
+ info,
+ addralign,
+ entsize;
+};
+_Static_assert(sizeof(struct elf32shdr) == 40, "");
enum {
STB_LOCAL,
@@ -160,47 +165,47 @@ enum {
#define ELF_S_INFO(b,t) ((b) << 4 | (t))
struct elf64sym {
- uint name;
- uchar info,
+ u32int name;
+ u8int info,
other;
- ushort shndx;
- uvlong value,
+ u16int shndx;
+ u64int value,
size;
};
-static_assert(sizeof(struct elf64sym) == 24);
+_Static_assert(sizeof(struct elf64sym) == 24, "");
struct elf32sym {
- uint name,
+ u32int name,
value,
size;
- uchar info,
+ u8int info,
other;
- ushort shndx;
+ u16int shndx;
};
-static_assert(sizeof(struct elf32sym) == 16);
+_Static_assert(sizeof(struct elf32sym) == 16, "");
-#define ELF64_R_INFO(s,t) ((uvlong) (s) << 32 | (uint)(t))
+#define ELF64_R_INFO(s,t) ((u64int) (s) << 32 | (u32int)(t))
struct elf64rel {
- uvlong offset, info;
+ u64int offset, info;
};
-static_assert(sizeof(struct elf64rel) == 16);
+_Static_assert(sizeof(struct elf64rel) == 16, "");
-#define ELF32_R_INFO(s,t) ((s) << 8 | (uchar)(t))
+#define ELF32_R_INFO(s,t) ((s) << 8 | (u8int)(t))
struct elf32rel {
- uint offset, info;
+ u32int offset, info;
};
-static_assert(sizeof(struct elf32rel) == 8);
+_Static_assert(sizeof(struct elf32rel) == 8, "");
struct elf64rela {
- uvlong offset, info;
- vlong addend;
+ u64int offset, info;
+ s64int addend;
};
-static_assert(sizeof(struct elf64rela) == 24);
+_Static_assert(sizeof(struct elf64rela) == 24, "");
struct elf32rela {
- uint offset, info;
- int addend;
+ u32int offset, info;
+ s32int addend;
};
-static_assert(sizeof(struct elf32rela) == 12);
+_Static_assert(sizeof(struct elf32rela) == 12, "");
/* vim:set ts=3 sw=3 expandtab: */
diff --git a/src/obj.c b/src/obj.c
index 12f0db7..fc0a711 100644
--- a/src/obj.c
+++ b/src/obj.c
@@ -1,5 +1,5 @@
#include "obj.h"
-#include "../ir/ir.h"
+#include "ir.h"
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
diff --git a/src/obj.h b/src/obj.h
index 1982033..b421b3f 100644
--- a/src/obj.h
+++ b/src/obj.h
@@ -1,4 +1,4 @@
-#include "../common.h"
+#include "antcc.h"
extern struct objfile {
const char *infile, *outfile;
diff --git a/src/t_aarch64.h b/src/t_aarch64.h
index 828909e..ad017c1 100644
--- a/src/t_aarch64.h
+++ b/src/t_aarch64.h
@@ -1,4 +1,4 @@
-#include "../ir/ir.h"
+#include "ir.h"
enum reg {
R0 = 0,
diff --git a/src/t_aarch64_aapcs.c b/src/t_aarch64_aapcs.c
index fc08da1..8b90ff2 100644
--- a/src/t_aarch64_aapcs.c
+++ b/src/t_aarch64_aapcs.c
@@ -1,4 +1,4 @@
-#include "all.h"
+#include "t_aarch64.h"
static int
abiarg(short r[2], uchar cls[2], uchar *r2off, int *ni, int *nf, int *ns, union irtype typ)
diff --git a/src/t_aarch64_emit.c b/src/t_aarch64_emit.c
index 9fdcd83..ac7004b 100644
--- a/src/t_aarch64_emit.c
+++ b/src/t_aarch64_emit.c
@@ -1,6 +1,6 @@
-#include "all.h"
-#include "../obj/obj.h"
-#include "../endian.h"
+#include "t_aarch64.h"
+#include "obj.h"
+#include "u_endian.h"
/* References:
* ARM ARM https://developer.arm.com/documentation/ddi0628/aa/?lang=en
diff --git a/src/t_aarch64_isel.c b/src/t_aarch64_isel.c
index 398ea28..7e5057c 100644
--- a/src/t_aarch64_isel.c
+++ b/src/t_aarch64_isel.c
@@ -1,4 +1,4 @@
-#include "all.h"
+#include "t_aarch64.h"
#define isimm32(r) (iscon(r) && concls(r) == KI32)
diff --git a/src/t_x86-64.h b/src/t_x86-64.h
index c0c38ff..91021ed 100644
--- a/src/t_x86-64.h
+++ b/src/t_x86-64.h
@@ -1,4 +1,4 @@
-#include "../ir/ir.h"
+#include "ir.h"
#define LIST_REGS(_) \
_(RAX) _(RCX) _(RDX) _(RBX) _(RSP) _(RBP) _(RSI) _(RDI) \
diff --git a/src/t_x86-64_emit.c b/src/t_x86-64_emit.c
index d3a466b..37a3f9c 100644
--- a/src/t_x86-64_emit.c
+++ b/src/t_x86-64_emit.c
@@ -1,6 +1,6 @@
-#include "all.h"
-#include "../obj/obj.h"
-#include "../endian.h"
+#include "t_x86-64.h"
+#include "obj.h"
+#include "u_endian.h"
/** Instruction operands **
*
diff --git a/src/t_x86-64_isel.c b/src/t_x86-64_isel.c
index 4b4a099..a2c41be 100644
--- a/src/t_x86-64_isel.c
+++ b/src/t_x86-64_isel.c
@@ -1,5 +1,5 @@
-#include "all.h"
-#include "../endian.h"
+#include "t_x86-64.h"
+#include "u_endian.h"
enum flag {
ZF = 1 << 0,
diff --git a/src/t_x86-64_sysv.c b/src/t_x86-64_sysv.c
index 317f40f..b0cf204 100644
--- a/src/t_x86-64_sysv.c
+++ b/src/t_x86-64_sysv.c
@@ -1,4 +1,4 @@
-#include "all.h"
+#include "t_x86-64.h"
static int classify(uchar cls[2], const struct typedata *td, uint off);
diff --git a/src/u_endian.h b/src/u_endian.h
index 34b7721..bf4b008 100644
--- a/src/u_endian.h
+++ b/src/u_endian.h
@@ -1,7 +1,7 @@
#ifndef ENDIAN_H_
#define ENDIAN_H_
-#include "common.h"
+#include "antcc.h"
extern bool targ_bigendian;
/*** Macros and functions for endian specific memory access ***/
diff --git a/src/io.c b/src/u_io.c
index d33afb1..ac5bfdb 100644
--- a/src/io.c
+++ b/src/u_io.c
@@ -1,4 +1,4 @@
-#include "c/lex.h"
+#include "c_lex.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -600,7 +600,7 @@ vbfmt(struct wbuf *out, const char *fmt, va_list ap)
if (tok->t >= TKWBEGIN_ && tok->t <= TKWEND_) {
static const char *tab[] = {
#define _(kw, c, ...) #kw,
- #include "c/keywords.def"
+ #include "c_keywords.def"
#undef _
};
tok->s = tab[tok->t - TKWBEGIN_];
diff --git a/src/u_mem.c b/src/u_mem.c
index 9ee8864..9495a5f 100644
--- a/src/u_mem.c
+++ b/src/u_mem.c
@@ -1,4 +1,4 @@
-#include "common.h"
+#include "antcc.h"
#include <stdlib.h>
#include <errno.h>
#include <stdint.h>
diff --git a/tool/depgen.c b/tool/depgen.c
index 0291859..2e880d1 100644
--- a/tool/depgen.c
+++ b/tool/depgen.c
@@ -95,18 +95,22 @@ dofile(const char *f)
files[nfiles++] = f;
FILE *fp = fopen(f, "r");
if (!fp) {
+ fprintf(stderr, "depgen ERR: ");
perror(f);
return 1;
}
char line[MAXLINE], hdr[MAXLINE];
- while (fgets(line, sizeof line, fp)) {
+ for (int ln = 1; fgets(line, sizeof line, fp); ++ln) {
if (sscanf(line, " # include \"%[^\"]\"", hdr) == 1) {
const char *abspath = catpath(dirname(f), hdr);
for (int i = 0; files[i] && i < MAXFILES; ++i) {
if (!strcmp(files[i], abspath)) goto Skip;
}
fprintf(out, " %s", abspath);
- ret |= dofile(abspath);
+ if (dofile(abspath) != 0) {
+ fprintf(stderr, " #included from %s:%d\n", f, ln);
+ ret = 1;
+ }
}
Skip:;
}
@@ -118,7 +122,7 @@ dofile(const char *f)
int
main(int argc, char **argv)
{
-#define DIE(...) return fprintf(stderr, "? "__VA_ARGS__), fputc('\n', stderr), 1
+#define DIE(...) return fprintf(stderr, "depgen ERR: "__VA_ARGS__), fputc('\n', stderr), 1
const char *src = NULL, *targ = NULL, *mf = NULL;
int mp = 0;
for (int i = 1; i < argc; ++i) {