| 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 | |
| 13 | #include "WebAssemblyLegalizerInfo.h" |
| 14 | #include "WebAssemblySubtarget.h" |
| 15 | |
| 16 | #define DEBUG_TYPE "wasm-legalinfo" |
| 17 | |
| 18 | using namespace llvm; |
| 19 | using namespace LegalizeActions; |
| 20 | |
| 21 | WebAssemblyLegalizerInfo::WebAssemblyLegalizerInfo( |
| 22 | const WebAssemblySubtarget &ST) { |
| 23 | using namespace TargetOpcode; |
| 24 | |
| 25 | const LLT s32 = LLT::scalar(SizeInBits: 32); |
| 26 | const LLT s64 = LLT::scalar(SizeInBits: 64); |
| 27 | |
| 28 | getActionDefinitionsBuilder(Opcodes: {G_CONSTANT, G_ADD, G_AND}) |
| 29 | .legalFor(Types: {s32, s64}) |
| 30 | .widenScalarToNextPow2(TypeIdx: 0) |
| 31 | .clampScalar(TypeIdx: 0, MinTy: s32, MaxTy: s64); |
| 32 | |
| 33 | getActionDefinitionsBuilder(Opcodes: {G_ASHR, G_SHL}) |
| 34 | .legalFor(Types: {{s32, s32}, {s64, s64}}) |
| 35 | .widenScalarToNextPow2(TypeIdx: 0) |
| 36 | .clampScalar(TypeIdx: 0, MinTy: s32, MaxTy: s64) |
| 37 | .scalarSameSizeAs(TypeIdx: 1, SameSizeIdx: 0); |
| 38 | |
| 39 | getActionDefinitionsBuilder(Opcode: G_SEXT_INREG).lower(); |
| 40 | |
| 41 | getLegacyLegalizerInfo().computeTables(); |
| 42 | } |
| 43 | |