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" 13 #include "llvm/CodeGen/GlobalISel/LegalizerHelper.h" 14 #include "llvm/CodeGen/GlobalISel/LegalizerInfo.h" 15 #include "llvm/CodeGen/TargetOpcodes.h" 16 #include "llvm/CodeGen/ValueTypes.h" 17 #include "llvm/IR/DerivedTypes.h" 18 #include "llvm/IR/Type.h" 19 20 using namespace llvm; 21 22 M68kLegalizerInfo::M68kLegalizerInfo(const M68kSubtarget &ST) { 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 51 getLegacyLegalizerInfo().computeTables(); 52 } 53