Background:
- A list of libc builtins (for operations with memory and strings) should be supported: #I3ZSKS:mapleC builtin support
- Required changes for backend / middle end and FEIR were added by previously merged PRs #1063,#1076.
- This PR contains the code of HIR2MPL implementation of builtins emitting via intrinsicop/intrinsiccall.
Solution:
I. From AST to FEIR:
-
intrinsics for libc functions derived as operations (no side effects) from UniqueFEIRExpr by CreateIntrinsicOpForC:
INTRN_C_memcmp
INTRN_C_strlen
INTRN_C_strcmp
INTRN_C_strncmp
INTRN_C_strchr
INTRN_C_strrchr -
intrinsics for libc functions derived as intrinsiccalls from UniqueFEIRExpr by CreateIntrinsicCallForC function (also added in this PR):
INTRN_C_memcpy;
INTRN_C_memmove;
INTRN_C_memset;
INTRN_C_strcpy;
INTRN_C_strncpy;
I*. Intrinsics emit refactoring:
New macro for intrinsics emit are added for more convenient way of default emitter of intrinsic call/op function registration: DEF_INTRIN_C_CALL and DEF_INTRIN_C_OP.
II. Sanity tests (SANITY0043-64) are added for builtins testing.