619659bdc122 — Leonard Ritter 2 months ago
* added `O0` compile flag (which appears to do nothing, currently)
M include/scopes/config.h +1 -4
@@ 19,7 19,7 @@ 
 // turning this on is detrimental to startup time
 // scopes output is typically clean enough to provide fairly good performance
 // on its own.
-#define SCOPES_OPTIMIZE_ASSEMBLY 0
+// #define SCOPES_OPTIMIZE_ASSEMBLY CF_O1
 
 // any location error aborts immediately and can not be caught
 #define SCOPES_EARLY_ABORT 0

          
@@ 40,9 40,6 @@ 
 // 100% of the time, the answer is yes because the performance is much better.
 #define SCOPES_MAX_RECURSIONS 64
 
-// maximum number of jump skips permitted
-#define SCOPES_MAX_SKIP_JUMPS 256
-
 // folder name in ~/.cache in which all cache files are stored
 #define SCOPES_CACHE_DIRNAME "scopes"
 

          
M lib/scopes/core.sc +5 -3
@@ 4019,9 4019,9 @@ fn exec-module (expr eval-scope)
             do
                 hide-traceback;
                 sc_compile wrapf
-                    compile-flag-cache
-                    # can't use this flag yet because it breaks code
-                    #| compile-flag-cache compile-flag-O2
+                    | compile-flag-cache
+                        # can't use this flag yet because it breaks code
+                        #compile-flag-O1
         if (('typeof f) == StageFunctionType)
             let fptr = (f as StageFunctionType)
             let result =

          
@@ 4685,6 4685,7 @@ let parse-compile-flags =
                         \ " " (repr 'dump-function)
                         \ " " (repr 'dump-time)
                         \ " " (repr 'no-debug-info)
+                        \ " " (repr 'O0)
                         \ " " (repr 'O1)
                         \ " " (repr 'O2)
                         \ " " (repr 'O3)

          
@@ 4701,6 4702,7 @@ let parse-compile-flags =
                     case 'dump-function compile-flag-dump-function
                     case 'dump-time compile-flag-dump-time
                     case 'no-debug-info compile-flag-no-debug-info
+                    case 'O0 compile-flag-O0
                     case 'O1 compile-flag-O1
                     case 'O2 compile-flag-O2
                     case 'O3 compile-flag-O3

          
M src/compiler_flags.hpp +3 -2
@@ 15,8 15,9 @@ namespace scopes {
     T(CF_DumpFunction, (1 << 2), "compile-flag-dump-function") \
     T(CF_DumpTime, (1 << 3), "compile-flag-dump-time") \
     T(CF_NoDebugInfo, (1 << 4), "compile-flag-no-debug-info") \
-    T(CF_O1, (1 << 5), "compile-flag-O1") \
-    T(CF_O2, (1 << 6), "compile-flag-O2") \
+    T(CF_O0, (1 << 4), "compile-flag-O0") \
+    T(CF_O1, (CF_O0 | (1 << 5)), "compile-flag-O1") \
+    T(CF_O2, (CF_O0 | (1 << 6)), "compile-flag-O2") \
     T(CF_O3, (CF_O1 | CF_O2), "compile-flag-O3") \
     T(CF_Cache, (1 << 7), "compile-flag-cache") \
 

          
M src/gen_llvm.cpp +2 -9
@@ 3365,13 3365,6 @@ SCOPES_RESULT(void) compile_object(const
     CompilerFileKind kind, const String *path, const Scope *scope, uint64_t flags) {
     SCOPES_RESULT_TYPE(void);
     Timer sum_compile_time(TIMER_Compile);
-#if SCOPES_COMPILE_WITH_DEBUG_INFO
-#else
-    flags |= CF_NoDebugInfo;
-#endif
-#if SCOPES_OPTIMIZE_ASSEMBLY
-    flags |= CF_O3;
-#endif
 
     LLVMIRGenerator ctx;
     ctx.generate_object = true;

          
@@ 3455,8 3448,8 @@ SCOPES_RESULT(ConstPointerRef) compile(c
 #else
     flags |= CF_NoDebugInfo;
 #endif
-#if SCOPES_OPTIMIZE_ASSEMBLY
-    flags |= CF_O3;
+#ifdef SCOPES_OPTIMIZE_ASSEMBLY
+    flags |= SCOPES_OPTIMIZE_ASSEMBLY;
 #endif
 
     /*

          
M testing/test_all.sc +1 -0
@@ 19,6 19,7 @@ test-modules
     .test_capture
     .test_clang
     .test_closure
+    .test_codegen
     .test_conversion
     .test_convert
     .test_copy

          
A => testing/test_codegen.sc +9 -0
@@ 0,0 1,9 @@ 
+
+using import testing
+
+fn elidable (x)
+    extractvalue (insertvalue x 1 0) 0
+
+compile (static-typify elidable (tuple i32 i32)) 'dump-function 'O1
+
+;
  No newline at end of file