Support table driven importation for scalar hardware intrinsics (#33350)
authorKunal Pathak <Kunal.Pathak@microsoft.com>
Wed, 11 Mar 2020 21:48:46 +0000 (14:48 -0700)
committerGitHub <noreply@github.com>
Wed, 11 Mar 2020 21:48:46 +0000 (14:48 -0700)
commitac51d7802ca5a2ca9285a8db38ef61b75273414d
tree9269cf941d07e22ddcfad90b00e79c38e5f17608
parent83016f3bf2b5c4331bec431ef19a72064552779d
Support table driven importation for scalar hardware intrinsics (#33350)

* Deleted `mustExpand` parameter that we were passing to methods that never used it.
* Below xarch instructions are now imported with table driven logic:
  * NI_BMI1_AndNot
  * NI_BMI1_X64_AndNot
  * NI_BMI2_ParallelBitDeposit
  * NI_BMI2_ParallelBitExtract
  * NI_BMI2_X64_ParallelBitDeposit
  * NI_BMI2_X64_ParallelBitExtract
  * NI_BMI1_ExtractLowestSetBit
  * NI_BMI1_GetMaskUpToLowestSetBit
  * NI_BMI1_ResetLowestSetBit
  * NI_BMI1_TrailingZeroCount
  * NI_BMI1_X64_ExtractLowestSetBit
  * NI_BMI1_X64_GetMaskUpToLowestSetBit
  * NI_BMI1_X64_ResetLowestSetBit
  * NI_BMI1_X64_TrailingZeroCount
  * NI_BMI2_MultiplyNoFlags
  * NI_BMI2_X64_MultiplyNoFlags
  * InstructionSet_LZCNT
  * InstructionSet_LZCNT_X64
  * InstructionSet_POPCNT
  * InstructionSet_POPCNT_X64
  * NI_SSE42_Crc32
  * NI_SSE42_X64_Crc32
* Below ARM instructions are now imported with table driven logic:
  * NI_ArmBase_LeadingZeroCount
  * NI_ArmBase_ReverseElementBits
  * NI_ArmBase_Arm64_LeadingSignCount
  * NI_ArmBase_Arm64_LeadingZeroCount
  * NI_ArmBase_Arm64_ReverseElementBits
  * NI_Sha1_FixedRotate
  * NI_Crc32_ComputeCrc32
  * NI_Crc32_ComputeCrc32C
  * NI_Crc32_Arm64_ComputeCrc32
  * NI_Crc32_Arm64_ComputeCrc32C

* Updated the impIsTableDrivenHWIntrinsic() method to not check for `HW_Category_Scalar` anymore because almost all scalar intrinsic will be handled by table-driven. For scalar intrinsic which needs special handling I have tagged them with `HW_Flag_SpecialImport` to make sure they don't get imported using table-driven logic.
* In `hwintrinsiccodegenarm64.cpp`, I have removed a condition of `HW_Category_Special` because no instruction of arm64 were tagged with this category.
* I have created `getBaseTypeFromArgIfNeeded()` method that contains logic to extract `baesType` from args if the argument was flagged as one of `BaseTypeFromFirstArg` or `BaseTypeFromSecondArg`. This method is reused inside special handling of intrinsic for arm.
src/coreclr/src/jit/compiler.h
src/coreclr/src/jit/hwintrinsic.cpp
src/coreclr/src/jit/hwintrinsicarm64.cpp
src/coreclr/src/jit/hwintrinsiccodegenarm64.cpp
src/coreclr/src/jit/hwintrinsiclistarm64.h
src/coreclr/src/jit/hwintrinsiclistxarch.h
src/coreclr/src/jit/hwintrinsicxarch.cpp