Repository: dotnet/runtime
File: src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs (C#)

Code before:
                matchingVectorType = "Vector128`1"u8;
            else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector256Bit)
                matchingVectorType = "Vector256`1"u8;
            else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector512Bit)
                matchingVectorType = "Vector512`1"u8;

            _vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, _vectorFieldLayoutAlgorithm, matchingVectorType);
            _int128FieldLayoutAlgorithm = new Int128FieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);

            _typeWithRepeatedFieldsFieldLayoutAlgorithm = new TypeWithRepeatedFieldsFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);

            if (oldTypeSystemContext != null)
            {
                InheritOpenModules(oldTypeSystemContext);
            }
        }

        public bool BubbleIncludesCoreModule { get; }

        public InstructionSetSupport InstructionSetSupport { get; }

        public bool TargetAllowsRuntimeCodeGeneration
        {
            get
            {
                if (Target.OperatingSystem is TargetOS.iOS or TargetOS.iOSSimulator or TargetOS.MacCatalyst or TargetOS.tvOS or TargetOS.tvOSSimulator)
                {
                    return false;
                }

                if (Target.Architecture is TargetArchitecture.Wasm32)
                {
                    return false;
                }

                return true;
            }
        }

        public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type)
        {
            if (type.IsObject)
                return _systemObjectFieldLayoutAlgorithm;
            else if (type == UniversalCanonType)
                throw new NotImplementedException();
            else if (type.IsRuntimeDeterminedType)
                throw new NotImplementedException();
            else if (VectorOfTFieldLayoutAlgorithm.IsVectorOfTType(type))
            {
                return _vectorOfTFieldLayoutAlgorithm;
            }

Review comment (suggestion):
crossgen2 is meant to be cross-targeting by construction. It would be better to expose this as a command line option. 

I understand that the ifdef is more convenient for what you are trying to do. I am ok with it - no need to fix it in this PR.

Code after:
                matchingVectorType = "Vector128`1"u8;
            else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector256Bit)
                matchingVectorType = "Vector256`1"u8;
            else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector512Bit)
                matchingVectorType = "Vector512`1"u8;

            _vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, _vectorFieldLayoutAlgorithm, matchingVectorType);
            _int128FieldLayoutAlgorithm = new Int128FieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);

            _typeWithRepeatedFieldsFieldLayoutAlgorithm = new TypeWithRepeatedFieldsFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);

            if (oldTypeSystemContext != null)
            {
                InheritOpenModules(oldTypeSystemContext);
            }
        }

        public bool BubbleIncludesCoreModule { get; }

        public InstructionSetSupport InstructionSetSupport { get; }

        public bool TargetAllowsRuntimeCodeGeneration
        {
            get
            {
#if FEATURE_DYNAMIC_CODE_COMPILED
                if (Target.OperatingSystem is TargetOS.iOS or TargetOS.iOSSimulator or TargetOS.MacCatalyst or TargetOS.tvOS or TargetOS.tvOSSimulator)
                {
                    return false;
                }

                if (Target.Architecture is TargetArchitecture.Wasm32)
                {
                    return false;
                }

                return true;
#else
                return false;
#endif
            }
        }

        public override FieldLayoutAlgorithm GetLayoutAlgorithmForType(DefType type)
        {
            if (type.IsObject)
                return _systemObjectFieldLayoutAlgorithm;
            else if (type == UniversalCanonType)
                throw new NotImplementedException();
            else if (type.IsRuntimeDeterminedType)
                throw new NotImplementedException();