sun::codegen::CodegenVisitor
class · Source (opens in a new tab)
class sun::codegen::CodegenVisitorTraverses the AST and generates LLVM IR using the provided CodegenContext.
Functions
codegen
codegen(const sun::ast::MatchExprAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::MatchExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::MatchExprAST
codegen(const sun::ast::ArrayIndexAST &expr)
private · function · Source (opens in a new tab)
llvm::Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::ArrayIndexAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::ArrayIndexAST
codegen(const IndexAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const IndexAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: IndexAST
codegen(const sun::ast::StringLiteralAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::StringLiteralAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::StringLiteralAST
codegen(const ExprAST &expr)
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const ExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: ExprAST
codegen(const sun::ast::CharLiteralAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::CharLiteralAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::CharLiteralAST
codegen(const T &)=delete
public · function · Source (opens in a new tab)
template <typename T>
llvm::Value * sun::codegen::CodegenVisitor::codegen(const T &)=deleteA node kind whose codegen lives on a component must be dispatched to that component.
Without this, the missing overload would bind to codegen(const ExprAST&) instead — which re-enters the dispatch switch and recurses until the stack runs out. Make it a compile error instead.
Related: ExprAST, codegen(const ExprAST&)
codegen(const sun::ast::TernaryExprAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::TernaryExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::TernaryExprAST
codegen(const sun::ast::IfExprAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::IfExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::IfExprAST
codegen(const sun::ast::NumberExprAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::NumberExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::NumberExprAST
codegen(const sun::ast::BlockExprAST &block, size_t start=0)
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::BlockExprAST &block, size_t start=0)Emits a block, optionally skipping a prefix already emitted by its caller.
Related: sun::ast::BlockExprAST
codegen(const sun::ast::ArrayLiteralAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::ArrayLiteralAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::ArrayLiteralAST
codegen(const CallExprAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const CallExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: CallExprAST
codegen(const sun::ast::UnaryExprAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::UnaryExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::UnaryExprAST
codegen(const sun::ast::BinaryExprAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::BinaryExprAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::BinaryExprAST
codegen(const sun::ast::IndexedAssignmentAST &expr)
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegen(const sun::ast::IndexedAssignmentAST &expr)Emits LLVM instructions for this syntax node and returns its generated value.
Related: sun::ast::IndexedAssignmentAST
Public Functions
- CodegenVisitor
- applyMoveSemantics
- arrayDimsTable
- assignToVariableSlot
- boxIndicesToArrayRef
- classGenerator
- codegenAddress
- codegenArrayQuery
- codegenBorrowAddress
- codegenExpression
- codegenIndexElementPtr
- codegenObjectPtr
- createEntryBlockAlloca
- createIntDivRem
- debugDeclareParam
- emitArrayTransfer
- emitArrayView
- emitBinaryOp
- emitCallArguments
- emitClassIndexCall
- emitClassSetIndexCall
- emitStaticInitFunction
- enumGenerator
- errorGenerator
- externCEmitter
- finalizeDebugInfo
- functionGenerator
- functionRegistry
- getUserDefinedFunctions
- intrinsicsGenerator
- isPayloadEnum
- isPrecompiledFunction
- loadArrayView
- materializeMethodClosure
- materializeMethodClosureValue
- materializeStructReturn
- noteUserDefinedFunction
- scopeManager
- snapshotPrecompiledFunctions
- state
- storeArrayElement
- tryCodegenAddress
- unifyBinaryOperands
- variableGenerator
CodegenVisitor
public · function · Source (opens in a new tab)
sun::codegen::CodegenVisitor::CodegenVisitor(CodegenContext &ctx, std::shared_ptr< sun::semantic_analysis::AnalysisResults > results)Creates the expression visitor and its cooperating code generators.
Related: CodegenContext, sun::semantic_analysis::AnalysisResults
applyMoveSemantics
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::applyMoveSemantics(llvm::Value *argVal, TypePtr argSunType)Applies move semantics for class arguments passed by value.
Loads the struct value and zeros the source memory to prevent double-free. If the argument is not a pointer to a class, returns it unchanged.
Related: TypePtr
arrayDimsTable
public · function · Source (opens in a new tab)
Constant * sun::codegen::CodegenVisitor::arrayDimsTable(const std::vector< size_t > &dims)Views: the { ptr data, i32 ndims, ptr dims } value a sized array decays to at a ref array<T> site.
The dims table is a private constant global.
assignToVariableSlot
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::assignToVariableSlot(llvm::Value *slot, llvm::Value *value, const TypePtr &varType, const std::string &name)Assign an already-evaluated value to a variable slot (local alloca or global).
Compound values (classes, payload enums) drop the overwritten value first and MOVE the source in; self-assignment emits nothing.
Related: TypePtr
boxIndicesToArrayRef
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::boxIndicesToArrayRef(const IndexAST &expr)Class index/__setindex__ protocol pieces, decomposed so compound assignment can box the indices and resolve the receiver exactly once.
The boxed indices are a ref array<i64> view value.
Related: IndexAST
classGenerator
public · function · Source (opens in a new tab)
classes::ClassGenerator & sun::codegen::CodegenVisitor::classGenerator()Provides the generator for class layouts and member operations.
Related: classes::ClassGenerator
codegenAddress
public · function · Source (opens in a new tab)
llvm::Value * sun::codegen::CodegenVisitor::codegenAddress(const ExprAST &expr)Emits the storage address of an addressable expression.
Related: ExprAST
codegenArrayQuery
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenArrayQuery(const CallExprAST &call, const MemberAccessAST &member)arr.ndims() and arr.dim(i) on a sized array or a view
Related: CallExprAST, MemberAccessAST
codegenBorrowAddress
public · function · Source (opens in a new tab)
llvm::Value * sun::codegen::CodegenVisitor::codegenBorrowAddress(const ExprAST &expr)Emits the address used to borrow an expression without moving its value.
Related: ExprAST
codegenExpression
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenExpression(const ExprAST &expr)The node dispatch that codegen(const ExprAST&) wraps.
Call codegen().
Related: ExprAST, codegen(const ExprAST&), codegen()
codegenIndexElementPtr
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenIndexElementPtr(const IndexAST &expr)Element address for the slice-aware index form.
Related: IndexAST
codegenObjectPtr
public · function · Source (opens in a new tab)
std::pair< llvm::Value *, ClassType * > sun::codegen::CodegenVisitor::codegenObjectPtr(const ExprAST &object)Codegen a member-access object down to (objectPtr, ClassType*), applying the generic-this fixup and unwrapping raw_ptr/static_ptr/ref to class.
ClassType* is null when the object is not class-shaped.
createEntryBlockAlloca
public · function · Source (opens in a new tab)
AllocaInst * sun::codegen::CodegenVisitor::createEntryBlockAlloca(Function *func, StringRef varName, llvm::Type *type=nullptr)An alloca in the function's entry block, so loops don't grow the stack.
createIntDivRem
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::createIntDivRem(llvm::Value *L, llvm::Value *R, bool isModulo, bool isUnsigned)Emits integer division or remainder, throwing ArithmeticError on failure.
debugDeclareParam
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::debugDeclareParam(llvm::AllocaInst *alloca, const std::string &name, const sun::ast::PrototypeAST &proto, unsigned userArgIdx, unsigned argNoBase=1)Attach a dbg_declare for a source parameter (no-op without -g).
DWARF argNo is 1-based; argNoBase is 2 for methods, whose slot 1 is the artificial 'this'.
Related: sun::ast::PrototypeAST
emitArrayTransfer
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::emitArrayTransfer(llvm::Value *dest, llvm::Value *src, const sun::types::ArrayType &type, bool move)Copy a sized array's inline storage from src to dest; a move also invalidates the source so its own drop releases nothing.
Related: sun::types::ArrayType
emitArrayView
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::emitArrayView(llvm::Value *storagePtr, const std::vector< size_t > &dims)Builds an array view from storage and its dimension sizes.
emitBinaryOp
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::emitBinaryOp(sun::parsing::TokenKind op, llvm::Value *L, llvm::Value *R, bool unsignedOp, const sun::support::Position &loc)Emit an arithmetic/bitwise/shift op on unified operands; shared by binary expressions and compound assignment.
Related: sun::parsing::TokenKind, sun::support::Position
emitCallArguments
public · function · Source (opens in a new tab)
bool sun::codegen::CodegenVisitor::emitCallArguments(const std::vector< std::unique_ptr< ExprAST > > &args, const std::vector< sun::semantic_analysis::ArgConversion > &conversions, const std::vector< TypePtr > ¶mTypes, llvm::FunctionType *calleeTy, std::vector< llvm::Value * > &argValues, const std::string &calleeName, size_t firstArg=0)Lower a call's arguments as semantic analysis decided (one ArgConversion per argument), appending to argValues.
The one argument loop for every kind of call. paramTypes supplies the target type where a conversion needs one, calleeTy the LLVM parameter types for closure values. firstArg skips leading arguments the caller lowered itself. Returns false if an argument failed to codegen.
Related: ExprAST, sun::semantic_analysis::ArgConversion, TypePtr, ArgConversion
emitClassIndexCall
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::emitClassIndexCall(llvm::Value *objectPtr, llvm::Value *idxView, sun::semantic_analysis::DeclarationId declaration)Emits a call to the class method implementing indexed access.
Related: sun::semantic_analysis::DeclarationId
emitClassSetIndexCall
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::emitClassSetIndexCall(llvm::Value *objectPtr, llvm::Value *idxView, llvm::Value *value, const sun::types::ClassMethod *method)Emits a call to the class method implementing indexed assignment.
Related: sun::types::ClassMethod
emitStaticInitFunction
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::emitStaticInitFunction(uint32_t initOrder, const std::string &bundleHash)Emit static initialization for globals that need it.
Call after all top-level codegen but before main runs. See VariableGenerator::emitStaticInitFunction for the parameters.
enumGenerator
public · function · Source (opens in a new tab)
enums::EnumGenerator & sun::codegen::CodegenVisitor::enumGenerator()Gives codegen components access to enum generation.
Related: enums::EnumGenerator
errorGenerator
public · function · Source (opens in a new tab)
errors::ErrorGenerator & sun::codegen::CodegenVisitor::errorGenerator()Provides the generator for throwing and catching errors.
Related: errors::ErrorGenerator
externCEmitter
public · function · Source (opens in a new tab)
sun::codegen::abi::ExternCEmitter & sun::codegen::CodegenVisitor::externCEmitter()Provides the emitter for calls that use the C calling convention.
Related: sun::codegen::abi::ExternCEmitter
finalizeDebugInfo
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::finalizeDebugInfo()Run DIBuilder finalization; call after all codegen, before verifyModule.
functionGenerator
public · function · Source (opens in a new tab)
functions::FunctionGenerator & sun::codegen::CodegenVisitor::functionGenerator()Provides the generator for function bodies and calls.
Related: functions::FunctionGenerator
functionRegistry
public · function · Source (opens in a new tab)
functions::FunctionRegistry & sun::codegen::CodegenVisitor::functionRegistry()Provides the registry of generated functions and signatures.
Related: functions::FunctionRegistry
getUserDefinedFunctions
public · function · Source (opens in a new tab)
const std::set< std::string > & sun::codegen::CodegenVisitor::getUserDefinedFunctions() constGet the set of user-defined function names (for IR filtering).
intrinsicsGenerator
public · function · Source (opens in a new tab)
intrinsics::IntrinsicsGenerator & sun::codegen::CodegenVisitor::intrinsicsGenerator()Provides the generator for built-in operations.
Related: intrinsics::IntrinsicsGenerator
isPayloadEnum
public · function · static · Source (opens in a new tab)
static bool sun::codegen::CodegenVisitor::isPayloadEnum(const TypePtr &t)Payload enums: struct-valued like classes, handled by pointer.
Related: TypePtr
isPrecompiledFunction
public · function · Source (opens in a new tab)
bool sun::codegen::CodegenVisitor::isPrecompiledFunction(const std::string &name) constCheck if a function was declared from precompiled bitcode.
loadArrayView
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::loadArrayView(llvm::Value *value)The view value from however an unsized-array expression arrived: the value itself, or a pointer to where it is stored.
materializeMethodClosure
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::materializeMethodClosure(llvm::Value *fnPtr, llvm::Value *receiverPtr, llvm::StringRef name="method.closure")Method closure ABI: methods take a ptr to { ptr func, ptr env } as their hidden first argument; env holds the receiver ('this').
Returns a ptr to an entry-block alloca holding { fnPtr, receiverPtr } (stores emitted at the current insert point, so loops don't grow the stack).
materializeMethodClosureValue
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::materializeMethodClosureValue(llvm::Value *fnPtr, llvm::Value *receiverPtr)Closure struct VALUE { fnPtr, receiverPtr } via insertvalue (for method references in value position).
materializeStructReturn
public · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::materializeStructReturn(llvm::Value *callResult)Materializes a struct or array return value to the caller's stack.
Functions return classes and sized arrays as LLVM aggregate values; using the result (reaching a field, indexing) needs an addressable location. Keeps non-owning internal structures, such as array views, as values.
noteUserDefinedFunction
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::noteUserDefinedFunction(const std::string &name)Record a function as user-written, so an IR dump keeps it.
The set is keyed by name, so a pass that renames a function has to say so.
scopeManager
public · function · Source (opens in a new tab)
scopes::ScopeManager & sun::codegen::CodegenVisitor::scopeManager()Provides the manager of generated lexical scopes and cleanup.
Related: scopes::ScopeManager
snapshotPrecompiledFunctions
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::snapshotPrecompiledFunctions()Snapshot the module's current function declarations.
Call after declareAvailableFunctions() but before codegen().
Related: codegen()
state
public · function · Source (opens in a new tab)
CodegenState & sun::codegen::CodegenVisitor::state()The state every codegen component shares.
Related: CodegenState
storeArrayElement
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::storeArrayElement(llvm::Value *slotPtr, llvm::Value *elemVal, const TypePtr &elemSunType, llvm::Type *slotType)Store one element into a slot of inline storage (compounds move in).
Related: TypePtr
tryCodegenAddress
public · function · Source (opens in a new tab)
llvm::Value * sun::codegen::CodegenVisitor::tryCodegenAddress(const ExprAST &expr)The lvalue surface, forwarded to VariableGenerator so every component reaches it the same way.
tryCodegenAddress returns nullptr for shapes with no addressable slot (class index targets, slices, closure captures, temporaries); codegenAddress throws instead.
Related: ExprAST
unifyBinaryOperands
public · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::unifyBinaryOperands(llvm::Value *&L, llvm::Value *&R, const TypePtr &lhsSunType, const TypePtr &rhsSunType, const sun::support::Position &loc)Bring two scalar operands to a common type (int/float widening); throws on incompatible types.
Related: TypePtr, sun::support::Position
variableGenerator
public · function · Source (opens in a new tab)
variables::VariableGenerator & sun::codegen::CodegenVisitor::variableGenerator()Provides the generator for variable storage and access.
Related: variables::VariableGenerator
Private Functions
- codegenArrayElementPtr
- codegenBuiltinTypeMethod
- codegenClassIndex
- codegenClassMethodCall
- codegenClassSetIndex
- codegenClassSlice
- codegenFunctionCall
- codegenInterfaceMethodCall
- codegenLambdaCall
- codegenLogicalOp
- codegenMethodCall
- codegenModuleFunctionCall
- coerceStaticPtrToRawPtr
- debugDeclareLocal
- emitExternArguments
- emitMarshalledExternCall
- extendInt
- extractStaticPtrField
- loadClosureForLambdaParam
- loadIfRef
- prepareRefArgument
- widenNumericIfNeeded
codegenArrayElementPtr
private · function · Source (opens in a new tab)
llvm::Value * sun::codegen::CodegenVisitor::codegenArrayElementPtr(const sun::ast::ArrayIndexAST &expr)Computes the address of an indexed array element.
Related: sun::ast::ArrayIndexAST
codegenBuiltinTypeMethod
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenBuiltinTypeMethod(const CallExprAST &expr, llvm::Value *objectPtr, TypePtr objectType, const std::string &methodName)Handles builtin type methods: Thread.join(), static_ptr.length()/.raw().
Returns nullptr if not a builtin type method (caller should continue).
Related: CallExprAST, TypePtr
codegenClassIndex
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenClassIndex(const IndexAST &expr, llvm::Value *objectPtr, ClassType *classType)Class indexing via index and slice methods.
codegenClassMethodCall
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenClassMethodCall(const CallExprAST &expr, llvm::Value *objectPtr, const std::string &methodName, const MemberAccessAST *memberAccess)Handles class method dispatch (regular and generic).
Related: CallExprAST, MemberAccessAST
codegenClassSetIndex
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenClassSetIndex(const IndexAST &indexExpr, const ExprAST *valueExpr, const sun::types::ClassMethod *method)Emits indexed assignment through the selected class method.
Related: IndexAST, ExprAST, sun::types::ClassMethod
codegenClassSlice
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenClassSlice(const IndexAST &expr, llvm::Value *objectPtr, ClassType *classType)Emits the class operation implementing a slice expression.
codegenFunctionCall
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenFunctionCall(const CallExprAST &expr, const std::string &calleeName, const sun::types::FunctionType &funcType)Call helpers for different calling conventions.
Related: CallExprAST, sun::types::FunctionType
codegenInterfaceMethodCall
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenInterfaceMethodCall(const CallExprAST &expr, llvm::Value *objectPtr, sun::types::InterfaceType *ifaceType, const std::string &methodName)Handles interface method dispatch via vtable.
Related: CallExprAST, sun::types::InterfaceType
codegenLambdaCall
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenLambdaCall(const CallExprAST &expr, const std::string &calleeName, const sun::types::LambdaType &lambdaType)Emits a lambda invocation with its captured environment.
Related: CallExprAST, sun::types::LambdaType
codegenLogicalOp
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenLogicalOp(const sun::ast::BinaryExprAST &expr)Short-circuit logical operators (and, or).
Related: sun::ast::BinaryExprAST
codegenMethodCall
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenMethodCall(const CallExprAST &expr, const MemberAccessAST &memberAccess)Top-level method call handler: dispatches to the sub-handlers below.
Related: CallExprAST, MemberAccessAST
codegenModuleFunctionCall
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::codegenModuleFunctionCall(const CallExprAST &expr, const std::string &funcName, const MemberAccessAST &memberAccess)Handles module-qualified function calls: mymod.foo().
Related: CallExprAST, MemberAccessAST
coerceStaticPtrToRawPtr
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::coerceStaticPtrToRawPtr(llvm::Value *argVal, const TypePtr &argSunType, const TypePtr ¶mType)Narrows a static_ptr<T> fat { ptr, i64 } argument to the bare data pointer a raw_ptr<T> parameter expects.
No-op for any other type pairing.
Related: TypePtr
debugDeclareLocal
private · function · Source (opens in a new tab)
void sun::codegen::CodegenVisitor::debugDeclareLocal(llvm::AllocaInst *alloca, const std::string &name, const TypePtr &type, const sun::support::Position &loc)Attach a dbg_declare for a user variable (no-op without -g).
Related: TypePtr, sun::support::Position
emitExternArguments
private · function · Source (opens in a new tab)
bool sun::codegen::CodegenVisitor::emitExternArguments(const CallExprAST &expr, const std::vector< TypePtr > ¶mTypes, std::vector< sun::codegen::abi::PreparedArg > &out)Generate the arguments for a call across the C boundary, carrying out only Sun's own conversions.
C-specific marshalling is ExternCEmitter's job.
Related: CallExprAST, TypePtr, sun::codegen::abi::PreparedArg
emitMarshalledExternCall
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::emitMarshalledExternCall(const CallExprAST &expr, const std::vector< TypePtr > ¶mTypes, llvm::Function *func)Emit a call to a C function whose signature needed ABI rewriting: its LLVM parameters no longer line up one-to-one with the Sun arguments, so the normal argument path cannot be used.
Shared by plain and module-qualified call sites.
Related: CallExprAST, TypePtr
extendInt
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::extendInt(llvm::Value *value, llvm::Type *destTy, const TypePtr &sourceType)Widen an integer value to destTy; the source expression's Sun type decides zero- vs sign-extension (unsigned -> zext).
Related: TypePtr
extractStaticPtrField
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::extractStaticPtrField(llvm::Value *fatPtr, unsigned index, const TypePtr &staticPtrType, const char *name)Field 0 (data) or 1 (length) of a static_ptr fat pointer, whether it arrived as the struct value or as its address.
Related: TypePtr
loadClosureForLambdaParam
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::loadClosureForLambdaParam(llvm::Value *argVal, TypePtr paramType, llvm::Type *expectedTy)Coerces a lambda argument to the callee's closure struct param type: loads lambda literals (alloca ptr) and rebuilds closure values carrying a differently-named but structurally identical struct type.
Related: TypePtr
loadIfRef
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::loadIfRef(llvm::Value *value, const TypePtr &type)Read through a reference where a plain value is wanted.
A reference is an address until something consumes it; this is what does the consuming.
Related: TypePtr
prepareRefArgument
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::prepareRefArgument(const ExprAST *argExpr, TypePtr argSunType, bool allowTemporaryCopy=true)Prepares an argument value for a reference parameter.
Handles variable references, member access, arrays, and raw_ptr auto-deref.
widenNumericIfNeeded
private · function · Source (opens in a new tab)
Value * sun::codegen::CodegenVisitor::widenNumericIfNeeded(llvm::Value *argVal, const TypePtr ¶mType, const TypePtr &sourceType)Widens integer or float arguments to match parameter type if needed.
Handles i32->i64, f32->f64, etc. Returns the original value if no widening needed.
Related: TypePtr
Private Fields
- classes
- ctx
- currentClass
- currentFunctionCanError
- currentFunctionReturnsRef
- currentFunctionValueType
- debugInfo
- enums
- errors
- externC
- functions
- functions_
- intrinsics
- loops
- module
- scopes
- state_
- thisPtr
- typeRegistry
- typeResolver
- variables
classes
private · variable · Source (opens in a new tab)
classes::ClassGenerator sun::codegen::CodegenVisitor::classes {state_, *this}No documentation comment.
Related: classes::ClassGenerator, state_
ctx
private · variable · Source (opens in a new tab)
CodegenContext& sun::codegen::CodegenVisitor::ctxNo documentation comment.
Related: CodegenContext
currentClass
private · variable · Source (opens in a new tab)
std::shared_ptr<ClassType>& sun::codegen::CodegenVisitor::currentClassNo documentation comment.
Related: ClassType
currentFunctionCanError
private · variable · Source (opens in a new tab)
bool& sun::codegen::CodegenVisitor::currentFunctionCanErrorNo documentation comment.
currentFunctionReturnsRef
private · variable · Source (opens in a new tab)
bool& sun::codegen::CodegenVisitor::currentFunctionReturnsRefNo documentation comment.
currentFunctionValueType
private · variable · Source (opens in a new tab)
llvm::Type*& sun::codegen::CodegenVisitor::currentFunctionValueTypeNo documentation comment.
debugInfo
private · variable · Source (opens in a new tab)
sun::codegen::DebugInfoBuilder& sun::codegen::CodegenVisitor::debugInfoNo documentation comment.
Related: sun::codegen::DebugInfoBuilder
enums
private · variable · Source (opens in a new tab)
enums::EnumGenerator sun::codegen::CodegenVisitor::enums {state_, *this}No documentation comment.
Related: enums::EnumGenerator, state_
errors
private · variable · Source (opens in a new tab)
errors::ErrorGenerator sun::codegen::CodegenVisitor::errors {state_, *this}No documentation comment.
Related: errors::ErrorGenerator, state_
externC
private · variable · Source (opens in a new tab)
sun::codegen::abi::ExternCEmitter sun::codegen::CodegenVisitor::externCNo documentation comment.
Related: sun::codegen::abi::ExternCEmitter
functions
private · variable · Source (opens in a new tab)
functions::FunctionRegistry sun::codegen::CodegenVisitor::functions {state_}No documentation comment.
Related: functions::FunctionRegistry, state_
functions_
private · variable · Source (opens in a new tab)
functions::FunctionGenerator sun::codegen::CodegenVisitor::functions_ {state_, *this}No documentation comment.
Related: functions::FunctionGenerator, state_
intrinsics
private · variable · Source (opens in a new tab)
intrinsics::IntrinsicsGenerator sun::codegen::CodegenVisitor::intrinsics {state_, *this}No documentation comment.
Related: intrinsics::IntrinsicsGenerator, state_
loops
private · variable · Source (opens in a new tab)
loops::LoopGenerator sun::codegen::CodegenVisitor::loops {state_, *this}No documentation comment.
Related: loops::LoopGenerator, state_
module
private · variable · Source (opens in a new tab)
llvm::Module* sun::codegen::CodegenVisitor::moduleNo documentation comment.
scopes
private · variable · Source (opens in a new tab)
scopes::ScopeManager sun::codegen::CodegenVisitor::scopes {state_, *this}No documentation comment.
Related: scopes::ScopeManager, state_
state_
private · variable · Source (opens in a new tab)
CodegenState sun::codegen::CodegenVisitor::state_No documentation comment.
Related: CodegenState
thisPtr
private · variable · Source (opens in a new tab)
llvm::Value*& sun::codegen::CodegenVisitor::thisPtrNo documentation comment.
typeRegistry
private · variable · Source (opens in a new tab)
std::shared_ptr<sun::semantic_analysis::TypeRegistry>& sun::codegen::CodegenVisitor::typeRegistryNo documentation comment.
Related: sun::semantic_analysis::TypeRegistry
typeResolver
private · variable · Source (opens in a new tab)
LLVMTypeResolver& sun::codegen::CodegenVisitor::typeResolverNo documentation comment.
Related: LLVMTypeResolver
variables
private · variable · Source (opens in a new tab)
variables::VariableGenerator sun::codegen::CodegenVisitor::variables {state_, *this}No documentation comment.
Related: variables::VariableGenerator, state_