2015-06-30 01:51:55 +02:00
|
|
|
//=- WebAssemblySubtarget.h - Define Subtarget for the WebAssembly -*- C++ -*-//
|
|
|
|
//
|
2019-01-19 09:50:56 +01:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-06-30 01:51:55 +02:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
2018-05-01 17:54:18 +02:00
|
|
|
/// This file declares the WebAssembly-specific subclass of
|
2015-06-30 01:51:55 +02:00
|
|
|
/// TargetSubtarget.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
|
|
|
|
#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYSUBTARGET_H
|
|
|
|
|
|
|
|
#include "WebAssemblyFrameLowering.h"
|
|
|
|
#include "WebAssemblyISelLowering.h"
|
|
|
|
#include "WebAssemblyInstrInfo.h"
|
|
|
|
#include "WebAssemblySelectionDAGInfo.h"
|
2017-11-17 02:07:10 +01:00
|
|
|
#include "llvm/CodeGen/TargetSubtargetInfo.h"
|
2015-06-30 01:51:55 +02:00
|
|
|
#include <string>
|
|
|
|
|
[WebAssembly] Merge used feature sets, update atomics linkage policy
Summary:
It does not currently make sense to use WebAssembly features in some functions
but not others, so this CL adds an IR pass that takes the union of all used
feature sets and applies it to each function in the module. This allows us to
prevent atomics from being lowered away if some function has opted in to using
them. When atomics is not enabled anywhere, we detect whether there exists any
atomic operations or thread local storage that would be stripped and disallow
linking with objects that contain atomics if and only if atomics or tls are
stripped. When atomics is enabled, mark it as used but do not require it of
other objects in the link. These changes allow libraries that do not use atomics
to be built once and linked into both single-threaded and multithreaded
binaries.
Reviewers: aheejin, sbc100, dschuff
Subscribers: jgravelle-google, hiraditya, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59625
llvm-svn: 357226
2019-03-29 01:14:01 +01:00
|
|
|
#define GET_SUBTARGETINFO_ENUM
|
2015-06-30 01:51:55 +02:00
|
|
|
#define GET_SUBTARGETINFO_HEADER
|
|
|
|
#include "WebAssemblyGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
[WebAssembly] Merge used feature sets, update atomics linkage policy
Summary:
It does not currently make sense to use WebAssembly features in some functions
but not others, so this CL adds an IR pass that takes the union of all used
feature sets and applies it to each function in the module. This allows us to
prevent atomics from being lowered away if some function has opted in to using
them. When atomics is not enabled anywhere, we detect whether there exists any
atomic operations or thread local storage that would be stripped and disallow
linking with objects that contain atomics if and only if atomics or tls are
stripped. When atomics is enabled, mark it as used but do not require it of
other objects in the link. These changes allow libraries that do not use atomics
to be built once and linked into both single-threaded and multithreaded
binaries.
Reviewers: aheejin, sbc100, dschuff
Subscribers: jgravelle-google, hiraditya, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59625
llvm-svn: 357226
2019-03-29 01:14:01 +01:00
|
|
|
// Defined in WebAssemblyGenSubtargetInfo.inc.
|
|
|
|
extern const SubtargetFeatureKV
|
|
|
|
WebAssemblyFeatureKV[WebAssembly::NumSubtargetFeatures];
|
|
|
|
|
2015-06-30 01:51:55 +02:00
|
|
|
class WebAssemblySubtarget final : public WebAssemblyGenSubtargetInfo {
|
2019-01-10 23:32:11 +01:00
|
|
|
enum SIMDEnum {
|
|
|
|
NoSIMD,
|
|
|
|
SIMD128,
|
|
|
|
} SIMDLevel = NoSIMD;
|
|
|
|
|
|
|
|
bool HasAtomics = false;
|
|
|
|
bool HasNontrappingFPToInt = false;
|
|
|
|
bool HasSignExt = false;
|
|
|
|
bool HasExceptionHandling = false;
|
2019-01-31 22:02:19 +01:00
|
|
|
bool HasBulkMemory = false;
|
2019-05-23 19:26:47 +02:00
|
|
|
bool HasMultivalue = false;
|
[WebAssembly] Add mutable globals feature
Summary:
This feature is not actually used for anything in the WebAssembly
backend, but adding it allows users to get it into the target features
sections of their objects, which makes these objects
future-compatible.
Reviewers: aheejin, dschuff
Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, jdoerfert, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D60013
llvm-svn: 357321
2019-03-29 23:00:18 +01:00
|
|
|
bool HasMutableGlobals = false;
|
2019-05-23 19:26:47 +02:00
|
|
|
bool HasTailCall = false;
|
2020-01-24 04:22:51 +01:00
|
|
|
bool HasReferenceTypes = false;
|
2015-06-30 01:51:55 +02:00
|
|
|
|
|
|
|
/// What processor and OS we're targeting.
|
|
|
|
Triple TargetTriple;
|
|
|
|
|
|
|
|
WebAssemblyFrameLowering FrameLowering;
|
|
|
|
WebAssemblyInstrInfo InstrInfo;
|
|
|
|
WebAssemblySelectionDAGInfo TSInfo;
|
|
|
|
WebAssemblyTargetLowering TLInfo;
|
|
|
|
|
2020-04-10 22:07:19 +02:00
|
|
|
WebAssemblySubtarget &initializeSubtargetDependencies(StringRef CPU,
|
|
|
|
StringRef FS);
|
2015-06-30 01:51:55 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
/// This constructor initializes the data members to match that
|
|
|
|
/// of the specified triple.
|
|
|
|
WebAssemblySubtarget(const Triple &TT, const std::string &CPU,
|
|
|
|
const std::string &FS, const TargetMachine &TM);
|
|
|
|
|
|
|
|
const WebAssemblySelectionDAGInfo *getSelectionDAGInfo() const override {
|
|
|
|
return &TSInfo;
|
|
|
|
}
|
|
|
|
const WebAssemblyFrameLowering *getFrameLowering() const override {
|
|
|
|
return &FrameLowering;
|
|
|
|
}
|
|
|
|
const WebAssemblyTargetLowering *getTargetLowering() const override {
|
|
|
|
return &TLInfo;
|
|
|
|
}
|
2015-07-22 23:28:15 +02:00
|
|
|
const WebAssemblyInstrInfo *getInstrInfo() const override {
|
|
|
|
return &InstrInfo;
|
|
|
|
}
|
|
|
|
const WebAssemblyRegisterInfo *getRegisterInfo() const override {
|
|
|
|
return &getInstrInfo()->getRegisterInfo();
|
|
|
|
}
|
2015-06-30 01:51:55 +02:00
|
|
|
const Triple &getTargetTriple() const { return TargetTriple; }
|
[WebAssembly] Merge used feature sets, update atomics linkage policy
Summary:
It does not currently make sense to use WebAssembly features in some functions
but not others, so this CL adds an IR pass that takes the union of all used
feature sets and applies it to each function in the module. This allows us to
prevent atomics from being lowered away if some function has opted in to using
them. When atomics is not enabled anywhere, we detect whether there exists any
atomic operations or thread local storage that would be stripped and disallow
linking with objects that contain atomics if and only if atomics or tls are
stripped. When atomics is enabled, mark it as used but do not require it of
other objects in the link. These changes allow libraries that do not use atomics
to be built once and linked into both single-threaded and multithreaded
binaries.
Reviewers: aheejin, sbc100, dschuff
Subscribers: jgravelle-google, hiraditya, sunfish, jfb, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D59625
llvm-svn: 357226
2019-03-29 01:14:01 +01:00
|
|
|
bool enableAtomicExpand() const override;
|
2019-07-04 01:54:06 +02:00
|
|
|
bool enableIndirectBrExpand() const override { return true; }
|
2015-06-30 01:51:55 +02:00
|
|
|
bool enableMachineScheduler() const override;
|
2015-12-05 20:27:18 +01:00
|
|
|
bool useAA() const override;
|
2015-06-30 01:51:55 +02:00
|
|
|
|
|
|
|
// Predicates used by WebAssemblyInstrInfo.td.
|
2015-07-02 01:41:25 +02:00
|
|
|
bool hasAddr64() const { return TargetTriple.isArch64Bit(); }
|
2019-01-10 23:32:11 +01:00
|
|
|
bool hasSIMD128() const { return SIMDLevel >= SIMD128; }
|
2017-08-30 20:07:45 +02:00
|
|
|
bool hasAtomics() const { return HasAtomics; }
|
2017-11-28 02:13:40 +01:00
|
|
|
bool hasNontrappingFPToInt() const { return HasNontrappingFPToInt; }
|
2018-01-19 18:16:24 +01:00
|
|
|
bool hasSignExt() const { return HasSignExt; }
|
2018-02-24 01:40:50 +01:00
|
|
|
bool hasExceptionHandling() const { return HasExceptionHandling; }
|
2019-01-31 22:02:19 +01:00
|
|
|
bool hasBulkMemory() const { return HasBulkMemory; }
|
2019-05-23 19:26:47 +02:00
|
|
|
bool hasMultivalue() const { return HasMultivalue; }
|
[WebAssembly] Add mutable globals feature
Summary:
This feature is not actually used for anything in the WebAssembly
backend, but adding it allows users to get it into the target features
sections of their objects, which makes these objects
future-compatible.
Reviewers: aheejin, dschuff
Subscribers: sbc100, jgravelle-google, hiraditya, sunfish, jdoerfert, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D60013
llvm-svn: 357321
2019-03-29 23:00:18 +01:00
|
|
|
bool hasMutableGlobals() const { return HasMutableGlobals; }
|
2019-05-23 19:26:47 +02:00
|
|
|
bool hasTailCall() const { return HasTailCall; }
|
2020-01-24 04:22:51 +01:00
|
|
|
bool hasReferenceTypes() const { return HasReferenceTypes; }
|
2015-06-30 01:51:55 +02:00
|
|
|
|
|
|
|
/// Parses features string setting specified subtarget options. Definition of
|
|
|
|
/// function is auto generated by tblgen.
|
2020-08-14 23:56:54 +02:00
|
|
|
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS);
|
2015-06-30 01:51:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace llvm
|
|
|
|
|
|
|
|
#endif
|