Skip to content

Commit cd9e053

Browse files
AlexeySachkovvmaksimo
authored andcommitted
Refactor transOCLBuiltinFromExtInst
Removed extra variables, simplified code, removed dead code related to "read_image" handling: it is not present in OpenCL.std extended instruction set and therefore we can't encounter it in `transOCLBuiltinFromExtInst` function.
1 parent e88dcfc commit cd9e053

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

llvm-spirv/lib/SPIRV/SPIRVReader.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4090,18 +4090,14 @@ Instruction *SPIRVToLLVM::transOCLBuiltinFromExtInst(SPIRVExtInst *BC,
40904090
assert(BB && "Invalid BB");
40914091
std::string MangledName;
40924092
SPIRVWord EntryPoint = BC->getExtOp();
4093-
bool IsVarArg = false;
4094-
bool IsPrintf = false;
40954093
std::string UnmangledName;
4096-
auto BArgs = BC->getArguments();
4094+
std::vector<SPIRVWord> BArgs = BC->getArguments();
40974095

40984096
assert(BM->getBuiltinSet(BC->getExtSetId()) == SPIRVEIS_OpenCL &&
40994097
"Not OpenCL extended instruction");
4100-
if (EntryPoint == OpenCLLIB::Printf)
4101-
IsPrintf = true;
4102-
else {
4103-
UnmangledName = OCLExtOpMap::map(static_cast<OCLExtOpKind>(EntryPoint));
4104-
}
4098+
4099+
bool IsPrintf = (EntryPoint == OpenCLLIB::Printf);
4100+
UnmangledName = OCLExtOpMap::map(static_cast<OCLExtOpKind>(EntryPoint));
41054101

41064102
SPIRVDBG(spvdbgs() << "[transOCLBuiltinFromExtInst] OrigUnmangledName: "
41074103
<< UnmangledName << '\n');
@@ -4111,21 +4107,16 @@ Instruction *SPIRVToLLVM::transOCLBuiltinFromExtInst(SPIRVExtInst *BC,
41114107

41124108
if (IsPrintf) {
41134109
MangledName = "printf";
4114-
IsVarArg = true;
41154110
ArgTypes.resize(1);
4116-
} else if (UnmangledName.find("read_image") == 0) {
4117-
auto ModifiedArgTypes = ArgTypes;
4118-
ModifiedArgTypes[1] = getOrCreateOpaquePtrType(M, "opencl.sampler_t");
4119-
mangleOpenClBuiltin(UnmangledName, ModifiedArgTypes, MangledName);
41204111
} else {
41214112
mangleOpenClBuiltin(UnmangledName, ArgTypes, MangledName);
41224113
}
41234114
SPIRVDBG(spvdbgs() << "[transOCLBuiltinFromExtInst] ModifiedUnmangledName: "
41244115
<< UnmangledName << " MangledName: " << MangledName
41254116
<< '\n');
41264117

4127-
FunctionType *FT =
4128-
FunctionType::get(transType(BC->getType()), ArgTypes, IsVarArg);
4118+
FunctionType *FT = FunctionType::get(transType(BC->getType()), ArgTypes,
4119+
/* IsVarArg */ IsPrintf);
41294120
Function *F = M->getFunction(MangledName);
41304121
if (!F) {
41314122
F = Function::Create(FT, GlobalValue::ExternalLinkage, MangledName, M);

0 commit comments

Comments
 (0)