Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | //===-- WebAssemblySubtarget.cpp - WebAssembly Subtarget Information ------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // 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 Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | /// |
| 9 | /// \file |
Adrian Prantl | 5f8f34e4 | 2018-05-01 15:54:18 +0000 | [diff] [blame] | 10 | /// This file implements the WebAssembly-specific subclass of |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 11 | /// TargetSubtarget. |
| 12 | /// |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 15 | #include "WebAssemblySubtarget.h" |
Dan Gohman | ec977b0 | 2016-01-25 15:12:05 +0000 | [diff] [blame] | 16 | #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" |
| 17 | #include "WebAssemblyInstrInfo.h" |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 18 | #include "llvm/Support/TargetRegistry.h" |
| 19 | using namespace llvm; |
| 20 | |
JF Bastien | 03855df | 2015-07-01 23:41:25 +0000 | [diff] [blame] | 21 | #define DEBUG_TYPE "wasm-subtarget" |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 22 | |
| 23 | #define GET_SUBTARGETINFO_CTOR |
| 24 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 25 | #include "WebAssemblyGenSubtargetInfo.inc" |
| 26 | |
| 27 | WebAssemblySubtarget & |
| 28 | WebAssemblySubtarget::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 | |
| 38 | WebAssemblySubtarget::WebAssemblySubtarget(const Triple &TT, |
| 39 | const std::string &CPU, |
| 40 | const std::string &FS, |
| 41 | const TargetMachine &TM) |
Thomas Lively | 64a39a1 | 2019-01-10 22:32:11 +0000 | [diff] [blame] | 42 | : WebAssemblyGenSubtargetInfo(TT, CPU, FS), CPUString(CPU), |
| 43 | TargetTriple(TT), FrameLowering(), |
| 44 | InstrInfo(initializeSubtargetDependencies(FS)), TSInfo(), |
JF Bastien | b379643 | 2015-07-09 21:00:09 +0000 | [diff] [blame] | 45 | TLInfo(TM, *this) {} |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 46 | |
Thomas Lively | 3f34e1b8 | 2019-03-29 00:14:01 +0000 | [diff] [blame] | 47 | bool WebAssemblySubtarget::enableAtomicExpand() const { |
| 48 | // If atomics are disabled, atomic ops are lowered instead of expanded |
| 49 | return hasAtomics(); |
| 50 | } |
| 51 | |
Dan Gohman | e045f67 | 2016-05-18 20:19:02 +0000 | [diff] [blame] | 52 | bool 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 Gohman | 7615e46 | 2015-12-05 19:27:18 +0000 | [diff] [blame] | 59 | bool WebAssemblySubtarget::useAA() const { return true; } |