From 4a296032ab7de20f80ba088104614b340727099b Mon Sep 17 00:00:00 2001 From: Christoffer Lerno Date: Sun, 28 Aug 2022 16:22:10 +0200 Subject: [PATCH] Add fshl fshr + new optimizer. --- lib/std/bits.c3 | 20 +++++++++ lib/std/core/types.c3 | 2 +- src/build/build_options.c | 6 +++ src/build/build_options.h | 26 ++++++------ src/build/builder.c | 1 + src/compiler/enums.h | 2 + src/compiler/llvm_codegen.c | 72 ++++++++++++++++++++++++++++---- src/compiler/llvm_codegen_expr.c | 4 ++ src/compiler/sema_expr.c | 11 +++++ src/compiler/symtab.c | 2 + src/version.h | 2 +- 11 files changed, 127 insertions(+), 21 deletions(-) diff --git a/lib/std/bits.c3 b/lib/std/bits.c3 index e2f12c6ea..1a6e7fd17 100644 --- a/lib/std/bits.c3 +++ b/lib/std/bits.c3 @@ -39,3 +39,23 @@ macro clz(i) @builtin { return $$clz(i); } + +/** + * @require types::is_intlike($typeof(hi)) && types::is_intlike($typeof(lo)) && types::is_intlike($typeof(shift)) `The input must be an integer or integer vector` + * @require $typeof(hi).typeid == $typeof(lo).typeid `Hi and low arguments must have the same type` + * @require $typeof(hi).typeid == $typeof(shift).typeid `The shift value must have the same type` + **/ +macro fshl(hi, lo, shift) @builtin +{ + return $$fshl(hi, lo, ($typeof(hi))shift); +} + +/** + * @require types::is_intlike($typeof(hi)) && types::is_intlike($typeof(lo)) && types::is_intlike($typeof(shift)) `The input must be an integer or integer vector` + * @require $typeof(hi).typeid == $typeof(lo).typeid `Hi and low arguments must have the same type` + * @require $typeof(hi).typeid == $typeof(shift).typeid `The shift value must have the same type` + **/ +macro fshr(hi, lo, shift) @builtin +{ + return $$fshr(hi, lo, ($typeof(hi))shift); +} diff --git a/lib/std/core/types.c3 b/lib/std/core/types.c3 index b7e05ca46..7a2d1ec17 100644 --- a/lib/std/core/types.c3 +++ b/lib/std/core/types.c3 @@ -128,7 +128,7 @@ macro bool is_intlike($Type) $case UNSIGNED_INT: return true; $case VECTOR: - return is_intlike($Type.inner); + return $Type.inner.kind == TypeKind.SIGNED_INT || $Type.inner.kind == TypeKind.UNSIGNED_INT; $default: return false; $endswitch; diff --git a/src/build/build_options.c b/src/build/build_options.c index 53ffb9fa6..46417f2ba 100644 --- a/src/build/build_options.c +++ b/src/build/build_options.c @@ -114,6 +114,7 @@ static void usage(void) OUTPUT(" -L - Append the directory to the linker search paths."); OUTPUT(" -z - Send the as a parameter to the linker."); OUTPUT(" --forcelinker - Force built in linker usage when doing non-cross linking."); + OUTPUT(" --newoptimizer - Use new optimizer pipeline."); OUTPUT(""); OUTPUT(" --reloc=