/*===-- calc.c - tool for testing libLLVM and llvm-c API ------------------===*\ |* *| |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *| |* Exceptions. *| |* See https://llvm.org/LICENSE.txt for license information. *| |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *| |* *| |*===----------------------------------------------------------------------===*| |* *| |* This file implements the --calc command in llvm-c-test. --calc reads lines *| |* from stdin, parses them as a name and an expression in reverse polish *| |* notation and prints a module with a function with the expression. *| |* *| \*===----------------------------------------------------------------------===*/ #include "llvm-c-test.h" #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> binop_func_t; static LLVMOpcode op_to_opcode(char op) { … } #define MAX_DEPTH … static LLVMValueRef build_from_tokens(char **tokens, int ntokens, LLVMBuilderRef builder, LLVMValueRef param) { … } static void handle_line(char **tokens, int ntokens) { … } int llvm_calc(void) { … }