diff options
author | Tom Harley | 2019-12-23 01:32:39 +0000 |
---|---|---|
committer | Tom Harley | 2019-12-23 01:32:39 +0000 |
commit | 7bc67b95161a34f8eca635d4000d9602508a9243 (patch) | |
tree | 585b3778dc1967832390e5829e4b3909b4184a2c | |
parent | Add basics for interpreter; add CLI options (diff) | |
download | sinter-7bc67b95161a34f8eca635d4000d9602508a9243.tar.gz sinter-7bc67b95161a34f8eca635d4000d9602508a9243.zip |
checkpoint
45 files changed, 7955 insertions, 884 deletions
@@ -1,12 +1,10 @@ *.o *.bc -*.ll lex.c parse.c parse.h -basic -simple +sinter *.sw* @@ -4,31 +4,41 @@ YACC = bison LEX = flex DEBUG = -ggdb3 -O0 -DGC_DEBUG -RELEASE = -O3 -DNDEBUG +RELEASE = -O2 -DNDEBUG CFLAGS = --std=c99 -Wpedantic -Wall -Wextra -Werror $(DEBUG) LFLAGS = -D_POSIX_C_SOURCE=200809L LLVM_MODULES = core executionengine mcjit interpreter analysis native bitwriter -CFLAGS += $(shell llvm-config --cflags) +CFLAGS += $(shell llvm-config --cflags) -I$(HOME)/usr/include CXXFLAGS += $(shell llvm-config --cppflags) -LDFLAGS += $(shell llvm-config --ldflags) +LDFLAGS += $(shell llvm-config --ldflags) -L$(HOME)/usr/lib LDLIBS += $(shell llvm-config --libs $(LLVM_MODULES) --system-libs) -lgc -.PHONY: default all clean +.PHONY: default all clean test + default: all -all: basic -basic.o: basic.h parse.h debug.h error.h scope.h -parse.o: basic.h -lex.o: basic.h parse.h -scope.o: scope.h error.h +all: sinter common.o + +sinter.o: sinter.h parse.h debug.h error.h scope.h llvm_codegen.h \ + graphviz_codegen.h +llvm_codegen.o: llvm_codegen.h sinter.h scope.h debug.h parse.h error.h +sinter_codegen.o: sinter_codegen.h parse.h +graphviz_codegen.o: graphviz_codegen.h parse.h error.h +parse.o: sinter.h +lex.o: sinter.h parse.h +scope.o: scope.h error.h debug.h +common.o: debug.h -basic: basic.o parse.o lex.o scope.o +sinter: sinter.o parse.o lex.o scope.o llvm_codegen.o sinter_codegen.o \ + graphviz_codegen.o $(LINK.cc) $(OUTPUT_OPTION) $^ $(LDLIBS) -# explicit rules for parse and lex prevent -Weverything being passed to them +test: all + $(MAKE) -C examples test + parse.o: parse.c $(CC) -c --std=c99 $(OUTPUT_OPTION) $< @@ -41,29 +51,5 @@ lex.o: lex.c %.c: %.y $(YACC) -o $@ $< -# test stuff (warning: influenced by compiler flags declared above!) -# TODO should probably rearrange the system so tests don't use the same build -# configs as the compiler - -simple: simple.o common.o - -%.o: %.c - $(COMPILE.c) $(OUTPUT_OPTION) $< - -%.o: %.ll - clang -c $(OUTPUT_OPTION) $< - -%.o: %.bc - clang -c $(OUTPUT_OPTION) $< - -%.ll: %.int basic - ./basic -clo $@ $< - -%.bc: %.int basic - ./basic -cbo $@ $< - -%.ll: %.c - clang -S -emit-llvm $(OUTPUT_OPTION) $< - clean: - $(RM) basic simple y.tab.* *.ll *.o lex.c parse.c parse.h + $(RM) sinter *.tab.* *.o lex.c parse.c parse.h diff --git a/basic.c b/basic.c deleted file mode 100644 index e8f1341..0000000 --- a/basic.c +++ /dev/null @@ -1,775 +0,0 @@ -#include <stdlib.h> -#include <stdio.h> -#include <assert.h> -#include <string.h> -#include <unistd.h> - -#include <llvm-c/Core.h> -#include <llvm-c/ExecutionEngine.h> -#include <llvm-c/Target.h> -#include <llvm-c/Analysis.h> -#include <llvm-c/BitWriter.h> - -#include "basic.h" -#include "parse.h" -#include "debug.h" -#include "error.h" -#include "scope.h" - -typedef unsigned int uint; -typedef void *(*main_func_t)(void); - -enum mode_t { - INTERPRET, - COMPILE -}; - -enum format_t { - BC, - LL -}; - -static LLVMModuleRef module; -static LLVMValueRef function; -static LLVMBuilderRef builder; - -static LLVMTypeRef gc_alloc_t; -static LLVMValueRef gc_alloc_p; - -static LLVMTypeRef print_int_t; -static LLVMValueRef print_int_p; - -static LLVMTypeRef print_str_t; -static LLVMValueRef print_str_p; - -static LLVMTypeRef llvm_int_t; -static LLVMTypeRef llvm_str_t; -static LLVMTypeRef boxed_t; - -static scope sc; - -static char *output_fn; -static enum mode_t mode; -static enum format_t format; - -extern FILE *yyin; -int yyparse(void); - -sexpr *new_sexpr(int type, contents val); - -void _fprint_sexpr(FILE *fd, sexpr *c); - -LLVMValueRef box_val(LLVMBuilderRef b, LLVMValueRef val, LLVMTypeRef type); -LLVMValueRef unbox_val(LLVMBuilderRef b, LLVMValueRef box, LLVMTypeRef type); -LLVMTypeRef make_function_type(uint param_c, LLVMBool arg); - -LLVMValueRef codegen_int(sexpr* s); -LLVMValueRef codegen_id(char *id); -LLVMValueRef codegen_print_int(LLVMValueRef ref); -LLVMValueRef codegen_definition(sexpr *se); -LLVMValueRef codegen_type_definition(sexpr *se); -LLVMValueRef codegen_invocation(sexpr *se); -LLVMValueRef codegen_conditional(sexpr *se); -LLVMValueRef codegen_branch(sexpr *se); -LLVMValueRef codegen_from_scope(char *func_id, LLVMValueRef *args, uint arg_c); -LLVMValueRef codegen_inbuilt_functions(sexpr *se, uint arg_c, - LLVMValueRef *args_v); -LLVMValueRef _codegen(sexpr *sexpr); - -uint get_args_from_list(sexpr *se, LLVMValueRef *args); -void get_param_info(sexpr *param_def, char **id, LLVMTypeRef *type); -uint make_func_params(sexpr *params, char **ids, LLVMTypeRef *types); - -void write_bitcode(LLVMModuleRef mod, char *fn); -void write_module(LLVMModuleRef mod, char *fn); - -void prologue(void); -void epilogue(void); - -sexpr *new_sexpr(int type, contents val) { - /* FIXME: unchecked memory allocation! */ - sexpr *ret = malloc(sizeof (*ret)); - ret->type = type; - ret->contents = val; - return ret; -} - -sexpr *new_int(int num) { - contents c; - c.i = num; - return new_sexpr(INT, c); -} - -sexpr *new_str(char *str) { - contents c; - c.s = str; - return new_sexpr(STRING, c); -} - -sexpr *new_float(double num) { - contents c; - c.f = num; - return new_sexpr(FLOAT, c); -} - -sexpr *new_id(char *id) { - contents c; - c.s = id; - return new_sexpr(ID, c); -} - -sexpr *new_node(sexpr *l, sexpr *r) { - contents c; - c.n.l = l; - c.n.r = r; - return new_sexpr(BRANCH, c); -} - -void _fprint_sexpr(FILE *fd, sexpr *c) { - if (!c) { - fprintf(fd, "NIL"); - } else { - switch (c->type) { - case INT: - fprintf(fd, "INT %i", c->contents.i); - break; - case FLOAT: - fprintf(fd, "FLOAT %f", c->contents.f); - break; - case STRING: - fprintf(fd, "STRING %s", c->contents.s); - break; - case ID: - fprintf(fd, "ID %s", c->contents.s); - break; - case BRANCH: - fprintf(fd, "("); - _fprint_sexpr(fd, c->contents.n.l); - fprintf(fd, ";"); - _fprint_sexpr(fd, c->contents.n.r); - fprintf(fd, ")"); - break; - case NIL: - default: - fprintf(fd, "ERROR"); - } - } -} - -void fprint_sexpr(FILE *fd, sexpr *c) { - _fprint_sexpr(fd, c); - fprintf(fd, "\n"); -} - -void print_sexpr(sexpr *se) { - fprint_sexpr(stdin, se); -} - -LLVMValueRef box_val(LLVMBuilderRef b, LLVMValueRef val, LLVMTypeRef type) { - /* FIXME: memory leak */ - /* LLVMValueRef box = LLVMBuildMalloc(b, type, "box"); */ - LLVMValueRef size = LLVMSizeOf(type); - LLVMValueRef size_cast = LLVMConstIntCast(size, llvm_int_t, 0); - LLVMTypeRef ptr_type = LLVMPointerType(type, 0); - - LLVMValueRef box = - LLVMBuildCall2(b, gc_alloc_t, gc_alloc_p, &size_cast, 1, "boxed"); - LLVMValueRef box_cast = LLVMBuildPointerCast(b, box, ptr_type, "box_cast"); - LLVMBuildStore(b, val, box_cast); - - return box; -} - -LLVMValueRef unbox_val(LLVMBuilderRef b, LLVMValueRef box, LLVMTypeRef type) { - LLVMTypeRef ptr_type = LLVMPointerType(type, 0); - LLVMValueRef uncast = LLVMBuildPointerCast(b, box, ptr_type, "uncast"); - LLVMValueRef val = LLVMBuildLoad2(b, type, uncast, "unboxed"); - return val; -} - -LLVMValueRef codegen_print_int(LLVMValueRef ref) { - LLVMValueRef args[] = { ref }; - LLVMValueRef ret = - LLVMBuildCall2(builder, print_int_t, print_int_p, args, 1, ""); - return ret; -} - -LLVMValueRef codegen_int(sexpr *sexpr) { - LLVMValueRef val = - LLVMConstInt(llvm_int_t, (unsigned) sexpr->contents.i, 0); - LLVMValueRef box = box_val(builder, val, llvm_int_t); - return box; -} - -LLVMValueRef codegen_id(char *id) { - scope_entry *entry = scope_find(sc, id); - if (!entry) return 0; - - return entry->value; -} - -LLVMTypeRef make_function_type(unsigned param_c, LLVMBool vararg) { - - /* FIXME: memory leak */ - LLVMTypeRef *boxed_params = malloc((sizeof (LLVMTypeRef)) * param_c); - for (uint i = 0; i < param_c; i++) { - boxed_params[i] = boxed_t; - } - - return LLVMFunctionType(boxed_t, boxed_params, param_c, vararg); -} - -uint get_args_from_list(sexpr *se, LLVMValueRef *args) { - debug("getting args from list @%p\n", (void *) se); - if (!se) return 0; - assert(se->type == BRANCH); - - *args = _codegen(se->contents.n.l); - return 1 + get_args_from_list(se->contents.n.r, args + 1); -} - -void get_param_info(sexpr *param_def, char **id, LLVMTypeRef *type) { - assert(param_def); - assert(param_def->type == BRANCH); - - sexpr *var_type_node = param_def->contents.n.l; - sexpr *var_name_node = param_def->contents.n.r; - - assert(var_type_node); - assert(var_type_node->type == ID); - assert(var_name_node); - assert(var_name_node->type == ID); - - char *var_type_str = var_type_node->contents.s; - assert(var_type_str); - - *id = var_name_node->contents.s; - - if (!strcmp(var_type_str, "INT")) { - *type = llvm_int_t; - } else if (!strcmp(var_type_str, "STR")) { - *type = llvm_str_t; - } else { - error(UNKNOWN_ID, "Unknown parameter type %s", var_type_str); - } -} - -uint make_func_params(sexpr *params, char **ids, LLVMTypeRef *types) { - if (!params) return 0; - - assert(params->type == BRANCH); - - sexpr *l = params->contents.n.l; - sexpr *r = params->contents.n.r; - - assert(l); - assert(l->type == BRANCH); - - get_param_info(l, ids, types); - - return 1 + make_func_params(r, ids + 1, types + 1); -} - -LLVMValueRef codegen_type_definition(sexpr *se) { - assert(se); - assert(se->type == BRANCH); - - sexpr *title = se->contents.n.l; - sexpr *info = se->contents.n.r; - - assert(title); - assert(info); - - /* - * TODO - * Decide how to do struct declarations. - * Would be nice to allow named and unnamed struct properties. - * - * What should accessing a struct's preoperties look like? - * - * Should it look like Haskell's property accessing? If it did, the struct - * type would also need to be mentioned, kinda like: - * `<struct_name> <property_name> <value>` - * Would require doing a special thing to get the property index from its - * name. - * - * Similar option is something like: - * `<struct_name>.<property_name> <value>` - * Where a function is defined for each struct-property combo. - * Think I'll go with this option for now. - */ - - /* FIXME: magic sizes */ - char *prop_ids[50]; - LLVMTypeRef prop_t[50]; - uint prop_c = make_func_params(info->contents.n.l, prop_ids, prop_t); - - char *struct_id = title->contents.s; - - debug("building struct %s\n", struct_id); - - /* last parameter determines if struct is packed */ - LLVMTypeRef struct_t = LLVMStructType(prop_t, prop_c, 0); - - /* - * TODO - * I'm not sure what the second parameter of LLVMPointerType (unsigned - * AddressSpace) is used for: - * https://llvm.org/doxygen/group__LLVMCCoreTypeSequential.html#ga299fe6147083678d0494b1b875f542fa - * I'm guessing it's for restricting the address space the pointer can - * point to, which would be a cool property to expose to front-end - * languages. - */ - LLVMTypeRef struct_ptr_t = LLVMPointerType(struct_t, 0); - - /* - * Create a temporary builder for building some extra functions so that the - * main builder doesn't lose its place. Disposed of at end of scope. - */ - LLVMBuilderRef util_b = LLVMCreateBuilder(); - - /* - * Make a function for constructing an instance of this struct type. Takes - * each of the struct's properties as an individual argument. - */ - LLVMTypeRef ctor_t = make_function_type(prop_c, 0); - LLVMValueRef ctor_p = LLVMAddFunction(module, struct_id, ctor_t); - LLVMBasicBlockRef ctor_b = LLVMAppendBasicBlock(ctor_p, "entry"); - LLVMPositionBuilderAtEnd(util_b, ctor_b); - /* FIXME: memory leak */ - LLVMValueRef src = LLVMBuildMalloc(util_b, struct_t, "src"); - for (uint i = 0; i < prop_c; i++) { - LLVMValueRef prop_pos = LLVMBuildStructGEP(util_b, src, i, "pos"); - LLVMValueRef param = LLVMGetParam(ctor_p, i); - LLVMValueRef val = unbox_val(util_b, param, prop_t[i]); - LLVMBuildStore(util_b, val, prop_pos); - } - LLVMValueRef cast = LLVMBuildPointerCast(util_b, src, boxed_t, "cast"); - LLVMBuildRet(util_b, cast); - scope_add_entry(sc, struct_id, ctor_p, ctor_t); - - /* - * Make functions to retreive each property of the struct. - */ - /* FIXME: magic size */ - char prop_func_id[50]; - for (uint i = 0; i < prop_c; i++) { - /* TODO: maybe choose a different separator character? */ - snprintf(prop_func_id, 50, "%s.%s", struct_id, prop_ids[i]); - - LLVMTypeRef prop_func_t = make_function_type(1, 0); - LLVMValueRef prop_func_p = - LLVMAddFunction(module, prop_func_id, prop_func_t); - LLVMBasicBlockRef prop_func_b = - LLVMAppendBasicBlock(prop_func_p, "entry"); - LLVMPositionBuilderAtEnd(util_b, prop_func_b); - LLVMValueRef param = LLVMGetParam(prop_func_p, 0); - LLVMValueRef uncast = - LLVMBuildPointerCast(util_b, param, struct_ptr_t, "uncast"); - LLVMValueRef ptr = - LLVMBuildStructGEP2(util_b, struct_t, uncast, i, "part"); - LLVMValueRef val = LLVMBuildLoad(util_b, ptr, "deref"); - LLVMValueRef box = box_val(util_b, val, prop_t[i]); - LLVMBuildRet(util_b, box); - - debug("adding %s to scope\n", prop_func_id); - scope_add_entry(sc, prop_func_id, prop_func_p, prop_func_t); - } - LLVMDisposeBuilder(util_b); - - return ctor_p; -} - -LLVMValueRef codegen_definition(sexpr *se) { - assert(se); - assert(se->type == BRANCH); - - sexpr *title = se->contents.n.l; - sexpr *info = se->contents.n.r; - - assert(title); - assert(info); - - // TODO I'm finding it really hard to figure out how I should do this, I - // want to add this function's argument names to the scope table, but also I - // need the function's types first - // The function's arg types will be declared with the args themselves, like - // [(int x) (str y) (int z)] - // For now don't make a general thing, just get definitions to work - - char *func_id; - LLVMTypeRef ret_type; - get_param_info(title, &func_id, &ret_type); - - /* FIXME: magic sizes */ - char *ids[50]; - LLVMTypeRef param_t[50]; - uint param_c = make_func_params(info->contents.n.l, ids, param_t); - - debug("building function %s\n", func_id); - - LLVMTypeRef func_t = make_function_type(param_c, 0); - LLVMValueRef func_p = LLVMAddFunction(module, func_id, func_t); - LLVMBasicBlockRef func_b = LLVMAppendBasicBlock(func_p, "entry"); - LLVMPositionBuilderAtEnd(builder, func_b); - - function = func_p; - - scope_add_entry(sc, func_id, func_p, func_t); - - scope_push_layer(&sc); - for (uint i = 0; i < param_c; i++) { - scope_add_entry(sc, ids[i], LLVMGetParam(func_p, i), param_t[i]); - } - - assert(!info->contents.n.r->contents.n.r); - LLVMValueRef ret = _codegen(info->contents.n.r->contents.n.l); - LLVMBuildRet(builder, ret); - - scope_pop_layer(&sc); - - debug("built function %s\n", func_id); - - return func_p; -} - -LLVMValueRef codegen_from_scope(char *func_id, LLVMValueRef *args, uint arg_c) { - scope_entry *entry = scope_find(sc, func_id); - if (!entry) return 0; - - LLVMValueRef res = - LLVMBuildCall2(builder, entry->type, entry->value, args, arg_c, ""); - - return res; -} - -/* TODO: maybe make a function? */ -#define codegen_binop(b, x, y, op) do { \ - assert(arg_c == 2); \ - LLVMValueRef deref_x = unbox_val(b, x, llvm_int_t); \ - LLVMValueRef deref_y = unbox_val(b, y, llvm_int_t); \ - LLVMValueRef op_res = op(b, deref_x, deref_y, "op_res"); \ - LLVMValueRef res_box = box_val(b, op_res, llvm_int_t); \ - res = res_box; \ -} while (0) - -LLVMValueRef codegen_inbuilt_functions(sexpr *se, uint arg_c, LLVMValueRef - *args_v) { - - assert(se); - - sexpr *l = se->contents.n.l; - /* sexpr *r = se->contents.n.r; */ - - assert(l->type == ID); - - char *func_id = l->contents.s; - - LLVMValueRef res = 0; - - if (!strcmp(func_id, "+")) { - codegen_binop(builder, args_v[0], args_v[1], LLVMBuildAdd); - } else if (!strcmp(func_id, "*")) { - codegen_binop(builder, args_v[0], args_v[1], LLVMBuildMul); - } else if (!strcmp(func_id, "-")) { - codegen_binop(builder, args_v[0], args_v[1], LLVMBuildSub); - } - - return res; -} - -/* - * To implement lazy evaluation, I could implement thunks - * Closures would require using a struct to keep track of variable's values from - * when the closure was created - */ - -LLVMValueRef codegen_invocation(sexpr *se) { - assert(se); - - sexpr *l = se->contents.n.l; - sexpr *r = se->contents.n.r; - - assert(l->type == ID); - - char *func_id = l->contents.s; - debug("invoking %s\n", func_id); - - /* - * args_t may not be needed as we can just get the types of values from the - * function declaration. Who knows, really. - */ - /* FIXME: magic values */ - LLVMValueRef args[50]; - uint arg_c = get_args_from_list(r, args); - - LLVMValueRef res = codegen_from_scope(func_id, args, arg_c); - if (!res) res = codegen_inbuilt_functions(se, arg_c, args); - - if (!res) error(UNKNOWN_ID, "unrecognised ID %s", func_id); - - - return res; -} - -LLVMValueRef codegen_conditional(sexpr *se) { - assert(se); - assert(se->type == BRANCH); - - sexpr *cond_ast = se->contents.n.l; - assert(cond_ast); - - se = se->contents.n.r; - assert(se); - assert(se->type == BRANCH); - - sexpr *then_ast = se->contents.n.l; - assert(then_ast); - - se = se->contents.n.r; - assert(se); - assert(se->type == BRANCH); - - sexpr *else_ast = se->contents.n.l; - assert(else_ast); - - assert(!se->contents.n.r); - - LLVMBasicBlockRef then_b = LLVMAppendBasicBlock(function, "then"); - LLVMBasicBlockRef else_b = LLVMAppendBasicBlock(function, "else"); - LLVMBasicBlockRef done_b = LLVMAppendBasicBlock(function, "done"); - - LLVMValueRef llvm_zero_v = LLVMConstInt(llvm_int_t, 0, 0); - LLVMValueRef cond_res = _codegen(cond_ast); - LLVMValueRef unboxed_cond_res = unbox_val(builder, cond_res, llvm_int_t); - LLVMValueRef cond_v = LLVMBuildICmp(builder, LLVMIntNE, unboxed_cond_res, - llvm_zero_v, "neq_0"); - LLVMBuildCondBr(builder, cond_v, then_b, else_b); - - LLVMPositionBuilderAtEnd(builder, then_b); - LLVMValueRef then_v = _codegen(then_ast); - LLVMBuildBr(builder, done_b); - - LLVMPositionBuilderAtEnd(builder, else_b); - LLVMValueRef else_v = _codegen(else_ast); - LLVMBuildBr(builder, done_b); - - LLVMPositionBuilderAtEnd(builder, done_b); - LLVMValueRef phi_p = LLVMBuildPhi(builder, boxed_t, "if_res"); - LLVMBasicBlockRef phi_bs[] = { then_b, else_b }; - LLVMValueRef phi_vs[] = { then_v, else_v }; - LLVMAddIncoming(phi_p, phi_vs, phi_bs, 2); - - return phi_p; -} - -LLVMValueRef codegen_branch(sexpr *se) { - - assert(se); - - sexpr *l = se->contents.n.l; - sexpr *r = se->contents.n.r; - - LLVMValueRef res; - - if (l->type == ID) { - if (!strcmp(l->contents.s, "def")) { - res = codegen_definition(r); - } else if (!strcmp(l->contents.s, "type")) { - res = codegen_type_definition(r); - } else if (!strcmp(l->contents.s, "if")) { - res = codegen_conditional(r); - } else { - res = codegen_invocation(se); - } - } else { - fprint_sexpr(stderr, se); - error(SYNTAX_ERROR, "don't know what to do with above AST"); - - } - - return res; -} - -LLVMValueRef _codegen(sexpr *sexpr) { - switch (sexpr->type) { - case NIL: - case INT: - return codegen_int(sexpr); - case ID: - return codegen_id(sexpr->contents.s); - case BRANCH: - return codegen_branch(sexpr); - default: - printf("erm\n"); - return 0; - } -} - -void codegen(sexpr *sexpr) { - _codegen(sexpr); -} - -void prologue() { - sc = 0; - scope_push_layer(&sc); - - llvm_int_t = LLVMInt32Type(); - llvm_str_t = LLVMPointerType(LLVMInt8Type(), 0); - boxed_t = LLVMPointerType(LLVMInt8Type(), 0); - - char *target_triple = LLVMGetDefaultTargetTriple(); - debug("using target %s\n", target_triple); - - module = LLVMModuleCreateWithName("main_module"); - LLVMSetTarget(module, target_triple); - builder = LLVMCreateBuilder(); - - LLVMDisposeMessage(target_triple); - - /* add print_int */ - print_int_t = make_function_type(1, 0); - print_int_p = LLVMAddFunction(module, "debug_int", print_int_t); - scope_add_entry(sc, "debug_int", print_int_p, print_int_t); - - /* add print_str */ - LLVMTypeRef print_str_params[] = { llvm_str_t }; - print_str_t = LLVMFunctionType(LLVMInt32Type(), print_str_params, 1, 0); - print_str_p = LLVMAddFunction(module, "debug_str", print_str_t); - scope_add_entry(sc, "debug_str", print_str_p, print_str_t); - - /* add gc_alloc */ - LLVMTypeRef gc_alloc_params[] = { llvm_int_t }; - gc_alloc_t = LLVMFunctionType(boxed_t, gc_alloc_params, 1, 0); - gc_alloc_p = LLVMAddFunction(module, "gc_alloc", gc_alloc_t); - scope_add_entry(sc, "gc_alloc", gc_alloc_p, gc_alloc_t); -} - -void write_bitcode(LLVMModuleRef mod, char *fn) { - LLVMWriteBitcodeToFile(mod, fn); -} - -void write_module(LLVMModuleRef mod, char *fn) { - char *code = LLVMPrintModuleToString(mod); - FILE *fp = fopen(fn, "w"); - fprintf(fp, "%s", code); - LLVMDisposeMessage(code); -} - -void epilogue() { - char *error_str = 0; - - /* LLVMVerifyModule(module, LLVMAbortProcessAction, &error_str); */ - /* LLVMDisposeMessage(error_str); */ - - if (mode == COMPILE) { - if (format == BC) { - write_bitcode(module, output_fn ? output_fn : "/dev/stdout"); - } else { - write_module(module, output_fn ? output_fn : "/dev/stdout"); - } - - } else { - - LLVMExecutionEngineRef engine; - error_str = 0; - - LLVMLinkInMCJIT(); - LLVMInitializeNativeTarget(); - LLVMInitializeNativeAsmPrinter(); - - if (LLVMCreateExecutionEngineForModule(&engine, module, &error_str)) { - error(GENERAL_ERROR, "failed to create execution engine"); - } - - if (error_str) { - error(GENERAL_ERROR, "%s", error_str); - } - - /* - * This is a very ugly cast, fetching a function pointer from the JIT'd - * code. C will never like this cast because LLVMGetFunctionAddress - * returns a uint64_t (deliberately, so that a cast is necessary). - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wbad-function-cast" - main_func_t main_func = - (main_func_t) LLVMGetFunctionAddress(engine, "main"); -#pragma clang diagnostic pop - - int *res = (int *) main_func(); - printf("%i\n", *res); - } - - LLVMDisposeBuilder(builder); - LLVMDisposeModule(module); -} - -int main(int argc, char **argv) { - int c; - - output_fn = 0; - mode = INTERPRET; - format = LL; - - while ((c = getopt(argc, argv, "bchilo:")) != -1) { - switch (c) { - case 'b': - format = BC; - break; - - case 'c': - mode = COMPILE; - break; - - case 'h': - printf( "usage: %s [options] <input_file>\n" - "-b Specify bitcode-format output\n" - "-c Compile mode\n" - "-h Print this help message\n" - "-i Interpret mode\n" - "-l Specify human-readable output\n" - "-o <output> Specify output filename\n", - argv[0]); - exit(0); - - case 'i': - mode = INTERPRET; - break; - - case 'l': - format = LL; - break; - - case 'o': - output_fn = optarg; - break; - - case '?': - switch (optopt) { - case 'o': - error(INVALID_ARGUMENTS, - "-%c option requires an argument", optopt); - break; - - default: - error(INVALID_ARGUMENTS, "unknown option %c", optopt); - } - break; - - default: - error(INVALID_ARGUMENTS, "error parsing arguments"); - } - } - - if (argc - optind > 1) { - error(INVALID_ARGUMENTS, "too many arguments"); - } else if (argc - optind == 1) { - yyin = fopen(argv[argc - 1], "r"); - } - - prologue(); - yyparse(); - epilogue(); - return 0; -} diff --git a/basic.h b/basic.h deleted file mode 100644 index 13c375d..0000000 --- a/basic.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef BASIC_H -#define BASIC_H - -/* - * This struct being padded is unimportant. - */ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" - -typedef struct sexpr { - int type; - union contents { - double f; - char *s; - int i; - struct node { - struct sexpr *l; - struct sexpr *r; - } n; - } contents; -} sexpr; - -#pragma clang diagnostic pop - -typedef struct node node; -typedef union contents contents; - -sexpr *new_int(int num); -sexpr *new_float(double num); -sexpr *new_id(char *id); -sexpr *new_node(sexpr *l, sexpr *r); -sexpr *new_str(char *str); - -void print_sexpr(sexpr *se); -void fprint_sexpr(FILE *f, sexpr *se); - -void codegen(sexpr *sexpr); - -#endif /* BASIC_H */ @@ -1,16 +1,22 @@ #include <stddef.h> -#include <gc.h> +#include <stdio.h> -#include "debug.h" +#include <gc.h> void *inter_main(void); void *debug_int(void *i) { int *p = (int *) i; - debug("%d\n", *p); + fprintf(stderr, "%d\n", *p); return i; } +void *debug_func_call(void *f) { + char *func_id = (char *) f; + fprintf(stderr, "%s\n", func_id); + return 0; +} + void *gc_alloc(int size) { void *p = GC_MALLOC(size); @@ -34,5 +40,7 @@ int main() { */ GC_INIT(); - return (int) inter_main(); + int *ret = (int *) inter_main(); + + return *ret; } diff --git a/common.mak b/common.mak new file mode 100644 index 0000000..5b49f55 --- /dev/null +++ b/common.mak @@ -0,0 +1,14 @@ +LLC ?= clang +SINC ?= sinter + +%.o: %.ll + $(LLC) -c $(LLCFLAGS) -o $@ $< + +%.ll: %.sin + $(SINC) -l $(SINCFLAGS) -o $@ $< + +%.dot: %.sin + $(SINC) -g $(SINCFLAGS) -o $@ $< + +%.svg: %.dot + dot -Tsvg $< > $@ @@ -3,6 +3,12 @@ #include <stdio.h> -#define debug(...) fprintf(stderr, __VA_ARGS__) +extern int verbose; + +#define debug(...) do { \ + if (verbose) { \ + fprintf(stderr, __VA_ARGS__); \ + } \ +} while (0) #endif /* DEBUG_H */ diff --git a/examples/Makefile b/examples/Makefile new file mode 100644 index 0000000..3707e79 --- /dev/null +++ b/examples/Makefile @@ -0,0 +1,23 @@ +CC = clang +CXX = clang++ +SINC = ../sinter + +CFLAGS = -g -O0 -Werror -Wpedantic -Wall +LDFLAGS = -L$(HOME)/usr/lib -g +LDLIBS = -lgc + +LLCFLAGS = $(CFLAGS) +SINCFLAGS = + +TRGT = + +include ../common.mak + +.PHONY: default all clean + +default: all + +all: $(TRGT) + +clean: + $(RM) *.ll *.dot *.svg *.o $(TRGT) diff --git a/examples/algebraic.sin b/examples/algebraic.sin new file mode 100644 index 0000000..a3d4337 --- /dev/null +++ b/examples/algebraic.sin @@ -0,0 +1,13 @@ +[dec just [x]] +[dec none []] +[dec has_value [x]] +[dec Maybe.>>= [a f]] +[dec just.val [x]] + +[def double [x] + [just [* x 2]]] + +[def inter_main [] + [debug_int + [just.val + [Maybe.>>= [just 10] double]]]] diff --git a/examples/crosses.int b/examples/crosses.int new file mode 100644 index 0000000..a1d8c99 --- /dev/null +++ b/examples/crosses.int @@ -0,0 +1,8 @@ +[dec loop [c]] +[dec create_window [c x y w h]] +[dec init_sdl []] + +[def on_click [x y] [debug_int [+ x y]]] + +[def inter_main [] + [loop [create_window [init_sdl] 10 10 100 100]]] diff --git a/examples/e.int b/examples/e.int new file mode 100644 index 0000000..f49b406 --- /dev/null +++ b/examples/e.int @@ -0,0 +1,21 @@ +[type cons [(INT head) (cons tail)]] +[def (INT ==) [(INT a) (INT b)] [if [- a b] 0 1]] +[def (INT hastail) [(INT list)] [if [cons.tail list] 1 0]] +[def (INT carry_guess) [(INT d) (INT base)] [/ d base]] +[def (INT remainder) [(INT d) (INT base)] [% d base]] +[def (INT carry_propagate) [(INT a) (INT b)] [+ 1 1]] +[def (INT next_carry) [(INT base) (INT ds)] + [carry_propagate [+ base 1] [cons.tail ds]]] +[def (INT d_corrected) [(INT base) (INT ds)] + [+ [cons.head ds] [next_carry base ds]]] + +[def (INT carry_propagate) [(INT base) (INT ds)] [ + if [== [carry_guess [cons.head ds] base] [/ [+ [cons.head ds] 9] base]] + [cons [carry_guess [cons.head ds] base] + [+ [remainder [cons.head ds] base] [next_carry base [cons.tail ds]]]] + [cons [/ d_corrected base] [% d_corrected base]] +]] + +[def (INT e) [(INT n)] + [ +[def (INT inter_main) [] [debug_int [+ 1 1]]] diff --git a/examples/either.sin b/examples/either.sin new file mode 100644 index 0000000..e16b7b8 --- /dev/null +++ b/examples/either.sin @@ -0,0 +1,25 @@ +[type left_ [kind val]] +[type right_ [kind val]] + +[def left [val] + [left_ 0 val]] + +[def right [val] + [right_ 1 val]] + +[def left.val [x] + [left_.val x]] + +[def right.val [x] + [right_.val x]] + +[def is_right [x] + [right_.kind x]] + +[def Either.>>= [a f] + [if [is_right a] + [f [right.val a]] + a]] + +[def Either.return [x] + [right x]] diff --git a/examples/fib.int b/examples/fib.int new file mode 100644 index 0000000..11736d0 --- /dev/null +++ b/examples/fib.int @@ -0,0 +1,12 @@ +[dec wowow []] +[type test [(INT x) (INT y)]] +[def testest [] [test.y [test 3 10]]] +[def dec [n] [- n 1]] +[def inc [n] [+ n 1]] +[def ttt [x y] [test y x]] +[def ! [b] [if b 0 1]] +[def != [x y] [- x y]] +[def == [x y] [! [!= x y]]] +[def or [a b] [if a 1 b]] +[def fib [n] [debug_int [if [or [== n 0] [== n 1]] 1 [+ [fib [- n 1]] [fib [- n 2]]]]]] +[def inter_main [] [fib [test.y [ttt 10 10]]]] diff --git a/examples/function.sin b/examples/function.sin new file mode 100644 index 0000000..461b9e2 --- /dev/null +++ b/examples/function.sin @@ -0,0 +1,76 @@ +[type hunk [func args_req arg_c args]] + +[dec run_func [f v as]] + +[dec list [x n]] +[dec nil []] +[dec is_nil [x]] +[dec append [xs x]] +[dec head [xs]] +[dec tail [xs]] + +[dec left [x]] +[dec right [x]] +[dec is_right [x]] +[dec right.val [x]] +[dec left.val [x]] + +[def = [a b] + [if [- a b] + 0 + 1]] + +[def add_arg [h a] + [hunk [hunk.func h] + [hunk.args_req h] + [+ [hunk.arg_c h] 1] + [append [hunk.args h] a]]] + +[def run_hunk [h] + [run_func [hunk.func h] [hunk.args_req h] [hunk.args h]]] + +[def maybe_run_hunk [h] + [if [= [hunk.args_req h] [hunk.arg_c h]] + [left [run_hunk h]] + [right h]]] + +[def add_arg_and_maybe_run [h a] + [maybe_run_hunk [add_arg h a]]] + +[def !1 [h a] + [add_arg_and_maybe_run h a]] + +[def swap_args [f a b] + [f b a]] + +[def make_hunk [f v] + [if v + [right [hunk f v 0 [nil]]] + [left [run_func f 0 [nil]]]]] + +[def !> [h a] + [if [is_right h] + [!1 [right.val h] a] + h]] + +[dec add_args_and_maybe_run_rev [as h]] + +[def add_args_and_maybe_run [h as] + [if [is_nil as] + h + [add_args_and_maybe_run [!> h [head as]] + [tail as]]]] + +[def ! [h as] + [add_args_and_maybe_run h as]] + +[def countdown [x] + [if x + [list x [countdown [- x 1]]] + [nil]]] + +[def mult [x y] + [* x y]] + +[def inter_main [] + [debug_int [left.val [! [make_hunk mult 2] [countdown 10]]]]] diff --git a/examples/glue.c b/examples/glue.c new file mode 100644 index 0000000..33e44bd --- /dev/null +++ b/examples/glue.c @@ -0,0 +1,42 @@ +#include <stdio.h> + +#include <SDL2/SDL.h> + +void *on_click(void *x, void *y); + +void *init_sdl() { + return (void *) SDL_Init(SDL_INIT_VIDEO); +} + +void *create_window(void *init, void *xv, void *yv, void *wv, void *hv) { + int x = (int) xv, y = (int) yv, w = (int) wv, h = (int) hv; + int window_flags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE; + SDL_Window *window = SDL_CreateWindow("window", x, y, w, h, window_flags); + int rend_flags = SDL_RENDERER_ACCELERATED; + SDL_Renderer *rend = SDL_CreateRenderer(window, -1, rend_flags); + printf("window created\n"); + return (void *) window; +} + +void *loop(void *window) { + int running = 1; + SDL_Event e; + while (running) { + while (SDL_PollEvent(&e)) { + printf("event\n"); + switch (e.type) { + case SDL_QUIT: + running = 0; + break; + case SDL_MOUSEBUTTONDOWN: { + SDL_MouseButtonEvent mbe = e.button; + if (mbe.button == SDL_BUTTON_LEFT) { + on_click((void *) mbe.x, (void *) mbe.y); + } + break; + } + } + } + } + return 0; +} diff --git a/examples/list.sin b/examples/list.sin new file mode 100644 index 0000000..5952ae3 --- /dev/null +++ b/examples/list.sin @@ -0,0 +1,53 @@ +[type list_ [kind head tail]] +[type nil_ [kind]] + +[def list [head tail] + [list_ 1 head tail]] + +[def nil [] + [nil_ 0]] + +[def head [xs] + [list_.head xs]] + +[def tail [xs] + [list_.tail xs]] + +[def has_tail [xs] + [nil_.kind xs]] + +[def is_nil [x] + [if [nil_.kind x] + 0 + 1]] + +[def concat [as bs] + [list [head as] + [if [is_nil [tail as]] + bs + [concat [tail as] bs]]]] + +[def alt_concat [as bs] + [if [is_nil [tail as]] + [list [head as] bs] + [list [head as] [concat [tail as] bs]]]] + +[def prepend [x xs] + [list x xs]] + +[def append [xs x] + [if [is_nil xs] + [list [debug_int x] [nil]] + [list [head xs] [append [tail xs] x]]]] + +[def map [xs f] + [if [is_nil xs] + xs + [list [f [head xs]] + [map [tail xs] f]]]] + +[def debug_list_int [xs] + [if [is_nil xs] + xs + [list [debug_int [head xs]] + [debug_list_int [tail xs]]]]] diff --git a/examples/list_null.c b/examples/list_null.c new file mode 100644 index 0000000..85a3d2c --- /dev/null +++ b/examples/list_null.c @@ -0,0 +1,27 @@ +typedef struct list_t { + void *content; + struct list_t *next; +} list_t; + +void *list(void *head, void *tail) { + list_t *ret = gc_alloc(sizeof (*ret)); + ret->content = head; + ret->next = (list_t *) tail; + return ret; +} + +void *nil() { + return (void *) 0; +} + +void *head(void *list) { + return list->head; +} + +void *tail(void *list) { + return list->tail; +} + +void *has_tail(void *list) { + return list->tail; +} diff --git a/examples/maybe.sin b/examples/maybe.sin new file mode 100644 index 0000000..91367cd --- /dev/null +++ b/examples/maybe.sin @@ -0,0 +1,22 @@ +[type just_ [kind val]] +[type none_ [kind]] + +[def just [val] + [just_ 1 val]] + +[def just.val [x] + [just_.val x]] + +[def none [] + [none_ 0]] + +[def has_value [x] + [just_.kind x]] + +[def Maybe.>>= [a f] + [if [has_value a] + [f [just.val a]] + a]] + +[def Maybe.return [x] + [just x]] diff --git a/examples/nqueens/list.sin b/examples/nqueens/list.sin new file mode 100644 index 0000000..9a59945 --- /dev/null +++ b/examples/nqueens/list.sin @@ -0,0 +1,56 @@ +[type cons_ [kind head tail]] +[type nil_ [kind]] + +[def cons [head tail] + [cons_ 1 head tail]] + +[def nil [] + [nil_ 0]] + +[def head [xs] + [cons_.head xs]] + +[def tail [xs] + [cons_.tail xs]] + +[def has_tail [xs] + [nil_.kind xs]] + +[def is_nil [x] + [if [nil_.kind x] + 0 + 1]] + +[def concat [as bs] + [cons [head as] + [if [is_nil [tail as]] + bs + [concat [tail as] bs]]]] + +[def alt_concat [as bs] + [if [is_nil [tail as]] + [cons [head as] bs] + [cons [head as] [concat [tail as] bs]]]] + +[def flatten_once [xs] + [concat [head xs] [flatten_once [tail xs]]]] + +[def List.>>= [ma f] + [flatten_once [map ma f]]] + +[def List.return [a] + [cons a [nil]]] + +[def prepend [x xs] + [cons x xs]] + +[def append [xs x] + [if [is_nil xs] + [cons [debug_int x] [nil]] + [cons [head xs] [append [tail xs] x]]]] + +[def map [xs f] + [if [is_nil xs] + xs + [cons [f [head xs]] + [map [tail xs] f]]]] diff --git a/examples/nqueens/nqueens.sin b/examples/nqueens/nqueens.sin new file mode 100644 index 0000000..4779586 --- /dev/null +++ b/examples/nqueens/nqueens.sin @@ -0,0 +1,67 @@ +[dec cons [head tail]] +[dec nil []] +[dec head [xs]] +[dec tail [xs]] +[dec length [xs]] + +[type pair [(INT left) (INT right)]] + +[def nsoln [nq] + [length [gen nq nq]]] + +[def inter_main [] + [debug_int [nsoln 4]]] + +[def (INT ==) [(INT a) (INT b)] + [if [- a b] 1 0]] + +[def (INT not) [(INT x)] + [if x 0 1]] + +[def (INT !=) [(INT a) (INT b)] + [not [== a b]]] + +[def (INT and) [(INT a) (INT b)] + [if a [if b 1 0] 0]] + +[def (INT length) [(INT xs)] + [debug_int [if xs [+ 1 [length [cons.tail xs]]] 0]]] + +[def (INT count) [(INT from) (INT to)] + [if [== from to] to [cons from [count [+ from 1] to]]]] + +[def (INT concat) [(INT as) (INT bs)] + [if [cons.tail as] + [cons [cons.head as] [concat [cons.tail as] bs]] + [cons [cons.head as] bs]]] + +[def (INT combo2) [(INT a) (INT bs)] + [if bs + [cons [pair a [cons.head bs]] [combo2 a [cons.tail bs]]] + 0]] + +[def (INT combo) [(INT as) (INT bs)] + [if as + [concat [combo2 [cons.head as] bs] [combo [cons.tail as] bs]] + 0]] + +[def (INT safe) [(INT x) (INT d) (INT qs)] + [if qs + [and [and [!= x [cons.head qs]] + [!= x [+ [cons.head qs] d]]] + [and [!= x [- [cons.head qs] d]] + [safe x [+ d 1] [cons.tail qs]]]] + 1]] + +[def (INT safe_filter) [(INT xs)] + [if [safe [pair.left xs] 1 [pair.right xs]] + [cons [cons.head xs] [safe_filter [cons.tail xs]]] + [safe_filter [cons.tail xs]]]] + +[def (INT gen) [(INT n) (INT nq)] + [if n [safe_filter [combo [gen [- n 1] nq] [count 1 nq]]] 0]] + +[def (INT nsoln) [(INT nq)] + [length [gen nq nq]]] + +[def (INT inter_main) [] [debug_int [nsoln 4]]] diff --git a/examples/power.int b/examples/power.int new file mode 100644 index 0000000..119166d --- /dev/null +++ b/examples/power.int @@ -0,0 +1,18 @@ +[def -- [x] + [- x 1]] + +[def +++ [x y] + [+ x y]] + +[def *** [x y] + [if x + [+++ y [*** [-- x] y]] + 0]] + +[def ^^^ [b p] + [if p + [*** b [^^^ b [-- p]]] + 1]] + +[def inter_main [] + [debug_int [^^^ 3 6]]] diff --git a/examples/repeat.h b/examples/repeat.h new file mode 100644 index 0000000..8564abf --- /dev/null +++ b/examples/repeat.h @@ -0,0 +1,70 @@ +#ifndef REPEAT_H +#define REPEAT_H + +#define repeat_1(x) x +#define repeat_2(x) x, repeat_1(x) +#define repeat_3(x) x, repeat_2(x) +#define repeat_4(x) x, repeat_3(x) +#define repeat_5(x) x, repeat_4(x) +#define repeat_6(x) x, repeat_5(x) +#define repeat_7(x) x, repeat_6(x) +#define repeat_8(x) x, repeat_7(x) +#define repeat_9(x) x, repeat_8(x) +#define repeat_10(x) x, repeat_9(x) +#define repeat_11(x) x, repeat_10(x) +#define repeat_12(x) x, repeat_11(x) +#define repeat_13(x) x, repeat_12(x) +#define repeat_14(x) x, repeat_13(x) +#define repeat_15(x) x, repeat_14(x) +#define repeat_16(x) x, repeat_15(x) +#define repeat_17(x) x, repeat_16(x) +#define repeat_18(x) x, repeat_17(x) +#define repeat_19(x) x, repeat_18(x) +#define repeat_20(x) x, repeat_19(x) +#define repeat_21(x) x, repeat_20(x) +#define repeat_22(x) x, repeat_21(x) +#define repeat_23(x) x, repeat_22(x) +#define repeat_24(x) x, repeat_23(x) +#define repeat_25(x) x, repeat_24(x) +#define repeat_26(x) x, repeat_25(x) +#define repeat_27(x) x, repeat_26(x) +#define repeat_28(x) x, repeat_27(x) +#define repeat_29(x) x, repeat_28(x) +#define repeat_30(x) x, repeat_29(x) +#define repeat_31(x) x, repeat_30(x) +#define repeat_32(x) x, repeat_31(x) + +#define repeat_n_1(x) concat(x, 1) +#define repeat_n_2(x) repeat_n_1(x), concat(x, 2) +#define repeat_n_3(x) repeat_n_2(x), concat(x, 3) +#define repeat_n_4(x) repeat_n_3(x), concat(x, 4) +#define repeat_n_5(x) repeat_n_4(x), concat(x, 5) +#define repeat_n_6(x) repeat_n_5(x), concat(x, 6) +#define repeat_n_7(x) repeat_n_6(x), concat(x, 7) +#define repeat_n_8(x) repeat_n_7(x), concat(x, 8) +#define repeat_n_9(x) repeat_n_8(x), concat(x, 9) +#define repeat_n_10(x) repeat_n_9(x), concat(x, 10) +#define repeat_n_11(x) repeat_n_10(x), concat(x, 11) +#define repeat_n_12(x) repeat_n_11(x), concat(x, 12) +#define repeat_n_13(x) repeat_n_12(x), concat(x, 13) +#define repeat_n_14(x) repeat_n_13(x), concat(x, 14) +#define repeat_n_15(x) repeat_n_14(x), concat(x, 15) +#define repeat_n_16(x) repeat_n_15(x), concat(x, 16) +#define repeat_n_17(x) repeat_n_16(x), concat(x, 17) +#define repeat_n_18(x) repeat_n_17(x), concat(x, 18) +#define repeat_n_19(x) repeat_n_18(x), concat(x, 19) +#define repeat_n_20(x) repeat_n_19(x), concat(x, 20) +#define repeat_n_21(x) repeat_n_20(x), concat(x, 21) +#define repeat_n_22(x) repeat_n_21(x), concat(x, 22) +#define repeat_n_23(x) repeat_n_22(x), concat(x, 23) +#define repeat_n_24(x) repeat_n_23(x), concat(x, 24) +#define repeat_n_25(x) repeat_n_24(x), concat(x, 25) +#define repeat_n_26(x) repeat_n_25(x), concat(x, 26) +#define repeat_n_27(x) repeat_n_26(x), concat(x, 27) +#define repeat_n_28(x) repeat_n_27(x), concat(x, 28) +#define repeat_n_29(x) repeat_n_28(x), concat(x, 29) +#define repeat_n_30(x) repeat_n_29(x), concat(x, 30) +#define repeat_n_31(x) repeat_n_30(x), concat(x, 31) +#define repeat_n_32(x) repeat_n_31(x), concat(x, 32) + +#endif /* REPEAT_H */ diff --git a/examples/run_func.c b/examples/run_func.c new file mode 100644 index 0000000..e4ca8fb --- /dev/null +++ b/examples/run_func.c @@ -0,0 +1,75 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "repeat.h" + +typedef struct list { + void *kind; + void *contents; + struct list *next; +} list; + +/* FIXME: double fprintf is ugly */ +#define error(v, ...) do { \ + fprintf(stderr, __VA_ARGS__); \ + fprintf(stderr, "\n"); \ + exit(v); \ +} while (0) + +#define _concat(a, b) a ## b +#define concat(a, b) _concat(a, b) + +#define assign_arg(n) \ + concat(arg_, n) = l->contents; \ + fprintf(stderr, "%p: %i\n", concat(arg_, n), *((int *) concat(arg_, n))); \ + l = l->next + +#define cast_apply_f(n) return ((void *(*)(concat(repeat_, n)(void *))) f)\ +(concat(repeat_n_, n)(arg_)) + +#define new_case(n) \ + assign_arg(n); \ + if (arity == n) cast_apply_f(n) + +void *run_func(void *f, void *v, void *as) { + int arity = *((int *) v); + fprintf(stderr, "calling function %p with arity %i\n", f, arity); + list *l = (list *) as; + + void repeat_n_32(*arg_); + + if (arity == 0) return ((void *(*)()) f)(); + new_case(1); + new_case(2); + new_case(3); + new_case(4); + new_case(5); + new_case(6); + new_case(7); + new_case(8); + new_case(9); + new_case(10); + new_case(11); + new_case(12); + new_case(13); + new_case(14); + new_case(15); + new_case(16); + new_case(17); + new_case(18); + new_case(19); + new_case(20); + new_case(21); + new_case(22); + new_case(23); + new_case(24); + new_case(25); + new_case(26); + new_case(27); + new_case(28); + new_case(29); + new_case(30); + new_case(31); + new_case(32); + error(1, "arity %i not handled", arity); +} diff --git a/examples/tree.sin b/examples/tree.sin new file mode 100644 index 0000000..b11cae9 --- /dev/null +++ b/examples/tree.sin @@ -0,0 +1,16 @@ +[type branch_ [kind val l r]] +[type leaf_ [kind val]] + +[dec == [a b]] + +[def branch [v l r] + [branch_ 0 v l r]] + +[def leaf [x] + [leaf_ 1 x]] + +[def is_branch [x] + [== [branch_.kind x] 0]] + +[def is_leaf [x] + [== [leaf_.kind x] 1]] diff --git a/examples/unit/Makefile b/examples/unit/Makefile new file mode 100644 index 0000000..aadf541 --- /dev/null +++ b/examples/unit/Makefile @@ -0,0 +1,19 @@ +CC = clang +SINC = ../../sinter + +TRGT = $(patsubst %.sin,%,$(wildcard test*.sin)) +LDFLAGS = -L$(HOME)/usr/lib +LDLIBS = -lgc + +include ../../common.mak + +.PHONY: default all clean + +default: all + +all: $(TRGT) + +$(TRGT): test_framework.o ../../common.o + +clean: + $(RM) *.o *.ll $(TRGT) diff --git a/examples/unit/run_tests.sh b/examples/unit/run_tests.sh new file mode 100755 index 0000000..2146746 --- /dev/null +++ b/examples/unit/run_tests.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +make --silent clean +make --silent test_framework.o + +for t in test_*.sin ; do + exe="$(basename -s .sin $t)" + echo -n "$exe... " + make --silent "$exe" + if [ $? -ne 0 ] ; then + echo "cannot build" + continue + fi + echo -n "built " + ./"$exe" + if [ $? -ne 0 ] ; then + echo "failed" + continue + fi + echo "passed" +done diff --git a/examples/unit/test_001_return_literal_int.sin b/examples/unit/test_001_return_literal_int.sin new file mode 100644 index 0000000..d367d11 --- /dev/null +++ b/examples/unit/test_001_return_literal_int.sin @@ -0,0 +1,2 @@ +[def test [] + 0] diff --git a/examples/unit/test_002_return_right_value.sin b/examples/unit/test_002_return_right_value.sin new file mode 100644 index 0000000..680ed7a --- /dev/null +++ b/examples/unit/test_002_return_right_value.sin @@ -0,0 +1,7 @@ +[dec assert_equals [a b c]] + +[def returns_ten [] + 10] + +[def test [] + [assert_equals [returns_ten] 10 0]] diff --git a/examples/unit/test_framework.c b/examples/unit/test_framework.c new file mode 100644 index 0000000..22ededd --- /dev/null +++ b/examples/unit/test_framework.c @@ -0,0 +1,13 @@ +#include <assert.h> + +void *test(void); + +void *inter_main(void) { + return test(); +} + +void *assert_equals(void *a, void *b, void *c) { + int ia = *((int *) a), ib = *((int *) b); + assert(ia == ib); + return c; +} diff --git a/examples/util.sin b/examples/util.sin new file mode 100644 index 0000000..5911a34 --- /dev/null +++ b/examples/util.sin @@ -0,0 +1,2 @@ +[def == [a b] + [- a b]] diff --git a/graphviz_codegen.c b/graphviz_codegen.c new file mode 100644 index 0000000..4e94483 --- /dev/null +++ b/graphviz_codegen.c @@ -0,0 +1,116 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "graphviz_codegen.h" +#include "sinter.h" +#include "parse.h" +#include "error.h" + +/* + * TODO + * The structure of this file is very similar to that of sinter_codegen.c; maybe + * they can be merged? + */ + +typedef struct func_str { + /* FIXME: magic size */ + char buf[100000]; + struct func_str *next; +} func_str; + +func_str *ffs; +func_str *lfs; + +int nid; + +static int make_node(char *buf, sexpr *ast, sexpr *parent) { + if (!ast) { + return sprintf(buf, "\"%p%p\"[label=\"()\",shape=\"circle\"]\n", + (void *) parent, (void *) ast); + + } else switch (ast->type) { + + case INT: + return sprintf(buf, "\"%p%p\"[label=\"%i\"]\n", (void *) parent, + (void *) ast, ast->contents.i); + + case FLOAT: + return sprintf(buf, "\"%p%p\"[label=\"%f\"]\n", (void *) parent, + (void *) ast, ast->contents.f); + + case STRING: + return sprintf(buf, "\"%p%p\"[label=\"\\\"%s\\\"\"]\n", + (void *) parent, (void *) ast, ast->contents.s); + + case ID: + return sprintf(buf, "\"%p%p\"[label=\"%s\"]\n", (void *) parent, + (void *) ast, ast->contents.s); + + case BRANCH: + return sprintf(buf, + "\"%p%p\"[label=\"\",shape=\"circle\",style=\"filled\",width=\"0.2\",fillcolor=\"black\"]\n", + (void *) parent, (void *) ast); + + default: + return 0; + } +} + +static int make_children(char *buf, sexpr *ast, sexpr *parent) { + if (!ast || ast->type != BRANCH) return 0; + + char *old_buf = buf; + + buf += sprintf(buf, "{\nrank=\"same\"\nrankdir=\"LR\"\n"); + sexpr *last = ast->contents.n.l; + sexpr *rast = ast->contents.n.r; + buf += make_node(buf, last, ast); + buf += make_node(buf, rast, ast); + buf += sprintf(buf, "\"%p%p\"->\"%p%p\"[style=\"invis\"]\n", (void *) ast, + (void *) last, (void *) ast, (void *) rast); + buf += sprintf(buf, "}\n"); + buf += sprintf(buf, "\"%p%p\"->\"%p%p\"\n", (void *) parent, (void *) ast, + (void *) ast, (void *) last); + buf += sprintf(buf, "\"%p%p\"->\"%p%p\"\n", (void *) parent, (void *) ast, + (void *) ast, (void *) rast); + + buf += make_children(buf, last, ast); + buf += make_children(buf, rast, ast); + + return buf - old_buf; +} + +void graphviz_codegen_prologue() { + ffs = 0; + lfs = 0; + nid = 0; +} + +void graphviz_codegen(sexpr *ast) { + func_str *fs = (func_str *) malloc(sizeof (*fs)); + if (!fs) error(GENERAL_ERROR, "cannot malloc"); + + char *buf = fs->buf; + buf += sprintf(buf, "subgraph \"cluster_%i\" {\n", ++nid); + buf += make_node(buf, ast, 0); + buf += make_children(buf, ast, 0); + buf += sprintf(buf, "}\n"); + fs->next = 0; + + if (!ffs) ffs = fs; + if (lfs) lfs->next = fs; + lfs = fs; +} + +int graphviz_codegen_epilogue(char *output_filename) { + FILE *fp = fopen(output_filename, "w"); + + fprintf(fp, "digraph {\n"); + fprintf(fp, "node[fontname=\"monospace\"]\n"); + for (func_str *fs = ffs; fs; fs = fs->next) { + fprintf(fp, "%s\n", fs->buf); + } + fprintf(fp, "}\n"); + + return 0; +} diff --git a/graphviz_codegen.h b/graphviz_codegen.h new file mode 100644 index 0000000..6fae8d5 --- /dev/null +++ b/graphviz_codegen.h @@ -0,0 +1,10 @@ +#ifndef GRAPHVIZ_CODEGEN_H +#define GRAPHVIZ_CODEGEN_H + +#include "sinter.h" + +void graphviz_codegen_prologue(); +void graphviz_codegen(sexpr *ast); +int graphviz_codegen_epilogue(char *output_filename); + +#endif /* GRAPHVIZ_CODEGEN_H */ @@ -1,18 +1,35 @@ +%option noinput nounput %option noyywrap %option nodefault -%option yylineno -%option noinput nounput +/* %option reentrant bison-bridge bison-locations */ %{ #include <string.h> -#include "basic.h" +#include "sexpr.h" +#include "sinter.h" #include "parse.h" void yyerror(const char *s, ...); char *str_value(char *s); +void update_yylloc() { + yylloc.first_line = yylloc.last_line; + yylloc.first_column = yylloc.last_column; + + for (int i = 0; yytext[i]; i++) { + if (yytext[i] == '\n') { + yylloc.last_line++; + yylloc.last_column = 0; + } else { + yylloc.last_column++; + } + } +} + +#define YY_USER_ACTION update_yylloc(); + char *str_value(char *s) { s++; /* FIXME: strdup allocates memory! */ @@ -24,7 +41,9 @@ char *str_value(char *s) { %} -ID [-A-Za-z_+*!/.=<>][-A-Za-z0-9_+*!.=<>]* +%option yylineno + +ID [-A-Za-z_+*^!:/%.=<>][-A-Za-z0-9_+*^!:/%.=<>]* STRING ["][^"]*["]|['][^']*['] FLOAT [+-]?([0-9]+[.][0-9]*([Ee][+-]?[0-9]+)?|[.][0-9]+([Ee][+-]?[0-9]+)?) INT [+-]?[0-9]+ diff --git a/llvm_codegen.c b/llvm_codegen.c new file mode 100644 index 0000000..b27af9b --- /dev/null +++ b/llvm_codegen.c @@ -0,0 +1,842 @@ +#include <stdlib.h> +#include <unistd.h> +#include <assert.h> +#include <string.h> +#include <stddef.h> + +#include <llvm-c/Core.h> +#include <llvm-c/ExecutionEngine.h> +#include <llvm-c/Target.h> +#include <llvm-c/Analysis.h> +#include <llvm-c/BitWriter.h> +#include <llvm-c/DebugInfo.h> + +#include "llvm_codegen.h" +#include "sinter.h" +#include "scope.h" +#include "debug.h" +#include "parse.h" +#include "error.h" + +#define LLVMDIBuilderFinalise LLVMDIBuilderFinalize + +typedef void *(*main_func_t)(void); + +static LLVMModuleRef module; +static LLVMValueRef function; +static LLVMBuilderRef builder; +static LLVMContextRef global_context; + +static LLVMBasicBlockRef builder_block; + +static LLVMTypeRef gc_alloc_t; +static LLVMValueRef gc_alloc_p; + +static LLVMTypeRef print_int_t; +static LLVMValueRef print_int_p; + +static LLVMTypeRef debug_func_call_t; +static LLVMValueRef debug_func_call_p; + +static LLVMTypeRef print_str_t; +static LLVMValueRef print_str_p; + +static LLVMTypeRef llvm_int_t; +static LLVMTypeRef llvm_str_t; +static LLVMTypeRef boxed_t; + +static LLVMDIBuilderRef di_builder; +static LLVMMetadataRef di_file; +static LLVMMetadataRef di_cu; + +static LLVMMetadataRef boxed_t_meta; +static LLVMMetadataRef last_func_m; + +static scope sc; + +void put_builder_at_end(LLVMBuilderRef b, LLVMBasicBlockRef block) { + LLVMPositionBuilderAtEnd(b, block); + if (b == builder) { + builder_block = block; + } +} + +LLVMValueRef box_val(LLVMBuilderRef b, LLVMValueRef val, LLVMTypeRef type) { + /* FIXME: memory leak */ + /* LLVMValueRef box = LLVMBuildMalloc(b, type, "box"); */ + LLVMValueRef size = LLVMSizeOf(type); + LLVMValueRef size_cast = LLVMConstIntCast(size, llvm_int_t, 0); + LLVMTypeRef ptr_type = LLVMPointerType(type, 0); + + LLVMValueRef box = + LLVMBuildCall2(b, gc_alloc_t, gc_alloc_p, &size_cast, 1, "boxed"); + LLVMValueRef box_cast = LLVMBuildPointerCast(b, box, ptr_type, "box_cast"); + LLVMBuildStore(b, val, box_cast); + + return box; +} + +LLVMValueRef unbox_val(LLVMBuilderRef b, LLVMValueRef box, LLVMTypeRef type) { + LLVMTypeRef ptr_type = LLVMPointerType(type, 0); + LLVMValueRef uncast = LLVMBuildPointerCast(b, box, ptr_type, "uncast"); + LLVMValueRef val = LLVMBuildLoad2(b, type, uncast, "unboxed"); + return val; +} + +LLVMValueRef codegen_print_int(LLVMValueRef ref) { + LLVMValueRef args[] = { ref }; + LLVMValueRef ret = + LLVMBuildCall2(builder, print_int_t, print_int_p, args, 1, ""); + return ret; +} + +LLVMValueRef codegen_int(sexpr *sexpr) { + LLVMValueRef val = + LLVMConstInt(llvm_int_t, (unsigned) sexpr->contents.i, 0); + LLVMValueRef box = box_val(builder, val, llvm_int_t); + return box; +} + +LLVMValueRef codegen_id(char *id) { + scope_entry *entry = scope_find(sc, id); + if (!entry) return 0; + + LLVMValueRef val = entry->value; + + /* + * all uses of this function want a value, and since all values are assumed + * to be boxed right now, it should be safe to cast function pointers to i8* + */ + //if (entry->type == boxed_t) { + val = LLVMBuildPointerCast(builder, val, boxed_t, "func_generic_cast"); + //} + + return val; +} + +LLVMTypeRef make_function_type(unsigned param_c, LLVMBool vararg) { + + /* FIXME: memory leak */ + LLVMTypeRef *boxed_params = malloc((sizeof (LLVMTypeRef)) * param_c); + for (uint i = 0; i < param_c; i++) { + boxed_params[i] = boxed_t; + } + + return LLVMFunctionType(boxed_t, boxed_params, param_c, vararg); +} + +LLVMTypeRef make_struct_type(char *id, uint param_c, LLVMBool packed) { + + /* FIXME: memory leak */ + LLVMTypeRef *boxed_props = malloc((sizeof (LLVMTypeRef)) *param_c); + for (uint i = 0; i < param_c; i++) { + boxed_props[i] = boxed_t; + } + + LLVMTypeRef struct_t = LLVMStructCreateNamed(global_context, id); + LLVMStructSetBody(struct_t, boxed_props, param_c, packed); + return struct_t; +} + +LLVMValueRef _codegen(sexpr *sexpr); + +uint get_args_from_list(sexpr *se, LLVMValueRef *args) { + debug("getting args from list @%p\n", (void *) se); + if (!se) return 0; + assert(se->type == BRANCH); + + *args = _codegen(se->contents.n.l); + + return 1 + get_args_from_list(se->contents.n.r, args + 1); +} + +int get_type_param(sexpr *param, char **id, LLVMTypeRef *type) { + assert(param); + assert(param->type == BRANCH); + + sexpr *type_se = param->contents.n.l; + sexpr *id_se = param->contents.n.r; + + *id = id_se->contents.s; + + char *type_str = type_se->contents.s; + if (!strcmp(type_str, "INT")) { + *type = llvm_int_t; + } else if (!strcmp(type_str, "STR")) { + *type = llvm_str_t; + } else { + + /* + * FIXME + * For now, if we don't recognise the type identifier, we assume it's a + * user-defined type (aka a boxed value) + */ + *type = boxed_t; + } + + debug("type element %s with type %s\n", *id, type_str); + + return 0; +} + +uint make_type_params(sexpr *params, char **ids) { + if (!params) return 0; + + assert(params->type == BRANCH); + sexpr *l = params->contents.n.l; + sexpr *r = params->contents.n.r; + + assert(l->type == ID); + *ids = l->contents.s; + + return 1 + make_type_params(r, ids + 1); +} + +uint make_func_params(sexpr *params, char **ids, lloc_t **llocs) { + if (!params) return 0; + + assert(params->type == BRANCH); + sexpr* l = params->contents.n.l; + sexpr* r = params->contents.n.r; + + assert(l->type == ID); + *ids = l->contents.s; + *llocs = &l->lloc; + + return 1 + make_func_params(r, ids + 1, llocs + 1); +} + +LLVMValueRef codegen_type_definition(sexpr *se) { + assert(se); + assert(se->type == BRANCH); + + sexpr *title = se->contents.n.l; + sexpr *info = se->contents.n.r; + + assert(title); + assert(info); + + /* FIXME: magic sizes */ + char *prop_ids[50]; + uint prop_c = make_type_params(info->contents.n.l, prop_ids); + + char *struct_id = title->contents.s; + + debug("building struct %s\n", struct_id); + + /* last parameter determines if struct is packed */ + LLVMTypeRef struct_t = make_struct_type(struct_id, prop_c, 0); + + /* + * TODO + * I'm not sure what the second parameter of LLVMPointerType (unsigned + * AddressSpace) is used for: + * https://llvm.org/doxygen/group__LLVMCCoreTypeSequential.html#ga299fe6147083678d0494b1b875f542fa + * I'm guessing it's for restricting the address space the pointer can + * point to, which would be a cool property to expose to front-end + * languages. + */ + LLVMTypeRef struct_ptr_t = LLVMPointerType(struct_t, 0); + + /* + * Create a temporary builder for building some extra functions so that the + * main builder doesn't lose its place. Disposed of at end of scope. + */ + LLVMBuilderRef util_b = LLVMCreateBuilder(); + + /* + * Make a function for constructing an instance of this struct type. Takes + * each of the struct's properties as an individual argument. + */ + LLVMTypeRef ctor_t = make_function_type(prop_c, 0); + LLVMValueRef ctor_p = LLVMAddFunction(module, struct_id, ctor_t); + LLVMBasicBlockRef ctor_b = LLVMAppendBasicBlock(ctor_p, "entry"); + put_builder_at_end(util_b, ctor_b); + /* FIXME: memory leak */ + LLVMValueRef src = LLVMBuildMalloc(util_b, struct_t, "src"); + for (uint i = 0; i < prop_c; i++) { + LLVMValueRef prop_pos = LLVMBuildStructGEP(util_b, src, i, "pos"); + LLVMValueRef param = LLVMGetParam(ctor_p, i); + LLVMBuildStore(util_b, param, prop_pos); + } + LLVMValueRef cast = LLVMBuildPointerCast(util_b, src, boxed_t, "cast"); + LLVMBuildRet(util_b, cast); + scope_add_entry(sc, struct_id, ctor_p, ctor_t); + + /* + * Make functions to retreive each property of the struct. + */ + /* FIXME: magic size */ + char prop_func_id[50]; + for (uint i = 0; i < prop_c; i++) { + /* TODO: maybe choose a different separator character? */ + snprintf(prop_func_id, 50, "%s.%s", struct_id, prop_ids[i]); + + LLVMTypeRef prop_func_t = make_function_type(1, 0); + LLVMValueRef prop_func_p = + LLVMAddFunction(module, prop_func_id, prop_func_t); + LLVMBasicBlockRef prop_func_b = + LLVMAppendBasicBlock(prop_func_p, "entry"); + put_builder_at_end(util_b, prop_func_b); + LLVMValueRef param = LLVMGetParam(prop_func_p, 0); + LLVMValueRef uncast = + LLVMBuildPointerCast(util_b, param, struct_ptr_t, "uncast"); + LLVMValueRef ptr = + LLVMBuildStructGEP2(util_b, struct_t, uncast, i, "part"); + LLVMValueRef val = LLVMBuildLoad(util_b, ptr, "deref"); + LLVMBuildRet(util_b, val); + + debug("adding %s to scope\n", prop_func_id); + scope_add_entry(sc, prop_func_id, prop_func_p, prop_func_t); + } + LLVMDisposeBuilder(util_b); + + return ctor_p; +} + +LLVMValueRef codegen_declaration(sexpr *se) { + assert(se); + assert(se->type == BRANCH); + + sexpr *title = se->contents.n.l; + sexpr *info = se->contents.n.r; + + assert(title); + assert(info); + + char *func_id = title->contents.s; + + /* FIXME: magic sizes */ + char *ids[50]; + lloc_t *llocs[50]; + uint param_c = make_func_params(info->contents.n.l, ids, llocs); + + debug("building function %s\n", func_id); + + LLVMTypeRef func_t = make_function_type(param_c, 0); + LLVMValueRef func_p = LLVMAddFunction(module, func_id, func_t); + + scope_add_entry(sc, func_id, func_p, func_t); + + return func_p; +} + +LLVMMetadataRef debug_make_subprogram(LLVMDIBuilderRef di_builder, + LLVMMetadataRef scope, char *id, LLVMMetadataRef di_file, lloc_t *lloc, + LLVMTypeRef type) { + + debug("%p\n", (void *) scope); + + LLVMDIFlags flags = 0; + + uint param_c = LLVMCountParamTypes(type); + /* FIXME: magic size */ + LLVMMetadataRef func_param_types[20]; + for (uint i = 0; i <= param_c; i++) { + func_param_types[i] = boxed_t_meta; + } + + LLVMMetadataRef type_meta = LLVMDIBuilderCreateSubroutineType(di_builder, + di_file, func_param_types, param_c + 1, flags); + + size_t id_len = strlen(id); + uint lineno = lloc->first_line; + int local = 0; + int definition = 1; + uint scope_line = lloc->first_line; + int optimised = 0; + + last_func_m = LLVMDIBuilderCreateFunction(di_builder, scope, id, id_len, id, + id_len, di_file, lineno, type_meta, local, definition, scope_line, + flags, optimised); + + return last_func_m; +} + +LLVMMetadataRef debug_make_parameter(LLVMDIBuilderRef di_builder, + LLVMMetadataRef scope, char *id, uint i, LLVMMetadataRef di_file, + lloc_t *lloc) { + + size_t id_len = strlen(id); + uint lineno = lloc->first_line; + LLVMMetadataRef type = boxed_t_meta; + int preserve = 0; + int flags = 0; + + return LLVMDIBuilderCreateParameterVariable(di_builder, scope, id, id_len, + i, di_file, lineno, type, preserve, flags); +} + +LLVMMetadataRef debug_make_location(LLVMContextRef context, lloc_t *lloc, + LLVMMetadataRef scope) { + + uint lineno = lloc->first_line; + uint colno = lloc->first_column; + + return LLVMDIBuilderCreateDebugLocation(context, lineno, colno, scope, 0); +} + +LLVMValueRef codegen_definition(sexpr *se) { + assert(se); + assert(se->type == BRANCH); + + sexpr *title = se->contents.n.l; + sexpr *info = se->contents.n.r; + + assert(title); + assert(info); + + char *func_id = title->contents.s; + debug("%s\n", func_id); + + scope_entry *entry = scope_find(sc, func_id); + if (!entry) { + codegen_declaration(se); + entry = scope_find(sc, func_id); + } + + /* FIXME: magic sizes */ + char *ids[50]; + lloc_t *llocs[50]; + uint param_c = make_func_params(info->contents.n.l, ids, llocs); + LLVMValueRef func_p = entry->value; + LLVMTypeRef func_t = entry->type; + + assert(param_c == LLVMCountParamTypes(entry->type)); + + LLVMBasicBlockRef func_b = LLVMAppendBasicBlock(func_p, "entry"); + + /* create debug info for function */ + LLVMMetadataRef func_m = debug_make_subprogram(di_builder, di_file, func_id, + di_file, &title->lloc, func_t); + entry->metadata = func_m; + LLVMSetSubprogram(func_p, func_m); + + /* create debug info for function's parameters */ + for (uint i = 0; i < param_c; i++) { + LLVMValueRef param_v = LLVMGetParam(func_p, i); + LLVMMetadataRef param_m = debug_make_parameter(di_builder, func_m, + ids[i], i + 1, di_file, llocs[i]); + LLVMMetadataRef param_loc = debug_make_location(global_context, + llocs[i], func_m); + LLVMMetadataRef diexpr = LLVMDIBuilderCreateExpression(di_builder, 0, + 0); + LLVMDIBuilderInsertDbgValueAtEnd(di_builder, param_v, param_m, diexpr, + param_loc, func_b); + } + + put_builder_at_end(builder, func_b); + + LLVMMetadataRef loc = + debug_make_location(global_context, &title->lloc, func_m); + + /* + * LLVM 9 onwards has LLVMSetCurrentDebugLocation2, and this call is + * deprecated + */ + LLVMSetCurrentDebugLocation(builder, LLVMMetadataAsValue(global_context, + loc)); + +/* LLVMValueRef func_name = */ +/* LLVMBuildGlobalString(builder, func_id, "func_name"); */ +/* LLVMValueRef f_n_cast = */ +/* LLVMBuildPointerCast(builder, func_name, boxed_t, "func_name_cast"); */ +/* LLVMBuildCall2(builder, debug_func_call_t, debug_func_call_p, &f_n_cast, 1, */ +/* ""); */ + + function = func_p; + + scope_push_layer(&sc); + for (uint i = 0; i < param_c; i++) { + scope_add_entry(sc, ids[i], LLVMGetParam(func_p, i), boxed_t); + } + + assert(!info->contents.n.r->contents.n.r); + LLVMValueRef ret = _codegen(info->contents.n.r->contents.n.l); + LLVMBuildRet(builder, ret); + + scope_pop_layer(&sc); + + debug("built function %s\n", func_id); + + return func_p; +} + +LLVMValueRef codegen_from_scope(char *func_id, LLVMValueRef *args, uint arg_c) { + scope_entry *entry = scope_find(sc, func_id); + if (!entry) return 0; + + LLVMValueRef func_p = entry->value; + LLVMTypeRef func_t = entry->type; + + /* + * in the case that the function being called is passed in as an argument, + * we cast it to the function kind that we're expecting. + */ + if (func_t == boxed_t) { + LLVMTypeRef exp_func_t = make_function_type(arg_c, 0); + LLVMTypeRef exp_func_ptr_t = LLVMPointerType(exp_func_t, 0); + LLVMValueRef casted = LLVMBuildPointerCast(builder, entry->value, + exp_func_ptr_t, "func_cast"); + func_t = exp_func_t; + func_p = casted; + } + + LLVMValueRef res = + LLVMBuildCall2(builder, func_t, func_p, args, arg_c, ""); + + return res; +} + +/* TODO: maybe make a function? */ +#define codegen_binop(b, x, y, op) do { \ + assert(arg_c == 2); \ + LLVMValueRef deref_x = unbox_val(b, x, llvm_int_t); \ + LLVMValueRef deref_y = unbox_val(b, y, llvm_int_t); \ + LLVMValueRef op_res = op(b, deref_x, deref_y, "op_res"); \ + LLVMValueRef res_box = box_val(b, op_res, llvm_int_t); \ + res = res_box; \ +} while (0) + +LLVMValueRef codegen_inbuilt_functions(sexpr *se, uint arg_c, LLVMValueRef + *args_v) { + + assert(se); + + sexpr *l = se->contents.n.l; + /* sexpr *r = se->contents.n.r; */ + + assert(l->type == ID); + + char *func_id = l->contents.s; + + LLVMValueRef res = 0; + + if (!strcmp(func_id, "+")) { + codegen_binop(builder, args_v[0], args_v[1], LLVMBuildAdd); + } else if (!strcmp(func_id, "*")) { + codegen_binop(builder, args_v[0], args_v[1], LLVMBuildMul); + } else if (!strcmp(func_id, "-")) { + codegen_binop(builder, args_v[0], args_v[1], LLVMBuildSub); + } else if (!strcmp(func_id, "/")) { + codegen_binop(builder, args_v[0], args_v[1], LLVMBuildSDiv); + } else if (!strcmp(func_id, "%")) { + codegen_binop(builder, args_v[0], args_v[1], LLVMBuildSRem); + } + + return res; +} + +LLVMValueRef codegen_invocation(sexpr *se) { + assert(se); + + sexpr *l = se->contents.n.l; + sexpr *r = se->contents.n.r; + + assert(l->type == ID); + + char *func_id = l->contents.s; + debug("invoking %s\n", func_id); + + /* FIXME: magic values */ + LLVMValueRef args[50]; + uint arg_c = get_args_from_list(r, args); + + LLVMMetadataRef loc = + debug_make_location(global_context, &l->lloc, last_func_m); + + /* + * LLVM 9 onwards has LLVMSetCurrentDebugLocation2, and this call is + * deprecated + */ + LLVMSetCurrentDebugLocation(builder, LLVMMetadataAsValue(global_context, + loc)); + + LLVMValueRef res = codegen_from_scope(func_id, args, arg_c); + if (!res) res = codegen_inbuilt_functions(se, arg_c, args); + + if (!res) error(UNKNOWN_ID, "unrecognised ID %s", func_id); + + debug("invoked %s\n", func_id); + return res; +} + +LLVMValueRef codegen_conditional(sexpr *se) { + assert(se); + assert(se->type == BRANCH); + + sexpr *cond_ast = se->contents.n.l; + assert(cond_ast); + + se = se->contents.n.r; + assert(se); + assert(se->type == BRANCH); + + sexpr *then_ast = se->contents.n.l; + assert(then_ast); + + se = se->contents.n.r; + assert(se); + assert(se->type == BRANCH); + + sexpr *else_ast = se->contents.n.l; + assert(else_ast); + + assert(!se->contents.n.r); + + LLVMBasicBlockRef then_b = LLVMAppendBasicBlock(function, "then"); + LLVMBasicBlockRef else_b = LLVMAppendBasicBlock(function, "else"); + LLVMBasicBlockRef done_b = LLVMAppendBasicBlock(function, "done"); + + LLVMValueRef llvm_zero_v = LLVMConstInt(llvm_int_t, 0, 0); + LLVMValueRef cond_res = _codegen(cond_ast); + LLVMValueRef unboxed_cond_res = unbox_val(builder, cond_res, llvm_int_t); + LLVMValueRef cond_v = LLVMBuildICmp(builder, LLVMIntNE, unboxed_cond_res, + llvm_zero_v, "neq_0"); + LLVMBuildCondBr(builder, cond_v, then_b, else_b); + + put_builder_at_end(builder, then_b); + LLVMValueRef then_v = _codegen(then_ast); + LLVMBasicBlockRef then_exit_b = builder_block; + LLVMBuildBr(builder, done_b); + + put_builder_at_end(builder, else_b); + LLVMValueRef else_v = _codegen(else_ast); + LLVMBasicBlockRef else_exit_b = builder_block; + LLVMBuildBr(builder, done_b); + + put_builder_at_end(builder, done_b); + LLVMValueRef phi_p = LLVMBuildPhi(builder, boxed_t, "if_res"); + LLVMBasicBlockRef phi_bs[] = { then_exit_b, else_exit_b }; + LLVMValueRef phi_vs[] = { then_v, else_v }; + LLVMAddIncoming(phi_p, phi_vs, phi_bs, 2); + + return phi_p; +} + +LLVMValueRef codegen_branch(sexpr *se) { + + assert(se); + + sexpr *l = se->contents.n.l; + sexpr *r = se->contents.n.r; + + LLVMValueRef res; + + if (l->type == ID) { + if (!strcmp(l->contents.s, "def")) { + res = codegen_definition(r); + } else if (!strcmp(l->contents.s, "dec")) { + res = codegen_declaration(r); + } else if (!strcmp(l->contents.s, "type")) { + res = codegen_type_definition(r); + } else if (!strcmp(l->contents.s, "if")) { + res = codegen_conditional(r); + } else { + res = codegen_invocation(se); + } + + } else { + error(SYNTAX_ERROR, "don't know what to do with above AST"); + } + + return res; +} + +LLVMValueRef _codegen(sexpr *sexpr) { + switch (sexpr->type) { + case NIL: + case INT: + return codegen_int(sexpr); + case ID: + return codegen_id(sexpr->contents.s); + case BRANCH: + return codegen_branch(sexpr); + default: + printf("erm\n"); + return 0; + } +} + +void set_module_flag_int(LLVMModuleRef module, char *flag, int n, int val) { + n = n ? n : strlen(flag); + + LLVMTypeRef flag_val_t = LLVMInt32Type(); + LLVMValueRef flag_llvm_val = LLVMConstInt(flag_val_t, val, 0); + LLVMMetadataRef flag_meta_val = LLVMValueAsMetadata(flag_llvm_val); + + int flag_behaviour = LLVMModuleFlagBehaviorWarning; + + LLVMAddModuleFlag(module, flag_behaviour, flag, n, flag_meta_val); +} + +LLVMMetadataRef debug_make_file(LLVMDIBuilderRef di_builder, char *filename) { + filename = filename ? filename : "<stdin>"; + char *cwd = getcwd(0, 0); + size_t filename_len = strlen(filename); + size_t cwd_len = strlen(cwd); + + /* + * this is a hacky solution that will work when the compiler is compiling + * files found in the cwd + */ + + return LLVMDIBuilderCreateFile(di_builder, filename, filename_len, cwd, + cwd_len); +} + +LLVMMetadataRef debug_make_compile_unit(LLVMDIBuilderRef di_builder, + LLVMMetadataRef di_file) { + + LLVMDWARFSourceLanguage lang = LLVMDWARFSourceLanguageC; + char *producer = "Sinter"; + size_t producer_len = strlen(producer); + int optimised = 0; + char *flags = ""; // TODO: include compiler flags + size_t flags_len = strlen(flags); + uint runtime_version = 0; // TODO: include runtime version + char *split_name = ""; + size_t split_name_len = strlen(split_name); + LLVMDWARFEmissionKind emission = LLVMDWARFEmissionFull; + uint dwoid = 0; + int inline_debug_info = 1; + int profile_debug_info = 1; + + return LLVMDIBuilderCreateCompileUnit(di_builder, lang, di_file, producer, + producer_len, optimised, flags, flags_len, runtime_version, + split_name, split_name_len, emission, dwoid, inline_debug_info, + profile_debug_info); +} + +void llvm_codegen_prologue(char *filename) { + sc = 0; + scope_push_layer(&sc); + + llvm_int_t = LLVMInt32Type(); + llvm_str_t = LLVMPointerType(LLVMInt8Type(), 0); + boxed_t = LLVMPointerType(LLVMInt8Type(), 0); + + char *target_triple = LLVMGetDefaultTargetTriple(); + debug("using target %s\n", target_triple); + + module = LLVMModuleCreateWithName("main_module"); + set_module_flag_int(module, "Dwarf Version", 0, 4); + set_module_flag_int(module, "Debug Info Version", 0, 3); + + LLVMSetTarget(module, target_triple); + builder = LLVMCreateBuilder(); + di_builder = LLVMCreateDIBuilder(module); + + boxed_t_meta = LLVMDIBuilderCreatePointerType(di_builder, 0, + (sizeof (uintptr_t) * 8), 0, 0, "box", strlen("box")); + + global_context = LLVMGetGlobalContext(); + + di_file = debug_make_file(di_builder, filename); + di_cu = debug_make_compile_unit(di_builder, di_file); + + LLVMDisposeMessage(target_triple); + + /* add print_int */ + print_int_t = make_function_type(1, 0); + print_int_p = LLVMAddFunction(module, "debug_int", print_int_t); + scope_add_entry(sc, "debug_int", print_int_p, print_int_t); + + /* add print_str */ + LLVMTypeRef print_str_params[] = { llvm_str_t }; + print_str_t = LLVMFunctionType(LLVMInt32Type(), print_str_params, 1, 0); + print_str_p = LLVMAddFunction(module, "debug_str", print_str_t); + scope_add_entry(sc, "debug_str", print_str_p, print_str_t); + + /* add debug_func_call */ + debug_func_call_t = make_function_type(1, 0); + debug_func_call_p = + LLVMAddFunction(module, "debug_func_call", debug_func_call_t); + + /* add gc_alloc */ + LLVMTypeRef gc_alloc_params[] = { llvm_int_t }; + gc_alloc_t = LLVMFunctionType(boxed_t, gc_alloc_params, 1, 0); + gc_alloc_p = LLVMAddFunction(module, "gc_alloc", gc_alloc_t); + scope_add_entry(sc, "gc_alloc", gc_alloc_p, gc_alloc_t); +} + +int write_bitcode(LLVMModuleRef mod, char *fn) { + LLVMWriteBitcodeToFile(mod, fn); + return 0; +} + +int write_module(LLVMModuleRef mod, char *fn) { + char *code = LLVMPrintModuleToString(mod); + FILE *fp = fopen(fn, "w"); + fprintf(fp, "%s", code); + LLVMDisposeMessage(code); + return 0; +} + +int interpret(LLVMModuleRef module) { + + /* + * XXX + * This doesn't work right now, due to the need to call external GC + * functions + */ + + LLVMExecutionEngineRef engine; + char *error_str = 0; + + LLVMLinkInMCJIT(); + LLVMInitializeNativeTarget(); + LLVMInitializeNativeAsmPrinter(); + + if (LLVMCreateExecutionEngineForModule(&engine, module, &error_str)) { + error(GENERAL_ERROR, "failed to create execution engine"); + } + + if (error_str) { + error(GENERAL_ERROR, "%s", error_str); + } + + /* + * This is a very ugly cast, fetching a function pointer from the JIT'd + * code. C will never like this cast because LLVMGetFunctionAddress + * returns a uint64_t (deliberately, so that a cast is necessary). + */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wbad-function-cast" + main_func_t main_func = + (main_func_t) LLVMGetFunctionAddress(engine, "main"); +#pragma clang diagnostic pop + + int *res = (int *) main_func(); + return *res; +} + +int llvm_codegen_epilogue(char *output_filename, format_t format) { + // char *error_str = 0; + + // LLVMVerifyModule(module, LLVMAbortProcessAction, &error_str); + // LLVMDisposeMessage(error_str); + + LLVMDIBuilderFinalise(di_builder); + + switch (format) { + case BITCODE: + return write_bitcode(module, + output_filename ? output_filename : "/dev/stdout"); + + case LLVM_INTERMEDIATE: + return write_module(module, + output_filename ? output_filename : "/dev/stdout"); + + case INTERPRET: + return interpret(module); + + default: + error(GENERAL_ERROR, "somehow got here with wrong format"); + + } +} + +void llvm_codegen(sexpr *se) { + _codegen(se); +} diff --git a/llvm_codegen.h b/llvm_codegen.h new file mode 100644 index 0000000..0662a67 --- /dev/null +++ b/llvm_codegen.h @@ -0,0 +1,10 @@ +#ifndef LLVM_CODEGEN_H +#define LLVM_CODEGEN_H + +#include "sinter.h" + +void llvm_codegen_prologue(char *filename); +void llvm_codegen(sexpr *ast); +int llvm_codegen_epilogue(char *output_filename, format_t format); + +#endif /* LLVM_CODEGEN_H */ @@ -1,15 +1,20 @@ +%locations + %{ #include <stdio.h> #include <stdarg.h> #include <stdlib.h> -#include "basic.h" +#include "sexpr.h" +#include "sinter.h" extern int yylineno; int yylex(void); void yyerror(char *s, ...); +sexpr *ast; + %} %union { @@ -32,20 +37,20 @@ void yyerror(char *s, ...); %% cmds: - | cmds sexpr { fprint_sexpr(stderr, $2); codegen($2); } + | cmds sexpr { handle($2); } -sexpr: '(' sexpr ';' sexpr ')' { $$ = new_node($2, $4); } - | '(' sexpr sexpr ')' { $$ = new_node($2, $3); } +sexpr: '(' sexpr ';' sexpr ')' { $$ = new_node($2, $4, yylloc); } + | '(' sexpr sexpr ')' { $$ = new_node($2, $3, yylloc); } | '[' lexpr { $$ = $2; } - | INT { $$ = new_int($1); } - | FLOAT { $$ = new_float($1); } - | ID { $$ = new_id($1); } + | INT { $$ = new_int($1, yylloc); } + | FLOAT { $$ = new_float($1, yylloc); } + | ID { $$ = new_id($1, yylloc); } | NIL { $$ = 0; } - | STRING { $$ = new_str($1); } + | STRING { $$ = new_str($1, yylloc); } lexpr: ']' { $$ = 0; } - | sexpr ';' lexpr { $$ = new_node($1, $3); } - | sexpr lexpr { $$ = new_node($1, $2); } + | sexpr ';' lexpr { $$ = new_node($1, $3, yylloc); } + | sexpr lexpr { $$ = new_node($1, $2, yylloc); } %% @@ -45,6 +45,8 @@ void scope_add_entry(scope sc, char *id, LLVMValueRef val, LLVMTypeRef type) { scope_entry *new_entry = malloc(sizeof (*new_entry)); if (!new_entry) error(GENERAL_ERROR, "cannot malloc?"); + debug("adding entry for %s\n", id); + new_entry->id = strdup(id); new_entry->value = val; new_entry->type = type; @@ -7,6 +7,7 @@ typedef struct scope_entry { char *id; LLVMValueRef value; LLVMTypeRef type; + LLVMMetadataRef metadata; struct scope_entry *prev; } scope_entry; diff --git a/scope.pp.c b/scope.pp.c new file mode 100644 index 0000000..dd3cfba --- /dev/null +++ b/scope.pp.c @@ -0,0 +1,5831 @@ +# 1 "scope.c" +# 1 "<built-in>" +# 1 "<command-line>" +# 31 "<command-line>" +# 1 "/usr/include/stdc-predef.h" 1 3 4 +# 32 "<command-line>" 2 +# 1 "scope.c" +# 1 "/usr/include/stdlib.h" 1 3 4 +# 25 "/usr/include/stdlib.h" 3 4 +# 1 "/usr/include/bits/libc-header-start.h" 1 3 4 +# 33 "/usr/include/bits/libc-header-start.h" 3 4 +# 1 "/usr/include/features.h" 1 3 4 +# 450 "/usr/include/features.h" 3 4 +# 1 "/usr/include/sys/cdefs.h" 1 3 4 +# 460 "/usr/include/sys/cdefs.h" 3 4 +# 1 "/usr/include/bits/wordsize.h" 1 3 4 +# 461 "/usr/include/sys/cdefs.h" 2 3 4 +# 1 "/usr/include/bits/long-double.h" 1 3 4 +# 462 "/usr/include/sys/cdefs.h" 2 3 4 +# 451 "/usr/include/features.h" 2 3 4 +# 474 "/usr/include/features.h" 3 4 +# 1 "/usr/include/gnu/stubs.h" 1 3 4 +# 10 "/usr/include/gnu/stubs.h" 3 4 +# 1 "/usr/include/gnu/stubs-64.h" 1 3 4 +# 11 "/usr/include/gnu/stubs.h" 2 3 4 +# 475 "/usr/include/features.h" 2 3 4 +# 34 "/usr/include/bits/libc-header-start.h" 2 3 4 +# 26 "/usr/include/stdlib.h" 2 3 4 + + + + + +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 1 3 4 +# 209 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 3 4 + +# 209 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 3 4 +typedef long unsigned int size_t; +# 321 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 3 4 +typedef int wchar_t; +# 32 "/usr/include/stdlib.h" 2 3 4 + + + + + + + +# 1 "/usr/include/bits/waitflags.h" 1 3 4 +# 40 "/usr/include/stdlib.h" 2 3 4 +# 1 "/usr/include/bits/waitstatus.h" 1 3 4 +# 41 "/usr/include/stdlib.h" 2 3 4 +# 55 "/usr/include/stdlib.h" 3 4 +# 1 "/usr/include/bits/floatn.h" 1 3 4 +# 119 "/usr/include/bits/floatn.h" 3 4 +# 1 "/usr/include/bits/floatn-common.h" 1 3 4 +# 24 "/usr/include/bits/floatn-common.h" 3 4 +# 1 "/usr/include/bits/long-double.h" 1 3 4 +# 25 "/usr/include/bits/floatn-common.h" 2 3 4 +# 120 "/usr/include/bits/floatn.h" 2 3 4 +# 56 "/usr/include/stdlib.h" 2 3 4 + + +typedef struct + { + int quot; + int rem; + } div_t; + + + +typedef struct + { + long int quot; + long int rem; + } ldiv_t; + + + + + +__extension__ typedef struct + { + long long int quot; + long long int rem; + } lldiv_t; +# 97 "/usr/include/stdlib.h" 3 4 +extern size_t __ctype_get_mb_cur_max (void) __attribute__ ((__nothrow__ , __leaf__)) ; + + + +extern double atof (const char *__nptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; + +extern int atoi (const char *__nptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; + +extern long int atol (const char *__nptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; + + + +__extension__ extern long long int atoll (const char *__nptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; + + + +extern double strtod (const char *__restrict __nptr, + char **__restrict __endptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + +extern float strtof (const char *__restrict __nptr, + char **__restrict __endptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + +extern long double strtold (const char *__restrict __nptr, + char **__restrict __endptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); +# 176 "/usr/include/stdlib.h" 3 4 +extern long int strtol (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + +extern unsigned long int strtoul (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + +__extension__ +extern long long int strtoq (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + +__extension__ +extern unsigned long long int strtouq (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + +__extension__ +extern long long int strtoll (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + +__extension__ +extern unsigned long long int strtoull (const char *__restrict __nptr, + char **__restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); +# 385 "/usr/include/stdlib.h" 3 4 +extern char *l64a (long int __n) __attribute__ ((__nothrow__ , __leaf__)) ; + + +extern long int a64l (const char *__s) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))) ; + + + + +# 1 "/usr/include/sys/types.h" 1 3 4 +# 27 "/usr/include/sys/types.h" 3 4 + + +# 1 "/usr/include/bits/types.h" 1 3 4 +# 27 "/usr/include/bits/types.h" 3 4 +# 1 "/usr/include/bits/wordsize.h" 1 3 4 +# 28 "/usr/include/bits/types.h" 2 3 4 +# 1 "/usr/include/bits/timesize.h" 1 3 4 +# 29 "/usr/include/bits/types.h" 2 3 4 + + +typedef unsigned char __u_char; +typedef unsigned short int __u_short; +typedef unsigned int __u_int; +typedef unsigned long int __u_long; + + +typedef signed char __int8_t; +typedef unsigned char __uint8_t; +typedef signed short int __int16_t; +typedef unsigned short int __uint16_t; +typedef signed int __int32_t; +typedef unsigned int __uint32_t; + +typedef signed long int __int64_t; +typedef unsigned long int __uint64_t; + + + + + + +typedef __int8_t __int_least8_t; +typedef __uint8_t __uint_least8_t; +typedef __int16_t __int_least16_t; +typedef __uint16_t __uint_least16_t; +typedef __int32_t __int_least32_t; +typedef __uint32_t __uint_least32_t; +typedef __int64_t __int_least64_t; +typedef __uint64_t __uint_least64_t; + + + +typedef long int __quad_t; +typedef unsigned long int __u_quad_t; + + + + + + + +typedef long int __intmax_t; +typedef unsigned long int __uintmax_t; +# 141 "/usr/include/bits/types.h" 3 4 +# 1 "/usr/include/bits/typesizes.h" 1 3 4 +# 142 "/usr/include/bits/types.h" 2 3 4 +# 1 "/usr/include/bits/time64.h" 1 3 4 +# 143 "/usr/include/bits/types.h" 2 3 4 + + +typedef unsigned long int __dev_t; +typedef unsigned int __uid_t; +typedef unsigned int __gid_t; +typedef unsigned long int __ino_t; +typedef unsigned long int __ino64_t; +typedef unsigned int __mode_t; +typedef unsigned long int __nlink_t; +typedef long int __off_t; +typedef long int __off64_t; +typedef int __pid_t; +typedef struct { int __val[2]; } __fsid_t; +typedef long int __clock_t; +typedef unsigned long int __rlim_t; +typedef unsigned long int __rlim64_t; +typedef unsigned int __id_t; +typedef long int __time_t; +typedef unsigned int __useconds_t; +typedef long int __suseconds_t; + +typedef int __daddr_t; +typedef int __key_t; + + +typedef int __clockid_t; + + +typedef void * __timer_t; + + +typedef long int __blksize_t; + + + + +typedef long int __blkcnt_t; +typedef long int __blkcnt64_t; + + +typedef unsigned long int __fsblkcnt_t; +typedef unsigned long int __fsblkcnt64_t; + + +typedef unsigned long int __fsfilcnt_t; +typedef unsigned long int __fsfilcnt64_t; + + +typedef long int __fsword_t; + +typedef long int __ssize_t; + + +typedef long int __syscall_slong_t; + +typedef unsigned long int __syscall_ulong_t; + + + +typedef __off64_t __loff_t; +typedef char *__caddr_t; + + +typedef long int __intptr_t; + + +typedef unsigned int __socklen_t; + + + + +typedef int __sig_atomic_t; +# 30 "/usr/include/sys/types.h" 2 3 4 + + + +typedef __u_char u_char; +typedef __u_short u_short; +typedef __u_int u_int; +typedef __u_long u_long; +typedef __quad_t quad_t; +typedef __u_quad_t u_quad_t; +typedef __fsid_t fsid_t; + + +typedef __loff_t loff_t; + + + + +typedef __ino_t ino_t; +# 59 "/usr/include/sys/types.h" 3 4 +typedef __dev_t dev_t; + + + + +typedef __gid_t gid_t; + + + + +typedef __mode_t mode_t; + + + + +typedef __nlink_t nlink_t; + + + + +typedef __uid_t uid_t; + + + + + +typedef __off_t off_t; +# 97 "/usr/include/sys/types.h" 3 4 +typedef __pid_t pid_t; + + + + + +typedef __id_t id_t; + + + + +typedef __ssize_t ssize_t; + + + + + +typedef __daddr_t daddr_t; +typedef __caddr_t caddr_t; + + + + + +typedef __key_t key_t; + + + + +# 1 "/usr/include/bits/types/clock_t.h" 1 3 4 + + + + + + +typedef __clock_t clock_t; +# 127 "/usr/include/sys/types.h" 2 3 4 + +# 1 "/usr/include/bits/types/clockid_t.h" 1 3 4 + + + + + + +typedef __clockid_t clockid_t; +# 129 "/usr/include/sys/types.h" 2 3 4 +# 1 "/usr/include/bits/types/time_t.h" 1 3 4 + + + + + + +typedef __time_t time_t; +# 130 "/usr/include/sys/types.h" 2 3 4 +# 1 "/usr/include/bits/types/timer_t.h" 1 3 4 + + + + + + +typedef __timer_t timer_t; +# 131 "/usr/include/sys/types.h" 2 3 4 +# 144 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 1 3 4 +# 145 "/usr/include/sys/types.h" 2 3 4 + + + +typedef unsigned long int ulong; +typedef unsigned short int ushort; +typedef unsigned int uint; + + + + +# 1 "/usr/include/bits/stdint-intn.h" 1 3 4 +# 24 "/usr/include/bits/stdint-intn.h" 3 4 +typedef __int8_t int8_t; +typedef __int16_t int16_t; +typedef __int32_t int32_t; +typedef __int64_t int64_t; +# 156 "/usr/include/sys/types.h" 2 3 4 + + +typedef __uint8_t u_int8_t; +typedef __uint16_t u_int16_t; +typedef __uint32_t u_int32_t; +typedef __uint64_t u_int64_t; + + +typedef int register_t __attribute__ ((__mode__ (__word__))); +# 176 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/include/endian.h" 1 3 4 +# 36 "/usr/include/endian.h" 3 4 +# 1 "/usr/include/bits/endian.h" 1 3 4 +# 37 "/usr/include/endian.h" 2 3 4 +# 60 "/usr/include/endian.h" 3 4 +# 1 "/usr/include/bits/byteswap.h" 1 3 4 +# 33 "/usr/include/bits/byteswap.h" 3 4 +static __inline __uint16_t +__bswap_16 (__uint16_t __bsx) +{ + + return __builtin_bswap16 (__bsx); + + + +} + + + + + + +static __inline __uint32_t +__bswap_32 (__uint32_t __bsx) +{ + + return __builtin_bswap32 (__bsx); + + + +} +# 69 "/usr/include/bits/byteswap.h" 3 4 +__extension__ static __inline __uint64_t +__bswap_64 (__uint64_t __bsx) +{ + + return __builtin_bswap64 (__bsx); + + + +} +# 61 "/usr/include/endian.h" 2 3 4 +# 1 "/usr/include/bits/uintn-identity.h" 1 3 4 +# 32 "/usr/include/bits/uintn-identity.h" 3 4 +static __inline __uint16_t +__uint16_identity (__uint16_t __x) +{ + return __x; +} + +static __inline __uint32_t +__uint32_identity (__uint32_t __x) +{ + return __x; +} + +static __inline __uint64_t +__uint64_identity (__uint64_t __x) +{ + return __x; +} +# 62 "/usr/include/endian.h" 2 3 4 +# 177 "/usr/include/sys/types.h" 2 3 4 + + +# 1 "/usr/include/sys/select.h" 1 3 4 +# 30 "/usr/include/sys/select.h" 3 4 +# 1 "/usr/include/bits/select.h" 1 3 4 +# 22 "/usr/include/bits/select.h" 3 4 +# 1 "/usr/include/bits/wordsize.h" 1 3 4 +# 23 "/usr/include/bits/select.h" 2 3 4 +# 31 "/usr/include/sys/select.h" 2 3 4 + + +# 1 "/usr/include/bits/types/sigset_t.h" 1 3 4 + + + +# 1 "/usr/include/bits/types/__sigset_t.h" 1 3 4 + + + + +typedef struct +{ + unsigned long int __val[(1024 / (8 * sizeof (unsigned long int)))]; +} __sigset_t; +# 5 "/usr/include/bits/types/sigset_t.h" 2 3 4 + + +typedef __sigset_t sigset_t; +# 34 "/usr/include/sys/select.h" 2 3 4 + + + +# 1 "/usr/include/bits/types/struct_timeval.h" 1 3 4 + + + + + + + +struct timeval +{ + __time_t tv_sec; + __suseconds_t tv_usec; +}; +# 38 "/usr/include/sys/select.h" 2 3 4 + +# 1 "/usr/include/bits/types/struct_timespec.h" 1 3 4 +# 9 "/usr/include/bits/types/struct_timespec.h" 3 4 +struct timespec +{ + __time_t tv_sec; + __syscall_slong_t tv_nsec; +}; +# 40 "/usr/include/sys/select.h" 2 3 4 + + + +typedef __suseconds_t suseconds_t; + + + + + +typedef long int __fd_mask; +# 59 "/usr/include/sys/select.h" 3 4 +typedef struct + { + + + + + + + __fd_mask __fds_bits[1024 / (8 * (int) sizeof (__fd_mask))]; + + + } fd_set; + + + + + + +typedef __fd_mask fd_mask; +# 91 "/usr/include/sys/select.h" 3 4 + +# 101 "/usr/include/sys/select.h" 3 4 +extern int select (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + struct timeval *__restrict __timeout); +# 113 "/usr/include/sys/select.h" 3 4 +extern int pselect (int __nfds, fd_set *__restrict __readfds, + fd_set *__restrict __writefds, + fd_set *__restrict __exceptfds, + const struct timespec *__restrict __timeout, + const __sigset_t *__restrict __sigmask); +# 126 "/usr/include/sys/select.h" 3 4 + +# 180 "/usr/include/sys/types.h" 2 3 4 + + + + + +typedef __blksize_t blksize_t; + + + + + + +typedef __blkcnt_t blkcnt_t; + + + +typedef __fsblkcnt_t fsblkcnt_t; + + + +typedef __fsfilcnt_t fsfilcnt_t; +# 227 "/usr/include/sys/types.h" 3 4 +# 1 "/usr/include/bits/pthreadtypes.h" 1 3 4 +# 23 "/usr/include/bits/pthreadtypes.h" 3 4 +# 1 "/usr/include/bits/thread-shared-types.h" 1 3 4 +# 77 "/usr/include/bits/thread-shared-types.h" 3 4 +# 1 "/usr/include/bits/pthreadtypes-arch.h" 1 3 4 +# 21 "/usr/include/bits/pthreadtypes-arch.h" 3 4 +# 1 "/usr/include/bits/wordsize.h" 1 3 4 +# 22 "/usr/include/bits/pthreadtypes-arch.h" 2 3 4 +# 65 "/usr/include/bits/pthreadtypes-arch.h" 3 4 +struct __pthread_rwlock_arch_t +{ + unsigned int __readers; + unsigned int __writers; + unsigned int __wrphase_futex; + unsigned int __writers_futex; + unsigned int __pad3; + unsigned int __pad4; + + int __cur_writer; + int __shared; + signed char __rwelision; + + + + + unsigned char __pad1[7]; + + + unsigned long int __pad2; + + + unsigned int __flags; +# 99 "/usr/include/bits/pthreadtypes-arch.h" 3 4 +}; +# 78 "/usr/include/bits/thread-shared-types.h" 2 3 4 + + + + +typedef struct __pthread_internal_list +{ + struct __pthread_internal_list *__prev; + struct __pthread_internal_list *__next; +} __pthread_list_t; +# 118 "/usr/include/bits/thread-shared-types.h" 3 4 +struct __pthread_mutex_s +{ + int __lock ; + unsigned int __count; + int __owner; + + unsigned int __nusers; +# 148 "/usr/include/bits/thread-shared-types.h" 3 4 + int __kind; + + + + + + short __spins; short __elision; + __pthread_list_t __list; +# 165 "/usr/include/bits/thread-shared-types.h" 3 4 + +}; + + + + +struct __pthread_cond_s +{ + __extension__ union + { + __extension__ unsigned long long int __wseq; + struct + { + unsigned int __low; + unsigned int __high; + } __wseq32; + }; + __extension__ union + { + __extension__ unsigned long long int __g1_start; + struct + { + unsigned int __low; + unsigned int __high; + } __g1_start32; + }; + unsigned int __g_refs[2] ; + unsigned int __g_size[2]; + unsigned int __g1_orig_size; + unsigned int __wrefs; + unsigned int __g_signals[2]; +}; +# 24 "/usr/include/bits/pthreadtypes.h" 2 3 4 + + + +typedef unsigned long int pthread_t; + + + + +typedef union +{ + char __size[4]; + int __align; +} pthread_mutexattr_t; + + + + +typedef union +{ + char __size[4]; + int __align; +} pthread_condattr_t; + + + +typedef unsigned int pthread_key_t; + + + +typedef int pthread_once_t; + + +union pthread_attr_t +{ + char __size[56]; + long int __align; +}; + +typedef union pthread_attr_t pthread_attr_t; + + + + +typedef union +{ + struct __pthread_mutex_s __data; + char __size[40]; + long int __align; +} pthread_mutex_t; + + +typedef union +{ + struct __pthread_cond_s __data; + char __size[48]; + __extension__ long long int __align; +} pthread_cond_t; + + + + + +typedef union +{ + struct __pthread_rwlock_arch_t __data; + char __size[56]; + long int __align; +} pthread_rwlock_t; + +typedef union +{ + char __size[8]; + long int __align; +} pthread_rwlockattr_t; + + + + + +typedef volatile int pthread_spinlock_t; + + + + +typedef union +{ + char __size[32]; + long int __align; +} pthread_barrier_t; + +typedef union +{ + char __size[4]; + int __align; +} pthread_barrierattr_t; +# 228 "/usr/include/sys/types.h" 2 3 4 + + + +# 395 "/usr/include/stdlib.h" 2 3 4 + + + + + + +extern long int random (void) __attribute__ ((__nothrow__ , __leaf__)); + + +extern void srandom (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__)); + + + + + +extern char *initstate (unsigned int __seed, char *__statebuf, + size_t __statelen) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); + + + +extern char *setstate (char *__statebuf) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + + + + +struct random_data + { + int32_t *fptr; + int32_t *rptr; + int32_t *state; + int rand_type; + int rand_deg; + int rand_sep; + int32_t *end_ptr; + }; + +extern int random_r (struct random_data *__restrict __buf, + int32_t *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + +extern int srandom_r (unsigned int __seed, struct random_data *__buf) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); + +extern int initstate_r (unsigned int __seed, char *__restrict __statebuf, + size_t __statelen, + struct random_data *__restrict __buf) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4))); + +extern int setstate_r (char *__restrict __statebuf, + struct random_data *__restrict __buf) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + + + + +extern int rand (void) __attribute__ ((__nothrow__ , __leaf__)); + +extern void srand (unsigned int __seed) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int rand_r (unsigned int *__seed) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + +extern double drand48 (void) __attribute__ ((__nothrow__ , __leaf__)); +extern double erand48 (unsigned short int __xsubi[3]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + +extern long int lrand48 (void) __attribute__ ((__nothrow__ , __leaf__)); +extern long int nrand48 (unsigned short int __xsubi[3]) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + +extern long int mrand48 (void) __attribute__ ((__nothrow__ , __leaf__)); +extern long int jrand48 (unsigned short int __xsubi[3]) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + +extern void srand48 (long int __seedval) __attribute__ ((__nothrow__ , __leaf__)); +extern unsigned short int *seed48 (unsigned short int __seed16v[3]) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); +extern void lcong48 (unsigned short int __param[7]) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + + +struct drand48_data + { + unsigned short int __x[3]; + unsigned short int __old_x[3]; + unsigned short int __c; + unsigned short int __init; + __extension__ unsigned long long int __a; + + }; + + +extern int drand48_r (struct drand48_data *__restrict __buffer, + double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); +extern int erand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + double *__restrict __result) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern int lrand48_r (struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); +extern int nrand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern int mrand48_r (struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); +extern int jrand48_r (unsigned short int __xsubi[3], + struct drand48_data *__restrict __buffer, + long int *__restrict __result) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern int srand48_r (long int __seedval, struct drand48_data *__buffer) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); + +extern int seed48_r (unsigned short int __seed16v[3], + struct drand48_data *__buffer) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + +extern int lcong48_r (unsigned short int __param[7], + struct drand48_data *__buffer) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + + + +extern void *malloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; + +extern void *calloc (size_t __nmemb, size_t __size) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; + + + + + + +extern void *realloc (void *__ptr, size_t __size) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)); + + + + + + + +extern void *reallocarray (void *__ptr, size_t __nmemb, size_t __size) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__warn_unused_result__)); + + + +extern void free (void *__ptr) __attribute__ ((__nothrow__ , __leaf__)); + + +# 1 "/usr/include/alloca.h" 1 3 4 +# 24 "/usr/include/alloca.h" 3 4 +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 1 3 4 +# 25 "/usr/include/alloca.h" 2 3 4 + + + + + + + +extern void *alloca (size_t __size) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +# 567 "/usr/include/stdlib.h" 2 3 4 + + + + + +extern void *valloc (size_t __size) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; + + + + +extern int posix_memalign (void **__memptr, size_t __alignment, size_t __size) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; + + + + +extern void *aligned_alloc (size_t __alignment, size_t __size) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__alloc_size__ (2))) ; + + + +extern void abort (void) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); + + + +extern int atexit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + + + + +extern int at_quick_exit (void (*__func) (void)) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + + + +extern int on_exit (void (*__func) (int __status, void *__arg), void *__arg) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + + +extern void exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); + + + + + +extern void quick_exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); + + + + + +extern void _Exit (int __status) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__noreturn__)); + + + + +extern char *getenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; +# 644 "/usr/include/stdlib.h" 3 4 +extern int putenv (char *__string) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + + +extern int setenv (const char *__name, const char *__value, int __replace) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); + + +extern int unsetenv (const char *__name) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + + + + +extern int clearenv (void) __attribute__ ((__nothrow__ , __leaf__)); +# 672 "/usr/include/stdlib.h" 3 4 +extern char *mktemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); +# 685 "/usr/include/stdlib.h" 3 4 +extern int mkstemp (char *__template) __attribute__ ((__nonnull__ (1))) ; +# 707 "/usr/include/stdlib.h" 3 4 +extern int mkstemps (char *__template, int __suffixlen) __attribute__ ((__nonnull__ (1))) ; +# 728 "/usr/include/stdlib.h" 3 4 +extern char *mkdtemp (char *__template) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; +# 781 "/usr/include/stdlib.h" 3 4 +extern int system (const char *__command) ; +# 797 "/usr/include/stdlib.h" 3 4 +extern char *realpath (const char *__restrict __name, + char *__restrict __resolved) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + + + +typedef int (*__compar_fn_t) (const void *, const void *); +# 817 "/usr/include/stdlib.h" 3 4 +extern void *bsearch (const void *__key, const void *__base, + size_t __nmemb, size_t __size, __compar_fn_t __compar) + __attribute__ ((__nonnull__ (1, 2, 5))) ; + + + + + + + +extern void qsort (void *__base, size_t __nmemb, size_t __size, + __compar_fn_t __compar) __attribute__ ((__nonnull__ (1, 4))); +# 837 "/usr/include/stdlib.h" 3 4 +extern int abs (int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; +extern long int labs (long int __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; + + +__extension__ extern long long int llabs (long long int __x) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; + + + + + + +extern div_t div (int __numer, int __denom) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; +extern ldiv_t ldiv (long int __numer, long int __denom) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; + + +__extension__ extern lldiv_t lldiv (long long int __numer, + long long int __denom) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)) ; +# 869 "/usr/include/stdlib.h" 3 4 +extern char *ecvt (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; + + + + +extern char *fcvt (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; + + + + +extern char *gcvt (double __value, int __ndigit, char *__buf) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ; + + + + +extern char *qecvt (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; +extern char *qfcvt (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4))) ; +extern char *qgcvt (long double __value, int __ndigit, char *__buf) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3))) ; + + + + +extern int ecvt_r (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign, char *__restrict __buf, + size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); +extern int fcvt_r (double __value, int __ndigit, int *__restrict __decpt, + int *__restrict __sign, char *__restrict __buf, + size_t __len) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); + +extern int qecvt_r (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign, + char *__restrict __buf, size_t __len) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); +extern int qfcvt_r (long double __value, int __ndigit, + int *__restrict __decpt, int *__restrict __sign, + char *__restrict __buf, size_t __len) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (3, 4, 5))); + + + + + +extern int mblen (const char *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); + + +extern int mbtowc (wchar_t *__restrict __pwc, + const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); + + +extern int wctomb (char *__s, wchar_t __wchar) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern size_t mbstowcs (wchar_t *__restrict __pwcs, + const char *__restrict __s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); + +extern size_t wcstombs (char *__restrict __s, + const wchar_t *__restrict __pwcs, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + +extern int rpmatch (const char *__response) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))) ; +# 954 "/usr/include/stdlib.h" 3 4 +extern int getsubopt (char **__restrict __optionp, + char *const *__restrict __tokens, + char **__restrict __valuep) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2, 3))) ; +# 1000 "/usr/include/stdlib.h" 3 4 +extern int getloadavg (double __loadavg[], int __nelem) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); +# 1010 "/usr/include/stdlib.h" 3 4 +# 1 "/usr/include/bits/stdlib-float.h" 1 3 4 +# 1011 "/usr/include/stdlib.h" 2 3 4 +# 1020 "/usr/include/stdlib.h" 3 4 + +# 2 "scope.c" 2 +# 1 "/usr/include/string.h" 1 3 4 +# 26 "/usr/include/string.h" 3 4 +# 1 "/usr/include/bits/libc-header-start.h" 1 3 4 +# 27 "/usr/include/string.h" 2 3 4 + + + + + + +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 1 3 4 +# 34 "/usr/include/string.h" 2 3 4 +# 42 "/usr/include/string.h" 3 4 +extern void *memcpy (void *__restrict __dest, const void *__restrict __src, + size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern void *memmove (void *__dest, const void *__src, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + + + + +extern void *memccpy (void *__restrict __dest, const void *__restrict __src, + int __c, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + + + +extern void *memset (void *__s, int __c, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + +extern int memcmp (const void *__s1, const void *__s2, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); +# 90 "/usr/include/string.h" 3 4 +extern void *memchr (const void *__s, int __c, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); +# 121 "/usr/include/string.h" 3 4 +extern char *strcpy (char *__restrict __dest, const char *__restrict __src) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + +extern char *strncpy (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern char *strcat (char *__restrict __dest, const char *__restrict __src) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + +extern char *strncat (char *__restrict __dest, const char *__restrict __src, + size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern int strcmp (const char *__s1, const char *__s2) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + +extern int strncmp (const char *__s1, const char *__s2, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern int strcoll (const char *__s1, const char *__s2) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + +extern size_t strxfrm (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); + + + +# 1 "/usr/include/bits/types/locale_t.h" 1 3 4 +# 22 "/usr/include/bits/types/locale_t.h" 3 4 +# 1 "/usr/include/bits/types/__locale_t.h" 1 3 4 +# 28 "/usr/include/bits/types/__locale_t.h" 3 4 +struct __locale_struct +{ + + struct __locale_data *__locales[13]; + + + const unsigned short int *__ctype_b; + const int *__ctype_tolower; + const int *__ctype_toupper; + + + const char *__names[13]; +}; + +typedef struct __locale_struct *__locale_t; +# 23 "/usr/include/bits/types/locale_t.h" 2 3 4 + +typedef __locale_t locale_t; +# 153 "/usr/include/string.h" 2 3 4 + + +extern int strcoll_l (const char *__s1, const char *__s2, locale_t __l) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); + + +extern size_t strxfrm_l (char *__dest, const char *__src, size_t __n, + locale_t __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 4))); + + + + + +extern char *strdup (const char *__s) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); + + + + + + +extern char *strndup (const char *__string, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) __attribute__ ((__nonnull__ (1))); +# 225 "/usr/include/string.h" 3 4 +extern char *strchr (const char *__s, int __c) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); +# 252 "/usr/include/string.h" 3 4 +extern char *strrchr (const char *__s, int __c) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); +# 272 "/usr/include/string.h" 3 4 +extern size_t strcspn (const char *__s, const char *__reject) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern size_t strspn (const char *__s, const char *__accept) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); +# 302 "/usr/include/string.h" 3 4 +extern char *strpbrk (const char *__s, const char *__accept) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); +# 329 "/usr/include/string.h" 3 4 +extern char *strstr (const char *__haystack, const char *__needle) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + + + + +extern char *strtok (char *__restrict __s, const char *__restrict __delim) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); + + + +extern char *__strtok_r (char *__restrict __s, + const char *__restrict __delim, + char **__restrict __save_ptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3))); + +extern char *strtok_r (char *__restrict __s, const char *__restrict __delim, + char **__restrict __save_ptr) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2, 3))); +# 384 "/usr/include/string.h" 3 4 +extern size_t strlen (const char *__s) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); + + + + +extern size_t strnlen (const char *__string, size_t __maxlen) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); + + + + +extern char *strerror (int __errnum) __attribute__ ((__nothrow__ , __leaf__)); +# 409 "/usr/include/string.h" 3 4 +extern int strerror_r (int __errnum, char *__buf, size_t __buflen) __asm__ ("" "__xpg_strerror_r") __attribute__ ((__nothrow__ , __leaf__)) + + __attribute__ ((__nonnull__ (2))); +# 427 "/usr/include/string.h" 3 4 +extern char *strerror_l (int __errnum, locale_t __l) __attribute__ ((__nothrow__ , __leaf__)); + + + +# 1 "/usr/include/strings.h" 1 3 4 +# 23 "/usr/include/strings.h" 3 4 +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 1 3 4 +# 24 "/usr/include/strings.h" 2 3 4 + + + + + + + + + + +extern int bcmp (const void *__s1, const void *__s2, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern void bcopy (const void *__src, void *__dest, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern void bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); +# 68 "/usr/include/strings.h" 3 4 +extern char *index (const char *__s, int __c) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); +# 96 "/usr/include/strings.h" 3 4 +extern char *rindex (const char *__s, int __c) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1))); + + + + + + +extern int ffs (int __i) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + + +extern int ffsl (long int __l) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); +__extension__ extern int ffsll (long long int __ll) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + +extern int strcasecmp (const char *__s1, const char *__s2) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + + +extern int strncasecmp (const char *__s1, const char *__s2, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2))); + + + + + + +extern int strcasecmp_l (const char *__s1, const char *__s2, locale_t __loc) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 3))); + + + +extern int strncasecmp_l (const char *__s1, const char *__s2, + size_t __n, locale_t __loc) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__pure__)) __attribute__ ((__nonnull__ (1, 2, 4))); + + + +# 432 "/usr/include/string.h" 2 3 4 + + + +extern void explicit_bzero (void *__s, size_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1))); + + + +extern char *strsep (char **__restrict __stringp, + const char *__restrict __delim) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + + + +extern char *strsignal (int __sig) __attribute__ ((__nothrow__ , __leaf__)); + + +extern char *__stpcpy (char *__restrict __dest, const char *__restrict __src) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); +extern char *stpcpy (char *__restrict __dest, const char *__restrict __src) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); + + + +extern char *__stpncpy (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); +extern char *stpncpy (char *__restrict __dest, + const char *__restrict __src, size_t __n) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (1, 2))); +# 498 "/usr/include/string.h" 3 4 + +# 3 "scope.c" 2 + +# 1 "scope.h" 1 + + + +# 1 "/usr/include/llvm-c/Core.h" 1 3 4 +# 18 "/usr/include/llvm-c/Core.h" 3 4 +# 1 "/usr/include/llvm-c/ErrorHandling.h" 1 3 4 +# 21 "/usr/include/llvm-c/ErrorHandling.h" 3 4 +typedef void (*LLVMFatalErrorHandler)(const char *Reason); +# 30 "/usr/include/llvm-c/ErrorHandling.h" 3 4 +void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); + + + + + +void LLVMResetFatalErrorHandler(void); + + + + + + +void LLVMEnablePrettyStackTrace(void); +# 19 "/usr/include/llvm-c/Core.h" 2 3 4 +# 1 "/usr/include/llvm-c/Types.h" 1 3 4 +# 17 "/usr/include/llvm-c/Types.h" 3 4 +# 1 "/usr/include/llvm-c/DataTypes.h" 1 3 4 +# 30 "/usr/include/llvm-c/DataTypes.h" 3 4 +# 1 "/usr/include/math.h" 1 3 4 +# 27 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/libc-header-start.h" 1 3 4 +# 28 "/usr/include/math.h" 2 3 4 + + + + + + + + + + + + +# 1 "/usr/include/bits/math-vector.h" 1 3 4 +# 25 "/usr/include/bits/math-vector.h" 3 4 +# 1 "/usr/include/bits/libm-simd-decl-stubs.h" 1 3 4 +# 26 "/usr/include/bits/math-vector.h" 2 3 4 +# 41 "/usr/include/math.h" 2 3 4 +# 138 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/flt-eval-method.h" 1 3 4 +# 139 "/usr/include/math.h" 2 3 4 +# 149 "/usr/include/math.h" 3 4 +typedef float float_t; +typedef double double_t; +# 190 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/fp-logb.h" 1 3 4 +# 191 "/usr/include/math.h" 2 3 4 +# 233 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/fp-fast.h" 1 3 4 +# 234 "/usr/include/math.h" 2 3 4 +# 289 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/mathcalls-helper-functions.h" 1 3 4 +# 21 "/usr/include/bits/mathcalls-helper-functions.h" 3 4 +extern int __fpclassify (double __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + +extern int __signbit (double __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + + +extern int __isinf (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __finite (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __isnan (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __iseqsig (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern int __issignaling (double __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); +# 290 "/usr/include/math.h" 2 3 4 +# 1 "/usr/include/bits/mathcalls.h" 1 3 4 +# 53 "/usr/include/bits/mathcalls.h" 3 4 +extern double acos (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __acos (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double asin (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __asin (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double atan (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __atan (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double atan2 (double __y, double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __atan2 (double __y, double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + extern double cos (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __cos (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + extern double sin (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __sin (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double tan (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __tan (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern double cosh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __cosh (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double sinh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __sinh (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double tanh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __tanh (double __x) __attribute__ ((__nothrow__ , __leaf__)); +# 85 "/usr/include/bits/mathcalls.h" 3 4 +extern double acosh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __acosh (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double asinh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __asinh (double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern double atanh (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __atanh (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + extern double exp (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __exp (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double frexp (double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); extern double __frexp (double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double ldexp (double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); extern double __ldexp (double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); + + + extern double log (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __log (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double log10 (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __log10 (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double modf (double __x, double *__iptr) __attribute__ ((__nothrow__ , __leaf__)); extern double __modf (double __x, double *__iptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); +# 119 "/usr/include/bits/mathcalls.h" 3 4 +extern double expm1 (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __expm1 (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double log1p (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __log1p (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double logb (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __logb (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern double exp2 (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __exp2 (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double log2 (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __log2 (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + extern double pow (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __pow (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double sqrt (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __sqrt (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern double hypot (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __hypot (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern double cbrt (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __cbrt (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern double ceil (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __ceil (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern double fabs (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __fabs (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern double floor (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __floor (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern double fmod (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __fmod (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); +# 177 "/usr/include/bits/mathcalls.h" 3 4 +extern int isinf (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern int finite (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern double drem (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __drem (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern double significand (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __significand (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern double copysign (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __copysign (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern double nan (const char *__tagb) __attribute__ ((__nothrow__ , __leaf__)); extern double __nan (const char *__tagb) __attribute__ ((__nothrow__ , __leaf__)); +# 211 "/usr/include/bits/mathcalls.h" 3 4 +extern int isnan (double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + + +extern double j0 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __j0 (double) __attribute__ ((__nothrow__ , __leaf__)); +extern double j1 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __j1 (double) __attribute__ ((__nothrow__ , __leaf__)); +extern double jn (int, double) __attribute__ ((__nothrow__ , __leaf__)); extern double __jn (int, double) __attribute__ ((__nothrow__ , __leaf__)); +extern double y0 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __y0 (double) __attribute__ ((__nothrow__ , __leaf__)); +extern double y1 (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __y1 (double) __attribute__ ((__nothrow__ , __leaf__)); +extern double yn (int, double) __attribute__ ((__nothrow__ , __leaf__)); extern double __yn (int, double) __attribute__ ((__nothrow__ , __leaf__)); + + + + + +extern double erf (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __erf (double) __attribute__ ((__nothrow__ , __leaf__)); +extern double erfc (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __erfc (double) __attribute__ ((__nothrow__ , __leaf__)); +extern double lgamma (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __lgamma (double) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern double tgamma (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __tgamma (double) __attribute__ ((__nothrow__ , __leaf__)); + + + + + +extern double gamma (double) __attribute__ ((__nothrow__ , __leaf__)); extern double __gamma (double) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + +extern double lgamma_r (double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); extern double __lgamma_r (double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern double rint (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __rint (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double nextafter (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __nextafter (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); + +extern double nexttoward (double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __nexttoward (double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); +# 272 "/usr/include/bits/mathcalls.h" 3 4 +extern double remainder (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __remainder (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern double scalbn (double __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); extern double __scalbn (double __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int ilogb (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern int __ilogb (double __x) __attribute__ ((__nothrow__ , __leaf__)); +# 290 "/usr/include/bits/mathcalls.h" 3 4 +extern double scalbln (double __x, long int __n) __attribute__ ((__nothrow__ , __leaf__)); extern double __scalbln (double __x, long int __n) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern double nearbyint (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern double __nearbyint (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern double round (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __round (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + +extern double trunc (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __trunc (double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern double remquo (double __x, double __y, int *__quo) __attribute__ ((__nothrow__ , __leaf__)); extern double __remquo (double __x, double __y, int *__quo) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern long int lrint (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long int __lrint (double __x) __attribute__ ((__nothrow__ , __leaf__)); +__extension__ +extern long long int llrint (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long long int __llrint (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long int lround (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long int __lround (double __x) __attribute__ ((__nothrow__ , __leaf__)); +__extension__ +extern long long int llround (double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long long int __llround (double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern double fdim (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); extern double __fdim (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern double fmax (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __fmax (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern double fmin (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern double __fmin (double __x, double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern double fma (double __x, double __y, double __z) __attribute__ ((__nothrow__ , __leaf__)); extern double __fma (double __x, double __y, double __z) __attribute__ ((__nothrow__ , __leaf__)); +# 396 "/usr/include/bits/mathcalls.h" 3 4 +extern double scalb (double __x, double __n) __attribute__ ((__nothrow__ , __leaf__)); extern double __scalb (double __x, double __n) __attribute__ ((__nothrow__ , __leaf__)); +# 291 "/usr/include/math.h" 2 3 4 +# 306 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/mathcalls-helper-functions.h" 1 3 4 +# 21 "/usr/include/bits/mathcalls-helper-functions.h" 3 4 +extern int __fpclassifyf (float __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + +extern int __signbitf (float __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + + +extern int __isinff (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __finitef (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __isnanf (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __iseqsigf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern int __issignalingf (float __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); +# 307 "/usr/include/math.h" 2 3 4 +# 1 "/usr/include/bits/mathcalls.h" 1 3 4 +# 53 "/usr/include/bits/mathcalls.h" 3 4 +extern float acosf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __acosf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float asinf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __asinf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float atanf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __atanf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float atan2f (float __y, float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __atan2f (float __y, float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + extern float cosf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __cosf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + extern float sinf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __sinf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float tanf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __tanf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern float coshf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __coshf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float sinhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __sinhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float tanhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __tanhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); +# 85 "/usr/include/bits/mathcalls.h" 3 4 +extern float acoshf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __acoshf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float asinhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __asinhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern float atanhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __atanhf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + extern float expf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __expf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float frexpf (float __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); extern float __frexpf (float __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float ldexpf (float __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); extern float __ldexpf (float __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); + + + extern float logf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __logf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float log10f (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __log10f (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float modff (float __x, float *__iptr) __attribute__ ((__nothrow__ , __leaf__)); extern float __modff (float __x, float *__iptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); +# 119 "/usr/include/bits/mathcalls.h" 3 4 +extern float expm1f (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __expm1f (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float log1pf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __log1pf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float logbf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __logbf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern float exp2f (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __exp2f (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float log2f (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __log2f (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + extern float powf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __powf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float sqrtf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __sqrtf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern float hypotf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __hypotf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern float cbrtf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __cbrtf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern float ceilf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __ceilf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern float fabsf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __fabsf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern float floorf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __floorf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern float fmodf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __fmodf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); +# 177 "/usr/include/bits/mathcalls.h" 3 4 +extern int isinff (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern int finitef (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern float dremf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __dremf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern float significandf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __significandf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern float copysignf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __copysignf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern float nanf (const char *__tagb) __attribute__ ((__nothrow__ , __leaf__)); extern float __nanf (const char *__tagb) __attribute__ ((__nothrow__ , __leaf__)); +# 211 "/usr/include/bits/mathcalls.h" 3 4 +extern int isnanf (float __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + + +extern float j0f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __j0f (float) __attribute__ ((__nothrow__ , __leaf__)); +extern float j1f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __j1f (float) __attribute__ ((__nothrow__ , __leaf__)); +extern float jnf (int, float) __attribute__ ((__nothrow__ , __leaf__)); extern float __jnf (int, float) __attribute__ ((__nothrow__ , __leaf__)); +extern float y0f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __y0f (float) __attribute__ ((__nothrow__ , __leaf__)); +extern float y1f (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __y1f (float) __attribute__ ((__nothrow__ , __leaf__)); +extern float ynf (int, float) __attribute__ ((__nothrow__ , __leaf__)); extern float __ynf (int, float) __attribute__ ((__nothrow__ , __leaf__)); + + + + + +extern float erff (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __erff (float) __attribute__ ((__nothrow__ , __leaf__)); +extern float erfcf (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __erfcf (float) __attribute__ ((__nothrow__ , __leaf__)); +extern float lgammaf (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __lgammaf (float) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern float tgammaf (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __tgammaf (float) __attribute__ ((__nothrow__ , __leaf__)); + + + + + +extern float gammaf (float) __attribute__ ((__nothrow__ , __leaf__)); extern float __gammaf (float) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + +extern float lgammaf_r (float, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); extern float __lgammaf_r (float, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern float rintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __rintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float nextafterf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __nextafterf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); + +extern float nexttowardf (float __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __nexttowardf (float __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); +# 272 "/usr/include/bits/mathcalls.h" 3 4 +extern float remainderf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __remainderf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern float scalbnf (float __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); extern float __scalbnf (float __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int ilogbf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern int __ilogbf (float __x) __attribute__ ((__nothrow__ , __leaf__)); +# 290 "/usr/include/bits/mathcalls.h" 3 4 +extern float scalblnf (float __x, long int __n) __attribute__ ((__nothrow__ , __leaf__)); extern float __scalblnf (float __x, long int __n) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern float nearbyintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern float __nearbyintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern float roundf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __roundf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + +extern float truncf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __truncf (float __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern float remquof (float __x, float __y, int *__quo) __attribute__ ((__nothrow__ , __leaf__)); extern float __remquof (float __x, float __y, int *__quo) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern long int lrintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern long int __lrintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); +__extension__ +extern long long int llrintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern long long int __llrintf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long int lroundf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern long int __lroundf (float __x) __attribute__ ((__nothrow__ , __leaf__)); +__extension__ +extern long long int llroundf (float __x) __attribute__ ((__nothrow__ , __leaf__)); extern long long int __llroundf (float __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern float fdimf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); extern float __fdimf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern float fmaxf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __fmaxf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern float fminf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern float __fminf (float __x, float __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern float fmaf (float __x, float __y, float __z) __attribute__ ((__nothrow__ , __leaf__)); extern float __fmaf (float __x, float __y, float __z) __attribute__ ((__nothrow__ , __leaf__)); +# 396 "/usr/include/bits/mathcalls.h" 3 4 +extern float scalbf (float __x, float __n) __attribute__ ((__nothrow__ , __leaf__)); extern float __scalbf (float __x, float __n) __attribute__ ((__nothrow__ , __leaf__)); +# 308 "/usr/include/math.h" 2 3 4 +# 349 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/mathcalls-helper-functions.h" 1 3 4 +# 21 "/usr/include/bits/mathcalls-helper-functions.h" 3 4 +extern int __fpclassifyl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + +extern int __signbitl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + + +extern int __isinfl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __finitel (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __isnanl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __iseqsigl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern int __issignalingl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); +# 350 "/usr/include/math.h" 2 3 4 +# 1 "/usr/include/bits/mathcalls.h" 1 3 4 +# 53 "/usr/include/bits/mathcalls.h" 3 4 +extern long double acosl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __acosl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double asinl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __asinl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double atanl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __atanl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double atan2l (long double __y, long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __atan2l (long double __y, long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + extern long double cosl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __cosl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + extern long double sinl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __sinl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double tanl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __tanl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern long double coshl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __coshl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double sinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __sinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double tanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __tanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); +# 85 "/usr/include/bits/mathcalls.h" 3 4 +extern long double acoshl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __acoshl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double asinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __asinhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double atanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __atanhl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + extern long double expl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __expl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double frexpl (long double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); extern long double __frexpl (long double __x, int *__exponent) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double ldexpl (long double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); extern long double __ldexpl (long double __x, int __exponent) __attribute__ ((__nothrow__ , __leaf__)); + + + extern long double logl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __logl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double log10l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __log10l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double modfl (long double __x, long double *__iptr) __attribute__ ((__nothrow__ , __leaf__)); extern long double __modfl (long double __x, long double *__iptr) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__nonnull__ (2))); +# 119 "/usr/include/bits/mathcalls.h" 3 4 +extern long double expm1l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __expm1l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double log1pl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __log1pl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double logbl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __logbl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern long double exp2l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __exp2l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double log2l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __log2l (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + extern long double powl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __powl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double sqrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __sqrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long double hypotl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __hypotl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern long double cbrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __cbrtl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern long double ceill (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __ceill (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern long double fabsl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __fabsl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern long double floorl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __floorl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern long double fmodl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __fmodl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); +# 177 "/usr/include/bits/mathcalls.h" 3 4 +extern int isinfl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern int finitel (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern long double dreml (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __dreml (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long double significandl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __significandl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern long double copysignl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __copysignl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern long double nanl (const char *__tagb) __attribute__ ((__nothrow__ , __leaf__)); extern long double __nanl (const char *__tagb) __attribute__ ((__nothrow__ , __leaf__)); +# 211 "/usr/include/bits/mathcalls.h" 3 4 +extern int isnanl (long double __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + + +extern long double j0l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __j0l (long double) __attribute__ ((__nothrow__ , __leaf__)); +extern long double j1l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __j1l (long double) __attribute__ ((__nothrow__ , __leaf__)); +extern long double jnl (int, long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __jnl (int, long double) __attribute__ ((__nothrow__ , __leaf__)); +extern long double y0l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __y0l (long double) __attribute__ ((__nothrow__ , __leaf__)); +extern long double y1l (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __y1l (long double) __attribute__ ((__nothrow__ , __leaf__)); +extern long double ynl (int, long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __ynl (int, long double) __attribute__ ((__nothrow__ , __leaf__)); + + + + + +extern long double erfl (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __erfl (long double) __attribute__ ((__nothrow__ , __leaf__)); +extern long double erfcl (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __erfcl (long double) __attribute__ ((__nothrow__ , __leaf__)); +extern long double lgammal (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __lgammal (long double) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern long double tgammal (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __tgammal (long double) __attribute__ ((__nothrow__ , __leaf__)); + + + + + +extern long double gammal (long double) __attribute__ ((__nothrow__ , __leaf__)); extern long double __gammal (long double) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + +extern long double lgammal_r (long double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); extern long double __lgammal_r (long double, int *__signgamp) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern long double rintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __rintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double nextafterl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __nextafterl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); + +extern long double nexttowardl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __nexttowardl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); +# 272 "/usr/include/bits/mathcalls.h" 3 4 +extern long double remainderl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __remainderl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long double scalbnl (long double __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); extern long double __scalbnl (long double __x, int __n) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int ilogbl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern int __ilogbl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); +# 290 "/usr/include/bits/mathcalls.h" 3 4 +extern long double scalblnl (long double __x, long int __n) __attribute__ ((__nothrow__ , __leaf__)); extern long double __scalblnl (long double __x, long int __n) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long double nearbyintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long double __nearbyintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long double roundl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __roundl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + +extern long double truncl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __truncl (long double __x) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + + + +extern long double remquol (long double __x, long double __y, int *__quo) __attribute__ ((__nothrow__ , __leaf__)); extern long double __remquol (long double __x, long double __y, int *__quo) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern long int lrintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long int __lrintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); +__extension__ +extern long long int llrintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long long int __llrintl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long int lroundl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long int __lroundl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); +__extension__ +extern long long int llroundl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); extern long long int __llroundl (long double __x) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern long double fdiml (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); extern long double __fdiml (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern long double fmaxl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __fmaxl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern long double fminl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); extern long double __fminl (long double __x, long double __y) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern long double fmal (long double __x, long double __y, long double __z) __attribute__ ((__nothrow__ , __leaf__)); extern long double __fmal (long double __x, long double __y, long double __z) __attribute__ ((__nothrow__ , __leaf__)); +# 396 "/usr/include/bits/mathcalls.h" 3 4 +extern long double scalbl (long double __x, long double __n) __attribute__ ((__nothrow__ , __leaf__)); extern long double __scalbl (long double __x, long double __n) __attribute__ ((__nothrow__ , __leaf__)); +# 351 "/usr/include/math.h" 2 3 4 +# 420 "/usr/include/math.h" 3 4 +# 1 "/usr/include/bits/mathcalls-helper-functions.h" 1 3 4 +# 21 "/usr/include/bits/mathcalls-helper-functions.h" 3 4 +extern int __fpclassifyf128 (_Float128 __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + +extern int __signbitf128 (_Float128 __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); + + + +extern int __isinff128 (_Float128 __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __finitef128 (_Float128 __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __isnanf128 (_Float128 __value) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern int __iseqsigf128 (_Float128 __x, _Float128 __y) __attribute__ ((__nothrow__ , __leaf__)); + + +extern int __issignalingf128 (_Float128 __value) __attribute__ ((__nothrow__ , __leaf__)) + __attribute__ ((__const__)); +# 421 "/usr/include/math.h" 2 3 4 +# 773 "/usr/include/math.h" 3 4 +extern int signgam; +# 853 "/usr/include/math.h" 3 4 +enum + { + FP_NAN = + + 0, + FP_INFINITE = + + 1, + FP_ZERO = + + 2, + FP_SUBNORMAL = + + 3, + FP_NORMAL = + + 4 + }; +# 1553 "/usr/include/math.h" 3 4 + +# 31 "/usr/include/llvm-c/DataTypes.h" 2 3 4 + + +# 1 "/usr/include/inttypes.h" 1 3 4 +# 27 "/usr/include/inttypes.h" 3 4 +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stdint.h" 1 3 4 +# 9 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stdint.h" 3 4 +# 1 "/usr/include/stdint.h" 1 3 4 +# 26 "/usr/include/stdint.h" 3 4 +# 1 "/usr/include/bits/libc-header-start.h" 1 3 4 +# 27 "/usr/include/stdint.h" 2 3 4 + +# 1 "/usr/include/bits/wchar.h" 1 3 4 +# 29 "/usr/include/stdint.h" 2 3 4 +# 1 "/usr/include/bits/wordsize.h" 1 3 4 +# 30 "/usr/include/stdint.h" 2 3 4 + + + + + + + +# 1 "/usr/include/bits/stdint-uintn.h" 1 3 4 +# 24 "/usr/include/bits/stdint-uintn.h" 3 4 +typedef __uint8_t uint8_t; +typedef __uint16_t uint16_t; +typedef __uint32_t uint32_t; +typedef __uint64_t uint64_t; +# 38 "/usr/include/stdint.h" 2 3 4 + + + + + +typedef __int_least8_t int_least8_t; +typedef __int_least16_t int_least16_t; +typedef __int_least32_t int_least32_t; +typedef __int_least64_t int_least64_t; + + +typedef __uint_least8_t uint_least8_t; +typedef __uint_least16_t uint_least16_t; +typedef __uint_least32_t uint_least32_t; +typedef __uint_least64_t uint_least64_t; + + + + + +typedef signed char int_fast8_t; + +typedef long int int_fast16_t; +typedef long int int_fast32_t; +typedef long int int_fast64_t; +# 71 "/usr/include/stdint.h" 3 4 +typedef unsigned char uint_fast8_t; + +typedef unsigned long int uint_fast16_t; +typedef unsigned long int uint_fast32_t; +typedef unsigned long int uint_fast64_t; +# 87 "/usr/include/stdint.h" 3 4 +typedef long int intptr_t; + + +typedef unsigned long int uintptr_t; +# 101 "/usr/include/stdint.h" 3 4 +typedef __intmax_t intmax_t; +typedef __uintmax_t uintmax_t; +# 10 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stdint.h" 2 3 4 +# 28 "/usr/include/inttypes.h" 2 3 4 + + + + + + +typedef int __gwchar_t; +# 266 "/usr/include/inttypes.h" 3 4 + + + + + +typedef struct + { + long int quot; + long int rem; + } imaxdiv_t; +# 290 "/usr/include/inttypes.h" 3 4 +extern intmax_t imaxabs (intmax_t __n) __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern imaxdiv_t imaxdiv (intmax_t __numer, intmax_t __denom) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__const__)); + + +extern intmax_t strtoimax (const char *__restrict __nptr, + char **__restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)); + + +extern uintmax_t strtoumax (const char *__restrict __nptr, + char ** __restrict __endptr, int __base) __attribute__ ((__nothrow__ , __leaf__)); + + +extern intmax_t wcstoimax (const __gwchar_t *__restrict __nptr, + __gwchar_t **__restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)); + + +extern uintmax_t wcstoumax (const __gwchar_t *__restrict __nptr, + __gwchar_t ** __restrict __endptr, int __base) + __attribute__ ((__nothrow__ , __leaf__)); +# 432 "/usr/include/inttypes.h" 3 4 + +# 34 "/usr/include/llvm-c/DataTypes.h" 2 3 4 +# 18 "/usr/include/llvm-c/Types.h" 2 3 4 +# 29 "/usr/include/llvm-c/Types.h" 3 4 +typedef int LLVMBool; +# 49 "/usr/include/llvm-c/Types.h" 3 4 +typedef struct LLVMOpaqueMemoryBuffer *LLVMMemoryBufferRef; + + + + +typedef struct LLVMOpaqueContext *LLVMContextRef; + + + + + + + +typedef struct LLVMOpaqueModule *LLVMModuleRef; + + + + + + +typedef struct LLVMOpaqueType *LLVMTypeRef; + + + + + + +typedef struct LLVMOpaqueValue *LLVMValueRef; + + + + + + +typedef struct LLVMOpaqueBasicBlock *LLVMBasicBlockRef; + + + + + + +typedef struct LLVMOpaqueMetadata *LLVMMetadataRef; + + + + + + +typedef struct LLVMOpaqueNamedMDNode *LLVMNamedMDNodeRef; + + + + + + +typedef struct LLVMOpaqueValueMetadataEntry LLVMValueMetadataEntry; + + + + + + +typedef struct LLVMOpaqueBuilder *LLVMBuilderRef; + + + + + + +typedef struct LLVMOpaqueDIBuilder *LLVMDIBuilderRef; + + + + + + +typedef struct LLVMOpaqueModuleProvider *LLVMModuleProviderRef; + + +typedef struct LLVMOpaquePassManager *LLVMPassManagerRef; + + +typedef struct LLVMOpaquePassRegistry *LLVMPassRegistryRef; + + + + + +typedef struct LLVMOpaqueUse *LLVMUseRef; + + + + + + +typedef struct LLVMOpaqueAttributeRef *LLVMAttributeRef; + + + + +typedef struct LLVMOpaqueDiagnosticInfo *LLVMDiagnosticInfoRef; + + + + +typedef struct LLVMComdat *LLVMComdatRef; + + + + +typedef struct LLVMOpaqueModuleFlagEntry LLVMModuleFlagEntry; + + + + +typedef struct LLVMOpaqueJITEventListener *LLVMJITEventListenerRef; +# 20 "/usr/include/llvm-c/Core.h" 2 3 4 +# 59 "/usr/include/llvm-c/Core.h" 3 4 +typedef enum { + + LLVMRet = 1, + LLVMBr = 2, + LLVMSwitch = 3, + LLVMIndirectBr = 4, + LLVMInvoke = 5, + + LLVMUnreachable = 7, + + + LLVMFNeg = 66, + + + LLVMAdd = 8, + LLVMFAdd = 9, + LLVMSub = 10, + LLVMFSub = 11, + LLVMMul = 12, + LLVMFMul = 13, + LLVMUDiv = 14, + LLVMSDiv = 15, + LLVMFDiv = 16, + LLVMURem = 17, + LLVMSRem = 18, + LLVMFRem = 19, + + + LLVMShl = 20, + LLVMLShr = 21, + LLVMAShr = 22, + LLVMAnd = 23, + LLVMOr = 24, + LLVMXor = 25, + + + LLVMAlloca = 26, + LLVMLoad = 27, + LLVMStore = 28, + LLVMGetElementPtr = 29, + + + LLVMTrunc = 30, + LLVMZExt = 31, + LLVMSExt = 32, + LLVMFPToUI = 33, + LLVMFPToSI = 34, + LLVMUIToFP = 35, + LLVMSIToFP = 36, + LLVMFPTrunc = 37, + LLVMFPExt = 38, + LLVMPtrToInt = 39, + LLVMIntToPtr = 40, + LLVMBitCast = 41, + LLVMAddrSpaceCast = 60, + + + LLVMICmp = 42, + LLVMFCmp = 43, + LLVMPHI = 44, + LLVMCall = 45, + LLVMSelect = 46, + LLVMUserOp1 = 47, + LLVMUserOp2 = 48, + LLVMVAArg = 49, + LLVMExtractElement = 50, + LLVMInsertElement = 51, + LLVMShuffleVector = 52, + LLVMExtractValue = 53, + LLVMInsertValue = 54, + + + LLVMFence = 55, + LLVMAtomicCmpXchg = 56, + LLVMAtomicRMW = 57, + + + LLVMResume = 58, + LLVMLandingPad = 59, + LLVMCleanupRet = 61, + LLVMCatchRet = 62, + LLVMCatchPad = 63, + LLVMCleanupPad = 64, + LLVMCatchSwitch = 65 +} LLVMOpcode; + +typedef enum { + LLVMVoidTypeKind, + LLVMHalfTypeKind, + LLVMFloatTypeKind, + LLVMDoubleTypeKind, + LLVMX86_FP80TypeKind, + LLVMFP128TypeKind, + LLVMPPC_FP128TypeKind, + LLVMLabelTypeKind, + LLVMIntegerTypeKind, + LLVMFunctionTypeKind, + LLVMStructTypeKind, + LLVMArrayTypeKind, + LLVMPointerTypeKind, + LLVMVectorTypeKind, + LLVMMetadataTypeKind, + LLVMX86_MMXTypeKind, + LLVMTokenTypeKind +} LLVMTypeKind; + +typedef enum { + LLVMExternalLinkage, + LLVMAvailableExternallyLinkage, + LLVMLinkOnceAnyLinkage, + LLVMLinkOnceODRLinkage, + + LLVMLinkOnceODRAutoHideLinkage, + LLVMWeakAnyLinkage, + LLVMWeakODRLinkage, + + LLVMAppendingLinkage, + LLVMInternalLinkage, + + LLVMPrivateLinkage, + LLVMDLLImportLinkage, + LLVMDLLExportLinkage, + LLVMExternalWeakLinkage, + LLVMGhostLinkage, + LLVMCommonLinkage, + LLVMLinkerPrivateLinkage, + LLVMLinkerPrivateWeakLinkage +} LLVMLinkage; + +typedef enum { + LLVMDefaultVisibility, + LLVMHiddenVisibility, + LLVMProtectedVisibility +} LLVMVisibility; + +typedef enum { + LLVMNoUnnamedAddr, + LLVMLocalUnnamedAddr, + LLVMGlobalUnnamedAddr +} LLVMUnnamedAddr; + +typedef enum { + LLVMDefaultStorageClass = 0, + LLVMDLLImportStorageClass = 1, + LLVMDLLExportStorageClass = 2 +} LLVMDLLStorageClass; + +typedef enum { + LLVMCCallConv = 0, + LLVMFastCallConv = 8, + LLVMColdCallConv = 9, + LLVMGHCCallConv = 10, + LLVMHiPECallConv = 11, + LLVMWebKitJSCallConv = 12, + LLVMAnyRegCallConv = 13, + LLVMPreserveMostCallConv = 14, + LLVMPreserveAllCallConv = 15, + LLVMSwiftCallConv = 16, + LLVMCXXFASTTLSCallConv = 17, + LLVMX86StdcallCallConv = 64, + LLVMX86FastcallCallConv = 65, + LLVMARMAPCSCallConv = 66, + LLVMARMAAPCSCallConv = 67, + LLVMARMAAPCSVFPCallConv = 68, + LLVMMSP430INTRCallConv = 69, + LLVMX86ThisCallCallConv = 70, + LLVMPTXKernelCallConv = 71, + LLVMPTXDeviceCallConv = 72, + LLVMSPIRFUNCCallConv = 75, + LLVMSPIRKERNELCallConv = 76, + LLVMIntelOCLBICallConv = 77, + LLVMX8664SysVCallConv = 78, + LLVMWin64CallConv = 79, + LLVMX86VectorCallCallConv = 80, + LLVMHHVMCallConv = 81, + LLVMHHVMCCallConv = 82, + LLVMX86INTRCallConv = 83, + LLVMAVRINTRCallConv = 84, + LLVMAVRSIGNALCallConv = 85, + LLVMAVRBUILTINCallConv = 86, + LLVMAMDGPUVSCallConv = 87, + LLVMAMDGPUGSCallConv = 88, + LLVMAMDGPUPSCallConv = 89, + LLVMAMDGPUCSCallConv = 90, + LLVMAMDGPUKERNELCallConv = 91, + LLVMX86RegCallCallConv = 92, + LLVMAMDGPUHSCallConv = 93, + LLVMMSP430BUILTINCallConv = 94, + LLVMAMDGPULSCallConv = 95, + LLVMAMDGPUESCallConv = 96 +} LLVMCallConv; + +typedef enum { + LLVMArgumentValueKind, + LLVMBasicBlockValueKind, + LLVMMemoryUseValueKind, + LLVMMemoryDefValueKind, + LLVMMemoryPhiValueKind, + + LLVMFunctionValueKind, + LLVMGlobalAliasValueKind, + LLVMGlobalIFuncValueKind, + LLVMGlobalVariableValueKind, + LLVMBlockAddressValueKind, + LLVMConstantExprValueKind, + LLVMConstantArrayValueKind, + LLVMConstantStructValueKind, + LLVMConstantVectorValueKind, + + LLVMUndefValueValueKind, + LLVMConstantAggregateZeroValueKind, + LLVMConstantDataArrayValueKind, + LLVMConstantDataVectorValueKind, + LLVMConstantIntValueKind, + LLVMConstantFPValueKind, + LLVMConstantPointerNullValueKind, + LLVMConstantTokenNoneValueKind, + + LLVMMetadataAsValueValueKind, + LLVMInlineAsmValueKind, + + LLVMInstructionValueKind, +} LLVMValueKind; + +typedef enum { + LLVMIntEQ = 32, + LLVMIntNE, + LLVMIntUGT, + LLVMIntUGE, + LLVMIntULT, + LLVMIntULE, + LLVMIntSGT, + LLVMIntSGE, + LLVMIntSLT, + LLVMIntSLE +} LLVMIntPredicate; + +typedef enum { + LLVMRealPredicateFalse, + LLVMRealOEQ, + LLVMRealOGT, + LLVMRealOGE, + LLVMRealOLT, + LLVMRealOLE, + LLVMRealONE, + LLVMRealORD, + LLVMRealUNO, + LLVMRealUEQ, + LLVMRealUGT, + LLVMRealUGE, + LLVMRealULT, + LLVMRealULE, + LLVMRealUNE, + LLVMRealPredicateTrue +} LLVMRealPredicate; + +typedef enum { + LLVMLandingPadCatch, + LLVMLandingPadFilter +} LLVMLandingPadClauseTy; + +typedef enum { + LLVMNotThreadLocal = 0, + LLVMGeneralDynamicTLSModel, + LLVMLocalDynamicTLSModel, + LLVMInitialExecTLSModel, + LLVMLocalExecTLSModel +} LLVMThreadLocalMode; + +typedef enum { + LLVMAtomicOrderingNotAtomic = 0, + LLVMAtomicOrderingUnordered = 1, + + LLVMAtomicOrderingMonotonic = 2, + + + LLVMAtomicOrderingAcquire = 4, + + + LLVMAtomicOrderingRelease = 5, + + + LLVMAtomicOrderingAcquireRelease = 6, + + + + LLVMAtomicOrderingSequentiallyConsistent = 7 + + + + + + + +} LLVMAtomicOrdering; + +typedef enum { + LLVMAtomicRMWBinOpXchg, + LLVMAtomicRMWBinOpAdd, + LLVMAtomicRMWBinOpSub, + LLVMAtomicRMWBinOpAnd, + LLVMAtomicRMWBinOpNand, + LLVMAtomicRMWBinOpOr, + LLVMAtomicRMWBinOpXor, + LLVMAtomicRMWBinOpMax, + + + LLVMAtomicRMWBinOpMin, + + + LLVMAtomicRMWBinOpUMax, + + + LLVMAtomicRMWBinOpUMin + + +} LLVMAtomicRMWBinOp; + +typedef enum { + LLVMDSError, + LLVMDSWarning, + LLVMDSRemark, + LLVMDSNote +} LLVMDiagnosticSeverity; + +typedef enum { + LLVMInlineAsmDialectATT, + LLVMInlineAsmDialectIntel +} LLVMInlineAsmDialect; + +typedef enum { + + + + + + + LLVMModuleFlagBehaviorError, + + + + + + + LLVMModuleFlagBehaviorWarning, +# 415 "/usr/include/llvm-c/Core.h" 3 4 + LLVMModuleFlagBehaviorRequire, + + + + + + + + LLVMModuleFlagBehaviorOverride, + + + + + + LLVMModuleFlagBehaviorAppend, + + + + + + + + LLVMModuleFlagBehaviorAppendUnique, +} LLVMModuleFlagBehavior; + + + + + +enum { + LLVMAttributeReturnIndex = 0U, + + + + LLVMAttributeFunctionIndex = -1, +}; + +typedef unsigned LLVMAttributeIndex; + + + + + +void LLVMInitializeCore(LLVMPassRegistryRef R); + + + + +void LLVMShutdown(void); + + + +char *LLVMCreateMessage(const char *Message); +void LLVMDisposeMessage(char *Message); +# 482 "/usr/include/llvm-c/Core.h" 3 4 +typedef void (*LLVMDiagnosticHandler)(LLVMDiagnosticInfoRef, void *); +typedef void (*LLVMYieldCallback)(LLVMContextRef, void *); + + + + + + + +LLVMContextRef LLVMContextCreate(void); + + + + +LLVMContextRef LLVMGetGlobalContext(void); + + + + +void LLVMContextSetDiagnosticHandler(LLVMContextRef C, + LLVMDiagnosticHandler Handler, + void *DiagnosticContext); + + + + +LLVMDiagnosticHandler LLVMContextGetDiagnosticHandler(LLVMContextRef C); + + + + +void *LLVMContextGetDiagnosticContext(LLVMContextRef C); + + + + + + +void LLVMContextSetYieldCallback(LLVMContextRef C, LLVMYieldCallback Callback, + void *OpaqueHandle); + + + + + + +LLVMBool LLVMContextShouldDiscardValueNames(LLVMContextRef C); +# 538 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMContextSetDiscardValueNames(LLVMContextRef C, LLVMBool Discard); + + + + + + + +void LLVMContextDispose(LLVMContextRef C); + + + + + + + +char *LLVMGetDiagInfoDescription(LLVMDiagnosticInfoRef DI); + + + + + + +LLVMDiagnosticSeverity LLVMGetDiagInfoSeverity(LLVMDiagnosticInfoRef DI); + +unsigned LLVMGetMDKindIDInContext(LLVMContextRef C, const char *Name, + unsigned SLen); +unsigned LLVMGetMDKindID(const char *Name, unsigned SLen); +# 578 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetEnumAttributeKindForName(const char *Name, size_t SLen); +unsigned LLVMGetLastEnumAttributeKind(void); + + + + +LLVMAttributeRef LLVMCreateEnumAttribute(LLVMContextRef C, unsigned KindID, + uint64_t Val); + + + + + +unsigned LLVMGetEnumAttributeKind(LLVMAttributeRef A); + + + + +uint64_t LLVMGetEnumAttributeValue(LLVMAttributeRef A); + + + + +LLVMAttributeRef LLVMCreateStringAttribute(LLVMContextRef C, + const char *K, unsigned KLength, + const char *V, unsigned VLength); + + + + +const char *LLVMGetStringAttributeKind(LLVMAttributeRef A, unsigned *Length); + + + + +const char *LLVMGetStringAttributeValue(LLVMAttributeRef A, unsigned *Length); + + + + +LLVMBool LLVMIsEnumAttribute(LLVMAttributeRef A); +LLVMBool LLVMIsStringAttribute(LLVMAttributeRef A); +# 644 "/usr/include/llvm-c/Core.h" 3 4 +LLVMModuleRef LLVMModuleCreateWithName(const char *ModuleID); + + + + + + + +LLVMModuleRef LLVMModuleCreateWithNameInContext(const char *ModuleID, + LLVMContextRef C); + + + +LLVMModuleRef LLVMCloneModule(LLVMModuleRef M); + + + + + + + +void LLVMDisposeModule(LLVMModuleRef M); +# 675 "/usr/include/llvm-c/Core.h" 3 4 +const char *LLVMGetModuleIdentifier(LLVMModuleRef M, size_t *Len); +# 685 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *Ident, size_t Len); +# 695 "/usr/include/llvm-c/Core.h" 3 4 +const char *LLVMGetSourceFileName(LLVMModuleRef M, size_t *Len); +# 706 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetSourceFileName(LLVMModuleRef M, const char *Name, size_t Len); +# 717 "/usr/include/llvm-c/Core.h" 3 4 +const char *LLVMGetDataLayoutStr(LLVMModuleRef M); +const char *LLVMGetDataLayout(LLVMModuleRef M); + + + + + + +void LLVMSetDataLayout(LLVMModuleRef M, const char *DataLayoutStr); + + + + + + +const char *LLVMGetTarget(LLVMModuleRef M); + + + + + + +void LLVMSetTarget(LLVMModuleRef M, const char *Triple); +# 748 "/usr/include/llvm-c/Core.h" 3 4 +LLVMModuleFlagEntry *LLVMCopyModuleFlagsMetadata(LLVMModuleRef M, size_t *Len); + + + + +void LLVMDisposeModuleFlagsMetadata(LLVMModuleFlagEntry *Entries); + + + + + + +LLVMModuleFlagBehavior +LLVMModuleFlagEntriesGetFlagBehavior(LLVMModuleFlagEntry *Entries, + unsigned Index); + + + + + + +const char *LLVMModuleFlagEntriesGetKey(LLVMModuleFlagEntry *Entries, + unsigned Index, size_t *Len); + + + + + + +LLVMMetadataRef LLVMModuleFlagEntriesGetMetadata(LLVMModuleFlagEntry *Entries, + unsigned Index); + + + + + + + +LLVMMetadataRef LLVMGetModuleFlag(LLVMModuleRef M, + const char *Key, size_t KeyLen); + + + + + + + +void LLVMAddModuleFlag(LLVMModuleRef M, LLVMModuleFlagBehavior Behavior, + const char *Key, size_t KeyLen, + LLVMMetadataRef Val); + + + + + + +void LLVMDumpModule(LLVMModuleRef M); + + + + + + + +LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, + char **ErrorMessage); + + + + + + + +char *LLVMPrintModuleToString(LLVMModuleRef M); + + + + + + +const char *LLVMGetModuleInlineAsm(LLVMModuleRef M, size_t *Len); + + + + + + +void LLVMSetModuleInlineAsm2(LLVMModuleRef M, const char *Asm, size_t Len); + + + + + + +void LLVMAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm, size_t Len); + + + + + + +LLVMValueRef LLVMGetInlineAsm(LLVMTypeRef Ty, + char *AsmString, size_t AsmStringSize, + char *Constraints, size_t ConstraintsSize, + LLVMBool HasSideEffects, LLVMBool IsAlignStack, + LLVMInlineAsmDialect Dialect); + + + + + + +LLVMContextRef LLVMGetModuleContext(LLVMModuleRef M); + + + + +LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name); + + + + + + +LLVMNamedMDNodeRef LLVMGetFirstNamedMetadata(LLVMModuleRef M); + + + + + + +LLVMNamedMDNodeRef LLVMGetLastNamedMetadata(LLVMModuleRef M); + + + + + + + +LLVMNamedMDNodeRef LLVMGetNextNamedMetadata(LLVMNamedMDNodeRef NamedMDNode); + + + + + + + +LLVMNamedMDNodeRef LLVMGetPreviousNamedMetadata(LLVMNamedMDNodeRef NamedMDNode); + + + + + + + +LLVMNamedMDNodeRef LLVMGetNamedMetadata(LLVMModuleRef M, + const char *Name, size_t NameLen); + + + + + + + +LLVMNamedMDNodeRef LLVMGetOrInsertNamedMetadata(LLVMModuleRef M, + const char *Name, + size_t NameLen); + + + + + + +const char *LLVMGetNamedMetadataName(LLVMNamedMDNodeRef NamedMD, + size_t *NameLen); + + + + + + +unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char *Name); +# 942 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char *Name, + LLVMValueRef *Dest); + + + + + + + +void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char *Name, + LLVMValueRef Val); +# 962 "/usr/include/llvm-c/Core.h" 3 4 +const char *LLVMGetDebugLocDirectory(LLVMValueRef Val, unsigned *Length); +# 972 "/usr/include/llvm-c/Core.h" 3 4 +const char *LLVMGetDebugLocFilename(LLVMValueRef Val, unsigned *Length); +# 982 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetDebugLocLine(LLVMValueRef Val); + + + + + + + +unsigned LLVMGetDebugLocColumn(LLVMValueRef Val); + + + + + + +LLVMValueRef LLVMAddFunction(LLVMModuleRef M, const char *Name, + LLVMTypeRef FunctionTy); +# 1007 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetNamedFunction(LLVMModuleRef M, const char *Name); + + + + + + +LLVMValueRef LLVMGetFirstFunction(LLVMModuleRef M); + + + + + + +LLVMValueRef LLVMGetLastFunction(LLVMModuleRef M); + + + + + + + +LLVMValueRef LLVMGetNextFunction(LLVMValueRef Fn); + + + + + + + +LLVMValueRef LLVMGetPreviousFunction(LLVMValueRef Fn); + + +void LLVMSetModuleInlineAsm(LLVMModuleRef M, const char *Asm); +# 1080 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeKind LLVMGetTypeKind(LLVMTypeRef Ty); +# 1089 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty); + + + + + + +LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); + + + + + + +void LLVMDumpType(LLVMTypeRef Val); + + + + + + + +char *LLVMPrintTypeToString(LLVMTypeRef Val); +# 1124 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMInt1TypeInContext(LLVMContextRef C); +LLVMTypeRef LLVMInt8TypeInContext(LLVMContextRef C); +LLVMTypeRef LLVMInt16TypeInContext(LLVMContextRef C); +LLVMTypeRef LLVMInt32TypeInContext(LLVMContextRef C); +LLVMTypeRef LLVMInt64TypeInContext(LLVMContextRef C); +LLVMTypeRef LLVMInt128TypeInContext(LLVMContextRef C); +LLVMTypeRef LLVMIntTypeInContext(LLVMContextRef C, unsigned NumBits); + + + + + +LLVMTypeRef LLVMInt1Type(void); +LLVMTypeRef LLVMInt8Type(void); +LLVMTypeRef LLVMInt16Type(void); +LLVMTypeRef LLVMInt32Type(void); +LLVMTypeRef LLVMInt64Type(void); +LLVMTypeRef LLVMInt128Type(void); +LLVMTypeRef LLVMIntType(unsigned NumBits); +unsigned LLVMGetIntTypeWidth(LLVMTypeRef IntegerTy); +# 1158 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMHalfTypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMFloatTypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMDoubleTypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMX86FP80TypeInContext(LLVMContextRef C); + + + + + +LLVMTypeRef LLVMFP128TypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C); + + + + + + +LLVMTypeRef LLVMHalfType(void); +LLVMTypeRef LLVMFloatType(void); +LLVMTypeRef LLVMDoubleType(void); +LLVMTypeRef LLVMX86FP80Type(void); +LLVMTypeRef LLVMFP128Type(void); +LLVMTypeRef LLVMPPCFP128Type(void); +# 1214 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMFunctionType(LLVMTypeRef ReturnType, + LLVMTypeRef *ParamTypes, unsigned ParamCount, + LLVMBool IsVarArg); + + + + +LLVMBool LLVMIsFunctionVarArg(LLVMTypeRef FunctionTy); + + + + +LLVMTypeRef LLVMGetReturnType(LLVMTypeRef FunctionTy); + + + + +unsigned LLVMCountParamTypes(LLVMTypeRef FunctionTy); +# 1244 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMGetParamTypes(LLVMTypeRef FunctionTy, LLVMTypeRef *Dest); +# 1268 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMStructTypeInContext(LLVMContextRef C, LLVMTypeRef *ElementTypes, + unsigned ElementCount, LLVMBool Packed); + + + + + + +LLVMTypeRef LLVMStructType(LLVMTypeRef *ElementTypes, unsigned ElementCount, + LLVMBool Packed); + + + + + + +LLVMTypeRef LLVMStructCreateNamed(LLVMContextRef C, const char *Name); + + + + + + +const char *LLVMGetStructName(LLVMTypeRef Ty); + + + + + + +void LLVMStructSetBody(LLVMTypeRef StructTy, LLVMTypeRef *ElementTypes, + unsigned ElementCount, LLVMBool Packed); + + + + + + +unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy); +# 1318 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMGetStructElementTypes(LLVMTypeRef StructTy, LLVMTypeRef *Dest); + + + + + + +LLVMTypeRef LLVMStructGetTypeAtIndex(LLVMTypeRef StructTy, unsigned i); + + + + + + +LLVMBool LLVMIsPackedStruct(LLVMTypeRef StructTy); + + + + + + +LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy); + + + + + + +LLVMBool LLVMIsLiteralStruct(LLVMTypeRef StructTy); +# 1368 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty); + + + + + + +void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr); + + + + + + +unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp); +# 1392 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount); +# 1401 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy); +# 1411 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMPointerType(LLVMTypeRef ElementType, unsigned AddressSpace); +# 1420 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetPointerAddressSpace(LLVMTypeRef PointerTy); +# 1431 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMVectorType(LLVMTypeRef ElementType, unsigned ElementCount); +# 1440 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetVectorSize(LLVMTypeRef VectorTy); +# 1455 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C); + + + + +LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C); + + + + + +LLVMTypeRef LLVMVoidType(void); +LLVMTypeRef LLVMLabelType(void); +LLVMTypeRef LLVMX86MMXType(void); +# 1611 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMTypeOf(LLVMValueRef Val); + + + + + + +LLVMValueKind LLVMGetValueKind(LLVMValueRef Val); + + + + + + +const char *LLVMGetValueName2(LLVMValueRef Val, size_t *Length); + + + + + + +void LLVMSetValueName2(LLVMValueRef Val, const char *Name, size_t NameLen); + + + + + + +void LLVMDumpValue(LLVMValueRef Val); + + + + + + + +char *LLVMPrintValueToString(LLVMValueRef Val); + + + + + + +void LLVMReplaceAllUsesWith(LLVMValueRef OldVal, LLVMValueRef NewVal); + + + + +LLVMBool LLVMIsConstant(LLVMValueRef Val); + + + + +LLVMBool LLVMIsUndef(LLVMValueRef Val); +# 1679 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMIsAArgument(LLVMValueRef Val); LLVMValueRef LLVMIsABasicBlock(LLVMValueRef Val); LLVMValueRef LLVMIsAInlineAsm(LLVMValueRef Val); LLVMValueRef LLVMIsAUser(LLVMValueRef Val); LLVMValueRef LLVMIsAConstant(LLVMValueRef Val); LLVMValueRef LLVMIsABlockAddress(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantAggregateZero(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantArray(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantDataSequential(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantDataArray(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantDataVector(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantExpr(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantFP(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantInt(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantPointerNull(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantStruct(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantTokenNone(LLVMValueRef Val); LLVMValueRef LLVMIsAConstantVector(LLVMValueRef Val); LLVMValueRef LLVMIsAGlobalValue(LLVMValueRef Val); LLVMValueRef LLVMIsAGlobalAlias(LLVMValueRef Val); LLVMValueRef LLVMIsAGlobalIFunc(LLVMValueRef Val); LLVMValueRef LLVMIsAGlobalObject(LLVMValueRef Val); LLVMValueRef LLVMIsAFunction(LLVMValueRef Val); LLVMValueRef LLVMIsAGlobalVariable(LLVMValueRef Val); LLVMValueRef LLVMIsAUndefValue(LLVMValueRef Val); LLVMValueRef LLVMIsAInstruction(LLVMValueRef Val); LLVMValueRef LLVMIsABinaryOperator(LLVMValueRef Val); LLVMValueRef LLVMIsACallInst(LLVMValueRef Val); LLVMValueRef LLVMIsAIntrinsicInst(LLVMValueRef Val); LLVMValueRef LLVMIsADbgInfoIntrinsic(LLVMValueRef Val); LLVMValueRef LLVMIsADbgVariableIntrinsic(LLVMValueRef Val); LLVMValueRef LLVMIsADbgDeclareInst(LLVMValueRef Val); LLVMValueRef LLVMIsADbgLabelInst(LLVMValueRef Val); LLVMValueRef LLVMIsAMemIntrinsic(LLVMValueRef Val); LLVMValueRef LLVMIsAMemCpyInst(LLVMValueRef Val); LLVMValueRef LLVMIsAMemMoveInst(LLVMValueRef Val); LLVMValueRef LLVMIsAMemSetInst(LLVMValueRef Val); LLVMValueRef LLVMIsACmpInst(LLVMValueRef Val); LLVMValueRef LLVMIsAFCmpInst(LLVMValueRef Val); LLVMValueRef LLVMIsAICmpInst(LLVMValueRef Val); LLVMValueRef LLVMIsAExtractElementInst(LLVMValueRef Val); LLVMValueRef LLVMIsAGetElementPtrInst(LLVMValueRef Val); LLVMValueRef LLVMIsAInsertElementInst(LLVMValueRef Val); LLVMValueRef LLVMIsAInsertValueInst(LLVMValueRef Val); LLVMValueRef LLVMIsALandingPadInst(LLVMValueRef Val); LLVMValueRef LLVMIsAPHINode(LLVMValueRef Val); LLVMValueRef LLVMIsASelectInst(LLVMValueRef Val); LLVMValueRef LLVMIsAShuffleVectorInst(LLVMValueRef Val); LLVMValueRef LLVMIsAStoreInst(LLVMValueRef Val); LLVMValueRef LLVMIsABranchInst(LLVMValueRef Val); LLVMValueRef LLVMIsAIndirectBrInst(LLVMValueRef Val); LLVMValueRef LLVMIsAInvokeInst(LLVMValueRef Val); LLVMValueRef LLVMIsAReturnInst(LLVMValueRef Val); LLVMValueRef LLVMIsASwitchInst(LLVMValueRef Val); LLVMValueRef LLVMIsAUnreachableInst(LLVMValueRef Val); LLVMValueRef LLVMIsAResumeInst(LLVMValueRef Val); LLVMValueRef LLVMIsACleanupReturnInst(LLVMValueRef Val); LLVMValueRef LLVMIsACatchReturnInst(LLVMValueRef Val); LLVMValueRef LLVMIsAFuncletPadInst(LLVMValueRef Val); LLVMValueRef LLVMIsACatchPadInst(LLVMValueRef Val); LLVMValueRef LLVMIsACleanupPadInst(LLVMValueRef Val); LLVMValueRef LLVMIsAUnaryInstruction(LLVMValueRef Val); LLVMValueRef LLVMIsAAllocaInst(LLVMValueRef Val); LLVMValueRef LLVMIsACastInst(LLVMValueRef Val); LLVMValueRef LLVMIsAAddrSpaceCastInst(LLVMValueRef Val); LLVMValueRef LLVMIsABitCastInst(LLVMValueRef Val); LLVMValueRef LLVMIsAFPExtInst(LLVMValueRef Val); LLVMValueRef LLVMIsAFPToSIInst(LLVMValueRef Val); LLVMValueRef LLVMIsAFPToUIInst(LLVMValueRef Val); LLVMValueRef LLVMIsAFPTruncInst(LLVMValueRef Val); LLVMValueRef LLVMIsAIntToPtrInst(LLVMValueRef Val); LLVMValueRef LLVMIsAPtrToIntInst(LLVMValueRef Val); LLVMValueRef LLVMIsASExtInst(LLVMValueRef Val); LLVMValueRef LLVMIsASIToFPInst(LLVMValueRef Val); LLVMValueRef LLVMIsATruncInst(LLVMValueRef Val); LLVMValueRef LLVMIsAUIToFPInst(LLVMValueRef Val); LLVMValueRef LLVMIsAZExtInst(LLVMValueRef Val); LLVMValueRef LLVMIsAExtractValueInst(LLVMValueRef Val); LLVMValueRef LLVMIsALoadInst(LLVMValueRef Val); LLVMValueRef LLVMIsAVAArgInst(LLVMValueRef Val); + +LLVMValueRef LLVMIsAMDNode(LLVMValueRef Val); +LLVMValueRef LLVMIsAMDString(LLVMValueRef Val); + + +const char *LLVMGetValueName(LLVMValueRef Val); + +void LLVMSetValueName(LLVMValueRef Val, const char *Name); +# 1716 "/usr/include/llvm-c/Core.h" 3 4 +LLVMUseRef LLVMGetFirstUse(LLVMValueRef Val); + + + + + + + +LLVMUseRef LLVMGetNextUse(LLVMUseRef U); +# 1733 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetUser(LLVMUseRef U); + + + + + + +LLVMValueRef LLVMGetUsedValue(LLVMUseRef U); +# 1761 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetOperand(LLVMValueRef Val, unsigned Index); + + + + + + +LLVMUseRef LLVMGetOperandUse(LLVMValueRef Val, unsigned Index); + + + + + + +void LLVMSetOperand(LLVMValueRef User, unsigned Index, LLVMValueRef Val); + + + + + + +int LLVMGetNumOperands(LLVMValueRef Val); +# 1805 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMConstNull(LLVMTypeRef Ty); +# 1815 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMConstAllOnes(LLVMTypeRef Ty); + + + + + + +LLVMValueRef LLVMGetUndef(LLVMTypeRef Ty); + + + + + + +LLVMBool LLVMIsNull(LLVMValueRef Val); + + + + + +LLVMValueRef LLVMConstPointerNull(LLVMTypeRef Ty); +# 1864 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N, + LLVMBool SignExtend); + + + + + + +LLVMValueRef LLVMConstIntOfArbitraryPrecision(LLVMTypeRef IntTy, + unsigned NumWords, + const uint64_t Words[]); +# 1885 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMConstIntOfString(LLVMTypeRef IntTy, const char *Text, + uint8_t Radix); + + + + + + + +LLVMValueRef LLVMConstIntOfStringAndSize(LLVMTypeRef IntTy, const char *Text, + unsigned SLen, uint8_t Radix); + + + + +LLVMValueRef LLVMConstReal(LLVMTypeRef RealTy, double N); + + + + + + + +LLVMValueRef LLVMConstRealOfString(LLVMTypeRef RealTy, const char *Text); + + + + +LLVMValueRef LLVMConstRealOfStringAndSize(LLVMTypeRef RealTy, const char *Text, + unsigned SLen); + + + + + + +unsigned long long LLVMConstIntGetZExtValue(LLVMValueRef ConstantVal); + + + + + + +long long LLVMConstIntGetSExtValue(LLVMValueRef ConstantVal); + + + + + + + +double LLVMConstRealGetDouble(LLVMValueRef ConstantVal, LLVMBool *losesInfo); +# 1955 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMConstStringInContext(LLVMContextRef C, const char *Str, + unsigned Length, LLVMBool DontNullTerminate); +# 1967 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMConstString(const char *Str, unsigned Length, + LLVMBool DontNullTerminate); + + + + + + +LLVMBool LLVMIsConstantString(LLVMValueRef c); + + + + + + +const char *LLVMGetAsString(LLVMValueRef c, size_t *Length); + + + + + + +LLVMValueRef LLVMConstStructInContext(LLVMContextRef C, + LLVMValueRef *ConstantVals, + unsigned Count, LLVMBool Packed); +# 2001 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count, + LLVMBool Packed); + + + + + + +LLVMValueRef LLVMConstArray(LLVMTypeRef ElementTy, + LLVMValueRef *ConstantVals, unsigned Length); + + + + + + +LLVMValueRef LLVMConstNamedStruct(LLVMTypeRef StructTy, + LLVMValueRef *ConstantVals, + unsigned Count); + + + + + + +LLVMValueRef LLVMGetElementAsConstant(LLVMValueRef C, unsigned idx); + + + + + + +LLVMValueRef LLVMConstVector(LLVMValueRef *ScalarConstantVals, unsigned Size); +# 2048 "/usr/include/llvm-c/Core.h" 3 4 +LLVMOpcode LLVMGetConstOpcode(LLVMValueRef ConstantVal); +LLVMValueRef LLVMAlignOf(LLVMTypeRef Ty); +LLVMValueRef LLVMSizeOf(LLVMTypeRef Ty); +LLVMValueRef LLVMConstNeg(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstNSWNeg(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstNUWNeg(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstFNeg(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstNot(LLVMValueRef ConstantVal); +LLVMValueRef LLVMConstAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNSWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNUWAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFAdd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNSWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNUWSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFSub(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNSWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstNUWMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFMul(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstExactUDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstExactSDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFDiv(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstURem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstSRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFRem(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstAnd(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstOr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstXor(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstICmp(LLVMIntPredicate Predicate, + LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstFCmp(LLVMRealPredicate Predicate, + LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstShl(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstLShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstAShr(LLVMValueRef LHSConstant, LLVMValueRef RHSConstant); +LLVMValueRef LLVMConstGEP(LLVMValueRef ConstantVal, + LLVMValueRef *ConstantIndices, unsigned NumIndices); +LLVMValueRef LLVMConstGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, + LLVMValueRef *ConstantIndices, unsigned NumIndices); +LLVMValueRef LLVMConstInBoundsGEP(LLVMValueRef ConstantVal, + LLVMValueRef *ConstantIndices, + unsigned NumIndices); +LLVMValueRef LLVMConstInBoundsGEP2(LLVMTypeRef Ty, LLVMValueRef ConstantVal, + LLVMValueRef *ConstantIndices, + unsigned NumIndices); +LLVMValueRef LLVMConstTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstSExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstZExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstFPTrunc(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstFPExt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstUIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstSIToFP(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstFPToUI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, + LLVMTypeRef ToType); +LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, + LLVMTypeRef ToType); +LLVMValueRef LLVMConstTruncOrBitCast(LLVMValueRef ConstantVal, + LLVMTypeRef ToType); +LLVMValueRef LLVMConstPointerCast(LLVMValueRef ConstantVal, + LLVMTypeRef ToType); +LLVMValueRef LLVMConstIntCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType, + LLVMBool isSigned); +LLVMValueRef LLVMConstFPCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstSelect(LLVMValueRef ConstantCondition, + LLVMValueRef ConstantIfTrue, + LLVMValueRef ConstantIfFalse); +LLVMValueRef LLVMConstExtractElement(LLVMValueRef VectorConstant, + LLVMValueRef IndexConstant); +LLVMValueRef LLVMConstInsertElement(LLVMValueRef VectorConstant, + LLVMValueRef ElementValueConstant, + LLVMValueRef IndexConstant); +LLVMValueRef LLVMConstShuffleVector(LLVMValueRef VectorAConstant, + LLVMValueRef VectorBConstant, + LLVMValueRef MaskConstant); +LLVMValueRef LLVMConstExtractValue(LLVMValueRef AggConstant, unsigned *IdxList, + unsigned NumIdx); +LLVMValueRef LLVMConstInsertValue(LLVMValueRef AggConstant, + LLVMValueRef ElementValueConstant, + unsigned *IdxList, unsigned NumIdx); +LLVMValueRef LLVMBlockAddress(LLVMValueRef F, LLVMBasicBlockRef BB); + + +LLVMValueRef LLVMConstInlineAsm(LLVMTypeRef Ty, + const char *AsmString, const char *Constraints, + LLVMBool HasSideEffects, LLVMBool IsAlignStack); +# 2158 "/usr/include/llvm-c/Core.h" 3 4 +LLVMModuleRef LLVMGetGlobalParent(LLVMValueRef Global); +LLVMBool LLVMIsDeclaration(LLVMValueRef Global); +LLVMLinkage LLVMGetLinkage(LLVMValueRef Global); +void LLVMSetLinkage(LLVMValueRef Global, LLVMLinkage Linkage); +const char *LLVMGetSection(LLVMValueRef Global); +void LLVMSetSection(LLVMValueRef Global, const char *Section); +LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); +void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); +LLVMDLLStorageClass LLVMGetDLLStorageClass(LLVMValueRef Global); +void LLVMSetDLLStorageClass(LLVMValueRef Global, LLVMDLLStorageClass Class); +LLVMUnnamedAddr LLVMGetUnnamedAddress(LLVMValueRef Global); +void LLVMSetUnnamedAddress(LLVMValueRef Global, LLVMUnnamedAddr UnnamedAddr); + + + + + + + +LLVMTypeRef LLVMGlobalGetValueType(LLVMValueRef Global); + + +LLVMBool LLVMHasUnnamedAddr(LLVMValueRef Global); + +void LLVMSetUnnamedAddr(LLVMValueRef Global, LLVMBool HasUnnamedAddr); +# 2198 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetAlignment(LLVMValueRef V); +# 2207 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); + + + + + + + +void LLVMGlobalSetMetadata(LLVMValueRef Global, unsigned Kind, + LLVMMetadataRef MD); + + + + + + +void LLVMGlobalEraseMetadata(LLVMValueRef Global, unsigned Kind); + + + + + + +void LLVMGlobalClearMetadata(LLVMValueRef Global); +# 2239 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueMetadataEntry *LLVMGlobalCopyAllMetadata(LLVMValueRef Value, + size_t *NumEntries); + + + + +void LLVMDisposeValueMetadataEntries(LLVMValueMetadataEntry *Entries); + + + + +unsigned LLVMValueMetadataEntriesGetKind(LLVMValueMetadataEntry *Entries, + unsigned Index); + + + + + +LLVMMetadataRef +LLVMValueMetadataEntriesGetMetadata(LLVMValueMetadataEntry *Entries, + unsigned Index); +# 2274 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name); +LLVMValueRef LLVMAddGlobalInAddressSpace(LLVMModuleRef M, LLVMTypeRef Ty, + const char *Name, + unsigned AddressSpace); +LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name); +LLVMValueRef LLVMGetFirstGlobal(LLVMModuleRef M); +LLVMValueRef LLVMGetLastGlobal(LLVMModuleRef M); +LLVMValueRef LLVMGetNextGlobal(LLVMValueRef GlobalVar); +LLVMValueRef LLVMGetPreviousGlobal(LLVMValueRef GlobalVar); +void LLVMDeleteGlobal(LLVMValueRef GlobalVar); +LLVMValueRef LLVMGetInitializer(LLVMValueRef GlobalVar); +void LLVMSetInitializer(LLVMValueRef GlobalVar, LLVMValueRef ConstantVal); +LLVMBool LLVMIsThreadLocal(LLVMValueRef GlobalVar); +void LLVMSetThreadLocal(LLVMValueRef GlobalVar, LLVMBool IsThreadLocal); +LLVMBool LLVMIsGlobalConstant(LLVMValueRef GlobalVar); +void LLVMSetGlobalConstant(LLVMValueRef GlobalVar, LLVMBool IsConstant); +LLVMThreadLocalMode LLVMGetThreadLocalMode(LLVMValueRef GlobalVar); +void LLVMSetThreadLocalMode(LLVMValueRef GlobalVar, LLVMThreadLocalMode Mode); +LLVMBool LLVMIsExternallyInitialized(LLVMValueRef GlobalVar); +void LLVMSetExternallyInitialized(LLVMValueRef GlobalVar, LLVMBool IsExtInit); +# 2308 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMAddAlias(LLVMModuleRef M, LLVMTypeRef Ty, LLVMValueRef Aliasee, + const char *Name); +# 2318 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetNamedGlobalAlias(LLVMModuleRef M, + const char *Name, size_t NameLen); + + + + + + +LLVMValueRef LLVMGetFirstGlobalAlias(LLVMModuleRef M); + + + + + + +LLVMValueRef LLVMGetLastGlobalAlias(LLVMModuleRef M); + + + + + + + +LLVMValueRef LLVMGetNextGlobalAlias(LLVMValueRef GA); + + + + + + + +LLVMValueRef LLVMGetPreviousGlobalAlias(LLVMValueRef GA); + + + + +LLVMValueRef LLVMAliasGetAliasee(LLVMValueRef Alias); + + + + +void LLVMAliasSetAliasee(LLVMValueRef Alias, LLVMValueRef Aliasee); +# 2381 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMDeleteFunction(LLVMValueRef Fn); + + + + + + +LLVMBool LLVMHasPersonalityFn(LLVMValueRef Fn); + + + + + + +LLVMValueRef LLVMGetPersonalityFn(LLVMValueRef Fn); + + + + + + +void LLVMSetPersonalityFn(LLVMValueRef Fn, LLVMValueRef PersonalityFn); + + + + + + +unsigned LLVMGetIntrinsicID(LLVMValueRef Fn); + + + + + + + +LLVMValueRef LLVMGetIntrinsicDeclaration(LLVMModuleRef Mod, + unsigned ID, + LLVMTypeRef *ParamTypes, + size_t ParamCount); + + + + + + + +LLVMTypeRef LLVMIntrinsicGetType(LLVMContextRef Ctx, unsigned ID, + LLVMTypeRef *ParamTypes, size_t ParamCount); + + + + + + +const char *LLVMIntrinsicGetName(unsigned ID, size_t *NameLength); +# 2447 "/usr/include/llvm-c/Core.h" 3 4 +const char *LLVMIntrinsicCopyOverloadedName(unsigned ID, + LLVMTypeRef *ParamTypes, + size_t ParamCount, + size_t *NameLength); + + + + + + +LLVMBool LLVMIntrinsicIsOverloaded(unsigned ID); +# 2466 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetFunctionCallConv(LLVMValueRef Fn); +# 2476 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetFunctionCallConv(LLVMValueRef Fn, unsigned CC); + + + + + + + +const char *LLVMGetGC(LLVMValueRef Fn); + + + + + + +void LLVMSetGC(LLVMValueRef Fn, const char *Name); + + + + + + +void LLVMAddAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + LLVMAttributeRef A); +unsigned LLVMGetAttributeCountAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx); +void LLVMGetAttributesAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + LLVMAttributeRef *Attrs); +LLVMAttributeRef LLVMGetEnumAttributeAtIndex(LLVMValueRef F, + LLVMAttributeIndex Idx, + unsigned KindID); +LLVMAttributeRef LLVMGetStringAttributeAtIndex(LLVMValueRef F, + LLVMAttributeIndex Idx, + const char *K, unsigned KLen); +void LLVMRemoveEnumAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + unsigned KindID); +void LLVMRemoveStringAttributeAtIndex(LLVMValueRef F, LLVMAttributeIndex Idx, + const char *K, unsigned KLen); + + + + + +void LLVMAddTargetDependentFunctionAttr(LLVMValueRef Fn, const char *A, + const char *V); +# 2537 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMCountParams(LLVMValueRef Fn); +# 2550 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMGetParams(LLVMValueRef Fn, LLVMValueRef *Params); +# 2559 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); +# 2570 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetParamParent(LLVMValueRef Inst); + + + + + + +LLVMValueRef LLVMGetFirstParam(LLVMValueRef Fn); + + + + + + +LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); +# 2593 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetNextParam(LLVMValueRef Arg); + + + + + + +LLVMValueRef LLVMGetPreviousParam(LLVMValueRef Arg); + + + + + + + +void LLVMSetParamAlignment(LLVMValueRef Arg, unsigned Align); +# 2641 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMMDStringInContext(LLVMContextRef C, const char *Str, + unsigned SLen); + + + + +LLVMValueRef LLVMMDString(const char *Str, unsigned SLen); + + + + + + +LLVMValueRef LLVMMDNodeInContext(LLVMContextRef C, LLVMValueRef *Vals, + unsigned Count); + + + + +LLVMValueRef LLVMMDNode(LLVMValueRef *Vals, unsigned Count); + + + + +LLVMValueRef LLVMMetadataAsValue(LLVMContextRef C, LLVMMetadataRef MD); + + + + +LLVMMetadataRef LLVMValueAsMetadata(LLVMValueRef Val); +# 2679 "/usr/include/llvm-c/Core.h" 3 4 +const char *LLVMGetMDString(LLVMValueRef V, unsigned *Length); + + + + + + + +unsigned LLVMGetMDNodeNumOperands(LLVMValueRef V); +# 2700 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest); +# 2726 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); + + + + +LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); + + + + +LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); + + + + +const char *LLVMGetBasicBlockName(LLVMBasicBlockRef BB); + + + + + + +LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB); +# 2760 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetBasicBlockTerminator(LLVMBasicBlockRef BB); + + + + + + +unsigned LLVMCountBasicBlocks(LLVMValueRef Fn); +# 2777 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMGetBasicBlocks(LLVMValueRef Fn, LLVMBasicBlockRef *BasicBlocks); +# 2787 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBasicBlockRef LLVMGetFirstBasicBlock(LLVMValueRef Fn); + + + + + + +LLVMBasicBlockRef LLVMGetLastBasicBlock(LLVMValueRef Fn); + + + + +LLVMBasicBlockRef LLVMGetNextBasicBlock(LLVMBasicBlockRef BB); + + + + +LLVMBasicBlockRef LLVMGetPreviousBasicBlock(LLVMBasicBlockRef BB); + + + + + + + +LLVMBasicBlockRef LLVMGetEntryBasicBlock(LLVMValueRef Fn); + + + + + + +LLVMBasicBlockRef LLVMCreateBasicBlockInContext(LLVMContextRef C, + const char *Name); + + + + + + +LLVMBasicBlockRef LLVMAppendBasicBlockInContext(LLVMContextRef C, + LLVMValueRef Fn, + const char *Name); + + + + + + + +LLVMBasicBlockRef LLVMAppendBasicBlock(LLVMValueRef Fn, const char *Name); +# 2847 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBasicBlockRef LLVMInsertBasicBlockInContext(LLVMContextRef C, + LLVMBasicBlockRef BB, + const char *Name); + + + + + + +LLVMBasicBlockRef LLVMInsertBasicBlock(LLVMBasicBlockRef InsertBeforeBB, + const char *Name); +# 2867 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMDeleteBasicBlock(LLVMBasicBlockRef BB); +# 2877 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMRemoveBasicBlockFromParent(LLVMBasicBlockRef BB); + + + + + + +void LLVMMoveBasicBlockBefore(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); + + + + + + +void LLVMMoveBasicBlockAfter(LLVMBasicBlockRef BB, LLVMBasicBlockRef MovePos); + + + + + + + +LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); + + + + + + +LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); +# 2932 "/usr/include/llvm-c/Core.h" 3 4 +int LLVMHasMetadata(LLVMValueRef Val); + + + + +LLVMValueRef LLVMGetMetadata(LLVMValueRef Val, unsigned KindID); + + + + +void LLVMSetMetadata(LLVMValueRef Val, unsigned KindID, LLVMValueRef Node); + + + + + + + +LLVMValueMetadataEntry * +LLVMInstructionGetAllMetadataOtherThanDebugLoc(LLVMValueRef Instr, + size_t *NumEntries); + + + + + + +LLVMBasicBlockRef LLVMGetInstructionParent(LLVMValueRef Inst); +# 2969 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetNextInstruction(LLVMValueRef Inst); + + + + + + + +LLVMValueRef LLVMGetPreviousInstruction(LLVMValueRef Inst); +# 2987 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMInstructionRemoveFromParent(LLVMValueRef Inst); +# 2997 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMInstructionEraseFromParent(LLVMValueRef Inst); + + + + + + +LLVMOpcode LLVMGetInstructionOpcode(LLVMValueRef Inst); +# 3014 "/usr/include/llvm-c/Core.h" 3 4 +LLVMIntPredicate LLVMGetICmpPredicate(LLVMValueRef Inst); +# 3024 "/usr/include/llvm-c/Core.h" 3 4 +LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst); +# 3034 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst); +# 3043 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst); +# 3065 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetNumArgOperands(LLVMValueRef Instr); +# 3076 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC); +# 3086 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr); + +void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index, + unsigned Align); + +void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, + LLVMAttributeRef A); +unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C, LLVMAttributeIndex Idx); +void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx, + LLVMAttributeRef *Attrs); +LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C, + LLVMAttributeIndex Idx, + unsigned KindID); +LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C, + LLVMAttributeIndex Idx, + const char *K, unsigned KLen); +void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, + unsigned KindID); +void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx, + const char *K, unsigned KLen); + + + + + + +LLVMTypeRef LLVMGetCalledFunctionType(LLVMValueRef C); +# 3123 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr); +# 3132 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBool LLVMIsTailCall(LLVMValueRef CallInst); +# 3141 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetTailCall(LLVMValueRef CallInst, LLVMBool IsTailCall); +# 3150 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBasicBlockRef LLVMGetNormalDest(LLVMValueRef InvokeInst); +# 3162 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBasicBlockRef LLVMGetUnwindDest(LLVMValueRef InvokeInst); +# 3171 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetNormalDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); +# 3183 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B); +# 3203 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetNumSuccessors(LLVMValueRef Term); + + + + + + +LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i); + + + + + + +void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block); +# 3226 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBool LLVMIsConditional(LLVMValueRef Branch); +# 3235 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetCondition(LLVMValueRef Branch); +# 3244 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetCondition(LLVMValueRef Branch, LLVMValueRef Cond); +# 3253 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBasicBlockRef LLVMGetSwitchDefaultDest(LLVMValueRef SwitchInstr); +# 3271 "/usr/include/llvm-c/Core.h" 3 4 +LLVMTypeRef LLVMGetAllocatedType(LLVMValueRef Alloca); +# 3289 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBool LLVMIsInBounds(LLVMValueRef GEP); + + + + +void LLVMSetIsInBounds(LLVMValueRef GEP, LLVMBool InBounds); +# 3312 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, + LLVMBasicBlockRef *IncomingBlocks, unsigned Count); + + + + +unsigned LLVMCountIncoming(LLVMValueRef PhiNode); + + + + +LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); + + + + +LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); +# 3348 "/usr/include/llvm-c/Core.h" 3 4 +unsigned LLVMGetNumIndices(LLVMValueRef Inst); + + + + +const unsigned *LLVMGetIndices(LLVMValueRef Inst); +# 3376 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBuilderRef LLVMCreateBuilderInContext(LLVMContextRef C); +LLVMBuilderRef LLVMCreateBuilder(void); +void LLVMPositionBuilder(LLVMBuilderRef Builder, LLVMBasicBlockRef Block, + LLVMValueRef Instr); +void LLVMPositionBuilderBefore(LLVMBuilderRef Builder, LLVMValueRef Instr); +void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); +LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); +void LLVMClearInsertionPosition(LLVMBuilderRef Builder); +void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); +void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, + const char *Name); +void LLVMDisposeBuilder(LLVMBuilderRef Builder); + + +void LLVMSetCurrentDebugLocation(LLVMBuilderRef Builder, LLVMValueRef L); +LLVMValueRef LLVMGetCurrentDebugLocation(LLVMBuilderRef Builder); +void LLVMSetInstDebugLocation(LLVMBuilderRef Builder, LLVMValueRef Inst); + + +LLVMValueRef LLVMBuildRetVoid(LLVMBuilderRef); +LLVMValueRef LLVMBuildRet(LLVMBuilderRef, LLVMValueRef V); +LLVMValueRef LLVMBuildAggregateRet(LLVMBuilderRef, LLVMValueRef *RetVals, + unsigned N); +LLVMValueRef LLVMBuildBr(LLVMBuilderRef, LLVMBasicBlockRef Dest); +LLVMValueRef LLVMBuildCondBr(LLVMBuilderRef, LLVMValueRef If, + LLVMBasicBlockRef Then, LLVMBasicBlockRef Else); +LLVMValueRef LLVMBuildSwitch(LLVMBuilderRef, LLVMValueRef V, + LLVMBasicBlockRef Else, unsigned NumCases); +LLVMValueRef LLVMBuildIndirectBr(LLVMBuilderRef B, LLVMValueRef Addr, + unsigned NumDests); + + +LLVMValueRef LLVMBuildInvoke(LLVMBuilderRef, LLVMValueRef Fn, + LLVMValueRef *Args, unsigned NumArgs, + LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, + const char *Name); +LLVMValueRef LLVMBuildInvoke2(LLVMBuilderRef, LLVMTypeRef Ty, LLVMValueRef Fn, + LLVMValueRef *Args, unsigned NumArgs, + LLVMBasicBlockRef Then, LLVMBasicBlockRef Catch, + const char *Name); +LLVMValueRef LLVMBuildUnreachable(LLVMBuilderRef); + + +LLVMValueRef LLVMBuildResume(LLVMBuilderRef B, LLVMValueRef Exn); +LLVMValueRef LLVMBuildLandingPad(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef PersFn, unsigned NumClauses, + const char *Name); +LLVMValueRef LLVMBuildCleanupRet(LLVMBuilderRef B, LLVMValueRef CatchPad, + LLVMBasicBlockRef BB); +LLVMValueRef LLVMBuildCatchRet(LLVMBuilderRef B, LLVMValueRef CatchPad, + LLVMBasicBlockRef BB); +LLVMValueRef LLVMBuildCatchPad(LLVMBuilderRef B, LLVMValueRef ParentPad, + LLVMValueRef *Args, unsigned NumArgs, + const char *Name); +LLVMValueRef LLVMBuildCleanupPad(LLVMBuilderRef B, LLVMValueRef ParentPad, + LLVMValueRef *Args, unsigned NumArgs, + const char *Name); +LLVMValueRef LLVMBuildCatchSwitch(LLVMBuilderRef B, LLVMValueRef ParentPad, + LLVMBasicBlockRef UnwindBB, + unsigned NumHandlers, const char *Name); + + +void LLVMAddCase(LLVMValueRef Switch, LLVMValueRef OnVal, + LLVMBasicBlockRef Dest); + + +void LLVMAddDestination(LLVMValueRef IndirectBr, LLVMBasicBlockRef Dest); + + +unsigned LLVMGetNumClauses(LLVMValueRef LandingPad); + + +LLVMValueRef LLVMGetClause(LLVMValueRef LandingPad, unsigned Idx); + + +void LLVMAddClause(LLVMValueRef LandingPad, LLVMValueRef ClauseVal); + + +LLVMBool LLVMIsCleanup(LLVMValueRef LandingPad); + + +void LLVMSetCleanup(LLVMValueRef LandingPad, LLVMBool Val); + + +void LLVMAddHandler(LLVMValueRef CatchSwitch, LLVMBasicBlockRef Dest); + + +unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch); +# 3476 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers); + + + + +LLVMValueRef LLVMGetArgOperand(LLVMValueRef Funclet, unsigned i); + + +void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value); +# 3493 "/usr/include/llvm-c/Core.h" 3 4 +LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad); +# 3502 "/usr/include/llvm-c/Core.h" 3 4 +void LLVMSetParentCatchSwitch(LLVMValueRef CatchPad, LLVMValueRef CatchSwitch); + + +LLVMValueRef LLVMBuildAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNSWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNUWAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildFAdd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNSWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNUWSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildFSub(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNSWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNUWMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildFMul(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildExactUDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildExactSDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildFDiv(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildURem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildSRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildFRem(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildShl(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildLShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildAShr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildAnd(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildOr(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildXor(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildBinOp(LLVMBuilderRef B, LLVMOpcode Op, + LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); +LLVMValueRef LLVMBuildNSWNeg(LLVMBuilderRef B, LLVMValueRef V, + const char *Name); +LLVMValueRef LLVMBuildNUWNeg(LLVMBuilderRef B, LLVMValueRef V, + const char *Name); +LLVMValueRef LLVMBuildFNeg(LLVMBuilderRef, LLVMValueRef V, const char *Name); +LLVMValueRef LLVMBuildNot(LLVMBuilderRef, LLVMValueRef V, const char *Name); + + +LLVMValueRef LLVMBuildMalloc(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); +LLVMValueRef LLVMBuildArrayMalloc(LLVMBuilderRef, LLVMTypeRef Ty, + LLVMValueRef Val, const char *Name); + + + + + + + +LLVMValueRef LLVMBuildMemSet(LLVMBuilderRef B, LLVMValueRef Ptr, + LLVMValueRef Val, LLVMValueRef Len, + unsigned Align); + + + + + +LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B, + LLVMValueRef Dst, unsigned DstAlign, + LLVMValueRef Src, unsigned SrcAlign, + LLVMValueRef Size); + + + + + +LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B, + LLVMValueRef Dst, unsigned DstAlign, + LLVMValueRef Src, unsigned SrcAlign, + LLVMValueRef Size); + +LLVMValueRef LLVMBuildAlloca(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); +LLVMValueRef LLVMBuildArrayAlloca(LLVMBuilderRef, LLVMTypeRef Ty, + LLVMValueRef Val, const char *Name); +LLVMValueRef LLVMBuildFree(LLVMBuilderRef, LLVMValueRef PointerVal); + + +LLVMValueRef LLVMBuildLoad(LLVMBuilderRef, LLVMValueRef PointerVal, + const char *Name); +LLVMValueRef LLVMBuildLoad2(LLVMBuilderRef, LLVMTypeRef Ty, + LLVMValueRef PointerVal, const char *Name); +LLVMValueRef LLVMBuildStore(LLVMBuilderRef, LLVMValueRef Val, LLVMValueRef Ptr); + + +LLVMValueRef LLVMBuildGEP(LLVMBuilderRef B, LLVMValueRef Pointer, + LLVMValueRef *Indices, unsigned NumIndices, + const char *Name); +LLVMValueRef LLVMBuildInBoundsGEP(LLVMBuilderRef B, LLVMValueRef Pointer, + LLVMValueRef *Indices, unsigned NumIndices, + const char *Name); +LLVMValueRef LLVMBuildStructGEP(LLVMBuilderRef B, LLVMValueRef Pointer, + unsigned Idx, const char *Name); +LLVMValueRef LLVMBuildGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef Pointer, LLVMValueRef *Indices, + unsigned NumIndices, const char *Name); +LLVMValueRef LLVMBuildInBoundsGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef Pointer, LLVMValueRef *Indices, + unsigned NumIndices, const char *Name); +LLVMValueRef LLVMBuildStructGEP2(LLVMBuilderRef B, LLVMTypeRef Ty, + LLVMValueRef Pointer, unsigned Idx, + const char *Name); +LLVMValueRef LLVMBuildGlobalString(LLVMBuilderRef B, const char *Str, + const char *Name); +LLVMValueRef LLVMBuildGlobalStringPtr(LLVMBuilderRef B, const char *Str, + const char *Name); +LLVMBool LLVMGetVolatile(LLVMValueRef MemoryAccessInst); +void LLVMSetVolatile(LLVMValueRef MemoryAccessInst, LLVMBool IsVolatile); +LLVMAtomicOrdering LLVMGetOrdering(LLVMValueRef MemoryAccessInst); +void LLVMSetOrdering(LLVMValueRef MemoryAccessInst, LLVMAtomicOrdering Ordering); + + +LLVMValueRef LLVMBuildTrunc(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildZExt(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildSExt(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildFPToUI(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildFPToSI(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildUIToFP(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildSIToFP(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildFPTrunc(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildFPExt(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildPtrToInt(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildTruncOrBitCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildCast(LLVMBuilderRef B, LLVMOpcode Op, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildPointerCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildIntCast2(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, LLVMBool IsSigned, + const char *Name); +LLVMValueRef LLVMBuildFPCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); + + +LLVMValueRef LLVMBuildIntCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); + + +LLVMValueRef LLVMBuildICmp(LLVMBuilderRef, LLVMIntPredicate Op, + LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); +LLVMValueRef LLVMBuildFCmp(LLVMBuilderRef, LLVMRealPredicate Op, + LLVMValueRef LHS, LLVMValueRef RHS, + const char *Name); + + +LLVMValueRef LLVMBuildPhi(LLVMBuilderRef, LLVMTypeRef Ty, const char *Name); + + +LLVMValueRef LLVMBuildCall(LLVMBuilderRef, LLVMValueRef Fn, + LLVMValueRef *Args, unsigned NumArgs, + const char *Name); +LLVMValueRef LLVMBuildCall2(LLVMBuilderRef, LLVMTypeRef, LLVMValueRef Fn, + LLVMValueRef *Args, unsigned NumArgs, + const char *Name); +LLVMValueRef LLVMBuildSelect(LLVMBuilderRef, LLVMValueRef If, + LLVMValueRef Then, LLVMValueRef Else, + const char *Name); +LLVMValueRef LLVMBuildVAArg(LLVMBuilderRef, LLVMValueRef List, LLVMTypeRef Ty, + const char *Name); +LLVMValueRef LLVMBuildExtractElement(LLVMBuilderRef, LLVMValueRef VecVal, + LLVMValueRef Index, const char *Name); +LLVMValueRef LLVMBuildInsertElement(LLVMBuilderRef, LLVMValueRef VecVal, + LLVMValueRef EltVal, LLVMValueRef Index, + const char *Name); +LLVMValueRef LLVMBuildShuffleVector(LLVMBuilderRef, LLVMValueRef V1, + LLVMValueRef V2, LLVMValueRef Mask, + const char *Name); +LLVMValueRef LLVMBuildExtractValue(LLVMBuilderRef, LLVMValueRef AggVal, + unsigned Index, const char *Name); +LLVMValueRef LLVMBuildInsertValue(LLVMBuilderRef, LLVMValueRef AggVal, + LLVMValueRef EltVal, unsigned Index, + const char *Name); + +LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val, + const char *Name); +LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, + const char *Name); +LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, + LLVMValueRef RHS, const char *Name); +LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering, + LLVMBool singleThread, const char *Name); +LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op, + LLVMValueRef PTR, LLVMValueRef Val, + LLVMAtomicOrdering ordering, + LLVMBool singleThread); +LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B, LLVMValueRef Ptr, + LLVMValueRef Cmp, LLVMValueRef New, + LLVMAtomicOrdering SuccessOrdering, + LLVMAtomicOrdering FailureOrdering, + LLVMBool SingleThread); + +LLVMBool LLVMIsAtomicSingleThread(LLVMValueRef AtomicInst); +void LLVMSetAtomicSingleThread(LLVMValueRef AtomicInst, LLVMBool SingleThread); + +LLVMAtomicOrdering LLVMGetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst); +void LLVMSetCmpXchgSuccessOrdering(LLVMValueRef CmpXchgInst, + LLVMAtomicOrdering Ordering); +LLVMAtomicOrdering LLVMGetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst); +void LLVMSetCmpXchgFailureOrdering(LLVMValueRef CmpXchgInst, + LLVMAtomicOrdering Ordering); +# 3766 "/usr/include/llvm-c/Core.h" 3 4 +LLVMModuleProviderRef +LLVMCreateModuleProviderForExistingModule(LLVMModuleRef M); + + + + +void LLVMDisposeModuleProvider(LLVMModuleProviderRef M); +# 3784 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBool LLVMCreateMemoryBufferWithContentsOfFile(const char *Path, + LLVMMemoryBufferRef *OutMemBuf, + char **OutMessage); +LLVMBool LLVMCreateMemoryBufferWithSTDIN(LLVMMemoryBufferRef *OutMemBuf, + char **OutMessage); +LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRange(const char *InputData, + size_t InputDataLength, + const char *BufferName, + LLVMBool RequiresNullTerminator); +LLVMMemoryBufferRef LLVMCreateMemoryBufferWithMemoryRangeCopy(const char *InputData, + size_t InputDataLength, + const char *BufferName); +const char *LLVMGetBufferStart(LLVMMemoryBufferRef MemBuf); +size_t LLVMGetBufferSize(LLVMMemoryBufferRef MemBuf); +void LLVMDisposeMemoryBuffer(LLVMMemoryBufferRef MemBuf); +# 3812 "/usr/include/llvm-c/Core.h" 3 4 +LLVMPassRegistryRef LLVMGetGlobalPassRegistry(void); +# 3827 "/usr/include/llvm-c/Core.h" 3 4 +LLVMPassManagerRef LLVMCreatePassManager(void); + + + + + +LLVMPassManagerRef LLVMCreateFunctionPassManagerForModule(LLVMModuleRef M); + + +LLVMPassManagerRef LLVMCreateFunctionPassManager(LLVMModuleProviderRef MP); + + + + + +LLVMBool LLVMRunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M); + + + + +LLVMBool LLVMInitializeFunctionPassManager(LLVMPassManagerRef FPM); + + + + + +LLVMBool LLVMRunFunctionPassManager(LLVMPassManagerRef FPM, LLVMValueRef F); + + + + +LLVMBool LLVMFinalizeFunctionPassManager(LLVMPassManagerRef FPM); + + + + +void LLVMDisposePassManager(LLVMPassManagerRef PM); +# 3880 "/usr/include/llvm-c/Core.h" 3 4 +LLVMBool LLVMStartMultithreaded(void); + + + +void LLVMStopMultithreaded(void); + + + +LLVMBool LLVMIsMultithreaded(void); +# 5 "scope.h" 2 + + +# 6 "scope.h" +typedef struct scope_entry { + char *id; + LLVMValueRef value; + LLVMTypeRef type; + LLVMMetadataRef metadata; + struct scope_entry *prev; +} scope_entry; + +typedef struct scope_layer { + struct scope_entry *head; + struct scope_layer *prev; +} scope_layer; + +typedef scope_layer *scope; + +void scope_push_layer(scope *sc); +void scope_pop_layer(scope *sc); + +void scope_add_entry(scope sc, char *id, LLVMValueRef val, LLVMTypeRef type); +scope_entry *scope_find(scope sc, char *id); +# 5 "scope.c" 2 +# 1 "error.h" 1 + + + +# 1 "/usr/include/stdio.h" 1 3 4 +# 27 "/usr/include/stdio.h" 3 4 +# 1 "/usr/include/bits/libc-header-start.h" 1 3 4 +# 28 "/usr/include/stdio.h" 2 3 4 + + + + + +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stddef.h" 1 3 4 +# 34 "/usr/include/stdio.h" 2 3 4 + + +# 1 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stdarg.h" 1 3 4 +# 40 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stdarg.h" 3 4 + +# 40 "/usr/lib/gcc/x86_64-redhat-linux/9/include/stdarg.h" 3 4 +typedef __builtin_va_list __gnuc_va_list; +# 37 "/usr/include/stdio.h" 2 3 4 + + +# 1 "/usr/include/bits/types/__fpos_t.h" 1 3 4 + + + + +# 1 "/usr/include/bits/types/__mbstate_t.h" 1 3 4 +# 13 "/usr/include/bits/types/__mbstate_t.h" 3 4 +typedef struct +{ + int __count; + union + { + unsigned int __wch; + char __wchb[4]; + } __value; +} __mbstate_t; +# 6 "/usr/include/bits/types/__fpos_t.h" 2 3 4 + + + + +typedef struct _G_fpos_t +{ + __off_t __pos; + __mbstate_t __state; +} __fpos_t; +# 40 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/bits/types/__fpos64_t.h" 1 3 4 +# 10 "/usr/include/bits/types/__fpos64_t.h" 3 4 +typedef struct _G_fpos64_t +{ + __off64_t __pos; + __mbstate_t __state; +} __fpos64_t; +# 41 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/bits/types/__FILE.h" 1 3 4 + + + +struct _IO_FILE; +typedef struct _IO_FILE __FILE; +# 42 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/bits/types/FILE.h" 1 3 4 + + + +struct _IO_FILE; + + +typedef struct _IO_FILE FILE; +# 43 "/usr/include/stdio.h" 2 3 4 +# 1 "/usr/include/bits/types/struct_FILE.h" 1 3 4 +# 35 "/usr/include/bits/types/struct_FILE.h" 3 4 +struct _IO_FILE; +struct _IO_marker; +struct _IO_codecvt; +struct _IO_wide_data; + + + + +typedef void _IO_lock_t; + + + + + +struct _IO_FILE +{ + int _flags; + + + char *_IO_read_ptr; + char *_IO_read_end; + char *_IO_read_base; + char *_IO_write_base; + char *_IO_write_ptr; + char *_IO_write_end; + char *_IO_buf_base; + char *_IO_buf_end; + + + char *_IO_save_base; + char *_IO_backup_base; + char *_IO_save_end; + + struct _IO_marker *_markers; + + struct _IO_FILE *_chain; + + int _fileno; + int _flags2; + __off_t _old_offset; + + + unsigned short _cur_column; + signed char _vtable_offset; + char _shortbuf[1]; + + _IO_lock_t *_lock; + + + + + + + + __off64_t _offset; + + struct _IO_codecvt *_codecvt; + struct _IO_wide_data *_wide_data; + struct _IO_FILE *_freeres_list; + void *_freeres_buf; + size_t __pad5; + int _mode; + + char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; +}; +# 44 "/usr/include/stdio.h" 2 3 4 +# 52 "/usr/include/stdio.h" 3 4 +typedef __gnuc_va_list va_list; +# 84 "/usr/include/stdio.h" 3 4 +typedef __fpos_t fpos_t; +# 133 "/usr/include/stdio.h" 3 4 +# 1 "/usr/include/bits/stdio_lim.h" 1 3 4 +# 134 "/usr/include/stdio.h" 2 3 4 + + + +extern FILE *stdin; +extern FILE *stdout; +extern FILE *stderr; + + + + + + +extern int remove (const char *__filename) __attribute__ ((__nothrow__ , __leaf__)); + +extern int rename (const char *__old, const char *__new) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int renameat (int __oldfd, const char *__old, int __newfd, + const char *__new) __attribute__ ((__nothrow__ , __leaf__)); +# 173 "/usr/include/stdio.h" 3 4 +extern FILE *tmpfile (void) ; +# 187 "/usr/include/stdio.h" 3 4 +extern char *tmpnam (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + +extern char *tmpnam_r (char *__s) __attribute__ ((__nothrow__ , __leaf__)) ; +# 204 "/usr/include/stdio.h" 3 4 +extern char *tempnam (const char *__dir, const char *__pfx) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__malloc__)) ; + + + + + + + +extern int fclose (FILE *__stream); + + + + +extern int fflush (FILE *__stream); +# 227 "/usr/include/stdio.h" 3 4 +extern int fflush_unlocked (FILE *__stream); +# 246 "/usr/include/stdio.h" 3 4 +extern FILE *fopen (const char *__restrict __filename, + const char *__restrict __modes) ; + + + + +extern FILE *freopen (const char *__restrict __filename, + const char *__restrict __modes, + FILE *__restrict __stream) ; +# 279 "/usr/include/stdio.h" 3 4 +extern FILE *fdopen (int __fd, const char *__modes) __attribute__ ((__nothrow__ , __leaf__)) ; +# 292 "/usr/include/stdio.h" 3 4 +extern FILE *fmemopen (void *__s, size_t __len, const char *__modes) + __attribute__ ((__nothrow__ , __leaf__)) ; + + + + +extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + + +extern void setbuf (FILE *__restrict __stream, char *__restrict __buf) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf, + int __modes, size_t __n) __attribute__ ((__nothrow__ , __leaf__)); + + + + +extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf, + size_t __size) __attribute__ ((__nothrow__ , __leaf__)); + + +extern void setlinebuf (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + + +extern int fprintf (FILE *__restrict __stream, + const char *__restrict __format, ...); + + + + +extern int printf (const char *__restrict __format, ...); + +extern int sprintf (char *__restrict __s, + const char *__restrict __format, ...) __attribute__ ((__nothrow__)); + + + + + +extern int vfprintf (FILE *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg); + + + + +extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg); + +extern int vsprintf (char *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg) __attribute__ ((__nothrow__)); + + + +extern int snprintf (char *__restrict __s, size_t __maxlen, + const char *__restrict __format, ...) + __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 4))); + +extern int vsnprintf (char *__restrict __s, size_t __maxlen, + const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__nothrow__)) __attribute__ ((__format__ (__printf__, 3, 0))); +# 379 "/usr/include/stdio.h" 3 4 +extern int vdprintf (int __fd, const char *__restrict __fmt, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__printf__, 2, 0))); +extern int dprintf (int __fd, const char *__restrict __fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); + + + + + + + +extern int fscanf (FILE *__restrict __stream, + const char *__restrict __format, ...) ; + + + + +extern int scanf (const char *__restrict __format, ...) ; + +extern int sscanf (const char *__restrict __s, + const char *__restrict __format, ...) __attribute__ ((__nothrow__ , __leaf__)); + + + + + + +extern int fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __asm__ ("" "__isoc99_fscanf") + + ; +extern int scanf (const char *__restrict __format, ...) __asm__ ("" "__isoc99_scanf") + ; +extern int sscanf (const char *__restrict __s, const char *__restrict __format, ...) __asm__ ("" "__isoc99_sscanf") __attribute__ ((__nothrow__ , __leaf__)) + + ; +# 432 "/usr/include/stdio.h" 3 4 +extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, + __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 2, 0))) ; + + + + + +extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__format__ (__scanf__, 1, 0))) ; + + +extern int vsscanf (const char *__restrict __s, + const char *__restrict __format, __gnuc_va_list __arg) + __attribute__ ((__nothrow__ , __leaf__)) __attribute__ ((__format__ (__scanf__, 2, 0))); + + + + +extern int vfscanf (FILE *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vfscanf") + + + + __attribute__ ((__format__ (__scanf__, 2, 0))) ; +extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vscanf") + + __attribute__ ((__format__ (__scanf__, 1, 0))) ; +extern int vsscanf (const char *__restrict __s, const char *__restrict __format, __gnuc_va_list __arg) __asm__ ("" "__isoc99_vsscanf") __attribute__ ((__nothrow__ , __leaf__)) + + + + __attribute__ ((__format__ (__scanf__, 2, 0))); +# 485 "/usr/include/stdio.h" 3 4 +extern int fgetc (FILE *__stream); +extern int getc (FILE *__stream); + + + + + +extern int getchar (void); + + + + + + +extern int getc_unlocked (FILE *__stream); +extern int getchar_unlocked (void); +# 510 "/usr/include/stdio.h" 3 4 +extern int fgetc_unlocked (FILE *__stream); +# 521 "/usr/include/stdio.h" 3 4 +extern int fputc (int __c, FILE *__stream); +extern int putc (int __c, FILE *__stream); + + + + + +extern int putchar (int __c); +# 537 "/usr/include/stdio.h" 3 4 +extern int fputc_unlocked (int __c, FILE *__stream); + + + + + + + +extern int putc_unlocked (int __c, FILE *__stream); +extern int putchar_unlocked (int __c); + + + + + + +extern int getw (FILE *__stream); + + +extern int putw (int __w, FILE *__stream); + + + + + + + +extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream) + ; +# 603 "/usr/include/stdio.h" 3 4 +extern __ssize_t __getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) ; +extern __ssize_t getdelim (char **__restrict __lineptr, + size_t *__restrict __n, int __delimiter, + FILE *__restrict __stream) ; + + + + + + + +extern __ssize_t getline (char **__restrict __lineptr, + size_t *__restrict __n, + FILE *__restrict __stream) ; + + + + + + + +extern int fputs (const char *__restrict __s, FILE *__restrict __stream); + + + + + +extern int puts (const char *__s); + + + + + + +extern int ungetc (int __c, FILE *__stream); + + + + + + +extern size_t fread (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream) ; + + + + +extern size_t fwrite (const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __s); +# 673 "/usr/include/stdio.h" 3 4 +extern size_t fread_unlocked (void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream) ; +extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size, + size_t __n, FILE *__restrict __stream); + + + + + + + +extern int fseek (FILE *__stream, long int __off, int __whence); + + + + +extern long int ftell (FILE *__stream) ; + + + + +extern void rewind (FILE *__stream); +# 707 "/usr/include/stdio.h" 3 4 +extern int fseeko (FILE *__stream, __off_t __off, int __whence); + + + + +extern __off_t ftello (FILE *__stream) ; +# 731 "/usr/include/stdio.h" 3 4 +extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos); + + + + +extern int fsetpos (FILE *__stream, const fpos_t *__pos); +# 757 "/usr/include/stdio.h" 3 4 +extern void clearerr (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); + +extern int feof (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + +extern int ferror (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + + +extern void clearerr_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); +extern int feof_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; +extern int ferror_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + + + + +extern void perror (const char *__s); + + + + + +# 1 "/usr/include/bits/sys_errlist.h" 1 3 4 +# 26 "/usr/include/bits/sys_errlist.h" 3 4 +extern int sys_nerr; +extern const char *const sys_errlist[]; +# 782 "/usr/include/stdio.h" 2 3 4 + + + + +extern int fileno (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + + + +extern int fileno_unlocked (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; +# 800 "/usr/include/stdio.h" 3 4 +extern FILE *popen (const char *__command, const char *__modes) ; + + + + + +extern int pclose (FILE *__stream); + + + + + +extern char *ctermid (char *__s) __attribute__ ((__nothrow__ , __leaf__)); +# 840 "/usr/include/stdio.h" 3 4 +extern void flockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); + + + +extern int ftrylockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)) ; + + +extern void funlockfile (FILE *__stream) __attribute__ ((__nothrow__ , __leaf__)); +# 858 "/usr/include/stdio.h" 3 4 +extern int __uflow (FILE *); +extern int __overflow (FILE *, int); +# 873 "/usr/include/stdio.h" 3 4 + +# 5 "error.h" 2 + + + +# 7 "error.h" +enum errcode { + OK = 0, + GENERAL_ERROR = 1, + COMMAND_NOT_FOUND = 2, + UNKNOWN_ID, + SYNTAX_ERROR, + INVALID_ARGUMENTS +}; +# 6 "scope.c" 2 +# 1 "debug.h" 1 + + + + + +extern char verbose; +# 7 "scope.c" 2 +# 15 "scope.c" +void free_layer(scope_layer *layer); + +void free_layer(scope_layer *layer) { + for (scope_entry *entry = layer->head; entry;) { + scope_entry *x = entry; + entry = entry->prev; + free(x->id); + free(x); + } + + free(layer); +} + +void scope_push_layer(scope *sc) { + scope_layer *new_layer = malloc(sizeof (*new_layer)); + if (!new_layer) do { fprintf( +# 30 "scope.c" 3 4 + stderr +# 30 "scope.c" + , "cannot malloc?"); fprintf( +# 30 "scope.c" 3 4 + stderr +# 30 "scope.c" + , "\n"); exit(GENERAL_ERROR); } while (0); + + new_layer->prev = *sc; + new_layer->head = 0; + + *sc = new_layer; +} + +void scope_pop_layer(scope *sc) { + scope new_sc = (**sc).prev; + free_layer(*sc); + *sc = new_sc; +} + +void scope_add_entry(scope sc, char *id, LLVMValueRef val, LLVMTypeRef type) { + scope_entry *new_entry = malloc(sizeof (*new_entry)); + if (!new_entry) do { fprintf( + stderr + , "cannot malloc?"); fprintf( + stderr + , "\n"); exit(GENERAL_ERROR); } while (0); + + do { if (verbose) { fprintf( + stderr + , "adding entry for %s\n", id); } } while (0); + + new_entry->id = strdup(id); + new_entry->value = val; + new_entry->type = type; + + scope_layer *layer = sc; + new_entry->prev = layer->head; + layer->head = new_entry; +} + +scope_entry *scope_find(scope sc, char *id) { + for (scope_layer *layer = sc; layer; layer = layer->prev) { + for (scope_entry *entry = layer->head; entry; entry = entry->prev) { + if (!strcmp(entry->id, id)) { + return entry; + } + } + } + + return 0; +} @@ -0,0 +1,29 @@ +#ifndef SEXPR_H +#define SEXPR_H + +typedef struct YYLTYPE { + int first_line; + int first_column; + int last_line; + int last_column; +} YYLTYPE; +typedef YYLTYPE lloc_t; + +#define YYLTYPE_IS_DECLARED 1 +#define YYLTYPE_IS_TRIVIAL 1 + +typedef struct sexpr { + int type; + union contents { + double f; + char *s; + int i; + struct node { + struct sexpr *l; + struct sexpr *r; + } n; + } contents; + lloc_t lloc; +} sexpr; + +#endif /* SEXPR_H */ diff --git a/simple.int b/simple.int deleted file mode 100644 index 9d55f15..0000000 --- a/simple.int +++ /dev/null @@ -1,12 +0,0 @@ -[type test [(INT x) (INT y)]] -[def (INT testest) [] [test.y [test 3 10]]] -[def (INT dec) [(INT n)] [- n 1]] -[def (INT inc) [(INT n)] [+ n 1]] -[def (INT fact) [(INT n)] [debug_int [if [dec n] [* n [fact [dec n]]] 1]]] -[def (INT ttt) [(INT x) (INT y)] [test y x]] -[def (INT !) [(INT b)] [if b 0 1]] -[def (INT !=) [(INT x) (INT y)] [- x y]] -[def (INT ==) [(INT x) (INT y)] [! [!= x y]]] -[def (INT or) [(INT a) (INT b)] [if a 1 b]] -[def (INT fib) [(INT n)] [debug_int [if [or [== n 0] [== n 1]] 1 [+ [fib [- n 1]] [fib [- n 2]]]]]] -[def (INT inter_main) [] [fib [test.y [ttt 10 10]]]] diff --git a/sinter.c b/sinter.c new file mode 100644 index 0000000..1021d86 --- /dev/null +++ b/sinter.c @@ -0,0 +1,215 @@ +#include <stdlib.h> +#include <stdio.h> +#include <assert.h> +#include <string.h> +#include <unistd.h> + +#include "sinter.h" +#include "sexpr.h" +#include "llvm_codegen.h" +#include "sinter_codegen.h" +#include "graphviz_codegen.h" +#include "parse.h" +#include "debug.h" +#include "error.h" + +typedef unsigned int uint; + +static char *input_filename; +static char *output_filename; +static format_t format; + +extern FILE *yyin; +int yyparse(void); + +int verbose; + +sexpr *new_sexpr(int type, contents val, lloc_t lloc) { + /* FIXME: unchecked memory allocation! */ + sexpr *ret = malloc(sizeof (*ret)); + ret->type = type; + ret->contents = val; + ret->lloc = lloc; + return ret; +} + +sexpr *new_int(int num, lloc_t lloc) { + contents c; + c.i = num; + return new_sexpr(INT, c, lloc); +} + +sexpr *new_str(char *str, lloc_t lloc) { + contents c; + c.s = str; + return new_sexpr(STRING, c, lloc); +} + +sexpr *new_float(double num, lloc_t lloc) { + contents c; + c.f = num; + return new_sexpr(FLOAT, c, lloc); +} + +sexpr *new_id(char *id, lloc_t lloc) { + contents c; + c.s = id; + return new_sexpr(ID, c, lloc); +} + +sexpr *new_node(sexpr *l, sexpr *r, lloc_t lloc) { + contents c; + c.n.l = l; + c.n.r = r; + return new_sexpr(BRANCH, c, lloc); +} + +void prologue() { + + switch (format) { + + case LLVM_INTERMEDIATE: + case BITCODE: + case INTERPRET: + llvm_codegen_prologue(input_filename); + break; + + case GRAPHVIZ: + graphviz_codegen_prologue(); + break; + + case SINTER: + sinter_codegen_prologue(); + break; + + } +} + +void handle(sexpr *se) { + + switch (format) { + + case LLVM_INTERMEDIATE: + case BITCODE: + case INTERPRET: + llvm_codegen(se); + break; + + case GRAPHVIZ: + graphviz_codegen(se); + break; + + case SINTER: + sinter_codegen(se); + break; + + } +} + +void epilogue(char *output_filename, format_t format) { + + switch (format) { + + case LLVM_INTERMEDIATE: + case BITCODE: + case INTERPRET: + llvm_codegen_epilogue(output_filename, format); + break; + + case GRAPHVIZ: + graphviz_codegen_epilogue(output_filename); + break; + + case SINTER: + sinter_codegen_epilogue(output_filename); + break; + + } +} + +int main(int argc, char **argv) { + int c; + + output_filename = 0; + format = LLVM_INTERMEDIATE; + + verbose = 0; + + while ((c = getopt(argc, argv, "bghilo:qsv")) != -1) { + switch (c) { + case 'b': + format = BITCODE; + break; + + case 'g': + format = GRAPHVIZ; + break; + + case 'h': + printf( "usage: %s [options] <input_file>\n" + "-b Specify bitcode-format output\n" + "-c Compile mode\n" + "-g Output a Graphviz .dot file\n" + "-h Print this help message\n" + "-i Interpret mode\n" + "-l Specify human-readable output\n" + "-o <output> Specify output filename\n" + "-q Quiet (default)\n" + "-s Output S-expression description\n" + "-v Verbose\n", + argv[0]); + exit(0); + + case 'i': + format = INTERPRET; + break; + + case 'l': + format = LLVM_INTERMEDIATE; + break; + + case 'o': + output_filename = optarg; + break; + + case 'q': + verbose = 0; + break; + + case 's': + format = SINTER; + break; + + case 'v': + verbose = 1; + break; + + case '?': + switch (optopt) { + case 'o': + error(INVALID_ARGUMENTS, + "-%c option requires an argument", optopt); + break; + + default: + error(INVALID_ARGUMENTS, "unknown option %c", optopt); + } + break; + + default: + error(INVALID_ARGUMENTS, "error parsing arguments"); + } + } + + if (argc - optind > 1) { + error(INVALID_ARGUMENTS, "too many arguments"); + } else if (argc - optind == 1) { + input_filename = argv[argc - 1]; + yyin = fopen(input_filename, "r"); + } + + prologue(); + yyparse(); + epilogue(output_filename, format); + return 0; +} diff --git a/sinter.h b/sinter.h new file mode 100644 index 0000000..0288887 --- /dev/null +++ b/sinter.h @@ -0,0 +1,31 @@ +#ifndef SINTER_H +#define SINTER_H + +#include <stdio.h> + +#include "sexpr.h" +#include "parse.h" + +typedef enum { + BITCODE, + LLVM_INTERMEDIATE, + INTERPRET, + GRAPHVIZ, + SINTER +} format_t; + +typedef struct node node; +typedef union contents contents; + +sexpr *new_int(int num, lloc_t lloc); +sexpr *new_float(double num, lloc_t lloc); +sexpr *new_id(char *id, lloc_t lloc); +sexpr *new_node(sexpr *l, sexpr *r, lloc_t lloc); +sexpr *new_str(char *str, lloc_t lloc); + +void print_sexpr(sexpr *se); +void fprint_sexpr(FILE *f, sexpr *se); + +void handle(sexpr *se); + +#endif /* SINTER_H */ diff --git a/sinter_codegen.c b/sinter_codegen.c new file mode 100644 index 0000000..56930df --- /dev/null +++ b/sinter_codegen.c @@ -0,0 +1,76 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "sinter_codegen.h" +#include "sinter.h" +#include "parse.h" +#include "error.h" + +typedef struct func_str_s { + /* FIXME: magic size */ + char buf[1000]; + struct func_str_s *next; +} func_str; + +func_str *ffs; +func_str *lfs; + +static int fill_buf(char *buf, sexpr *ast) { + char *old_buf = buf; + + if (!ast) { + return sprintf(buf, "()"); + + } else switch (ast->type) { + + case INT: + return sprintf(buf, "%i", ast->contents.i); + + case FLOAT: + return sprintf(buf, "%f", ast->contents.f); + + case STRING: + return sprintf(buf, "\"%s\"", ast->contents.s); + + case ID: + return sprintf(buf, "%s", ast->contents.s); + + case BRANCH: + buf += sprintf(buf, "("); + buf += fill_buf(buf, ast->contents.n.l); + buf += sprintf(buf, ";"); + buf += fill_buf(buf, ast->contents.n.r); + buf += sprintf(buf, ")"); + return buf - old_buf; + + default: + return sprintf(buf, "?"); + } +} + +void sinter_codegen_prologue() { + ffs = 0; + lfs = 0; +} + +void sinter_codegen(sexpr *ast) { + func_str *fs = (func_str *) malloc(sizeof (*fs)); + if (!fs) error(GENERAL_ERROR, "cannot malloc"); + + fill_buf(fs->buf, ast); + fs->next = 0; + + if (!ffs) ffs = fs; + if (lfs) lfs->next = fs; + lfs = fs; +} + +int sinter_codegen_epilogue(char *output_filename) { + FILE *fp = fopen(output_filename, "w"); + + for (func_str *fs = ffs; fs; fs = fs->next) { + fprintf(fp, "%s\n", fs->buf); + } + + return 0; +} diff --git a/sinter_codegen.h b/sinter_codegen.h new file mode 100644 index 0000000..e0a0737 --- /dev/null +++ b/sinter_codegen.h @@ -0,0 +1,10 @@ +#ifndef SINTER_CODEGEN_H +#define SINTER_CODEGEN_H + +#include "sinter.h" + +void sinter_codegen_prologue(); +void sinter_codegen(sexpr *ast); +int sinter_codegen_epilogue(char *output_filename); + +#endif /* SINTER_CODEGEN_H */ |