summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Sotkin <alexey.sotkin@intel.com>2016-06-06 18:22:53 +0300
committerYaxun (Sam) Liu <yaxun.liu@amd.com>2016-06-06 11:22:53 -0400
commite5bb7db2f0788e2a8089244142a34a72a9f38cda (patch)
tree4080fa94ad826ad06034ccf2d5ebbffd00427d57
parent1f269d0355a0cd42e4172e64849b12a89c43989b (diff)
Adding DeviceEnqueue capability for OpTypeQueue (#152)
-rw-r--r--lib/SPIRV/SPIRVWriter.cpp4
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVModule.cpp8
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVModule.h8
-rw-r--r--lib/SPIRV/libSPIRV/SPIRVType.h20
-rw-r--r--test/opencl.queue_t.ll28
-rw-r--r--test/spirv.Queue.ll28
6 files changed, 91 insertions, 5 deletions
diff --git a/lib/SPIRV/SPIRVWriter.cpp b/lib/SPIRV/SPIRVWriter.cpp
index 4637b68..16a602b 100644
--- a/lib/SPIRV/SPIRVWriter.cpp
+++ b/lib/SPIRV/SPIRVWriter.cpp
@@ -504,6 +504,8 @@ LLVMToSPIRV::transType(Type *T) {
return mapType(T, BM->addPipeType());
case OpTypeDeviceEvent:
return mapType(T, BM->addDeviceEventType());
+ case OpTypeQueue:
+ return mapType(T, BM->addQueueType());
}
} else if (isPointerToOpaqueStructType(T)) {
return mapType(T, BM->addPointerType(SPIRSPIRVAddrSpaceMap::map(
@@ -617,6 +619,8 @@ LLVMToSPIRV::transSPIRVOpaqueType(Type *T) {
return mapType(T, BM->addSamplerType());
else if (TN == kSPIRVTypeName::DeviceEvent)
return mapType(T, BM->addDeviceEventType());
+ else if (TN == kSPIRVTypeName::Queue)
+ return mapType(T, BM->addQueueType());
else
return mapType(T, BM->addOpaqueGenericType(
SPIRVOpaqueTypeOpCodeMap::map(TN)));
diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.cpp b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
index 9d8774b..7e1d52f 100644
--- a/lib/SPIRV/libSPIRV/SPIRVModule.cpp
+++ b/lib/SPIRV/libSPIRV/SPIRVModule.cpp
@@ -89,7 +89,7 @@ public:
SPIRVAddressingModelKind getAddressingModel() { return AddrModel;}
SPIRVExtInstSetKind getBuiltinSet(SPIRVId SetId) const;
const SPIRVCapMap &getCapability() const { return CapMap; }
- bool hasCapability(SPIRVCapabilityKind Cap) const {
+ bool hasCapability(SPIRVCapabilityKind Cap) const {
return CapMap.find(Cap) != CapMap.end();
}
std::set<std::string> &getExtension() { return SPIRVExt;}
@@ -203,6 +203,7 @@ public:
virtual SPIRVTypeVector *addVectorType(SPIRVType *, SPIRVWord);
virtual SPIRVType *addOpaqueGenericType(Op);
virtual SPIRVTypeDeviceEvent *addDeviceEventType();
+ virtual SPIRVTypeQueue *addQueueType();
virtual SPIRVTypePipe *addPipeType();
virtual SPIRVTypeVoid *addVoidType();
virtual void createForwardPointers();
@@ -726,6 +727,11 @@ SPIRVModuleImpl::addDeviceEventType() {
return addType(new SPIRVTypeDeviceEvent(this, getId()));
}
+SPIRVTypeQueue *
+SPIRVModuleImpl::addQueueType() {
+ return addType(new SPIRVTypeQueue(this, getId()));
+}
+
SPIRVTypePipe*
SPIRVModuleImpl::addPipeType() {
return addType(new SPIRVTypePipe(this, getId()));
diff --git a/lib/SPIRV/libSPIRV/SPIRVModule.h b/lib/SPIRV/libSPIRV/SPIRVModule.h
index 8739c3d..987bfec 100644
--- a/lib/SPIRV/libSPIRV/SPIRVModule.h
+++ b/lib/SPIRV/libSPIRV/SPIRVModule.h
@@ -1,4 +1,4 @@
-//===- SPIRVModule.h – Class to represent a SPIR-V module --------*- C++ -*-===//
+//===- SPIRVModule.h - Class to represent a SPIR-V module --------*- C++ -*-===//
//
// The LLVM/SPIRV Translator
//
@@ -71,6 +71,7 @@ class SPIRVTypeStruct;
class SPIRVTypeVector;
class SPIRVTypeVoid;
class SPIRVTypeDeviceEvent;
+class SPIRVTypeQueue;
class SPIRVTypePipe;
class SPIRVValue;
class SPIRVVariable;
@@ -149,8 +150,8 @@ public:
virtual void setGeneratorVer(unsigned short) = 0;
virtual void resolveUnknownStructFields() = 0;
virtual void setSPIRVVersion(SPIRVWord) = 0;
-
- void setMinSPIRVVersion(SPIRVWord Ver) {
+
+ void setMinSPIRVVersion(SPIRVWord Ver) {
setSPIRVVersion(std::max(Ver, getSPIRVVersion()));
}
@@ -206,6 +207,7 @@ public:
virtual SPIRVTypeVoid *addVoidType() = 0;
virtual SPIRVType *addOpaqueGenericType(Op) = 0;
virtual SPIRVTypeDeviceEvent *addDeviceEventType() = 0;
+ virtual SPIRVTypeQueue *addQueueType() = 0;
virtual SPIRVTypePipe *addPipeType() = 0;
virtual void createForwardPointers() = 0;
diff --git a/lib/SPIRV/libSPIRV/SPIRVType.h b/lib/SPIRV/libSPIRV/SPIRVType.h
index 182247d..aa0273d 100644
--- a/lib/SPIRV/libSPIRV/SPIRVType.h
+++ b/lib/SPIRV/libSPIRV/SPIRVType.h
@@ -636,7 +636,6 @@ public:
#define _SPIRV_OP(x) typedef SPIRVOpaqueGenericType<OpType##x> SPIRVType##x;
_SPIRV_OP(Event)
_SPIRV_OP(ReserveId)
-_SPIRV_OP(Queue)
#undef _SPIRV_OP
class SPIRVTypeDeviceEvent : public SPIRVType {
@@ -659,6 +658,25 @@ protected:
void validate() const { SPIRVEntry::validate(); }
};
+class SPIRVTypeQueue : public SPIRVType {
+public:
+ // Complete constructor
+ SPIRVTypeQueue(SPIRVModule *M, SPIRVId TheId)
+ : SPIRVType(M, 2, OpTypeQueue, TheId) {
+ validate();
+ }
+
+ // Incomplete constructor
+ SPIRVTypeQueue() : SPIRVType(OpTypeQueue) {}
+
+ SPIRVCapVec getRequiredCapability() const {
+ return getVec(CapabilityDeviceEnqueue);
+ }
+
+protected:
+ _SPIRV_DEF_ENCDEC1(Id)
+};
+
class SPIRVTypePipe :public SPIRVType {
public:
// Complete constructor
diff --git a/test/opencl.queue_t.ll b/test/opencl.queue_t.ll
new file mode 100644
index 0000000..90cf187
--- /dev/null
+++ b/test/opencl.queue_t.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | llvm-spirv -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+
+; CHECK-SPIRV: Capability DeviceEnqueue
+; CHECK-SPIRV: 2 TypeQueue
+
+target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
+target triple = "spir"
+
+%opencl.queue_t = type opaque
+
+; Function Attrs: nounwind readnone
+define spir_func void @enqueue_simple_block(%opencl.queue_t* addrspace(3)* nocapture %q) #0 {
+entry:
+ ret void
+}
+
+attributes #0 = { nounwind readnone "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!opencl.enable.FP_CONTRACT = !{}
+!opencl.spir.version = !{!0}
+!opencl.ocl.version = !{!1}
+!opencl.used.extensions = !{!2}
+!opencl.used.optional.core.features = !{!2}
+!opencl.compiler.options = !{!2}
+
+!0 = !{i32 1, i32 2}
+!1 = !{i32 2, i32 0}
+!2 = !{}
diff --git a/test/spirv.Queue.ll b/test/spirv.Queue.ll
new file mode 100644
index 0000000..0923d30
--- /dev/null
+++ b/test/spirv.Queue.ll
@@ -0,0 +1,28 @@
+; RUN: llvm-as < %s | llvm-spirv -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+
+; CHECK-SPIRV: Capability DeviceEnqueue
+; CHECK-SPIRV: 2 TypeQueue
+
+target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"
+target triple = "spir"
+
+%spirv.Queue = type opaque
+
+; Function Attrs: nounwind readnone
+define spir_func void @enqueue_simple_block(%spirv.Queue* addrspace(3)* nocapture %q) #0 {
+entry:
+ ret void
+}
+
+attributes #0 = { nounwind readnone "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
+
+!opencl.enable.FP_CONTRACT = !{}
+!opencl.spir.version = !{!0}
+!opencl.ocl.version = !{!1}
+!opencl.used.extensions = !{!2}
+!opencl.used.optional.core.features = !{!2}
+!opencl.compiler.options = !{!2}
+
+!0 = !{i32 1, i32 2}
+!1 = !{i32 2, i32 0}
+!2 = !{}