s390: use /proc/cpuinfo to check vx availability

R=joransiu@ca.ibm.com, bjaideep@ca.ibm.com

Bug: 
Change-Id: I73c44a0dd93e3925dbe895a477175d255edbed56
Reviewed-on: https://chromium-review.googlesource.com/514123
Reviewed-by: Joran Siu <joransiu@ca.ibm.com>
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#45532}
This commit is contained in:
Junliang Yan 2017-05-25 12:46:08 -04:00 committed by Commit Bot
parent 601f1fdf8d
commit 0c6c3974fe

View File

@ -35,6 +35,9 @@
// Copyright 2014 the V8 project authors. All rights reserved.
#include "src/s390/assembler-s390.h"
#include <sys/auxv.h>
#include <set>
#include <string>
#if V8_TARGET_ARCH_S390
@ -57,6 +60,43 @@ static unsigned CpuFeaturesImpliedByCompiler() {
return answer;
}
static bool supportsCPUFeature(const char* feature) {
static std::set<std::string> features;
static std::set<std::string> all_available_features = {
"iesan3", "zarch", "stfle", "msa", "ldisp", "eimm",
"dfp", "etf3eh", "highgprs", "te", "vx"};
if (features.empty()) {
#if V8_HOST_ARCH_S390
#ifndef HWCAP_S390_VX
#define HWCAP_S390_VX 2048
#endif
#define CHECK_AVAILABILITY_FOR(mask, value) \
if (f & mask) features.insert(value);
// initialize feature vector
uint64_t f = getauxval(AT_HWCAP);
CHECK_AVAILABILITY_FOR(HWCAP_S390_ESAN3, "iesan3")
CHECK_AVAILABILITY_FOR(HWCAP_S390_ZARCH, "zarch")
CHECK_AVAILABILITY_FOR(HWCAP_S390_STFLE, "stfle")
CHECK_AVAILABILITY_FOR(HWCAP_S390_MSA, "msa")
CHECK_AVAILABILITY_FOR(HWCAP_S390_LDISP, "ldisp")
CHECK_AVAILABILITY_FOR(HWCAP_S390_EIMM, "eimm")
CHECK_AVAILABILITY_FOR(HWCAP_S390_DFP, "dfp")
CHECK_AVAILABILITY_FOR(HWCAP_S390_ETF3EH, "etf3eh")
CHECK_AVAILABILITY_FOR(HWCAP_S390_HIGH_GPRS, "highgprs")
CHECK_AVAILABILITY_FOR(HWCAP_S390_TE, "te")
CHECK_AVAILABILITY_FOR(HWCAP_S390_VX, "vx")
#else
// import all features
features.insert(all_available_features.begin(),
all_available_features.end());
#endif
}
USE(all_available_features);
return features.find(feature) != features.end();
}
// Check whether Store Facility STFLE instruction is available on the platform.
// Instruction returns a bit vector of the enabled hardware facilities.
static bool supportsSTFLE() {
@ -106,8 +146,8 @@ static bool supportsSTFLE() {
// HWCAP_S390_STFLE is defined to be 4 in include/asm/elf.h. Currently
// hardcoded in case that include file does not exist.
const uint32_t HWCAP_S390_STFLE = 4;
return (auxv_hwcap & HWCAP_S390_STFLE);
const uint32_t _HWCAP_S390_STFLE = 4;
return (auxv_hwcap & _HWCAP_S390_STFLE);
#else
// STFLE is not available on non-s390 hosts
return false;
@ -163,7 +203,8 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
supported_ |= (1u << FLOATING_POINT_EXT);
}
// Test for Vector Facility - Bit 129
if (facilities[2] & (one << (63 - (129 - 128)))) {
if (facilities[2] & (one << (63 - (129 - 128))) &&
supportsCPUFeature("vx")) {
supported_ |= (1u << VECTOR_FACILITY);
}
// Test for Miscellaneous Instruction Extension Facility - Bit 58
@ -179,6 +220,7 @@ void CpuFeatures::ProbeImpl(bool cross_compile) {
supported_ |= (1u << FLOATING_POINT_EXT);
supported_ |= (1u << MISC_INSTR_EXT2);
USE(performSTFLE); // To avoid assert
USE(supportsCPUFeature);
supported_ |= (1u << VECTOR_FACILITY);
#endif
supported_ |= (1u << FPU);