Skip to content

Mirror C++ predicate, vector, intrinsic, and comdat surface on the managed API#270

Merged
tannergooding merged 5 commits into
dotnet:mainfrom
tannergooding:tannergooding-managed-cpp-api-emulation
Jul 16, 2026
Merged

Mirror C++ predicate, vector, intrinsic, and comdat surface on the managed API#270
tannergooding merged 5 commits into
dotnet:mainfrom
tannergooding:tannergooding-managed-cpp-api-emulation

Conversation

@tannergooding

Copy link
Copy Markdown
Member

Mirror a set of llvm:: C++ class members on the managed high-level API that are pure functions of state already reachable through the LLVM-C API, so no native libLLVMSharp rebuild is required. Each addition is validated against the LLVM 21.1.8 C++ headers and covered by new ManagedApi unit tests.


CmpInst predicate surface (CmpInst.Predicate.cs, CmpInst.cs, ICmpInst.cs, FCmpInst.cs)

  • Static predicate helpers off the Predicate enum: GetInverse/Swapped/Ordered/Unordered/Strict/NonStrictPredicate, IsFP/IsInt/IsStrict/IsEquality/IsRelational/IsSigned/IsUnsigned/IsOrdered/IsUnordered/IsTrueWhenEqual/IsFalseWhenEqual.
  • ICmpInst.GetSigned/GetUnsignedPredicate + IsEquality; FCmpInst.IsEquality.
  • Instance forms mirroring the C++ overloads (getInversePredicate(), isSigned(), FCmpInst.isOrdered(), etc.), each delegating to the vetted static helper off GetPredicate().

VectorType scalable support (Type.cs, CompositeType.cs, SequentialType.cs, VectorType.cs)

  • Route LLVMScalableVectorTypeKind to VectorType and add VectorType.IsScalable.

Function.IsIntrinsicIntrinsicID != 0.

Managed Comdat type (Comdat.cs, GlobalObject.cs, Module.cs)

  • Sealed Comdat wrapper exposing SelectionKind; GlobalObject.Comdat/HasComdat; Module.GetOrInsertComdat, over the existing LLVM-C comdat API.

Builds with 0 warnings; 2620 unit tests pass (7 Kaleidoscope failures are pre-existing environmental, unrelated to this change).

tannergooding and others added 5 commits July 15, 2026 22:36
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Wrap LLVMComdatRef in a managed Comdat exposing SelectionKind, add the LLVMValueRef.Comdat / LLVMComdatRef.SelectionKind / LLVMModuleRef.GetOrInsertComdat interop accessors it builds on, and surface GlobalObject.Comdat/HasComdat and Module.GetOrInsertComdat over the existing LLVM-C comdat API.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Mirror the C++ CmpInst/ICmpInst/FCmpInst instance predicate overloads (getInverse/swapped/ordered/unordered/strict/non-strict predicate, isFP/isInt/isStrict/isEquality/isRelational/isSigned/isUnsigned/isTrueWhenEqual/isFalseWhenEqual, ICmpInst getSigned/getUnsignedPredicate, FCmpInst isOrdered/isUnordered) by delegating to the existing static predicate helpers off GetPredicate(). Pure managed, so the isEquality/isRelational follow-up needs no native round-trip.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@tannergooding
tannergooding merged commit 93bfaba into dotnet:main Jul 16, 2026
12 checks passed
@tannergooding
tannergooding deleted the tannergooding-managed-cpp-api-emulation branch July 16, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant