blob: 196a74565285eef06841068106a4db19114c3c8f [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//===-- WebAssemblySubtarget.cpp - WebAssembly Subtarget Information ------===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Dan Gohman10e730a2015-06-29 23:51:55 +00006//
7//===----------------------------------------------------------------------===//
8///
9/// \file
Adrian Prantl5f8f34e42018-05-01 15:54:18 +000010/// This file implements the WebAssembly-specific subclass of
Dan Gohman10e730a2015-06-29 23:51:55 +000011/// TargetSubtarget.
12///
13//===----------------------------------------------------------------------===//
14
Dan Gohman10e730a2015-06-29 23:51:55 +000015#include "WebAssemblySubtarget.h"
Dan Gohmanec977b02016-01-25 15:12:05 +000016#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
17#include "WebAssemblyInstrInfo.h"
Dan Gohman10e730a2015-06-29 23:51:55 +000018#include "llvm/Support/TargetRegistry.h"
19using namespace llvm;
20
JF Bastien03855df2015-07-01 23:41:25 +000021#define DEBUG_TYPE "wasm-subtarget"
Dan Gohman10e730a2015-06-29 23:51:55 +000022
23#define GET_SUBTARGETINFO_CTOR
24#define GET_SUBTARGETINFO_TARGET_DESC
25#include "WebAssemblyGenSubtargetInfo.inc"
26
27WebAssemblySubtarget &
28WebAssemblySubtarget::initializeSubtargetDependencies(StringRef FS) {
29 // Determine default and user-specified characteristics
30
31 if (CPUString.empty())
32 CPUString = "generic";
33
34 ParseSubtargetFeatures(CPUString, FS);
35 return *this;
36}
37
38WebAssemblySubtarget::WebAssemblySubtarget(const Triple &TT,
39 const std::string &CPU,
40 const std::string &FS,
41 const TargetMachine &TM)
Thomas Lively64a39a12019-01-10 22:32:11 +000042 : WebAssemblyGenSubtargetInfo(TT, CPU, FS), CPUString(CPU),
43 TargetTriple(TT), FrameLowering(),
44 InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(),
JF Bastienb3796432015-07-09 21:00:09 +000045 TLInfo(TM, *this) {}
Dan Gohman10e730a2015-06-29 23:51:55 +000046
Thomas Lively3f34e1b82019-03-29 00:14:01 +000047bool WebAssemblySubtarget::enableAtomicExpand() const {
48 // If atomics are disabled, atomic ops are lowered instead of expanded
49 return hasAtomics();
50}
51
Dan Gohmane045f672016-05-18 20:19:02 +000052bool WebAssemblySubtarget::enableMachineScheduler() const {
53 // Disable the MachineScheduler for now. Even with ShouldTrackPressure set and
54 // enableMachineSchedDefaultSched overridden, it appears to have an overall
55 // negative effect for the kinds of register optimizations we're doing.
56 return false;
57}
58
Dan Gohman7615e462015-12-05 19:27:18 +000059bool WebAssemblySubtarget::useAA() const { return true; }