Skip to content

Commit 0264197

Browse files
svenvhsys-ce-bb
authored andcommitted
Remove more unused utility functions; NFC (#2294)
Original commit: KhronosGroup/SPIRV-LLVM-Translator@01d7586
1 parent 78bd996 commit 0264197

File tree

2 files changed

+0
-90
lines changed

2 files changed

+0
-90
lines changed

llvm-spirv/lib/SPIRV/SPIRVInternal.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -717,12 +717,6 @@ void makeVector(Instruction *InsPos, std::vector<Value *> &Ops,
717717
/// Get size_t type.
718718
IntegerType *getSizetType(Module *M);
719719

720-
/// Get void(void) function type.
721-
Type *getVoidFuncType(Module *M);
722-
723-
/// Get void(void) function pointer type.
724-
Type *getVoidFuncPtrType(Module *M, unsigned AddrSpace = 0);
725-
726720
/// Get a 64 bit integer constant.
727721
ConstantInt *getInt64(Module *M, int64_t Value);
728722

@@ -779,10 +773,6 @@ std::set<std::string> getNamedMDAsStringSet(Module *M,
779773
/// Get SPIR-V language by SPIR-V metadata spirv.Source
780774
std::tuple<unsigned, unsigned, std::string> getSPIRVSource(Module *M);
781775

782-
/// Get postfix for given decoration.
783-
/// The returned postfix does not include "_" at the beginning.
784-
std::string getPostfix(Decoration Dec, unsigned Value = 0);
785-
786776
/// Get postfix _R{ReturnType} for return type
787777
/// The returned postfix does not includ "_" at the beginning
788778
std::string getPostfixForReturnType(CallInst *CI, bool IsSigned = false);
@@ -813,10 +803,6 @@ std::string getSPIRVTypeName(StringRef BaseTyName, StringRef Postfixes = "");
813803
/// Checks if given type name is either ConstantSampler or ConsantPipeStorage.
814804
bool isSPIRVConstantName(StringRef TyName);
815805

816-
/// Get the sampled type name used in postfix of image type in SPIR-V
817-
/// friendly LLVM IR.
818-
std::string getSPIRVImageSampledTypeName(SPIRVType *Ty);
819-
820806
/// Get LLVM type for sampled type of SPIR-V image type by postfix.
821807
Type *getLLVMTypeForSPIRVImageSampledTypePostfix(StringRef Postfix,
822808
LLVMContext &Ctx);
@@ -848,8 +834,6 @@ bool eraseUselessFunctions(Module *M);
848834
/// Erase a function if it is declaration, has internal linkage and has no use.
849835
bool eraseIfNoUse(Function *F);
850836

851-
void eraseIfNoUse(Value *V);
852-
853837
// Check if a mangled type name is unsigned
854838
bool isMangledTypeUnsigned(char Mangled);
855839

@@ -1005,8 +989,6 @@ bool postProcessBuiltinsReturningStruct(Module *M, bool IsCpp = false);
1005989

1006990
bool postProcessBuiltinsWithArrayArguments(Module *M, bool IsCpp = false);
1007991

1008-
template <typename T>
1009-
MetadataAsValue *map2MDString(LLVMContext &C, SPIRVValue *V);
1010992
} // namespace SPIRV
1011993

1012994
#endif // SPIRV_SPIRVINTERNAL_H

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

Lines changed: 0 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,6 @@ SPIRVValue *addDecorations(SPIRVValue *Target,
373373
return Target;
374374
}
375375

376-
std::string getPostfix(Decoration Dec, unsigned Value) {
377-
switch (Dec) {
378-
default:
379-
llvm_unreachable("not implemented");
380-
return "unknown";
381-
case spv::DecorationSaturatedConversion:
382-
return kSPIRVPostfix::Sat;
383-
case spv::DecorationFPRoundingMode:
384-
return rmap<std::string>(static_cast<SPIRVFPRoundingModeKind>(Value));
385-
}
386-
}
387-
388376
std::string getPostfixForReturnType(CallInst *CI, bool IsSigned) {
389377
return getPostfixForReturnType(CI->getType(), IsSigned);
390378
}
@@ -1024,14 +1012,6 @@ IntegerType *getSizetType(Module *M) {
10241012
M->getDataLayout().getPointerSizeInBits(0));
10251013
}
10261014

1027-
Type *getVoidFuncType(Module *M) {
1028-
return FunctionType::get(Type::getVoidTy(M->getContext()), false);
1029-
}
1030-
1031-
Type *getVoidFuncPtrType(Module *M, unsigned AddrSpace) {
1032-
return PointerType::get(getVoidFuncType(M), AddrSpace);
1033-
}
1034-
10351015
ConstantInt *getInt64(Module *M, int64_t Value) {
10361016
return ConstantInt::getSigned(Type::getInt64Ty(M->getContext()), Value);
10371017
}
@@ -1505,35 +1485,6 @@ bool isSPIRVConstantName(StringRef TyName) {
15051485
return false;
15061486
}
15071487

1508-
std::string getSPIRVImageSampledTypeName(SPIRVType *Ty) {
1509-
switch (Ty->getOpCode()) {
1510-
case OpTypeVoid:
1511-
return kSPIRVImageSampledTypeName::Void;
1512-
case OpTypeInt:
1513-
if (Ty->getIntegerBitWidth() == 32) {
1514-
if (static_cast<SPIRVTypeInt *>(Ty)->isSigned())
1515-
return kSPIRVImageSampledTypeName::Int;
1516-
else
1517-
return kSPIRVImageSampledTypeName::UInt;
1518-
}
1519-
break;
1520-
case OpTypeFloat:
1521-
switch (Ty->getFloatBitWidth()) {
1522-
case 16:
1523-
return kSPIRVImageSampledTypeName::Half;
1524-
case 32:
1525-
return kSPIRVImageSampledTypeName::Float;
1526-
default:
1527-
break;
1528-
}
1529-
break;
1530-
default:
1531-
break;
1532-
}
1533-
llvm_unreachable("Invalid sampled type for image");
1534-
return std::string();
1535-
}
1536-
15371488
// ToDo: Find a way to represent uint sampled type in LLVM, maybe an
15381489
// opaque type.
15391490
Type *getLLVMTypeForSPIRVImageSampledTypePostfix(StringRef Postfix,
@@ -1649,20 +1600,6 @@ bool eraseIfNoUse(Function *F) {
16491600
return Changed;
16501601
}
16511602

1652-
void eraseIfNoUse(Value *V) {
1653-
if (!V->use_empty())
1654-
return;
1655-
if (Constant *C = dyn_cast<Constant>(V)) {
1656-
C->destroyConstant();
1657-
return;
1658-
}
1659-
if (Instruction *I = dyn_cast<Instruction>(V)) {
1660-
if (!I->mayHaveSideEffects())
1661-
I->eraseFromParent();
1662-
}
1663-
eraseIfNoUse(dyn_cast<Function>(V));
1664-
}
1665-
16661603
bool eraseUselessFunctions(Module *M) {
16671604
bool Changed = false;
16681605
for (auto I = M->begin(), E = M->end(); I != E;)
@@ -2540,13 +2477,4 @@ std::string getSPIRVFriendlyIRFunctionName(const std::string &UniqName,
25402477
return mangleBuiltin(UniqName, ArgTys, &MangleInfo);
25412478
}
25422479

2543-
template <typename T>
2544-
MetadataAsValue *map2MDString(LLVMContext &C, SPIRVValue *V) {
2545-
if (V->getOpCode() != OpConstant)
2546-
return nullptr;
2547-
uint64_t Const = static_cast<SPIRVConstant *>(V)->getZExtIntValue();
2548-
std::string Str = SPIRVMap<T, std::string>::map(static_cast<T>(Const));
2549-
return MetadataAsValue::get(C, MDString::get(C, Str));
2550-
}
2551-
25522480
} // namespace SPIRV

0 commit comments

Comments
 (0)