Commit f272427b by Nicolas Capens Committed by Nicolas Capens

Eliminate dead host/target feature code for Subzero

Subzero requires specifying the target CPU features at construction, and doesn't use this legacy LLVM support code. It is conceivable that this code was putting build host specific information into static variables, thus not producing the same binary when built on different machines. Bug: chromium:937268 Bug: b/155971541 Change-Id: I8934c4abfebc3901ef50edfe86a0122b1b50e319 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46689Reviewed-by: 's avatarAntonio Maiorano <amaiorano@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 7d529ff6
...@@ -241,7 +241,6 @@ if (use_swiftshader_with_subzero) { ...@@ -241,7 +241,6 @@ if (use_swiftshader_with_subzero) {
"$subzero_llvm_dir/lib/Support/ErrorHandling.cpp", "$subzero_llvm_dir/lib/Support/ErrorHandling.cpp",
"$subzero_llvm_dir/lib/Support/FoldingSet.cpp", "$subzero_llvm_dir/lib/Support/FoldingSet.cpp",
"$subzero_llvm_dir/lib/Support/Hashing.cpp", "$subzero_llvm_dir/lib/Support/Hashing.cpp",
"$subzero_llvm_dir/lib/Support/Host.cpp",
"$subzero_llvm_dir/lib/Support/ManagedStatic.cpp", "$subzero_llvm_dir/lib/Support/ManagedStatic.cpp",
"$subzero_llvm_dir/lib/Support/MemoryBuffer.cpp", "$subzero_llvm_dir/lib/Support/MemoryBuffer.cpp",
"$subzero_llvm_dir/lib/Support/Mutex.cpp", "$subzero_llvm_dir/lib/Support/Mutex.cpp",
...@@ -257,10 +256,8 @@ if (use_swiftshader_with_subzero) { ...@@ -257,10 +256,8 @@ if (use_swiftshader_with_subzero) {
"$subzero_llvm_dir/lib/Support/StringMap.cpp", "$subzero_llvm_dir/lib/Support/StringMap.cpp",
"$subzero_llvm_dir/lib/Support/StringRef.cpp", "$subzero_llvm_dir/lib/Support/StringRef.cpp",
"$subzero_llvm_dir/lib/Support/StringSaver.cpp", "$subzero_llvm_dir/lib/Support/StringSaver.cpp",
"$subzero_llvm_dir/lib/Support/TargetParser.cpp",
"$subzero_llvm_dir/lib/Support/Threading.cpp", "$subzero_llvm_dir/lib/Support/Threading.cpp",
"$subzero_llvm_dir/lib/Support/Timer.cpp", "$subzero_llvm_dir/lib/Support/Timer.cpp",
"$subzero_llvm_dir/lib/Support/Triple.cpp",
"$subzero_llvm_dir/lib/Support/Twine.cpp", "$subzero_llvm_dir/lib/Support/Twine.cpp",
"$subzero_llvm_dir/lib/Support/circular_raw_ostream.cpp", "$subzero_llvm_dir/lib/Support/circular_raw_ostream.cpp",
"$subzero_llvm_dir/lib/Support/raw_os_ostream.cpp", "$subzero_llvm_dir/lib/Support/raw_os_ostream.cpp",
......
...@@ -49,7 +49,6 @@ cc_library_static { ...@@ -49,7 +49,6 @@ cc_library_static {
"lib/Support/ErrorHandling.cpp", "lib/Support/ErrorHandling.cpp",
"lib/Support/FoldingSet.cpp", "lib/Support/FoldingSet.cpp",
"lib/Support/Hashing.cpp", "lib/Support/Hashing.cpp",
"lib/Support/Host.cpp",
"lib/Support/ManagedStatic.cpp", "lib/Support/ManagedStatic.cpp",
"lib/Support/MemoryBuffer.cpp", "lib/Support/MemoryBuffer.cpp",
"lib/Support/Mutex.cpp", "lib/Support/Mutex.cpp",
...@@ -72,10 +71,8 @@ cc_library_static { ...@@ -72,10 +71,8 @@ cc_library_static {
"lib/Support/StringMap.cpp", "lib/Support/StringMap.cpp",
"lib/Support/StringRef.cpp", "lib/Support/StringRef.cpp",
"lib/Support/StringSaver.cpp", "lib/Support/StringSaver.cpp",
"lib/Support/TargetParser.cpp",
"lib/Support/Threading.cpp", "lib/Support/Threading.cpp",
"lib/Support/Timer.cpp", "lib/Support/Timer.cpp",
"lib/Support/Triple.cpp",
"lib/Support/Twine.cpp", "lib/Support/Twine.cpp",
], ],
......
...@@ -70,7 +70,6 @@ set(LLVM_SUBZERO_SRC_FILES ...@@ -70,7 +70,6 @@ set(LLVM_SUBZERO_SRC_FILES
"include/llvm/ADT/StringMap.h" "include/llvm/ADT/StringMap.h"
"include/llvm/ADT/StringRef.h" "include/llvm/ADT/StringRef.h"
"include/llvm/ADT/StringSwitch.h" "include/llvm/ADT/StringSwitch.h"
"include/llvm/ADT/Triple.h"
"include/llvm/ADT/Twine.h" "include/llvm/ADT/Twine.h"
"include/llvm/Demangle/Demangle.h" "include/llvm/Demangle/Demangle.h"
"include/llvm/IR/Argument.h" "include/llvm/IR/Argument.h"
...@@ -123,7 +122,6 @@ set(LLVM_SUBZERO_SRC_FILES ...@@ -123,7 +122,6 @@ set(LLVM_SUBZERO_SRC_FILES
"include/llvm/Support/FormatProviders.h" "include/llvm/Support/FormatProviders.h"
"include/llvm/Support/FormatVariadic.h" "include/llvm/Support/FormatVariadic.h"
"include/llvm/Support/FormatVariadicDetails.h" "include/llvm/Support/FormatVariadicDetails.h"
"include/llvm/Support/Host.h"
"include/llvm/Support/MachO.h" "include/llvm/Support/MachO.h"
"include/llvm/Support/ManagedStatic.h" "include/llvm/Support/ManagedStatic.h"
"include/llvm/Support/MathExtras.h" "include/llvm/Support/MathExtras.h"
...@@ -148,7 +146,6 @@ set(LLVM_SUBZERO_SRC_FILES ...@@ -148,7 +146,6 @@ set(LLVM_SUBZERO_SRC_FILES
"include/llvm/Support/StreamingMemoryObject.h" "include/llvm/Support/StreamingMemoryObject.h"
"include/llvm/Support/StringSaver.h" "include/llvm/Support/StringSaver.h"
"include/llvm/Support/SwapByteOrder.h" "include/llvm/Support/SwapByteOrder.h"
"include/llvm/Support/TargetParser.h"
"include/llvm/Support/thread.h" "include/llvm/Support/thread.h"
"include/llvm/Support/Threading.h" "include/llvm/Support/Threading.h"
"include/llvm/Support/Timer.h" "include/llvm/Support/Timer.h"
...@@ -171,7 +168,6 @@ set(LLVM_SUBZERO_SRC_FILES ...@@ -171,7 +168,6 @@ set(LLVM_SUBZERO_SRC_FILES
"lib/Support/ErrorHandling.cpp" "lib/Support/ErrorHandling.cpp"
"lib/Support/FoldingSet.cpp" "lib/Support/FoldingSet.cpp"
"lib/Support/Hashing.cpp" "lib/Support/Hashing.cpp"
"lib/Support/Host.cpp"
"lib/Support/ManagedStatic.cpp" "lib/Support/ManagedStatic.cpp"
"lib/Support/MemoryBuffer.cpp" "lib/Support/MemoryBuffer.cpp"
"lib/Support/Mutex.cpp" "lib/Support/Mutex.cpp"
...@@ -199,10 +195,8 @@ set(LLVM_SUBZERO_SRC_FILES ...@@ -199,10 +195,8 @@ set(LLVM_SUBZERO_SRC_FILES
"lib/Support/StringMap.cpp" "lib/Support/StringMap.cpp"
"lib/Support/StringRef.cpp" "lib/Support/StringRef.cpp"
"lib/Support/StringSaver.cpp" "lib/Support/StringSaver.cpp"
"lib/Support/TargetParser.cpp"
"lib/Support/Threading.cpp" "lib/Support/Threading.cpp"
"lib/Support/Timer.cpp" "lib/Support/Timer.cpp"
"lib/Support/Triple.cpp"
"lib/Support/Twine.cpp" "lib/Support/Twine.cpp"
"lib/Support/Unix/Unix.h" "lib/Support/Unix/Unix.h"
"lib/Support/Windows/WindowsSupport.h" "lib/Support/Windows/WindowsSupport.h"
......
...@@ -38,43 +38,6 @@ namespace sys { ...@@ -38,43 +38,6 @@ namespace sys {
#endif #endif
static const bool IsLittleEndianHost = !IsBigEndianHost; static const bool IsLittleEndianHost = !IsBigEndianHost;
/// getDefaultTargetTriple() - Return the default target triple the compiler
/// has been configured to produce code for.
///
/// The target triple is a string in the format of:
/// CPU_TYPE-VENDOR-OPERATING_SYSTEM
/// or
/// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM
std::string getDefaultTargetTriple();
/// getProcessTriple() - Return an appropriate target triple for generating
/// code to be loaded into the current process, e.g. when using the JIT.
std::string getProcessTriple();
/// getHostCPUName - Get the LLVM name for the host CPU. The particular format
/// of the name is target dependent, and suitable for passing as -mcpu to the
/// target which matches the host.
///
/// \return - The host CPU name, or empty if the CPU could not be determined.
StringRef getHostCPUName();
/// getHostCPUFeatures - Get the LLVM names for the host CPU features.
/// The particular format of the names are target dependent, and suitable for
/// passing as -mattr to the target which matches the host.
///
/// \param Features - A string mapping feature names to either
/// true (if enabled) or false (if disabled). This routine makes no guarantees
/// about exactly which features may appear in this map, except that they are
/// all valid LLVM feature names.
///
/// \return - True on success.
bool getHostCPUFeatures(StringMap<bool> &Features);
/// Get the number of physical cores (as opposed to logical cores returned
/// from thread::hardware_concurrency(), which includes hyperthreads).
/// Returns -1 if unknown for the current host system.
int getHostNumPhysicalCores();
} }
} }
......
//===-- TargetParser - Parser for target features ---------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements a target parser to recognise hardware features such as
// FPU/CPU/ARCH names as well as specific support such as HDIV, etc.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_TARGETPARSER_H
#define LLVM_SUPPORT_TARGETPARSER_H
// FIXME: vector is used because that's what clang uses for subtarget feature
// lists, but SmallVector would probably be better
#include <vector>
namespace llvm {
class StringRef;
// Target specific information into their own namespaces. These should be
// generated from TableGen because the information is already there, and there
// is where new information about targets will be added.
// FIXME: To TableGen this we need to make some table generated files available
// even if the back-end is not compiled with LLVM, plus we need to create a new
// back-end to TableGen to create these clean tables.
namespace ARM {
// FPU names.
enum FPUKind {
#define ARM_FPU(NAME, KIND, VERSION, NEON_SUPPORT, RESTRICTION) KIND,
#include "ARMTargetParser.def"
FK_LAST
};
// FPU Version
enum FPUVersion {
FV_NONE = 0,
FV_VFPV2,
FV_VFPV3,
FV_VFPV3_FP16,
FV_VFPV4,
FV_VFPV5
};
// An FPU name implies one of three levels of Neon support:
enum NeonSupportLevel {
NS_None = 0, ///< No Neon
NS_Neon, ///< Neon
NS_Crypto ///< Neon with Crypto
};
// An FPU name restricts the FPU in one of three ways:
enum FPURestriction {
FR_None = 0, ///< No restriction
FR_D16, ///< Only 16 D registers
FR_SP_D16 ///< Only single-precision instructions, with 16 D registers
};
// Arch names.
enum ArchKind {
#define ARM_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
#include "ARMTargetParser.def"
AK_LAST
};
// Arch extension modifiers for CPUs.
enum ArchExtKind : unsigned {
AEK_INVALID = 0x0,
AEK_NONE = 0x1,
AEK_CRC = 0x2,
AEK_CRYPTO = 0x4,
AEK_FP = 0x8,
AEK_HWDIV = 0x10,
AEK_HWDIVARM = 0x20,
AEK_MP = 0x40,
AEK_SIMD = 0x80,
AEK_SEC = 0x100,
AEK_VIRT = 0x200,
AEK_DSP = 0x400,
AEK_FP16 = 0x800,
AEK_RAS = 0x1000,
// Unsupported extensions.
AEK_OS = 0x8000000,
AEK_IWMMXT = 0x10000000,
AEK_IWMMXT2 = 0x20000000,
AEK_MAVERICK = 0x40000000,
AEK_XSCALE = 0x80000000,
};
// ISA kinds.
enum ISAKind { IK_INVALID = 0, IK_ARM, IK_THUMB, IK_AARCH64 };
// Endianness
// FIXME: BE8 vs. BE32?
enum EndianKind { EK_INVALID = 0, EK_LITTLE, EK_BIG };
// v6/v7/v8 Profile
enum ProfileKind { PK_INVALID = 0, PK_A, PK_R, PK_M };
StringRef getCanonicalArchName(StringRef Arch);
// Information by ID
StringRef getFPUName(unsigned FPUKind);
unsigned getFPUVersion(unsigned FPUKind);
unsigned getFPUNeonSupportLevel(unsigned FPUKind);
unsigned getFPURestriction(unsigned FPUKind);
// FIXME: These should be moved to TargetTuple once it exists
bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
bool getHWDivFeatures(unsigned HWDivKind, std::vector<StringRef> &Features);
bool getExtensionFeatures(unsigned Extensions,
std::vector<StringRef> &Features);
StringRef getArchName(unsigned ArchKind);
unsigned getArchAttr(unsigned ArchKind);
StringRef getCPUAttr(unsigned ArchKind);
StringRef getSubArch(unsigned ArchKind);
StringRef getArchExtName(unsigned ArchExtKind);
StringRef getArchExtFeature(StringRef ArchExt);
StringRef getHWDivName(unsigned HWDivKind);
// Information by Name
unsigned getDefaultFPU(StringRef CPU, unsigned ArchKind);
unsigned getDefaultExtensions(StringRef CPU, unsigned ArchKind);
StringRef getDefaultCPU(StringRef Arch);
// Parser
unsigned parseHWDiv(StringRef HWDiv);
unsigned parseFPU(StringRef FPU);
unsigned parseArch(StringRef Arch);
unsigned parseArchExt(StringRef ArchExt);
unsigned parseCPUArch(StringRef CPU);
unsigned parseArchISA(StringRef Arch);
unsigned parseArchEndian(StringRef Arch);
unsigned parseArchProfile(StringRef Arch);
unsigned parseArchVersion(StringRef Arch);
} // namespace ARM
// FIXME:This should be made into class design,to avoid dupplication.
namespace AArch64 {
// Arch names.
enum class ArchKind {
#define AARCH64_ARCH(NAME, ID, CPU_ATTR, SUB_ARCH, ARCH_ATTR, ARCH_FPU, ARCH_BASE_EXT) ID,
#include "AArch64TargetParser.def"
AK_LAST
};
// Arch extension modifiers for CPUs.
enum ArchExtKind : unsigned {
AEK_INVALID = 0x0,
AEK_NONE = 0x1,
AEK_CRC = 0x2,
AEK_CRYPTO = 0x4,
AEK_FP = 0x8,
AEK_SIMD = 0x10,
AEK_FP16 = 0x20,
AEK_PROFILE = 0x40,
AEK_RAS = 0x80,
AEK_LSE = 0x100
};
StringRef getCanonicalArchName(StringRef Arch);
// Information by ID
StringRef getFPUName(unsigned FPUKind);
unsigned getFPUVersion(unsigned FPUKind);
unsigned getFPUNeonSupportLevel(unsigned FPUKind);
unsigned getFPURestriction(unsigned FPUKind);
// FIXME: These should be moved to TargetTuple once it exists
bool getFPUFeatures(unsigned FPUKind, std::vector<StringRef> &Features);
bool getExtensionFeatures(unsigned Extensions,
std::vector<StringRef> &Features);
bool getArchFeatures(unsigned ArchKind, std::vector<StringRef> &Features);
StringRef getArchName(unsigned ArchKind);
unsigned getArchAttr(unsigned ArchKind);
StringRef getCPUAttr(unsigned ArchKind);
StringRef getSubArch(unsigned ArchKind);
StringRef getArchExtName(unsigned ArchExtKind);
StringRef getArchExtFeature(StringRef ArchExt);
unsigned checkArchVersion(StringRef Arch);
// Information by Name
unsigned getDefaultFPU(StringRef CPU, unsigned ArchKind);
unsigned getDefaultExtensions(StringRef CPU, unsigned ArchKind);
StringRef getDefaultCPU(StringRef Arch);
// Parser
unsigned parseFPU(StringRef FPU);
unsigned parseArch(StringRef Arch);
unsigned parseArchExt(StringRef ArchExt);
unsigned parseCPUArch(StringRef CPU);
unsigned parseArchISA(StringRef Arch);
unsigned parseArchEndian(StringRef Arch);
unsigned parseArchProfile(StringRef Arch);
unsigned parseArchVersion(StringRef Arch);
} // namespace AArch64
} // namespace llvm
#endif
...@@ -2053,69 +2053,6 @@ static void (*OverrideVersionPrinter)() = nullptr; ...@@ -2053,69 +2053,6 @@ static void (*OverrideVersionPrinter)() = nullptr;
static std::vector<void (*)()> *ExtraVersionPrinters = nullptr; static std::vector<void (*)()> *ExtraVersionPrinters = nullptr;
namespace {
class VersionPrinter {
public:
void print() {
raw_ostream &OS = outs();
#ifdef PACKAGE_VENDOR
OS << PACKAGE_VENDOR << " ";
#else
OS << "LLVM (http://llvm.org/):\n ";
#endif
OS << PACKAGE_NAME << " version " << PACKAGE_VERSION;
#ifdef LLVM_VERSION_INFO
OS << " " << LLVM_VERSION_INFO;
#endif
OS << "\n ";
#ifndef __OPTIMIZE__
OS << "DEBUG build";
#else
OS << "Optimized build";
#endif
#ifndef NDEBUG
OS << " with assertions";
#endif
std::string CPU = sys::getHostCPUName();
if (CPU == "generic")
CPU = "(unknown)";
OS << ".\n"
<< " Default target: " << sys::getDefaultTargetTriple() << '\n'
<< " Host CPU: " << CPU << '\n';
}
void operator=(bool OptionWasSpecified) {
if (!OptionWasSpecified)
return;
if (OverrideVersionPrinter != nullptr) {
(*OverrideVersionPrinter)();
exit(0);
}
print();
// Iterate over any registered extra printers and call them to add further
// information.
if (ExtraVersionPrinters != nullptr) {
outs() << '\n';
for (std::vector<void (*)()>::iterator I = ExtraVersionPrinters->begin(),
E = ExtraVersionPrinters->end();
I != E; ++I)
(*I)();
}
exit(0);
}
};
} // End anonymous namespace
// Define the --version option that prints out the LLVM version for the tool
static VersionPrinter VersionPrinterInstance;
static cl::opt<VersionPrinter, true, parser<bool>>
VersOp("version", cl::desc("Display the version of this program"),
cl::location(VersionPrinterInstance), cl::ValueDisallowed,
cl::cat(GenericCategory));
// Utility function for printing the help message. // Utility function for printing the help message.
void cl::PrintHelpMessage(bool Hidden, bool Categorized) { void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
// This looks weird, but it actually prints the help message. The Printers are // This looks weird, but it actually prints the help message. The Printers are
...@@ -2135,9 +2072,6 @@ void cl::PrintHelpMessage(bool Hidden, bool Categorized) { ...@@ -2135,9 +2072,6 @@ void cl::PrintHelpMessage(bool Hidden, bool Categorized) {
CategorizedHiddenPrinter = true; CategorizedHiddenPrinter = true;
} }
/// Utility function for printing version number.
void cl::PrintVersionMessage() { VersionPrinterInstance.print(); }
void cl::SetVersionPrinter(void (*func)()) { OverrideVersionPrinter = func; } void cl::SetVersionPrinter(void (*func)()) { OverrideVersionPrinter = func; }
void cl::AddExtraVersionPrinter(void (*func)()) { void cl::AddExtraVersionPrinter(void (*func)()) {
......
...@@ -117,13 +117,3 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData, ...@@ -117,13 +117,3 @@ void llvm::llvm_execute_on_thread(void (*Fn)(void*), void *UserData,
} }
#endif #endif
unsigned llvm::heavyweight_hardware_concurrency() {
#if !LLVM_ENABLE_THREADS
return 1;
#endif
int NumPhysical = sys::getHostNumPhysicalCores();
if (NumPhysical == -1)
return thread::hardware_concurrency();
return NumPhysical;
}
//===- llvm/Support/Unix/Host.inc -------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the UNIX Host support.
//
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
//=== WARNING: Implementation here must contain only generic UNIX code that
//=== is guaranteed to work on *all* UNIX variants.
//===----------------------------------------------------------------------===//
#include "Unix.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Config/config.h"
#include <cctype>
#include <string>
#include <sys/utsname.h>
using namespace llvm;
static std::string getOSVersion() {
struct utsname info;
if (uname(&info))
return "";
return info.release;
}
std::string sys::getDefaultTargetTriple() {
std::string TargetTripleString(LLVM_DEFAULT_TARGET_TRIPLE);
// On darwin, we want to update the version to match that of the
// target.
std::string::size_type DarwinDashIdx = TargetTripleString.find("-darwin");
if (DarwinDashIdx != std::string::npos) {
TargetTripleString.resize(DarwinDashIdx + strlen("-darwin"));
TargetTripleString += getOSVersion();
}
return Triple::normalize(TargetTripleString);
}
//===- llvm/Support/Win32/Host.inc ------------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements the Win32 Host support.
//
//===----------------------------------------------------------------------===//
#include "WindowsSupport.h"
#include <cstdio>
#include <string>
using namespace llvm;
std::string sys::getDefaultTargetTriple() {
return Triple::normalize(LLVM_DEFAULT_TARGET_TRIPLE);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment