Expand the managed API for Module, BasicBlock, Target, and instruction flags#265
Merged
tannergooding merged 4 commits intoJul 16, 2026
Conversation
Introduces a context-scoped ownership registry on LLVMContext so a Module is a cached, non-owning wrapper (matching the other managed value/type wrappers) and fills out the full accessor surface: identity, source file name, target triple, data-layout string, and module inline asm; function and global lookup, insertion, and enumeration; named struct-type lookup; and print/verify/clone/bitcode. Also exposes ModuleIdentifier, SourceFileName, and InlineAsm on LLVMModuleRef. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fills out BasicBlock to mirror llvm::BasicBlock: parent function, terminator, first/last instruction, next/previous block, instruction enumeration, and the move/remove/erase helpers. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
… API Round-trips the instruction poison-generating and fast-math flags through the C API rather than the native helpers: HasNoSignedWrap/HasNoUnsignedWrap move onto LLVMGetNSW/GetNUW with setters, and Exact, disjoint, non-negative, GEP no-wrap, in-bounds, icmp same-sign, and fast-math flags are added, each guarded by the owning instruction kind so a release build never reads the wrong option bits. Also adds the trivially-derived accessors that need no new interop: CalledFunction, the GEP index/pointer operands, and the load/store pointer and value operands. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Fills the target codegen wrappers to mirror the C++ surface: Target gains description and JIT/target-machine/asm-backend queries and target enumeration; TargetMachine gains CPU, feature string, target, and triple; DataLayout gains a target-data constructor plus call-frame alignment, element offset, and the element-containing-offset query. Adds the matching getters on LLVMTargetRef and LLVMTargetMachineRef. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Expands the high-level managed API (
sources/LLVMSharp) to cover thePhase-1 gaps that don't depend on new native
libLLVMSharphelpers, movingit closer to a faithful reproduction of the LLVM C++ API a real compiler or
JIT needs. Split into four logical commits by area.
Module -- adds a context-scoped ownership registry to
LLVMContextso aModuleis a cached, non-owning wrapper (consistent with the other managedvalue/type wrappers), and fills out the full accessor set: identity, source
file name, target triple, data-layout string, module inline asm; function and
global lookup/insertion/enumeration; named struct-type lookup; and
print/verify/clone/bitcode. Also exposes
ModuleIdentifier,SourceFileName, andInlineAsmonLLVMModuleRef.BasicBlock -- parent, terminator, first/last instruction, next/previous
block, instruction enumeration, and move/remove/erase helpers.
Instruction flags + derived accessors -- round-trips the poison-generating
and fast-math flags through the C API instead of native helpers:
HasNoSignedWrap/HasNoUnsignedWrapmove ontoLLVMGetNSW/GetNUWwith setters, and
Exact, disjoint, non-negative, GEP no-wrap, in-bounds,icmp same-sign, and fast-math flags are added -- each guarded by the owning
instruction kind so a release build never reads the wrong
SubclassOptionalDatabits. Also adds the trivially-derived
CalledFunction, GEP index/pointeroperands, and load/store pointer/value operands (no new interop).
Target / TargetMachine / DataLayout -- description, JIT/target-machine/
asm-backend queries, and target enumeration on
Target; CPU, feature string,target, and triple on
TargetMachine; a target-data constructor pluscall-frame alignment, element offset, and element-containing-offset on
DataLayout. Adds the matching getters onLLVMTargetRefandLLVMTargetMachineRef.Builds clean (0 warnings,
TreatWarningsAsErrors) with 5 new managed tests;full suite green. This is the managed half; the native
libLLVMSharphelpersand the managed accessors that consume them follow separately once the native
packages are rebuilt.