void ICompilationRootProvider.AddCompilationRoots(IRootingServiceProvider rootProvider)
 {
     if (_isaSupport.Architecture == TargetArchitecture.X64 ||
         _isaSupport.Architecture == TargetArchitecture.X86)
     {
         int    isaFlags = HardwareIntrinsicHelpers.GetRuntimeRequiredIsaFlags(_isaSupport);
         byte[] bytes    = BitConverter.GetBytes(isaFlags);
         rootProvider.RootReadOnlyDataBlob(bytes, 4, "ISA support flags", "g_requiredCpuFeatures");
     }
 }
Exemple #2
0
        public override MethodIL GetMethodIL(MethodDesc method)
        {
            if (HardwareIntrinsicHelpers.IsHardwareIntrinsic(method) &&
                HardwareIntrinsicHelpers.IsIsSupportedMethod(method))
            {
                MethodIL methodIL = HardwareIntrinsicHelpers.EmitIsSupportedIL(method, _hardwareIntrinsicFlags);
                if (methodIL != null)
                {
                    return(methodIL);
                }
            }

            return(base.GetMethodIL(method));
        }
        public override MethodIL GetMethodIL(MethodDesc method)
        {
            TypeDesc owningType  = method.OwningType;
            string   intrinsicId = InstructionSetSupport.GetHardwareIntrinsicId(TypeSystemContext.Target.Architecture, owningType);

            if (!string.IsNullOrEmpty(intrinsicId) &&
                HardwareIntrinsicHelpers.IsIsSupportedMethod(method))
            {
                InstructionSet instructionSet = _instructionSetMap[intrinsicId];

                // If this is an instruction set that is optimistically supported, but is not one of the
                // intrinsics that are known to be always available, emit IL that checks the support level
                // at runtime.
                if (!InstructionSetSupport.IsInstructionSetSupported(instructionSet) &&
                    InstructionSetSupport.OptimisticFlags.HasInstructionSet(instructionSet))
                {
                    return(HardwareIntrinsicHelpers.EmitIsSupportedIL(method, _hardwareIntrinsicFlags, instructionSet));
                }
            }

            return(base.GetMethodIL(method));
        }