Skip to content

Commit 43da807

Browse files
jgu222igcbot
authored andcommitted
Changes in code.
1 parent 587c7e9 commit 43da807

File tree

2 files changed

+83
-3
lines changed

2 files changed

+83
-3
lines changed

IGC/Compiler/CISACodeGen/EmitVISAPass.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9081,7 +9081,7 @@ bool EmitPass::validateInlineAsmConstraints(llvm::CallInst *inst, SmallVector<St
90819081
} else if (str.getAsInteger(10, matchVal) == 0) {
90829082
// Also allows matching input reg to output reg
90839083
return true;
9084-
} else if (str.equals("i")) {
9084+
} else if (str.equals("i") || str.equals("P")) {
90859085
return cv && cv->IsImmediate();
90869086
} else if (str.equals("rw.u")) {
90879087
return cv && cv->IsUniform();
@@ -9205,7 +9205,7 @@ void EmitPass::EmitInlineAsm(llvm::CallInst *inst) {
92059205
}
92069206
// Special handling if LLVM replaces a variable with an immediate, we need
92079207
// to insert an extra move
9208-
else if (opVar->IsImmediate() && !constraint.equals("i")) {
9208+
else if (opVar->IsImmediate() && !constraint.equals("i") && !constraint.equals("P")) {
92099209
CVariable *tempMov = m_currShader->GetNewVariable(1, opVar->GetType(), EALIGN_GRF, true, opVar->getName());
92109210
m_encoder->Copy(tempMov, opVar);
92119211
m_encoder->Push();
@@ -9271,7 +9271,13 @@ void EmitPass::EmitInlineAsm(llvm::CallInst *inst) {
92719271
IGC_ASSERT_MESSAGE(0, "Invalid operand index");
92729272
return;
92739273
}
9274-
string varName = opnds[val] ? m_encoder->GetVariableName(opnds[val]) : "null";
9274+
string varName;
9275+
if (constraints[val].equals("P"))
9276+
varName = std::to_string(opnds[val]->GetImmediateValue());
9277+
else if (opnds[val])
9278+
varName = m_encoder->GetVariableName(opnds[val]);
9279+
else
9280+
varName = "null";
92759281
asmStr.replace(varPos, (idEnd - idStart + 1), varName);
92769282

92779283
startPos = varPos + varName.size();
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
;=========================== begin_copyright_notice ============================
2+
;
3+
; Copyright (C) 2023 Intel Corporation
4+
;
5+
; SPDX-License-Identifier: MIT
6+
;
7+
;============================ end_copyright_notice =============================
8+
9+
; To test inline as on constraint "P" : plain immediate
10+
11+
; REQUIRES: llvm-14-plus, regkeys
12+
13+
; RUN: igc_opt --opaque-pointers --CheckInstrTypes --igc-update-instrtypes-on-run -inputocl --neo \
14+
; RUN: -platformpvc -igc-emit-visa -regkey DumpVISAASMToConsole -simd-mode 16 %s \
15+
; RUN: | FileCheck %s
16+
17+
; CHECK-LABEL: .function
18+
; CHECK: dpas.bf.bf.8.2 (M1, 16)
19+
; CHECK: ret (M1, 1)
20+
21+
; Function Attrs: convergent nounwind null_pointer_is_valid
22+
define spir_kernel void @test(i32 addrspace(1)* align 4 %a, i32 addrspace(1)* align 4 %b, <8 x i32> %r0, <8 x i32> %payloadHeader,
23+
i16 %localIdX, i16 %localIdY, i16 %localIdZ ) {
24+
entry:
25+
%lid = zext i16 %localIdX to i64
26+
%base = ptrtoint i32 addrspace(1)* %a to i64
27+
%bbase = ptrtoint i32 addrspace(1)* %b to i64
28+
%tmp0 = add i64 %base, %lid
29+
%a_addr = inttoptr i64 %tmp0 to i16 addrspace(1)*
30+
%tmp1 = add i64 %bbase, %lid
31+
%b_addr = inttoptr i64 %tmp1 to i16 addrspace(1)*
32+
%ma = load i32, ptr addrspace(1) %a, align 4
33+
%mb = load i32, ptr addrspace(1) %b, align 4
34+
35+
%r = call i32 asm "dpas.bf.bf.8.$4 (M1, 16) $0.0 $1.0 $2.0 $3(0,0)" , "=rw,rw,rw,rw,P"(i32 0, i32 %ma, i32 %mb, i32 2)
36+
37+
%tmp3 = add i64 %tmp0, 1024
38+
%d_addr = inttoptr i64 %tmp3 to i32 addrspace(1)*
39+
store i32 %r, i32 addrspace(1)* %d_addr
40+
ret void
41+
}
42+
43+
44+
!igc.functions = !{!0}
45+
!IGCMetadata = !{!13}
46+
47+
!0 = !{void (i16 addrspace(1)*, i16 addrspace(1)*, <8 x i32>, <8 x i32>, i16, i16, i16)* @test, !1}
48+
!1 = !{!2, !3}
49+
!2 = !{!"function_type", i32 0}
50+
!3 = !{!"sub_group_size", i32 16}
51+
!13 = !{!"ModuleMD", !14}
52+
!14 = !{!"FuncMD", !15, !16}
53+
!15 = !{!"FuncMDMap[0]", void (i16 addrspace(1)*, i16 addrspace(1)*, <8 x i32>, <8 x i32>, i16, i16, i16)* @test}
54+
!16 = !{!"FuncMDValue[0]", !90, !100, !226}
55+
!90 = !{!"localOffsets"}
56+
!100 = !{!"resAllocMD", !183, !184, !185, !186}
57+
!183 = !{!"uavsNumType", i32 0}
58+
!184 = !{!"srvsNumType", i32 0}
59+
!185 = !{!"samplersNumType", i32 0}
60+
!186 = !{!"argAllocMDList", !187, !191, !192, !193, !194, !195, !196}
61+
!187 = !{!"argAllocMDListVec[0]", !188, !189, !190}
62+
!188 = !{!"type", i32 0}
63+
!189 = !{!"extensionType", i32 -1}
64+
!190 = !{!"indexType", i32 -1}
65+
!191 = !{!"argAllocMDListVec[1]", !188, !189, !190}
66+
!192 = !{!"argAllocMDListVec[2]", !188, !189, !190}
67+
!193 = !{!"argAllocMDListVec[3]", !188, !189, !190}
68+
!194 = !{!"argAllocMDListVec[4]", !188, !189, !190}
69+
!195 = !{!"argAllocMDListVec[5]", !188, !189, !190}
70+
!196 = !{!"argAllocMDListVec[6]", !188, !189, !190}
71+
!226 = !{!"m_OpenCLArgTypeQualifiers", !227, !228}
72+
!227 = !{!"m_OpenCLArgTypeQualifiersVec[0]", !""}
73+
!228 = !{!"m_OpenCLArgTypeQualifiersVec[1]", !""}
74+

0 commit comments

Comments
 (0)