Skip to content

Commit 8108b22

Browse files
jcranmer-inteldbudanov-cmplr
authored andcommitted
Cleanup code after all the mutator changes (#1625)
With this commit, the last call to Type::getPointerElementType in the translator is truly dead, completing the first phase of transitioning to opaque pointers. Original commit: KhronosGroup/SPIRV-LLVM-Translator@3938c74
1 parent e1041ff commit 8108b22

12 files changed

+9
-130
lines changed

llvm-spirv/lib/SPIRV/OCLUtil.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,25 +1306,6 @@ class OCLBuiltinFuncMangleInfo : public SPIRV::BuiltinFuncMangleInfo {
13061306
Function *F; // SPIRV decorated function
13071307
};
13081308

1309-
CallInst *mutateCallInstOCL(
1310-
Module *M, CallInst *CI,
1311-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
1312-
AttributeList *Attrs) {
1313-
OCLBuiltinFuncMangleInfo BtnInfo(CI->getCalledFunction());
1314-
return mutateCallInst(M, CI, ArgMutate, &BtnInfo, Attrs);
1315-
}
1316-
1317-
Instruction *mutateCallInstOCL(
1318-
Module *M, CallInst *CI,
1319-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
1320-
ArgMutate,
1321-
std::function<Instruction *(CallInst *)> RetMutate, AttributeList *Attrs,
1322-
bool TakeFuncName) {
1323-
OCLBuiltinFuncMangleInfo BtnInfo(CI->getCalledFunction());
1324-
return mutateCallInst(M, CI, ArgMutate, RetMutate, &BtnInfo, Attrs,
1325-
TakeFuncName);
1326-
}
1327-
13281309
std::unique_ptr<SPIRV::BuiltinFuncMangleInfo> makeMangler(Function &F) {
13291310
return std::make_unique<OCLBuiltinFuncMangleInfo>(&F);
13301311
}

llvm-spirv/lib/SPIRV/OCLUtil.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -487,20 +487,6 @@ inline OCLMemOrderKind mapSPIRVMemOrderToOCL(unsigned Sema) {
487487
return OCLMemOrderMap::rmap(extractSPIRVMemOrderSemantic(Sema));
488488
}
489489

490-
/// Mutate call instruction to call OpenCL builtin function.
491-
CallInst *mutateCallInstOCL(
492-
Module *M, CallInst *CI,
493-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
494-
AttributeList *Attrs = nullptr);
495-
496-
/// Mutate call instruction to call OpenCL builtin function.
497-
Instruction *mutateCallInstOCL(
498-
Module *M, CallInst *CI,
499-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
500-
ArgMutate,
501-
std::function<Instruction *(CallInst *)> RetMutate,
502-
AttributeList *Attrs = nullptr, bool TakeFuncName = false);
503-
504490
/// If the value is a special type initializer (something that bitcasts from
505491
/// spirv.ConstantSampler to spirv.Sampler or likewise for PipeStorage), get the
506492
/// original type initializer, unwrap the bitcast. Otherwise, return nullptr.

llvm-spirv/lib/SPIRV/SPIRVInternal.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -704,20 +704,6 @@ Instruction *mutateCallInst(
704704
BuiltinFuncMangleInfo *Mangle = nullptr, AttributeList *Attrs = nullptr,
705705
bool TakeName = false);
706706

707-
/// Mutate call instruction to call SPIR-V builtin function.
708-
CallInst *mutateCallInstSPIRV(
709-
Module *M, CallInst *CI,
710-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
711-
AttributeList *Attrs = nullptr);
712-
713-
/// Mutate call instruction to call SPIR-V builtin function.
714-
Instruction *mutateCallInstSPIRV(
715-
Module *M, CallInst *CI,
716-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
717-
ArgMutate,
718-
std::function<Instruction *(CallInst *)> RetMutate,
719-
AttributeList *Attrs = nullptr);
720-
721707
/// Mutate function by change the arguments.
722708
/// \param ArgMutate mutates the function arguments.
723709
/// \param TakeName Take the original function's name if a new function with
@@ -770,13 +756,6 @@ Value *addVector(Instruction *InsPos, ValueVecRange Range);
770756
void makeVector(Instruction *InsPos, std::vector<Value *> &Ops,
771757
ValueVecRange Range);
772758

773-
/// Expand a vector type value in \param Ops at index \param VecPos.
774-
/// Generate extract element instructions at \param InsPos and replace
775-
/// the vector type value with scalar type values.
776-
/// If the value to be expanded is not vector type, do nothing.
777-
void expandVector(Instruction *InsPos, std::vector<Value *> &Ops,
778-
size_t VecPos);
779-
780759
/// Get size_t type.
781760
IntegerType *getSizetType(Module *M);
782761

@@ -883,11 +862,6 @@ std::string getSPIRVTypeName(StringRef BaseTyName, StringRef Postfixes = "");
883862
/// Checks if given type name is either ConstantSampler or ConsantPipeStorage.
884863
bool isSPIRVConstantName(StringRef TyName);
885864

886-
/// Get SPIR-V type by changing the type name from spirv.OldName.Postfixes
887-
/// to spirv.NewName.Postfixes.
888-
Type *getSPIRVTypeByChangeBaseTypeName(Module *M, Type *T, StringRef OldName,
889-
StringRef NewName);
890-
891865
/// Get SPIR-V type by changing the type name from spirv.OldName.Postfixes
892866
/// to spirv.NewName.Postfixes.
893867
Type *getSPIRVStructTypeByChangeBaseTypeName(Module *M, Type *T,

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -920,26 +920,6 @@ void getParameterTypes(Function *F, SmallVectorImpl<TypedPointerType *> &ArgTys,
920920
}
921921
}
922922

923-
static Type *toTypedPointerType(Type *T) {
924-
if (!isa<PointerType>(T))
925-
return T;
926-
return TypedPointerType::get(
927-
toTypedPointerType(T->getNonOpaquePointerElementType()),
928-
T->getPointerAddressSpace());
929-
}
930-
931-
// This is a transitional helper function to fill in mangling information for
932-
// mangleBuiltin while all the calls to mutateCallInst are being transitioned.
933-
static void typeMangle(BuiltinFuncMangleInfo *Mangle, ArrayRef<Value *> Args) {
934-
if (!Mangle)
935-
return;
936-
for (unsigned I = 0; I < Args.size(); I++)
937-
if (Args[I]->getType()->isPointerTy()) {
938-
Mangle->getTypeMangleInfo(I).PointerTy =
939-
toTypedPointerType(Args[I]->getType());
940-
}
941-
}
942-
943923
CallInst *mutateCallInst(
944924
Module *M, CallInst *CI,
945925
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
@@ -953,7 +933,6 @@ CallInst *mutateCallInst(
953933
InstName = CI->getName().str();
954934
CI->setName(InstName + ".old");
955935
}
956-
typeMangle(Mangle, Args);
957936
auto NewCI = addCallInst(M, NewName, CI->getType(), Args, Attrs, CI, Mangle,
958937
InstName, TakeFuncName);
959938
NewCI->setDebugLoc(CI->getDebugLoc());
@@ -975,7 +954,6 @@ Instruction *mutateCallInst(
975954
Type *RetTy = CI->getType();
976955
auto NewName = ArgMutate(CI, Args, RetTy);
977956
StringRef InstName = CI->getName();
978-
typeMangle(Mangle, Args);
979957
auto NewCI = addCallInst(M, NewName, RetTy, Args, Attrs, CI, Mangle, InstName,
980958
TakeFuncName);
981959
auto NewI = RetMutate(NewCI);
@@ -1016,23 +994,6 @@ void mutateFunction(
1016994
F->eraseFromParent();
1017995
}
1018996

1019-
CallInst *mutateCallInstSPIRV(
1020-
Module *M, CallInst *CI,
1021-
std::function<std::string(CallInst *, std::vector<Value *> &)> ArgMutate,
1022-
AttributeList *Attrs) {
1023-
BuiltinFuncMangleInfo BtnInfo;
1024-
return mutateCallInst(M, CI, ArgMutate, &BtnInfo, Attrs);
1025-
}
1026-
1027-
Instruction *mutateCallInstSPIRV(
1028-
Module *M, CallInst *CI,
1029-
std::function<std::string(CallInst *, std::vector<Value *> &, Type *&RetTy)>
1030-
ArgMutate,
1031-
std::function<Instruction *(CallInst *)> RetMutate, AttributeList *Attrs) {
1032-
BuiltinFuncMangleInfo BtnInfo;
1033-
return mutateCallInst(M, CI, ArgMutate, RetMutate, &BtnInfo, Attrs);
1034-
}
1035-
1036997
CallInst *addCallInst(Module *M, StringRef FuncName, Type *RetTy,
1037998
ArrayRef<Value *> Args, AttributeList *Attrs,
1038999
Instruction *Pos, BuiltinFuncMangleInfo *Mangle,
@@ -1089,22 +1050,6 @@ void makeVector(Instruction *InsPos, std::vector<Value *> &Ops,
10891050
Ops.push_back(Vec);
10901051
}
10911052

1092-
void expandVector(Instruction *InsPos, std::vector<Value *> &Ops,
1093-
size_t VecPos) {
1094-
auto Vec = Ops[VecPos];
1095-
auto *VT = dyn_cast<FixedVectorType>(Vec->getType());
1096-
if (!VT)
1097-
return;
1098-
size_t N = VT->getNumElements();
1099-
IRBuilder<> Builder(InsPos);
1100-
for (size_t I = 0; I != N; ++I)
1101-
Ops.insert(Ops.begin() + VecPos + I,
1102-
Builder.CreateExtractElement(
1103-
Vec, ConstantInt::get(Type::getInt32Ty(InsPos->getContext()),
1104-
I, false)));
1105-
Ops.erase(Ops.begin() + VecPos + N);
1106-
}
1107-
11081053
Constant *castToInt8Ptr(Constant *V, unsigned Addr = 0) {
11091054
return ConstantExpr::getBitCast(V, Type::getInt8PtrTy(V->getContext(), Addr));
11101055
}
@@ -1588,13 +1533,6 @@ bool isSPIRVConstantName(StringRef TyName) {
15881533
return false;
15891534
}
15901535

1591-
Type *getSPIRVTypeByChangeBaseTypeName(Module *M, Type *T, StringRef OldName,
1592-
StringRef NewName) {
1593-
return PointerType::get(
1594-
getSPIRVStructTypeByChangeBaseTypeName(M, T, OldName, NewName),
1595-
SPIRAS_Global);
1596-
}
1597-
15981536
Type *getSPIRVStructTypeByChangeBaseTypeName(Module *M, Type *T,
15991537
StringRef OldName,
16001538
StringRef NewName) {

llvm-spirv/test/read_image.cl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir64 -fdeclare-opencl-builtins -finclude-default-header -O0 -cl-std=CL2.0 -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir64 -fdeclare-opencl-builtins -finclude-default-header -O0 -cl-std=CL2.0 -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv --spirv-max-version=1.3 %t.bc -o %t.spv
33
// RUN: spirv-val %t.spv
44
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
@@ -8,7 +8,7 @@
88
// RUN: spirv-val %t.rev.spv
99
// RUN: llvm-spirv --spirv-max-version=1.3 %t.rev.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
1010

11-
// CHECK-SPIRV: TypeInt [[IntTy:[0-9]+]]
11+
// CHECK-SPIRV: TypeInt [[IntTy:[0-9]+]] 32
1212
// CHECK-SPIRV: TypeVector [[IVecTy:[0-9]+]] [[IntTy]]
1313
// CHECK-SPIRV: TypeFloat [[FloatTy:[0-9]+]]
1414
// CHECK-SPIRV: TypeVector [[FVecTy:[0-9]+]] [[FloatTy]]

llvm-spirv/test/transcoding/AtomicCompareExchangeExplicit_cl20.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv %t.bc -spirv-text -o %t.txt
33
// RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
44
// RUN: llvm-spirv %t.bc -o %t.spv

llvm-spirv/test/transcoding/OpImageWrite.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -O1 -triple spir-unknown-unknown -cl-std=CL2.0 %s -finclude-default-header -emit-llvm-bc -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -O1 -triple spir-unknown-unknown -cl-std=CL2.0 %s -finclude-default-header -emit-llvm-bc -o %t.bc
22
// RUN: llvm-spirv %t.bc -spirv-text -o %t.txt
33
// RUN: FileCheck < %t.txt %s --check-prefix=CHECK-SPIRV
44
// RUN: llvm-spirv %t.bc -o %t.spv

llvm-spirv/test/transcoding/OpenCL/atomic_cmpxchg.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc
22
// RUN: llvm-spirv %t.bc -o %t.spv
33
// RUN: spirv-val %t.spv
44
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV

llvm-spirv/test/transcoding/OpenCL/atomic_legacy.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 %s -triple spir -cl-std=CL1.2 -emit-llvm-bc -fdeclare-opencl-builtins -o %t.bc
22
// RUN: llvm-spirv %t.bc -o %t.spv
33
// RUN: spirv-val %t.spv
44
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV

llvm-spirv/test/transcoding/SPV_INTEL_media_block_io.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv --spirv-ext=+SPV_INTEL_media_block_io %t.bc -o %t.spv
33
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
44
// RUN: spirv-val %t.spv

llvm-spirv/test/transcoding/atomic_explicit_arguments.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir -cl-std=cl2.0 %s -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir -cl-std=cl2.0 %s -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc -o %t.bc
22
// RUN: llvm-spirv %t.bc -o %t.spv
33
// RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
44
// RUN: llvm-spirv %t.spv -r --spirv-target-env=CL2.0 -o - | llvm-dis -o - | FileCheck %s --check-prefix=CHECK-LLVM

llvm-spirv/test/transcoding/atomic_flag.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc -no-opaque-pointers
1+
// RUN: %clang_cc1 -triple spir-unknown-unknown -O1 -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -emit-llvm-bc %s -o %t.bc
22
// RUN: llvm-spirv %t.bc -spirv-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
33
// RUN: llvm-spirv %t.bc -o %t.spv
44
// RUN: spirv-val %t.spv

0 commit comments

Comments
 (0)