; Define the set of instruction sets available on a platform
; Format is
;
; Add new instruction set
; instructionset,<architecture>,<managed name>,<r2r name if different>,<R2R numeric value>, <jit instruction set name>, <public name>
;
; The public name is intended to match with mono for specifying what the name of the instruction set is. These names match names produced by other compilers as well.
;
; Add jit 64bit architecture specific instruction set when instruction set is available
; instructionset64bit,<architecture>,<jit instruction set name>
;
; Note that a instruction set is a "Vector" instruction set. A vector instruction set may only imply a single other instruction set
; vectorinstructionset,<architecture>,<jit instruction set name>
;
; Add an instruction set implication (i.e, if instruction set A is present, then instruction set B must be present too.)
; implication,<architecture>,<jit instruction set name>,<implied jit instruction set name>
;
; Copy instruction sets defined for other architecture at this point in the file.
; copyinstructionsets,<architecture>,<copytoarchitecture>

; UPDATE JIT/EE INTERFACE GUID WHEN CHANGING THESE DEFINITIONS. The instruction set definitions are part of JIT/EE interface contract.

; DO NOT CHANGE R2R NUMERIC VALUES OF THE EXISTING SETS. Changing R2R numeric values definitions would be R2R format breaking change.

; The ISA definitions should also be mapped to `hwintrinsicIsaRangeArray` in hwintrinsic.cpp.
; NEXT_AVAILABLE_R2R_BIT = 82

; Definition of X86 instruction sets
definearch         ,X86   ,32Bit                ,X64, X64

instructionset     ,X86   ,X86Base              ,                   ,22 ,X86Base               ,base
instructionset     ,X86   ,Sse                  ,                   ,1  ,X86Base               ,base
instructionset     ,X86   ,Sse2                 ,                   ,2  ,X86Base               ,base

instructionset     ,X86   ,Sse42                ,                   ,6  ,SSE42                 ,sse4.2
instructionset     ,X86   ,Sse3                 ,                   ,3  ,SSE42                 ,sse4.2
instructionset     ,X86   ,Ssse3                ,                   ,4  ,SSE42                 ,sse4.2
instructionset     ,X86   ,Sse41                ,                   ,5  ,SSE42                 ,sse4.2
instructionset     ,X86   ,Popcnt               ,                   ,15 ,SSE42                 ,sse4.2

instructionset     ,X86   ,Avx                  ,                   ,7  ,AVX                   ,avx

instructionset     ,X86   ,Avx2                 ,                   ,8  ,AVX2                  ,avx2
instructionset     ,X86   ,Bmi1                 ,                   ,10 ,AVX2                  ,avx2
instructionset     ,X86   ,Bmi2                 ,                   ,11 ,AVX2                  ,avx2
instructionset     ,X86   ,F16C                 ,                   ,67 ,AVX2                  ,avx2
instructionset     ,X86   ,Fma                  ,                   ,12 ,AVX2                  ,avx2
instructionset     ,X86   ,Lzcnt                ,                   ,13 ,AVX2                  ,avx2
instructionset     ,X86   ,                     ,Movbe              ,27 ,AVX2                  ,avx2

instructionset     ,X86   ,                     ,Evex               ,47 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512F              ,                   ,29 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512F_VL           ,                   ,30 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512BW             ,                   ,31 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512BW_VL          ,                   ,32 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512CD             ,                   ,33 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512CD_VL          ,                   ,34 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512DQ             ,                   ,35 ,AVX512                ,avx512
instructionset     ,X86   ,Avx512DQ_VL          ,                   ,36 ,AVX512                ,avx512

instructionset     ,X86   ,                     ,Avx512Ifma         ,76 ,AVX512v2              ,avx512v2
instructionset     ,X86   ,Avx512Vbmi           ,                   ,37 ,AVX512v2              ,avx512v2
instructionset     ,X86   ,Avx512Vbmi_VL        ,                   ,38 ,AVX512v2              ,avx512v2

instructionset     ,X86   ,Avx512Bitalg         ,                   ,70 ,AVX512v3              ,avx512v3
instructionset     ,X86   ,Avx512Bitalg_VL      ,                   ,71 ,AVX512v3              ,avx512v3
instructionset     ,X86   ,Avx512Vbmi2          ,                   ,77 ,AVX512v3              ,avx512v3
instructionset     ,X86   ,Avx512Vbmi2_VL       ,                   ,78 ,AVX512v3              ,avx512v3
instructionset     ,X86   ,                     ,Avx512Vnni         ,79 ,AVX512v3              ,avx512v3
instructionset     ,X86   ,Avx512Vpopcntdq      ,                   ,82 ,AVX512v3              ,avx512v3
instructionset     ,X86   ,Avx512Vpopcntdq_VL   ,                   ,83 ,AVX512v3              ,avx512v3

instructionset     ,X86   ,Avx512Bf16           ,                   ,72 ,AVX10v1               ,avx10v1
instructionset     ,X86   ,Avx512Bf16_VL        ,                   ,73 ,AVX10v1               ,avx10v1
instructionset     ,X86   ,Avx512Fp16           ,                   ,74 ,AVX10v1               ,avx10v1
instructionset     ,X86   ,Avx512Fp16_VL        ,                   ,75 ,AVX10v1               ,avx10v1
instructionset     ,X86   ,Avx10v1              ,                   ,44 ,AVX10v1               ,avx10v1
instructionset     ,X86   ,Avx10v1_V512         ,                   ,46 ,AVX10v1               ,avx10v1

instructionset     ,X86   ,Avx10v2              ,                   ,51 ,AVX10v2               ,avx10v2
instructionset     ,X86   ,Avx10v2_V512         ,                   ,52 ,AVX10v2               ,avx10v2

instructionset     ,X86   ,                     ,Apx                ,48 ,APX                   ,apx

instructionset     ,X86   ,Aes                  ,                   ,9  ,AES                   ,aes
instructionset     ,X86   ,Aes_V256             ,                   ,64 ,AES_V256              ,aes_v256
instructionset     ,X86   ,Aes_V512             ,                   ,65 ,AES_V512              ,aes_v512

instructionset     ,X86   ,Pclmulqdq            ,                   ,14 ,AES                   ,aes
instructionset     ,X86   ,Pclmulqdq_V256       ,                   ,49 ,AES_V256              ,aes_v256
instructionset     ,X86   ,Pclmulqdq_V512       ,                   ,50 ,AES_V512              ,aes_v512

instructionset     ,X86   ,Avx512Vp2intersect   ,                   ,80 ,AVX512VP2INTERSECT    ,avx512vp2intersect
instructionset     ,X86   ,Avx512Vp2intersect_VL,                   ,81 ,AVX512VP2INTERSECT    ,avx512vp2intersect

instructionset     ,X86   ,AvxIfma              ,                   ,66 ,AVXIFMA               ,avxifma
instructionset     ,X86   ,AvxVnni              ,                   ,25 ,AVXVNNI               ,avxvnni

instructionset     ,X86   ,Gfni                 ,                   ,53 ,GFNI                  ,gfni
instructionset     ,X86   ,Gfni_V256            ,                   ,54 ,GFNI_V256             ,gfni_v256
instructionset     ,X86   ,Gfni_V512            ,                   ,55 ,GFNI_V512             ,gfni_v512

instructionset     ,X86   ,Sha                  ,                   ,68 ,SHA                   ,sha

instructionset     ,X86   ,WaitPkg              ,                   ,69 ,WAITPKG               ,waitpkg
instructionset     ,X86   ,X86Serialize         ,                   ,28 ,X86Serialize          ,x86serialize

instructionset     ,X86   ,                     ,                   ,   ,Vector128             ,
instructionset     ,X86   ,                     ,                   ,   ,Vector256             ,
instructionset     ,X86   ,                     ,                   ,   ,Vector512             ,

instructionset     ,X86   ,                     ,VectorT128         ,39 ,VectorT128            ,vectort128
instructionset     ,X86   ,                     ,VectorT256         ,40 ,VectorT256            ,vectort256
instructionset     ,X86   ,                     ,VectorT512         ,41 ,VectorT512            ,vectort512


instructionset     ,X86   ,AvxVnniInt8          ,                   ,60 ,AVXVNNIINT            ,avxvnniint
instructionset     ,X86   ,AvxVnniInt8_V512     ,                   ,61 ,AVXVNNIINT_V512       ,avxvnniint_v512
instructionset     ,X86   ,AvxVnniInt16         ,                   ,62 ,AVXVNNIINT            ,avxvnniint
instructionset     ,X86   ,AvxVnniInt16_V512    ,                   ,63 ,AVXVNNIINT_V512       ,avxvnniint_v512

; 64-bit Instruction Sets

instructionset64bit,X86   ,X86Base
instructionset64bit,X86   ,SSE42

instructionset64bit,X86   ,AVX
instructionset64bit,X86   ,AVX2

instructionset64bit,X86   ,AVX512
instructionset64bit,X86   ,AVX512v2
instructionset64bit,X86   ,AVX512v3

instructionset64bit,X86   ,AVX10v1
instructionset64bit,X86   ,AVX10v2

instructionset64bit,X86   ,AES

instructionset64bit,X86   ,AVX512VP2INTERSECT
instructionset64bit,X86   ,AVXIFMA
instructionset64bit,X86   ,AVXVNNI

instructionset64bit,X86   ,GFNI
instructionset64bit,X86   ,SHA
instructionset64bit,X86   ,WAITPKG
instructionset64bit,X86   ,X86Serialize

; Vector Instruction Sets

vectorinstructionset,X86  ,Vector128
vectorinstructionset,X86  ,Vector256
vectorinstructionset,X86  ,Vector512

; Implications

implication        ,X86   ,SSE42                ,X86Base

implication        ,X86   ,AVX                  ,SSE42
implication        ,X86   ,AVX2                 ,AVX

implication        ,X86   ,AVX512               ,AVX2
implication        ,X86   ,AVX512v2             ,AVX512
implication        ,X86   ,AVX512v3             ,AVX512v2

implication        ,X86   ,AVX10v1              ,AVX512v3
implication        ,X86   ,AVX10v2              ,AVX10v1

implication        ,X86   ,AES                  ,X86Base
implication        ,X86   ,AES_V256             ,AES
implication        ,X86   ,AES_V256             ,AVX
implication        ,X86   ,AES_V512             ,AES_V256
implication        ,X86   ,AES_V512             ,AVX512

implication        ,X86   ,AVX512VP2INTERSECT   ,AVX512
implication        ,X86   ,AVXIFMA              ,AVX2
implication        ,X86   ,AVXVNNI              ,AVX2

implication        ,X86   ,GFNI                 ,SSE42
implication        ,X86   ,GFNI_V256            ,GFNI
implication        ,X86   ,GFNI_V256            ,AVX
implication        ,X86   ,GFNI_V512            ,GFNI_V256
implication        ,X86   ,GFNI_V512            ,AVX512

implication        ,X86   ,SHA                  ,X86Base
implication        ,X86   ,WAITPKG              ,X86Base
implication        ,X86   ,X86Serialize         ,X86Base

implication        ,X86   ,AVXVNNIINT           ,AVX2
implication        ,X86   ,AVXVNNIINT_V512      ,AVX10v2

; These synthetic ISAs need to appear after the core ISAs
; as they depend on the other implications being correct first
; otherwise they may not be disabled if the required isa is disabled

implication        ,X86   ,Vector128            ,X86Base
implication        ,X86   ,Vector256            ,AVX
implication        ,X86   ,Vector512            ,AVX512

implication        ,X86   ,VectorT128           ,X86Base
implication        ,X86   ,VectorT256           ,AVX2
implication        ,X86   ,VectorT512           ,AVX512

; Definition of X64 instruction sets
definearch         ,X64   ,64Bit     ,X64, X64

copyinstructionsets,X86   ,X64

; Definition of Arm64 instruction sets
definearch         ,ARM64 ,64Bit     ,Arm64, Arm64

instructionset     ,ARM64 ,ArmBase               ,        ,16 ,ArmBase               ,base
instructionset     ,ARM64 ,AdvSimd               ,        ,17 ,AdvSimd               ,neon
instructionset     ,ARM64 ,Aes                   ,        ,9  ,Aes                   ,aes
instructionset     ,ARM64 ,Crc32                 ,        ,18 ,Crc32                 ,crc
instructionset     ,ARM64 ,Dp                    ,        ,23 ,Dp                    ,dotprod
instructionset     ,ARM64 ,Rdm                   ,        ,24 ,Rdm                   ,rdma
instructionset     ,ARM64 ,Sha1                  ,        ,19 ,Sha1                  ,sha1
instructionset     ,ARM64 ,Sha256                ,        ,20 ,Sha256                ,sha2
instructionset     ,ARM64 ,                      ,Atomics ,21 ,Atomics               ,lse
instructionset     ,ARM64 ,                      ,        ,   ,Vector64              ,
instructionset     ,ARM64 ,                      ,        ,   ,Vector128             ,
instructionset     ,ARM64 ,                      ,        ,   ,Dczva                 ,
instructionset     ,ARM64 ,                      ,Rcpc    ,26 ,Rcpc                  ,rcpc
instructionset     ,ARM64 ,VectorT128            ,        ,39 ,VectorT128            ,vectort128
instructionset     ,ARM64 ,                      ,Rcpc2   ,42 ,Rcpc2                 ,rcpc2
instructionset     ,ARM64 ,Sve                   ,        ,43 ,Sve                   ,sve
instructionset     ,ARM64 ,Sve2                  ,        ,59 ,Sve2                  ,sve2

instructionset64bit,ARM64 ,ArmBase
instructionset64bit,ARM64 ,AdvSimd
instructionset64bit,ARM64 ,Aes
instructionset64bit,ARM64 ,Crc32
instructionset64bit,ARM64 ,Dp
instructionset64bit,ARM64 ,Rdm
instructionset64bit,ARM64 ,Sha1
instructionset64bit,ARM64 ,Sha256
instructionset64bit,ARM64 ,Sve
instructionset64bit,ARM64 ,Sve2

vectorinstructionset,ARM64,Vector64
vectorinstructionset,ARM64,Vector128

implication        ,ARM64 ,AdvSimd    ,ArmBase
implication        ,ARM64 ,Aes        ,ArmBase
implication        ,ARM64 ,Crc32      ,ArmBase
implication        ,ARM64 ,Dp         ,AdvSimd
implication        ,ARM64 ,Rdm        ,AdvSimd
implication        ,ARM64 ,Sha1       ,ArmBase
implication        ,ARM64 ,Sha256     ,ArmBase
implication        ,ARM64 ,Vector64   ,AdvSimd
implication        ,ARM64 ,Vector128  ,AdvSimd
implication        ,ARM64 ,VectorT128 ,AdvSimd
implication        ,ARM64 ,Sve        ,AdvSimd
implication        ,ARM64 ,Sve2       ,Sve

; Definition of Riscv64 instruction sets
definearch         ,RiscV64 ,64Bit     ,RiscV64, RiscV64

instructionset     ,RiscV64 ,RiscV64Base         ,        ,56 ,RiscV64Base         ,base
instructionset     ,RiscV64 ,Zba                 ,        ,57 ,Zba                 ,zba
instructionset     ,RiscV64 ,Zbb                 ,        ,58 ,Zbb                 ,zbb

implication        ,RiscV64 ,Zbb                 ,RiscV64Base
implication        ,RiscV64 ,Zba                 ,RiscV64Base

;                    ,name and aliases           ,archs    ,lower baselines included by implication
instructionsetgroup  ,x86-64                     ,X64 X86  ,base
instructionsetgroup  ,x86-64-v2                  ,X64 X86  ,x86-64 sse4.2
instructionsetgroup  ,x86-64-v3                  ,X64 X86  ,x86-64-v2 avx2
instructionsetgroup  ,x86-64-v4                  ,X64 X86  ,x86-64-v3 avx512

instructionsetgroup  ,armv8-a                    ,ARM64    ,neon
instructionsetgroup  ,armv8.1-a                  ,ARM64    ,armv8-a lse crc rdma
instructionsetgroup  ,armv8.2-a                  ,ARM64    ,armv8.1-a
instructionsetgroup  ,armv8.3-a                  ,ARM64    ,armv8.2-a rcpc
instructionsetgroup  ,armv8.4-a                  ,ARM64    ,armv8.3-a dotprod rcpc2
instructionsetgroup  ,armv8.5-a                  ,ARM64    ,armv8.4-a
instructionsetgroup  ,armv8.6-a                  ,ARM64    ,armv8.5-a

; Technically, apple-m1 is v8.5+
instructionsetgroup  ,apple-m1                   ,ARM64    ,armv8.5-a
