Skip to content

Commit

Permalink
Update_1
Browse files Browse the repository at this point in the history
  • Loading branch information
bwlodarcz committed Dec 1, 2023
1 parent a93e9e8 commit 1fa3a91
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/SPIRV/SPIRVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4535,6 +4535,11 @@ bool SPIRVToLLVM::transFPGAFunctionMetadata(SPIRVFunction *BF, Function *F) {
MetadataVec.push_back(ConstantAsMetadata::get(getInt32(M, 1)));
F->setMetadata(kSPIR2MD::StallEnable, MDNode::get(*Context, MetadataVec));
}
if (BF->hasDecorate(DecorationStallFreeINTEL)) {
std::vector<Metadata *> MetadataVec;
MetadataVec.push_back(ConstantAsMetadata::get(getInt32(M, 1)));
F->setMetadata(kSPIR2MD::StallFree, MDNode::get(*Context, MetadataVec));
}
if (BF->hasDecorate(DecorationFuseLoopsInFunctionINTEL)) {
std::vector<Metadata *> MetadataVec;
auto Literals =
Expand Down
7 changes: 4 additions & 3 deletions lib/SPIRV/SPIRVWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1000,10 +1000,11 @@ void LLVMToSPIRVBase::transFPGAFunctionMetadata(SPIRVFunction *BF,
}
if (MDNode *StallFree = F->getMetadata(kSPIR2MD::StallFree)) {
if (BM->isAllowedToUseExtension(
ExtensionID::SPV_INTEL_fpga_cluster_attributes) &&
BM->hasCapability(spv::CapabilityFPGAClusterAttributesV2INTEL)) {
if (getMDOperandAsInt(StallFree, 0))
ExtensionID::SPV_INTEL_fpga_cluster_attributes)) {
if (getMDOperandAsInt(StallFree, 0)) {
BM->addCapability(spv::CapabilityFPGAClusterAttributesV2INTEL);
BF->addDecorate(new SPIRVDecorateStallFreeINTEL(BF));
}
}
}
if (MDNode *LoopFuse = F->getMetadata(kSPIR2MD::LoopFuse)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
; RUN: llvm-as %s -o %t.bc
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_fpga_cluster_attributes -spirv-text -o - %t.bc | FileCheck --check-prefix CHECK-SPIRV %s
; RUN: llvm-spirv --spirv-ext=+SPV_INTEL_fpga_cluster_attributes %t.bc -o %t.spv
; spirv-val %t.spv
; RUN: llvm-spirv -r --spirv-ext=+SPV_INTEL_fpga_cluster_attributes %t.spv -o %t.rev.bc
; RUN: llvm-dis %t.rev.bc -o - | FileCheck --check-prefix CHECK-LLVM %s

target triple = "spir64-unknown-unknown"

; CHECK-SPIRV-DAG: Capability FPGAClusterAttributesINTEL
; CHECK-SPIRV-DAG: Capability FPGAClusterAttributesV2INTEL
; CHECK-SPIRV-DAG: Extension "SPV_INTEL_fpga_cluster_attributes"
; CHECK-SPIRV-DAG: Decorate [[#STALLENABLE_DEC:]] StallEnableINTEL
; CHECK-SPIRV-DAG: Decorate [[#STALLFREE_DEC:]] StallFreeINTEL
; CHECK-SPIRV: Function {{[0-9]+}} [[#STALLENABLE_DEC]] {{[0-9]+}} {{[0-9]+}}
; CHECK-SPIRV: Function {{[0-9]+}} [[#STALLFREE_DEC]] {{[0-9]+}} {{[0-9]+}}
; CHECK-LLVM: define spir_func void @test_fpga_stallenable_attr() {{.*}} !stall_enable [[STALL_MD:![0-9]+]]
; CHECK-LLVM: define spir_func void @test_fpga_stallfree_attr() {{.*}} !stall_free [[STALL_MD]]
; CHECK-LLVM: [[STALL_MD]] = !{i32 1}


define spir_func void @test_fpga_stallenable_attr() !stall_enable !0 {
entry:
ret void
}

define spir_func void @test_fpga_stallfree_attr() !stall_free !1 {
entry:
ret void
}

!0 = !{ i32 1 }
!1 = !{ i32 1 }

0 comments on commit 1fa3a91

Please sign in to comment.