LLVM 23.0.0git
WebAssemblySubtarget.cpp
Go to the documentation of this file.
1//===-- WebAssemblySubtarget.cpp - WebAssembly Subtarget Information ------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file implements the WebAssembly-specific subclass of
11/// TargetSubtarget.
12///
13//===----------------------------------------------------------------------===//
14
20#include "WebAssembly.h"
24using namespace llvm;
25
26#define DEBUG_TYPE "wasm-subtarget"
27
28#define GET_SUBTARGETINFO_CTOR
29#define GET_SUBTARGETINFO_TARGET_DESC
30#include "WebAssemblyGenSubtargetInfo.inc"
31
33WebAssemblySubtarget::initializeSubtargetDependencies(StringRef CPU,
34 StringRef FS) {
35 // Determine default and user-specified characteristics
36 LLVM_DEBUG(llvm::dbgs() << "initializeSubtargetDependencies\n");
37
38 if (CPU.empty())
39 CPU = "generic";
40
41 ParseSubtargetFeatures(CPU, /*TuneCPU*/ CPU, FS);
42
43 FeatureBitset Bits = getFeatureBits();
44
45 // bulk-memory implies bulk-memory-opt
46 if (HasBulkMemory) {
47 HasBulkMemoryOpt = true;
48 Bits.set(WebAssembly::FeatureBulkMemoryOpt);
49 }
50
51 // gc implies reference-types
52 if (HasGC) {
53 HasReferenceTypes = true;
54 }
55
56 // reference-types implies call-indirect-overlong
57 if (HasReferenceTypes) {
58 HasCallIndirectOverlong = true;
59 Bits.set(WebAssembly::FeatureCallIndirectOverlong);
60 }
61
62 // In case we changed any bits, update `MCSubtargetInfo`'s `FeatureBitset`.
63 setFeatureBits(Bits);
64
65 return *this;
66}
67
69 const std::string &CPU,
70 const std::string &FS,
71 const TargetMachine &TM)
72 : WebAssemblyGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
73 TargetTriple(TT), InstrInfo(initializeSubtargetDependencies(CPU, FS)),
74 TLInfo(TM, *this) {
75 CallLoweringInfo.reset(new WebAssemblyCallLowering(*getTargetLowering()));
76 Legalizer.reset(new WebAssemblyLegalizerInfo(*this));
78 RegBankInfo.reset(RBI);
79
80 InstSelector.reset(createWebAssemblyInstructionSelector(
81 *static_cast<const WebAssemblyTargetMachine *>(&TM), *this, *RBI));
82}
83
85 // If atomics are disabled, atomic ops are lowered instead of expanded
86 return hasAtomics();
87}
88
90 // Disable the MachineScheduler for now. Even with ShouldTrackPressure set and
91 // enableMachineSchedDefaultSched overridden, it appears to have an overall
92 // negative effect for the kinds of register optimizations we're doing.
93 return false;
94}
95
96bool WebAssemblySubtarget::useAA() const { return true; }
97
99 return CallLoweringInfo.get();
100}
101
103 return InstSelector.get();
104}
105
107 return Legalizer.get();
108}
109
111 return RegBankInfo.get();
112}
#define LLVM_DEBUG(...)
Definition Debug.h:114
This file describes how to lower LLVM calls to machine code calls.
This file contains the WebAssembly implementation of the TargetInstrInfo class.
This file declares the targeting of the Machinelegalizer class for WebAssembly.
This file provides WebAssembly-specific target descriptions.
This file declares the targeting of the RegisterBankInfo class for WebAssembly.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This file declares the WebAssembly-specific subclass of TargetMachine.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Container class for subtarget features.
Holds all the information related to register banks.
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Primary interface to the complete machine description for the target machine.
Triple - Helper class for working with autoconf configuration names.
Definition Triple.h:47
This class provides the information for the WebAssembly target legalizer for GlobalISel.
This class provides the information for the target register banks.
bool enableAtomicExpand() const override
const CallLowering * getCallLowering() const override
const WebAssemblyTargetLowering * getTargetLowering() const override
const WebAssemblyRegisterInfo * getRegisterInfo() const override
const RegisterBankInfo * getRegBankInfo() const override
bool enableMachineScheduler() const override
InstructionSelector * getInstructionSelector() const override
WebAssemblySubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM)
This constructor initializes the data members to match that of the specified triple.
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
Parses features string setting specified subtarget options.
const LegalizerInfo * getLegalizerInfo() const override
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:207
InstructionSelector * createWebAssemblyInstructionSelector(const WebAssemblyTargetMachine &TM, const WebAssemblySubtarget &Subtarget, const WebAssemblyRegisterBankInfo &RBI)