LLVM 23.0.0git
WebAssemblyLegalizerInfo.cpp
Go to the documentation of this file.
1//===- WebAssemblyLegalizerInfo.cpp ------------------------------*- C++ -*-==//
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/// \file
9/// This file implements the targeting of the Machinelegalizer class for
10/// WebAssembly.
11//===----------------------------------------------------------------------===//
12
15
16#define DEBUG_TYPE "wasm-legalinfo"
17
18using namespace llvm;
19using namespace LegalizeActions;
20
22 const WebAssemblySubtarget &ST) {
23 using namespace TargetOpcode;
24
25 const LLT s32 = LLT::scalar(32);
26 const LLT s64 = LLT::scalar(64);
27
28 getActionDefinitionsBuilder({G_CONSTANT, G_ADD, G_AND})
29 .legalFor({s32, s64})
30 .widenScalarToNextPow2(0)
31 .clampScalar(0, s32, s64);
32
33 getActionDefinitionsBuilder({G_ASHR, G_SHL})
34 .legalFor({{s32, s32}, {s64, s64}})
35 .widenScalarToNextPow2(0)
36 .clampScalar(0, s32, s64)
37 .scalarSameSizeAs(1, 0);
38
39 getActionDefinitionsBuilder(G_SEXT_INREG).lower();
40
42}
This file declares the targeting of the Machinelegalizer class for WebAssembly.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
static constexpr LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
LLVM_ABI void computeTables()
Compute any ancillary tables needed to quickly decide how an operation should be handled.
LegalizeRuleSet & scalarSameSizeAs(unsigned TypeIdx, unsigned SameSizeIdx)
Change the type TypeIdx to have the same scalar size as type SameSizeIdx.
LegalizeRuleSet & lower()
The instruction is lowered.
LegalizeRuleSet & clampScalar(unsigned TypeIdx, const LLT MinTy, const LLT MaxTy)
Limit the range of scalar sizes to MinTy and MaxTy.
LegalizeRuleSet & getActionDefinitionsBuilder(unsigned Opcode)
Get the action definition builder for the given opcode.
const LegacyLegalizerInfo & getLegacyLegalizerInfo() const
WebAssemblyLegalizerInfo(const WebAssemblySubtarget &ST)
Invariant opcodes: All instruction sets have these as their low opcodes.
This is an optimization pass for GlobalISel generic memory operations.