From ae8d5acd42d52078894cdfc1a2d71988387b2e23 Mon Sep 17 00:00:00 2001 From: Yang Ni Date: Thu, 2 Mar 2017 17:22:10 -0800 Subject: Removed KernelSignature class Bug: 30964317 No longer used. Also made other minor cleanups: Moved an #include from a .h to .cpp file; And removed an unused unimplemented method. Test: lit tests Change-Id: I0cbf4bba42b90acecd466beb255d5593faaa186f --- rsov/compiler/Android.mk | 1 - rsov/compiler/KernelSignature.cpp | 86 ------------------------------------- rsov/compiler/KernelSignature.h | 63 --------------------------- rsov/compiler/RSAllocationUtils.cpp | 1 + rsov/compiler/RSAllocationUtils.h | 4 +- 5 files changed, 3 insertions(+), 152 deletions(-) delete mode 100644 rsov/compiler/KernelSignature.cpp delete mode 100644 rsov/compiler/KernelSignature.h (limited to 'rsov') diff --git a/rsov/compiler/Android.mk b/rsov/compiler/Android.mk index 0b03c45d..d78adfe5 100644 --- a/rsov/compiler/Android.mk +++ b/rsov/compiler/Android.mk @@ -29,7 +29,6 @@ RS2SPIRV_SOURCES := \ GlobalAllocSPIRITPass.cpp \ GlobalMergePass.cpp \ InlinePreparationPass.cpp \ - KernelSignature.cpp \ RemoveNonkernelsPass.cpp \ RSAllocationUtils.cpp \ RSSPIRVWriter.cpp \ diff --git a/rsov/compiler/KernelSignature.cpp b/rsov/compiler/KernelSignature.cpp deleted file mode 100644 index 6367ed4c..00000000 --- a/rsov/compiler/KernelSignature.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2017, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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. - */ - -#include "KernelSignature.h" - -#include "llvm/Support/Debug.h" -#include "llvm/Support/raw_ostream.h" - -using namespace llvm; - -namespace { -std::string TypeToString(const Type *Ty) { - assert(Ty); - if (Ty->isVoidTy()) - return "void"; - - if (auto *IT = dyn_cast(Ty)) { - if (IT->getBitWidth() == 32) - return "int"; - else if (IT->getBitWidth() == 8) - return "uchar"; - } - - if (Ty->isFloatTy()) - return "float"; - - if (auto *VT = dyn_cast(Ty)) { - auto *ET = VT->getElementType(); - if (auto *IT = dyn_cast(ET)) { - if (IT->getBitWidth() == 32) - return "int4"; - else if (IT->getBitWidth() == 8) - return "uchar4"; - } - if (ET->isFloatTy()) - return "float4"; - } - - std::string badNameString; - raw_string_ostream badNameStream(badNameString); - badNameStream << '['; - Ty->print(badNameStream); - badNameStream << ']'; - return badNameStream.str(); -} -} // namespace - -namespace rs2spirv { - -const std::string KernelSignature::wrapperPrefix = "%__rsov_"; - -KernelSignature::KernelSignature(const FunctionType *FT, - const std::string Fname, Coords CK) - : returnType(TypeToString(FT->getReturnType())), name(Fname), - coordsKind(CK) { - for (const auto *ArgT : FT->params()) { - argumentTypes.push_back(TypeToString(ArgT)); - } - // Drop special arguments - // TODO: handle all special argument cases. - argumentTypes.resize(argumentTypes.size()-size_t(CK)); -} - -void KernelSignature::dump() const { - dbgs() << returnType << ' ' << name << '(' << argumentTypes[0]; - const auto CoordsNum = size_t(coordsKind); - for (size_t i = 0; i != CoordsNum; ++i) - dbgs() << ", " << CoordsNames[i]; - - dbgs() << ")\n"; -} - -} // namespace rs2spirv diff --git a/rsov/compiler/KernelSignature.h b/rsov/compiler/KernelSignature.h deleted file mode 100644 index 32adcf5f..00000000 --- a/rsov/compiler/KernelSignature.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2016, The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * 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. - */ - -#ifndef RS_KERNEL_SIGNATURE_H -#define RS_KERNEL_SIGNATURE_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/IR/DerivedTypes.h" - -#include -#include - -namespace rs2spirv { - -static const llvm::StringRef CoordsNames[] = {"x", "y", "z"}; - -// Numeric value corresponds to the number of components. -enum class Coords : size_t { None = 0, X, XY, XYZ, Last = XYZ }; - -struct KernelSignature { - typedef std::vector ArgumentTypes; - std::string returnType; - std::string name; - ArgumentTypes argumentTypes; - Coords coordsKind; - - KernelSignature(const llvm::FunctionType *FT, const std::string Fname, - Coords CK); - - void dump() const; - - inline std::string getWrapperName(void) const { - return wrapperPrefix + "entry_" + name; - } - - inline std::string getTempName(const std::string suffix) const { - return wrapperPrefix + name + "_" + suffix; - } - - static bool isWrapper(const llvm::StringRef &id) { - return id.startswith(wrapperPrefix); - } - -private: - static const std::string wrapperPrefix; -}; - -} // namespace rs2spirv - -#endif diff --git a/rsov/compiler/RSAllocationUtils.cpp b/rsov/compiler/RSAllocationUtils.cpp index 2c6b8911..b9d016b4 100644 --- a/rsov/compiler/RSAllocationUtils.cpp +++ b/rsov/compiler/RSAllocationUtils.cpp @@ -16,6 +16,7 @@ #include "RSAllocationUtils.h" +#include "llvm/ADT/StringRef.h" #include "llvm/IR/Constants.h" #include "llvm/IR/GlobalVariable.h" #include "llvm/IR/Instructions.h" diff --git a/rsov/compiler/RSAllocationUtils.h b/rsov/compiler/RSAllocationUtils.h index 23884d19..a3c22d1c 100644 --- a/rsov/compiler/RSAllocationUtils.h +++ b/rsov/compiler/RSAllocationUtils.h @@ -19,7 +19,8 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallVector.h" -#include "llvm/ADT/StringRef.h" + +#include namespace llvm { class CallInst; @@ -46,7 +47,6 @@ struct RSAllocationCallInfo { }; bool isRSAllocation(const llvm::GlobalVariable &GV); -llvm::Optional getRSTypeName(const llvm::GlobalVariable &GV); bool getRSAllocationInfo(llvm::Module &M, llvm::SmallVectorImpl &Allocs); bool getRSAllocAccesses(llvm::SmallVectorImpl &Allocs, -- cgit v1.2.3