LLVM  15.0.0git
M68kLegalizerInfo.cpp
Go to the documentation of this file.
1 //===-- M68kLegalizerInfo.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 M68k.
10 //===----------------------------------------------------------------------===//
11 
12 #include "M68kLegalizerInfo.h"
17 #include "llvm/IR/DerivedTypes.h"
18 #include "llvm/IR/Type.h"
19 
20 using namespace llvm;
21 
23  using namespace TargetOpcode;
24  const LLT s8 = LLT::scalar(8);
25  const LLT s16 = LLT::scalar(16);
26  const LLT s32 = LLT::scalar(32);
27  const LLT p0 = LLT::pointer(0, 32);
28 
29  getActionDefinitionsBuilder({G_ADD, G_SUB, G_MUL, G_UDIV, G_AND})
30  .legalFor({s8, s16, s32})
31  .clampScalar(0, s8, s32)
32  .widenScalarToNextPow2(0, 8);
33 
34  getActionDefinitionsBuilder(G_CONSTANT)
35  .legalFor({s32, p0})
36  .clampScalar(0, s32, s32);
37 
38  getActionDefinitionsBuilder({G_FRAME_INDEX, G_GLOBAL_VALUE}).legalFor({p0});
39 
40  getActionDefinitionsBuilder({G_STORE, G_LOAD})
41  .legalForTypesWithMemDesc({{s32, p0, s32, 4},
42  {s32, p0, s16, 4},
43  {s32, p0, s8, 4},
44  {s16, p0, s16, 2},
45  {s8, p0, s8, 1},
46  {p0, p0, s32, 4}})
47  .clampScalar(0, s8, s32);
48 
49  getActionDefinitionsBuilder(G_PTR_ADD).legalFor({{p0, s32}});
50 
52 }
ValueTypes.h
llvm::LegalizeRuleSet::widenScalarToNextPow2
LegalizeRuleSet & widenScalarToNextPow2(unsigned TypeIdx, unsigned MinSize=0)
Widen the scalar to the next power of two that is at least MinSize.
Definition: LegalizerInfo.h:877
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::LegalizerInfo::getActionDefinitionsBuilder
LegalizeRuleSet & getActionDefinitionsBuilder(unsigned Opcode)
Get the action definition builder for the given opcode.
Definition: LegalizerInfo.cpp:288
llvm::LegacyLegalizerInfo::computeTables
void computeTables()
Compute any ancillary tables needed to quickly decide how an operation should be handled.
Definition: LegacyLegalizerInfo.cpp:102
LegalizerInfo.h
TargetOpcodes.h
Type.h
llvm::M68kSubtarget
Definition: M68kSubtarget.h:45
llvm::LLT::pointer
static LLT pointer(unsigned AddressSpace, unsigned SizeInBits)
Get a low-level pointer in the given address space.
Definition: LowLevelTypeImpl.h:49
llvm::LegalizeRuleSet::legalFor
LegalizeRuleSet & legalFor(std::initializer_list< LLT > Types)
The instruction is legal when type index 0 is any type in the given list.
Definition: LegalizerInfo.h:593
llvm::ARM_MB::ST
@ ST
Definition: ARMBaseInfo.h:73
llvm::M68kLegalizerInfo::M68kLegalizerInfo
M68kLegalizerInfo(const M68kSubtarget &ST)
Definition: M68kLegalizerInfo.cpp:22
llvm::LegalizerInfo::getLegacyLegalizerInfo
const LegacyLegalizerInfo & getLegacyLegalizerInfo() const
Definition: LegalizerInfo.h:1184
LegalizerHelper.h
M68kLegalizerInfo.h
DerivedTypes.h
llvm::LLT::scalar
static LLT scalar(unsigned SizeInBits)
Get a low-level scalar or aggregate "bag of bits".
Definition: LowLevelTypeImpl.h:42
llvm::LLT
Definition: LowLevelTypeImpl.h:39