mirror of
https://github.com/RPCS3/llvm.git
synced 2025-04-13 19:40:26 +00:00
WebAssembly: start instructions
Summary: * Add 64-bit address space feature. * Rename SIMD feature to SIMD128. * Handle single-thread model with an IR pass (same way ARM does). * Rename generic processor to MVP, to follow design's lead. * Add bleeding-edge processors, with all features included. * Fix a few DEBUG_TYPE to match other backends. Test Plan: ninja check Reviewers: sunfish Subscribers: jfb, llvm-commits Differential Revision: http://reviews.llvm.org/D10880 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a1a323c637
commit
1ff585db47
@ -22,8 +22,8 @@ include "llvm/Target/Target.td"
|
|||||||
// WebAssembly Subtarget features.
|
// WebAssembly Subtarget features.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
def FeatureSIMD : SubtargetFeature<"simd", "HasSIMD", "true",
|
def FeatureSIMD128 : SubtargetFeature<"simd128", "HasSIMD128", "false",
|
||||||
"Enable SIMD">;
|
"Enable 128-bit SIMD">;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Architectures.
|
// Architectures.
|
||||||
@ -47,7 +47,11 @@ def WebAssemblyInstrInfo : InstrInfo;
|
|||||||
// WebAssembly Processors supported.
|
// WebAssembly Processors supported.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
def : ProcessorModel<"generic", NoSchedModel, [FeatureSIMD]>;
|
// Minimal Viable Product.
|
||||||
|
def : ProcessorModel<"mvp", NoSchedModel, []>;
|
||||||
|
|
||||||
|
// Latest and greatest experimental version of WebAssembly. Bugs included!
|
||||||
|
def : ProcessorModel<"bleeding-edge", NoSchedModel, [FeatureSIMD128]>;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Target Declaration
|
// Target Declaration
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#define DEBUG_TYPE "frame-info"
|
#define DEBUG_TYPE "wasm-frame-info"
|
||||||
|
|
||||||
// TODO: Implement a red zone?
|
// TODO: Implement a red zone?
|
||||||
|
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
//
|
//
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
// TODO: Implement atomic instructions.
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// Atomic fences
|
// Atomic fences
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -15,6 +15,11 @@
|
|||||||
// WebAssembly Instruction Predicate Definitions.
|
// WebAssembly Instruction Predicate Definitions.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
def HasAddr32 : Predicate<"!Subtarget->hasAddr64()">;
|
||||||
|
def HasAddr64 : Predicate<"Subtarget->hasAddr64()">;
|
||||||
|
def HasSIMD128 : Predicate<"Subtarget->hasSIMD128()">,
|
||||||
|
AssemblerPredicate<"FeatureSIMD128", "simd128">;
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
// WebAssembly-specific DAG Node Types.
|
// WebAssembly-specific DAG Node Types.
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
@ -12,4 +12,4 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
// TODO: Implement SIMD instructions.
|
// TODO: Implement SIMD instructions.
|
||||||
// Note: use Requires<[HasSIMD]>.
|
// Note: use Requires<[HasSIMD128]>.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#define DEBUG_TYPE "subtarget"
|
#define DEBUG_TYPE "wasm-subtarget"
|
||||||
|
|
||||||
#define GET_SUBTARGETINFO_CTOR
|
#define GET_SUBTARGETINFO_CTOR
|
||||||
#define GET_SUBTARGETINFO_TARGET_DESC
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
||||||
@ -40,8 +40,8 @@ WebAssemblySubtarget::WebAssemblySubtarget(const Triple &TT,
|
|||||||
const std::string &CPU,
|
const std::string &CPU,
|
||||||
const std::string &FS,
|
const std::string &FS,
|
||||||
const TargetMachine &TM)
|
const TargetMachine &TM)
|
||||||
: WebAssemblyGenSubtargetInfo(TT, CPU, FS), HasSIMD(true), CPUString(CPU),
|
: WebAssemblyGenSubtargetInfo(TT, CPU, FS), HasSIMD128(false),
|
||||||
TargetTriple(TT), FrameLowering(),
|
CPUString(CPU), TargetTriple(TT), FrameLowering(),
|
||||||
InstrInfo(initializeSubtargetDependencies(FS)),
|
InstrInfo(initializeSubtargetDependencies(FS)),
|
||||||
TSInfo(TM.getDataLayout()), TLInfo(TM, *this) {}
|
TSInfo(TM.getDataLayout()), TLInfo(TM, *this) {}
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
|
class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
|
||||||
bool HasSIMD;
|
bool HasSIMD128;
|
||||||
|
|
||||||
/// String name of used CPU.
|
/// String name of used CPU.
|
||||||
std::string CPUString;
|
std::string CPUString;
|
||||||
@ -66,7 +66,8 @@ public:
|
|||||||
bool useAA() const override { return true; }
|
bool useAA() const override { return true; }
|
||||||
|
|
||||||
// Predicates used by WebAssemblyInstrInfo.td.
|
// Predicates used by WebAssemblyInstrInfo.td.
|
||||||
bool hasSIMD() const { return HasSIMD; }
|
bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
|
||||||
|
bool hasSIMD128() const { return HasSIMD128; }
|
||||||
|
|
||||||
/// Parses features string setting specified subtarget options. Definition of
|
/// Parses features string setting specified subtarget options. Definition of
|
||||||
/// function is auto generated by tblgen.
|
/// function is auto generated by tblgen.
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/TargetRegistry.h"
|
#include "llvm/Support/TargetRegistry.h"
|
||||||
#include "llvm/Target/TargetOptions.h"
|
#include "llvm/Target/TargetOptions.h"
|
||||||
|
#include "llvm/Transforms/Scalar.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
#define DEBUG_TYPE "wasm"
|
#define DEBUG_TYPE "wasm"
|
||||||
@ -139,9 +140,14 @@ void WebAssemblyPassConfig::addOptimizedRegAlloc(FunctionPass *RegAllocPass) {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
void WebAssemblyPassConfig::addIRPasses() {
|
void WebAssemblyPassConfig::addIRPasses() {
|
||||||
// Expand some atomic operations. WebAssemblyTargetLowering has hooks which
|
// FIXME: the default for this option is currently POSIX, whereas
|
||||||
// control specifically what gets lowered.
|
// WebAssembly's MVP should default to Single.
|
||||||
addPass(createAtomicExpandPass(&getTM<WebAssemblyTargetMachine>()));
|
if (TM->Options.ThreadModel == ThreadModel::Single)
|
||||||
|
addPass(createLowerAtomicPass());
|
||||||
|
else
|
||||||
|
// Expand some atomic operations. WebAssemblyTargetLowering has hooks which
|
||||||
|
// control specifically what gets lowered.
|
||||||
|
addPass(createAtomicExpandPass(TM));
|
||||||
|
|
||||||
TargetPassConfig::addIRPasses();
|
TargetPassConfig::addIRPasses();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user