|
15 | 15 | //===----------------------------------------------------------------------===// |
16 | 16 |
|
17 | 17 | #include "SPIRVModuleAnalysis.h" |
| 18 | +#include "MCTargetDesc/SPIRVBaseInfo.h" |
| 19 | +#include "MCTargetDesc/SPIRVMCTargetDesc.h" |
18 | 20 | #include "SPIRV.h" |
19 | 21 | #include "SPIRVSubtarget.h" |
20 | 22 | #include "SPIRVTargetMachine.h" |
@@ -523,6 +525,12 @@ void SPIRV::RequirementHandler::addAvailableCaps(const CapabilityList &ToAdd) { |
523 | 525 | SPIRV::OperandCategory::CapabilityOperand, Cap)); |
524 | 526 | } |
525 | 527 |
|
| 528 | +void SPIRV::RequirementHandler::removeCapabilityIf(const Capability::Capability ToRemove, |
| 529 | + const Capability::Capability IfPresent) { |
| 530 | + if (AvailableCaps.contains(IfPresent)) |
| 531 | + AvailableCaps.erase(ToRemove); |
| 532 | +} |
| 533 | + |
526 | 534 | namespace llvm { |
527 | 535 | namespace SPIRV { |
528 | 536 | void RequirementHandler::initAvailableCapabilities(const SPIRVSubtarget &ST) { |
@@ -734,6 +742,11 @@ void addInstrRequirements(const MachineInstr &MI, |
734 | 742 | break; |
735 | 743 | } |
736 | 744 | case SPIRV::OpBitReverse: |
| 745 | + case SPIRV::OpBitFieldInsert: |
| 746 | + case SPIRV::OpBitFieldSExtract: |
| 747 | + case SPIRV::OpBitFieldUExtract: |
| 748 | + Reqs.addExtension(SPIRV::Extension::SPV_KHR_bit_instructions); |
| 749 | + break; |
737 | 750 | case SPIRV::OpTypeRuntimeArray: |
738 | 751 | Reqs.addCapability(SPIRV::Capability::Shader); |
739 | 752 | break; |
@@ -887,6 +900,12 @@ void addInstrRequirements(const MachineInstr &MI, |
887 | 900 | default: |
888 | 901 | break; |
889 | 902 | } |
| 903 | + |
| 904 | + // If we require capability Shader, then we can remove the requirement for |
| 905 | + // the BitInstructions capability, since Shader is a superset capability |
| 906 | + // of BitInstructions. |
| 907 | + Reqs.removeCapabilityIf(SPIRV::Capability::Shader, |
| 908 | + SPIRV::Capability::BitInstructions); |
890 | 909 | } |
891 | 910 |
|
892 | 911 | static void collectReqs(const Module &M, SPIRV::ModuleAnalysisInfo &MAI, |
|
0 commit comments