Skip to content

Commit

Permalink
new x86 backend
Browse files Browse the repository at this point in the history
  • Loading branch information
alexander.nutz committed Aug 6, 2024
1 parent 0796bc6 commit 4b2554d
Show file tree
Hide file tree
Showing 16 changed files with 1,261 additions and 169 deletions.
4 changes: 4 additions & 0 deletions build.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,13 @@ struct CompileData target_x86_files[] = {
DIR("build"),

DIR("build/cg"),

DIR("build/cg/x86"),
SP(CT_C, "cg/x86/prep.c"),
SP(CT_C, "cg/x86/constraints.c"),

DIR("build/cg/x86_stupid"),
SP(CT_C, "cg/x86_stupid/cg.c"),
};

enum CompileResult target_x86() {
Expand Down
3 changes: 2 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ set -e
: ${CFLAGS:="-Wall -Wextra -Wno-unused -Wpedantic -Werror -std=c11"}
: ${CC:="clang"}

FILES="main.c ir/*.c common/*.c ir/opt/*.c ir/transform/*.c cg/x86/*.c"
FILES="test.c ir/*.c common/*.c ir/opt/*.c ir/transform/*.c cg/x86/*.c cg/x86_stupid/*.c"

# shellcheck disable=SC2086

Expand All @@ -22,6 +22,7 @@ else
clang build.c -o build.exe
./build.exe lib.a
./build.exe x86.a
./build.exe tests
fi

# shellcheck enable=SC2086
21 changes: 20 additions & 1 deletion cg/cg.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
#include <stddef.h>
#include <stdlib.h>

#ifndef VX_BASE_TYPES
#define VX_BASE_TYPES
typedef size_t vx_IrVar;
#endif

typedef struct vx_OpInfo_X86CG_s * vx_OpInfo_X86CG;

typedef enum {
Expand All @@ -15,7 +20,7 @@ typedef struct {
vx_OpInfoKind kind;
union {
vx_OpInfo_X86CG x86;
} value;
} value;
} vx_OpInfo;

typedef struct {
Expand Down Expand Up @@ -55,4 +60,18 @@ static void * vx_OpInfo_lookup__impl(vx_OpInfoList list, vx_OpInfoKind kind) {
// example usage: vx_OpInfo_lookup(list, X86CG)
#define vx_OpInfo_lookup(list, kind) ((vx_OpInfo_##kind *) vx_OpInfo_lookup__impl(list, VX_OPINFO_##kind))

typedef size_t vx_CgReg;
#define VX_CGREG_NONE ((vx_CgReg) 0)

typedef struct {
vx_CgReg (*allocRegFor)(struct vx_IrBlock_s *root, vx_IrVar var);
vx_CgReg (*allocArgReg)(struct vx_IrBlock_s *root, size_t id);
vx_CgReg (*allocRetReg)(struct vx_IrBlock_s *root, size_t id);
void (*freeRe)(vx_CgReg);

union {
struct vx_X86CgState * x86;
};
} vx_CgState;

#endif
4 changes: 4 additions & 0 deletions cg/x86/x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ void vx_x86cg_regconstraints(vx_IrBlock * block);
static struct vx_OpInfo_X86CG_s* vx_x86cg_make_opinfo(void) {
return (struct vx_OpInfo_X86CG_s*) fastalloc(sizeof(struct vx_OpInfo_X86CG_s));
}

struct X86CgState {

};
Loading

0 comments on commit 4b2554d

Please sign in to comment.