Reland "[assembler] Split out CPUFeatures into its own file"
This is a reland of 3ad101f5bf9b30bd4378e1643fd86cc4c61d3aa9
Original change's description:
> [assembler] Split out CPUFeatures into its own file
>
> This reduces the preprocessor expanded source size by 84,675 LoC:
>
> gen ( 20 files): 71,349 to 1,523,934 ( 21x)
> src ( 624 files): 367,410 to 53,253,894 ( 145x)
> test ( 392 files): 490,503 to 37,436,176 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,031 to 102,736,424 ( 87x)
>
> to
>
> gen ( 20 files): 71,349 to 1,523,794 ( 21x)
> src ( 624 files): 367,411 to 53,186,896 ( 145x)
> test ( 392 files): 490,504 to 37,418,639 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,033 to 102,651,749 ( 87x)
>
>
> Change-Id: Ia8a79092051a42815b65e86a0784297915368c9b
> Reviewed-on: https://chromium-review.googlesource.com/c/1291471
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58266}
TBR=marja@chromium.org,clemensh@chromium.org,ulan@chromium.org
Change-Id: I5b857666508b1c80dcadd0b470aada37dd49077e
Reviewed-on: https://chromium-review.googlesource.com/c/1379872
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58278}
2018-12-17 10:32:43 +00:00
|
|
|
// Copyright 2018 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef V8_CPU_FEATURES_H_
|
|
|
|
#define V8_CPU_FEATURES_H_
|
|
|
|
|
|
|
|
#include "src/globals.h"
|
|
|
|
|
|
|
|
namespace v8 {
|
|
|
|
|
|
|
|
namespace internal {
|
|
|
|
|
|
|
|
// CPU feature flags.
|
|
|
|
enum CpuFeature {
|
|
|
|
// x86
|
|
|
|
SSE4_1,
|
|
|
|
SSSE3,
|
|
|
|
SSE3,
|
|
|
|
SAHF,
|
|
|
|
AVX,
|
|
|
|
FMA3,
|
|
|
|
BMI1,
|
|
|
|
BMI2,
|
|
|
|
LZCNT,
|
|
|
|
POPCNT,
|
|
|
|
ATOM,
|
|
|
|
// ARM
|
|
|
|
// - Standard configurations. The baseline is ARMv6+VFPv2.
|
|
|
|
ARMv7, // ARMv7-A + VFPv3-D32 + NEON
|
|
|
|
ARMv7_SUDIV, // ARMv7-A + VFPv4-D32 + NEON + SUDIV
|
|
|
|
ARMv8, // ARMv8-A (+ all of the above)
|
|
|
|
// MIPS, MIPS64
|
|
|
|
FPU,
|
|
|
|
FP64FPU,
|
|
|
|
MIPSr1,
|
|
|
|
MIPSr2,
|
|
|
|
MIPSr6,
|
|
|
|
MIPS_SIMD, // MSA instructions
|
|
|
|
// PPC
|
|
|
|
FPR_GPR_MOV,
|
|
|
|
LWSYNC,
|
|
|
|
ISELECT,
|
|
|
|
VSX,
|
|
|
|
MODULO,
|
|
|
|
// S390
|
|
|
|
DISTINCT_OPS,
|
|
|
|
GENERAL_INSTR_EXT,
|
|
|
|
FLOATING_POINT_EXT,
|
|
|
|
VECTOR_FACILITY,
|
|
|
|
MISC_INSTR_EXT2,
|
|
|
|
|
|
|
|
NUMBER_OF_CPU_FEATURES,
|
|
|
|
|
|
|
|
// ARM feature aliases (based on the standard configurations above).
|
|
|
|
VFPv3 = ARMv7,
|
|
|
|
NEON = ARMv7,
|
|
|
|
VFP32DREGS = ARMv7,
|
|
|
|
SUDIV = ARMv7_SUDIV
|
|
|
|
};
|
|
|
|
|
|
|
|
// CpuFeatures keeps track of which features are supported by the target CPU.
|
|
|
|
// Supported features must be enabled by a CpuFeatureScope before use.
|
|
|
|
// Example:
|
|
|
|
// if (assembler->IsSupported(SSE3)) {
|
|
|
|
// CpuFeatureScope fscope(assembler, SSE3);
|
|
|
|
// // Generate code containing SSE3 instructions.
|
|
|
|
// } else {
|
|
|
|
// // Generate alternative code.
|
|
|
|
// }
|
2019-04-04 08:46:51 +00:00
|
|
|
class V8_EXPORT_PRIVATE CpuFeatures : public AllStatic {
|
Reland "[assembler] Split out CPUFeatures into its own file"
This is a reland of 3ad101f5bf9b30bd4378e1643fd86cc4c61d3aa9
Original change's description:
> [assembler] Split out CPUFeatures into its own file
>
> This reduces the preprocessor expanded source size by 84,675 LoC:
>
> gen ( 20 files): 71,349 to 1,523,934 ( 21x)
> src ( 624 files): 367,410 to 53,253,894 ( 145x)
> test ( 392 files): 490,503 to 37,436,176 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,031 to 102,736,424 ( 87x)
>
> to
>
> gen ( 20 files): 71,349 to 1,523,794 ( 21x)
> src ( 624 files): 367,411 to 53,186,896 ( 145x)
> test ( 392 files): 490,504 to 37,418,639 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,033 to 102,651,749 ( 87x)
>
>
> Change-Id: Ia8a79092051a42815b65e86a0784297915368c9b
> Reviewed-on: https://chromium-review.googlesource.com/c/1291471
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58266}
TBR=marja@chromium.org,clemensh@chromium.org,ulan@chromium.org
Change-Id: I5b857666508b1c80dcadd0b470aada37dd49077e
Reviewed-on: https://chromium-review.googlesource.com/c/1379872
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58278}
2018-12-17 10:32:43 +00:00
|
|
|
public:
|
|
|
|
static void Probe(bool cross_compile) {
|
|
|
|
STATIC_ASSERT(NUMBER_OF_CPU_FEATURES <= kBitsPerInt);
|
|
|
|
if (initialized_) return;
|
|
|
|
initialized_ = true;
|
|
|
|
ProbeImpl(cross_compile);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned SupportedFeatures() {
|
|
|
|
Probe(false);
|
|
|
|
return supported_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool IsSupported(CpuFeature f) {
|
|
|
|
return (supported_ & (1u << f)) != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool SupportsOptimizer();
|
|
|
|
|
|
|
|
static inline bool SupportsWasmSimd128();
|
|
|
|
|
|
|
|
static inline unsigned icache_line_size() {
|
|
|
|
DCHECK_NE(icache_line_size_, 0);
|
|
|
|
return icache_line_size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline unsigned dcache_line_size() {
|
|
|
|
DCHECK_NE(dcache_line_size_, 0);
|
|
|
|
return dcache_line_size_;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void PrintTarget();
|
|
|
|
static void PrintFeatures();
|
|
|
|
|
|
|
|
private:
|
2019-02-06 15:30:18 +00:00
|
|
|
friend void V8_EXPORT_PRIVATE FlushInstructionCache(void*, size_t);
|
Reland "[assembler] Split out CPUFeatures into its own file"
This is a reland of 3ad101f5bf9b30bd4378e1643fd86cc4c61d3aa9
Original change's description:
> [assembler] Split out CPUFeatures into its own file
>
> This reduces the preprocessor expanded source size by 84,675 LoC:
>
> gen ( 20 files): 71,349 to 1,523,934 ( 21x)
> src ( 624 files): 367,410 to 53,253,894 ( 145x)
> test ( 392 files): 490,503 to 37,436,176 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,031 to 102,736,424 ( 87x)
>
> to
>
> gen ( 20 files): 71,349 to 1,523,794 ( 21x)
> src ( 624 files): 367,411 to 53,186,896 ( 145x)
> test ( 392 files): 490,504 to 37,418,639 ( 76x)
> third_party ( 432 files): 239,085 to 9,547,902 ( 40x)
> total ( 1520 files): 1,183,033 to 102,651,749 ( 87x)
>
>
> Change-Id: Ia8a79092051a42815b65e86a0784297915368c9b
> Reviewed-on: https://chromium-review.googlesource.com/c/1291471
> Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
> Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
> Reviewed-by: Marja Hölttä <marja@chromium.org>
> Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#58266}
TBR=marja@chromium.org,clemensh@chromium.org,ulan@chromium.org
Change-Id: I5b857666508b1c80dcadd0b470aada37dd49077e
Reviewed-on: https://chromium-review.googlesource.com/c/1379872
Reviewed-by: Clemens Hammacher <clemensh@chromium.org>
Reviewed-by: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Sigurd Schneider <sigurds@chromium.org>
Commit-Queue: Sigurd Schneider <sigurds@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58278}
2018-12-17 10:32:43 +00:00
|
|
|
friend class ExternalReference;
|
|
|
|
// Flush instruction cache.
|
|
|
|
static void FlushICache(void* start, size_t size);
|
|
|
|
|
|
|
|
// Platform-dependent implementation.
|
|
|
|
static void ProbeImpl(bool cross_compile);
|
|
|
|
|
|
|
|
static unsigned supported_;
|
|
|
|
static unsigned icache_line_size_;
|
|
|
|
static unsigned dcache_line_size_;
|
|
|
|
static bool initialized_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CpuFeatures);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
} // namespace v8
|
|
|
|
#endif // V8_CPU_FEATURES_H_
|