-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #214 from frasercrmck/spirv-ll-more-names
[spirv-ll] Attach names to values more often
- Loading branch information
Showing
15 changed files
with
190 additions
and
42 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// Copyright (C) Codeplay Software Limited | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License") with LLVM | ||
// Exceptions; you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
// License for the specific language governing permissions and limitations | ||
// under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
// RUN: %if online-glsl %{ glslangValidator -s -V -o %spv_file_s %s %} | ||
// RUN: %if online-glsl %{ spirv-val %spv_file_s %} | ||
// RUN: spirv-ll-tool -a Vulkan %spv_file_s | FileCheck %s | ||
|
||
#version 450 | ||
|
||
// Check that we don't pick up either of these functions called printf as "the" | ||
// printf, and give it the signature of printf (e.g., variadic). | ||
|
||
// CHECK: define private spir_func void @"printf("() {{(#0 )?}}{ | ||
void printf() { | ||
return; | ||
} | ||
|
||
// CHECK: define private spir_func void @"printf(u1;"(ptr %id) {{(#0 )?}}{ | ||
void printf(uint id) { | ||
return; | ||
} | ||
|
||
void main() { | ||
printf(); | ||
printf(0); | ||
} |
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
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
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
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
106 changes: 106 additions & 0 deletions
106
modules/compiler/spirv-ll/test/spvasm/op_phi_forward_ref.spvasm
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,106 @@ | ||
; Copyright (C) Codeplay Software Limited | ||
; | ||
; Licensed under the Apache License, Version 2.0 (the "License") with LLVM | ||
; Exceptions; you may not use this file except in compliance with the License. | ||
; You may obtain a copy of the License at | ||
; | ||
; https://github.com/codeplaysoftware/oneapi-construction-kit/blob/main/LICENSE.txt | ||
; | ||
; Unless required by applicable law or agreed to in writing, software | ||
; distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
; WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
; License for the specific language governing permissions and limitations | ||
; under the License. | ||
; | ||
; SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
||
; RUN: %if online-spirv-as %{ spirv-as --target-env %spv_tgt_env -o %spv_file_s %s %} | ||
; RUN: %if online-spirv-as %{ spirv-val %spv_file_s %} | ||
; RUN: spirv-ll-tool -a OpenCL -b 64 %spv_file_s | FileCheck %s | ||
|
||
OpCapability Addresses | ||
OpCapability Kernel | ||
OpCapability Int8 | ||
OpMemoryModel Physical64 OpenCL | ||
OpEntryPoint Kernel %testfn "testfn" | ||
|
||
OpName %entry "entry" | ||
OpName %for_cond "for.cond" | ||
OpName %for_body "for.body" | ||
OpName %exit_label "exit" | ||
|
||
OpName %input "input" | ||
OpName %output "output" | ||
OpName %add "add0" | ||
OpName %and26 "and26" | ||
OpName %shl10 "mask_next" | ||
OpName %mul1 "mul1" | ||
OpName %res "res" | ||
OpName %mask "mask" | ||
OpName %cmp0 "cmp0" | ||
OpName %cmp1 "cmp1" | ||
OpName %frombool "sel" | ||
OpName %52 "load" | ||
|
||
OpDecorate %output Alignment 1 | ||
%uint = OpTypeInt 32 0 | ||
%uchar = OpTypeInt 8 0 | ||
%uint_0 = OpConstant %uint 0 | ||
%uint_1 = OpConstant %uint 1 | ||
%uchar_0 = OpConstant %uchar 0 | ||
%uchar_1 = OpConstant %uchar 1 | ||
%void = OpTypeVoid | ||
%bool = OpTypeBool | ||
%ptr_uchar = OpTypePointer CrossWorkgroup %uchar | ||
%ptr_uint = OpTypePointer CrossWorkgroup %uint | ||
%fn_ty = OpTypeFunction %void %ptr_uchar %ptr_uint | ||
%true = OpConstantTrue %bool | ||
|
||
; CHECK: define spir_kernel void @testfn(ptr addrspace(1) %output, ptr addrspace(1) %input) | ||
%testfn = OpFunction %void None %fn_ty | ||
%output = OpFunctionParameter %ptr_uchar | ||
%input = OpFunctionParameter %ptr_uint | ||
|
||
; CHECK-LABEL: entry: | ||
; CHECK: %load = load i32, ptr addrspace(1) %input, align 4 | ||
; CHECK: %add0 = add i32 %load, 1 | ||
; CHECK: br label %for.cond | ||
%entry = OpLabel | ||
%52 = OpLoad %uint %input Aligned 4 | ||
%add = OpIAdd %uint %52 %uint_1 | ||
OpBranch %for_cond | ||
|
||
; CHECK-LABEL: for.cond: | ||
; CHECK: %res = phi i1 [ true, %entry ], [ %and26, %for.body ] | ||
; CHECK: %mask = phi i32 [ 1, %entry ], [ %mask_next, %for.body ] | ||
; CHECK: %cmp0 = icmp eq i32 %mask, 0 | ||
; CHECK: br i1 %cmp0, label %exit, label %for.body | ||
%for_cond = OpLabel | ||
%res = OpPhi %bool %true %entry %and26 %for_body | ||
%mask = OpPhi %uint %uint_1 %entry %shl10 %for_body | ||
%cmp0 = OpIEqual %bool %mask %uint_0 | ||
OpBranchConditional %cmp0 %exit_label %for_body | ||
|
||
; CHECK-LABEL: for.body: | ||
; CHECK: %mul1 = mul i32 %add0, %mask | ||
; CHECK: %cmp1 = icmp eq i32 %mul1, %add0 | ||
; CHECK: %and26 = and i1 %res, %cmp1 | ||
; CHECK: %mask_next = shl i32 %mask, 1 | ||
; CHECK: br label %for.cond | ||
%for_body = OpLabel | ||
%mul1 = OpIMul %uint %add %mask | ||
%cmp1 = OpIEqual %bool %mul1 %add | ||
%and26 = OpLogicalAnd %bool %res %cmp1 | ||
%shl10 = OpShiftLeftLogical %uint %mask %uint_1 | ||
OpBranch %for_cond | ||
|
||
; CHECK-LABEL: exit: | ||
; CHECK: %sel = select i1 %res, i8 1, i8 0 | ||
; CHECK: store i8 %sel, ptr addrspace(1) %output, align 1 | ||
; CHECK: ret void | ||
%exit_label = OpLabel | ||
%frombool = OpSelect %uchar %res %uchar_1 %uchar_0 | ||
OpStore %output %frombool Aligned 1 | ||
OpReturn | ||
|
||
OpFunctionEnd |
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