Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/binary-releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: ocaml/setup-ocaml@v2
with:
# Version of the OCaml compiler to initialise
ocaml-compiler: 4.11.2
ocaml-compiler: 4.13.1

- name: Install dependencies
run: |
Expand Down
7 changes: 6 additions & 1 deletion makefiles/c_backend.mk
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DGFIP_TARGET_FLAGS?=-g,-O,-k4
# bouclant sur la table des variables restituables (IN_init_extraction).
DGFIP_COMMON_FLAGS=-m$(YEAR),-X

MLANG_DGFIP=$(MLANG_BIN) $(MLANG_DEFAULT_OPTS) $(MLANG_DGFIP_C_OPTS)
MLANG_DGFIP=$(MLANG_BIN) $(MLANG_DEFAULT_OPTS) $(MLANG_DGFIP_C_OPTS) $(NO_LOCAL_VAR_FLAG)

QUIET=>/dev/null # Uncomment to suppress output

Expand Down Expand Up @@ -56,6 +56,7 @@ calc/mlang.h: $(SOURCE_FILES) $(SOURCE_EXT_FILES) | calc_dir
@echo " MPP_FUNCTION=$(MPP_FUNCTION_BACKEND)"
@echo " DGFIP_TARGET_FLAGS=$(DGFIP_TARGET_FLAGS)"
@echo " DGFIP_COMMON_FLAGS=$(DGFIP_COMMON_FLAGS)"
@echo " NO_LOCAL_VAR_FLAG=$(NO_LOCAL_VAR_FLAG)"
@$(MLANG_DGFIP) \
--income-year=$(YEAR) \
--comparison_error_margin=$(COMPARISON_ERROR_MARGIN) \
Expand Down Expand Up @@ -137,7 +138,11 @@ endif

ifeq ($(call is_in,$(DGFIP_DIR)),1)
backend_tests: compile_dgfip_c_backend
ifdef OUTPUT_TEST_TIME_IN_DIR
time -f "%U" --append -o $(OUTPUT_TEST_TIME_IN_DIR)/$(CC)$(OV)_time ./cal -mode primitif -recursif ${TEST_FILES}
else
./cal -mode primitif -recursif ${TEST_FILES}
endif
endif

ifeq ($(call is_in,$(DGFIP_DIR)),1)
Expand Down
27 changes: 19 additions & 8 deletions makefiles/variables.mk
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,20 @@ ifeq ($(origin CC),default)
CC=clang
endif

ifndef OV
ifeq ($(CC), clang)
OV=2
else ifeq ($(CC), gcc)
OV=1
endif
endif

COMMON_CFLAGS?=-std=c89 -pedantic

# Options pour le compilateur C
# Attention, très long à compiler avec GCC en O2/O3
COMMON_CFLAGS?=-std=c89 -pedantic
ifeq ($(CC), clang)
COMPILER_SPECIFIC_CFLAGS=-O2
# COMPILER_SPECIFIC_CFLAGS=
else ifeq ($(CC), gcc)
COMPILER_SPECIFIC_CFLAGS=-O1
endif
COMPILER_SPECIFIC_CFLAGS=-O$(OV)

BACKEND_CFLAGS?=$(COMMON_CFLAGS) $(COMPILER_SPECIFIC_CFLAGS)

# Directory of the driver sources for tax calculator
Expand Down Expand Up @@ -107,6 +112,12 @@ else
TEST_FILES=$(TESTS_DIR)/*
endif

ifeq ($(NO_LOCAL_VAR), 1)
NO_LOCAL_VAR_FLAG=--no-local-var
else
NO_LOCAL_VAR_FLAG=
endif

# Précision des comparaisons entre flottants pendant les calculs
COMPARISON_ERROR_MARGIN?=0.000001

Expand All @@ -115,7 +126,7 @@ MLANG_INTERPRETER_OPTS=\
--comparison_error_margin=$(COMPARISON_ERROR_MARGIN) \
--mpp_function=$(MPP_FUNCTION)

MLANG_TEST=$(MLANG_BIN) $(MLANG_DEFAULT_OPTS) $(MLANG_INTERPRETER_OPTS) $(CODE_COVERAGE_FLAG)
MLANG_TEST=$(MLANG_BIN) $(MLANG_DEFAULT_OPTS) $(MLANG_INTERPRETER_OPTS) $(CODE_COVERAGE_FLAG) $(NO_LOCAL_VAR_FLAG)

DGFIP_DIR?=examples/dgfip_c/ml_primitif

Expand Down
9 changes: 5 additions & 4 deletions src/mlang/backend_compilers/bir_to_dgfip_c.ml
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,11 @@ and generate_c_expr (p : Mir.program) (e : Mir.expression Pos.marked) :
let se1 = generate_c_expr p e1 in
let se2 = generate_c_expr p e2 in
comparison op se1 se2
| Binop (op, e1, e2) ->
let se1 = generate_c_expr p e1 in
let se2 = generate_c_expr p e2 in
binop op se1 se2
| Binop (op, l) -> (
let sl = List.map (generate_c_expr p) l in
match sl with
| [] -> assert false (* Cannot have a binop with no arguments *)
| hd :: tl -> List.fold_left (binop op) hd tl)
| Unop (op, e) -> unop op @@ generate_c_expr p e
| Conditional (c, t, f_opt) ->
let cond = generate_c_expr p c in
Expand Down
Loading
Loading