diff options
author | Michael Smith <mikesmiffy128@gmail.com> | 2022-04-10 01:42:32 +0100 |
---|---|---|
committer | Michael Smith <mikesmiffy128@gmail.com> | 2022-04-14 21:04:55 +0100 |
commit | 99e9a6765a9a358987c062ec4a251f8254581933 (patch) | |
tree | 8b545ff0e0d52fdda30e0aeb0c340c7de5d54481 /src/3p/chibicc/chibicc.h | |
parent | d823e5f524403e5c278d3c863e93bac4b1d8d2ce (diff) |
Remove some more unused chibicc bits
Diffstat (limited to 'src/3p/chibicc/chibicc.h')
-rw-r--r-- | src/3p/chibicc/chibicc.h | 227 |
1 files changed, 4 insertions, 223 deletions
diff --git a/src/3p/chibicc/chibicc.h b/src/3p/chibicc/chibicc.h index 82aad11..dd810ec 100644 --- a/src/3p/chibicc/chibicc.h +++ b/src/3p/chibicc/chibicc.h @@ -3,46 +3,31 @@ #ifndef INC_CHIBICC_H #define INC_CHIBICC_H -// note: removing defs/headers that aren't needed in tokenize.c and/or don't -// exist on Windows, in order to get our stuff working. total hack; oh well. -//#define _POSIX_C_SOURCE 200809L #include <assert.h> #include <ctype.h> #include <errno.h> -//#include <glob.h> -//#include <libgen.h> #include <stdarg.h> #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> -// stdnoreturn means we can't use our noreturn (_Noreturn void) +// mike: stdnoreturn means we can't use our noreturn (_Noreturn void) // there are no noreturns in tokenize.c anyway, and the ones in this header have // been changed to just _Noreturn to avoid any possible conflict //#include <stdnoreturn.h> #include <string.h> -//#include <strings.h> -#include <sys/stat.h> -//#include <sys/types.h> -//#include <sys/wait.h> -#include <time.h> -//#include <unistd.h> // exists on all Unixes but normally hidden behind _GNU_SOURCE on Linux. // missing entirely on Windows (implemented in 3p/openbsd/asprintf.c for compat) int vasprintf(char **str, const char *fmt, va_list ap); -#define MAX(x, y) ((x) < (y) ? (y) : (x)) -#define MIN(x, y) ((x) < (y) ? (x) : (y)) - #if !defined(__GNUC__) && !defined(__clang__) # define __attribute__(x) #endif typedef struct Type Type; -typedef struct Node Node; typedef struct Member Member; -typedef struct Relocation Relocation; +typedef struct Node Node; typedef struct Hideset Hideset; // @@ -136,192 +121,6 @@ static inline char *format(const char *fmt, ...) { error("internal error at %s:%d", __FILE__, __LINE__) // -// preprocess.c -// - -char *search_include_paths(char *filename); -void init_macros(void); -void define_macro(char *name, char *buf); -void undef_macro(char *name); -Token *preprocess(Token *tok); - -// -// parse.c -// - -// Variable or function -typedef struct Obj Obj; -struct Obj { - Obj *next; - char *name; // Variable name - Type *ty; // Type - Token *tok; // representative token - bool is_local; // local or global/function - int align; // alignment - - // Local variable - int offset; - - // Global variable or function - bool is_function; - bool is_definition; - bool is_static; - - // Global variable - bool is_tentative; - bool is_tls; - char *init_data; - Relocation *rel; - - // Function - bool is_inline; - Obj *params; - Node *body; - Obj *locals; - Obj *va_area; - Obj *alloca_bottom; - int stack_size; - - // Static inline function - bool is_live; - bool is_root; - StringArray refs; -}; - -// Global variable can be initialized either by a constant expression -// or a pointer to another global variable. This struct represents the -// latter. -typedef struct Relocation Relocation; -struct Relocation { - Relocation *next; - int offset; - char **label; - long addend; -}; - -// AST node -typedef enum { - ND_NULL_EXPR, // Do nothing - ND_ADD, // + - ND_SUB, // - - ND_MUL, // * - ND_DIV, // / - ND_NEG, // unary - - ND_MOD, // % - ND_BITAND, // & - ND_BITOR, // | - ND_BITXOR, // ^ - ND_SHL, // << - ND_SHR, // >> - ND_EQ, // == - ND_NE, // != - ND_LT, // < - ND_LE, // <= - ND_ASSIGN, // = - ND_COND, // ?: - ND_COMMA, // , - ND_MEMBER, // . (struct member access) - ND_ADDR, // unary & - ND_DEREF, // unary * - ND_NOT, // ! - ND_BITNOT, // ~ - ND_LOGAND, // && - ND_LOGOR, // || - ND_RETURN, // "return" - ND_IF, // "if" - ND_FOR, // "for" or "while" - ND_DO, // "do" - ND_SWITCH, // "switch" - ND_CASE, // "case" - ND_BLOCK, // { ... } - ND_GOTO, // "goto" - ND_GOTO_EXPR, // "goto" labels-as-values - ND_LABEL, // Labeled statement - ND_LABEL_VAL, // [GNU] Labels-as-values - ND_FUNCALL, // Function call - ND_EXPR_STMT, // Expression statement - ND_STMT_EXPR, // Statement expression - ND_VAR, // Variable - ND_VLA_PTR, // VLA designator - ND_NUM, // Integer - ND_CAST, // Type cast - ND_MEMZERO, // Zero-clear a stack variable - ND_ASM, // "asm" - ND_CAS, // Atomic compare-and-swap - ND_EXCH, // Atomic exchange -} NodeKind; - -// AST node type -struct Node { - NodeKind kind; // Node kind - Node *next; // Next node - Type *ty; // Type, e.g. int or pointer to int - Token *tok; // Representative token - - Node *lhs; // Left-hand side - Node *rhs; // Right-hand side - - // "if" or "for" statement - Node *cond; - Node *then; - Node *els; - Node *init; - Node *inc; - - // "break" and "continue" labels - char *brk_label; - char *cont_label; - - // Block or statement expression - Node *body; - - // Struct member access - Member *member; - - // Function call - Type *func_ty; - Node *args; - bool pass_by_stack; - Obj *ret_buffer; - - // Goto or labeled statement, or labels-as-values - char *label; - char *unique_label; - Node *goto_next; - - // Switch - Node *case_next; - Node *default_case; - - // Case - long begin; - long end; - - // "asm" string literal - char *asm_str; - - // Atomic compare-and-swap - Node *cas_addr; - Node *cas_old; - Node *cas_new; - - // Atomic op= operators - Obj *atomic_addr; - Node *atomic_expr; - - // Variable - Obj *var; - - // Numeric literal - int64_t val; - long double fval; -}; - -Node *new_cast(Node *expr, Type *ty); -int64_t const_expr(Token **rest, Token *tok); -Obj *parse(Token *tok); - -// // type.c // @@ -370,8 +169,8 @@ struct Type { int array_len; // Variable-length array - Node *vla_len; // # of elements - Obj *vla_size; // sizeof() value + //Node *vla_len; // # of elements + //Obj *vla_size; // sizeof() value // Struct Member *members; @@ -432,13 +231,6 @@ Type *struct_type(void); void add_type(Node *node); // -// codegen.c -// - -void codegen(Obj *prog, FILE *out); -int align_to(int n, int align); - -// // unicode.c // @@ -472,15 +264,4 @@ void hashmap_delete(HashMap *map, char *key); void hashmap_delete2(HashMap *map, char *key, int keylen); void hashmap_test(void); -// -// main.c -// - -bool file_exists(char *path); - -extern StringArray include_paths; -extern bool opt_fpic; -extern bool opt_fcommon; -extern char *base_file; - #endif |