Skip to content

Commit 1e38f0e

Browse files
committed
add Expr(:ivdepscope)
1. introduce `jl_ivdepscope_sym` 2. define `jl_ivdepscope_error` to thrown error message.
1 parent 30fe8cc commit 1e38f0e

File tree

10 files changed

+18
-6
lines changed

10 files changed

+18
-6
lines changed

base/compiler/validation.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const VALID_EXPR_HEADS = IdDict{Symbol,UnitRange{Int}}(
2828
:isdefined => 1:1,
2929
:code_coverage_effect => 0:0,
3030
:loopinfo => 0:typemax(Int),
31+
:ivdepscope => 1:1,
3132
:gc_preserve_begin => 0:typemax(Int),
3233
:gc_preserve_end => 0:typemax(Int),
3334
:thunk => 1:1,
@@ -145,7 +146,7 @@ function validate_code!(errors::Vector{>:InvalidCodeError}, c::CodeInfo, is_top_
145146
head === :inbounds || head === :foreigncall || head === :cfunction ||
146147
head === :const || head === :enter || head === :leave || head === :pop_exception ||
147148
head === :method || head === :global || head === :static_parameter ||
148-
head === :new || head === :splatnew || head === :thunk || head === :loopinfo ||
149+
head === :new || head === :splatnew || head === :thunk || head === :loopinfo || head === :ivdepscope ||
149150
head === :throw_undef_if_not || head === :code_coverage_effect || head === :inline || head === :noinline
150151
validate_val!(x)
151152
else

src/ast.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ JL_DLLEXPORT jl_sym_t *jl_copyast_sym;
6868
JL_DLLEXPORT jl_sym_t *jl_cfunction_sym;
6969
JL_DLLEXPORT jl_sym_t *jl_pure_sym;
7070
JL_DLLEXPORT jl_sym_t *jl_loopinfo_sym;
71+
JL_DLLEXPORT jl_sym_t *jl_ivdepscope_sym;
7172
JL_DLLEXPORT jl_sym_t *jl_meta_sym;
7273
JL_DLLEXPORT jl_sym_t *jl_inert_sym;
7374
JL_DLLEXPORT jl_sym_t *jl_polly_sym;
@@ -317,6 +318,7 @@ void jl_init_common_symbols(void)
317318
jl_newvar_sym = jl_symbol("newvar");
318319
jl_copyast_sym = jl_symbol("copyast");
319320
jl_loopinfo_sym = jl_symbol("loopinfo");
321+
jl_ivdepscope_sym = jl_symbol("ivdepscope");
320322
jl_pure_sym = jl_symbol("pure");
321323
jl_meta_sym = jl_symbol("meta");
322324
jl_list_sym = jl_symbol("list");

src/ast.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@
296296
;; predicates and accessors
297297

298298
(define (quoted? e)
299-
(memq (car e) '(quote top core globalref outerref line break inert meta inbounds inline noinline loopinfo)))
299+
(memq (car e) '(quote top core globalref outerref line break inert meta inbounds inline noinline loopinfo ivdepscope)))
300300
(define (quotify e) `',e)
301301
(define (unquote e)
302302
(if (and (pair? e) (memq (car e) '(quote inert)))

src/interpreter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ static jl_value_t *eval_value(jl_value_t *e, interpreter_state *s)
314314
else if (head == jl_boundscheck_sym) {
315315
return jl_true;
316316
}
317-
else if (head == jl_meta_sym || head == jl_coverageeffect_sym || head == jl_inbounds_sym || head == jl_loopinfo_sym ||
317+
else if (head == jl_meta_sym || head == jl_coverageeffect_sym || head == jl_inbounds_sym || head == jl_loopinfo_sym || head == jl_ivdepscope_sym ||
318318
head == jl_aliasscope_sym || head == jl_popaliasscope_sym || head == jl_inline_sym || head == jl_noinline_sym) {
319319
return jl_nothing;
320320
}

src/jl_exported_funcs.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@
472472
XX(jl_tty_set_mode) \
473473
XX(jl_tupletype_fill) \
474474
XX(jl_typeassert) \
475+
XX(jl_ivdepscope_error) \
475476
XX(jl_type_equality_is_identity) \
476477
XX(jl_type_error) \
477478
XX(jl_type_error_rt) \

src/julia-syntax.scm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,7 +3516,7 @@ f(x) = yt(x)
35163516

35173517
(define lambda-opt-ignored-exprs
35183518
(Set '(quote top core line inert local-def unnecessary copyast
3519-
meta inbounds boundscheck loopinfo decl aliasscope popaliasscope
3519+
meta inbounds boundscheck loopinfo ivdepscope decl aliasscope popaliasscope
35203520
thunk with-static-parameters toplevel-only
35213521
global globalref outerref const-if-global thismodule
35223522
const atomic null true false ssavalue isdefined toplevel module lambda
@@ -4625,7 +4625,7 @@ f(x) = yt(x)
46254625
(cons (car e) args)))
46264626

46274627
;; metadata expressions
4628-
((line meta inbounds loopinfo gc_preserve_end aliasscope popaliasscope inline noinline)
4628+
((line meta inbounds loopinfo ivdepscope gc_preserve_end aliasscope popaliasscope inline noinline)
46294629
(let ((have-ret? (and (pair? code) (pair? (car code)) (eq? (caar code) 'return))))
46304630
(cond ((eq? (car e) 'line)
46314631
(set! current-loc e)

src/julia_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,7 @@ JL_DLLEXPORT jl_value_t *jl_get_exceptionf(jl_datatype_t *exception_type, const
534534

535535
JL_DLLEXPORT jl_value_t *jl_get_keyword_sorter(jl_value_t *f);
536536
JL_DLLEXPORT void jl_typeassert(jl_value_t *x, jl_value_t *t);
537+
JL_DLLEXPORT void jl_ivdepscope_error(void);
537538

538539
#define JL_CALLABLE(name) \
539540
JL_DLLEXPORT jl_value_t *name(jl_value_t *F, jl_value_t **args, uint32_t nargs)
@@ -1408,6 +1409,7 @@ extern JL_DLLEXPORT jl_sym_t *jl_copyast_sym;
14081409
extern JL_DLLEXPORT jl_sym_t *jl_cfunction_sym;
14091410
extern JL_DLLEXPORT jl_sym_t *jl_pure_sym;
14101411
extern JL_DLLEXPORT jl_sym_t *jl_loopinfo_sym;
1412+
extern JL_DLLEXPORT jl_sym_t *jl_ivdepscope_sym;
14111413
extern JL_DLLEXPORT jl_sym_t *jl_meta_sym;
14121414
extern JL_DLLEXPORT jl_sym_t *jl_inert_sym;
14131415
extern JL_DLLEXPORT jl_sym_t *jl_polly_sym;

src/macroexpand.scm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@
354354
,(resolve-expansion-vars-with-new-env (caddr arg) env m parent-scope inarg))))
355355
(else
356356
`(global ,(resolve-expansion-vars-with-new-env arg env m parent-scope inarg))))))
357-
((using import export meta line inbounds boundscheck loopinfo inline noinline) (map unescape e))
357+
((using import export meta line inbounds boundscheck loopinfo ivdepscope inline noinline) (map unescape e))
358358
((macrocall) e) ; invalid syntax anyways, so just act like it's quoted.
359359
((symboliclabel) e)
360360
((symbolicgoto) e)

src/method.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ static jl_value_t *resolve_globals(jl_value_t *expr, jl_module_t *module, jl_sve
8484
e->head == jl_quote_sym || e->head == jl_inert_sym ||
8585
e->head == jl_meta_sym || e->head == jl_inbounds_sym ||
8686
e->head == jl_boundscheck_sym || e->head == jl_loopinfo_sym ||
87+
e->head == jl_ivdepscope_sym ||
8788
e->head == jl_aliasscope_sym || e->head == jl_popaliasscope_sym ||
8889
e->head == jl_inline_sym || e->head == jl_noinline_sym) {
8990
// ignore these

src/rtutils.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,11 @@ JL_DLLEXPORT void jl_typeassert(jl_value_t *x, jl_value_t *t)
214214
jl_type_error("typeassert", t, x);
215215
}
216216

217+
JL_DLLEXPORT void jl_ivdepscope_error(void)
218+
{
219+
jl_errorf("Found ivdepscope outside @simd.");
220+
}
221+
217222
#ifndef HAVE_SSP
218223
JL_DLLEXPORT uintptr_t __stack_chk_guard = (uintptr_t)0xBAD57ACCBAD67ACC; // 0xBADSTACKBADSTACK
219224

0 commit comments

Comments
 (0)