<commit_before>#===------------------------------------------------------------------===
# Typed IR (initial input)
#===------------------------------------------------------------------===

# IR Constants

# operator
add                = 'add'
sub                = 'sub'
mult               = 'mult'
div                = 'div'
mod                = 'mod'
pow                = 'pow'
lshift             = 'lshift'
rshift             = 'rshift'
bitor              = 'bitor'
bitxor             = 'bitxor'
bitand             = 'bitand'
floordiv           = 'floordiv'

# unaryop
invert             = 'invert'
not_               = 'not'
uadd               = 'uadd'
usub               = 'usub'

# cmpop
eq                 = 'eq'
noteq              = 'noteq'
lt                 = 'lt'
lte                = 'lte'
gt                 = 'gt'
gte                = 'gte'
is_                = 'is'
isnot              = 'isnot'
in_                = 'in'
notin              = 'notin'

# math
sin                = ' sin '
asin               = ' asin '
sinh               = ' sinh '
asinh              = ' asinh'
cos                = ' cos '
acos               = ' acos '
cosh               = ' cosh '
acosh              = ' acosh'
tan                = ' tan '
atan               = ' atan '
atan2              = ' atan2 '
tanh               = ' tanh '
atanh              = ' atanh'
log                = ' log '
log2               = ' log2 '
log10              = ' log10 '
log1p              = ' log1p'
exp                = ' exp '
exp2               = ' exp2 '
expm1              = ' expm1'
floor              = ' floor '
ceil               = ' ceil '
abs                = ' abs '
erfc               = ' erfc '
rint               = ' rint'
pow                = ' pow '
round              = ' round'

# ______________________________________________________________________
# Constants

constant           = 'constant'         # (object pyval)

# ______________________________________________________________________
# Variables

alloca             = 'alloca'           # (expr n)
load               = 'load'             # (alloc var)
store              = 'store'            # (alloc var, expr value)
# phi is below

# ______________________________________________________________________
# Primitives

# Arrays/lists
map                = 'map'              # (fn func, expr arrays, const axes)
reduce             = 'reduce'           # (fn func, expr array, const axes)
scan               = 'scan'             # (fn func, expr array, const axes)
allpairs           = 'allpairs'         # (fn func, expr array, const axes)

# Scalars
min                = 'min'              # expr *args
max                = 'max'              # expr *args

# ______________________________________________________________________
# Containers

### TODO: This should be library code instead ?
# No matter how we do this, we'll end up reinventing pypy.

# ______________________________________________________________________
# Boxing and coercion

box                = 'box'              # (expr arg)
unbox              = 'unbox'            # (expr arg)
convert            = 'convert'          # (expr arg)

# ______________________________________________________________________
# Constructors

new_list           = 'new_list'         # (expr elems)
new_tuple          = 'new_tuple'        # (expr elems)
new_dict           = 'new_dict'         # (expr keys, expr values)
new_set            = 'new_set'          # (expr elems)

new_string         = 'new_string'       # (expr string)
new_unicode        = 'new_unicode'      # (expr string)

new_object         = 'new_object'       # (expr args)
new_struct         = 'new_struct'       # (expr *initializers)
new_complex        = 'new_complex'      # (expr real, expr imag)
new_data           = 'new_data'         # (expr size)

# ______________________________________________________________________
# Control flow

# Basic block leaders
phi                = 'phi'              # (expr blocks, expr values)
exc_setup          = 'exc_setup'        # (str body, exc_catch *handlers,
                                        #  str orelse)
exc_catch          = 'exc_catch'        # (expr *types)

# Basic block terminators
jump               = 'jump'             # (str target)
cbranch            = 'cbranch'          # (expr test, str true_target,
                                        #  str false_target)
exc_throw          = 'exc_throw'        # (expr exn)
ret                = 'ret'              # (expr result)

# ______________________________________________________________________
# Functions

function           = 'function'         # (str funcname)
partial            = 'partial'          # (fn function, expr vals)
# virtual_method     = 'virtual_method'   # (expr extobj, string methname)
func_from_addr     = 'func_from_addr'   # (expr pointer)

call               = 'call'             # (expr obj, expr *args)
call_obj           = 'call_obj'         # (expr obj, expr args, expr kwds)
call_virtual       = 'call_virtual'     # (fn method, expr args, expr kwds)
call_external      = 'call_external'    # (str name, expr *args)
call_math          = 'call_math'        # (str func, expr *args)

# ______________________________________________________________________
# Pointers

ptradd             = 'ptradd'           # (expr pointer, expr addition)
ptrload            = 'ptrload'          # (expr pointer)
ptrstore           = 'ptrstore'         # (expr pointer, expr value)
ptrcast            = 'ptrcast'          # (expr pointer)
ptr_isnull         = 'ptr_isnull'       # (expr pointer)

# ______________________________________________________________________
# Iterators

getiter            = 'getiter'          # (expr obj)
next               = 'next'             # (iter it)

# ______________________________________________________________________
# Generators

yield_             = 'yield'            # (expr value)
yieldfrom          = 'yieldfrom'        # (expr value)

# ______________________________________________________________________
# Attributes

getfield_struct    = 'getfield_struct'  # (expr struct, int field_idx)
setfield_struct    = 'setfield_struct'  # (expr struct, int field_idx, expr value)
getfield           = 'getfield'         # (expr value, str attr)
setfield           = 'setfield'         # (expr value, str attr, expr value)

# ______________________________________________________________________
# Indexing

getindex           = 'getindex'         # (expr value, expr indices)
setindex           = 'setindex'         # (expr value, expr indices, expr value)
getslice           = 'getslice'         # (expr value, expr indices)
setslice           = 'setslice'         # (expr value, expr indices, expr value)

slice              = 'slice'            # (expr lower, expr upper, expr step)
# newaxis            = 'newaxis'        # => const(None)

# ______________________________________________________________________
# Basic operators

# op
compare            = 'compare'          # (expr left, str op, expr right)
binop              = 'binop'            # (expr left, str op, expr right)
unop               = 'unop'             # (str op, expr operand)

# ______________________________________________________________________
# Closures

make_frame         = 'make_frame'       # (frame parent, string names)
make_cell          = 'make_cell'        # ()

# ______________________________________________________________________
# Threads

threadpool_start   = 'threadpool_start' # (expr nthreads)
threadpool_submit  = 'threadpool_submit' # (expr threadpool, fn function)
threadpool_join    = 'threadpool_join'  # (expr threadpool)
threadpool_close   = 'threadpool_close' # (expr threadpool)
thread_start       = 'thread_start'     # (fn function)
thread_join        = 'thread_join'      # (expr thread)

#===------------------------------------------------------------------===
# Low-level IR
#===------------------------------------------------------------------===

# Low-level result:
#   - no objects, arrays, complex numbers
#   - no builtins
#   - no frames
#   - no map, reduce, scan, or yield

to_object          = 'to_object'        # (expr arg)
from_object        = 'from_object'      # (expr arg)
ptr_to_int         = 'ptr_to_int'       # (expr arg)
int_to_ptr         = 'int_to_ptr'       # (expr arg)

check_overflow     = 'check_overflow'   # (expr arg)

load_vtable        = 'load_vtable'      # (expr obj)
vtable_lookup      = 'vtable_lookup'    # (expr vtable, str method)

# ______________________________________________________________________
# Garbage collection

# Refcounting
gc_gotref          = 'gc_gotref'        # (expr arg)
gc_giveref         = 'gc_giveref'       # (expr arg)
gc_incref          = 'gc_incref'        # (expr obj)
gc_decref          = 'gc_decref'        # (expr obj)

# GC
gc_alloc           = 'gc_alloc'         # (expr n)
gc_dealloc         = 'gc_dealloc'       # (expr value)
gc_collect         = 'gc_collect'
gc_write_barrier   = 'gc_write_barrier'
gc_read_barrier    = 'gc_read_barrier'
gc_traverse        = 'gc_traverse'<commit_msg>Make operator constants start with uppercase<commit_after>#===------------------------------------------------------------------===
# Typed IR (initial input)
#===------------------------------------------------------------------===

# IR Constants. Constants start with an uppercase letter

# operator
Add                = 'Add'
Sub                = 'Sub'
Mult               = 'Mult'
Div                = 'Div'
Mod                = 'Mod'
Pow                = 'Pow'
Lshift             = 'Lshift'
Rshift             = 'Rshift'
Bitor              = 'Bitor'
Bitxor             = 'Bitxor'
Bitand             = 'Bitand'
Floordiv           = 'Floordiv'

# unaryop
Invert             = 'Invert'
Not                = 'Not'
Uadd               = 'Uadd'
Usub               = 'Usub'

# cmpop
Eq                 = 'Eq'
Noteq              = 'Noteq'
Lt                 = 'Lt'
Lte                = 'Lte'
Gt                 = 'Gt'
Gte                = 'Gte'
Is                 = 'Is'
Isnot              = 'Isnot'
In                 = 'In'
Notin              = 'Notin'

# math
Sin                = 'Sin'
Asin               = 'Asin'
Sinh               = 'Sinh'
Asinh              = 'Asinh'
Cos                = 'Cos'
Acos               = 'Acos'
Cosh               = 'Cosh'
Acosh              = 'Acosh'
Tan                = 'Tan'
Atan               = 'Atan'
Atan2              = 'Atan2'
Tanh               = 'Tanh'
Atanh              = 'Atanh'
Log                = 'Log'
Log2               = 'Log2'
Log10              = 'Log10'
Log1p              = 'Log1p'
Exp                = 'Exp'
Exp2               = 'Exp2'
Expm1              = 'Expm1'
Floor              = 'Floor'
Ceil               = 'Ceil'
Abs                = 'Abs'
Erfc               = 'Erfc'
Rint               = 'Rint'
Pow                = 'Pow'
Round              = 'Round'

# ______________________________________________________________________
# Constants

constant           = 'constant'         # (object pyval)

# ______________________________________________________________________
# Variables

alloca             = 'alloca'           # (expr n)
load               = 'load'             # (alloc var)
store              = 'store'            # (alloc var, expr value)
# phi is below

# ______________________________________________________________________
# Primitives

# Arrays/lists
map                = 'map'              # (fn func, expr arrays, const axes)
reduce             = 'reduce'           # (fn func, expr array, const axes)
scan               = 'scan'             # (fn func, expr array, const axes)
allpairs           = 'allpairs'         # (fn func, expr array, const axes)

# Scalars
min                = 'min'              # expr *args
max                = 'max'              # expr *args

# ______________________________________________________________________
# Containers

### TODO: This should be library code instead ?
# No matter how we do this, we'll end up reinventing pypy.

# ______________________________________________________________________
# Boxing and coercion

box                = 'box'              # (expr arg)
unbox              = 'unbox'            # (expr arg)
convert            = 'convert'          # (expr arg)

# ______________________________________________________________________
# Constructors

new_list           = 'new_list'         # (expr elems)
new_tuple          = 'new_tuple'        # (expr elems)
new_dict           = 'new_dict'         # (expr keys, expr values)
new_set            = 'new_set'          # (expr elems)

new_string         = 'new_string'       # (expr string)
new_unicode        = 'new_unicode'      # (expr string)

new_object         = 'new_object'       # (expr args)
new_struct         = 'new_struct'       # (expr *initializers)
new_complex        = 'new_complex'      # (expr real, expr imag)
new_data           = 'new_data'         # (expr size)

# ______________________________________________________________________
# Control flow

# Basic block leaders
phi                = 'phi'              # (expr blocks, expr values)
exc_setup          = 'exc_setup'        # (str body, exc_catch *handlers,
                                        #  str orelse)
exc_catch          = 'exc_catch'        # (expr *types)

# Basic block terminators
jump               = 'jump'             # (str target)
cbranch            = 'cbranch'          # (expr test, str true_target,
                                        #  str false_target)
exc_throw          = 'exc_throw'        # (expr exn)
ret                = 'ret'              # (expr result)

# ______________________________________________________________________
# Functions

function           = 'function'         # (str funcname)
partial            = 'partial'          # (fn function, expr vals)
# virtual_method     = 'virtual_method'   # (expr extobj, string methname)
func_from_addr     = 'func_from_addr'   # (expr pointer)

call               = 'call'             # (expr obj, expr *args)
call_obj           = 'call_obj'         # (expr obj, expr args, expr kwds)
call_virtual       = 'call_virtual'     # (fn method, expr args, expr kwds)
call_external      = 'call_external'    # (str name, expr *args)
call_math          = 'call_math'        # (str func, expr *args)

# ______________________________________________________________________
# Pointers

ptradd             = 'ptradd'           # (expr pointer, expr addition)
ptrload            = 'ptrload'          # (expr pointer)
ptrstore           = 'ptrstore'         # (expr pointer, expr value)
ptrcast            = 'ptrcast'          # (expr pointer)
ptr_isnull         = 'ptr_isnull'       # (expr' pointer)

# ______________________________________________________________________
# Iterators

getiter            = 'getiter'          # (expr obj)
next               = 'next'             # (iter it)

# ______________________________________________________________________
# Generators

yieldval           = 'yieldval'         # (expr value)
yieldfrom          = 'yieldfrom'        # (expr value)

# ______________________________________________________________________
# Attributes

getfield_struct    = 'getfield_struct'  # (expr struct, int field_idx)
setfield_struct    = 'setfield_struct'  # (expr struct, int field_idx, expr value)
getfield           = 'getfield'         # (expr value, str attr)
setfield           = 'setfield'         # (expr value, str attr, expr value)

# ______________________________________________________________________
# Indexing

getindex           = 'getindex'         # (expr value, expr indices)
setindex           = 'setindex'         # (expr value, expr indices, expr value)
getslice           = 'getslice'         # (expr value, expr indices)
setslice           = 'setslice'         # (expr value, expr indices, expr value)

slice              = 'slice'            # (expr lower, expr upper, expr step)
# newaxis            = 'newaxis'        # => const(None)

# ______________________________________________________________________
# Basic operators

# op
compare            = 'compare'          # (expr left, str op, expr right)
binop              = 'binop'            # (expr left, str op, expr right)
unop               = 'unop'             # (str op, expr operand)

# ______________________________________________________________________
# Closures

make_frame         = 'make_frame'       # (frame parent, string names)
make_cell          = 'make_cell'        # ()

# ______________________________________________________________________
# Threads

threadpool_start   = 'threadpool_start' # (expr nthreads)
threadpool_submit  = 'threadpool_submit' # (expr threadpool, fn function)
threadpool_join    = 'threadpool_join'  # (expr threadpool)
threadpool_close   = 'threadpool_close' # (expr threadpool)
thread_start       = 'thread_start'     # (fn function)
thread_join        = 'thread_join'      # (expr thread)

#===------------------------------------------------------------------===
# Low-level IR
#===------------------------------------------------------------------===

# Low-level result:
#   - no objects, arrays, complex numbers
#   - no builtins
#   - no frames
#   - no map, reduce, scan, or yield

to_object          = 'to_object'        # (expr arg)
from_object        = 'from_object'      # (expr arg)
ptr_to_int         = 'ptr_to_int'       # (expr arg)
int_to_ptr         = 'int_to_ptr'       # (expr arg)

check_overflow     = 'check_overflow'   # (expr arg)

load_vtable        = 'load_vtable'      # (expr obj)
vtable_lookup      = 'vtable_lookup'    # (expr vtable, str method)

# ______________________________________________________________________
# Garbage collection

# Refcounting
gc_gotref          = 'gc_gotref'        # (expr arg)
gc_giveref         = 'gc_giveref'       # (expr arg)
gc_incref          = 'gc_incref'        # (expr obj)
gc_decref          = 'gc_decref'        # (expr obj)

# GC
gc_alloc           = 'gc_alloc'         # (expr n)
gc_dealloc         = 'gc_dealloc'       # (expr value)
gc_collect         = 'gc_collect'
gc_write_barrier   = 'gc_write_barrier'
gc_read_barrier    = 'gc_read_barrier'
gc_traverse        = 'gc_traverse'

{'fraction_non_alphanumeric': 0.11948108579526873, 'fraction_numerical': 0.001526218249209637, 'mean_word_length': 1.6079601990049752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1251960', 'n_tokens_mistral': 4853, 'n_tokens_neox': 4736, 'n_words': 1252}