/// <summary> /// Constructs a new intrinsic implementation. /// </summary> /// <param name="implementation">The intrinsic implementation.</param> internal IntrinsicMapping(IntrinsicImplementation implementation) { Debug.Assert(implementation != null, "Invalid implementation"); Implementation = implementation; TargetMethod = implementation.TargetMethod; }
private TMatcher ResolveMatcher <TMatcher>( IntrinsicMatcher.MatcherKind kind, IntrinsicImplementation implementation) where TMatcher : IntrinsicMatcher <ImplementationEntry> { if (implementation == null) { throw new ArgumentNullException(nameof(implementation)); } var container = this[implementation.BackendType]; return(container[kind] as TMatcher); }
/// <summary> /// Registers the given intrinsic implementation. /// </summary> /// <param name="method">The method information.</param> /// <param name="implementation">The intrinsic implementation.</param> public void RegisterMethod(MethodInfo method, IntrinsicImplementation implementation) { var matcher = ResolveMatcher <IntrinsicMethodMatcher <ImplementationEntry> >( IntrinsicMatcher.MatcherKind.Method, implementation); if (!matcher.TryGetImplementation(method, out var entry)) { entry = new ImplementationEntry(); matcher.Register(method, entry); } entry.Register(implementation); }
private static bool CheckImplementations( Backend backend, IntrinsicImplementationManager.ImplementationEntry implementations, out IntrinsicImplementation mainImplementation) { mainImplementation = null; foreach (var implementation in implementations) { if (implementation.CanHandleBackend(backend)) { mainImplementation = implementation; return(true); } } return(false); }