-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d2ccf4f
commit 4d03388
Showing
6 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...gnan/src/main/java/com/dat3m/dartagnan/parsers/program/visitors/spirv/VisitorOpsMisc.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package com.dat3m.dartagnan.parsers.program.visitors.spirv; | ||
|
||
import com.dat3m.dartagnan.exception.ParsingException; | ||
import com.dat3m.dartagnan.expression.Expression; | ||
import com.dat3m.dartagnan.expression.Type; | ||
import com.dat3m.dartagnan.expression.type.VoidType; | ||
import com.dat3m.dartagnan.parsers.SpirvBaseVisitor; | ||
import com.dat3m.dartagnan.parsers.SpirvParser; | ||
import com.dat3m.dartagnan.parsers.program.visitors.spirv.builders.ProgramBuilder; | ||
|
||
import java.util.Set; | ||
|
||
public class VisitorOpsMisc extends SpirvBaseVisitor<Expression> { | ||
|
||
private final ProgramBuilder builder; | ||
|
||
public VisitorOpsMisc(ProgramBuilder builder) { | ||
this.builder = builder; | ||
} | ||
|
||
@Override | ||
public Expression visitOpUndef(SpirvParser.OpUndefContext ctx) { | ||
String id = ctx.idResult().getText(); | ||
Type type = builder.getType(ctx.idResultType().getText()); | ||
if (!(type instanceof VoidType)) { | ||
Expression expression = builder.makeUndefinedValue(type); | ||
return builder.addExpression(id, expression); | ||
} | ||
throw new ParsingException("Illegal definition '%s': " + | ||
"OpUndef cannot have void type", id); | ||
} | ||
|
||
public Set<String> getSupportedOps() { | ||
return Set.of( | ||
"OpUndef" | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
dartagnan/src/test/resources/spirv/basic/undef-exists.spv.dis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; @Input: %out = {0, 0} | ||
; @Output: exists (%out[0] == %out[1]) | ||
; @Config: 2, 1, 1 | ||
; SPIR-V | ||
; Version: 1.0 | ||
; Schema: 0 | ||
OpCapability Shader | ||
OpCapability VulkanMemoryModel | ||
OpMemoryModel Logical Vulkan | ||
OpEntryPoint GLCompute %main "main" %ids | ||
OpSource GLSL 450 | ||
OpDecorate %ids BuiltIn GlobalInvocationId | ||
%void = OpTypeVoid | ||
%bool = OpTypeBool | ||
%func = OpTypeFunction %void | ||
%uint = OpTypeInt 32 0 | ||
%v3uint = OpTypeVector %uint 3 | ||
%v2uint = OpTypeVector %uint 2 | ||
%ptr_uint = OpTypePointer Private %uint | ||
%ptr_v3uint = OpTypePointer Input %v3uint | ||
%ptr_v2uint = OpTypePointer Output %v2uint | ||
%c0 = OpConstant %uint 0 | ||
%ids = OpVariable %ptr_v3uint Input | ||
%out = OpVariable %ptr_v2uint Output | ||
%undef = OpUndef %uint | ||
%main = OpFunction %void None %func | ||
%label = OpLabel | ||
%id_ptr = OpAccessChain %ptr_uint %ids %c0 | ||
%id = OpLoad %uint %id_ptr | ||
%ptr_out = OpAccessChain %ptr_uint %out %id | ||
OpStore %ptr_out %undef | ||
OpReturn | ||
OpFunctionEnd |
33 changes: 33 additions & 0 deletions
33
dartagnan/src/test/resources/spirv/basic/undef-forall.spv.dis
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
; @Input: %out = {0, 0} | ||
; @Output: forall (%out[0] == %out[1]) | ||
; @Config: 2, 1, 1 | ||
; SPIR-V | ||
; Version: 1.0 | ||
; Schema: 0 | ||
OpCapability Shader | ||
OpCapability VulkanMemoryModel | ||
OpMemoryModel Logical Vulkan | ||
OpEntryPoint GLCompute %main "main" %ids | ||
OpSource GLSL 450 | ||
OpDecorate %ids BuiltIn GlobalInvocationId | ||
%void = OpTypeVoid | ||
%bool = OpTypeBool | ||
%func = OpTypeFunction %void | ||
%uint = OpTypeInt 32 0 | ||
%v3uint = OpTypeVector %uint 3 | ||
%v2uint = OpTypeVector %uint 2 | ||
%ptr_uint = OpTypePointer Private %uint | ||
%ptr_v3uint = OpTypePointer Input %v3uint | ||
%ptr_v2uint = OpTypePointer Output %v2uint | ||
%c0 = OpConstant %uint 0 | ||
%ids = OpVariable %ptr_v3uint Input | ||
%out = OpVariable %ptr_v2uint Output | ||
%undef = OpUndef %uint | ||
%main = OpFunction %void None %func | ||
%label = OpLabel | ||
%id_ptr = OpAccessChain %ptr_uint %ids %c0 | ||
%id = OpLoad %uint %id_ptr | ||
%ptr_out = OpAccessChain %ptr_uint %out %id | ||
OpStore %ptr_out %undef | ||
OpReturn | ||
OpFunctionEnd |