Enum Class IROpcode
- All Implemented Interfaces:
Serializable
,Comparable<IROpcode>
,Constable
Enumeration of all IR opcodes used in the EK9 intermediate representation.
Key Design Principle: All EK9 operators become method calls (CALL instructions). No primitive arithmetic operations (ADD, SUB, etc.) are included - everything goes through EK9's object method dispatch system.
This design ensures target-agnostic IR that works equally well for: - JVM bytecode generation - LLVM-C++ target
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAssert that condition is true.Unconditional assertion failure.Unconditional branch/jump.Branch if condition is false.Branch if condition is true.Standard method call with resolved signature.Dispatcher method call (runtime type-based dispatch).Static method/function call.Virtual method call (polymorphic dispatch).Cleanup after exception handling.High-level conditional block construct.Unified control flow block construct for all EK9 conditional evaluation.Get singleton instance of a function.Guarded assignment block construct for conditional assignment (:=? operator).Check if reference/object is null or uninitialized.Mark instruction position as branch target.Load value from memory location into temporary/register.Load literal/constant value into temporary/register.Logical AND block construct with short-circuit capability.Logical OR block construct with short-circuit capability.Annotation marker: skip RELEASE operation for this object.Annotation marker: skip RETAIN operation for this object.Annotation marker: skip SCOPE_REGISTER operation for this object.PHI node for merging values from different control flow paths.Question operator block construct for null-safe _isSet() calls.Declare variable reference (no memory allocation).Decrement object reference count.Increment object reference count.Return from method/function.Enter new memory management scope.Exit memory management scope.Register object for automatic cleanup in scope.Setup exception handler for try block.Allocate object on stack instead of heap.Create literal value on stack instead of heap.Release heap references held by stack objects before destruction.Store value from temporary/register into memory location.Throw exception.Transfer ownership without reference counting overhead. -
Method Summary
-
Enum Constant Details
-
LOAD
Load value from memory location into temporary/register. Format: LOAD dest = source_location -
STORE
Store value from temporary/register into memory location. Format: STORE dest_location = source -
LOAD_LITERAL
Load literal/constant value into temporary/register. Format: LOAD_LITERAL dest = literal_value, literal_type Handles: String literals, numeric literals, boolean literals, etc. -
REFERENCE
Declare variable reference (no memory allocation). Format: REFERENCE variable_name, type_info Used for parameters and variable-only declarations. Backend handles appropriate reference storage. -
CALL
Standard method call with resolved signature. Format: CALL result = object.method(args...) Handles: EK9 operators (a + b → a._add(b)), normal method calls -
CALL_VIRTUAL
Virtual method call (polymorphic dispatch). Format: CALL_VIRTUAL result = object.method(args...) -
CALL_STATIC
Static method/function call. Format: CALL_STATIC result = Type.method(args...) -
FUNCTION_INSTANCE
Get singleton instance of a function. Format: FUNCTION_INSTANCE result = FunctionType Returns the singleton instance of the specified function type. No memory management needed - singletons are never released. -
CALL_DISPATCHER
Dispatcher method call (runtime type-based dispatch). Format: CALL_DISPATCHER result = object.dispatcherMethod(args...) Uses runtime type information and dispatch matrix -
BRANCH
Unconditional branch/jump. Format: BRANCH target_label -
BRANCH_TRUE
Branch if condition is true. Format: BRANCH_TRUE condition, target_label -
BRANCH_FALSE
Branch if condition is false. Format: BRANCH_FALSE condition, target_label -
RETURN
Return from method/function. Format: RETURN [value] -
ASSERT
Assert that condition is true. Format: ASSERT condition Traps/throws if condition is false. -
ASSERT_FAILURE
Unconditional assertion failure. Format: ASSERT_FAILURE Always traps/throws - used when failure is known at compile time. More efficient than creating Boolean objects just to fail assertions. -
THROW
Throw exception. Format: THROW exception_object -
SETUP_HANDLER
Setup exception handler for try block. Format: SETUP_HANDLER handler_label, exception_types... -
CLEANUP
Cleanup after exception handling. Format: CLEANUP -
RETAIN
Increment object reference count. Format: RETAIN object JVM: no-op, LLVM: increment ref count -
RELEASE
Decrement object reference count. Format: RELEASE object JVM: no-op, LLVM: decrement ref count, possible deallocation -
SCOPE_ENTER
Enter new memory management scope. Format: SCOPE_ENTER scope_id Creates cleanup boundary for exception safety -
SCOPE_EXIT
Exit memory management scope. Format: SCOPE_EXIT scope_id Automatically RELEASE all registered objects in scope -
SCOPE_REGISTER
Register object for automatic cleanup in scope. Format: SCOPE_REGISTER object, scope_id Object will be RELEASE'd when scope exits -
IS_NULL
Check if reference/object is null or uninitialized. Format: IS_NULL result = operand -
LABEL
Mark instruction position as branch target. Format: LABEL label_name Used by BRANCH, BRANCH_TRUE, BRANCH_FALSE instructions for control flow -
PHI
PHI node for merging values from different control flow paths. Format: PHI result = [value1, block1], [value2, block2], ... Essential for SSA form and LLVM IR generation. -
CONDITIONAL_BLOCK
High-level conditional block construct. Format: CONDITIONAL_BLOCK condition_var, result_var, true_block, false_block Backends lower this to appropriate target-specific control flow. -
LOGICAL_AND_BLOCK
Logical AND block construct with short-circuit capability. Format: LOGICAL_AND_BLOCK result = left_operand, condition, right_evaluation, logical_result Contains complete evaluation paths for both short-circuit and full evaluation. -
LOGICAL_OR_BLOCK
Logical OR block construct with short-circuit capability. Format: LOGICAL_OR_BLOCK result = left_operand, condition, right_evaluation, logical_result Contains complete evaluation paths for both short-circuit and full evaluation. -
QUESTION_BLOCK
Question operator block construct for null-safe _isSet() calls. Format: QUESTION_BLOCK result = operand_evaluation, null_case_evaluation, set_case_evaluation Contains complete evaluation paths for both null and non-null cases. Avoids explicit branching by pre-computing both execution paths. -
GUARDED_ASSIGNMENT_BLOCK
Guarded assignment block construct for conditional assignment (:=? operator). Format: GUARDED_ASSIGNMENT_BLOCK result = condition_evaluation, assignment_evaluation Contains complete evaluation paths for both condition checking and assignment. Assigns only if LHS is null OR LHS._isSet() == false. Uses QUESTION_BLOCK logic internally for consistent null-safety semantics. -
CONTROL_FLOW_CHAIN
Unified control flow block construct for all EK9 conditional evaluation. Format: CONTROL_FLOW_CHAIN result = evaluation_variable, condition_chain, default_evaluation
Unifies all EK9 control flow constructs into a single, powerful IR opcode: - Question operator (?): NULL_CHECK condition + _isSet() default - If/else statements: Sequential condition evaluation + else default - Switch statements: Case condition evaluation + default clause - Guarded assignment (:=?): Composition with question operator logic
Contains complete evaluation paths for all conditions and their corresponding bodies. Backends can optimize based on chain_type hints: - QUESTION_OPERATOR: Optimize null checks and method calls - IF_ELSE/IF_ELSE_IF: Standard conditional branching - SWITCH/SWITCH_ENUM: Jump tables for dense enums, sequential for complex expressions
Key benefits: - Single source of truth for all control flow logic - Consistent memory management across all constructs - Enhanced backend optimization opportunities - Reduced IR complexity and maintenance burden -
STACK_ALLOC
Allocate object on stack instead of heap. Format: STACK_ALLOC result = type_info Used when escape analysis determines object never leaves function scope. Backend: LLVM uses alloca, JVM uses optimized local variables. Eliminates need for RETAIN/RELEASE/SCOPE_REGISTER for this object. -
STACK_ALLOC_LITERAL
Create literal value on stack instead of heap. Format: STACK_ALLOC_LITERAL result = literal_value, literal_type Optimization for non-escaping literals (strings, numbers, etc.). More efficient than heap allocation - automatic cleanup on function exit. Replaces LOAD_LITERAL during IR optimization phase. -
STACK_CLEANUP_REFS
Release heap references held by stack objects before destruction. Format: STACK_CLEANUP_REFS stack_object Handles mixed heap/stack reference scenarios where stack objects hold references to heap-allocated objects. Ensures proper reference counting before stack object is automatically destroyed. -
TRANSFER_OWNERSHIP
Transfer ownership without reference counting overhead. Format: TRANSFER_OWNERSHIP dest = source Optimization for clear ownership transfers - avoids retain/release pair. Used when analysis shows object ownership cleanly passes from source to dest with no intermediate sharing or aliasing. -
NO_RETAIN
Annotation marker: skip RETAIN operation for this object. Format: NO_RETAIN object Used during IR optimization to mark objects that don't need reference counting. Does not generate code - just prevents RETAIN instruction emission. -
NO_RELEASE
Annotation marker: skip RELEASE operation for this object. Format: NO_RELEASE object Used during IR optimization to mark objects that don't need reference counting. Does not generate code - just prevents RELEASE instruction emission. -
NO_SCOPE_REGISTER
Annotation marker: skip SCOPE_REGISTER operation for this object. Format: NO_SCOPE_REGISTER object, scope Used during IR optimization for objects with automatic cleanup (e.g., stack allocated). Does not generate code - just prevents SCOPE_REGISTER instruction emission.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-